Ignore:
Timestamp:
Jan 7, 2017, 11:32:14 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Formated all project source files using Delphi formatter as original indentation and other formatting was really bad.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/NatStat.pas

    r2 r6  
    11{$INCLUDE switches}
    2 
    32unit NatStat;
    43
     
    65
    76uses
    8   Protocol,ClientTools,Term,ScreenTools,BaseWin,
     7  Protocol, ClientTools, Term, ScreenTools, BaseWin,
    98
    109  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
     
    1211
    1312type
    14   PEnemyReport=^TEnemyReport;
     13  PEnemyReport = ^TEnemyReport;
    1514
    1615  TNatStatDlg = class(TBufferedDrawDlg)
     
    2827    procedure ToggleBtnClick(Sender: TObject);
    2928    procedure PlayerClick(Sender: TObject);
    30     procedure FormKeyDown(Sender: TObject; var Key: word;
    31       Shift: TShiftState);
     29    procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
    3230    procedure FormDestroy(Sender: TObject);
    3331    procedure ScrollUpBtnClick(Sender: TObject);
     
    4543  private
    4644    pView, AgePrepared, LinesDown: integer;
    47     SelfReport,CurrentReport: PEnemyReport;
    48     ShowContact,ContactEnabled: boolean;
     45    SelfReport, CurrentReport: PEnemyReport;
     46    ShowContact, ContactEnabled: boolean;
    4947    Back, Template: TBitmap;
    5048    ReportText: TStringList;
     
    5553  NatStatDlg: TNatStatDlg;
    5654
    57 
    5855implementation
    5956
     
    6158
    6259uses
    63   Diagram,Select,Messg,MessgEx, Help,Tribes,Directories;
     60  Diagram, Select, Messg, MessgEx, Help, Tribes, Directories;
    6461
    6562const
    66 xIcon=326; yIcon=49;
    67 xAttrib=96; yAttrib=40;
    68 xRelation=16; yRelation=110;
    69 PaperShade=3;
    70 ReportLines=12;
    71 LineSpacing=22;
    72 xReport=24; yReport=165; wReport=352; hReport=ReportLines*LineSpacing;
    73 
     63  xIcon = 326;
     64  yIcon = 49;
     65  xAttrib = 96;
     66  yAttrib = 40;
     67  xRelation = 16;
     68  yRelation = 110;
     69  PaperShade = 3;
     70  ReportLines = 12;
     71  LineSpacing = 22;
     72  xReport = 24;
     73  yReport = 165;
     74  wReport = 352;
     75  hReport = ReportLines * LineSpacing;
    7476
    7577procedure TNatStatDlg.FormCreate(Sender: TObject);
    7678begin
    77 inherited;
    78 AgePrepared:=-2;
    79 GetMem(SelfReport,SizeOf(TEnemyReport)-2*(INFIN+1));
    80 ReportText:=TStringList.Create;
    81 InitButtons();
    82 ContactBtn.Template:=Templates;
    83 HelpContext:='DIPLOMACY';
    84 ToggleBtn.Hint:=Phrases.Lookup('BTN_SELECT');
    85 ContactBtn.Hint:=Phrases.Lookup('BTN_DIALOG');
    86 
    87 Back:=TBitmap.Create;
    88 Back.PixelFormat:=pf24bit;
    89 Back.Width:=ClientWidth; Back.Height:=ClientHeight;
    90 Template:=TBitmap.Create;
    91 LoadGraphicFile(Template, HomeDir+'Graphics\Nation', gfNoGamma);
    92 Template.PixelFormat:=pf8bit;
     79  inherited;
     80  AgePrepared := -2;
     81  GetMem(SelfReport, SizeOf(TEnemyReport) - 2 * (INFIN + 1));
     82  ReportText := TStringList.Create;
     83  InitButtons();
     84  ContactBtn.Template := Templates;
     85  HelpContext := 'DIPLOMACY';
     86  ToggleBtn.Hint := Phrases.Lookup('BTN_SELECT');
     87  ContactBtn.Hint := Phrases.Lookup('BTN_DIALOG');
     88
     89  Back := TBitmap.Create;
     90  Back.PixelFormat := pf24bit;
     91  Back.Width := ClientWidth;
     92  Back.Height := ClientHeight;
     93  Template := TBitmap.Create;
     94  LoadGraphicFile(Template, HomeDir + 'Graphics\Nation', gfNoGamma);
     95  Template.PixelFormat := pf8bit;
    9396end;
    9497
    9598procedure TNatStatDlg.FormDestroy(Sender: TObject);
    9699begin
    97 ReportText.Free;
    98 FreeMem(SelfReport);
    99 Template.Free;
    100 Back.Free;
     100  ReportText.Free;
     101  FreeMem(SelfReport);
     102  Template.Free;
     103  Back.Free;
    101104end;
    102105
    103106procedure TNatStatDlg.CheckAge;
    104107begin
    105 if MainTextureAge<>AgePrepared then
    106   begin
    107   AgePrepared:=MainTextureAge;
    108   bitblt(Back.Canvas.Handle,0,0,ClientWidth,ClientHeight,
    109     MainTexture.Image.Canvas.Handle,(wMainTexture-ClientWidth) div 2,
    110     (hMainTexture-ClientHeight) div 2,SRCCOPY);
    111   ImageOp_B(Back,Template,0,0,0,0,ClientWidth,ClientHeight);
     108  if MainTextureAge <> AgePrepared then
     109  begin
     110    AgePrepared := MainTextureAge;
     111    bitblt(Back.Canvas.Handle, 0, 0, ClientWidth, ClientHeight,
     112      MainTexture.Image.Canvas.Handle, (wMainTexture - ClientWidth) div 2,
     113      (hMainTexture - ClientHeight) div 2, SRCCOPY);
     114    ImageOp_B(Back, Template, 0, 0, 0, 0, ClientWidth, ClientHeight);
    112115  end
    113116end;
     
    115118procedure TNatStatDlg.FormShow(Sender: TObject);
    116119begin
    117 if pView=me then
    118   begin
    119   SelfReport.TurnOfCivilReport:=MyRO.Turn;
    120   SelfReport.TurnOfMilReport:=MyRO.Turn;
    121   move(MyRO.Treaty, SelfReport.Treaty, sizeof(SelfReport.Treaty));
    122   SelfReport.Government:=MyRO.Government;
    123   SelfReport.Money:=MyRO.Money;
    124   CurrentReport:=pointer(SelfReport);
    125   end
    126 else CurrentReport:=pointer(MyRO.EnemyReport[pView]);
    127 if CurrentReport.TurnOfCivilReport>=0 then
    128   GenerateReportText;
    129 ShowContact:= (pView<>me) and (not supervising or (me<>0));
    130 ContactEnabled:= ShowContact and not supervising
    131   and (1 shl pView and MyRO.Alive<>0);
    132 ContactBtn.Visible:=ContactEnabled and (MyRO.Happened and phGameEnd=0)
    133   and (ClientMode<scContact);
    134 ScrollUpBtn.Visible:=(CurrentReport.TurnOfCivilReport>=0)
    135   and (ReportText.Count>ReportLines);
    136 ScrollDownBtn.Visible:=(CurrentReport.TurnOfCivilReport>=0)
    137   and (ReportText.Count>ReportLines);
    138 if OptionChecked and (1 shl soTellAI)<>0 then
    139   TellAIBtn.ButtonIndex:=3
    140 else TellAIBtn.ButtonIndex:=2;
    141 Caption:=Tribe[pView].TPhrase('TITLE_NATION');
    142 LinesDown:=0;
    143 
    144 OffscreenPaint;
    145 end;
    146 
    147 procedure TNatStatDlg.ShowNewContent(NewMode,p: integer);
    148 begin
    149 if p<0 then
    150   if ClientMode>=scContact then
    151     pView:=DipMem[me].pContact
     120  if pView = me then
     121  begin
     122    SelfReport.TurnOfCivilReport := MyRO.Turn;
     123    SelfReport.TurnOfMilReport := MyRO.Turn;
     124    move(MyRO.Treaty, SelfReport.Treaty, SizeOf(SelfReport.Treaty));
     125    SelfReport.Government := MyRO.Government;
     126    SelfReport.Money := MyRO.Money;
     127    CurrentReport := pointer(SelfReport);
     128  end
    152129  else
    153     begin
    154     pView:=0;
    155     while (pView<nPl) and ((MyRO.Treaty[pView]<trNone)
    156       or (1 shl pView and MyRO.Alive=0)) do
    157       inc(pView);
    158     if pView>=nPl then pView:=me;
     130    CurrentReport := pointer(MyRO.EnemyReport[pView]);
     131  if CurrentReport.TurnOfCivilReport >= 0 then
     132    GenerateReportText;
     133  ShowContact := (pView <> me) and (not supervising or (me <> 0));
     134  ContactEnabled := ShowContact and not supervising and
     135    (1 shl pView and MyRO.Alive <> 0);
     136  ContactBtn.Visible := ContactEnabled and (MyRO.Happened and phGameEnd = 0) and
     137    (ClientMode < scContact);
     138  ScrollUpBtn.Visible := (CurrentReport.TurnOfCivilReport >= 0) and
     139    (ReportText.Count > ReportLines);
     140  ScrollDownBtn.Visible := (CurrentReport.TurnOfCivilReport >= 0) and
     141    (ReportText.Count > ReportLines);
     142  if OptionChecked and (1 shl soTellAI) <> 0 then
     143    TellAIBtn.ButtonIndex := 3
     144  else
     145    TellAIBtn.ButtonIndex := 2;
     146  Caption := Tribe[pView].TPhrase('TITLE_NATION');
     147  LinesDown := 0;
     148
     149  OffscreenPaint;
     150end;
     151
     152procedure TNatStatDlg.ShowNewContent(NewMode, p: integer);
     153begin
     154  if p < 0 then
     155    if ClientMode >= scContact then
     156      pView := DipMem[me].pContact
     157    else
     158    begin
     159      pView := 0;
     160      while (pView < nPl) and ((MyRO.Treaty[pView] < trNone) or
     161        (1 shl pView and MyRO.Alive = 0)) do
     162        inc(pView);
     163      if pView >= nPl then
     164        pView := me;
    159165    end
    160 else pView:=p;
    161 inherited ShowNewContent(NewMode);
     166  else
     167    pView := p;
     168  inherited ShowNewContent(NewMode);
    162169end;
    163170
    164171procedure TNatStatDlg.PlayerClick(Sender: TObject);
    165172begin
    166 ShowNewContent(FWindowMode, TComponent(Sender).Tag);
     173  ShowNewContent(FWindowMode, TComponent(Sender).Tag);
    167174end;
    168175
    169176procedure TNatStatDlg.GenerateReportText;
    170177var
    171 List: ^TChart;
     178  List: ^TChart;
    172179
    173180  function StatText(no: integer): string;
    174181  var
    175   i: integer;
    176   begin
    177   if (CurrentReport.TurnOfCivilReport>=0) and (Server(sGetChart+no shl 4,me,pView,List^)>=rExecuted) then
    178     begin
    179     i:=List[CurrentReport.TurnOfCivilReport];
    180     case no of
    181       stPop: result:=Format(Phrases.Lookup('FRSTATPOP'),[i]);
    182       stTerritory: result:=Format(Phrases.Lookup('FRSTATTER'),[i]);
    183       stScience: result:=Format(Phrases.Lookup('FRSTATTECH'),[i div nAdv]);
    184       stExplore: result:=Format(Phrases.Lookup('FRSTATEXP'),[i*100 div (G.lx*G.ly)]);
     182    i: integer;
     183  begin
     184    if (CurrentReport.TurnOfCivilReport >= 0) and
     185      (Server(sGetChart + no shl 4, me, pView, List^) >= rExecuted) then
     186    begin
     187      i := List[CurrentReport.TurnOfCivilReport];
     188      case no of
     189        stPop:
     190          result := Format(Phrases.Lookup('FRSTATPOP'), [i]);
     191        stTerritory:
     192          result := Format(Phrases.Lookup('FRSTATTER'), [i]);
     193        stScience:
     194          result := Format(Phrases.Lookup('FRSTATTECH'), [i div nAdv]);
     195        stExplore:
     196          result := Format(Phrases.Lookup('FRSTATEXP'),
     197            [i * 100 div (G.lx * G.ly)]);
    185198      end;
    186199    end
     
    188201
    189202var
    190 p1,Treaty: integer;
    191 s: string;
    192 HasContact,ExtinctPart: boolean;
    193 begin
    194 GetMem(List,4*(MyRO.Turn+2));
    195 
    196 ReportText.Clear;
    197 ReportText.Add('');
    198 if (MyRO.Turn-CurrentReport.TurnOfCivilReport>1)
    199   and (1 shl pView and MyRO.Alive<>0) then
    200   begin
    201   s:=Format(Phrases.Lookup('FROLDCIVILREP'),
    202     [TurnToString(CurrentReport.TurnOfCivilReport)]);
    203   ReportText.Add('C'+s);
     203  p1, Treaty: integer;
     204  s: string;
     205  HasContact, ExtinctPart: boolean;
     206begin
     207  GetMem(List, 4 * (MyRO.Turn + 2));
     208
     209  ReportText.Clear;
    204210  ReportText.Add('');
    205   end;
    206 
    207 if (1 shl pView and MyRO.Alive<>0) then
    208   begin
    209   ReportText.Add('M'+Format(Phrases.Lookup('FRTREASURY'),[CurrentReport.Money]));
    210   ReportText.Add('P'+StatText(stPop));
    211   ReportText.Add('T'+StatText(stTerritory));
    212   end;
    213 ReportText.Add('S'+StatText(stScience));
    214 ReportText.Add('E'+StatText(stExplore));
    215 HasContact:=false;
    216 for p1:=0 to nPl-1 do
    217   if (p1<>me) and (CurrentReport.Treaty[p1]>trNoContact) then
    218     HasContact:=true;
    219 if HasContact then
    220   begin
     211  if (MyRO.Turn - CurrentReport.TurnOfCivilReport > 1) and
     212    (1 shl pView and MyRO.Alive <> 0) then
     213  begin
     214    s := Format(Phrases.Lookup('FROLDCIVILREP'),
     215      [TurnToString(CurrentReport.TurnOfCivilReport)]);
     216    ReportText.Add('C' + s);
     217    ReportText.Add('');
     218  end;
     219
     220  if (1 shl pView and MyRO.Alive <> 0) then
     221  begin
     222    ReportText.Add('M' + Format(Phrases.Lookup('FRTREASURY'),
     223      [CurrentReport.Money]));
     224    ReportText.Add('P' + StatText(stPop));
     225    ReportText.Add('T' + StatText(stTerritory));
     226  end;
     227  ReportText.Add('S' + StatText(stScience));
     228  ReportText.Add('E' + StatText(stExplore));
     229  HasContact := false;
     230  for p1 := 0 to nPl - 1 do
     231    if (p1 <> me) and (CurrentReport.Treaty[p1] > trNoContact) then
     232      HasContact := true;
     233  if HasContact then
     234  begin
     235    ReportText.Add('');
     236    ReportText.Add(' ' + Phrases.Lookup('FRRELATIONS'));
     237    for ExtinctPart := false to true do
     238      for Treaty := trAlliance downto trNone do
     239        for p1 := 0 to nPl - 1 do
     240          if (p1 <> me) and (CurrentReport.Treaty[p1] = Treaty) and
     241            ((1 shl p1 and MyRO.Alive = 0) = ExtinctPart) then
     242          begin
     243            s := Tribe[p1].TString(Phrases.Lookup('HAVETREATY', Treaty));
     244            if ExtinctPart then
     245              s := '(' + s + ')';
     246            ReportText.Add(char(48 + Treaty) + s);
     247          end;
     248  end;
    221249  ReportText.Add('');
    222   ReportText.Add(' '+Phrases.Lookup('FRRELATIONS'));
    223   for ExtinctPart:=false to true do
    224     for Treaty:=trAlliance downto trNone do
    225       for p1:=0 to nPl-1 do
    226         if (p1<>me) and (CurrentReport.Treaty[p1]=Treaty)
    227           and ((1 shl p1 and MyRO.Alive=0)=ExtinctPart) then
    228           begin
    229           s:=Tribe[p1].TString(Phrases.Lookup('HAVETREATY', Treaty));
    230           if ExtinctPart then s:='('+s+')';
    231           ReportText.Add(char(48+Treaty)+s);
    232           end;
    233   end;
    234 ReportText.Add('');
    235 
    236 FreeMem(List);
     250
     251  FreeMem(List);
    237252end;
    238253
    239254procedure TNatStatDlg.OffscreenPaint;
    240255var
    241 i, y: integer;
    242 s: string;
    243 ps: pchar;
    244 Extinct: boolean;
    245 
    246 begin
    247 inherited;
    248 
    249 Extinct:= 1 shl pView and MyRO.Alive=0;
    250 
    251 bitblt(offscreen.canvas.handle,0,0,ClientWidth,ClientHeight,Back.Canvas.handle,0,0,SRCCOPY);
    252 
    253 offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
    254 RisedTextout(offscreen.Canvas,40{(ClientWidth-BiColorTextWidth(offscreen.canvas,caption)) div 2},7,Caption);
    255 
    256 offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
    257 
    258 with offscreen do
    259   begin
    260   // show leader picture
    261   Tribe[pView].InitAge(GetAge(pView));
    262   if Tribe[pView].faceHGr>=0 then
    263     begin
    264     Dump(offscreen,Tribe[pView].faceHGr,18,yIcon-4,64,48,
    265       1+Tribe[pView].facepix mod 10 *65,1+Tribe[pView].facepix div 10 *49);
    266     frame(offscreen.Canvas,18-1,yIcon-4-1,18+64,yIcon-4+48,$000000,$000000);
     256  i, y: integer;
     257  s: string;
     258  ps: pchar;
     259  Extinct: boolean;
     260
     261begin
     262  inherited;
     263
     264  Extinct := 1 shl pView and MyRO.Alive = 0;
     265
     266  bitblt(offscreen.Canvas.Handle, 0, 0, ClientWidth, ClientHeight,
     267    Back.Canvas.Handle, 0, 0, SRCCOPY);
     268
     269  offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
     270  RisedTextout(offscreen.Canvas,
     271    40 { (ClientWidth-BiColorTextWidth(offscreen.canvas,caption)) div 2 } ,
     272    7, Caption);
     273
     274  offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
     275
     276  with offscreen do
     277  begin
     278    // show leader picture
     279    Tribe[pView].InitAge(GetAge(pView));
     280    if Tribe[pView].faceHGr >= 0 then
     281    begin
     282      Dump(offscreen, Tribe[pView].faceHGr, 18, yIcon - 4, 64, 48,
     283        1 + Tribe[pView].facepix mod 10 * 65,
     284        1 + Tribe[pView].facepix div 10 * 49);
     285      frame(offscreen.Canvas, 18 - 1, yIcon - 4 - 1, 18 + 64, yIcon - 4 + 48,
     286        $000000, $000000);
    267287    end;
    268288
    269   if (pView=me) or not Extinct then
    270     LoweredTextOut(Canvas,-1,MainTexture,xAttrib,yAttrib,
    271       Phrases.Lookup('GOVERNMENT',CurrentReport.Government)+Phrases.Lookup('FRAND'));
    272   if pView=me then
    273     begin
    274     LoweredTextOut(Canvas,-1,MainTexture,xAttrib,yAttrib+19,
    275       Phrases.Lookup('CREDIBILITY',RoughCredibility(MyRO.Credibility)));
    276     LoweredTextOut(Canvas,-1,MainTexture,xAttrib,yAttrib+38,
    277       Format(Phrases.Lookup('FRCREDIBILITY'),[MyRO.Credibility]));
     289    if (pView = me) or not Extinct then
     290      LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib,
     291        Phrases.Lookup('GOVERNMENT', CurrentReport.Government) +
     292        Phrases.Lookup('FRAND'));
     293    if pView = me then
     294    begin
     295      LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib + 19,
     296        Phrases.Lookup('CREDIBILITY', RoughCredibility(MyRO.Credibility)));
     297      LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib + 38,
     298        Format(Phrases.Lookup('FRCREDIBILITY'), [MyRO.Credibility]));
    278299    end
    279   else
    280     begin
    281     if Extinct then
    282       begin
    283       LoweredTextOut(Canvas,-1,MainTexture,xAttrib,yAttrib+9,
    284         Phrases.Lookup('FREXTINCT'));
    285       LoweredTextOut(Canvas,-1,MainTexture,xAttrib,yAttrib+28,
    286         TurnToString(CurrentReport.TurnOfCivilReport))
     300    else
     301    begin
     302      if Extinct then
     303      begin
     304        LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib + 9,
     305          Phrases.Lookup('FREXTINCT'));
     306        LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib + 28,
     307          TurnToString(CurrentReport.TurnOfCivilReport))
    287308      end
    288     else
    289       begin
    290       LoweredTextOut(Canvas,-1,MainTexture,xAttrib,yAttrib+19,
    291         Phrases.Lookup('CREDIBILITY',RoughCredibility(CurrentReport.Credibility)));
    292       LoweredTextOut(Canvas,-1,MainTexture,xAttrib,yAttrib+38,
    293         Format(Phrases.Lookup('FRCREDIBILITY'),[CurrentReport.Credibility]));
     309      else
     310      begin
     311        LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib + 19,
     312          Phrases.Lookup('CREDIBILITY',
     313          RoughCredibility(CurrentReport.Credibility)));
     314        LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib + 38,
     315          Format(Phrases.Lookup('FRCREDIBILITY'), [CurrentReport.Credibility]));
    294316      end;
    295317
    296     if MyRO.Treaty[pView]=trNoContact then
    297       begin
    298       s:=Phrases.Lookup('FRNOCONTACT');
    299       LoweredTextOut(Canvas,-1,MainTexture,
    300         (ClientWidth-BiColorTextWidth(canvas,s)) div 2,yRelation+9,s)
     318      if MyRO.Treaty[pView] = trNoContact then
     319      begin
     320        s := Phrases.Lookup('FRNOCONTACT');
     321        LoweredTextOut(Canvas, -1, MainTexture,
     322          (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, yRelation + 9, s)
    301323      end
    302     else if ShowContact then
    303       begin
    304       LoweredTextOut(Canvas,-1,MainTexture,xRelation,yRelation,
    305         Phrases.Lookup('FRTREATY'));
    306       LoweredTextOut(Canvas,-1,MainTexture,ClientWidth div 2,yRelation,
    307         Phrases.Lookup('TREATY',MyRO.Treaty[pView]));
    308       if CurrentReport.TurnOfContact<0 then
    309         LoweredTextOut(Canvas,-1,MainTexture,ClientWidth div 2,yRelation+19,
    310           Phrases.Lookup('FRNOVISIT'))
    311       else
     324      else if ShowContact then
     325      begin
     326        LoweredTextOut(Canvas, -1, MainTexture, xRelation, yRelation,
     327          Phrases.Lookup('FRTREATY'));
     328        LoweredTextOut(Canvas, -1, MainTexture, ClientWidth div 2, yRelation,
     329          Phrases.Lookup('TREATY', MyRO.Treaty[pView]));
     330        if CurrentReport.TurnOfContact < 0 then
     331          LoweredTextOut(Canvas, -1, MainTexture, ClientWidth div 2,
     332            yRelation + 19, Phrases.Lookup('FRNOVISIT'))
     333        else
    312334        begin
    313         LoweredTextOut(Canvas,-1,MainTexture,xRelation,yRelation+19,
    314           Phrases.Lookup('FRLASTCONTACT'));
    315         if CurrentReport.TurnOfContact>=0 then
    316           LoweredTextOut(Canvas,-1,MainTexture,ClientWidth div 2,yRelation+19,
    317             TurnToString(CurrentReport.TurnOfContact));
     335          LoweredTextOut(Canvas, -1, MainTexture, xRelation, yRelation + 19,
     336            Phrases.Lookup('FRLASTCONTACT'));
     337          if CurrentReport.TurnOfContact >= 0 then
     338            LoweredTextOut(Canvas, -1, MainTexture, ClientWidth div 2,
     339              yRelation + 19, TurnToString(CurrentReport.TurnOfContact));
    318340        end;
    319341      end;
    320342
    321     if Extinct then
    322       FrameImage(canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,0,200)
    323     {else if CurrentReport.Government=gAnarchy then
    324       FrameImage(canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,112,400,
    325         ContactEnabled and (MyRO.Happened and phGameEnd=0) and (ClientMode<scContact))
    326     else
    327       FrameImage(canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,
    328         56*(CurrentReport.Government-1),40,
    329         ContactEnabled and (MyRO.Happened and phGameEnd=0) and (ClientMode<scContact))};
     343      if Extinct then
     344        FrameImage(Canvas, BigImp, xIcon, yIcon, xSizeBig, ySizeBig, 0, 200)
     345        { else if CurrentReport.Government=gAnarchy then
     346          FrameImage(canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,112,400,
     347          ContactEnabled and (MyRO.Happened and phGameEnd=0) and (ClientMode<scContact))
     348          else
     349          FrameImage(canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,
     350          56*(CurrentReport.Government-1),40,
     351          ContactEnabled and (MyRO.Happened and phGameEnd=0) and (ClientMode<scContact)) };
    330352    end;
    331353
    332   if CurrentReport.TurnOfCivilReport>=0 then
     354    if CurrentReport.TurnOfCivilReport >= 0 then
    333355    begin // print state report
    334     FillSeamless(Canvas, xReport, yReport, wReport, hReport, 0, 0, Paper);
    335     with canvas do
    336       begin
    337       Brush.Color:=MainTexture.clBevelShade;
    338       FillRect(Rect(xReport+wReport, yReport+PaperShade,
    339         xReport+wReport+PaperShade, yReport+hReport+PaperShade));
    340       FillRect(Rect(xReport+PaperShade, yReport+hReport,
    341         xReport+wReport+PaperShade, yReport+hReport+PaperShade));
    342       Brush.Style:=bsClear;
     356      FillSeamless(Canvas, xReport, yReport, wReport, hReport, 0, 0, Paper);
     357      with Canvas do
     358      begin
     359        Brush.Color := MainTexture.clBevelShade;
     360        FillRect(Rect(xReport + wReport, yReport + PaperShade,
     361          xReport + wReport + PaperShade, yReport + hReport + PaperShade));
     362        FillRect(Rect(xReport + PaperShade, yReport + hReport,
     363          xReport + wReport + PaperShade, yReport + hReport + PaperShade));
     364        Brush.Style := bsClear;
    343365      end;
    344366
    345     y:=0;
    346     for i:=0 to ReportText.Count-1 do
    347       begin
    348       if (i>=LinesDown) and (i<LinesDown+ReportLines) then
     367      y := 0;
     368      for i := 0 to ReportText.Count - 1 do
     369      begin
     370        if (i >= LinesDown) and (i < LinesDown + ReportLines) then
    349371        begin
    350         s:=ReportText[i];
    351         if s<>'' then
     372          s := ReportText[i];
     373          if s <> '' then
    352374          begin
    353 //          LineType:=s[1];
    354           delete(s,1,1);
    355           BiColorTextOut(canvas,Colors.Canvas.Pixels[clkMisc,cliPaperText],
    356             $7F007F,xReport+8,yReport+LineSpacing*y,s);
     375            // LineType:=s[1];
     376            delete(s, 1, 1);
     377            BiColorTextOut(Canvas, Colors.Canvas.Pixels[clkMisc, cliPaperText],
     378              $7F007F, xReport + 8, yReport + LineSpacing * y, s);
    357379          end;
    358         inc(y);
     380          inc(y);
    359381        end
    360382      end;
    361383    end
     384    else
     385    begin
     386      s := Phrases.Lookup('FRNOCIVILREP');
     387      RisedTextout(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s)) div 2,
     388        yReport + hReport div 2 - 10, s);
     389    end;
     390
     391    if OptionChecked and (1 shl soTellAI) <> 0 then
     392    begin
     393      Server(sGetAIInfo, me, pView, ps);
     394      LoweredTextOut(Canvas, -1, MainTexture, 42, 445, ps);
     395    end
     396    else
     397      LoweredTextOut(Canvas, -2, MainTexture, 42, 445,
     398        Phrases2.Lookup('MENU_TELLAI'));
     399  end;
     400  ContactBtn.SetBack(offscreen.Canvas, ContactBtn.Left, ContactBtn.Top);
     401
     402  MarkUsedOffscreen(ClientWidth, ClientHeight);
     403end; { OffscreenPaint }
     404
     405procedure TNatStatDlg.CloseBtnClick(Sender: TObject);
     406begin
     407  Close
     408end;
     409
     410procedure TNatStatDlg.DialogBtnClick(Sender: TObject);
     411var
     412  ContactResult: integer;
     413begin
     414  ContactResult := MainScreen.DipCall(scContact + pView shl 4);
     415  if ContactResult < rExecuted then
     416  begin
     417    if ContactResult = eColdWar then
     418      SoundMessage(Phrases.Lookup('FRCOLDWAR'), 'MSG_DEFAULT')
     419    else if MyRO.Government = gAnarchy then
     420      SoundMessage(Tribe[me].TPhrase('FRMYANARCHY'), 'MSG_DEFAULT')
     421    else if ContactResult = eAnarchy then
     422      if MyRO.Treaty[pView] >= trPeace then
     423      begin
     424        if MainScreen.ContactRefused(pView, 'FRANARCHY') then
     425          SmartUpdateContent
     426      end
     427      else
     428        SoundMessage(Tribe[pView].TPhrase('FRANARCHY'), 'MSG_DEFAULT');
     429  end
    362430  else
    363     begin
    364     s:=Phrases.Lookup('FRNOCIVILREP');
    365     RisedTextOut(Canvas,(ClientWidth-BiColorTextWidth(Canvas,s)) div 2,
    366       yReport+hReport div 2-10,s);
     431    Close
     432end;
     433
     434procedure TNatStatDlg.ToggleBtnClick(Sender: TObject);
     435var
     436  p1, StartCount: integer;
     437  m: TMenuItem;
     438  ExtinctPart: boolean;
     439begin
     440  EmptyMenu(Popup.Items);
     441
     442  // own nation
     443  if G.Difficulty[me] <> 0 then
     444  begin
     445    m := TMenuItem.Create(Popup);
     446    m.RadioItem := true;
     447    m.Caption := Tribe[me].TPhrase('TITLE_NATION');
     448    m.Tag := me;
     449    m.OnClick := PlayerClick;
     450    if me = pView then
     451      m.Checked := true;
     452    Popup.Items.Add(m);
     453  end;
     454
     455  // foreign nations
     456  for ExtinctPart := false to true do
     457  begin
     458    StartCount := Popup.Items.Count;
     459    for p1 := 0 to nPl - 1 do
     460      if ExtinctPart and (G.Difficulty[p1] > 0) and
     461        (1 shl p1 and MyRO.Alive = 0) or not ExtinctPart and
     462        (1 shl p1 and MyRO.Alive <> 0) and (MyRO.Treaty[p1] >= trNone) then
     463      begin
     464        m := TMenuItem.Create(Popup);
     465        m.RadioItem := true;
     466        m.Caption := Tribe[p1].TPhrase('TITLE_NATION');
     467        if ExtinctPart then
     468          m.Caption := '(' + m.Caption + ')';
     469        m.Tag := p1;
     470        m.OnClick := PlayerClick;
     471        if p1 = pView then
     472          m.Checked := true;
     473        Popup.Items.Add(m);
     474      end;
     475    if (StartCount > 0) and (Popup.Items.Count > StartCount) then
     476    begin // seperator
     477      m := TMenuItem.Create(Popup);
     478      m.Caption := '-';
     479      Popup.Items.Insert(StartCount, m);
    367480    end;
    368 
    369   if OptionChecked and (1 shl soTellAI)<>0 then
    370     begin
    371     Server(sGetAIInfo,me,pView,ps);
    372     LoweredTextOut(Canvas,-1,MainTexture,42,445,ps);
    373     end
    374   else LoweredTextOut(Canvas,-2,MainTexture,42,445,Phrases2.Lookup('MENU_TELLAI'));
    375   end;
    376 ContactBtn.SetBack(Offscreen.Canvas,ContactBtn.Left,ContactBtn.Top);
    377 
    378 MarkUsedOffscreen(ClientWidth,ClientHeight);
    379 end; {OffscreenPaint}
    380 
    381 procedure TNatStatDlg.CloseBtnClick(Sender: TObject);
    382 begin
    383 Close
    384 end;
    385 
    386 procedure TNatStatDlg.DialogBtnClick(Sender: TObject);
    387 var
    388 ContactResult: integer;
    389 begin
    390 ContactResult:=MainScreen.DipCall(scContact+pView shl 4);
    391 if ContactResult<rExecuted then
    392   begin
    393   if ContactResult=eColdWar then
    394     SoundMessage(Phrases.Lookup('FRCOLDWAR'),'MSG_DEFAULT')
    395   else if MyRO.Government=gAnarchy then
    396     SoundMessage(Tribe[me].TPhrase('FRMYANARCHY'),'MSG_DEFAULT')
    397   else if ContactResult=eAnarchy then
    398     if MyRO.Treaty[pView]>=trPeace then
    399       begin
    400       if MainScreen.ContactRefused(pView, 'FRANARCHY') then
    401         SmartUpdateContent
    402       end
    403     else SoundMessage(Tribe[pView].TPhrase('FRANARCHY'),'MSG_DEFAULT');
    404   end
    405 else Close
    406 end;
    407 
    408 procedure TNatStatDlg.ToggleBtnClick(Sender: TObject);
    409 var
    410 p1,StartCount: integer;
    411 m: TMenuItem;
    412 ExtinctPart: boolean;
    413 begin
    414 EmptyMenu(Popup.Items);
    415 
    416 // own nation
    417 if G.Difficulty[me]<>0 then
    418   begin
    419   m:=TMenuItem.Create(Popup);
    420   m.RadioItem:=true;
    421   m.Caption:=Tribe[me].TPhrase('TITLE_NATION');
    422   m.Tag:=me;
    423   m.OnClick:=PlayerClick;
    424   if me=pView then m.Checked:=true;
    425   Popup.Items.Add(m);
    426   end;
    427 
    428 // foreign nations
    429 for ExtinctPart:=false to true do
    430   begin
    431   StartCount:=Popup.Items.Count;
    432   for p1:=0 to nPl-1 do
    433     if ExtinctPart and (G.Difficulty[p1]>0) and (1 shl p1 and MyRO.Alive=0)
    434       or not ExtinctPart and (1 shl p1 and MyRO.Alive<>0)
    435       and (MyRO.Treaty[p1]>=trNone) then
    436       begin
    437       m:=TMenuItem.Create(Popup);
    438       m.RadioItem:=true;
    439       m.Caption:=Tribe[p1].TPhrase('TITLE_NATION');
    440       if ExtinctPart then
    441         m.Caption:='('+m.Caption+')';
    442       m.Tag:=p1;
    443       m.OnClick:=PlayerClick;
    444       if p1=pView then m.Checked:=true;
    445       Popup.Items.Add(m);
    446       end;
    447   if (StartCount>0) and (Popup.Items.Count>StartCount) then
    448     begin //seperator
    449     m:=TMenuItem.Create(Popup);
    450     m.Caption:='-';
    451     Popup.Items.Insert(StartCount,m);
    452     end;
    453   end;
    454 
    455 Popup.Popup(Left+ToggleBtn.Left, Top+ToggleBtn.Top+ToggleBtn.Height);
     481  end;
     482
     483  Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top + ToggleBtn.Height);
    456484end;
    457485
     
    459487  Shift: TShiftState);
    460488var
    461 i: integer;
    462 begin
    463 if Key=VK_F9 then // my key
     489  i: integer;
     490begin
     491  if Key = VK_F9 then // my key
    464492  begin // toggle nation
    465   i:=0;
    466   repeat
    467     pView:=(pView+1) mod nPl;
    468     inc(i);
    469   until (i>=nPl)
    470     or (1 shl pView and MyRO.Alive<>0) and (MyRO.Treaty[pView]>=trNone);
    471   if i>=nPl then pView:=me;
    472   Tag:=pView;
    473   PlayerClick(self); // no, this is not nice
    474   end
    475 else inherited 
     493    i := 0;
     494    repeat
     495      pView := (pView + 1) mod nPl;
     496      inc(i);
     497    until (i >= nPl) or (1 shl pView and MyRO.Alive <> 0) and
     498      (MyRO.Treaty[pView] >= trNone);
     499    if i >= nPl then
     500      pView := me;
     501    Tag := pView;
     502    PlayerClick(self); // no, this is not nice
     503  end
     504  else
     505    inherited
    476506end;
    477507
    478508procedure TNatStatDlg.EcoChange;
    479509begin
    480 if Visible and (pView=me) then
    481   begin
    482   SelfReport.Government:=MyRO.Government;
    483   SelfReport.Money:=MyRO.Money;
     510  if Visible and (pView = me) then
     511  begin
     512    SelfReport.Government := MyRO.Government;
     513    SelfReport.Money := MyRO.Money;
     514    SmartUpdateContent
     515  end
     516end;
     517
     518procedure TNatStatDlg.ScrollUpBtnClick(Sender: TObject);
     519begin
     520  if LinesDown > 0 then
     521  begin
     522    dec(LinesDown);
     523    SmartUpdateContent;
     524  end
     525end;
     526
     527procedure TNatStatDlg.ScrollDownBtnClick(Sender: TObject);
     528begin
     529  if LinesDown + ReportLines < ReportText.Count then
     530  begin
     531    inc(LinesDown);
     532    SmartUpdateContent;
     533  end
     534end;
     535
     536procedure TNatStatDlg.TellAIBtnClick(Sender: TObject);
     537begin
     538  OptionChecked := OptionChecked xor (1 shl soTellAI);
     539  if OptionChecked and (1 shl soTellAI) <> 0 then
     540    TellAIBtn.ButtonIndex := 3
     541  else
     542    TellAIBtn.ButtonIndex := 2;
    484543  SmartUpdateContent
    485   end
    486 end;
    487 
    488 procedure TNatStatDlg.ScrollUpBtnClick(Sender: TObject);
    489 begin
    490 if LinesDown>0 then
    491   begin
    492   dec(LinesDown);
    493   SmartUpdateContent;
    494   end
    495 end;
    496 
    497 procedure TNatStatDlg.ScrollDownBtnClick(Sender: TObject);
    498 begin
    499 if LinesDown+ReportLines<ReportText.Count then
    500   begin
    501   inc(LinesDown);
    502   SmartUpdateContent;
    503   end
    504 end;
    505 
    506 procedure TNatStatDlg.TellAIBtnClick(Sender: TObject);
    507 begin
    508 OptionChecked:=OptionChecked xor (1 shl soTellAI);
    509 if OptionChecked and (1 shl soTellAI)<>0 then
    510   TellAIBtn.ButtonIndex:=3
    511 else TellAIBtn.ButtonIndex:=2;
    512 SmartUpdateContent
    513544end;
    514545
    515546end.
    516 
Note: See TracChangeset for help on using the changeset viewer.