Ignore:
Timestamp:
May 19, 2022, 10:39:34 PM (2 years ago)
Author:
chronos
Message:
  • Modified: Use first capital letter in identifiers.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/NatStat.pas

    r442 r447  
    2525    procedure ToggleBtnClick(Sender: TObject);
    2626    procedure PlayerClick(Sender: TObject);
    27     procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
     27    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    2828    procedure FormDestroy(Sender: TObject);
    2929    procedure ScrollUpBtnClick(Sender: TObject);
     
    3232  public
    3333    procedure CheckAge;
    34     procedure ShowNewContent(NewMode: TWindowMode; p: integer = -1);
     34    procedure ShowNewContent(NewMode: TWindowMode; P: Integer = -1);
    3535    procedure EcoChange;
    3636  protected
    3737    procedure OffscreenPaint; override;
    3838  private
    39     pView, AgePrepared, LinesDown: integer;
     39    pView, AgePrepared, LinesDown: Integer;
    4040    SelfReport, CurrentReport: PEnemyReport;
    41     ShowContact, ContactEnabled: boolean;
     41    ShowContact, ContactEnabled: Boolean;
    4242    Back, Template: TBitmap;
    4343    ReportText: TStringList;
     
    114114procedure TNatStatDlg.FormShow(Sender: TObject);
    115115begin
    116   if pView = me then
     116  if pView = Me then
    117117  begin
    118118    SelfReport.TurnOfCivilReport := MyRO.Turn;
    119119    SelfReport.TurnOfMilReport := MyRO.Turn;
    120     move(MyRO.Treaty, SelfReport.Treaty, SizeOf(SelfReport.Treaty));
     120    Move(MyRO.Treaty, SelfReport.Treaty, SizeOf(SelfReport.Treaty));
    121121    SelfReport.Government := MyRO.Government;
    122122    SelfReport.Money := MyRO.Money;
    123     CurrentReport := pointer(SelfReport);
     123    CurrentReport := Pointer(SelfReport);
    124124  end
    125125  else
    126     CurrentReport := pointer(MyRO.EnemyReport[pView]);
     126    CurrentReport := Pointer(MyRO.EnemyReport[pView]);
    127127  if CurrentReport.TurnOfCivilReport >= 0 then
    128128    GenerateReportText;
    129   ShowContact := (pView <> me) and (not supervising or (me <> 0));
    130   ContactEnabled := ShowContact and not supervising and
     129  ShowContact := (pView <> Me) and (not Supervising or (Me <> 0));
     130  ContactEnabled := ShowContact and not Supervising and
    131131    (1 shl pView and MyRO.Alive <> 0);
    132132  ContactBtn.Visible := ContactEnabled and (MyRO.Happened and phGameEnd = 0) and
     
    146146end;
    147147
    148 procedure TNatStatDlg.ShowNewContent(NewMode: TWindowMode; p: integer);
    149 begin
    150   if p < 0 then
     148procedure TNatStatDlg.ShowNewContent(NewMode: TWindowMode; P: Integer);
     149begin
     150  if P < 0 then
    151151    if ClientMode >= scContact then
    152       pView := DipMem[me].pContact
     152      pView := DipMem[Me].pContact
    153153    else
    154154    begin
     
    156156      while (pView < nPl) and ((MyRO.Treaty[pView] < trNone) or
    157157        (1 shl pView and MyRO.Alive = 0)) do
    158         inc(pView);
     158        Inc(pView);
    159159      if pView >= nPl then
    160         pView := me;
     160        pView := Me;
    161161    end
    162162  else
    163     pView := p;
     163    pView := P;
    164164  inherited ShowNewContent(NewMode);
    165165end;
     
    174174  List: ^TChart;
    175175
    176   function StatText(no: integer): string;
     176  function StatText(no: Integer): string;
    177177  var
    178     i: integer;
     178    I: Integer;
    179179  begin
    180180    if (CurrentReport.TurnOfCivilReport >= 0) and
    181       (Server(sGetChart + no shl 4, me, pView, List^) >= rExecuted) then
     181      (Server(sGetChart + no shl 4, Me, pView, List^) >= rExecuted) then
    182182    begin
    183       i := List[CurrentReport.TurnOfCivilReport];
     183      I := List[CurrentReport.TurnOfCivilReport];
    184184      case no of
    185185        stPop:
    186           result := Format(Phrases.Lookup('FRSTATPOP'), [i]);
     186          Result := Format(Phrases.Lookup('FRSTATPOP'), [I]);
    187187        stTerritory:
    188           result := Format(Phrases.Lookup('FRSTATTER'), [i]);
     188          Result := Format(Phrases.Lookup('FRSTATTER'), [I]);
    189189        stScience:
    190           result := Format(Phrases.Lookup('FRSTATTECH'), [i div nAdv]);
     190          Result := Format(Phrases.Lookup('FRSTATTECH'), [I div nAdv]);
    191191        stExplore:
    192           result := Format(Phrases.Lookup('FRSTATEXP'),
    193             [i * 100 div (G.lx * G.ly)]);
     192          Result := Format(Phrases.Lookup('FRSTATEXP'),
     193            [I * 100 div (G.lx * G.ly)]);
    194194      end;
    195195    end
     
    197197
    198198var
    199   p1, Treaty: integer;
    200   s: string;
    201   HasContact, ExtinctPart: boolean;
     199  p1, Treaty: Integer;
     200  S: string;
     201  HasContact, ExtinctPart: Boolean;
    202202begin
    203203  GetMem(List, 4 * (MyRO.Turn + 2));
     
    208208    (1 shl pView and MyRO.Alive <> 0) then
    209209  begin
    210     s := Format(Phrases.Lookup('FROLDCIVILREP'),
     210    S := Format(Phrases.Lookup('FROLDCIVILREP'),
    211211      [TurnToString(CurrentReport.TurnOfCivilReport)]);
    212     ReportText.Add('C' + s);
     212    ReportText.Add('C' + S);
    213213    ReportText.Add('');
    214214  end;
     
    223223  ReportText.Add('S' + StatText(stScience));
    224224  ReportText.Add('E' + StatText(stExplore));
    225   HasContact := false;
     225  HasContact := False;
    226226  for p1 := 0 to nPl - 1 do
    227     if (p1 <> me) and (CurrentReport.Treaty[p1] > trNoContact) then
    228       HasContact := true;
     227    if (p1 <> Me) and (CurrentReport.Treaty[p1] > trNoContact) then
     228      HasContact := True;
    229229  if HasContact then
    230230  begin
    231231    ReportText.Add('');
    232232    ReportText.Add(' ' + Phrases.Lookup('FRRELATIONS'));
    233     for ExtinctPart := false to true do
     233    for ExtinctPart := False to True do
    234234      for Treaty := trAlliance downto trNone do
    235235        for p1 := 0 to nPl - 1 do
    236           if (p1 <> me) and (CurrentReport.Treaty[p1] = Treaty) and
     236          if (p1 <> Me) and (CurrentReport.Treaty[p1] = Treaty) and
    237237            ((1 shl p1 and MyRO.Alive = 0) = ExtinctPart) then
    238238          begin
    239             s := Tribe[p1].TString(Phrases.Lookup('HAVETREATY', Treaty));
     239            S := Tribe[p1].TString(Phrases.Lookup('HAVETREATY', Treaty));
    240240            if ExtinctPart then
    241               s := '(' + s + ')';
    242             ReportText.Add(char(48 + Treaty) + s);
     241              S := '(' + S + ')';
     242            ReportText.Add(char(48 + Treaty) + S);
    243243          end;
    244244  end;
     
    250250procedure TNatStatDlg.OffscreenPaint;
    251251var
    252   i, y: integer;
    253   s: string;
    254   ps: pchar;
    255   Extinct: boolean;
     252  I, Y: Integer;
     253  S: string;
     254  ps: PChar;
     255  Extinct: Boolean;
    256256
    257257begin
     
    260260  Extinct := 1 shl pView and MyRO.Alive = 0;
    261261
    262   BitBltCanvas(offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,
     262  BitBltCanvas(Offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,
    263263    Back.Canvas, 0, 0);
    264264
    265   offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
    266   RisedTextout(offscreen.Canvas,
     265  Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
     266  RisedTextout(Offscreen.Canvas,
    267267    40 { (ClientWidth-BiColorTextWidth(offscreen.canvas,caption)) div 2 } ,
    268268    7, Caption);
    269269
    270   offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
    271 
    272   with offscreen do
     270  Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
     271
     272  with Offscreen do
    273273  begin
    274274    // show leader picture
     
    276276    if Assigned(Tribe[pView].faceHGr) then
    277277    begin
    278       Dump(offscreen, Tribe[pView].faceHGr, 18, yIcon - 4, 64, 48,
     278      Dump(Offscreen, Tribe[pView].faceHGr, 18, yIcon - 4, 64, 48,
    279279        1 + Tribe[pView].facepix mod 10 * 65,
    280280        1 + Tribe[pView].facepix div 10 * 49);
    281       frame(offscreen.Canvas, 18 - 1, yIcon - 4 - 1, 18 + 64, yIcon - 4 + 48,
     281      frame(Offscreen.Canvas, 18 - 1, yIcon - 4 - 1, 18 + 64, yIcon - 4 + 48,
    282282        $000000, $000000);
    283283    end;
    284284
    285     if (pView = me) or not Extinct then
     285    if (pView = Me) or not Extinct then
    286286      LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib,
    287287        Phrases.Lookup('GOVERNMENT', CurrentReport.Government) +
    288288        Phrases.Lookup('FRAND'));
    289     if pView = me then
     289    if pView = Me then
    290290    begin
    291291      LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib + 19,
     
    314314      if MyRO.Treaty[pView] = trNoContact then
    315315      begin
    316         s := Phrases.Lookup('FRNOCONTACT');
     316        S := Phrases.Lookup('FRNOCONTACT');
    317317        LoweredTextOut(Canvas, -1, MainTexture,
    318           (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, yRelation + 9, s);
     318          (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, yRelation + 9, S);
    319319      end
    320320      else if ShowContact then
     
    340340        FrameImage(Canvas, BigImp, xIcon, yIcon, xSizeBig, ySizeBig, 0, 200)
    341341        { else if CurrentReport.Government=gAnarchy then
    342           FrameImage(canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,112,400,
     342          FrameImage(Canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,112,400,
    343343          ContactEnabled and (MyRO.Happened and phGameEnd=0) and (ClientMode<scContact))
    344344          else
    345           FrameImage(canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,
     345          FrameImage(Canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,
    346346          56*(CurrentReport.Government-1),40,
    347347          ContactEnabled and (MyRO.Happened and phGameEnd=0) and (ClientMode<scContact)) };
     
    361361      end;
    362362
    363       y := 0;
    364       for i := 0 to ReportText.Count - 1 do
    365       begin
    366         if (i >= LinesDown) and (i < LinesDown + ReportLines) then
     363      Y := 0;
     364      for I := 0 to ReportText.Count - 1 do
     365      begin
     366        if (I >= LinesDown) and (I < LinesDown + ReportLines) then
    367367        begin
    368           s := ReportText[i];
    369           if s <> '' then
     368          S := ReportText[I];
     369          if S <> '' then
    370370          begin
    371371            // LineType:=s[1];
    372             delete(s, 1, 1);
     372            Delete(S, 1, 1);
    373373            BiColorTextOut(Canvas, Colors.Canvas.Pixels[clkMisc, cliPaperText],
    374               $7F007F, xReport + 8, yReport + LineSpacing * y, s);
     374              $7F007F, xReport + 8, yReport + LineSpacing * Y, S);
    375375          end;
    376           inc(y);
     376          Inc(Y);
    377377        end;
    378378      end;
     
    380380    else
    381381    begin
    382       s := Phrases.Lookup('FRNOCIVILREP');
    383       RisedTextout(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s)) div 2,
    384         yReport + hReport div 2 - 10, s);
     382      S := Phrases.Lookup('FRNOCIVILREP');
     383      RisedTextout(Canvas, (ClientWidth - BiColorTextWidth(Canvas, S)) div 2,
     384        yReport + hReport div 2 - 10, S);
    385385    end;
    386386
    387387    if soTellAI in OptionChecked then begin
    388       Server(sGetAIInfo, me, pView, ps);
     388      Server(sGetAIInfo, Me, pView, ps);
    389389      LoweredTextOut(Canvas, -1, MainTexture, 42, 445, ps);
    390390    end else
     
    392392        Phrases2.Lookup('MENU_TELLAI'));
    393393  end;
    394   ContactBtn.SetBack(offscreen.Canvas, ContactBtn.Left, ContactBtn.Top);
     394  ContactBtn.SetBack(Offscreen.Canvas, ContactBtn.Left, ContactBtn.Top);
    395395
    396396  MarkUsedOffscreen(ClientWidth, ClientHeight);
     
    404404procedure TNatStatDlg.DialogBtnClick(Sender: TObject);
    405405var
    406   ContactResult: integer;
     406  ContactResult: Integer;
    407407begin
    408408  ContactResult := MainScreen.DipCall(scContact + pView shl 4);
     
    412412      SoundMessage(Phrases.Lookup('FRCOLDWAR'), 'MSG_DEFAULT')
    413413    else if MyRO.Government = gAnarchy then
    414       SoundMessage(Tribe[me].TPhrase('FRMYANARCHY'), 'MSG_DEFAULT')
     414      SoundMessage(Tribe[Me].TPhrase('FRMYANARCHY'), 'MSG_DEFAULT')
    415415    else if ContactResult = eAnarchy then
    416416      if MyRO.Treaty[pView] >= trPeace then
     
    428428procedure TNatStatDlg.ToggleBtnClick(Sender: TObject);
    429429var
    430   p1, StartCount: integer;
    431   m: TMenuItem;
    432   ExtinctPart: boolean;
     430  p1, StartCount: Integer;
     431  M: TMenuItem;
     432  ExtinctPart: Boolean;
    433433begin
    434434  EmptyMenu(Popup.Items);
    435435
    436436  // own nation
    437   if G.Difficulty[me] <> 0 then
    438   begin
    439     m := TMenuItem.Create(Popup);
    440     m.RadioItem := true;
    441     m.Caption := Tribe[me].TPhrase('TITLE_NATION');
    442     m.Tag := me;
    443     m.OnClick := PlayerClick;
    444     if me = pView then
    445       m.Checked := true;
    446     Popup.Items.Add(m);
     437  if G.Difficulty[Me] <> 0 then
     438  begin
     439    M := TMenuItem.Create(Popup);
     440    M.RadioItem := True;
     441    M.Caption := Tribe[Me].TPhrase('TITLE_NATION');
     442    M.Tag := Me;
     443    M.OnClick := PlayerClick;
     444    if Me = pView then
     445      M.Checked := True;
     446    Popup.Items.Add(M);
    447447  end;
    448448
    449449  // foreign nations
    450   for ExtinctPart := false to true do
     450  for ExtinctPart := False to True do
    451451  begin
    452452    StartCount := Popup.Items.Count;
     
    456456        (1 shl p1 and MyRO.Alive <> 0) and (MyRO.Treaty[p1] >= trNone) then
    457457      begin
    458         m := TMenuItem.Create(Popup);
    459         m.RadioItem := true;
    460         m.Caption := Tribe[p1].TPhrase('TITLE_NATION');
     458        M := TMenuItem.Create(Popup);
     459        M.RadioItem := True;
     460        M.Caption := Tribe[p1].TPhrase('TITLE_NATION');
    461461        if ExtinctPart then
    462           m.Caption := '(' + m.Caption + ')';
    463         m.Tag := p1;
    464         m.OnClick := PlayerClick;
     462          M.Caption := '(' + M.Caption + ')';
     463        M.Tag := p1;
     464        M.OnClick := PlayerClick;
    465465        if p1 = pView then
    466           m.Checked := true;
    467         Popup.Items.Add(m);
     466          M.Checked := True;
     467        Popup.Items.Add(M);
    468468      end;
    469469    if (StartCount > 0) and (Popup.Items.Count > StartCount) then
    470470    begin // seperator
    471       m := TMenuItem.Create(Popup);
    472       m.Caption := '-';
    473       Popup.Items.Insert(StartCount, m);
     471      M := TMenuItem.Create(Popup);
     472      M.Caption := '-';
     473      Popup.Items.Insert(StartCount, M);
    474474    end;
    475475  end;
     
    478478end;
    479479
    480 procedure TNatStatDlg.FormKeyDown(Sender: TObject; var Key: word;
     480procedure TNatStatDlg.FormKeyDown(Sender: TObject; var Key: Word;
    481481  Shift: TShiftState);
    482482var
    483   i: integer;
     483  I: Integer;
    484484begin
    485485  if Key = VK_F9 then // my key
    486486  begin // toggle nation
    487     i := 0;
     487    I := 0;
    488488    repeat
    489489      pView := (pView + 1) mod nPl;
    490       inc(i);
    491     until (i >= nPl) or (1 shl pView and MyRO.Alive <> 0) and
     490      Inc(I);
     491    until (I >= nPl) or (1 shl pView and MyRO.Alive <> 0) and
    492492      (MyRO.Treaty[pView] >= trNone);
    493     if i >= nPl then
    494       pView := me;
     493    if I >= nPl then
     494      pView := Me;
    495495    Tag := pView;
    496496    PlayerClick(self); // no, this is not nice
     
    502502procedure TNatStatDlg.EcoChange;
    503503begin
    504   if Visible and (pView = me) then
     504  if Visible and (pView = Me) then
    505505  begin
    506506    SelfReport.Government := MyRO.Government;
     
    514514  if LinesDown > 0 then
    515515  begin
    516     dec(LinesDown);
     516    Dec(LinesDown);
    517517    SmartUpdateContent;
    518518  end;
     
    523523  if LinesDown + ReportLines < ReportText.Count then
    524524  begin
    525     inc(LinesDown);
     525    Inc(LinesDown);
    526526    SmartUpdateContent;
    527527  end;
Note: See TracChangeset for help on using the changeset viewer.