Changeset 465 for branches/highdpi/LocalPlayer/NatStat.pas
- Timestamp:
- Nov 30, 2023, 10:16:14 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/NatStat.pas
r361 r465 5 5 6 6 uses 7 UDpiControls, Protocol, ClientTools, Term, ScreenTools, BaseWin, 8 9 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, 10 ButtonB, ButtonC, Menus, EOTButton; 7 UDpiControls, Protocol, ClientTools, ScreenTools, BaseWin, LCLIntf, LCLType, SysUtils, 8 Classes, Graphics, Controls, Forms, ButtonB, ButtonC, Menus, EOTButton; 11 9 12 10 type … … 27 25 procedure ToggleBtnClick(Sender: TObject); 28 26 procedure PlayerClick(Sender: TObject); 29 procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);27 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 30 28 procedure FormDestroy(Sender: TObject); 31 29 procedure ScrollUpBtnClick(Sender: TObject); 32 30 procedure ScrollDownBtnClick(Sender: TObject); 33 31 procedure TellAIBtnClick(Sender: TObject); 34 35 32 public 36 33 procedure CheckAge; 37 procedure ShowNewContent(NewMode: integer; p: integer = -1);34 procedure ShowNewContent(NewMode: TWindowMode; P: Integer = -1); 38 35 procedure EcoChange; 39 40 36 protected 41 37 procedure OffscreenPaint; override; 42 43 38 private 44 pView, AgePrepared, LinesDown: integer; 45 SelfReport, CurrentReport: PEnemyReport; 46 ShowContact, ContactEnabled: boolean; 47 Back, Template: TDpiBitmap; 39 pView: Integer; 40 AgePrepared: Integer; 41 LinesDown: Integer; 42 SelfReport: PEnemyReport; 43 CurrentReport: PEnemyReport; 44 ShowContact: Boolean; 45 ContactEnabled: Boolean; 46 Back: TDpiBitmap; 47 Template: TDpiBitmap; 48 48 ReportText: TStringList; 49 49 procedure GenerateReportText; 50 50 end; 51 51 52 var53 NatStatDlg: TNatStatDlg;54 52 55 53 implementation … … 58 56 59 57 uses 60 Messg, Tribes, Directories;58 Term, Messg, Tribes, Directories; 61 59 62 60 const … … 109 107 if MainTexture.Age <> AgePrepared then begin 110 108 AgePrepared := MainTexture.Age; 111 DpiBit Canvas(Back.Canvas, 0, 0, ClientWidth, ClientHeight,109 DpiBitBltCanvas(Back.Canvas, 0, 0, ClientWidth, ClientHeight, 112 110 MainTexture.Image.Canvas, (MainTexture.Width - ClientWidth) div 2, 113 111 (MainTexture.Height - ClientHeight) div 2); … … 118 116 procedure TNatStatDlg.FormShow(Sender: TObject); 119 117 begin 120 if pView = me then118 if pView = Me then 121 119 begin 122 120 SelfReport.TurnOfCivilReport := MyRO.Turn; 123 121 SelfReport.TurnOfMilReport := MyRO.Turn; 124 move(MyRO.Treaty, SelfReport.Treaty, SizeOf(SelfReport.Treaty));122 Move(MyRO.Treaty, SelfReport.Treaty, SizeOf(SelfReport.Treaty)); 125 123 SelfReport.Government := MyRO.Government; 126 124 SelfReport.Money := MyRO.Money; 127 CurrentReport := pointer(SelfReport);125 CurrentReport := Pointer(SelfReport); 128 126 end 129 127 else 130 CurrentReport := pointer(MyRO.EnemyReport[pView]);128 CurrentReport := Pointer(MyRO.EnemyReport[pView]); 131 129 if CurrentReport.TurnOfCivilReport >= 0 then 132 130 GenerateReportText; 133 ShowContact := (pView <> me) and (not supervising or (me <> 0));134 ContactEnabled := ShowContact and not supervising and131 ShowContact := (pView <> Me) and (not Supervising or (Me <> 0)); 132 ContactEnabled := ShowContact and not Supervising and 135 133 (1 shl pView and MyRO.Alive <> 0); 136 134 ContactBtn.Visible := ContactEnabled and (MyRO.Happened and phGameEnd = 0) and … … 150 148 end; 151 149 152 procedure TNatStatDlg.ShowNewContent(NewMode , p: integer);153 begin 154 if p< 0 then150 procedure TNatStatDlg.ShowNewContent(NewMode: TWindowMode; P: Integer); 151 begin 152 if P < 0 then 155 153 if ClientMode >= scContact then 156 pView := DipMem[ me].pContact154 pView := DipMem[Me].pContact 157 155 else 158 156 begin … … 160 158 while (pView < nPl) and ((MyRO.Treaty[pView] < trNone) or 161 159 (1 shl pView and MyRO.Alive = 0)) do 162 inc(pView);160 Inc(pView); 163 161 if pView >= nPl then 164 pView := me;162 pView := Me; 165 163 end 166 164 else 167 pView := p;165 pView := P; 168 166 inherited ShowNewContent(NewMode); 169 167 end; … … 178 176 List: ^TChart; 179 177 180 function StatText(no: integer): string;178 function StatText(no: Integer): string; 181 179 var 182 i: integer;180 I: Integer; 183 181 begin 184 182 if (CurrentReport.TurnOfCivilReport >= 0) and 185 (Server(sGetChart + no shl 4, me, pView, List^) >= rExecuted) then183 (Server(sGetChart + no shl 4, Me, pView, List^) >= rExecuted) then 186 184 begin 187 i:= List[CurrentReport.TurnOfCivilReport];185 I := List[CurrentReport.TurnOfCivilReport]; 188 186 case no of 189 187 stPop: 190 result := Format(Phrases.Lookup('FRSTATPOP'), [i]);188 Result := Format(Phrases.Lookup('FRSTATPOP'), [I]); 191 189 stTerritory: 192 result := Format(Phrases.Lookup('FRSTATTER'), [i]);190 Result := Format(Phrases.Lookup('FRSTATTER'), [I]); 193 191 stScience: 194 result := Format(Phrases.Lookup('FRSTATTECH'), [idiv nAdv]);192 Result := Format(Phrases.Lookup('FRSTATTECH'), [I div nAdv]); 195 193 stExplore: 196 result := Format(Phrases.Lookup('FRSTATEXP'),197 [ i* 100 div (G.lx * G.ly)]);194 Result := Format(Phrases.Lookup('FRSTATEXP'), 195 [I * 100 div (G.lx * G.ly)]); 198 196 end; 199 end 197 end; 200 198 end; 201 199 202 200 var 203 p1, Treaty: integer;204 s: string;205 HasContact, ExtinctPart: boolean;201 p1, Treaty: Integer; 202 S: string; 203 HasContact, ExtinctPart: Boolean; 206 204 begin 207 205 GetMem(List, 4 * (MyRO.Turn + 2)); … … 212 210 (1 shl pView and MyRO.Alive <> 0) then 213 211 begin 214 s:= Format(Phrases.Lookup('FROLDCIVILREP'),212 S := Format(Phrases.Lookup('FROLDCIVILREP'), 215 213 [TurnToString(CurrentReport.TurnOfCivilReport)]); 216 ReportText.Add('C' + s);214 ReportText.Add('C' + S); 217 215 ReportText.Add(''); 218 216 end; … … 227 225 ReportText.Add('S' + StatText(stScience)); 228 226 ReportText.Add('E' + StatText(stExplore)); 229 HasContact := false;227 HasContact := False; 230 228 for p1 := 0 to nPl - 1 do 231 if (p1 <> me) and (CurrentReport.Treaty[p1] > trNoContact) then232 HasContact := true;229 if (p1 <> Me) and (CurrentReport.Treaty[p1] > trNoContact) then 230 HasContact := True; 233 231 if HasContact then 234 232 begin 235 233 ReportText.Add(''); 236 234 ReportText.Add(' ' + Phrases.Lookup('FRRELATIONS')); 237 for ExtinctPart := false to true do235 for ExtinctPart := False to True do 238 236 for Treaty := trAlliance downto trNone do 239 237 for p1 := 0 to nPl - 1 do 240 if (p1 <> me) and (CurrentReport.Treaty[p1] = Treaty) and238 if (p1 <> Me) and (CurrentReport.Treaty[p1] = Treaty) and 241 239 ((1 shl p1 and MyRO.Alive = 0) = ExtinctPart) then 242 240 begin 243 s:= Tribe[p1].TString(Phrases.Lookup('HAVETREATY', Treaty));241 S := Tribe[p1].TString(Phrases.Lookup('HAVETREATY', Treaty)); 244 242 if ExtinctPart then 245 s := '(' + s+ ')';246 ReportText.Add(char(48 + Treaty) + s);243 S := '(' + S + ')'; 244 ReportText.Add(char(48 + Treaty) + S); 247 245 end; 248 246 end; … … 254 252 procedure TNatStatDlg.OffscreenPaint; 255 253 var 256 i, y: integer; 257 s: string; 258 ps: pchar; 259 Extinct: boolean; 260 254 I, Y: Integer; 255 S: string; 256 ps: PChar; 257 Extinct: Boolean; 261 258 begin 262 259 inherited; … … 264 261 Extinct := 1 shl pView and MyRO.Alive = 0; 265 262 266 DpiBit Canvas(offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,263 DpiBitBltCanvas(Offscreen.Canvas, 0, 0, ClientWidth, ClientHeight, 267 264 Back.Canvas, 0, 0); 268 265 269 offscreen.Canvas.Font.Assign(UniFont[ftCaption]);270 RisedTextout( offscreen.Canvas,266 Offscreen.Canvas.Font.Assign(UniFont[ftCaption]); 267 RisedTextout(Offscreen.Canvas, 271 268 40 { (ClientWidth-BiColorTextWidth(offscreen.canvas,caption)) div 2 } , 272 269 7, Caption); 273 270 274 offscreen.Canvas.Font.Assign(UniFont[ftNormal]);275 276 with offscreen do271 Offscreen.Canvas.Font.Assign(UniFont[ftNormal]); 272 273 with Offscreen do 277 274 begin 278 275 // show leader picture … … 280 277 if Assigned(Tribe[pView].faceHGr) then 281 278 begin 282 Dump( offscreen, Tribe[pView].faceHGr, 18, yIcon - 4, 64, 48,279 Dump(Offscreen, Tribe[pView].faceHGr, 18, yIcon - 4, 64, 48, 283 280 1 + Tribe[pView].facepix mod 10 * 65, 284 281 1 + Tribe[pView].facepix div 10 * 49); 285 frame(offscreen.Canvas, 18 - 1, yIcon - 4 - 1, 18 + 64, yIcon - 4 + 48,282 Frame(Offscreen.Canvas, 18 - 1, yIcon - 4 - 1, 18 + 64, yIcon - 4 + 48, 286 283 $000000, $000000); 287 284 end; 288 285 289 if (pView = me) or not Extinct then286 if (pView = Me) or not Extinct then 290 287 LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib, 291 288 Phrases.Lookup('GOVERNMENT', CurrentReport.Government) + 292 289 Phrases.Lookup('FRAND')); 293 if pView = me then290 if pView = Me then 294 291 begin 295 292 LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib + 19, … … 305 302 Phrases.Lookup('FREXTINCT')); 306 303 LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib + 28, 307 TurnToString(CurrentReport.TurnOfCivilReport)) 304 TurnToString(CurrentReport.TurnOfCivilReport)); 308 305 end 309 306 else … … 318 315 if MyRO.Treaty[pView] = trNoContact then 319 316 begin 320 s:= Phrases.Lookup('FRNOCONTACT');317 S := Phrases.Lookup('FRNOCONTACT'); 321 318 LoweredTextOut(Canvas, -1, MainTexture, 322 (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, yRelation + 9, s)319 (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, yRelation + 9, S); 323 320 end 324 321 else if ShowContact then … … 344 341 FrameImage(Canvas, BigImp, xIcon, yIcon, xSizeBig, ySizeBig, 0, 200) 345 342 { else if CurrentReport.Government=gAnarchy then 346 FrameImage( canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,112,400,343 FrameImage(Canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,112,400, 347 344 ContactEnabled and (MyRO.Happened and phGameEnd=0) and (ClientMode<scContact)) 348 345 else 349 FrameImage( canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig,346 FrameImage(Canvas,BigImp,xIcon,yIcon,xSizeBig,ySizeBig, 350 347 56*(CurrentReport.Government-1),40, 351 348 ContactEnabled and (MyRO.Happened and phGameEnd=0) and (ClientMode<scContact)) }; … … 365 362 end; 366 363 367 y:= 0;368 for i:= 0 to ReportText.Count - 1 do369 begin 370 if ( i >= LinesDown) and (i< LinesDown + ReportLines) then364 Y := 0; 365 for I := 0 to ReportText.Count - 1 do 366 begin 367 if (I >= LinesDown) and (I < LinesDown + ReportLines) then 371 368 begin 372 s := ReportText[i];373 if s<> '' then369 S := ReportText[I]; 370 if S <> '' then 374 371 begin 375 372 // LineType:=s[1]; 376 delete(s, 1, 1);373 Delete(S, 1, 1); 377 374 BiColorTextOut(Canvas, Colors.Canvas.Pixels[clkMisc, cliPaperText], 378 $7F007F, xReport + 8, yReport + LineSpacing * y, s);375 $7F007F, xReport + 8, yReport + LineSpacing * Y, S); 379 376 end; 380 inc(y);381 end 377 Inc(Y); 378 end; 382 379 end; 383 380 end 384 381 else 385 382 begin 386 s:= Phrases.Lookup('FRNOCIVILREP');387 RisedTextout(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s)) div 2,388 yReport + hReport div 2 - 10, s);383 S := Phrases.Lookup('FRNOCIVILREP'); 384 RisedTextout(Canvas, (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, 385 yReport + hReport div 2 - 10, S); 389 386 end; 390 387 391 388 if soTellAI in OptionChecked then begin 392 Server(sGetAIInfo, me, pView, ps);389 Server(sGetAIInfo, Me, pView, ps); 393 390 LoweredTextOut(Canvas, -1, MainTexture, 42, 445, ps); 394 391 end else … … 396 393 Phrases2.Lookup('MENU_TELLAI')); 397 394 end; 398 ContactBtn.SetBack(offscreen.Canvas, ContactBtn.Left, ContactBtn.Top); 395 396 ContactBtn.SetBack(Offscreen.Canvas, ContactBtn.Left, ContactBtn.Top); 399 397 400 398 MarkUsedOffscreen(ClientWidth, ClientHeight); 401 end; { OffscreenPaint }399 end; 402 400 403 401 procedure TNatStatDlg.CloseBtnClick(Sender: TObject); 404 402 begin 405 Close 403 Close; 406 404 end; 407 405 408 406 procedure TNatStatDlg.DialogBtnClick(Sender: TObject); 409 407 var 410 ContactResult: integer;408 ContactResult: Integer; 411 409 begin 412 410 ContactResult := MainScreen.DipCall(scContact + pView shl 4); … … 416 414 SoundMessage(Phrases.Lookup('FRCOLDWAR'), 'MSG_DEFAULT') 417 415 else if MyRO.Government = gAnarchy then 418 SoundMessage(Tribe[ me].TPhrase('FRMYANARCHY'), 'MSG_DEFAULT')416 SoundMessage(Tribe[Me].TPhrase('FRMYANARCHY'), 'MSG_DEFAULT') 419 417 else if ContactResult = eAnarchy then 420 418 if MyRO.Treaty[pView] >= trPeace then 421 419 begin 422 420 if MainScreen.ContactRefused(pView, 'FRANARCHY') then 423 SmartUpdateContent 421 SmartUpdateContent; 424 422 end 425 423 else … … 427 425 end 428 426 else 429 Close 427 Close; 430 428 end; 431 429 432 430 procedure TNatStatDlg.ToggleBtnClick(Sender: TObject); 433 431 var 434 p1, StartCount: integer;435 m: TDpiMenuItem;436 ExtinctPart: boolean;432 p1, StartCount: Integer; 433 M: TDpiMenuItem; 434 ExtinctPart: Boolean; 437 435 begin 438 436 EmptyMenu(Popup.Items); 439 437 440 438 // own nation 441 if G.Difficulty[ me] <> 0 then442 begin 443 m:= TDpiMenuItem.Create(Popup);444 m.RadioItem := true;445 m.Caption := Tribe[me].TPhrase('TITLE_NATION');446 m.Tag := me;447 m.OnClick := PlayerClick;448 if me = pView then449 m.Checked := true;450 Popup.Items.Add( m);439 if G.Difficulty[Me] <> 0 then 440 begin 441 M := TDpiMenuItem.Create(Popup); 442 M.RadioItem := True; 443 M.Caption := Tribe[Me].TPhrase('TITLE_NATION'); 444 M.Tag := Me; 445 M.OnClick := PlayerClick; 446 if Me = pView then 447 M.Checked := True; 448 Popup.Items.Add(M); 451 449 end; 452 450 453 451 // foreign nations 454 for ExtinctPart := false to true do452 for ExtinctPart := False to True do 455 453 begin 456 454 StartCount := Popup.Items.Count; … … 460 458 (1 shl p1 and MyRO.Alive <> 0) and (MyRO.Treaty[p1] >= trNone) then 461 459 begin 462 m:= TDpiMenuItem.Create(Popup);463 m.RadioItem := true;464 m.Caption := Tribe[p1].TPhrase('TITLE_NATION');460 M := TDpiMenuItem.Create(Popup); 461 M.RadioItem := True; 462 M.Caption := Tribe[p1].TPhrase('TITLE_NATION'); 465 463 if ExtinctPart then 466 m.Caption := '(' + m.Caption + ')';467 m.Tag := p1;468 m.OnClick := PlayerClick;464 M.Caption := '(' + M.Caption + ')'; 465 M.Tag := p1; 466 M.OnClick := PlayerClick; 469 467 if p1 = pView then 470 m.Checked := true;471 Popup.Items.Add( m);468 M.Checked := True; 469 Popup.Items.Add(M); 472 470 end; 473 471 if (StartCount > 0) and (Popup.Items.Count > StartCount) then 474 472 begin // seperator 475 m:= TDpiMenuItem.Create(Popup);476 m.Caption := '-';477 Popup.Items.Insert(StartCount, m);473 M := TDpiMenuItem.Create(Popup); 474 M.Caption := '-'; 475 Popup.Items.Insert(StartCount, M); 478 476 end; 479 477 end; … … 482 480 end; 483 481 484 procedure TNatStatDlg.FormKeyDown(Sender: TObject; var Key: word;482 procedure TNatStatDlg.FormKeyDown(Sender: TObject; var Key: Word; 485 483 Shift: TShiftState); 486 484 var 487 i: integer;485 I: Integer; 488 486 begin 489 487 if Key = VK_F9 then // my key 490 488 begin // toggle nation 491 i:= 0;489 I := 0; 492 490 repeat 493 491 pView := (pView + 1) mod nPl; 494 inc(i);495 until ( i>= nPl) or (1 shl pView and MyRO.Alive <> 0) and492 Inc(I); 493 until (I >= nPl) or (1 shl pView and MyRO.Alive <> 0) and 496 494 (MyRO.Treaty[pView] >= trNone); 497 if i>= nPl then498 pView := me;495 if I >= nPl then 496 pView := Me; 499 497 Tag := pView; 500 498 PlayerClick(self); // no, this is not nice 501 499 end 502 500 else 503 inherited 501 inherited; 504 502 end; 505 503 506 504 procedure TNatStatDlg.EcoChange; 507 505 begin 508 if Visible and (pView = me) then506 if Visible and (pView = Me) then 509 507 begin 510 508 SelfReport.Government := MyRO.Government; 511 509 SelfReport.Money := MyRO.Money; 512 SmartUpdateContent 513 end 510 SmartUpdateContent; 511 end; 514 512 end; 515 513 … … 518 516 if LinesDown > 0 then 519 517 begin 520 dec(LinesDown);518 Dec(LinesDown); 521 519 SmartUpdateContent; 522 end 520 end; 523 521 end; 524 522 … … 527 525 if LinesDown + ReportLines < ReportText.Count then 528 526 begin 529 inc(LinesDown);527 Inc(LinesDown); 530 528 SmartUpdateContent; 531 end 529 end; 532 530 end; 533 531 … … 540 538 else 541 539 TellAIBtn.ButtonIndex := 2; 542 SmartUpdateContent 540 SmartUpdateContent; 543 541 end; 544 542
Note:
See TracChangeset
for help on using the changeset viewer.