Changeset 447 for trunk/LocalPlayer/NatStat.pas
- Timestamp:
- May 19, 2022, 10:39:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/NatStat.pas
r442 r447 25 25 procedure ToggleBtnClick(Sender: TObject); 26 26 procedure PlayerClick(Sender: TObject); 27 procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);27 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 28 28 procedure FormDestroy(Sender: TObject); 29 29 procedure ScrollUpBtnClick(Sender: TObject); … … 32 32 public 33 33 procedure CheckAge; 34 procedure ShowNewContent(NewMode: TWindowMode; p: integer = -1);34 procedure ShowNewContent(NewMode: TWindowMode; P: Integer = -1); 35 35 procedure EcoChange; 36 36 protected 37 37 procedure OffscreenPaint; override; 38 38 private 39 pView, AgePrepared, LinesDown: integer;39 pView, AgePrepared, LinesDown: Integer; 40 40 SelfReport, CurrentReport: PEnemyReport; 41 ShowContact, ContactEnabled: boolean;41 ShowContact, ContactEnabled: Boolean; 42 42 Back, Template: TBitmap; 43 43 ReportText: TStringList; … … 114 114 procedure TNatStatDlg.FormShow(Sender: TObject); 115 115 begin 116 if pView = me then116 if pView = Me then 117 117 begin 118 118 SelfReport.TurnOfCivilReport := MyRO.Turn; 119 119 SelfReport.TurnOfMilReport := MyRO.Turn; 120 move(MyRO.Treaty, SelfReport.Treaty, SizeOf(SelfReport.Treaty));120 Move(MyRO.Treaty, SelfReport.Treaty, SizeOf(SelfReport.Treaty)); 121 121 SelfReport.Government := MyRO.Government; 122 122 SelfReport.Money := MyRO.Money; 123 CurrentReport := pointer(SelfReport);123 CurrentReport := Pointer(SelfReport); 124 124 end 125 125 else 126 CurrentReport := pointer(MyRO.EnemyReport[pView]);126 CurrentReport := Pointer(MyRO.EnemyReport[pView]); 127 127 if CurrentReport.TurnOfCivilReport >= 0 then 128 128 GenerateReportText; 129 ShowContact := (pView <> me) and (not supervising or (me <> 0));130 ContactEnabled := ShowContact and not supervising and129 ShowContact := (pView <> Me) and (not Supervising or (Me <> 0)); 130 ContactEnabled := ShowContact and not Supervising and 131 131 (1 shl pView and MyRO.Alive <> 0); 132 132 ContactBtn.Visible := ContactEnabled and (MyRO.Happened and phGameEnd = 0) and … … 146 146 end; 147 147 148 procedure TNatStatDlg.ShowNewContent(NewMode: TWindowMode; p: integer);149 begin 150 if p< 0 then148 procedure TNatStatDlg.ShowNewContent(NewMode: TWindowMode; P: Integer); 149 begin 150 if P < 0 then 151 151 if ClientMode >= scContact then 152 pView := DipMem[ me].pContact152 pView := DipMem[Me].pContact 153 153 else 154 154 begin … … 156 156 while (pView < nPl) and ((MyRO.Treaty[pView] < trNone) or 157 157 (1 shl pView and MyRO.Alive = 0)) do 158 inc(pView);158 Inc(pView); 159 159 if pView >= nPl then 160 pView := me;160 pView := Me; 161 161 end 162 162 else 163 pView := p;163 pView := P; 164 164 inherited ShowNewContent(NewMode); 165 165 end; … … 174 174 List: ^TChart; 175 175 176 function StatText(no: integer): string;176 function StatText(no: Integer): string; 177 177 var 178 i: integer;178 I: Integer; 179 179 begin 180 180 if (CurrentReport.TurnOfCivilReport >= 0) and 181 (Server(sGetChart + no shl 4, me, pView, List^) >= rExecuted) then181 (Server(sGetChart + no shl 4, Me, pView, List^) >= rExecuted) then 182 182 begin 183 i:= List[CurrentReport.TurnOfCivilReport];183 I := List[CurrentReport.TurnOfCivilReport]; 184 184 case no of 185 185 stPop: 186 result := Format(Phrases.Lookup('FRSTATPOP'), [i]);186 Result := Format(Phrases.Lookup('FRSTATPOP'), [I]); 187 187 stTerritory: 188 result := Format(Phrases.Lookup('FRSTATTER'), [i]);188 Result := Format(Phrases.Lookup('FRSTATTER'), [I]); 189 189 stScience: 190 result := Format(Phrases.Lookup('FRSTATTECH'), [idiv nAdv]);190 Result := Format(Phrases.Lookup('FRSTATTECH'), [I div nAdv]); 191 191 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)]); 194 194 end; 195 195 end … … 197 197 198 198 var 199 p1, Treaty: integer;200 s: string;201 HasContact, ExtinctPart: boolean;199 p1, Treaty: Integer; 200 S: string; 201 HasContact, ExtinctPart: Boolean; 202 202 begin 203 203 GetMem(List, 4 * (MyRO.Turn + 2)); … … 208 208 (1 shl pView and MyRO.Alive <> 0) then 209 209 begin 210 s:= Format(Phrases.Lookup('FROLDCIVILREP'),210 S := Format(Phrases.Lookup('FROLDCIVILREP'), 211 211 [TurnToString(CurrentReport.TurnOfCivilReport)]); 212 ReportText.Add('C' + s);212 ReportText.Add('C' + S); 213 213 ReportText.Add(''); 214 214 end; … … 223 223 ReportText.Add('S' + StatText(stScience)); 224 224 ReportText.Add('E' + StatText(stExplore)); 225 HasContact := false;225 HasContact := False; 226 226 for p1 := 0 to nPl - 1 do 227 if (p1 <> me) and (CurrentReport.Treaty[p1] > trNoContact) then228 HasContact := true;227 if (p1 <> Me) and (CurrentReport.Treaty[p1] > trNoContact) then 228 HasContact := True; 229 229 if HasContact then 230 230 begin 231 231 ReportText.Add(''); 232 232 ReportText.Add(' ' + Phrases.Lookup('FRRELATIONS')); 233 for ExtinctPart := false to true do233 for ExtinctPart := False to True do 234 234 for Treaty := trAlliance downto trNone do 235 235 for p1 := 0 to nPl - 1 do 236 if (p1 <> me) and (CurrentReport.Treaty[p1] = Treaty) and236 if (p1 <> Me) and (CurrentReport.Treaty[p1] = Treaty) and 237 237 ((1 shl p1 and MyRO.Alive = 0) = ExtinctPart) then 238 238 begin 239 s:= Tribe[p1].TString(Phrases.Lookup('HAVETREATY', Treaty));239 S := Tribe[p1].TString(Phrases.Lookup('HAVETREATY', Treaty)); 240 240 if ExtinctPart then 241 s := '(' + s+ ')';242 ReportText.Add(char(48 + Treaty) + s);241 S := '(' + S + ')'; 242 ReportText.Add(char(48 + Treaty) + S); 243 243 end; 244 244 end; … … 250 250 procedure TNatStatDlg.OffscreenPaint; 251 251 var 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; 256 256 257 257 begin … … 260 260 Extinct := 1 shl pView and MyRO.Alive = 0; 261 261 262 BitBltCanvas( offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,262 BitBltCanvas(Offscreen.Canvas, 0, 0, ClientWidth, ClientHeight, 263 263 Back.Canvas, 0, 0); 264 264 265 offscreen.Canvas.Font.Assign(UniFont[ftCaption]);266 RisedTextout( offscreen.Canvas,265 Offscreen.Canvas.Font.Assign(UniFont[ftCaption]); 266 RisedTextout(Offscreen.Canvas, 267 267 40 { (ClientWidth-BiColorTextWidth(offscreen.canvas,caption)) div 2 } , 268 268 7, Caption); 269 269 270 offscreen.Canvas.Font.Assign(UniFont[ftNormal]);271 272 with offscreen do270 Offscreen.Canvas.Font.Assign(UniFont[ftNormal]); 271 272 with Offscreen do 273 273 begin 274 274 // show leader picture … … 276 276 if Assigned(Tribe[pView].faceHGr) then 277 277 begin 278 Dump( offscreen, Tribe[pView].faceHGr, 18, yIcon - 4, 64, 48,278 Dump(Offscreen, Tribe[pView].faceHGr, 18, yIcon - 4, 64, 48, 279 279 1 + Tribe[pView].facepix mod 10 * 65, 280 280 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, 282 282 $000000, $000000); 283 283 end; 284 284 285 if (pView = me) or not Extinct then285 if (pView = Me) or not Extinct then 286 286 LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib, 287 287 Phrases.Lookup('GOVERNMENT', CurrentReport.Government) + 288 288 Phrases.Lookup('FRAND')); 289 if pView = me then289 if pView = Me then 290 290 begin 291 291 LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib + 19, … … 314 314 if MyRO.Treaty[pView] = trNoContact then 315 315 begin 316 s:= Phrases.Lookup('FRNOCONTACT');316 S := Phrases.Lookup('FRNOCONTACT'); 317 317 LoweredTextOut(Canvas, -1, MainTexture, 318 (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, yRelation + 9, s);318 (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, yRelation + 9, S); 319 319 end 320 320 else if ShowContact then … … 340 340 FrameImage(Canvas, BigImp, xIcon, yIcon, xSizeBig, ySizeBig, 0, 200) 341 341 { 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, 343 343 ContactEnabled and (MyRO.Happened and phGameEnd=0) and (ClientMode<scContact)) 344 344 else 345 FrameImage( canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,345 FrameImage(Canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig, 346 346 56*(CurrentReport.Government-1),40, 347 347 ContactEnabled and (MyRO.Happened and phGameEnd=0) and (ClientMode<scContact)) }; … … 361 361 end; 362 362 363 y:= 0;364 for i:= 0 to ReportText.Count - 1 do365 begin 366 if ( i >= LinesDown) and (i< LinesDown + ReportLines) then363 Y := 0; 364 for I := 0 to ReportText.Count - 1 do 365 begin 366 if (I >= LinesDown) and (I < LinesDown + ReportLines) then 367 367 begin 368 s := ReportText[i];369 if s<> '' then368 S := ReportText[I]; 369 if S <> '' then 370 370 begin 371 371 // LineType:=s[1]; 372 delete(s, 1, 1);372 Delete(S, 1, 1); 373 373 BiColorTextOut(Canvas, Colors.Canvas.Pixels[clkMisc, cliPaperText], 374 $7F007F, xReport + 8, yReport + LineSpacing * y, s);374 $7F007F, xReport + 8, yReport + LineSpacing * Y, S); 375 375 end; 376 inc(y);376 Inc(Y); 377 377 end; 378 378 end; … … 380 380 else 381 381 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); 385 385 end; 386 386 387 387 if soTellAI in OptionChecked then begin 388 Server(sGetAIInfo, me, pView, ps);388 Server(sGetAIInfo, Me, pView, ps); 389 389 LoweredTextOut(Canvas, -1, MainTexture, 42, 445, ps); 390 390 end else … … 392 392 Phrases2.Lookup('MENU_TELLAI')); 393 393 end; 394 ContactBtn.SetBack( offscreen.Canvas, ContactBtn.Left, ContactBtn.Top);394 ContactBtn.SetBack(Offscreen.Canvas, ContactBtn.Left, ContactBtn.Top); 395 395 396 396 MarkUsedOffscreen(ClientWidth, ClientHeight); … … 404 404 procedure TNatStatDlg.DialogBtnClick(Sender: TObject); 405 405 var 406 ContactResult: integer;406 ContactResult: Integer; 407 407 begin 408 408 ContactResult := MainScreen.DipCall(scContact + pView shl 4); … … 412 412 SoundMessage(Phrases.Lookup('FRCOLDWAR'), 'MSG_DEFAULT') 413 413 else if MyRO.Government = gAnarchy then 414 SoundMessage(Tribe[ me].TPhrase('FRMYANARCHY'), 'MSG_DEFAULT')414 SoundMessage(Tribe[Me].TPhrase('FRMYANARCHY'), 'MSG_DEFAULT') 415 415 else if ContactResult = eAnarchy then 416 416 if MyRO.Treaty[pView] >= trPeace then … … 428 428 procedure TNatStatDlg.ToggleBtnClick(Sender: TObject); 429 429 var 430 p1, StartCount: integer;431 m: TMenuItem;432 ExtinctPart: boolean;430 p1, StartCount: Integer; 431 M: TMenuItem; 432 ExtinctPart: Boolean; 433 433 begin 434 434 EmptyMenu(Popup.Items); 435 435 436 436 // own nation 437 if G.Difficulty[ me] <> 0 then438 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 then445 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); 447 447 end; 448 448 449 449 // foreign nations 450 for ExtinctPart := false to true do450 for ExtinctPart := False to True do 451 451 begin 452 452 StartCount := Popup.Items.Count; … … 456 456 (1 shl p1 and MyRO.Alive <> 0) and (MyRO.Treaty[p1] >= trNone) then 457 457 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'); 461 461 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; 465 465 if p1 = pView then 466 m.Checked := true;467 Popup.Items.Add( m);466 M.Checked := True; 467 Popup.Items.Add(M); 468 468 end; 469 469 if (StartCount > 0) and (Popup.Items.Count > StartCount) then 470 470 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); 474 474 end; 475 475 end; … … 478 478 end; 479 479 480 procedure TNatStatDlg.FormKeyDown(Sender: TObject; var Key: word;480 procedure TNatStatDlg.FormKeyDown(Sender: TObject; var Key: Word; 481 481 Shift: TShiftState); 482 482 var 483 i: integer;483 I: Integer; 484 484 begin 485 485 if Key = VK_F9 then // my key 486 486 begin // toggle nation 487 i:= 0;487 I := 0; 488 488 repeat 489 489 pView := (pView + 1) mod nPl; 490 inc(i);491 until ( i>= nPl) or (1 shl pView and MyRO.Alive <> 0) and490 Inc(I); 491 until (I >= nPl) or (1 shl pView and MyRO.Alive <> 0) and 492 492 (MyRO.Treaty[pView] >= trNone); 493 if i>= nPl then494 pView := me;493 if I >= nPl then 494 pView := Me; 495 495 Tag := pView; 496 496 PlayerClick(self); // no, this is not nice … … 502 502 procedure TNatStatDlg.EcoChange; 503 503 begin 504 if Visible and (pView = me) then504 if Visible and (pView = Me) then 505 505 begin 506 506 SelfReport.Government := MyRO.Government; … … 514 514 if LinesDown > 0 then 515 515 begin 516 dec(LinesDown);516 Dec(LinesDown); 517 517 SmartUpdateContent; 518 518 end; … … 523 523 if LinesDown + ReportLines < ReportText.Count then 524 524 begin 525 inc(LinesDown);525 Inc(LinesDown); 526 526 SmartUpdateContent; 527 527 end;
Note:
See TracChangeset
for help on using the changeset viewer.