Changeset 465 for branches/highdpi/LocalPlayer
- Timestamp:
- Nov 30, 2023, 10:16:14 PM (18 months ago)
- Location:
- branches/highdpi/LocalPlayer
- Files:
-
- 25 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/highdpi/LocalPlayer/Battle.pas ¶
r361 r465 32 32 uix, ToLoc: Integer; 33 33 Forecast: TBattleForecastEx; 34 IsSuicideQuery: boolean; 35 end; 36 37 var 38 BattleDlg: TBattleDlg; 34 IsSuicideQuery: Boolean; 35 end; 36 39 37 40 38 implementation … … 62 60 TextSize: TSize; 63 61 LabelText: string; 64 FirstStrike: boolean;62 FirstStrike: Boolean; 65 63 begin 66 64 MaxBar := 65; … … 112 110 VLightGradient(ca, xm - 8, ym + 8 + LABaseDamage, LADamage - LABaseDamage, 113 111 FanaticColor); 114 DpiBit Canvas(ca, xm - 12, ym - 12, 24, 24,112 DpiBitBltCanvas(ca, xm - 12, ym - 12, 24, 24, 115 113 HGrSystem.Mask.Canvas, 26, 146, SRCAND); 116 DpiBit Canvas(ca, xm - 12, ym - 12, 24, 24,114 DpiBitBltCanvas(ca, xm - 12, ym - 12, 24, 24, 117 115 HGrSystem.Data.Canvas, 26, 146, SRCPAINT); 118 116 … … 137 135 if Forecast.EndHealthDef <= 0 then 138 136 begin 139 DpiBit Canvas(ca, xm + 9 + LDDamage - 7, ym - 6, 14, 17,137 DpiBitBltCanvas(ca, xm + 9 + LDDamage - 7, ym - 6, 14, 17, 140 138 HGrSystem.Mask.Canvas, 51, 153, SRCAND); 141 DpiBit Canvas(ca, xm + 8 + LDDamage - 7, ym - 7, 14, 17,139 DpiBitBltCanvas(ca, xm + 8 + LDDamage - 7, ym - 7, 14, 17, 142 140 HGrSystem.Mask.Canvas, 51, 153, SRCAND); 143 DpiBit Canvas(ca, xm + 8 + LDDamage - 7, ym - 7, 14, 17,141 DpiBitBltCanvas(ca, xm + 8 + LDDamage - 7, ym - 7, 14, 17, 144 142 HGrSystem.Data.Canvas, 51, 153, SRCPAINT); 145 143 end; … … 149 147 begin 150 148 if Forecast.EndHealthDef > 0 then 151 RisedTextOut(ca, xm + 10, ym - (TextSize.cy + 1) div 2, LabelText) 149 RisedTextOut(ca, xm + 10, ym - (TextSize.cy + 1) div 2, LabelText); 152 150 end 153 151 else … … 157 155 if Forecast.EndHealthAtt <= 0 then 158 156 begin 159 DpiBit Canvas(ca, xm - 6, ym + 9 + LADamage - 7, 14, 17,157 DpiBitBltCanvas(ca, xm - 6, ym + 9 + LADamage - 7, 14, 17, 160 158 HGrSystem.Mask.Canvas, 51, 153, SRCAND); 161 DpiBit Canvas(ca, xm - 7, ym + 8 + LADamage - 7, 14, 17,159 DpiBitBltCanvas(ca, xm - 7, ym + 8 + LADamage - 7, 14, 17, 162 160 HGrSystem.Mask.Canvas, 51, 153, SRCAND); 163 DpiBit Canvas(ca, xm - 7, ym + 8 + LADamage - 7, 14, 17,161 DpiBitBltCanvas(ca, xm - 7, ym + 8 + LADamage - 7, 14, 17, 164 162 HGrSystem.Data.Canvas, 51, 153, SRCPAINT); 165 163 end; … … 171 169 if Forecast.EndHealthAtt > 0 then 172 170 RisedTextOut(ca, xm - (TextSize.cx + 1) div 2, ym + 8 + LAAvoidedDamage, 173 LabelText) 171 LabelText); 174 172 end 175 173 else … … 178 176 179 177 IsoMap.SetOutput(Buffer); 180 DpiBit Canvas(Buffer.Canvas, 0, 0, 66, 48, ca, xm + 8 + 4,178 DpiBitBltCanvas(Buffer.Canvas, 0, 0, 66, 48, ca, xm + 8 + 4, 181 179 ym - 8 - 12 - 48); 182 180 { if TerrType<fForest then … … 190 188 end; } 191 189 IsoMap.PaintUnit(1, 0, UnitInfo, 0); 192 DpiBit Canvas(ca, xm + 8 + 4, ym - 8 - 12 - 48, 66, 48, Buffer.Canvas,190 DpiBitBltCanvas(ca, xm + 8 + 4, ym - 8 - 12 - 48, 66, 48, Buffer.Canvas, 193 191 0, 0); 194 192 195 DpiBit Canvas(Buffer.Canvas, 0, 0, 66, 48, ca, xm - 8 - 4 - 66,193 DpiBitBltCanvas(Buffer.Canvas, 0, 0, 66, 48, ca, xm - 8 - 4 - 66, 196 194 ym + 8 + 12); 197 MakeUnitInfo( me, MyUn[uix], UnitInfo);195 MakeUnitInfo(Me, MyUn[uix], UnitInfo); 198 196 UnitInfo.Flags := UnitInfo.Flags and not unFortified; 199 197 IsoMap.PaintUnit(1, 0, UnitInfo, 0); 200 DpiBit Canvas(ca, xm - 8 - 4 - 66, ym + 8 + 12, 66, 48, Buffer.Canvas, 0, 0);201 end; { PaintBattleOutcome }198 DpiBitBltCanvas(ca, xm - 8 - 4 - 66, ym + 8 + 12, 66, 48, Buffer.Canvas, 0, 0); 199 end; 202 200 203 201 procedure TBattleDlg.FormCreate(Sender: TObject); … … 215 213 ClientWidth := 300; 216 214 ClientHeight := 288; 217 OKBtn.Visible := true;218 CancelBtn.Visible := true;215 OKBtn.Visible := True; 216 CancelBtn.Visible := True; 219 217 Left := (DpiScreen.Width - ClientWidth) div 2; // center on screen 220 218 Top := (DpiScreen.Height - ClientHeight) div 2; … … 224 222 ClientWidth := 178; 225 223 ClientHeight := 178; 226 OKBtn.Visible := false;227 CancelBtn.Visible := false;224 OKBtn.Visible := False; 225 CancelBtn.Visible := False; 228 226 end; 229 227 end; … … 231 229 procedure TBattleDlg.FormPaint(Sender: TObject); 232 230 var 233 ym, cix, p: Integer;234 s, s1: string;231 ym, cix, P: Integer; 232 S, s1: string; 235 233 begin 236 234 with Canvas do … … 240 238 Brush.Style := bsClear; 241 239 PaintBackground(self, 3 + Border, 3 + Border, 242 ClientWidth - (6 + 2 * Border), ClientHeight - (6 + 2 * Border)) 240 ClientWidth - (6 + 2 * Border), ClientHeight - (6 + 2 * Border)); 243 241 end; 244 242 Frame(Canvas, Border + 1, Border + 1, ClientWidth - (2 + Border), … … 252 250 begin 253 251 Canvas.Font.Assign(UniFont[ftCaption]); 254 s:= Phrases.Lookup('TITLE_SUICIDE');255 RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s)) div 2,256 7 + Border, s);252 S := Phrases.Lookup('TITLE_SUICIDE'); 253 RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, 254 7 + Border, S); 257 255 Canvas.Font.Assign(UniFont[ftNormal]); 258 s:= Phrases.Lookup('SUICIDE');259 p := pos('\', s);260 if p= 0 then261 RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s))262 div 2, 205, s)256 S := Phrases.Lookup('SUICIDE'); 257 P := Pos('\', S); 258 if P = 0 then 259 RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, S)) 260 div 2, 205, S) 263 261 else 264 262 begin 265 s1 := copy(s, 1, p- 1);263 s1 := Copy(S, 1, P - 1); 266 264 RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s1)) div 2, 267 265 205 - MessageLineSpacing div 2, s1); 268 s1 := copy(s, p+ 1, 255);266 s1 := Copy(S, P + 1, 255); 269 267 RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s1)) div 2, 270 268 205 + (MessageLineSpacing - MessageLineSpacing div 2), s1); 271 269 end; 272 ym := 110 270 ym := 110; 273 271 end 274 272 else … … 297 295 begin 298 296 if not IsSuicideQuery then 299 Close 297 Close; 300 298 end; 301 299 … … 309 307 if Key <> VK_ESCAPE then 310 308 MainScreen.FormKeyDown(Sender, Key, Shift); 311 end 309 end; 312 310 end; 313 311 -
TabularUnified branches/highdpi/LocalPlayer/CityScreen.pas ¶
r405 r465 5 5 6 6 uses 7 UDpiControls, {$IFDEF LINUX}LMessages,{$ENDIF}8 Protocol, ClientTools, Term, ScreenTools, IsoEngine, BaseWin,9 LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,10 Button A, ButtonC, Area, GraphType, UTexture;7 UDpiControls, {$IFDEF UNIX}LMessages,{$ENDIF} 8 Protocol, ClientTools, ScreenTools, IsoEngine, BaseWin, LCLIntf, LCLType, 9 Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls, ButtonA, 10 ButtonC, Area, GraphType, Texture; 11 11 12 12 const … … 39 39 procedure FormDestroy(Sender: TObject); 40 40 procedure FormMouseDown(Sender: TObject; Button: TMouseButton; 41 Shift: TShiftState; x, y: integer);41 Shift: TShiftState; X, Y: Integer); 42 42 procedure BuyClick(Sender: TObject); 43 43 procedure CloseBtnClick(Sender: TObject); … … 49 49 procedure PrevCityBtnClick(Sender: TObject); 50 50 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 51 // procedure AdviceBtnClick(Sender: TObject);52 51 procedure PageUpBtnClick(Sender: TObject); 53 52 procedure PageDownBtnClick(Sender: TObject); 54 53 private 55 c: TCity;54 C: TCity; 56 55 Report: TCityReportNew; 57 56 cOwner: Integer; … … 70 69 Optimize_cixTileChange: Integer; 71 70 Optimize_TilesBeforeChange: Integer; 72 Happened: cardinal;73 imix: array [0 .. 15] of integer;71 Happened: Cardinal; 72 imix: array [0 .. 15] of Integer; 74 73 CityAreaInfo: TCityAreaInfo; 75 74 AreaMap: TIsoMap; … … 89 88 procedure InitZoomCityMap; 90 89 procedure ChooseProject; 91 procedure ChangeCity( d: integer);92 procedure ChangeResourceWeights(iResourceWeights: integer);90 procedure ChangeCity(D: Integer); 91 procedure ChangeResourceWeights(iResourceWeights: Integer); 93 92 procedure OnPlaySound(var Msg: TMessage); message WM_PLAYSOUND; 94 93 public 95 RestoreUnFocus: integer;94 RestoreUnFocus: Integer; 96 95 CloseAction: TCityCloseAction; 97 96 procedure OffscreenPaint; override; 98 procedure ShowNewContent(NewMode , Loc: integer; ShowEvent: cardinal);97 procedure ShowNewContent(NewMode: TWindowMode; Loc: Integer; ShowEvent: Cardinal); 99 98 procedure Reset; 100 99 procedure CheckAge; 101 100 end; 102 101 103 var104 CityDlg: TCityDlg;105 106 102 107 103 implementation 108 104 109 105 uses 110 Select, Messg, MessgEx, Help, Tribes, Directories, Math, Sound ;106 Select, Messg, MessgEx, Help, Tribes, Directories, Math, Sound, Term; 111 107 112 108 {$R *.lfm} … … 148 144 wZoomEnvironment = 68; 149 145 150 ImpPosition: array [28 .. nImp - 1] of integer = (-1, // imTrGoods 146 ImpPosition: array [28 .. nImp - 1] of Integer = ( 147 -1, // imTrGoods 151 148 21, // imBarracks 152 149 6, // imGranary … … 192 189 193 190 var 194 ImpSorted: array [0 .. nImp - 1] of integer;191 ImpSorted: array [0 .. nImp - 1] of Integer; 195 192 196 193 procedure TCityDlg.FormCreate(Sender: TObject); … … 201 198 NoMap := TIsoMap.Create; 202 199 AreaMap := TIsoMap.Create; 203 AreaMap.SetOutput( offscreen);200 AreaMap.SetOutput(Offscreen); 204 201 AreaMap.SetPaintBounds(xmArea - 192, ymArea - 96 - 32, xmArea + 192, 205 202 ymArea + 96); 206 SmallMapMode := smImprovements; 207 ZoomArea := 1; 208 ProdHint := false; 203 Reset; 204 ProdHint := False; 209 205 RestoreUnFocus := -1; 210 206 OpenSoundEvent := -1; … … 279 275 280 276 UnshareBitmap(Back); 281 DpiBit Canvas(Back.Canvas, 0, 0, ClientWidth, ClientHeight,277 DpiBitBltCanvas(Back.Canvas, 0, 0, ClientWidth, ClientHeight, 282 278 MainTexture.Image.Canvas, 0, 0); 283 279 ImageOp_B(Back, Template, 0, 0, 0, 0, ClientWidth, ClientHeight); … … 292 288 procedure TCityDlg.InitSmallCityMap; 293 289 var 294 i, iix, cli1, Color0, Color1, Color2: integer;290 I, iix, cli1, Color0, Color1, Color2: Integer; 295 291 begin 296 292 if cix >= 0 then 297 c:= MyCity[cix];293 C := MyCity[cix]; 298 294 case MyMap[cLoc] and fTerrain of 299 295 fPrairie: cli1 := cliPrairie; … … 307 303 Color2 := Colors.Canvas.Pixels[clkAge0 + Age, cliHouse]; 308 304 SmallCityMap.Canvas.FillRect(0, 0, SmallCityMap.Width, SmallCityMap.Height); 309 DpiBit Canvas(SmallCityMap.Canvas, 0, 0, 83, hSmallMap,305 DpiBitBltCanvas(SmallCityMap.Canvas, 0, 0, 83, hSmallMap, 310 306 SmallCityMapTemplate.Canvas, 83 * SizeClass, 0); 311 307 if IsPort then 312 308 begin 313 DpiBit Canvas(SmallCityMap.Canvas, 83, 0, 15, hSmallMap,309 DpiBitBltCanvas(SmallCityMap.Canvas, 83, 0, 15, hSmallMap, 314 310 SmallCityMapTemplate.Canvas, 332 + 15, 0); 315 311 ImageOp_CCC(SmallCityMap, 0, 0, 83, hSmallMap, Color0, Color1, Color2); … … 319 315 else 320 316 begin 321 DpiBit Canvas(SmallCityMap.Canvas, 83, 0, 15, hSmallMap,317 DpiBitBltCanvas(SmallCityMap.Canvas, 83, 0, 15, hSmallMap, 322 318 SmallCityMapTemplate.Canvas, 332, 0); 323 319 ImageOp_CCC(SmallCityMap, 0, 0, wSmallMap, hSmallMap, Color0, … … 328 324 begin 329 325 Brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImp]; 330 for i:= 0 to 29 do326 for I := 0 to 29 do 331 327 begin 332 328 for iix := nWonder to nImp - 1 do 333 if (ImpPosition[iix] = i) and (c.Built[iix] > 0) then329 if (ImpPosition[iix] = I) and (C.Built[iix] > 0) then 334 330 begin 335 FillRect(Rect(5 + 16 * ( i mod 3) + 48 * (idiv 18),336 3 + 12 * ( i mod 18 div 3), 13 + 16 * (i mod 3) + 48 * (idiv 18),337 11 + 12 * ( imod 18 div 3)));338 break;331 FillRect(Rect(5 + 16 * (I mod 3) + 48 * (I div 18), 332 3 + 12 * (I mod 18 div 3), 13 + 16 * (I mod 3) + 48 * (I div 18), 333 11 + 12 * (I mod 18 div 3))); 334 Break; 339 335 end; 340 336 end; 341 i:= 30;337 I := 30; 342 338 for iix := 0 to nImp do 343 if ( c.Built[iix] > 0) and ((iix < nWonder) or (ImpPosition[iix] < 0)) then339 if (C.Built[iix] > 0) and ((iix < nWonder) or (ImpPosition[iix] < 0)) then 344 340 begin 345 FillRect(Rect(5 + 16 * ( i mod 3) + 48 * (idiv 18),346 3 + 12 * ( i mod 18 div 3), 13 + 16 * (i mod 3) + 48 * (idiv 18),347 11 + 12 * ( imod 18 div 3)));348 inc(i);349 if i= 36 then350 break; // area is full341 FillRect(Rect(5 + 16 * (I mod 3) + 48 * (I div 18), 342 3 + 12 * (I mod 18 div 3), 13 + 16 * (I mod 3) + 48 * (I div 18), 343 11 + 12 * (I mod 18 div 3))); 344 Inc(I); 345 if I = 36 then 346 Break; // area is full 351 347 end; 352 if c.Project and cpImp <> 0 then353 begin 354 iix := c.Project and cpIndex;348 if C.Project and cpImp <> 0 then 349 begin 350 iix := C.Project and cpIndex; 355 351 if iix <> imTrGoods then 356 352 begin 357 353 if (iix >= nWonder) and (ImpPosition[iix] >= 0) then 358 i:= ImpPosition[iix];359 if i< 36 then354 I := ImpPosition[iix]; 355 if I < 36 then 360 356 begin 361 brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImpProject];362 FillRect(Rect(5 + 16 * ( i mod 3) + 48 * (idiv 18),363 3 + 12 * ( i mod 18 div 3), 13 + 16 * (i mod 3) + 48 * (idiv 18),364 11 + 12 * ( imod 18 div 3)));357 Brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImpProject]; 358 FillRect(Rect(5 + 16 * (I mod 3) + 48 * (I div 18), 359 3 + 12 * (I mod 18 div 3), 13 + 16 * (I mod 3) + 48 * (I div 18), 360 11 + 12 * (I mod 18 div 3))); 365 361 end; 366 362 end; 367 363 end; 368 brush.style := bsClear;364 Brush.style := bsClear; 369 365 end; 370 366 end; … … 373 369 begin 374 370 UnshareBitmap(ZoomCityMap); 375 DpiBit Canvas(ZoomCityMap.Canvas, 0, 0, wZoomMap, hZoomMap,371 DpiBitBltCanvas(ZoomCityMap.Canvas, 0, 0, wZoomMap, hZoomMap, 376 372 Back.Canvas, xZoomMap, yZoomMap); 377 373 if SmallMapMode = smImprovements then begin … … 383 379 112 * (ZoomArea - 3), wZoomMap - wZoomEnvironment, hZoomMap); 384 380 ImageOp_B(ZoomCityMap, CityMapTemplate, wZoomMap - wZoomEnvironment, 0, 385 1504 + wZoomEnvironment * byte(IsPort), 112 * (ZoomArea - 3),381 1504 + wZoomEnvironment * Byte(IsPort), 112 * (ZoomArea - 3), 386 382 wZoomEnvironment, hZoomMap); 387 383 end; … … 391 387 procedure TCityDlg.OffscreenPaint; 392 388 393 procedure FillBar( x, y, pos, Growth, max, Kind: integer;394 IndicateComplete: boolean);389 procedure FillBar(X, Y, Pos, Growth, Max, Kind: Integer; 390 IndicateComplete: Boolean); 395 391 begin 396 392 BarTex.Assign(MainTexture); … … 399 395 BarTex.ColorBevelShade := BarTex.ColorBevelLight; 400 396 end; 401 PaintRelativeProgressBar( offscreen.Canvas, Kind, x - 3, y, wBar - 4, pos,402 Growth, max, IndicateComplete, BarTex);403 end; 404 405 procedure PaintResources( x, y, Loc: integer; Add4Happy: boolean);397 PaintRelativeProgressBar(Offscreen.Canvas, Kind, X - 3, Y, wBar - 4, Pos, 398 Growth, Max, IndicateComplete, BarTex); 399 end; 400 401 procedure PaintResources(X, Y, Loc: Integer; Add4Happy: Boolean); 406 402 var 407 d, i, Total, xGr, yGr: integer;403 D, I, Total, xGr, yGr: Integer; 408 404 TileInfo: TTileInfo; 409 rare: boolean;405 rare: Boolean; 410 406 begin 411 407 with AreaMap do begin 412 if Server(sGetCityTileInfo, me, Loc, TileInfo) <> eOk then413 begin 414 assert(cix < 0);415 exit408 if Server(sGetCityTileInfo, Me, Loc, TileInfo) <> eOk then 409 begin 410 Assert(cix < 0); 411 Exit 416 412 end; 417 413 Total := TileInfo.Food + TileInfo.Prod + TileInfo.Trade; 418 414 rare := MyMap[Loc] and $06000000 > 0; 419 415 if rare then 420 inc(Total);416 Inc(Total); 421 417 if Add4Happy then 422 inc(Total, 4);418 Inc(Total, 4); 423 419 if Total > 1 then 424 d:= (xxt - 11) div (Total - 1);425 if d< 1 then426 d:= 1;427 if d> 4 then428 d:= 4;429 for i:= 0 to Total - 1 do420 D := (xxt - 11) div (Total - 1); 421 if D < 1 then 422 D := 1; 423 if D > 4 then 424 D := 4; 425 for I := 0 to Total - 1 do 430 426 begin 431 427 yGr := 115; 432 if Add4Happy and ( i>= Total - 4) then428 if Add4Happy and (I >= Total - 4) then 433 429 begin 434 430 xGr := 132; 435 431 yGr := 126 436 432 end 437 else if rare and ( i= Total - 1) then433 else if rare and (I = Total - 1) then 438 434 xGr := 66 + 110 439 else if i>= TileInfo.Food + TileInfo.Prod then435 else if I >= TileInfo.Food + TileInfo.Prod then 440 436 xGr := 66 + 44 441 else if i>= TileInfo.Prod then437 else if I >= TileInfo.Prod then 442 438 xGr := 66 443 439 else 444 440 xGr := 66 + 22; 445 Sprite( offscreen, HGrSystem, x + xxt - 5 + d * (2 * i+ 1 - Total),446 y+ yyt - 5, 10, 10, xGr, yGr);441 Sprite(Offscreen, HGrSystem, X + xxt - 5 + D * (2 * I + 1 - Total), 442 Y + yyt - 5, 10, 10, xGr, yGr); 447 443 end; 448 444 end; 449 445 end; 450 446 var 451 line, MessageCount: integer;452 453 procedure CheckMessage(Flag: integer);447 Line, MessageCount: Integer; 448 449 procedure CheckMessage(Flag: Integer); 454 450 var 455 i, test: integer;456 s: string;451 I, Test: Integer; 452 S: string; 457 453 begin 458 454 if Happened and Flag <> 0 then 459 455 begin 460 i:= 0;461 test := 1;462 while test < Flag do456 I := 0; 457 Test := 1; 458 while Test < Flag do 463 459 begin 464 inc(i);465 inc(test, test)460 Inc(I); 461 Inc(Test, Test); 466 462 end; 467 463 468 464 if AllowChange and (Sounds <> nil) and (OpenSoundEvent = -1) then 469 465 begin 470 s := CityEventSoundItem[i];471 if s<> '' then472 s := Sounds.Lookup(s);473 if (Flag = chProduction) or ( s <> '') and (s[1] <> '*') and (s[1] <> '[')466 S := CityEventSoundItem[I]; 467 if S <> '' then 468 S := Sounds.Lookup(S); 469 if (Flag = chProduction) or (S <> '') and (S[1] <> '*') and (S[1] <> '[') 474 470 then 475 OpenSoundEvent := i471 OpenSoundEvent := I; 476 472 end; 477 473 478 s := CityEventName(i);474 S := CityEventName(I); 479 475 { if Flag=chNoGrowthWarning then 480 if c.Built[imAqueduct]=0 then481 s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])482 else s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); }483 RisedTextOut( offscreen.Canvas, xmOpt + 40, ymOpt - 1 - 8 * MessageCount +484 16 * line, s);485 inc(line)476 if C.Built[imAqueduct]=0 then 477 S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)]) 478 else S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); } 479 RisedTextOut(Offscreen.Canvas, xmOpt + 40, ymOpt - 1 - 8 * MessageCount + 480 16 * Line, S); 481 Inc(Line); 486 482 end; 487 483 end; 488 484 489 485 var 490 x, y, xGr, i, j, iix, d, dx, dy, PrCost, Cnt, Loc1, FreeSupp, Paintiix,491 HappyGain, OptiType, rx, ry, TrueFood, TrueProd, TruePoll: integer;492 av: integer;493 PrName, s: string;486 X, Y, xGr, I, J, iix, D, dx, dy, PrCost, Cnt, Loc1, FreeSupp, Paintiix, 487 HappyGain, OptiType, rx, ry, TrueFood, TrueProd, TruePoll: Integer; 488 av: Integer; 489 PrName, S: string; 494 490 UnitInfo: TUnitInfo; 495 491 UnitReport: TUnitReport; 496 IsCityAlive, CanGrow: boolean;492 IsCityAlive, CanGrow: Boolean; 497 493 begin 498 494 inherited; 499 495 if cix >= 0 then 500 c:= MyCity[cix];496 C := MyCity[cix]; 501 497 Report.HypoTiles := -1; 502 498 Report.HypoTaxRate := -1; 503 499 Report.HypoLuxuryRate := -1; 504 500 if cix >= 0 then 505 Server(sGetCityReportNew, me, cix, Report) // own city501 Server(sGetCityReportNew, Me, cix, Report) // own city 506 502 else 507 Server(sGetEnemyCityReportNew, me, cLoc, Report); // enemy city508 TrueFood := c.Food;509 TrueProd := c.Prod;510 TruePoll := c.Pollution;511 if supervising or (cix < 0) then503 Server(sGetEnemyCityReportNew, Me, cLoc, Report); // enemy city 504 TrueFood := C.Food; 505 TrueProd := C.Prod; 506 TruePoll := C.Pollution; 507 if Supervising or (cix < 0) then 512 508 begin // normalize city from after-turn state 513 dec(TrueFood, Report.FoodSurplus);509 Dec(TrueFood, Report.FoodSurplus); 514 510 if TrueFood < 0 then 515 511 TrueFood := 0; // shouldn't happen 516 dec(TrueProd, Report.Production);512 Dec(TrueProd, Report.Production); 517 513 if TrueProd < 0 then 518 514 TrueProd := 0; // shouldn't happen 519 dec(TruePoll, Report.AddPollution);515 Dec(TruePoll, Report.AddPollution); 520 516 if TruePoll < 0 then 521 517 TruePoll := 0; // shouldn't happen 522 518 end; 523 IsCityAlive := (cGov <> gAnarchy) and ( c.Flags and chCaptured = 0);519 IsCityAlive := (cGov <> gAnarchy) and (C.Flags and chCaptured = 0); 524 520 if not IsCityAlive then 525 Report.Working := c.Size;521 Report.Working := C.Size; 526 522 527 523 RedTex.Assign(MainTexture); … … 531 527 RedTex.ColorTextShade := $0000FF; 532 528 533 DpiBit Canvas(offscreen.Canvas, 0, 0, 640, 480, Back.Canvas, 0, 0);529 DpiBitBltCanvas(Offscreen.Canvas, 0, 0, 640, 480, Back.Canvas, 0, 0); 534 530 535 531 Offscreen.Canvas.Font.Assign(UniFont[ftCaption]); 536 RisedTextOut( offscreen.Canvas, 42, 7, Caption);537 with offscreen.Canvas do532 RisedTextOut(Offscreen.Canvas, 42, 7, Caption); 533 with Offscreen.Canvas do 538 534 begin // city size 539 brush.Color := $000000;535 Brush.Color := $000000; 540 536 FillRect(Rect(8 + 1, 7 + 1, 36 + 1, 32 + 1)); 541 brush.Color := $FFFFFF;537 Brush.Color := $FFFFFF; 542 538 FillRect(Rect(8, 7, 36, 32)); 543 brush.style := bsClear;539 Brush.style := bsClear; 544 540 Font.Color := $000000; 545 s := inttostr(c.Size);546 TextOut(8 + 14 - textwidth(s) div 2, 7, s);541 S := IntToStr(C.Size); 542 TextOut(8 + 14 - TextWidth(S) div 2, 7, S); 547 543 end; 548 544 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); … … 552 548 MakeRed(Offscreen, 18, 280, 298, 40); 553 549 if cGov = gAnarchy then 554 s:= Phrases.Lookup('GOVERNMENT', gAnarchy)550 S := Phrases.Lookup('GOVERNMENT', gAnarchy) 555 551 else { if c.Flags and chCaptured<>0 then } 556 s:= Phrases.Lookup('CITYEVENTS', 14);557 RisedTextOut( offscreen.Canvas, 167 - BiColorTextWidth(offscreen.Canvas, s)558 div 2, ymOpt - 9, s);552 S := Phrases.Lookup('CITYEVENTS', 14); 553 RisedTextOut(Offscreen.Canvas, 167 - BiColorTextWidth(Offscreen.Canvas, S) 554 div 2, ymOpt - 9, S); 559 555 end 560 556 else if AllowChange then 561 557 begin 562 OptiType := c.Status shr 4 and $0F;563 Sprite( offscreen, HGrSystem2, xmOpt - 32, ymOpt - 32, 64, 64,558 OptiType := C.Status shr 4 and $0F; 559 Sprite(Offscreen, HGrSystem2, xmOpt - 32, ymOpt - 32, 64, 64, 564 560 1 + OptiType mod 3 * 64, 217 + OptiType div 3 * 64); 565 561 566 562 { display messages now } 567 563 MessageCount := 0; 568 for i:= 0 to 31 do569 if Happened and ($FFFFFFFF - chCaptured) and (1 shl i) <> 0 then570 inc(MessageCount);564 for I := 0 to 31 do 565 if Happened and ($FFFFFFFF - chCaptured) and (1 shl I) <> 0 then 566 Inc(MessageCount); 571 567 if MessageCount > 3 then 572 568 MessageCount := 3; 573 569 if MessageCount > 0 then 574 570 begin 575 MakeBlue( offscreen, 74, 280, 242, 40);576 line := 0;577 for i:= 0 to nCityEventPriority - 1 do578 if line < MessageCount then579 CheckMessage(CityEventPriority[ i]);571 MakeBlue(Offscreen, 74, 280, 242, 40); 572 Line := 0; 573 for I := 0 to nCityEventPriority - 1 do 574 if Line < MessageCount then 575 CheckMessage(CityEventPriority[I]); 580 576 end 581 577 else 582 578 begin 583 s:= Phrases.Lookup('CITYMANAGETYPE', OptiType);584 j := pos('\', s);585 if j= 0 then586 LoweredTextout( offscreen.Canvas, -1, MainTexture, xmOpt + 40,587 ymOpt - 9, s)579 S := Phrases.Lookup('CITYMANAGETYPE', OptiType); 580 J := Pos('\', S); 581 if J = 0 then 582 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xmOpt + 40, 583 ymOpt - 9, S) 588 584 else 589 585 begin 590 LoweredTextout( offscreen.Canvas, -1, MainTexture, xmOpt + 40,591 ymOpt - 17, copy(s, 1, j- 1));592 LoweredTextout( offscreen.Canvas, -1, MainTexture, xmOpt + 40, ymOpt - 1,593 copy(s, j+ 1, 255));586 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xmOpt + 40, 587 ymOpt - 17, Copy(S, 1, J - 1)); 588 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xmOpt + 40, ymOpt - 1, 589 Copy(S, J + 1, 255)); 594 590 end; 595 591 end; … … 601 597 AreaMap.Paint(xmArea - xxt * 2 * rx, ymArea - yyt * 2 * ry - 3 * yyt, 602 598 dLoc(cLoc, -2 * rx + 1, -2 * ry - 1), 4 * rx - 1, 4 * ry + 1, cLoc, cOwner, 603 false, AllowChange and IsCityAlive and604 ( c.Status and csResourceWeightsMask = 0));605 DpiBit Canvas(offscreen.Canvas, xmArea + 102, 42, 90, 33, Back.Canvas,599 False, AllowChange and IsCityAlive and 600 (C.Status and csResourceWeightsMask = 0)); 601 DpiBitBltCanvas(Offscreen.Canvas, xmArea + 102, 42, 90, 33, Back.Canvas, 606 602 xmArea + 102, 42); 607 603 … … 615 611 ((Loc1 < 0) or (Loc1 >= G.lx * G.ly) or (MyMap[Loc1] and fCity = 0)) 616 612 then 617 Sprite( offscreen, HGrTerrain, xmArea - xxt + xxt * dx,613 Sprite(Offscreen, HGrTerrain, xmArea - xxt + xxt * dx, 618 614 ymArea - yyt + yyt * dy, xxt * 2, yyt * 2, 1 + 5 * (xxt * 2 + 1), 619 615 1 + yyt + 15 * (yyt * 3 + 1)); 620 if (1 shl ((dy + 3) shl 2 + (dx + 3) shr 1) and c.Tiles <> 0) then616 if (1 shl ((dy + 3) shl 2 + (dx + 3) shr 1) and C.Tiles <> 0) then 621 617 PaintResources(xmArea - xxt + xxt * dx, ymArea - yyt + yyt * dy, 622 618 Loc1, (dx = 0) and (dy = 0)); … … 625 621 626 622 if Report.Working > 1 then 627 d:= (xService - (xmArea - 192) - 8 - 32) div (Report.Working - 1);628 if d> 28 then629 d:= 28;630 for i:= Report.Working - 1 downto 0 do623 D := (xService - (xmArea - 192) - 8 - 32) div (Report.Working - 1); 624 if D > 28 then 625 D := 28; 626 for I := Report.Working - 1 downto 0 do 631 627 begin 632 628 if IsCityAlive then … … 634 630 else 635 631 xGr := 141; 636 DpiBit Canvas(offscreen.Canvas, xmArea - 192 + 5 + i * d, ymArea - 96 - 29,632 DpiBitBltCanvas(Offscreen.Canvas, xmArea - 192 + 5 + I * D, ymArea - 96 - 29, 637 633 27, 30, HGrSystem.Mask.Canvas, xGr, 171, SRCAND); { shadow } 638 Sprite( offscreen, HGrSystem, xmArea - 192 + 4 + i * d, ymArea - 96 - 30, 27,634 Sprite(Offscreen, HGrSystem, xmArea - 192 + 4 + I * D, ymArea - 96 - 30, 27, 639 635 30, xGr, 171); 640 636 end; 641 if c.Size - Report.Working > 1 then642 d := (xmArea + 192 - xService - 32) div (c.Size - Report.Working - 1);643 if d> 28 then644 d:= 28;645 for i := 0 to c.Size - Report.Working - 1 do637 if C.Size - Report.Working > 1 then 638 D := (xmArea + 192 - xService - 32) div (C.Size - Report.Working - 1); 639 if D > 28 then 640 D := 28; 641 for I := 0 to C.Size - Report.Working - 1 do 646 642 begin 647 643 xGr := 1 + 112; 648 DpiBit Canvas(offscreen.Canvas, xmArea + 192 - 27 + 1 - i * d, 29 + 1, 27,644 DpiBitBltCanvas(Offscreen.Canvas, xmArea + 192 - 27 + 1 - I * D, 29 + 1, 27, 649 645 30, HGrSystem.Mask.Canvas, xGr, 171, SRCAND); { shadow } 650 Sprite( offscreen, HGrSystem, xmArea + 192 - 27 - i * d, 29, 27, 30,646 Sprite(Offscreen, HGrSystem, xmArea + 192 - 27 - I * D, 29, 27, 30, 651 647 xGr, 171); 652 Sprite( offscreen, HGrSystem, xmArea + 192 - 27 + 4 - i * d, 29 + 32, 10,648 Sprite(Offscreen, HGrSystem, xmArea + 192 - 27 + 4 - I * D, 29 + 32, 10, 653 649 10, 121, 126); 654 Sprite( offscreen, HGrSystem, xmArea + 192 - 27 + 13 - i * d, 29 + 32, 10,650 Sprite(Offscreen, HGrSystem, xmArea + 192 - 27 + 13 - I * D, 29 + 32, 10, 655 651 10, 121, 126); 656 652 // Sprite(offscreen,HGrSystem,xmArea+192-31+18-i*d,ymArea-96-80+32,10,10,88,115); 657 653 end; 658 654 659 if c.Project and cpImp = 0 then660 PrName := Tribe[cOwner].ModelName[ c.Project and cpIndex]655 if C.Project and cpImp = 0 then 656 PrName := Tribe[cOwner].ModelName[C.Project and cpIndex] 661 657 else 662 PrName := Phrases.Lookup('IMPROVEMENTS', c.Project and cpIndex);658 PrName := Phrases.Lookup('IMPROVEMENTS', C.Project and cpIndex); 663 659 PrCost := Report.ProjectCost; 664 660 … … 667 663 begin 668 664 if cGov = gFundamentalism then 669 CountBar( offscreen, xHapp, yHapp + dyBar, wBar, 17,665 CountBar(Offscreen, xHapp, yHapp + dyBar, wBar, 17, 670 666 Phrases.Lookup('FAITH'), Report.CollectedControl, MainTexture) 671 667 else 672 668 begin 673 CountBar( offscreen, xHapp, yHapp + dyBar, wBar, 17,669 CountBar(Offscreen, xHapp, yHapp + dyBar, wBar, 17, 674 670 Phrases.Lookup('HAPPINESS'), Report.Morale, MainTexture); 675 CountBar( offscreen, xHapp, yHapp + 2 * dyBar, wBar, 16,671 CountBar(Offscreen, xHapp, yHapp + 2 * dyBar, wBar, 16, 676 672 Phrases.Lookup('CONTROL'), Report.CollectedControl, MainTexture); 677 673 end; 678 CountBar( offscreen, xHapp, yHapp, wBar, 8, Phrases.Lookup('LUX'),674 CountBar(Offscreen, xHapp, yHapp, wBar, 8, Phrases.Lookup('LUX'), 679 675 Report.Luxury, MainTexture); 680 CountBar( offscreen, xHapp + dxBar, yHapp, wBar, 19,676 CountBar(Offscreen, xHapp + dxBar, yHapp, wBar, 19, 681 677 Phrases.Lookup('UNREST'), 2 * Report.Deployed, MainTexture); 682 CountBar( offscreen, xHapp + dxBar, yHapp + dyBar, wBar, 17,683 Phrases.Lookup('HAPPINESSDEMAND'), c.Size, MainTexture);678 CountBar(Offscreen, xHapp + dxBar, yHapp + dyBar, wBar, 17, 679 Phrases.Lookup('HAPPINESSDEMAND'), C.Size, MainTexture); 684 680 if Report.HappinessBalance >= 0 then 685 CountBar( offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 17,681 CountBar(Offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 17, 686 682 Phrases.Lookup('HAPPINESSPLUS'), Report.HappinessBalance, MainTexture) 687 683 else 688 684 begin 689 685 MakeRed(Offscreen, xHapp + dxBar - 6, yHapp + 2 * dyBar, wBar + 10, 38); 690 CountBar( offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 18,686 CountBar(Offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 18, 691 687 Phrases.Lookup('LACK'), -Report.HappinessBalance, RedTex); 692 688 end; … … 696 692 if IsCityAlive then 697 693 begin 698 CountBar( offscreen, xFood, yFood + dyBar div 2, wBar, 0,694 CountBar(Offscreen, xFood, yFood + dyBar div 2, wBar, 0, 699 695 Phrases.Lookup('FOOD'), Report.CollectedFood, MainTexture); 700 CountBar( offscreen, xFood + dxBar, yFood + dyBar, wBar, 0,701 Phrases.Lookup('DEMAND'), 2 * c.Size, MainTexture);702 CountBar( offscreen, xFood + dxBar, yFood, wBar, 0,696 CountBar(Offscreen, xFood + dxBar, yFood + dyBar, wBar, 0, 697 Phrases.Lookup('DEMAND'), 2 * C.Size, MainTexture); 698 CountBar(Offscreen, xFood + dxBar, yFood, wBar, 0, 703 699 Phrases.Lookup('SUPPORT'), Report.FoodSupport, MainTexture); 704 700 if Report.FoodSurplus >= 0 then 705 if (cGov = gFuture) or ( c.Size >= NeedAqueductSize) and701 if (cGov = gFuture) or (C.Size >= NeedAqueductSize) and 706 702 (Report.FoodSurplus < 2) then 707 CountBar( offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 6,703 CountBar(Offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 6, 708 704 Phrases.Lookup('PROFIT'), Report.FoodSurplus, MainTexture) 709 705 else 710 CountBar( offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 0,706 CountBar(Offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 0, 711 707 Phrases.Lookup('SURPLUS'), Report.FoodSurplus, MainTexture) 712 708 else 713 709 begin 714 710 MakeRed(Offscreen, xFood + dxBar - 6, yFood + 2 * dyBar, wBar + 10, 38); 715 CountBar( offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 1,711 CountBar(Offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 1, 716 712 Phrases.Lookup('LACK'), -Report.FoodSurplus, RedTex); 717 713 end; 718 714 end; 719 CanGrow := ( c.Size < MaxCitySize) and (cGov <> gFuture) and720 (Report.FoodSurplus > 0) and (( c.Size < NeedAqueductSize) or721 ( c.Built[imAqueduct] = 1) and (c.Size < NeedSewerSize) or722 ( c.Built[imSewer] = 1));715 CanGrow := (C.Size < MaxCitySize) and (cGov <> gFuture) and 716 (Report.FoodSurplus > 0) and ((C.Size < NeedAqueductSize) or 717 (C.Built[imAqueduct] = 1) and (C.Size < NeedSewerSize) or 718 (C.Built[imSewer] = 1)); 723 719 FillBar(xFood + 3, yFood + 102, TrueFood, 724 CutCityFoodSurplus(Report.FoodSurplus, IsCityAlive, cGov, c.Size),720 CutCityFoodSurplus(Report.FoodSurplus, IsCityAlive, cGov, C.Size), 725 721 Report.Storage, 1, CanGrow); 726 LoweredTextout( offscreen.Canvas, -1, MainTexture, xFood + 3 - 5,722 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xFood + 3 - 5, 727 723 yFood + 102 - 20, Format('%d/%d', [TrueFood, Report.Storage])); 728 LoweredTextout( offscreen.Canvas, -1, MainTexture, xFood - 2, yFood + 66,724 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xFood - 2, yFood + 66, 729 725 Phrases.Lookup('STORAGE')); 730 726 … … 732 728 if IsCityAlive then 733 729 begin 734 CountBar( offscreen, xProd, yProd, wBar, 2, Phrases.Lookup('MATERIAL'),730 CountBar(Offscreen, xProd, yProd, wBar, 2, Phrases.Lookup('MATERIAL'), 735 731 Report.CollectedMaterial, MainTexture); 736 CountBar( offscreen, xProd + dxBar, yProd, wBar, 2,732 CountBar(Offscreen, xProd + dxBar, yProd, wBar, 2, 737 733 Phrases.Lookup('SUPPORT'), Report.MaterialSupport, MainTexture); 738 734 if Report.Production >= 0 then 739 if c.Project and (cpImp + cpIndex) = cpImp + imTrGoods then740 CountBar( offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 6,735 if C.Project and (cpImp + cpIndex) = cpImp + imTrGoods then 736 CountBar(Offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 6, 741 737 Phrases.Lookup('PROFIT'), Report.Production, MainTexture) 742 738 else 743 CountBar( offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 2,739 CountBar(Offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 2, 744 740 Phrases.Lookup('PROD'), Report.Production, MainTexture) 745 741 else 746 742 begin 747 743 MakeRed(Offscreen, xProd + dxBar - 6, yProd + dyBar + 17, wBar + 10, 38); 748 CountBar( offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 3,744 CountBar(Offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 3, 749 745 Phrases.Lookup('LACK'), -Report.Production, RedTex); 750 746 end; 751 747 end; 752 if c.Project and (cpImp + cpIndex) <> cpImp + imTrGoods then753 with offscreen.Canvas do754 begin 755 i:= Report.Production;756 if ( i< 0) or not IsCityAlive then757 i:= 0;758 FillBar(xProd + 3, yProd + 16 + 63, TrueProd, i, PrCost, 4, true);759 LoweredTextout( offscreen.Canvas, -1, MainTexture, xProd + 3 - 5,748 if C.Project and (cpImp + cpIndex) <> cpImp + imTrGoods then 749 with Offscreen.Canvas do 750 begin 751 I := Report.Production; 752 if (I < 0) or not IsCityAlive then 753 I := 0; 754 FillBar(xProd + 3, yProd + 16 + 63, TrueProd, I, PrCost, 4, True); 755 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xProd + 3 - 5, 760 756 yProd + 16 + 43, Format('%d/%d', [TrueProd, PrCost])); 761 if BiColorTextWidth( offscreen.Canvas, PrName) > wBar + dxBar then757 if BiColorTextWidth(Offscreen.Canvas, PrName) > wBar + dxBar then 762 758 begin 763 759 repeat 764 Delete(PrName, length(PrName), 1)765 until BiColorTextWidth( offscreen.Canvas, PrName) <= wBar + dxBar;760 Delete(PrName, Length(PrName), 1) 761 until BiColorTextWidth(Offscreen.Canvas, PrName) <= wBar + dxBar; 766 762 PrName := PrName + '.' 767 763 end; 768 764 end; 769 RisedTextOut( offscreen.Canvas, xProd - 2, yProd + 36, PrName);765 RisedTextOut(Offscreen.Canvas, xProd - 2, yProd + 36, PrName); 770 766 771 767 // pollution section … … 773 769 begin 774 770 FillBar(xPoll + 3, yPoll + 20, TruePoll, Report.AddPollution, 775 MaxPollution, 3, true);776 RisedTextOut( offscreen.Canvas, xPoll + 3 - 5, yPoll + 20 - 20,771 MaxPollution, 3, True); 772 RisedTextOut(Offscreen.Canvas, xPoll + 3 - 5, yPoll + 20 - 20, 777 773 Phrases.Lookup('POLL')); 778 774 end; … … 781 777 if IsCityAlive and (Report.CollectedTrade > 0) then 782 778 begin 783 CountBar( offscreen, xTrade, yTrade + dyBar div 2, wBar, 4,779 CountBar(Offscreen, xTrade, yTrade + dyBar div 2, wBar, 4, 784 780 Phrases.Lookup('TRADE'), Report.CollectedTrade, MainTexture); 785 CountBar( offscreen, xTrade + dxBar, yTrade + 2 * dyBar, wBar, 5,781 CountBar(Offscreen, xTrade + dxBar, yTrade + 2 * dyBar, wBar, 5, 786 782 Phrases.Lookup('CORR'), Report.Corruption, MainTexture); 787 CountBar( offscreen, xTrade + dxBar, yTrade, wBar, 6, Phrases.Lookup('TAX'),783 CountBar(Offscreen, xTrade + dxBar, yTrade, wBar, 6, Phrases.Lookup('TAX'), 788 784 Report.Tax, MainTexture); 789 CountBar( offscreen, xTrade + dxBar, yTrade + dyBar, wBar, 12,785 CountBar(Offscreen, xTrade + dxBar, yTrade + dyBar, wBar, 12, 790 786 Phrases.Lookup('SCIENCE'), Report.Science, MainTexture); 791 787 end; 792 788 793 789 // small map 794 DpiBit Canvas(offscreen.Canvas, xSmallMap, ySmallMap, wSmallMap, hSmallMap,790 DpiBitBltCanvas(Offscreen.Canvas, xSmallMap, ySmallMap, wSmallMap, hSmallMap, 795 791 SmallCityMap.Canvas, 0, 0); 796 792 if SmallMapMode = smImprovements then 797 Frame( offscreen.Canvas, xSmallMap + 48 * (ZoomArea div 3),793 Frame(Offscreen.Canvas, xSmallMap + 48 * (ZoomArea div 3), 798 794 ySmallMap + 24 * (ZoomArea mod 3), xSmallMap + 48 * (ZoomArea div 3) + 49, 799 795 ySmallMap + 24 * (ZoomArea mod 3) + 25, MainTexture.ColorMark, 800 796 MainTexture.ColorMark); 801 Frame( offscreen.Canvas, xSmallMap - 1, ySmallMap - 1, xSmallMap + wSmallMap,797 Frame(Offscreen.Canvas, xSmallMap - 1, ySmallMap - 1, xSmallMap + wSmallMap, 802 798 ySmallMap + hSmallMap, $B0B0B0, $FFFFFF); 803 RFrame( offscreen.Canvas, xSmallMap - 2, ySmallMap - 2, xSmallMap + wSmallMap +799 RFrame(Offscreen.Canvas, xSmallMap - 2, ySmallMap - 2, xSmallMap + wSmallMap + 804 800 1, ySmallMap + hSmallMap + 1, $FFFFFF, $B0B0B0); 805 801 806 Frame( offscreen.Canvas, xSupport - 1, ySupport - 1, xSupport + wSupport,802 Frame(Offscreen.Canvas, xSupport - 1, ySupport - 1, xSupport + wSupport, 807 803 ySupport + hSupport, $B0B0B0, $FFFFFF); 808 RFrame( offscreen.Canvas, xSupport - 2, ySupport - 2, xSupport + wSupport + 1,804 RFrame(Offscreen.Canvas, xSupport - 2, ySupport - 2, xSupport + wSupport + 1, 809 805 ySupport + hSupport + 1, $FFFFFF, $B0B0B0); 810 x:= xSupport + wSupport div 2;811 y:= ySupport + hSupport div 2;806 X := xSupport + wSupport div 2; 807 Y := ySupport + hSupport div 2; 812 808 if SmallMapMode = smSupportedUnits then 813 809 begin 814 offscreen.Canvas.brush.Color := MainTexture.ColorMark;815 offscreen.Canvas.FillRect(Rect(x - 27, y - 6, x + 27, y+ 6));816 offscreen.Canvas.brush.style := bsClear;817 end; 818 Sprite( offscreen, HGrSystem, x - 16, y- 5, 10, 10, 88, 115);819 Sprite( offscreen, HGrSystem, x - 5, y- 5, 10, 10, 66, 115);820 Sprite( offscreen, HGrSystem, x + 6, y- 5, 10, 10, 154, 126);821 822 DpiBit Canvas(offscreen.Canvas, xZoomMap, yZoomMap, wZoomMap, hZoomMap,810 Offscreen.Canvas.Brush.Color := MainTexture.ColorMark; 811 Offscreen.Canvas.FillRect(Rect(X - 27, Y - 6, X + 27, Y + 6)); 812 Offscreen.Canvas.Brush.style := bsClear; 813 end; 814 Sprite(Offscreen, HGrSystem, X - 16, Y - 5, 10, 10, 88, 115); 815 Sprite(Offscreen, HGrSystem, X - 5, Y - 5, 10, 10, 66, 115); 816 Sprite(Offscreen, HGrSystem, X + 6, Y - 5, 10, 10, 154, 126); 817 818 DpiBitBltCanvas(Offscreen.Canvas, xZoomMap, yZoomMap, wZoomMap, hZoomMap, 823 819 ZoomCityMap.Canvas, 0, 0); 824 820 825 for i:= 0 to 5 do826 imix[ i] := -1;821 for I := 0 to 5 do 822 imix[I] := -1; 827 823 if SmallMapMode = smImprovements then 828 824 begin … … 831 827 Cnt := 0; 832 828 for iix := 0 to nImp - 1 do 833 if ((iix < nWonder) or (ImpPosition[iix] < 0)) and ( c.Built[iix] > 0) then829 if ((iix < nWonder) or (ImpPosition[iix] < 0)) and (C.Built[iix] > 0) then 834 830 begin 835 i:= Cnt - Page * 6;836 if ( i >= 0) and (i< 6) then837 imix[ i] := iix;838 inc(Cnt);831 I := Cnt - Page * 6; 832 if (I >= 0) and (I < 6) then 833 imix[I] := iix; 834 Inc(Cnt); 839 835 end; 840 836 PageCount := (Cnt + 5) div 6; … … 844 840 for iix := nWonder to nImp - 1 do 845 841 begin 846 i:= ImpPosition[iix] - 6 * ZoomArea;847 if ( i >= 0) and (i < 6) and (c.Built[iix] > 0) then848 imix[ i] := iix;842 I := ImpPosition[iix] - 6 * ZoomArea; 843 if (I >= 0) and (I < 6) and (C.Built[iix] > 0) then 844 imix[I] := iix; 849 845 end; 850 846 PageCount := 0; 851 847 end; 852 for i:= 0 to 5 do853 if imix[ i] >= 0 then848 for I := 0 to 5 do 849 if imix[I] >= 0 then 854 850 begin 855 iix := imix[ i];856 x := xZoomMap + 14 + 72 * (imod 3);857 y := yZoomMap + 14 + 56 * (idiv 3);858 ImpImage( offscreen.Canvas, x, y, iix, cGov, AllowChange and851 iix := imix[I]; 852 X := xZoomMap + 14 + 72 * (I mod 3); 853 Y := yZoomMap + 14 + 56 * (I div 3); 854 ImpImage(Offscreen.Canvas, X, Y, iix, cGov, AllowChange and 859 855 (ClientMode < scContact)); 860 856 if IsCityAlive then … … 862 858 if iix = imColosseum then 863 859 begin 864 Sprite( offscreen, HGrSystem, x + 46, y, 14, 14, 82, 100);860 Sprite(Offscreen, HGrSystem, X + 46, Y, 14, 14, 82, 100); 865 861 end 866 862 else … … 880 876 if HappyGain > 1 then 881 877 begin 882 d:= 30 div (HappyGain - 1);883 if d> 10 then884 d:= 10878 D := 30 div (HappyGain - 1); 879 if D > 10 then 880 D := 10 885 881 end; 886 for j:= 0 to HappyGain - 1 do887 Sprite( offscreen, HGrSystem, x + 50, y + d * j, 10, 10, 132, 126);882 for J := 0 to HappyGain - 1 do 883 Sprite(Offscreen, HGrSystem, X + 50, Y + D * J, 10, 10, 132, 126); 888 884 end; 889 for j:= 0 to Imp[iix].Maint - 1 do890 Sprite( offscreen, HGrSystem, x - 4, y + 29 - 3 * j, 10, 10,885 for J := 0 to Imp[iix].Maint - 1 do 886 Sprite(Offscreen, HGrSystem, X - 4, Y + 29 - 3 * J, 10, 10, 891 887 132, 115); 892 888 end … … 919 915 else { if SmallMapMode = smSupportedUnits then } 920 916 begin 921 LoweredTextout( offscreen.Canvas, -1, MainTexture, xZoomMap + 6,917 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xZoomMap + 6, 922 918 yZoomMap + 2, Phrases.Lookup('SUPUNITS')); 923 FreeSupp := c.Size * SupportFree[cGov] shr 1;919 FreeSupp := C.Size * SupportFree[cGov] shr 1; 924 920 Cnt := 0; 925 for i:= 0 to MyRO.nUn - 1 do926 if (MyUn[ i].Loc >= 0) and (MyUn[i].Home = cix) then927 with MyModel[MyUn[ i].mix] do921 for I := 0 to MyRO.nUn - 1 do 922 if (MyUn[I].Loc >= 0) and (MyUn[I].Home = cix) then 923 with MyModel[MyUn[I].mix] do 928 924 begin 929 Server(sGetUnitReport, me, i, UnitReport);925 Server(sGetUnitReport, Me, I, UnitReport); 930 926 if (Cnt >= 6 * Page) and (Cnt < 6 * (Page + 1)) then 931 927 begin // unit visible in display 932 imix[Cnt - 6 * Page] := i;933 x:= ((Cnt - 6 * Page) mod 3) * 64 + xZoomMap;934 y:= ((Cnt - 6 * Page) div 3) * 52 + yZoomMap + 20;935 MakeUnitInfo( me, MyUn[i], UnitInfo);936 NoMap.SetOutput( offscreen);937 NoMap.PaintUnit( x, y, UnitInfo, MyUn[i].Status);938 939 for j:= 0 to UnitReport.FoodSupport - 1 do940 Sprite( offscreen, HGrSystem, x + 38 + 11 * j, y+ 40, 10,928 imix[Cnt - 6 * Page] := I; 929 X := ((Cnt - 6 * Page) mod 3) * 64 + xZoomMap; 930 Y := ((Cnt - 6 * Page) div 3) * 52 + yZoomMap + 20; 931 MakeUnitInfo(Me, MyUn[I], UnitInfo); 932 NoMap.SetOutput(Offscreen); 933 NoMap.PaintUnit(X, Y, UnitInfo, MyUn[I].Status); 934 935 for J := 0 to UnitReport.FoodSupport - 1 do 936 Sprite(Offscreen, HGrSystem, X + 38 + 11 * J, Y + 40, 10, 941 937 10, 66, 115); 942 for j:= 0 to UnitReport.ProdSupport - 1 do938 for J := 0 to UnitReport.ProdSupport - 1 do 943 939 begin 944 940 if (FreeSupp > 0) and 945 941 (UnitReport.ReportFlags and urfAlwaysSupport = 0) then 946 942 begin 947 Sprite( offscreen, HGrSystem, x + 16 - 11 * j, y+ 40, 10,943 Sprite(Offscreen, HGrSystem, X + 16 - 11 * J, Y + 40, 10, 948 944 10, 143, 115); 949 dec(FreeSupp);945 Dec(FreeSupp); 950 946 end 951 947 else 952 Sprite( offscreen, HGrSystem, x + 16 - 11 * j, y+ 40, 10,948 Sprite(Offscreen, HGrSystem, X + 16 - 11 * J, Y + 40, 10, 953 949 10, 88, 115); 954 950 end; 955 951 if UnitReport.ReportFlags and urfDeployed <> 0 then 956 for j:= 0 to 1 do957 Sprite( offscreen, HGrSystem, x + 27 + 11 * j, y+ 40, 10,952 for J := 0 to 1 do 953 Sprite(Offscreen, HGrSystem, X + 27 + 11 * J, Y + 40, 10, 958 954 10, 154, 126) 959 955 end // unit visible in display 960 956 else 961 dec(FreeSupp, UnitReport.ProdSupport);962 inc(Cnt);957 Dec(FreeSupp, UnitReport.ProdSupport); 958 Inc(Cnt); 963 959 end; 964 960 PageCount := (Cnt + 5) div 6; … … 973 969 PageDownBtn.Visible := PageCount > 1; 974 970 975 with offscreen.Canvas do971 with Offscreen.Canvas do 976 972 begin 977 973 { display project now } 978 DLine( offscreen.Canvas, xView + 9 + xSizeBig, xProd + 2 * wBar + 10,974 DLine(Offscreen.Canvas, xView + 9 + xSizeBig, xProd + 2 * wBar + 10, 979 975 yProd + dyBar + 16, $FFFFFF, $B0B0B0); 980 976 if ProdHint then 981 977 begin 982 ScreenTools.Frame( offscreen.Canvas, xView + 9 - 1, yView + 5 - 1,978 ScreenTools.Frame(Offscreen.Canvas, xView + 9 - 1, yView + 5 - 1, 983 979 xView + 9 + xSizeBig, yView + 5 + ySizeBig, $B0B0B0, $FFFFFF); 984 RFrame( offscreen.Canvas, xView + 9 - 2, yView + 5 - 2,980 RFrame(Offscreen.Canvas, xView + 9 - 2, yView + 5 - 2, 985 981 xView + 9 + xSizeBig + 1, yView + 5 + ySizeBig + 1, $FFFFFF, $B0B0B0); 986 with offscreen.Canvas do982 with Offscreen.Canvas do 987 983 begin 988 brush.Color := $000000;984 Brush.Color := $000000; 989 985 FillRect(Rect(xView + 9, yView + 5, xView + 1 + 72 - 8, 990 986 yView + 5 + 40)); 991 brush.style := bsClear;987 Brush.style := bsClear; 992 988 end; 993 989 end 994 else if AllowChange and ( c.Status and 7 <> 0) then990 else if AllowChange and (C.Status and 7 <> 0) then 995 991 begin // city type autobuild 996 FrameImage( offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig,997 ySizeBig, ( c.Status and 7 - 1 + 3) * xSizeBig, 0, (cix >= 0) and992 FrameImage(Offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig, 993 ySizeBig, (C.Status and 7 - 1 + 3) * xSizeBig, 0, (cix >= 0) and 998 994 (ClientMode < scContact)); 999 995 end 1000 else if c.Project and cpImp = 0 then996 else if C.Project and cpImp = 0 then 1001 997 begin // project is unit 1002 FrameImage( offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig,998 FrameImage(Offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig, 1003 999 ySizeBig, 0, 0, AllowChange and (ClientMode < scContact)); 1004 with Tribe[cOwner].ModelPicture[ c.Project and cpIndex] do1005 Sprite( offscreen, HGr, xView + 5, yView + 1, 64, 44,1000 with Tribe[cOwner].ModelPicture[C.Project and cpIndex] do 1001 Sprite(Offscreen, HGr, xView + 5, yView + 1, 64, 44, 1006 1002 pix mod 10 * 65 + 1, pix div 10 * 49 + 1); 1007 1003 end … … 1009 1005 begin // project is building 1010 1006 if ProdHint then 1011 Paintiix := c.Project0 and cpIndex1007 Paintiix := C.Project0 and cpIndex 1012 1008 else 1013 Paintiix := c.Project and cpIndex;1014 ImpImage( offscreen.Canvas, xView + 9, yView + 5, Paintiix, cGov,1009 Paintiix := C.Project and cpIndex; 1010 ImpImage(Offscreen.Canvas, xView + 9, yView + 5, Paintiix, cGov, 1015 1011 AllowChange and (ClientMode < scContact)); 1016 1012 end; … … 1019 1015 if AllowChange and (ClientMode < scContact) then 1020 1016 begin 1021 i := Server(sBuyCityProject - sExecute, me, cix, nil^);1022 BuyBtn.Visible := ( i = eOk) or (i= eViolation);1017 I := Server(sBuyCityProject - sExecute, Me, cix, nil^); 1018 BuyBtn.Visible := (I = eOk) or (I = eViolation); 1023 1019 end 1024 1020 else 1025 BuyBtn.Visible := false;1021 BuyBtn.Visible := False; 1026 1022 1027 1023 MarkUsedOffscreen(ClientWidth, ClientHeight); 1028 end; { OffscreenPaint }1024 end; 1029 1025 1030 1026 procedure TCityDlg.FormShow(Sender: TObject); 1031 1027 var 1032 dx, dy, Loc1: integer;1028 dx, dy, Loc1: Integer; 1033 1029 GetCityData: TGetCityData; 1034 1030 begin … … 1036 1032 if cix >= 0 then 1037 1033 begin { own city } 1038 c:= MyCity[cix];1039 cOwner := me;1034 C := MyCity[cix]; 1035 cOwner := Me; 1040 1036 cGov := MyRO.Government; 1041 1037 ProdHint := (cGov <> gAnarchy) and 1042 1038 (Happened and (chProduction or chFounded or chCaptured or 1043 1039 chAllImpsMade) <> 0); 1044 Server(sGetCityAreaInfo, me, cix, CityAreaInfo);1040 Server(sGetCityAreaInfo, Me, cix, CityAreaInfo); 1045 1041 NextCityBtn.Visible := WindowMode = wmPersistent; 1046 1042 PrevCityBtn.Visible := WindowMode = wmPersistent; … … 1049 1045 begin 1050 1046 SmallMapMode := smImprovements; 1051 Server(sGetCity, me, cLoc, GetCityData);1052 c := GetCityData.c;1047 Server(sGetCity, Me, cLoc, GetCityData); 1048 C := GetCityData.C; 1053 1049 cOwner := GetCityData.Owner; 1054 1050 cGov := MyRO.EnemyReport[cOwner].Government; 1055 Happened := c.Flags and $7FFFFFFF;1056 ProdHint := false;1057 Server(sGetEnemyCityAreaInfo, me, cLoc, CityAreaInfo);1058 1059 if c.Project and cpImp = 0 then1051 Happened := C.Flags and $7FFFFFFF; 1052 ProdHint := False; 1053 Server(sGetEnemyCityAreaInfo, Me, cLoc, CityAreaInfo); 1054 1055 if C.Project and cpImp = 0 then 1060 1056 begin 1061 1057 emix := MyRO.nEnemyModel - 1; 1062 1058 while (emix > 0) and ((MyRO.EnemyModel[emix].Owner <> cOwner) or 1063 ( integer(MyRO.EnemyModel[emix].mix) <> c.Project and cpIndex)) do1064 dec(emix);1065 if not Assigned(Tribe[cOwner].ModelPicture[ c.Project and cpIndex].HGr) then1059 (Integer(MyRO.EnemyModel[emix].mix) <> C.Project and cpIndex)) do 1060 Dec(emix); 1061 if not Assigned(Tribe[cOwner].ModelPicture[C.Project and cpIndex].HGr) then 1066 1062 InitEnemyModel(emix); 1067 1063 end; 1068 1064 1069 NextCityBtn.Visible := false;1070 PrevCityBtn.Visible := false;1065 NextCityBtn.Visible := False; 1066 PrevCityBtn.Visible := False; 1071 1067 end; 1072 1068 Page := 0; 1073 1069 1074 if c.Size < 5 then1070 if C.Size < 5 then 1075 1071 SizeClass := 0 1076 else if c.Size < 9 then1072 else if C.Size < 9 then 1077 1073 SizeClass := 1 1078 else if c.Size < 13 then1074 else if C.Size < 13 then 1079 1075 SizeClass := 2 1080 1076 else … … 1082 1078 1083 1079 // check if port 1084 IsPort := false;1080 IsPort := False; 1085 1081 for dx := -2 to 2 do 1086 1082 for dy := -2 to 2 do 1087 if abs(dx) + abs(dy) = 2 then1083 if Abs(dx) + Abs(dy) = 2 then 1088 1084 begin 1089 1085 Loc1 := dLoc(cLoc, dx, dy); 1090 1086 if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) and 1091 1087 (MyMap[Loc1] and fTerrain < fGrass) then 1092 IsPort := true;1088 IsPort := True; 1093 1089 end; 1094 1090 … … 1099 1095 end; 1100 1096 1101 Caption := CityName( c.ID);1097 Caption := CityName(C.ID); 1102 1098 1103 1099 InitSmallCityMap; … … 1105 1101 OpenSoundEvent := -1; 1106 1102 OffscreenPaint; 1107 Timer1.Enabled := true;1108 end; 1109 1110 procedure TCityDlg.ShowNewContent(NewMode , Loc: integer; ShowEvent: cardinal);1103 Timer1.Enabled := True; 1104 end; 1105 1106 procedure TCityDlg.ShowNewContent(NewMode: TWindowMode; Loc: Integer; ShowEvent: Cardinal); 1111 1107 begin 1112 1108 if MyMap[Loc] and fOwned <> 0 then … … 1114 1110 cix := MyRO.nCity - 1; 1115 1111 while (cix >= 0) and (MyCity[cix].Loc <> Loc) do 1116 dec(cix);1117 assert(cix >= 0);1112 Dec(cix); 1113 Assert(cix >= 0); 1118 1114 if (Optimize_cixTileChange >= 0) and 1119 1115 (Optimize_TilesBeforeChange and not MyCity[Optimize_cixTileChange].Tiles … … 1131 1127 else 1132 1128 cix := -1; 1133 AllowChange := not supervising and (cix >= 0);1129 AllowChange := not Supervising and (cix >= 0); 1134 1130 cLoc := Loc; 1135 1131 Happened := ShowEvent; … … 1138 1134 1139 1135 procedure TCityDlg.FormMouseDown(Sender: TObject; Button: TMouseButton; 1140 Shift: TShiftState; x, y: integer);1136 Shift: TShiftState; X, Y: Integer); 1141 1137 var 1142 i, qx, qy, dx, dy, fix, NewTiles, Loc1, iix, SellResult: integer;1143 Rebuild: boolean;1144 begin 1145 if (ssLeft in Shift) and ( x >= xSmallMap) and (x< xSmallMap + wSmallMap) and1146 ( y >= ySmallMap) and (y< ySmallMap + hSmallMap) then1138 I, qx, qy, dx, dy, fix, NewTiles, Loc1, iix, SellResult: Integer; 1139 Rebuild: Boolean; 1140 begin 1141 if (ssLeft in Shift) and (X >= xSmallMap) and (X < xSmallMap + wSmallMap) and 1142 (Y >= ySmallMap) and (Y < ySmallMap + hSmallMap) then 1147 1143 begin 1148 1144 SmallMapMode := smImprovements; 1149 ZoomArea := ( y- ySmallMap) * 3 div hSmallMap + 3 *1150 (( x- xSmallMap) * 2 div wSmallMap);1145 ZoomArea := (Y - ySmallMap) * 3 div hSmallMap + 3 * 1146 ((X - xSmallMap) * 2 div wSmallMap); 1151 1147 Page := 0; 1152 1148 InitZoomCityMap; 1153 1149 SmartUpdateContent; 1154 exit;1155 end; 1156 if (ssLeft in Shift) and ( x >= xSupport) and (x< xSupport + wSupport) and1157 ( y >= ySupport) and (y< ySupport + hSupport) then1150 Exit; 1151 end; 1152 if (ssLeft in Shift) and (X >= xSupport) and (X < xSupport + wSupport) and 1153 (Y >= ySupport) and (Y < ySupport + hSupport) then 1158 1154 begin 1159 1155 SmallMapMode := smSupportedUnits; … … 1161 1157 InitZoomCityMap; 1162 1158 SmartUpdateContent; 1163 exit;1159 Exit; 1164 1160 end; 1165 1161 if not AllowChange then 1166 exit; // not an own city1162 Exit; // Not an own city 1167 1163 1168 1164 if (ssLeft in Shift) then 1169 if (ClientMode < scContact) and ( x >= xView) and (y>= yView) and1170 ( x < xView + 73) and (y< yView + 50) then1165 if (ClientMode < scContact) and (X >= xView) and (Y >= yView) and 1166 (X < xView + 73) and (Y < yView + 50) then 1171 1167 if cGov = gAnarchy then 1172 with M essgExDlg do1168 with MainScreen.MessgExDlg do 1173 1169 begin 1174 1170 { MessgText:=Phrases.Lookup('OUTOFCONTROL'); 1175 if c.Project and cpImp=0 then1176 MessgText:=Format(MessgText,[Tribe[cOwner].ModelName[ c.Project and cpIndex]])1177 else MessgText:=Format(MessgText,[Phrases.Lookup('IMPROVEMENTS', c.Project and cpIndex)]); }1171 if C.Project and cpImp=0 then 1172 MessgText:=Format(MessgText,[Tribe[cOwner].ModelName[C.Project and cpIndex]]) 1173 else MessgText:=Format(MessgText,[Phrases.Lookup('IMPROVEMENTS',C.Project and cpIndex)]); } 1178 1174 MessgText := Phrases.Lookup('NOCHANGEINANARCHY'); 1179 1175 Kind := mkOk; … … 1184 1180 if ProdHint then 1185 1181 begin 1186 ProdHint := false;1182 ProdHint := False; 1187 1183 SmartUpdateContent 1188 1184 end; 1189 1185 ChooseProject; 1190 1186 end 1191 else if (SmallMapMode = smImprovements) and ( x >= xZoomMap) and (x< xZoomMap + wZoomMap) and1192 ( y >= yZoomMap) and (y< yZoomMap + hZoomMap) then1193 begin 1194 i:= 5;1195 while ( i >= 0) and not((x >= xZoomMap + 14 + 72 * (imod 3)) and1196 ( x < xZoomMap + 14 + 56 + 72 * (imod 3)) and1197 ( y >= yZoomMap + 14 + 56 * (idiv 3)) and1198 ( y < yZoomMap + 14 + 40 + 56 * (idiv 3))) do1199 dec(i);1200 if i>= 0 then1187 else if (SmallMapMode = smImprovements) and (X >= xZoomMap) and (X < xZoomMap + wZoomMap) and 1188 (Y >= yZoomMap) and (Y < yZoomMap + hZoomMap) then 1189 begin 1190 I := 5; 1191 while (I >= 0) and not((X >= xZoomMap + 14 + 72 * (I mod 3)) and 1192 (X < xZoomMap + 14 + 56 + 72 * (I mod 3)) and 1193 (Y >= yZoomMap + 14 + 56 * (I div 3)) and 1194 (Y < yZoomMap + 14 + 40 + 56 * (I div 3))) do 1195 Dec(I); 1196 if I >= 0 then 1201 1197 begin 1202 iix := imix[ i];1198 iix := imix[I]; 1203 1199 if iix >= 0 then 1204 1200 if ssShift in Shift then 1205 HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkImp, iix)1201 MainScreen.HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkImp, iix) 1206 1202 else if (ClientMode < scContact) then 1207 with M essgExDlg do1203 with MainScreen.MessgExDlg do 1208 1204 begin 1209 1205 IconKind := mikImp; … … 1220 1216 else 1221 1217 begin 1222 SellResult := Server(sSellCityImprovement - sExecute, me,1218 SellResult := Server(sSellCityImprovement - sExecute, Me, 1223 1219 cix, iix); 1224 1220 if SellResult < rExecuted then … … 1235 1231 else 1236 1232 begin 1237 if Server(sRebuildCityImprovement - sExecute, me, cix, iix) < rExecuted1233 if Server(sRebuildCityImprovement - sExecute, Me, cix, iix) < rExecuted 1238 1234 then 1239 1235 begin // no rebuild possible, ask for sell only 1240 Rebuild := false;1236 Rebuild := False; 1241 1237 MessgText := Phrases.Lookup('IMPROVEMENTS', iix); 1242 1238 if not Phrases2FallenBackToEnglish then 1243 1239 MessgText := Format(Phrases2.Lookup('SELL2'), 1244 1240 [MessgText, Imp[iix].Cost * BuildCostMod 1245 [G.Difficulty[ me]] div 12])1241 [G.Difficulty[Me]] div 12]) 1246 1242 else 1247 1243 MessgText := Format(Phrases.Lookup('SELL'), [MessgText]); 1248 1244 if iix = imSpacePort then 1249 with MyRO.Ship[ me] do1245 with MyRO.Ship[Me] do 1250 1246 if Parts[0] + Parts[1] + Parts[2] > 0 then 1251 1247 MessgText := MessgText + ' ' + … … 1258 1254 else 1259 1255 begin 1260 Rebuild := true;1256 Rebuild := True; 1261 1257 MessgText := Phrases.Lookup('IMPROVEMENTS', iix); 1262 1258 if not Phrases2FallenBackToEnglish then 1263 1259 MessgText := Format(Phrases2.Lookup('DISPOSE2'), 1264 1260 [MessgText, Imp[iix].Cost * BuildCostMod 1265 [G.Difficulty[ me]] div 12 * 2 div 3])1261 [G.Difficulty[Me]] div 12 * 2 div 3]) 1266 1262 else 1267 1263 MessgText := Format(Phrases.Lookup('DISPOSE'), 1268 1264 [MessgText]); 1269 1265 if iix = imSpacePort then 1270 with MyRO.Ship[ me] do1266 with MyRO.Ship[Me] do 1271 1267 if Parts[0] + Parts[1] + Parts[2] > 0 then 1272 1268 MessgText := MessgText + ' ' + … … 1282 1278 begin 1283 1279 Play('CITY_REBUILDIMP'); 1284 Server(sRebuildCityImprovement, me, cix, iix);1280 Server(sRebuildCityImprovement, Me, cix, iix); 1285 1281 end 1286 1282 else 1287 1283 begin 1288 1284 Play('CITY_SELLIMP'); 1289 Server(sSellCityImprovement, me, cix, iix);1285 Server(sSellCityImprovement, Me, cix, iix); 1290 1286 end; 1291 1287 CityOptimizer_CityChange(cix); … … 1300 1296 end; 1301 1297 end 1302 else if (SmallMapMode = smSupportedUnits) and ( x >= xZoomMap) and (x< xZoomMap + wZoomMap) and1303 ( y >= yZoomMap) and (y< yZoomMap + hZoomMap) then1304 begin 1305 i:= 5;1306 while ( i >= 0) and not((x >= xZoomMap + 64 * (imod 3)) and1307 ( x < xZoomMap + 64 + 64 * (imod 3)) and1308 ( y >= yZoomMap + 20 + 48 * (idiv 3)) and1309 ( y < yZoomMap + 20 + 52 + 48 * (idiv 3))) do1310 dec(i);1311 if ( i >= 0) and (imix[i] >= 0) then1298 else if (SmallMapMode = smSupportedUnits) and (X >= xZoomMap) and (X < xZoomMap + wZoomMap) and 1299 (Y >= yZoomMap) and (Y < yZoomMap + hZoomMap) then 1300 begin 1301 I := 5; 1302 while (I >= 0) and not((X >= xZoomMap + 64 * (I mod 3)) and 1303 (X < xZoomMap + 64 + 64 * (I mod 3)) and 1304 (Y >= yZoomMap + 20 + 48 * (I div 3)) and 1305 (Y < yZoomMap + 20 + 52 + 48 * (I div 3))) do 1306 Dec(I); 1307 if (I >= 0) and (imix[I] >= 0) then 1312 1308 if ssShift in Shift then 1313 1309 else if (cix >= 0) and (ClientMode < scContact) and … … 1316 1312 CloseAction := None; 1317 1313 Close; 1318 MainScreen.CityClosed(imix[ i], false, true);1314 MainScreen.CityClosed(imix[I], False, True); 1319 1315 end; 1320 1316 end 1321 else if ( x >= xmArea - 192) and (x < xmArea + 192) and (y>= ymArea - 96)1322 and ( y< ymArea + 96) then1317 else if (X >= xmArea - 192) and (X < xmArea + 192) and (Y >= ymArea - 96) 1318 and (Y < ymArea + 96) then 1323 1319 with AreaMap do begin 1324 qx := ((4000 * xxt * yyt) + ( x - xmArea) * (yyt * 2) + (y- ymArea + yyt)1320 qx := ((4000 * xxt * yyt) + (X - xmArea) * (yyt * 2) + (Y - ymArea + yyt) 1325 1321 * (xxt * 2)) div (xxt * yyt * 4) - 1000; 1326 qy := ((4000 * xxt * yyt) + ( y - ymArea + yyt) * (xxt * 2) - (x- xmArea)1322 qy := ((4000 * xxt * yyt) + (Y - ymArea + yyt) * (xxt * 2) - (X - xmArea) 1327 1323 * (yyt * 2)) div (xxt * yyt * 4) - 1000; 1328 1324 dx := qx - qy; … … 1334 1330 Loc1 := dLoc(cLoc, dx, dy); 1335 1331 if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) then 1336 HelpOnTerrain(Loc1, FWindowMode or wmPersistent)1332 HelpOnTerrain(Loc1, WindowModeMakePersistent(FWindowMode)) 1337 1333 end 1338 1334 else if (ClientMode < scContact) and (cGov <> gAnarchy) and 1339 ( c.Flags and chCaptured = 0) then1335 (C.Flags and chCaptured = 0) then 1340 1336 begin // toggle exploitation 1341 assert(not supervising);1342 if c.Status and csResourceWeightsMask <> 0 then1337 Assert(not Supervising); 1338 if C.Status and csResourceWeightsMask <> 0 then 1343 1339 begin 1344 with M essgExDlg do1340 with MainScreen.MessgExDlg do 1345 1341 begin 1346 1342 MessgText := Phrases.Lookup('CITYMANAGEOFF'); … … 1350 1346 ShowModal; 1351 1347 end; 1352 if M essgExDlg.ModalResult = mrOK then1348 if MainScreen.MessgExDlg.ModalResult = mrOK then 1353 1349 begin 1354 1350 MyCity[cix].Status := MyCity[cix].Status and 1355 1351 not csResourceWeightsMask; // off 1356 c.Status := MyCity[cix].Status;1352 C.Status := MyCity[cix].Status; 1357 1353 SmartUpdateContent; 1358 1354 end; 1359 exit;1355 Exit; 1360 1356 end; 1361 1357 fix := (dy + 3) shl 2 + (dx + 3) shr 1; 1362 1358 NewTiles := MyCity[cix].Tiles xor (1 shl fix); 1363 if Server(sSetCityTiles, me, cix, NewTiles) >= rExecuted then1359 if Server(sSetCityTiles, Me, cix, NewTiles) >= rExecuted then 1364 1360 begin 1365 1361 SmartUpdateContent; … … 1370 1366 end 1371 1367 else if (ClientMode < scContact) and (cGov <> gAnarchy) and 1372 ( c.Flags and chCaptured = 0) and (x >= xmOpt - 32) and (x< xmOpt + 32)1373 and ( y >= ymOpt - 32) and (y< ymOpt + 32) then1374 begin 1375 i := sqr(x - xmOpt) + sqr(y- ymOpt); // click radius1376 if i<= 32 * 32 then1368 (C.Flags and chCaptured = 0) and (X >= xmOpt - 32) and (X < xmOpt + 32) 1369 and (Y >= ymOpt - 32) and (Y < ymOpt + 32) then 1370 begin 1371 I := sqr(X - xmOpt) + sqr(Y - ymOpt); // click radius 1372 if I <= 32 * 32 then 1377 1373 begin 1378 if i< 16 * 16 then // inner area clicked1379 if c.Status and csResourceWeightsMask <> 0 then1380 i := (c.Status shr 4 and $0F) mod 5 + 1 // rotate except off1374 if I < 16 * 16 then // inner area clicked 1375 if C.Status and csResourceWeightsMask <> 0 then 1376 I := (C.Status shr 4 and $0F) mod 5 + 1 // rotate except off 1381 1377 else 1382 i:= 3 // rwGrowth1378 I := 3 // rwGrowth 1383 1379 else 1384 case trunc(arctan2( x - xmOpt, ymOpt - y) * 180 / pi) of1380 case trunc(arctan2(X - xmOpt, ymOpt - Y) * 180 / pi) of 1385 1381 - 25 - 52 * 2 .. -26 - 52: 1386 i:= 1;1382 I := 1; 1387 1383 -25 - 52 .. -26: 1388 i:= 2;1384 I := 2; 1389 1385 -25 .. 25: 1390 i:= 3;1386 I := 3; 1391 1387 26 .. 25 + 52: 1392 i:= 4;1388 I := 4; 1393 1389 26 + 52 .. 25 + 52 * 2: 1394 i:= 5;1390 I := 5; 1395 1391 180 - 26 .. 180, -180 .. -180 + 26: 1396 i:= 0;1392 I := 0; 1397 1393 else 1398 i:= -1;1394 I := -1; 1399 1395 end; 1400 if i>= 0 then1396 if I >= 0 then 1401 1397 begin 1402 ChangeResourceWeights( i);1398 ChangeResourceWeights(I); 1403 1399 SmartUpdateContent; 1404 1400 if WindowMode <> wmModal then … … 1407 1403 end; 1408 1404 end; 1409 end; { FormMouseDown }1405 end; 1410 1406 1411 1407 procedure TCityDlg.ChooseProject; … … 1422 1418 ); 1423 1419 1424 function ProjectType(Project: integer): TProjectType;1420 function ProjectType(Project: Integer): TProjectType; 1425 1421 begin 1426 1422 if Project and cpCompleted <> 0 then … … 1444 1440 1445 1441 var 1446 NewProject, OldMoney, cix1: integer;1442 NewProject, OldMoney, cix1: Integer; 1447 1443 pt0, pt1: TProjectType; 1448 QueryOk: boolean;1449 begin 1450 Assert(not supervising);1451 M odalSelectDlg.ShowNewContent_CityProject(wmModal, cix);1452 if M odalSelectDlg.result <> -1 then1453 begin 1454 if M odalSelectDlg.result and cpType <> 0 then1444 QueryOk: Boolean; 1445 begin 1446 Assert(not Supervising); 1447 MainScreen.ModalSelectDlg.ShowNewContent_CityProject(wmModal, cix); 1448 if MainScreen.ModalSelectDlg.Result <> -1 then 1449 begin 1450 if MainScreen.ModalSelectDlg.Result and cpType <> 0 then 1455 1451 begin 1456 1452 MyCity[cix].Status := MyCity[cix].Status and not 7 or 1457 (1 + M odalSelectDlg.result and cpIndex);1458 AutoBuild(cix, MyData.ImpOrder[M odalSelectDlg.result and cpIndex]);1453 (1 + MainScreen.ModalSelectDlg.Result and cpIndex); 1454 AutoBuild(cix, MyData.ImpOrder[MainScreen.ModalSelectDlg.Result and cpIndex]); 1459 1455 end 1460 1456 else 1461 1457 begin 1462 NewProject := M odalSelectDlg.Result;1458 NewProject := MainScreen.ModalSelectDlg.Result; 1463 1459 QueryOk := True; 1464 1460 if (NewProject and cpImp <> 0) and (NewProject and cpIndex >= 28) and 1465 1461 (MyRO.NatBuilt[NewProject and cpIndex] > 0) then 1466 with M essgExDlg do1462 with MainScreen.MessgExDlg do 1467 1463 begin 1468 1464 cix1 := MyRO.nCity - 1; … … 1521 1517 then 1522 1518 NewProject := NewProject or cpDisbandCity; 1523 Server(sSetCityProject, me, cix, NewProject);1524 c.Project := MyCity[cix].Project;1519 Server(sSetCityProject, Me, cix, NewProject); 1520 C.Project := MyCity[cix].Project; 1525 1521 if MyRO.Money > OldMoney then 1526 1522 Play('CITY_SELLIMP'); … … 1537 1533 procedure TCityDlg.BuyClick(Sender: TObject); 1538 1534 var 1539 NextProd, Cost: integer;1535 NextProd, Cost: Integer; 1540 1536 begin 1541 1537 if (cix < 0) or (ClientMode >= scContact) then 1542 exit;1543 with MyCity[cix], M essgExDlg do1538 Exit; 1539 with MyCity[cix], MainScreen.MessgExDlg do 1544 1540 begin 1545 1541 Cost := Report.ProjectCost; … … 1548 1544 NextProd := 0; 1549 1545 Cost := Cost - Prod - NextProd; 1550 if (MyRO.Wonder[woMich].EffectiveOwner = me) and (Project and cpImp <> 0)1546 if (MyRO.Wonder[woMich].EffectiveOwner = Me) and (Project and cpImp <> 0) 1551 1547 then 1552 1548 Cost := Cost * 2 … … 1572 1568 if (Kind = mkYesNo) and (ModalResult = mrOK) then 1573 1569 begin 1574 if Server(sBuyCityProject, me, cix, nil^) >= rExecuted then1570 if Server(sBuyCityProject, Me, cix, nil^) >= rExecuted then 1575 1571 begin 1576 1572 Play('CITY_BUYPROJECT'); … … 1585 1581 procedure TCityDlg.FormClose(Sender: TObject; var Action: TCloseAction); 1586 1582 begin 1587 Timer1.Enabled := false;1588 ProdHint := false;1583 Timer1.Enabled := False; 1584 ProdHint := False; 1589 1585 MarkCityLoc := -1; 1590 1586 if Optimize_cixTileChange >= 0 then … … 1615 1611 with Canvas do 1616 1612 begin 1617 DpiBit Canvas(Canvas, xView + 5, yView + 1, 64, 2, Back.Canvas,1613 DpiBitBltCanvas(Canvas, xView + 5, yView + 1, 64, 2, Back.Canvas, 1618 1614 xView + 5, yView + 1); 1619 DpiBit Canvas(Canvas, xView + 5, yView + 3, 2, 42, Back.Canvas,1615 DpiBitBltCanvas(Canvas, xView + 5, yView + 3, 2, 42, Back.Canvas, 1620 1616 xView + 5, yView + 3); 1621 DpiBit Canvas(Canvas, xView + 5 + 62, yView + 3, 2, 42,1617 DpiBitBltCanvas(Canvas, xView + 5 + 62, yView + 3, 2, 42, 1622 1618 Back.Canvas, xView + 5 + 62, yView + 3); 1623 1619 ScreenTools.Frame(Canvas, xView + 9 - 1, yView + 5 - 1, xView + 9 + xSizeBig, … … 1632 1628 else if BlinkTime = 6 then 1633 1629 begin 1634 if AllowChange and ( c.Status and 7 <> 0) then1630 if AllowChange and (C.Status and 7 <> 0) then 1635 1631 begin // city type autobuild 1636 1632 FrameImage(Canvas, bigimp, xView + 9, yView + 5, xSizeBig, ySizeBig, 1637 ( c.Status and 7 - 1 + 3) * xSizeBig, 0, true);1633 (C.Status and 7 - 1 + 3) * xSizeBig, 0, True); 1638 1634 end 1639 else if c.Project and cpImp = 0 then1635 else if C.Project and cpImp = 0 then 1640 1636 begin // project is unit 1641 DpiBit Canvas(Canvas, xView + 9, yView + 5, xSizeBig, ySizeBig,1637 DpiBitBltCanvas(Canvas, xView + 9, yView + 5, xSizeBig, ySizeBig, 1642 1638 Bigimp.Canvas, 0, 0); 1643 with Tribe[cOwner].ModelPicture[ c.Project and cpIndex] do1639 with Tribe[cOwner].ModelPicture[C.Project and cpIndex] do 1644 1640 Sprite(Canvas, HGr, xView + 5, yView + 1, 64, 44, pix mod 10 * 65 + 1, 1645 1641 pix div 10 * 49 + 1); 1646 1642 end 1647 1643 else 1648 ImpImage(Canvas, xView + 9, yView + 5, c.Project0 and cpIndex,1649 cGov, true);1644 ImpImage(Canvas, xView + 9, yView + 5, C.Project0 and cpIndex, 1645 cGov, True); 1650 1646 end; 1651 1647 end; … … 1663 1659 if 1 shl OpenSoundEvent = chProduction then 1664 1660 begin 1665 if c.Project0 and cpImp <> 0 then1666 begin 1667 if c.Project0 and cpIndex >= 28 then1661 if C.Project0 and cpImp <> 0 then 1662 begin 1663 if C.Project0 and cpIndex >= 28 then 1668 1664 // wonders have already extra message with sound 1669 if Imp[ c.Project0 and cpIndex].Kind = ikShipPart then1665 if Imp[C.Project0 and cpIndex].Kind = ikShipPart then 1670 1666 Play('SHIP_BUILT') 1671 1667 else … … 1681 1677 end; 1682 1678 1683 function Prio(iix: integer): integer;1679 function Prio(iix: Integer): Integer; 1684 1680 begin 1685 1681 case Imp[iix].Kind of 1686 1682 ikWonder: 1687 result := iix + 10000;1683 Result := iix + 10000; 1688 1684 ikNatLocal, ikNatGlobal: 1689 1685 case iix of 1690 1686 imPalace: 1691 result := 0;1687 Result := 0; 1692 1688 else 1693 result := iix + 20000;1689 Result := iix + 20000; 1694 1690 end; 1695 1691 else 1696 1692 case iix of 1697 1693 imTownHall, imCourt: 1698 result := iix + 30000;1694 Result := iix + 30000; 1699 1695 imAqueduct, imSewer: 1700 result := iix + 40000;1696 Result := iix + 40000; 1701 1697 imTemple, imTheater, imCathedral: 1702 result := iix + 50000;1703 else 1704 result := iix + 90000;1698 Result := iix + 50000; 1699 else 1700 Result := iix + 90000; 1705 1701 end; 1706 1702 end; … … 1717 1713 end; 1718 1714 1719 procedure TCityDlg.ChangeCity( d: integer);1715 procedure TCityDlg.ChangeCity(D: Integer); 1720 1716 var 1721 cixNew: integer;1717 cixNew: Integer; 1722 1718 begin 1723 1719 cixNew := cix; 1724 1720 repeat 1725 cixNew := (cixNew + MyRO.nCity + d) mod MyRO.nCity;1721 cixNew := (cixNew + MyRO.nCity + D) mod MyRO.nCity; 1726 1722 until (MyCity[cixNew].Loc >= 0) or (cixNew = cix); 1727 1723 if cixNew <> cix then … … 1742 1738 end; 1743 1739 1744 { procedure TCityDlg.AdviceBtnClick(Sender: TObject);1745 begin1746 AdvisorDlg.GiveCityAdvice(cix);1747 end; }1748 1749 1740 procedure TCityDlg.PageUpBtnClick(Sender: TObject); 1750 1741 begin 1751 1742 if Page > 0 then 1752 1743 begin 1753 dec(Page);1744 Dec(Page); 1754 1745 SmartUpdateContent; 1755 1746 end; … … 1760 1751 if Page < PageCount - 1 then 1761 1752 begin 1762 inc(Page);1753 Inc(Page); 1763 1754 SmartUpdateContent; 1764 1755 end; 1765 1756 end; 1766 1757 1767 procedure TCityDlg.ChangeResourceWeights(iResourceWeights: integer);1758 procedure TCityDlg.ChangeResourceWeights(iResourceWeights: Integer); 1768 1759 var 1769 1760 Advice: TCityTileAdviceData; 1770 1761 begin 1771 assert(not supervising);1772 assert(cix >= 0);1762 Assert(not Supervising); 1763 Assert(cix >= 0); 1773 1764 MyCity[cix].Status := MyCity[cix].Status and not csResourceWeightsMask or 1774 1765 (iResourceWeights shl 4); 1775 c.Status := MyCity[cix].Status;1766 C.Status := MyCity[cix].Status; 1776 1767 if iResourceWeights > 0 then 1777 1768 begin 1778 1769 Advice.ResourceWeights := OfferedResourceWeights[iResourceWeights]; 1779 Server(sGetCityTileAdvice, me, cix, Advice);1770 Server(sGetCityTileAdvice, Me, cix, Advice); 1780 1771 if Advice.Tiles <> MyCity[cix].Tiles then 1781 Server(sSetCityTiles, me, cix, Advice.Tiles);1772 Server(sSetCityTiles, Me, cix, Advice.Tiles); 1782 1773 end; 1783 1774 end; … … 1785 1776 procedure SortImprovements; 1786 1777 var 1787 i, j, k: integer;1788 begin 1789 for i:= 0 to nImp - 1 do1790 ImpSorted[ i] := i;1791 for i:= 0 to nImp - 2 do1792 for j := i+ 1 to nImp - 1 do1793 if Prio(ImpSorted[ i]) > Prio(ImpSorted[j]) then begin1794 k := ImpSorted[i];1795 ImpSorted[ i] := ImpSorted[j];1796 ImpSorted[ j] := k;1778 I, J, K: Integer; 1779 begin 1780 for I := 0 to nImp - 1 do 1781 ImpSorted[I] := I; 1782 for I := 0 to nImp - 2 do 1783 for J := I + 1 to nImp - 1 do 1784 if Prio(ImpSorted[I]) > Prio(ImpSorted[J]) then begin 1785 K := ImpSorted[I]; 1786 ImpSorted[I] := ImpSorted[J]; 1787 ImpSorted[J] := K; 1797 1788 end; 1798 1789 end; -
TabularUnified branches/highdpi/LocalPlayer/CityType.pas ¶
r361 r465 5 5 6 6 uses 7 UDpiControls, Protocol, ClientTools, Term, ScreenTools, BaseWin, LCLIntf, LCLType, 8 SysUtils, Classes, Graphics, Controls, Forms, 9 ButtonB, ExtCtrls; 7 UDpiControls, Protocol, ClientTools, ScreenTools, BaseWin, LCLIntf, LCLType, 8 SysUtils, Classes, Graphics, Controls, Forms, ButtonB, ExtCtrls; 10 9 11 10 type … … 18 17 procedure FormShow(Sender: TObject); 19 18 procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 20 Shift: TShiftState; x, y: integer);19 Shift: TShiftState; X, Y: Integer); 21 20 procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton; 22 Shift: TShiftState; x, y: integer);21 Shift: TShiftState; X, Y: Integer); 23 22 procedure FormClose(Sender: TObject; var Action: TCloseAction); 24 23 procedure DeleteBtnClick(Sender: TObject); 25 24 public 26 procedure ShowNewContent(NewMode: integer);25 procedure ShowNewContent(NewMode: TWindowMode); 27 26 protected 28 27 procedure OffscreenPaint; override; 29 28 private 30 nPool, dragiix, ctype: integer;31 Pooliix: array [0 .. nImp - 1] of integer;29 nPool, dragiix, ctype: Integer; 30 Pooliix: array [0 .. nImp - 1] of Integer; 32 31 listed: Set of 0 .. nImp; 33 Changed: boolean;34 procedure LoadType(NewType: integer);32 Changed: Boolean; 33 procedure LoadType(NewType: Integer); 35 34 procedure SaveType; 36 35 end; 37 36 38 var39 CityTypeDlg: TCityTypeDlg;40 37 41 38 implementation 42 39 43 uses Help; 40 uses 41 Help, Term; 44 42 45 43 {$R *.lfm} … … 82 80 procedure TCityTypeDlg.OffscreenPaint; 83 81 var 84 i, iix: integer;85 s: string;82 I, iix: Integer; 83 S: string; 86 84 begin 87 85 inherited; 88 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);86 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 89 87 FillOffscreen(xList - 7, yList, 42 * nListCol + 14, 32 * nListRow); 90 88 FillOffscreen(xPool - 7, yPool, 42 * nPoolCol + 14, 32 * nPoolRow); … … 92 90 yPool - yList - 32 * nListRow); 93 91 94 Frame( offscreen.Canvas, 0, yList + 32 * nListRow, InnerWidth - 255,92 Frame(Offscreen.Canvas, 0, yList + 32 * nListRow, InnerWidth - 255, 95 93 yPool - 23, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 96 Frame( offscreen.Canvas, InnerWidth - 254, yList + 32 * nListRow,94 Frame(Offscreen.Canvas, InnerWidth - 254, yList + 32 * nListRow, 97 95 InnerWidth - 89, yPool - 23, MainTexture.ColorBevelLight, 98 96 MainTexture.ColorBevelShade); 99 Frame( offscreen.Canvas, InnerWidth - 88, yList + 32 * nListRow,97 Frame(Offscreen.Canvas, InnerWidth - 88, yList + 32 * nListRow, 100 98 InnerWidth - 1, yPool - 23, MainTexture.ColorBevelLight, 101 99 MainTexture.ColorBevelShade); 102 Frame( offscreen.Canvas, 0, yPool - 22, InnerWidth - 1, yPool - 1,100 Frame(Offscreen.Canvas, 0, yPool - 22, InnerWidth - 1, yPool - 1, 103 101 MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 104 for i:= 0 to nCityType - 1 do105 begin 106 RFrame( offscreen.Canvas, xSwitch + i * 42, ySwitch, xSwitch + 39 + i* 42,102 for I := 0 to nCityType - 1 do 103 begin 104 RFrame(Offscreen.Canvas, xSwitch + I * 42, ySwitch, xSwitch + 39 + I * 42, 107 105 ySwitch + 23, MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 108 if i= ctype then109 Frame( offscreen.Canvas, xSwitch + 1 + i* 42, ySwitch + 1,110 xSwitch + 38 + i* 42, ySwitch + 22, MainTexture.ColorBevelShade,106 if I = ctype then 107 Frame(Offscreen.Canvas, xSwitch + 1 + I * 42, ySwitch + 1, 108 xSwitch + 38 + I * 42, ySwitch + 22, MainTexture.ColorBevelShade, 111 109 MainTexture.ColorBevelLight) 112 110 else 113 Frame( offscreen.Canvas, xSwitch + 1 + i* 42, ySwitch + 1,114 xSwitch + 38 + i* 42, ySwitch + 22, MainTexture.ColorBevelLight,111 Frame(Offscreen.Canvas, xSwitch + 1 + I * 42, ySwitch + 1, 112 xSwitch + 38 + I * 42, ySwitch + 22, MainTexture.ColorBevelLight, 115 113 MainTexture.ColorBevelShade); 116 DpiBit Canvas(offscreen.Canvas, xSwitch + 2 + i* 42, ySwitch + 2,117 xSizeSmall, ySizeSmall, SmallImp.Canvas, ( i+ 3) * xSizeSmall, 0);118 end; 119 RisedTextOut( offscreen.Canvas, 8, yList + 32 * nListRow + 2,114 DpiBitBltCanvas(Offscreen.Canvas, xSwitch + 2 + I * 42, ySwitch + 2, 115 xSizeSmall, ySizeSmall, SmallImp.Canvas, (I + 3) * xSizeSmall, 0); 116 end; 117 RisedTextOut(Offscreen.Canvas, 8, yList + 32 * nListRow + 2, 120 118 Phrases.Lookup('BUILDORDER')); 121 RisedTextOut( offscreen.Canvas, 8, ySwitch + 26,119 RisedTextOut(Offscreen.Canvas, 8, ySwitch + 26, 122 120 Phrases.Lookup('CITYTYPE', ctype)); 123 s:= Phrases.Lookup('BUILDREST');124 RisedTextOut( offscreen.Canvas,125 (InnerWidth - BiColorTextWidth( offscreen.Canvas, s)) div 2,126 yList + 72 + 32 * nListRow, s);127 128 with offscreen.Canvas do129 begin 130 for i:= 1 to nListRow - 1 do131 DLine( offscreen.Canvas, xList - 5, xList + 4 + 42 * nListCol,132 yList - 1 + 32 * i, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);133 for i:= 0 to nListCol * nListRow - 1 do134 begin 135 s := IntToStr(i+ 1);121 S := Phrases.Lookup('BUILDREST'); 122 RisedTextOut(Offscreen.Canvas, 123 (InnerWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2, 124 yList + 72 + 32 * nListRow, S); 125 126 with Offscreen.Canvas do 127 begin 128 for I := 1 to nListRow - 1 do 129 DLine(Offscreen.Canvas, xList - 5, xList + 4 + 42 * nListCol, 130 yList - 1 + 32 * I, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 131 for I := 0 to nListCol * nListRow - 1 do 132 begin 133 S := IntToStr(I + 1); 136 134 Font.Color := MainTexture.ColorTextLight; 137 Textout(xList + 20 + i mod nListCol * 42 - TextWidth(s) div 2,138 yList + 15 + i div nListCol * 32 - TextHeight(s) div 2, s);139 end; 140 end; 141 142 i:= 0;143 while MyData.ImpOrder[ctype, i] >= 0 do144 begin 145 RFrame( offscreen.Canvas, xList + 20 - xSizeSmall div 2 + imod nListCol *146 42, yList + 15 - ySizeSmall div 2 + idiv nListCol * 32,147 xList + 21 + xSizeSmall div 2 + imod nListCol * 42,148 yList + 16 + ySizeSmall div 2 + idiv nListCol * 32,135 Textout(xList + 20 + I mod nListCol * 42 - TextWidth(S) div 2, 136 yList + 15 + I div nListCol * 32 - TextHeight(S) div 2, S); 137 end; 138 end; 139 140 I := 0; 141 while MyData.ImpOrder[ctype, I] >= 0 do 142 begin 143 RFrame(Offscreen.Canvas, xList + 20 - xSizeSmall div 2 + I mod nListCol * 144 42, yList + 15 - ySizeSmall div 2 + I div nListCol * 32, 145 xList + 21 + xSizeSmall div 2 + I mod nListCol * 42, 146 yList + 16 + ySizeSmall div 2 + I div nListCol * 32, 149 147 MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 150 DpiBit Canvas(offscreen.Canvas, xList + 21 - xSizeSmall div 2 +151 i mod nListCol * 42, yList + 16 - ySizeSmall div 2 + idiv nListCol * 32,148 DpiBitBltCanvas(Offscreen.Canvas, xList + 21 - xSizeSmall div 2 + 149 I mod nListCol * 42, yList + 16 - ySizeSmall div 2 + I div nListCol * 32, 152 150 xSizeSmall, ySizeSmall, SmallImp.Canvas, 153 MyData.ImpOrder[ctype, i] mod 7 * xSizeSmall,154 (MyData.ImpOrder[ctype, i] + SystemIconLines * 7) div 7 *151 MyData.ImpOrder[ctype, I] mod 7 * xSizeSmall, 152 (MyData.ImpOrder[ctype, I] + SystemIconLines * 7) div 7 * 155 153 ySizeSmall); 156 inc(i);154 Inc(I); 157 155 end; 158 156 … … 165 163 begin 166 164 Pooliix[nPool] := iix; 167 RFrame( offscreen.Canvas, xPool + 20 - xSizeSmall div 2 +165 RFrame(Offscreen.Canvas, xPool + 20 - xSizeSmall div 2 + 168 166 nPool mod nPoolCol * 42, yPool + 15 - ySizeSmall div 2 + 169 167 nPool div nPoolCol * 32, xPool + 21 + xSizeSmall div 2 + … … 171 169 nPool div nPoolCol * 32, MainTexture.ColorBevelLight, 172 170 MainTexture.ColorBevelShade); 173 DpiBit Canvas(offscreen.Canvas, xPool + 21 - xSizeSmall div 2 +171 DpiBitBltCanvas(Offscreen.Canvas, xPool + 21 - xSizeSmall div 2 + 174 172 nPool mod nPoolCol * 42, yPool + 16 - ySizeSmall div 2 + 175 173 nPool div nPoolCol * 32, xSizeSmall, ySizeSmall, SmallImp.Canvas, 176 174 iix mod 7 * xSizeSmall, (iix + SystemIconLines * 7) div 7 * 177 175 ySizeSmall); 178 inc(nPool);176 Inc(nPool); 179 177 end; 180 178 DeleteBtn.Visible := MyData.ImpOrder[ctype, 0] >= 0; … … 182 180 if dragiix >= 0 then 183 181 begin 184 ImpImage( offscreen.Canvas, xView + 9, yView + 5, dragiix);185 s:= Phrases.Lookup('IMPROVEMENTS', dragiix);186 RisedTextOut( offscreen.Canvas,187 xView + 36 - BiColorTextWidth( offscreen.Canvas, s) div 2,188 ySwitch + 26, s);182 ImpImage(Offscreen.Canvas, xView + 9, yView + 5, dragiix); 183 S := Phrases.Lookup('IMPROVEMENTS', dragiix); 184 RisedTextOut(Offscreen.Canvas, 185 xView + 36 - BiColorTextWidth(Offscreen.Canvas, S) div 2, 186 ySwitch + 26, S); 189 187 end; 190 188 MarkUsedOffscreen(InnerWidth, InnerHeight); 191 end; { MainPaint }192 193 procedure TCityTypeDlg.LoadType(NewType: integer);194 var 195 i: integer;189 end; 190 191 procedure TCityTypeDlg.LoadType(NewType: Integer); 192 var 193 I: Integer; 196 194 begin 197 195 ctype := NewType; 198 196 listed := []; 199 i:= 0;200 while MyData.ImpOrder[ctype, i] >= 0 do201 begin 202 include(listed, MyData.ImpOrder[ctype, i]);203 inc(i);204 end; 205 Changed := false;197 I := 0; 198 while MyData.ImpOrder[ctype, I] >= 0 do 199 begin 200 Include(listed, MyData.ImpOrder[ctype, I]); 201 Inc(I); 202 end; 203 Changed := False; 206 204 end; 207 205 208 206 procedure TCityTypeDlg.SaveType; 209 207 var 210 cix: integer;208 cix: Integer; 211 209 begin 212 210 if Changed then … … 215 213 if (MyCity[cix].Loc >= 0) and (MyCity[cix].Status and 7 = ctype + 1) then 216 214 AutoBuild(cix, MyData.ImpOrder[ctype]); 217 Changed := false;215 Changed := False; 218 216 end; 219 217 end; … … 226 224 end; 227 225 228 procedure TCityTypeDlg.ShowNewContent(NewMode: integer);226 procedure TCityTypeDlg.ShowNewContent(NewMode: TWindowMode); 229 227 begin 230 228 inherited ShowNewContent(NewMode); … … 232 230 233 231 procedure TCityTypeDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 234 Shift: TShiftState; x, y: integer);235 var 236 i: integer;237 begin 238 x := x- SideFrame;239 y := y- WideFrame;240 i := (x - xList) div 42 + (y- yList) div 32 * nListCol;241 if ( i < nImp) and (MyData.ImpOrder[ctype, i] >= 0) and242 ( x > xList + 2 + imod nListCol * 42) and243 ( y > yList + 5 + idiv nListCol * 32) and244 ( x < xList + 3 + 36 + imod nListCol * 42) and245 ( y < yList + 6 + 20 + idiv nListCol * 32) then232 Shift: TShiftState; X, Y: Integer); 233 var 234 I: Integer; 235 begin 236 X := X - SideFrame; 237 Y := Y - WideFrame; 238 I := (X - xList) div 42 + (Y - yList) div 32 * nListCol; 239 if (I < nImp) and (MyData.ImpOrder[ctype, I] >= 0) and 240 (X > xList + 2 + I mod nListCol * 42) and 241 (Y > yList + 5 + I div nListCol * 32) and 242 (X < xList + 3 + 36 + I mod nListCol * 42) and 243 (Y < yList + 6 + 20 + I div nListCol * 32) then 246 244 begin 247 245 if ssShift in Shift then 248 HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkImp,249 MyData.ImpOrder[ctype, i])246 MainScreen.HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkImp, 247 MyData.ImpOrder[ctype, I]) 250 248 else 251 249 begin 252 dragiix := MyData.ImpOrder[ctype, i];250 dragiix := MyData.ImpOrder[ctype, I]; 253 251 DpiScreen.Cursor := crImpDrag; 254 252 SmartUpdateContent; 255 253 end; 256 exit;257 end; 258 i := (x - xPool) div 42 + (y- yPool) div 32 * nPoolCol;259 if ( i < nPool) and (x > xPool + 2 + imod nPoolCol * 42) and260 ( y > yPool + 5 + idiv nPoolCol * 32) and261 ( x < xPool + 3 + 36 + imod nPoolCol * 42) and262 ( y < yPool + 6 + 20 + idiv nPoolCol * 32) then254 Exit; 255 end; 256 I := (X - xPool) div 42 + (Y - yPool) div 32 * nPoolCol; 257 if (I < nPool) and (X > xPool + 2 + I mod nPoolCol * 42) and 258 (Y > yPool + 5 + I div nPoolCol * 32) and 259 (X < xPool + 3 + 36 + I mod nPoolCol * 42) and 260 (Y < yPool + 6 + 20 + I div nPoolCol * 32) then 263 261 begin 264 262 if ssShift in Shift then 265 HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkImp, Pooliix[i])263 MainScreen.HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkImp, Pooliix[I]) 266 264 else 267 265 begin 268 dragiix := Pooliix[ i];266 dragiix := Pooliix[I]; 269 267 DpiScreen.Cursor := crImpDrag; 270 268 SmartUpdateContent; 271 269 end; 272 exit;273 end; 274 i := (x- xSwitch) div 42;275 if ( i < nCityType) and (x > xSwitch + 2 + i* 42) and276 ( x < xSwitch + 3 + 36 + i * 42) and (y >= ySwitch + 2) and (y< ySwitch + 22)270 Exit; 271 end; 272 I := (X - xSwitch) div 42; 273 if (I < nCityType) and (X > xSwitch + 2 + I * 42) and 274 (X < xSwitch + 3 + 36 + I * 42) and (Y >= ySwitch + 2) and (Y < ySwitch + 22) 277 275 then 278 276 begin 279 277 SaveType; 280 LoadType( i);278 LoadType(I); 281 279 SmartUpdateContent; 282 280 end; … … 284 282 285 283 procedure TCityTypeDlg.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton; 286 Shift: TShiftState; x, y: integer);287 288 procedure UnList(iix: integer);284 Shift: TShiftState; X, Y: Integer); 285 286 procedure UnList(iix: Integer); 289 287 var 290 i: integer;291 begin 292 i:= 0;293 while (MyData.ImpOrder[ctype, i] >= 0) and294 (MyData.ImpOrder[ctype, i] <> iix) do295 inc(i);296 assert(MyData.ImpOrder[ctype, i] = iix);297 move(MyData.ImpOrder[ctype, i + 1], MyData.ImpOrder[ctype, i], nImp - i);288 I: Integer; 289 begin 290 I := 0; 291 while (MyData.ImpOrder[ctype, I] >= 0) and 292 (MyData.ImpOrder[ctype, I] <> iix) do 293 Inc(I); 294 Assert(MyData.ImpOrder[ctype, I] = iix); 295 Move(MyData.ImpOrder[ctype, I + 1], MyData.ImpOrder[ctype, I], nImp - I); 298 296 Exclude(listed, iix); 299 297 end; 300 298 301 299 var 302 i: integer;303 begin 304 x := x- SideFrame;305 y := y- WideFrame;300 I: Integer; 301 begin 302 X := X - SideFrame; 303 Y := Y - WideFrame; 306 304 if dragiix >= 0 then 307 305 begin 308 if ( x >= xList) and (x < xList + nListCol * 42) and (y>= yList) and309 ( y< yList + nListRow * 32) then306 if (X >= xList) and (X < xList + nListCol * 42) and (Y >= yList) and 307 (Y < yList + nListRow * 32) then 310 308 begin 311 309 if dragiix in listed then 312 310 UnList(dragiix); 313 i := (x - xList) div 42 + (y- yList) div 32 * nListCol;314 while ( i > 0) and (MyData.ImpOrder[ctype, i- 1] < 0) do315 dec(i);316 move(MyData.ImpOrder[ctype, i], MyData.ImpOrder[ctype, i+ 1],317 nImp - i- 1);318 MyData.ImpOrder[ctype, i] := dragiix;319 include(listed, dragiix);320 Changed := true;311 I := (X - xList) div 42 + (Y - yList) div 32 * nListCol; 312 while (I > 0) and (MyData.ImpOrder[ctype, I - 1] < 0) do 313 Dec(I); 314 Move(MyData.ImpOrder[ctype, I], MyData.ImpOrder[ctype, I + 1], 315 nImp - I - 1); 316 MyData.ImpOrder[ctype, I] := dragiix; 317 Include(listed, dragiix); 318 Changed := True; 321 319 end 322 else if (dragiix in listed) and ( x >= xPool) and (x< xPool + nPoolCol * 42)323 and ( y >= yPool) and (y< yPool + nPoolRow * 32) then320 else if (dragiix in listed) and (X >= xPool) and (X < xPool + nPoolCol * 42) 321 and (Y >= yPool) and (Y < yPool + nPoolRow * 32) then 324 322 begin 325 323 UnList(dragiix); 326 Changed := true;324 Changed := True; 327 325 end; 328 326 dragiix := -1; … … 340 338 procedure TCityTypeDlg.DeleteBtnClick(Sender: TObject); 341 339 begin 342 fillchar(MyData.ImpOrder[ctype], sizeof(MyData.ImpOrder[ctype]), Byte(-1));340 FillChar(MyData.ImpOrder[ctype], SizeOf(MyData.ImpOrder[ctype]), Byte(-1)); 343 341 listed := []; 344 Changed := true;342 Changed := True; 345 343 SmartUpdateContent; 346 344 end; -
TabularUnified branches/highdpi/LocalPlayer/ClientTools.pas ¶
r405 r465 9 9 const 10 10 nOfferedResourceWeights = 6; 11 OfferedResourceWeights: array [0 .. nOfferedResourceWeights - 1] of cardinal =11 OfferedResourceWeights: array [0 .. nOfferedResourceWeights - 1] of Cardinal = 12 12 (rwOff, rwMaxScience, rwForceScience, rwMaxGrowth, rwForceProd, rwMaxProd); 13 13 14 14 type 15 TImpOrder = array [0 .. (nImp + 4) div 4 * 4 - 1] of shortint;16 TEnhancementJobs = array [0 .. 11, 0 .. 7] of byte;15 TImpOrder = array [0 .. (nImp + 4) div 4 * 4 - 1] of ShortInt; 16 TEnhancementJobs = array [0 .. 11, 0 .. 7] of Byte; 17 17 JobResultSet = set of 0 .. 39; 18 18 … … 36 36 Server: TServerCall; 37 37 G: TNewGameData; 38 me: integer;38 Me: Integer; 39 39 MyRO: ^TPlayerContext; 40 40 MyMap: ^TTileList; … … 43 43 MyModel: ^TModelList; 44 44 45 AdvValue: array [0 .. nAdv - 1] of integer;46 47 function dLoc(Loc, dx, dy: integer): integer;48 function Distance(Loc0, Loc1: integer): integer;49 function UnrestAtLoc(uix, Loc: integer): boolean;50 function GetMoveAdvice(uix, ToLoc: integer;51 var MoveAdviceData: TMoveAdviceData): integer;52 function ColorOfHealth(Health: integer): integer;53 function IsMultiPlayerGame: boolean;54 procedure ItsMeAgain( p: integer);55 function GetAge( p: integer): integer;56 function IsCivilReportNew(Enemy: integer): boolean;57 function IsMilReportNew(Enemy: integer): boolean;58 function CutCityFoodSurplus(FoodSurplus: integer; IsCityAlive: boolean;59 gov, size: integer): integer;60 function CityTaxBalance(cix: integer; const CityReport: TCityReportNew): integer;61 procedure SumCities(var TaxSum, ScienceSum: integer);62 function JobTest(uix, Job: integer; IgnoreResults: JobResultSet = []): boolean;63 procedure GetUnitInfo(Loc: integer; var uix: integer; var UnitInfo: TUnitInfo);64 procedure GetCityInfo(Loc: integer; var cix: integer; var CityInfo: TCityInfo);65 function UnitExhausted(uix: integer): boolean;66 function ModelHash(const ModelInfo: TModelInfo): integer;67 function ProcessEnhancement(uix: integer; const Jobs: TEnhancementJobs): integer;68 function AutoBuild(cix: integer; const ImpOrder: TImpOrder): boolean;69 procedure DebugMessage(Level: integer; Text: string);45 AdvValue: array [0 .. nAdv - 1] of Integer; 46 47 function dLoc(Loc, dx, dy: Integer): Integer; 48 function Distance(Loc0, Loc1: Integer): Integer; 49 function UnrestAtLoc(uix, Loc: Integer): Boolean; 50 function GetMoveAdvice(uix, ToLoc: Integer; 51 var MoveAdviceData: TMoveAdviceData): Integer; 52 function ColorOfHealth(Health: Integer): Integer; 53 function IsMultiPlayerGame: Boolean; 54 procedure ItsMeAgain(P: Integer); 55 function GetAge(P: Integer): Integer; 56 function IsCivilReportNew(Enemy: Integer): Boolean; 57 function IsMilReportNew(Enemy: Integer): Boolean; 58 function CutCityFoodSurplus(FoodSurplus: Integer; IsCityAlive: Boolean; 59 gov, size: Integer): Integer; 60 function CityTaxBalance(cix: Integer; const CityReport: TCityReportNew): Integer; 61 procedure SumCities(var TaxSum, ScienceSum: Integer); 62 function JobTest(uix, Job: Integer; IgnoreResults: JobResultSet = []): Boolean; 63 procedure GetUnitInfo(Loc: Integer; var uix: Integer; var UnitInfo: TUnitInfo); 64 procedure GetCityInfo(Loc: Integer; var cix: Integer; var CityInfo: TCityInfo); 65 function UnitExhausted(uix: Integer): Boolean; 66 function ModelHash(const ModelInfo: TModelInfo): Integer; 67 function ProcessEnhancement(uix: Integer; const Jobs: TEnhancementJobs): Integer; 68 function AutoBuild(cix: Integer; const ImpOrder: TImpOrder): Boolean; 69 procedure DebugMessage(Level: Integer; Text: string); 70 70 procedure CityOptimizer_BeginOfTurn; 71 procedure CityOptimizer_CityChange(cix: integer);72 procedure CityOptimizer_TileBecomesAvailable(Loc: integer);73 procedure CityOptimizer_ReleaseCityTiles(cix, ReleasedTiles: integer);74 procedure CityOptimizer_BeforeRemoveUnit(uix: integer);71 procedure CityOptimizer_CityChange(cix: Integer); 72 procedure CityOptimizer_TileBecomesAvailable(Loc: Integer); 73 procedure CityOptimizer_ReleaseCityTiles(cix, ReleasedTiles: Integer); 74 procedure CityOptimizer_BeforeRemoveUnit(uix: Integer); 75 75 procedure CityOptimizer_AfterRemoveUnit; 76 76 procedure CityOptimizer_EndOfTurn; … … 84 84 85 85 var 86 CityNeedsOptimize: array [0 .. ncmax - 1] of boolean;87 88 function dLoc(Loc, dx, dy: integer): integer;89 var 90 y0: integer;86 CityNeedsOptimize: array [0 .. ncmax - 1] of Boolean; 87 88 function dLoc(Loc, dx, dy: Integer): Integer; 89 var 90 y0: Integer; 91 91 begin 92 92 y0 := (Loc + G.lx * 1024) div G.lx - 1024; … … 94 94 end; 95 95 96 function Distance(Loc0, Loc1: integer): integer;97 var 98 dx, dy: integer;96 function Distance(Loc0, Loc1: Integer): Integer; 97 var 98 dx, dy: Integer; 99 99 begin 100 100 Inc(Loc0, G.lx * 1024); … … 106 106 end; 107 107 108 function UnrestAtLoc(uix, Loc: integer): boolean;109 var 110 uix1: integer;108 function UnrestAtLoc(uix, Loc: Integer): Boolean; 109 var 110 uix1: Integer; 111 111 begin 112 112 Result := False; … … 114 114 case MyRO.Government of 115 115 gRepublic, gFuture: 116 Result := (MyRO.Territory[Loc] >= 0) and (MyRO.Territory[Loc] <> me) and116 Result := (MyRO.Territory[Loc] >= 0) and (MyRO.Territory[Loc] <> Me) and 117 117 (MyRO.Treaty[MyRO.Territory[Loc]] < trAlliance); 118 118 gDemocracy: 119 Result := (MyRO.Territory[Loc] < 0) or (MyRO.Territory[Loc] <> me) and119 Result := (MyRO.Territory[Loc] < 0) or (MyRO.Territory[Loc] <> Me) and 120 120 (MyRO.Treaty[MyRO.Territory[Loc]] < trAlliance); 121 121 end; … … 127 127 end; 128 128 129 function GetMoveAdvice(uix, ToLoc: integer;130 var MoveAdviceData: TMoveAdviceData): integer;131 var 132 MinEndHealth: integer;129 function GetMoveAdvice(uix, ToLoc: Integer; 130 var MoveAdviceData: TMoveAdviceData): Integer; 131 var 132 MinEndHealth: Integer; 133 133 begin 134 134 if MyModel[MyUn[uix].mix].Domain = dGround then … … 142 142 MoveAdviceData.MoreTurns := 999; 143 143 MoveAdviceData.MaxHostile_MovementLeft := MyUn[uix].Health - MinEndHealth; 144 Result := Server(sGetMoveAdvice, me, uix, MoveAdviceData);144 Result := Server(sGetMoveAdvice, Me, uix, MoveAdviceData); 145 145 if (MinEndHealth <= 1) or (Result <> eNoWay) then 146 exit;146 Exit; 147 147 end; 148 148 case MinEndHealth of … … 159 159 end; 160 160 161 function ColorOfHealth(Health: integer): integer;162 var 163 red, green: integer;164 begin 165 green := 400 * Health div 100;166 if green > 200 then167 green := 200;168 red := 510 * (100 - Health) div 100;169 if red > 255 then170 red := 255;171 Result := green shl 8 + red;172 end; 173 174 function IsMultiPlayerGame: boolean;175 var 176 p1: integer;161 function ColorOfHealth(Health: Integer): Integer; 162 var 163 Red, Green: Integer; 164 begin 165 Green := 400 * Health div 100; 166 if Green > 200 then 167 Green := 200; 168 Red := 510 * (100 - Health) div 100; 169 if Red > 255 then 170 Red := 255; 171 Result := Green shl 8 + Red; 172 end; 173 174 function IsMultiPlayerGame: Boolean; 175 var 176 p1: Integer; 177 177 begin 178 178 Result := False; … … 182 182 end; 183 183 184 procedure ItsMeAgain( p: integer);185 begin 186 if G.RO[ p] <> nil then187 MyRO := pointer(G.RO[p])188 else if G.SuperVisorRO[ p] <> nil then189 MyRO := pointer(G.SuperVisorRO[p])184 procedure ItsMeAgain(P: Integer); 185 begin 186 if G.RO[P] <> nil then 187 MyRO := Pointer(G.RO[P]) 188 else if G.SuperVisorRO[P] <> nil then 189 MyRO := Pointer(G.SuperVisorRO[P]) 190 190 else 191 exit;192 me := p;193 MyMap := pointer(MyRO.Map);194 MyUn := pointer(MyRO.Un);195 MyCity := pointer(MyRO.City);196 MyModel := pointer(MyRO.Model);197 end; 198 199 function GetAge( p: integer): integer;200 var 201 i: integer;202 begin 203 if p = me then begin191 Exit; 192 Me := P; 193 MyMap := Pointer(MyRO.Map); 194 MyUn := Pointer(MyRO.Un); 195 MyCity := Pointer(MyRO.City); 196 MyModel := Pointer(MyRO.Model); 197 end; 198 199 function GetAge(P: Integer): Integer; 200 var 201 I: Integer; 202 begin 203 if P = Me then begin 204 204 Result := 0; 205 for i:= 1 to 3 do206 if MyRO.Tech[AgePreq[ i]] >= tsApplicable then207 Result := i;205 for I := 1 to 3 do 206 if MyRO.Tech[AgePreq[I]] >= tsApplicable then 207 Result := I; 208 208 end else begin 209 209 Result := 0; 210 for i:= 1 to 3 do211 if MyRO.EnemyReport[ p].Tech[AgePreq[i]] >= tsApplicable then212 Result := i;213 end; 214 end; 215 216 function IsCivilReportNew(Enemy: integer): boolean;217 var 218 i: integer;219 begin 220 assert(Enemy <> me);221 i:= MyRO.EnemyReport[Enemy].TurnOfCivilReport;222 Result := ( i = MyRO.Turn) or (i = MyRO.Turn - 1) and (Enemy > me);223 end; 224 225 function IsMilReportNew(Enemy: integer): boolean;226 var 227 i: integer;228 begin 229 assert(Enemy <> me);230 i:= MyRO.EnemyReport[Enemy].TurnOfMilReport;231 Result := ( i = MyRO.Turn) or (i = MyRO.Turn - 1) and (Enemy > me);232 end; 233 234 function CutCityFoodSurplus(FoodSurplus: integer; IsCityAlive: boolean;235 gov, size: integer): integer;210 for I := 1 to 3 do 211 if MyRO.EnemyReport[P].Tech[AgePreq[I]] >= tsApplicable then 212 Result := I; 213 end; 214 end; 215 216 function IsCivilReportNew(Enemy: Integer): Boolean; 217 var 218 I: Integer; 219 begin 220 Assert(Enemy <> Me); 221 I := MyRO.EnemyReport[Enemy].TurnOfCivilReport; 222 Result := (I = MyRO.Turn) or (I = MyRO.Turn - 1) and (Enemy > Me); 223 end; 224 225 function IsMilReportNew(Enemy: Integer): Boolean; 226 var 227 I: Integer; 228 begin 229 Assert(Enemy <> Me); 230 I := MyRO.EnemyReport[Enemy].TurnOfMilReport; 231 Result := (I = MyRO.Turn) or (I = MyRO.Turn - 1) and (Enemy > Me); 232 end; 233 234 function CutCityFoodSurplus(FoodSurplus: Integer; IsCityAlive: Boolean; 235 gov, size: Integer): Integer; 236 236 begin 237 237 Result := FoodSurplus; … … 241 241 end; 242 242 243 function CityTaxBalance(cix: integer; const CityReport: TCityReportNew): integer;244 var 245 i: integer;243 function CityTaxBalance(cix: Integer; const CityReport: TCityReportNew): Integer; 244 var 245 I: Integer; 246 246 begin 247 247 Result := 0; … … 258 258 Inc(Result, CityReport.FoodSurplus); 259 259 end; 260 for i:= nWonder to nImp - 1 do261 if MyCity[cix].Built[ i] > 0 then262 Dec(Result, Imp[ i].Maint);263 end; 264 265 procedure SumCities(var TaxSum, ScienceSum: integer);266 var 267 cix: integer;260 for I := nWonder to nImp - 1 do 261 if MyCity[cix].Built[I] > 0 then 262 Dec(Result, Imp[I].Maint); 263 end; 264 265 procedure SumCities(var TaxSum, ScienceSum: Integer); 266 var 267 cix: Integer; 268 268 CityReport: TCityReportNew; 269 269 begin … … 271 271 ScienceSum := 0; 272 272 if MyRO.Government = gAnarchy then 273 exit;273 Exit; 274 274 for cix := 0 to MyRO.nCity - 1 do 275 275 if MyCity[cix].Loc >= 0 then … … 278 278 CityReport.HypoTaxRate := -1; 279 279 CityReport.HypoLuxuryRate := -1; 280 Server(sGetCityReportNew, me, cix, CityReport);280 Server(sGetCityReportNew, Me, cix, CityReport); 281 281 if (CityReport.HappinessBalance >= 0) { no disorder } and 282 282 (MyCity[cix].Flags and chCaptured = 0) then // not captured … … 286 286 end; 287 287 288 function JobTest(uix, Job: integer; IgnoreResults: JobResultSet): boolean;289 var 290 Test: integer;291 begin 292 Test := Server(sStartJob + Job shl 4 - sExecute, me, uix, nil^);288 function JobTest(uix, Job: Integer; IgnoreResults: JobResultSet): Boolean; 289 var 290 Test: Integer; 291 begin 292 Test := Server(sStartJob + Job shl 4 - sExecute, Me, uix, nil^); 293 293 Result := (Test >= rExecuted) or (Test in IgnoreResults); 294 294 end; 295 295 296 procedure GetUnitInfo(Loc: integer; var uix: integer; var UnitInfo: TUnitInfo);297 var 298 i, Cnt: integer;296 procedure GetUnitInfo(Loc: Integer; var uix: Integer; var UnitInfo: TUnitInfo); 297 var 298 I, Cnt: Integer; 299 299 begin 300 300 if MyMap[Loc] and fOwned <> 0 then 301 301 begin 302 Server(sGetDefender, me, Loc, uix);302 Server(sGetDefender, Me, Loc, uix); 303 303 Cnt := 0; 304 for i:= 0 to MyRO.nUn - 1 do305 if MyUn[ i].Loc = Loc then304 for I := 0 to MyRO.nUn - 1 do 305 if MyUn[I].Loc = Loc then 306 306 Inc(Cnt); 307 MakeUnitInfo( me, MyUn[uix], UnitInfo);307 MakeUnitInfo(Me, MyUn[uix], UnitInfo); 308 308 if Cnt > 1 then 309 309 UnitInfo.Flags := UnitInfo.Flags or unMulti; … … 316 316 UnitInfo := MyRO.EnemyUn[uix]; 317 317 end; 318 end; { GetUnitInfo }319 320 procedure GetCityInfo(Loc: integer; var cix: integer; var CityInfo: TCityInfo);318 end; 319 320 procedure GetCityInfo(Loc: Integer; var cix: Integer; var CityInfo: TCityInfo); 321 321 begin 322 322 if MyMap[Loc] and fOwned <> 0 then … … 328 328 with CityInfo do 329 329 begin 330 Owner := me;330 Owner := Me; 331 331 ID := MyCity[cix].ID; 332 332 size := MyCity[cix].size; … … 356 356 end; 357 357 358 function UnitExhausted(uix: integer): boolean;358 function UnitExhausted(uix: Integer): Boolean; 359 359 // check if another move of this unit is still possible 360 360 var 361 dx, dy: integer;361 dx, dy: Integer; 362 362 begin 363 363 Result := True; 364 364 if (MyUn[uix].Movement > 0) or 365 (MyRO.Wonder[woShinkansen].EffectiveOwner = me) then365 (MyRO.Wonder[woShinkansen].EffectiveOwner = Me) then 366 366 if (MyUn[uix].Movement >= 100) or 367 367 ((MyModel[MyUn[uix].mix].Kind = mkCaravan) and … … 373 373 if abs(dx) + abs(dy) = 2 then 374 374 if Server(sMoveUnit - sExecute + dx and 7 shl 4 + dy and 375 7 shl 7, me, uix, nil^) >= rExecuted then375 7 shl 7, Me, uix, nil^) >= rExecuted then 376 376 Result := False; 377 377 end; 378 378 379 function ModelHash(const ModelInfo: TModelInfo): integer;380 var 381 i, FeatureCode, Hash1, Hash2, Hash2r, d: cardinal;379 function ModelHash(const ModelInfo: TModelInfo): Integer; 380 var 381 I, FeatureCode, Hash1, Hash2, Hash2r, D: Cardinal; 382 382 begin 383 383 with ModelInfo do 384 384 if Kind > mkEnemyDeveloped then 385 Result := integer($C0000000 + Speed div 50 + Kind shl 8)385 Result := Integer($C0000000 + Speed div 50 + Kind shl 8) 386 386 else 387 387 begin 388 388 FeatureCode := 0; 389 for i:= mcFirstNonCap to nFeature - 1 do390 if 1 shl Domain and Feature[ i].Domains <> 0 then389 for I := mcFirstNonCap to nFeature - 1 do 390 if 1 shl Domain and Feature[I].Domains <> 0 then 391 391 begin 392 392 FeatureCode := FeatureCode * 2; 393 if 1 shl ( i- mcFirstNonCap) <> 0 then393 if 1 shl (I - mcFirstNonCap) <> 0 then 394 394 Inc(FeatureCode); 395 395 end; … … 397 397 dGround: 398 398 begin 399 assert(FeatureCode < 1 shl 8);400 assert(Attack < 5113);401 assert(Defense < 2273);402 assert(Cost < 1611);399 Assert(FeatureCode < 1 shl 8); 400 Assert(Attack < 5113); 401 Assert(Defense < 2273); 402 Assert(Cost < 1611); 403 403 Hash1 := (Attack * 2273 + Defense) * 9 + (Speed - 150) div 50; 404 404 Hash2 := FeatureCode * 1611 + Cost; … … 406 406 dSea: 407 407 begin 408 assert(FeatureCode < 1 shl 9);409 assert(Attack < 12193);410 assert(Defense < 6097);411 assert(Cost < 4381);408 Assert(FeatureCode < 1 shl 9); 409 Assert(Attack < 12193); 410 Assert(Defense < 6097); 411 Assert(Cost < 4381); 412 412 Hash1 := ((Attack * 6097 + Defense) * 5 + 413 413 (Speed - 350) div 100) * 2; … … 419 419 dAir: 420 420 begin 421 assert(FeatureCode < 1 shl 5);422 assert(Attack < 2407);423 assert(Defense < 1605);424 assert(Bombs < 4813);425 assert(Cost < 2089);421 Assert(FeatureCode < 1 shl 5); 422 Assert(Attack < 2407); 423 Assert(Defense < 1605); 424 Assert(Bombs < 4813); 425 Assert(Cost < 2089); 426 426 Hash1 := (Attack * 1605 + Defense) shl 5 + FeatureCode; 427 427 Hash2 := ((Bombs * 7 + ATrans_Fuel) * 4 + TTrans) * 2089 + Cost; … … 429 429 end; 430 430 Hash2r := 0; 431 for i:= 0 to 7 do431 for I := 0 to 7 do 432 432 begin 433 433 Hash2r := Hash2r * 13; 434 d:= Hash2 div 13;435 Inc(Hash2r, Hash2 - d* 13);436 Hash2 := d;434 D := Hash2 div 13; 435 Inc(Hash2r, Hash2 - D * 13); 436 Hash2 := D; 437 437 end; 438 Result := integer(Domain shl 30 + Hash1 xor Hash2r);438 Result := Integer(Domain shl 30 + Hash1 xor Hash2r); 439 439 end; 440 440 end; 441 441 442 function ProcessEnhancement(uix: integer; const Jobs: TEnhancementJobs): integer;442 function ProcessEnhancement(uix: Integer; const Jobs: TEnhancementJobs): Integer; 443 443 { return values: 444 444 eJobDone - all applicable jobs done … … 446 446 eDied - job done and died (thurst) } 447 447 var 448 stage, NextJob, Tile: integer;448 stage, NextJob, Tile: Integer; 449 449 Done: set of jNone .. jPoll; 450 450 begin … … 452 452 Tile := MyMap[MyUn[uix].Loc]; 453 453 if Tile and fRoad <> 0 then 454 include(Done, jRoad);454 Include(Done, jRoad); 455 455 if Tile and fRR <> 0 then 456 include(Done, jRR);456 Include(Done, jRR); 457 457 if (Tile and fTerImp = tiIrrigation) or (Tile and fTerImp = tiFarm) then 458 include(Done, jIrr);458 Include(Done, jIrr); 459 459 if Tile and fTerImp = tiFarm then 460 include(Done, jFarm);460 Include(Done, jFarm); 461 461 if Tile and fTerImp = tiMine then 462 include(Done, jMine);462 Include(Done, jMine); 463 463 if Tile and fPoll = 0 then 464 include(Done, jPoll);464 Include(Done, jPoll); 465 465 466 466 if MyUn[uix].Job = jNone then … … 485 485 Break; 486 486 end; // tile enhancement complete 487 Result := Server(sStartJob + NextJob shl 4, me, uix, nil^);488 include(Done, NextJob);489 end; 490 end; 491 492 function AutoBuild(cix: integer; const ImpOrder: TImpOrder): boolean;493 var 494 i, NewProject: integer;487 Result := Server(sStartJob + NextJob shl 4, Me, uix, nil^); 488 Include(Done, NextJob); 489 end; 490 end; 491 492 function AutoBuild(cix: Integer; const ImpOrder: TImpOrder): Boolean; 493 var 494 I, NewProject: Integer; 495 495 begin 496 496 Result := False; … … 498 498 (MyCity[cix].Flags and chProduction <> 0) then 499 499 begin 500 i:= 0;500 I := 0; 501 501 repeat 502 while (ImpOrder[ i] >= 0) and (MyCity[cix].Built[ImpOrder[i]] > 0) do503 Inc( i);504 if ImpOrder[ i] < 0 then502 while (ImpOrder[I] >= 0) and (MyCity[cix].Built[ImpOrder[I]] > 0) do 503 Inc(I); 504 if ImpOrder[I] < 0 then 505 505 Break; 506 assert(i< nImp);507 NewProject := cpImp + ImpOrder[ i];508 if Server(sSetCityProject, me, cix, NewProject) >= rExecuted then506 Assert(I < nImp); 507 NewProject := cpImp + ImpOrder[I]; 508 if Server(sSetCityProject, Me, cix, NewProject) >= rExecuted then 509 509 begin 510 510 Result := True; … … 512 512 Break; 513 513 end; 514 Inc( i);514 Inc(I); 515 515 until False; 516 516 end; … … 519 519 procedure CalculateAdvValues; 520 520 var 521 i, j: integer;522 known: array [0 .. nAdv - 1] of integer;523 524 procedure MarkPreqs( i: integer);525 begin 526 if known[ i] = 0 then521 I, J: Integer; 522 known: array [0 .. nAdv - 1] of Integer; 523 524 procedure MarkPreqs(I: Integer); 525 begin 526 if known[I] = 0 then 527 527 begin 528 known[ i] := 1;529 if ( i <> adScience) and (i<> adMassProduction) then528 known[I] := 1; 529 if (I <> adScience) and (I <> adMassProduction) then 530 530 begin 531 if (AdvPreq[ i, 0] >= 0) then532 MarkPreqs(AdvPreq[ i, 0]);533 if (AdvPreq[ i, 1] >= 0) then534 MarkPreqs(AdvPreq[ i, 1]);531 if (AdvPreq[I, 0] >= 0) then 532 MarkPreqs(AdvPreq[I, 0]); 533 if (AdvPreq[I, 1] >= 0) then 534 MarkPreqs(AdvPreq[I, 1]); 535 535 end; 536 536 end; … … 539 539 begin 540 540 FillChar(AdvValue, SizeOf(AdvValue), 0); 541 for i:= 0 to nAdv - 1 do541 for I := 0 to nAdv - 1 do 542 542 begin 543 543 FillChar(known, SizeOf(known), 0); 544 MarkPreqs( i);545 for j:= 0 to nAdv - 1 do546 if known[ j] > 0 then547 Inc(AdvValue[ i]);548 if iin FutureTech then549 Inc(AdvValue[ i], 3000)544 MarkPreqs(I); 545 for J := 0 to nAdv - 1 do 546 if known[J] > 0 then 547 Inc(AdvValue[I]); 548 if I in FutureTech then 549 Inc(AdvValue[I], 3000) 550 550 else if known[adMassProduction] > 0 then 551 Inc(AdvValue[ i], 2000)551 Inc(AdvValue[I], 2000) 552 552 else if known[adScience] > 0 then 553 Inc(AdvValue[ i], 1000);554 end; 555 end; 556 557 procedure DebugMessage(Level: integer; Text: string);558 begin 559 Server(sMessage, me, Level, PChar(Text)^);560 end; 561 562 function MarkCitiesAround(Loc, cixExcept: integer): boolean;553 Inc(AdvValue[I], 1000); 554 end; 555 end; 556 557 procedure DebugMessage(Level: Integer; Text: string); 558 begin 559 Server(sMessage, Me, Level, PChar(Text)^); 560 end; 561 562 function MarkCitiesAround(Loc, cixExcept: Integer): Boolean; 563 563 // return whether a city was marked 564 564 var 565 cix: integer;565 cix: Integer; 566 566 begin 567 567 Result := False; … … 576 576 end; 577 577 578 procedure OptimizeCities(CheckOnly: boolean);579 var 580 cix, fix, dx, dy, Loc1, OptiType: integer;581 Done: boolean;578 procedure OptimizeCities(CheckOnly: Boolean); 579 var 580 cix, fix, dx, dy, Loc1, OptiType: Integer; 581 Done: Boolean; 582 582 Advice: TCityTileAdviceData; 583 583 begin … … 591 591 begin 592 592 Advice.ResourceWeights := OfferedResourceWeights[OptiType]; 593 Server(sGetCityTileAdvice, me, cix, Advice);593 Server(sGetCityTileAdvice, Me, cix, Advice); 594 594 if Advice.Tiles <> MyCity[cix].Tiles then 595 595 if CheckOnly then … … 611 611 Done := False; 612 612 end; 613 Server(sSetCityTiles, me, cix, Advice.Tiles);613 Server(sSetCityTiles, Me, cix, Advice.Tiles); 614 614 end; 615 615 end; … … 621 621 procedure CityOptimizer_BeginOfTurn; 622 622 var 623 cix: integer;623 cix: Integer; 624 624 begin 625 625 FillChar(CityNeedsOptimize, MyRO.nCity - 1, 0); // false … … 634 634 end; 635 635 636 procedure CityOptimizer_CityChange(cix: integer);636 procedure CityOptimizer_CityChange(cix: Integer); 637 637 begin 638 638 if (MyRO.Government <> gAnarchy) and (cix <> -1) and (MyCity[cix].Flags and … … 644 644 end; 645 645 646 procedure CityOptimizer_TileBecomesAvailable(Loc: integer);646 procedure CityOptimizer_TileBecomesAvailable(Loc: Integer); 647 647 begin 648 648 if (MyRO.Government <> gAnarchy) and MarkCitiesAround(Loc, -1) then … … 650 650 end; 651 651 652 procedure CityOptimizer_ReleaseCityTiles(cix, ReleasedTiles: integer);653 var 654 fix, dx, dy, Loc1: integer;655 Done: boolean;652 procedure CityOptimizer_ReleaseCityTiles(cix, ReleasedTiles: Integer); 653 var 654 fix, dx, dy, Loc1: Integer; 655 Done: Boolean; 656 656 begin 657 657 if (MyRO.Government <> gAnarchy) and (ReleasedTiles <> 0) then … … 672 672 end; 673 673 674 procedure CityOptimizer_BeforeRemoveUnit(uix: integer);675 var 676 uix1: integer;674 procedure CityOptimizer_BeforeRemoveUnit(uix: Integer); 675 var 676 uix1: Integer; 677 677 begin 678 678 if MyRO.Government <> gAnarchy then … … 698 698 // all cities should already be optimized here -- only check this 699 699 var 700 cix: integer;700 cix: Integer; 701 701 begin 702 702 {$IFOPT O-} -
TabularUnified branches/highdpi/LocalPlayer/Diagram.pas ¶
r361 r465 9 9 10 10 type 11 TDiagramKind = (dkChart, dkShip); 12 11 13 TDiaDlg = class(TFramedDlg) 12 14 CloseBtn: TButtonB; … … 19 21 procedure ToggleBtnClick(Sender: TObject); 20 22 procedure PlayerClick(Sender: TObject); 21 procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState); 22 23 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 23 24 public 24 25 procedure OffscreenPaint; override; 25 procedure ShowNewContent_Charts(NewMode: integer); 26 procedure ShowNewContent_Ship(NewMode: integer; p: integer = -1); 27 26 procedure ShowNewContent_Charts(NewMode: TWindowMode); 27 procedure ShowNewContent_Ship(NewMode: TWindowMode; P: Integer = -1); 28 28 private 29 Kind: (dkChart, dkShip); 30 Player, Mode: integer; 31 end; 32 33 var 34 DiaDlg: TDiaDlg; 35 36 procedure PaintColonyShip(canvas: TDpiCanvas; Player, Left, Width, Top: integer); 29 Kind: TDiagramKind; 30 Player: Integer; 31 Mode: Integer; 32 end; 33 34 procedure PaintColonyShip(Canvas: TDpiCanvas; Player, Left, Width, Top: Integer); 35 37 36 38 37 implementation … … 45 44 const 46 45 Border = 24; 47 RoundPixels: array [0 .. nStat - 1] of integer = (0, 0, 0, 5, 5, 5);46 RoundPixels: array [0 .. nStat - 1] of Integer = (0, 0, 0, 5, 5, 5); 48 47 49 48 yArea = 48; 50 xComp: array [0 .. 5] of integer = (-60, -28, 4, 4, 36, 68);51 yComp: array [0 .. 5] of integer = (-40, -40, -79, -1, -40, -40);52 xPow: array [0 .. 3] of integer = (-116, -116, -116, -116);53 yPow: array [0 .. 3] of integer = (-28, 0, -44, 16);54 xHab: array [0 .. 1] of integer = (23, 23);55 yHab: array [0 .. 1] of integer = (-81, 1);56 57 procedure PaintColonyShip( canvas: TDpiCanvas; Player, Left, Width, Top: integer);49 xComp: array [0 .. 5] of Integer = (-60, -28, 4, 4, 36, 68); 50 yComp: array [0 .. 5] of Integer = (-40, -40, -79, -1, -40, -40); 51 xPow: array [0 .. 3] of Integer = (-116, -116, -116, -116); 52 yPow: array [0 .. 3] of Integer = (-28, 0, -44, 16); 53 xHab: array [0 .. 1] of Integer = (23, 23); 54 yHab: array [0 .. 1] of Integer = (-81, 1); 55 56 procedure PaintColonyShip(Canvas: TDpiCanvas; Player, Left, Width, Top: Integer); 58 57 var 59 i, x, r, nComp, nPow, nHab: integer;58 I, X, R, nComp, nPow, nHab: Integer; 60 59 begin 61 60 Canvas.Brush.Color := $000000; 62 61 Canvas.FillRect(Rect(Left, Top, Left + Width, Top + 200)); 63 62 Canvas.Brush.Style := bsClear; 64 ScreenTools.Frame( canvas, Left - 1, Top - 1, Left + Width, Top + 200,63 ScreenTools.Frame(Canvas, Left - 1, Top - 1, Left + Width, Top + 200, 65 64 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 66 RFrame( canvas, Left - 2, Top - 2, Left + Width + 1, Top + 200 + 1,65 RFrame(Canvas, Left - 2, Top - 2, Left + Width + 1, Top + 200 + 1, 67 66 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 68 67 69 68 // stars 70 69 DelphiRandSeed := Player * 11111; 71 for i:= 1 to Width - 16 do70 for I := 1 to Width - 16 do 72 71 begin 73 x:= DelphiRandom((Width - 16) * 200);74 r:= DelphiRandom(13) + 28;75 Canvas.Pixels[ x div 200 + 8, xmod 200 + Top] :=76 ( r * r * r * rdiv 10001) * $10101;72 X := DelphiRandom((Width - 16) * 200); 73 R := DelphiRandom(13) + 28; 74 Canvas.Pixels[X div 200 + 8, X mod 200 + Top] := 75 (R * R * R * R div 10001) * $10101; 77 76 end; 78 77 … … 86 85 if nHab > 2 then 87 86 nHab := 2; 88 for i:= 0 to nHab - 1 do89 Sprite( canvas, HGrSystem2, Left + Width div 2 + xHab[i],90 Top + 100 + yHab[ i], 80, 80, 34, 1);91 for i:= 0 to nComp - 1 do92 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[i],93 Top + 100 + yComp[ i], 32, 80, 1, 1);87 for I := 0 to nHab - 1 do 88 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xHab[I], 89 Top + 100 + yHab[I], 80, 80, 34, 1); 90 for I := 0 to nComp - 1 do 91 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[I], 92 Top + 100 + yComp[I], 32, 80, 1, 1); 94 93 if nComp > 0 then 95 for i:= 3 downto nPow do96 Sprite( canvas, HGrSystem2, Left + Width div 2 + xPow[i] + 40,97 Top + 100 + yPow[ i], 16, 27, 1, 82);98 for i:= nPow - 1 downto 0 do99 Sprite( canvas, HGrSystem2, Left + Width div 2 + xPow[i],100 Top + 100 + yPow[ i], 56, 28, 58, 82);94 for I := 3 downto nPow do 95 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xPow[I] + 40, 96 Top + 100 + yPow[I], 16, 27, 1, 82); 97 for I := nPow - 1 downto 0 do 98 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xPow[I], 99 Top + 100 + yPow[I], 56, 28, 58, 82); 101 100 if (nComp < 3) and (nHab >= 1) then 102 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32 - 16,101 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32 - 16, 103 102 Top + 100 + 7 + yComp[2], 16, 27, 1, 82); 104 103 if (nComp >= 3) and (nHab < 1) then 105 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32,104 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32, 106 105 Top + 100 + 7 + yComp[2], 16, 27, 18, 82); 107 106 if (nComp < 4) and (nHab >= 2) then 108 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32 - 16,107 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32 - 16, 109 108 Top + 100 + 46 + yComp[3], 16, 27, 1, 82); 110 109 if (nComp >= 4) and (nHab < 2) then 111 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32,110 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32, 112 111 Top + 100 + 46 + yComp[3], 16, 27, 18, 82); 113 112 if (nComp <> 6) and (nComp <> 2) and not((nComp = 0) and (nPow < 1)) then 114 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[nComp],113 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[nComp], 115 114 Top + 100 + 7 + yComp[nComp], 16, 27, 18, 82); 116 115 if (nComp <> 6) and (nComp <> 3) and not((nComp = 0) and (nPow < 2)) then 117 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[nComp],116 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[nComp], 118 117 Top + 100 + 46 + yComp[nComp], 16, 27, 18, 82); 119 118 if nComp = 2 then 120 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[3],119 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[3], 121 120 Top + 100 + 7 + yComp[3], 16, 27, 18, 82); 122 121 if nComp = 3 then 123 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[4],122 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[4], 124 123 Top + 100 + 7 + yComp[4], 16, 27, 18, 82); 125 124 end; … … 142 141 procedure TDiaDlg.OffscreenPaint; 143 142 var 144 p, T, max, x, y, y0, Stop, r, RoundRange, LineStep: integer;145 s: string;143 P, T, Max, X, Y, y0, Stop, R, RoundRange, LineStep: Integer; 144 S: string; 146 145 List: ^TChart; 147 146 148 function Round(T: integer): integer;147 function Round(T: Integer): Integer; 149 148 var 150 n, i: integer;149 N, I: Integer; 151 150 begin 152 151 if T < RoundRange then 153 n:= T152 N := T 154 153 else 155 n:= RoundRange;156 result := 0;157 for i := T - nto T do158 inc(result, List[i]);159 result := result div (n+ 1);160 end; 161 162 procedure ShareBar( x, y: integer; Cap: string; val0, val1: integer);163 begin 164 LoweredTextOut( offscreen.canvas, -1, MainTexture, x - 2, y, Cap);165 DLine( offscreen.canvas, x - 2, x + 169, y+ 16, MainTexture.ColorTextShade,154 N := RoundRange; 155 Result := 0; 156 for I := T - N to T do 157 Inc(Result, List[I]); 158 Result := Result div (N + 1); 159 end; 160 161 procedure ShareBar(X, Y: Integer; Cap: string; val0, val1: Integer); 162 begin 163 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, X - 2, Y, Cap); 164 DLine(Offscreen.Canvas, X - 2, X + 169, Y + 16, MainTexture.ColorTextShade, 166 165 MainTexture.ColorTextLight); 167 166 if val0 > 0 then 168 s:= Format(Phrases.Lookup('SHARE'), [val0, val1])167 S := Format(Phrases.Lookup('SHARE'), [val0, val1]) 169 168 else 170 s:= '0';171 RisedTextOut( offscreen.canvas,172 x + 170 - BiColorTextWidth(offscreen.canvas, s), y, s);169 S := '0'; 170 RisedTextOut(Offscreen.Canvas, 171 X + 170 - BiColorTextWidth(Offscreen.Canvas, S), Y, S); 173 172 end; 174 173 … … 176 175 inherited; 177 176 if Kind = dkChart then 178 with offscreen.canvas do177 with Offscreen.Canvas do 179 178 begin 180 179 Font.Assign(UniFont[ftTiny]); … … 186 185 GetMem(List, 4 * (MyRO.Turn + 2)); 187 186 if Mode = stExplore then 188 max := G.lx * G.ly187 Max := G.lx * G.ly 189 188 else 190 189 begin 191 max := -1;192 for p:= 0 to nPl - 1 do193 if (G.Difficulty[ p] > 0) and194 (Server(sGetChart + Mode shl 4, me, p, List^) >= rExecuted) then190 Max := -1; 191 for P := 0 to nPl - 1 do 192 if (G.Difficulty[P] > 0) and 193 (Server(sGetChart + Mode shl 4, Me, P, List^) >= rExecuted) then 195 194 for T := 0 to MyRO.Turn - 1 do 196 195 begin 197 r:= Round(T);198 if r > max then199 max := r;196 R := Round(T); 197 if R > Max then 198 Max := R; 200 199 end; 201 200 end; … … 215 214 for T := 0 to (MyRO.Turn - 1) div LineStep do 216 215 begin 217 x:= Border + (InnerWidth - 2 * Border) * T *216 X := Border + (InnerWidth - 2 * Border) * T * 218 217 LineStep div (MyRO.Turn - 1); 219 MoveTo( x, Border);220 LineTo( x, InnerHeight - Border);221 s:= IntToStr(abs(TurnToYear(T * LineStep)));222 Textout( x - TextWidth(s) div 2, Border - 16, s);218 MoveTo(X, Border); 219 LineTo(X, InnerHeight - Border); 220 S := IntToStr(abs(TurnToYear(T * LineStep))); 221 Textout(X - TextWidth(S) div 2, Border - 16, S); 223 222 end; 224 223 225 224 y0 := 0; 226 if max > 0 then225 if Max > 0 then 227 226 begin 228 for p:= 0 to nPl - 1 do229 if (G.Difficulty[ p] > 0) and230 (Server(sGetChart + Mode shl 4, me, p, List^) >= rExecuted) then227 for P := 0 to nPl - 1 do 228 if (G.Difficulty[P] > 0) and 229 (Server(sGetChart + Mode shl 4, Me, P, List^) >= rExecuted) then 231 230 begin 232 Pen.Color := Tribe[ p].Color;231 Pen.Color := Tribe[P].Color; 233 232 Stop := MyRO.Turn - 1; 234 233 while (Stop > 0) and (List[Stop] = 0) do 235 dec(Stop);234 Dec(Stop); 236 235 for T := 0 to Stop do 237 236 begin 238 r:= Round(T);239 x:= Border + (InnerWidth - 2 * Border) * T div (MyRO.Turn - 1);240 y:= InnerHeight - Border - (InnerHeight - 2 * Border) *241 r div max;237 R := Round(T); 238 X := Border + (InnerWidth - 2 * Border) * T div (MyRO.Turn - 1); 239 Y := InnerHeight - Border - (InnerHeight - 2 * Border) * 240 R div Max; 242 241 if T = 0 then 243 MoveTo( x, y)242 MoveTo(X, Y) 244 243 // else if Mode=stTerritory then 245 244 // begin LineTo(x,y0); LineTo(x,y) end 246 245 else if RoundPixels[Mode] = 0 then 247 246 begin 248 if ( y<> y0) or (T = Stop) then249 LineTo( x, y)247 if (Y <> y0) or (T = Stop) then 248 LineTo(X, Y) 250 249 end 251 250 else 252 LineTo( x, y);253 y0 := y;251 LineTo(X, Y); 252 y0 := Y; 254 253 end; 255 254 end; … … 258 257 end 259 258 else 260 with offscreen.canvas do259 with Offscreen.Canvas do 261 260 begin 262 261 Font.Assign(UniFont[ftSmall]); 263 262 FillOffscreen(0, 0, InnerWidth, InnerHeight); 264 263 265 PaintColonyShip( offscreen.canvas, Player, 8, InnerWidth - 16, yArea);264 PaintColonyShip(Offscreen.Canvas, Player, 8, InnerWidth - 16, yArea); 266 265 267 266 ShareBar(InnerWidth div 2 - 85, InnerHeight - 62, … … 273 272 end; 274 273 MarkUsedOffscreen(InnerWidth, InnerHeight); 275 end; // OffscreenPaint274 end; 276 275 277 276 procedure TDiaDlg.FormPaint(Sender: TObject); 278 277 var 279 s: string;278 S: string; 280 279 begin 281 280 inherited; 282 canvas.Font.Assign(UniFont[ftNormal]);281 Canvas.Font.Assign(UniFont[ftNormal]); 283 282 if Kind = dkChart then 284 s:= Phrases.Lookup('DIAGRAM', Mode)285 else 286 s:= Tribe[Player].TPhrase('SHORTNAME');287 LoweredTextOut( canvas, -1, MainTexture,288 (ClientWidth - BiColorTextWidth( canvas, s)) div 2, 31, s);283 S := Phrases.Lookup('DIAGRAM', Mode) 284 else 285 S := Tribe[Player].TPhrase('SHORTNAME'); 286 LoweredTextOut(Canvas, -1, MainTexture, 287 (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, 31, S); 289 288 end; 290 289 … … 299 298 end; 300 299 301 procedure TDiaDlg.ShowNewContent_Charts(NewMode: integer);300 procedure TDiaDlg.ShowNewContent_Charts(NewMode: TWindowMode); 302 301 begin 303 302 Kind := dkChart; … … 309 308 end; 310 309 311 procedure TDiaDlg.ShowNewContent_Ship(NewMode , p: integer);310 procedure TDiaDlg.ShowNewContent_Ship(NewMode: TWindowMode; P: Integer); 312 311 begin 313 312 Kind := dkShip; 314 if p< 0 then315 begin 316 Player := me;313 if P < 0 then 314 begin 315 Player := Me; 317 316 while MyRO.Ship[Player].Parts[spComp] + MyRO.Ship[Player].Parts[spPow] + 318 317 MyRO.Ship[Player].Parts[spHab] = 0 do … … 320 319 end 321 320 else 322 Player := p;321 Player := P; 323 322 ToggleBtn.ButtonIndex := 28; 324 323 ToggleBtn.Hint := Phrases.Lookup('BTN_SELECT'); … … 329 328 procedure TDiaDlg.ToggleBtnClick(Sender: TObject); 330 329 var 331 p1: integer;332 m: TDpiMenuItem;330 p1: Integer; 331 M: TDpiMenuItem; 333 332 begin 334 333 if Kind = dkChart then … … 345 344 MyRO.Ship[p1].Parts[spHab] > 0 then 346 345 begin 347 m:= TDpiMenuItem.Create(Popup);348 m.RadioItem := true;349 m.Caption := Tribe[p1].TPhrase('SHORTNAME');350 m.Tag := p1;351 m.OnClick := PlayerClick;346 M := TDpiMenuItem.Create(Popup); 347 M.RadioItem := True; 348 M.Caption := Tribe[p1].TPhrase('SHORTNAME'); 349 M.Tag := p1; 350 M.OnClick := PlayerClick; 352 351 if p1 = Player then 353 m.Checked := true;354 Popup.Items.Add( m);352 M.Checked := True; 353 Popup.Items.Add(M); 355 354 end; 356 355 Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top + ToggleBtn.Height); … … 363 362 end; 364 363 365 procedure TDiaDlg.FormKeyDown(Sender: TObject; var Key: word;364 procedure TDiaDlg.FormKeyDown(Sender: TObject; var Key: Word; 366 365 Shift: TShiftState); 367 366 begin -
TabularUnified branches/highdpi/LocalPlayer/Diplomacy.pas ¶
r210 r465 7 7 8 8 function DipCommandToString(pSender, pTarget, Treaty, OppCommand, 9 Command: integer; const OppOffer, Offer: TOffer): string;9 Command: Integer; const OppOffer, Offer: TOffer): string; 10 10 11 11 implementation … … 16 16 function DipCommandToString; 17 17 18 function PriceToString( p, Price: integer): string;18 function PriceToString(P, Price: Integer): string; 19 19 begin 20 20 case Price and opMask of 21 21 opChoose: 22 result := Phrases.Lookup('PRICE_CHOOSE');22 Result := Phrases.Lookup('PRICE_CHOOSE'); 23 23 opCivilReport: 24 result := Tribe[p].TPhrase('PRICE_CIVIL');24 Result := Tribe[P].TPhrase('PRICE_CIVIL'); 25 25 opMilReport: 26 result := Tribe[p].TPhrase('PRICE_MIL');26 Result := Tribe[P].TPhrase('PRICE_MIL'); 27 27 opMap: 28 result := Tribe[p].TPhrase('PRICE_MAP');28 Result := Tribe[P].TPhrase('PRICE_MAP'); 29 29 opTreaty: 30 30 { if Price-opTreaty<Treaty then 31 31 case Treaty of 32 trPeace: result:=Phrases.Lookup('FRENDTREATY_PEACE');33 trFriendlyContact: result:=Phrases.Lookup('FRENDTREATY_FRIENDLY');34 trAlliance: result:=Phrases.Lookup('FRENDTREATY_ALLIANCE');35 end 36 else } result := Phrases.Lookup('TREATY', Price - opTreaty);32 trPeace: Result:=Phrases.Lookup('FRENDTREATY_PEACE'); 33 trFriendlyContact: Result:=Phrases.Lookup('FRENDTREATY_FRIENDLY'); 34 trAlliance: Result:=Phrases.Lookup('FRENDTREATY_ALLIANCE'); 35 end 36 else } Result := Phrases.Lookup('TREATY', Price - opTreaty); 37 37 opShipParts: 38 38 case Price shr 16 and $F of 39 39 0: 40 result := Format(Phrases.Lookup('PRICE_SHIPCOMP'),40 Result := Format(Phrases.Lookup('PRICE_SHIPCOMP'), 41 41 [Price and $FFFF]); 42 42 1: 43 result := Format(Phrases.Lookup('PRICE_SHIPPOW'),43 Result := Format(Phrases.Lookup('PRICE_SHIPPOW'), 44 44 [Price and $FFFF]); 45 45 2: 46 result := Format(Phrases.Lookup('PRICE_SHIPHAB'),46 Result := Format(Phrases.Lookup('PRICE_SHIPHAB'), 47 47 [Price and $FFFF]); 48 48 end; 49 49 opMoney: 50 result := Format('%d%%c', [Price - opMoney]);50 Result := Format('%d%%c', [Price - opMoney]); 51 51 opTribute: 52 result := Format(Phrases.Lookup('PRICE_TRIBUTE'), [Price - opTribute]);52 Result := Format(Phrases.Lookup('PRICE_TRIBUTE'), [Price - opTribute]); 53 53 opTech: 54 result := Phrases.Lookup('ADVANCES', Price - opTech);54 Result := Phrases.Lookup('ADVANCES', Price - opTech); 55 55 opAllTech: 56 result := Tribe[p].TPhrase('PRICE_ALLTECH');56 Result := Tribe[P].TPhrase('PRICE_ALLTECH'); 57 57 opModel: 58 result := Tribe[p].ModelName[Price - opModel];58 Result := Tribe[P].ModelName[Price - opModel]; 59 59 opAllModel: 60 result := Tribe[p].TPhrase('PRICE_ALLMODEL');60 Result := Tribe[P].TPhrase('PRICE_ALLMODEL'); 61 61 { opCity: 62 result:=Format(TPhrase('PRICE_CITY',p),[CityName(Price-opCity)]); }62 Result:=Format(TPhrase('PRICE_CITY',P),[CityName(Price-opCity)]); } 63 63 end 64 64 end; 65 65 66 66 var 67 i: integer;67 I: Integer; 68 68 sAdd, sDeliver, sCost: string; 69 DoIntro: boolean;69 DoIntro: Boolean; 70 70 begin 71 71 DoIntro := OppCommand = scDipStart; … … 75 75 case Treaty of 76 76 trPeace: 77 result := Phrases.Lookup('FRCANCELTREATY_PEACE');77 Result := Phrases.Lookup('FRCANCELTREATY_PEACE'); 78 78 trFriendlyContact: 79 result := Phrases.Lookup('FRCANCELTREATY_FRIENDLY');79 Result := Phrases.Lookup('FRCANCELTREATY_FRIENDLY'); 80 80 trAlliance: 81 result := Phrases.Lookup('FRCANCELTREATY_ALLIANCE');82 end; 83 DoIntro := false;81 Result := Phrases.Lookup('FRCANCELTREATY_ALLIANCE'); 82 end; 83 DoIntro := False; 84 84 end; 85 85 scDipNotice: 86 result := Phrases.Lookup('FRNOTICE');86 Result := Phrases.Lookup('FRNOTICE'); 87 87 scDipAccept: 88 88 begin 89 89 if (OppOffer.nDeliver + OppOffer.nCost = 1) and 90 90 (OppOffer.Price[0] and opMask = opTreaty) and 91 ( integer(OppOffer.Price[0] - opTreaty) > Treaty) then91 (Integer(OppOffer.Price[0] - opTreaty) > Treaty) then 92 92 // simple treaty offer 93 93 { if OppOffer.Price[0]-opTreaty=trCeaseFire then 94 result:=Tribe[pTarget].TPhrase('FRACCEPTCEASEFIRE')95 else } result := Tribe[pTarget].TPhrase('FRACCEPTTREATY')94 Result:=Tribe[pTarget].TPhrase('FRACCEPTCEASEFIRE') 95 else } Result := Tribe[pTarget].TPhrase('FRACCEPTTREATY') 96 96 else if OppOffer.nDeliver = 0 then 97 result := Tribe[pSender].TPhrase('FRACCEPTDEMAND_STRONG')97 Result := Tribe[pSender].TPhrase('FRACCEPTDEMAND_STRONG') 98 98 else if OppOffer.nCost = 0 then 99 result := Tribe[pSender].TPhrase('FRACCEPTPRESENT')99 Result := Tribe[pSender].TPhrase('FRACCEPTPRESENT') 100 100 else 101 result := Tribe[pSender].TPhrase('FRACCEPTOFFER');101 Result := Tribe[pSender].TPhrase('FRACCEPTOFFER'); 102 102 end; 103 103 scDipBreak: 104 104 begin 105 result := Tribe[pTarget].TPhrase('FRBREAK');106 DoIntro := false;105 Result := Tribe[pTarget].TPhrase('FRBREAK'); 106 DoIntro := False; 107 107 end; 108 108 scDipOffer: 109 109 begin 110 result := '';110 Result := ''; 111 111 if (OppCommand = scDipOffer) and 112 112 ((OppOffer.nDeliver > 0) or (OppOffer.nCost > 0)) and … … 115 115 if (OppOffer.nDeliver + OppOffer.nCost = 1) and 116 116 (OppOffer.Price[0] and opMask = opTreaty) and 117 ( integer(OppOffer.Price[0] - opTreaty) > Treaty) then117 (Integer(OppOffer.Price[0] - opTreaty) > Treaty) then 118 118 // simple treaty offer 119 result := Tribe[pSender].TPhrase('FRNOTACCEPTTREATY') + '\'119 Result := Tribe[pSender].TPhrase('FRNOTACCEPTTREATY') + '\' 120 120 else if OppOffer.nDeliver = 0 then 121 result := Tribe[pSender].TPhrase('FRNOTACCEPTDEMAND_STRONG') + '\'121 Result := Tribe[pSender].TPhrase('FRNOTACCEPTDEMAND_STRONG') + '\' 122 122 else if OppOffer.nCost = 0 then 123 result := Tribe[pSender].TPhrase('FRNOTACCEPTPRESENT') + '\';123 Result := Tribe[pSender].TPhrase('FRNOTACCEPTPRESENT') + '\'; 124 124 end; 125 125 126 126 sDeliver := ''; 127 for i:= 0 to Offer.nDeliver - 1 do128 begin 129 sAdd := PriceToString(pSender, Offer.Price[ i]);130 if i= 0 then127 for I := 0 to Offer.nDeliver - 1 do 128 begin 129 sAdd := PriceToString(pSender, Offer.Price[I]); 130 if I = 0 then 131 131 sDeliver := sAdd 132 132 else … … 134 134 end; 135 135 sCost := ''; 136 for i:= 0 to Offer.nCost - 1 do137 begin 138 sAdd := PriceToString(pTarget, Offer.Price[Offer.nDeliver + i]);139 if i= 0 then136 for I := 0 to Offer.nCost - 1 do 137 begin 138 sAdd := PriceToString(pTarget, Offer.Price[Offer.nDeliver + I]); 139 if I = 0 then 140 140 sCost := sAdd 141 141 else … … 147 147 if (OppCommand = scDipOffer) and 148 148 ((OppOffer.nDeliver = 0) and (OppOffer.nCost = 0)) then 149 result := Tribe[pTarget].TPhrase('FRBYE')149 Result := Tribe[pTarget].TPhrase('FRBYE') 150 150 else 151 151 begin 152 if ( result = '') and (OppCommand = scDipOffer) and152 if (Result = '') and (OppCommand = scDipOffer) and 153 153 ((OppOffer.nDeliver > 0) or (OppOffer.nCost > 0)) then 154 154 begin 155 155 if (OppOffer.nDeliver = 1) and (OppOffer.Price[0] = opChoose) and 156 156 not Phrases2FallenBackToEnglish then 157 result := Tribe[pSender].TString157 Result := Tribe[pSender].TString 158 158 (Phrases2.Lookup('FRNOTACCEPTANYOFFER')) + ' ' 159 159 else if (OppOffer.nCost = 1) and 160 160 (OppOffer.Price[OppOffer.nDeliver] = opChoose) and not Phrases2FallenBackToEnglish 161 161 then 162 result := Tribe[pSender].TString162 Result := Tribe[pSender].TString 163 163 (Phrases2.Lookup('FRNOTACCEPTANYWANT')) + ' ' 164 164 else 165 result := Tribe[pSender].TPhrase('FRNOTACCEPTOFFER') + ' ';165 Result := Tribe[pSender].TPhrase('FRNOTACCEPTOFFER') + ' '; 166 166 end; 167 result := result + Phrases.Lookup('FRDONE');168 DoIntro := false167 Result := Result + Phrases.Lookup('FRDONE'); 168 DoIntro := False 169 169 end 170 170 end 171 171 else if (Offer.nDeliver + Offer.nCost = 1) and 172 172 (Offer.Price[0] and opMask = opTreaty) and 173 ( integer(Offer.Price[0] - opTreaty) > Treaty) then173 (Integer(Offer.Price[0] - opTreaty) > Treaty) then 174 174 // simple treaty offer 175 175 begin … … 177 177 // trCeaseFire: result:=result+Tribe[pTarget].TPhrase('FRCEASEFIRE'); 178 178 trPeace: 179 result := result + Tribe[pTarget].TPhrase('FRPEACE');179 Result := Result + Tribe[pTarget].TPhrase('FRPEACE'); 180 180 trFriendlyContact: 181 result := result + Tribe[pTarget].TPhrase('FRFRIENDLY');181 Result := Result + Tribe[pTarget].TPhrase('FRFRIENDLY'); 182 182 trAlliance: 183 result := result + Tribe[pTarget].TPhrase('FRALLIANCE');183 Result := Result + Tribe[pTarget].TPhrase('FRALLIANCE'); 184 184 end 185 185 end … … 188 188 if (Treaty >= trFriendlyContact) and not Phrases2FallenBackToEnglish 189 189 then 190 result := result +190 Result := Result + 191 191 Format(Tribe[pTarget].TString(Phrases2.Lookup('FRDEMAND_SOFT') 192 192 ), [sCost]) 193 193 else 194 194 begin 195 result := result +195 Result := Result + 196 196 Format(Tribe[pTarget].TPhrase('FRDEMAND_STRONG'), [sCost]); 197 DoIntro := false197 DoIntro := False 198 198 end 199 199 end 200 200 else if Offer.nCost = 0 then // present 201 result := result + Format(Tribe[pTarget].TPhrase('FRPRESENT'),201 Result := Result + Format(Tribe[pTarget].TPhrase('FRPRESENT'), 202 202 [sDeliver]) 203 203 else if (Offer.nDeliver = 1) and (Offer.Price[0] = opChoose) then 204 result := result + Format(Phrases.Lookup('FRDELCHOICE'), [sCost])204 Result := Result + Format(Phrases.Lookup('FRDELCHOICE'), [sCost]) 205 205 else if (Offer.nCost = 1) and (Offer.Price[Offer.nDeliver] = opChoose) 206 206 then 207 result := result + Format(Phrases.Lookup('FRCOSTCHOICE'), [sDeliver])207 Result := Result + Format(Phrases.Lookup('FRCOSTCHOICE'), [sDeliver]) 208 208 else 209 result := result + Format(Phrases.Lookup('FROFFER'),209 Result := Result + Format(Phrases.Lookup('FROFFER'), 210 210 [sDeliver, sCost]); 211 211 end; … … 213 213 if DoIntro then 214 214 if Treaty < trPeace then 215 result := Tribe[pSender].TPhrase('FRSTART_NOTREATY') + ' ' + result215 Result := Tribe[pSender].TPhrase('FRSTART_NOTREATY') + ' ' + Result 216 216 else 217 result := Tribe[pSender].TPhrase('FRSTART_PEACE') + ' ' + result217 Result := Tribe[pSender].TPhrase('FRSTART_PEACE') + ' ' + Result 218 218 end; 219 219 -
TabularUnified branches/highdpi/LocalPlayer/Draft.pas ¶
r361 r465 5 5 6 6 uses 7 UDpiControls, Protocol, ClientTools, Term, ScreenTools, BaseWin, 8 9 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls, 10 ButtonA, 11 ButtonB, Area; 7 UDpiControls, Protocol, ClientTools, ScreenTools, BaseWin, LCLIntf, LCLType, SysUtils, 8 Classes, Graphics, Controls, Forms, ExtCtrls, ButtonA, ButtonB, Area; 12 9 13 10 type … … 23 20 procedure CloseBtnClick(Sender: TObject); 24 21 procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 25 Shift: TShiftState; x, y: integer);22 Shift: TShiftState; X, Y: Integer); 26 23 procedure OKBtnClick(Sender: TObject); 27 24 procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton; 28 Shift: TShiftState; x, y: integer);25 Shift: TShiftState; X, Y: Integer); 29 26 public 30 procedure ShowNewContent(NewMode: integer);27 procedure ShowNewContent(NewMode: TWindowMode); 31 28 protected 32 29 procedure OffscreenPaint; override; 33 30 private 34 31 Domain, MaxLines, Lines, Cut, yDomain, yFeature, yWeight, yTotal, yView, 35 IncCap, DecCap: integer;36 code: array [0 .. nFeature - 1] of integer;32 IncCap, DecCap: Integer; 33 Code: array [0 .. nFeature - 1] of Integer; 37 34 Template, Back: TDpiBitmap; 38 function IsFeatureInList(d, i: integer): boolean; 39 procedure SetDomain(d: integer); 40 end; 41 42 var 43 DraftDlg: TDraftDlg; 35 function IsFeatureInList(D, I: Integer): Boolean; 36 procedure SetDomain(D: Integer); 37 end; 38 44 39 45 40 implementation 46 41 47 uses Help, Tribes, Directories; 42 uses 43 Term, Help, Tribes, Directories; 48 44 49 45 {$R *.lfm} … … 109 105 procedure TDraftDlg.OffscreenPaint; 110 106 111 function DomainAvailable( d: integer): boolean;112 begin 113 result := (upgrade[d, 0].Preq = preNone) or114 (MyRO.Tech[upgrade[ d, 0].Preq] >= tsApplicable);107 function DomainAvailable(D: Integer): Boolean; 108 begin 109 Result := (upgrade[D, 0].Preq = preNone) or 110 (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable); 115 111 end; 116 112 117 113 procedure PaintTotalBars; 118 114 var 119 i, y, dx, num, w: integer;120 s: string;121 begin 122 with offscreen.Canvas do115 I, Y, dx, num, W: Integer; 116 S: string; 117 begin 118 with Offscreen.Canvas do 123 119 begin 124 120 // strength bar 125 y:= yTotal;126 DarkGradient( offscreen.Canvas, xTotal - 6, y+ 1, 184, 2);127 DarkGradient( offscreen.Canvas, xTotal2 + 172, y+ 1, 95, 2);128 RisedTextOut( offscreen.Canvas, xTotal - 2, y,121 Y := yTotal; 122 DarkGradient(Offscreen.Canvas, xTotal - 6, Y + 1, 184, 2); 123 DarkGradient(Offscreen.Canvas, xTotal2 + 172, Y + 1, 95, 2); 124 RisedTextOut(Offscreen.Canvas, xTotal - 2, Y, 129 125 Phrases.Lookup('UNITSTRENGTH')); 130 RisedTextOut( offscreen.Canvas, xTotal + 112 + 30, y,126 RisedTextOut(Offscreen.Canvas, xTotal + 112 + 30, Y, 131 127 'x' + IntToStr(MyRO.DevModel.MStrength)); 132 RisedTextOut( offscreen.Canvas, xTotal2 + 148 + 30, y, '=');133 s:= IntToStr(MyRO.DevModel.Attack) + '/' +128 RisedTextOut(Offscreen.Canvas, xTotal2 + 148 + 30, Y, '='); 129 S := IntToStr(MyRO.DevModel.Attack) + '/' + 134 130 IntToStr(MyRO.DevModel.Defense); 135 RisedTextOut( offscreen.Canvas, xTotal2 + 170 + 64 + 30 -136 BiColorTextWidth( offscreen.Canvas, s), y, s);131 RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 132 BiColorTextWidth(Offscreen.Canvas, S), Y, S); 137 133 138 134 // transport bar 139 135 if MyRO.DevModel.MTrans > 0 then 140 136 begin 141 y:= yTotal + 19;142 DarkGradient( offscreen.Canvas, xTotal - 6, y+ 1, 184, 1);143 DarkGradient( offscreen.Canvas, xTotal2 + 172, y+ 1, 95, 1);144 RisedTextOut( offscreen.Canvas, xTotal - 2, y,137 Y := yTotal + 19; 138 DarkGradient(Offscreen.Canvas, xTotal - 6, Y + 1, 184, 1); 139 DarkGradient(Offscreen.Canvas, xTotal2 + 172, Y + 1, 95, 1); 140 RisedTextOut(Offscreen.Canvas, xTotal - 2, Y, 145 141 Phrases.Lookup('UNITTRANSPORT')); 146 RisedTextOut( offscreen.Canvas, xTotal + 112 + 30, y,142 RisedTextOut(Offscreen.Canvas, xTotal + 112 + 30, Y, 147 143 'x' + IntToStr(MyRO.DevModel.MTrans)); 148 RisedTextOut( offscreen.Canvas, xTotal2 + 148 + 30, y, '=');144 RisedTextOut(Offscreen.Canvas, xTotal2 + 148 + 30, Y, '='); 149 145 150 146 Font.Color := $000000; 151 147 dx := -237 - 30; 152 for i:= mcFirstNonCap - 1 downto 3 do153 if iin [mcSeaTrans, mcCarrier, mcAirTrans] then148 for I := mcFirstNonCap - 1 downto 3 do 149 if I in [mcSeaTrans, mcCarrier, mcAirTrans] then 154 150 begin 155 num := MyRO.DevModel.Cap[ i] * MyRO.DevModel.MTrans;151 num := MyRO.DevModel.Cap[I] * MyRO.DevModel.MTrans; 156 152 if num > 0 then 157 153 begin 158 inc(dx, 15);154 Inc(dx, 15); 159 155 Brush.Color := $C0C0C0; 160 FrameRect(Rect(xTotal2 - 3 - dx, y+ 2,161 xTotal2 + 11 - dx, y+ 16));156 FrameRect(Rect(xTotal2 - 3 - dx, Y + 2, 157 xTotal2 + 11 - dx, Y + 16)); 162 158 Brush.Style := bsClear; 163 Sprite( offscreen, HGrSystem, xTotal2 - 1 - dx, y+ 4, 10, 10,164 66 + i mod 11 * 11, 137 + idiv 11 * 11);159 Sprite(Offscreen, HGrSystem, xTotal2 - 1 - dx, Y + 4, 10, 10, 160 66 + I mod 11 * 11, 137 + I div 11 * 11); 165 161 if num > 1 then 166 162 begin 167 s:= IntToStr(num);168 w := TextWidth(s);169 inc(dx, w+ 1);163 S := IntToStr(num); 164 W := TextWidth(S); 165 Inc(dx, W + 1); 170 166 Brush.Color := $FFFFFF; 171 FillRect(Rect(xTotal2 - 3 - dx, y+ 2,172 xTotal2 + w - 1 - dx, y+ 16));167 FillRect(Rect(xTotal2 - 3 - dx, Y + 2, 168 xTotal2 + W - 1 - dx, Y + 16)); 173 169 Brush.Style := bsClear; 174 Textout(xTotal2 - 3 - dx + 1, y, s);170 Textout(xTotal2 - 3 - dx + 1, Y, S); 175 171 end; 176 172 end; 177 end 173 end; 178 174 end; 179 175 180 176 // speed bar 181 y:= yTotal + 38;182 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xTotal - 2, y,177 Y := yTotal + 38; 178 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y, 183 179 Phrases.Lookup('UNITSPEED')); 184 DLine( offscreen.Canvas, xTotal - 2, xTotal + 174, y+ 16,180 DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16, 185 181 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 186 DLine( offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, y+ 16,182 DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16, 187 183 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 188 s:= MovementToString(MyRO.DevModel.Speed);189 RisedTextOut( offscreen.Canvas, xTotal2 + 170 + 64 + 30 -190 TextWidth( s), y, s);184 S := MovementToString(MyRO.DevModel.Speed); 185 RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 186 TextWidth(S), Y, S); 191 187 192 188 // cost bar 193 y:= yTotal + 57;194 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xTotal - 2, y,189 Y := yTotal + 57; 190 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y, 195 191 Phrases.Lookup('UNITCOST')); 196 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xTotal + 112 + 30, y,192 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal + 112 + 30, Y, 197 193 'x' + IntToStr(MyRO.DevModel.MCost)); 198 LoweredTextOut( offscreen.Canvas, -1, MainTexture,199 xTotal2 + 148 + 30, y, '=');200 DLine( offscreen.Canvas, xTotal - 2, xTotal + 174, y+ 16,194 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, 195 xTotal2 + 148 + 30, Y, '='); 196 DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16, 201 197 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 202 DLine( offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, y+ 16,198 DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16, 203 199 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 204 s:= IntToStr(MyRO.DevModel.Cost);205 RisedTextOut( offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -206 TextWidth( s), y, s);207 Sprite( offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, y+ 4, 10,200 S := IntToStr(MyRO.DevModel.Cost); 201 RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 - 202 TextWidth(S), Y, S); 203 Sprite(Offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, Y + 4, 10, 208 204 10, 88, 115); 209 205 210 if G.Difficulty[ me] <> 2 then206 if G.Difficulty[Me] <> 2 then 211 207 begin // corrected cost bar 212 y:= yTotal + 76;213 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xTotal - 2, y,214 Phrases.Lookup('COSTDIFF' + char(48 + G.Difficulty[ me])));215 LoweredTextOut( offscreen.Canvas, -1, MainTexture,216 xTotal2 + 148 + 30, y, '=');217 DLine( offscreen.Canvas, xTotal - 2, xTotal + 174, y+ 16,208 Y := yTotal + 76; 209 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y, 210 Phrases.Lookup('COSTDIFF' + char(48 + G.Difficulty[Me]))); 211 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, 212 xTotal2 + 148 + 30, Y, '='); 213 DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16, 218 214 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 219 DLine( offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, y+ 16,215 DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16, 220 216 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 221 s:= IntToStr(MyRO.DevModel.Cost * BuildCostMod222 [G.Difficulty[ me]] div 12);223 RisedTextOut( offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -224 TextWidth( s), y, s);225 Sprite( offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, y+ 4, 10,217 S := IntToStr(MyRO.DevModel.Cost * BuildCostMod 218 [G.Difficulty[Me]] div 12); 219 RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 - 220 TextWidth(S), Y, S); 221 Sprite(Offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, Y + 4, 10, 226 222 10, 88, 115); 227 223 end; … … 230 226 231 227 var 232 i, j, x, d, n, TextColor, CapWeight, DomainCount: integer;228 I, J, X, D, N, TextColor, CapWeight, DomainCount: Integer; 233 229 begin 234 230 inherited; … … 239 235 // assemble background from 2 texture tiles 240 236 begin 241 DpiBit Canvas(Back.Canvas, 0, 0, ClientWidth, 64,237 DpiBitBltCanvas(Back.Canvas, 0, 0, ClientWidth, 64, 242 238 MainTexture.Image.Canvas, (MainTexture.Width - ClientWidth) div 2, 243 239 MainTexture.Height - 64); 244 DpiBit Canvas(Back.Canvas, 0, 64, ClientWidth, ClientHeight - 64,240 DpiBitBltCanvas(Back.Canvas, 0, 64, ClientWidth, ClientHeight - 64, 245 241 MainTexture.Image.Canvas, (MainTexture.Width - ClientWidth) div 2, 246 242 0); 247 243 end 248 244 else 249 DpiBit Canvas(Back.Canvas, 0, 0, ClientWidth, ClientHeight,245 DpiBitBltCanvas(Back.Canvas, 0, 0, ClientWidth, ClientHeight, 250 246 MainTexture.Image.Canvas, (MainTexture.Width - ClientWidth) div 2, 251 247 (MainTexture.Height - ClientHeight) div 2); … … 254 250 Template.Height - 64 - Cut); 255 251 256 DpiBit Canvas(offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,252 DpiBitBltCanvas(Offscreen.Canvas, 0, 0, ClientWidth, ClientHeight, 257 253 Back.Canvas, 0, 0); 258 254 259 offscreen.Canvas.Font.Assign(UniFont[ftCaption]);260 RisedTextOut( offscreen.Canvas, 10, 7, Caption);261 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);255 Offscreen.Canvas.Font.Assign(UniFont[ftCaption]); 256 RisedTextOut(Offscreen.Canvas, 10, 7, Caption); 257 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 262 258 263 259 with MyRO.DevModel do 264 260 begin 265 261 DomainCount := 0; 266 for d:= 0 to nDomains - 1 do267 if DomainAvailable( d) then268 inc(DomainCount);262 for D := 0 to nDomains - 1 do 263 if DomainAvailable(D) then 264 Inc(DomainCount); 269 265 if DomainCount > 1 then 270 266 begin 271 for d:= 0 to nDomains - 1 do272 if DomainAvailable( d) then267 for D := 0 to nDomains - 1 do 268 if DomainAvailable(D) then 273 269 begin 274 x := xDomain + d* DomainPitch;275 if d= Domain then276 ImageOp_BCC( offscreen, Templates.Data, x, yDomain, 142, 246 + 37 * d, 36,270 X := xDomain + D * DomainPitch; 271 if D = Domain then 272 ImageOp_BCC(Offscreen, Templates.Data, X, yDomain, 142, 246 + 37 * D, 36, 277 273 36, 0, $00C0FF) 278 274 else 279 ImageOp_BCC( offscreen, Templates.Data, x, yDomain, 142, 246 + 37 * d, 36,275 ImageOp_BCC(Offscreen, Templates.Data, X, yDomain, 142, 246 + 37 * D, 36, 280 276 36, 0, $606060); 281 277 end; 282 Frame( offscreen.Canvas, xDomain - 11, yDomain - 3,278 Frame(Offscreen.Canvas, xDomain - 11, yDomain - 3, 283 279 xDomain + 2 * DomainPitch + 46, yDomain + 38, $B0B0B0, $FFFFFF); 284 RFrame( offscreen.Canvas, xDomain - 12, yDomain - 4,280 RFrame(Offscreen.Canvas, xDomain - 12, yDomain - 4, 285 281 xDomain + 2 * DomainPitch + 47, yDomain + 39, $FFFFFF, $B0B0B0); 286 282 end; … … 295 291 296 292 // display weight 297 with offscreen.Canvas do298 begin 299 for i:= 0 to MaxWeight - 1 do300 if i< Weight then301 ImageOp_BCC( offscreen, Templates.Data, Point(xWeight + 20 * i, yWeight),293 with Offscreen.Canvas do 294 begin 295 for I := 0 to MaxWeight - 1 do 296 if I < Weight then 297 ImageOp_BCC(Offscreen, Templates.Data, Point(xWeight + 20 * I, yWeight), 302 298 WeightOn.BoundsRect, 0, $949494) 303 299 else 304 ImageOp_BCC( offscreen, Templates.Data, Point(xWeight + 20 * i, yWeight),300 ImageOp_BCC(Offscreen, Templates.Data, Point(xWeight + 20 * I, yWeight), 305 301 WeightOff.BoundsRect, 0, $949494); 306 302 end; 307 303 308 with offscreen.Canvas do309 for i:= 0 to Lines - 1 do304 with Offscreen.Canvas do 305 for I := 0 to Lines - 1 do 310 306 begin 311 if not( code[i] in AutoFeature) then307 if not(Code[I] in AutoFeature) then 312 308 begin 313 309 // paint +/- butttons 314 if code[i] < mcFirstNonCap then310 if Code[I] < mcFirstNonCap then 315 311 begin 316 Dump( offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *317 i, 12, 12, 169, 172);318 Dump( offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *319 i, 12, 12, 169, 159);320 RFrame( offscreen.Canvas, xFeature - (21 + 1),321 yFeature + 2 + LinePitch * i- 1, xFeature - (21 - 24),322 yFeature + 2 + LinePitch * i+ 12, MainTexture.ColorBevelShade,312 Dump(Offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch * 313 I, 12, 12, 169, 172); 314 Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch * 315 I, 12, 12, 169, 159); 316 RFrame(Offscreen.Canvas, xFeature - (21 + 1), 317 yFeature + 2 + LinePitch * I - 1, xFeature - (21 - 24), 318 yFeature + 2 + LinePitch * I + 12, MainTexture.ColorBevelShade, 323 319 MainTexture.ColorBevelLight); 324 320 end 325 321 else 326 322 begin 327 Dump( offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *328 i, 12, 12, 169, 185 + 13 * MyRO.DevModel.Cap[code[i]]);329 RFrame( offscreen.Canvas, xFeature - (9 + 1),330 yFeature + 2 + LinePitch * i- 1, xFeature - (21 - 24),331 yFeature + 2 + LinePitch * i+ 12, MainTexture.ColorBevelShade,323 Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch * 324 I, 12, 12, 169, 185 + 13 * MyRO.DevModel.Cap[Code[I]]); 325 RFrame(Offscreen.Canvas, xFeature - (9 + 1), 326 yFeature + 2 + LinePitch * I - 1, xFeature - (21 - 24), 327 yFeature + 2 + LinePitch * I + 12, MainTexture.ColorBevelShade, 332 328 MainTexture.ColorBevelLight); 333 329 end; 334 330 335 331 // paint cost 336 LightGradient( offscreen.Canvas, xFeature + 34,337 yFeature + LinePitch * i, 50, HGrSystem.Data.Canvas.Pixels332 LightGradient(Offscreen.Canvas, xFeature + 34, 333 yFeature + LinePitch * I, 50, HGrSystem.Data.Canvas.Pixels 338 334 [187, 137]); 339 if (Domain = dGround) and ( code[i] = mcDefense) then335 if (Domain = dGround) and (Code[I] = mcDefense) then 340 336 CapWeight := 2 341 337 else 342 CapWeight := Feature[ code[i]].Weight;343 n := CapWeight + Feature[code[i]].Cost;344 d:= 6;345 while ( n - 1) * d* 2 > 48 - 10 do346 dec(d);347 for j := 0 to n- 1 do348 if j< CapWeight then349 Sprite( offscreen, HGrSystem, xFeature + 54 + (j * 2 + 1 - n) * d,350 yFeature + 2 + LinePitch * i+ 1, 10, 10, 88, 126)338 CapWeight := Feature[Code[I]].Weight; 339 N := CapWeight + Feature[Code[I]].Cost; 340 D := 6; 341 while (N - 1) * D * 2 > 48 - 10 do 342 Dec(D); 343 for J := 0 to N - 1 do 344 if J < CapWeight then 345 Sprite(Offscreen, HGrSystem, xFeature + 54 + (J * 2 + 1 - N) * D, 346 yFeature + 2 + LinePitch * I + 1, 10, 10, 88, 126) 351 347 else 352 Sprite( offscreen, HGrSystem, xFeature + 54 + (j * 2 + 1 - n) * d,353 yFeature + 2 + LinePitch * i+ 1, 10, 10, 88, 115);348 Sprite(Offscreen, HGrSystem, xFeature + 54 + (J * 2 + 1 - N) * D, 349 yFeature + 2 + LinePitch * I + 1, 10, 10, 88, 115); 354 350 end; // if not (code[i] in AutoFeature) 355 DarkGradient( offscreen.Canvas, xFeature + 17,356 yFeature + LinePitch * i, 16, 1);357 ScreenTools.Frame( offscreen.Canvas, xFeature + 18, yFeature + 1 + LinePitch * i,358 xFeature + 20 - 2 + 13, yFeature + 2 + 1 - 2 + 13 + LinePitch * i,351 DarkGradient(Offscreen.Canvas, xFeature + 17, 352 yFeature + LinePitch * I, 16, 1); 353 ScreenTools.Frame(Offscreen.Canvas, xFeature + 18, yFeature + 1 + LinePitch * I, 354 xFeature + 20 - 2 + 13, yFeature + 2 + 1 - 2 + 13 + LinePitch * I, 359 355 $C0C0C0, $C0C0C0); 360 Sprite( offscreen, HGrSystem, xFeature + 20, yFeature + 2 + 1 + LinePitch361 * i, 10, 10, 66 + code[i] mod 11 * 11, 137 + code[i] div 11 * 11);362 363 if MyRO.DevModel.Cap[ code[i]] > 0 then356 Sprite(Offscreen, HGrSystem, xFeature + 20, yFeature + 2 + 1 + LinePitch 357 * I, 10, 10, 66 + Code[I] mod 11 * 11, 137 + Code[I] div 11 * 11); 358 359 if MyRO.DevModel.Cap[Code[I]] > 0 then 364 360 TextColor := MainTexture.ColorLitText 365 361 else 366 362 TextColor := -1; 367 363 368 if code[i] < mcFirstNonCap then369 LoweredTextOut( offscreen.Canvas, TextColor, MainTexture, xFeature + 7,370 yFeature + LinePitch * i - 1, IntToStr(MyRO.DevModel.Cap[code[i]]));371 LoweredTextOut( offscreen.Canvas, TextColor, MainTexture, xFeature + 88,372 yFeature + LinePitch * i - 1, Phrases.Lookup('FEATURES', code[i]));364 if Code[I] < mcFirstNonCap then 365 LoweredTextOut(Offscreen.Canvas, TextColor, MainTexture, xFeature + 7, 366 yFeature + LinePitch * I - 1, IntToStr(MyRO.DevModel.Cap[Code[I]])); 367 LoweredTextOut(Offscreen.Canvas, TextColor, MainTexture, xFeature + 88, 368 yFeature + LinePitch * I - 1, Phrases.Lookup('FEATURES', Code[I])); 373 369 end; 374 370 end; 375 371 376 372 // free features 377 j:= 0;378 for i:= 0 to nFeature - 1 do379 if ( i in AutoFeature) and (1 shl Domain and Feature[i].Domains <> 0) and380 (Feature[ i].Preq <> preNA) and381 ((Feature[ i].Preq = preSun) and (MyRO.Wonder[woSun].EffectiveOwner = me)382 or (Feature[ i].Preq >= 0) and (MyRO.Tech[Feature[i].Preq] >= tsApplicable)383 ) and not((Feature[ i].Preq = adSteamEngine) and373 J := 0; 374 for I := 0 to nFeature - 1 do 375 if (I in AutoFeature) and (1 shl Domain and Feature[I].Domains <> 0) and 376 (Feature[I].Preq <> preNA) and 377 ((Feature[I].Preq = preSun) and (MyRO.Wonder[woSun].EffectiveOwner = Me) 378 or (Feature[I].Preq >= 0) and (MyRO.Tech[Feature[I].Preq] >= tsApplicable) 379 ) and not((Feature[I].Preq = adSteamEngine) and 384 380 (MyRO.Tech[adNuclearPower] >= tsApplicable)) then 385 381 begin 386 DarkGradient( offscreen.Canvas, xWeight + 4, yWeight + 32 + LinePitch387 * j, 16, 1);388 Frame( offscreen.Canvas, xWeight + 5, yWeight + 33 + LinePitch * j,389 xWeight + 18, yWeight + 47 + LinePitch * j, $C0C0C0, $C0C0C0);390 Sprite( offscreen, HGrSystem, xWeight + 7, yWeight + 36 + LinePitch * j,391 10, 10, 66 + i mod 11 * 11, 137 + idiv 11 * 11);392 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xWeight + 26,393 yWeight + 31 + LinePitch * j, Phrases.Lookup('FEATURES', i));394 inc(j);395 end; 396 397 with Tribe[ me].ModelPicture[MyRO.nModel] do398 begin 399 FrameImage( offscreen.Canvas, BigImp, xView + 4, yView + 4, xSizeBig,382 DarkGradient(Offscreen.Canvas, xWeight + 4, yWeight + 32 + LinePitch 383 * J, 16, 1); 384 Frame(Offscreen.Canvas, xWeight + 5, yWeight + 33 + LinePitch * J, 385 xWeight + 18, yWeight + 47 + LinePitch * J, $C0C0C0, $C0C0C0); 386 Sprite(Offscreen, HGrSystem, xWeight + 7, yWeight + 36 + LinePitch * J, 387 10, 10, 66 + I mod 11 * 11, 137 + I div 11 * 11); 388 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xWeight + 26, 389 yWeight + 31 + LinePitch * J, Phrases.Lookup('FEATURES', I)); 390 Inc(J); 391 end; 392 393 with Tribe[Me].ModelPicture[MyRO.nModel] do 394 begin 395 FrameImage(Offscreen.Canvas, BigImp, xView + 4, yView + 4, xSizeBig, 400 396 ySizeBig, 0, 0); 401 Sprite( offscreen, HGr, xView, yView, 64, 44, pix mod 10 * 65 + 1,397 Sprite(Offscreen, HGr, xView, yView, 64, 44, pix mod 10 * 65 + 1, 402 398 pix div 10 * 49 + 1); 403 399 end; 404 400 MarkUsedOffscreen(ClientWidth, ClientHeight); 405 end; { MainPaint }406 407 procedure TDraftDlg.SetDomain( d: integer);408 409 function Prio(fix: integer): integer;401 end; 402 403 procedure TDraftDlg.SetDomain(D: Integer); 404 405 function Prio(fix: Integer): Integer; 410 406 var 411 FeaturePreq: integer;407 FeaturePreq: Integer; 412 408 begin 413 409 FeaturePreq := Feature[fix].Preq; 414 assert(FeaturePreq <> preNA);410 Assert(FeaturePreq <> preNA); 415 411 if fix < mcFirstNonCap then 416 result := 10000 + fix412 Result := 10000 + fix 417 413 else if FeaturePreq = preNone then 418 result := 20000414 Result := 20000 419 415 else if FeaturePreq < 0 then 420 result := 40000416 Result := 40000 421 417 else 422 result := 30000 + AdvValue[FeaturePreq];418 Result := 30000 + AdvValue[FeaturePreq]; 423 419 if not(fix in AutoFeature) then 424 inc(result, 90000);420 Inc(Result, 90000); 425 421 end; 426 422 427 423 var 428 i, j, x: integer;429 begin 430 Domain := d;424 I, J, X: Integer; 425 begin 426 Domain := D; 431 427 Lines := 0; 432 for i:= 0 to nFeature - 1 do433 if IsFeatureInList(Domain, i) then434 begin 435 code[Lines] := i;436 inc(Lines)428 for I := 0 to nFeature - 1 do 429 if IsFeatureInList(Domain, I) then 430 begin 431 Code[Lines] := I; 432 Inc(Lines); 437 433 end; 438 434 yFeature := yFeature0 + (MaxLines - Lines) * LinePitch div 2; 439 435 440 436 // sort features 441 for i:= 0 to Lines - 2 do442 for j := i+ 1 to Lines - 1 do443 if Prio( code[i]) > Prio(code[j]) then437 for I := 0 to Lines - 2 do 438 for J := I + 1 to Lines - 1 do 439 if Prio(Code[I]) > Prio(Code[J]) then 444 440 begin // exchange 445 x := code[i];446 code[i] := code[j];447 code[j] := x441 X := Code[I]; 442 Code[I] := Code[J]; 443 Code[J] := X; 448 444 end; 449 445 end; 450 446 451 function TDraftDlg.IsFeatureInList( d, i: integer): boolean;452 begin 453 result := not(i in AutoFeature) and (1 shl d and Feature[i].Domains <> 0) and454 (Feature[ i].Preq <> preNA) and455 ((Feature[ i].Preq = preNone) or (Feature[i].Preq = preSun) and456 (MyRO.Wonder[woSun].EffectiveOwner = me) or (Feature[i].Preq >= 0) and457 (MyRO.Tech[Feature[ i].Preq] >= tsApplicable));447 function TDraftDlg.IsFeatureInList(D, I: Integer): Boolean; 448 begin 449 Result := not(I in AutoFeature) and (1 shl D and Feature[I].Domains <> 0) and 450 (Feature[I].Preq <> preNA) and 451 ((Feature[I].Preq = preNone) or (Feature[I].Preq = preSun) and 452 (MyRO.Wonder[woSun].EffectiveOwner = Me) or (Feature[I].Preq >= 0) and 453 (MyRO.Tech[Feature[I].Preq] >= tsApplicable)); 458 454 end; 459 455 460 456 procedure TDraftDlg.FormShow(Sender: TObject); 461 457 var 462 count, d, i: integer;458 count, D, I: Integer; 463 459 begin 464 460 Domain := dGround; 465 461 while (Domain < dAir) and (upgrade[Domain, 0].Preq <> preNone) and 466 462 (MyRO.Tech[upgrade[Domain, 0].Preq] < tsApplicable) do 467 inc(Domain);463 Inc(Domain); 468 464 469 465 // count max number of features in any domain 470 466 MaxLines := 0; 471 for d:= 0 to nDomains - 1 do472 if (upgrade[ d, 0].Preq = preNone) or473 (MyRO.Tech[upgrade[ d, 0].Preq] >= tsApplicable) then467 for D := 0 to nDomains - 1 do 468 if (upgrade[D, 0].Preq = preNone) or 469 (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable) then 474 470 begin 475 471 count := 0; 476 for i:= 0 to nFeature - 1 do477 if IsFeatureInList( d, i) then478 inc(count);472 for I := 0 to nFeature - 1 do 473 if IsFeatureInList(D, I) then 474 Inc(count); 479 475 if count > MaxLines then 480 476 MaxLines := count; … … 494 490 495 491 SetDomain(Domain); 496 Server(sCreateDevModel, me, Domain, nil^);492 Server(sCreateDevModel, Me, Domain, nil^); 497 493 MyModel[MyRO.nModel] := MyRO.DevModel; 498 InitMyModel(MyRO.nModel, false);494 InitMyModel(MyRO.nModel, False); 499 495 OffscreenPaint; 500 496 IncCap := -1; … … 502 498 end; 503 499 504 procedure TDraftDlg.ShowNewContent(NewMode: integer);500 procedure TDraftDlg.ShowNewContent(NewMode: TWindowMode); 505 501 begin 506 502 inherited ShowNewContent(NewMode); … … 508 504 509 505 procedure TDraftDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 510 Shift: TShiftState; x, y: integer);506 Shift: TShiftState; X, Y: Integer); 511 507 var 512 i, d: integer;508 I, D: Integer; 513 509 begin 514 510 if Button = mbLeft then 515 511 begin 516 for d:= 0 to nDomains - 1 do517 if ( d <> Domain) and ((upgrade[d, 0].Preq = preNone) or518 (MyRO.Tech[upgrade[ d, 0].Preq] >= tsApplicable)) and519 ( x >= xDomain + d* DomainPitch) and520 ( x < xDomain + d * DomainPitch + 36) and (y>= yDomain) and521 ( y< yDomain + 36) then512 for D := 0 to nDomains - 1 do 513 if (D <> Domain) and ((upgrade[D, 0].Preq = preNone) or 514 (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable)) and 515 (X >= xDomain + D * DomainPitch) and 516 (X < xDomain + D * DomainPitch + 36) and (Y >= yDomain) and 517 (Y < yDomain + 36) then 522 518 begin 523 SetDomain( d);524 Server(sCreateDevModel, me, Domain, nil^);519 SetDomain(D); 520 Server(sCreateDevModel, Me, Domain, nil^); 525 521 MyModel[MyRO.nModel] := MyRO.DevModel; 526 InitMyModel(MyRO.nModel, false);522 InitMyModel(MyRO.nModel, False); 527 523 SmartUpdateContent; 528 524 end; 529 525 530 if ( y >= yFeature) and (y< yFeature + LinePitch * Lines) then531 begin 532 i := (y- yFeature) div LinePitch;533 if ( x >= xFeature - 21) and (x< ClientWidth) and (ssShift in Shift) then534 HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkFeature, code[i])535 else if not( code[i] in AutoFeature) then526 if (Y >= yFeature) and (Y < yFeature + LinePitch * Lines) then 527 begin 528 I := (Y - yFeature) div LinePitch; 529 if (X >= xFeature - 21) and (X < ClientWidth) and (ssShift in Shift) then 530 MainScreen.HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkFeature, Code[I]) 531 else if not(Code[I] in AutoFeature) then 536 532 begin 537 if ( code[i] < mcFirstNonCap) and (x>= xFeature - 21) and538 ( x< xFeature - 21 + 12) then533 if (Code[I] < mcFirstNonCap) and (X >= xFeature - 21) and 534 (X < xFeature - 21 + 12) then 539 535 begin 540 IncCap := code[i];541 Dump( offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *542 i, 12, 12, 182, 172);536 IncCap := Code[I]; 537 Dump(Offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch * 538 I, 12, 12, 182, 172); 543 539 SmartInvalidate; 544 540 end 545 else if ( x >= xFeature - 9) and (x< xFeature - 9 + 12) then541 else if (X >= xFeature - 9) and (X < xFeature - 9 + 12) then 546 542 begin 547 DecCap := code[i];548 if code[i] < mcFirstNonCap then549 Dump( offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *550 i, 12, 12, 182, 159)543 DecCap := Code[I]; 544 if Code[I] < mcFirstNonCap then 545 Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch * 546 I, 12, 12, 182, 159) 551 547 else 552 Dump( offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *553 i, 12, 12, 182, 185 + 13 * MyRO.DevModel.Cap[code[i]]);548 Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch * 549 I, 12, 12, 182, 185 + 13 * MyRO.DevModel.Cap[Code[I]]); 554 550 SmartInvalidate; 555 551 end; 556 end 557 end 558 end 552 end; 553 end; 554 end; 559 555 end; 560 556 561 557 procedure TDraftDlg.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton; 562 Shift: TShiftState; x, y: integer);558 Shift: TShiftState; X, Y: Integer); 563 559 var 564 NewValue: integer;560 NewValue: Integer; 565 561 begin 566 562 if IncCap >= 0 then 567 563 begin 568 564 NewValue := MyRO.DevModel.Cap[IncCap] + 1; 569 Server(sSetDevModelCap + NewValue shl 4, me, IncCap, nil^);565 Server(sSetDevModelCap + NewValue shl 4, Me, IncCap, nil^); 570 566 MyModel[MyRO.nModel] := MyRO.DevModel; 571 InitMyModel(MyRO.nModel, false);567 InitMyModel(MyRO.nModel, False); 572 568 SmartUpdateContent; 573 569 IncCap := -1; … … 580 576 if DecCap >= mcFirstNonCap then 581 577 NewValue := -NewValue; 582 Server(sSetDevModelCap + NewValue shl 4, me, DecCap, nil^);578 Server(sSetDevModelCap + NewValue shl 4, Me, DecCap, nil^); 583 579 MyModel[MyRO.nModel] := MyRO.DevModel; 584 InitMyModel(MyRO.nModel, false);580 InitMyModel(MyRO.nModel, False); 585 581 end; 586 582 SmartUpdateContent; -
TabularUnified branches/highdpi/LocalPlayer/Enhance.pas ¶
r361 r465 5 5 6 6 uses 7 UDpiControls, ScreenTools, BaseWin, Protocol, ClientTools, Term, LCLIntf, LCLType, 8 9 SysUtils, Classes, Graphics, Controls, Forms, IsoEngine, 10 ButtonB, ButtonC, Menus; 7 UDpiControls, ScreenTools, BaseWin, Protocol, ClientTools, LCLIntf, LCLType, SysUtils, 8 Classes, Graphics, Controls, Forms, IsoEngine, ButtonB, ButtonC, Menus; 11 9 12 10 type … … 39 37 NoMap: TIsoMap; 40 38 public 41 procedure ShowNewContent(NewMode: integer; TerrType: integer = -1);39 procedure ShowNewContent(NewMode: TWindowMode; TerrType: Integer = -1); 42 40 protected 43 Page: integer;41 Page: Integer; 44 42 procedure OffscreenPaint; override; 45 43 end; 46 44 47 var48 EnhanceDlg: TEnhanceDlg;49 50 45 51 46 implementation 52 47 53 48 uses 54 Help, UKeyBindings;49 Help, KeyBindings, Term; 55 50 56 51 {$R *.lfm} … … 58 53 procedure TEnhanceDlg.FormCreate(Sender: TObject); 59 54 var 60 TerrType: integer;61 m: TDpiMenuItem;55 TerrType: Integer; 56 M: TDpiMenuItem; 62 57 begin 63 58 inherited; … … 73 68 if TerrType <> fJungle then 74 69 begin 75 m:= TDpiMenuItem.Create(Popup);76 m.RadioItem := true;70 M := TDpiMenuItem.Create(Popup); 71 M.RadioItem := True; 77 72 if TerrType = fGrass then 78 m.Caption := Format(Phrases.Lookup('TWOTERRAINS'),73 M.Caption := Format(Phrases.Lookup('TWOTERRAINS'), 79 74 [Phrases.Lookup('TERRAIN', fGrass), Phrases.Lookup('TERRAIN', 80 75 fGrass + 12)]) 81 76 else if TerrType = fForest then 82 m.Caption := Format(Phrases.Lookup('TWOTERRAINS'),77 M.Caption := Format(Phrases.Lookup('TWOTERRAINS'), 83 78 [Phrases.Lookup('TERRAIN', fForest), Phrases.Lookup('TERRAIN', 84 79 fJungle)]) 85 80 else 86 m.Caption := Phrases.Lookup('TERRAIN', TerrType);87 m.Tag := TerrType;88 m.OnClick := TerrClick;89 Popup.Items.Add( m);81 M.Caption := Phrases.Lookup('TERRAIN', TerrType); 82 M.Tag := TerrType; 83 M.OnClick := TerrClick; 84 Popup.Items.Add(M); 90 85 end; 91 86 end; … … 98 93 procedure TEnhanceDlg.FormPaint(Sender: TObject); 99 94 var 100 i: integer;95 I: Integer; 101 96 begin 102 97 inherited; … … 105 100 BtnFrame(Canvas, Rect(job3.Left, job3.Top, job9.Left + job9.Width, 106 101 job3.Top + job3.Height), MainTexture); 107 for i:= 0 to ControlCount - 1 do108 if Controls[ i] is TButtonC then109 DpiBit Canvas(Canvas, Controls[i].Left + 2, Controls[i].Top - 11, 8, 8,110 HGrSystem.Data.Canvas, 121 + Controls[ i].Tag mod 7 * 9,111 1 + Controls[ i].Tag div 7 * 9);102 for I := 0 to ControlCount - 1 do 103 if Controls[I] is TButtonC then 104 DpiBitBltCanvas(Canvas, Controls[I].Left + 2, Controls[I].Top - 11, 8, 8, 105 HGrSystem.Data.Canvas, 121 + Controls[I].Tag mod 7 * 9, 106 1 + Controls[I].Tag div 7 * 9); 112 107 end; 113 108 … … 117 112 end; 118 113 119 procedure TEnhanceDlg.ShowNewContent(NewMode , TerrType: integer);114 procedure TEnhanceDlg.ShowNewContent(NewMode: TWindowMode; TerrType: Integer); 120 115 begin 121 116 if (TerrType < fGrass) or (TerrType > fMountains) then … … 128 123 procedure TEnhanceDlg.OffscreenPaint; 129 124 var 130 i, stage, TerrType, TileImp, x, EndStage, Cost, LastJob: integer;131 s: string;132 Done: Set of jNone .. jTrans;133 TypeChanged: boolean;125 I, stage, TerrType, TileImp, X, EndStage, Cost, LastJob: Integer; 126 S: string; 127 Done: set of jNone .. jTrans; 128 TypeChanged: Boolean; 134 129 begin 135 130 OffscreenUser := self; 136 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);131 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 137 132 FillOffscreen(0, 0, InnerWidth, InnerHeight); 138 133 139 134 EndStage := 0; 140 135 while (EndStage < 5) and (MyData.EnhancementJobs[Page, EndStage] <> jNone) do 141 inc(EndStage);136 Inc(EndStage); 142 137 with NoMap do 143 x:= InnerWidth div 2 - xxt - (xxt + 3) * EndStage;138 X := InnerWidth div 2 - xxt - (xxt + 3) * EndStage; 144 139 145 140 TerrType := Page; … … 151 146 if stage > 0 then 152 147 begin 153 Sprite( offscreen, HGrSystem, x- 10, 66, 14, 14, 80, 1);148 Sprite(Offscreen, HGrSystem, X - 10, 66, 14, 14, 80, 1); 154 149 case MyData.EnhancementJobs[Page, stage - 1] of 155 150 jRoad: 156 151 begin 157 inc(Cost, Terrain[TerrType].MoveCost * RoadWork);152 Inc(Cost, Terrain[TerrType].MoveCost * RoadWork); 158 153 TileImp := TileImp or fRoad; 159 154 end; 160 155 jRR: 161 156 begin 162 inc(Cost, Terrain[TerrType].MoveCost * RRWork);157 Inc(Cost, Terrain[TerrType].MoveCost * RRWork); 163 158 TileImp := TileImp or fRR; 164 159 end; 165 160 jIrr: 166 161 begin 167 inc(Cost, Terrain[TerrType].IrrClearWork);162 Inc(Cost, Terrain[TerrType].IrrClearWork); 168 163 TileImp := TileImp and not fTerImp or tiIrrigation; 169 164 end; 170 165 jFarm: 171 166 begin 172 inc(Cost, Terrain[TerrType].IrrClearWork * FarmWork);167 Inc(Cost, Terrain[TerrType].IrrClearWork * FarmWork); 173 168 TileImp := TileImp and not fTerImp or tiFarm; 174 169 end; 175 170 jMine: 176 171 begin 177 inc(Cost, Terrain[TerrType].MineAfforestWork);172 Inc(Cost, Terrain[TerrType].MineAfforestWork); 178 173 TileImp := TileImp and not fTerImp or tiMine; 179 174 end; 180 175 jClear: 181 176 begin 182 inc(Cost, Terrain[TerrType].IrrClearWork);177 Inc(Cost, Terrain[TerrType].IrrClearWork); 183 178 TerrType := Terrain[TerrType].ClearTerrain; 184 179 end; 185 180 jAfforest: 186 181 begin 187 inc(Cost, Terrain[TerrType].MineAfforestWork);182 Inc(Cost, Terrain[TerrType].MineAfforestWork); 188 183 TerrType := Terrain[TerrType].AfforestTerrain; 189 184 end; 190 185 jTrans: 191 186 begin 192 inc(Cost, Terrain[TerrType].TransWork);187 Inc(Cost, Terrain[TerrType].TransWork); 193 188 TerrType := Terrain[TerrType].TransTerrain; 194 189 end; 195 190 end; 196 include(Done, MyData.EnhancementJobs[Page, stage - 1]);191 Include(Done, MyData.EnhancementJobs[Page, stage - 1]); 197 192 end; 198 193 199 194 with NoMap do begin 200 195 if TerrType < fForest then 201 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,196 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 202 197 1 + TerrType * (xxt * 2 + 1), 1 + yyt) 203 198 else 204 199 begin 205 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,200 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 206 201 1 + 2 * (xxt * 2 + 1), 1 + yyt + 2 * (yyt * 3 + 1)); 207 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,202 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 208 203 1 + 7 * (xxt * 2 + 1), 1 + yyt + 2 * (2 + TerrType - fForest) * 209 204 (yyt * 3 + 1)); 210 205 end; 211 206 if TileImp and fTerImp = tiFarm then 212 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,207 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 213 208 1 + (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1)) 214 209 else if TileImp and fTerImp = tiIrrigation then 215 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1,210 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 1, 216 211 1 + yyt + 12 * (yyt * 3 + 1)); 217 212 if TileImp and fRR <> 0 then 218 213 begin 219 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,214 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 220 215 1 + 6 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1)); 221 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,216 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 222 217 1 + 2 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1)); 223 218 end 224 219 else if TileImp and fRoad <> 0 then 225 220 begin 226 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,221 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 227 222 1 + 6 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1)); 228 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,223 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 229 224 1 + 2 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1)); 230 225 end; 231 226 if TileImp and fTerImp = tiMine then 232 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,227 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 233 228 1 + 2 * (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1)); 234 inc(x, xxt * 2 + 6);235 end; 236 end; 237 238 for i:= 0 to Popup.Items.Count - 1 do239 if Popup.Items[ i].Tag = Page then240 s := Popup.Items[i].Caption;229 Inc(X, xxt * 2 + 6); 230 end; 231 end; 232 233 for I := 0 to Popup.Items.Count - 1 do 234 if Popup.Items[I].Tag = Page then 235 S := Popup.Items[I].Caption; 241 236 if Cost > 0 then 242 s := Format(Phrases.Lookup('ENHANCE'), [s, MovementToString(Cost)]);243 LoweredTextOut( offscreen.Canvas, -1, MainTexture,244 (InnerWidth - BiColorTextWidth( offscreen.Canvas, s)) div 2, 12, s);237 S := Format(Phrases.Lookup('ENHANCE'), [S, MovementToString(Cost)]); 238 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, 239 (InnerWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2, 12, S); 245 240 246 241 if EndStage > 0 then … … 291 286 (Terrain[TerrType].MineEff > 0); 292 287 job3.Visible := not TypeChanged and (Terrain[TerrType].ClearTerrain >= 0) and 293 ((TerrType <> fDesert) or (MyRO.Wonder[woGardens].EffectiveOwner = me)) or288 ((TerrType <> fDesert) or (MyRO.Wonder[woGardens].EffectiveOwner = Me)) or 294 289 (LastJob = jClear); 295 290 job6.Visible := not TypeChanged and (Terrain[TerrType].AfforestTerrain >= 0) … … 299 294 300 295 MarkUsedOffscreen(InnerWidth, InnerHeight); 301 end; { OffscreenPaint }296 end; 302 297 303 298 procedure TEnhanceDlg.CloseBtnClick(Sender: TObject); … … 308 303 procedure TEnhanceDlg.ToggleBtnClick(Sender: TObject); 309 304 var 310 i: integer;311 begin 312 for i:= 0 to Popup.Items.Count - 1 do313 Popup.Items[ i].Checked := Popup.Items[i].Tag = Page;305 I: Integer; 306 begin 307 for I := 0 to Popup.Items.Count - 1 do 308 Popup.Items[I].Checked := Popup.Items[I].Tag = Page; 314 309 Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top + ToggleBtn.Height); 315 310 end; … … 323 318 procedure TEnhanceDlg.JobClick(Sender: TObject); 324 319 var 325 stage, NewJob: integer;320 Stage, NewJob: Integer; 326 321 Done: Set of jNone .. jTrans; 327 322 328 procedure RemoveJob( j: integer);323 procedure RemoveJob(J: Integer); 329 324 begin // remove job 330 stage := 0;331 while ( stage < 5) and (MyData.EnhancementJobs[Page, stage] <> jNone) do332 begin 333 if (MyData.EnhancementJobs[Page, stage] = j) or (j= jRoad) and334 (MyData.EnhancementJobs[Page, stage] = jRR) or (j= jIrr) and335 (MyData.EnhancementJobs[Page, stage] = jFarm) then325 Stage := 0; 326 while (Stage < 5) and (MyData.EnhancementJobs[Page, Stage] <> jNone) do 327 begin 328 if (MyData.EnhancementJobs[Page, Stage] = J) or (J = jRoad) and 329 (MyData.EnhancementJobs[Page, Stage] = jRR) or (J = jIrr) and 330 (MyData.EnhancementJobs[Page, Stage] = jFarm) then 336 331 begin 337 if stage < 4 then338 move(MyData.EnhancementJobs[Page, stage + 1],339 MyData.EnhancementJobs[Page, stage], 4 - stage);332 if Stage < 4 then 333 Move(MyData.EnhancementJobs[Page, Stage + 1], 334 MyData.EnhancementJobs[Page, Stage], 4 - Stage); 340 335 MyData.EnhancementJobs[Page, 4] := jNone; 341 336 end 342 337 else 343 inc(stage);338 Inc(Stage); 344 339 end; 345 340 end; … … 348 343 NewJob := TButtonC(Sender).Tag; 349 344 Done := []; 350 stage := 0;351 while ( stage < 5) and (MyData.EnhancementJobs[Page, stage] <> jNone) do345 Stage := 0; 346 while (Stage < 5) and (MyData.EnhancementJobs[Page, Stage] <> jNone) do 352 347 begin 353 include(Done, MyData.EnhancementJobs[Page, stage]);354 inc(stage);348 Include(Done, MyData.EnhancementJobs[Page, Stage]); 349 Inc(Stage); 355 350 end; 356 351 if NewJob in Done then … … 364 359 if (NewJob = jRR) and not(jRoad in Done) then 365 360 begin 366 MyData.EnhancementJobs[Page, stage] := jRoad;367 inc(stage);361 MyData.EnhancementJobs[Page, Stage] := jRoad; 362 Inc(Stage); 368 363 end; 369 364 if (NewJob = jFarm) and not(jIrr in Done) then 370 365 begin 371 MyData.EnhancementJobs[Page, stage] := jIrr;372 inc(stage);373 end; 374 MyData.EnhancementJobs[Page, stage] := NewJob;366 MyData.EnhancementJobs[Page, Stage] := jIrr; 367 Inc(Stage); 368 end; 369 MyData.EnhancementJobs[Page, Stage] := NewJob; 375 370 end; 376 371 SmartUpdateContent; … … 384 379 ShortCut := KeyToShortCut(Key, Shift); 385 380 if BHelp.Test(ShortCut) then 386 HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText,387 HelpDlg.TextIndex('MACRO'))381 MainScreen.HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkText, 382 MainScreen.HelpDlg.TextIndex('MACRO')) 388 383 end; 389 384 -
TabularUnified branches/highdpi/LocalPlayer/Help.pas ¶
r412 r465 7 7 UDpiControls, Protocol, ScreenTools, BaseWin, StringTables, Math, LCLIntf, LCLType, 8 8 Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls, 9 ButtonB, PVSB, Types, fgl, IsoEngine;9 ButtonB, PVSB, Types, Generics.Collections, IsoEngine; 10 10 11 11 const 12 12 MaxHist = 16; 13 13 14 { link categories } 15 hkNoLink = 0; 16 hkAdv = 1; 17 hkImp = 2; 18 hkTer = 3; 19 hkFeature = 4; 20 hkInternet = 5; 21 hkModel = 6; 22 hkMisc = 7; 23 hkCrossLink = $40; 24 hkText = $80; 25 26 liInvalid = $3FFF; // link index indicates invalid link 27 28 { link indices for category hkMisc } 29 miscMain = 0; 30 miscCredits = 1; 31 miscGovList = 2; 32 miscJobList = 3; 33 miscSearchResult = 7; 34 35 fJungle = 8; // pseudo terrain 14 fJungle = 8; // Pseudo terrain 36 15 37 16 type 17 { Link categories } 18 TLinkCategory = ( 19 hkNoLink, 20 hkAdv, 21 hkImp, 22 hkTer, 23 hkFeature , 24 hkInternet, 25 hkModel, 26 hkMisc, 27 hkText); 28 29 { Link indices for category hkMisc } 30 TMiscLinkIndex = ( 31 miscMain, 32 miscCredits, 33 miscGovList, 34 miscJobList, 35 miscSearchResult); 36 37 TTextFormat = ( 38 pkNormal, 39 pkCaption, 40 pkSmallIcon, 41 pkBigIcon, 42 pkAdvIcon, 43 pkTer, 44 pkBigTer, 45 pkFeature, 46 pkDot, 47 pkNormal_Dot, 48 pkDomain, 49 pkSection, 50 pkBigFeature, 51 pkExp, 52 pkAITStat, 53 pkExternal, 54 pkModel, 55 pkNormal_64, 56 pkIllu, 57 pkLogo, 58 pkTerImp, 59 pkRightIcon, 60 pkAdvIcon_AsPreq, 61 pkSmallIcon_AsPreq, 62 pkSpecialIcon, 63 pkGov); 38 64 39 65 { THyperText } … … 41 67 THyperText = class(TStringList) 42 68 public 43 procedure AddLine( s: String = ''; Format: integer = 0; Picpix: Integer = 0;44 LinkCategory: integer = 0; LinkIndex: integer = 0);69 procedure AddLine(S: String = ''; Format: TTextFormat = pkNormal; Picpix: Integer = 0; 70 LinkCategory: TLinkCategory = hkNoLink; LinkIndex: Integer = 0; CrossLink: Boolean = False); 45 71 procedure LineFeed; 46 72 procedure AppendList(Source: THyperText); 47 destructor Destroy; override;48 73 end; 49 74 … … 51 76 52 77 THistItem = class 53 Kind: Integer;78 Kind: TLinkCategory; 54 79 No: Integer; 55 80 Pos: Integer; … … 60 85 { THistItems } 61 86 62 THistItems = class(T FPGObjectList<THistItem>)63 function AddNew(Kind ,No, Pos: Integer; SearchContent: string): THistItem;87 THistItems = class(TObjectList<THistItem>) 88 function AddNew(Kind: TLinkCategory; No, Pos: Integer; SearchContent: string): THistItem; 64 89 end; 65 90 … … 78 103 procedure CloseBtnClick(Sender: TObject); 79 104 procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; 80 x, y: integer);105 X, Y: Integer); 81 106 procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 82 Shift: TShiftState; x, y: integer);107 Shift: TShiftState; X, Y: Integer); 83 108 procedure BackBtnClick(Sender: TObject); 84 109 procedure TopBtnClick(Sender: TObject); … … 89 114 procedure OffscreenPaint; override; 90 115 private 91 Kind: Integer;92 no: Integer;116 Kind: TLinkCategory; 117 No: Integer; 93 118 Sel: Integer; 94 119 CaptionColor: Integer; … … 100 125 SearchResult: THyperText; 101 126 HelpText: TStringTable; 102 ExtPic, TerrIcon: TDpiBitmap; 127 ExtPic: TDpiBitmap; 128 TerrIcon: TDpiBitmap; 103 129 ScrollBar: TPVScrollbar; 104 130 NoMap: TIsoMap; 105 131 x0: array [-2..180] of Integer; 106 procedure PaintTerrIcon( x, y, xSrc, ySrc: Integer);132 procedure PaintTerrIcon(X, Y, xSrc, ySrc: Integer); 107 133 procedure ScrollBarUpdate(Sender: TObject); 108 procedure Line( ca: TDpiCanvas; i: Integer; lit: Boolean);134 procedure Line(ACanvas: TDpiCanvas; I: Integer; Lit: Boolean); 109 135 procedure Prepare(sbPos: Integer = 0); 110 procedure ShowNewContentProcExecute(NewMode: Integer; HelpContext: string);136 procedure ShowNewContentProcExecute(NewMode: TWindowMode; HelpContext: string); 111 137 procedure WaterSign(x0, y0, iix: Integer); 112 138 procedure Search(SearchString: string); … … 117 143 Difficulty: Integer; 118 144 procedure ClearHistory; 119 procedure ShowNewContent(NewMode , Category,Index: Integer);145 procedure ShowNewContent(NewMode: TWindowMode; Category: TLinkCategory; Index: Integer); 120 146 function TextIndex(Item: string): Integer; 121 147 end; 122 148 123 var124 HelpDlg: THelpDlg;125 126 149 127 150 implementation 128 151 129 152 uses 130 Directories, ClientTools, Term, Tribes, Inp, Messg, UPixelPointer, Global,131 UKeyBindings;153 Directories, ClientTools, Term, Tribes, Inp, Messg, PixelPointer, Global, 154 KeyBindings; 132 155 133 156 {$R *.lfm} … … 138 161 139 162 THelpLineInfo = class 140 Format: Byte;163 Format: TTextFormat; 141 164 Picpix: Byte; 142 Link: Word; 165 Category: TLinkCategory; 166 Index: Integer; 167 CrossLink: Boolean; 143 168 procedure Assign(Source: THelpLineInfo); 144 169 end; 145 170 146 { THelpLineInfo } 147 148 procedure THelpLineInfo.Assign(Source: THelpLineInfo); 149 begin 150 Format := Source.Format; 151 PicPix := Source.PicPix; 152 Link := Source.Link; 153 end; 154 155 { THistItem } 156 157 procedure THistItem.Assign(Source: THistItem); 158 begin 159 Kind := Source.Kind; 160 No := Source.No; 161 Pos := Source.Pos; 162 SearchContent := Source.SearchContent; 163 end; 164 165 { THistItems } 166 167 function THistItems.AddNew(Kind, No, Pos: Integer; SearchContent: string 168 ): THistItem; 169 begin 170 Result := THistItem.Create; 171 Result.Kind := Kind; 172 Result.No := No; 173 Result.Pos := Pos; 174 Result.SearchContent := SearchContent; 175 Add(Result); 176 end; 177 178 procedure THyperText.AddLine(s: String; Format: integer; Picpix: integer; 179 LinkCategory: integer; LinkIndex: integer); 180 var 181 HelpLineInfo: THelpLineInfo; 182 begin 183 HelpLineInfo := THelpLineInfo.Create; 184 if LinkIndex < 0 then 185 LinkIndex := liInvalid; 186 HelpLineInfo.Format := Format; 187 HelpLineInfo.Picpix := Picpix; 188 HelpLineInfo.Link := LinkCategory shl 8 + LinkIndex; 189 AddObject(s, TObject(HelpLineInfo)); 190 end; 191 192 procedure THyperText.LineFeed; 193 begin 194 AddLine; 195 end; 196 197 procedure THyperText.AppendList(Source: THyperText); 198 var 199 I: Integer; 200 HelpLineInfo: THelpLineInfo; 201 begin 202 for I := 0 to Source.Count - 1 do begin 203 HelpLineInfo := THelpLineInfo.Create; 204 HelpLineInfo.Assign(THelpLineInfo(Source.Objects[I])); 205 AddObject(Source.Strings[I], HelpLineInfo); 206 end; 207 end; 208 209 destructor THyperText.Destroy; 210 begin 211 inherited; 212 end; 171 TSeeAlso = record 172 Kind: TLinkCategory; 173 No: Integer; 174 SeeKind: TLinkCategory; 175 SeeNo: Integer; 176 end; 213 177 214 178 const 215 { text formats } 216 pkNormal = 0; 217 pkCaption = 1; 218 pkSmallIcon = 2; 219 pkBigIcon = 3; 220 pkAdvIcon = 4; 221 pkTer = 5; 222 pkBigTer = 6; 223 pkFeature = 7; 224 pkDot = 8; 225 pkNormal_Dot = 9; 226 pkDomain = 10; 227 pkSection = 11; 228 pkBigFeature = 12; 229 pkExp = 13; 230 pkAITStat = 14; 231 pkExternal = 15; 232 pkModel = 16; 233 pkNormal_64 = 17; 234 pkIllu = 18; 235 pkLogo = 19; 236 pkTerImp = 20; 237 pkRightIcon = 21; 238 pkAdvIcon_AsPreq = 22; 239 pkSmallIcon_AsPreq = 23; 240 pkSpecialIcon = 24; 241 pkGov = 25; 242 243 nSeeAlso = 14; 244 SeeAlso: array [0 .. nSeeAlso - 1] of record 245 Kind: Integer; 246 no: Integer; 247 SeeKind: Integer; 248 SeeNo: Integer; 249 end = ((Kind: hkImp; no: imWalls; SeeKind: hkFeature; 179 SeeAlso: array[0..13] of TSeeAlso = ((Kind: hkImp; no: imWalls; SeeKind: hkFeature; 250 180 SeeNo: mcArtillery), (Kind: hkImp; no: imHydro; SeeKind: hkImp; 251 181 SeeNo: woHoover), (Kind: hkImp; no: imWalls; SeeKind: hkImp; … … 262 192 SeeKind: hkFeature; SeeNo: mcDefense)); 263 193 264 nTerrainHelp = 14; 265 TerrainHelp: array [0 .. nTerrainHelp - 1] of integer = (fGrass, fGrass + 12, 194 TerrainHelp: array[0..13] of Integer = (fGrass, fGrass + 12, 266 195 fPrairie, fForest, fJungle, fHills, fMountains, fSwamp, fTundra, fArctic, 267 fDesert, 3 * 12 { DeadLands } , fShore, fOcean); 268 269 nJobHelp = 8; 270 JobHelp: array [0 .. nJobHelp - 1] of integer = (jRoad, jRR, jCanal, jIrr, 196 fDesert, 3 * 12 { DeadLands }, fShore, fOcean); 197 198 JobHelp: array[0..7] of Integer = (jRoad, jRR, jCanal, jIrr, 271 199 jFarm, jMine, jFort, jBase); 272 200 201 { THelpLineInfo } 202 203 procedure THelpLineInfo.Assign(Source: THelpLineInfo); 204 begin 205 Format := Source.Format; 206 PicPix := Source.PicPix; 207 Category := Source.Category; 208 Index := Source.Index; 209 end; 210 211 { THistItem } 212 213 procedure THistItem.Assign(Source: THistItem); 214 begin 215 Kind := Source.Kind; 216 No := Source.No; 217 Pos := Source.Pos; 218 SearchContent := Source.SearchContent; 219 end; 220 221 { THistItems } 222 223 function THistItems.AddNew(Kind: TLinkCategory; No, Pos: Integer; SearchContent: string 224 ): THistItem; 225 begin 226 Result := THistItem.Create; 227 Result.Kind := Kind; 228 Result.No := No; 229 Result.Pos := Pos; 230 Result.SearchContent := SearchContent; 231 Add(Result); 232 end; 233 234 procedure THyperText.AddLine(S: String; Format: TTextFormat; Picpix: Integer; 235 LinkCategory: TLinkCategory = hkNoLink; LinkIndex: Integer = 0; 236 CrossLink: Boolean = False); 237 var 238 HelpLineInfo: THelpLineInfo; 239 begin 240 HelpLineInfo := THelpLineInfo.Create; 241 HelpLineInfo.Format := Format; 242 HelpLineInfo.Picpix := Picpix; 243 HelpLineInfo.Category := LinkCategory; 244 HelpLineInfo.Index := LinkIndex; 245 HelpLineInfo.CrossLink := CrossLink; 246 AddObject(S, HelpLineInfo); 247 end; 248 249 procedure THyperText.LineFeed; 250 begin 251 AddLine; 252 end; 253 254 procedure THyperText.AppendList(Source: THyperText); 255 var 256 I: Integer; 257 HelpLineInfo: THelpLineInfo; 258 begin 259 for I := 0 to Source.Count - 1 do begin 260 HelpLineInfo := THelpLineInfo.Create; 261 HelpLineInfo.Assign(THelpLineInfo(Source.Objects[I])); 262 AddObject(Source.Strings[I], HelpLineInfo); 263 end; 264 end; 265 273 266 procedure THelpDlg.FormCreate(Sender: TObject); 274 267 begin 275 inherited;276 268 NoMap := TIsoMap.Create; 277 269 … … 280 272 CaptionLeft := BackBtn.Left + BackBtn.Width; 281 273 CaptionRight := SearchBtn.Left; 282 inc(ModalFrameIndent, 29);274 Inc(ModalFrameIndent, 29); 283 275 MainText := THyperText.Create; 284 276 MainText.OwnsObjects := True; … … 290 282 291 283 HelpText := TStringTable.Create; 292 HelpText.LoadFromFile(LocalizedFilePath('Help' + DirectorySeparator + ' help.txt'));284 HelpText.LoadFromFile(LocalizedFilePath('Help' + DirectorySeparator + 'Help.txt')); 293 285 hADVHELP := HelpText.Gethandle('ADVHELP'); 294 286 hIMPHELP := HelpText.Gethandle('IMPHELP'); … … 316 308 end; 317 309 318 procedure THelpDlg.ShowNewContentProcExecute(NewMode: Integer;310 procedure THelpDlg.ShowNewContentProcExecute(NewMode: TWindowMode; 319 311 HelpContext: string); 320 312 begin 321 HelpDlg.ShowNewContent(NewMode, hkText, 322 HelpDlg.TextIndex(HelpContext)) 313 ShowNewContent(NewMode, hkText, TextIndex(HelpContext)); 323 314 end; 324 315 … … 356 347 if ScrollBar.Process(Msg) then begin 357 348 Sel := -1; 358 SmartUpdateContent( true)349 SmartUpdateContent(True) 359 350 end; 360 351 } … … 364 355 begin 365 356 if Sel <> -1 then begin 366 Line(Canvas, Sel, false);367 Sel := -1 357 Line(Canvas, Sel, False); 358 Sel := -1; 368 359 end; 369 360 end; … … 380 371 end; 381 372 382 procedure THelpDlg.Line( ca: TDpiCanvas; i: Integer; lit: Boolean);373 procedure THelpDlg.Line(ACanvas: TDpiCanvas; I: Integer; Lit: Boolean); 383 374 var 384 TextColor, x, y: Integer; 375 TextColor: TColor; 376 X, Y: Integer; 385 377 TextSize: TSize; 386 s: string;387 begin 388 s := MainText[ScrollBar.Position + i];389 if s= '' then378 S: string; 379 begin 380 S := MainText[ScrollBar.Position + I]; 381 if S = '' then 390 382 Exit; 391 x := x0[i];392 y := 2 + i* 24;393 if ca= Canvas then394 begin 395 x := x+ SideFrame;396 y := y + WideFrame397 end; 398 if THelpLineInfo(MainText.Objects[ScrollBar.Position + i]).Format383 X := x0[I]; 384 Y := 2 + I * 24; 385 if ACanvas = Canvas then 386 begin 387 X := X + SideFrame; 388 Y := Y + WideFrame; 389 end; 390 if THelpLineInfo(MainText.Objects[ScrollBar.Position + I]).Format 399 391 in [pkCaption, pkBigTer, pkRightIcon, pkBigFeature] then 400 392 begin 401 ca.Font.Assign(CaptionFont);402 { ca.brush.color:=CaptionColor;403 ca.FillRect(rect(x,i*24,x+24,i*24+24));404 ca.brush.color:=$FFFFFF;405 ca.FrameRect(rect(x+1,i*24+1,x+24-1,i*24+24-1));406 ca.Brush.Style:=bsClear; }407 DpiBit Canvas(ca, x, y- 4, 24, 24, HGrSystem.Data.Canvas, 1,393 ACanvas.Font.Assign(CaptionFont); 394 { ACanvas.brush.color:=CaptionColor; 395 ACanvas.FillRect(rect(X,I*24,X+24,I*24+24)); 396 ACanvas.Brush.Color:=$FFFFFF; 397 ACanvas.FrameRect(rect(X+1,I*24+1,X+24-1,I*24+24-1)); 398 ACanvas.Brush.Style:=bsClear; } 399 DpiBitBltCanvas(ACanvas, X, Y - 4, 24, 24, HGrSystem.Data.Canvas, 1, 408 400 146); 409 BiColorTextOut( ca, $FFFFFF, $7F007F, x + 10 - ca.Textwidth(s[1]) div 2,410 y - 3, s[1]);411 BiColorTextOut( ca, CaptionColor, $7F007F, x + 24, y - 3, copy(s, 2, 255));412 ca.Font.Assign(UniFont[ftNormal]);401 BiColorTextOut(ACanvas, $FFFFFF, $7F007F, X + 10 - ACanvas.Textwidth(S[1]) div 2, 402 Y - 3, S[1]); 403 BiColorTextOut(ACanvas, CaptionColor, $7F007F, X + 24, Y - 3, Copy(S, 2, 255)); 404 ACanvas.Font.Assign(UniFont[ftNormal]); 413 405 end 414 else if THelpLineInfo(MainText.Objects[ScrollBar.Position + i]).Format = pkSection 415 then 416 begin 417 ca.Font.Assign(CaptionFont); 418 BiColorTextOut(ca, CaptionColor, $7F007F, x, y - 3, s); 419 ca.Font.Assign(UniFont[ftNormal]); 406 else if THelpLineInfo(MainText.Objects[ScrollBar.Position + I]).Format = pkSection then 407 begin 408 ACanvas.Font.Assign(CaptionFont); 409 BiColorTextOut(ACanvas, CaptionColor, $7F007F, X, Y - 3, S); 410 ACanvas.Font.Assign(UniFont[ftNormal]); 420 411 end 421 412 else 422 413 begin 423 if (Kind = hkMisc) and ( no = miscMain) then424 ca.Font.Assign(CaptionFont);414 if (Kind = hkMisc) and (No = Integer(miscMain)) then 415 ACanvas.Font.Assign(CaptionFont); 425 416 TextColor := Colors.Canvas.Pixels[clkMisc, cliPaperText]; 426 if ca= Canvas then417 if ACanvas = Canvas then 427 418 begin 428 TextSize.cx := BiColorTextWidth( ca, s);429 TextSize.cy := ca.TextHeight(s);430 if y+ TextSize.cy >= WideFrame + InnerHeight then431 TextSize.cy := WideFrame + InnerHeight - y;432 FillSeamless( ca, x, y, TextSize.cx, TextSize.cy, -SideFrame,419 TextSize.cx := BiColorTextWidth(ACanvas, S); 420 TextSize.cy := ACanvas.TextHeight(S); 421 if Y + TextSize.cy >= WideFrame + InnerHeight then 422 TextSize.cy := WideFrame + InnerHeight - Y; 423 FillSeamless(ACanvas, X, Y, TextSize.cx, TextSize.cy, -SideFrame, 433 424 ScrollBar.Position * 24 - WideFrame, Paper); 434 425 end; 435 BiColorTextOut( ca, TextColor, $7F007F, x, y, s);426 BiColorTextOut(ACanvas, TextColor, $7F007F, X, Y, S); 436 427 if lit then 437 with cado428 with ACanvas do 438 429 begin 439 Assert( ca= Canvas);430 Assert(ACanvas = Canvas); 440 431 Pen.Color := TextColor; 441 MoveTo( x + 1, y+ TextSize.cy - 2);442 LineTo( x + TextSize.cx, y+ TextSize.cy - 2);432 MoveTo(X + 1, Y + TextSize.cy - 2); 433 LineTo(X + TextSize.cx, Y + TextSize.cy - 2); 443 434 end; 444 if (Kind = hkMisc) and ( no = miscMain) then445 ca.Font.Assign(UniFont[ftNormal]);446 end; 447 end; 448 449 procedure THelpDlg.WaterSign(x0, y0, iix: integer);435 if (Kind = hkMisc) and (No = Integer(miscMain)) then 436 ACanvas.Font.Assign(UniFont[ftNormal]); 437 end; 438 end; 439 440 procedure THelpDlg.WaterSign(x0, y0, iix: Integer); 450 441 const 451 442 nHeaven = 28; 452 443 MaxSum = 9 * 9 * 255 * 75 div 100; 453 444 var 454 x, y, dx, dy, xSrc, ySrc, Sum, xx: integer;455 Heaven: array [0..nHeaven] of integer;445 X, Y, dx, dy, xSrc, ySrc, Sum, xx: Integer; 446 Heaven: array [0..nHeaven] of Integer; 456 447 PaintPtr: TPixelPointer; 457 448 CoalPtr: TPixelPointer; … … 467 458 xSrc := iix mod 7 * xSizeBig; 468 459 ySrc := (iix div 7 + 1) * ySizeBig; 469 PaintPtr := PixelPointer(OffScreen, ScaleToNative(x0), ScaleToNative(y0));470 CoalPtr := PixelPointer(Templates.Data, ScaleToNative(xCoal), ScaleToNative(yCoal));460 PaintPtr := TPixelPointer.Create(OffScreen, ScaleToNative(x0), ScaleToNative(y0)); 461 CoalPtr := TPixelPointer.Create(Templates.Data, ScaleToNative(xCoal), ScaleToNative(yCoal)); 471 462 for dy := -1 to 1 do 472 ImpPtr[dy] := PixelPointer(BigImp, ScaleToNative(xSrc), ScaleToNative(ySrc));473 for y:= 0 to ScaleToNative(ySizeBig) * 2 - 1 do begin474 if ((ScaleToNative(y0) + y) >= 0) and ((ScaleToNative(y0) + y) < ScaleToNative(InnerHeight)) then begin463 ImpPtr[dy] := TPixelPointer.Create(BigImp, ScaleToNative(xSrc), ScaleToNative(ySrc)); 464 for Y := 0 to ScaleToNative(ySizeBig) * 2 - 1 do begin 465 if ((ScaleToNative(y0) + Y) >= 0) and ((ScaleToNative(y0) + Y) < ScaleToNative(InnerHeight)) then begin 475 466 for dy := -1 to 1 do 476 if ((Max( y + ScaleToNative(dy), 0) shr 1) >= 0) and ((Max(y+ ScaleToNative(dy), 0) shr 1) < ScaleToNative(ySizeBig)) then477 ImpPtr[dy].SetXY(0, Max( y+ ScaleToNative(dy), 0) shr 1);478 for x:= 0 to ScaleToNative(xSizeBig * 2) - 1 do begin467 if ((Max(Y + ScaleToNative(dy), 0) shr 1) >= 0) and ((Max(Y + ScaleToNative(dy), 0) shr 1) < ScaleToNative(ySizeBig)) then 468 ImpPtr[dy].SetXY(0, Max(Y + ScaleToNative(dy), 0) shr 1); 469 for X := 0 to ScaleToNative(xSizeBig * 2) - 1 do begin 479 470 Sum := 0; 480 471 for dx := -1 to 1 do begin 481 xx := Max(( x+ ScaleToNative(dx)), 0) shr 1;472 xx := Max((X + ScaleToNative(dx)), 0) shr 1; 482 473 for dy := -1 to 1 do begin 483 474 ImpPtr[dy].SetX(xx); 484 if (( y + ScaleToNative(dy)) shr 1 < 0) or ((y+ ScaleToNative(dy)) shr 1 >= ScaleToNative(ySizeBig)) or485 (( x + ScaleToNative(dx)) shr 1 < 0) or ((x+ ScaleToNative(dx)) shr 1 >= ScaleToNative(xSizeBig)) or486 (( y+ ScaleToNative(dy)) shr 1 < ScaleToNative(nHeaven)) and475 if ((Y + ScaleToNative(dy)) shr 1 < 0) or ((Y + ScaleToNative(dy)) shr 1 >= ScaleToNative(ySizeBig)) or 476 ((X + ScaleToNative(dx)) shr 1 < 0) or ((X + ScaleToNative(dx)) shr 1 >= ScaleToNative(xSizeBig)) or 477 ((Y + ScaleToNative(dy)) shr 1 < ScaleToNative(nHeaven)) and 487 478 (ImpPtr[dy].Pixel^.B shl 16 + ImpPtr[dy].Pixel^.G shl 8 + 488 ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromNative( y+ ScaleToNative(dy))) shr 1]) then479 ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromNative(Y + ScaleToNative(dy))) shr 1]) then 489 480 Sum := Sum + 9 * 255 490 481 else … … 493 484 end; 494 485 end; 495 if Sum < MaxSum then begin // no saturation486 if Sum < MaxSum then begin // No saturation 496 487 Sum := 1 shl 22 - (MaxSum - Sum) * (256 - CoalPtr.Pixel^.B * 2); 497 488 PaintPtr.Pixel^.B := Min(PaintPtr.Pixel^.B * Sum shr 22, 255); … … 510 501 end; 511 502 512 procedure THelpDlg.PaintTerrIcon( x, y, xSrc, ySrc: integer);503 procedure THelpDlg.PaintTerrIcon(X, Y, xSrc, ySrc: Integer); 513 504 begin 514 505 with NoMap do begin 515 Frame(OffScreen.Canvas, x - 1, y - 1, x + xSizeBig, y+ ySizeBig,506 Frame(OffScreen.Canvas, X - 1, Y - 1, X + xSizeBig, Y + ySizeBig, 516 507 $000000, $000000); 517 508 if 2 * yyt < 40 then begin 518 Sprite(OffScreen, HGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc);519 Sprite(OffScreen, HGrTerrain, x, y+ 2 * yyt, 56, 40 - 2 * yyt,509 Sprite(OffScreen, HGrTerrain, X, Y, 56, 2 * yyt, xSrc, ySrc); 510 Sprite(OffScreen, HGrTerrain, X, Y + 2 * yyt, 56, 40 - 2 * yyt, 520 511 xSrc, ySrc); 521 512 end else 522 Sprite(OffScreen, HGrTerrain, x, y, 56, 40, xSrc, ySrc);523 Sprite(OffScreen, HGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt);524 Sprite(OffScreen, HGrTerrain, x, y+ yyt, xxt, 40 - yyt, xSrc + xxt, ySrc);525 Sprite(OffScreen, HGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt);526 Sprite(OffScreen, HGrTerrain, x + xxt, y+ yyt, 56 - xxt, 40 - yyt,513 Sprite(OffScreen, HGrTerrain, X, Y, 56, 40, xSrc, ySrc); 514 Sprite(OffScreen, HGrTerrain, X, Y, xxt, yyt, xSrc + xxt, ySrc + yyt); 515 Sprite(OffScreen, HGrTerrain, X, Y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc); 516 Sprite(OffScreen, HGrTerrain, X + xxt, Y, 56 - xxt, yyt, xSrc, ySrc + yyt); 517 Sprite(OffScreen, HGrTerrain, X + xxt, Y + yyt, 56 - xxt, 40 - yyt, 527 518 xSrc, ySrc); 528 519 end; … … 531 522 procedure THelpDlg.OffscreenPaint; 532 523 var 533 i, j, yl, srcno, ofs, cnt, y: Integer;534 s: string;524 I, J, yl, srcno, ofs, cnt, Y: Integer; 525 S: string; 535 526 HelpLineInfo: THelpLineInfo; 536 527 begin … … 542 533 begin 543 534 Font.Assign(UniFont[ftNormal]); 544 for i:= -ScrollBar.Position to InnerHeight div 24 do545 if ScrollBar.Position + i< MainText.Count then535 for I := -ScrollBar.Position to InnerHeight div 24 do 536 if ScrollBar.Position + I < MainText.Count then 546 537 begin 547 HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + i]);538 HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + I]); 548 539 if HelpLineInfo.Format = pkExternal then 549 540 begin 550 541 yl := ExtPic.Height; 551 if 4 + i* 24 + yl > InnerHeight then552 yl := InnerHeight - (4 + i* 24);553 DpiBit Canvas(OffScreen.Canvas, 8, 4 + i* 24, ExtPic.Width, yl, ExtPic.Canvas,542 if 4 + I * 24 + yl > InnerHeight then 543 yl := InnerHeight - (4 + I * 24); 544 DpiBitBltCanvas(OffScreen.Canvas, 8, 4 + I * 24, ExtPic.Width, yl, ExtPic.Canvas, 554 545 0, 0); 555 546 end; 556 547 end; 557 for i:= -2 to InnerHeight div 24 do558 if (ScrollBar.Position + i >= 0) and (ScrollBar.Position + i< MainText.Count) then548 for I := -2 to InnerHeight div 24 do 549 if (ScrollBar.Position + I >= 0) and (ScrollBar.Position + I < MainText.Count) then 559 550 begin 560 HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + i]);561 if HelpLineInfo.Link <> 0then551 HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + I]); 552 if (HelpLineInfo.Category <> hkNoLink) or (HelpLineInfo.Index <> 0) then 562 553 begin 563 if (Kind = hkMisc) and ( no = miscSearchResult) then564 Sprite(OffScreen, HGrSystem, 18, 9 + i* 24, 8, 8, 90, 16)554 if (Kind = hkMisc) and (No = Integer(miscSearchResult)) then 555 Sprite(OffScreen, HGrSystem, 18, 9 + I * 24, 8, 8, 90, 16) 565 556 else if HelpLineInfo.Format in [pkSmallIcon_AsPreq, pkAdvIcon_AsPreq] 566 557 then 567 Sprite(OffScreen, HGrSystem, 12, i* 24 + 5, 14, 14, 65, 20)568 else if HelpLineInfo. Link and (hkCrossLink shl 8) <> 0then569 Sprite(OffScreen, HGrSystem, 12, i* 24 + 5, 14, 14, 80, 1)570 else if not((Kind = hkMisc) and ( no = miscMain)) then571 Sprite(OffScreen, HGrSystem, 10, i* 24 + 6, 14, 14, 65, 1);572 x0[ i] := 24;558 Sprite(OffScreen, HGrSystem, 12, I * 24 + 5, 14, 14, 65, 20) 559 else if HelpLineInfo.CrossLink then 560 Sprite(OffScreen, HGrSystem, 12, I * 24 + 5, 14, 14, 80, 1) 561 else if not((Kind = hkMisc) and (No = Integer(miscMain))) then 562 Sprite(OffScreen, HGrSystem, 10, I * 24 + 6, 14, 14, 65, 1); 563 x0[I] := 24; 573 564 end 574 565 else 575 x0[ i] := 0;566 x0[I] := 0; 576 567 case HelpLineInfo.Format of 577 568 pkLogo: 578 569 begin 579 Server(sGetVersion, 0, 0, j);580 s := Format('%d.%d.%d', [j shr 16 and $FF, jshr 8 and $FF,581 jand $FF]);582 PaintLogo(OffScreen.Canvas, (InnerWidth - 122) div 2, i* 24 + 1,570 Server(sGetVersion, 0, 0, J); 571 S := Format('%d.%d.%d', [J shr 16 and $FF, J shr 8 and $FF, 572 J and $FF]); 573 PaintLogo(OffScreen.Canvas, (InnerWidth - 122) div 2, I * 24 + 1, 583 574 HGrSystem.Data.Canvas.Pixels[95, 1], $000000); 584 575 Font.Assign(UniFont[ftSmall]); 585 576 BiColorTextOut(OffScreen.Canvas, $000000, $7F007F, 586 (InnerWidth - Textwidth( s)) div 2, i * 24 + 26, s);577 (InnerWidth - Textwidth(S)) div 2, I * 24 + 26, S); 587 578 Font.Assign(UniFont[ftNormal]); 588 579 end; 589 580 pkSmallIcon, pkSmallIcon_AsPreq: 590 581 begin 591 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[ i], 2 - 1 + i* 24,592 8 + xSizeSmall + x0[ i], 2 + 20 + i* 24, $000000, $000000);582 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[I], 2 - 1 + I * 24, 583 8 + xSizeSmall + x0[I], 2 + 20 + I * 24, $000000, $000000); 593 584 if HelpLineInfo.Picpix = imPalace then 594 DpiBit Canvas(OffScreen.Canvas, 8 + x0[i], 2 + i* 24,585 DpiBitBltCanvas(OffScreen.Canvas, 8 + x0[I], 2 + I * 24, 595 586 xSizeSmall, ySizeSmall, SmallImp.Canvas, 596 587 0 * xSizeSmall, 1 * ySizeSmall) 597 588 else 598 DpiBit Canvas(OffScreen.Canvas, 8 + x0[i], 2 + i* 24,589 DpiBitBltCanvas(OffScreen.Canvas, 8 + x0[I], 2 + I * 24, 599 590 xSizeSmall, ySizeSmall, SmallImp.Canvas, 600 591 HelpLineInfo.Picpix mod 7 * xSizeSmall, 601 592 (HelpLineInfo.Picpix + SystemIconLines * 7) div 7 * 602 593 ySizeSmall); 603 x0[ i] := x0[i] + (8 + 8 + 36);594 x0[I] := x0[I] + (8 + 8 + 36); 604 595 end; 605 596 pkBigIcon: 606 597 begin 607 FrameImage(OffScreen.Canvas, BigImp, x0[ i] + 12, i* 24 - 7, 56,598 FrameImage(OffScreen.Canvas, BigImp, x0[I] + 12, I * 24 - 7, 56, 608 599 40, HelpLineInfo.Picpix mod 7 * xSizeBig, 609 600 HelpLineInfo.Picpix div 7 * ySizeBig); 610 x0[ i] := 64 + 8 + 8 + x0[i];601 x0[I] := 64 + 8 + 8 + x0[I]; 611 602 end; 612 603 pkSpecialIcon: … … 615 606 0: 616 607 FrameImage(OffScreen.Canvas, HGrSystem2.Data, 617 12 + x0[ i], -7 + i* 24, 56, 40, 137, 127);608 12 + x0[I], -7 + I * 24, 56, 40, 137, 127); 618 609 1: 619 610 with NoMap do begin 620 PaintTerrIcon(12 + x0[ i], -7 + i* 24,611 PaintTerrIcon(12 + x0[I], -7 + I * 24, 621 612 1 + 3 * (xxt * 2 + 1), 1 + yyt); 622 613 if 2 * yyt < 40 then 623 Sprite(OffScreen, HGrTerrain, 12 + x0[ i], -7 + 4 + i* 24,614 Sprite(OffScreen, HGrTerrain, 12 + x0[I], -7 + 4 + I * 24, 624 615 56, 2 * yyt, 1 + 3 * (xxt * 2 + 1) + xxt - 28, 625 616 1 + yyt + 1 * (yyt * 3 + 1)) 626 617 else 627 Sprite(OffScreen, HGrTerrain, 12 + x0[ i],628 -7 + 4 + i* 24 - 4, 56, 40, 1 + 3 * (xxt * 2 + 1) + xxt618 Sprite(OffScreen, HGrTerrain, 12 + x0[I], 619 -7 + 4 + I * 24 - 4, 56, 40, 1 + 3 * (xxt * 2 + 1) + xxt 629 620 - 28, 1 + yyt + 1 * (yyt * 3 + 1) + yyt - 20); 630 621 end; 631 622 2: 632 623 with NoMap do begin 633 PaintTerrIcon(12 + x0[ i], -7 + i* 24,624 PaintTerrIcon(12 + x0[I], -7 + I * 24, 634 625 1 + 7 * (xxt * 2 + 1), 1 + yyt + 4 * (yyt * 3 + 1)); 635 626 if 2 * yyt < 40 then 636 Sprite(OffScreen, HGrTerrain, 12 + x0[ i], -7 + 4 + i* 24,627 Sprite(OffScreen, HGrTerrain, 12 + x0[I], -7 + 4 + I * 24, 637 628 56, 32, 1 + 4 * (xxt * 2 + 1) + xxt - 28, 638 629 1 + yyt + 12 * (yyt * 3 + 1) + yyt - 16) 639 630 else 640 Sprite(OffScreen, HGrTerrain, 12 + x0[ i], -7 + 4 + i* 24,631 Sprite(OffScreen, HGrTerrain, 12 + x0[I], -7 + 4 + I * 24, 641 632 56, 32, 1 + 4 * (xxt * 2 + 1) + xxt - 28, 642 633 1 + yyt + 12 * (yyt * 3 + 1) + yyt - 16) 643 634 end; 644 635 end; 645 x0[ i] := 64 + 8 + 8 + x0[i];636 x0[I] := 64 + 8 + 8 + x0[I]; 646 637 end; 647 638 pkDomain: 648 639 begin 649 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[ i], 2 - 1 + i* 24,650 8 + 36 + x0[ i], 2 + 20 + i* 24, $000000, $000000);651 Dump(OffScreen, HGrSystem, 8 + x0[ i], 2 + i* 24, 36, 20,640 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[I], 2 - 1 + I * 24, 641 8 + 36 + x0[I], 2 + 20 + I * 24, $000000, $000000); 642 Dump(OffScreen, HGrSystem, 8 + x0[I], 2 + I * 24, 36, 20, 652 643 75 + HelpLineInfo.Picpix * 37, 295); 653 x0[ i] := x0[i] + (8 + 8 + 36);644 x0[I] := x0[I] + (8 + 8 + 36); 654 645 end; 655 646 pkAdvIcon, pkAdvIcon_AsPreq: 656 647 begin 657 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[ i], 2 - 1 + i* 24,658 8 + xSizeSmall + x0[ i], 2 + ySizeSmall + i* 24,648 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[I], 2 - 1 + I * 24, 649 8 + xSizeSmall + x0[I], 2 + ySizeSmall + I * 24, 659 650 $000000, $000000); 660 651 if AdvIcon[HelpLineInfo.Picpix] < 84 then 661 DpiBit Canvas(OffScreen.Canvas, 8 + x0[i], 2 + i* 24,652 DpiBitBltCanvas(OffScreen.Canvas, 8 + x0[I], 2 + I * 24, 662 653 xSizeSmall, ySizeSmall, SmallImp.Canvas, 663 654 (AdvIcon[HelpLineInfo.Picpix] + SystemIconLines * 7) mod 7 * … … 665 656 7) div 7 * ySizeSmall) 666 657 else 667 Dump(OffScreen, HGrSystem, 8 + x0[ i], 2 + i* 24, 36, 20,658 Dump(OffScreen, HGrSystem, 8 + x0[I], 2 + I * 24, 36, 20, 668 659 1 + (AdvIcon[HelpLineInfo.Picpix] - 84) mod 8 * 37, 669 660 295 + (AdvIcon[HelpLineInfo.Picpix] - 84) div 8 * 21); 670 j:= AdvValue[HelpLineInfo.Picpix] div 1000;671 DpiBit Canvas(OffScreen.Canvas, x0[i] + 4, 4 + i* 24, 14, 14,672 HGrSystem.Mask.Canvas, 127 + j* 15, 85, SRCAND);673 Sprite(OffScreen, HGrSystem, x0[ i] + 3, 3 + i* 24, 14, 14,674 127 + j* 15, 85);675 x0[ i] := x0[i] + (8 + 8 + 36);661 J := AdvValue[HelpLineInfo.Picpix] div 1000; 662 DpiBitBltCanvas(OffScreen.Canvas, x0[I] + 4, 4 + I * 24, 14, 14, 663 HGrSystem.Mask.Canvas, 127 + J * 15, 85, SRCAND); 664 Sprite(OffScreen, HGrSystem, x0[I] + 3, 3 + I * 24, 14, 14, 665 127 + J * 15, 85); 666 x0[I] := x0[I] + (8 + 8 + 36); 676 667 end; 677 668 pkRightIcon: 678 669 begin 679 670 if Imp[HelpLineInfo.Picpix].Kind <> ikWonder then 680 ImpImage(OffScreen.Canvas, InnerWidth - (40 + xSizeBig), i* 24,671 ImpImage(OffScreen.Canvas, InnerWidth - (40 + xSizeBig), I * 24, 681 672 HelpLineInfo.Picpix, gDespotism) 682 673 else 683 WaterSign(InnerWidth - (40 + 2 * xSizeBig), i* 24 - 8,674 WaterSign(InnerWidth - (40 + 2 * xSizeBig), I * 24 - 8, 684 675 HelpLineInfo.Picpix + 7); 685 x0[ i] := x0[i] + 8;676 x0[I] := x0[I] + 8; 686 677 end; 687 678 pkIllu: 688 WaterSign(8, i* 24 - 8, HelpLineInfo.Picpix);679 WaterSign(8, I * 24 - 8, HelpLineInfo.Picpix); 689 680 pkBigFeature: 690 681 begin 691 682 cnt := 0; 692 for j:= nDomains - 1 downto 0 do693 if 1 shl jand Feature[HelpLineInfo.Picpix].Domains <> 0 then683 for J := nDomains - 1 downto 0 do 684 if 1 shl J and Feature[HelpLineInfo.Picpix].Domains <> 0 then 694 685 begin 695 inc(cnt);686 Inc(cnt); 696 687 Dump(OffScreen, HGrSystem, InnerWidth - 38 - 38 * cnt, 697 i * 24 + 1, 36, 20, 75 + j* 37, 295);698 ScreenTools.Frame(OffScreen.Canvas, InnerWidth - 39 - 38 * cnt, i* 24,699 InnerWidth - 2 - 38 * cnt, i* 24 + 21, $000000, $000000);688 I * 24 + 1, 36, 20, 75 + J * 37, 295); 689 ScreenTools.Frame(OffScreen.Canvas, InnerWidth - 39 - 38 * cnt, I * 24, 690 InnerWidth - 2 - 38 * cnt, I * 24 + 21, $000000, $000000); 700 691 end; 701 692 DarkGradient(OffScreen.Canvas, InnerWidth - 38 - 38 * cnt, 702 i* 24 + 23, cnt * 38 - 2, 1);693 I * 24 + 23, cnt * 38 - 2, 1); 703 694 ofs := InnerWidth - (39 + 7) - 19 * cnt; 704 695 with OffScreen.Canvas do 705 696 begin 706 Brush. color := $C0C0C0;707 FrameRect(Rect(ofs, 1 + 23 + i* 24, ofs + 14,708 15 + 23 + i* 24));697 Brush.Color := $C0C0C0; 698 FrameRect(Rect(ofs, 1 + 23 + I * 24, ofs + 14, 699 15 + 23 + I * 24)); 709 700 Brush.Style := bsClear; 710 Sprite(OffScreen, HGrSystem, ofs + 2, 3 + 23 + i* 24, 10, 10,701 Sprite(OffScreen, HGrSystem, ofs + 2, 3 + 23 + I * 24, 10, 10, 711 702 66 + HelpLineInfo.Picpix mod 11 * 11, 712 703 137 + HelpLineInfo.Picpix div 11 * 11); 713 704 end; 714 x0[ i] := x0[i] + 8;705 x0[I] := x0[I] + 8; 715 706 end; 716 707 pkTer, pkBigTer: 717 708 with NoMap do begin 718 709 if HelpLineInfo.Format = pkBigTer then 719 y := i* 24 - 3 + yyt710 Y := I * 24 - 3 + yyt 720 711 else 721 y := i* 24 + 13;712 Y := I * 24 + 13; 722 713 if HelpLineInfo.Picpix >= 3 * 12 then 723 714 srcno := 2 * 9 + 6 … … 730 721 if HelpLineInfo.Format = pkTer then 731 722 begin 732 ofs := x0[ i] + 8;733 x0[ i] := 2 * xxt + 8 + ofs;723 ofs := x0[I] + 8; 724 x0[I] := 2 * xxt + 8 + ofs; 734 725 end 735 726 else 736 727 begin 737 728 ofs := InnerWidth - (2 * xxt + 38); 738 x0[ i] := x0[i] + 8;729 x0[I] := x0[I] + 8; 739 730 end; 740 731 if srcno >= fJungle then 741 732 begin 742 Sprite(OffScreen, HGrTerrain, ofs + 4, y- yyt + 2, xxt * 2 - 8,733 Sprite(OffScreen, HGrTerrain, ofs + 4, Y - yyt + 2, xxt * 2 - 8, 743 734 yyt * 2 - 4, 5 + 2 * (xxt * 2 + 1), 744 735 3 + yyt + 2 * (yyt * 3 + 1)); 745 Sprite(OffScreen, HGrTerrain, ofs, y- 2 * yyt, xxt * 2,736 Sprite(OffScreen, HGrTerrain, ofs, Y - 2 * yyt, xxt * 2, 746 737 yyt * 3 - 2, 1 + srcno mod 9 * (xxt * 2 + 1), 747 738 1 + srcno div 9 * (yyt * 3 + 1)); 748 739 end 749 740 else 750 Sprite(OffScreen, HGrTerrain, ofs + 4, y- yyt + 2, xxt * 2 - 8,741 Sprite(OffScreen, HGrTerrain, ofs + 4, Y - yyt + 2, xxt * 2 - 8, 751 742 yyt * 2 - 4, 5 + srcno mod 9 * (xxt * 2 + 1), 752 743 3 + yyt + srcno div 9 * (yyt * 3 + 1)); 753 744 if HelpLineInfo.Picpix >= 3 * 12 then { rare resource } 754 Sprite(OffScreen, HGrTerrain, ofs, y- 2 * yyt, xxt * 2,745 Sprite(OffScreen, HGrTerrain, ofs, Y - 2 * yyt, xxt * 2, 755 746 yyt * 3, 1 + 8 * (xxt * 2 + 1), 756 747 1 + (HelpLineInfo.Picpix - 2 * 12) * (yyt * 3 + 1)) … … 764 755 srcno := 18 + 8 + (HelpLineInfo.Picpix mod 12 - 9) * 18; 765 756 srcno := srcno + HelpLineInfo.Picpix div 12 * 9; 766 Sprite(OffScreen, HGrTerrain, ofs, y- 2 * yyt, xxt * 2,757 Sprite(OffScreen, HGrTerrain, ofs, Y - 2 * yyt, xxt * 2, 767 758 yyt * 3, 1 + srcno mod 9 * (xxt * 2 + 1), 768 759 1 + srcno div 9 * (yyt * 3 + 1)); … … 774 765 if HelpLineInfo.Picpix = 5 then 775 766 begin // display mine on hills 776 Sprite(OffScreen, HGrTerrain, ofs + 4, i* 24 + 13 - yyt,767 Sprite(OffScreen, HGrTerrain, ofs + 4, I * 24 + 13 - yyt, 777 768 xxt * 2 - 8, yyt * 2 - 4, 5 + 2 * (xxt * 2 + 1), 778 769 3 + yyt + 2 * (yyt * 3 + 1)); … … 781 772 else 782 773 srcno := fPrairie; // display on prairie 783 Sprite(OffScreen, HGrTerrain, ofs + 4, i* 24 + 13 - yyt,774 Sprite(OffScreen, HGrTerrain, ofs + 4, I * 24 + 13 - yyt, 784 775 xxt * 2 - 8, yyt * 2 - 4, 5 + srcno mod 9 * (xxt * 2 + 1), 785 776 3 + yyt + srcno div 9 * (yyt * 3 + 1)); 786 777 if HelpLineInfo.Picpix = 12 then { river } 787 Sprite(OffScreen, HGrTerrain, ofs, i* 24 + 11 - yyt, xxt * 2,778 Sprite(OffScreen, HGrTerrain, ofs, I * 24 + 11 - yyt, xxt * 2, 788 779 yyt * 2, 1 + 5 * (xxt * 2 + 1), 1 + yyt + 13 * (yyt * 3 + 1)) 789 780 else if HelpLineInfo.Picpix >= 3 then { improvement 2 } 790 781 begin 791 782 if HelpLineInfo.Picpix = 6 then 792 Sprite(OffScreen, HGrTerrain, ofs, i* 24 + 11 - 2 * yyt,783 Sprite(OffScreen, HGrTerrain, ofs, I * 24 + 11 - 2 * yyt, 793 784 xxt * 2, yyt * 3, 1 + 7 * (xxt * 2 + 1), 794 785 1 + 12 * (yyt * 3 + 1)); 795 Sprite(OffScreen, HGrTerrain, ofs, i* 24 + 11 - 2 * yyt,786 Sprite(OffScreen, HGrTerrain, ofs, I * 24 + 11 - 2 * yyt, 796 787 xxt * 2, yyt * 3, 1 + (HelpLineInfo.Picpix - 3) * 797 788 (xxt * 2 + 1), 1 + 12 * (yyt * 3 + 1)) … … 799 790 else { improvement 1 } 800 791 begin 801 Sprite(OffScreen, HGrTerrain, ofs, i* 24 + 11 - 2 * yyt,792 Sprite(OffScreen, HGrTerrain, ofs, I * 24 + 11 - 2 * yyt, 802 793 xxt * 2, yyt * 3, 1 + 2 * (xxt * 2 + 1), 803 794 1 + (9 + HelpLineInfo.Picpix) * (yyt * 3 + 1)); 804 Sprite(OffScreen, HGrTerrain, ofs, i* 24 + 11 - 2 * yyt,795 Sprite(OffScreen, HGrTerrain, ofs, I * 24 + 11 - 2 * yyt, 805 796 xxt * 2, yyt * 3, 1 + 5 * (xxt * 2 + 1), 806 797 1 + (9 + HelpLineInfo.Picpix) * (yyt * 3 + 1)) 807 798 end; 808 x0[ i] := x0[i] + 8;799 x0[I] := x0[I] + 8; 809 800 end; 810 801 pkModel: 811 802 begin 812 FrameImage(OffScreen.Canvas, BigImp, x0[ i] + 12, i* 24 - 7,803 FrameImage(OffScreen.Canvas, BigImp, x0[I] + 12, I * 24 - 7, 813 804 56, 40, 0, 0); 814 Sprite(OffScreen, HGrStdUnits, x0[ i] + 8, i* 24 - 11, 64, 44,805 Sprite(OffScreen, HGrStdUnits, x0[I] + 8, I * 24 - 11, 64, 44, 815 806 1 + HelpLineInfo.Picpix mod 10 * 65, 816 807 1 + HelpLineInfo.Picpix div 10 * 49); 817 x0[ i] := 64 + 8 + 8 + x0[i];808 x0[I] := 64 + 8 + 8 + x0[I]; 818 809 end; 819 810 pkFeature: 820 811 begin 821 DarkGradient(OffScreen.Canvas, x0[ i] + 8 - 1,822 7 + i* 24 - 3, 16, 1);823 ScreenTools.Frame(OffScreen.Canvas, x0[ i] + 8, 7 + i * 24 - 2, x0[i] + 8 + 13,824 7 + i* 24 - 2 + 13, $C0C0C0, $C0C0C0);825 Sprite(OffScreen, HGrSystem, x0[ i] + 8 + 2, 7 + i* 24, 10, 10,812 DarkGradient(OffScreen.Canvas, x0[I] + 8 - 1, 813 7 + I * 24 - 3, 16, 1); 814 ScreenTools.Frame(OffScreen.Canvas, x0[I] + 8, 7 + I * 24 - 2, x0[I] + 8 + 13, 815 7 + I * 24 - 2 + 13, $C0C0C0, $C0C0C0); 816 Sprite(OffScreen, HGrSystem, x0[I] + 8 + 2, 7 + I * 24, 10, 10, 826 817 66 + HelpLineInfo.Picpix mod 11 * 11, 827 818 137 + HelpLineInfo.Picpix div 11 * 11); 828 x0[ i] := x0[i] + 8 + 8 + 2 + 13;819 x0[I] := x0[I] + 8 + 8 + 2 + 13; 829 820 end; 830 821 pkExp: 831 822 begin 832 ScreenTools.Frame(OffScreen.Canvas, 20 - 1, 8 - 4 + i* 24, 20 + 12,833 8 + 11 + i* 24, $000000, $000000);834 Dump(OffScreen, HGrSystem, 20, 8 - 3 + i* 24, 12, 14,823 ScreenTools.Frame(OffScreen.Canvas, 20 - 1, 8 - 4 + I * 24, 20 + 12, 824 8 + 11 + I * 24, $000000, $000000); 825 Dump(OffScreen, HGrSystem, 20, 8 - 3 + I * 24, 12, 14, 835 826 121 + HelpLineInfo.Picpix * 13, 28); 836 x0[ i] := 20 + 8 + 11;827 x0[I] := 20 + 8 + 11; 837 828 end; 838 829 pkAITStat: 839 830 begin 840 Sprite(OffScreen, HGrSystem, 20, 6 + i* 24, 14, 14,831 Sprite(OffScreen, HGrSystem, 20, 6 + I * 24, 14, 14, 841 832 1 + HelpLineInfo.Picpix * 15, 316); 842 x0[ i] := 20 + 8 + 11;833 x0[I] := 20 + 8 + 11; 843 834 end; 844 835 pkGov: 845 836 begin 846 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[ i], 2 - 1 + i* 24,847 8 + xSizeSmall + x0[ i], 2 + 20 + i* 24, $000000, $000000);848 DpiBit Canvas(OffScreen.Canvas, 8 + x0[i], 2 + i* 24, xSizeSmall,837 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[I], 2 - 1 + I * 24, 838 8 + xSizeSmall + x0[I], 2 + 20 + I * 24, $000000, $000000); 839 DpiBitBltCanvas(OffScreen.Canvas, 8 + x0[I], 2 + I * 24, xSizeSmall, 849 840 ySizeSmall, SmallImp.Canvas, (HelpLineInfo.Picpix - 1) * 850 841 xSizeSmall, ySizeSmall); 851 x0[ i] := x0[i] + (8 + 8 + 36);842 x0[I] := x0[I] + (8 + 8 + 36); 852 843 end; 853 844 pkDot: 854 845 begin 855 Sprite(OffScreen, HGrSystem, x0[ i] + 18, 9 + i* 24, 8,846 Sprite(OffScreen, HGrSystem, x0[I] + 18, 9 + I * 24, 8, 856 847 8, 81, 16); 857 x0[ i] := 20 + 8 + 4;848 x0[I] := 20 + 8 + 4; 858 849 end; 859 850 pkNormal_Dot: 860 x0[ i] := 20 + 8 + 4;851 x0[I] := 20 + 8 + 4; 861 852 pkNormal_64: 862 x0[ i] := 64 + 8 + 8;853 x0[I] := 64 + 8 + 8; 863 854 else 864 x0[ i] := x0[i] + 8;855 x0[I] := x0[I] + 8; 865 856 end; 866 Self.Line(OffScreen.Canvas, i, False)857 Self.Line(OffScreen.Canvas, I, False) 867 858 end; 868 859 end; … … 873 864 begin 874 865 Sel := -1; 875 SmartUpdateContent( true)876 end; 877 878 procedure THelpDlg.Prepare(sbPos: integer = 0);866 SmartUpdateContent(True); 867 end; 868 869 procedure THelpDlg.Prepare(sbPos: Integer = 0); 879 870 var 880 i, j, Special, Domain, Headline, TerrType, TerrSubType: integer;881 s: string;882 ps: pchar;871 I, J, Special, Domain, Headline, TerrType, TerrSubType: Integer; 872 S: string; 873 ps: PChar; 883 874 List: THyperText; 884 875 CheckSeeAlso: Boolean; 885 876 886 procedure AddAdvance( i: integer);887 begin 888 MainText.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon, i,889 hkAdv + hkCrossLink, i);890 end; 891 892 procedure AddPreqAdv( i: integer);893 begin 894 MainText.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon_AsPreq, i,895 hkAdv + hkCrossLink, i);896 end; 897 898 procedure AddImprovement( i: integer);899 begin 900 MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i,901 hkImp + hkCrossLink, i);902 end; 903 904 procedure AddPreqImp( i: integer);905 begin 906 MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon_AsPreq, i,907 hkImp + hkCrossLink, i);908 end; 909 910 procedure AddTerrain( i: integer);877 procedure AddAdvance(I: Integer); 878 begin 879 MainText.AddLine(Phrases.Lookup('ADVANCES', I), pkAdvIcon, I, 880 hkAdv, I, True); 881 end; 882 883 procedure AddPreqAdv(I: Integer); 884 begin 885 MainText.AddLine(Phrases.Lookup('ADVANCES', I), pkAdvIcon_AsPreq, I, 886 hkAdv, I, True); 887 end; 888 889 procedure AddImprovement(I: Integer); 890 begin 891 MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', I), pkSmallIcon, I, 892 hkImp, I, True); 893 end; 894 895 procedure AddPreqImp(I: Integer); 896 begin 897 MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', I), pkSmallIcon_AsPreq, I, 898 hkImp, I, True); 899 end; 900 901 procedure AddTerrain(I: Integer); 911 902 begin 912 903 if MainText.Count > 1 then … … 914 905 MainText.LineFeed; 915 906 end; 916 MainText.AddLine(Phrases.Lookup('TERRAIN', i), pkTer, i, hkTer, i);917 end; 918 919 procedure AddFeature( i: integer);920 begin 921 MainText.AddLine(Phrases.Lookup('FEATURES', i), pkFeature, i,922 hkFeature + hkCrossLink, i);923 end; 924 925 procedure AddModel( i: integer);907 MainText.AddLine(Phrases.Lookup('TERRAIN', I), pkTer, I, hkTer, I); 908 end; 909 910 procedure AddFeature(I: Integer); 911 begin 912 MainText.AddLine(Phrases.Lookup('FEATURES', I), pkFeature, I, 913 hkFeature, I, True); 914 end; 915 916 procedure AddModel(I: Integer); 926 917 var 927 pix: integer;918 pix: Integer; 928 919 Name: string; 929 920 begin 930 921 if MainText.Count > 1 then 931 922 MainText.LineFeed; 932 FindStdModelPicture(SpecialModelPictureCode[ i], pix, Name);933 MainText.AddLine(Name, pkModel, pix, hkModel + hkCrossLink, i)923 FindStdModelPicture(SpecialModelPictureCode[I], pix, Name); 924 MainText.AddLine(Name, pkModel, pix, hkModel, I, True); 934 925 end; 935 926 936 927 procedure AddStandardBlock(Item: string); 937 928 var 938 i: integer;929 I: Integer; 939 930 begin 940 931 with MainText do … … 947 938 else if Item = 'TECHFORMULA' then 948 939 begin 949 i:= Difficulty;950 if i= 0 then951 i:= 2;952 AddLine(Format(HelpText.Lookup('TECHFORMULA'), [TechFormula_M[ i],953 TechFormula_D[ i]]))940 I := Difficulty; 941 if I = 0 then 942 I := 2; 943 AddLine(Format(HelpText.Lookup('TECHFORMULA'), [TechFormula_M[I], 944 TechFormula_D[I]])); 954 945 end 955 946 else if Item = 'EXPERIENCE' then 956 for i:= 0 to nExp - 1 do957 AddLine(Phrases.Lookup('EXPERIENCE', i), pkExp, i)947 for I := 0 to nExp - 1 do 948 AddLine(Phrases.Lookup('EXPERIENCE', I), pkExp, I) 958 949 else if Item = 'MODERN' then 959 for i:= 1 to 3 do950 for I := 1 to 3 do 960 951 begin 961 952 LineFeed; 962 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + i), pkTer, 3 * 12 + i);953 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + I), pkTer, 3 * 12 + I); 963 954 end 964 955 else if Item = 'SAVED' then 965 956 AddLine(DataDir + 'Saved', pkNormal) 966 957 else if Item = 'AITSTAT' then 967 for i:= 0 to 3 do968 AddLine(Phrases2.Lookup('AITSTAT', i), pkAITStat, i)969 end 970 end; 971 972 procedure DecodeItem( s: string; var Category,Index: Integer);958 for I := 0 to 3 do 959 AddLine(Phrases2.Lookup('AITSTAT', I), pkAITStat, I) 960 end; 961 end; 962 963 procedure DecodeItem(S: string; var Category: TLinkCategory; var Index: Integer); 973 964 var 974 i: Integer;975 begin 976 if (Length( s) > 0) and (s[1] = ':') then begin965 I: Integer; 966 begin 967 if (Length(S) > 0) and (S[1] = ':') then begin 977 968 Category := hkMisc; 978 969 Index := 0; 979 for i := 3 to length(s) do980 Index := Index * 10 + Ord( s[i]) - 48;981 case s[2] of970 for I := 3 to Length(S) do 971 Index := Index * 10 + Ord(S[I]) - 48; 972 case S[2] of 982 973 'A': Category := hkAdv; 983 974 'B': Category := hkImp; … … 986 977 'E': Category := hkInternet; 987 978 'S': Category := hkModel; 988 'C': Index := miscCredits;989 'J': Index := miscJobList;990 'G': Index := miscGovList;979 'C': Index := Integer(miscCredits); 980 'J': Index := Integer(miscJobList); 981 'G': Index := Integer(miscGovList); 991 982 end; 992 983 if (Category <> hkMisc) and (Index = 0) then … … 994 985 end else begin 995 986 Category := hkText; 996 Index := HelpText.Get handle(Copy(s, 1, 255));987 Index := HelpText.GetHandle(Copy(S, 1, 255)); 997 988 end; 998 989 end; 999 990 1000 procedure AddTextual( s: string);991 procedure AddTextual(S: string); 1001 992 var 1002 i: Integer;1003 p: Integer;1004 l: Integer;993 I: Integer; 994 P: Integer; 995 L: Integer; 1005 996 ofs: Integer; 1006 CurrentFormat: Integer;1007 FollowFormat: Integer;997 CurrentFormat: TTextFormat; 998 FollowFormat: TTextFormat; 1008 999 Picpix: Integer; 1009 LinkCategory: Integer; 1000 LinkCategory: TLinkCategory; 1001 CrossLink: Boolean; 1010 1002 LinkIndex: Integer; 1011 1003 RightMargin: Integer; … … 1013 1005 Text: string; 1014 1006 begin 1007 CrossLink := False; 1015 1008 RightMargin := InnerWidth - 16 - DpiGetSystemMetrics(SM_CXVSCROLL); 1016 1009 FollowFormat := pkNormal; 1017 while s<> '' do1010 while S <> '' do 1018 1011 begin 1019 1012 Picpix := 0; 1020 LinkCategory := 0;1013 LinkCategory := hkNoLink; 1021 1014 LinkIndex := 0; 1022 if s[1] = '$' then1023 begin // window caption1024 p:= 1;1015 if S[1] = '$' then 1016 begin // Window caption 1017 P := 1; 1025 1018 repeat 1026 inc(p)1027 until ( p > Length(s)) or (s[p] = '\');1028 Caption := Copy( s, 2, p- 2);1029 Delete( s, 1, p);1019 Inc(P); 1020 until (P > Length(S)) or (S[P] = '\'); 1021 Caption := Copy(S, 2, P - 2); 1022 Delete(S, 1, P); 1030 1023 end 1031 else if s[1] = '&' then1032 begin // standard block1033 p:= 1;1024 else if S[1] = '&' then 1025 begin // Standard block 1026 P := 1; 1034 1027 repeat 1035 inc(p)1036 until ( p > Length(s)) or (s[p] = '\');1037 AddStandardBlock(Copy( s, 2, p- 2));1038 Delete( s, 1, p);1028 Inc(P); 1029 until (P > Length(S)) or (S[P] = '\'); 1030 AddStandardBlock(Copy(S, 2, P - 2)); 1031 Delete(S, 1, P); 1039 1032 end 1040 else if s[1] = '@' then1041 begin // image1042 if (Length( s) >= 2) and (s[2] = '@') then1043 begin // generate from icon1033 else if S[1] = '@' then 1034 begin // Image 1035 if (Length(S) >= 2) and (S[2] = '@') then 1036 begin // Generate from icon 1044 1037 Picpix := 0; 1045 p:= 3;1046 while ( p <= Length(s)) and (s[p] <> '\') do1038 P := 3; 1039 while (P <= Length(S)) and (S[P] <> '\') do 1047 1040 begin 1048 Picpix := Picpix * 10 + Ord( s[p]) - 48;1049 inc(p)1041 Picpix := Picpix * 10 + Ord(S[P]) - 48; 1042 Inc(P); 1050 1043 end; 1051 1044 if (Picpix < 0) or (Picpix >= nImp) then … … 1057 1050 else 1058 1051 begin // external image 1059 p:= 1;1052 P := 1; 1060 1053 repeat 1061 Inc( p)1062 until ( p > Length(s)) or (s[p] = '\');1054 Inc(P); 1055 until (P > Length(S)) or (S[P] = '\'); 1063 1056 if LoadGraphicFile(ExtPic, LocalizedFilePath('Help' + 1064 DirectorySeparator + Copy( s, 2, p- 2)) + '.png') then1057 DirectorySeparator + Copy(S, 2, P - 2)) + '.png') then 1065 1058 begin 1066 1059 MainText.AddLine('', pkExternal); 1067 for i:= 0 to (ExtPic.Height - 12) div 24 do1060 for I := 0 to (ExtPic.Height - 12) div 24 do 1068 1061 MainText.LineFeed; 1069 1062 end; 1070 1063 end; 1071 Delete( s, 1, p);1064 Delete(S, 1, P); 1072 1065 end 1073 1066 else 1074 1067 begin 1075 case s[1] of1068 case S[1] of 1076 1069 ':', ';': 1077 1070 begin // link 1078 p:= 1;1071 P := 1; 1079 1072 repeat 1080 inc(p)1081 until ( p > Length(s)) or (s[p] = '\') or (s[p] = ' ');1082 DecodeItem(Copy( s, 2, p- 2), LinkCategory, LinkIndex);1083 CurrentFormat := 0;1073 Inc(P); 1074 until (P > Length(S)) or (S[P] = '\') or (S[P] = ' '); 1075 DecodeItem(Copy(S, 2, P - 2), LinkCategory, LinkIndex); 1076 CurrentFormat := pkNormal; 1084 1077 if (LinkCategory <> hkText) and (LinkIndex < 200) then 1085 1078 // show icon … … 1088 1081 begin 1089 1082 CurrentFormat := pkAdvIcon; 1090 Picpix := LinkIndex 1083 Picpix := LinkIndex; 1091 1084 end; 1092 1085 hkImp: 1093 1086 begin 1094 1087 CurrentFormat := pkSmallIcon; 1095 Picpix := LinkIndex 1088 Picpix := LinkIndex; 1096 1089 end; 1097 1090 hkTer: … … 1103 1096 begin 1104 1097 CurrentFormat := pkFeature; 1105 Picpix := LinkIndex 1098 Picpix := LinkIndex; 1106 1099 end; 1107 1100 hkModel: … … 1112 1105 end; 1113 1106 end; 1114 if s[1] = ':' then1115 LinkCategory := LinkCategory + hkCrossLink;1116 if ( p > Length(s)) or (s[p] = ' ') then1117 Delete( s, 1, p)1107 if S[1] = ':' then 1108 CrossLink := True; 1109 if (P > Length(S)) or (S[P] = ' ') then 1110 Delete(S, 1, P) 1118 1111 else 1119 Delete( s, 1, p- 1)1120 end; 1121 '!': // highli ted1122 if (Length( s) >= 2) and (s[2] = '!') then1112 Delete(S, 1, P - 1) 1113 end; 1114 '!': // highlighted 1115 if (Length(S) >= 2) and (S[2] = '!') then 1123 1116 begin 1124 1117 if MainText.Count > 1 then … … 1126 1119 FollowFormat := pkCaption; 1127 1120 CurrentFormat := pkCaption; 1128 Delete( s, 1, 2);1121 Delete(S, 1, 2); 1129 1122 end 1130 1123 else … … 1132 1125 FollowFormat := pkSection; 1133 1126 CurrentFormat := pkSection; 1134 Delete( s, 1, 1);1127 Delete(S, 1, 1); 1135 1128 end; 1136 1129 '-': … … 1138 1131 FollowFormat := pkNormal_Dot; 1139 1132 CurrentFormat := pkDot; 1140 Delete( s, 1, 1);1133 Delete(S, 1, 1); 1141 1134 end; 1142 1135 else … … 1147 1140 else 1148 1141 ofs := 8; 1149 p:= 0;1142 P := 0; 1150 1143 repeat 1151 1144 repeat 1152 Inc( p)1153 until ( p > Length(s)) or (s[p] = ' ') or (s[p] = '\');1154 if (BiColorTextWidth(OffScreen.Canvas, Copy( s, 1, p- 1)) <=1145 Inc(P) 1146 until (P > Length(S)) or (S[P] = ' ') or (S[P] = '\'); 1147 if (BiColorTextWidth(OffScreen.Canvas, Copy(S, 1, P - 1)) <= 1155 1148 RightMargin - ofs) then 1156 l := p- 11149 L := P - 1 1157 1150 else 1158 1151 Break; 1159 until ( p >= Length(s)) or (s[l+ 1] = '\');1160 Text := Copy( s, 1, l);1161 if LinkCategory and $3f= hkInternet then begin1152 until (P >= Length(S)) or (S[L + 1] = '\'); 1153 Text := Copy(S, 1, L); 1154 if LinkCategory = hkInternet then begin 1162 1155 if LinkIndex = 1 then Text := AITemplateManual 1163 1156 else if LinkIndex = 2 then Text := CevoHomepageShort … … 1165 1158 end; 1166 1159 MainText.AddLine(Text, CurrentFormat, Picpix, LinkCategory, 1167 LinkIndex );1168 if ( l < Length(s)) and (s[l+ 1] = '\') then1160 LinkIndex, CrossLink); 1161 if (L < Length(S)) and (S[L + 1] = '\') then 1169 1162 FollowFormat := pkNormal; 1170 Delete( s, 1, l+ 1);1171 end 1172 end 1163 Delete(S, 1, L + 1); 1164 end; 1165 end; 1173 1166 end; 1174 1167 … … 1178 1171 end; 1179 1172 1180 procedure AddModelText( i: Integer);1173 procedure AddModelText(I: Integer); 1181 1174 var 1182 1175 pix: Integer; 1183 s: string;1176 S: string; 1184 1177 begin 1185 1178 with MainText do begin … … 1188 1181 LineFeed; 1189 1182 end; 1190 FindStdModelPicture(SpecialModelPictureCode[ i], pix, s);1191 AddLine( s, pkSection);1192 AddLine(Format(HelpText.Lookup('STRENGTH'), [SpecialModel[ i].Attack,1193 SpecialModel[ i].Defense]), pkNormal_64);1183 FindStdModelPicture(SpecialModelPictureCode[I], pix, S); 1184 AddLine(S, pkSection); 1185 AddLine(Format(HelpText.Lookup('STRENGTH'), [SpecialModel[I].Attack, 1186 SpecialModel[I].Defense]), pkNormal_64); 1194 1187 AddLine(Format(HelpText.Lookup('SPEED'), 1195 [MovementToString(SpecialModel[ i].Speed)]), pkModel, pix);1188 [MovementToString(SpecialModel[I].Speed)]), pkModel, pix); 1196 1189 if Difficulty = 0 then 1197 AddLine(Format(HelpText.Lookup('BUILDCOST'), [SpecialModel[ i].Cost]),1190 AddLine(Format(HelpText.Lookup('BUILDCOST'), [SpecialModel[I].Cost]), 1198 1191 pkNormal_64) 1199 1192 else 1200 1193 AddLine(Format(HelpText.Lookup('BUILDCOST'), 1201 [SpecialModel[ i].Cost * BuildCostMod[Difficulty] div 12]),1194 [SpecialModel[I].Cost * BuildCostMod[Difficulty] div 12]), 1202 1195 pkNormal_64); 1203 s := HelpText.LookupByHandle(hSPECIALMODEL, i);1204 if ( s <> '') and (s<> '*') then1205 AddTextual( s);1206 if SpecialModelPreq[ i] >= 0 then1207 AddPreqAdv(SpecialModelPreq[ i])1208 else if SpecialModelPreq[ i] = preLighthouse then1196 S := HelpText.LookupByHandle(hSPECIALMODEL, I); 1197 if (S <> '') and (S <> '*') then 1198 AddTextual(S); 1199 if SpecialModelPreq[I] >= 0 then 1200 AddPreqAdv(SpecialModelPreq[I]) 1201 else if SpecialModelPreq[I] = preLighthouse then 1209 1202 AddPreqImp(woLighthouse) 1210 else if SpecialModelPreq[ i] = preBuilder then1203 else if SpecialModelPreq[I] = preBuilder then 1211 1204 AddPreqImp(woPyramids) 1212 else if SpecialModelPreq[ i] = preLeo then1205 else if SpecialModelPreq[I] = preLeo then 1213 1206 AddPreqImp(woLeo); 1214 if SpecialModelPreq[ i] <> preNone then1207 if SpecialModelPreq[I] <> preNone then 1215 1208 MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'), 1216 1209 [MainText[Count - 1]]); … … 1220 1213 procedure AddJobList; 1221 1214 var 1222 i, JobCost: Integer;1215 I, JobCost: Integer; 1223 1216 begin 1224 1217 with MainText do begin 1225 for i := 0 to nJobHelp- 1 do begin1226 if i> 0 then begin1218 for I := 0 to Length(JobHelp) - 1 do begin 1219 if I > 0 then begin 1227 1220 LineFeed; 1228 1221 LineFeed; 1229 1222 end; 1230 AddLine(Phrases.Lookup('JOBRESULT', JobHelp[ i]), pkSection);1223 AddLine(Phrases.Lookup('JOBRESULT', JobHelp[I]), pkSection); 1231 1224 AddLine; 1232 AddLine('', pkTerImp, i);1225 AddLine('', pkTerImp, I); 1233 1226 AddLine; 1234 AddTextual(HelpText.LookupByHandle(hJOBHELP, i));1227 AddTextual(HelpText.LookupByHandle(hJOBHELP, I)); 1235 1228 JobCost := -1; 1236 case JobHelp[ i] of1229 case JobHelp[I] of 1237 1230 jCanal: JobCost := CanalWork; 1238 1231 jFort: JobCost := FortWork; … … 1244 1237 else 1245 1238 AddTextual(HelpText.Lookup('JOBCOSTVAR')); 1246 if JobPreq[JobHelp[ i]] <> preNone then begin1247 AddPreqAdv(JobPreq[JobHelp[ i]]);1239 if JobPreq[JobHelp[I]] <> preNone then begin 1240 AddPreqAdv(JobPreq[JobHelp[I]]); 1248 1241 MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'), 1249 1242 [MainText[Count - 1]]); … … 1255 1248 procedure AddGraphicCredits; 1256 1249 var 1257 i: Integer;1258 s: string;1250 I: Integer; 1251 S: string; 1259 1252 sr: TSearchRec; 1260 1253 List, Plus: TStringList; … … 1271 1264 1272 1265 List.Sort; 1273 i:= 1;1274 while i< List.Count do1275 if List[ i] = List[i- 1] then1276 List.Delete( i)1266 I := 1; 1267 while I < List.Count do 1268 if List[I] = List[I - 1] then 1269 List.Delete(I) 1277 1270 else 1278 Inc( i);1279 1280 for i:= 0 to List.Count - 1 do begin1281 s := List[i];1282 while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 -1271 Inc(I); 1272 1273 for I := 0 to List.Count - 1 do begin 1274 S := List[I]; 1275 while BiColorTextWidth(OffScreen.Canvas, S) > InnerWidth - 16 - 1283 1276 DpiGetSystemMetrics(SM_CXVSCROLL) do 1284 Delete( s, length(s), 1);1285 MainText.AddLine( s);1277 Delete(S, Length(S), 1); 1278 MainText.AddLine(S); 1286 1279 end; 1287 1280 FreeAndNil(List); … … 1290 1283 procedure AddSoundCredits; 1291 1284 var 1292 i: Integer;1293 s: string;1285 I: Integer; 1286 S: string; 1294 1287 List: TStringList; 1295 1288 begin 1296 1289 List := TStringList.Create; 1297 1290 List.LoadFromFile(GetSoundsDir + DirectorySeparator + 'sound.credits.txt'); 1298 for i:= 0 to List.Count - 1 do begin1299 s := List[i];1300 while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 -1291 for I := 0 to List.Count - 1 do begin 1292 S := List[I]; 1293 while BiColorTextWidth(OffScreen.Canvas, S) > InnerWidth - 16 - 1301 1294 DpiGetSystemMetrics(SM_CXVSCROLL) do 1302 Delete( s, length(s), 1);1303 MainText.AddLine( s);1295 Delete(S, Length(S), 1); 1296 MainText.AddLine(S); 1304 1297 end; 1305 1298 FreeAndNil(List); … … 1323 1316 Clear; 1324 1317 Headline := -1; 1325 if ( no >= 200) or not(Kind in [hkAdv, hkImp, hkTer, hkFeature]) then1318 if (No >= 200) or not (Kind in [hkAdv, hkImp, hkTer, hkFeature]) then 1326 1319 LineFeed; 1327 1320 case Kind of 1328 1321 hkText: 1329 AddTextual(HelpText.LookupByHandle( no));1322 AddTextual(HelpText.LookupByHandle(No)); 1330 1323 hkMisc: 1331 1324 begin 1332 case no of1333 miscMain:1325 case No of 1326 Integer(miscMain): 1334 1327 begin 1335 1328 Caption := HelpText.Lookup('HELPTITLE_MAIN'); 1336 1329 AddLine(HelpText.Lookup('HELPTITLE_QUICKSTART'), pkSpecialIcon, 1337 0, { pkBigIcon,22, } hkText, HelpText.Get handle('QUICK'));1330 0, { pkBigIcon,22, } hkText, HelpText.GetHandle('QUICK')); 1338 1331 LineFeed; 1339 1332 AddLine(HelpText.Lookup('HELPTITLE_CONCEPTS'), pkBigIcon, 6, … … 1344 1337 LineFeed; 1345 1338 AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkSpecialIcon, 2, 1346 hkMisc, miscJobList);1339 hkMisc, Integer(miscJobList)); 1347 1340 LineFeed; 1348 1341 AddLine(HelpText.Lookup('HELPTITLE_TECHLIST'), pkBigIcon, 39, 1349 1342 hkAdv, 200); 1350 1343 LineFeed; 1351 FindStdModelPicture(SpecialModelPictureCode[6], i, s);1352 AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkModel, i,1344 FindStdModelPicture(SpecialModelPictureCode[6], I, S); 1345 AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkModel, I, 1353 1346 hkModel, 0); 1354 1347 LineFeed; … … 1366 1359 LineFeed; 1367 1360 AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkBigIcon, 1368 gDemocracy + 6, hkMisc, miscGovList);1361 gDemocracy + 6, hkMisc, Integer(miscGovList)); 1369 1362 LineFeed; 1370 1363 AddLine(HelpText.Lookup('HELPTITLE_KEYS'), pkBigIcon, 2, hkText, … … 1375 1368 LineFeed; 1376 1369 AddLine(HelpText.Lookup('HELPTITLE_CREDITS'), pkBigIcon, 22, 1377 hkMisc, miscCredits);1370 hkMisc, Integer(miscCredits)); 1378 1371 end; 1379 miscCredits:1372 Integer(miscCredits): 1380 1373 begin 1381 1374 AddItem('CREDITS'); … … 1390 1383 AddItem('AUTHOR'); 1391 1384 end; 1392 miscJobList:1385 Integer(miscJobList): 1393 1386 begin 1394 1387 Caption := HelpText.Lookup('HELPTITLE_JOBLIST'); … … 1399 1392 AddItem('TERIMPCITY'); 1400 1393 end; 1401 miscGovList:1394 Integer(miscGovList): 1402 1395 begin 1403 1396 Caption := HelpText.Lookup('HELPTITLE_GOVLIST'); 1404 for i:= 1 to nGov do1397 for I := 1 to nGov do 1405 1398 begin 1406 AddLine(Phrases.Lookup('GOVERNMENT', imod nGov), pkSection);1399 AddLine(Phrases.Lookup('GOVERNMENT', I mod nGov), pkSection); 1407 1400 LineFeed; 1408 if i= nGov then1401 if I = nGov then 1409 1402 AddLine('', pkBigIcon, 7 * SystemIconLines + imPalace) 1410 1403 else 1411 AddLine('', pkBigIcon, i+ 6);1404 AddLine('', pkBigIcon, I + 6); 1412 1405 LineFeed; 1413 AddTextual(HelpText.LookupByHandle(hGOVHELP, imod nGov));1414 if imod nGov >= 2 then1406 AddTextual(HelpText.LookupByHandle(hGOVHELP, I mod nGov)); 1407 if I mod nGov >= 2 then 1415 1408 begin 1416 AddPreqAdv(GovPreq[ imod nGov]);1409 AddPreqAdv(GovPreq[I mod nGov]); 1417 1410 MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'), 1418 1411 [MainText[Count - 1]]); 1419 1412 end; 1420 if i< nGov then1413 if I < nGov then 1421 1414 begin 1422 1415 LineFeed; … … 1425 1418 end; 1426 1419 end; 1427 miscSearchResult:1420 Integer(miscSearchResult): 1428 1421 begin 1429 1422 Caption := HelpText.Lookup('HELPTITLE_SEARCHRESULTS'); … … 1431 1424 MainText.AppendList(SearchResult); 1432 1425 end; 1433 end; // case no1426 end; // case No 1434 1427 end; 1435 1428 1436 1429 hkAdv: 1437 if no = 200 then1430 if No = 200 then 1438 1431 begin // complete advance list 1439 1432 Caption := HelpText.Lookup('HELPTITLE_TECHLIST'); 1440 1433 List := THyperText.Create; 1441 1434 List.OwnsObjects := True; 1442 for j:= 0 to 3 do1435 for J := 0 to 3 do 1443 1436 begin 1444 if j> 0 then1437 if J > 0 then 1445 1438 begin 1446 1439 LineFeed; 1447 1440 LineFeed; 1448 1441 end; 1449 AddLine(HelpText.Lookup('TECHAGE', j), pkSection);1450 if j= 1 then1442 AddLine(HelpText.Lookup('TECHAGE', J), pkSection); 1443 if J = 1 then 1451 1444 AddLine(Phrases.Lookup('ADVANCES', adScience) + ' ' + 1452 1445 HelpText.Lookup('BASETECH'), pkAdvIcon, adScience, hkAdv, 1453 1446 adScience); 1454 if j= 2 then1447 if J = 2 then 1455 1448 AddLine(Phrases.Lookup('ADVANCES', adMassProduction) + ' ' + 1456 1449 HelpText.Lookup('BASETECH'), pkAdvIcon, adMassProduction, hkAdv, 1457 1450 adMassProduction); 1458 1451 List.Clear; 1459 for i:= 0 to nAdv - 1 do1460 if ( i <> adScience) and (i<> adMassProduction) and1461 (AdvValue[ i] div 1000 = j) then1462 List.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon, i,1463 hkAdv, i);1452 for I := 0 to nAdv - 1 do 1453 if (I <> adScience) and (I <> adMassProduction) and 1454 (AdvValue[I] div 1000 = J) then 1455 List.AddLine(Phrases.Lookup('ADVANCES', I), pkAdvIcon, I, 1456 hkAdv, I); 1464 1457 List.Sort; 1465 1458 AppendList(List); … … 1469 1462 else // single advance 1470 1463 begin 1471 Caption := Phrases.Lookup('ADVANCES', no);1464 Caption := Phrases.Lookup('ADVANCES', No); 1472 1465 LineFeed; 1473 AddLine(Phrases.Lookup('ADVANCES', no), pkCaption);1474 if no in FutureTech then1466 AddLine(Phrases.Lookup('ADVANCES', No), pkCaption); 1467 if No in FutureTech then 1475 1468 begin 1476 1469 AddLine(HelpText.Lookup('HELPSPEC_FUTURE')); 1477 1470 LineFeed; 1478 if no = futResearchTechnology then1471 if No = futResearchTechnology then 1479 1472 AddItem('FUTURETECHHELP100') 1480 1473 else … … 1483 1476 else 1484 1477 AddLine(HelpText.Lookup('HELPSPEC_ADV')); 1485 if AdvPreq[ no, 2] <> preNone then1478 if AdvPreq[No, 2] <> preNone then 1486 1479 NextSection('PREREQALT') 1487 1480 else 1488 1481 NextSection('PREREQ'); 1489 for i:= 0 to 2 do1490 if AdvPreq[ no, i] <> preNone then1491 AddPreqAdv(AdvPreq[ no, i]);1482 for I := 0 to 2 do 1483 if AdvPreq[No, I] <> preNone then 1484 AddPreqAdv(AdvPreq[No, I]); 1492 1485 NextSection('GOVALLOW'); 1493 for i:= 2 to nGov - 1 do1494 if GovPreq[ i] = no then1495 AddLine(Phrases.Lookup('GOVERNMENT', i), pkGov, i,1496 hkMisc + hkCrossLink, miscGovList);1486 for I := 2 to nGov - 1 do 1487 if GovPreq[I] = No then 1488 AddLine(Phrases.Lookup('GOVERNMENT', I), pkGov, I, 1489 hkMisc, Integer(miscGovList), True); 1497 1490 NextSection('BUILDALLOW'); 1498 for i:= 0 to nWonder - 1 do1499 if Imp[ i].Preq = no then1500 AddImprovement( i);1501 for i:= nWonder to nImp - 1 do1502 if (Imp[ i].Preq = no) and (Imp[i].Kind <> ikCommon) then1503 AddImprovement( i);1504 for i:= nWonder to nImp - 1 do1505 if (Imp[ i].Preq = no) and (Imp[i].Kind = ikCommon) then1506 AddImprovement( i);1491 for I := 0 to nWonder - 1 do 1492 if Imp[I].Preq = No then 1493 AddImprovement(I); 1494 for I := nWonder to nImp - 1 do 1495 if (Imp[I].Preq = No) and (Imp[I].Kind <> ikCommon) then 1496 AddImprovement(I); 1497 for I := nWonder to nImp - 1 do 1498 if (Imp[I].Preq = No) and (Imp[I].Kind = ikCommon) then 1499 AddImprovement(I); 1507 1500 NextSection('MODELALLOW'); 1508 for i:= 0 to nSpecialModel - 1 do1509 if SpecialModelPreq[ i] = no then1510 AddModel( i);1501 for I := 0 to nSpecialModel - 1 do 1502 if SpecialModelPreq[I] = No then 1503 AddModel(I); 1511 1504 NextSection('FEATALLOW'); 1512 for i:= 0 to nFeature - 1 do1513 if Feature[ i].Preq = no then1514 AddFeature( i);1505 for I := 0 to nFeature - 1 do 1506 if Feature[I].Preq = No then 1507 AddFeature(I); 1515 1508 NextSection('FOLLOWADV'); 1516 for i:= 0 to nAdv - 1 do1517 if (AdvPreq[ i, 0] = no) or (AdvPreq[i, 1] = no) or1518 (AdvPreq[ i, 2] = no) then1519 AddAdvance( i);1509 for I := 0 to nAdv - 1 do 1510 if (AdvPreq[I, 0] = No) or (AdvPreq[I, 1] = No) or 1511 (AdvPreq[I, 2] = No) then 1512 AddAdvance(I); 1520 1513 NextSection('UPGRADEALLOW'); 1521 1514 for Domain := 0 to nDomains - 1 do 1522 for i:= 1 to nUpgrade - 1 do1523 if upgrade[Domain, i].Preq = no then1515 for I := 1 to nUpgrade - 1 do 1516 if upgrade[Domain, I].Preq = No then 1524 1517 begin 1525 if upgrade[Domain, i].Strength > 0 then1518 if upgrade[Domain, I].Strength > 0 then 1526 1519 AddLine(Format(HelpText.Lookup('STRENGTHUP'), 1527 1520 [Phrases.Lookup('DOMAIN', Domain), upgrade[Domain, 1528 i].Strength]), pkDomain, Domain);1529 if upgrade[Domain, i].Trans > 0 then1521 I].Strength]), pkDomain, Domain); 1522 if upgrade[Domain, I].Trans > 0 then 1530 1523 AddLine(Format(HelpText.Lookup('TRANSUP'), 1531 [Phrases.Lookup('DOMAIN', Domain), upgrade[Domain, i].Trans]1524 [Phrases.Lookup('DOMAIN', Domain), upgrade[Domain, I].Trans] 1532 1525 ), pkDomain, Domain); 1533 if no in FutureTech then1526 if No in FutureTech then 1534 1527 AddLine(Format(HelpText.Lookup('COSTUP'), 1535 [upgrade[Domain, i].Cost]), pkNormal_Dot)1528 [upgrade[Domain, I].Cost]), pkNormal_Dot) 1536 1529 else 1537 1530 AddLine(Format(HelpText.Lookup('COSTMIN'), 1538 [upgrade[Domain, i].Cost]), pkNormal_Dot)1531 [upgrade[Domain, I].Cost]), pkNormal_Dot) 1539 1532 end; 1540 1533 NextSection('EXPIRATION'); 1541 for i:= 0 to nWonder - 1 do1542 if (Imp[ i].Preq <> preNA) and (Imp[i].Expiration = no) then1543 AddImprovement( i);1534 for I := 0 to nWonder - 1 do 1535 if (Imp[I].Preq <> preNA) and (Imp[I].Expiration = No) then 1536 AddImprovement(I); 1544 1537 NextSection('ADVEFFECT'); 1545 s := HelpText.LookupByHandle(hADVHELP, no);1546 if s<> '*' then1547 AddTextual( s);1538 S := HelpText.LookupByHandle(hADVHELP, No); 1539 if S <> '*' then 1540 AddTextual(S); 1548 1541 NextSection('SEEALSO'); 1549 CheckSeeAlso := true1542 CheckSeeAlso := True; 1550 1543 end; 1551 1544 1552 1545 hkImp: 1553 if no = 200 then1546 if No = 200 then 1554 1547 begin // complete city improvement list 1555 1548 Caption := HelpText.Lookup('HELPTITLE_IMPLIST'); … … 1557 1550 List := THyperText.Create; 1558 1551 List.OwnsObjects := True; 1559 for i:= nWonder to nImp - 1 do1560 if ( i <> imTrGoods) and (Imp[i].Preq <> preNA) and1561 (Imp[ i].Kind = ikCommon) then1562 List.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon,1563 i, hkImp, i);1552 for I := nWonder to nImp - 1 do 1553 if (I <> imTrGoods) and (Imp[I].Preq <> preNA) and 1554 (Imp[I].Kind = ikCommon) then 1555 List.AddLine(Phrases.Lookup('IMPROVEMENTS', I), pkSmallIcon, 1556 I, hkImp, I); 1564 1557 List.Sort; 1565 1558 AppendList(List); 1566 1559 FreeAndNil(List); 1567 1560 end 1568 else if no = 201 then1561 else if No = 201 then 1569 1562 begin // complete nat. project list 1570 1563 Caption := HelpText.Lookup('HELPTITLE_UNIQUELIST'); 1571 1564 // AddLine(HelpText.Lookup('HELPTITLE_UNIQUELIST'),pkSection); 1572 for i:= nWonder to nImp - 1 do1573 if (Imp[ i].Preq <> preNA) and1574 ((Imp[ i].Kind = ikNatLocal) or (Imp[i].Kind = ikNatGlobal)) then1575 AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i,1576 hkImp, i);1565 for I := nWonder to nImp - 1 do 1566 if (Imp[I].Preq <> preNA) and 1567 ((Imp[I].Kind = ikNatLocal) or (Imp[I].Kind = ikNatGlobal)) then 1568 AddLine(Phrases.Lookup('IMPROVEMENTS', I), pkSmallIcon, I, 1569 hkImp, I); 1577 1570 { LineFeed; 1578 1571 LineFeed; 1579 1572 AddLine(HelpText.Lookup('HELPTITLE_SHIPPARTLIST'),pkSection); 1580 for i:= nWonder to nImp-1 do1581 if (Imp[ i].Preq<>preNA) and (Imp[i].Kind=ikShipPart) then1582 AddLine(Phrases.Lookup('IMPROVEMENTS', i),pkSmallIcon,i,hkImp,i); }1573 for I:= nWonder to nImp-1 do 1574 if (Imp[I].Preq<>preNA) and (Imp[I].Kind=ikShipPart) then 1575 AddLine(Phrases.Lookup('IMPROVEMENTS',I),pkSmallIcon,I,hkImp,I); } 1583 1576 end 1584 else if no = 202 then1577 else if No = 202 then 1585 1578 begin // complete wonder list 1586 1579 Caption := HelpText.Lookup('HELPTITLE_WONDERLIST'); 1587 1580 // AddLine(HelpText.Lookup('HELPTITLE_WONDERLIST'),pkSection); 1588 for i:= 0 to nWonder - 1 do1589 if Imp[ i].Preq <> preNA then1590 AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i,1591 hkImp, i);1581 for I := 0 to nWonder - 1 do 1582 if Imp[I].Preq <> preNA then 1583 AddLine(Phrases.Lookup('IMPROVEMENTS', I), pkSmallIcon, I, 1584 hkImp, I); 1592 1585 end 1593 1586 else 1594 1587 begin // single building 1595 Caption := Phrases.Lookup('IMPROVEMENTS', no);1588 Caption := Phrases.Lookup('IMPROVEMENTS', No); 1596 1589 LineFeed; 1597 AddLine(Phrases.Lookup('IMPROVEMENTS', no), pkRightIcon, no);1598 case Imp[ no].Kind of1590 AddLine(Phrases.Lookup('IMPROVEMENTS', No), pkRightIcon, No); 1591 case Imp[No].Kind of 1599 1592 ikWonder: AddLine(HelpText.Lookup('HELPSPEC_WONDER')); 1600 1593 ikCommon: AddLine(HelpText.Lookup('HELPSPEC_IMP')); … … 1603 1596 AddLine(HelpText.Lookup('HELPSPEC_NAT')) 1604 1597 end; 1605 if Imp[ no].Kind <> ikShipPart then begin1598 if Imp[No].Kind <> ikShipPart then begin 1606 1599 NextSection('EFFECT'); 1607 AddTextual(HelpText.LookupByHandle(hIMPHELP, no));1600 AddTextual(HelpText.LookupByHandle(hIMPHELP, No)); 1608 1601 end; 1609 if no = woSun then begin1602 if No = woSun then begin 1610 1603 AddFeature(mcFirst); 1611 1604 AddFeature(mcWill); 1612 1605 AddFeature(mcAcademy); 1613 1606 end; 1614 if ( no < nWonder) and not Phrases2FallenBackToEnglish then1607 if (No < nWonder) and not Phrases2FallenBackToEnglish then 1615 1608 begin 1616 1609 LineFeed; 1617 if Imp[ no].Expiration >= 0 then1610 if Imp[No].Expiration >= 0 then 1618 1611 AddTextual(Phrases2.Lookup('HELP_WONDERMORALE1')) 1619 1612 else 1620 1613 AddTextual(Phrases2.Lookup('HELP_WONDERMORALE2')); 1621 1614 end; 1622 if Imp[ no].Preq <> preNone then1615 if Imp[No].Preq <> preNone then 1623 1616 begin 1624 1617 NextSection('PREREQ'); 1625 AddPreqAdv(Imp[ no].Preq);1618 AddPreqAdv(Imp[No].Preq); 1626 1619 end; 1627 1620 NextSection('COSTS'); 1628 1621 if Difficulty = 0 then 1629 s := Format(HelpText.Lookup('BUILDCOST'), [Imp[no].Cost])1622 S := Format(HelpText.Lookup('BUILDCOST'), [Imp[No].Cost]) 1630 1623 else 1631 s:= Format(HelpText.Lookup('BUILDCOST'),1632 [Imp[ no].Cost * BuildCostMod[Difficulty] div 12]);1633 AddLine( s);1634 if Imp[ no].Maint > 0 then1635 AddLine(Format(HelpText.Lookup('MAINTCOST'), [Imp[ no].Maint]));1636 j:= 0;1637 for i:= 0 to nImpReplacement - 1 do1638 if ImpReplacement[ i].NewImp = no then1639 begin 1640 if j= 0 then1624 S := Format(HelpText.Lookup('BUILDCOST'), 1625 [Imp[No].Cost * BuildCostMod[Difficulty] div 12]); 1626 AddLine(S); 1627 if Imp[No].Maint > 0 then 1628 AddLine(Format(HelpText.Lookup('MAINTCOST'), [Imp[No].Maint])); 1629 J := 0; 1630 for I := 0 to nImpReplacement - 1 do 1631 if ImpReplacement[I].NewImp = No then 1632 begin 1633 if J = 0 then 1641 1634 begin 1642 1635 NextSection('REPLACE'); 1643 1636 AddItem('REPLACETEXT'); 1644 j:= 1;1637 J := 1; 1645 1638 end; 1646 AddImprovement(ImpReplacement[ i].OldImp);1647 end; 1648 if Imp[ no].Kind = ikShipPart then1639 AddImprovement(ImpReplacement[I].OldImp); 1640 end; 1641 if Imp[No].Kind = ikShipPart then 1649 1642 begin 1650 1643 LineFeed; 1651 if no = imShipComp then1652 i:= 11653 else if no = imShipPow then1654 i:= 21655 else { if no=imShipHab then }1656 i:= 3;1644 if No = imShipComp then 1645 I := 1 1646 else if No = imShipPow then 1647 I := 2 1648 else { if No=imShipHab then } 1649 I := 3; 1657 1650 AddLine(Format(HelpText.Lookup('RAREREQUIRED'), 1658 [Phrases.Lookup('TERRAIN', 3 * 12 + i)]), pkTer, 3 * 12 + i);1651 [Phrases.Lookup('TERRAIN', 3 * 12 + I)]), pkTer, 3 * 12 + I); 1659 1652 end; 1660 if ( no < nWonder) and (Imp[no].Expiration >= 0) then1653 if (No < nWonder) and (Imp[No].Expiration >= 0) then 1661 1654 begin 1662 1655 NextSection('EXPIRATION'); 1663 s:= Format(HelpText.Lookup('EXPWITH'),1664 [Phrases.Lookup('ADVANCES', Imp[ no].Expiration)]);1665 if no = woPyramids then1666 s := s+ ' ' + HelpText.Lookup('EXPSLAVE');1667 AddTextual( s);1656 S := Format(HelpText.Lookup('EXPWITH'), 1657 [Phrases.Lookup('ADVANCES', Imp[No].Expiration)]); 1658 if No = woPyramids then 1659 S := S + ' ' + HelpText.Lookup('EXPSLAVE'); 1660 AddTextual(S); 1668 1661 end; 1669 1662 NextSection('SEEALSO'); 1670 if ( no < nWonder) and (Imp[no].Expiration >= 0) then1663 if (No < nWonder) and (Imp[No].Expiration >= 0) then 1671 1664 AddImprovement(woEiffel); 1672 for i:= 0 to nImpReplacement - 1 do1673 if ImpReplacement[ i].OldImp = no then1674 AddImprovement(ImpReplacement[ i].NewImp);1675 if no = imSupermarket then1665 for I := 0 to nImpReplacement - 1 do 1666 if ImpReplacement[I].OldImp = No then 1667 AddImprovement(ImpReplacement[I].NewImp); 1668 if No = imSupermarket then 1676 1669 AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0, 1677 hkMisc + hkCrossLink, miscJobList);1678 CheckSeeAlso := true;1670 hkMisc, Integer(miscJobList), True); 1671 CheckSeeAlso := True; 1679 1672 end; 1680 1673 1681 1674 hkTer: 1682 if no = 200 then1675 if No = 200 then 1683 1676 begin // complete terrain type list 1684 1677 Caption := HelpText.Lookup('HELPTITLE_TERLIST'); 1685 1678 // AddLine(HelpText.Lookup('HELPTITLE_TERLIST'),pkSection); 1686 for i := 0 to nTerrainHelp- 1 do1687 AddTerrain(TerrainHelp[ i]);1679 for I := 0 to Length(TerrainHelp) - 1 do 1680 AddTerrain(TerrainHelp[I]); 1688 1681 end 1689 1682 else 1690 1683 begin // sigle terrain type 1691 TerrType := no mod 12;1684 TerrType := No mod 12; 1692 1685 if TerrType = fJungle then 1693 1686 TerrType := fForest; 1694 TerrSubType := no div 12;1695 if no = 3 * 12 then1687 TerrSubType := No div 12; 1688 if No = 3 * 12 then 1696 1689 begin 1697 1690 TerrType := fDesert; … … 1700 1693 with Terrain[TerrType] do 1701 1694 begin 1702 Caption := Phrases.Lookup('TERRAIN', no);1695 Caption := Phrases.Lookup('TERRAIN', No); 1703 1696 LineFeed; 1704 AddLine(Phrases.Lookup('TERRAIN', no), pkBigTer, no);1697 AddLine(Phrases.Lookup('TERRAIN', No), pkBigTer, No); 1705 1698 AddLine(HelpText.Lookup('HELPSPEC_TER')); 1706 1699 LineFeed; … … 1708 1701 AddLine(Format(HelpText.Lookup('RESPROD'), 1709 1702 [ProdRes[TerrSubType]])); 1710 if ( no < 3 * 12) and (MineEff > 0) then1703 if (No < 3 * 12) and (MineEff > 0) then 1711 1704 MainText[Count - 1] := MainText[Count - 1] + ' ' + 1712 1705 Format(HelpText.Lookup('MOREMINE'), [MineEff]); … … 1714 1707 AddLine(Format(HelpText.Lookup('RESFOOD'), 1715 1708 [FoodRes[TerrSubType]])); 1716 if ( no < 3 * 12) and (IrrEff > 0) then1709 if (No < 3 * 12) and (IrrEff > 0) then 1717 1710 MainText[Count - 1] := MainText[Count - 1] + ' ' + 1718 1711 Format(HelpText.Lookup('MOREIRR'), [IrrEff]); … … 1728 1721 else 1729 1722 AddLine(HelpText.Lookup('MOVEPLAIN')); 1730 if no = 3 * 12 then1723 if No = 3 * 12 then 1731 1724 begin 1732 1725 LineFeed; 1733 1726 AddTextual(HelpText.Lookup('DEADLANDS')); 1734 1727 end; 1735 if (TerrType = fDesert) and ( no <> fDesert + 12) then1728 if (TerrType = fDesert) and (No <> fDesert + 12) then 1736 1729 begin 1737 1730 LineFeed; … … 1743 1736 AddTextual(Format(HelpText.Lookup('HOSTILE'), [ArcticThurst])); 1744 1737 end; 1745 if ( no < 3 * 12) and (TransTerrain >= 0) then1738 if (No < 3 * 12) and (TransTerrain >= 0) then 1746 1739 begin 1747 1740 LineFeed; 1748 i:= TransTerrain;1749 if (TerrType <> fGrass) and ( i<> fGrass) then1750 i := i+ TerrSubType * 12;1741 I := TransTerrain; 1742 if (TerrType <> fGrass) and (I <> fGrass) then 1743 I := I + TerrSubType * 12; 1751 1744 // trafo to same Special resource group 1752 1745 AddLine(Format(HelpText.Lookup('TRAFO'), 1753 [Phrases.Lookup('TERRAIN', i)]), pkTer, i,1754 hkTer + hkCrossLink, i);1755 if no = fSwamp + 12 then1746 [Phrases.Lookup('TERRAIN', I)]), pkTer, I, 1747 hkTer, I, True); 1748 if No = fSwamp + 12 then 1756 1749 begin 1757 1750 LineFeed; 1758 1751 AddLine(Format(HelpText.Lookup('TRAFO'), 1759 1752 [Phrases.Lookup('TERRAIN', TransTerrain + 24)]), pkTer, 1760 TransTerrain + 24, hkTer + hkCrossLink, TransTerrain + 24);1753 TransTerrain + 24, hkTer, TransTerrain + 24, True); 1761 1754 end 1762 else if i= fGrass then1755 else if I = fGrass then 1763 1756 begin 1764 1757 LineFeed; 1765 1758 AddLine(Format(HelpText.Lookup('TRAFO'), 1766 1759 [Phrases.Lookup('TERRAIN', fGrass + 12)]), pkTer, fGrass + 12, 1767 hkTer + hkCrossLink, fGrass + 12);1760 hkTer, fGrass + 12, True); 1768 1761 end; 1769 1762 end; 1770 1763 NextSection('SPECIAL'); 1771 if no = 3 * 12 then1764 if No = 3 * 12 then 1772 1765 begin 1773 1766 LineFeed; … … 1780 1773 end; 1781 1774 end 1782 else if ( no < 12) and (no <> fGrass) and (no <> fOcean) then1775 else if (No < 12) and (No <> fGrass) and (No <> fOcean) then 1783 1776 begin 1784 1777 LineFeed; 1785 1778 for Special := 1 to 2 do 1786 if ( no <> fArctic) and (no <> fSwamp) or (Special < 2) then1779 if (No <> fArctic) and (No <> fSwamp) or (Special < 2) then 1787 1780 begin 1788 1781 if Special > 1 then 1789 1782 LineFeed; 1790 AddLine(Phrases.Lookup('TERRAIN', no + Special * 12), pkTer,1791 no + Special * 12);1792 i:= FoodRes[Special] - FoodRes[0];1793 if i<> 0 then1783 AddLine(Phrases.Lookup('TERRAIN', No + Special * 12), pkTer, 1784 No + Special * 12); 1785 I := FoodRes[Special] - FoodRes[0]; 1786 if I <> 0 then 1794 1787 MainText[Count - 1] := MainText[Count - 1] + 1795 Format(HelpText.Lookup('SPECIALFOOD'), [ i]);1796 i:= ProdRes[Special] - ProdRes[0];1797 if i<> 0 then1788 Format(HelpText.Lookup('SPECIALFOOD'), [I]); 1789 I := ProdRes[Special] - ProdRes[0]; 1790 if I <> 0 then 1798 1791 MainText[Count - 1] := MainText[Count - 1] + 1799 Format(HelpText.Lookup('SPECIALPROD'), [ i]);1800 i:= TradeRes[Special] - TradeRes[0];1801 if i<> 0 then1792 Format(HelpText.Lookup('SPECIALPROD'), [I]); 1793 I := TradeRes[Special] - TradeRes[0]; 1794 if I <> 0 then 1802 1795 MainText[Count - 1] := MainText[Count - 1] + 1803 Format(HelpText.Lookup('SPECIALTRADE'), [ i]);1796 Format(HelpText.Lookup('SPECIALTRADE'), [I]); 1804 1797 end; 1805 1798 end; 1806 if no = 3 * 12 then1799 if No = 3 * 12 then 1807 1800 begin 1808 1801 LineFeed; 1809 1802 AddTextual(HelpText.Lookup('RARE')); 1810 1803 end; 1811 if ( no < 3 * 12) and (TerrType in [fDesert, fArctic]) then1804 if (No < 3 * 12) and (TerrType in [fDesert, fArctic]) then 1812 1805 begin 1813 1806 NextSection('SEEALSO'); 1814 1807 AddImprovement(woGardens); 1815 CheckSeeAlso := true1808 CheckSeeAlso := True; 1816 1809 end; 1817 1810 end; … … 1819 1812 1820 1813 hkFeature: 1821 if no = 200 then1814 if No = 200 then 1822 1815 begin // complete feature list 1823 1816 Caption := HelpText.Lookup('HELPTITLE_FEATURELIST'); … … 1837 1830 end; 1838 1831 List.Clear; 1839 for i:= 0 to nFeature - 1 do1840 if Feature[ i].Preq <> preNA then1832 for I := 0 to nFeature - 1 do 1833 if Feature[I].Preq <> preNA then 1841 1834 begin 1842 if i< mcFirstNonCap then1843 j:= 01844 else if iin AutoFeature then1845 j:= 21835 if I < mcFirstNonCap then 1836 J := 0 1837 else if I in AutoFeature then 1838 J := 2 1846 1839 else 1847 j:= 1;1848 if j= Special then1849 List.AddLine(Phrases.Lookup('FEATURES', i), pkFeature, i,1850 hkFeature, i);1840 J := 1; 1841 if J = Special then 1842 List.AddLine(Phrases.Lookup('FEATURES', I), pkFeature, I, 1843 hkFeature, I); 1851 1844 end; 1852 1845 List.Sort; … … 1857 1850 else 1858 1851 begin // single feature 1859 Caption := Phrases.Lookup('FEATURES', no);1852 Caption := Phrases.Lookup('FEATURES', No); 1860 1853 LineFeed; 1861 AddLine(Phrases.Lookup('FEATURES', no), pkBigFeature, no);1862 if no < mcFirstNonCap then1854 AddLine(Phrases.Lookup('FEATURES', No), pkBigFeature, No); 1855 if No < mcFirstNonCap then 1863 1856 AddLine(HelpText.Lookup('HELPSPEC_CAP')) 1864 else if no in AutoFeature then1857 else if No in AutoFeature then 1865 1858 AddLine(HelpText.Lookup('HELPSPEC_STANDARD')) 1866 1859 else 1867 1860 AddLine(HelpText.Lookup('HELPSPEC_FEATURE')); 1868 1861 NextSection('EFFECT'); 1869 AddTextual(HelpText.LookupByHandle(hFEATUREHELP, no));1870 if (Feature[ no].Weight <> 0) or (Feature[no].Cost <> 0) then1862 AddTextual(HelpText.LookupByHandle(hFEATUREHELP, No)); 1863 if (Feature[No].Weight <> 0) or (Feature[No].Cost <> 0) then 1871 1864 begin 1872 1865 NextSection('COSTS'); 1873 s := IntToStr(Feature[no].Cost);1874 if Feature[ no].Cost >= 0 then1875 s := '+' + s;1876 AddLine(Format(HelpText.Lookup('COSTBASE'), [ s]));1877 if Feature[ no].Weight > 0 then1866 S := IntToStr(Feature[No].Cost); 1867 if Feature[No].Cost >= 0 then 1868 S := '+' + S; 1869 AddLine(Format(HelpText.Lookup('COSTBASE'), [S])); 1870 if Feature[No].Weight > 0 then 1878 1871 begin 1879 1872 AddLine(Format(HelpText.Lookup('WEIGHT'), 1880 ['+' + IntToStr(Feature[ no].Weight)]));1881 if no = mcDefense then1873 ['+' + IntToStr(Feature[No].Weight)])); 1874 if No = mcDefense then 1882 1875 AddLine(Format(HelpText.Lookup('WEIGHT'), ['+2']), 1883 1876 pkDomain, dGround); 1884 1877 end; 1885 1878 end; 1886 if Feature[ no].Preq <> preNone then1879 if Feature[No].Preq <> preNone then 1887 1880 begin 1888 1881 LineFeed; 1889 if Feature[ no].Preq = preSun then1882 if Feature[No].Preq = preSun then 1890 1883 AddPreqImp(woSun) // sun tsu feature 1891 1884 else 1892 AddPreqAdv(Feature[ no].Preq);1885 AddPreqAdv(Feature[No].Preq); 1893 1886 MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'), 1894 1887 [MainText[Count - 1]]); … … 1901 1894 begin 1902 1895 Caption := HelpText.Lookup('HELPTITLE_MODELLIST'); 1903 for i:= 0 to nSpecialModel - 1 do1904 if i<> 2 then1905 AddModelText( i);1896 for I := 0 to nSpecialModel - 1 do 1897 if I <> 2 then 1898 AddModelText(I); 1906 1899 LineFeed; 1907 1900 AddItem('MODELNOTE'); … … 1910 1903 end; 1911 1904 if CheckSeeAlso then 1912 for i := 0 to nSeeAlso- 1 do1913 if (SeeAlso[ i].Kind = Kind) and (SeeAlso[i].no = no) then1914 case SeeAlso[ i].SeeKind of1915 hkImp: AddImprovement(SeeAlso[ i].SeeNo);1916 hkAdv: AddAdvance(SeeAlso[ i].SeeNo);1917 hkFeature: AddFeature(SeeAlso[ i].SeeNo);1905 for I := 0 to Length(SeeAlso) - 1 do 1906 if (SeeAlso[I].Kind = Kind) and (SeeAlso[I].No = No) then 1907 case SeeAlso[I].SeeKind of 1908 hkImp: AddImprovement(SeeAlso[I].SeeNo); 1909 hkAdv: AddAdvance(SeeAlso[I].SeeNo); 1910 hkFeature: AddFeature(SeeAlso[I].SeeNo); 1918 1911 end; 1919 1912 if (Headline >= 0) and (Count = Headline + 1) then … … 1926 1919 ScrollBar.SetPos(sbPos); 1927 1920 BackBtn.Visible := HistItems.Count > 1; 1928 TopBtn.Visible := (HistItems.Count > 1) or (Kind <> hkMisc) or ( no <> miscMain);1921 TopBtn.Visible := (HistItems.Count > 1) or (Kind <> hkMisc) or (No <> Integer(miscMain)); 1929 1922 Sel := -1; 1930 1923 end; // with MainText 1931 1924 end; 1932 1925 1933 procedure THelpDlg.ShowNewContent(NewMode, Category, Index: Integer); 1934 begin 1935 if (Category <> Kind) or (Index <> no) or (Category = hkMisc) and 1936 (Index = miscSearchResult) then begin 1926 procedure THelpDlg.ShowNewContent(NewMode: TWindowMode; Category: TLinkCategory; 1927 Index: Integer); 1928 begin 1929 if (Category <> Kind) or (Index <> No) or (Category = hkMisc) and 1930 (Index = Integer(miscSearchResult)) then begin 1937 1931 if HistItems.Count = MaxHist then HistItems.Delete(0); 1938 1932 if HistItems.Count = 0 then … … 1941 1935 end; 1942 1936 Kind := Category; 1943 no := Index;1937 No := Index; 1944 1938 SearchContent := NewSearchContent; 1945 1939 Prepare; … … 1949 1943 1950 1944 procedure THelpDlg.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; 1951 x, y: integer);1945 X, Y: Integer); 1952 1946 var 1953 1947 i0, Sel0: Integer; 1954 1948 begin 1955 y := y- WideFrame;1949 Y := Y - WideFrame; 1956 1950 i0 := ScrollBar.Position; 1957 1951 Sel0 := Sel; 1958 if ( x >= SideFrame) and (x < SideFrame + InnerWidth) and (y>= 0) and1959 ( y < InnerHeight) and (ymod 24 >= 8) then1960 Sel := ydiv 241952 if (X >= SideFrame) and (X < SideFrame + InnerWidth) and (Y >= 0) and 1953 (Y < InnerHeight) and (Y mod 24 >= 8) then 1954 Sel := Y div 24 1961 1955 else 1962 1956 Sel := -1; 1963 1957 if (Sel + i0 >= MainText.Count) or (Sel >= 0) and 1964 (THelpLineInfo(MainText.Objects[Sel + i0]).Link = 0) then 1958 (THelpLineInfo(MainText.Objects[Sel + i0]).Category = hkNoLink) and 1959 (THelpLineInfo(MainText.Objects[Sel + i0]).Index = 0)then 1965 1960 Sel := -1; 1966 1961 if Sel <> Sel0 then … … 1974 1969 1975 1970 procedure THelpDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 1976 Shift: TShiftState; x, y: integer);1971 Shift: TShiftState; X, Y: Integer); 1977 1972 begin 1978 1973 if Sel >= 0 then 1979 1974 with THelpLineInfo(MainText.Objects[Sel + ScrollBar.Position]) do 1980 if Link shr 8 and $3F= hkInternet then1981 case Link and $FFof1975 if Category = hkInternet then 1976 case Index of 1982 1977 1: OpenDocument(HomeDir + AITemplateFileName); 1983 1978 2: OpenURL(CevoHomepage); … … 1986 1981 else 1987 1982 begin 1988 if (Link >= $8000) and (Link and $3FFF = liInvalid) then 1989 exit; // invalid link; 1990 if Link >= $8000 then 1991 ShowNewContent(FWindowMode, hkText, Link and $3FFF) 1992 else 1993 ShowNewContent(FWindowMode, Link shr 8 and $3F, Link and $FF); 1983 if Index < 0 then Exit; // invalid link; 1984 ShowNewContent(FWindowMode, Category, Index); 1994 1985 end; 1995 1986 end; … … 2003 1994 HistItem.Assign(HistItems.Last); 2004 1995 HistItems.Delete(HistItems.Count - 1); 2005 if (HistItem.Kind = hkMisc) and (HistItem.No = miscSearchResult) and1996 if (HistItem.Kind = hkMisc) and (HistItem.No = Integer(miscSearchResult)) and 2006 1997 (HistItem.SearchContent <> SearchContent) then 2007 1998 begin … … 2010 2001 end; 2011 2002 Kind := HistItem.Kind; 2012 no := HistItem.No;2003 No := HistItem.No; 2013 2004 Prepare(HistItem.Pos); 2014 2005 OffscreenPaint; … … 2022 2013 while HistItems.Count > 1 do HistItems.Delete(HistItems.Count - 1); 2023 2014 Kind := hkMisc; 2024 no := miscMain;2015 No := Integer(miscMain); 2025 2016 Prepare; 2026 2017 OffscreenPaint; … … 2036 2027 function THelpDlg.TextIndex(Item: string): Integer; 2037 2028 begin 2038 Result := HelpText.Get handle(Item);2029 Result := HelpText.GetHandle(Item); 2039 2030 end; 2040 2031 … … 2064 2055 1: 2065 2056 with THelpLineInfo(SearchResult.Objects[0]) do 2066 if Link >= $8000 then 2067 ShowNewContent(FWindowMode, hkText, Link and $3FFF) 2068 else 2069 ShowNewContent(FWindowMode, Link shr 8 and $3F, Link and $FF); 2070 else 2071 begin 2057 ShowNewContent(FWindowMode, Category, Index); 2058 else begin 2072 2059 NewSearchContent := InputDlg.EInput.Text; 2073 ShowNewContent(FWindowMode, hkMisc, miscSearchResult);2060 ShowNewContent(FWindowMode, hkMisc, Integer(miscSearchResult)); 2074 2061 end; 2075 2062 end; … … 2079 2066 procedure THelpDlg.Search(SearchString: string); 2080 2067 var 2081 h, i, PrevHandle, PrevIndex, p, RightMargin: Integer;2082 s: string;2083 mADVHELP, mIMPHELP, mFEATUREHELP: set of 0 ..255;2068 H, I, PrevHandle, PrevIndex, P, RightMargin: Integer; 2069 S: string; 2070 mADVHELP, mIMPHELP, mFEATUREHELP: set of 0..255; 2084 2071 bGOVHELP, bSPECIALMODEL, bJOBHELP: Boolean; 2085 2072 begin … … 2092 2079 bJOBHELP := False; 2093 2080 2094 // search in generic reference2081 // Search in generic reference 2095 2082 SearchString := UpperCase(SearchString); 2096 for i:= 0 to 35 + 4 do begin2097 s := Phrases.Lookup('TERRAIN', i);2098 if pos(SearchString, UpperCase(s)) > 0 then2099 if i< 36 then2100 SearchResult.AddLine( s+ ' ' + HelpText.Lookup('HELPSPEC_TER'),2101 pkNormal, 0, hkTer + hkCrossLink, i)2083 for I := 0 to 35 + 4 do begin 2084 S := Phrases.Lookup('TERRAIN', I); 2085 if Pos(SearchString, UpperCase(S)) > 0 then 2086 if I < 36 then 2087 SearchResult.AddLine(S + ' ' + HelpText.Lookup('HELPSPEC_TER'), 2088 pkNormal, 0, hkTer, I, True) 2102 2089 else 2103 2090 begin 2104 2091 SearchResult.AddLine(Phrases.Lookup('TERRAIN', 36) + ' ' + 2105 2092 HelpText.Lookup('HELPSPEC_TER'), pkNormal, 0, 2106 hkTer + hkCrossLink, 36);2107 if i> 36 then2093 hkTer, 36, True); 2094 if I > 36 then 2108 2095 SearchResult.AddLine(Phrases.Lookup('IMPROVEMENTS', 2109 imShipComp + i- 37) + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART'),2110 pkNormal, 0, hkImp + hkCrossLink, imShipComp + i - 37);2096 imShipComp + I - 37) + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART'), 2097 pkNormal, 0, hkImp, imShipComp + I - 37, True); 2111 2098 Break; 2112 2099 end; 2113 2100 end; 2114 for i := 0 to nJobHelp- 1 do2115 if pos(SearchString, UpperCase(Phrases.Lookup('JOBRESULT', JobHelp[i]))) > 02101 for I := 0 to Length(JobHelp) - 1 do 2102 if Pos(SearchString, UpperCase(Phrases.Lookup('JOBRESULT', JobHelp[I]))) > 0 2116 2103 then 2117 2104 begin 2118 2105 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0, 2119 hkMisc + hkCrossLink, miscJobList);2106 hkMisc, Integer(miscJobList), True); 2120 2107 bJOBHELP := True; 2121 2108 Break; 2122 2109 end; 2123 for i:= 0 to nAdv - 1 do2124 begin 2125 s := Phrases.Lookup('ADVANCES', i);2126 if pos(SearchString, UpperCase(s)) > 0 then2110 for I := 0 to nAdv - 1 do 2111 begin 2112 S := Phrases.Lookup('ADVANCES', I); 2113 if Pos(SearchString, UpperCase(S)) > 0 then 2127 2114 begin 2128 if iin FutureTech then2129 s := s+ ' ' + HelpText.Lookup('HELPSPEC_FUTURE')2115 if I in FutureTech then 2116 S := S + ' ' + HelpText.Lookup('HELPSPEC_FUTURE') 2130 2117 else 2131 s := s+ ' ' + HelpText.Lookup('HELPSPEC_ADV');2132 SearchResult.AddLine( s, pkNormal, 0, hkAdv + hkCrossLink, i);2133 include(mADVHELP, i);2118 S := S + ' ' + HelpText.Lookup('HELPSPEC_ADV'); 2119 SearchResult.AddLine(S, pkNormal, 0, hkAdv, I, True); 2120 Include(mADVHELP, I); 2134 2121 end; 2135 2122 end; 2136 for i:= 0 to nSpecialModel - 1 do2137 begin 2138 FindStdModelPicture(SpecialModelPictureCode[ i], h, s);2139 if pos(SearchString, UpperCase(s)) > 0 then2123 for I := 0 to nSpecialModel - 1 do 2124 begin 2125 FindStdModelPicture(SpecialModelPictureCode[I], H, S); 2126 if Pos(SearchString, UpperCase(S)) > 0 then 2140 2127 begin 2141 2128 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkNormal, 0, 2142 hkModel + hkCrossLink, 0);2129 hkModel, 0, True); 2143 2130 bSPECIALMODEL := True; 2144 2131 Break; 2145 2132 end; 2146 2133 end; 2147 for i:= 0 to nFeature - 1 do2148 begin 2149 s := Phrases.Lookup('FEATURES', i);2150 if Pos(SearchString, UpperCase( s)) > 0 then2134 for I := 0 to nFeature - 1 do 2135 begin 2136 S := Phrases.Lookup('FEATURES', I); 2137 if Pos(SearchString, UpperCase(S)) > 0 then 2151 2138 begin 2152 if i< mcFirstNonCap then2153 s := s+ ' ' + HelpText.Lookup('HELPSPEC_CAP')2154 else if iin AutoFeature then2155 s := s+ ' ' + HelpText.Lookup('HELPSPEC_STANDARD')2139 if I < mcFirstNonCap then 2140 S := S + ' ' + HelpText.Lookup('HELPSPEC_CAP') 2141 else if I in AutoFeature then 2142 S := S + ' ' + HelpText.Lookup('HELPSPEC_STANDARD') 2156 2143 else 2157 s := s+ ' ' + HelpText.Lookup('HELPSPEC_FEATURE');2158 SearchResult.AddLine( s, pkNormal, 0, hkFeature + hkCrossLink, i);2159 Include(mFEATUREHELP, i);2144 S := S + ' ' + HelpText.Lookup('HELPSPEC_FEATURE'); 2145 SearchResult.AddLine(S, pkNormal, 0, hkFeature, I, True); 2146 Include(mFEATUREHELP, I); 2160 2147 end; 2161 2148 end; 2162 for i:= 0 to nImp - 1 do2163 begin 2164 s := Phrases.Lookup('IMPROVEMENTS', i);2165 if Pos(SearchString, UpperCase( s)) > 0 then2149 for I := 0 to nImp - 1 do 2150 begin 2151 S := Phrases.Lookup('IMPROVEMENTS', I); 2152 if Pos(SearchString, UpperCase(S)) > 0 then 2166 2153 begin 2167 case Imp[ i].Kind of2154 case Imp[I].Kind of 2168 2155 ikWonder: 2169 s := s+ ' ' + HelpText.Lookup('HELPSPEC_WONDER');2156 S := S + ' ' + HelpText.Lookup('HELPSPEC_WONDER'); 2170 2157 ikCommon: 2171 s := s+ ' ' + HelpText.Lookup('HELPSPEC_IMP');2158 S := S + ' ' + HelpText.Lookup('HELPSPEC_IMP'); 2172 2159 ikShipPart: 2173 s := s+ ' ' + HelpText.Lookup('HELPSPEC_SHIPPART');2160 S := S + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART'); 2174 2161 else 2175 s := s+ ' ' + HelpText.Lookup('HELPSPEC_NAT')2162 S := S + ' ' + HelpText.Lookup('HELPSPEC_NAT') 2176 2163 end; 2177 SearchResult.AddLine( s, pkNormal, 0, hkImp + hkCrossLink, i);2178 Include(mIMPHELP, i);2164 SearchResult.AddLine(S, pkNormal, 0, hkImp, I, True); 2165 Include(mIMPHELP, I); 2179 2166 end 2180 2167 end; 2181 for i:= 0 to nGov - 1 do2182 if Pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', i))) > 0 then2168 for I := 0 to nGov - 1 do 2169 if Pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', I))) > 0 then 2183 2170 begin 2184 2171 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkNormal, 0, 2185 hkMisc + hkCrossLink, miscGovList);2172 hkMisc, Integer(miscGovList), True); 2186 2173 bGOVHELP := True; 2187 2174 Break; 2188 2175 end; 2189 2176 2190 // full text search2191 h:= -1;2177 // Full text search 2178 H := -1; 2192 2179 repeat 2193 PrevHandle := h;2194 PrevIndex := i;2195 if not HelpText.Search(SearchString, h, i) then2180 PrevHandle := H; 2181 PrevIndex := I; 2182 if not HelpText.Search(SearchString, H, I) then 2196 2183 Break; 2197 if h= hADVHELP then2184 if H = hADVHELP then 2198 2185 begin 2199 if ( i >= 0) and ((i <> PrevIndex) or (h<> PrevHandle)) and2200 not( iin mADVHELP) then2186 if (I >= 0) and ((I <> PrevIndex) or (H <> PrevHandle)) and 2187 not(I in mADVHELP) then 2201 2188 begin 2202 s := Phrases.Lookup('ADVANCES', i);2203 if iin FutureTech then2204 s := s+ ' ' + HelpText.Lookup('HELPSPEC_FUTURE')2189 S := Phrases.Lookup('ADVANCES', I); 2190 if I in FutureTech then 2191 S := S + ' ' + HelpText.Lookup('HELPSPEC_FUTURE') 2205 2192 else 2206 s := s+ ' ' + HelpText.Lookup('HELPSPEC_ADV');2207 SearchResult.AddLine( s, pkNormal, 0, hkAdv + hkCrossLink, i)2193 S := S + ' ' + HelpText.Lookup('HELPSPEC_ADV'); 2194 SearchResult.AddLine(S, pkNormal, 0, hkAdv, I, True); 2208 2195 end; 2209 2196 end 2210 else if h= hIMPHELP then2197 else if H = hIMPHELP then 2211 2198 begin 2212 if ( i >= 0) and ((i <> PrevIndex) or (h<> PrevHandle)) and2213 not( iin mIMPHELP) then2199 if (I >= 0) and ((I <> PrevIndex) or (H <> PrevHandle)) and 2200 not(I in mIMPHELP) then 2214 2201 begin 2215 s := Phrases.Lookup('IMPROVEMENTS', i);2216 case Imp[ i].Kind of2202 S := Phrases.Lookup('IMPROVEMENTS', I); 2203 case Imp[I].Kind of 2217 2204 ikWonder: 2218 s := s+ ' ' + HelpText.Lookup('HELPSPEC_WONDER');2205 S := S + ' ' + HelpText.Lookup('HELPSPEC_WONDER'); 2219 2206 ikCommon: 2220 s := s+ ' ' + HelpText.Lookup('HELPSPEC_IMP');2207 S := S + ' ' + HelpText.Lookup('HELPSPEC_IMP'); 2221 2208 ikShipPart: 2222 s := s+ ' ' + HelpText.Lookup('HELPSPEC_SHIPPART');2209 S := S + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART'); 2223 2210 else 2224 s := s+ ' ' + HelpText.Lookup('HELPSPEC_NAT')2211 S := S + ' ' + HelpText.Lookup('HELPSPEC_NAT') 2225 2212 end; 2226 SearchResult.AddLine( s, pkNormal, 0, hkImp + hkCrossLink, i)2213 SearchResult.AddLine(S, pkNormal, 0, hkImp, I, True); 2227 2214 end; 2228 2215 end 2229 else if h= hFEATUREHELP then2216 else if H = hFEATUREHELP then 2230 2217 begin 2231 if ( i >= 0) and ((i <> PrevIndex) or (h<> PrevHandle)) and2232 not( iin mFEATUREHELP) then2218 if (I >= 0) and ((I <> PrevIndex) or (H <> PrevHandle)) and 2219 not(I in mFEATUREHELP) then 2233 2220 begin 2234 s := Phrases.Lookup('FEATURES', i);2235 if i< mcFirstNonCap then2236 s := s+ ' ' + HelpText.Lookup('HELPSPEC_CAP')2237 else if iin AutoFeature then2238 s := s+ ' ' + HelpText.Lookup('HELPSPEC_STANDARD')2221 S := Phrases.Lookup('FEATURES', I); 2222 if I < mcFirstNonCap then 2223 S := S + ' ' + HelpText.Lookup('HELPSPEC_CAP') 2224 else if I in AutoFeature then 2225 S := S + ' ' + HelpText.Lookup('HELPSPEC_STANDARD') 2239 2226 else 2240 s := s+ ' ' + HelpText.Lookup('HELPSPEC_FEATURE');2241 SearchResult.AddLine( s, pkNormal, 0, hkFeature + hkCrossLink, i);2227 S := S + ' ' + HelpText.Lookup('HELPSPEC_FEATURE'); 2228 SearchResult.AddLine(S, pkNormal, 0, hkFeature, I, True); 2242 2229 end; 2243 2230 end 2244 else if h= hGOVHELP then2231 else if H = hGOVHELP then 2245 2232 begin 2246 if ( i >= 0) and (h<> PrevHandle) and not bGOVHELP then2233 if (I >= 0) and (H <> PrevHandle) and not bGOVHELP then 2247 2234 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkNormal, 0, 2248 hkMisc + hkCrossLink, miscGovList)2235 hkMisc, Integer(miscGovList), True); 2249 2236 end 2250 else if h= hSPECIALMODEL then2237 else if H = hSPECIALMODEL then 2251 2238 begin 2252 if ( i >= 0) and (h<> PrevHandle) and not bSPECIALMODEL then2239 if (I >= 0) and (H <> PrevHandle) and not bSPECIALMODEL then 2253 2240 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkNormal, 2254 0, hkModel + hkCrossLink, 0)2241 0, hkModel, 0, True); 2255 2242 end 2256 else if h= hJOBHELP then2243 else if H = hJOBHELP then 2257 2244 begin 2258 if ( i >= 0) and (h<> PrevHandle) and not bJOBHELP then2245 if (I >= 0) and (H <> PrevHandle) and not bJOBHELP then 2259 2246 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0, 2260 hkMisc + hkCrossLink, miscJobList)2247 hkMisc, Integer(miscJobList), True); 2261 2248 end 2262 else if { (h<>hMAIN) and } ( h<> PrevHandle) then2249 else if { (h<>hMAIN) and } (H <> PrevHandle) then 2263 2250 begin 2264 s := HelpText.LookupByHandle(h);2265 p := Pos('$', s);2266 if p> 0 then2251 S := HelpText.LookupByHandle(H); 2252 P := Pos('$', S); 2253 if P > 0 then 2267 2254 begin 2268 s := Copy(s, p + 1, maxint);2269 p := Pos('\', s);2270 if p> 0 then2271 s := Copy(s, 1, p- 1);2272 SearchResult.AddLine( s, pkNormal, 0, hkText + hkCrossLink, h);2255 S := Copy(S, P + 1, MaxInt); 2256 P := Pos('\', S); 2257 if P > 0 then 2258 S := Copy(S, 1, P - 1); 2259 SearchResult.AddLine(S, pkNormal, 0, hkText, H, True); 2273 2260 end; 2274 2261 end; 2275 2276 2277 // cut lines to fit to window2278 2279 2280 for i:= 0 to SearchResult.Count - 1 do2281 2282 while BiColorTextWidth(OffScreen.Canvas, SearchResult[i]) >2283 2284 SearchResult[i] := copy(SearchResult[i], 1, length(SearchResult[i]) - 1)2285 2286 2262 until False; 2263 2264 // Cut lines to fit to window 2265 RightMargin := InnerWidth - 16 - DpiGetSystemMetrics(SM_CXVSCROLL); 2266 OffScreen.Canvas.Font.Assign(UniFont[ftNormal]); 2267 for I := 0 to SearchResult.Count - 1 do 2268 begin 2269 while BiColorTextWidth(OffScreen.Canvas, SearchResult[I]) > 2270 RightMargin - 32 do 2271 SearchResult[I] := Copy(SearchResult[I], 1, Length(SearchResult[I]) - 1) 2272 end; 2273 end; 2287 2274 2288 2275 end. -
TabularUnified branches/highdpi/LocalPlayer/IsoEngine.pas ¶
r405 r465 5 5 6 6 uses 7 UDpiControls, Protocol, ClientTools, ScreenTools, Tribes, 8 LCLIntf, LCLType, SysUtils, Classes, Graphics, UPixelPointer, UGraphicSet;7 UDpiControls, Protocol, ClientTools, ScreenTools, Tribes, LCLIntf, LCLType, SysUtils, 8 Classes, Graphics, PixelPointer, GraphicSet; 9 9 10 10 const … … 13 13 14 14 type 15 TInitEnemyModelEvent = function(emix: integer): boolean;15 TInitEnemyModelEvent = function(emix: Integer): Boolean; 16 16 TTileSize = (tsSmall, tsMedium, tsBig); 17 17 … … 33 33 Dirx: array [0..7] of Integer = (1, 2, 1, 0, -1, -2, -1, 0); 34 34 Diry: array [0..7] of Integer = (-1, 0, 1, 2, 1, 0, -1, -2); 35 procedure CityGrid(xm, ym: integer; CityAllowClick: Boolean);36 function IsShoreTile(Loc: integer): boolean;35 procedure CityGrid(xm, ym: Integer; CityAllowClick: Boolean); 36 function IsShoreTile(Loc: Integer): Boolean; 37 37 procedure MakeDark(Line: PPixelPointer; Length: Integer); 38 38 procedure SetTileSize(AValue: TTileSize); 39 procedure ShadeOutside(x0, y0, Width, Height, xm, ym: integer);39 procedure ShadeOutside(x0, y0, Width, Height, xm, ym: Integer); 40 40 protected 41 41 FOutput: TDpiBitmap; … … 65 65 ShowDebug: Boolean; 66 66 FoW: Boolean; 67 function Connection4(Loc, Mask, Value: integer): integer;68 function Connection8(Loc, Mask: integer): integer;69 function OceanConnection(Loc: integer): integer;70 procedure PaintShore( x, y, Loc: integer);71 procedure PaintTileExtraTerrain( x, y, Loc: integer);72 procedure PaintTileObjects( x, y, Loc, CityLoc, CityOwner: integer;73 UseBlink: boolean);74 procedure PaintGrid( x, y, nx, ny: integer);75 procedure FillRect( x, y, Width, Height, Color: integer);76 procedure Textout( x, y, Color: integer; const s: string);77 procedure Sprite(HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);78 procedure TSprite(xDst, yDst, grix: integer; PureBlack: boolean = false);67 function Connection4(Loc, Mask, Value: Integer): Integer; 68 function Connection8(Loc, Mask: Integer): Integer; 69 function OceanConnection(Loc: Integer): Integer; 70 procedure PaintShore(X, Y, Loc: Integer); 71 procedure PaintTileExtraTerrain(X, Y, Loc: Integer); 72 procedure PaintTileObjects(X, Y, Loc, CityLoc, CityOwner: Integer; 73 UseBlink: Boolean); 74 procedure PaintGrid(X, Y, nx, ny: Integer); 75 procedure FillRect(X, Y, Width, Height, Color: Integer); 76 procedure Textout(X, Y, Color: Integer; const S: string); 77 procedure Sprite(HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: Integer); 78 procedure TSprite(xDst, yDst, grix: Integer; PureBlack: Boolean = False); 79 79 procedure ApplyTileSize(ATileSize: TTileSize); 80 80 public … … 89 89 procedure Reset; 90 90 procedure SetOutput(Output: TDpiBitmap); 91 procedure SetPaintBounds(Left, Top, Right, Bottom: integer);92 procedure Paint( x, y, Loc, nx, ny, CityLoc, CityOwner: integer;93 UseBlink: boolean = false; CityAllowClick: boolean = false);94 procedure PaintUnit( x, y: integer; const UnitInfo: TUnitInfo;95 Status: integer);96 procedure PaintCity( x, y: integer; const CityInfo: TCityInfo;97 accessory: boolean = true);98 procedure BitBltBitmap(Src: TDpiBitmap; x, y, Width, Height, xSrc, ySrc,99 Rop: integer);91 procedure SetPaintBounds(Left, Top, Right, Bottom: Integer); 92 procedure Paint(X, Y, Loc, nx, ny, CityLoc, CityOwner: Integer; 93 UseBlink: Boolean = False; CityAllowClick: Boolean = False); 94 procedure PaintUnit(X, Y: Integer; const UnitInfo: TUnitInfo; 95 Status: Integer); 96 procedure PaintCity(X, Y: Integer; const CityInfo: TCityInfo; 97 accessory: Boolean = True); 98 procedure BitBltBitmap(Src: TDpiBitmap; X, Y, Width, Height, xSrc, ySrc, 99 Rop: Integer); 100 100 procedure AttackBegin(const ShowMove: TShowMove); 101 101 procedure AttackEffect(const ShowMove: TShowMove); 102 102 procedure AttackEnd; 103 103 procedure ReduceTerrainIconsSize; 104 property AdviceLoc: integer read FAdviceLoc write FAdviceLoc;104 property AdviceLoc: Integer read FAdviceLoc write FAdviceLoc; 105 105 property TileSize: TTileSize read FTileSize write SetTileSize; 106 106 end; … … 127 127 (X: 72; Y: 36)); 128 128 129 function IsJungle( y: integer): boolean;129 function IsJungle(Y: Integer): Boolean; 130 130 procedure Init(InitEnemyModelHandler: TInitEnemyModelEvent); 131 131 … … 173 173 IsoMapCache: array[TTileSize] of TIsoMapCache; 174 174 175 function IsJungle( y: integer): boolean;176 begin 177 result := (y > (G.ly - 2) div 4) and (G.ly - 1 - y> (G.ly - 2) div 4)175 function IsJungle(Y: Integer): Boolean; 176 begin 177 Result := (Y > (G.ly - 2) div 4) and (G.ly - 1 - Y > (G.ly - 2) div 4) 178 178 end; 179 179 … … 254 254 Mask24.BeginUpdate; 255 255 for ySrc := 0 to TerrainIconLines - 1 do begin 256 for i:= 0 to yyt * 3 - 1 do257 MaskLine[ i] := PixelPointer(Mask24, ScaleToNative(0),258 ScaleToNative(1 + ySrc * (yyt * 3 + 1) + i));256 for I := 0 to yyt * 3 - 1 do 257 MaskLine[I] := TPixelPointer.Create(Mask24, ScaleToNative(0), 258 ScaleToNative(1 + ySrc * (yyt * 3 + 1) + I)); 259 259 for xSrc := 0 to TerrainIconCols - 1 do begin 260 i:= ySrc * 9 + xSrc;261 TSpriteSize[ i].Left := 0;260 I := ySrc * 9 + xSrc; 261 TSpriteSize[I].Left := 0; 262 262 repeat 263 Border := true;264 for y:= 0 to yyt * 3 - 1 do begin265 MaskLine[ y].SetX(ScaleToNative(1 + xSrc * (xxt * 2 + 1) + TSpriteSize[i].Left));266 if MaskLine[ y].Pixel^.B = 0 then Border := false;263 Border := True; 264 for Y := 0 to yyt * 3 - 1 do begin 265 MaskLine[Y].SetX(ScaleToNative(1 + xSrc * (xxt * 2 + 1) + TSpriteSize[I].Left)); 266 if MaskLine[Y].Pixel^.B = 0 then Border := False; 267 267 end; 268 if Border then Inc(TSpriteSize[ i].Left);269 until not Border or (TSpriteSize[ i].Left = xxt * 2 - 1);270 TSpriteSize[ i].Top := 0;268 if Border then Inc(TSpriteSize[I].Left); 269 until not Border or (TSpriteSize[I].Left = xxt * 2 - 1); 270 TSpriteSize[I].Top := 0; 271 271 repeat 272 Border := true;273 for x:= 0 to xxt * 2 - 1 do begin274 MaskLine[TSpriteSize[ i].Top].SetX(ScaleToNative(1 + xSrc * (xxt * 2 + 1) + x));275 if MaskLine[TSpriteSize[ i].Top].Pixel^.B = 0 then Border := false;272 Border := True; 273 for X := 0 to xxt * 2 - 1 do begin 274 MaskLine[TSpriteSize[I].Top].SetX(ScaleToNative(1 + xSrc * (xxt * 2 + 1) + X)); 275 if MaskLine[TSpriteSize[I].Top].Pixel^.B = 0 then Border := False; 276 276 end; 277 if Border then inc(TSpriteSize[i].Top);278 until not Border or (TSpriteSize[ i].Top = yyt * 3 - 1);279 TSpriteSize[ i].Right := xxt * 2;277 if Border then Inc(TSpriteSize[I].Top); 278 until not Border or (TSpriteSize[I].Top = yyt * 3 - 1); 279 TSpriteSize[I].Right := xxt * 2; 280 280 repeat 281 Border := true;282 for y:= 0 to yyt * 3 - 1 do begin283 MaskLine[ y].SetX(ScaleToNative(xSrc * (xxt * 2 + 1) + TSpriteSize[i].Right));284 if MaskLine[ y].Pixel^.B = 0 then Border := false;281 Border := True; 282 for Y := 0 to yyt * 3 - 1 do begin 283 MaskLine[Y].SetX(ScaleToNative(xSrc * (xxt * 2 + 1) + TSpriteSize[I].Right)); 284 if MaskLine[Y].Pixel^.B = 0 then Border := False; 285 285 end; 286 if Border then Dec(TSpriteSize[ i].Right);287 until not Border or (TSpriteSize[ i].Right = TSpriteSize[i].Left);288 TSpriteSize[ i].Bottom := yyt * 3;286 if Border then Dec(TSpriteSize[I].Right); 287 until not Border or (TSpriteSize[I].Right = TSpriteSize[I].Left); 288 TSpriteSize[I].Bottom := yyt * 3; 289 289 repeat 290 Border := true;291 for x:= 0 to xxt * 2 - 1 do begin292 MaskLine[TSpriteSize[ i].Bottom - 1].SetX(ScaleToNative(1 + xSrc * (xxt * 2 + 1) + x));293 if MaskLine[TSpriteSize[ i].Bottom - 1].Pixel^.B = 0 then Border := false;290 Border := True; 291 for X := 0 to xxt * 2 - 1 do begin 292 MaskLine[TSpriteSize[I].Bottom - 1].SetX(ScaleToNative(1 + xSrc * (xxt * 2 + 1) + X)); 293 if MaskLine[TSpriteSize[I].Bottom - 1].Pixel^.B = 0 then Border := False; 294 294 end; 295 if Border then Dec(TSpriteSize[ i].Bottom);296 until not Border or (TSpriteSize[ i].Bottom = TSpriteSize[i].Top);295 if Border then Dec(TSpriteSize[I].Bottom); 296 until not Border or (TSpriteSize[I].Bottom = TSpriteSize[I].Top); 297 297 end; 298 298 end; … … 303 303 procedure TIsoMap.ApplyTileSize(ATileSize: TTileSize); 304 304 var 305 x: Integer;306 y: Integer;305 X: Integer; 306 Y: Integer; 307 307 xSrc: Integer; 308 308 ySrc: Integer; … … 357 357 DitherMask.SetSize(xxt * 2, yyt * 2); 358 358 DitherMask.Canvas.FillRect(0, 0, DitherMask.Width, DitherMask.Height); 359 DpiBit Canvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,359 DpiBitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2, 360 360 HGrTerrain.Mask.Canvas, 1 + 7 * (xxt * 2 + 1), 361 361 1 + yyt + 15 * (yyt * 3 + 1), SRCAND); 362 362 363 for x:= -1 to 6 do begin364 if x= -1 then begin363 for X := -1 to 6 do begin 364 if X = -1 then begin 365 365 xSrc := ShoreDither * (xxt * 2 + 1) + 1; 366 366 ySrc := 1 + yyt; 367 367 end 368 else if x= 6 then begin368 else if X = 6 then begin 369 369 xSrc := 1 + (xxt * 2 + 1) * 2; 370 370 ySrc := 1 + yyt + (yyt * 3 + 1) * 2; 371 371 end else begin 372 xSrc := ( x+ 2) * (xxt * 2 + 1) + 1;372 xSrc := (X + 2) * (xxt * 2 + 1) + 1; 373 373 ySrc := 1 + yyt; 374 374 end; 375 for y:= -1 to 6 do376 DpiBit Canvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y+ 2) * yyt,375 for Y := -1 to 6 do 376 DpiBitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2), (Y + 2) * yyt, 377 377 xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc); 378 for y:= -2 to 6 do379 DpiBit Canvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y+ 2) * yyt, xxt,378 for Y := -2 to 6 do 379 DpiBitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2), (Y + 2) * yyt, xxt, 380 380 yyt, HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt, 381 381 SRCPAINT); 382 for y:= -2 to 6 do383 DpiBit Canvas(LandPatch.Canvas, (x + 2) * (xxt * 2) + xxt, (y+ 2) * yyt,382 for Y := -2 to 6 do 383 DpiBitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2) + xxt, (Y + 2) * yyt, 384 384 xxt, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc + yyt, 385 385 SRCPAINT); 386 for y:= -2 to 6 do387 DpiBit Canvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y+ 2) * yyt, xxt,386 for Y := -2 to 6 do 387 DpiBitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2), (Y + 2) * yyt, xxt, 388 388 yyt, DitherMask.Canvas, xxt, yyt, SRCAND); 389 for y:= -2 to 6 do390 DpiBit Canvas(LandPatch.Canvas, (x + 2) * (xxt * 2) + xxt, (y+ 2) * yyt,389 for Y := -2 to 6 do 390 DpiBitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2) + xxt, (Y + 2) * yyt, 391 391 xxt, yyt, DitherMask.Canvas, 0, yyt, SRCAND); 392 392 end; 393 393 394 for y:= -1 to 6 do begin395 if y= -1 then begin394 for Y := -1 to 6 do begin 395 if Y = -1 then begin 396 396 xSrc := ShoreDither * (xxt * 2 + 1) + 1; 397 397 ySrc := 1 + yyt; 398 398 end 399 else if y= 6 then begin399 else if Y = 6 then begin 400 400 xSrc := 1 + 2 * (xxt * 2 + 1); 401 401 ySrc := 1 + yyt + 2 * (yyt * 3 + 1); 402 402 end else begin 403 xSrc := ( y+ 2) * (xxt * 2 + 1) + 1;403 xSrc := (Y + 2) * (xxt * 2 + 1) + 1; 404 404 ySrc := 1 + yyt; 405 405 end; 406 for x:= -2 to 6 do407 DpiBit Canvas(LandMore.Canvas, (x + 2) * (xxt * 2), (y+ 2) * yyt,406 for X := -2 to 6 do 407 DpiBitBltCanvas(LandMore.Canvas, (X + 2) * (xxt * 2), (Y + 2) * yyt, 408 408 xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc); 409 DpiBit Canvas(LandMore.Canvas, xxt * 2, (y+ 2) * yyt, xxt, yyt,409 DpiBitBltCanvas(LandMore.Canvas, xxt * 2, (Y + 2) * yyt, xxt, yyt, 410 410 HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt, SRCPAINT); 411 for x:= 0 to 7 do412 DpiBit Canvas(LandMore.Canvas, (x + 2) * (xxt * 2) - xxt, (y+ 2) * yyt,411 for X := 0 to 7 do 412 DpiBitBltCanvas(LandMore.Canvas, (X + 2) * (xxt * 2) - xxt, (Y + 2) * yyt, 413 413 xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc + yyt, 414 414 SRCPAINT); 415 for x:= -2 to 6 do416 DpiBit Canvas(LandMore.Canvas, (x + 2) * (xxt * 2), (y+ 2) * yyt,415 for X := -2 to 6 do 416 DpiBitBltCanvas(LandMore.Canvas, (X + 2) * (xxt * 2), (Y + 2) * yyt, 417 417 xxt * 2, yyt, DitherMask.Canvas, 0, 0, SRCAND); 418 418 end; 419 419 420 for x:= 0 to 3 do begin421 for y:= 0 to 3 do begin422 if ( x = 1) and (y= 1) then xSrc := 1420 for X := 0 to 3 do begin 421 for Y := 0 to 3 do begin 422 if (X = 1) and (Y = 1) then xSrc := 1 423 423 else 424 xSrc := ( xmod 2) * (xxt * 2 + 1) + 1;424 xSrc := (X mod 2) * (xxt * 2 + 1) + 1; 425 425 ySrc := 1 + yyt; 426 if ( x >= 1) = (y>= 2) then427 DpiBit Canvas(OceanPatch.Canvas, x * (xxt * 2), y* yyt, xxt * 2, yyt,426 if (X >= 1) = (Y >= 2) then 427 DpiBitBltCanvas(OceanPatch.Canvas, X * (xxt * 2), Y * yyt, xxt * 2, yyt, 428 428 HGrTerrain.Data.Canvas, xSrc, ySrc); 429 if ( x >= 1) and ((y < 2) or (x>= 2)) then429 if (X >= 1) and ((Y < 2) or (X >= 2)) then 430 430 begin 431 DpiBit Canvas(OceanPatch.Canvas, x * (xxt * 2), y* yyt, xxt, yyt,431 DpiBitBltCanvas(OceanPatch.Canvas, X * (xxt * 2), Y * yyt, xxt, yyt, 432 432 HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt, 433 433 SRCPAINT); 434 DpiBit Canvas(OceanPatch.Canvas, x * (xxt * 2) + xxt, y* yyt, xxt, yyt,434 DpiBitBltCanvas(OceanPatch.Canvas, X * (xxt * 2) + xxt, Y * yyt, xxt, yyt, 435 435 HGrTerrain.Data.Canvas, xSrc, ySrc + yyt, SRCPAINT); 436 436 end; 437 DpiBit Canvas(OceanPatch.Canvas, x * (xxt * 2), y* yyt, xxt, yyt,437 DpiBitBltCanvas(OceanPatch.Canvas, X * (xxt * 2), Y * yyt, xxt, yyt, 438 438 DitherMask.Canvas, xxt, yyt, SRCAND); 439 DpiBit Canvas(OceanPatch.Canvas, x * (xxt * 2) + xxt, y* yyt, xxt, yyt,439 DpiBitBltCanvas(OceanPatch.Canvas, X * (xxt * 2) + xxt, Y * yyt, xxt, yyt, 440 440 DitherMask.Canvas, 0, yyt, SRCAND); 441 441 end; 442 442 end; 443 443 444 for y:= 0 to 3 do begin445 for x:= 0 to 3 do begin446 if ( x = 1) and (y= 1) then xSrc := 1444 for Y := 0 to 3 do begin 445 for X := 0 to 3 do begin 446 if (X = 1) and (Y = 1) then xSrc := 1 447 447 else 448 xSrc := ( ymod 2) * (xxt * 2 + 1) + 1;448 xSrc := (Y mod 2) * (xxt * 2 + 1) + 1; 449 449 ySrc := 1 + yyt; 450 if ( x < 1) or (y>= 2) then451 DpiBit Canvas(OceanMore.Canvas, x * (xxt * 2), y* yyt, xxt * 2, yyt,450 if (X < 1) or (Y >= 2) then 451 DpiBitBltCanvas(OceanMore.Canvas, X * (xxt * 2), Y * yyt, xxt * 2, yyt, 452 452 HGrTerrain.Data.Canvas, xSrc, ySrc); 453 if ( x = 1) and (y < 2) or (x >= 2) and (y>= 1) then453 if (X = 1) and (Y < 2) or (X >= 2) and (Y >= 1) then 454 454 begin 455 DpiBit Canvas(OceanMore.Canvas, x * (xxt * 2), y* yyt, xxt, yyt,455 DpiBitBltCanvas(OceanMore.Canvas, X * (xxt * 2), Y * yyt, xxt, yyt, 456 456 HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt, 457 457 SRCPAINT); 458 DpiBit Canvas(OceanMore.Canvas, x * (xxt * 2) + xxt, y* yyt, xxt, yyt,458 DpiBitBltCanvas(OceanMore.Canvas, X * (xxt * 2) + xxt, Y * yyt, xxt, yyt, 459 459 HGrTerrain.Data.Canvas, xSrc, ySrc + yyt, SRCPAINT); 460 460 end; 461 DpiBit Canvas(OceanMore.Canvas, x * (xxt * 2), y* yyt, xxt * 2, yyt,461 DpiBitBltCanvas(OceanMore.Canvas, X * (xxt * 2), Y * yyt, xxt * 2, yyt, 462 462 DitherMask.Canvas, 0, 0, SRCAND); 463 463 end; 464 464 end; 465 465 466 DpiBit Canvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,466 DpiBitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2, 467 467 DitherMask.Canvas, 0, 0, DSTINVERT); { invert dither mask } 468 DpiBit Canvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,468 DpiBitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2, 469 469 HGrTerrain.Mask.Canvas, 1, 1 + yyt, SRCPAINT); 470 470 471 for x:= -1 to 6 do472 for y:= -2 to 6 do473 DpiBit Canvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y+ 2) * yyt,471 for X := -1 to 6 do 472 for Y := -2 to 6 do 473 DpiBitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2), (Y + 2) * yyt, 474 474 xxt * 2, yyt, DitherMask.Canvas, 0, 0, SRCAND); 475 475 476 for y:= -1 to 6 do477 for x:= -2 to 7 do478 DpiBit Canvas(LandMore.Canvas, (x + 2) * (xxt * 2) - xxt, (y+ 2) * yyt,476 for Y := -1 to 6 do 477 for X := -2 to 7 do 478 DpiBitBltCanvas(LandMore.Canvas, (X + 2) * (xxt * 2) - xxt, (Y + 2) * yyt, 479 479 xxt * 2, yyt, DitherMask.Canvas, 0, yyt, SRCAND); 480 480 481 DpiBit Canvas(LandPatch.Canvas, 0, 0, (xxt * 2) * 9, yyt * 9,481 DpiBitBltCanvas(LandPatch.Canvas, 0, 0, (xxt * 2) * 9, yyt * 9, 482 482 LandMore.Canvas, 0, 0, SRCPAINT); 483 483 484 for x:= 0 to 3 do485 for y:= 0 to 3 do486 DpiBit Canvas(OceanPatch.Canvas, x * (xxt * 2), y* yyt, xxt * 2, yyt,484 for X := 0 to 3 do 485 for Y := 0 to 3 do 486 DpiBitBltCanvas(OceanPatch.Canvas, X * (xxt * 2), Y * yyt, xxt * 2, yyt, 487 487 DitherMask.Canvas, 0, 0, SRCAND); 488 488 489 for y:= 0 to 3 do490 for x:= 0 to 4 do491 DpiBit Canvas(OceanMore.Canvas, x * (xxt * 2) - xxt, y* yyt, xxt * 2,489 for Y := 0 to 3 do 490 for X := 0 to 4 do 491 DpiBitBltCanvas(OceanMore.Canvas, X * (xxt * 2) - xxt, Y * yyt, xxt * 2, 492 492 yyt, DitherMask.Canvas, 0, yyt, SRCAND); 493 493 494 DpiBit Canvas(OceanPatch.Canvas, 0, 0, (xxt * 2) * 4, yyt * 4,494 DpiBitBltCanvas(OceanPatch.Canvas, 0, 0, (xxt * 2) * 4, yyt * 4, 495 495 OceanMore.Canvas, 0, 0, SRCPAINT); 496 496 … … 499 499 FillRect(Rect(0, 0, xxt * 2, yyt)); 500 500 end; 501 DpiBit Canvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt,501 DpiBitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt, 502 502 HGrTerrain.Mask.Canvas, 1, 1 + yyt); 503 503 504 for x:= 0 to 6 do505 DpiBit Canvas(LandPatch.Canvas, (x+ 2) * (xxt * 2), yyt, xxt * 2, yyt,504 for X := 0 to 6 do 505 DpiBitBltCanvas(LandPatch.Canvas, (X + 2) * (xxt * 2), yyt, xxt * 2, yyt, 506 506 DitherMask.Canvas, 0, 0, SRCAND); 507 DpiBit Canvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt, DitherMask.Canvas,507 DpiBitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt, DitherMask.Canvas, 508 508 0, 0, DSTINVERT); 509 509 510 for y:= 0 to 6 do511 DpiBit Canvas(LandPatch.Canvas, xxt * 2, (y+ 2) * yyt, xxt * 2, yyt,510 for Y := 0 to 6 do 511 DpiBitBltCanvas(LandPatch.Canvas, xxt * 2, (Y + 2) * yyt, xxt * 2, yyt, 512 512 DitherMask.Canvas, 0, 0, SRCAND); 513 513 … … 555 555 end; 556 556 557 procedure TIsoMap.SetPaintBounds(Left, Top, Right, Bottom: integer);557 procedure TIsoMap.SetPaintBounds(Left, Top, Right, Bottom: Integer); 558 558 begin 559 559 FLeft := Left; … … 563 563 end; 564 564 565 procedure TIsoMap.FillRect( x, y, Width, Height, Color: integer);566 begin 567 if x< FLeft then568 begin 569 Width := Width - (FLeft - x);570 x:= FLeft;571 end; 572 if y< FTop then573 begin 574 Height := Height - (FTop - y);575 y:= FTop;576 end; 577 if x+ Width >= FRight then578 Width := FRight - x;579 if y+ Height >= FBottom then580 Height := FBottom - y;565 procedure TIsoMap.FillRect(X, Y, Width, Height, Color: Integer); 566 begin 567 if X < FLeft then 568 begin 569 Width := Width - (FLeft - X); 570 X := FLeft; 571 end; 572 if Y < FTop then 573 begin 574 Height := Height - (FTop - Y); 575 Y := FTop; 576 end; 577 if X + Width >= FRight then 578 Width := FRight - X; 579 if Y + Height >= FBottom then 580 Height := FBottom - Y; 581 581 if (Width <= 0) or (Height <= 0) then 582 exit;582 Exit; 583 583 584 584 FOutput.Canvas.Brush.Color := Color; 585 FOutput.Canvas.FillRect(Rect( x, y, x + Width, y+ Height));585 FOutput.Canvas.FillRect(Rect(X, Y, X + Width, Y + Height)); 586 586 FOutput.Canvas.Brush.Style := bsClear; 587 587 end; 588 588 589 procedure TIsoMap.Textout( x, y, Color: integer; const s: string);589 procedure TIsoMap.Textout(X, Y, Color: Integer; const S: string); 590 590 begin 591 591 FOutput.Canvas.Font.Color := Color; 592 FOutput.Canvas.TextRect(Rect(FLeft, FTop, FRight, FBottom), x, y, s)593 end; 594 595 procedure TIsoMap.BitBltBitmap(Src: TDpiBitmap; x, y, Width, Height, xSrc, ySrc,596 Rop: integer);597 begin 598 if x< FLeft then599 begin 600 Width := Width - (FLeft - x);601 xSrc := xSrc + (FLeft - x);602 x:= FLeft;603 end; 604 if y< FTop then605 begin 606 Height := Height - (FTop - y);607 ySrc := ySrc + (FTop - y);608 y:= FTop;609 end; 610 if x+ Width >= FRight then611 Width := FRight - x;612 if y+ Height >= FBottom then613 Height := FBottom - y;592 FOutput.Canvas.TextRect(Rect(FLeft, FTop, FRight, FBottom), X, Y, S) 593 end; 594 595 procedure TIsoMap.BitBltBitmap(Src: TDpiBitmap; X, Y, Width, Height, xSrc, ySrc, 596 Rop: Integer); 597 begin 598 if X < FLeft then 599 begin 600 Width := Width - (FLeft - X); 601 xSrc := xSrc + (FLeft - X); 602 X := FLeft; 603 end; 604 if Y < FTop then 605 begin 606 Height := Height - (FTop - Y); 607 ySrc := ySrc + (FTop - Y); 608 Y := FTop; 609 end; 610 if X + Width >= FRight then 611 Width := FRight - X; 612 if Y + Height >= FBottom then 613 Height := FBottom - Y; 614 614 if (Width <= 0) or (Height <= 0) then 615 exit;616 617 DpiBit Canvas(FOutput.Canvas, x, y, Width, Height, Src.Canvas, xSrc, ySrc, Rop);618 end; 619 620 procedure TIsoMap.Sprite(HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);615 Exit; 616 617 DpiBitBltCanvas(FOutput.Canvas, X, Y, Width, Height, Src.Canvas, xSrc, ySrc, Rop); 618 end; 619 620 procedure TIsoMap.Sprite(HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: Integer); 621 621 begin 622 622 BitBltBitmap(HGr.Mask, xDst, yDst, Width, Height, xGr, yGr, SRCAND); … … 624 624 end; 625 625 626 procedure TIsoMap.TSprite(xDst, yDst, grix: integer;627 PureBlack: boolean = false);626 procedure TIsoMap.TSprite(xDst, yDst, grix: Integer; 627 PureBlack: Boolean = False); 628 628 var 629 629 Width: Integer; 630 630 Height: Integer; 631 631 xSrc: Integer; 632 ySrc: integer;632 ySrc: Integer; 633 633 begin 634 634 Width := TSpriteSize[grix].Right - TSpriteSize[grix].Left; … … 653 653 Height := FBottom - yDst; 654 654 if (Width <= 0) or (Height <= 0) then 655 exit;656 657 DpiBit Canvas(FOutput.Canvas, xDst, yDst, Width, Height, MaskCanvas, xSrc, ySrc, SRCAND);655 Exit; 656 657 DpiBitBltCanvas(FOutput.Canvas, xDst, yDst, Width, Height, MaskCanvas, xSrc, ySrc, SRCAND); 658 658 if not PureBlack then 659 DpiBit Canvas(FOutput.Canvas, xDst, yDst, Width, Height, DataCanvas, xSrc, ySrc, SRCPAINT);660 end; 661 662 procedure TIsoMap.PaintUnit( x, y: integer; const UnitInfo: TUnitInfo;663 Status: integer);664 var 665 xsh, ysh, xGr, yGr, j, mixShow: integer;659 DpiBitBltCanvas(FOutput.Canvas, xDst, yDst, Width, Height, DataCanvas, xSrc, ySrc, SRCPAINT); 660 end; 661 662 procedure TIsoMap.PaintUnit(X, Y: Integer; const UnitInfo: TUnitInfo; 663 Status: Integer); 664 var 665 xsh, ysh, xGr, yGr, J, mixShow: Integer; 666 666 begin 667 667 with UnitInfo do 668 if (Owner = me) or (emix <> $FFFF) then668 if (Owner = Me) or (emix <> $FFFF) then 669 669 begin 670 670 if Job = jCity then … … 675 675 (@OnInitEnemyModel <> nil) then 676 676 if not OnInitEnemyModel(emix) then 677 exit;677 Exit; 678 678 xsh := Tribe[Owner].ModelPicture[mixShow].xShield; 679 679 ysh := Tribe[Owner].ModelPicture[mixShow].yShield; 680 680 {$IFNDEF SCR} if Status and usStay <> 0 then 681 j:= 19681 J := 19 682 682 else if Status and usRecover <> 0 then 683 j:= 16683 J := 16 684 684 else if Status and (usGoto or usEnhance) = usGoto or usEnhance then 685 j:= 18685 J := 18 686 686 else if Status and usEnhance <> 0 then 687 j:= 17687 J := 17 688 688 else if Status and usGoto <> 0 then 689 j:= 20689 J := 20 690 690 else {$ENDIF} if Job = jCity then 691 j:= jNone691 J := jNone 692 692 else 693 j:= Job;693 J := Job; 694 694 if Flags and unMulti <> 0 then 695 Sprite(Tribe[Owner].symHGr, x + xsh - 1 + 4, y+ ysh - 2, 14, 12,695 Sprite(Tribe[Owner].symHGr, X + xsh - 1 + 4, Y + ysh - 2, 14, 12, 696 696 33 + Tribe[Owner].sympix mod 10 * 65, 697 697 1 + Tribe[Owner].sympix div 10 * 49); 698 Sprite(Tribe[Owner].symHGr, x + xsh - 1, y+ ysh - 2, 14, 12,698 Sprite(Tribe[Owner].symHGr, X + xsh - 1, Y + ysh - 2, 14, 12, 699 699 18 + Tribe[Owner].sympix mod 10 * 65, 700 700 1 + Tribe[Owner].sympix div 10 * 49); 701 FillRect( x + xsh, y+ ysh + 5, 1 + Health * 11 div 100, 3,701 FillRect(X + xsh, Y + ysh + 5, 1 + Health * 11 div 100, 3, 702 702 ColorOfHealth(Health)); 703 if j> 0 then703 if J > 0 then 704 704 begin 705 xGr := 121 + jmod 7 * 9;706 yGr := 1 + jdiv 7 * 9;707 BitBltBitmap(HGrSystem.Mask, x + xsh + 3, y+ ysh + 9, 8, 8, xGr,705 xGr := 121 + J mod 7 * 9; 706 yGr := 1 + J div 7 * 9; 707 BitBltBitmap(HGrSystem.Mask, X + xsh + 3, Y + ysh + 9, 8, 8, xGr, 708 708 yGr, SRCAND); 709 Sprite(HGrSystem, x + xsh + 2, y+ ysh + 8, 8, 8, xGr, yGr);709 Sprite(HGrSystem, X + xsh + 2, Y + ysh + 8, 8, 8, xGr, yGr); 710 710 end; 711 711 with Tribe[Owner].ModelPicture[mixShow] do 712 Sprite(HGr, x, y, 64, 48, pix mod 10 * 65 + 1, pix div 10 * 49 + 1);712 Sprite(HGr, X, Y, 64, 48, pix mod 10 * 65 + 1, pix div 10 * 49 + 1); 713 713 if Flags and unFortified <> 0 then 714 714 begin 715 715 { DataCanvas:=HGrTerrain.Data.Canvas; 716 716 MaskCanvas:=HGrTerrain.Mask.Canvas; 717 TSprite( x,y+16,12*9+7); }718 Sprite(HGrStdUnits, x, y, xxu * 2, yyu * 2, 1 + 6 * (xxu * 2 + 1), 1);717 TSprite(X,Y+16,12*9+7); } 718 Sprite(HGrStdUnits, X, Y, xxu * 2, yyu * 2, 1 + 6 * (xxu * 2 + 1), 1); 719 719 end; 720 720 end; 721 end; { PaintUnit }722 723 procedure TIsoMap.PaintCity( x, y: integer; const CityInfo: TCityInfo;724 accessory: boolean);721 end; 722 723 procedure TIsoMap.PaintCity(X, Y: Integer; const CityInfo: TCityInfo; 724 accessory: Boolean); 725 725 var 726 726 age: Integer; … … 733 733 LabelLength: Integer; 734 734 cpic: TCityPicture; 735 s: string;735 S: string; 736 736 begin 737 737 age := GetAge(CityInfo.Owner); … … 752 752 (cHGr.Data.Canvas.Pixels[(xGr + 4) * 65, cpix * 49 + 48] = $00FFFF) 753 753 then 754 Sprite(cHGr, x - xxc, y- 2 * yyc, xxc * 2, yyc * 3,754 Sprite(cHGr, X - xxc, Y - 2 * yyc, xxc * 2, yyc * 3, 755 755 xGr * (xxc * 2 + 1) + 1, 1 + cpix * (yyc * 3 + 1)); 756 756 if ciWalled and CityInfo.Flags <> 0 then 757 Sprite(cHGr, x - xxc, y- 2 * yyc, xxc * 2, yyc * 3,757 Sprite(cHGr, X - xxc, Y - 2 * yyc, xxc * 2, yyc * 3, 758 758 (xGr + 4) * (xxc * 2 + 1) + 1, 1 + cpix * (yyc * 3 + 1)); 759 759 end … … 761 761 begin 762 762 if ciWalled and CityInfo.Flags <> 0 then 763 Sprite(HGrCities, x - xxt, y- 2 * yyt, 2 * xxt, 3 * yyt,763 Sprite(HGrCities, X - xxt, Y - 2 * yyt, 2 * xxt, 3 * yyt, 764 764 (xGr + 4) * (2 * xxt + 1) + 1, 1 + (age - 2) * (3 * yyt + 1)) 765 765 else 766 Sprite(HGrCities, x - xxt, y- 2 * yyt, 2 * xxt, 3 * yyt,766 Sprite(HGrCities, X - xxt, Y - 2 * yyt, 2 * xxt, 3 * yyt, 767 767 xGr * (2 * xxt + 1) + 1, 1 + (age - 2) * (3 * yyt + 1)); 768 768 end; 769 769 770 770 if not accessory then 771 exit;771 Exit; 772 772 773 773 { if ciCapital and CityInfo.Flags<>0 then 774 Sprite(Tribe[CityInfo.Owner].symHGr, x+cpic.xf,y-13+cpic.yf,13,14,774 Sprite(Tribe[CityInfo.Owner].symHGr,X+cpic.xf,Y-13+cpic.yf,13,14, 775 775 1+Tribe[CityInfo.Owner].sympix mod 10 *65, 776 776 1+Tribe[CityInfo.Owner].sympix div 10 *49); {capital -- paint flag } … … 781 781 begin 782 782 cpic := Tribe[CityInfo.Owner].CityPicture[xGr]; 783 xShield := x- xxc + cpic.xShield;784 yShield := y- 2 * yyc + cpic.yShield;783 xShield := X - xxc + cpic.xShield; 784 yShield := Y - 2 * yyc + cpic.yShield; 785 785 end 786 786 else 787 787 begin 788 788 cpic := CitiesPictures.Pictures[age, xGr]; 789 xShield := x- xxt + cpic.xShield;790 yShield := y- 2 * yyt + cpic.yShield;789 xShield := X - xxt + cpic.xShield; 790 yShield := Y - 2 * yyt + cpic.yShield; 791 791 end; 792 s:= IntToStr(CityInfo.size);793 LabelLength := FOutput.Canvas.TextWidth( s);792 S := IntToStr(CityInfo.size); 793 LabelLength := FOutput.Canvas.TextWidth(S); 794 794 FillRect(xShield, yShield, LabelLength + 4, 16, $000000); 795 795 if MyMap[CityInfo.Loc] and (fUnit or fObserved) = fObserved then … … 802 802 LabelTextColor := $000000; 803 803 end; 804 Textout(xShield + 2, yShield - 1, LabelTextColor, s);805 end; 806 end; { PaintCity }807 808 function PoleTile(Loc: integer): integer;804 Textout(xShield + 2, yShield - 1, LabelTextColor, S); 805 end; 806 end; 807 808 function PoleTile(Loc: Integer): Integer; 809 809 begin { virtual pole tile } 810 result := fUNKNOWN;810 Result := fUNKNOWN; 811 811 if Loc < -2 * G.lx then 812 812 else if Loc < -G.lx then … … 815 815 (MyMap[dLoc(Loc, -2, 2)] and fTerrain <> fUNKNOWN) and 816 816 (MyMap[dLoc(Loc, 2, 2)] and fTerrain <> fUNKNOWN) then 817 result := fArctic;817 Result := fArctic; 818 818 if (MyMap[dLoc(Loc, 0, 2)] and fObserved <> 0) and 819 819 (MyMap[dLoc(Loc, -2, 2)] and fObserved <> 0) and 820 820 (MyMap[dLoc(Loc, 2, 2)] and fObserved <> 0) then 821 result := result or fObserved;821 Result := Result or fObserved; 822 822 end 823 823 else if Loc < 0 then … … 825 825 if (MyMap[dLoc(Loc, -1, 1)] and fTerrain <> fUNKNOWN) and 826 826 (MyMap[dLoc(Loc, 1, 1)] and fTerrain <> fUNKNOWN) then 827 result := fArctic;827 Result := fArctic; 828 828 if (MyMap[dLoc(Loc, -1, 1)] and fObserved <> 0) and 829 829 (MyMap[dLoc(Loc, 1, 1)] and fObserved <> 0) then 830 result := result or fObserved;830 Result := Result or fObserved; 831 831 end 832 832 else if Loc < G.lx * (G.ly + 1) then … … 834 834 if (MyMap[dLoc(Loc, -1, -1)] and fTerrain <> fUNKNOWN) and 835 835 (MyMap[dLoc(Loc, 1, -1)] and fTerrain <> fUNKNOWN) then 836 result := fArctic;836 Result := fArctic; 837 837 if (MyMap[dLoc(Loc, -1, -1)] and fObserved <> 0) and 838 838 (MyMap[dLoc(Loc, 1, -1)] and fObserved <> 0) then 839 result := result or fObserved;839 Result := Result or fObserved; 840 840 end 841 841 else if Loc < G.lx * (G.ly + 2) then … … 844 844 (MyMap[dLoc(Loc, -2, -2)] and fTerrain <> fUNKNOWN) and 845 845 (MyMap[dLoc(Loc, 2, -2)] and fTerrain <> fUNKNOWN) then 846 result := fArctic;846 Result := fArctic; 847 847 if (MyMap[dLoc(Loc, 0, -2)] and fObserved <> 0) and 848 848 (MyMap[dLoc(Loc, -2, -2)] and fObserved <> 0) and 849 849 (MyMap[dLoc(Loc, 2, -2)] and fObserved <> 0) then 850 result := result or fObserved;851 end; 852 end; 853 854 function TIsoMap.Connection4(Loc, Mask, Value: integer): integer;855 begin 856 result := 0;850 Result := Result or fObserved; 851 end; 852 end; 853 854 function TIsoMap.Connection4(Loc, Mask, Value: Integer): Integer; 855 begin 856 Result := 0; 857 857 if dLoc(Loc, 1, -1) >= 0 then 858 858 begin 859 859 if MyMap[dLoc(Loc, 1, -1)] and Mask = Cardinal(Value) then 860 inc(result, 1);860 Inc(Result, 1); 861 861 if MyMap[dLoc(Loc, -1, -1)] and Mask = Cardinal(Value) then 862 inc(result, 8);862 Inc(Result, 8); 863 863 end; 864 864 if dLoc(Loc, 1, 1) < G.lx * G.ly then 865 865 begin 866 866 if MyMap[dLoc(Loc, 1, 1)] and Mask = Cardinal(Value) then 867 inc(result, 2);867 Inc(Result, 2); 868 868 if MyMap[dLoc(Loc, -1, 1)] and Mask = Cardinal(Value) then 869 inc(result, 4);870 end; 871 end; 872 873 function TIsoMap.Connection8(Loc, Mask: integer): integer;869 Inc(Result, 4); 870 end; 871 end; 872 873 function TIsoMap.Connection8(Loc, Mask: Integer): Integer; 874 874 var 875 875 Dir: Integer; 876 876 ConnLoc: Integer; 877 877 begin 878 result := 0;878 Result := 0; 879 879 for Dir := 0 to 7 do 880 880 begin … … 882 882 if (ConnLoc >= 0) and (ConnLoc < G.lx * G.ly) and 883 883 (MyMap[ConnLoc] and Mask <> 0) then 884 inc(result, 1 shl Dir);885 end; 886 end; 887 888 function TIsoMap.OceanConnection(Loc: integer): integer;884 Inc(Result, 1 shl Dir); 885 end; 886 end; 887 888 function TIsoMap.OceanConnection(Loc: Integer): Integer; 889 889 var 890 890 Dir: Integer; 891 891 ConnLoc: Integer; 892 892 begin 893 result := 0;893 Result := 0; 894 894 for Dir := 0 to 7 do 895 895 begin … … 897 897 if (ConnLoc < 0) or (ConnLoc >= G.lx * G.ly) or 898 898 ((MyMap[ConnLoc] - 2) and fTerrain < 13) then 899 inc(result, 1 shl Dir);900 end; 901 end; 902 903 procedure TIsoMap.PaintShore( x, y, Loc: integer);899 Inc(Result, 1 shl Dir); 900 end; 901 end; 902 903 procedure TIsoMap.PaintShore(X, Y, Loc: Integer); 904 904 var 905 905 Conn: Integer; 906 906 Tile: Integer; 907 907 begin 908 if ( y <= FTop - yyt * 2) or (y > FBottom) or (x<= FLeft - xxt * 2) or909 ( x> FRight) then910 exit;908 if (Y <= FTop - yyt * 2) or (Y > FBottom) or (X <= FLeft - xxt * 2) or 909 (X > FRight) then 910 Exit; 911 911 if (Loc < 0) or (Loc >= G.lx * G.ly) then 912 exit;912 Exit; 913 913 Tile := MyMap[Loc]; 914 914 if Tile and fTerrain >= fGrass then 915 exit;915 Exit; 916 916 Conn := OceanConnection(Loc); 917 917 if Conn = 0 then 918 exit;919 920 BitBltBitmap(HGrTerrain.Data, x + xxt div 2, y, xxt, yyt,918 Exit; 919 920 BitBltBitmap(HGrTerrain.Data, X + xxt div 2, Y, xxt, yyt, 921 921 1 + (Conn shr 6 + Conn and 1 shl 2) * (xxt * 2 + 1), 922 922 1 + yyt + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT); 923 BitBltBitmap(HGrTerrain.Data, x + xxt, y+ yyt div 2, xxt, yyt,923 BitBltBitmap(HGrTerrain.Data, X + xxt, Y + yyt div 2, xxt, yyt, 924 924 1 + (Conn and 7) * (xxt * 2 + 1) + xxt, 925 925 1 + yyt * 2 + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT); 926 BitBltBitmap(HGrTerrain.Data, x + xxt div 2, y+ yyt, xxt, yyt,926 BitBltBitmap(HGrTerrain.Data, X + xxt div 2, Y + yyt, xxt, yyt, 927 927 1 + (Conn shr 2 and 7) * (xxt * 2 + 1) + xxt, 928 928 1 + yyt + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT); 929 BitBltBitmap(HGrTerrain.Data, x, y+ yyt div 2, xxt, yyt,929 BitBltBitmap(HGrTerrain.Data, X, Y + yyt div 2, xxt, yyt, 930 930 1 + (Conn shr 4 and 7) * (xxt * 2 + 1), 931 931 1 + yyt * 2 + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT); 932 932 Conn := Connection4(Loc, fTerrain, fUNKNOWN); { dither to black } 933 933 if Conn and 1 <> 0 then 934 BitBltBitmap(HGrTerrain.Mask, x + xxt, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1) +934 BitBltBitmap(HGrTerrain.Mask, X + xxt, Y, xxt, yyt, 1 + 7 * (xxt * 2 + 1) + 935 935 xxt, 1 + yyt + 15 * (yyt * 3 + 1), SRCAND); 936 936 if Conn and 2 <> 0 then 937 BitBltBitmap(HGrTerrain.Mask, x + xxt, y+ yyt, xxt, yyt,937 BitBltBitmap(HGrTerrain.Mask, X + xxt, Y + yyt, xxt, yyt, 938 938 1 + 7 * (xxt * 2 + 1) + xxt, 1 + yyt * 2 + 15 * (yyt * 3 + 1), SRCAND); 939 939 if Conn and 4 <> 0 then 940 BitBltBitmap(HGrTerrain.Mask, x, y+ yyt, xxt, yyt, 1 + 7 * (xxt * 2 + 1),940 BitBltBitmap(HGrTerrain.Mask, X, Y + yyt, xxt, yyt, 1 + 7 * (xxt * 2 + 1), 941 941 1 + yyt * 2 + 15 * (yyt * 3 + 1), SRCAND); 942 942 if Conn and 8 <> 0 then 943 BitBltBitmap(HGrTerrain.Mask, x, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1),943 BitBltBitmap(HGrTerrain.Mask, X, Y, xxt, yyt, 1 + 7 * (xxt * 2 + 1), 944 944 1 + yyt + 15 * (yyt * 3 + 1), SRCAND); 945 945 end; 946 946 947 procedure TIsoMap.PaintTileExtraTerrain( x, y, Loc: integer);948 var 949 Dir, Conn, RRConn, yGr, Tile, yLoc: integer;950 begin 951 if (Loc < 0) or (Loc >= G.lx * G.ly) or ( y<= -yyt * 2) or952 ( y > FOutput.Height) or (x <= -xxt * 2) or (x> FOutput.Width) then953 exit;947 procedure TIsoMap.PaintTileExtraTerrain(X, Y, Loc: Integer); 948 var 949 Dir, Conn, RRConn, yGr, Tile, yLoc: Integer; 950 begin 951 if (Loc < 0) or (Loc >= G.lx * G.ly) or (Y <= -yyt * 2) or 952 (Y > FOutput.Height) or (X <= -xxt * 2) or (X > FOutput.Width) then 953 Exit; 954 954 Tile := MyMap[Loc]; 955 955 if Tile and fTerrain = fForest then … … 966 966 then 967 967 Conn := Conn and not 9; // no connection to north 968 TSprite( x, y, yGr + Conn mod 8 + (Conn div 8) * TerrainIconCols);968 TSprite(X, Y, yGr + Conn mod 8 + (Conn div 8) * TerrainIconCols); 969 969 end 970 970 else if Tile and fTerrain in [fHills, fMountains, fForest] then … … 972 972 yGr := 3 + 2 * (Tile and fTerrain - fForest); 973 973 Conn := Connection4(Loc, fTerrain, Tile and fTerrain); 974 TSprite( x, y, Conn mod 8 + (yGr + Conn div 8) * TerrainIconCols);974 TSprite(X, Y, Conn mod 8 + (yGr + Conn div 8) * TerrainIconCols); 975 975 end 976 976 else if Tile and fDeadLands <> 0 then 977 TSprite( x, y, spRow2);977 TSprite(X, Y, spRow2); 978 978 979 979 if ShowObjects then 980 980 begin 981 981 if Tile and fTerImp = tiFarm then 982 TSprite( x, y, spFarmLand)982 TSprite(X, Y, spFarmLand) 983 983 else if Tile and fTerImp = tiIrrigation then 984 TSprite( x, y, spIrrigation);984 TSprite(X, Y, spIrrigation); 985 985 end; 986 986 if Tile and fRiver <> 0 then … … 989 989 Connection4(Loc, fTerrain, fShore) or Connection4(Loc, fTerrain, 990 990 fUNKNOWN); 991 TSprite( x, y, spRiver + Conn mod 8 + (Conn div 8) * TerrainIconCols);991 TSprite(X, Y, spRiver + Conn mod 8 + (Conn div 8) * TerrainIconCols); 992 992 end; 993 993 … … 997 997 for Dir := 0 to 3 do 998 998 if Conn and (1 shl Dir) <> 0 then { river mouths } 999 TSprite( x, y, spRiverMouths + Dir);999 TSprite(X, Y, spRiverMouths + Dir); 1000 1000 if ShowObjects then 1001 1001 begin … … 1003 1003 for Dir := 0 to 7 do 1004 1004 if Conn and (1 shl Dir) <> 0 then { canal mouths } 1005 TSprite( x, y, spCanalMouths + 1 + Dir);1005 TSprite(X, Y, spCanalMouths + 1 + Dir); 1006 1006 end; 1007 1007 end; … … 1015 1015 if Conn = 0 then begin 1016 1016 if Tile and fCanal <> 0 then 1017 TSprite( x, y, spCanal);1017 TSprite(X, Y, spCanal); 1018 1018 end 1019 1019 else 1020 1020 for Dir := 0 to 7 do 1021 1021 if (1 shl Dir) and Conn <> 0 then 1022 TSprite( x, y, spCanal + 1 + Dir);1022 TSprite(X, Y, spCanal + 1 + Dir); 1023 1023 end; 1024 1024 … … 1032 1032 Conn := Connection8(Loc, fRoad or fRR or fCity) and not RRConn; 1033 1033 if (Conn = 0) and (Tile and (fRR or fCity) = 0) then 1034 TSprite( x, y, spRoad)1034 TSprite(X, Y, spRoad) 1035 1035 else if Conn > 0 then 1036 1036 for Dir := 0 to 7 do 1037 1037 if (1 shl Dir) and Conn <> 0 then 1038 TSprite( x, y, spRoad + 1 + Dir);1038 TSprite(X, Y, spRoad + 1 + Dir); 1039 1039 end; 1040 1040 1041 1041 // Paint railroad connections 1042 1042 if (Tile and fRR <> 0) and (RRConn = 0) then 1043 TSprite( x, y, spRailRoad)1043 TSprite(X, Y, spRailRoad) 1044 1044 else if RRConn > 0 then begin 1045 1045 for Dir := 0 to 7 do 1046 1046 if (1 shl Dir) and RRConn <> 0 then 1047 TSprite( x, y, spRailRoad + 1 + Dir);1047 TSprite(X, Y, spRailRoad + 1 + Dir); 1048 1048 end; 1049 1049 end; … … 1051 1051 1052 1052 // (x,y) is top left pixel of (2*xxt,3*yyt) rectangle 1053 procedure TIsoMap.PaintTileObjects( x, y, Loc, CityLoc, CityOwner: integer;1054 UseBlink: boolean);1055 var 1056 p1, p2, uix, cix, dy, Loc1, Tile, Multi, Destination: integer;1053 procedure TIsoMap.PaintTileObjects(X, Y, Loc, CityLoc, CityOwner: Integer; 1054 UseBlink: Boolean); 1055 var 1056 p1, p2, uix, cix, dy, Loc1, Tile, Multi, Destination: Integer; 1057 1057 CityInfo: TCityInfo; 1058 1058 UnitInfo: TUnitInfo; 1059 fog: boolean;1059 fog: Boolean; 1060 1060 SpecialRow: Integer; 1061 1061 SpecialCol: Integer; … … 1063 1063 procedure NameCity; 1064 1064 var 1065 cix, xs, w: integer;1065 cix, xs, W: Integer; 1066 1066 BehindCityInfo: TCityInfo; 1067 s: string;1068 IsCapital: boolean;1067 S: string; 1068 IsCapital: Boolean; 1069 1069 begin 1070 1070 BehindCityInfo.Loc := Loc - 2 * G.lx; … … 1076 1076 IsCapital := BehindCityInfo.Flags and ciCapital <> 0; 1077 1077 { if Showuix and (cix>=0) then s:=IntToStr(cix) 1078 else } s:= CityName(BehindCityInfo.ID);1079 w := FOutput.Canvas.TextWidth(s);1080 xs := x + xxt - (w+ 1) div 2;1078 else } S := CityName(BehindCityInfo.ID); 1079 W := FOutput.Canvas.TextWidth(S); 1080 xs := X + xxt - (W + 1) div 2; 1081 1081 if IsCapital then 1082 1082 FOutput.Canvas.Font.Style := FOutput.Canvas.Font.Style + [fsUnderline]; 1083 Textout(xs + 1, y - 9, $000000, s);1084 Textout(xs, y - 10, $FFFFFF, s);1083 Textout(xs + 1, Y - 9, $000000, S); 1084 Textout(xs, Y - 10, $FFFFFF, S); 1085 1085 if IsCapital then 1086 1086 FOutput.Canvas.Font.Style := FOutput.Canvas.Font.Style - [fsUnderline]; … … 1092 1092 if ShowObjects and not (moEditMode in MapOptions) and 1093 1093 (Tile and fCity <> 0) and (CityInfo.Flags and ciSpacePort <> 0) then 1094 TSprite( x + xxt, y- 6, spSpacePort);1094 TSprite(X + xxt, Y - 6, spSpacePort); 1095 1095 end; 1096 1096 1097 1097 procedure PaintBorder; 1098 1098 var 1099 dx, dy: integer;1099 dx, dy: Integer; 1100 1100 begin 1101 1101 if ShowBorder and (Loc >= 0) and (Loc < G.lx * G.ly) and 1102 1102 (Tile and fTerrain <> fUNKNOWN) then begin 1103 1103 p1 := MyRO.Territory[Loc]; 1104 if (p1 >= 0) and (ShowMyBorder or (p1 <> me)) then begin1104 if (p1 >= 0) and (ShowMyBorder or (p1 <> Me)) then begin 1105 1105 if BordersOK^ and (1 shl p1) = 0 then begin 1106 1106 UnshareBitmap(Borders); 1107 DpiBit Canvas(Borders.Canvas, 0, p1 * (yyt * 2), xxt * 2,1107 DpiBitBltCanvas(Borders.Canvas, 0, p1 * (yyt * 2), xxt * 2, 1108 1108 yyt * 2, HGrTerrain.Data.Canvas, 1109 1109 1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1)); … … 1123 1123 if p2 <> p1 then 1124 1124 begin 1125 BitBltBitmap(HGrTerrain.Mask, x + dx * xxt, y+ dy * yyt, xxt,1125 BitBltBitmap(HGrTerrain.Mask, X + dx * xxt, Y + dy * yyt, xxt, 1126 1126 yyt, 1 + 8 * (xxt * 2 + 1) + dx * xxt, 1127 1127 1 + yyt + 16 * (yyt * 3 + 1) + dy * yyt, SRCAND); 1128 BitBltBitmap(Borders, x + dx * xxt, y+ dy * yyt, xxt, yyt, dx * xxt,1128 BitBltBitmap(Borders, X + dx * xxt, Y + dy * yyt, xxt, yyt, dx * xxt, 1129 1129 p1 * (yyt * 2) + dy * yyt, SRCPAINT); 1130 1130 end; … … 1143 1143 (Tile and fCity <> 0) then 1144 1144 GetCityInfo(Loc, cix, CityInfo); 1145 if ( y <= FTop - yyt * 2) or (y > FBottom) or (x<= FLeft - xxt * 2) or1146 ( x> FRight) then1145 if (Y <= FTop - yyt * 2) or (Y > FBottom) or (X <= FLeft - xxt * 2) or 1146 (X > FRight) then 1147 1147 begin 1148 1148 NameCity; 1149 1149 ShowSpacePort; 1150 exit;1150 Exit; 1151 1151 end; 1152 1152 if Tile and fTerrain = fUNKNOWN then … … 1154 1154 NameCity; 1155 1155 ShowSpacePort; 1156 exit;1156 Exit; 1157 1157 end; { square not discovered } 1158 1158 … … 1161 1161 1162 1162 if (Loc >= 0) and (Loc < G.lx * G.ly) and (Loc = FAdviceLoc) then 1163 TSprite( x, y, spPlain);1163 TSprite(X, Y, spPlain); 1164 1164 1165 1165 if (Loc >= 0) and (Loc < G.lx * G.ly) and (Tile and fSpecial <> 0) … … 1170 1170 SpecialRow := Tile and fSpecial shr 5; 1171 1171 if SpecialCol < fForest then 1172 TSprite( x, y, SpecialCol + SpecialRow * TerrainIconCols)1172 TSprite(X, Y, SpecialCol + SpecialRow * TerrainIconCols) 1173 1173 else if (SpecialCol = fForest) and IsJungle(dy) then 1174 TSprite( x, y, spJungle - 1 + SpecialRow * TerrainIconCols)1174 TSprite(X, Y, spJungle - 1 + SpecialRow * TerrainIconCols) 1175 1175 else 1176 TSprite( x, y, spForest - 1 + ((SpecialCol - fForest) * 2 + SpecialRow) * TerrainIconCols);1176 TSprite(X, Y, spForest - 1 + ((SpecialCol - fForest) * 2 + SpecialRow) * TerrainIconCols); 1177 1177 end; 1178 1178 … … 1180 1180 begin 1181 1181 if Tile and fTerImp = tiMine then 1182 TSprite( x, y, spMine);1182 TSprite(X, Y, spMine); 1183 1183 if Tile and fTerImp = tiBase then 1184 TSprite( x, y, spBase);1184 TSprite(X, Y, spBase); 1185 1185 if Tile and fPoll <> 0 then 1186 TSprite( x, y, spPollution);1186 TSprite(X, Y, spPollution); 1187 1187 if Tile and fTerImp = tiFort then 1188 1188 begin 1189 TSprite( x, y, spFortBack);1189 TSprite(X, Y, spFortBack); 1190 1190 if Tile and fObserved = 0 then 1191 TSprite( x, y, spFortFront);1191 TSprite(X, Y, spFortFront); 1192 1192 end; 1193 1193 end; 1194 1194 if (Tile and fDeadLands) <> 0 then 1195 TSprite( x, y, spMinerals + (Tile shr 25 and 3) * TerrainIconCols);1195 TSprite(X, Y, spMinerals + (Tile shr 25 and 3) * TerrainIconCols); 1196 1196 1197 1197 if moEditMode in MapOptions then … … 1205 1205 if fog and ShowObjects then 1206 1206 if Loc < -G.lx then 1207 Sprite(HGrTerrain, x, y+ yyt, xxt * 2, yyt, 1 + 6 * (xxt * 2 + 1),1207 Sprite(HGrTerrain, X, Y + yyt, xxt * 2, yyt, 1 + 6 * (xxt * 2 + 1), 1208 1208 1 + yyt * 2 + 15 * (yyt * 3 + 1)) 1209 1209 else if Loc >= G.lx * (G.ly + 1) then 1210 Sprite(HGrTerrain, x, y, xxt * 2, yyt, 1 + 6 * (xxt * 2 + 1),1210 Sprite(HGrTerrain, X, Y, xxt * 2, yyt, 1 + 6 * (xxt * 2 + 1), 1211 1211 1 + yyt + 15 * (yyt * 3 + 1)) 1212 1212 else 1213 TSprite( x, y, spGrid, xxt <> 33);1213 TSprite(X, Y, spGrid, xxt <> 33); 1214 1214 1215 1215 if FoW and (Tile and fObserved = 0) then … … 1224 1224 if (Destination = Loc) and (Destination <> MyUn[UnFocus].Loc) then 1225 1225 if not UseBlink or BlinkOn then 1226 TSprite( x, y, spBlink1)1226 TSprite(X, Y, spBlink1) 1227 1227 else 1228 TSprite( x, y, spBlink2)1228 TSprite(X, Y, spBlink2) 1229 1229 end; 1230 1230 {$ENDIF} … … 1232 1232 begin 1233 1233 if Tile and fPrefStartPos <> 0 then 1234 TSprite( x, y, spPrefStartPos)1234 TSprite(X, Y, spPrefStartPos) 1235 1235 else if Tile and fStartPos <> 0 then 1236 TSprite( x, y, spStartPos);1236 TSprite(X, Y, spStartPos); 1237 1237 end 1238 1238 else if ShowObjects then 1239 1239 begin 1240 1240 { if (CityLoc<0) and (UnFocus>=0) and (Loc=MyUn[UnFocus].Loc) then 1241 if BlinkOn then TSprite( x,y,8+9*0)1242 else TSprite( x,y,8+9*1); }1241 if BlinkOn then TSprite(X,Y,8+9*0) 1242 else TSprite(X,Y,8+9*1); } 1243 1243 1244 1244 NameCity; 1245 1245 ShowSpacePort; 1246 1246 if Tile and fCity <> 0 then 1247 PaintCity( x + xxt, y+ yyt, CityInfo, CityOwner < 0);1247 PaintCity(X + xxt, Y + yyt, CityInfo, CityOwner < 0); 1248 1248 1249 1249 if (Tile and fUnit <> 0) and (Loc <> AttLoc) and … … 1259 1259 UnitInfo.Health := DefHealth; 1260 1260 if (UnitInfo.Owner <> CityOwner) and 1261 not((CityOwner = me) and (MyRO.Treaty[UnitInfo.Owner] = trAlliance))1261 not((CityOwner = Me) and (MyRO.Treaty[UnitInfo.Owner] = trAlliance)) 1262 1262 then 1263 1263 {$IFNDEF SCR} if (UnFocus >= 0) and (Loc = MyUn[UnFocus].Loc) then { active unit } 1264 1264 begin 1265 1265 Multi := UnitInfo.Flags and unMulti; 1266 MakeUnitInfo( me, MyUn[UnFocus], UnitInfo);1266 MakeUnitInfo(Me, MyUn[UnFocus], UnitInfo); 1267 1267 UnitInfo.Flags := UnitInfo.Flags or Multi; 1268 PaintUnit( x + (xxt - xxu), y+ (yyt - yyu_anchor), UnitInfo,1268 PaintUnit(X + (xxt - xxu), Y + (yyt - yyu_anchor), UnitInfo, 1269 1269 MyUn[UnFocus].Status); 1270 1270 end 1271 else if UnitInfo.Owner = me then1271 else if UnitInfo.Owner = Me then 1272 1272 begin 1273 1273 if ClientMode = cMovieTurn then 1274 PaintUnit( x + (xxt - xxu), y+ (yyt - yyu_anchor), UnitInfo, 0)1274 PaintUnit(X + (xxt - xxu), Y + (yyt - yyu_anchor), UnitInfo, 0) 1275 1275 // status is not set with precise timing during loading 1276 1276 else 1277 PaintUnit( x + (xxt - xxu), y+ (yyt - yyu_anchor), UnitInfo,1277 PaintUnit(X + (xxt - xxu), Y + (yyt - yyu_anchor), UnitInfo, 1278 1278 MyUn[uix].Status); 1279 1279 // if Showuix then Textout(x+16,y+5,$80FF00,IntToStr(uix)); 1280 1280 end 1281 else {$ENDIF} PaintUnit( x + (xxt - xxu), y+ (yyt - yyu_anchor), UnitInfo, 0);1281 else {$ENDIF} PaintUnit(X + (xxt - xxu), Y + (yyt - yyu_anchor), UnitInfo, 0); 1282 1282 end 1283 1283 else if Tile and fHiddenUnit <> 0 then 1284 Sprite(HGrStdUnits, x + (xxt - xxu), y+ (yyt - yyu_anchor), xxu * 2,1284 Sprite(HGrStdUnits, X + (xxt - xxu), Y + (yyt - yyu_anchor), xxu * 2, 1285 1285 yyu * 2, 1 + 5 * (xxu * 2 + 1), 1) 1286 1286 else if Tile and fStealthUnit <> 0 then 1287 Sprite(HGrStdUnits, x + (xxt - xxu), y+ (yyt - yyu_anchor), xxu * 2,1287 Sprite(HGrStdUnits, X + (xxt - xxu), Y + (yyt - yyu_anchor), xxu * 2, 1288 1288 yyu * 2, 1 + 5 * (xxu * 2 + 1), 1 + 1 * (yyu * 2 + 1)) 1289 1289 end; … … 1291 1291 if ShowObjects and (Tile and fTerImp = tiFort) and (Tile and fObserved <> 0) 1292 1292 then 1293 TSprite( x, y, spFortFront);1293 TSprite(X, Y, spFortFront); 1294 1294 1295 1295 if (Loc >= 0) and (Loc < G.lx * G.ly) then 1296 1296 if ShowLoc then 1297 Textout( x + xxt - 16, y+ yyt - 9, $FFFF00, IntToStr(Loc))1297 Textout(X + xxt - 16, Y + yyt - 9, $FFFF00, IntToStr(Loc)) 1298 1298 else if ShowDebug and (DebugMap <> nil) and (Loc >= 0) and 1299 1299 (Loc < G.lx * G.ly) and (DebugMap[Loc] <> 0) then 1300 Textout( x + xxt - 16, y+ yyt - 9, $00E0FF,1301 IntToStr( integer(DebugMap[Loc])))1302 end; { PaintTileObjects }1303 1304 procedure TIsoMap.PaintGrid( x, y, nx, ny: integer);1305 1306 procedure ClippedLine(dx0, dy0: integer; mirror: boolean);1300 Textout(X + xxt - 16, Y + yyt - 9, $00E0FF, 1301 IntToStr(Integer(DebugMap[Loc]))) 1302 end; 1303 1304 procedure TIsoMap.PaintGrid(X, Y, nx, ny: Integer); 1305 1306 procedure ClippedLine(dx0, dy0: Integer; mirror: Boolean); 1307 1307 var 1308 x0, x1, dxmin, dymin, dxmax, dymax, n: integer;1308 x0, x1, dxmin, dymin, dxmax, dymax, N: Integer; 1309 1309 begin 1310 1310 with FOutput.Canvas do 1311 1311 begin 1312 dxmin := (FLeft - x) div xxt;1313 dymin := (RealTop - y) div yyt;1314 dxmax := (FRight - x- 1) div xxt + 1;1315 dymax := (RealBottom - y- 1) div yyt + 1;1316 n:= dymax - dy0;1312 dxmin := (FLeft - X) div xxt; 1313 dymin := (RealTop - Y) div yyt; 1314 dxmax := (FRight - X - 1) div xxt + 1; 1315 dymax := (RealBottom - Y - 1) div yyt + 1; 1316 N := dymax - dy0; 1317 1317 if mirror then 1318 1318 begin 1319 if dx0 - dxmin < nthen1320 n:= dx0 - dxmin;1319 if dx0 - dxmin < N then 1320 N := dx0 - dxmin; 1321 1321 if dx0 > dxmax then 1322 1322 begin 1323 n := n- (dx0 - dxmax);1323 N := N - (dx0 - dxmax); 1324 1324 dy0 := dy0 + (dx0 - dxmax); 1325 1325 dx0 := dxmax … … 1327 1327 if dy0 < dymin then 1328 1328 begin 1329 n := n- (dymin - dy0);1329 N := N - (dymin - dy0); 1330 1330 dx0 := dx0 - (dymin - dy0); 1331 1331 dy0 := dymin … … 1334 1334 else 1335 1335 begin 1336 if dxmax - dx0 < nthen1337 n:= dxmax - dx0;1336 if dxmax - dx0 < N then 1337 N := dxmax - dx0; 1338 1338 if dx0 < dxmin then 1339 1339 begin 1340 n := n- (dxmin - dx0);1340 N := N - (dxmin - dx0); 1341 1341 dy0 := dy0 + (dxmin - dx0); 1342 1342 dx0 := dxmin … … 1344 1344 if dy0 < dymin then 1345 1345 begin 1346 n := n- (dymin - dy0);1346 N := N - (dymin - dy0); 1347 1347 dx0 := dx0 + (dymin - dy0); 1348 1348 dy0 := dymin 1349 1349 end; 1350 1350 end; 1351 if n<= 0 then1352 exit;1351 if N <= 0 then 1352 Exit; 1353 1353 if mirror then 1354 1354 begin 1355 x0 := x+ dx0 * xxt - 1;1356 x1 := x + (dx0 - n) * xxt - 1;1355 x0 := X + dx0 * xxt - 1; 1356 x1 := X + (dx0 - N) * xxt - 1; 1357 1357 end 1358 1358 else 1359 1359 begin 1360 x0 := x+ dx0 * xxt;1361 x1 := x + (dx0 + n) * xxt;1360 x0 := X + dx0 * xxt; 1361 x1 := X + (dx0 + N) * xxt; 1362 1362 end; 1363 moveto(x0, y+ dy0 * yyt);1364 lineto(x1, y + (dy0 + n) * yyt);1363 moveto(x0, Y + dy0 * yyt); 1364 lineto(x1, Y + (dy0 + N) * yyt); 1365 1365 end; 1366 1366 end; 1367 1367 1368 1368 var 1369 i: integer;1369 I: Integer; 1370 1370 begin 1371 1371 FOutput.Canvas.pen.Color := $000000; // $FF shl (8*random(3)); 1372 for i:= 0 to nx div 2 do1373 ClippedLine( i * 2, 0, false);1374 for i:= 1 to (nx + 1) div 2 do1375 ClippedLine( i * 2, 0, true);1376 for i:= 0 to ny div 2 do1377 begin 1378 ClippedLine(0, 2 * i + 2, false);1379 ClippedLine(nx + 1, 2 * i + 1 + nx and 1, true);1380 end; 1381 end; 1382 1383 function TIsoMap.IsShoreTile(Loc: integer): boolean;1372 for I := 0 to nx div 2 do 1373 ClippedLine(I * 2, 0, False); 1374 for I := 1 to (nx + 1) div 2 do 1375 ClippedLine(I * 2, 0, True); 1376 for I := 0 to ny div 2 do 1377 begin 1378 ClippedLine(0, 2 * I + 2, False); 1379 ClippedLine(nx + 1, 2 * I + 1 + nx and 1, True); 1380 end; 1381 end; 1382 1383 function TIsoMap.IsShoreTile(Loc: Integer): Boolean; 1384 1384 var 1385 1385 Dir: Integer; 1386 ConnLoc: integer;1387 begin 1388 result := false;1386 ConnLoc: Integer; 1387 begin 1388 Result := False; 1389 1389 for Dir := 0 to 7 do 1390 1390 begin … … 1392 1392 if (ConnLoc < 0) or (ConnLoc >= G.lx * G.ly) or 1393 1393 ((MyMap[ConnLoc] - 2) and fTerrain < 13) then 1394 result := true;1394 Result := True; 1395 1395 end; 1396 1396 end; … … 1401 1401 begin 1402 1402 for I := 0 to Length - 1 do begin 1403 Line^.Pixel^.B := (Line^.Pixel^.B shr 1) and $7 f;1404 Line^.Pixel^.G := (Line^.Pixel^.G shr 1) and $7 f;1405 Line^.Pixel^.R := (Line^.Pixel^.R shr 1) and $7 f;1403 Line^.Pixel^.B := (Line^.Pixel^.B shr 1) and $7F; 1404 Line^.Pixel^.G := (Line^.Pixel^.G shr 1) and $7F; 1405 Line^.Pixel^.R := (Line^.Pixel^.R shr 1) and $7F; 1406 1406 Line^.NextPixel; 1407 1407 end; … … 1415 1415 end; 1416 1416 1417 procedure TIsoMap.ShadeOutside(x0, y0, Width, Height, xm, ym: integer);1417 procedure TIsoMap.ShadeOutside(x0, y0, Width, Height, xm, ym: Integer); 1418 1418 const 1419 1419 rShade = 3.75; 1420 1420 var 1421 y, wBright: integer;1422 y_n, w_n: single;1421 Y, wBright: Integer; 1422 y_n, w_n: Single; 1423 1423 Line: TPixelPointer; 1424 1424 begin 1425 1425 FOutput.BeginUpdate; 1426 Line := PixelPointer(FOutput, ScaleToNative(x0), ScaleToNative(y0));1427 for y:= 0 to ScaleToNative(Height) - 1 do begin1428 y_n := (ScaleFromNative( y) + y0 - ym) / yyt;1426 Line := TPixelPointer.Create(FOutput, ScaleToNative(x0), ScaleToNative(y0)); 1427 for Y := 0 to ScaleToNative(Height) - 1 do begin 1428 y_n := (ScaleFromNative(Y) + y0 - ym) / yyt; 1429 1429 if abs(y_n) < rShade then begin 1430 1430 // Darken left and right parts of elipsis … … 1445 1445 end; 1446 1446 1447 procedure TIsoMap.CityGrid(xm, ym: integer; CityAllowClick: Boolean);1448 var 1449 i: integer;1447 procedure TIsoMap.CityGrid(xm, ym: Integer; CityAllowClick: Boolean); 1448 var 1449 I: Integer; 1450 1450 begin 1451 1451 with FOutput.Canvas do … … 1456 1456 pen.Color := $000000; 1457 1457 pen.Width := 1; 1458 for i:= 0 to 3 do1458 for I := 0 to 3 do 1459 1459 begin 1460 moveto(xm - xxt * (4 - i), ym + yyt * (1 + i));1461 lineto(xm + xxt * (1 + i), ym - yyt * (4 - i));1462 moveto(xm - xxt * (4 - i), ym - yyt * (1 + i));1463 lineto(xm + xxt * (1 + i), ym + yyt * (4 - i));1460 moveto(xm - xxt * (4 - I), ym + yyt * (1 + I)); 1461 lineto(xm + xxt * (1 + I), ym - yyt * (4 - I)); 1462 moveto(xm - xxt * (4 - I), ym - yyt * (1 + I)); 1463 lineto(xm + xxt * (1 + I), ym + yyt * (4 - I)); 1464 1464 end; 1465 1465 moveto(xm - xxt * 4, ym + yyt * 1); … … 1475 1475 end; 1476 1476 1477 procedure TIsoMap.Paint( x, y, Loc, nx, ny, CityLoc, CityOwner: integer;1478 UseBlink: boolean; CityAllowClick: boolean);1479 var 1480 dx, dy, xm, ym, ALoc, BLoc, ATer, BTer, Aix, bix: integer;1481 begin 1482 FoW := true;1477 procedure TIsoMap.Paint(X, Y, Loc, nx, ny, CityLoc, CityOwner: Integer; 1478 UseBlink: Boolean; CityAllowClick: Boolean); 1479 var 1480 dx, dy, xm, ym, ALoc, BLoc, ATer, BTer, Aix, bix: Integer; 1481 begin 1482 FoW := True; 1483 1483 ShowLoc := moLocCodes in MapOptions; 1484 1484 ShowDebug := pDebugMap >= 0; … … 1486 1486 ShowCityNames := ShowObjects and (CityOwner < 0) and 1487 1487 (moCityNames in MapOptions); 1488 ShowBorder := true;1488 ShowBorder := True; 1489 1489 ShowMyBorder := CityOwner < 0; 1490 1490 ShowGrWall := (CityOwner < 0) and (moGreatWall in MapOptions); 1491 1491 if ShowDebug then 1492 Server(sGetDebugMap, me, pDebugMap, DebugMap)1492 Server(sGetDebugMap, Me, pDebugMap, DebugMap) 1493 1493 else 1494 1494 DebugMap := nil; 1495 1495 with FOutput.Canvas do 1496 1496 begin 1497 RealTop := y- ((Loc + 12345 * G.lx) div G.lx - 12345) * yyt;1498 RealBottom := y+ (G.ly - ((Loc + 12345 * G.lx) div G.lx - 12345) +1497 RealTop := Y - ((Loc + 12345 * G.lx) div G.lx - 12345) * yyt; 1498 RealBottom := Y + (G.ly - ((Loc + 12345 * G.lx) div G.lx - 12345) + 1499 1499 3) * yyt; 1500 1500 Brush.Color := EmptySpaceColor; … … 1573 1573 bix := 0; 1574 1574 end; 1575 BitBltBitmap(OceanPatch, x + dx * xxt, y+ dy * yyt, xxt, yyt,1575 BitBltBitmap(OceanPatch, X + dx * xxt, Y + dy * yyt, xxt, yyt, 1576 1576 Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY) 1577 1577 end … … 1621 1621 bix := Aix; 1622 1622 if Aix = -1 then 1623 BitBltBitmap(HGrTerrain.Data, x + dx * xxt, y+ dy * yyt, xxt,1623 BitBltBitmap(HGrTerrain.Data, X + dx * xxt, Y + dy * yyt, xxt, 1624 1624 yyt, 1 + 6 * (xxt * 2 + 1) + (dx + dy + 1) and 1 * xxt, 1 + yyt, 1625 1625 SRCCOPY) // arctic <-> ocean 1626 1626 else if bix = -1 then 1627 BitBltBitmap(HGrTerrain.Data, x + dx * xxt, y+ dy * yyt, xxt,1627 BitBltBitmap(HGrTerrain.Data, X + dx * xxt, Y + dy * yyt, xxt, 1628 1628 yyt, 1 + 6 * (xxt * 2 + 1) + xxt - (dx + dy + 1) and 1 * xxt, 1629 1629 1 + yyt * 2, SRCCOPY) // arctic <-> ocean 1630 1630 else 1631 BitBltBitmap(LandPatch, x + dx * xxt, y+ dy * yyt, xxt, yyt,1631 BitBltBitmap(LandPatch, X + dx * xxt, Y + dy * yyt, xxt, yyt, 1632 1632 Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY) 1633 1633 end; … … 1639 1639 for dx := -1 to nx do 1640 1640 if (dx + dy) and 1 = 0 then 1641 PaintShore( x + xxt * dx, y+ yyt + yyt * dy, dLoc(Loc, dx, dy));1641 PaintShore(X + xxt * dx, Y + yyt + yyt * dy, dLoc(Loc, dx, dy)); 1642 1642 for dy := -2 to ny + 1 do 1643 1643 for dx := -1 to nx do 1644 1644 if (dx + dy) and 1 = 0 then 1645 PaintTileExtraTerrain( x + xxt * dx, y+ yyt + yyt * dy,1645 PaintTileExtraTerrain(X + xxt * dx, Y + yyt + yyt * dy, 1646 1646 dLoc(Loc, dx, dy)); 1647 1647 if CityOwner >= 0 then … … 1653 1653 ALoc := dLoc(Loc, dx, dy); 1654 1654 if Distance(ALoc, CityLoc) > 5 then 1655 PaintTileObjects( x + xxt * dx, y+ yyt + yyt * dy, ALoc, CityLoc,1655 PaintTileObjects(X + xxt * dx, Y + yyt + yyt * dy, ALoc, CityLoc, 1656 1656 CityOwner, UseBlink); 1657 1657 end; … … 1660 1660 * G.lx) mod (2 * G.lx) - G.lx; 1661 1661 dy := CityLoc div G.lx - (Loc + 666 * G.lx) div G.lx + 666; 1662 xm := x+ (dx + 1) * xxt;1663 ym := y+ (dy + 1) * yyt + yyt;1662 xm := X + (dx + 1) * xxt; 1663 ym := Y + (dy + 1) * yyt + yyt; 1664 1664 ShadeOutside(FLeft, FTop, FRight - FLeft, FBottom - FTop, xm, ym); 1665 1665 CityGrid(xm, ym, CityAllowClick); … … 1670 1670 ALoc := dLoc(Loc, dx, dy); 1671 1671 if Distance(ALoc, CityLoc) <= 5 then 1672 PaintTileObjects( x + xxt * dx, y+ yyt + yyt * dy, ALoc, CityLoc,1672 PaintTileObjects(X + xxt * dx, Y + yyt + yyt * dy, ALoc, CityLoc, 1673 1673 CityOwner, UseBlink); 1674 1674 end; … … 1678 1678 if ShowLoc or (moEditMode in MapOptions) or 1679 1679 (moGrid in MapOptions) then 1680 PaintGrid( x, y, nx, ny);1680 PaintGrid(X, Y, nx, ny); 1681 1681 for dy := -2 to ny + 1 do 1682 1682 for dx := -2 to nx + 1 do 1683 1683 if (dx + dy) and 1 = 0 then 1684 PaintTileObjects( x + xxt * dx, y+ yyt + yyt * dy, dLoc(Loc, dx, dy),1684 PaintTileObjects(X + xxt * dx, Y + yyt + yyt * dy, dLoc(Loc, dx, dy), 1685 1685 CityLoc, CityOwner, UseBlink); 1686 1686 end; 1687 1687 1688 1688 // frame(FOutput.Canvas,x+1,y+1,x+nx*33+33-2,y+ny*16+32-2,$FFFF,$FFFF); 1689 end; { Paint }1689 end; 1690 1690 1691 1691 procedure TIsoMap.AttackBegin(const ShowMove: TShowMove); -
TabularUnified branches/highdpi/LocalPlayer/KeyBindings.pas ¶
r464 r465 1 unit UKeyBindings; 2 3 {$mode delphi} 1 unit KeyBindings; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, fgl, LCLProc, LCLType, Menus, Registry; 6 Classes, SysUtils, Generics.Collections, Generics.Defaults, LCLProc, LCLType, 7 Menus, Registry; 9 8 10 9 type … … 26 25 { TKeyBindings } 27 26 28 TKeyBindings = class(T FPGObjectList<TKeyBinding>)27 TKeyBindings = class(TObjectList<TKeyBinding>) 29 28 private 30 29 public … … 38 37 procedure ResetToDefault; 39 38 procedure RemoveShortCut(ShortCut: TShortCut); 39 procedure SortAlpha; 40 40 end; 41 41 … … 241 241 Text: string; 242 242 begin 243 Strings.Clear; 244 for I := 0 to Count - 1 do begin 245 Text:= ''; 246 if Items[I].ShortCut <> 0 then 247 Text:= Text + ShortCutToText(Items[I].ShortCut); 248 if Items[I].ShortCut2 <> 0 then begin 249 if Text <> '' then Text := Text + ', '; 250 Text:= Text + ShortCutToText(Items[I].ShortCut2); 243 Strings.BeginUpdate; 244 try 245 Strings.Clear; 246 for I := 0 to Count - 1 do begin 247 Text := ''; 248 if Items[I].ShortCut <> 0 then 249 Text := Text + ShortCutToText(Items[I].ShortCut); 250 if Items[I].ShortCut2 <> 0 then begin 251 if Text <> '' then Text := Text + ', '; 252 Text := Text + ShortCutToText(Items[I].ShortCut2); 253 end; 254 if Text <> '' then Text := Items[I].FullName + ' (' + Text + ')' 255 else Text := Items[I].FullName; 256 Strings.Add(Text); 251 257 end; 252 if Text <> '' then Text := Items[I].FullName + ' (' + Text + ')' 253 else Text := Items[I].FullName; 254 Strings.Add(Text); 258 finally 259 Strings.EndUpdate; 255 260 end; 256 261 end; … … 284 289 if Items[I].ShortCut2 = ShortCut then Items[I].ShortCut2 := 0; 285 290 end; 291 end; 292 293 function CompareAlpha(constref Item1, Item2: TKeyBinding): Integer; 294 begin 295 Result := CompareStr(Item1.FullName, Item2.FullName); 296 end; 297 298 procedure TKeyBindings.SortAlpha; 299 begin 300 Sort(TComparer<TKeyBinding>.Construct(CompareAlpha)); 286 301 end; 287 302 … … 372 387 BMoveLeftUp := AddItem('MoveLeftUp', 'Move unit left-up', 'Num7', 'Home'); 373 388 BMoveLeft := AddItem('MoveLeft', 'Move unit left', 'Num4', 'Left'); 389 SortAlpha; 374 390 end; 375 391 … … 381 397 end. 382 398 399 -
TabularUnified branches/highdpi/LocalPlayer/LocalPlayer.pas ¶
r378 r465 4 4 interface 5 5 6 procedure Client(Command, Player: integer; var Data); stdcall;7 procedure SetAIName( p: integer; Name: string);6 procedure Client(Command, Player: Integer; var Data); stdcall; 7 procedure SetAIName(P: Integer; Name: string); 8 8 9 9 implementation 10 10 11 11 uses 12 UDpiControls, Term, CityScreen, Draft, MessgEx, Select, CityType, Help, UnitStat, Diagram, 13 NatStat, Wonders, Nego, Enhance, BaseWin, Battle, Rates, TechTree, Forms; 12 UDpiControls, Term, CityScreen, Nego, BaseWin, Forms; 14 13 15 14 var 16 FormsCreated: boolean;15 FormsCreated: Boolean; 17 16 18 procedure Client(Command, Player: integer; var Data);17 procedure Client(Command, Player: Integer; var Data); 19 18 begin 20 19 if not FormsCreated then 21 20 begin 22 FormsCreated := true;21 FormsCreated := True; 23 22 // TODO: Changing application name in runtime will cause change of Linux XML registry file path 24 // DpiApplication.MainForm := MainScreen;23 // Application.MainForm := MainScreen; 25 24 DpiApplication.CreateForm(TMainScreen, MainScreen); 26 DpiApplication.CreateForm(TCityDlg, CityDlg);27 DpiApplication.CreateForm(TModalSelectDlg, ModalSelectDlg);28 DpiApplication.CreateForm(TListDlg, ListDlg);29 DpiApplication.CreateForm(TMessgExDlg, MessgExDlg);30 DpiApplication.CreateForm(TDraftDlg, DraftDlg);31 DpiApplication.CreateForm(TCityTypeDlg, CityTypeDlg);32 DpiApplication.CreateForm(THelpDlg, HelpDlg);33 DpiApplication.CreateForm(TUnitStatDlg, UnitStatDlg);34 DpiApplication.CreateForm(TDiaDlg, DiaDlg);35 DpiApplication.CreateForm(TNatStatDlg, NatStatDlg);36 DpiApplication.CreateForm(TWondersDlg, WondersDlg);37 DpiApplication.CreateForm(TNegoDlg, NegoDlg);38 DpiApplication.CreateForm(TEnhanceDlg, EnhanceDlg);39 DpiApplication.CreateForm(TBattleDlg, BattleDlg);40 // DpiApplication.CreateForm(TAdvisorDlg, AdvisorDlg);41 DpiApplication.CreateForm(TRatesDlg, RatesDlg);42 DpiApplication.CreateForm(TTechTreeDlg, TechTreeDlg);43 25 end; 44 26 MainScreen.Client(Command, Player, Data); 45 27 end; 46 28 47 procedure SetAIName( p: integer; Name: string);29 procedure SetAIName(P: Integer; Name: string); 48 30 begin 49 MainScreen.SetAIName( p, Name);31 MainScreen.SetAIName(P, Name); 50 32 end; 51 33 52 34 initialization 53 35 54 FormsCreated := false;36 FormsCreated := False; 55 37 56 38 end. -
TabularUnified branches/highdpi/LocalPlayer/MessgEx.lfm ¶
r349 r465 6 6 BorderIcons = [] 7 7 BorderStyle = bsNone 8 Caption = ' C-evo'8 Caption = 'Message' 9 9 ClientHeight = 134 10 10 ClientWidth = 418 … … 12 12 DesignTimePPI = 144 13 13 Font.Color = clWindowText 14 Font.Height = - 1314 Font.Height = -20 15 15 Font.Name = 'MS Sans Serif' 16 16 FormStyle = fsStayOnTop … … 20 20 OnPaint = FormPaint 21 21 OnShow = FormShow 22 LCLVersion = '2. 0.12.0'22 LCLVersion = '2.2.2.0' 23 23 Scaled = False 24 24 object Button1: TButtonA … … 61 61 object EInput: TDpiEdit 62 62 Left = 125 63 Height = 2 663 Height = 27 64 64 Top = 64 65 65 Width = 168 -
TabularUnified branches/highdpi/LocalPlayer/MessgEx.pas ¶
r412 r465 5 5 6 6 uses 7 UDpiControls, Messg, Protocol, ScreenTools, Platform, DateUtils, 8 LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, ButtonA,9 ButtonB, StdCtrls, DrawDlg;7 UDpiControls, Messg, Protocol, ScreenTools, Platform, DateUtils, LCLIntf, LCLType, Messages, 8 SysUtils, Classes, Graphics, Controls, Forms, ButtonA, ButtonB, StdCtrls, 9 DrawDlg, Help; 10 10 11 11 type … … 13 13 mikPureIcon, mikMyArmy, mikEnemyArmy, mikFullControl, mikShip, mikBigIcon, 14 14 mikEnemyShipComplete); 15 16 { TMessgExDlg } 15 17 16 18 TMessgExDlg = class(TBaseMessgDlg) … … 32 34 Kind: TMessageKind; 33 35 IconIndex: Integer; 34 HelpKind: Integer;36 HelpKind: TLinkCategory; 35 37 HelpNo: Integer; 36 38 CenterTo: Integer; 37 39 IconKind: TMessageIconKind; 38 40 OpenSound: string; 39 function ShowModal: integer; override;41 function ShowModal: Integer; override; 40 42 procedure CancelMovie; 41 43 private 42 MovieCancelled: boolean;43 procedure PaintBook(ca: TDpiCanvas; x, y, clPage, clCover: integer);44 MovieCancelled: Boolean; 45 procedure PaintBook(ca: TDpiCanvas; X, Y, clPage, clCover: Integer); 44 46 procedure PaintMyArmy; 45 47 procedure PaintEnemyArmy; … … 47 49 end; 48 50 49 var50 MessgExDlg: TMessgExDlg;51 51 52 52 procedure SoundMessageEx(SimpleText, SoundItem: string); 53 procedure TribeMessage( p: integer; SimpleText, SoundItem: string);53 procedure TribeMessage(P: Integer; SimpleText, SoundItem: string); 54 54 function SimpleQuery(QueryKind: TMessageKind; SimpleText, SoundItem: string) 55 : integer;55 : Integer; 56 56 procedure ContextMessage(SimpleText, SoundItem: string; 57 ContextKind, ContextNo: integer); 57 ContextKind: TLinkCategory; ContextNo: Integer); 58 58 59 59 60 implementation 60 61 61 62 uses 62 ClientTools, BaseWin, Term, Help, UnitStat, Tribes, UPixelPointer,63 IsoEngine,Diagram, Sound;63 ClientTools, BaseWin, Term, UnitStat, Tribes, PixelPointer, 64 Diagram, Sound; 64 65 65 66 {$R *.lfm} … … 78 79 procedure TMessgExDlg.FormShow(Sender: TObject); 79 80 var 80 i: integer;81 I: Integer; 81 82 begin 82 83 if IconKind = mikEnemyArmy then … … 147 148 end; 148 149 149 SplitText( true);150 SplitText(True); 150 151 ClientHeight := 72 + Border + TopSpace + Lines * MessageLineSpacing; 151 152 if GameMode = cMovie then … … 178 179 end; 179 180 end; 180 for i:= 0 to ControlCount - 1 do181 Controls[ i].Top := ClientHeight - (34 + Border);181 for I := 0 to ControlCount - 1 do 182 Controls[I].Top := ClientHeight - (34 + Border); 182 183 if Kind = mkModel then 183 184 EInput.Top := ClientHeight - (76 + Border); 184 185 end; 185 186 186 function TMessgExDlg.ShowModal: integer;187 function TMessgExDlg.ShowModal: Integer; 187 188 var 188 189 Ticks0: TDateTime; 189 190 Ticks: TDateTime; 190 191 begin 192 Caption := Phrases.Lookup('TITLE_MESSAGE'); 191 193 if GameMode = cMovie then 192 194 begin 193 195 if not((GameMode = cMovie) and (MovieSpeed = 4)) then 194 196 begin 195 MovieCancelled := false;197 MovieCancelled := False; 196 198 Show; 197 199 Ticks0 := NowPrecise; … … 203 205 Hide; 204 206 end; 205 result := mrOk;207 Result := mrOk; 206 208 end 207 209 else 208 result := inherited; 210 Result := inherited; 211 //Gtk2Fix; 209 212 end; 210 213 211 214 procedure TMessgExDlg.CancelMovie; 212 215 begin 213 MovieCancelled := true;214 end; 215 216 procedure TMessgExDlg.PaintBook(ca: TDpiCanvas; x, y, clPage, clCover: integer);216 MovieCancelled := True; 217 end; 218 219 procedure TMessgExDlg.PaintBook(ca: TDpiCanvas; X, Y, clPage, clCover: Integer); 217 220 const 218 221 xScrewed = 77; … … 220 223 wScrewed = 43; 221 224 hScrewed = 27; 225 type 226 TScrewed = array [0 .. wScrewed - 1, 0 .. hScrewed - 1, 0 .. 3] of Single; 222 227 var 223 ix, iy, xDst, yDst, dx, dy, xIcon, yIcon: integer;228 ix, iy, xDst, yDst, dx, dy, xIcon, yIcon: Integer; 224 229 BookRect: TRect; 225 x1, xR, yR, share: single;226 Screwed: array [0 .. wScrewed - 1, 0 .. hScrewed - 1, 0 .. 3] of single;230 x1, xR, yR, share: Single; 231 Screwed: TScrewed; 227 232 SrcPtr: TPixelPointer; 228 233 Width: Integer; … … 235 240 yIcon := (IconIndex + SystemIconLines * 7) div 7 * ySizeBig; 236 241 // prepare screwed icon 237 FillChar(Screwed, sizeof(Screwed), 0);242 Screwed := Default(TScrewed); 238 243 BigImp.BeginUpdate; 239 SrcPtr := PixelPointer(BigImp, ScaleToNative(xIcon), ScaleToNative(yIcon));244 SrcPtr := TPixelPointer.Create(BigImp, ScaleToNative(xIcon), ScaleToNative(yIcon)); 240 245 for iy := 0 to ScaleToNative(Height) - 1 do begin 241 246 for ix := 0 to ScaleToNative(Width) - 1 do begin … … 277 282 BookRect := SmallBook.BoundsRect; 278 283 end; 279 x := x- BookRect.Width div 2;284 X := X - BookRect.Width div 2; 280 285 281 286 // paint 282 287 UnshareBitmap(LogoBuffer); 283 DpiBit Canvas(LogoBuffer.Canvas, 0, 0, BookRect.Width, BookRect.Height, ca, x, y);288 DpiBitBltCanvas(LogoBuffer.Canvas, 0, 0, BookRect.Width, BookRect.Height, ca, X, Y); 284 289 285 290 if IconIndex >= 0 then … … 294 299 ImageOp_BCC(LogoBuffer, Templates.Data, Point(0, 0), BookRect, clCover, clPage); 295 300 296 DpiBit Canvas(ca, x, y, BookRect.Width, BookRect.Height, LogoBuffer.Canvas, 0, 0);301 DpiBitBltCanvas(ca, X, Y, BookRect.Width, BookRect.Height, LogoBuffer.Canvas, 0, 0); 297 302 end; 298 303 … … 303 308 procedure TMessgExDlg.PaintEnemyArmy; 304 309 var 305 emix, ix, iy, x, y, count, UnitsInLine: integer;310 emix, ix, iy, X, Y, count, UnitsInLine: Integer; 306 311 begin 307 312 ix := 0; … … 314 319 for count := 0 to LostArmy[emix] - 1 do 315 320 begin 316 x:= ClientWidth div 2 + ix * 64 - UnitsInLine * 32;317 y:= 26 + Border + TopSpace + Lines * MessageLineSpacing + iy * 48;321 X := ClientWidth div 2 + ix * 64 - UnitsInLine * 32; 322 Y := 26 + Border + TopSpace + Lines * MessageLineSpacing + iy * 48; 318 323 with MyRO.EnemyModel[emix], Tribe[Owner].ModelPicture[mix] do 319 324 begin 320 DpiBit Canvas(Canvas, x, y, 64, 48, HGr.Mask.Canvas,325 DpiBitBltCanvas(Canvas, X, Y, 64, 48, HGr.Mask.Canvas, 321 326 pix mod 10 * 65 + 1, pix div 10 * 49 + 1, SRCAND); 322 DpiBit Canvas(Canvas, x, y, 64, 48, HGr.Data.Canvas,327 DpiBitBltCanvas(Canvas, X, Y, 64, 48, HGr.Data.Canvas, 323 328 pix mod 10 * 65 + 1, pix div 10 * 49 + 1, SRCPAINT); 324 329 end; 325 330 326 331 // next position 327 inc(ix);332 Inc(ix); 328 333 if ix = LostUnitsPerLine then 329 334 begin // next line 330 335 ix := 0; 331 inc(iy);336 Inc(iy); 332 337 if iy = 6 then 333 exit;338 Exit; 334 339 UnitsInLine := nLostArmy - LostUnitsPerLine * iy; 335 340 if UnitsInLine > LostUnitsPerLine then … … 341 346 procedure TMessgExDlg.FormPaint(Sender: TObject); 342 347 var 343 p1, clSaveTextLight, clSaveTextShade: integer;348 p1, clSaveTextLight, clSaveTextShade: Integer; 344 349 begin 345 350 if (IconKind = mikImp) and (IconIndex = 27) then … … 362 367 p1 := MyRO.Wonder[IconIndex].EffectiveOwner; 363 368 UnshareBitmap(Buffer); 364 DpiBit Canvas(Buffer.Canvas, 0, 0, xSizeBig + 2 * GlowRange,369 DpiBitBltCanvas(Buffer.Canvas, 0, 0, xSizeBig + 2 * GlowRange, 365 370 ySizeBig + 2 * GlowRange, Canvas, 366 371 ClientWidth div 2 - (28 + GlowRange), 24 - GlowRange); 367 DpiBit Canvas(Buffer.Canvas, GlowRange, GlowRange, xSizeBig, ySizeBig,372 DpiBitBltCanvas(Buffer.Canvas, GlowRange, GlowRange, xSizeBig, ySizeBig, 368 373 BigImp.Canvas, IconIndex mod 7 * xSizeBig, 369 374 (IconIndex + SystemIconLines * 7) div 7 * ySizeBig); … … 373 378 GlowFrame(Buffer, GlowRange, GlowRange, xSizeBig, ySizeBig, 374 379 Tribe[p1].Color); 375 DpiBit Canvas(Canvas, ClientWidth div 2 - (28 + GlowRange),380 DpiBitBltCanvas(Canvas, ClientWidth div 2 - (28 + GlowRange), 376 381 24 - GlowRange, xSizeBig + 2 * GlowRange, ySizeBig + 2 * GlowRange, 377 382 Buffer.Canvas, 0, 0); … … 387 392 end; 388 393 mikModel: 389 with Tribe[ me].ModelPicture[IconIndex] do394 with Tribe[Me].ModelPicture[IconIndex] do 390 395 begin 391 396 FrameImage(Canvas, BigImp, ClientWidth div 2 - 28, 24, xSizeBig, 392 397 ySizeBig, 0, 0); 393 DpiBit Canvas(Canvas, ClientWidth div 2 - 32, 20, 64, 44,398 DpiBitBltCanvas(Canvas, ClientWidth div 2 - 32, 20, 64, 44, 394 399 HGr.Mask.Canvas, pix mod 10 * 65 + 1, 395 400 pix div 10 * 49 + 1, SRCAND); 396 DpiBit Canvas(Canvas, ClientWidth div 2 - 32, 20, 64, 44,401 DpiBitBltCanvas(Canvas, ClientWidth div 2 - 32, 20, 64, 44, 397 402 HGr.Data.Canvas, pix mod 10 * 65 + 1, 398 403 pix div 10 * 49 + 1, SRCPAINT); … … 406 411 Frame(Canvas, ClientWidth div 2 - 32 - 1, 24 - 1, 407 412 ClientWidth div 2 + 32, 24 + 48, $000000, $000000); 408 DpiBit Canvas(Canvas, ClientWidth div 2 - 32, 24, 64, 48,413 DpiBitBltCanvas(Canvas, ClientWidth div 2 - 32, 24, 64, 48, 409 414 Tribe[IconIndex].faceHGr.Data.Canvas, 410 415 1 + Tribe[IconIndex].facepix mod 10 * 65, … … 420 425 mikEnemyShipComplete: 421 426 begin 422 DpiBit Canvas(Buffer.Canvas, 0, 0, 140, 120, Canvas,427 DpiBitBltCanvas(Buffer.Canvas, 0, 0, 140, 120, Canvas, 423 428 (ClientWidth - 140) div 2, 24); 424 429 ImageOp_BCC(Buffer, Templates.Data, Point(0, 0), StarshipDeparted.BoundsRect, 0, $FFFFFF); 425 DpiBit Canvas(Canvas, (ClientWidth - 140) div 2, 24, 140, 120,430 DpiBitBltCanvas(Canvas, (ClientWidth - 140) div 2, 24, 140, 120, 426 431 Buffer.Canvas, 0, 0); 427 432 end; … … 451 456 begin 452 457 if Kind = mkOkHelp then 453 HelpDlg.ShowNewContent(wmSubmodal, HelpKind, HelpNo)458 MainScreen.HelpDlg.ShowNewContent(wmSubmodal, HelpKind, HelpNo) 454 459 else if Kind = mkModel then 455 UnitStatDlg.ShowNewContent_OwnModel(wmSubmodal, IconIndex)460 MainScreen.UnitStatDlg.ShowNewContent_OwnModel(wmSubmodal, IconIndex) 456 461 else 457 462 ModalResult := mrIgnore; … … 482 487 // because Messg.SoundMessage not capable of movie mode 483 488 begin 484 with M essgExDlg do489 with MainScreen.MessgExDlg do 485 490 begin 486 491 MessgText := SimpleText; … … 491 496 end; 492 497 493 procedure TribeMessage( p: integer; SimpleText, SoundItem: string);494 begin 495 with M essgExDlg do498 procedure TribeMessage(P: Integer; SimpleText, SoundItem: string); 499 begin 500 with MainScreen.MessgExDlg do 496 501 begin 497 502 OpenSound := SoundItem; … … 499 504 Kind := mkOk; 500 505 IconKind := mikTribe; 501 IconIndex := p;506 IconIndex := P; 502 507 ShowModal; 503 508 end; … … 505 510 506 511 function SimpleQuery(QueryKind: TMessageKind; SimpleText, SoundItem: string) 507 : integer;508 begin 509 with M essgExDlg do512 : Integer; 513 begin 514 with MainScreen.MessgExDlg do 510 515 begin 511 516 MessgText := SimpleText; … … 513 518 Kind := QueryKind; 514 519 ShowModal; 515 result := ModalResult;520 Result := ModalResult; 516 521 end; 517 522 end; 518 523 519 524 procedure ContextMessage(SimpleText, SoundItem: string; 520 ContextKind , ContextNo: integer);521 begin 522 with M essgExDlg do525 ContextKind: TLinkCategory; ContextNo: Integer); 526 begin 527 with MainScreen.MessgExDlg do 523 528 begin 524 529 MessgText := SimpleText; … … 543 548 end; 544 549 545 546 initialization547 548 550 end. -
TabularUnified 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 -
TabularUnified branches/highdpi/LocalPlayer/Nego.pas ¶
r361 r465 5 5 6 6 uses 7 UDpiControls, ScreenTools, BaseWin, Protocol, Term,LCLType, SysUtils, Classes, Graphics,7 UDpiControls, ScreenTools, BaseWin, Protocol, LCLType, SysUtils, Classes, Graphics, 8 8 Controls, Forms, ButtonA, ButtonB, ButtonN; 9 9 … … 15 15 type 16 16 THistory = record 17 n: Integer;17 N: Integer; 18 18 Text: array[0 .. MaxHistory - 1] of ansistring; 19 19 end; 20 20 21 21 TCommandAllowedEnum = scDipNoticeStart..scDipBreakStart; 22 TPriceSet = set of $00..$FF; 22 23 23 24 { TNegoDlg } … … 59 60 procedure FormDestroy(Sender: TObject); 60 61 procedure FormMouseDown(Sender: TObject; Button: TMouseButton; 61 Shift: TShiftState; X, Y: integer);62 Shift: TShiftState; X, Y: Integer); 62 63 procedure OkBtnClick(Sender: TObject); 63 64 procedure BwdBtnClick(Sender: TObject); … … 69 70 procedure OfferClick(Sender: TObject); 70 71 procedure FastBtnClick(Sender: TObject); 71 72 72 public 73 73 procedure Initiate; // first turn of negotiation, initiate … … 75 75 procedure Start; // next turn of negotiation 76 76 procedure OffscreenPaint; override; 77 procedure ShowNewContent(NewMode: integer); 78 77 procedure ShowNewContent(NewMode: TWindowMode); 79 78 private 80 Page, DipCommand: integer;79 Page, DipCommand: Integer; 81 80 CurrentOffer: TOffer; 82 81 MyAllowed, OppoAllowed: TPriceSet; … … 84 83 History: array [0 .. nPl - 1] of THistory; 85 84 RomanFont: TDpiFont; 86 Costs, Delivers: array [0 .. 11] of cardinal;85 Costs, Delivers: array [0 .. 11] of Cardinal; 87 86 procedure ResetCurrentOffer; 88 87 procedure BuildCurrentOffer; 89 88 procedure FindAllowed; 90 89 procedure SplitText(Text: string; Bounds: TRect); 91 procedure PaintNationPicture(X, Y, p: integer);90 procedure PaintNationPicture(X, Y, P: Integer); 92 91 procedure SetButtonStates; 93 92 end; 94 93 95 var96 NegoDlg: TNegoDlg;97 94 98 95 implementation 99 96 100 97 uses 101 Messg, ClientTools, Diplomacy, Inp, Select, NatStat, Tribes, MessgEx ;98 Messg, ClientTools, Diplomacy, Inp, Select, NatStat, Tribes, MessgEx, Term; 102 99 103 100 {$R *.lfm} … … 136 133 'VII', 'VIII', 'IX', 'X', 'XI', 'XII', 'XIII', 'XIV', 'XV', 'XVI'); 137 134 138 ButtonPrice: array [0 .. 11] of cardinal = (opChoose, opCivilReport,135 ButtonPrice: array [0 .. 11] of Cardinal = (opChoose, opCivilReport, 139 136 opMilReport, opMap, opAllTech, opAllTech, opAllModel, opMoney, opTreaty, 140 137 opLowTreaty, opShipParts, opShipParts); … … 142 139 procedure TNegoDlg.FormCreate(Sender: TObject); 143 140 var 144 cix: integer;141 cix: Integer; 145 142 begin 146 143 InitButtons; … … 153 150 BackGraphic := HGrSystem2.Data; 154 151 case Tag shr 8 of 155 1: 156 SmartHint := Phrases.Lookup('WANT', ButtonIndex - 6); 157 2: 158 SmartHint := Phrases.Lookup('OFFER', ButtonIndex - 6); 152 1: SmartHint := Phrases.Lookup('WANT', ButtonIndex - 6); 153 2: SmartHint := Phrases.Lookup('OFFER', ButtonIndex - 6); 159 154 end; 160 155 end; 161 156 162 fillchar(History, sizeof(History), 0);157 FillChar(History, SizeOf(History), 0); 163 158 RomanFont := TDpiFont.Create; 164 159 RomanFont.Name := 'Times New Roman'; … … 184 179 procedure TNegoDlg.ResetCurrentOffer; 185 180 var 186 i: integer;181 I: Integer; 187 182 begin 188 183 CurrentOffer.nDeliver := 0; 189 184 CurrentOffer.nCost := 0; 190 for i:= 0 to 11 do191 Costs[ i] := $FFFFFFFF;192 for i:= 0 to 11 do193 Delivers[ i] := $FFFFFFFF;194 end; 195 196 procedure TNegoDlg.ShowNewContent(NewMode: integer);185 for I := 0 to 11 do 186 Costs[I] := $FFFFFFFF; 187 for I := 0 to 11 do 188 Delivers[I] := $FFFFFFFF; 189 end; 190 191 procedure TNegoDlg.ShowNewContent(NewMode: TWindowMode); 197 192 begin 198 193 inherited ShowNewContent(NewMode); … … 202 197 else 203 198 PassBtn.SmartHint := Phrases.Lookup('BTN_PASS'); 204 case MyRO.Treaty[DipMem[ me].pContact] of199 case MyRO.Treaty[DipMem[Me].pContact] of 205 200 trNone: 206 201 begin … … 238 233 begin 239 234 if ClientMode <> scDipStart then 240 with History[ me] do241 begin 242 if n= MaxHistory then243 begin 244 move(Text[2], Text[0], (MaxHistory - 2) * sizeof(integer));245 dec(n, 2);235 with History[Me] do 236 begin 237 if N = MaxHistory then 238 begin 239 Move(Text[2], Text[0], (MaxHistory - 2) * SizeOf(Integer)); 240 Dec(N, 2); 246 241 end; 247 Text[ n] := copy(DipCommandToString(DipMem[me].pContact, me,248 DipMem[ me].FormerTreaty, DipMem[me].SentCommand, ClientMode,249 DipMem[ me].SentOffer, ReceivedOffer), 1, 255);250 inc(n);242 Text[N] := Copy(DipCommandToString(DipMem[Me].pContact, Me, 243 DipMem[Me].FormerTreaty, DipMem[Me].SentCommand, ClientMode, 244 DipMem[Me].SentOffer, ReceivedOffer), 1, 255); 245 Inc(N); 251 246 end; 252 assert(History[me].nmod 2 = 1);253 254 Page := History[ me].n;247 Assert(History[Me].N mod 2 = 1); 248 249 Page := History[Me].N; 255 250 FindAllowed; 256 251 ResetCurrentOffer; … … 284 279 procedure TNegoDlg.SplitText(Text: string; Bounds: TRect); 285 280 var 286 nLines, Line, Start, Stop, OrdinaryStop, Indent, Y: integer;287 s: string;288 preview, Dot: boolean;281 nLines, Line, Start, Stop, OrdinaryStop, Indent, Y: Integer; 282 S: string; 283 preview, Dot: Boolean; 289 284 begin 290 285 nLines := 0; 291 for preview := true downto false do286 for preview := True downto False do 292 287 begin 293 288 Start := 1; … … 296 291 while Start < Length(Text) do 297 292 begin 298 Dot := false;293 Dot := False; 299 294 if (Start = 1) or (Text[Start - 1] = '\') then 300 295 if Text[Start] = '-' then 301 296 begin 302 297 Indent := ListIndent; 303 inc(Start);298 Inc(Start); 304 299 if Start = Length(Text) then 305 break;306 Dot := true;300 Break; 301 Dot := True; 307 302 end 308 303 else … … 311 306 while (Stop < Length(Text)) and (Text[Stop] <> '\') do 312 307 begin 313 inc(Stop);308 Inc(Stop); 314 309 if BiColorTextWidth(Offscreen.Canvas, 315 copy(Text, Start, Stop - Start + 1)) > Bounds.Right - Bounds.Left -310 Copy(Text, Start, Stop - Start + 1)) > Bounds.Right - Bounds.Left - 316 311 PaperBorder_Left - PaperBorder_Right - Indent then 317 312 begin 318 dec(Stop);319 break313 Dec(Stop); 314 Break 320 315 end; 321 316 end; … … 325 320 while (Text[OrdinaryStop + 1] <> ' ') and 326 321 (Text[OrdinaryStop + 1] <> '\') do 327 dec(OrdinaryStop);322 Dec(OrdinaryStop); 328 323 if (OrdinaryStop + 1 - Start) * 2 >= Stop - Start then 329 324 Stop := OrdinaryStop … … 335 330 Sprite(Offscreen, HGrSystem, Bounds.Left + PaperBorder_Left + 336 331 (ListIndent - 14), Y + 7, 8, 8, 90, 16); 337 s := copy(Text, Start, Stop - Start + 1);332 S := Copy(Text, Start, Stop - Start + 1); 338 333 BiColorTextOut(Offscreen.Canvas, Colors.Canvas.Pixels[clkMisc, 339 334 cliPaperText], $7F007F, Bounds.Left + PaperBorder_Left + 340 Indent, Y, s);335 Indent, Y, S); 341 336 end; 342 inc(Line);337 Inc(Line); 343 338 Start := Stop + 2; 344 339 end; … … 349 344 procedure TNegoDlg.FindAllowed; 350 345 var 351 i: integer;346 I: Integer; 352 347 begin 353 348 CommandAllowed := [scDipOffer - scDipStart]; 354 349 if ClientMode <> scDipBreak then 355 include(CommandAllowed, scDipBreak - scDipStart);356 if MyRO.Treaty[DipMem[ me].pContact] >= trPeace then357 include(CommandAllowed, scDipCancelTreaty - scDipStart);358 if (ClientMode = scDipOffer) and (Server(scDipAccept - sExecute, me, 0, nil^)350 Include(CommandAllowed, scDipBreak - scDipStart); 351 if MyRO.Treaty[DipMem[Me].pContact] >= trPeace then 352 Include(CommandAllowed, scDipCancelTreaty - scDipStart); 353 if (ClientMode = scDipOffer) and (Server(scDipAccept - sExecute, Me, 0, nil^) 359 354 >= rExecuted) then 360 include(CommandAllowed, scDipAccept - scDipStart);355 Include(CommandAllowed, scDipAccept - scDipStart); 361 356 362 357 MyAllowed := [opChoose shr 24, opMoney shr 24]; 363 358 OppoAllowed := [opChoose shr 24, opMoney shr 24]; 364 if not IsCivilReportNew(DipMem[ me].pContact) then359 if not IsCivilReportNew(DipMem[Me].pContact) then 365 360 begin // no up-to-date civil report 366 361 MyAllowed := MyAllowed + [opCivilReport shr 24]; 367 for i:= 0 to nAdv - 1 do368 if MyRO.Tech[ i] >= tsApplicable then362 for I := 0 to nAdv - 1 do 363 if MyRO.Tech[I] >= tsApplicable then 369 364 begin 370 365 MyAllowed := MyAllowed + [opAllTech shr 24]; 371 break366 Break 372 367 end; 373 368 OppoAllowed := OppoAllowed + [opCivilReport shr 24, opAllTech shr 24]; … … 375 370 else 376 371 begin // check techs 377 for i:= 0 to nAdv - 1 do378 if not( iin FutureTech) then379 if (MyRO.Tech[ i] < tsSeen) and380 (MyRO.EnemyReport[DipMem[ me].pContact].Tech[i] >= tsApplicable) then372 for I := 0 to nAdv - 1 do 373 if not(I in FutureTech) then 374 if (MyRO.Tech[I] < tsSeen) and 375 (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] >= tsApplicable) then 381 376 OppoAllowed := OppoAllowed + [opAllTech shr 24] 382 else if (MyRO.EnemyReport[DipMem[ me].pContact].Tech[i] < tsSeen) and383 (MyRO.Tech[ i] >= tsApplicable) then377 else if (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] < tsSeen) and 378 (MyRO.Tech[I] >= tsApplicable) then 384 379 MyAllowed := MyAllowed + [opAllTech shr 24]; 385 380 end; 386 if not IsMilReportNew(DipMem[ me].pContact) then381 if not IsMilReportNew(DipMem[Me].pContact) then 387 382 begin // no up-to-date military report 388 383 MyAllowed := MyAllowed + [opMilReport shr 24]; … … 393 388 else 394 389 begin 395 if M odalSelectDlg.OnlyChoice(kChooseModel) <> mixAll then390 if MainScreen.ModalSelectDlg.OnlyChoice(kChooseModel) <> mixAll then 396 391 MyAllowed := MyAllowed + [opAllModel shr 24]; 397 if M odalSelectDlg.OnlyChoice(kChooseEModel) <> mixAll then392 if MainScreen.ModalSelectDlg.OnlyChoice(kChooseEModel) <> mixAll then 398 393 OppoAllowed := OppoAllowed + [opAllModel shr 24]; 399 394 end; 400 if MyRO.Treaty[DipMem[ me].pContact] < trAlliance then395 if MyRO.Treaty[DipMem[Me].pContact] < trAlliance then 401 396 begin 402 397 MyAllowed := MyAllowed + [opTreaty shr 24, opMap shr 24]; … … 408 403 OppoAllowed:=OppoAllowed+[opLowTreaty shr 24]; 409 404 end; } 410 for i:= 0 to nShipPart - 1 do411 begin 412 if MyRO.Ship[ me].Parts[i] > 0 then413 include(MyAllowed, opShipParts shr 24);414 if MyRO.Ship[DipMem[ me].pContact].Parts[i] > 0 then415 include(OppoAllowed, opShipParts shr 24);416 end; 417 MyAllowed := MyAllowed - DipMem[ me].DeliveredPrices *405 for I := 0 to nShipPart - 1 do 406 begin 407 if MyRO.Ship[Me].Parts[I] > 0 then 408 Include(MyAllowed, opShipParts shr 24); 409 if MyRO.Ship[DipMem[Me].pContact].Parts[I] > 0 then 410 Include(OppoAllowed, opShipParts shr 24); 411 end; 412 MyAllowed := MyAllowed - DipMem[Me].DeliveredPrices * 418 413 [opAllTech shr 24, opAllModel shr 24, opCivilReport shr 24, 419 414 opMilReport shr 24, opMap shr 24]; 420 OppoAllowed := OppoAllowed - DipMem[ me].ReceivedPrices *415 OppoAllowed := OppoAllowed - DipMem[Me].ReceivedPrices * 421 416 [opAllTech shr 24, opAllModel shr 24, opCivilReport shr 24, 422 417 opMilReport shr 24, opMap shr 24]; 423 418 end; 424 419 425 procedure TNegoDlg.PaintNationPicture(X, Y, p: integer);420 procedure TNegoDlg.PaintNationPicture(X, Y, P: Integer); 426 421 begin 427 422 with Offscreen.Canvas do 428 423 begin 429 424 Pen.Color := $000000; 430 Brush.Color := Tribe[ p].Color;425 Brush.Color := Tribe[P].Color; 431 426 Rectangle(X - 6, Y - 1, X + 70, Y + 49); 432 427 Brush.Color := $000000; 433 Tribe[ p].InitAge(GetAge(p));434 if Assigned(Tribe[ p].faceHGr) then435 Dump(Offscreen, Tribe[ p].faceHGr, X, Y, 64, 48,436 1 + Tribe[ p].facepix mod 10 * 65, 1 + Tribe[p].facepix div 10 * 49)428 Tribe[P].InitAge(GetAge(P)); 429 if Assigned(Tribe[P].faceHGr) then 430 Dump(Offscreen, Tribe[P].faceHGr, X, Y, 64, 48, 431 1 + Tribe[P].facepix mod 10 * 65, 1 + Tribe[P].facepix div 10 * 49) 437 432 else 438 433 FillRect(Rect(X, Y, X + 64, Y + 48)); … … 444 439 procedure TNegoDlg.SetButtonStates; 445 440 var 446 cix: integer;447 IsActionPage: boolean;448 begin 449 IsActionPage := Page = History[ me].n;441 cix: Integer; 442 IsActionPage: Boolean; 443 begin 444 IsActionPage := Page = History[Me].N; 450 445 451 446 AcceptBtn.Possible := IsActionPage and … … 478 473 (ButtonPrice[Tag and $FF] shr 24 in MyAllowed); 479 474 Lit := Delivers[Tag and $FF] <> $FFFFFFFF; 480 end 475 end; 481 476 end; 482 477 end; … … 484 479 procedure TNegoDlg.OffscreenPaint; 485 480 var 486 i, cred: integer;487 s: string;488 OkEnabled: boolean;481 I, cred: Integer; 482 S: string; 483 OkEnabled: Boolean; 489 484 begin 490 485 if (OffscreenUser <> nil) and (OffscreenUser <> self) then … … 493 488 OffscreenUser := self; 494 489 495 if (DipCommand >= 0) and (Page = History[ me].n) then496 History[ me].Text[History[me].n] :=497 copy(DipCommandToString(me, DipMem[me].pContact,498 MyRO.Treaty[DipMem[ me].pContact], ClientMode, DipCommand, ReceivedOffer,490 if (DipCommand >= 0) and (Page = History[Me].N) then 491 History[Me].Text[History[Me].N] := 492 Copy(DipCommandToString(Me, DipMem[Me].pContact, 493 MyRO.Treaty[DipMem[Me].pContact], ClientMode, DipCommand, ReceivedOffer, 499 494 CurrentOffer), 1, 255); 500 495 501 FwdBtn.Visible := Page < History[ me].n;496 FwdBtn.Visible := Page < History[Me].N; 502 497 BwdBtn.Visible := Page >= 2; 503 if Page < History[ me].nthen504 OkEnabled := false498 if Page < History[Me].N then 499 OkEnabled := False 505 500 else if DipCommand = scDipOffer then 506 OkEnabled := Server(scDipOffer - sExecute, me, 0, CurrentOffer) >= rExecuted501 OkEnabled := Server(scDipOffer - sExecute, Me, 0, CurrentOffer) >= rExecuted 507 502 else 508 503 OkEnabled := DipCommand >= 0; … … 533 528 yPad1 + 41 + 42 * 2, $FFFFFF, $B0B0B0); 534 529 535 PaintNationPicture(xNationPicture0, yNationPicture, DipMem[ me].pContact);536 PaintNationPicture(xNationPicture1, yNationPicture, me);537 538 if History[ me].Text[Page - 1] <> '' then530 PaintNationPicture(xNationPicture0, yNationPicture, DipMem[Me].pContact); 531 PaintNationPicture(xNationPicture1, yNationPicture, Me); 532 533 if History[Me].Text[Page - 1] <> '' then 539 534 begin 540 535 FillSeamless(Offscreen.Canvas, xText0, yText0, wText, hText, 0, 0, Paper); 541 i:= Page - 1;542 if History[ me].Text[0] = '' then543 dec(i);544 if i< 16 then536 I := Page - 1; 537 if History[Me].Text[0] = '' then 538 Dec(I); 539 if I < 16 then 545 540 begin 546 541 Offscreen.Canvas.Font.Assign(RomanFont); 547 542 Offscreen.Canvas.TextOut 548 (xText0 + (wText - Offscreen.Canvas.TextWidth(RomanNo[ i])) div 2,549 yText0 + (hText - Offscreen.Canvas.TextHeight(RomanNo[ i])) div 2,550 RomanNo[ i]);543 (xText0 + (wText - Offscreen.Canvas.TextWidth(RomanNo[I])) div 2, 544 yText0 + (hText - Offscreen.Canvas.TextHeight(RomanNo[I])) div 2, 545 RomanNo[I]); 551 546 end 552 547 end; 553 548 FillSeamless(Offscreen.Canvas, xText1, yText1, wText, hText, 0, 0, Paper); 554 i:= Page;555 if History[ me].Text[0] = '' then556 dec(i);557 if i< 16 then549 I := Page; 550 if History[Me].Text[0] = '' then 551 Dec(I); 552 if I < 16 then 558 553 begin 559 554 Offscreen.Canvas.Font.Assign(RomanFont); 560 555 Offscreen.Canvas.TextOut 561 (xText1 + (wText - Offscreen.Canvas.TextWidth(RomanNo[ i])) div 2,562 yText1 + (hText - Offscreen.Canvas.TextHeight(RomanNo[ i])) div 2,563 RomanNo[ i]);556 (xText1 + (wText - Offscreen.Canvas.TextWidth(RomanNo[I])) div 2, 557 yText1 + (hText - Offscreen.Canvas.TextHeight(RomanNo[I])) div 2, 558 RomanNo[I]); 564 559 end; 565 560 with Offscreen.Canvas do 566 561 begin 567 562 Brush.Color := MainTexture.ColorBevelShade; 568 if History[ me].Text[Page - 1] <> '' then563 if History[Me].Text[Page - 1] <> '' then 569 564 begin 570 565 FillRect(Rect(xText0 + wText, yText0 + PaperShade, … … 584 579 { if Page=History[me].n then 585 580 begin // show attitude 586 s:=Phrases.Lookup('ATTITUDE',MyRO.EnemyReport[DipMem[me].pContact].Attitude);581 S:=Phrases.Lookup('ATTITUDE',MyRO.EnemyReport[DipMem[Me].pContact].Attitude); 587 582 //LoweredTextOut(Offscreen.Canvas,-1,MainTexture, 588 583 RisedTextOut(Offscreen.Canvas,xText0+wText div 2- 589 BiColorTextWidth(Offscreen.Canvas, s) div 2,yAttitude,s);590 s:=Phrases.Lookup('ATTITUDE',MyRO.Attitude[DipMem[me].pContact]);584 BiColorTextWidth(Offscreen.Canvas,S) div 2,yAttitude,S); 585 S:=Phrases.Lookup('ATTITUDE',MyRO.Attitude[DipMem[Me].pContact]); 591 586 //LoweredTextOut(Offscreen.Canvas,-1,MainTexture, 592 587 RisedTextOut(Offscreen.Canvas,xText1+wText div 2- 593 BiColorTextWidth(Offscreen.Canvas, s) div 2,yAttitude,s);588 BiColorTextWidth(Offscreen.Canvas,S) div 2,yAttitude,S); 594 589 end; } 595 590 596 if History[ me].Text[Page - 1] <> '' then597 SplitText(History[ me].Text[Page - 1], Rect(xText0, yText0, xText0 + wText,591 if History[Me].Text[Page - 1] <> '' then 592 SplitText(History[Me].Text[Page - 1], Rect(xText0, yText0, xText0 + wText, 598 593 yText0 + hText)); 599 if (Page < History[ me].n) or OkEnabled then600 SplitText(History[ me].Text[Page], Rect(xText1, yText1, xText1 + wText,594 if (Page < History[Me].N) or OkEnabled then 595 SplitText(History[Me].Text[Page], Rect(xText1, yText1, xText1 + wText, 601 596 yText1 + hText)); 602 597 603 598 // show credibility 604 599 Offscreen.Canvas.Font.Assign(UniFont[ftTiny]); 605 cred := MyRO.EnemyReport[DipMem[ me].pContact].Credibility;600 cred := MyRO.EnemyReport[DipMem[Me].pContact].Credibility; 606 601 case cred of 607 602 0 .. 49: 608 i:= 3;603 I := 3; 609 604 50 .. 90: 610 i:= 0;605 I := 0; 611 606 91 .. 100: 612 i:= 1;613 end; 614 PaintProgressBar(Offscreen.Canvas, i, xCred0, yCred0 + 17, (cred + 2) div 5,607 I := 1; 608 end; 609 PaintProgressBar(Offscreen.Canvas, I, xCred0, yCred0 + 17, (cred + 2) div 5, 615 610 0, 20, MainTexture); 616 s:= IntToStr(cred);611 S := IntToStr(cred); 617 612 RisedTextOut(Offscreen.Canvas, xCred0 + 10 - 618 (BiColorTextWidth(Offscreen.Canvas, s) + 1) div 2, yCred0, s);613 (BiColorTextWidth(Offscreen.Canvas, S) + 1) div 2, yCred0, S); 619 614 case MyRO.Credibility of 620 615 0 .. 49: 621 i:= 3;616 I := 3; 622 617 50 .. 90: 623 i:= 0;618 I := 0; 624 619 91 .. 100: 625 i:= 1;626 end; 627 PaintProgressBar(Offscreen.Canvas, i, xCred1, yCred1 + 17,620 I := 1; 621 end; 622 PaintProgressBar(Offscreen.Canvas, I, xCred1, yCred1 + 17, 628 623 (MyRO.Credibility + 2) div 5, 0, 20, MainTexture); 629 s:= IntToStr(MyRO.Credibility);624 S := IntToStr(MyRO.Credibility); 630 625 RisedTextOut(Offscreen.Canvas, xCred1 + 10 - 631 (BiColorTextWidth(Offscreen.Canvas, s) + 1) div 2, yCred1, s);626 (BiColorTextWidth(Offscreen.Canvas, S) + 1) div 2, yCred1, S); 632 627 633 628 MarkUsedOffscreen(ClientWidth, ClientHeight); 634 end; { OffscreenPaint }629 end; 635 630 636 631 procedure TNegoDlg.Initiate; 637 632 begin 638 History[ me].n:= 1;639 History[ me].Text[0] := '';633 History[Me].N := 1; 634 History[Me].Text[0] := ''; 640 635 end; 641 636 642 637 procedure TNegoDlg.Respond; 643 638 begin 644 History[ me].n:= 0;639 History[Me].N := 0; 645 640 end; 646 641 647 642 procedure TNegoDlg.FormMouseDown(Sender: TObject; Button: TMouseButton; 648 Shift: TShiftState; X, Y: integer);643 Shift: TShiftState; X, Y: Integer); 649 644 begin 650 645 if (X >= xNationPicture0) and (X < xNationPicture0 + 64) and 651 646 (Y >= yNationPicture) and (Y < yNationPicture + 48) then 652 NatStatDlg.ShowNewContent(FWindowMode or wmPersistent, DipMem[me].pContact)647 MainScreen.NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), DipMem[Me].pContact) 653 648 else if (X >= xNationPicture1) and (X < xNationPicture1 + 64) and 654 649 (Y >= yNationPicture) and (Y < yNationPicture + 48) then 655 NatStatDlg.ShowNewContent(FWindowMode or wmPersistent, me)650 MainScreen.NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), Me) 656 651 end; 657 652 658 653 procedure TNegoDlg.BwdBtnClick(Sender: TObject); 659 654 begin 660 dec(Page, 2);655 Dec(Page, 2); 661 656 SetButtonStates; 662 657 SmartUpdateContent; … … 665 660 procedure TNegoDlg.FwdBtnClick(Sender: TObject); 666 661 begin 667 inc(Page, 2);662 Inc(Page, 2); 668 663 SetButtonStates; 669 664 SmartUpdateContent; … … 672 667 procedure TNegoDlg.OkBtnClick(Sender: TObject); 673 668 begin 674 inc(History[me].n);669 Inc(History[Me].N); 675 670 if DipCommand = scDipOffer then 676 671 MainScreen.OfferCall(CurrentOffer) … … 698 693 procedure TNegoDlg.BuildCurrentOffer; 699 694 var 700 i: integer;695 I: Integer; 701 696 begin 702 697 CurrentOffer.nDeliver := 0; 703 698 CurrentOffer.nCost := 0; 704 for i:= 0 to 11 do705 if Delivers[ i] <> $FFFFFFFF then706 begin 707 CurrentOffer.Price[CurrentOffer.nDeliver] := Delivers[ i];708 inc(CurrentOffer.nDeliver);699 for I := 0 to 11 do 700 if Delivers[I] <> $FFFFFFFF then 701 begin 702 CurrentOffer.Price[CurrentOffer.nDeliver] := Delivers[I]; 703 Inc(CurrentOffer.nDeliver); 709 704 end; 710 for i:= 0 to 11 do711 if Costs[ i] <> $FFFFFFFF then705 for I := 0 to 11 do 706 if Costs[I] <> $FFFFFFFF then 712 707 begin 713 708 CurrentOffer.Price[CurrentOffer.nDeliver + CurrentOffer.nCost] := 714 Costs[ i];715 inc(CurrentOffer.nCost);709 Costs[I]; 710 Inc(CurrentOffer.nCost); 716 711 end; 717 712 end; … … 719 714 procedure TNegoDlg.WantClick(Sender: TObject); 720 715 var 721 a, i, max: integer;722 Price: cardinal;723 begin 724 if (Page <> History[ me].n) or (ClientMode = scDipCancelTreaty) or716 A, I, Max: Integer; 717 Price: Cardinal; 718 begin 719 if (Page <> History[Me].N) or (ClientMode = scDipCancelTreaty) or 725 720 (ClientMode = scDipBreak) then 726 exit;721 Exit; 727 722 if Costs[TButtonN(Sender).Tag and $FF] <> $FFFFFFFF then 728 723 Price := $FFFFFFFF // toggle off … … 732 727 begin 733 728 SimpleMessage(Phrases.Lookup('MAX2WANTS')); 734 exit729 Exit; 735 730 end; 736 731 Price := ButtonPrice[TButtonN(Sender).Tag and $FF]; 737 732 if not(Price shr 24 in OppoAllowed) then 738 exit;733 Exit; 739 734 case Price of 740 735 opCivilReport, opMilReport: 741 inc(Price, DipMem[me].pContact shl 16 + MyRO.Turn);736 Inc(Price, DipMem[Me].pContact shl 16 + MyRO.Turn); 742 737 // !!! choose player and year! 743 738 opMoney: … … 748 743 InputDlg.ShowModal; 749 744 if InputDlg.ModalResult <> mrOK then 750 exit;751 val(InputDlg.EInput.Text, a, i);752 if ( i <> 0) or (a <= 0) or (a>= MaxMoneyPrice) then753 exit;754 inc(Price, a);745 Exit; 746 val(InputDlg.EInput.Text, A, I); 747 if (I <> 0) or (A <= 0) or (A >= MaxMoneyPrice) then 748 Exit; 749 Inc(Price, A); 755 750 end; 756 751 opShipParts: 757 752 begin // choose type and number 758 753 if MyRO.NatBuilt[imSpacePort] = 0 then 759 with M essgExDlg do754 with MainScreen.MessgExDlg do 760 755 begin 761 756 OpenSound := 'WARNING_LOWSUPPORT'; … … 766 761 ShowModal; 767 762 if ModalResult <> mrOK then 768 exit763 Exit; 769 764 end; 770 M odalSelectDlg.ShowNewContent(wmModal, kEShipPart);771 if M odalSelectDlg.result < 0 then772 exit;773 inc(Price, ModalSelectDlg.result shl 16);774 max := MyRO.Ship[DipMem[me].pContact].Parts[ModalSelectDlg.result];765 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kEShipPart); 766 if MainScreen.ModalSelectDlg.Result < 0 then 767 Exit; 768 Inc(Price, MainScreen.ModalSelectDlg.Result shl 16); 769 Max := MyRO.Ship[DipMem[Me].pContact].Parts[MainScreen.ModalSelectDlg.Result]; 775 770 InputDlg.Caption := Phrases.Lookup('TITLE_NUMBER'); 776 771 InputDlg.EInput.Text := ''; … … 778 773 InputDlg.ShowModal; 779 774 if InputDlg.ModalResult <> mrOK then 780 exit;781 val(InputDlg.EInput.Text, a, i);782 if ( i <> 0) or (a<= 0) then783 exit;784 if a > max then785 a := max;786 if a> MaxShipPartPrice then787 a:= MaxShipPartPrice;788 inc(Price, a)775 Exit; 776 val(InputDlg.EInput.Text, A, I); 777 if (I <> 0) or (A <= 0) then 778 Exit; 779 if A > Max then 780 A := Max; 781 if A > MaxShipPartPrice then 782 A := MaxShipPartPrice; 783 Inc(Price, A); 789 784 end; 790 785 opAllTech: 791 786 begin // choose technology 792 M odalSelectDlg.ShowNewContent(wmModal, kChooseETech);793 if M odalSelectDlg.result < 0 then794 exit;795 if M odalSelectDlg.result = adAll then787 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kChooseETech); 788 if MainScreen.ModalSelectDlg.Result < 0 then 789 Exit; 790 if MainScreen.ModalSelectDlg.Result = adAll then 796 791 Price := opAllTech 797 792 else 798 Price := OpTech + M odalSelectDlg.result;793 Price := OpTech + MainScreen.ModalSelectDlg.Result; 799 794 end; 800 795 opAllModel: 801 796 begin // choose model 802 M odalSelectDlg.ShowNewContent(wmModal, kChooseEModel);803 if M odalSelectDlg.result < 0 then804 exit;805 if M odalSelectDlg.result = mixAll then797 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kChooseEModel); 798 if MainScreen.ModalSelectDlg.Result < 0 then 799 Exit; 800 if MainScreen.ModalSelectDlg.Result = mixAll then 806 801 Price := opAllModel 807 802 else 808 Price := OpModel + MyRO.EnemyModel[M odalSelectDlg.result].mix;803 Price := OpModel + MyRO.EnemyModel[MainScreen.ModalSelectDlg.Result].mix; 809 804 end; 810 805 opTreaty: 811 806 begin 812 if MyRO.Treaty[DipMem[ me].pContact] < trPeace then807 if MyRO.Treaty[DipMem[Me].pContact] < trPeace then 813 808 Price := opTreaty + trPeace 814 809 else 815 Price := opTreaty + MyRO.Treaty[DipMem[ me].pContact] + 1;810 Price := opTreaty + MyRO.Treaty[DipMem[Me].pContact] + 1; 816 811 end; 817 812 { opLowTreaty: 818 813 begin 819 if MyRO.Treaty[DipMem[ me].pContact]=trNone then Price:=opTreaty+trCeaseFire820 else Price:=opTreaty+MyRO.Treaty[DipMem[ me].pContact]-1;814 if MyRO.Treaty[DipMem[Me].pContact]=trNone then Price:=opTreaty+trCeaseFire 815 else Price:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1; 821 816 end } 822 817 end; … … 832 827 procedure TNegoDlg.OfferClick(Sender: TObject); 833 828 var 834 a, i, max: integer;835 Price: cardinal;836 begin 837 if (Page <> History[ me].n) or (ClientMode = scDipCancelTreaty) or829 A, I, Max: Integer; 830 Price: Cardinal; 831 begin 832 if (Page <> History[Me].N) or (ClientMode = scDipCancelTreaty) or 838 833 (ClientMode = scDipBreak) then 839 exit;834 Exit; 840 835 if Delivers[TButtonN(Sender).Tag and $FF] <> $FFFFFFFF then 841 836 Price := $FFFFFFFF // toggle off … … 845 840 begin 846 841 SimpleMessage(Phrases.Lookup('MAX2OFFERS')); 847 exit842 Exit; 848 843 end; 849 844 Price := ButtonPrice[TButtonN(Sender).Tag and $FF]; 850 845 if not(Price shr 24 in MyAllowed) then 851 exit;846 Exit; 852 847 case Price of 853 848 opCivilReport, opMilReport: 854 inc(Price, me shl 16 + MyRO.Turn); // !!! choose player and year!849 Inc(Price, Me shl 16 + MyRO.Turn); // !!! choose player and year! 855 850 opMoney: 856 851 begin // choose amount … … 860 855 InputDlg.ShowModal; 861 856 if InputDlg.ModalResult <> mrOK then 862 exit;863 val(InputDlg.EInput.Text, a, i);864 if ( i <> 0) or (a <= 0) or (a>= MaxMoneyPrice) then865 exit;866 if (Price = opMoney) and ( a> MyRO.Money) then867 a:= MyRO.Money;868 inc(Price, a);857 Exit; 858 val(InputDlg.EInput.Text, A, I); 859 if (I <> 0) or (A <= 0) or (A >= MaxMoneyPrice) then 860 Exit; 861 if (Price = opMoney) and (A > MyRO.Money) then 862 A := MyRO.Money; 863 Inc(Price, A); 869 864 end; 870 865 opShipParts: 871 866 begin // choose type and number 872 M odalSelectDlg.ShowNewContent(wmModal, kShipPart);873 if M odalSelectDlg.result < 0 then874 exit;875 inc(Price, ModalSelectDlg.result shl 16);876 max := MyRO.Ship[me].Parts[ModalSelectDlg.result];867 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kShipPart); 868 if MainScreen.ModalSelectDlg.Result < 0 then 869 Exit; 870 Inc(Price, MainScreen.ModalSelectDlg.Result shl 16); 871 Max := MyRO.Ship[Me].Parts[MainScreen.ModalSelectDlg.Result]; 877 872 InputDlg.Caption := Phrases.Lookup('TITLE_NUMBER'); 878 873 InputDlg.EInput.Text := ''; … … 880 875 InputDlg.ShowModal; 881 876 if InputDlg.ModalResult <> mrOK then 882 exit;883 val(InputDlg.EInput.Text, a, i);884 if ( i <> 0) or (a<= 0) then885 exit;886 if a > max then887 a := max;888 if a> MaxShipPartPrice then889 a:= MaxShipPartPrice;890 inc(Price, a)877 Exit; 878 val(InputDlg.EInput.Text, A, I); 879 if (I <> 0) or (A <= 0) then 880 Exit; 881 if A > Max then 882 A := Max; 883 if A > MaxShipPartPrice then 884 A := MaxShipPartPrice; 885 Inc(Price, A); 891 886 end; 892 887 opAllTech: 893 888 begin // choose technology 894 M odalSelectDlg.ShowNewContent(wmModal, kChooseTech);895 if M odalSelectDlg.result < 0 then896 exit;897 if M odalSelectDlg.result = adAll then889 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kChooseTech); 890 if MainScreen.ModalSelectDlg.Result < 0 then 891 Exit; 892 if MainScreen.ModalSelectDlg.Result = adAll then 898 893 Price := opAllTech 899 894 else 900 Price := OpTech + M odalSelectDlg.result;895 Price := OpTech + MainScreen.ModalSelectDlg.Result; 901 896 end; 902 897 opAllModel: 903 898 begin // choose model 904 M odalSelectDlg.ShowNewContent(wmModal, kChooseModel);905 if M odalSelectDlg.result < 0 then906 exit;907 if M odalSelectDlg.result = mixAll then899 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kChooseModel); 900 if MainScreen.ModalSelectDlg.Result < 0 then 901 Exit; 902 if MainScreen.ModalSelectDlg.Result = mixAll then 908 903 Price := opAllModel 909 904 else 910 Price := OpModel + M odalSelectDlg.result905 Price := OpModel + MainScreen.ModalSelectDlg.Result; 911 906 end; 912 907 opTreaty: 913 908 begin 914 if MyRO.Treaty[DipMem[ me].pContact] < trPeace then909 if MyRO.Treaty[DipMem[Me].pContact] < trPeace then 915 910 Price := opTreaty + trPeace 916 911 else 917 Price := opTreaty + MyRO.Treaty[DipMem[ me].pContact] + 1;912 Price := opTreaty + MyRO.Treaty[DipMem[Me].pContact] + 1; 918 913 end; 919 914 { opLowTreaty: 920 915 begin 921 if MyRO.Treaty[DipMem[ me].pContact]=trNone then Price:=opTreaty+trCeaseFire922 else Price:=opTreaty+MyRO.Treaty[DipMem[ me].pContact]-1;916 if MyRO.Treaty[DipMem[Me].pContact]=trNone then Price:=opTreaty+trCeaseFire 917 else Price:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1; 923 918 end } 924 919 end; … … 934 929 procedure TNegoDlg.FastBtnClick(Sender: TObject); 935 930 var 936 NewCommand: cardinal;937 begin 938 if Page <> History[ me].nthen939 exit;931 NewCommand: Cardinal; 932 begin 933 if Page <> History[Me].N then 934 Exit; 940 935 NewCommand := TButtonN(Sender).Tag and $FF + scDipStart; 941 936 if not(NewCommand - scDipStart in CommandAllowed) then 942 exit;937 Exit; 943 938 if (NewCommand = scDipCancelTreaty) and 944 (MyRO.Turn < MyRO.LastCancelTreaty[DipMem[ me].pContact] + CancelTreatyTurns)939 (MyRO.Turn < MyRO.LastCancelTreaty[DipMem[Me].pContact] + CancelTreatyTurns) 945 940 then 946 941 begin 947 942 SimpleMessage(Phrases.Lookup('CANCELTREATYRUSH')); 948 exit;943 Exit; 949 944 end; 950 945 if (NewCommand = scDipOffer) and ((ClientMode = scDipCancelTreaty) or -
TabularUnified branches/highdpi/LocalPlayer/PVSB.pas ¶
r349 r465 5 5 6 6 uses 7 UDpiControls, {$IFDEF WINDOWS} 8 Windows, 9 {$ENDIF} 7 UDpiControls, {$IFDEF WINDOWS}Windows,{$ENDIF} 10 8 Classes, Controls, Forms, LCLIntf, LCLType, LMessages, Messages, SysUtils, 11 9 StdCtrls, Math; … … 32 30 procedure Init(Max, PageSize: Integer); 33 31 procedure SetPos(Pos: Integer); 34 function Process(const Msg: TMessage): boolean;32 function Process(const Msg: TMessage): Boolean; 35 33 function ProcessMouseWheel(Delta: Integer): Boolean; 36 procedure Show(Visible: boolean);34 procedure Show(Visible: Boolean); 37 35 procedure EndSB; 38 36 procedure SetBorderSpacing(Top, Right, Bottom: Integer); … … 65 63 end; 66 64 67 function TPVScrollBar.Process(const Msg: TMessage): boolean;65 function TPVScrollBar.Process(const Msg: TMessage): Boolean; 68 66 var 69 NewPos: integer;67 NewPos: Integer; 70 68 begin 71 69 if Max < ScrollBar.PageSize then 72 result := false70 Result := False 73 71 else 74 72 begin 75 73 if (Msg.wParam and $ffff) in [SB_THUMBPOSITION, SB_THUMBTRACK] then 76 74 begin 77 result := ((Msg.wParam shr 16) and $ffff) <> ScrollBar.Position;75 Result := ((Msg.wParam shr 16) and $ffff) <> ScrollBar.Position; 78 76 ScrollBar.Position := (Msg.wParam shr 16) and $ffff; 79 77 end else begin … … 94 92 if NewPos > Max - ScrollBar.PageSize + 1 then 95 93 NewPos := Max - ScrollBar.PageSize + 1; 96 result := NewPos <> ScrollBar.Position;94 Result := NewPos <> ScrollBar.Position; 97 95 if (NewPos <> ScrollBar.Position) or ((Msg.wParam and $ffff) = SB_ENDSCROLL) then 98 96 begin … … 105 103 function TPVScrollBar.ProcessMouseWheel(Delta: Integer): Boolean; 106 104 var 107 NewPos: integer;105 NewPos: Integer; 108 106 begin 109 107 if Max < ScrollBar.PageSize then Result := False … … 120 118 end; 121 119 122 procedure TPVScrollBar.Show(Visible: boolean);120 procedure TPVScrollBar.Show(Visible: Boolean); 123 121 begin 124 122 if not Visible or (Max < ScrollBar.PageSize) then -
TabularUnified branches/highdpi/LocalPlayer/Rates.pas ¶
r361 r465 5 5 6 6 uses 7 UDpiControls, Protocol, ScreenTools, BaseWin, LCLIntf, LCLType, 8 9 SysUtils, Classes, Graphics, Controls, Forms, 10 ButtonB, ButtonC; 7 UDpiControls, Protocol, ScreenTools, BaseWin, LCLIntf, LCLType, SysUtils, Classes, Graphics, 8 Controls, Forms, ButtonB, ButtonC; 11 9 12 10 type … … 23 21 public 24 22 procedure OffscreenPaint; override; 25 procedure ShowNewContent(NewMode: integer); 26 end; 27 28 var 29 RatesDlg: TRatesDlg; 23 procedure ShowNewContent(NewMode: TWindowMode); 24 end; 25 30 26 31 27 implementation … … 47 43 procedure TRatesDlg.OffscreenPaint; 48 44 var 49 p, x, y, current, max, i: integer;50 s, s1: string;45 P, X, Y, current, Max, I: Integer; 46 S, s1: string; 51 47 begin 52 48 if (OffscreenUser <> nil) and (OffscreenUser <> self) then … … 65 61 BtnFrame(Offscreen.Canvas, CloseBtn.BoundsRect, MainTexture); 66 62 Offscreen.Canvas.Font.Assign(UniFont[ftCaption]); 67 s:= Phrases.Lookup('TITLE_RATES');63 S := Phrases.Lookup('TITLE_RATES'); 68 64 RisedTextOut(Offscreen.Canvas, 69 (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s)) div 2 - 1, 7, s);70 71 if MyRO.Wonder[woLiberty].EffectiveOwner = me then72 s:= Phrases.Lookup('NORATES')73 else 74 s:= Phrases.Lookup('RATES');65 (ClientWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2 - 1, 7, S); 66 67 if MyRO.Wonder[woLiberty].EffectiveOwner = Me then 68 S := Phrases.Lookup('NORATES') 69 else 70 S := Phrases.Lookup('RATES'); 75 71 Offscreen.Canvas.Font.Assign(UniFont[ftNormal]); 76 p := pos('\', s);77 if p= 0 then78 RisedTextOut(Offscreen.Canvas, (ClientWidth - BiColorTextWidth(Canvas, s))79 div 2, 114, s)80 else 81 begin 82 s1 := copy(s, 1, p- 1);72 P := Pos('\', S); 73 if P = 0 then 74 RisedTextOut(Offscreen.Canvas, (ClientWidth - BiColorTextWidth(Canvas, S)) 75 div 2, 114, S) 76 else 77 begin 78 s1 := Copy(S, 1, P - 1); 83 79 RisedTextOut(Offscreen.Canvas, 84 80 (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s1)) div 2, 85 81 114 - MessageLineSpacing div 2, s1); 86 s1 := copy(s, p+ 1, 255);82 s1 := Copy(S, P + 1, 255); 87 83 RisedTextOut(Offscreen.Canvas, 88 84 (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s1)) div 2, … … 91 87 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 92 88 93 if MyRO.Wonder[woLiberty].EffectiveOwner = me then89 if MyRO.Wonder[woLiberty].EffectiveOwner = Me then 94 90 begin 95 91 GlowFrame(Offscreen, ClientWidth div 2 - xSizeBig div 2, 52, xSizeBig, 96 ySizeBig, Tribe[ me].Color);97 DpiBit Canvas(Offscreen.Canvas, ClientWidth div 2 - xSizeBig div 2, 52,92 ySizeBig, Tribe[Me].Color); 93 DpiBitBltCanvas(Offscreen.Canvas, ClientWidth div 2 - xSizeBig div 2, 52, 98 94 xSizeBig, ySizeBig, BigImp.Canvas, (woLiberty mod 7) * xSizeBig, 99 95 (woLiberty div 7 + SystemIconLines) * ySizeBig); … … 103 99 // ImageOp_CBC(Offscreen,Templates,260,40,145,112,36,36,$404000,$8B8BEB); 104 100 105 s:= Phrases.Lookup('SCIENCE');106 RisedTextOut(Offscreen.Canvas, 107 16 + 120 - BiColorTextWidth(Offscreen.Canvas, s), 44, s);108 s:= Format('%d%%', [100 - MyRO.TaxRate - MyRO.LuxRate]);109 RisedTextOut(Offscreen.Canvas, 110 16 + 120 - BiColorTextWidth(Offscreen.Canvas, s), 60, s);101 S := Phrases.Lookup('SCIENCE'); 102 RisedTextOut(Offscreen.Canvas, 103 16 + 120 - BiColorTextWidth(Offscreen.Canvas, S), 44, S); 104 S := Format('%d%%', [100 - MyRO.TaxRate - MyRO.LuxRate]); 105 RisedTextOut(Offscreen.Canvas, 106 16 + 120 - BiColorTextWidth(Offscreen.Canvas, S), 60, S); 111 107 // PaintProgressBar(Offscreen.Canvas,2,16,81,(100-MyRO.LuxRate-MyRO.TaxRate)*120 div 100,0,120,MainTexture); 112 108 113 109 // reverse progress bar for science 114 x:= 16;115 y:= 81;110 X := 16; 111 Y := 81; 116 112 current := (100 - MyRO.LuxRate - MyRO.TaxRate) * 120 div 100; 117 max := 120;118 Frame(Offscreen.Canvas, x - 1, y - 1, x + max, y+ 7, $000000, $000000);119 RFrame(Offscreen.Canvas, x - 2, y - 2, x + max + 1, y+ 8,113 Max := 120; 114 Frame(Offscreen.Canvas, X - 1, Y - 1, X + Max, Y + 7, $000000, $000000); 115 RFrame(Offscreen.Canvas, X - 2, Y - 2, X + Max + 1, Y + 8, 120 116 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 121 117 with Offscreen.Canvas do 122 118 begin 123 for i:= 0 to current div 8 - 1 do124 DpiBit Canvas(Offscreen.Canvas, x + max - 8 - i * 8, y, 8, 7,119 for I := 0 to current div 8 - 1 do 120 DpiBitBltCanvas(Offscreen.Canvas, X + Max - 8 - I * 8, Y, 8, 7, 125 121 HGrSystem.Data.Canvas, 104, 9 + 8 * 2); 126 DpiBit Canvas(Offscreen.Canvas, x + max - current, y, current - 8 * (current div 8), 7,122 DpiBitBltCanvas(Offscreen.Canvas, X + Max - current, Y, current - 8 * (current div 8), 7, 127 123 HGrSystem.Data.Canvas, 104, 9 + 8 * 2); 128 124 Brush.Color := $000000; 129 FillRect(Rect( x, y, x + max - current, y+ 7));125 FillRect(Rect(X, Y, X + Max - current, Y + 7)); 130 126 Brush.Style := bsClear; 131 127 end; 132 128 133 129 RisedTextOut(Offscreen.Canvas, 16 + 160, 44, Phrases.Lookup('LUX')); 134 s:= Format('%d%%', [MyRO.LuxRate]);135 RisedTextOut(Offscreen.Canvas, 136 16 + 160 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 60, s);130 S := Format('%d%%', [MyRO.LuxRate]); 131 RisedTextOut(Offscreen.Canvas, 132 16 + 160 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 60, S); 137 133 PaintProgressBar(Offscreen.Canvas, 5, 16 + 160, 81, 138 134 MyRO.LuxRate * 120 div 100, 0, 120, MainTexture); … … 145 141 MainTexture.ColorBevelLight); 146 142 RisedTextOut(Offscreen.Canvas, 16 + 80, 164, Phrases.Lookup('TAXRATE')); 147 s:= Format('%d%%', [MyRO.TaxRate]);143 S := Format('%d%%', [MyRO.TaxRate]); 148 144 RisedTextOut(Offscreen.Canvas, 149 16 + 80 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 180, s);145 16 + 80 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 180, S); 150 146 PaintProgressBar(Offscreen.Canvas, 0, 16 + 80, 201, 151 147 MyRO.TaxRate * 120 div 100, 0, 120, MainTexture); … … 157 153 end; 158 154 159 procedure TRatesDlg.ShowNewContent(NewMode: integer);155 procedure TRatesDlg.ShowNewContent(NewMode: TWindowMode); 160 156 begin 161 157 inherited ShowNewContent(NewMode); … … 164 160 procedure TRatesDlg.FormShow(Sender: TObject); 165 161 begin 166 if MyRO.Wonder[woLiberty].EffectiveOwner = me then 167 begin 168 ScienceBtn.Visible := false; 169 LuxBtn.Visible := false; 162 Caption := Phrases.Lookup('TITLE_RATES'); 163 if MyRO.Wonder[woLiberty].EffectiveOwner = Me then 164 begin 165 ScienceBtn.Visible := False; 166 LuxBtn.Visible := False; 170 167 end 171 168 else 172 169 begin 173 ScienceBtn.Visible := true;174 LuxBtn.Visible := true;170 ScienceBtn.Visible := True; 171 LuxBtn.Visible := True; 175 172 end; 176 173 OffscreenPaint; … … 184 181 procedure TRatesDlg.TaxLuxBtnClick(Sender: TObject); 185 182 var 186 NewTax, NewLux: integer;183 NewTax, NewLux: Integer; 187 184 begin 188 185 NewTax := MyRO.TaxRate div 10; … … 191 188 begin 192 189 if NewTax < 10 then 193 inc(NewTax);190 Inc(NewTax); 194 191 if NewTax + NewLux > 10 then 195 dec(NewLux);192 Dec(NewLux); 196 193 end 197 194 else if (Sender = TaxDownBtn) and (NewTax > 0) then 198 dec(NewTax)195 Dec(NewTax) 199 196 else if (Sender = ScienceBtn) and (NewLux > 0) then 200 dec(NewLux)197 Dec(NewLux) 201 198 else if (Sender = LuxBtn) and (NewLux + NewTax < 100) then 202 inc(NewLux);203 if Server(sSetRates, me, NewTax + NewLux shl 4, nil^) <> eNotChanged then199 Inc(NewLux); 200 if Server(sSetRates, Me, NewTax + NewLux shl 4, nil^) <> eNotChanged then 204 201 begin 205 202 CityOptimizer_BeginOfTurn; 206 203 SmartUpdateContent; 207 MainScreen.UpdateViews( true);204 MainScreen.UpdateViews(True); 208 205 end; 209 206 end; -
TabularUnified branches/highdpi/LocalPlayer/Select.lfm ¶
r246 r465 1 1 object ListDlg: TListDlg 2 2 Left = 290 3 Height = 262 3 4 Top = 145 5 Width = 381 4 6 BorderIcons = [] 5 7 BorderStyle = bsNone … … 7 9 ClientWidth = 381 8 10 Color = clBtnFace 9 Font.Charset = DEFAULT_CHARSET11 DesignTimePPI = 144 10 12 Font.Color = clWindowText 11 Font.Height = - 1313 Font.Height = -20 12 14 Font.Name = 'MS Sans Serif' 13 Font.Style = []14 15 FormStyle = fsStayOnTop 15 16 OnCloseQuery = FormCloseQuery … … 17 18 OnDestroy = FormDestroy 18 19 OnKeyDown = FormKeyDown 19 OnMouseWheel = FormMouseWheel20 20 OnMouseDown = PaintBox1MouseDown 21 21 OnMouseMove = PaintBox1MouseMove 22 OnMouseWheel = FormMouseWheel 22 23 OnPaint = FormPaint 23 24 OnShow = FormShow 24 PixelsPerInch = 9625 LCLVersion = '2.2.2.0' 25 26 Scaled = False 26 27 object CloseBtn: TButtonB 27 28 Left = 343 29 Height = 25 28 30 Top = 6 29 31 Width = 25 30 Height = 2531 32 Down = False 32 33 Permanent = False … … 37 38 Tag = 2 38 39 Left = 344 40 Height = 25 39 41 Top = 224 40 42 Width = 25 41 Height = 2542 43 Down = False 43 44 Permanent = True … … 48 49 Tag = 1 49 50 Left = 312 51 Height = 25 50 52 Top = 224 51 53 Width = 25 52 Height = 2553 54 Down = False 54 55 Permanent = True … … 58 59 object Layer0Btn: TButtonB 59 60 Left = 280 61 Height = 25 60 62 Top = 224 61 63 Width = 25 62 Height = 2563 64 Down = False 64 65 Permanent = True … … 68 69 object ToggleBtn: TButtonB 69 70 Left = 13 71 Height = 25 70 72 Top = 6 71 73 Width = 25 72 Height = 2573 74 Down = False 74 75 Permanent = False -
TabularUnified branches/highdpi/LocalPlayer/Select.pas ¶
r378 r465 5 5 6 6 uses 7 UDpiControls, Protocol, ClientTools, Term, ScreenTools, IsoEngine, PVSB, BaseWin,7 UDpiControls, Protocol, ClientTools, ScreenTools, PVSB, BaseWin, 8 8 LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, 9 9 ExtCtrls, ButtonB, ButtonBase, Menus, Types; … … 27 27 ToggleBtn: TButtonB; 28 28 Popup: TDpiPopupMenu; 29 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 29 30 procedure FormMouseWheel(Sender: TObject; Shift: TShiftState; 30 31 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); 31 32 procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; 32 x, y: integer);33 X, Y: Integer); 33 34 procedure FormCreate(Sender: TObject); 34 35 procedure FormDestroy(Sender: TObject); 35 36 procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 36 Shift: TShiftState; x, y: integer);37 Shift: TShiftState; X, Y: Integer); 37 38 procedure FormPaint(Sender: TObject); 38 39 procedure CloseBtnClick(Sender: TObject); 39 procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);40 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); 40 41 procedure FormShow(Sender: TObject); 41 42 procedure ModeBtnClick(Sender: TObject); 42 43 procedure ToggleBtnClick(Sender: TObject); 43 procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);44 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 44 45 procedure PlayerClick(Sender: TObject); 45 46 private … … 49 50 cixProject: Integer; 50 51 pView: Integer; 51 Sel : Integer;52 Selected: Integer; 52 53 DispLines: Integer; 53 54 Layer: Integer; … … 55 56 TechNameSpace: Integer; 56 57 ScienceNation: Integer; 57 sb: TPVScrollbar; 58 Lines, FirstShrinkedLine: array [0 .. MaxLayer - 1] of integer; 59 code: array [0 .. MaxLayer - 1, 0 .. 4095] of integer; 60 Column: array [0 .. nPl - 1] of integer; 58 ScrollBar: TPVScrollbar; 59 Lines: array [0 .. MaxLayer - 1] of Integer; 60 FirstShrinkedLine: array [0 .. MaxLayer - 1] of Integer; 61 Code: array [0 .. MaxLayer - 1, 0 .. 4095] of Integer; 62 Column: array [0 .. nPl - 1] of Integer; 61 63 Closable: Boolean; 62 64 MultiPage: Boolean; … … 64 66 procedure ScrollBarUpdate(Sender: TObject); 65 67 procedure InitLines; 66 procedure line(ca: TDpiCanvas; l: integer; NonText, lit: boolean);67 function RenameCity(cix: integer): boolean;68 function RenameModel(mix: integer): boolean;68 procedure Line(ca: TDpiCanvas; L: Integer; NonText, lit: Boolean); 69 function RenameCity(cix: Integer): Boolean; 70 function RenameModel(mix: Integer): Boolean; 69 71 procedure OnScroll(var Msg: TMessage); message WM_VSCROLL; 70 72 procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE; 71 73 public 72 result: integer;73 function OnlyChoice(TestKind: TListKind): integer;74 Result: Integer; 75 function OnlyChoice(TestKind: TListKind): Integer; 74 76 // -2=empty, -1=ambiguous, other=only choice 75 77 procedure OffscreenPaint; override; 76 procedure ShowNewContent(NewMode: integer; ListKind: TListKind);77 procedure ShowNewContent_CityProject(NewMode , cix: integer);78 procedure ShowNewContent_MilReport(NewMode , p: integer);78 procedure ShowNewContent(NewMode: TWindowMode; ListKind: TListKind); 79 procedure ShowNewContent_CityProject(NewMode: TWindowMode; cix: Integer); 80 procedure ShowNewContent_MilReport(NewMode: TWindowMode; P: Integer); 79 81 procedure EcoChange; 80 82 procedure TechChange; … … 90 92 adAll = $10000; 91 93 92 var93 ListDlg: TListDlg;94 ModalSelectDlg: TModalSelectDlg;95 96 94 97 95 implementation 98 96 99 97 uses 100 CityScreen, Help, UnitStat, Tribes, Inp;98 Term, CityScreen, Help, UnitStat, Tribes, Inp, CmdList; 101 99 102 100 {$R *.lfm} … … 111 109 inherited; 112 110 Canvas.Font.Assign(UniFont[ftNormal]); 113 sb:= TPVScrollbar.Create(Self);114 sb.SetBorderSpacing(36, 10, 36);115 sb.OnUpdate := ScrollBarUpdate;111 ScrollBar := TPVScrollbar.Create(Self); 112 ScrollBar.SetBorderSpacing(36, 10, 36); 113 ScrollBar.OnUpdate := ScrollBarUpdate; 116 114 InitButtons; 117 115 Kind := kMission; … … 127 125 procedure TListDlg.FormDestroy(Sender: TObject); 128 126 begin 129 FreeAndNil( sb);127 FreeAndNil(ScrollBar); 130 128 FreeAndNil(ScienceNationDotBuffer); 131 129 end; … … 133 131 procedure TListDlg.CloseBtnClick(Sender: TObject); 134 132 begin 135 Closable := true;133 Closable := True; 136 134 Close; 137 135 end; 138 136 139 procedure TListDlg.FormCloseQuery(Sender: TObject; var CanClose: boolean);137 procedure TListDlg.FormCloseQuery(Sender: TObject; var CanClose: Boolean); 140 138 begin 141 139 CanClose := Closable or not(Kind in MustChooseKind); … … 145 143 begin 146 144 { TODO: Handled by MouseWheel event 147 if sb.Process(Msg) then begin148 Sel := -2;149 SmartUpdateContent( true);145 if ScrollBar.Process(Msg) then begin 146 Selected := -2; 147 SmartUpdateContent(True); 150 148 end; 151 149 } … … 154 152 procedure TListDlg.OnMouseLeave(var Msg: TMessage); 155 153 begin 156 if not Closable and (Sel <> -2) then157 begin 158 line(Canvas, Sel, false, false);159 Sel := -2;154 if not Closable and (Selected <> -2) then 155 begin 156 Line(Canvas, Selected, False, False); 157 Selected := -2; 160 158 end; 161 159 end; … … 163 161 procedure TListDlg.FormPaint(Sender: TObject); 164 162 var 165 s: string;163 S: string; 166 164 begin 167 165 inherited; 168 166 Canvas.Font.Assign(UniFont[ftNormal]); 169 if Sel <> -2 then170 line(Canvas, Sel, false, true);171 s:= '';167 if Selected <> -2 then 168 Line(Canvas, Selected, False, True); 169 S := ''; 172 170 if (Kind = kAdvance) and (MyData.FarTech <> adNone) then 173 s:= Format(Phrases.Lookup('TECHFOCUS'),171 S := Format(Phrases.Lookup('TECHFOCUS'), 174 172 [Phrases.Lookup('ADVANCES', MyData.FarTech)]) 175 173 else if Kind = kModels then 176 s := Tribe[me].TPhrase('SHORTNAME')174 S := Tribe[Me].TPhrase('SHORTNAME') 177 175 else if Kind = kEModels then 178 s:= Tribe[pView].TPhrase('SHORTNAME') + ' (' +176 S := Tribe[pView].TPhrase('SHORTNAME') + ' (' + 179 177 TurnToString(MyRO.EnemyReport[pView].TurnOfMilReport) + ')'; 180 if s<> '' then178 if S <> '' then 181 179 LoweredTextOut(Canvas, -1, MainTexture, 182 (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, 31, s);180 (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, 31, S); 183 181 if not MultiPage and (Kind in [kProject, kAdvance, kFarAdvance]) and not Phrases2FallenBackToEnglish 184 182 then 185 183 begin 186 s:= Phrases2.Lookup('SHIFTCLICK');184 S := Phrases2.Lookup('SHIFTCLICK'); 187 185 LoweredTextOut(Canvas, -2, MainTexture, 188 (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, ClientHeight - 29, s);189 end; 190 end; 191 192 procedure TListDlg. line(ca: TDpiCanvas; l: integer; NonText, lit: boolean);186 (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, ClientHeight - 29, S); 187 end; 188 end; 189 190 procedure TListDlg.Line(ca: TDpiCanvas; L: Integer; NonText, lit: Boolean); 193 191 // paint a line 194 192 195 procedure DisplayProject( x, y, pix: integer);193 procedure DisplayProject(X, Y, pix: Integer); 196 194 begin 197 195 if pix and (cpType or cpImp) = 0 then 198 with Tribe[ me].ModelPicture[pix and cpIndex] do199 Sprite( offscreen, HGr, x, y, 64, 48, pix mod 10 * 65 + 1,196 with Tribe[Me].ModelPicture[pix and cpIndex] do 197 Sprite(Offscreen, HGr, X, Y, 64, 48, pix mod 10 * 65 + 1, 200 198 pix div 10 * 49 + 1) 201 199 else 202 200 begin 203 Frame( offscreen.Canvas, x + (16 - 1), y + (16 - 2), x+ (16 + xSizeSmall),204 y+ (16 - 1 + ySizeSmall), MainTexture.ColorBevelLight,201 Frame(Offscreen.Canvas, X + (16 - 1), Y + (16 - 2), X + (16 + xSizeSmall), 202 Y + (16 - 1 + ySizeSmall), MainTexture.ColorBevelLight, 205 203 MainTexture.ColorBevelShade); 206 204 if pix and cpType = 0 then 207 205 if (pix and cpIndex = imPalace) and (MyRO.Government <> gAnarchy) then 208 DpiBit Canvas(offscreen.Canvas, x + 16, y+ (16 - 1), xSizeSmall,206 DpiBitBltCanvas(Offscreen.Canvas, X + 16, Y + (16 - 1), xSizeSmall, 209 207 ySizeSmall, SmallImp.Canvas, (MyRO.Government - 1) * 210 208 xSizeSmall, ySizeSmall) 211 209 else 212 DpiBit Canvas(offscreen.Canvas, x + 16, y+ (16 - 1), xSizeSmall,210 DpiBitBltCanvas(Offscreen.Canvas, X + 16, Y + (16 - 1), xSizeSmall, 213 211 ySizeSmall, SmallImp.Canvas, pix and cpIndex mod 7 * 214 212 xSizeSmall, (pix and cpIndex + SystemIconLines * 7) div 7 * 215 213 ySizeSmall) 216 214 else 217 DpiBit Canvas(offscreen.Canvas, x + 16, y+ (16 - 1), xSizeSmall,215 DpiBitBltCanvas(Offscreen.Canvas, X + 16, Y + (16 - 1), xSizeSmall, 218 216 ySizeSmall, SmallImp.Canvas, (3 + pix and cpIndex) * 219 217 xSizeSmall, 0); … … 221 219 end; 222 220 223 procedure ReplaceText( x, y, Color: integer; s: string);221 procedure ReplaceText(X, Y, Color: Integer; S: string); 224 222 var 225 223 TextSize: TSize; … … 227 225 if ca = Canvas then 228 226 begin 229 TextSize.cx := BiColorTextWidth(ca, s);230 TextSize.cy := ca.TextHeight( s);231 if y+ TextSize.cy >= TitleHeight + InnerHeight then232 TextSize.cy := TitleHeight + InnerHeight - y;233 Fill(ca, x, y, TextSize.cx, TextSize.cy, (Maintexture.Width - ClientWidth)227 TextSize.cx := BiColorTextWidth(ca, S); 228 TextSize.cy := ca.TextHeight(S); 229 if Y + TextSize.cy >= TitleHeight + InnerHeight then 230 TextSize.cy := TitleHeight + InnerHeight - Y; 231 Fill(ca, X, Y, TextSize.cx, TextSize.cy, (Maintexture.Width - ClientWidth) 234 232 div 2, (Maintexture.Height - ClientHeight) div 2); 235 233 end; 236 LoweredTextOut(ca, Color, MainTexture, x, y, s);234 LoweredTextOut(ca, Color, MainTexture, X, Y, S); 237 235 end; 238 236 239 237 var 240 icon, ofs, x, y, y0, lix, i, j, TextColor, Available, first, test,241 FutureCount, growth, TrueFood, TrueProd: integer;238 icon, ofs, X, Y, y0, lix, I, J, TextColor, Available, first, Test, 239 FutureCount, growth, TrueFood, TrueProd: Integer; 242 240 CityReport: TCityReportNew; 243 241 mox: ^TModelInfo; 244 s, number: string;245 CanGrow: boolean;246 begin 247 lix := code[Layer, sb.Position + l];248 y0 := 2 + ( l+ 1) * LineDistance;249 if sb.Position + l>= FirstShrinkedLine[Layer] then250 ofs := ( sb.Position + l- FirstShrinkedLine[Layer]) and 1 * 33242 S, number: string; 243 CanGrow: Boolean; 244 begin 245 lix := Code[Layer, ScrollBar.Position + L]; 246 y0 := 2 + (L + 1) * LineDistance; 247 if ScrollBar.Position + L >= FirstShrinkedLine[Layer] then 248 ofs := (ScrollBar.Position + L - FirstShrinkedLine[Layer]) and 1 * 33 251 249 else { if FirstShrinkedLine[Layer]<Lines[Layer] then } 252 250 ofs := 33; … … 255 253 with MyCity[lix] do 256 254 begin 257 x:= 104 - 76;258 y:= y0;255 X := 104 - 76; 256 Y := y0; 259 257 if ca = Canvas then 260 258 begin 261 x := x+ SideFrame;262 y := y+ TitleHeight;259 X := X + SideFrame; 260 Y := Y + TitleHeight; 263 261 end; 264 262 if lit then … … 266 264 else 267 265 TextColor := -1; 268 s:= CityName(ID);269 while BiColorTextWidth(ca, s) > CityNameSpace do270 delete(s, length(s), 1);271 ReplaceText( x + 15, y, TextColor, s);266 S := CityName(ID); 267 while BiColorTextWidth(ca, S) > CityNameSpace do 268 Delete(S, Length(S), 1); 269 ReplaceText(X + 15, Y, TextColor, S); 272 270 273 271 if NonText then 274 with offscreen.Canvas do272 with Offscreen.Canvas do 275 273 begin // city size 276 brush.Color := $000000;277 fillrect(rect(x - 4 - 11, y + 1, x - 4 + 13, y+ 21));278 brush.Color := $FFFFFF;279 fillrect(rect(x - 4 - 12, y, x - 4 + 12, y+ 20));280 brush.style := bsClear;274 Brush.Color := $000000; 275 FillRect(rect(X - 4 - 11, Y + 1, X - 4 + 13, Y + 21)); 276 Brush.Color := $FFFFFF; 277 FillRect(rect(X - 4 - 12, Y, X - 4 + 12, Y + 20)); 278 Brush.style := bsClear; 281 279 Font.Color := $000000; 282 s := inttostr(MyCity[lix].Size);283 TextOut( x - 4 - textwidth(s) div 2, y, s);280 S := IntToStr(MyCity[lix].Size); 281 TextOut(X - 4 - textwidth(S) div 2, Y, S); 284 282 end; 285 283 … … 287 285 begin 288 286 first := -1; 289 for j:= 0 to nCityEventPriority - 1 do290 if (Flags and CityRepMask and CityEventPriority[ j] <> 0) then291 begin 292 first := j;293 Break 287 for J := 0 to nCityEventPriority - 1 do 288 if (Flags and CityRepMask and CityEventPriority[J] <> 0) then 289 begin 290 first := J; 291 Break; 294 292 end; 295 293 if first >= 0 then 296 294 begin 297 i:= 0;298 test := 1;299 while test < CityEventPriority[first] do300 begin 301 inc(i);302 inc(test, test)303 end; 304 s := CityEventName(i);295 I := 0; 296 Test := 1; 297 while Test < CityEventPriority[first] do 298 begin 299 Inc(I); 300 Inc(Test, Test); 301 end; 302 S := CityEventName(I); 305 303 { if CityEventPriority[first]=chNoGrowthWarning then 306 304 if Built[imAqueduct]=0 then 307 s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])308 else begin s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); i:=17 end; }309 ReplaceText( x + (CityNameSpace + 4 + 40 + 18 + 8), y, TextColor, s);305 S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)]) 306 else begin S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); I:=17 end; } 307 ReplaceText(X + (CityNameSpace + 4 + 40 + 18 + 8), Y, TextColor, S); 310 308 if NonText then 311 309 begin 312 Sprite( offscreen, HGrSystem, 105 - 76 + CityNameSpace + 4 + 40,313 y0 + 1, 18, 18, 1 + i mod 3 * 19, 1 + idiv 3 * 19);314 x:= InnerWidth - 26;315 for j:= nCityEventPriority - 1 downto first + 1 do316 if (Flags and CityRepMask and CityEventPriority[ j] <> 0) then310 Sprite(Offscreen, HGrSystem, 105 - 76 + CityNameSpace + 4 + 40, 311 y0 + 1, 18, 18, 1 + I mod 3 * 19, 1 + I div 3 * 19); 312 X := InnerWidth - 26; 313 for J := nCityEventPriority - 1 downto first + 1 do 314 if (Flags and CityRepMask and CityEventPriority[J] <> 0) then 317 315 begin 318 i:= 0;319 test := 1;320 while test < CityEventPriority[j] do316 I := 0; 317 Test := 1; 318 while Test < CityEventPriority[J] do 321 319 begin 322 inc(i);323 inc(test, test)320 Inc(I); 321 Inc(Test, Test); 324 322 end; 325 if (CityEventPriority[ j] = chNoGrowthWarning) and323 if (CityEventPriority[J] = chNoGrowthWarning) and 326 324 (Built[imAqueduct] > 0) then 327 i:= 17;328 Sprite( offscreen, HGrSystem, x, y0 + 1, 18, 18,329 1 + i mod 3 * 19, 1 + idiv 3 * 19);330 dec(x, 20)331 end 332 end 333 end 325 I := 17; 326 Sprite(Offscreen, HGrSystem, X, y0 + 1, 18, 18, 327 1 + I mod 3 * 19, 1 + I div 3 * 19); 328 Dec(X, 20); 329 end; 330 end; 331 end; 334 332 end 335 333 else … … 338 336 CityReport.HypoTaxRate := -1; 339 337 CityReport.HypoLuxuryRate := -1; 340 Server(sGetCityReportNew, me, lix, CityReport);338 Server(sGetCityReportNew, Me, lix, CityReport); 341 339 TrueFood := Food; 342 340 TrueProd := Prod; 343 if supervising then341 if Supervising then 344 342 begin // normalize city from after-turn state 345 dec(TrueFood, CityReport.FoodSurplus);343 Dec(TrueFood, CityReport.FoodSurplus); 346 344 if TrueFood < 0 then 347 345 TrueFood := 0; // shouldn't happen 348 dec(TrueProd, CityReport.Production);346 Dec(TrueProd, CityReport.Production); 349 347 if TrueProd < 0 then 350 348 TrueProd := 0; // shouldn't happen 351 349 end; 352 350 353 s:= ''; // disorder info351 S := ''; // disorder info 354 352 if Flags and chCaptured <> 0 then 355 s:= Phrases.Lookup('CITYEVENTS', 14)353 S := Phrases.Lookup('CITYEVENTS', 14) 356 354 else if CityReport.HappinessBalance < 0 then 357 s:= Phrases.Lookup('CITYEVENTS', 0);358 if s<> '' then355 S := Phrases.Lookup('CITYEVENTS', 0); 356 if S <> '' then 359 357 begin { disorder } 360 358 if NonText then 361 359 begin 362 DarkGradient( offscreen.Canvas, 99 + 31 + CityNameSpace + 4,360 DarkGradient(Offscreen.Canvas, 99 + 31 + CityNameSpace + 4, 363 361 y0 + 2, 131, 3); 364 362 ca.Font.Assign(UniFont[ftSmall]); 365 RisedTextout( offscreen.Canvas, 103 + CityNameSpace + 4 + 31,366 y0 + 1, s);363 RisedTextout(Offscreen.Canvas, 103 + CityNameSpace + 4 + 31, 364 y0 + 1, S); 367 365 ca.Font.Assign(UniFont[ftNormal]); 368 end 366 end; 369 367 end 370 368 else 371 369 begin 372 370 { s:=IntToStr(CityReport.FoodSurplus); 373 ReplaceText( x+(CityNameSpace+4+48)-BiColorTextWidth(ca,s),y,TextColor,s); }374 s := inttostr(CityReport.Science);375 ReplaceText( x+ CityNameSpace + 4 + 370 + 48 - BiColorTextWidth(ca,376 s), y, TextColor, s);377 s := inttostr(CityReport.Production);378 ReplaceText( x + CityNameSpace + 4 + 132 - BiColorTextWidth(ca, s), y,379 TextColor, s);371 ReplaceText(X+(CityNameSpace+4+48)-BiColorTextWidth(ca,S),Y,TextColor,S); } 372 S := IntToStr(CityReport.Science); 373 ReplaceText(X + CityNameSpace + 4 + 370 + 48 - BiColorTextWidth(ca, 374 S), Y, TextColor, S); 375 S := IntToStr(CityReport.Production); 376 ReplaceText(X + CityNameSpace + 4 + 132 - BiColorTextWidth(ca, S), Y, 377 TextColor, S); 380 378 if NonText then 381 379 begin 382 380 // Sprite(offscreen,HGrSystem,x+CityNameSpace+4+333+1,y+6,10,10,66,115); 383 Sprite( offscreen, HGrSystem, x+ CityNameSpace + 4 + 370 + 48 + 1,384 y+ 6, 10, 10, 77, 126);385 Sprite( offscreen, HGrSystem, x + CityNameSpace + 4 + 132 + 1, y+ 6,381 Sprite(Offscreen, HGrSystem, X + CityNameSpace + 4 + 370 + 48 + 1, 382 Y + 6, 10, 10, 77, 126); 383 Sprite(Offscreen, HGrSystem, X + CityNameSpace + 4 + 132 + 1, Y + 6, 386 384 10, 10, 88, 115); 387 end 388 end; 389 s := inttostr(CityTaxBalance(lix, CityReport));390 ReplaceText( x + CityNameSpace + 4 + 370 - BiColorTextWidth(ca, s), y,391 TextColor, s);385 end; 386 end; 387 S := IntToStr(CityTaxBalance(lix, CityReport)); 388 ReplaceText(X + CityNameSpace + 4 + 370 - BiColorTextWidth(ca, S), Y, 389 TextColor, S); 392 390 // if Project and (cpImp+cpIndex)<>cpImp+imTrGoods then 393 391 // ReplaceText(x+CityNameSpace+4+333+1,y,TextColor,Format('%d/%d',[TrueProd,CityReport.ProjectCost])); 394 392 if NonText then 395 393 begin 396 Sprite( offscreen, HGrSystem, x + CityNameSpace + 4 + 370 + 1, y+ 6,394 Sprite(Offscreen, HGrSystem, X + CityNameSpace + 4 + 370 + 1, Y + 6, 397 395 10, 10, 132, 115); 398 396 … … 402 400 ((Size < NeedAqueductSize) or (Built[imAqueduct] = 1) and 403 401 (Size < NeedSewerSize) or (Built[imSewer] = 1)); 404 PaintRelativeProgressBar( offscreen.Canvas, 1, x+ 15 + CityNameSpace +405 4, y+ 7, 68, TrueFood, CutCityFoodSurplus(CityReport.FoodSurplus,402 PaintRelativeProgressBar(Offscreen.Canvas, 1, X + 15 + CityNameSpace + 403 4, Y + 7, 68, TrueFood, CutCityFoodSurplus(CityReport.FoodSurplus, 406 404 (MyRO.Government <> gAnarchy) and (Flags and chCaptured = 0), 407 405 MyRO.Government, Size), CityReport.Storage, CanGrow, MainTexture); … … 409 407 if Project <> cpImp + imTrGoods then 410 408 begin 411 DisplayProject(ofs + 104 - 76 + x- 28 + CityNameSpace + 4 + 206 -409 DisplayProject(ofs + 104 - 76 + X - 28 + CityNameSpace + 4 + 206 - 412 410 60, y0 - 15, Project); 413 411 … … 417 415 (Flags and chCaptured <> 0) then 418 416 growth := 0; 419 PaintRelativeProgressBar( offscreen.Canvas, 4,420 x + CityNameSpace + 4 + 304 - 60 + 9, y+ 7, 68, TrueProd, growth,421 CityReport.ProjectCost, true, MainTexture);422 end; 423 end 417 PaintRelativeProgressBar(Offscreen.Canvas, 4, 418 X + CityNameSpace + 4 + 304 - 60 + 9, Y + 7, 68, TrueProd, growth, 419 CityReport.ProjectCost, True, MainTexture); 420 end; 421 end; 424 422 end; 425 423 end 426 424 else if Kind in [kModels, kEModels] then 427 425 begin 428 x:= 104;429 y:= y0;426 X := 104; 427 Y := y0; 430 428 if ca = Canvas then 431 429 begin 432 x := x+ SideFrame;433 y := y + TitleHeight430 X := X + SideFrame; 431 Y := Y + TitleHeight; 434 432 end; 435 433 if lit then … … 440 438 begin 441 439 Available := 0; 442 for j:= 0 to MyRO.nUn - 1 do443 if (MyUn[ j].Loc >= 0) and (MyUn[j].mix = lix) then444 inc(Available);440 for J := 0 to MyRO.nUn - 1 do 441 if (MyUn[J].Loc >= 0) and (MyUn[J].mix = lix) then 442 Inc(Available); 445 443 if MainScreen.mNames.Checked then 446 s := Tribe[me].ModelName[lix]444 S := Tribe[Me].ModelName[lix] 447 445 else 448 s := Format(Tribe[me].TPhrase('GENMODEL'), [lix]);446 S := Format(Tribe[Me].TPhrase('GENMODEL'), [lix]); 449 447 if NonText then 450 448 DisplayProject(8 + ofs, y0 - 15, lix); … … 454 452 Available := MyRO.EnemyReport[pView].UnCount[lix]; 455 453 if MainScreen.mNames.Checked then 456 s:= Tribe[pView].ModelName[lix]454 S := Tribe[pView].ModelName[lix] 457 455 else 458 s:= Format(Tribe[pView].TPhrase('GENMODEL'), [lix]);456 S := Format(Tribe[pView].TPhrase('GENMODEL'), [lix]); 459 457 if NonText then 460 458 with Tribe[pView].ModelPicture[lix] do 461 Sprite( offscreen, HGr, 8 + ofs, y0 - 15, 64, 48, pix mod 10 * 65 + 1,459 Sprite(Offscreen, HGr, 8 + ofs, y0 - 15, 64, 48, pix mod 10 * 65 + 1, 462 460 pix div 10 * 49 + 1); 463 461 end; 464 462 if Available > 0 then 465 ReplaceText( x + 32 - BiColorTextWidth(ca, inttostr(Available)), y,466 TextColor, inttostr(Available));467 ReplaceText( x + 40, y, TextColor, s);463 ReplaceText(X + 32 - BiColorTextWidth(ca, IntToStr(Available)), Y, 464 TextColor, IntToStr(Available)); 465 ReplaceText(X + 40, Y, TextColor, S); 468 466 end 469 467 else … … 472 470 kAllEModels, kChooseEModel: 473 471 if lix = mixAll then 474 s:= Phrases.Lookup('PRICECAT_ALLMODEL')472 S := Phrases.Lookup('PRICECAT_ALLMODEL') 475 473 else 476 474 begin … … 478 476 if MainScreen.mNames.Checked then 479 477 begin 480 s:= Tribe[mox.Owner].ModelName[mox.mix];481 if (Kind = kAllEModels) and ( code[1, sb.Position + l] = 0) then482 s := Format(Tribe[mox.Owner].TPhrase('OWNED'), [s]);478 S := Tribe[mox.Owner].ModelName[mox.mix]; 479 if (Kind = kAllEModels) and (Code[1, ScrollBar.Position + L] = 0) then 480 S := Format(Tribe[mox.Owner].TPhrase('OWNED'), [S]); 483 481 end 484 482 else 485 s:= Format(Tribe[mox.Owner].TPhrase('GENMODEL'), [mox.mix]);483 S := Format(Tribe[mox.Owner].TPhrase('GENMODEL'), [mox.mix]); 486 484 if NonText then 487 485 with Tribe[mox.Owner].ModelPicture[mox.mix] do 488 Sprite( offscreen, HGr, 8 + ofs, y0 - 15, 64, 48,486 Sprite(Offscreen, HGr, 8 + ofs, y0 - 15, 64, 48, 489 487 pix mod 10 * 65 + 1, pix div 10 * 49 + 1); 490 488 end; 491 489 kChooseModel: 492 490 if lix = mixAll then 493 s:= Phrases.Lookup('PRICECAT_ALLMODEL')491 S := Phrases.Lookup('PRICECAT_ALLMODEL') 494 492 else 495 493 begin 496 s := Tribe[me].ModelName[lix];494 S := Tribe[Me].ModelName[lix]; 497 495 if NonText then 498 496 DisplayProject(8 + ofs, y0 - 15, lix); … … 501 499 begin 502 500 if lix and cpType <> 0 then 503 s:= Phrases.Lookup('CITYTYPE', lix and cpIndex)501 S := Phrases.Lookup('CITYTYPE', lix and cpIndex) 504 502 else if lix and cpImp = 0 then 505 503 with MyModel[lix and cpIndex] do 506 504 begin 507 s := Tribe[me].ModelName[lix and cpIndex];505 S := Tribe[Me].ModelName[lix and cpIndex]; 508 506 if lix and cpConscripts <> 0 then 509 s := Format(Phrases.Lookup('CONSCRIPTS'), [s]);507 S := Format(Phrases.Lookup('CONSCRIPTS'), [S]); 510 508 end 511 509 else 512 510 begin 513 s:= Phrases.Lookup('IMPROVEMENTS', lix and cpIndex);511 S := Phrases.Lookup('IMPROVEMENTS', lix and cpIndex); 514 512 if (Imp[lix and cpIndex].Kind in [ikNatLocal, ikNatGlobal]) and 515 513 (MyRO.NatBuilt[lix and cpIndex] > 0) or … … 517 515 (MyCity[cixProject].Built[imPower] + MyCity[cixProject].Built 518 516 [imHydro] + MyCity[cixProject].Built[imNuclear] > 0) then 519 s := Format(Phrases.Lookup('NATEXISTS'), [s]);517 S := Format(Phrases.Lookup('NATEXISTS'), [S]); 520 518 end; 521 519 if NonText then … … 525 523 begin 526 524 if lix = adAll then 527 s:= Phrases.Lookup('PRICECAT_ALLTECH')525 S := Phrases.Lookup('PRICECAT_ALLTECH') 528 526 else 529 527 begin 530 528 if lix = adNexus then 531 s:= Phrases.Lookup('NEXUS')529 S := Phrases.Lookup('NEXUS') 532 530 else if lix = adNone then 533 s:= Phrases.Lookup('NOFARTECH')531 S := Phrases.Lookup('NOFARTECH') 534 532 else if lix = adMilitary then 535 s:= Phrases.Lookup('INITUNIT')533 S := Phrases.Lookup('INITUNIT') 536 534 else 537 535 begin 538 s:= Phrases.Lookup('ADVANCES', lix);536 S := Phrases.Lookup('ADVANCES', lix); 539 537 if (Kind = kAdvance) and (lix in FutureTech) then 540 538 if MyRO.Tech[lix] < tsApplicable then 541 s := s+ ' 1'539 S := S + ' 1' 542 540 else 543 s := s + ' ' + inttostr(MyRO.Tech[lix] + 1);541 S := S + ' ' + IntToStr(MyRO.Tech[lix] + 1); 544 542 end; 545 if BiColorTextWidth(ca, s) > TechNameSpace + 8 then543 if BiColorTextWidth(ca, S) > TechNameSpace + 8 then 546 544 begin 547 545 repeat 548 delete(s, length(s), 1);549 until BiColorTextWidth(ca, s) <= TechNameSpace + 5;550 s := s+ '.';546 Delete(S, Length(S), 1); 547 until BiColorTextWidth(ca, S) <= TechNameSpace + 5; 548 S := S + '.'; 551 549 end; 552 550 … … 555 553 if lix = adNexus then 556 554 begin 557 Frame( offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),555 Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36), 558 556 y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 559 Dump( offscreen, HGrSystem, (8 + 16), y0, 36, 20, 223, 295)557 Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 223, 295) 560 558 end 561 559 else if lix = adNone then 562 560 begin 563 Frame( offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),561 Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36), 564 562 y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 565 Dump( offscreen, HGrSystem, (8 + 16), y0, 36, 20, 260, 295)563 Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 260, 295) 566 564 end 567 565 else if lix = adMilitary then 568 566 begin 569 Frame( offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),567 Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36), 570 568 y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 571 Dump( offscreen, HGrSystem, (8 + 16), y0, 36, 20, 38, 295)569 Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 38, 295) 572 570 end 573 571 else 574 572 begin 575 Frame( offscreen.Canvas, (8 + 16 - 1), y0 - 1,573 Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, 576 574 (8 + 16 + xSizeSmall), y0 + ySizeSmall, 577 575 MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 578 576 if AdvIcon[lix] < 84 then 579 DpiBit Canvas(offscreen.Canvas, (8 + 16), y0, xSizeSmall,577 DpiBitBltCanvas(Offscreen.Canvas, (8 + 16), y0, xSizeSmall, 580 578 ySizeSmall, SmallImp.Canvas, 581 579 (AdvIcon[lix] + SystemIconLines * 7) mod 7 * xSizeSmall, … … 583 581 ySizeSmall) 584 582 else 585 Dump( offscreen, HGrSystem, (8 + 16), y0, 36, 20,583 Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 586 584 1 + (AdvIcon[lix] - 84) mod 8 * 37, 587 585 295 + (AdvIcon[lix] - 84) div 8 * 21); 588 j:= AdvValue[lix] div 1000;589 DpiBit Canvas(offscreen.Canvas, (8 + 16 - 4), y0 + 2, 14, 14,590 HGrSystem.Mask.Canvas, 127 + j* 15,586 J := AdvValue[lix] div 1000; 587 DpiBitBltCanvas(Offscreen.Canvas, (8 + 16 - 4), y0 + 2, 14, 14, 588 HGrSystem.Mask.Canvas, 127 + J * 15, 591 589 85, SRCAND); 592 Sprite( offscreen, HGrSystem, (8 + 16 - 5), y0 + 1, 14, 14,593 127 + j* 15, 85);590 Sprite(Offscreen, HGrSystem, (8 + 16 - 5), y0 + 1, 14, 14, 591 127 + J * 15, 85); 594 592 end; 595 593 end; … … 598 596 if NonText and (Kind in [kAdvance, kScience]) then 599 597 begin // show research state 600 for j:= 0 to nColumn - 1 do598 for J := 0 to nColumn - 1 do 601 599 begin 602 600 FutureCount := 0; 603 if j= 0 then // own science601 if J = 0 then // own science 604 602 if lix = MyRO.ResearchTech then 605 603 begin 606 Server(sGetTechCost, me, 0, icon);604 Server(sGetTechCost, Me, 0, icon); 607 605 icon := 4 + MyRO.Research * 4 div icon; 608 606 if icon > 4 + 3 then … … 623 621 icon := -1 624 622 else 625 with MyRO.EnemyReport[Column[ j]]^ do // enemy science626 if (MyRO.Alive and (1 shl Column[ j]) <> 0) and623 with MyRO.EnemyReport[Column[J]]^ do // enemy science 624 if (MyRO.Alive and (1 shl Column[J]) <> 0) and 627 625 (TurnOfCivilReport >= 0) and (lix = ResearchTech) and 628 626 ((lix = adMilitary) or (lix in FutureTech) or … … 631 629 icon := 4 + ResearchDone div 25; 632 630 if icon > 4 + 3 then 633 icon := 4 + 3 631 icon := 4 + 3; 634 632 end 635 633 else if lix = adMilitary then … … 647 645 icon := -1; 648 646 if icon >= 0 then 649 Sprite( offscreen, HGrSystem, 104 - 33 + 15 + 3 + TechNameSpace +650 24 * j, y0 + 3, 14, 14, 67 + icon * 15, 85)647 Sprite(Offscreen, HGrSystem, 104 - 33 + 15 + 3 + TechNameSpace + 648 24 * J, y0 + 3, 14, 14, 67 + icon * 15, 85) 651 649 else if (Kind = kScience) and (FutureCount > 0) then 652 650 begin 653 number := inttostr(FutureCount);654 RisedTextout(ca, 104 - 33 + 15 + 10 + TechNameSpace + 24 * j-651 number := IntToStr(FutureCount); 652 RisedTextout(ca, 104 - 33 + 15 + 10 + TechNameSpace + 24 * J - 655 653 BiColorTextWidth(ca, number) div 2, y0, number); 656 end 657 end 654 end; 655 end; 658 656 end; 659 657 end; // kAdvance, kScience 660 658 kTribe: 661 s:= TribeNames[lix];659 S := TribeNames[lix]; 662 660 kShipPart: 663 661 begin 664 s:= Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +665 inttostr(MyRO.Ship[me].Parts[lix]) + ')';662 S := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' + 663 IntToStr(MyRO.Ship[Me].Parts[lix]) + ')'; 666 664 if NonText then 667 665 DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix); … … 669 667 kEShipPart: 670 668 begin 671 s:= Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +672 inttostr(MyRO.Ship[DipMem[me].pContact].Parts[lix]) + ')';669 S := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' + 670 IntToStr(MyRO.Ship[DipMem[Me].pContact].Parts[lix]) + ')'; 673 671 if NonText then 674 672 DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix); … … 676 674 kGov: 677 675 begin 678 s:= Phrases.Lookup('GOVERNMENT', lix);676 S := Phrases.Lookup('GOVERNMENT', lix); 679 677 if NonText then 680 678 begin 681 Frame( offscreen.Canvas, 8 + 16 - 1, y0 - 15 + (16 - 2),679 Frame(Offscreen.Canvas, 8 + 16 - 1, y0 - 15 + (16 - 2), 682 680 8 + 16 + xSizeSmall, y0 - 15 + (16 - 1 + ySizeSmall), 683 681 MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 684 DpiBit Canvas(offscreen.Canvas, 8 + 16, y0 - 15 + (16 - 1),682 DpiBitBltCanvas(Offscreen.Canvas, 8 + 16, y0 - 15 + (16 - 1), 685 683 xSizeSmall, ySizeSmall, SmallImp.Canvas, 686 684 (lix - 1) * xSizeSmall, ySizeSmall); 687 end 685 end; 688 686 end; 689 687 kMission: 690 s:= Phrases.Lookup('SPYMISSION', lix);688 S := Phrases.Lookup('SPYMISSION', lix); 691 689 end; 692 690 case Kind of 693 691 kTribe, kMission: // center text 694 692 if Lines[0] > MaxLines then 695 x:= (InnerWidth - DpiGetSystemMetrics(SM_CXVSCROLL)) div 2 -696 BiColorTextWidth(ca, s) div 2693 X := (InnerWidth - DpiGetSystemMetrics(SM_CXVSCROLL)) div 2 - 694 BiColorTextWidth(ca, S) div 2 697 695 else 698 x := InnerWidth div 2 - BiColorTextWidth(ca, s) div 2;696 X := InnerWidth div 2 - BiColorTextWidth(ca, S) div 2; 699 697 kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, 700 698 kStealTech, kGov: 701 x:= 104 - 33;699 X := 104 - 33; 702 700 kAllEModels: 703 x:= 104;701 X := 104; 704 702 else 705 x:= 104 + 15;703 X := 104 + 15; 706 704 end; 707 y:= y0;705 Y := y0; 708 706 if ca = Canvas then 709 707 begin 710 x := x+ SideFrame;711 y := y + TitleHeight708 X := X + SideFrame; 709 Y := Y + TitleHeight; 712 710 end; 713 711 if lit then … … 716 714 TextColor := -1; 717 715 { if Kind=kTribe then ReplaceText_Tribe(x,y,TextColor, 718 integer(TribeNames.Objects[lix]),s)719 else } ReplaceText( x, y, TextColor, s);720 end 716 Integer(TribeNames.Objects[lix]),S) 717 else } ReplaceText(X, Y, TextColor, S); 718 end; 721 719 end; 722 720 723 721 procedure TListDlg.OffscreenPaint; 724 722 var 725 i, j: integer;723 I, J: Integer; 726 724 begin 727 725 case Kind of 728 726 kCities: 729 Caption := Tribe[ me].TPhrase('TITLE_CITIES');727 Caption := Tribe[Me].TPhrase('TITLE_CITIES'); 730 728 kCityEvents: 731 729 Caption := Format(Phrases.Lookup('TITLE_EVENTS'), … … 734 732 735 733 inherited; 736 offscreen.Canvas.Font.Assign(UniFont[ftNormal]);734 Offscreen.Canvas.Font.Assign(UniFont[ftNormal]); 737 735 FillOffscreen(0, 0, InnerWidth, InnerHeight); 738 with offscreen.Canvas do736 with Offscreen.Canvas do 739 737 begin 740 738 if Kind = kScience then 741 for i:= 1 to nColumn - 1 do739 for I := 1 to nColumn - 1 do 742 740 begin 743 741 Pen.Color := $000000; 744 MoveTo(104 - 33 + 15 + TechNameSpace + 24 * i, 0);745 LineTo(104 - 33 + 15 + TechNameSpace + 24 * i, InnerHeight);746 MoveTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * i, 0);747 LineTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * i, InnerHeight);748 if MyRO.EnemyReport[Column[ i]].TurnOfCivilReport >= MyRO.Turn - 1 then749 begin 750 brush.Color := Tribe[Column[i]].Color;751 fillrect(rect(104 - 33 + 14 + TechNameSpace + 24 * i+ 1 * 2, 0,752 104 - 33 + 17 + TechNameSpace + 24 * i+ 8 * 2, InnerHeight));753 brush.style := bsClear;742 MoveTo(104 - 33 + 15 + TechNameSpace + 24 * I, 0); 743 LineTo(104 - 33 + 15 + TechNameSpace + 24 * I, InnerHeight); 744 MoveTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * I, 0); 745 LineTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * I, InnerHeight); 746 if MyRO.EnemyReport[Column[I]].TurnOfCivilReport >= MyRO.Turn - 1 then 747 begin 748 Brush.Color := Tribe[Column[I]].Color; 749 FillRect(rect(104 - 33 + 14 + TechNameSpace + 24 * I + 1 * 2, 0, 750 104 - 33 + 17 + TechNameSpace + 24 * I + 8 * 2, InnerHeight)); 751 Brush.style := bsClear; 754 752 end 755 753 else 756 754 begin // colored player columns 757 Pen.Color := Tribe[Column[ i]].Color;758 for j:= 1 to 8 do759 begin 760 MoveTo(104 - 33 + 15 + TechNameSpace + 24 * i + j* 2, 0);761 LineTo(104 - 33 + 15 + TechNameSpace + 24 * i + j* 2, InnerHeight);762 end 763 end; 764 end; 765 766 for i:= -1 to DispLines do767 if ( i + sb.Position >= 0) and (i + sb.Position < Lines[Layer]) then768 Self. line(offscreen.Canvas, i, true, false)755 Pen.Color := Tribe[Column[I]].Color; 756 for J := 1 to 8 do 757 begin 758 MoveTo(104 - 33 + 15 + TechNameSpace + 24 * I + J * 2, 0); 759 LineTo(104 - 33 + 15 + TechNameSpace + 24 * I + J * 2, InnerHeight); 760 end; 761 end; 762 end; 763 764 for I := -1 to DispLines do 765 if (I + ScrollBar.Position >= 0) and (I + ScrollBar.Position < Lines[Layer]) then 766 Self.Line(Offscreen.Canvas, I, True, False); 769 767 end; 770 768 MarkUsedOffscreen(InnerWidth, 8 + 48 + DispLines * LineDistance); … … 772 770 773 771 procedure TListDlg.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; 774 x, y: integer);772 X, Y: Integer); 775 773 var 776 i0, Sel0, iColumn, OldScienceNation, xScreen: integer;777 s: string;778 begin 779 y := y- TitleHeight;780 i0 := sb.Position;781 Sel0 := Sel ;782 if ( x >= SideFrame) and (x < SideFrame + InnerWidth) and (y>= 0) and783 ( y < InnerHeight) and (y mod LineDistance >= 4) and (ymod LineDistance < 20)774 i0, Sel0, iColumn, OldScienceNation, xScreen: Integer; 775 S: string; 776 begin 777 Y := Y - TitleHeight; 778 i0 := ScrollBar.Position; 779 Sel0 := Selected; 780 if (X >= SideFrame) and (X < SideFrame + InnerWidth) and (Y >= 0) and 781 (Y < InnerHeight) and (Y mod LineDistance >= 4) and (Y mod LineDistance < 20) 784 782 then 785 Sel := ydiv LineDistance - 1783 Selected := Y div LineDistance - 1 786 784 else 787 Sel := -2;788 if (Sel < -1) or (Sel > DispLines) or (Sel+ i0 < 0) or789 (Sel + i0 >= Lines[Layer]) then790 Sel := -2;791 if Sel <> Sel0 then785 Selected := -2; 786 if (Selected < -1) or (Selected > DispLines) or (Selected + i0 < 0) or 787 (Selected + i0 >= Lines[Layer]) then 788 Selected := -2; 789 if Selected <> Sel0 then 792 790 begin 793 791 if Sel0 <> -2 then 794 line(Canvas, Sel0, false, false);795 if Sel <> -2 then796 line(Canvas, Sel, false, true)792 Line(Canvas, Sel0, False, False); 793 if Selected <> -2 then 794 Line(Canvas, Selected, False, True); 797 795 end; 798 796 … … 801 799 OldScienceNation := ScienceNation; 802 800 ScienceNation := -1; 803 if ( x>= SideFrame + (104 - 33 + 15 + TechNameSpace)) and804 (( x- SideFrame - (104 - 33 + 15 + TechNameSpace)) mod 24 <= 18) and805 ( y >= 0) and (y< InnerHeight) then801 if (X >= SideFrame + (104 - 33 + 15 + TechNameSpace)) and 802 ((X - SideFrame - (104 - 33 + 15 + TechNameSpace)) mod 24 <= 18) and 803 (Y >= 0) and (Y < InnerHeight) then 806 804 begin 807 iColumn := ( x- SideFrame - (104 - 33 + 15 + TechNameSpace)) div 24;805 iColumn := (X - SideFrame - (104 - 33 + 15 + TechNameSpace)) div 24; 808 806 if (iColumn >= 1) and (iColumn < nColumn) then 809 807 ScienceNation := Column[iColumn]; … … 816 814 if ScienceNation >= 0 then 817 815 begin 818 s:= Tribe[ScienceNation].TPhrase('SHORTNAME');816 S := Tribe[ScienceNation].TPhrase('SHORTNAME'); 819 817 if MyRO.Alive and (1 shl ScienceNation) = 0 then 820 s := Format(Phrases.Lookup('SCIENCEREPORT_EXTINCT'), [s]) // extinct818 S := Format(Phrases.Lookup('SCIENCEREPORT_EXTINCT'), [S]) // extinct 821 819 else if MyRO.EnemyReport[ScienceNation].TurnOfCivilReport < MyRO.Turn - 1 822 820 then 823 s := s+ ' (' + TurnToString(MyRO.EnemyReport[ScienceNation]821 S := S + ' (' + TurnToString(MyRO.EnemyReport[ScienceNation] 824 822 .TurnOfCivilReport) + ')'; // old report 825 xScreen := (ClientWidth - BiColorTextWidth(Canvas, s)) div 2;823 xScreen := (ClientWidth - BiColorTextWidth(Canvas, S)) div 2; 826 824 LoweredTextOut(Canvas, -1, MainTexture, xScreen + 10, 827 ClientHeight - 29, s);828 DpiBit Canvas(ScienceNationDotBuffer.Canvas, 0, 0, ScienceNationDot.Width,825 ClientHeight - 29, S); 826 DpiBitBltCanvas(ScienceNationDotBuffer.Canvas, 0, 0, ScienceNationDot.Width, 829 827 ScienceNationDot.Height, Canvas, xScreen - 10, ClientHeight - 27); 830 828 ImageOp_BCC(ScienceNationDotBuffer, Templates.Data, Point(0, 0), 831 829 ScienceNationDot.BoundsRect, MainTexture.ColorBevelShade, Tribe[ScienceNation].Color); 832 DpiBit Canvas(Canvas, xScreen - 10, ClientHeight - 27, ScienceNationDot.Width,830 DpiBitBltCanvas(Canvas, xScreen - 10, ClientHeight - 27, ScienceNationDot.Width, 833 831 ScienceNationDot.Height, ScienceNationDotBuffer.Canvas, 0, 0); 834 832 end; … … 840 838 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); 841 839 begin 842 if sb.ProcessMouseWheel(WheelDelta) then begin840 if ScrollBar.ProcessMouseWheel(WheelDelta) then begin 843 841 PaintBox1MouseMove(nil, [], MousePos.X - Left, 844 842 MousePos.Y - Top); … … 846 844 end; 847 845 848 function TListDlg.RenameCity(cix: integer): boolean; 846 procedure TListDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction); 847 begin 848 //Gtk2Fix; 849 end; 850 851 function TListDlg.RenameCity(cix: Integer): Boolean; 849 852 var 850 853 CityNameInfo: TCityNameInfo; … … 859 862 CityNameInfo.ID := MyCity[cix].ID; 860 863 CityNameInfo.NewName := InputDlg.EInput.Text; 861 Server(cSetCityName + (length(CityNameInfo.NewName) + 8) div 4, me, 0, 862 CityNameInfo); 863 if CityDlg.Visible then 864 if CityNameInfo.GetCommandDataSize > CommandDataMaxSize then 865 Delete(CityNameInfo.NewName, Length(CityNameInfo.NewName) - 866 (CityNameInfo.GetCommandDataSize - 1 - CommandDataMaxSize), MaxInt); 867 Server(CommandWithData(cSetCityName, CityNameInfo.GetCommandDataSize), 868 Me, 0, CityNameInfo); 869 if MainScreen.CityDlg.Visible then 864 870 begin 865 CityDlg.FormShow(nil);866 CityDlg.Invalidate;871 MainScreen.CityDlg.FormShow(nil); 872 MainScreen.CityDlg.Invalidate; 867 873 end; 868 result := true;874 Result := True; 869 875 end 870 876 else 871 result := false;872 end; 873 874 function TListDlg.RenameModel(mix: integer): boolean;877 Result := False; 878 end; 879 880 function TListDlg.RenameModel(mix: Integer): Boolean; 875 881 var 876 882 ModelNameInfo: TModelNameInfo; 877 883 begin 878 884 InputDlg.Caption := Phrases.Lookup('TITLE_MODELNAME'); 879 InputDlg.EInput.Text := Tribe[ me].ModelName[mix];885 InputDlg.EInput.Text := Tribe[Me].ModelName[mix]; 880 886 InputDlg.CenterToRect(BoundsRect); 881 887 InputDlg.ShowModal; 882 888 if (InputDlg.ModalResult = mrOK) and (InputDlg.EInput.Text <> '') and 883 (InputDlg.EInput.Text <> Tribe[ me].ModelName[mix]) then889 (InputDlg.EInput.Text <> Tribe[Me].ModelName[mix]) then 884 890 begin 885 891 ModelNameInfo.mix := mix; 886 892 ModelNameInfo.NewName := InputDlg.EInput.Text; 887 Server(cSetModelName + (length(ModelNameInfo.NewName) + 1 + 4 + 3) div 4, 888 me, 0, ModelNameInfo); 889 if UnitStatDlg.Visible then 893 if ModelNameInfo.GetCommandDataSize > CommandDataMaxSize then 894 Delete(ModelNameInfo.NewName, Length(ModelNameInfo.NewName) - 895 (ModelNameInfo.GetCommandDataSize - 1 - CommandDataMaxSize), MaxInt); 896 Server(CommandWithData(cSetModelName, ModelNameInfo.GetCommandDataSize), 897 Me, 0, ModelNameInfo); 898 if MainScreen.UnitStatDlg.Visible then 890 899 begin 891 UnitStatDlg.FormShow(nil);892 UnitStatDlg.Invalidate;900 MainScreen.UnitStatDlg.FormShow(nil); 901 MainScreen.UnitStatDlg.Invalidate; 893 902 end; 894 result := true;903 Result := True; 895 904 end 896 905 else 897 result := false;906 Result := False; 898 907 end; 899 908 900 909 procedure TListDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 901 Shift: TShiftState; x, y: integer);910 Shift: TShiftState; X, Y: Integer); 902 911 var 903 lix: integer;904 begin 905 if sb.Position + Sel>= 0 then906 lix := code[Layer, sb.Position + Sel];912 lix: Integer; 913 begin 914 if ScrollBar.Position + Selected >= 0 then 915 lix := Code[Layer, ScrollBar.Position + Selected]; 907 916 if Kind in [kScience, kCities, kCityEvents, kModels, kEModels, kAllEModels] 908 917 then 909 include(Shift, ssShift); // don't close list window918 Include(Shift, ssShift); // don't close list window 910 919 if (ssLeft in Shift) and not(ssShift in Shift) then 911 920 begin 912 if Sel <> -2 then921 if Selected <> -2 then 913 922 begin 914 result := lix;915 Closable := true;923 Result := lix; 924 Closable := True; 916 925 Close; 917 926 end; … … 919 928 else if (ssLeft in Shift) and (ssShift in Shift) then 920 929 begin // show help/info popup 921 if Sel <> -2 then930 if Selected <> -2 then 922 931 case Kind of 923 932 kCities: 924 933 MainScreen.ZoomToCity(MyCity[lix].Loc); 925 934 kCityEvents: 926 MainScreen.ZoomToCity(MyCity[lix].Loc, false, MyCity[lix].Flags and935 MainScreen.ZoomToCity(MyCity[lix].Loc, False, MyCity[lix].Flags and 927 936 CityRepMask); 928 937 kModels, kChooseModel: 929 938 if lix <> mixAll then 930 UnitStatDlg.ShowNewContent_OwnModel(FWindowMode or 931 wmPersistent, lix); 939 MainScreen.UnitStatDlg.ShowNewContent_OwnModel(wmPersistent, lix); 932 940 kEModels: 933 UnitStatDlg.ShowNewContent_EnemyModel(FWindowMode orwmPersistent,934 code[1, sb.Position + Sel]);941 MainScreen.UnitStatDlg.ShowNewContent_EnemyModel(wmPersistent, 942 Code[1, ScrollBar.Position + Selected]); 935 943 kAllEModels, kChooseEModel: 936 944 if lix <> mixAll then 937 UnitStatDlg.ShowNewContent_EnemyModel(FWindowMode or 938 wmPersistent, lix); 945 MainScreen.UnitStatDlg.ShowNewContent_EnemyModel(wmPersistent, lix); 939 946 kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, kStealTech: 940 947 if lix = adMilitary then 941 HelpDlg.ShowNewContent(FWindowMode orwmPersistent, hkText,942 HelpDlg.TextIndex('MILRES'))948 MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkText, 949 MainScreen.HelpDlg.TextIndex('MILRES')) 943 950 else if lix < adMilitary then 944 HelpDlg.ShowNewContent(FWindowMode orwmPersistent, hkAdv, lix);951 MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkAdv, lix); 945 952 kProject: 946 953 if lix = cpImp + imTrGoods then 947 HelpDlg.ShowNewContent(FWindowMode orwmPersistent, hkText,948 HelpDlg.TextIndex('TRADINGGOODS'))954 MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkText, 955 MainScreen.HelpDlg.TextIndex('TRADINGGOODS')) 949 956 else if lix and (cpImp + cpType) = 0 then 950 UnitStatDlg.ShowNewContent_OwnModel(FWindowMode orwmPersistent,957 MainScreen.UnitStatDlg.ShowNewContent_OwnModel(wmPersistent, 951 958 lix and cpIndex) 952 959 else if (lix and cpType = 0) and (lix <> cpImp + imTrGoods) then 953 HelpDlg.ShowNewContent(FWindowMode orwmPersistent, hkImp,960 MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkImp, 954 961 lix and cpIndex); 955 962 kGov: 956 HelpDlg.ShowNewContent(FWindowMode orwmPersistent, hkMisc,957 miscGovList);963 MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkMisc, 964 Integer(miscGovList)); 958 965 kShipPart, kEShipPart: 959 966 ; … … 962 969 else if ssRight in Shift then 963 970 begin 964 if Sel <> -2 then971 if Selected <> -2 then 965 972 case Kind of 966 973 kCities, kCityEvents: … … 976 983 procedure TListDlg.InitLines; 977 984 var 978 required: array [0 .. nAdv - 1] of integer;979 980 procedure TryAddImpLine(Layer, Project: integer);981 begin 982 if Server(sSetCityProject - sExecute, me, cixProject, Project) >= rExecuted985 required: array [0 .. nAdv - 1] of Integer; 986 987 procedure TryAddImpLine(Layer, Project: Integer); 988 begin 989 if Server(sSetCityProject - sExecute, Me, cixProject, Project) >= rExecuted 983 990 then 984 991 begin 985 code[Layer, Lines[Layer]] := Project;986 inc(Lines[Layer]);992 Code[Layer, Lines[Layer]] := Project; 993 Inc(Lines[Layer]); 987 994 end; 988 995 end; … … 990 997 procedure SortTechs; 991 998 var 992 i, j, swap: integer;999 I, J, swap: Integer; 993 1000 begin // sort by advancedness 994 for i:= 0 to Lines[0] - 2 do995 if code[0, i] < adMilitary then996 for j := i+ 1 to Lines[0] - 1 do997 if AdvValue[ code[0, i]] * nAdv + code[0, i] < AdvValue[code[0, j]] *998 nAdv + code[0, j] then999 begin 1000 swap := code[0, i];1001 code[0, i] := code[0, j];1002 code[0, j] := swap;1001 for I := 0 to Lines[0] - 2 do 1002 if Code[0, I] < adMilitary then 1003 for J := I + 1 to Lines[0] - 1 do 1004 if AdvValue[Code[0, I]] * nAdv + Code[0, I] < AdvValue[Code[0, J]] * 1005 nAdv + Code[0, J] then 1006 begin 1007 swap := Code[0, I]; 1008 Code[0, I] := Code[0, J]; 1009 Code[0, J] := swap; 1003 1010 end; 1004 1011 end; … … 1006 1013 procedure SortCities; 1007 1014 var 1008 i, j, swap: integer;1009 begin 1010 for i:= 0 to Lines[0] - 2 do1011 for j := i+ 1 to Lines[0] - 1 do1012 if CityName(MyCity[ code[0, i]].ID) > CityName(MyCity[code[0, j]].ID)1015 I, J, swap: Integer; 1016 begin 1017 for I := 0 to Lines[0] - 2 do 1018 for J := I + 1 to Lines[0] - 1 do 1019 if CityName(MyCity[Code[0, I]].ID) > CityName(MyCity[Code[0, J]].ID) 1013 1020 then 1014 1021 begin 1015 swap := code[0, i];1016 code[0, i] := code[0, j];1017 code[0, j] := swap;1022 swap := Code[0, I]; 1023 Code[0, I] := Code[0, J]; 1024 Code[0, J] := swap; 1018 1025 end; 1019 1026 end; 1020 1027 1021 1028 function ModelSortValue(const mi: TModelInfo; 1022 MixPlayers: boolean = false): integer;1023 begin 1024 result := (mi.Domain + 1) shl 28 - mi.mix;1029 MixPlayers: Boolean = False): Integer; 1030 begin 1031 Result := (mi.Domain + 1) shl 28 - mi.mix; 1025 1032 if MixPlayers then 1026 dec(result, ModelCode(mi) shl 16);1033 Dec(Result, ModelCode(mi) shl 16); 1027 1034 end; 1028 1035 1029 1036 procedure SortModels; 1030 1037 var 1031 i, j, swap: integer;1038 I, J, swap: Integer; 1032 1039 begin // sort by code[2] 1033 for i:= 0 to Lines[0] - 2 do1034 for j := i+ 1 to Lines[0] - 1 do1035 if code[2, i] > code[2, j] then1036 begin 1037 swap := code[0, i];1038 code[0, i] := code[0, j];1039 code[0, j] := swap;1040 swap := code[1, i];1041 code[1, i] := code[1, j];1042 code[1, j] := swap;1043 swap := code[2, i];1044 code[2, i] := code[2, j];1045 code[2, j] := swap;1046 end; 1047 end; 1048 1049 procedure MarkPreqs( i: integer);1050 begin 1051 required[ i] := 1;1052 if MyRO.Tech[ i] < tsSeen then1040 for I := 0 to Lines[0] - 2 do 1041 for J := I + 1 to Lines[0] - 1 do 1042 if Code[2, I] > Code[2, J] then 1043 begin 1044 swap := Code[0, I]; 1045 Code[0, I] := Code[0, J]; 1046 Code[0, J] := swap; 1047 swap := Code[1, I]; 1048 Code[1, I] := Code[1, J]; 1049 Code[1, J] := swap; 1050 swap := Code[2, I]; 1051 Code[2, I] := Code[2, J]; 1052 Code[2, J] := swap; 1053 end; 1054 end; 1055 1056 procedure MarkPreqs(I: Integer); 1057 begin 1058 required[I] := 1; 1059 if MyRO.Tech[I] < tsSeen then 1053 1060 begin 1054 if (AdvPreq[ i, 0] >= 0) then1055 MarkPreqs(AdvPreq[ i, 0]);1056 if (AdvPreq[ i, 1] >= 0) then1057 MarkPreqs(AdvPreq[ i, 1]);1061 if (AdvPreq[I, 0] >= 0) then 1062 MarkPreqs(AdvPreq[I, 0]); 1063 if (AdvPreq[I, 1] >= 0) then 1064 MarkPreqs(AdvPreq[I, 1]); 1058 1065 end; 1059 1066 end; 1060 1067 1061 1068 var 1062 Loc1, i, j, p1, dx, dy, mix, emix, EnemyType, TestEnemyType: integer;1069 Loc1, I, J, p1, dx, dy, mix, emix, EnemyType, TestEnemyType: Integer; 1063 1070 mi: TModelInfo; 1064 1071 PPicture, PTestPicture: ^TModelPicture; 1065 ModelOk: array [0 .. 4095] of boolean;1066 ok: boolean;1067 begin 1068 for i:= 0 to MaxLayer - 1 do1069 begin 1070 Lines[ i] := 0;1071 FirstShrinkedLine[ i] := MaxInt;1072 ModelOk: array [0 .. 4095] of Boolean; 1073 ok: Boolean; 1074 begin 1075 for I := 0 to MaxLayer - 1 do 1076 begin 1077 Lines[I] := 0; 1078 FirstShrinkedLine[I] := MaxInt; 1072 1079 end; 1073 1080 case Kind of … … 1075 1082 begin 1076 1083 // improvements 1077 code[0, 0] := cpImp + imTrGoods;1084 Code[0, 0] := cpImp + imTrGoods; 1078 1085 Lines[0] := 1; 1079 for i:= nWonder to nImp - 1 do1080 if Imp[ i].Kind = ikCommon then1081 TryAddImpLine(0, i+ cpImp);1082 for i:= nWonder to nImp - 1 do1083 if not(Imp[ i].Kind in [ikCommon, ikTrGoods]) and1084 ((MyRO.NatBuilt[ i] = 0) or (Imp[i].Kind = ikNatLocal)) then1085 TryAddImpLine(0, i+ cpImp);1086 for i:= 0 to nCityType - 1 do1087 if MyData.ImpOrder[ i, 0] >= 0 then1088 begin 1089 code[0, Lines[0]] := cpType + i;1090 inc(Lines[0]);1086 for I := nWonder to nImp - 1 do 1087 if Imp[I].Kind = ikCommon then 1088 TryAddImpLine(0, I + cpImp); 1089 for I := nWonder to nImp - 1 do 1090 if not(Imp[I].Kind in [ikCommon, ikTrGoods]) and 1091 ((MyRO.NatBuilt[I] = 0) or (Imp[I].Kind = ikNatLocal)) then 1092 TryAddImpLine(0, I + cpImp); 1093 for I := 0 to nCityType - 1 do 1094 if MyData.ImpOrder[I, 0] >= 0 then 1095 begin 1096 Code[0, Lines[0]] := cpType + I; 1097 Inc(Lines[0]); 1091 1098 end; 1092 1099 1093 1100 // wonders 1094 for i:= 0 to nWonder - 1 do1095 TryAddImpLine(1, i+ cpImp);1101 for I := 0 to nWonder - 1 do 1102 TryAddImpLine(1, I + cpImp); 1096 1103 1097 1104 // units 1098 for i:= 0 to MyRO.nModel - 1 do1105 for I := 0 to MyRO.nModel - 1 do 1099 1106 begin 1100 1107 { if MyModel[i].Kind=mkSlaves then 1101 ok:= MyRO.Wonder[woPyramids].EffectiveOwner= me1102 else } if MyModel[ i].Domain = dSea then1103 begin 1104 ok := false;1108 ok:= MyRO.Wonder[woPyramids].EffectiveOwner=Me 1109 else } if MyModel[I].Domain = dSea then 1110 begin 1111 ok := False; 1105 1112 for dx := -2 to 2 do 1106 1113 for dy := -2 to 2 do … … 1111 1118 ((MyMap[Loc1] and fTerrain = fShore) or 1112 1119 (MyMap[Loc1] and fCanal > 0)) then 1113 ok := true;1120 ok := True; 1114 1121 end; 1115 1122 end 1116 1123 else 1117 ok := true;1124 ok := True; 1118 1125 if ok then 1119 1126 begin 1120 if MyModel[ i].Status and msObsolete = 0 then1127 if MyModel[I].Status and msObsolete = 0 then 1121 1128 begin 1122 code[2, Lines[2]] := i;1123 inc(Lines[2]);1129 Code[2, Lines[2]] := I; 1130 Inc(Lines[2]); 1124 1131 end; 1125 if MyModel[ i].Status and msAllowConscripts <> 0 then1132 if MyModel[I].Status and msAllowConscripts <> 0 then 1126 1133 begin 1127 code[2, Lines[2]] := i+ cpConscripts;1128 inc(Lines[2]);1134 Code[2, Lines[2]] := I + cpConscripts; 1135 Inc(Lines[2]); 1129 1136 end; 1130 1137 end; … … 1140 1147 MarkPreqs(MyData.FarTech); 1141 1148 end; 1142 for i:= 0 to nAdv - 1 do1143 if (( i in FutureTech) or (MyRO.Tech[i] < tsApplicable)) and1144 (Server(sSetResearch - sExecute, me, i, nil^) >= rExecuted) and1145 ((MyData.FarTech = adNone) or (required[ i] > 0)) then1146 begin 1147 code[0, Lines[0]] := i;1148 inc(Lines[0]);1149 for I := 0 to nAdv - 1 do 1150 if ((I in FutureTech) or (MyRO.Tech[I] < tsApplicable)) and 1151 (Server(sSetResearch - sExecute, Me, I, nil^) >= rExecuted) and 1152 ((MyData.FarTech = adNone) or (required[I] > 0)) then 1153 begin 1154 Code[0, Lines[0]] := I; 1155 Inc(Lines[0]); 1149 1156 end; 1150 1157 SortTechs; 1151 1158 if Lines[0] = 0 then // no more techs -- offer nexus 1152 1159 begin 1153 code[0, Lines[0]] := adNexus;1154 inc(Lines[0]);1155 end; 1156 ok := false;1157 for i:= 0 to nDomains - 1 do1158 if (upgrade[ i, 0].Preq = preNone) or1159 (MyRO.Tech[upgrade[ i, 0].Preq] >= tsApplicable) then1160 ok := true;1160 Code[0, Lines[0]] := adNexus; 1161 Inc(Lines[0]); 1162 end; 1163 ok := False; 1164 for I := 0 to nDomains - 1 do 1165 if (upgrade[I, 0].Preq = preNone) or 1166 (MyRO.Tech[upgrade[I, 0].Preq] >= tsApplicable) then 1167 ok := True; 1161 1168 if ok then { new unit class } 1162 1169 begin 1163 code[0, Lines[0]] := adMilitary;1164 inc(Lines[0]);1170 Code[0, Lines[0]] := adMilitary; 1171 Inc(Lines[0]); 1165 1172 end; 1166 1173 end; 1167 1174 kFarAdvance: 1168 1175 begin 1169 code[0, Lines[0]] := adNone;1170 inc(Lines[0]);1171 for i:= 0 to nAdv - 1 do1172 if not( i in FutureTech) and (MyRO.Tech[i] < tsApplicable) and1173 ((AdvValue[ i] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and1174 ((AdvValue[ i] < 1000) or (MyRO.Tech[adScience] > tsNA)) then1175 begin 1176 code[0, Lines[0]] := i;1177 inc(Lines[0]);1176 Code[0, Lines[0]] := adNone; 1177 Inc(Lines[0]); 1178 for I := 0 to nAdv - 1 do 1179 if not(I in FutureTech) and (MyRO.Tech[I] < tsApplicable) and 1180 ((AdvValue[I] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and 1181 ((AdvValue[I] < 1000) or (MyRO.Tech[adScience] > tsNA)) then 1182 begin 1183 Code[0, Lines[0]] := I; 1184 Inc(Lines[0]); 1178 1185 end; 1179 1186 SortTechs; … … 1181 1188 kChooseTech: 1182 1189 begin 1183 for i:= 0 to nAdv - 1 do1184 if not( i in FutureTech) and (MyRO.Tech[i] >= tsApplicable) and1185 (MyRO.EnemyReport[DipMem[ me].pContact].Tech[i] < tsSeen) then1186 begin 1187 code[0, Lines[0]] := i;1188 inc(Lines[0]);1190 for I := 0 to nAdv - 1 do 1191 if not(I in FutureTech) and (MyRO.Tech[I] >= tsApplicable) and 1192 (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] < tsSeen) then 1193 begin 1194 Code[0, Lines[0]] := I; 1195 Inc(Lines[0]); 1189 1196 end; 1190 1197 SortTechs; 1191 1198 // if Lines[0]>1 then 1192 1199 begin 1193 code[0, Lines[0]] := adAll;1194 inc(Lines[0]);1200 Code[0, Lines[0]] := adAll; 1201 Inc(Lines[0]); 1195 1202 end; 1196 1203 end; 1197 1204 kChooseETech: 1198 1205 begin 1199 for i:= 0 to nAdv - 1 do1200 if not( i in FutureTech) and (MyRO.Tech[i] < tsSeen) and1201 (MyRO.EnemyReport[DipMem[ me].pContact].Tech[i] >= tsApplicable) then1202 begin 1203 code[0, Lines[0]] := i;1204 inc(Lines[0]);1206 for I := 0 to nAdv - 1 do 1207 if not(I in FutureTech) and (MyRO.Tech[I] < tsSeen) and 1208 (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] >= tsApplicable) then 1209 begin 1210 Code[0, Lines[0]] := I; 1211 Inc(Lines[0]); 1205 1212 end; 1206 1213 SortTechs; 1207 1214 // if Lines[0]>1 then 1208 1215 begin 1209 code[0, Lines[0]] := adAll;1210 inc(Lines[0]);1216 Code[0, Lines[0]] := adAll; 1217 Inc(Lines[0]); 1211 1218 end; 1212 1219 end; 1213 1220 kStealTech: 1214 1221 begin 1215 for i:= 0 to nAdv - 1 do1216 if Server(sStealTech - sExecute, me, i, nil^) >= rExecuted then1217 begin 1218 code[0, Lines[0]] := i;1219 inc(Lines[0]);1222 for I := 0 to nAdv - 1 do 1223 if Server(sStealTech - sExecute, Me, I, nil^) >= rExecuted then 1224 begin 1225 Code[0, Lines[0]] := I; 1226 Inc(Lines[0]); 1220 1227 end; 1221 1228 SortTechs; … … 1223 1230 kScience: 1224 1231 begin 1225 Column[0] := me;1232 Column[0] := Me; 1226 1233 nColumn := 1; 1227 1234 for EnemyType := 0 to 2 do … … 1241 1248 begin 1242 1249 Column[nColumn] := p1; 1243 inc(nColumn);1250 Inc(nColumn); 1244 1251 end; 1245 1252 end; 1246 for i:= 0 to nAdv - 1 do1247 begin 1248 ok := (MyRO.Tech[ i] <> tsNA) or (MyRO.ResearchTech = i);1249 for j:= 1 to nColumn - 1 do1250 with MyRO.EnemyReport[Column[ j]]^ do1251 if (Tech[ i] <> tsNA) or (TurnOfCivilReport >= 0) and1252 (ResearchTech = i) then1253 ok := true;1253 for I := 0 to nAdv - 1 do 1254 begin 1255 ok := (MyRO.Tech[I] <> tsNA) or (MyRO.ResearchTech = I); 1256 for J := 1 to nColumn - 1 do 1257 with MyRO.EnemyReport[Column[J]]^ do 1258 if (Tech[I] <> tsNA) or (TurnOfCivilReport >= 0) and 1259 (ResearchTech = I) then 1260 ok := True; 1254 1261 if ok then 1255 1262 begin 1256 code[0, Lines[0]] := i;1257 inc(Lines[0]);1263 Code[0, Lines[0]] := I; 1264 Inc(Lines[0]); 1258 1265 end; 1259 1266 end; … … 1261 1268 1262 1269 ok := MyRO.ResearchTech = adMilitary; 1263 for j:= 1 to nColumn - 1 do1264 with MyRO.EnemyReport[Column[ j]]^ do1265 if (MyRO.Alive and (1 shl Column[ j]) <> 0) and1270 for J := 1 to nColumn - 1 do 1271 with MyRO.EnemyReport[Column[J]]^ do 1272 if (MyRO.Alive and (1 shl Column[J]) <> 0) and 1266 1273 (TurnOfCivilReport >= 0) and (ResearchTech = adMilitary) then 1267 ok := true;1274 ok := True; 1268 1275 if ok then 1269 1276 begin 1270 code[0, Lines[0]] := adMilitary;1271 inc(Lines[0]);1277 Code[0, Lines[0]] := adMilitary; 1278 Inc(Lines[0]); 1272 1279 end 1273 1280 end; … … 1275 1282 begin 1276 1283 if ClientMode < scContact then 1277 for i:= 0 to MyRO.nCity - 1 do1278 if MyCity[ i].Loc >= 0 then1284 for I := 0 to MyRO.nCity - 1 do 1285 if MyCity[I].Loc >= 0 then 1279 1286 begin 1280 code[0, Lines[0]] := i;1281 inc(Lines[0]);1287 Code[0, Lines[0]] := I; 1288 Inc(Lines[0]); 1282 1289 end; 1283 1290 SortCities; … … 1286 1293 kCityEvents: 1287 1294 begin 1288 for i:= 0 to MyRO.nCity - 1 do1289 if (MyCity[ i].Loc >= 0) and (MyCity[i].Flags and CityRepMask <> 0)1295 for I := 0 to MyRO.nCity - 1 do 1296 if (MyCity[I].Loc >= 0) and (MyCity[I].Flags and CityRepMask <> 0) 1290 1297 then 1291 1298 begin 1292 code[0, Lines[0]] := i;1293 inc(Lines[0]);1299 Code[0, Lines[0]] := I; 1300 Inc(Lines[0]); 1294 1301 end; 1295 1302 SortCities; … … 1298 1305 { kChooseECity: 1299 1306 begin 1300 for i:=0 to MyRO.nEnemyCity-1 do1301 if (MyRO.EnemyCity[ i].Loc>=0)1302 and (MyRO.EnemyCity[ i].owner=DipMem[me].pContact) then1303 begin code[0,Lines[0]]:=i; inc(Lines[0]); end;1307 for I:=0 to MyRO.nEnemyCity-1 do 1308 if (MyRO.EnemyCity[I].Loc>=0) 1309 and (MyRO.EnemyCity[I].owner=DipMem[Me].pContact) then 1310 begin Code[0,Lines[0]]:=I; Inc(Lines[0]); end; 1304 1311 FirstShrinkedLine:=0 1305 1312 end; } … … 1308 1315 for mix := 0 to MyRO.nModel - 1 do 1309 1316 begin 1310 code[0, mix] := mix;1311 MakeModelInfo( me, mix, MyModel[mix], mi);1312 code[2, mix] := ModelSortValue(mi);1317 Code[0, mix] := mix; 1318 MakeModelInfo(Me, mix, MyModel[mix], mi); 1319 Code[2, mix] := ModelSortValue(mi); 1313 1320 end; 1314 1321 Lines[0] := MyRO.nModel; … … 1320 1327 for mix := 3 to MyRO.nModel - 1 do 1321 1328 begin // check if opponent already has this model 1322 MakeModelInfo( me, mix, MyModel[mix], mi);1323 ok := true;1329 MakeModelInfo(Me, mix, MyModel[mix], mi); 1330 ok := True; 1324 1331 for emix := 0 to MyRO.nEnemyModel - 1 do 1325 if (MyRO.EnemyModel[emix].Owner = DipMem[ me].pContact) and1332 if (MyRO.EnemyModel[emix].Owner = DipMem[Me].pContact) and 1326 1333 IsSameModel(MyRO.EnemyModel[emix], mi) then 1327 ok := false;1334 ok := False; 1328 1335 if ok then 1329 1336 begin 1330 code[0, Lines[0]] := mix;1331 MakeModelInfo( me, mix, MyModel[mix], mi);1332 code[2, Lines[0]] := ModelSortValue(mi);1333 inc(Lines[0]);1337 Code[0, Lines[0]] := mix; 1338 MakeModelInfo(Me, mix, MyModel[mix], mi); 1339 Code[2, Lines[0]] := ModelSortValue(mi); 1340 Inc(Lines[0]); 1334 1341 end; 1335 1342 end; … … 1337 1344 // if Lines[0]>1 then 1338 1345 begin 1339 code[0, Lines[0]] := mixAll;1340 inc(Lines[0]);;1346 Code[0, Lines[0]] := mixAll; 1347 Inc(Lines[0]);; 1341 1348 end; 1342 1349 FirstShrinkedLine[0] := 0; … … 1345 1352 begin 1346 1353 if MyRO.TestFlags and tfUncover <> 0 then 1347 Server(sGetModels, me, 0, nil^);1354 Server(sGetModels, Me, 0, nil^); 1348 1355 for emix := 0 to MyRO.nEnemyModel - 1 do 1349 ModelOk[emix] := MyRO.EnemyModel[emix].Owner = DipMem[ me].pContact;1356 ModelOk[emix] := MyRO.EnemyModel[emix].Owner = DipMem[Me].pContact; 1350 1357 for mix := 0 to MyRO.nModel - 1 do 1351 1358 begin // don't list models I already have 1352 MakeModelInfo( me, mix, MyModel[mix], mi);1359 MakeModelInfo(Me, mix, MyModel[mix], mi); 1353 1360 for emix := 0 to MyRO.nEnemyModel - 1 do 1354 1361 ModelOk[emix] := ModelOk[emix] and … … 1358 1365 if ModelOk[emix] then 1359 1366 begin 1360 if not Assigned(Tribe[DipMem[ me].pContact].ModelPicture1367 if not Assigned(Tribe[DipMem[Me].pContact].ModelPicture 1361 1368 [MyRO.EnemyModel[emix].mix].HGr) then 1362 1369 InitEnemyModel(emix); 1363 code[0, Lines[0]] := emix;1364 code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix]);1365 inc(Lines[0]);1370 Code[0, Lines[0]] := emix; 1371 Code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix]); 1372 Inc(Lines[0]); 1366 1373 end; 1367 1374 SortModels; 1368 1375 // if not IsMilReportNew(DipMem[me].pContact) or (Lines[0]>1) then 1369 1376 begin 1370 code[0, Lines[0]] := mixAll;1371 inc(Lines[0]);1377 Code[0, Lines[0]] := mixAll; 1378 Inc(Lines[0]); 1372 1379 end; 1373 1380 FirstShrinkedLine[0] := 0; … … 1375 1382 kEModels: 1376 1383 begin 1377 for i:= 0 to MyRO.EnemyReport[pView].nModelCounted - 1 do1378 begin 1379 code[1, Lines[0]] := MyRO.nEnemyModel - 1;1380 while ( code[1, Lines[0]] >= 0) and1381 not((MyRO.EnemyModel[ code[1, Lines[0]]].Owner = pView) and1382 (MyRO.EnemyModel[ code[1, Lines[0]]].mix = i)) do1383 dec(code[1, Lines[0]]);1384 if not Assigned(Tribe[pView].ModelPicture[ i].HGr) then1385 InitEnemyModel( code[1, Lines[0]]);1386 code[0, Lines[0]] := i;1387 code[2, Lines[0]] :=1388 ModelSortValue(MyRO.EnemyModel[ code[1, Lines[0]]]);1389 inc(Lines[0]);1384 for I := 0 to MyRO.EnemyReport[pView].nModelCounted - 1 do 1385 begin 1386 Code[1, Lines[0]] := MyRO.nEnemyModel - 1; 1387 while (Code[1, Lines[0]] >= 0) and 1388 not((MyRO.EnemyModel[Code[1, Lines[0]]].Owner = pView) and 1389 (MyRO.EnemyModel[Code[1, Lines[0]]].mix = I)) do 1390 Dec(Code[1, Lines[0]]); 1391 if not Assigned(Tribe[pView].ModelPicture[I].HGr) then 1392 InitEnemyModel(Code[1, Lines[0]]); 1393 Code[0, Lines[0]] := I; 1394 Code[2, Lines[0]] := 1395 ModelSortValue(MyRO.EnemyModel[Code[1, Lines[0]]]); 1396 Inc(Lines[0]); 1390 1397 end; 1391 1398 SortModels; … … 1394 1401 kAllEModels: 1395 1402 begin 1396 if (MyRO.TestFlags and tfUncover <> 0) or (G.Difficulty[ me] = 0) then1397 Server(sGetModels, me, 0, nil^);1403 if (MyRO.TestFlags and tfUncover <> 0) or (G.Difficulty[Me] = 0) then 1404 Server(sGetModels, Me, 0, nil^); 1398 1405 for emix := 0 to MyRO.nEnemyModel - 1 do 1399 1406 if (MyRO.EnemyModel[emix].mix >= 3) and … … 1405 1412 if not Assigned(PPicture.HGr) then 1406 1413 InitEnemyModel(emix); 1407 ok := true;1414 ok := True; 1408 1415 if MainScreen.mNames.Checked then 1409 for j:= 0 to Lines[0] - 1 do1416 for J := 0 to Lines[0] - 1 do 1410 1417 begin 1411 PTestPicture := @Tribe[MyRO.EnemyModel[ code[0, j]].Owner]1412 .ModelPicture[MyRO.EnemyModel[ code[0, j]].mix];1418 PTestPicture := @Tribe[MyRO.EnemyModel[Code[0, J]].Owner] 1419 .ModelPicture[MyRO.EnemyModel[Code[0, J]].mix]; 1413 1420 if (PPicture.HGr = PTestPicture.HGr) and 1414 1421 (PPicture.pix = PTestPicture.pix) and 1415 1422 (ModelHash(MyRO.EnemyModel[emix]) 1416 = ModelHash(MyRO.EnemyModel[ code[0, j]])) then1423 = ModelHash(MyRO.EnemyModel[Code[0, J]])) then 1417 1424 begin 1418 code[1, j] := 1;1419 ok := false;1425 Code[1, J] := 1; 1426 ok := False; 1420 1427 Break; 1421 1428 end; … … 1423 1430 if ok then 1424 1431 begin 1425 code[0, Lines[0]] := emix;1426 code[1, Lines[0]] := 0;1427 code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix], true);1428 inc(Lines[0]);1432 Code[0, Lines[0]] := emix; 1433 Code[1, Lines[0]] := 0; 1434 Code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix], True); 1435 Inc(Lines[0]); 1429 1436 end; 1430 1437 end; … … 1433 1440 end; 1434 1441 kTribe: 1435 for i:= 0 to TribeNames.Count - 1 do1436 begin 1437 code[0, Lines[0]] := i;1438 inc(Lines[0]);1442 for I := 0 to TribeNames.Count - 1 do 1443 begin 1444 Code[0, Lines[0]] := I; 1445 Inc(Lines[0]); 1439 1446 end; 1440 1447 (* kDeliver: 1441 if MyRO.Treaty[DipMem[ me].pContact]<trAlliance then1448 if MyRO.Treaty[DipMem[Me].pContact]<trAlliance then 1442 1449 begin // suggest next treaty level 1443 code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[me].pContact]+1;1444 inc(Lines[0]);1445 end; 1446 if MyRO.Treaty[DipMem[ me].pContact]=trNone then1450 Code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]+1; 1451 Inc(Lines[0]); 1452 end; 1453 if MyRO.Treaty[DipMem[Me].pContact]=trNone then 1447 1454 begin // suggest peace 1448 code[0,Lines[0]]:=opTreaty+trPeace;1449 inc(Lines[0]);1450 end; 1451 if MyRO.Treaty[DipMem[ me].pContact]>trNone then1455 Code[0,Lines[0]]:=opTreaty+trPeace; 1456 Inc(Lines[0]); 1457 end; 1458 if MyRO.Treaty[DipMem[Me].pContact]>trNone then 1452 1459 begin // suggest next treaty level 1453 code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;1454 inc(Lines[0]);1460 Code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1; 1461 Inc(Lines[0]); 1455 1462 end; *) 1456 1463 kShipPart: 1457 1464 begin 1458 1465 Lines[0] := 0; 1459 for i:= 0 to nShipPart - 1 do1460 if MyRO.Ship[ me].Parts[i] > 0 then1461 begin 1462 code[0, Lines[0]] := i;1463 inc(Lines[0]);1466 for I := 0 to nShipPart - 1 do 1467 if MyRO.Ship[Me].Parts[I] > 0 then 1468 begin 1469 Code[0, Lines[0]] := I; 1470 Inc(Lines[0]); 1464 1471 end; 1465 1472 end; … … 1467 1474 begin 1468 1475 Lines[0] := 0; 1469 for i:= 0 to nShipPart - 1 do1470 if MyRO.Ship[DipMem[ me].pContact].Parts[i] > 0 then1471 begin 1472 code[0, Lines[0]] := i;1473 inc(Lines[0]);1476 for I := 0 to nShipPart - 1 do 1477 if MyRO.Ship[DipMem[Me].pContact].Parts[I] > 0 then 1478 begin 1479 Code[0, Lines[0]] := I; 1480 Inc(Lines[0]); 1474 1481 end; 1475 1482 end; 1476 1483 kGov: 1477 for i:= 1 to nGov - 1 do1478 if (GovPreq[ i] <> preNA) and1479 ((GovPreq[ i] = preNone) or (MyRO.Tech[GovPreq[i]] >= tsApplicable))1484 for I := 1 to nGov - 1 do 1485 if (GovPreq[I] <> preNA) and 1486 ((GovPreq[I] = preNone) or (MyRO.Tech[GovPreq[I]] >= tsApplicable)) 1480 1487 then 1481 1488 begin 1482 code[0, Lines[0]] := i;1483 inc(Lines[0]);1489 Code[0, Lines[0]] := I; 1490 Inc(Lines[0]); 1484 1491 end; 1485 1492 kMission: 1486 for i:= 0 to nSpyMission - 1 do1487 begin 1488 code[0, Lines[0]] := i;1489 inc(Lines[0]);1493 for I := 0 to nSpyMission - 1 do 1494 begin 1495 Code[0, Lines[0]] := I; 1496 Inc(Lines[0]); 1490 1497 end; 1491 1498 end; … … 1494 1501 if Lines[0] + Lines[1] + Lines[2] <= MaxLines then 1495 1502 begin 1496 for i:= 0 to Lines[1] - 1 do // add wonders to first page1497 begin 1498 code[0, Lines[0]] := code[1, i];1499 inc(Lines[0]);1503 for I := 0 to Lines[1] - 1 do // add wonders to first page 1504 begin 1505 Code[0, Lines[0]] := Code[1, I]; 1506 Inc(Lines[0]); 1500 1507 end; 1501 1508 Lines[1] := 0; 1502 1509 FirstShrinkedLine[0] := Lines[0]; 1503 for i:= 0 to Lines[2] - 1 do // add models to first page1504 begin 1505 code[0, Lines[0]] := code[2, i];1506 inc(Lines[0]);1510 for I := 0 to Lines[2] - 1 do // add models to first page 1511 begin 1512 Code[0, Lines[0]] := Code[2, I]; 1513 Inc(Lines[0]); 1507 1514 end; 1508 1515 Lines[2] := 0; 1509 1516 end; 1510 end; // InitLines1511 1512 function TListDlg.OnlyChoice(TestKind: TListKind): integer;1517 end; 1518 1519 function TListDlg.OnlyChoice(TestKind: TListKind): Integer; 1513 1520 begin 1514 1521 Kind := TestKind; 1515 1522 InitLines; 1516 1523 if Lines[0] = 0 then 1517 result := -21524 Result := -2 1518 1525 else if Lines[0] > 1 then 1519 result := -11526 Result := -1 1520 1527 else 1521 result := code[0, 0];1528 Result := Code[0, 0]; 1522 1529 end; 1523 1530 1524 1531 procedure TListDlg.FormShow(Sender: TObject); 1525 1532 var 1526 i: integer;1527 begin 1528 result := -1;1529 Closable := false;1533 I: Integer; 1534 begin 1535 Result := -1; 1536 Closable := False; 1530 1537 1531 1538 if Kind = kTribe then … … 1543 1550 InitLines; 1544 1551 1545 MultiPage := false;1546 for i:= 1 to MaxLayer - 1 do1547 if Lines[ i] > 0 then1548 MultiPage := true;1552 MultiPage := False; 1553 for I := 1 to MaxLayer - 1 do 1554 if Lines[I] > 0 then 1555 MultiPage := True; 1549 1556 WideBottom := MultiPage or (Kind = kScience) or 1550 1557 not Phrases2FallenBackToEnglish and … … 1552 1559 if (Kind = kAdvance) and (MyData.FarTech <> adNone) or (Kind = kModels) or 1553 1560 (Kind = kEModels) then begin 1554 sb.SetBorderSpacing(56, 10, 10);1561 ScrollBar.SetBorderSpacing(56, 10, 10); 1555 1562 TitleHeight := WideFrame + 20; 1556 1563 end else begin 1557 sb.SetBorderSpacing(36, 10, 34);1564 ScrollBar.SetBorderSpacing(36, 10, 34); 1558 1565 TitleHeight := WideFrame; 1559 1566 end; 1560 1567 1561 1568 DispLines := Lines[0]; 1562 for i:= 0 to MaxLayer - 1 do1563 if Lines[ i] > DispLines then1564 DispLines := Lines[ i];1569 for I := 0 to MaxLayer - 1 do 1570 if Lines[I] > DispLines then 1571 DispLines := Lines[I]; 1565 1572 if WideBottom then 1566 1573 begin … … 1577 1584 ClientHeight := InnerHeight + TitleHeight + NarrowFrame; 1578 1585 end; 1579 assert(ClientHeight <= Maintexture.Height);1586 Assert(ClientHeight <= Maintexture.Height); 1580 1587 1581 1588 TechNameSpace := 224; … … 1615 1622 CaptionRight := CloseBtn.Left; 1616 1623 { TODO: 1617 SetWindowPos( sb.ScrollBar.Handle, 0, SideFrame + InnerWidth - DpiGetSystemMetrics(SM_CXVSCROLL),1624 SetWindowPos(ScrollBar.ScrollBar.Handle, 0, SideFrame + InnerWidth - DpiGetSystemMetrics(SM_CXVSCROLL), 1618 1625 TitleHeight, DpiGetSystemMetrics(SM_CXVSCROLL), LineDistance * DispLines + 48, 1619 1626 SWP_NOZORDER or SWP_NOREDRAW); … … 1638 1645 Layer0Btn.Top := ClientHeight - 31; 1639 1646 Layer0Btn.Left := ClientWidth div 2 - (12 + 29); 1640 Layer0Btn.Down := true;1647 Layer0Btn.Down := True; 1641 1648 Layer1Btn.Top := ClientHeight - 31; 1642 1649 Layer1Btn.Left := ClientWidth div 2 - (12 - 29); 1643 Layer1Btn.Down := false;1650 Layer1Btn.Down := False; 1644 1651 Layer2Btn.Top := ClientHeight - 31; 1645 1652 Layer2Btn.Left := ClientWidth div 2 - 12; 1646 Layer2Btn.Down := false;1653 Layer2Btn.Down := False; 1647 1654 end; 1648 1655 1649 1656 Layer := 0; 1650 Sel := -2;1657 Selected := -2; 1651 1658 ScienceNation := -1; 1652 sb.Init(Lines[Layer] - 1, DispLines);1659 ScrollBar.Init(Lines[Layer] - 1, DispLines); 1653 1660 1654 1661 OffscreenPaint; 1655 1662 end; 1656 1663 1657 procedure TListDlg.ShowNewContent(NewMode: integer; ListKind: TListKind);1664 procedure TListDlg.ShowNewContent(NewMode: TWindowMode; ListKind: TListKind); 1658 1665 var 1659 i: integer;1660 ShowFocus, forceclose: boolean;1666 I: Integer; 1667 ShowFocus, forceclose: Boolean; 1661 1668 begin 1662 1669 forceclose := (ListKind <> Kind) and … … 1722 1729 if Kind = kAdvance then // show focus button? 1723 1730 if MyData.FarTech <> adNone then 1724 ShowFocus := true1731 ShowFocus := True 1725 1732 else 1726 1733 begin 1727 ShowFocus := false;1728 for i:= 0 to nAdv - 1 do1729 if not( i in FutureTech) and (MyRO.Tech[i] < tsApplicable) and1730 ((AdvValue[ i] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and1731 ((AdvValue[ i] < 1000) or (MyRO.Tech[adScience] > tsNA)) and1732 (Server(sSetResearch - sExecute, me, i, nil^) < rExecuted) then1733 ShowFocus := true;1734 ShowFocus := False; 1735 for I := 0 to nAdv - 1 do 1736 if not(I in FutureTech) and (MyRO.Tech[I] < tsApplicable) and 1737 ((AdvValue[I] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and 1738 ((AdvValue[I] < 1000) or (MyRO.Tech[adScience] > tsNA)) and 1739 (Server(sSetResearch - sExecute, Me, I, nil^) < rExecuted) then 1740 ShowFocus := True; 1734 1741 end; 1735 ToggleBtn.Visible := (Kind = kCities) and not supervising or (Kind = kAdvance)1742 ToggleBtn.Visible := (Kind = kCities) and not Supervising or (Kind = kAdvance) 1736 1743 and ShowFocus or (Kind = kModels) or (Kind = kEModels); 1737 1744 CloseBtn.Visible := not(Kind in MustChooseKind); 1738 1745 1739 1746 inherited ShowNewContent(NewMode, forceclose); 1740 end; // ShowNewContent1741 1742 procedure TListDlg.ShowNewContent_CityProject(NewMode , cix: integer);1747 end; 1748 1749 procedure TListDlg.ShowNewContent_CityProject(NewMode: TWindowMode; cix: Integer); 1743 1750 begin 1744 1751 cixProject := cix; … … 1746 1753 end; 1747 1754 1748 procedure TListDlg.ShowNewContent_MilReport(NewMode , p: integer);1749 begin 1750 pView := p;1751 if p = me then1755 procedure TListDlg.ShowNewContent_MilReport(NewMode: TWindowMode; P: Integer); 1756 begin 1757 pView := P; 1758 if P = Me then 1752 1759 ShowNewContent(NewMode, kModels) 1753 1760 else … … 1757 1764 procedure TListDlg.PlayerClick(Sender: TObject); 1758 1765 begin 1759 if TComponent(Sender).Tag = me then1766 if TComponent(Sender).Tag = Me then 1760 1767 Kind := kModels 1761 1768 else … … 1765 1772 end; 1766 1773 InitLines; 1767 Sel := -2;1768 sb.Init(Lines[Layer] - 1, DispLines);1774 Selected := -2; 1775 ScrollBar.Init(Lines[Layer] - 1, DispLines); 1769 1776 OffscreenPaint; 1770 1777 Invalidate; … … 1778 1785 Layer := TComponent(Sender).Tag; 1779 1786 1780 Sel := -2;1781 sb.Init(Lines[Layer] - 1, DispLines);1787 Selected := -2; 1788 ScrollBar.Init(Lines[Layer] - 1, DispLines); 1782 1789 SmartUpdateContent; 1783 1790 end; … … 1785 1792 procedure TListDlg.ToggleBtnClick(Sender: TObject); 1786 1793 var 1787 p1: integer;1788 m: TDpiMenuItem;1794 p1: Integer; 1795 M: TDpiMenuItem; 1789 1796 begin 1790 1797 case Kind of 1791 1798 kAdvance: 1792 1799 begin 1793 result := adFar;1794 Closable := true;1800 Result := adFar; 1801 Closable := True; 1795 1802 Close; 1796 1803 end; … … 1807 1814 begin 1808 1815 EmptyMenu(Popup.Items); 1809 if G.Difficulty[ me] > 0 then1810 begin 1811 m:= TDpiMenuItem.Create(Popup);1812 m.RadioItem := true;1813 m.Caption := Tribe[me].TPhrase('SHORTNAME');1814 m.Tag := me;1815 m.OnClick := PlayerClick;1816 if G.Difficulty[Me] > 0 then 1817 begin 1818 M := TDpiMenuItem.Create(Popup); 1819 M.RadioItem := True; 1820 M.Caption := Tribe[Me].TPhrase('SHORTNAME'); 1821 M.Tag := Me; 1822 M.OnClick := PlayerClick; 1816 1823 if Kind = kModels then 1817 m.Checked := true;1818 Popup.Items.Add( m);1824 M.Checked := True; 1825 Popup.Items.Add(M); 1819 1826 end; 1820 1827 for p1 := 0 to nPl - 1 do 1821 if (p1 <> me) and (MyRO.EnemyReport[p1] <> nil) and1828 if (p1 <> Me) and (MyRO.EnemyReport[p1] <> nil) and 1822 1829 (MyRO.EnemyReport[p1].TurnOfMilReport >= 0) then 1823 1830 begin 1824 m:= TDpiMenuItem.Create(Popup);1825 m.RadioItem := true;1826 m.Caption := Tribe[p1].TPhrase('SHORTNAME');1827 m.Tag := p1;1828 m.OnClick := PlayerClick;1831 M := TDpiMenuItem.Create(Popup); 1832 M.RadioItem := True; 1833 M.Caption := Tribe[p1].TPhrase('SHORTNAME'); 1834 M.Tag := p1; 1835 M.OnClick := PlayerClick; 1829 1836 if (Kind = kEModels) and (p1 = pView) then 1830 m.Checked := true;1831 Popup.Items.Add( m);1837 M.Checked := True; 1838 Popup.Items.Add(M); 1832 1839 end; 1833 1840 Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top + … … 1837 1844 end; 1838 1845 1839 procedure TListDlg.FormKeyDown(Sender: TObject; var Key: word;1846 procedure TListDlg.FormKeyDown(Sender: TObject; var Key: Word; 1840 1847 Shift: TShiftState); 1841 1848 begin … … 1876 1883 procedure TListDlg.RemoveUnit; 1877 1884 begin 1878 if ListDlg.Visible and (Kind = kModels) then1885 if Visible and (Kind = kModels) then 1879 1886 SmartUpdateContent; 1880 1887 end; … … 1882 1889 procedure TListDlg.ScrollBarUpdate(Sender: TObject); 1883 1890 begin 1884 Sel := -2;1885 SmartUpdateContent( true);1891 Selected := -2; 1892 SmartUpdateContent(True); 1886 1893 end; 1887 1894 -
TabularUnified branches/highdpi/LocalPlayer/TechTree.pas ¶
r349 r465 30 30 end; 31 31 32 var33 TechTreeDlg: TTechTreeDlg;34 35 32 36 33 implementation … … 55 52 yLegendPitch = 32; 56 53 57 function min(a, b: Integer): Integer;58 begin 59 if a < bthen60 result := a54 function Min(A, B: Integer): Integer; 55 begin 56 if A < B then 57 Result := A 61 58 else 62 result := b;63 end; 64 65 function max(a, b: Integer): Integer;66 begin 67 if a > bthen68 result := a59 Result := B; 60 end; 61 62 function Max(A, B: Integer): Integer; 63 begin 64 if A > B then 65 Result := A 69 66 else 70 result := b;67 Result := B; 71 68 end; 72 69 … … 84 81 procedure TTechTreeDlg.FormPaint(Sender: TObject); 85 82 var 86 X, w: Integer;83 X, W: Integer; 87 84 begin 88 85 with Canvas do begin 89 86 // black border 90 brush.color := $000000;91 fillrect(rect(0, 0, BlackBorder, ClientHeight));92 fillrect(rect(BlackBorder, 0, ClientWidth - BlackBorder, BlackBorder));93 fillrect(rect(ClientWidth - BlackBorder, 0, ClientWidth, ClientHeight));94 fillrect(rect(BlackBorder, ClientHeight - BlackBorder,87 Brush.Color := $000000; 88 FillRect(rect(0, 0, BlackBorder, ClientHeight)); 89 FillRect(rect(BlackBorder, 0, ClientWidth - BlackBorder, BlackBorder)); 90 FillRect(rect(ClientWidth - BlackBorder, 0, ClientWidth, ClientHeight)); 91 FillRect(rect(BlackBorder, ClientHeight - BlackBorder, 95 92 ClientWidth - BlackBorder, ClientHeight)); 96 93 97 94 // texturize empty space 98 brush.color := $FFFFFF;95 Brush.Color := $FFFFFF; 99 96 if xOffset > 0 then 100 97 FillRectSeamless(Canvas, BlackBorder, BlackBorder, BlackBorder + xOffset, … … 105 102 ClientWidth - BlackBorder, ClientHeight - BlackBorder, 106 103 -BlackBorder - xOffset, -BlackBorder - yOffset, Paper); 107 X := max(BlackBorder, BlackBorder + xOffset);108 w := min(BlackBorder + xOffset + Image.width, ClientWidth - BlackBorder);104 X := Max(BlackBorder, BlackBorder + xOffset); 105 W := Min(BlackBorder + xOffset + Image.width, ClientWidth - BlackBorder); 109 106 if yOffset > 0 then 110 FillRectSeamless(Canvas, X, BlackBorder, w, BlackBorder + yOffset,107 FillRectSeamless(Canvas, X, BlackBorder, W, BlackBorder + yOffset, 111 108 -BlackBorder - xOffset, -BlackBorder - yOffset, Paper); 112 109 if yOffset + Image.height < ClientHeight - 2 * BlackBorder then 113 FillRectSeamless(Canvas, X, BlackBorder + yOffset + Image.height, w,110 FillRectSeamless(Canvas, X, BlackBorder + yOffset + Image.height, W, 114 111 ClientHeight - BlackBorder, -BlackBorder - xOffset, 115 112 -BlackBorder - yOffset, Paper); 116 113 end; 117 DpiBit Canvas(Canvas, max(BlackBorder, BlackBorder + xOffset),118 max(BlackBorder, BlackBorder + yOffset),119 min(Image.width, min(Image.width + xOffset,120 min(ClientWidth - 2 * BlackBorder, ClientWidth - 2 * BlackBorder - xOffset))121 ), min(Image.height, min(Image.height + yOffset,122 min(ClientHeight - 2 * BlackBorder, ClientHeight - 2 * BlackBorder -123 yOffset))), Image.Canvas, max(0, -xOffset),124 max(0, -yOffset));114 DpiBitBltCanvas(Canvas, Max(BlackBorder, BlackBorder + xOffset), 115 Max(BlackBorder, BlackBorder + yOffset), 116 Min(Image.width, Min(Image.width + xOffset, 117 Min(ClientWidth - 2 * BlackBorder, ClientWidth - 2 * BlackBorder - xOffset)) 118 ), Min(Image.height, Min(Image.height + yOffset, 119 Min(ClientHeight - 2 * BlackBorder, ClientHeight - 2 * BlackBorder - 120 yOffset))), Image.Canvas, Max(0, -xOffset), 121 Max(0, -yOffset)); 125 122 end; 126 123 … … 128 125 var 129 126 X, Y, ad: Integer; 130 s: string;127 S: string; 131 128 NewWidth: Integer; 132 129 NewHeight: Integer; 133 130 begin 131 Caption := Phrases2.Lookup('MENU_ADVTREE'); 134 132 if Image = nil then begin 135 133 Image := TDpiBitmap.Create; … … 139 137 140 138 with Image.Canvas do begin 141 // write advance names139 // Write advance names 142 140 Font.Assign(UniFont[ftSmall]); 143 Font. color := clBlack;144 brush.Style := bsClear;145 for X := 0 to (Image. width - xStart) div xPitch do146 for Y := 0 to (Image. height - yStart) div yPitch do141 Font.Color := clBlack; 142 Brush.Style := bsClear; 143 for X := 0 to (Image.Width - xStart) div xPitch do 144 for Y := 0 to (Image.Height - yStart) div yPitch do 147 145 begin 148 146 ad := Pixels[xStart + X * xPitch + 10, yStart + Y * yPitch - 1]; 149 147 if ad and $FFFF00 = 0 then 150 148 begin 151 s:= Phrases.Lookup('ADVANCES', ad);152 while TextWidth( s) > 112 do153 Delete( s, Length(s), 1);154 TextOut(xStart + X * xPitch + 2, yStart + Y * yPitch, s);149 S := Phrases.Lookup('ADVANCES', ad); 150 while TextWidth(S) > 112 do 151 Delete(S, Length(S), 1); 152 TextOut(xStart + X * xPitch + 2, yStart + Y * yPitch, S); 155 153 Pixels[xStart + X * xPitch + 10, yStart + Y * yPitch - 1] 156 154 := TransparentColor2; 157 end 155 end; 158 156 end; 159 157 160 // write legend158 // Write legend 161 159 TextOut(xLegend, yLegend, Phrases2.Lookup('ADVTREE_UP0')); 162 160 TextOut(xLegend, yLegend + yLegendPitch, Phrases2.Lookup('ADVTREE_UP1')); … … 172 170 end; 173 171 174 // fit window to image, center image in window, center window to screen172 // Fit window to image, center image in window, center window to screen 175 173 NewWidth := Min(DpiScreen.Width - 40, Image.Width + LeftBorder + RightBorder + 2 * BlackBorder); 176 174 NewHeight := Min(DpiScreen.Height - 40, Image.Height + TopBorder + BottomBorder + 2 * BlackBorder); … … 190 188 if Button = mbLeft then 191 189 begin 192 dragging := true;190 Dragging := True; 193 191 xDown := X; 194 192 yDown := Y; … … 199 197 Shift: TShiftState; X, Y: Integer); 200 198 begin 201 dragging := false;199 Dragging := False; 202 200 end; 203 201 … … 205 203 X, Y: Integer); 206 204 begin 207 if dragging then205 if Dragging then 208 206 begin 209 207 xOffset := xOffset + X - xDown; -
TabularUnified branches/highdpi/LocalPlayer/Term.lfm ¶
r405 r465 1 1 object MainScreen: TMainScreen 2 Left = 5162 Left = 469 3 3 Height = 480 4 Top = 8344 Top = 251 5 5 Width = 800 6 6 HorzScrollBar.Visible = False … … 14 14 DesignTimePPI = 144 15 15 Font.Color = clWindowText 16 Font.Height = - 1316 Font.Height = -20 17 17 Font.Name = 'MS Sans Serif' 18 18 KeyPreview = True … … 31 31 OnShow = FormShow 32 32 Position = poDefault 33 LCLVersion = '2. 0.12.0'33 LCLVersion = '2.2.0.4' 34 34 Scaled = False 35 35 WindowState = wsMaximized … … 227 227 Tag = 7 228 228 ShortCut = 112 229 OnClick = MenuClick229 OnClick = mHelpClick 230 230 end 231 231 object mTechTree: TDpiMenuItem 232 232 GroupIndex = 1 233 233 ShortCut = 84 234 OnClick = MenuClick234 OnClick = mTechTreeClick 235 235 end 236 236 object N12: TDpiMenuItem … … 251 251 object mOwnMovement: TDpiMenuItem 252 252 Tag = 30 253 GroupIndex = 1254 RadioItem = True255 253 object mSlowMoves: TDpiMenuItem 256 254 Tag = 75 … … 278 276 object mAllyMovement: TDpiMenuItem 279 277 Tag = 90 280 GroupIndex = 1281 RadioItem = True282 278 object mAlSlowMoves: TDpiMenuItem 283 279 Tag = 91 … … 305 301 object mEnemyMovement: TDpiMenuItem 306 302 Tag = 74 307 GroupIndex = 1308 RadioItem = True309 303 object mEnMoves: TDpiMenuItem 310 304 Tag = 78 … … 349 343 object mRep: TDpiMenuItem 350 344 Tag = 34 351 GroupIndex = 1352 345 object mRep0: TDpiMenuItem 353 346 OnClick = mRepClicked … … 417 410 Caption = '-' 418 411 GroupIndex = 1 412 RadioItem = True 419 413 end 420 414 object mWaitTurn: TDpiMenuItem 421 415 Tag = 32 422 GroupIndex = 1423 416 OnClick = Toggle 424 417 end 425 418 object mScrolling: TDpiMenuItem 426 419 Tag = 84 427 GroupIndex = 1428 420 object mScrollSlow: TDpiMenuItem 429 421 Tag = 85 … … 444 436 object mTileSize: TDpiMenuItem 445 437 Tag = 96 446 GroupIndex = 1447 438 object mSmallTiles: TDpiMenuItem 448 439 Tag = 97 … … 463 454 object mSound: TDpiMenuItem 464 455 Tag = 80 465 GroupIndex = 1466 456 object mSoundOn: TDpiMenuItem 467 457 Tag = 82 … … 484 474 Caption = '-' 485 475 GroupIndex = 1 476 RadioItem = True 486 477 end 487 478 object mTest: TDpiMenuItem 488 479 Tag = 8 489 GroupIndex = 1490 480 object mJump: TDpiMenuItem 491 481 Tag = 54 492 482 ShortCut = 16458 493 OnClick = MenuClick483 OnClick = mJumpClick 494 484 end 495 485 object mRun: TDpiMenuItem 496 486 Tag = 63 497 487 ShortCut = 16466 498 OnClick = MenuClick488 OnClick = mRunClick 499 489 end 500 490 object mNames: TDpiMenuItem … … 552 542 object mEnhanceDef: TDpiMenuItem 553 543 Tag = 40 554 OnClick = MenuClick544 OnClick = mEnhanceDefClick 555 545 end 556 546 object mCityTypes: TDpiMenuItem 557 547 Tag = 11 558 OnClick = MenuClick548 OnClick = mCityTypesClick 559 549 end 560 550 end … … 563 553 GroupIndex = 1 564 554 ShortCut = 16466 565 OnClick = MenuClick555 OnClick = mRandomMapClick 566 556 end 567 557 object N3: TDpiMenuItem … … 572 562 Tag = 88 573 563 GroupIndex = 1 574 OnClick = MenuClick564 OnClick = mWebsiteClick 575 565 end 576 566 object N2: TDpiMenuItem … … 582 572 GroupIndex = 1 583 573 ShortCut = 16465 584 OnClick = MenuClick574 OnClick = mResignClick 585 575 end 586 576 end … … 592 582 Tag = 72 593 583 ShortCut = 16452 594 OnClick = MenuClick584 OnClick = mDisbandOrUtilizeClick 595 585 end 596 586 object mUtilize: TDpiMenuItem 597 587 ShortCut = 90 598 OnClick = MenuClick588 OnClick = mDisbandOrUtilizeClick 599 589 end 600 590 object N1: TDpiMenuItem … … 603 593 object mcity: TDpiMenuItem 604 594 ShortCut = 66 605 OnClick = MenuClick595 OnClick = mcityClick 606 596 end 607 597 object mPillage: TDpiMenuItem 608 598 Tag = 19 609 599 ShortCut = 16464 610 OnClick = MenuClick600 OnClick = mPillageClick 611 601 end 612 602 object N5: TDpiMenuItem … … 615 605 object mhome: TDpiMenuItem 616 606 ShortCut = 72 617 OnClick = MenuClick607 OnClick = mhomeClick 618 608 end 619 609 object mLoad: TDpiMenuItem 620 610 Tag = 24 621 611 ShortCut = 76 622 OnClick = MenuClick612 OnClick = mLoadClick 623 613 end 624 614 object mUnload: TDpiMenuItem 625 615 Tag = 70 626 616 ShortCut = 85 627 OnClick = MenuClick617 OnClick = mUnloadClick 628 618 end 629 619 object mSelectTransport: TDpiMenuItem 630 620 Tag = 73 631 621 ShortCut = 16468 632 OnClick = MenuClick622 OnClick = mSelectTransportClick 633 623 end 634 624 object mGoOn: TDpiMenuItem 635 625 Tag = 13 636 626 ShortCut = 71 637 OnClick = MenuClick627 OnClick = mGoOnClick 638 628 end 639 629 object mCancel: TDpiMenuItem 640 630 Tag = 1 641 631 ShortCut = 16451 642 OnClick = MenuClick632 OnClick = mCancelClick 643 633 end 644 634 object mRecover: TDpiMenuItem 645 635 Tag = 69 646 636 ShortCut = 86 647 OnClick = MenuClick637 OnClick = mRecoverClick 648 638 end 649 639 object mwait: TDpiMenuItem 650 640 Tag = 25 651 641 ShortCut = 87 652 OnClick = MenuClick642 OnClick = mwaitClick 653 643 end 654 644 object mnoorders: TDpiMenuItem 655 645 Tag = 26 656 646 ShortCut = 32 657 OnClick = MenuClick647 OnClick = mnoordersClick 658 648 end 659 649 object mstay: TDpiMenuItem 660 650 Tag = 22 661 651 ShortCut = 83 662 OnClick = MenuClick652 OnClick = mstayClick 663 653 end 664 654 object mCentre: TDpiMenuItem 665 655 Tag = 12 666 656 ShortCut = 67 667 OnClick = MenuClick657 OnClick = mCentreClick 668 658 end 669 659 object N13: TDpiMenuItem … … 673 663 Tag = 100 674 664 ShortCut = 46 675 OnClick = MenuClick665 OnClick = mPrevUnitClick 676 666 end 677 667 object mNextUnit: TDpiMenuItem 678 668 Tag = 101 679 669 ShortCut = 45 680 OnClick = MenuClick670 OnClick = mNextUnitClick 681 671 end 682 672 end … … 688 678 Tag = 9 689 679 ShortCut = 113 690 OnClick = MenuClick680 OnClick = mUnitStatClick 691 681 end 692 682 object mCityStat: TDpiMenuItem 693 683 Tag = 37 694 684 ShortCut = 114 695 OnClick = MenuClick685 OnClick = mCityStatClick 696 686 end 697 687 object mScienceStat: TDpiMenuItem 698 688 Tag = 38 699 689 ShortCut = 115 700 OnClick = MenuClick690 OnClick = mScienceStatClick 701 691 end 702 692 object mEUnitStat: TDpiMenuItem 703 693 Tag = 50 704 694 ShortCut = 116 705 OnClick = MenuClick695 OnClick = mEUnitStatClick 706 696 end 707 697 object mDiagram: TDpiMenuItem 708 698 Tag = 21 709 699 ShortCut = 117 710 OnClick = MenuClick700 OnClick = mDiagramClick 711 701 end 712 702 object mWonders: TDpiMenuItem 713 703 Tag = 6 714 704 ShortCut = 118 715 OnClick = MenuClick705 OnClick = mWondersClick 716 706 end 717 707 object mShips: TDpiMenuItem 718 708 Tag = 41 719 709 ShortCut = 119 720 OnClick = MenuClick710 OnClick = mShipsClick 721 711 end 722 712 object N4: TDpiMenuItem … … 726 716 Tag = 55 727 717 ShortCut = 120 728 OnClick = MenuClick718 OnClick = mNationsClick 729 719 end 730 720 object mEmpire: TDpiMenuItem 731 721 Tag = 3 732 722 ShortCut = 121 733 OnClick = MenuClick723 OnClick = mEmpireClick 734 724 end 735 725 object mRevolution: TDpiMenuItem 736 726 Tag = 89 737 OnClick = MenuClick727 OnClick = mRevolutionClick 738 728 end 739 729 end … … 751 741 Tag = 273 752 742 ShortCut = 79 753 OnClick = MenuClick743 OnClick = mtransClick 754 744 end 755 745 object mAfforest: TDpiMenuItem 756 746 Tag = 301 757 747 ShortCut = 77 758 OnClick = MenuClick748 OnClick = mAfforestClick 759 749 end 760 750 object mClear: TDpiMenuItem 761 751 Tag = 298 762 752 ShortCut = 73 763 OnClick = MenuClick753 OnClick = mClearClick 764 754 end 765 755 object mfort: TDpiMenuItem 766 756 Tag = 276 767 757 ShortCut = 70 768 OnClick = MenuClick758 OnClick = mfortClick 769 759 end 770 760 object mAirBase: TDpiMenuItem 771 761 Tag = 272 772 762 ShortCut = 65 773 OnClick = MenuClick763 OnClick = mAirBaseClick 774 764 end 775 765 object mCanal: TDpiMenuItem 776 766 Tag = 279 777 767 ShortCut = 78 778 OnClick = MenuClick768 OnClick = mCanalClick 779 769 end 780 770 object mmine: TDpiMenuItem 781 771 Tag = 302 782 772 ShortCut = 77 783 OnClick = MenuClick773 OnClick = mmineClick 784 774 end 785 775 object mFarm: TDpiMenuItem 786 776 Tag = 300 787 777 ShortCut = 73 788 OnClick = MenuClick778 OnClick = mFarmClick 789 779 end 790 780 object mirrigation: TDpiMenuItem 791 781 Tag = 299 792 782 ShortCut = 73 793 OnClick = MenuClick794 end 795 object m rr: TDpiMenuItem783 OnClick = mirrigationClick 784 end 785 object mRailRoad: TDpiMenuItem 796 786 Tag = 297 797 787 ShortCut = 82 798 OnClick = MenuClick788 OnClick = mRailRoadClick 799 789 end 800 790 object mroad: TDpiMenuItem 801 791 Tag = 296 802 792 ShortCut = 82 803 OnClick = MenuClick793 OnClick = mroadClick 804 794 end 805 795 object mpollution: TDpiMenuItem 806 796 Tag = 274 807 797 ShortCut = 80 808 OnClick = MenuClick798 OnClick = mpollutionClick 809 799 end 810 800 object mEnhance: TDpiMenuItem 811 801 Tag = 295 812 802 ShortCut = 69 813 OnClick = MenuClick803 OnClick = mEnhanceClick 814 804 end 815 805 end -
TabularUnified branches/highdpi/LocalPlayer/Term.pas ¶
r405 r465 5 5 6 6 uses 7 UDpiControls, {$IFDEF W indows}7 UDpiControls, {$IFDEF WINDOWS} 8 8 Windows, 9 9 {$ENDIF} 10 {$IFDEF Linux}10 {$IFDEF UNIX} 11 11 LMessages, Messages, 12 12 {$ENDIF} … … 14 14 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, DrawDlg, Types, 15 15 Forms, Menus, ExtCtrls, dateutils, Platform, ButtonB, ButtonC, EOTButton, Area, 16 UGraphicSet, UMiniMap, IsoEngine; 16 GraphicSet, MiniMap, IsoEngine, Wonders, TechTree, Enhance, Nego, CityType, 17 Diagram, CityScreen, Rates, Battle, NatStat, UnitStat, Draft, Select, MessgEx, 18 Help; 17 19 18 20 const … … 68 70 mWonders: TDpiMenuItem; 69 71 mScienceStat: TDpiMenuItem; 70 mR R: TDpiMenuItem;72 mRailRoad: TDpiMenuItem; 71 73 mClear: TDpiMenuItem; 72 74 mFarm: TDpiMenuItem; … … 181 183 procedure FormMouseWheel(Sender: TObject; Shift: TShiftState; 182 184 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); 185 procedure mAfforestClick(Sender: TObject); 186 procedure mAirBaseClick(Sender: TObject); 187 procedure mCanalClick(Sender: TObject); 188 procedure mCancelClick(Sender: TObject); 189 procedure mCentreClick(Sender: TObject); 190 procedure mcityClick(Sender: TObject); 191 procedure mCityStatClick(Sender: TObject); 192 procedure mCityTypesClick(Sender: TObject); 193 procedure mClearClick(Sender: TObject); 194 procedure mDiagramClick(Sender: TObject); 195 procedure mEmpireClick(Sender: TObject); 196 procedure mEnhanceClick(Sender: TObject); 197 procedure mEnhanceDefClick(Sender: TObject); 198 procedure mEUnitStatClick(Sender: TObject); 199 procedure mFarmClick(Sender: TObject); 200 procedure mfortClick(Sender: TObject); 201 procedure mGoOnClick(Sender: TObject); 202 procedure mHelpClick(Sender: TObject); 203 procedure mhomeClick(Sender: TObject); 204 procedure mirrigationClick(Sender: TObject); 205 procedure mirrigationDrawItem(Sender: TObject; ACanvas: TDpiCanvas; 206 ARect: TRect; AState: TOwnerDrawState); 207 procedure mJumpClick(Sender: TObject); 208 procedure mLoadClick(Sender: TObject); 209 procedure mmineClick(Sender: TObject); 210 procedure mNationsClick(Sender: TObject); 211 procedure mNextUnitClick(Sender: TObject); 212 procedure mnoordersClick(Sender: TObject); 213 procedure mPillageClick(Sender: TObject); 214 procedure mpollutionClick(Sender: TObject); 215 procedure mPrevUnitClick(Sender: TObject); 216 procedure mRandomMapClick(Sender: TObject); 217 procedure mRecoverClick(Sender: TObject); 218 procedure mResignClick(Sender: TObject); 219 procedure mRevolutionClick(Sender: TObject); 220 procedure mroadClick(Sender: TObject); 221 procedure mRailRoadClick(Sender: TObject); 222 procedure mRunClick(Sender: TObject); 223 procedure mScienceStatClick(Sender: TObject); 224 procedure mSelectTransportClick(Sender: TObject); 225 procedure mShipsClick(Sender: TObject); 226 procedure mstayClick(Sender: TObject); 227 procedure mTechTreeClick(Sender: TObject); 228 procedure mtransClick(Sender: TObject); 229 procedure mUnitStatClick(Sender: TObject); 230 procedure mUnloadClick(Sender: TObject); 231 procedure mwaitClick(Sender: TObject); 232 procedure mWebsiteClick(Sender: TObject); 233 procedure mWondersClick(Sender: TObject); 183 234 procedure Timer1Timer(Sender: TObject); 184 235 procedure MapBoxMouseDown(Sender: TObject; Button: TMouseButton; 185 Shift: TShiftState; x, y: integer);236 Shift: TShiftState; X, Y: Integer); 186 237 procedure EOTClick(Sender: TObject); 187 238 procedure PanelBoxMouseDown(Sender: TObject; Button: TMouseButton; 188 Shift: TShiftState; x, y: integer);189 procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);190 procedure MenuClick(Sender: TObject);239 Shift: TShiftState; X, Y: Integer); 240 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 241 procedure mDisbandOrUtilizeClick(Sender: TObject); 191 242 procedure FormResize(Sender: TObject); 192 243 procedure PanelBtnClick(Sender: TObject); 193 procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);244 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); 194 245 procedure Toggle(Sender: TObject); 195 246 procedure PanelBoxMouseMove(Sender: TObject; Shift: TShiftState; 196 x, y: integer);247 X, Y: Integer); 197 248 procedure PanelBoxMouseUp(Sender: TObject; Button: TMouseButton; 198 Shift: TShiftState; x, y: integer);249 Shift: TShiftState; X, Y: Integer); 199 250 procedure MapBoxMouseMove(Sender: TObject; Shift: TShiftState; 200 x, y: integer);251 X, Y: Integer); 201 252 procedure mShowClick(Sender: TObject); 202 253 procedure FormMouseDown(Sender: TObject; Button: TMouseButton; 203 Shift: TShiftState; x, y: integer);204 procedure FormMouseMove(Sender: TObject; Shift: TShiftState; x, y: integer);254 Shift: TShiftState; X, Y: Integer); 255 procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); 205 256 procedure FormMouseUp(Sender: TObject; Button: TMouseButton; 206 Shift: TShiftState; x, y: integer);257 Shift: TShiftState; X, Y: Integer); 207 258 procedure FormPaint(Sender: TObject); 208 259 procedure mRepClicked(Sender: TObject); … … 214 265 procedure mNamesClick(Sender: TObject); 215 266 procedure MapBtnClick(Sender: TObject); 216 procedure FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);267 procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 217 268 procedure CreateUnitClick(Sender: TObject); 218 269 procedure mSoundOffClick(Sender: TObject); … … 275 326 NoMap: TIsoMap; 276 327 NoMapPanel: TIsoMap; 277 function ChooseUnusedTribe: integer; 328 // Forms 329 FWondersDlg: TWondersDlg; 330 FTechTreeDlg: TTechTreeDlg; 331 FEnhanceDlg: TEnhanceDlg; 332 FNegoDlg: TNegoDlg; 333 FCityTypeDlg: TCityTypeDlg; 334 FDiaDlg: TDiaDlg; 335 FCityDlg: TCityDlg; 336 FRatesDlg: TRatesDlg; 337 FBattleDlg: TBattleDlg; 338 FNatStatDlg: TNatStatDlg; 339 FUnitStatDlg: TUnitStatDlg; 340 FDraftDlg: TDraftDlg; 341 FModalSelectDlg: TModalSelectDlg; 342 FListDlg: TListDlg; 343 FMessgExDlg: TMessgExDlg; 344 FHelpDlg: THelpDlg; 345 procedure ArrangeDialogs; 346 procedure ArrangeDialog(Form: TBufferedDrawDlg); 347 function ChooseUnusedTribe: Integer; 348 function DoJob(j0: Integer): Integer; 349 function GetBattleDlg: TBattleDlg; 350 function GetCityDlg: TCityDlg; 351 function GetCityTypeDlg: TCityTypeDlg; 352 function GetDiaDlg: TDiaDlg; 353 function GetDraftDlg: TDraftDlg; 354 function GetEnhanceDlg: TEnhanceDlg; 355 function GetHelpDlg: THelpDlg; 356 function GetListDlg: TListDlg; 357 function GetMessgExDlg: TMessgExDlg; 358 function GetModalSelectDlg: TModalSelectDlg; 359 function GetNatStatDlg: TNatStatDlg; 360 function GetNegoDlg: TNegoDlg; 361 function GetRatesDlg: TRatesDlg; 362 function GetTechTreeDlg: TTechTreeDlg; 278 363 procedure GetTribeList; 364 function GetUnitStatDlg: TUnitStatDlg; 365 function GetWondersDlg: TWondersDlg; 279 366 procedure InitModule; 280 367 procedure DoneModule; 281 procedure InitTurn(NewPlayer: integer);368 procedure InitTurn(NewPlayer: Integer); 282 369 procedure SaveMenuItemsState; 283 370 procedure ScrollBarUpdate(Sender: TObject); … … 291 378 procedure FocusNextUnit(Dir: Integer = 1); 292 379 procedure NextUnit(NearLoc: Integer; AutoTurn: Boolean); 293 procedure Scroll(dx, dy: integer);294 procedure SetMapPos(Loc: integer; MapPos: TPoint);295 procedure Centre(Loc: integer);296 procedure SetTroopLoc(Loc: integer);297 procedure ProcessRect(x0, y0, nx, ny, Options: integer);298 procedure PaintLoc(Loc: integer; Radius: integer = 0);299 procedure PaintLoc_BeforeMove(FromLoc: integer);300 procedure PaintLocTemp(Loc: integer; Style: TPaintLocTempStyle = pltsNormal);301 procedure PaintBufferToScreen(xMap, yMap, width, height: integer);380 procedure Scroll(dx, dy: Integer); 381 procedure SetMapPos(Loc: Integer; MapPos: TPoint); 382 procedure Centre(Loc: Integer); 383 procedure SetTroopLoc(Loc: Integer); 384 procedure ProcessRect(x0, y0, nx, ny, Options: Integer); 385 procedure PaintLoc(Loc: Integer; Radius: Integer = 0); 386 procedure PaintLoc_BeforeMove(FromLoc: Integer); 387 procedure PaintLocTemp(Loc: Integer; Style: TPaintLocTempStyle = pltsNormal); 388 procedure PaintBufferToScreen(xMap, yMap, width, height: Integer); 302 389 procedure PaintDestination; 303 procedure SetUnFocus(uix: integer);304 function MoveUnit(dx, dy: integer; Options: integer = 0): integer;305 procedure MoveToLoc(Loc: integer; CheckSuicide: boolean);306 procedure MoveOnScreen(ShowMove: TShowMove; Step0, Step1, nStep: integer;307 Restore: boolean = true);308 procedure FocusOnLoc(Loc: integer; Options: integer = 0);309 function EndTurn(WasSkipped: boolean = false): boolean;390 procedure SetUnFocus(uix: Integer); 391 function MoveUnit(dx, dy: Integer; Options: Integer = 0): Integer; 392 procedure MoveToLoc(Loc: Integer; CheckSuicide: Boolean); 393 procedure MoveOnScreen(ShowMove: TShowMove; Step0, Step1, nStep: Integer; 394 Restore: Boolean = True); 395 procedure FocusOnLoc(Loc: Integer; Options: Integer = 0); 396 function EndTurn(WasSkipped: Boolean = False): Boolean; 310 397 procedure EndNego; 311 function IsPanelPixel( x, y: integer): boolean;398 function IsPanelPixel(X, Y: Integer): Boolean; 312 399 procedure InitPopup(Popup: TDpiPopupMenu); 313 400 procedure SetMapOptions; … … 315 402 procedure CheckTerrainBtnVisible; 316 403 procedure RememberPeaceViolation; 317 procedure SetDebugMap( p: integer);318 procedure SetViewpoint( p: integer);319 function LocationOfScreenPixel( x, y: integer): Integer;404 procedure SetDebugMap(P: Integer); 405 procedure SetViewpoint(P: Integer); 406 function LocationOfScreenPixel(X, Y: Integer): Integer; 320 407 function GetCenterLoc: Integer; 321 408 procedure SetTileSizeCenter(TileSize: TTileSize); 322 409 procedure SetTileSize(TileSize: TTileSize; Loc: Integer; MapPos: TPoint); 323 procedure RectInvalidate(Left, Top, Rigth, Bottom: integer);410 procedure RectInvalidate(Left, Top, Rigth, Bottom: Integer); 324 411 procedure ShowEnemyShipChange(ShowShipChange: TShowShipChange); 325 procedure SmartRectInvalidate(Left, Top, Rigth, Bottom: integer);412 procedure SmartRectInvalidate(Left, Top, Rigth, Bottom: Integer); 326 413 procedure LoadSettings; 327 414 procedure SaveSettings; … … 331 418 procedure UpdateKeyShortcuts; 332 419 procedure SetFullScreen(Active: Boolean); 333 procedure PaintZoomedTile(dst: TDpiBitmap; x, y, Loc: integer);420 procedure PaintZoomedTile(dst: TDpiBitmap; X, Y, Loc: Integer); 334 421 public 335 UsedOffscreenWidth, UsedOffscreenHeight: integer; 422 UsedOffscreenWidth: Integer; 423 UsedOffscreenHeight: Integer; 336 424 Offscreen: TDpiBitmap; 337 425 OffscreenUser: TDpiForm; 338 procedure Client(Command, NewPlayer: integer; var Data); 339 procedure SetAIName(p: integer; Name: string); 340 function ZoomToCity(Loc: integer; NextUnitOnClose: boolean = false; 341 ShowEvent: integer = 0): boolean; 342 procedure CityClosed(Activateuix: integer; StepFocus: boolean = false; 343 SelectFocus: boolean = false); 344 function DipCall(Command: integer): integer; 345 function OfferCall(var Offer: TOffer): integer; 346 procedure UpdateViews(UpdateCityScreen: boolean = false); 347 function ContactRefused(p: integer; Item: String): boolean; 426 procedure Client(Command, NewPlayer: Integer; var Data); 427 procedure SetAIName(P: Integer; Name: string); 428 function ZoomToCity(Loc: Integer; NextUnitOnClose: Boolean = False; 429 ShowEvent: Integer = 0): Boolean; 430 procedure CityClosed(Activateuix: Integer; StepFocus: Boolean = False; 431 SelectFocus: Boolean = False); 432 function DipCall(Command: Integer): Integer; 433 function OfferCall(var Offer: TOffer): Integer; 434 procedure UpdateViews(UpdateCityScreen: Boolean = False); 435 function ContactRefused(P: Integer; Item: String): Boolean; 436 // Forms 437 property WondersDlg: TWondersDlg read GetWondersDlg; 438 property TechTreeDlg: TTechTreeDlg read GetTechTreeDlg; 439 property EnhanceDlg: TEnhanceDlg read GetEnhanceDlg; 440 property NegoDlg: TNegoDlg read GetNegoDlg; 441 property CityTypeDlg: TCityTypeDlg read GetCityTypeDlg; 442 property DiaDlg: TDiaDlg read GetDiaDlg; 443 property CityDlg: TCityDlg read GetCityDlg; 444 property RatesDlg: TRatesDlg read GetRatesDlg; 445 property BattleDlg: TBattleDlg read GetBattleDlg; 446 property NatStatDlg: TNatStatDlg read GetNatStatDlg; 447 property UnitStatDlg: TUnitStatDlg read GetUnitStatDlg; 448 property DraftDlg: TDraftDlg read GetDraftDlg; 449 property ModalSelectDlg: TModalSelectDlg read GetModalSelectDlg; 450 property ListDlg: TListDlg read GetListDlg; 451 property MessgExDlg: TMessgExDlg read GetMessgExDlg; 452 property HelpDlg: THelpDlg read GetHelpDlg; 348 453 end; 349 454 … … 352 457 353 458 type 459 460 { TTribeInfo } 461 354 462 TTribeInfo = record 355 trix: integer;463 trix: Integer; 356 464 FileName: ShortString; 357 end; 465 function GetCommandDataSize: Byte; 466 end; 467 468 { TCityNameInfo } 358 469 359 470 TCityNameInfo = record 360 ID: integer;471 ID: Integer; 361 472 NewName: ShortString; 362 end; 473 function GetCommandDataSize: Byte; 474 end; 475 476 { TModelNameInfo } 363 477 364 478 TModelNameInfo = record 365 mix: integer;479 mix: Integer; 366 480 NewName: ShortString; 367 end; 368 369 TPriceSet = set of $00 .. $FF; 481 function GetCommandDataSize: Byte; 482 end; 483 484 TFormAction = (faClose, faEnable, faDisable, faUpdate, faSmartUpdateContent); 370 485 371 486 const … … 410 525 usToldNoReturn = $100; 411 526 usPersistent = usStay or usGoto or usEnhance or usRecover or 412 integer($FFFF0000);527 Integer($FFFF0000); 413 528 414 529 { model status flags } … … 424 539 adNexus = $803; 425 540 426 SpecialModelPictureCode: array [0 .. nSpecialModel - 1] of integer = (10,541 SpecialModelPictureCode: array [0 .. nSpecialModel - 1] of Integer = (10, 427 542 11, 40, 41, 21, 30, { 50,51, } 64, 74, { 71, } 73); 428 543 … … 437 552 438 553 nCityEventPriority = 16; 439 CityEventPriority: array [0 .. nCityEventPriority - 1] of integer =554 CityEventPriority: array [0 .. nCityEventPriority - 1] of Integer = 440 555 (chDisorder, chImprovementLost, chUnitLost, chAllImpsMade, chProduction, 441 556 chOldWonder, chNoSettlerProd, chPopDecrease, chProductionSabotaged, … … 504 619 DestinationMarkON: Boolean; 505 620 StartRunning: Boolean; 506 StayOnTop_Ensured: Boolean;507 621 Supervising: Boolean; 508 622 UnusedTribeFiles: TStringList; … … 512 626 DipMem: array [0 .. nPl - 1] of TDipMem; 513 627 514 function CityEventName( i: integer): string;515 function RoughCredibility(Credibility: integer): integer;516 517 function InitEnemyModel(emix: integer): boolean;628 function CityEventName(I: Integer): string; 629 function RoughCredibility(Credibility: Integer): Integer; 630 631 function InitEnemyModel(emix: Integer): Boolean; 518 632 procedure InitAllEnemyModels; 519 procedure InitMyModel(mix: integer; final: boolean); 520 521 procedure ImpImage(ca: TDpiCanvas; x, y, iix: integer; Government: integer = -1; 522 IsControl: boolean = false); 523 procedure HelpOnTerrain(Loc, NewMode: integer); 633 procedure InitMyModel(Mix: Integer; Final: Boolean); 634 635 procedure ImpImage(ca: TDpiCanvas; X, Y, iix: Integer; Government: Integer = -1; 636 IsControl: Boolean = False); 637 procedure HelpOnTerrain(Loc: Integer; NewMode: TWindowMode); 638 function AlignUp(Value, Alignment: Integer): Integer; 524 639 525 640 … … 527 642 528 643 uses 529 Directories, CityScreen, Draft, MessgEx, Select, CityType, Help, 530 UnitStat, Log, Diagram, NatStat, Wonders, Enhance, Nego, UPixelPointer, Sound, 531 Battle, Rates, TechTree, Registry, Global, UKeyBindings; 644 Directories, Log, PixelPointer, Sound, Registry, Global, KeyBindings, CmdList; 532 645 533 646 {$R *.lfm} … … 536 649 lxmax_xxx = 130; 537 650 LeftPanelWidth = 70; 538 LeftPanelWidth_Editor = 46;539 651 overlap = PanelHeight - MidPanelHeight; 540 652 yTroop = PanelHeight - 83; 541 653 xPalace = 66; 542 654 yPalace = 24; // 120; 543 xAdvisor = 108;544 yAdvisor = 48; 655 { xAdvisor = 108; 656 yAdvisor = 48;} 545 657 xUnitText = 80; 546 PaperShade = 3;547 658 BlinkOnTime = 12; 548 659 BlinkOffTime = 6; 549 660 MoveTime = 300; // {time for moving a unit in ms} 550 661 WaitAfterShowMove = 32; 551 FastScrolling = false; // causes problems with overlapping windows662 FastScrolling = False; // causes problems with overlapping windows 552 663 553 664 nBrushTypes = 26; … … 587 698 CurrentMoveInfo: TCurrentMoveInfo; 588 699 589 function CityEventName( i: integer): string;590 begin 591 if i= 14 then // chAllImpsMade700 function CityEventName(I: Integer): string; 701 begin 702 if I = 14 then // chAllImpsMade 592 703 if not Phrases2FallenBackToEnglish then 593 result := Phrases2.Lookup('CITYEVENT_ALLIMPSMADE')704 Result := Phrases2.Lookup('CITYEVENT_ALLIMPSMADE') 594 705 else 595 result := Phrases.Lookup('CITYEVENTS', 1)706 Result := Phrases.Lookup('CITYEVENTS', 1) 596 707 else 597 result := Phrases.Lookup('CITYEVENTS', i);708 Result := Phrases.Lookup('CITYEVENTS', I); 598 709 end; 599 710 … … 605 716 TBuffer = array [0 .. 99999, 0 .. 2] of Integer; 606 717 var 607 Sum, Cnt, dx, dy, nx, ny, ix, iy, ir, x, y, c, ch: Integer; 718 Sum: Int64; 719 Cnt, dx, dy, nx, ny, ix, iy, ir, X, Y, C, ch: Integer; 608 720 xdivider, ydivider: Integer; 609 721 Resampled: ^TBuffer; … … 611 723 begin 612 724 nx := BigImp.Width div xSizeBig * xSizeSmall; 613 ny := BigImp.Height div ySizeBig * ySizeSmall;614 SmallImp.SetSize(nx, ny);615 SmallImp.Canvas.StretchDraw(Rect(0, 0, SmallImp.Width, SmallImp.Height), BigImp);616 617 { nx := BigImp.Width div xSizeBig * xSizeSmall;618 725 ny := BigImp.Height div ySizeBig * ySizeSmall; 619 726 … … 624 731 for ix := 0 to BigImp.Width div xSizeBig - 1 do 625 732 for iy := 0 to BigImp.Height div ySizeBig - 1 do begin 626 PixelPtr := PixelPointer(BigImp, ScaleToNative(ix * xSizeBig),627 ScaleToNative( cut + iy * ySizeBig));628 for y := 0 to ScaleToNative(ySizeBig - 2 * cut) - 1 do begin629 ydivider := (ScaleFromNative( y) * ySizeSmall div (ySizeBig - 2 * cut) + 1) *630 (ySizeBig - 2 * cut) - ScaleFromNative(y) * ySizeSmall;733 PixelPtr := TPixelPointer.Create(BigImp, ScaleToNative(ix * xSizeBig), 734 ScaleToNative(Cut + iy * ySizeBig)); 735 for Y := 0 to ScaleToNative(ySizeBig - 2 * Cut) - 1 do begin 736 ydivider := (ScaleFromNative(Y) * ySizeSmall div (ySizeBig - 2 * Cut) + 1) * 737 (ySizeBig - 2 * Cut) - ScaleFromNative(Y) * ySizeSmall; 631 738 if ydivider > ySizeSmall then 632 739 ydivider := ySizeSmall; 633 for x:= 0 to ScaleToNative(xSizeBig) - 1 do begin634 ir := ix * xSizeSmall + iy * nx * ySizeSmall + ScaleFromNative( x) *635 xSizeSmall div xSizeBig + ScaleFromNative( y) *636 ySizeSmall div (ySizeBig - 2 * cut) * nx;637 xdivider := (ScaleFromNative( x) * xSizeSmall div xSizeBig + 1) *638 xSizeBig - ScaleFromNative( x) * xSizeSmall;740 for X := 0 to ScaleToNative(xSizeBig) - 1 do begin 741 ir := ix * xSizeSmall + iy * nx * ySizeSmall + ScaleFromNative(X) * 742 xSizeSmall div xSizeBig + ScaleFromNative(Y) * 743 ySizeSmall div (ySizeBig - 2 * Cut) * nx; 744 xdivider := (ScaleFromNative(X) * xSizeSmall div xSizeBig + 1) * 745 xSizeBig - ScaleFromNative(X) * xSizeSmall; 639 746 if xdivider > xSizeSmall then 640 747 xdivider := xSizeSmall; 641 748 for ch := 0 to 2 do begin 642 c:= PixelPtr.Pixel^.Planes[ch];643 Inc(Resampled[ir, ch], c* xdivider * ydivider);749 C := PixelPtr.Pixel^.Planes[ch]; 750 Inc(Resampled[ir, ch], C * xdivider * ydivider); 644 751 if xdivider < xSizeSmall then 645 Inc(Resampled[ir + 1, ch], c* (xSizeSmall - xdivider) *752 Inc(Resampled[ir + 1, ch], C * (xSizeSmall - xdivider) * 646 753 ydivider); 647 754 if ydivider < ySizeSmall then 648 755 Inc(Resampled[ir + nx, ch], 649 c* xdivider * (ySizeSmall - ydivider));756 C * xdivider * (ySizeSmall - ydivider)); 650 757 if (xdivider < xSizeSmall) and (ydivider < ySizeSmall) then 651 Inc(Resampled[ir + nx + 1, ch], c* (xSizeSmall - xdivider) *758 Inc(Resampled[ir + nx + 1, ch], C * (xSizeSmall - xdivider) * 652 759 (ySizeSmall - ydivider)); 653 760 end; … … 662 769 SmallImp.SetSize(nx, ny); 663 770 SmallImp.BeginUpdate; 664 PixelPtr := PixelPointer(SmallImp);665 for y:= 0 to ScaleToNative(ny) - 1 do begin666 for x:= 0 to ScaleToNative(nx) - 1 do begin771 PixelPtr := TPixelPointer.Create(SmallImp); 772 for Y := 0 to ScaleToNative(ny) - 1 do begin 773 for X := 0 to ScaleToNative(nx) - 1 do begin 667 774 for ch := 0 to 2 do begin 668 775 Sum := 0; 669 776 Cnt := 0; 670 777 for dy := -1 to 1 do 671 if ((dy >= 0) or (ScaleFromNative( y) mod ySizeSmall > 0)) and672 ((dy <= 0) or (ScaleFromNative( y) mod ySizeSmall < ySizeSmall - 1)) then778 if ((dy >= 0) or (ScaleFromNative(Y) mod ySizeSmall > 0)) and 779 ((dy <= 0) or (ScaleFromNative(Y) mod ySizeSmall < ySizeSmall - 1)) then 673 780 for dx := -1 to 1 do 674 if ((dx >= 0) or (ScaleFromNative( x) mod xSizeSmall > 0)) and675 ((dx <= 0) or (ScaleFromNative( x) mod xSizeSmall < xSizeSmall - 1)) then781 if ((dx >= 0) or (ScaleFromNative(X) mod xSizeSmall > 0)) and 782 ((dx <= 0) or (ScaleFromNative(X) mod xSizeSmall < xSizeSmall - 1)) then 676 783 begin 677 Inc(Sum, Resampled[ScaleFromNative( x) + dx + nx * (ScaleFromNative(y) + dy), ch]);784 Inc(Sum, Resampled[ScaleFromNative(X) + dx + nx * (ScaleFromNative(Y) + dy), ch]); 678 785 Inc(Cnt); 679 786 end; 680 Sum := ((Cnt * Sharpen + 800) * Resampled[ScaleFromNative( x) + nx * ScaleFromNative(y), ch] - Sum *681 Sharpen) div (800 * xSizeBig * (ySizeBig - 2 * cut));787 Sum := ((Cnt * Sharpen + 800) * Resampled[ScaleFromNative(X) + nx * ScaleFromNative(Y), ch] - Sum * 788 Sharpen) div (800 * xSizeBig * (ySizeBig - 2 * Cut)); 682 789 if Sum < 0 then Sum := 0; 683 790 if Sum > 255 then Sum := 255; … … 690 797 SmallImp.EndUpdate; 691 798 FreeMem(Resampled); 692 } 693 end; 694 695 procedure ImpImage(ca: TDpiCanvas; x, y, iix: integer; Government: integer; 696 IsControl: boolean); 799 end; 800 801 procedure ImpImage(ca: TDpiCanvas; X, Y, iix: Integer; Government: Integer; 802 IsControl: Boolean); 697 803 begin 698 804 if Government < 0 then … … 700 806 if (iix = imPalace) and (Government <> gAnarchy) then 701 807 iix := Government - 8; 702 FrameImage(ca, BigImp, x, y, xSizeBig, ySizeBig, (iix + SystemIconLines * 7)808 FrameImage(ca, BigImp, X, Y, xSizeBig, ySizeBig, (iix + SystemIconLines * 7) 703 809 mod 7 * xSizeBig, (iix + SystemIconLines * 7) div 7 * ySizeBig, IsControl); 704 810 end; 705 811 706 procedure HelpOnTerrain(Loc , NewMode: integer);812 procedure HelpOnTerrain(Loc: Integer; NewMode: TWindowMode); 707 813 begin 708 814 if MyMap[Loc] and fDeadLands <> 0 then 709 HelpDlg.ShowNewContent(NewMode, hkTer, 3 * 12)815 MainScreen.HelpDlg.ShowNewContent(NewMode, hkTer, 3 * 12) 710 816 else if (MyMap[Loc] and fTerrain = fForest) and IsJungle(Loc div G.lx) then 711 HelpDlg.ShowNewContent(NewMode, hkTer,817 MainScreen.HelpDlg.ShowNewContent(NewMode, hkTer, 712 818 fJungle + (MyMap[Loc] shr 5 and 3) * 12) 713 819 else 714 HelpDlg.ShowNewContent(NewMode, hkTer, MyMap[Loc] and fTerrain +820 MainScreen.HelpDlg.ShowNewContent(NewMode, hkTer, MyMap[Loc] and fTerrain + 715 821 (MyMap[Loc] shr 5 and 3) * 12); 716 822 end; 717 823 824 function AlignUp(Value, Alignment: Integer): Integer; 825 begin 826 Result := Value or (Alignment - 1); 827 end; 828 718 829 { *** tribe management procedures *** } 719 830 720 function RoughCredibility(Credibility: integer): integer;831 function RoughCredibility(Credibility: Integer): Integer; 721 832 begin 722 833 case Credibility of 723 834 0 .. 69: 724 result := 0;835 Result := 0; 725 836 70 .. 89: 726 result := 1;837 Result := 1; 727 838 90 .. 99: 728 result := 2;839 Result := 2; 729 840 100: 730 result := 3731 end; 732 end; 733 734 procedure ChooseModelPicture( p, mix, code, Hash, Turn: integer;735 ForceNew, final: boolean);841 Result := 3; 842 end; 843 end; 844 845 procedure ChooseModelPicture(P, mix, Code, Hash, Turn: Integer; 846 ForceNew, final: Boolean); 736 847 var 737 i: integer;848 I: Integer; 738 849 Picture: TModelPictureInfo; 739 IsNew: boolean;740 begin 741 Picture.trix := p;850 IsNew: Boolean; 851 begin 852 Picture.trix := P; 742 853 Picture.mix := mix; 743 if code = 74 then854 if Code = 74 then 744 855 begin // use correct pictures for slaves 745 if Tribe[ p].mixSlaves < 0 then746 if not TribeOriginal[ p] then747 Tribe[ p].mixSlaves := mix856 if Tribe[P].mixSlaves < 0 then 857 if not TribeOriginal[P] then 858 Tribe[P].mixSlaves := mix 748 859 else 749 860 begin 750 i := mix + pshl 16;751 Server(cSetSlaveIndex, 0, 0, i);861 I := mix + P shl 16; 862 Server(cSetSlaveIndex, 0, 0, I); 752 863 end; 753 864 if ToldSlavery = 1 then … … 757 868 Picture.Hash := 0; 758 869 Picture.GrName := 'StdUnits.png'; 759 IsNew := true;870 IsNew := True; 760 871 end 761 872 else 762 873 begin 763 874 Picture.Hash := Hash; 764 IsNew := Tribe[ p].ChooseModelPicture(Picture, code, Turn, ForceNew);875 IsNew := Tribe[P].ChooseModelPicture(Picture, Code, Turn, ForceNew); 765 876 end; 766 877 if final then 767 if not TribeOriginal[ p] then768 Tribe[ p].SetModelPicture(Picture, IsNew)878 if not TribeOriginal[P] then 879 Tribe[P].SetModelPicture(Picture, IsNew) 769 880 else if IsNew then 770 Server( cSetNewModelPicture + (Length(Picture.GrName) + 1 + 16 + 3) div 4,881 Server(CommandWithData(cSetNewModelPicture, Picture.GetCommandDataSize), 771 882 0, 0, Picture) 772 883 else 773 Server( cSetModelPicture + (Length(Picture.GrName) + 1 + 16 + 3) div 4, 0,774 0, Picture)884 Server(CommandWithData(cSetModelPicture, Picture.GetCommandDataSize), 885 0, 0, Picture) 775 886 else 776 with Tribe[ p].ModelPicture[mix] do887 with Tribe[P].ModelPicture[mix] do 777 888 begin 778 889 HGr := LoadGraphicSet(Picture.GrName); … … 781 892 end; 782 893 783 function InitEnemyModel(emix: integer): boolean;894 function InitEnemyModel(emix: Integer): Boolean; 784 895 begin 785 896 if GameMode = cMovie then 786 897 begin 787 result := false;788 exit898 Result := False; 899 Exit; 789 900 end; 790 901 with MyRO.EnemyModel[emix] do 791 902 ChooseModelPicture(Owner, mix, ModelCode(MyRO.EnemyModel[emix]), 792 ModelHash(MyRO.EnemyModel[emix]), MyRO.Turn, false, true);793 result := true;903 ModelHash(MyRO.EnemyModel[emix]), MyRO.Turn, False, True); 904 Result := True; 794 905 end; 795 906 796 907 procedure InitAllEnemyModels; 797 908 var 798 emix: integer;909 emix: Integer; 799 910 begin 800 911 for emix := 0 to MyRO.nEnemyModel - 1 do … … 804 915 end; 805 916 806 procedure InitMyModel( mix: integer; final: boolean);917 procedure InitMyModel(Mix: Integer; Final: Boolean); 807 918 var 808 919 mi: TModelInfo; 809 920 begin 810 921 if (GameMode = cMovie) and (MyModel[mix].Kind < $08) then 811 exit;922 Exit; 812 923 // don't exit for special units because cSetModelPicture comes after TellNewModels 813 MakeModelInfo( me, mix, MyModel[mix], mi);814 ChooseModelPicture( me, mix, ModelCode(mi), ModelHash(mi), MyRO.Turn,815 false, final);816 end; 817 818 function AttackSound( code: integer): string;819 begin 820 result := 'ATTACK_' + char(48 + code div 100 mod 10) +821 char(48 + code div 10 mod 10) + char(48 + code mod 10);822 end; 823 824 procedure CheckToldNoReturn(uix: integer);924 MakeModelInfo(Me, Mix, MyModel[mix], mi); 925 ChooseModelPicture(Me, Mix, ModelCode(mi), ModelHash(mi), MyRO.Turn, 926 False, Final); 927 end; 928 929 function AttackSound(Code: Integer): string; 930 begin 931 Result := 'ATTACK_' + char(48 + Code div 100 mod 10) + 932 char(48 + Code div 10 mod 10) + char(48 + Code mod 10); 933 end; 934 935 procedure CheckToldNoReturn(uix: Integer); 825 936 // check whether aircraft survived low-fuel warning 826 937 begin 827 assert(not supervising);938 Assert(not Supervising); 828 939 with MyUn[uix] do 829 940 if (Status and usToldNoReturn <> 0) and … … 833 944 end; 834 945 835 function CreateTribe( p: integer; FileName: string; Original: boolean): boolean;946 function CreateTribe(P: Integer; FileName: string; Original: Boolean): Boolean; 836 947 begin 837 948 FileName := LocalizedFilePath('Tribes' + DirectorySeparator + FileName + … … 843 954 end; 844 955 845 TribeOriginal[ p] := Original;846 Tribe[ p] := TTribe.Create(FileName);847 with Tribe[ p] do956 TribeOriginal[P] := Original; 957 Tribe[P] := TTribe.Create(FileName); 958 with Tribe[P] do 848 959 begin 849 960 if (GameMode = cNewGame) or not Original then 850 961 begin 851 Term.ChooseModelPicture( p, 0, 010, 1, 0, true, true);852 Term.ChooseModelPicture( p, 1, 040, 1, 0, true, true);853 Term.ChooseModelPicture( p, 2, 041, 1, 0, true, true);854 Term.ChooseModelPicture( p, -1, 017, 1, 0, true, true);855 end; 856 DipMem[ p].pContact := -1;857 end; 858 result := true;962 Term.ChooseModelPicture(P, 0, 010, 1, 0, True, True); 963 Term.ChooseModelPicture(P, 1, 040, 1, 0, True, True); 964 Term.ChooseModelPicture(P, 2, 041, 1, 0, True, True); 965 Term.ChooseModelPicture(P, -1, 017, 1, 0, True, True); 966 end; 967 DipMem[P].pContact := -1; 968 end; 969 Result := True; 859 970 end; 860 971 861 972 procedure TellNewContacts; 862 973 var 863 p1: integer;864 begin 865 if not supervising then974 p1: Integer; 975 begin 976 if not Supervising then 866 977 for p1 := 0 to nPl - 1 do 867 if (p1 <> me) and (1 shl p1 and MyData.ToldContact = 0) and978 if (p1 <> Me) and (1 shl p1 and MyData.ToldContact = 0) and 868 979 (1 shl p1 and MyRO.Alive <> 0) and (MyRO.Treaty[p1] > trNoContact) then 869 980 begin 870 981 TribeMessage(p1, Tribe[p1].TPhrase('FRNEWNATION'), ''); 871 982 MyData.ToldContact := MyData.ToldContact or (1 shl p1); 872 end 983 end; 873 984 end; 874 985 875 986 procedure TellNewModels; 876 987 var 877 mix: integer;988 mix: Integer; 878 989 ModelNameInfo: TModelNameInfo; 879 990 begin 880 if supervising then881 exit;882 with Tribe[ me] do991 if Supervising then 992 Exit; 993 with Tribe[Me] do 883 994 while MyData.ToldModels < MyRO.nModel do 884 995 begin { new Unit class available } … … 891 1002 end; 892 1003 if not Assigned(ModelPicture[MyData.ToldModels].HGr) then 893 InitMyModel(MyData.ToldModels, true);1004 InitMyModel(MyData.ToldModels, True); 894 1005 { only run if no researched model } 895 with M essgExDlg do1006 with MainScreen.MessgExDlg do 896 1007 begin 897 1008 { MakeModelInfo(me,MyData.ToldModels,MyModel[MyData.ToldModels],mi); … … 919 1030 ModelNameInfo.mix := MyData.ToldModels; 920 1031 ModelNameInfo.NewName := EInput.Text; 921 Server(cSetModelName + (Length(ModelNameInfo.NewName) + 1 + 4 + 3) 922 div 4, me, 0, ModelNameInfo); 1032 if ModelNameInfo.GetCommandDataSize > CommandDataMaxSize then 1033 Delete(ModelNameInfo.NewName, Length(ModelNameInfo.NewName) - 1034 (ModelNameInfo.GetCommandDataSize - 1 - CommandDataMaxSize), MaxInt); 1035 Server(CommandWithData(cSetModelName, ModelNameInfo.GetCommandDataSize), 1036 Me, 0, ModelNameInfo); 923 1037 end; 924 1038 end; … … 929 1043 MyModel[mix].Status := MyModel[mix].Status or msObsolete; 930 1044 end; 931 inc(MyData.ToldModels); 932 end; 933 end; 934 935 procedure TMainScreen.PaintZoomedTile(dst: TDpiBitmap; x, y, Loc: integer); 936 937 procedure TSprite(xDst, yDst, xSrc, ySrc: integer); 1045 Inc(MyData.ToldModels); 1046 end; 1047 end; 1048 1049 { TTribeInfo } 1050 1051 function TTribeInfo.GetCommandDataSize: Byte; 1052 begin 1053 Result := SizeOf(trix) + 1 + Length(FileName) 1054 end; 1055 1056 { TModelNameInfo } 1057 1058 function TModelNameInfo.GetCommandDataSize: Byte; 1059 begin 1060 Result := SizeOf(mix) + 1 + Length(NewName); 1061 end; 1062 1063 { TCityNameInfo } 1064 1065 function TCityNameInfo.GetCommandDataSize: Byte; 1066 begin 1067 Result := SizeOf(ID) + 1 + Length(NewName); 1068 end; 1069 1070 procedure TMainScreen.PaintZoomedTile(dst: TDpiBitmap; X, Y, Loc: Integer); 1071 1072 procedure TSprite(xDst, yDst, xSrc, ySrc: Integer); 938 1073 begin 939 1074 with NoMapPanel do 940 Sprite(dst, HGrTerrain, x + xDst, y+ yDst, xxt * 2, yyt * 3,1075 Sprite(dst, HGrTerrain, X + xDst, Y + yDst, xxt * 2, yyt * 3, 941 1076 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 942 1077 end; 943 1078 944 procedure TSprite4(xSrc, ySrc: integer);1079 procedure TSprite4(xSrc, ySrc: Integer); 945 1080 begin 946 1081 with NoMapPanel do begin 947 Sprite(dst, HGrTerrain, x + xxt, y+ yyt + 2, xxt * 2, yyt * 2 - 2,1082 Sprite(dst, HGrTerrain, X + xxt, Y + yyt + 2, xxt * 2, yyt * 2 - 2, 948 1083 1 + xSrc * (xxt * 2 + 1), 3 + yyt + ySrc * (yyt * 3 + 1)); 949 Sprite(dst, HGrTerrain, x + 4, y+ 2 * yyt, xxt * 2 - 4, yyt * 2,1084 Sprite(dst, HGrTerrain, X + 4, Y + 2 * yyt, xxt * 2 - 4, yyt * 2, 950 1085 5 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 951 Sprite(dst, HGrTerrain, x + xxt * 2, y+ 2 * yyt, xxt * 2 - 4, yyt * 2,1086 Sprite(dst, HGrTerrain, X + xxt * 2, Y + 2 * yyt, xxt * 2 - 4, yyt * 2, 952 1087 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 953 Sprite(dst, HGrTerrain, x + xxt, y+ yyt * 3, xxt * 2, yyt * 2 - 2,1088 Sprite(dst, HGrTerrain, X + xxt, Y + yyt * 3, xxt * 2, yyt * 2 - 2, 954 1089 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 955 1090 end; … … 957 1092 958 1093 var 959 cix, ySrc, Tile: integer;1094 cix, ySrc, Tile: Integer; 960 1095 begin 961 1096 with NoMapPanel do begin … … 971 1106 cix := MyRO.nCity - 1; 972 1107 while (cix >= 0) and (MyCity[cix].Loc <> Loc) do 973 dec(cix);974 assert(cix >= 0);1108 Dec(cix); 1109 Assert(cix >= 0); 975 1110 if MyCity[cix].Built[imSupermarket] > 0 then 976 1111 Tile := Tile or tiFarm … … 1063 1198 end; 1064 1199 1065 function ChooseResearch: boolean;1200 function ChooseResearch: Boolean; 1066 1201 var 1067 ChosenResearch: integer;1202 ChosenResearch: Integer; 1068 1203 begin 1069 1204 if (MyData.FarTech <> adNone) and (MyRO.Tech[MyData.FarTech] >= tsApplicable) … … 1073 1208 { research complete -- select new } 1074 1209 repeat 1075 M odalSelectDlg.ShowNewContent(wmModal, kAdvance);1076 if M odalSelectDlg.result < 0 then1210 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kAdvance); 1211 if MainScreen.ModalSelectDlg.Result < 0 then 1077 1212 begin 1078 result := false;1079 exit;1080 end; 1081 ChosenResearch := M odalSelectDlg.result;1213 Result := False; 1214 Exit; 1215 end; 1216 ChosenResearch := MainScreen.ModalSelectDlg.Result; 1082 1217 if ChosenResearch = adMilitary then 1083 1218 begin 1084 DraftDlg.ShowNewContent(wmModal);1085 if DraftDlg.ModalResult <> mrOK then1086 Tribe[ me].ModelPicture[MyRO.nModel].HGr := nil1087 end; 1088 until (ChosenResearch <> adMilitary) or ( DraftDlg.ModalResult = mrOK);1219 MainScreen.DraftDlg.ShowNewContent(wmModal); 1220 if MainScreen.DraftDlg.ModalResult <> mrOK then 1221 Tribe[Me].ModelPicture[MyRO.nModel].HGr := nil; 1222 end; 1223 until (ChosenResearch <> adMilitary) or (MainScreen.DraftDlg.ModalResult = mrOK); 1089 1224 1090 1225 if ChosenResearch = adMilitary then 1091 InitMyModel(MyRO.nModel, true)1226 InitMyModel(MyRO.nModel, True) 1092 1227 else if ChosenResearch = adFar then 1093 1228 begin 1094 M odalSelectDlg.ShowNewContent(wmModal, kFarAdvance);1095 if M odalSelectDlg.result >= 0 then1096 if (M odalSelectDlg.result = adNone) or1097 (Server(sSetResearch - sExecute, me, ModalSelectDlg.result, nil^) <1229 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kFarAdvance); 1230 if MainScreen.ModalSelectDlg.Result >= 0 then 1231 if (MainScreen.ModalSelectDlg.Result = adNone) or 1232 (Server(sSetResearch - sExecute, Me, MainScreen.ModalSelectDlg.Result, nil^) < 1098 1233 rExecuted) then 1099 MyData.FarTech := M odalSelectDlg.result1234 MyData.FarTech := MainScreen.ModalSelectDlg.Result 1100 1235 else 1101 1236 begin 1102 ChosenResearch := M odalSelectDlg.result;1237 ChosenResearch := MainScreen.ModalSelectDlg.Result; 1103 1238 // can be researched immediately 1104 MyData.FarTech := adNone 1239 MyData.FarTech := adNone; 1105 1240 end; 1106 1241 end; … … 1109 1244 MyData.FarTech := adNexus 1110 1245 else 1111 Server(sSetResearch, me, ChosenResearch, nil^); 1112 ListDlg.TechChange; 1113 result := true; 1246 Server(sSetResearch, Me, ChosenResearch, nil^); 1247 MainScreen.ListDlg.TechChange; 1248 Result := True; 1249 end; 1250 1251 procedure ApplyToVisibleForms(FormAction: TFormAction); 1252 var 1253 I: Integer; 1254 Form: TDpiForm; 1255 begin 1256 for I := 0 to DpiScreen.FormCount - 1 do begin 1257 Form := DpiScreen.Forms[I]; 1258 if Form.Visible and (Form is TBufferedDrawDlg) then begin 1259 case FormAction of 1260 faClose: Form.Close; 1261 faEnable: Form.Enabled := True; 1262 faDisable: Form.Enabled := False; 1263 faUpdate: begin 1264 if @Form.OnShow <> nil then Form.OnShow(nil); 1265 Form.Invalidate; 1266 Form.Update; 1267 end; 1268 faSmartUpdateContent: TBufferedDrawDlg(Form).SmartUpdateContent(False); 1269 end; 1270 end; 1271 end; 1114 1272 end; 1115 1273 1116 1274 (* ** client function handling ** *) 1117 1275 1118 function TMainScreen.DipCall(Command: integer): integer;1276 function TMainScreen.DipCall(Command: Integer): Integer; 1119 1277 var 1120 i: integer;1121 IsTreatyDeal: boolean;1122 begin 1123 result := Server(Command, me, 0, nil^);1124 if result >= rExecuted then1278 I: Integer; 1279 IsTreatyDeal: Boolean; 1280 begin 1281 Result := Server(Command, Me, 0, nil^); 1282 if Result >= rExecuted then 1125 1283 begin 1126 1284 if Command and $FF0F = scContact then 1127 1285 begin 1128 DipMem[ me].pContact := Command shr 4 and $F;1286 DipMem[Me].pContact := Command shr 4 and $F; 1129 1287 NegoDlg.Initiate; 1130 DipMem[ me].DeliveredPrices := [];1131 DipMem[ me].ReceivedPrices := [];1132 end; 1133 1134 DipMem[ me].SentCommand := Command;1135 DipMem[ me].FormerTreaty := MyRO.Treaty[DipMem[me].pContact];1288 DipMem[Me].DeliveredPrices := []; 1289 DipMem[Me].ReceivedPrices := []; 1290 end; 1291 1292 DipMem[Me].SentCommand := Command; 1293 DipMem[Me].FormerTreaty := MyRO.Treaty[DipMem[Me].pContact]; 1136 1294 if Command = scDipCancelTreaty then 1137 1295 Play('CANCELTREATY') 1138 1296 else if Command = scDipAccept then 1139 1297 begin // remember delivered and received prices 1140 for i:= 0 to ReceivedOffer.nDeliver - 1 do1141 include(DipMem[me].ReceivedPrices, ReceivedOffer.Price[i] shr 24);1142 for i:= 0 to ReceivedOffer.nCost - 1 do1143 include(DipMem[me].DeliveredPrices,1144 ReceivedOffer.Price[ReceivedOffer.nDeliver + i] shr 24);1145 IsTreatyDeal := false;1146 for i:= 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do1147 if ReceivedOffer.Price[ i] and opMask = opTreaty then1148 IsTreatyDeal := true;1298 for I := 0 to ReceivedOffer.nDeliver - 1 do 1299 Include(DipMem[Me].ReceivedPrices, ReceivedOffer.Price[I] shr 24); 1300 for I := 0 to ReceivedOffer.nCost - 1 do 1301 Include(DipMem[Me].DeliveredPrices, 1302 ReceivedOffer.Price[ReceivedOffer.nDeliver + I] shr 24); 1303 IsTreatyDeal := False; 1304 for I := 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do 1305 if ReceivedOffer.Price[I] and opMask = opTreaty then 1306 IsTreatyDeal := True; 1149 1307 if IsTreatyDeal then 1150 1308 Play('NEWTREATY') … … 1153 1311 end; 1154 1312 CityDlg.CloseAction := None; 1155 if G.RO[DipMem[ me].pContact] <> nil then1313 if G.RO[DipMem[Me].pContact] <> nil then 1156 1314 begin // close windows for next player 1157 for i := 0 to DpiScreen.FormCount - 1 do 1158 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) 1159 then 1160 DpiScreen.Forms[i].Close; 1315 ApplyToVisibleForms(faClose); 1161 1316 end 1162 1317 else … … 1170 1325 end; 1171 1326 1172 function TMainScreen.OfferCall(var Offer: TOffer): integer; 1173 var 1174 i: integer; 1175 begin 1176 result := Server(scDipOffer, me, 0, Offer); 1177 if result >= rExecuted then 1178 begin 1179 DipMem[me].SentCommand := scDipOffer; 1180 DipMem[me].FormerTreaty := MyRO.Treaty[DipMem[me].pContact]; 1181 DipMem[me].SentOffer := Offer; 1327 function TMainScreen.OfferCall(var Offer: TOffer): Integer; 1328 begin 1329 Result := Server(scDipOffer, Me, 0, Offer); 1330 if Result >= rExecuted then 1331 begin 1332 DipMem[Me].SentCommand := scDipOffer; 1333 DipMem[Me].FormerTreaty := MyRO.Treaty[DipMem[Me].pContact]; 1334 DipMem[Me].SentOffer := Offer; 1182 1335 CityDlg.CloseAction := None; 1183 if G.RO[DipMem[ me].pContact] <> nil then1336 if G.RO[DipMem[Me].pContact] <> nil then 1184 1337 begin // close windows for next player 1185 for i := 0 to DpiScreen.FormCount - 1 do 1186 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) 1187 then 1188 DpiScreen.Forms[i].Close; 1338 ApplyToVisibleForms(faClose); 1189 1339 end 1190 1340 else … … 1198 1348 end; 1199 1349 1200 procedure TMainScreen.SetUnFocus(uix: integer);1350 procedure TMainScreen.SetUnFocus(uix: Integer); 1201 1351 var 1202 Loc0: integer;1203 begin 1204 assert(not((uix >= 0) and supervising));1352 Loc0: Integer; 1353 begin 1354 Assert(not((uix >= 0) and Supervising)); 1205 1355 if uix <> UnFocus then 1206 1356 begin 1207 DestinationMarkON := false;1357 DestinationMarkON := False; 1208 1358 PaintDestination; 1209 1359 if uix >= 0 then 1210 1360 UnStartLoc := MyUn[uix].Loc; 1211 BlinkON := false;1361 BlinkON := False; 1212 1362 BlinkTime := -1; 1213 1363 if UnFocus >= 0 then … … 1229 1379 procedure TMainScreen.CheckTerrainBtnVisible; 1230 1380 var 1231 Tile: integer;1381 Tile: Integer; 1232 1382 mox: ^TModel; 1233 1383 begin … … 1241 1391 end 1242 1392 else 1243 TerrainBtn.Visible := false;1393 TerrainBtn.Visible := False; 1244 1394 end; 1245 1395 … … 1249 1399 begin 1250 1400 MovieSpeed1Btn.Down := MovieSpeed = 1; 1251 MovieSpeed1Btn.Visible := true;1401 MovieSpeed1Btn.Visible := True; 1252 1402 MovieSpeed2Btn.Down := MovieSpeed = 2; 1253 MovieSpeed2Btn.Visible := true;1403 MovieSpeed2Btn.Visible := True; 1254 1404 MovieSpeed3Btn.Down := MovieSpeed = 3; 1255 MovieSpeed3Btn.Visible := true;1405 MovieSpeed3Btn.Visible := True; 1256 1406 MovieSpeed4Btn.Down := MovieSpeed = 4; 1257 MovieSpeed4Btn.Visible := true;1407 MovieSpeed4Btn.Visible := True; 1258 1408 end 1259 1409 else 1260 1410 begin 1261 MovieSpeed1Btn.Visible := false;1262 MovieSpeed2Btn.Visible := false;1263 MovieSpeed3Btn.Visible := false;1264 MovieSpeed4Btn.Visible := false;1411 MovieSpeed1Btn.Visible := False; 1412 MovieSpeed2Btn.Visible := False; 1413 MovieSpeed3Btn.Visible := False; 1414 MovieSpeed4Btn.Visible := False; 1265 1415 end; 1266 1416 end; … … 1276 1426 end; 1277 1427 1278 procedure TMainScreen.UpdateViews(UpdateCityScreen: boolean);1428 procedure TMainScreen.UpdateViews(UpdateCityScreen: Boolean); 1279 1429 begin 1280 1430 SumCities(TaxSum, ScienceSum); … … 1286 1436 end; 1287 1437 1288 procedure TMainScreen.SetAIName( p: integer; Name: string);1438 procedure TMainScreen.SetAIName(P: Integer; Name: string); 1289 1439 begin 1290 1440 if Name = '' then 1291 1441 begin 1292 if AILogo[ p] <> nil then1442 if AILogo[P] <> nil then 1293 1443 begin 1294 FreeAndNil(AILogo[ p]);1444 FreeAndNil(AILogo[P]); 1295 1445 end; 1296 1446 end 1297 1447 else 1298 1448 begin 1299 if AILogo[ p] = nil then1300 AILogo[ p] := TDpiBitmap.Create;1301 if not LoadGraphicFile(AILogo[ p], HomeDir + Name + '.png', [gfNoError]) then1449 if AILogo[P] = nil then 1450 AILogo[P] := TDpiBitmap.Create; 1451 if not LoadGraphicFile(AILogo[P], HomeDir + Name + '.png', [gfNoError]) then 1302 1452 begin 1303 FreeAndNil(AILogo[ p]);1304 end; 1305 end; 1306 end; 1307 1308 function TMainScreen.ContactRefused( p: integer; Item: String): boolean;1453 FreeAndNil(AILogo[P]); 1454 end; 1455 end; 1456 end; 1457 1458 function TMainScreen.ContactRefused(P: Integer; Item: String): Boolean; 1309 1459 // return whether treaty was cancelled 1310 1460 var 1311 s: string;1312 begin 1313 assert(MyRO.Treaty[p] >= trPeace);1314 s := Tribe[p].TPhrase(Item);1315 if MyRO.Turn < MyRO.LastCancelTreaty[ p] + CancelTreatyTurns then1316 begin 1317 SimpleMessage( s);1318 result := false;1461 S: string; 1462 begin 1463 Assert(MyRO.Treaty[P] >= trPeace); 1464 S := Tribe[P].TPhrase(Item); 1465 if MyRO.Turn < MyRO.LastCancelTreaty[P] + CancelTreatyTurns then 1466 begin 1467 SimpleMessage(S); 1468 Result := False; 1319 1469 end 1320 1470 else 1321 1471 begin 1322 case MyRO.Treaty[ p] of1472 case MyRO.Treaty[P] of 1323 1473 trPeace: 1324 s := s+ ' ' + Phrases.Lookup('FRCANCELQUERY_PEACE');1474 S := S + ' ' + Phrases.Lookup('FRCANCELQUERY_PEACE'); 1325 1475 trFriendlyContact: 1326 s := s+ ' ' + Phrases.Lookup('FRCANCELQUERY_FRIENDLY');1476 S := S + ' ' + Phrases.Lookup('FRCANCELQUERY_FRIENDLY'); 1327 1477 trAlliance: 1328 s := s+ ' ' + Phrases.Lookup('FRCANCELQUERY_ALLIANCE');1329 end; 1330 result := SimpleQuery(mkYesNo, s, 'NEGO_REJECTED') = mrOK;1331 if result then1478 S := S + ' ' + Phrases.Lookup('FRCANCELQUERY_ALLIANCE'); 1479 end; 1480 Result := SimpleQuery(mkYesNo, S, 'NEGO_REJECTED') = mrOK; 1481 if Result then 1332 1482 begin 1333 1483 Play('CANCELTREATY'); 1334 Server(sCancelTreaty, me, 0, nil^);1335 if MyRO.Treaty[ p] = trNone then1484 Server(sCancelTreaty, Me, 0, nil^); 1485 if MyRO.Treaty[P] = trNone then 1336 1486 CityOptimizer_BeginOfTurn; 1337 1487 // peace treaty was cancelled -- use formerly forbidden tiles 1338 MapValid := false;1488 MapValid := False; 1339 1489 PaintAllMaps; 1340 1490 end; … … 1344 1494 procedure TMainScreen.RememberPeaceViolation; 1345 1495 var 1346 uix, p1: integer;1496 uix, p1: Integer; 1347 1497 begin 1348 1498 MyData.PeaceEvaHappened := 0; … … 1352 1502 begin 1353 1503 p1 := MyRO.Territory[Loc]; 1354 if (p1 <> me) and (p1 >= 0) and1504 if (p1 <> Me) and (p1 >= 0) and 1355 1505 (MyRO.Turn = MyRO.EvaStart[p1] + (PeaceEvaTurns - 1)) then 1356 1506 MyData.PeaceEvaHappened := MyData.PeaceEvaHappened or (1 shl p1); … … 1390 1540 1391 1541 var 1392 i, cix, mix: integer;1393 need: boolean;1542 I, cix, mix: Integer; 1543 need: Boolean; 1394 1544 mi: TModelInfo; 1395 1545 begin 1396 1546 if (sbStart in Check) and not (sbStart in SoundPreloadDone) then begin 1397 for i:= 0 to nStartBlock - 1 do1398 PreparePlay(StartBlock[ i]);1547 for I := 0 to nStartBlock - 1 do 1548 PreparePlay(StartBlock[I]); 1399 1549 SoundPreloadDone := SoundPreloadDone + [sbStart]; 1400 1550 end; 1401 1551 if (sbWonder in Check) and not (sbWonder in SoundPreloadDone) then begin 1402 need := false;1403 for i:= 0 to nWonder - 1 do1404 if MyRO.Wonder[ i].CityID <> WonderNotBuiltYet then1405 need := true;1552 need := False; 1553 for I := 0 to nWonder - 1 do 1554 if MyRO.Wonder[I].CityID <> WonderNotBuiltYet then 1555 need := True; 1406 1556 if need then begin 1407 for i:= 0 to nWonderBlock - 1 do1408 PreparePlay(WonderBlock[ i]);1557 for I := 0 to nWonderBlock - 1 do 1558 PreparePlay(WonderBlock[I]); 1409 1559 SoundPreloadDone := SoundPreloadDone + [sbWonder]; 1410 1560 end; … … 1412 1562 if ((sbScience in Check) and not (sbScience in SoundPreloadDone)) and 1413 1563 (MyRO.Tech[adScience] >= tsApplicable) then begin 1414 for i:= 0 to nScienceBlock - 1 do1415 PreparePlay(ScienceBlock[ i]);1564 for I := 0 to nScienceBlock - 1 do 1565 PreparePlay(ScienceBlock[I]); 1416 1566 SoundPreloadDone := SoundPreloadDone + [sbScience]; 1417 1567 end; 1418 1568 if ((sbContact in Check) and not (sbContact in SoundPreloadDone)) and 1419 1569 (MyRO.nEnemyModel + MyRO.nEnemyCity > 0) then begin 1420 for i:= 0 to nContactBlock - 1 do1421 PreparePlay(ContactBlock[ i]);1570 for I := 0 to nContactBlock - 1 do 1571 PreparePlay(ContactBlock[I]); 1422 1572 SoundPreloadDone := SoundPreloadDone + [sbContact]; 1423 1573 end; … … 1430 1580 with MyCity[cix] do 1431 1581 if (Loc >= 0) and (Flags and CityRepMask <> 0) then 1432 for i:= 0 to 12 do1433 if 1 shl iand Flags and CityRepMask <> 0 then1434 PreparePlay(CityEventSoundItem[ i]);1582 for I := 0 to 12 do 1583 if 1 shl I and Flags and CityRepMask <> 0 then 1584 PreparePlay(CityEventSoundItem[I]); 1435 1585 for mix := 0 to MyRO.nModel - 1 do 1436 1586 with MyModel[mix] do 1437 1587 if Attack > 0 then 1438 1588 begin 1439 MakeModelInfo( me, mix, MyModel[mix], mi);1589 MakeModelInfo(Me, mix, MyModel[mix], mi); 1440 1590 PreparePlay(AttackSound(ModelCode(mi))); 1441 1591 end; … … 1448 1598 Color: TColor; 1449 1599 Name: string; 1450 ok: boolean;1600 ok: Boolean; 1451 1601 begin 1452 1602 UnusedTribeFiles.Clear; … … 1468 1618 end; 1469 1619 1470 function TMainScreen.ChooseUnusedTribe: integer; 1620 function TMainScreen.GetUnitStatDlg: TUnitStatDlg; 1621 begin 1622 if not Assigned(FUnitStatDlg) then begin 1623 FUnitStatDlg := TUnitStatDlg.Create(nil); 1624 ArrangeDialog(FUnitStatDlg); 1625 FUnitStatDlg.CheckAge; 1626 end; 1627 Result := FUnitStatDlg; 1628 end; 1629 1630 function TMainScreen.GetWondersDlg: TWondersDlg; 1631 begin 1632 if not Assigned(FWondersDlg) then FWondersDlg := TWondersDlg.Create(nil); 1633 Result := FWondersDlg; 1634 end; 1635 1636 function TMainScreen.ChooseUnusedTribe: Integer; 1471 1637 var 1472 i: Integer;1473 j: Integer;1638 I: Integer; 1639 J: Integer; 1474 1640 ColorDistance: Integer; 1475 1641 BestColorDistance: Integer; … … 1477 1643 CountBest: Integer; 1478 1644 begin 1479 assert(UnusedTribeFiles.Count > 0);1480 result := -1;1645 Assert(UnusedTribeFiles.Count > 0); 1646 Result := -1; 1481 1647 BestColorDistance := -1; 1482 for j:= 0 to UnusedTribeFiles.Count - 1 do1648 for J := 0 to UnusedTribeFiles.Count - 1 do 1483 1649 begin 1484 1650 ColorDistance := 250; // consider differences more than this infinite 1485 for i:= 0 to nPl - 1 do1486 if Tribe[ i] <> nil then1651 for I := 0 to nPl - 1 do 1652 if Tribe[I] <> nil then 1487 1653 begin 1488 TestColorDistance := abs( integer(UnusedTribeFiles.Objects[j])1489 shr 16 and $FF - Tribe[ i].Color shr 16 and $FF) +1490 abs( integer(UnusedTribeFiles.Objects[j]) shr 8 and1491 $FF - Tribe[ i].Color shr 8 and $FF) * 3 +1492 abs( integer(UnusedTribeFiles.Objects[j]) and1493 $FF - Tribe[ i].Color and $FF) * 2;1654 TestColorDistance := abs(Integer(UnusedTribeFiles.Objects[J]) 1655 shr 16 and $FF - Tribe[I].Color shr 16 and $FF) + 1656 abs(Integer(UnusedTribeFiles.Objects[J]) shr 8 and 1657 $FF - Tribe[I].Color shr 8 and $FF) * 3 + 1658 abs(Integer(UnusedTribeFiles.Objects[J]) and 1659 $FF - Tribe[I].Color and $FF) * 2; 1494 1660 if TestColorDistance < ColorDistance then 1495 1661 ColorDistance := TestColorDistance; … … 1502 1668 if ColorDistance = BestColorDistance then 1503 1669 begin 1504 inc(CountBest);1670 Inc(CountBest); 1505 1671 if DelphiRandom(CountBest) = 0 then 1506 result := j;1672 Result := J; 1507 1673 end; 1508 1674 end; … … 1511 1677 procedure TMainScreen.ShowEnemyShipChange(ShowShipChange: TShowShipChange); 1512 1678 var 1513 i, TestCost, MostCost: integer;1514 Ship1Plus, Ship2Plus: boolean;1679 I, TestCost, MostCost: Integer; 1680 Ship1Plus, Ship2Plus: Boolean; 1515 1681 begin 1516 1682 with ShowShipChange, MessgExDlg do … … 1535 1701 begin 1536 1702 OpenSound := 'SHIP_TRADED'; 1537 Ship1Plus := false;1538 Ship2Plus := false;1539 for i:= 0 to nShipPart - 1 do1703 Ship1Plus := False; 1704 Ship2Plus := False; 1705 for I := 0 to nShipPart - 1 do 1540 1706 begin 1541 if Ship1Change[ i] > 0 then1542 Ship1Plus := true;1543 if Ship2Change[ i] > 0 then1544 Ship2Plus := true;1707 if Ship1Change[I] > 0 then 1708 Ship1Plus := True; 1709 if Ship2Change[I] > 0 then 1710 Ship2Plus := True; 1545 1711 end; 1546 1712 if Ship1Plus and Ship2Plus then … … 1569 1735 begin 1570 1736 MostCost := 0; 1571 for i:= 0 to nShipPart - 1 do1737 for I := 0 to nShipPart - 1 do 1572 1738 begin 1573 TestCost := abs(Ship1Change[ i]) * Imp[imShipComp + i].Cost;1739 TestCost := abs(Ship1Change[I]) * Imp[imShipComp + I].Cost; 1574 1740 if TestCost > MostCost then 1575 1741 begin 1576 1742 MostCost := TestCost; 1577 IconIndex := imShipComp + i;1743 IconIndex := imShipComp + I; 1578 1744 end; 1579 1745 end; … … 1587 1753 procedure TMainScreen.InitModule; 1588 1754 var 1589 i, j, Domain: integer;1755 I, J, Domain: Integer; 1590 1756 begin 1591 1757 { search icons for advances: } 1592 for i:= 0 to nAdv - 1 do1593 if iin FutureTech then1594 AdvIcon[ i] := 96 + i- futResearchTechnology1758 for I := 0 to nAdv - 1 do 1759 if I in FutureTech then 1760 AdvIcon[I] := 96 + I - futResearchTechnology 1595 1761 else 1596 1762 begin 1597 AdvIcon[ i] := -1;1763 AdvIcon[I] := -1; 1598 1764 for Domain := 0 to nDomains - 1 do 1599 for j:= 0 to nUpgrade - 1 do1600 if upgrade[Domain, j].Preq = ithen1601 if AdvIcon[ i] >= 0 then1602 AdvIcon[ i] := 851765 for J := 0 to nUpgrade - 1 do 1766 if upgrade[Domain, J].Preq = I then 1767 if AdvIcon[I] >= 0 then 1768 AdvIcon[I] := 85 1603 1769 else 1604 AdvIcon[ i] := 86 + Domain;1605 for j:= 0 to nFeature - 1 do1606 if Feature[ j].Preq = ithen1770 AdvIcon[I] := 86 + Domain; 1771 for J := 0 to nFeature - 1 do 1772 if Feature[J].Preq = I then 1607 1773 for Domain := 0 to nDomains - 1 do 1608 if 1 shl Domain and Feature[ j].Domains <> 0 then1609 if (AdvIcon[ i] >= 0) and (AdvIcon[i] <> 86 + Domain) then1610 AdvIcon[ i] := 851774 if 1 shl Domain and Feature[J].Domains <> 0 then 1775 if (AdvIcon[I] >= 0) and (AdvIcon[I] <> 86 + Domain) then 1776 AdvIcon[I] := 85 1611 1777 else 1612 AdvIcon[ i] := 86 + Domain;1613 for j:= nWonder to nImp - 1 do1614 if Imp[ j].Preq = ithen1615 AdvIcon[ i] := j;1616 for j:= nWonder to nImp - 1 do1617 if (Imp[ j].Preq = i) and (Imp[j].Kind <> ikCommon) then1618 AdvIcon[ i] := j;1619 for j:= 0 to nJob - 1 do1620 if i = JobPreq[j] then1621 AdvIcon[ i] := 84;1622 for j:= 0 to nWonder - 1 do1623 if Imp[ j].Preq = ithen1624 AdvIcon[ i] := j;1625 if AdvIcon[ i] < 0 then1626 if AdvValue[ i] < 1000 then1627 AdvIcon[ i] := -71778 AdvIcon[I] := 86 + Domain; 1779 for J := nWonder to nImp - 1 do 1780 if Imp[J].Preq = I then 1781 AdvIcon[I] := J; 1782 for J := nWonder to nImp - 1 do 1783 if (Imp[J].Preq = I) and (Imp[J].Kind <> ikCommon) then 1784 AdvIcon[I] := J; 1785 for J := 0 to nJob - 1 do 1786 if I = JobPreq[J] then 1787 AdvIcon[I] := 84; 1788 for J := 0 to nWonder - 1 do 1789 if Imp[J].Preq = I then 1790 AdvIcon[I] := J; 1791 if AdvIcon[I] < 0 then 1792 if AdvValue[I] < 1000 then 1793 AdvIcon[I] := -7 1628 1794 else 1629 AdvIcon[ i] := 24 + AdvValue[i] div 1000;1630 for j:= 2 to nGov - 1 do1631 if GovPreq[ j] = ithen1632 AdvIcon[ i] := j- 8;1795 AdvIcon[I] := 24 + AdvValue[I] div 1000; 1796 for J := 2 to nGov - 1 do 1797 if GovPreq[J] = I then 1798 AdvIcon[I] := J - 8; 1633 1799 end; 1634 1800 AdvIcon[adConscription] := 86 + dGround; 1635 1801 1636 1802 UnusedTribeFiles := tstringlist.Create; 1637 UnusedTribeFiles.Sorted := true;1803 UnusedTribeFiles.Sorted := True; 1638 1804 TribeNames := tstringlist.Create; 1639 1805 1640 1806 IsoEngine.Init(InitEnemyModel); 1641 1807 // non-default tile size is missing a file, switch to default 1642 MainMap.SetOutput( offscreen);1808 MainMap.SetOutput(Offscreen); 1643 1809 1644 1810 HGrStdUnits := LoadGraphicSet('StdUnits.png'); … … 1647 1813 InitSmallImp; 1648 1814 SoundPreloadDone := []; 1649 StartRunning := false; 1650 StayOnTop_Ensured := false; 1815 StartRunning := False; 1651 1816 1652 1817 sb := TPVScrollbar.Create(Self); … … 1659 1824 FreeAndNil(UnusedTribeFiles); 1660 1825 FreeAndNil(TribeNames); 1661 // AdvisorDlg.DeInit; 1662 end; 1663 1664 procedure TMainScreen.InitTurn(NewPlayer: integer); 1826 end; 1827 1828 procedure TMainScreen.InitTurn(NewPlayer: Integer); 1665 1829 const 1666 1830 nAdvBookIcon = 16; 1667 1831 AdvBookIcon: array [0 .. nAdvBookIcon - 1] of record Adv, 1668 Icon: integer end = ((Adv: adPolyTheism; Icon: woZeus),1832 Icon: Integer end = ((Adv: adPolyTheism; Icon: woZeus), 1669 1833 (Adv: adBronzeWorking; Icon: woColossus), (Adv: adMapMaking; 1670 1834 Icon: woLighthouse), (Adv: adPoetry; Icon: imTheater), (Adv: adMonotheism; … … 1678 1842 sbAll = [sbStart, sbWonder, sbScience, sbContact, sbTurn]; 1679 1843 var 1680 p1, i, ad, uix, cix, MoveOptions, MoveResult, Loc1,1844 p1, I, ad, uix, cix, MoveOptions, MoveResult, Loc1, 1681 1845 NewAgeCenterTo, Winners, NewGovAvailable, dx, 1682 dy: integer;1846 dy: Integer; 1683 1847 MoveAdviceData: TMoveAdviceData; 1684 1848 Picture: TModelPictureInfo; 1685 s, Item, Item2: string;1849 S, Item, Item2: string; 1686 1850 UpdatePanel, OwnWonder, ok, Stop, ShowCityList, WondersOnly, 1687 AllowCityScreen: boolean;1688 begin 1689 if IsMultiPlayerGame and (NewPlayer <> me) then1690 begin 1691 UnitInfoBtn.Visible := false;1692 UnitBtn.Visible := false;1693 TerrainBtn.Visible := false;1694 EOT.Visible := false;1695 end; 1696 if IsMultiPlayerGame and (NewPlayer <> me) and1851 AllowCityScreen: Boolean; 1852 begin 1853 if IsMultiPlayerGame and (NewPlayer <> Me) then 1854 begin 1855 UnitInfoBtn.Visible := False; 1856 UnitBtn.Visible := False; 1857 TerrainBtn.Visible := False; 1858 EOT.Visible := False; 1859 end; 1860 if IsMultiPlayerGame and (NewPlayer <> Me) and 1697 1861 (G.RO[0].Happened and phShipComplete = 0) then 1698 1862 begin // inter player screen 1699 for i:= 0 to ControlCount - 1 do1700 if Controls[ i] is TButtonC then1701 Controls[ i].Visible := false;1702 me := -1;1863 for I := 0 to ControlCount - 1 do 1864 if Controls[I] is TButtonC then 1865 Controls[I].Visible := False; 1866 Me := -1; 1703 1867 MainTexture.Age := -1; 1704 1868 with Panel.Canvas do … … 1716 1880 Invalidate; 1717 1881 1718 s:= TurnToString(G.RO[0].Turn);1719 if supervising then1720 SimpleMessage(Format(Phrases.Lookup('SUPERTURN'), [ s]))1882 S := TurnToString(G.RO[0].Turn); 1883 if Supervising then 1884 SimpleMessage(Format(Phrases.Lookup('SUPERTURN'), [S])) 1721 1885 else 1722 SimpleMessage(Format(Tribe[NewPlayer].TPhrase('TURN'), [ s]));1723 end; 1724 for i:= 0 to ControlCount - 1 do1725 if Controls[ i] is TButtonC then1726 Controls[ i].Visible := true;1886 SimpleMessage(Format(Tribe[NewPlayer].TPhrase('TURN'), [S])); 1887 end; 1888 for I := 0 to ControlCount - 1 do 1889 if Controls[I] is TButtonC then 1890 Controls[I].Visible := True; 1727 1891 1728 1892 ItsMeAgain(NewPlayer); 1729 1893 MyData := G.RO[NewPlayer].Data; 1730 if not supervising then1894 if not Supervising then 1731 1895 SoundPreload(sbAll); 1732 if ( me = 0) and ((MyRO.Turn = 0) or (ClientMode = cResume)) then1896 if (Me = 0) and ((MyRO.Turn = 0) or (ClientMode = cResume)) then 1733 1897 Invalidate; // colorize empty space 1734 1898 1735 if not supervising then1899 if not Supervising then 1736 1900 begin 1737 1901 … … 1743 1907 else } 1744 1908 begin 1745 Age := GetAge( me);1909 Age := GetAge(Me); 1746 1910 if MainTexture.Age <> Age then begin 1747 1911 MainTexture.Age := Age; … … 1767 1931 end; 1768 1932 InitCityMark(MainTexture); 1769 CityDlg.CheckAge;1770 NatStatDlg.CheckAge;1771 UnitStatDlg.CheckAge;1772 HelpDlg.Difficulty := G.Difficulty[me];1933 if Assigned(FCityDlg) then FCityDlg.CheckAge; 1934 if Assigned(FNatStatDlg) then FNatStatDlg.CheckAge; 1935 if Assigned(FUnitStatDlg) then FUnitStatDlg.CheckAge; 1936 if Assigned(FHelpDlg) then FHelpDlg.Difficulty := G.Difficulty[Me]; 1773 1937 1774 1938 UnFocus := -1; 1775 1939 MarkCityLoc := -1; 1776 BlinkON := false;1940 BlinkON := False; 1777 1941 BlinkTime := -1; 1778 Tracking := false;1779 TurnComplete := false;1942 Tracking := False; 1943 TurnComplete := False; 1780 1944 1781 1945 if (ToldSlavery < 0) or … … 1797 1961 Hash := 0; 1798 1962 GrName := 'StdUnits.png'; 1799 Tribe[p1].SetModelPicture(Picture, true);1800 end 1801 end; 1802 1803 if not supervising and (ClientMode = cTurn) then1963 Tribe[p1].SetModelPicture(Picture, True); 1964 end; 1965 end; 1966 1967 if not Supervising and (ClientMode = cTurn) then 1804 1968 begin 1805 1969 for cix := 0 to MyRO.nCity - 1 do … … 1816 1980 if ClientMode = cMovieTurn then 1817 1981 begin 1818 UnitInfoBtn.Visible := false;1819 UnitBtn.Visible := false;1820 TerrainBtn.Visible := false;1982 UnitInfoBtn.Visible := False; 1983 UnitBtn.Visible := False; 1984 TerrainBtn.Visible := False; 1821 1985 EOT.Hint := Phrases.Lookup('BTN_STOP'); 1822 EOT.Visible := true;1986 EOT.Visible := True; 1823 1987 end 1824 1988 else if ClientMode < scContact then … … 1827 1991 UnitBtn.Visible := UnFocus >= 0; 1828 1992 CheckTerrainBtnVisible; 1829 TurnComplete := supervising;1993 TurnComplete := Supervising; 1830 1994 EOT.Hint := Phrases.Lookup('BTN_ENDTURN'); 1831 EOT.Visible := Server(sTurn - sExecute, me, 0, nil^) >= rExecuted;1995 EOT.Visible := Server(sTurn - sExecute, Me, 0, nil^) >= rExecuted; 1832 1996 end 1833 1997 else 1834 1998 begin 1835 UnitInfoBtn.Visible := false;1836 UnitBtn.Visible := false;1837 TerrainBtn.Visible := false;1999 UnitInfoBtn.Visible := False; 2000 UnitBtn.Visible := False; 2001 TerrainBtn.Visible := False; 1838 2002 EOT.Hint := Phrases.Lookup('BTN_NEGO'); 1839 EOT.Visible := true;2003 EOT.Visible := True; 1840 2004 end; 1841 2005 SetTroopLoc(-1); 1842 MapValid := false;2006 MapValid := False; 1843 2007 NewAgeCenterTo := 0; 1844 if ((MyRO.Turn = 0) and not supervising or IsMultiPlayerGame or2008 if ((MyRO.Turn = 0) and not Supervising or IsMultiPlayerGame or 1845 2009 (ClientMode = cResume)) and (MyRO.nCity > 0) then 1846 2010 begin … … 1857 2021 begin 1858 2022 NewAgeCenterTo := -1; 1859 Loc1 := dLoc(Loc1, -dx, -dy) 2023 Loc1 := dLoc(Loc1, -dx, -dy); 1860 2024 end 1861 2025 else … … 1865 2029 end 1866 2030 end; 1867 Centre(Loc1) 1868 end; 1869 1870 for i := 0 to DpiScreen.FormCount - 1 do 1871 if DpiScreen.Forms[i] is TBufferedDrawDlg then 1872 DpiScreen.Forms[i].Enabled := true; 2031 Centre(Loc1); 2032 end; 2033 2034 ApplyToVisibleForms(faEnable); 1873 2035 1874 2036 if ClientMode <> cResume then … … 1881 2043 // first turn after anarchy -- don't show despotism palace! 1882 2044 Update; 1883 for i := 0 to DpiScreen.FormCount - 1 do 1884 if (DpiScreen.Forms[i].Visible) and (DpiScreen.Forms[i] is TBufferedDrawDlg) 1885 then 1886 begin 1887 if @DpiScreen.Forms[i].OnShow <> nil then 1888 DpiScreen.Forms[i].OnShow(nil); 1889 DpiScreen.Forms[i].Invalidate; 1890 DpiScreen.Forms[i].Update; 1891 end; 2045 ApplyToVisibleForms(faUpdate); 1892 2046 1893 2047 if MyRO.Happened and phGameEnd <> 0 then … … 1897 2051 begin 1898 2052 OpenSound := 'MSG_GAMEOVER'; 1899 MessgText := Tribe[ me].TPhrase('GAMEOVER');2053 MessgText := Tribe[Me].TPhrase('GAMEOVER'); 1900 2054 IconKind := mikBigIcon; 1901 2055 IconIndex := 8; … … 1908 2062 begin 1909 2063 Winners := Winners or 1 shl p1; 1910 for i:= 0 to nShipPart - 1 do1911 if MyRO.Ship[p1].Parts[ i] < ShipNeed[i] then2064 for I := 0 to nShipPart - 1 do 2065 if MyRO.Ship[p1].Parts[I] < ShipNeed[I] then 1912 2066 Winners := Winners and not(1 shl p1); 1913 2067 end; 1914 assert(Winners <> 0);1915 if Winners and (1 shl me) <> 0 then2068 Assert(Winners <> 0); 2069 if Winners and (1 shl Me) <> 0 then 1916 2070 begin 1917 s:= '';2071 S := ''; 1918 2072 for p1 := 0 to nPl - 1 do 1919 if (p1 <> me) and (1 shl p1 and Winners <> 0) then1920 if s= '' then1921 s:= Tribe[p1].TPhrase('SHORTNAME')2073 if (p1 <> Me) and (1 shl p1 and Winners <> 0) then 2074 if S = '' then 2075 S := Tribe[p1].TPhrase('SHORTNAME') 1922 2076 else 1923 s:= Format(Phrases.Lookup('SHAREDWIN_CONCAT'),1924 [ s, Tribe[p1].TPhrase('SHORTNAME')]);2077 S := Format(Phrases.Lookup('SHAREDWIN_CONCAT'), 2078 [S, Tribe[p1].TPhrase('SHORTNAME')]); 1925 2079 1926 2080 OpenSound := 'MSG_YOUWIN'; 1927 MessgText := Tribe[ me].TPhrase('MYSPACESHIP');1928 if s<> '' then2081 MessgText := Tribe[Me].TPhrase('MYSPACESHIP'); 2082 if S <> '' then 1929 2083 MessgText := MessgText + '\' + 1930 Format(Phrases.Lookup('SHAREDWIN'), [ s]);2084 Format(Phrases.Lookup('SHAREDWIN'), [S]); 1931 2085 IconKind := mikBigIcon; 1932 2086 IconIndex := 9; … … 1934 2088 else 1935 2089 begin 1936 assert(me = 0);2090 Assert(Me = 0); 1937 2091 OpenSound := 'MSG_GAMEOVER'; 1938 2092 MessgText := ''; … … 1946 2100 else { if MyRO.Happened and fTimeUp<>0 then } 1947 2101 begin 1948 assert(me = 0);2102 Assert(Me = 0); 1949 2103 OpenSound := 'MSG_GAMEOVER'; 1950 if not supervising then1951 MessgText := Tribe[ me].TPhrase('TIMEUP')2104 if not Supervising then 2105 MessgText := Tribe[Me].TPhrase('TIMEUP') 1952 2106 else 1953 2107 MessgText := Phrases.Lookup('TIMEUPSUPER'); … … 1961 2115 p1 := 0; 1962 2116 while (p1 < nPl - 1) and (Winners and (1 shl p1) = 0) do 1963 inc(p1);2117 Inc(p1); 1964 2118 if MyRO.Happened and phShipComplete = 0 then 1965 2119 DiaDlg.ShowNewContent_Charts(wmModal); 1966 2120 end; 1967 TurnComplete := true;1968 exit;1969 end; 1970 if not supervising and (1 shl me and MyRO.Alive = 0) then2121 TurnComplete := True; 2122 Exit; 2123 end; 2124 if not Supervising and (1 shl Me and MyRO.Alive = 0) then 1971 2125 begin 1972 TurnComplete := true;1973 exit;2126 TurnComplete := True; 2127 Exit; 1974 2128 end; 1975 2129 1976 2130 if (ClientMode = cContinue) and 1977 (DipMem[ me].SentCommand and $FF0F = scContact) then2131 (DipMem[Me].SentCommand and $FF0F = scContact) then 1978 2132 // contact was refused 1979 if MyRO.Treaty[DipMem[ me].pContact] >= trPeace then1980 ContactRefused(DipMem[ me].pContact, 'FRREJECTED')2133 if MyRO.Treaty[DipMem[Me].pContact] >= trPeace then 2134 ContactRefused(DipMem[Me].pContact, 'FRREJECTED') 1981 2135 else 1982 SoundMessage(Tribe[DipMem[ me].pContact].TPhrase('FRREJECTED'),2136 SoundMessage(Tribe[DipMem[Me].pContact].TPhrase('FRREJECTED'), 1983 2137 'NEGO_REJECTED'); 1984 2138 1985 if not supervising and (Age > MyData.ToldAge) and2139 if not Supervising and (Age > MyData.ToldAge) and 1986 2140 ((Age > 0) or (ClientMode <> cMovieTurn)) then 1987 2141 with MessgExDlg do … … 1991 2145 if Phrases2FallenBackToEnglish then 1992 2146 begin 1993 s := Tribe[me].TPhrase('AGE0');2147 S := Tribe[Me].TPhrase('AGE0'); 1994 2148 MessgText := 1995 Format( s, [TurnToString(MyRO.Turn), CityName(MyCity[0].ID)])2149 Format(S, [TurnToString(MyRO.Turn), CityName(MyCity[0].ID)]); 1996 2150 end 1997 2151 else 1998 2152 begin 1999 s := Tribe[me].TString(Phrases2.Lookup('AGE0'));2000 MessgText := Format( s, [TurnToString(MyRO.Turn)]);2001 end 2153 S := Tribe[Me].TString(Phrases2.Lookup('AGE0')); 2154 MessgText := Format(S, [TurnToString(MyRO.Turn)]); 2155 end; 2002 2156 end 2003 2157 else 2004 2158 begin 2005 s := Tribe[me].TPhrase('AGE' + char(48 + Age));2006 MessgText := Format( s, [TurnToString(MyRO.Turn)]);2159 S := Tribe[Me].TPhrase('AGE' + char(48 + Age)); 2160 MessgText := Format(S, [TurnToString(MyRO.Turn)]); 2007 2161 end; 2008 2162 IconKind := mikAge; … … 2012 2166 CenterTo := NewAgeCenterTo; 2013 2167 OpenSound := 'AGE_' + char(48 + Age); 2168 DpiApplication.ProcessMessages; 2014 2169 ShowModal; 2015 2170 MyData.ToldAge := Age; … … 2025 2180 begin 2026 2181 OpenSound := 'MSG_EXTINCT'; 2027 s:= Tribe[p1].TPhrase('EXTINCT');2028 MessgText := Format( s, [TurnToString(MyRO.Turn)]);2029 if MyRO.Alive = 1 shl me then2182 S := Tribe[p1].TPhrase('EXTINCT'); 2183 MessgText := Format(S, [TurnToString(MyRO.Turn)]); 2184 if MyRO.Alive = 1 shl Me then 2030 2185 MessgText := MessgText + Phrases.Lookup('EXTINCTALL'); 2031 2186 Kind := mkOk; … … 2034 2189 ShowModal; 2035 2190 end; 2036 if (ClientMode <> cMovieTurn) and not supervising then2191 if (ClientMode <> cMovieTurn) and not Supervising then 2037 2192 DiaDlg.ShowNewContent_Charts(wmModal); 2038 2193 end; 2039 2194 2040 2195 // tell changes of own credibility 2041 if not supervising then2196 if not Supervising then 2042 2197 begin 2043 2198 if RoughCredibility(MyRO.Credibility) <> … … 2046 2201 if RoughCredibility(MyRO.Credibility) > 2047 2202 RoughCredibility(MyData.ToldOwnCredibility) then 2048 s:= Phrases.Lookup('CREDUP')2203 S := Phrases.Lookup('CREDUP') 2049 2204 else 2050 s:= Phrases.Lookup('CREDDOWN');2051 TribeMessage( me, Format(s, [Phrases.Lookup('CREDIBILITY',2205 S := Phrases.Lookup('CREDDOWN'); 2206 TribeMessage(Me, Format(S, [Phrases.Lookup('CREDIBILITY', 2052 2207 RoughCredibility(MyRO.Credibility))]), ''); 2053 2208 end; … … 2055 2210 end; 2056 2211 2057 for i:= 0 to nWonder - 1 do2212 for I := 0 to nWonder - 1 do 2058 2213 begin 2059 OwnWonder := false;2214 OwnWonder := False; 2060 2215 for cix := 0 to MyRO.nCity - 1 do 2061 if (MyCity[cix].Loc >= 0) and (MyCity[cix].ID = MyRO.Wonder[ i].CityID)2216 if (MyCity[cix].Loc >= 0) and (MyCity[cix].ID = MyRO.Wonder[I].CityID) 2062 2217 then 2063 OwnWonder := true;2064 if MyRO.Wonder[ i].CityID <> MyData.ToldWonders[i].CityID then2218 OwnWonder := True; 2219 if MyRO.Wonder[I].CityID <> MyData.ToldWonders[I].CityID then 2065 2220 begin 2066 if MyRO.Wonder[ i].CityID = WonderDestroyed then2221 if MyRO.Wonder[I].CityID = WonderDestroyed then 2067 2222 with MessgExDlg do 2068 2223 begin { tell about destroyed wonders } 2069 2224 OpenSound := 'WONDER_DESTROYED'; 2070 2225 MessgText := Format(Phrases.Lookup('WONDERDEST'), 2071 [Phrases.Lookup('IMPROVEMENTS', i)]);2226 [Phrases.Lookup('IMPROVEMENTS', I)]); 2072 2227 Kind := mkOkHelp; 2073 2228 HelpKind := hkImp; 2074 HelpNo := i;2229 HelpNo := I; 2075 2230 IconKind := mikImp; 2076 IconIndex := i;2231 IconIndex := I; 2077 2232 ShowModal; 2078 2233 end 2079 2234 else 2080 2235 begin 2081 if i= woManhattan then2082 if MyRO.Wonder[ i].EffectiveOwner > me then2236 if I = woManhattan then 2237 if MyRO.Wonder[I].EffectiveOwner > Me then 2083 2238 MyData.ColdWarStart := MyRO.Turn - 1 2084 2239 else … … 2087 2242 with MessgExDlg do 2088 2243 begin { tell about newly built wonders } 2089 if i= woManhattan then2244 if I = woManhattan then 2090 2245 begin 2091 2246 OpenSound := 'MSG_COLDWAR'; 2092 s := Tribe[MyRO.Wonder[i].EffectiveOwner].TPhrase('COLDWAR')2247 S := Tribe[MyRO.Wonder[I].EffectiveOwner].TPhrase('COLDWAR'); 2093 2248 end 2094 else if MyRO.Wonder[ i].EffectiveOwner >= 0 then2249 else if MyRO.Wonder[I].EffectiveOwner >= 0 then 2095 2250 begin 2096 2251 OpenSound := 'WONDER_BUILT'; 2097 s := Tribe[MyRO.Wonder[i].EffectiveOwner]2098 .TPhrase('WONDERBUILT') 2252 S := Tribe[MyRO.Wonder[I].EffectiveOwner] 2253 .TPhrase('WONDERBUILT'); 2099 2254 end 2100 2255 else 2101 2256 begin 2102 2257 OpenSound := 'MSG_DEFAULT'; 2103 s:= Phrases.Lookup('WONDERBUILTEXP');2258 S := Phrases.Lookup('WONDERBUILTEXP'); 2104 2259 // already expired when built 2105 2260 end; 2106 MessgText := Format( s, [Phrases.Lookup('IMPROVEMENTS', i),2107 CityName(MyRO.Wonder[ i].CityID)]);2261 MessgText := Format(S, [Phrases.Lookup('IMPROVEMENTS', I), 2262 CityName(MyRO.Wonder[I].CityID)]); 2108 2263 Kind := mkOkHelp; 2109 2264 HelpKind := hkImp; 2110 HelpNo := i;2265 HelpNo := I; 2111 2266 IconKind := mikImp; 2112 IconIndex := i;2267 IconIndex := I; 2113 2268 ShowModal; 2114 end 2115 end 2269 end; 2270 end; 2116 2271 end 2117 else if (MyRO.Wonder[ i].EffectiveOwner <> MyData.ToldWonders[i]2118 .EffectiveOwner) and (MyRO.Wonder[ i].CityID > WonderDestroyed) then2119 if MyRO.Wonder[ i].EffectiveOwner < 0 then2272 else if (MyRO.Wonder[I].EffectiveOwner <> MyData.ToldWonders[I] 2273 .EffectiveOwner) and (MyRO.Wonder[I].CityID > WonderDestroyed) then 2274 if MyRO.Wonder[I].EffectiveOwner < 0 then 2120 2275 begin 2121 if i<> woMIR then2276 if I <> woMIR then 2122 2277 with MessgExDlg do 2123 2278 begin { tell about expired wonders } 2124 2279 OpenSound := 'WONDER_EXPIRED'; 2125 2280 MessgText := Format(Phrases.Lookup('WONDEREXP'), 2126 [Phrases.Lookup('IMPROVEMENTS', i),2127 CityName(MyRO.Wonder[ i].CityID)]);2281 [Phrases.Lookup('IMPROVEMENTS', I), 2282 CityName(MyRO.Wonder[I].CityID)]); 2128 2283 Kind := mkOkHelp; 2129 2284 HelpKind := hkImp; 2130 HelpNo := i;2285 HelpNo := I; 2131 2286 IconKind := mikImp; 2132 IconIndex := i;2287 IconIndex := I; 2133 2288 ShowModal; 2134 end 2289 end; 2135 2290 end 2136 else if (MyData.ToldWonders[ i].EffectiveOwner >= 0) and not OwnWonder2291 else if (MyData.ToldWonders[I].EffectiveOwner >= 0) and not OwnWonder 2137 2292 then 2138 2293 with MessgExDlg do 2139 2294 begin { tell about capture of wonders } 2140 2295 OpenSound := 'WONDER_CAPTURED'; 2141 s := Tribe[MyRO.Wonder[i].EffectiveOwner].TPhrase('WONDERCAPT');2142 MessgText := Format( s, [Phrases.Lookup('IMPROVEMENTS', i),2143 CityName(MyRO.Wonder[ i].CityID)]);2296 S := Tribe[MyRO.Wonder[I].EffectiveOwner].TPhrase('WONDERCAPT'); 2297 MessgText := Format(S, [Phrases.Lookup('IMPROVEMENTS', I), 2298 CityName(MyRO.Wonder[I].CityID)]); 2144 2299 Kind := mkOkHelp; 2145 2300 HelpKind := hkImp; 2146 HelpNo := i;2301 HelpNo := I; 2147 2302 IconKind := mikImp; 2148 IconIndex := i;2303 IconIndex := I; 2149 2304 ShowModal; 2150 2305 end; … … 2154 2309 begin 2155 2310 SoundMessageEx(Phrases.Lookup('COLDWAREND'), 'MSG_DEFAULT'); 2156 MyData.ColdWarStart := -ColdWarTurns - 1 2311 MyData.ColdWarStart := -ColdWarTurns - 1; 2157 2312 end; 2158 2313 … … 2160 2315 end; // ClientMode<>cResume 2161 2316 MyData.ToldAlive := MyRO.Alive; 2162 move(MyRO.Wonder, MyData.ToldWonders, SizeOf(MyData.ToldWonders));2317 Move(MyRO.Wonder, MyData.ToldWonders, SizeOf(MyData.ToldWonders)); 2163 2318 2164 2319 NewGovAvailable := -1; … … 2184 2339 IconKind := mikBook; 2185 2340 IconIndex := -1; 2186 for i:= 0 to nAdvBookIcon - 1 do2187 if AdvBookIcon[ i].Adv = ad then2188 IconIndex := AdvBookIcon[ i].Icon;2341 for I := 0 to nAdvBookIcon - 1 do 2342 if AdvBookIcon[I].Adv = ad then 2343 IconIndex := AdvBookIcon[I].Icon; 2189 2344 ShowModal; 2190 2345 MyData.ToldTech[ad] := MyRO.Tech[ad]; 2191 for i:= gMonarchy to nGov - 1 do2192 if GovPreq[ i] = ad then2193 NewGovAvailable := i;2346 for I := gMonarchy to nGov - 1 do 2347 if GovPreq[I] = ad then 2348 NewGovAvailable := I; 2194 2349 end; 2195 2350 end; 2196 2351 2197 ShowCityList := false;2352 ShowCityList := False; 2198 2353 if ClientMode = cTurn then 2199 2354 begin … … 2201 2356 ChooseResearch; 2202 2357 2203 UpdatePanel := false;2358 UpdatePanel := False; 2204 2359 if MyRO.Happened and phChangeGov <> 0 then 2205 2360 begin 2206 2361 ModalSelectDlg.ShowNewContent(wmModal, kGov); 2207 2362 Play('NEWGOV'); 2208 Server(sSetGovernment, me, ModalSelectDlg.result, nil^);2363 Server(sSetGovernment, Me, ModalSelectDlg.Result, nil^); 2209 2364 CityOptimizer_BeginOfTurn; 2210 UpdatePanel := true;2365 UpdatePanel := True; 2211 2366 end; 2212 2367 end; // ClientMode=cTurn 2213 2368 2214 if not supervising and ((ClientMode = cTurn) or (ClientMode = cMovieTurn))2369 if not Supervising and ((ClientMode = cTurn) or (ClientMode = cMovieTurn)) 2215 2370 then 2216 2371 for cix := 0 to MyRO.nCity - 1 do … … 2222 2377 begin 2223 2378 // tell what happened in cities 2224 for WondersOnly := true downto false do2379 for WondersOnly := True downto False do 2225 2380 for cix := 0 to MyRO.nCity - 1 do 2226 2381 with MyCity[cix] do … … 2233 2388 begin { tell about newly built wonder } 2234 2389 OpenSound := 'WONDER_BUILT'; 2235 s := Tribe[me].TPhrase('WONDERBUILTOWN');2390 S := Tribe[Me].TPhrase('WONDERBUILTOWN'); 2236 2391 MessgText := 2237 Format( s, [Phrases.Lookup('IMPROVEMENTS',2392 Format(S, [Phrases.Lookup('IMPROVEMENTS', 2238 2393 Project0 and cpIndex), CityName(ID)]); 2239 2394 Kind := mkOkHelp; … … 2244 2399 ShowModal; 2245 2400 end; 2246 if not supervising and (ClientMode = cTurn) then2401 if not Supervising and (ClientMode = cTurn) then 2247 2402 begin 2248 AllowCityScreen := true;2403 AllowCityScreen := True; 2249 2404 if (Status and 7 <> 0) and 2250 2405 (Project and (cpImp + cpIndex) = cpImp + imTrGoods) then … … 2252 2407 begin 2253 2408 if AutoBuild(cix, MyData.ImpOrder[Status and 7 - 1]) then 2254 AllowCityScreen := false2409 AllowCityScreen := False 2255 2410 else if Flags and chProduction <> 0 then 2256 2411 Flags := (Flags and not chProduction) or chAllImpsMade … … 2280 2435 CityDlg.ShowNewContent(wmModal, MyCity[cix].Loc, 2281 2436 Flags and CityRepMask); 2282 UpdatePanel := true;2437 UpdatePanel := True; 2283 2438 end; 2284 2439 end … … 2286 2441 begin 2287 2442 if Flags and CityRepMask <> 0 then 2288 ShowCityList := true2443 ShowCityList := True; 2289 2444 end; 2290 2445 end; … … 2306 2461 begin 2307 2462 Play('REVOLUTION'); 2308 Server(sRevolution, me, 0, nil^);2463 Server(sRevolution, Me, 0, nil^); 2309 2464 end; 2310 2465 end; … … 2340 2495 DpiApplication.ProcessMessages; 2341 2496 2342 if not supervising then2497 if not Supervising then 2343 2498 for uix := 0 to MyRO.nUn - 1 do 2344 2499 with MyUn[uix] do … … 2368 2523 begin // !!! Shinkansen 2369 2524 MoveResult := eOK; 2370 ok := true;2371 for i:= 0 to MoveAdviceData.nStep - 1 do2525 ok := True; 2526 for I := 0 to MoveAdviceData.nStep - 1 do 2372 2527 begin 2373 Loc1 := dLoc(Loc, MoveAdviceData.dx[ i],2374 MoveAdviceData.dy[ i]);2528 Loc1 := dLoc(Loc, MoveAdviceData.dx[I], 2529 MoveAdviceData.dy[I]); 2375 2530 if (MyMap[Loc1] and (fCity or fOwned) = fCity) 2376 2531 // don't capture cities during auto move … … 2378 2533 // don't attack during auto move 2379 2534 begin 2380 ok := false;2535 ok := False; 2381 2536 Break 2382 2537 end … … 2385 2540 if (Loc1 = MoveAdviceData.ToLoc) or 2386 2541 (MoveAdviceData.ToLoc = maNextCity) and 2387 (MyMap[dLoc(Loc, MoveAdviceData.dx[ i],2388 MoveAdviceData.dy[ i])] and fCity <> 0) then2542 (MyMap[dLoc(Loc, MoveAdviceData.dx[I], 2543 MoveAdviceData.dy[I])] and fCity <> 0) then 2389 2544 MoveOptions := muAutoNoWait 2390 2545 else 2391 2546 MoveOptions := 0; 2392 MoveResult := MoveUnit(MoveAdviceData.dx[ i],2393 MoveAdviceData.dy[ i], MoveOptions);2547 MoveResult := MoveUnit(MoveAdviceData.dx[I], 2548 MoveAdviceData.dy[I], MoveOptions); 2394 2549 if (MoveResult < rExecuted) or (MoveResult = eEnemySpotted) 2395 2550 then 2396 2551 begin 2397 ok := false;2552 ok := False; 2398 2553 Break 2399 2554 end; … … 2407 2562 begin 2408 2563 MoveResult := eOK; 2409 Stop := true;2564 Stop := True; 2410 2565 end; 2411 2566 … … 2430 2585 end; // ClientMode=cTurn 2431 2586 2432 HaveStrategyAdvice := false; 2433 // (GameMode<>cMovie) and not supervising 2434 // and AdvisorDlg.HaveStrategyAdvice; 2435 GoOnPhase := true; 2436 if supervising or (GameMode = cMovie) then 2587 HaveStrategyAdvice := False; 2588 GoOnPhase := True; 2589 if Supervising or (GameMode = cMovie) then 2437 2590 begin 2438 2591 SetTroopLoc(-1); … … 2449 2602 SetUnFocus(-1) 2450 2603 else 2451 NextUnit(-1, false);2604 NextUnit(-1, False); 2452 2605 if UnFocus < 0 then 2453 2606 begin … … 2466 2619 end; 2467 2620 2468 procedure TMainScreen.Client(Command, NewPlayer: integer; var Data);2621 procedure TMainScreen.Client(Command, NewPlayer: Integer; var Data); 2469 2622 var 2470 i, j, p1, mix, ToLoc, AnimationSpeed, ShowMoveDomain, cix, ecix: integer;2623 I, J, p1, mix, ToLoc, AnimationSpeed, ShowMoveDomain, cix, ecix: Integer; 2471 2624 Color: TColor; 2472 Name, s: string;2625 Name, S: string; 2473 2626 TribeInfo: TTribeInfo; 2474 2627 mi: TModelInfo; 2475 SkipTurn, IsAlpine, IsTreatyDeal: boolean;2628 SkipTurn, IsAlpine, IsTreatyDeal: Boolean; 2476 2629 begin 2477 2630 case Command of 2478 2631 cTurn, cResume, cContinue, cMovieTurn, scContact, scDipStart .. scDipBreak: 2479 2632 begin 2480 supervising := G.Difficulty[NewPlayer] = 0;2633 Supervising := G.Difficulty[NewPlayer] = 0; 2481 2634 ArrangeMidPanel; 2482 2635 end … … 2484 2637 case Command of 2485 2638 cDebugMessage: 2486 LogDlg.Add(NewPlayer, G.RO[0].Turn, pchar(@Data));2639 LogDlg.Add(NewPlayer, G.RO[0].Turn, PChar(@Data)); 2487 2640 2488 2641 cShowNego: 2489 2642 with TShowNegoData(Data) do 2490 2643 begin 2491 s:= Format('P%d to P%d: ', [pSender, pTarget]);2644 S := Format('P%d to P%d: ', [pSender, pTarget]); 2492 2645 if (Action = scDipOffer) and (Offer.nDeliver + Offer.nCost > 0) then 2493 2646 begin 2494 s := s+ 'Offer ';2495 for i:= 0 to Offer.nDeliver + Offer.nCost - 1 do2647 S := S + 'Offer '; 2648 for I := 0 to Offer.nDeliver + Offer.nCost - 1 do 2496 2649 begin 2497 if i= Offer.nDeliver then2498 s := s+ ' for '2499 else if i> 0 then2500 s := s+ '+';2501 case Offer.Price[ i] and opMask of2650 if I = Offer.nDeliver then 2651 S := S + ' for ' 2652 else if I > 0 then 2653 S := S + '+'; 2654 case Offer.Price[I] and opMask of 2502 2655 opChoose: 2503 s := s+ 'Price of choice';2656 S := S + 'Price of choice'; 2504 2657 opCivilReport: 2505 s := s+ 'State report';2658 S := S + 'State report'; 2506 2659 opMilReport: 2507 s := s+ 'Military report';2660 S := S + 'Military report'; 2508 2661 opMap: 2509 s := s+ 'Map';2662 S := S + 'Map'; 2510 2663 opTreaty: 2511 s := s+ 'Treaty';2664 S := S + 'Treaty'; 2512 2665 opShipParts: 2513 s := s+ 'Ship part';2666 S := S + 'Ship part'; 2514 2667 opMoney: 2515 s := s + IntToStr(Offer.Price[i] and $FFFFFF) + 'o';2668 S := S + IntToStr(Offer.Price[I] and $FFFFFF) + 'o'; 2516 2669 opTribute: 2517 s := s + IntToStr(Offer.Price[i] and $FFFFFF) + 'o tribute';2670 S := S + IntToStr(Offer.Price[I] and $FFFFFF) + 'o tribute'; 2518 2671 opTech: 2519 s := s + Phrases.Lookup('ADVANCES', Offer.Price[i] and $FFFFFF);2672 S := S + Phrases.Lookup('ADVANCES', Offer.Price[I] and $FFFFFF); 2520 2673 opAllTech: 2521 s := s+ 'All advances';2674 S := S + 'All advances'; 2522 2675 opModel: 2523 s := s + Tribe[pSender].ModelName[Offer.Price[i] and $FFFFFF];2676 S := S + Tribe[pSender].ModelName[Offer.Price[I] and $FFFFFF]; 2524 2677 opAllModel: 2525 s := s+ 'All models';2678 S := S + 'All models'; 2526 2679 end; 2527 2680 end; 2528 LogDlg.Add(NewPlayer, G.RO[0].Turn, pchar(s));2681 LogDlg.Add(NewPlayer, G.RO[0].Turn, PChar(S)); 2529 2682 end 2530 2683 else if Action = scDipAccept then 2531 2684 begin 2532 s := s+ '--- ACCEPTED! ---';2533 LogDlg.Add(NewPlayer, G.RO[0].Turn, pchar(s));2685 S := S + '--- ACCEPTED! ---'; 2686 LogDlg.Add(NewPlayer, G.RO[0].Turn, PChar(S)); 2534 2687 end; 2535 2688 end; … … 2538 2691 begin 2539 2692 Server := TInitModuleData(Data).Server; 2540 // AdvisorDlg.Init;2541 2693 InitModule; 2542 2694 TInitModuleData(Data).DataSize := SizeOf(TPersistentData); … … 2552 2704 MainTexture.Age := -1; 2553 2705 Tribes.Init; 2554 HelpDlg.UserLeft := (DpiScreen. width - HelpDlg.width) div 2;2555 HelpDlg.UserTop := (DpiScreen. height - HelpDlg.height) div 2;2706 HelpDlg.UserLeft := (DpiScreen.Width - HelpDlg.Width) div 2; 2707 HelpDlg.UserTop := (DpiScreen.Height - HelpDlg.Height) div 2; 2556 2708 HelpDlg.Difficulty := 0; 2557 2709 if Command = cStartCredits then 2558 HelpDlg.ShowNewContent(wmModal, hkMisc, miscCredits)2710 HelpDlg.ShowNewContent(wmModal, hkMisc, Integer(miscCredits)) 2559 2711 else 2560 HelpDlg.ShowNewContent(wmModal, hkMisc, miscMain);2712 HelpDlg.ShowNewContent(wmModal, hkMisc, Integer(miscMain)); 2561 2713 Tribes.Done; 2562 2714 end; … … 2564 2716 cNewGame, cLoadGame, cMovie, cNewMap: 2565 2717 begin 2566 { if (Command=cNewGame) or (Command=cLoadGame) then2567 AdvisorDlg.NewGame(Data); }2568 2718 GenerateNames := mNames.Checked; 2569 GameOK := true;2719 GameOK := True; 2570 2720 G := TNewGameData(Data); 2571 me := -1;2721 Me := -1; 2572 2722 pLogo := -1; 2573 2723 ClientMode := -1; 2574 2724 SetMapOptions; 2575 2725 MainMap.pDebugMap := -1; 2576 idle := false;2726 Idle := False; 2577 2727 FillChar(Jump, SizeOf(Jump), 0); 2578 2728 if StartRunning then … … 2597 2747 ToldContact := 0; 2598 2748 ToldOwnCredibility := InitialCredibility; 2599 for i:= 0 to nPl - 1 do2600 if G.Difficulty[ i] > 0 then2601 inc(ToldAlive, 1 shl i);2749 for I := 0 to nPl - 1 do 2750 if G.Difficulty[I] > 0 then 2751 Inc(ToldAlive, 1 shl I); 2602 2752 PeaceEvaHappened := 0; 2603 for i:= 0 to nWonder - 1 do2604 with ToldWonders[ i] do2753 for I := 0 to nWonder - 1 do 2754 with ToldWonders[I] do 2605 2755 begin 2606 2756 CityID := -1; 2607 EffectiveOwner := -1 2757 EffectiveOwner := -1; 2608 2758 end; 2609 2759 FillChar(ToldTech, SizeOf(ToldTech), Byte(tsNA)); … … 2612 2762 end; 2613 2763 2614 // arrange dialogs 2615 ListDlg.UserLeft := 8; 2616 ListDlg.UserTop := TopBarHeight + 8; 2617 HelpDlg.UserLeft := DpiScreen.width - HelpDlg.width - 8; 2618 HelpDlg.UserTop := TopBarHeight + 8; 2619 UnitStatDlg.UserLeft := 397; 2620 UnitStatDlg.UserTop := TopBarHeight + 64; 2621 DiaDlg.UserLeft := (DpiScreen.width - DiaDlg.width) div 2; 2622 DiaDlg.UserTop := (DpiScreen.height - DiaDlg.height) div 2; 2623 NatStatDlg.UserLeft := DpiScreen.width - NatStatDlg.width - 8; 2624 NatStatDlg.UserTop := DpiScreen.height - PanelHeight - 2625 NatStatDlg.height - 8; 2626 if NatStatDlg.UserTop < 8 then 2627 NatStatDlg.UserTop := 8; 2764 ArrangeDialogs; 2628 2765 2629 2766 Age := 0; 2630 2767 MovieSpeed := 1; 2631 LogDlg.mSlot.Visible := true;2632 LogDlg.Host := self;2633 HelpDlg.ClearHistory;2634 CityDlg.Reset;2768 LogDlg.mSlot.Visible := True; 2769 LogDlg.Host := Self; 2770 if Assigned(FHelpDlg) then FHelpDlg.ClearHistory; 2771 if Assigned(FCityDlg) then FCityDlg.Reset; 2635 2772 2636 2773 MiniMap.Size := Point(G.lx, G.ly); 2637 for i:= 0 to nPl - 1 do2774 for I := 0 to nPl - 1 do 2638 2775 begin 2639 Tribe[ i] := nil;2640 TribeOriginal[ i] := false;2776 Tribe[I] := nil; 2777 TribeOriginal[I] := False; 2641 2778 end; 2642 2779 ToldSlavery := -1; 2643 RepaintOnResize := false;2644 Closable := false;2645 FirstMovieTurn := true;2780 RepaintOnResize := False; 2781 Closable := False; 2782 FirstMovieTurn := True; 2646 2783 2647 2784 MenuArea.Visible := GameMode <> cMovie; … … 2654 2791 if NewPlayer = 0 then 2655 2792 begin 2656 i:= 0;2793 I := 0; 2657 2794 for p1 := 0 to nPl - 1 do 2658 2795 if (G.Difficulty[p1] > 0) and (Tribe[p1] = nil) then 2659 inc(i);2660 if i> UnusedTribeFiles.Count then2796 Inc(I); 2797 if I > UnusedTribeFiles.Count then 2661 2798 begin 2662 GameOK := false;2799 GameOK := False; 2663 2800 SimpleMessage(Phrases.Lookup('TOOFEWTRIBES')); 2664 2801 end … … 2671 2808 TribeInfo.trix := p1; 2672 2809 TribeNames.Clear; 2673 for j:= 0 to UnusedTribeFiles.Count - 1 do2810 for J := 0 to UnusedTribeFiles.Count - 1 do 2674 2811 begin 2675 GetTribeInfo(UnusedTribeFiles[ j], Name, Color);2812 GetTribeInfo(UnusedTribeFiles[J], Name, Color); 2676 2813 TribeNames.AddObject(Name, TObject(Color)); 2677 2814 end; 2678 assert(TribeNames.Count > 0);2815 Assert(TribeNames.Count > 0); 2679 2816 ModalSelectDlg.ShowNewContent(wmModal, kTribe); 2680 2817 DpiApplication.ProcessMessages; 2681 TribeInfo.FileName := UnusedTribeFiles[ModalSelectDlg. result];2682 UnusedTribeFiles.Delete(ModalSelectDlg. result);2818 TribeInfo.FileName := UnusedTribeFiles[ModalSelectDlg.Result]; 2819 UnusedTribeFiles.Delete(ModalSelectDlg.Result); 2683 2820 2684 2821 if GameMode = cLoadGame then 2685 CreateTribe(TribeInfo.trix, TribeInfo.FileName, false)2822 CreateTribe(TribeInfo.trix, TribeInfo.FileName, False) 2686 2823 else 2687 Server( cSetTribe + (Length(TribeInfo.FileName) + 1 + 7) div 4,2824 Server(CommandWithData(cSetTribe, TribeInfo.GetCommandDataSize), 2688 2825 0, 0, TribeInfo); 2689 2826 end; … … 2693 2830 then 2694 2831 begin // autoselect enemy tribes 2695 j:= ChooseUnusedTribe;2696 TribeInfo.FileName := UnusedTribeFiles[ j];2697 UnusedTribeFiles.Delete( j);2832 J := ChooseUnusedTribe; 2833 TribeInfo.FileName := UnusedTribeFiles[J]; 2834 UnusedTribeFiles.Delete(J); 2698 2835 TribeInfo.trix := p1; 2699 2836 if GameMode = cLoadGame then 2700 CreateTribe(TribeInfo.trix, TribeInfo.FileName, false)2837 CreateTribe(TribeInfo.trix, TribeInfo.FileName, False) 2701 2838 else 2702 Server( cSetTribe + (Length(TribeInfo.FileName) + 1 + 7) div 4,2839 Server(CommandWithData(cSetTribe, TribeInfo.GetCommandDataSize), 2703 2840 0, 0, TribeInfo); 2704 2841 end; … … 2714 2851 SaveSettings; 2715 2852 CityDlg.CloseAction := None; 2716 for i := 0 to DpiScreen.FormCount - 1 do 2717 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) 2718 then 2719 DpiScreen.Forms[i].Close; 2853 ApplyToVisibleForms(faClose); 2720 2854 if LogDlg.Visible then 2721 2855 LogDlg.Close; 2722 2856 LogDlg.List.Clear; 2723 StartRunning := not idle and (Jump[0] > 0); // AI called Reload2724 me := -1;2725 idle := false;2857 StartRunning := not Idle and (Jump[0] > 0); // AI called Reload 2858 Me := -1; 2859 Idle := False; 2726 2860 ClientMode := -1; 2727 UnitInfoBtn.Visible := false;2728 UnitBtn.Visible := false;2729 TerrainBtn.Visible := false;2730 MovieSpeed1Btn.Visible := false;2731 MovieSpeed2Btn.Visible := false;2732 MovieSpeed3Btn.Visible := false;2733 MovieSpeed4Btn.Visible := false;2734 EOT.Visible := false;2735 for i:= 0 to ControlCount - 1 do2736 if Controls[ i] is TButtonC then2737 Controls[ i].Visible := false;2861 UnitInfoBtn.Visible := False; 2862 UnitBtn.Visible := False; 2863 TerrainBtn.Visible := False; 2864 MovieSpeed1Btn.Visible := False; 2865 MovieSpeed2Btn.Visible := False; 2866 MovieSpeed3Btn.Visible := False; 2867 MovieSpeed4Btn.Visible := False; 2868 EOT.Visible := False; 2869 for I := 0 to ControlCount - 1 do 2870 if Controls[I] is TButtonC then 2871 Controls[I].Visible := False; 2738 2872 sb.Init(0, 1); 2739 2873 for p1 := 0 to nPl - 1 do … … 2741 2875 FreeAndNil(Tribe[p1]); 2742 2876 Tribes.Done; 2743 RepaintOnResize := false;2744 Closable := true;2877 RepaintOnResize := False; 2878 Closable := True; 2745 2879 Close; 2746 { if (GameMode=cNewGame) or (GameMode=cLoadGame) then2747 AdvisorDlg.BreakGame; }2748 2880 end; 2749 2881 … … 2765 2897 Show; 2766 2898 Update; 2767 RepaintOnResize := true;2899 RepaintOnResize := True; 2768 2900 xw := 0; 2769 2901 yw := ywcenter; 2770 if not StayOnTop_Ensured then2771 begin2772 StayOnTop_Ensured := true;2773 CityDlg.StayOnTop_Workaround;2774 CityTypeDlg.StayOnTop_Workaround;2775 DiaDlg.StayOnTop_Workaround;2776 DraftDlg.StayOnTop_Workaround;2777 EnhanceDlg.StayOnTop_Workaround;2778 HelpDlg.StayOnTop_Workaround;2779 NatStatDlg.StayOnTop_Workaround;2780 NegoDlg.StayOnTop_Workaround;2781 ModalSelectDlg.StayOnTop_Workaround;2782 ListDlg.StayOnTop_Workaround;2783 UnitStatDlg.StayOnTop_Workaround;2784 WondersDlg.StayOnTop_Workaround;2785 RatesDlg.StayOnTop_Workaround;2786 end;2787 2902 end; 2788 2903 2789 2904 cShowTurnChange: 2790 2905 begin 2791 if integer(Data) >= 0 then2906 if Integer(Data) >= 0 then 2792 2907 begin 2793 pLogo := integer(Data);2908 pLogo := Integer(Data); 2794 2909 if G.RO[pLogo] = nil then 2795 2910 begin 2796 2911 if AILogo[pLogo] <> nil then 2797 DpiBit Canvas(Canvas, (xRightPanel + 10) - (16 + 64),2912 DpiBitBltCanvas(Canvas, (xRightPanel + 10) - (16 + 64), 2798 2913 ClientHeight - PanelHeight, 64, 64, AILogo[pLogo].Canvas, 2799 2914 0, 0); 2800 end 2801 end 2915 end; 2916 end; 2802 2917 end; 2803 2918 … … 2818 2933 ItsMeAgain(p1); 2819 2934 for mix := 0 to MyRO.nModel - 1 do 2820 if not Assigned(Tribe[ me].ModelPicture[mix].HGr) then2821 InitMyModel(mix, true);2935 if not Assigned(Tribe[Me].ModelPicture[mix].HGr) then 2936 InitMyModel(mix, True); 2822 2937 end; 2823 me := -1;2938 Me := -1; 2824 2939 end; 2825 2940 … … 2830 2945 Jump[pTurn] := 0 2831 2946 else 2832 dec(Jump[pTurn]);2947 Dec(Jump[pTurn]); 2833 2948 SkipTurn := Jump[pTurn] > 0; 2834 2949 if SkipTurn then … … 2839 2954 MiniMapPaint; 2840 2955 InitAllEnemyModels; // necessary for correct replay 2841 if not EndTurn( true) then2842 SkipTurn := false;2956 if not EndTurn(True) then 2957 SkipTurn := False; 2843 2958 end; 2844 2959 if not SkipTurn then … … 2847 2962 NegoDlg.Visible then 2848 2963 NegoDlg.Close; 2849 skipped := false; // always show my moves during my turn2850 idle := true;2964 Skipped := False; // always show my moves during my turn 2965 Idle := True; 2851 2966 InitTurn(NewPlayer); 2852 DipMem[ me].pContact := -1;2853 (* if ( me=0) and (MyRO.Alive and (1 shl me)=0)} then2967 DipMem[Me].pContact := -1; 2968 (* if (Me=0) and (MyRO.Alive and (1 shl Me)=0)} then 2854 2969 begin 2855 2970 if SimpleQuery(Phrases.Lookup('RESIGN'))=mrIgnore then 2856 Server(sResign, me,0,nil^)2857 else Server(sBreak, me,0,nil^)2971 Server(sResign,Me,0,nil^) 2972 else Server(sBreak,Me,0,nil^) 2858 2973 end 2859 2974 else Play('TURNSTART'); *) … … 2866 2981 pTurn := NewPlayer; 2867 2982 pLogo := -1; 2868 skipped := false; // always show my moves during my turn2869 idle := true;2983 Skipped := False; // always show my moves during my turn 2984 Idle := True; 2870 2985 if FirstMovieTurn then 2871 2986 begin 2872 2987 CheckMovieSpeedBtnState; 2873 FirstMovieTurn := false;2988 FirstMovieTurn := False; 2874 2989 end; 2875 2990 InitTurn(NewPlayer); … … 2888 3003 pTurn := -1; 2889 3004 pLogo := -1; 2890 MapValid := false;3005 MapValid := False; 2891 3006 ClientMode := -1; 2892 idle := false;2893 skipped := false;3007 Idle := False; 3008 Skipped := False; 2894 3009 end; 2895 3010 … … 2901 3016 ItsMeAgain(0); 2902 3017 MyData := nil; 2903 UnitInfoBtn.Visible := false;2904 UnitBtn.Visible := false;2905 TerrainBtn.Visible := false;2906 MovieSpeed1Btn.Visible := false;2907 MovieSpeed2Btn.Visible := false;2908 MovieSpeed3Btn.Visible := false;2909 MovieSpeed4Btn.Visible := false;2910 EOT.Visible := false;3018 UnitInfoBtn.Visible := False; 3019 UnitBtn.Visible := False; 3020 TerrainBtn.Visible := False; 3021 MovieSpeed1Btn.Visible := False; 3022 MovieSpeed2Btn.Visible := False; 3023 MovieSpeed3Btn.Visible := False; 3024 MovieSpeed4Btn.Visible := False; 3025 EOT.Visible := False; 2911 3026 HelpDlg.Difficulty := 0; 2912 3027 BrushType := fGrass; 2913 3028 BrushLoc := -1; 2914 Edited := false;3029 Edited := False; 2915 3030 UnFocus := -1; 2916 3031 MarkCityLoc := -1; 2917 Tracking := false;2918 TurnComplete := false;2919 MapValid := false;3032 Tracking := False; 3033 TurnComplete := False; 3034 MapValid := False; 2920 3035 FormResize(nil); // calculate geometrics and paint all 2921 3036 SetTroopLoc(-1); 2922 idle := true;3037 Idle := True; 2923 3038 end; 2924 3039 … … 2930 3045 scContact: 2931 3046 begin 2932 DipMem[NewPlayer].pContact := integer(Data);3047 DipMem[NewPlayer].pContact := Integer(Data); 2933 3048 if Jump[NewPlayer] > 0 then 2934 3049 DipCall(scReject) … … 2937 3052 ClientMode := Command; 2938 3053 InitTurn(NewPlayer); 2939 MyData.ToldContact := MyData.ToldContact or (1 shl integer(Data));3054 MyData.ToldContact := MyData.ToldContact or (1 shl Integer(Data)); 2940 3055 // don't tell about new nation when already contacted by them 2941 3056 with MessgExDlg do 2942 3057 begin 2943 OpenSound := 'CONTACT_' + char(48 + MyRO.EnemyReport[ integer(Data)3058 OpenSound := 'CONTACT_' + char(48 + MyRO.EnemyReport[Integer(Data) 2944 3059 ].Attitude); 2945 MessgText := Tribe[ integer(Data)].TPhrase('FRCONTACT');3060 MessgText := Tribe[Integer(Data)].TPhrase('FRCONTACT'); 2946 3061 Kind := mkYesNo; 2947 3062 IconKind := mikTribe; 2948 IconIndex := integer(Data);3063 IconIndex := Integer(Data); 2949 3064 ShowModal; 2950 3065 if ModalResult = mrOK then 2951 3066 begin 2952 3067 NegoDlg.Respond; 2953 DipMem[ me].DeliveredPrices := [];2954 DipMem[ me].ReceivedPrices := [];3068 DipMem[Me].DeliveredPrices := []; 3069 DipMem[Me].ReceivedPrices := []; 2955 3070 DipCall(scDipStart); 2956 3071 end … … 2980 3095 else if Command = scDipAccept then 2981 3096 begin // remember delivered and received prices 2982 for i := 0 to DipMem[me].SentOffer.nDeliver - 1 do2983 include(DipMem[me].DeliveredPrices,2984 DipMem[ me].SentOffer.Price[i] shr 24);2985 for i := 0 to DipMem[me].SentOffer.nCost - 1 do2986 include(DipMem[me].ReceivedPrices,2987 DipMem[ me].SentOffer.Price[DipMem[me].SentOffer.nDeliver +2988 i] shr 24);2989 IsTreatyDeal := false;2990 for i:= 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do2991 if DipMem[ me].SentOffer.Price[i] and opMask = opTreaty then2992 IsTreatyDeal := true;3097 for I := 0 to DipMem[Me].SentOffer.nDeliver - 1 do 3098 Include(DipMem[Me].DeliveredPrices, 3099 DipMem[Me].SentOffer.Price[I] shr 24); 3100 for I := 0 to DipMem[Me].SentOffer.nCost - 1 do 3101 Include(DipMem[Me].ReceivedPrices, 3102 DipMem[Me].SentOffer.Price[DipMem[Me].SentOffer.nDeliver + 3103 I] shr 24); 3104 IsTreatyDeal := False; 3105 for I := 0 to ReceivedOffer.nDeliver + ReceivedOffer.nCost - 1 do 3106 if DipMem[Me].SentOffer.Price[I] and opMask = opTreaty then 3107 IsTreatyDeal := True; 2993 3108 if IsTreatyDeal then 2994 3109 Play('NEWTREATY') … … 2997 3112 end; 2998 3113 NegoDlg.Start; 2999 idle := true;3114 Idle := True; 3000 3115 end; 3001 3116 … … 3003 3118 if not IsMultiPlayerGame then 3004 3119 begin 3005 case G.RO[NewPlayer].Treaty[ integer(Data)] of3120 case G.RO[NewPlayer].Treaty[Integer(Data)] of 3006 3121 trPeace: 3007 s := Tribe[integer(Data)].TPhrase('FRCANCELBYREJECT_PEACE');3122 S := Tribe[Integer(Data)].TPhrase('FRCANCELBYREJECT_PEACE'); 3008 3123 trFriendlyContact: 3009 s := Tribe[integer(Data)].TPhrase('FRCANCELBYREJECT_FRIENDLY');3124 S := Tribe[Integer(Data)].TPhrase('FRCANCELBYREJECT_FRIENDLY'); 3010 3125 trAlliance: 3011 s := Tribe[integer(Data)].TPhrase('FRCANCELBYREJECT_ALLIANCE');3126 S := Tribe[Integer(Data)].TPhrase('FRCANCELBYREJECT_ALLIANCE'); 3012 3127 end; 3013 TribeMessage( integer(Data), s, 'CANCELTREATY');3128 TribeMessage(Integer(Data), S, 'CANCELTREATY'); 3014 3129 end; 3015 3130 3016 3131 cShowCancelTreatyByAlliance: 3017 if idle and (NewPlayer = me) then3018 TribeMessage( integer(Data), Tribe[integer(Data)3132 if Idle and (NewPlayer = Me) then 3133 TribeMessage(Integer(Data), Tribe[Integer(Data) 3019 3134 ].TPhrase('FRENEMYALLIANCE'), 'CANCELTREATY'); 3020 3135 3021 3136 cShowSupportAllianceAgainst: 3022 3137 if not IsMultiPlayerGame and (Jump[0] = 0) then 3023 TribeMessage( integer(Data) and $F, Tribe[integer(Data) and $F]3024 .TPhrase('FRMYALLIANCE1') + ' ' + Tribe[ integer(Data) shr 4]3138 TribeMessage(Integer(Data) and $F, Tribe[Integer(Data) and $F] 3139 .TPhrase('FRMYALLIANCE1') + ' ' + Tribe[Integer(Data) shr 4] 3025 3140 .TPhrase('FRMYALLIANCE2'), 'CANCELTREATY'); 3026 3141 3027 3142 cShowPeaceViolation: 3028 3143 if not IsMultiPlayerGame and (Jump[0] = 0) then 3029 TribeMessage( integer(Data),3030 Format(Tribe[ integer(Data)].TPhrase('EVIOLATION'),3144 TribeMessage(Integer(Data), 3145 Format(Tribe[Integer(Data)].TPhrase('EVIOLATION'), 3031 3146 [TurnToString(MyRO.Turn + PeaceEvaTurns - 1)]), 'MSG_WITHDRAW'); 3032 3147 … … 3035 3150 3036 3151 cShowUnitChanged, cShowCityChanged, cShowAfterMove, cShowAfterAttack: 3037 if ( idle and (NewPlayer = me) or not idle and not skipped) and3152 if (Idle and (NewPlayer = Me) or not Idle and not skipped) and 3038 3153 not((GameMode = cMovie) and (MovieSpeed = 4)) then 3039 3154 begin 3040 assert(NewPlayer = me);3041 if not idle or (GameMode = cMovie) then3155 Assert(NewPlayer = Me); 3156 if not Idle or (GameMode = cMovie) then 3042 3157 DpiApplication.ProcessMessages; 3043 3158 if Command = cShowCityChanged then 3044 3159 begin 3045 CurrentMoveInfo.DoShow := false;3046 if idle then3047 CurrentMoveInfo.DoShow := true3160 CurrentMoveInfo.DoShow := False; 3161 if Idle then 3162 CurrentMoveInfo.DoShow := True 3048 3163 else if CurrentMoveInfo.IsAlly then 3049 3164 CurrentMoveInfo.DoShow := not mAlNoMoves.Checked … … 3053 3168 else if Command = cShowUnitChanged then 3054 3169 begin 3055 CurrentMoveInfo.DoShow := false;3056 if idle then3170 CurrentMoveInfo.DoShow := False; 3171 if Idle then 3057 3172 CurrentMoveInfo.DoShow := not mEffectiveMovesOnly.Checked 3058 3173 else if CurrentMoveInfo.IsAlly then … … 3068 3183 begin 3069 3184 if Command = cShowCityChanged then 3070 MapValid := false;3071 FocusOnLoc( integer(Data), flImmUpdate);3185 MapValid := False; 3186 FocusOnLoc(Integer(Data), flImmUpdate); 3072 3187 // OldUnFocus:=UnFocus; 3073 3188 // UnFocus:=-1; 3074 3189 if Command = cShowAfterMove then 3075 PaintLoc( integer(Data), CurrentMoveInfo.AfterMovePaintRadius)3190 PaintLoc(Integer(Data), CurrentMoveInfo.AfterMovePaintRadius) 3076 3191 // show discovered areas 3077 3192 else 3078 PaintLoc( integer(Data), 1);3193 PaintLoc(Integer(Data), 1); 3079 3194 // UnFocus:=OldUnFocus; 3080 3195 if (Command = cShowAfterAttack) and … … 3086 3201 Update; // remove message box from screen 3087 3202 end 3088 else if not idle then3203 else if not Idle then 3089 3204 if Command = cShowCityChanged then 3090 3205 Sleep(MoveTime * WaitAfterShowMove div 16) 3091 3206 else if (Command = cShowUnitChanged) and 3092 (MyMap[ integer(Data)] and fUnit <> 0) then3207 (MyMap[Integer(Data)] and fUnit <> 0) then 3093 3208 Sleep(MoveTime * WaitAfterShowMove div 32) 3094 3209 end // if CurrentMoveInfo.DoShow 3095 3210 else 3096 MapValid := false;3211 MapValid := False; 3097 3212 end; 3098 3213 3099 3214 cShowMoving, cShowCapturing: 3100 if ( idle and (NewPlayer = me) or not idle and not skipped and3215 if (Idle and (NewPlayer = Me) or not Idle and not skipped and 3101 3216 (TShowMove(Data).emix <> $FFFF)) and 3102 3217 not((GameMode = cMovie) and (MovieSpeed = 4)) then 3103 3218 begin 3104 assert(NewPlayer = me);3105 if not idle or (GameMode = cMovie) then3219 Assert(NewPlayer = Me); 3220 if not Idle or (GameMode = cMovie) then 3106 3221 DpiApplication.ProcessMessages; 3107 3222 with TShowMove(Data) do 3108 3223 begin 3109 CurrentMoveInfo.DoShow := false;3110 if not idle and (not Assigned(Tribe[Owner].ModelPicture[mix].HGr)) then3224 CurrentMoveInfo.DoShow := False; 3225 if not Idle and (not Assigned(Tribe[Owner].ModelPicture[mix].HGr)) then 3111 3226 InitEnemyModel(emix); 3112 3227 3113 3228 ToLoc := dLoc(FromLoc, dx, dy); 3114 if idle then3229 if Idle then 3115 3230 begin // own unit -- make discovered land visible 3116 assert(Owner = me); // no foreign moves during my turn!3231 Assert(Owner = Me); // no foreign moves during my turn! 3117 3232 CurrentMoveInfo.DoShow := not mEffectiveMovesOnly.Checked or 3118 3233 (Command = cShowCapturing); … … 3147 3262 else 3148 3263 CurrentMoveInfo.AfterMovePaintRadius := 1; 3149 if (MyRO.Wonder[woShinkansen].EffectiveOwner = me) and3264 if (MyRO.Wonder[woShinkansen].EffectiveOwner = Me) and 3150 3265 (Domain = dGround) and 3151 3266 (MyMap[FromLoc] and (fRR or fCity) <> 0) and … … 3162 3277 CurrentMoveInfo.IsAlly := MyRO.Treaty[Owner] = trAlliance; 3163 3278 if GameMode = cMovie then 3164 CurrentMoveInfo.DoShow := true3279 CurrentMoveInfo.DoShow := True 3165 3280 else if CurrentMoveInfo.IsAlly then 3166 3281 CurrentMoveInfo.DoShow := not mAlNoMoves.Checked and … … 3178 3293 cix := MyRO.nCity - 1; 3179 3294 while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do 3180 dec(cix);3181 s:= CityName(MyCity[cix].ID);3295 Dec(cix); 3296 S := CityName(MyCity[cix].ID); 3182 3297 end 3183 3298 else … … 3185 3300 ecix := MyRO.nEnemyCity - 1; 3186 3301 while (ecix >= 0) and (MyRO.EnemyCity[ecix].Loc <> ToLoc) do 3187 dec(ecix);3188 s:= CityName(MyRO.EnemyCity[ecix].ID);3302 Dec(ecix); 3303 S := CityName(MyRO.EnemyCity[ecix].ID); 3189 3304 end; 3190 3305 TribeMessage(Owner, Format(Tribe[Owner].TPhrase('CAPTURE'), 3191 [ s]), '');3306 [S]), ''); 3192 3307 Update; // remove message box from screen 3193 3308 end; … … 3274 3389 end // if CurrentMoveInfo.DoShow 3275 3390 else 3276 MapValid := false;3391 MapValid := False; 3277 3392 end; 3278 3393 end; 3279 3394 3280 3395 cShowAttacking: 3281 if ( idle and (NewPlayer = me) or not idle and not skipped and3396 if (Idle and (NewPlayer = Me) or not Idle and not skipped and 3282 3397 (TShowMove(Data).emix <> $FFFF)) and 3283 3398 not((GameMode = cMovie) and (MovieSpeed = 4)) then 3284 3399 begin 3285 assert(NewPlayer = me);3286 if not idle or (GameMode = cMovie) then3400 Assert(NewPlayer = Me); 3401 if not Idle or (GameMode = cMovie) then 3287 3402 DpiApplication.ProcessMessages; 3288 3403 with TShowMove(Data) do 3289 3404 begin 3290 3405 CurrentMoveInfo.AfterAttackExpeller := -1; 3291 CurrentMoveInfo.DoShow := false;3292 if idle then3293 CurrentMoveInfo.DoShow := true // own unit -- always show attacks3406 CurrentMoveInfo.DoShow := False; 3407 if Idle then 3408 CurrentMoveInfo.DoShow := True // own unit -- always show attacks 3294 3409 else 3295 3410 begin … … 3311 3426 cix := MyRO.nCity - 1; 3312 3427 while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do 3313 dec(cix);3428 Dec(cix); 3314 3429 if MyCity[cix].Status and csToldBombard = 0 then 3315 3430 begin 3316 if not supervising then3431 if not Supervising then 3317 3432 MyCity[cix].Status := MyCity[cix].Status or csToldBombard; 3318 s:= CityName(MyCity[cix].ID);3433 S := CityName(MyCity[cix].ID); 3319 3434 SoundMessageEx(Format(Tribe[Owner].TPhrase('BOMBARD'), 3320 [ s]), '');3435 [S]), ''); 3321 3436 Update; // remove message box from screen 3322 3437 end; … … 3327 3442 if Flags and umExpelling <> 0 then 3328 3443 Play('MOVE_EXPEL') 3329 else if Owner = me then3444 else if Owner = Me then 3330 3445 begin 3331 MakeModelInfo( me, mix, MyModel[mix], mi);3446 MakeModelInfo(Me, mix, MyModel[mix], mi); 3332 3447 Play(AttackSound(ModelCode(mi))); 3333 3448 end … … 3354 3469 MoveOnScreen(TShowMove(Data), 10, 0, 16); 3355 3470 end 3356 else if not idle then3471 else if not Idle then 3357 3472 Sleep(MoveTime div 2); 3358 3473 MainMap.AttackEnd; 3359 3474 end // if CurrentMoveInfo.DoShow 3360 3475 else 3361 MapValid := false;3476 MapValid := False; 3362 3477 end; 3363 3478 end; … … 3368 3483 else 3369 3484 begin 3370 s:= Phrases.Lookup('FOREIGNINFO');3485 S := Phrases.Lookup('FOREIGNINFO'); 3371 3486 for p1 := 0 to nPl - 1 do 3372 3487 if 3 shl (p1 * 2) and Cardinal(Data) <> 0 then 3373 s := s+ '\' + Tribe[p1].TPhrase('SHORTNAME');3374 SoundMessageEx( s, '');3488 S := S + '\' + Tribe[p1].TPhrase('SHORTNAME'); 3489 SoundMessageEx(S, ''); 3375 3490 end; 3376 3491 … … 3384 3499 begin 3385 3500 MessgText := Format(Phrases.Lookup('GRLIB_GENERAL'), 3386 [Phrases.Lookup('ADVANCES', integer(Data))]);3501 [Phrases.Lookup('ADVANCES', Integer(Data))]); 3387 3502 OpenSound := 'NEWADVANCE_GRLIB'; 3388 3503 Kind := mkOk; … … 3394 3509 cRefreshDebugMap: 3395 3510 begin 3396 if integer(Data) = MainMap.pDebugMap then3511 if Integer(Data) = MainMap.pDebugMap then 3397 3512 begin 3398 MapValid := false;3513 MapValid := False; 3399 3514 MainOffscreenPaint; 3400 3515 Update; 3401 end 3516 end; 3402 3517 end; 3403 3518 3404 3519 else 3405 3520 if Command >= cClientEx then 3406 case Command and $FFF0 of 3407 3521 case Command and (not Integer(CommandDataElementCountMask)) of 3408 3522 cSetTribe: 3409 with TTribeInfo(Data) do 3410 begin 3411 i := UnusedTribeFiles.Count - 1; 3412 while (i >= 0) and 3413 (AnsiCompareFileName(UnusedTribeFiles[i], FileName) <> 0) do 3414 dec(i); 3415 if i >= 0 then 3416 UnusedTribeFiles.Delete(i); 3417 CreateTribe(trix, FileName, true); 3523 with TTribeInfo(Data) do begin 3524 I := UnusedTribeFiles.Count - 1; 3525 while (I >= 0) and 3526 (AnsiCompareFileName(UnusedTribeFiles[I], FileName) <> 0) do 3527 Dec(I); 3528 if I >= 0 then 3529 UnusedTribeFiles.Delete(I); 3530 CreateTribe(trix, FileName, True); 3418 3531 end; 3419 3420 cSetNewModelPicture, cSetModelPicture: 3532 cSetNewModelPicture: 3421 3533 if TribeOriginal[TModelPictureInfo(Data).trix] then 3422 3534 Tribe[TModelPictureInfo(Data).trix].SetModelPicture 3423 (TModelPictureInfo(Data), Command and 3424 $FFF0 = cSetNewModelPicture); 3425 3426 cSetSlaveIndex and $FFF0: 3427 Tribe[integer(Data) shr 16].mixSlaves := integer(Data) and $FFFF; 3428 3535 (TModelPictureInfo(Data), True); 3536 cSetModelPicture: 3537 if TribeOriginal[TModelPictureInfo(Data).trix] then 3538 Tribe[TModelPictureInfo(Data).trix].SetModelPicture 3539 (TModelPictureInfo(Data), False); 3540 cSetSlaveIndex: 3541 Tribe[Integer(Data) shr 16].mixSlaves := Integer(Data) and $FFFF; 3429 3542 cSetCityName: 3430 3543 with TCityNameInfo(Data) do 3431 3544 if TribeOriginal[ID shr 12] then 3432 3545 Tribe[ID shr 12].SetCityName(ID and $FFF, NewName); 3433 3434 3546 cSetModelName: 3435 3547 with TModelNameInfo(Data) do … … 3444 3556 procedure TMainScreen.FormCreate(Sender: TObject); 3445 3557 var 3446 i, j: integer;3558 I, J: Integer; 3447 3559 begin 3448 3560 NoMap := TIsoMap.Create; … … 3486 3598 3487 3599 // tag-controlled language 3488 for i:= 0 to ComponentCount - 1 do3489 if Components[ i].Tag and $FF <> 0 then3490 if Components[ i] is TDpiMenuItem then begin3491 TDpiMenuItem(Components[ i]).Caption := Phrases.Lookup('CONTROLS',3492 -1 + Components[ i].Tag and $FF);3493 for j:= 0 to Length(SaveOption) - 1 do3494 if Components[ i].Tag and $FF = SaveOption[j] then3495 TDpiMenuItem(Components[ i]).Checked := TSaveOption(j) in OptionChecked;3600 for I := 0 to ComponentCount - 1 do 3601 if Components[I].Tag and $FF <> 0 then 3602 if Components[I] is TDpiMenuItem then begin 3603 TDpiMenuItem(Components[I]).Caption := Phrases.Lookup('CONTROLS', 3604 -1 + Components[I].Tag and $FF); 3605 for J := 0 to Length(SaveOption) - 1 do 3606 if Components[I].Tag and $FF = SaveOption[J] then 3607 TDpiMenuItem(Components[I]).Checked := TSaveOption(J) in OptionChecked; 3496 3608 end else 3497 if Components[ i] is TButtonBase then begin3498 TButtonBase(Components[ i]).Hint := Phrases.Lookup('CONTROLS',3499 -1 + Components[ i].Tag and $FF);3500 if (Components[ i] is TButtonC) and3501 (TButtonC(Components[ i]).ButtonIndex <> 1) then3502 TButtonC(Components[ i]).ButtonIndex :=3503 Integer(MapOptionChecked) shr (Components[ i].Tag shr 8) and 1 + 23609 if Components[I] is TButtonBase then begin 3610 TButtonBase(Components[I]).Hint := Phrases.Lookup('CONTROLS', 3611 -1 + Components[I].Tag and $FF); 3612 if (Components[I] is TButtonC) and 3613 (TButtonC(Components[I]).ButtonIndex <> 1) then 3614 TButtonC(Components[I]).ButtonIndex := 3615 Integer(MapOptionChecked) shr (Components[I].Tag shr 8) and 1 + 2 3504 3616 end; 3505 3617 … … 3514 3626 ManagementArea.Hint := Phrases2.Lookup('BTN_MANAGE'); 3515 3627 end; 3516 for i:= 0 to mRep.Count - 1 do3517 begin 3518 j := mRep[i].Tag shr 8;3519 mRep[ i].Caption := CityEventName(j);3520 mRep[ i].Checked := CityRepMask and (1 shl j) <> 0;3628 for I := 0 to mRep.Count - 1 do 3629 begin 3630 J := mRep[I].Tag shr 8; 3631 mRep[I].Caption := CityEventName(J); 3632 mRep[I].Checked := CityRepMask and (1 shl J) <> 0; 3521 3633 end; 3522 3634 … … 3537 3649 else Buffer.height := 3 * ySizeBig; 3538 3650 Buffer.Canvas.Font.Assign(UniFont[ftSmall]); 3539 for i:= 0 to nPl - 1 do3540 AILogo[ i] := nil;3651 for I := 0 to nPl - 1 do 3652 AILogo[I] := nil; 3541 3653 Canvas.Font.Assign(UniFont[ftSmall]); 3542 3654 InitButtons; … … 3548 3660 I: Integer; 3549 3661 begin 3662 if Assigned(FWondersDlg) then FreeAndNil(FWondersDlg); 3663 if Assigned(FTechTreeDlg) then FreeAndNil(FTechTreeDlg); 3664 if Assigned(FEnhanceDlg) then FreeAndNil(FEnhanceDlg); 3665 if Assigned(FNegoDlg) then FreeAndNil(FNegoDlg); 3666 if Assigned(FCityTypeDlg) then FreeAndNil(FCityTypeDlg); 3667 if Assigned(FDiaDlg) then FreeAndNil(FDiaDlg); 3668 if Assigned(FCityDlg) then FreeAndNil(FCityDlg); 3669 if Assigned(FRatesDlg) then FreeAndNil(FRatesDlg); 3670 if Assigned(FBattleDlg) then FreeAndNil(FBattleDlg); 3671 if Assigned(FNatStatDlg) then FreeAndNil(FNatStatDlg); 3672 if Assigned(FUnitStatDlg) then FreeAndNil(FUnitStatDlg); 3673 if Assigned(FDraftDlg) then FreeAndNil(FDraftDlg); 3674 if Assigned(FModalSelectDlg) then FreeAndNil(FModalSelectDlg); 3675 if Assigned(FListDlg) then FreeAndNil(FListDlg); 3676 if Assigned(FMessgExDlg) then FreeAndNil(FMessgExDlg); 3677 if Assigned(FHelpDlg) then FreeAndNil(FHelpDlg); 3678 3550 3679 MainFormKeyDown := nil; 3551 3680 FreeAndNil(sb); … … 3555 3684 FreeAndNil(Panel); 3556 3685 for I := 0 to nPl - 1 do 3557 if AILogo[ i] <> nil then3686 if AILogo[I] <> nil then 3558 3687 FreeAndNil(AILogo[I]); 3559 3688 FreeAndNil(Offscreen); … … 3586 3715 end; 3587 3716 3717 procedure TMainScreen.mAfforestClick(Sender: TObject); 3718 begin 3719 if UnFocus >= 0 then 3720 with TUn(MyUn[UnFocus]) do 3721 DoJob(jAfforest); 3722 end; 3723 3724 procedure TMainScreen.mAirBaseClick(Sender: TObject); 3725 begin 3726 if UnFocus >= 0 then 3727 with TUn(MyUn[UnFocus]) do 3728 DoJob(jBase); 3729 end; 3730 3731 procedure TMainScreen.mCanalClick(Sender: TObject); 3732 begin 3733 if UnFocus >= 0 then 3734 with TUn(MyUn[UnFocus]) do 3735 DoJob(jCanal); 3736 end; 3737 3738 procedure TMainScreen.mCancelClick(Sender: TObject); 3739 begin 3740 if UnFocus >= 0 then 3741 with MyUn[UnFocus] do begin 3742 DestinationMarkON := False; 3743 PaintDestination; 3744 Status := Status and ($FFFF - usRecover - usGoto - usEnhance); 3745 if Job > jNone then 3746 Server(sStartJob + jNone shl 4, Me, UnFocus, nil^); 3747 end; 3748 end; 3749 3750 procedure TMainScreen.mCentreClick(Sender: TObject); 3751 begin 3752 if UnFocus >= 0 then 3753 with TUn(MyUn[UnFocus]) do begin 3754 Centre(Loc); 3755 PaintAllMaps; 3756 end; 3757 end; 3758 3759 procedure TMainScreen.mcityClick(Sender: TObject); 3760 var 3761 Loc0: Integer; 3762 cix: Integer; 3763 ServerResult: Integer; 3764 begin 3765 if UnFocus >= 0 then 3766 with TUn(MyUn[UnFocus]) do begin 3767 Loc0 := Loc; 3768 if MyMap[Loc] and fCity = 0 then 3769 begin // build city 3770 if DoJob(jCity) = eCity then 3771 begin 3772 MapValid := False; 3773 PaintAll; 3774 ZoomToCity(Loc0, True, chFounded); 3775 end; 3776 end else begin 3777 CityOptimizer_BeforeRemoveUnit(UnFocus); 3778 ServerResult := Server(sAddToCity, Me, UnFocus, nil^); 3779 if ServerResult >= rExecuted then 3780 begin 3781 cix := MyRO.nCity - 1; 3782 while (cix >= 0) and (MyCity[cix].Loc <> Loc0) do 3783 Dec(cix); 3784 Assert(cix >= 0); 3785 CityOptimizer_CityChange(cix); 3786 CityOptimizer_AfterRemoveUnit; // does nothing here 3787 SetTroopLoc(Loc0); 3788 UpdateViews(True); 3789 DestinationMarkON := False; 3790 PaintDestination; 3791 UnFocus := -1; 3792 PaintLoc(Loc0); 3793 NextUnit(UnStartLoc, True); 3794 end 3795 else if ServerResult = eMaxSize then 3796 SimpleMessage(Phrases.Lookup('ADDTOMAXSIZE')); 3797 end; 3798 end; 3799 end; 3800 3801 procedure TMainScreen.mCityStatClick(Sender: TObject); 3802 begin 3803 ListDlg.ShowNewContent(wmPersistent, kCities); 3804 end; 3805 3806 procedure TMainScreen.mCityTypesClick(Sender: TObject); 3807 begin 3808 CityTypeDlg.ShowNewContent(wmModal); 3809 // must be modal because types are not saved before closing 3810 end; 3811 3812 procedure TMainScreen.mClearClick(Sender: TObject); 3813 begin 3814 if UnFocus >= 0 then 3815 with TUn(MyUn[UnFocus]) do 3816 DoJob(jClear); 3817 end; 3818 3819 procedure TMainScreen.mDiagramClick(Sender: TObject); 3820 begin 3821 DiaDlg.ShowNewContent_Charts(wmPersistent); 3822 end; 3823 3824 procedure TMainScreen.mEmpireClick(Sender: TObject); 3825 begin 3826 RatesDlg.ShowNewContent(wmPersistent); 3827 end; 3828 3829 procedure TMainScreen.mEnhanceClick(Sender: TObject); 3830 begin 3831 if UnFocus >= 0 then 3832 with TUn(MyUn[UnFocus]) do 3833 DoJob(-1); 3834 end; 3835 3836 procedure TMainScreen.mEnhanceDefClick(Sender: TObject); 3837 begin 3838 if UnFocus >= 0 then 3839 EnhanceDlg.ShowNewContent(wmPersistent, 3840 MyMap[MyUn[UnFocus].Loc] and fTerrain) 3841 else 3842 EnhanceDlg.ShowNewContent(wmPersistent); 3843 end; 3844 3845 procedure TMainScreen.mEUnitStatClick(Sender: TObject); 3846 begin 3847 if MyRO.nEnemyModel > 0 then 3848 ListDlg.ShowNewContent(wmPersistent, kAllEModels); 3849 end; 3850 3851 procedure TMainScreen.mFarmClick(Sender: TObject); 3852 begin 3853 if UnFocus >= 0 then 3854 with TUn(MyUn[UnFocus]) do 3855 DoJob(jFarm); 3856 end; 3857 3858 procedure TMainScreen.mfortClick(Sender: TObject); 3859 begin 3860 if UnFocus >= 0 then 3861 with TUn(MyUn[UnFocus]) do 3862 DoJob(jFort); 3863 end; 3864 3865 procedure TMainScreen.mGoOnClick(Sender: TObject); 3866 var 3867 Destination: Integer; 3868 begin 3869 if UnFocus >= 0 then 3870 with TUn(MyUn[UnFocus]) do begin 3871 if Status shr 16 = $7FFF then 3872 Destination := maNextCity 3873 else 3874 Destination := Status shr 16; 3875 Status := Status and not(usStay or usRecover) or usWaiting; 3876 MoveToLoc(Destination, True); 3877 end; 3878 end; 3879 3880 procedure TMainScreen.mHelpClick(Sender: TObject); 3881 begin 3882 if ClientMode = cEditMap then 3883 HelpDlg.ShowNewContent(wmPersistent, hkText, HelpDlg.TextIndex('MAPEDIT')) 3884 else 3885 HelpDlg.ShowNewContent(wmPersistent, hkMisc, Integer(miscMain)); 3886 end; 3887 3888 procedure TMainScreen.mhomeClick(Sender: TObject); 3889 var 3890 cixOldHome: Integer; 3891 begin 3892 if UnFocus >= 0 then 3893 with TUn(MyUn[UnFocus]) do begin 3894 if MyMap[Loc] and fCity <> 0 then 3895 begin 3896 cixOldHome := Home; 3897 if Server(sSetUnitHome, Me, UnFocus, nil^) >= rExecuted then 3898 begin 3899 CityOptimizer_CityChange(cixOldHome); 3900 CityOptimizer_CityChange(Home); 3901 UpdateViews(True); 3902 end 3903 else 3904 Play('INVALID'); 3905 end 3906 else 3907 begin 3908 Status := Status and not(usStay or usRecover or usEnhance); 3909 MoveToLoc(maNextCity, True); 3910 end; 3911 end; 3912 end; 3913 3914 procedure TMainScreen.mirrigationClick(Sender: TObject); 3915 begin 3916 if UnFocus >= 0 then 3917 with TUn(MyUn[UnFocus]) do 3918 DoJob(jIrr); 3919 end; 3920 3921 procedure TMainScreen.mirrigationDrawItem(Sender: TObject; ACanvas: TDpiCanvas; 3922 ARect: TRect; AState: TOwnerDrawState); 3923 begin 3924 3925 end; 3926 3927 procedure TMainScreen.mJumpClick(Sender: TObject); 3928 begin 3929 if Supervising then 3930 Jump[0] := 20 3931 else 3932 Jump[Me] := 20; 3933 EndTurn(True); 3934 end; 3935 3936 procedure TMainScreen.mLoadClick(Sender: TObject); 3937 var 3938 I: Integer; 3939 begin 3940 if UnFocus >= 0 then 3941 with MyUn[UnFocus] do begin 3942 I := Server(sLoadUnit, Me, UnFocus, nil^); 3943 if I >= rExecuted then 3944 begin 3945 if MyModel[mix].Domain = dAir then 3946 Play('MOVE_PLANELANDING') 3947 else 3948 Play('MOVE_LOAD'); 3949 DestinationMarkON := False; 3950 PaintDestination; 3951 Status := Status and ($FFFF - usWaiting - usStay - usRecover - usGoto - usEnhance); 3952 NextUnit(UnStartLoc, True); 3953 end 3954 else if I = eNoTime_Load then 3955 if MyModel[mix].Domain = dAir then 3956 SoundMessage(Phrases.Lookup('NOTIMELOADAIR'), 'NOMOVE_TIME') 3957 else 3958 SoundMessage(Format(Phrases.Lookup('NOTIMELOADGROUND'), 3959 [MovementToString(MyModel[mix].speed)]), 'NOMOVE_TIME'); 3960 end; 3961 end; 3962 3963 procedure TMainScreen.mmineClick(Sender: TObject); 3964 begin 3965 if UnFocus >= 0 then 3966 with TUn(MyUn[UnFocus]) do 3967 DoJob(jMine); 3968 end; 3969 3970 procedure TMainScreen.mNationsClick(Sender: TObject); 3971 begin 3972 NatStatDlg.ShowNewContent(wmPersistent); 3973 end; 3974 3975 procedure TMainScreen.mNextUnitClick(Sender: TObject); 3976 begin 3977 if UnFocus >= 0 then 3978 with MyUn[UnFocus] do begin 3979 Status := Status and not usWaiting; 3980 FocusNextUnit(1); 3981 end; 3982 end; 3983 3984 procedure TMainScreen.mnoordersClick(Sender: TObject); 3985 begin 3986 if UnFocus >= 0 then 3987 with MyUn[UnFocus] do begin 3988 Status := Status and not usWaiting; 3989 NextUnit(UnStartLoc, True); 3990 end; 3991 end; 3992 3993 procedure TMainScreen.mPillageClick(Sender: TObject); 3994 begin 3995 DoJob(jPillage); 3996 end; 3997 3998 procedure TMainScreen.mpollutionClick(Sender: TObject); 3999 begin 4000 if UnFocus >= 0 then 4001 with TUn(MyUn[UnFocus]) do 4002 DoJob(jPoll); 4003 end; 4004 4005 procedure TMainScreen.mPrevUnitClick(Sender: TObject); 4006 begin 4007 if UnFocus >= 0 then 4008 with MyUn[UnFocus] do begin 4009 Status := Status and not usWaiting; 4010 FocusNextUnit(-1); 4011 end; 4012 end; 4013 4014 procedure TMainScreen.mRandomMapClick(Sender: TObject); 4015 begin 4016 if not Edited or (SimpleQuery(mkYesNo, Phrases.Lookup('MAP_RANDOM'), '') 4017 = mrOK) then begin 4018 Server(sRandomMap, Me, 0, nil^); 4019 Edited := True; 4020 MapValid := False; 4021 PaintAllMaps; 4022 end; 4023 end; 4024 4025 procedure TMainScreen.mRecoverClick(Sender: TObject); 4026 begin 4027 if UnFocus >= 0 then 4028 with MyUn[UnFocus] do begin 4029 DestinationMarkON := False; 4030 PaintDestination; 4031 Status := Status and ($FFFF - usStay - usGoto - usEnhance) or usRecover; 4032 if Job > jNone then 4033 Server(sStartJob + jNone shl 4, Me, UnFocus, nil^); 4034 NextUnit(UnStartLoc, True); 4035 end; 4036 end; 4037 4038 procedure TMainScreen.mResignClick(Sender: TObject); 4039 var 4040 QueryText: string; 4041 begin 4042 if ClientMode = cEditMap then begin 4043 if Edited then begin 4044 QueryText := Phrases.Lookup('MAP_CLOSE'); 4045 case SimpleQuery(mkYesNoCancel, QueryText, '') of 4046 mrIgnore: Server(sAbandonMap, Me, 0, nil^); 4047 mrOK: Server(sSaveMap, Me, 0, nil^); 4048 end; 4049 end else 4050 Server(sAbandonMap, Me, 0, nil^); 4051 end else begin 4052 if Server(sGetGameChanged, 0, 0, nil^) = eOK then begin 4053 QueryText := Phrases.Lookup('RESIGN'); 4054 case SimpleQuery(mkYesNoCancel, QueryText, '') of 4055 mrIgnore: Server(sResign, 0, 0, nil^); 4056 mrOK: Server(sBreak, 0, 0, nil^); 4057 end; 4058 end else 4059 Server(sResign, 0, 0, nil^); 4060 end; 4061 end; 4062 4063 procedure TMainScreen.mRevolutionClick(Sender: TObject); 4064 var 4065 AltGovs: Boolean; 4066 RevolutionChanged: Boolean; 4067 I: Integer; 4068 begin 4069 AltGovs := False; 4070 for I := 2 to nGov - 1 do 4071 if (GovPreq[I] <> preNA) and 4072 ((GovPreq[I] = preNone) or (MyRO.Tech[GovPreq[I]] >= tsApplicable)) then 4073 AltGovs := True; 4074 4075 if not AltGovs then 4076 SoundMessage(Phrases.Lookup('NOALTGOVS'), 'MSG_DEFAULT') 4077 else 4078 begin 4079 RevolutionChanged := False; 4080 if MyRO.Happened and phChangeGov <> 0 then 4081 begin 4082 ModalSelectDlg.ShowNewContent(wmModal, kGov); 4083 if ModalSelectDlg.Result >= 0 then 4084 begin 4085 Play('NEWGOV'); 4086 Server(sSetGovernment, Me, ModalSelectDlg.Result, nil^); 4087 CityOptimizer_BeginOfTurn; 4088 RevolutionChanged := True; 4089 end; 4090 end 4091 else 4092 with MessgExDlg do 4093 begin // revolution! 4094 MessgExDlg.MessgText := Tribe[Me].TPhrase('REVOLUTION'); 4095 MessgExDlg.Kind := mkYesNo; 4096 MessgExDlg.IconKind := mikPureIcon; 4097 MessgExDlg.IconIndex := 72; // anarchy palace 4098 MessgExDlg.ShowModal; 4099 if ModalResult = mrOK then 4100 begin 4101 Play('REVOLUTION'); 4102 Server(sRevolution, Me, 0, nil^); 4103 RevolutionChanged := True; 4104 if NatStatDlg.Visible then 4105 NatStatDlg.Close; 4106 if CityDlg.Visible then 4107 CityDlg.Close; 4108 end 4109 end; 4110 if RevolutionChanged then 4111 UpdateViews(True); 4112 end; 4113 end; 4114 4115 procedure TMainScreen.mroadClick(Sender: TObject); 4116 begin 4117 if UnFocus >= 0 then 4118 with TUn(MyUn[UnFocus]) do 4119 DoJob(jRoad); 4120 end; 4121 4122 procedure TMainScreen.mRailRoadClick(Sender: TObject); 4123 begin 4124 if UnFocus >= 0 then 4125 with TUn(MyUn[UnFocus]) do 4126 DoJob(jRR); 4127 end; 4128 4129 procedure TMainScreen.mRunClick(Sender: TObject); 4130 begin 4131 if Supervising then 4132 Jump[0] := 999999 4133 else 4134 Jump[Me] := 999999; 4135 EndTurn(True); 4136 end; 4137 4138 procedure TMainScreen.mScienceStatClick(Sender: TObject); 4139 begin 4140 ListDlg.ShowNewContent(wmPersistent, kScience); 4141 end; 4142 4143 procedure TMainScreen.mSelectTransportClick(Sender: TObject); 4144 begin 4145 if UnFocus >= 0 then 4146 with TUn(MyUn[UnFocus]) do 4147 Server(sSelectTransport, Me, UnFocus, nil^); 4148 end; 4149 4150 procedure TMainScreen.mShipsClick(Sender: TObject); 4151 begin 4152 DiaDlg.ShowNewContent_Ship(wmPersistent); 4153 end; 4154 4155 procedure TMainScreen.mstayClick(Sender: TObject); 4156 begin 4157 if UnFocus >= 0 then 4158 with TUn(MyUn[UnFocus]) do begin 4159 DestinationMarkON := False; 4160 PaintDestination; 4161 Status := Status and ($FFFF - usRecover - usGoto - usEnhance) or usStay; 4162 if Job > jNone then 4163 Server(sStartJob + jNone shl 4, Me, UnFocus, nil^); 4164 NextUnit(UnStartLoc, True); 4165 end; 4166 end; 4167 4168 procedure TMainScreen.mTechTreeClick(Sender: TObject); 4169 begin 4170 TechTreeDlg.ShowModal; 4171 end; 4172 4173 procedure TMainScreen.mtransClick(Sender: TObject); 4174 begin 4175 if UnFocus >= 0 then 4176 with TUn(MyUn[UnFocus]) do 4177 DoJob(jTrans); 4178 end; 4179 4180 procedure TMainScreen.mUnitStatClick(Sender: TObject); 4181 var 4182 I: Integer; 4183 begin 4184 if G.Difficulty[Me] > 0 then 4185 ListDlg.ShowNewContent_MilReport(wmPersistent, Me) 4186 else 4187 begin 4188 I := 1; 4189 while (I < nPl) and (1 shl I and MyRO.Alive = 0) do 4190 Inc(I); 4191 if I < nPl then 4192 ListDlg.ShowNewContent_MilReport(wmPersistent, I); 4193 end; 4194 end; 4195 4196 procedure TMainScreen.mUnloadClick(Sender: TObject); 4197 var 4198 I: Integer; 4199 OldMaster: Integer; 4200 NewFocus: Integer; 4201 uix: Integer; 4202 begin 4203 if UnFocus >= 0 then 4204 with MyUn[UnFocus] do begin 4205 if Master >= 0 then begin 4206 OldMaster := Master; 4207 I := Server(sUnloadUnit, Me, UnFocus, nil^); 4208 if I >= rExecuted then 4209 begin 4210 if MyModel[mix].Domain = dAir then 4211 Play('MOVE_PLANESTART') 4212 else if (MyModel[MyUn[OldMaster].mix].Domain = dAir) and 4213 (MyMap[Loc] and fCity = 0) and (MyMap[Loc] and fTerImp <> tiBase) 4214 then 4215 Play('MOVE_PARACHUTE') 4216 else 4217 Play('MOVE_UNLOAD'); 4218 Status := Status and not usWaiting; 4219 if MyModel[mix].Domain <> dAir then 4220 NextUnit(Loc, True) 4221 else 4222 PanelPaint; 4223 end 4224 else if I = eNoTime_Load then 4225 if MyModel[mix].Domain = dAir then 4226 SoundMessage(Phrases.Lookup('NOTIMELOADAIR'), 'NOMOVE_TIME') 4227 else 4228 SoundMessage(Format(Phrases.Lookup('NOTIMELOADGROUND'), 4229 [MovementToString(MyModel[mix].speed)]), 'NOMOVE_TIME'); 4230 end else begin 4231 NewFocus := -1; 4232 uix := UnFocus; 4233 for I := 1 to MyRO.nUn - 1 do 4234 begin 4235 uix := (uix + MyRO.nUn - 1) mod MyRO.nUn; 4236 if (MyUn[uix].Master = UnFocus) and 4237 (MyUn[uix].Movement = Integer(MyModel[MyUn[uix].mix].speed)) then 4238 begin 4239 MyUn[uix].Status := MyUn[uix].Status or usWaiting; 4240 NewFocus := uix; 4241 end; 4242 end; 4243 if NewFocus >= 0 then 4244 begin 4245 SetUnFocus(NewFocus); 4246 SetTroopLoc(Loc); 4247 PanelPaint; 4248 end; 4249 end; 4250 end; 4251 end; 4252 4253 procedure TMainScreen.mwaitClick(Sender: TObject); 4254 begin 4255 if UnFocus >= 0 then 4256 with MyUn[UnFocus] do begin 4257 DestinationMarkON := False; 4258 PaintDestination; 4259 Status := Status and ($FFFF - usStay - usRecover - usGoto - usEnhance) or usWaiting; 4260 end; 4261 NextUnit(-1, False); 4262 end; 4263 4264 procedure TMainScreen.mWebsiteClick(Sender: TObject); 4265 begin 4266 OpenURL(CevoHomepage); 4267 end; 4268 4269 procedure TMainScreen.mWondersClick(Sender: TObject); 4270 begin 4271 WondersDlg.ShowNewContent(wmPersistent); 4272 end; 4273 3588 4274 procedure TMainScreen.FormResize(Sender: TObject); 3589 4275 var 3590 MiniFrame, MaxMapWidth: integer;4276 MiniFrame, MaxMapWidth: Integer; 3591 4277 begin 3592 4278 SmallScreen := ClientWidth < 1024; … … 3666 4352 begin 3667 4353 RectInvalidate(0, TopBarHeight, ClientWidth, TopBarHeight + MapHeight); 3668 MapValid := false;4354 MapValid := False; 3669 4355 PaintAll; 3670 4356 end; 3671 4357 end; 3672 4358 3673 procedure TMainScreen.FormCloseQuery(Sender: TObject; var CanClose: boolean);4359 procedure TMainScreen.FormCloseQuery(Sender: TObject; var CanClose: Boolean); 3674 4360 begin 3675 4361 CanClose := Closable; 3676 if not Closable and idle and (me = 0) and (ClientMode < scContact) then3677 MenuClick(mResign);4362 if not Closable and Idle and (Me = 0) and (ClientMode < scContact) then 4363 mResign.Click; 3678 4364 end; 3679 4365 … … 3696 4382 begin 3697 4383 MessgExDlg.CancelMovie; 3698 Server(sBreak, me, 0, nil^);4384 Server(sBreak, Me, 0, nil^); 3699 4385 end 3700 4386 else if ClientMode < 0 then 3701 skipped := true4387 Skipped := True 3702 4388 else if ClientMode >= scContact then 3703 4389 NegoDlg.ShowNewContent(wmPersistent) … … 3705 4391 begin 3706 4392 Jump[pTurn] := 0; 3707 StartRunning := false;4393 StartRunning := False; 3708 4394 end 3709 4395 else … … 3718 4404 else 3719 4405 with MainMap do begin 3720 if supervising then4406 if Supervising then 3721 4407 xTerrain := xMidPanel + 2 * xxt + 14 3722 4408 else if ClientWidth < 1280 then … … 3725 4411 xTerrain := ClientWidth div 2; 3726 4412 xTroop := xTerrain + 2 * xxt + 12; 3727 if SmallScreen and not supervising then4413 if SmallScreen and not Supervising then 3728 4414 xTroop := xRightPanel + 10 - 3 * 66 - 3729 4415 DpiGetSystemMetrics(SM_CXVSCROLL) - 19 - 4; … … 3734 4420 end; 3735 4421 3736 function TMainScreen.EndTurn(WasSkipped: boolean): boolean;3737 3738 function IsResourceUnused(cix, NeedFood, NeedProd: integer): boolean;4422 function TMainScreen.EndTurn(WasSkipped: Boolean): Boolean; 4423 4424 function IsResourceUnused(cix, NeedFood, NeedProd: Integer): Boolean; 3739 4425 var 3740 dx, dy, fix: integer;4426 dx, dy, fix: Integer; 3741 4427 CityAreaInfo: TCityAreaInfo; 3742 4428 TileInfo: TTileInfo; 3743 4429 begin 3744 Server(sGetCityAreaInfo, me, cix, CityAreaInfo);4430 Server(sGetCityAreaInfo, Me, cix, CityAreaInfo); 3745 4431 for dy := -3 to 3 do 3746 4432 for dx := -3 to 3 do … … 3752 4438 begin 3753 4439 TileInfo.ExplCity := cix; 3754 Server(sGetHypoCityTileInfo, me, dLoc(MyCity[cix].Loc, dx, dy),4440 Server(sGetHypoCityTileInfo, Me, dLoc(MyCity[cix].Loc, dx, dy), 3755 4441 TileInfo); 3756 4442 if (TileInfo.Food >= NeedFood) and (TileInfo.Prod >= NeedProd) then 3757 4443 begin 3758 result := true;3759 exit4444 Result := True; 4445 Exit 3760 4446 end; 3761 4447 end 3762 4448 end; 3763 result := false;4449 Result := False; 3764 4450 end; 3765 4451 3766 4452 var 3767 i, p1, uix, cix, CenterLoc: integer;4453 p1, uix, cix, CenterLoc: Integer; 3768 4454 MsgItem: string; 3769 4455 CityReport: TCityReport; 3770 4456 PlaneReturnData: TPlaneReturnData; 3771 Zoom: boolean;3772 begin 3773 result := false;4457 Zoom: Boolean; 4458 begin 4459 Result := False; 3774 4460 if ClientMode >= scDipOffer then 3775 exit; 3776 3777 if supervising and (me <> 0) then 3778 begin 3779 for i := 0 to DpiScreen.FormCount - 1 do 3780 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then 3781 DpiScreen.Forms[i].Close; // close windows 4461 Exit; 4462 4463 if Supervising and (Me <> 0) then begin 4464 ApplyToVisibleForms(faClose); 3782 4465 ItsMeAgain(0); 3783 4466 end; … … 3797 4480 PlaneReturnData.Loc := Loc; 3798 4481 PlaneReturnData.Movement := 0; // end turn without further movement? 3799 if Server(sGetPlaneReturn, me, uix, PlaneReturnData) = eNoWay then4482 if Server(sGetPlaneReturn, Me, uix, PlaneReturnData) = eNoWay then 3800 4483 begin 3801 4484 CenterLoc := Loc + G.lx * 6; 3802 4485 // centering the unit itself would make it covered by the query dialog 3803 4486 while CenterLoc >= G.lx * G.ly do 3804 dec(CenterLoc, G.lx * 2);4487 Dec(CenterLoc, G.lx * 2); 3805 4488 Centre(CenterLoc); 3806 4489 SetTroopLoc(-1); … … 3817 4500 SetTroopLoc(Loc); 3818 4501 PanelPaint; 3819 exit;4502 Exit; 3820 4503 end; 3821 4504 MyUn[uix].Status := MyUn[uix].Status or usToldNoReturn; 3822 end 4505 end; 3823 4506 end; 3824 4507 3825 if not supervising and (MyRO.TestFlags and tfImmImprove = 0) and4508 if not Supervising and (MyRO.TestFlags and tfImmImprove = 0) and 3826 4509 (MyRO.Government <> gAnarchy) and (MyRO.Money + TaxSum < 0) and 3827 4510 (MyRO.TaxRate < 100) then // low funds! … … 3835 4518 ShowModal; 3836 4519 if ModalResult <> mrOK then 3837 exit4520 Exit; 3838 4521 end; 3839 4522 … … 3843 4526 if (Loc >= 0) and (Flags and chCaptured = 0) then 3844 4527 begin 3845 Zoom := false;4528 Zoom := False; 3846 4529 CityReport.HypoTiles := -1; 3847 4530 CityReport.HypoTax := -1; 3848 4531 CityReport.HypoLux := -1; 3849 Server(sGetCityReport, me, cix, CityReport);4532 Server(sGetCityReport, Me, cix, CityReport); 3850 4533 3851 4534 if (CityReport.Working - CityReport.Happy > Size shr 1) and … … 3904 4587 begin // zoom to city 3905 4588 ZoomToCity(Loc); 3906 exit3907 end 4589 Exit; 4590 end; 3908 4591 end; 3909 4592 … … 3911 4594 (MyData.FarTech <> adNexus) then 3912 4595 if not ChooseResearch then 3913 exit;4596 Exit; 3914 4597 end; 3915 4598 … … 3921 4604 3922 4605 CityDlg.CloseAction := None; 3923 if IsMultiPlayerGame then 3924 begin // close windows for next player 3925 for i := 0 to DpiScreen.FormCount - 1 do 3926 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then 3927 DpiScreen.Forms[i].Close; 3928 end 3929 else 3930 begin 4606 if IsMultiPlayerGame then begin 4607 // Close windows for next player 4608 ApplyToVisibleForms(faClose); 4609 end else begin 3931 4610 if CityDlg.Visible then 3932 4611 CityDlg.Close; … … 3934 4613 UnitStatDlg.Close; 3935 4614 end; 3936 for i := 0 to DpiScreen.FormCount - 1 do 3937 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then 3938 DpiScreen.Forms[i].Enabled := false; 4615 ApplyToVisibleForms(faDisable); 3939 4616 3940 4617 if Server(sTurn, pTurn, 0, nil^) >= rExecuted then … … 3944 4621 else 3945 4622 EOT.Hint := Phrases.Lookup('BTN_SKIP'); 3946 result := true;4623 Result := True; 3947 4624 SetTroopLoc(-1); 3948 4625 pTurn := -1; 3949 4626 pLogo := -1; 3950 UnitInfoBtn.Visible := false;3951 UnitBtn.Visible := false;3952 TerrainBtn.Visible := false;4627 UnitInfoBtn.Visible := False; 4628 UnitBtn.Visible := False; 4629 TerrainBtn.Visible := False; 3953 4630 EOT.ButtonIndex := eotCancel; 3954 EOT.Visible := true;3955 MapValid := false;4631 EOT.Visible := True; 4632 MapValid := False; 3956 4633 PanelPaint; 3957 4634 Update; 3958 4635 ClientMode := -1; 3959 idle := false;3960 skipped := WasSkipped;4636 Idle := False; 4637 Skipped := WasSkipped; 3961 4638 for p1 := 1 to nPl - 1 do 3962 4639 if G.RO[p1] <> nil then 3963 skipped := true; // don't show enemy moves in hotseat mode4640 Skipped := True; // don't show enemy moves in hotseat mode 3964 4641 end 3965 4642 else 3966 PanelPaint 3967 end; // EndTurn4643 PanelPaint; 4644 end; 3968 4645 3969 4646 procedure TMainScreen.EndNego; … … 3971 4648 if NegoDlg.Visible then 3972 4649 NegoDlg.Close; 3973 HaveStrategyAdvice := false; 3974 // AdvisorDlg.HaveStrategyAdvice; 3975 // negotiation might have changed advices 4650 HaveStrategyAdvice := False; 3976 4651 EOT.ButtonIndex := eotCancel; 3977 EOT.Visible := true;4652 EOT.Visible := True; 3978 4653 PanelPaint; 3979 4654 Update; 3980 4655 ClientMode := -1; 3981 idle := false;3982 end; 3983 3984 procedure TMainScreen.ProcessRect(x0, y0, nx, ny, Options: integer);4656 Idle := False; 4657 end; 4658 4659 procedure TMainScreen.ProcessRect(x0, y0, nx, ny, Options: Integer); 3985 4660 var 3986 xs, ys, xl, yl: integer;4661 xs, ys, xl, yl: Integer; 3987 4662 begin 3988 4663 with MainMap do begin … … 3993 4668 while abs(2 * (xs + G.lx * (xxt * 2)) + xl - MapWidth) < 3994 4669 abs(2 * xs + xl - MapWidth) do 3995 inc(xs, G.lx * (xxt * 2));4670 Inc(xs, G.lx * (xxt * 2)); 3996 4671 ys := (y0 - yw) * yyt - yyt; 3997 4672 if xs + xl > MapWidth then … … 4000 4675 yl := MapHeight - ys; 4001 4676 if (xl <= 0) or (yl <= 0) then 4002 exit;4677 Exit; 4003 4678 if Options and prPaint <> 0 then begin 4004 4679 if Options and prAutoBounds <> 0 then … … 4012 4687 end; 4013 4688 4014 procedure TMainScreen.PaintLoc(Loc: integer; Radius: integer = 0);4689 procedure TMainScreen.PaintLoc(Loc: Integer; Radius: Integer = 0); 4015 4690 var 4016 yLoc, x0: integer;4691 yLoc, x0: Integer; 4017 4692 begin 4018 4693 if MapValid then begin 4019 4694 yLoc := (Loc + G.lx * 1024) div G.lx - 1024; 4020 4695 x0 := (Loc + (yLoc and 1 - 2 * Radius + G.lx * 1024) div 2) mod G.lx; 4021 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);4696 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4022 4697 ProcessRect(x0, yLoc - 2 * Radius, 4 * Radius + 1, 4 * Radius + 1, 4023 4698 prPaint or prAutoBounds or prInvalidate); … … 4026 4701 end; 4027 4702 4028 procedure TMainScreen.PaintLocTemp(Loc: integer; Style: TPaintLocTempStyle);4703 procedure TMainScreen.PaintLocTemp(Loc: Integer; Style: TPaintLocTempStyle); 4029 4704 var 4030 y0, x0, xMap, yMap: integer;4705 y0, x0, xMap, yMap: Integer; 4031 4706 begin 4032 4707 with NoMap do begin 4033 4708 if not MapValid then 4034 exit;4709 Exit; 4035 4710 Buffer.Canvas.Font.Assign(UniFont[ftSmall]); 4036 4711 y0 := Loc div G.lx; … … 4040 4715 while abs(2 * (xMap + G.lx * (xxt * 2)) + 2 * xxt - MapWidth) < 4041 4716 abs(2 * xMap + 2 * xxt - MapWidth) do 4042 inc(xMap, G.lx * (xxt * 2));4717 Inc(xMap, G.lx * (xxt * 2)); 4043 4718 yMap := (y0 - yw) * yyt - yyt; 4044 4719 NoMap.SetOutput(Buffer); … … 4052 4727 // panel protusions are added 4053 4728 // NoMap must be set to buffer and bounds before 4054 procedure TMainScreen.PaintBufferToScreen(xMap, yMap, width, height: integer);4729 procedure TMainScreen.PaintBufferToScreen(xMap, yMap, width, height: Integer); 4055 4730 begin 4056 4731 if xMap + width > MapWidth then … … 4060 4735 if (width <= 0) or (height <= 0) or (width + xMap <= 0) or (height + yMap <= 0) 4061 4736 then 4062 exit;4737 Exit; 4063 4738 4064 4739 NoMap.BitBltBitmap(Panel, -xMap - MapOffset, -yMap + MapHeight - overlap, xMidPanel, … … 4070 4745 begin 4071 4746 if xMap < 0 then 4072 DpiBit Canvas(Canvas, MapOffset, TopBarHeight, width + xMap,4747 DpiBitBltCanvas(Canvas, MapOffset, TopBarHeight, width + xMap, 4073 4748 height + yMap, Buffer.Canvas, -xMap, -yMap) 4074 4749 else 4075 DpiBit Canvas(Canvas, xMap + MapOffset, TopBarHeight, width,4750 DpiBitBltCanvas(Canvas, xMap + MapOffset, TopBarHeight, width, 4076 4751 height + yMap, Buffer.Canvas, 0, -yMap); 4077 4752 end … … 4079 4754 begin 4080 4755 if xMap < 0 then 4081 DpiBit Canvas(Canvas, MapOffset, TopBarHeight + yMap, width + xMap,4756 DpiBitBltCanvas(Canvas, MapOffset, TopBarHeight + yMap, width + xMap, 4082 4757 height, Buffer.Canvas, -xMap, 0) 4083 4758 else 4084 DpiBit Canvas(Canvas, xMap + MapOffset, TopBarHeight + yMap, width,4759 DpiBitBltCanvas(Canvas, xMap + MapOffset, TopBarHeight + yMap, width, 4085 4760 height, Buffer.Canvas, 0, 0); 4086 4761 end; 4087 4762 end; 4088 4763 4089 procedure TMainScreen.PaintLoc_BeforeMove(FromLoc: integer);4764 procedure TMainScreen.PaintLoc_BeforeMove(FromLoc: Integer); 4090 4765 var 4091 yLoc, x0: integer;4766 yLoc, x0: Integer; 4092 4767 begin 4093 4768 if MapValid then … … 4095 4770 yLoc := (FromLoc + G.lx * 1024) div G.lx - 1024; 4096 4771 x0 := (FromLoc + (yLoc and 1 + G.lx * 1024) div 2) mod G.lx; 4097 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);4772 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4098 4773 ProcessRect(x0, yLoc, 1, 1, prPaint or prAutoBounds); 4099 4774 end … … 4102 4777 procedure TMainScreen.PaintDestination; 4103 4778 var 4104 Destination: integer;4779 Destination: Integer; 4105 4780 begin 4106 4781 if (UnFocus >= 0) and (MyUn[UnFocus].Status and usGoto <> 0) then … … 4112 4787 end; 4113 4788 4114 {$IFDEF LINUX}4789 {$IFDEF UNIX} 4115 4790 // Can't do scrolling of DC under Linux, then fallback into BitBlt. 4116 4791 function DpiScrollDC(Canvas: TDpiCanvas; dx: longint; dy: longint; const lprcScroll:TRect; const lprcClip:TRect; hrgnUpdate:HRGN; lprcUpdate: PRect):Boolean; 4117 4792 begin 4118 Result := DpiBit Canvas(Canvas, lprcScroll.Left + dx, lprcScroll.Top + dy, lprcScroll.Right - lprcScroll.Left, lprcScroll.Bottom - lprcScroll.Top,4793 Result := DpiBitBltCanvas(Canvas, lprcScroll.Left + dx, lprcScroll.Top + dy, lprcScroll.Right - lprcScroll.Left, lprcScroll.Bottom - lprcScroll.Top, 4119 4794 Canvas, lprcScroll.Left, lprcScroll.Top); 4120 4795 end; … … 4123 4798 procedure TMainScreen.MainOffscreenPaint; 4124 4799 var 4125 ProcessOptions: integer;4800 ProcessOptions: Integer; 4126 4801 rec: TRect; 4127 DoInvalidate: boolean;4128 begin 4129 if me < 0 then4130 with offscreen.Canvas do4802 DoInvalidate: Boolean; 4803 begin 4804 if Me < 0 then 4805 with Offscreen.Canvas do 4131 4806 begin 4132 4807 Brush.Color := $000000; … … 4134 4809 Brush.Style := bsClear; 4135 4810 OffscreenUser := self; 4136 exit;4811 Exit; 4137 4812 end; 4138 4813 … … 4145 4820 if MapValid and (xwd = xw) and (ywd = yw) then 4146 4821 MainMap.SetPaintBounds(0, 0, UsedOffscreenWidth, UsedOffscreenHeight); 4147 MapValid := false;4822 MapValid := False; 4148 4823 OffscreenUser := self; 4149 4824 end; … … 4158 4833 (ywd - yw > MapHeight div yyt) then 4159 4834 begin 4160 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);4835 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4161 4836 ProcessRect(xw, yw, MapWidth div xxt, MapHeight div yyt, 4162 4837 prPaint or prInvalidate); 4163 4838 end else begin 4164 4839 if (xwd = xw) and (ywd = yw) then 4165 exit; { map window not moved }4166 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);4840 Exit; { map window not moved } 4841 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4167 4842 rec := Rect(0, 0, MapWidth, MapHeight); 4168 4843 {$IFDEF WINDOWS} 4169 DpiScrollDC( offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt,4844 DpiScrollDC(Offscreen.Canvas.Handle, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4170 4845 rec, rec, 0, nil); 4171 4846 {$ENDIF} 4172 {$IFDEF LINUX}4173 DpiScrollDC( offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt,4847 {$IFDEF UNIX} 4848 DpiScrollDC(Offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4174 4849 rec, rec, 0, nil); 4175 4850 {$ENDIF} 4176 for DoInvalidate := false to FastScrolling do begin4851 for DoInvalidate := False to FastScrolling do begin 4177 4852 if DoInvalidate then begin 4178 4853 rec.Bottom := MapHeight - overlap; 4179 4854 {$IFDEF WINDOWS} 4180 DpiScrollDC(Canvas , (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, rec,4855 DpiScrollDC(Canvas.Handle, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, rec, 4181 4856 rec, 0, nil); 4182 4857 {$ENDIF} 4183 {$IFDEF LINUX}4858 {$IFDEF UNIX} 4184 4859 DpiScrollDC(Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4185 4860 rec, rec, 0, nil); … … 4231 4906 xwd := xw; 4232 4907 ywd := yw; 4233 MapValid := true;4908 MapValid := True; 4234 4909 end; 4235 4910 … … 4264 4939 begin 4265 4940 with MainMap do begin 4266 DpiBit Canvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly,4941 DpiBitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 4267 4942 MiniMap.Bitmap.Canvas, 0, 0); 4268 4943 if MarkCityLoc >= 0 then … … 4288 4963 function MovementToString(var Un: TUn): string; 4289 4964 begin 4290 result := ScreenTools.MovementToString(Un.Movement);4965 Result := ScreenTools.MovementToString(Un.Movement); 4291 4966 if Un.Master >= 0 then 4292 result := '(' + result + ')'4967 Result := '(' + Result + ')' 4293 4968 else if (MyModel[Un.mix].Domain = dAir) and 4294 4969 (MyModel[Un.mix].Kind <> mkSpecial_Glider) then 4295 result := Format('%s(%d)', [result, Un.Fuel]);4970 Result := Format('%s(%d)', [Result, Un.Fuel]); 4296 4971 end; 4297 4972 4298 4973 var 4299 i, uix, uixDefender, x, xSrc, ySrc, xSrcBase, ySrcBase, CostFactor, Count,4974 I, uix, uixDefender, X, xSrc, ySrc, xSrcBase, ySrcBase, CostFactor, Count, 4300 4975 mixShow, xTreasurySection, xResearchSection, JobFocus, TrueMoney, 4301 TrueResearch: integer;4976 TrueResearch: Integer; 4302 4977 Tile: Cardinal; 4303 s: string;4978 S: string; 4304 4979 unx: TUn; 4305 4980 UnitInfo: TUnitInfo; 4306 4981 JobProgressData: TJobProgressData; 4307 Prio: boolean;4982 Prio: Boolean; 4308 4983 begin 4309 4984 if not Assigned(MyRO) then Exit; … … 4349 5024 if ClientMode <> cEditMap then 4350 5025 begin 4351 if supervising then5026 if Supervising then 4352 5027 begin 4353 5028 ScreenTools.Frame(Panel.Canvas, ClientWidth - xPalace - 1, yPalace - 1, … … 4357 5032 ClientWidth - xPalace + xSizeBig + 1, yPalace + ySizeBig + 1, 4358 5033 $FFFFFF, $B0B0B0); 4359 DpiBit Canvas(Panel.Canvas, ClientWidth - xPalace, yPalace, xSizeBig,5034 DpiBitBltCanvas(Panel.Canvas, ClientWidth - xPalace, yPalace, xSizeBig, 4360 5035 ySizeBig, HGrSystem2.Data.Canvas, 70, 123); 4361 5036 end … … 4382 5057 CopyMiniToPanel; 4383 5058 if ClientMode <> cEditMap then // MapBtn icons 4384 for i:= 0 to 5 do4385 if i<> 3 then4386 Dump(Panel, HGrSystem, xMini + G.lx - 42 + 16 * i, PanelHeight - 26,4387 8, 8, 121 + i* 9, 61);5059 for I := 0 to 5 do 5060 if I <> 3 then 5061 Dump(Panel, HGrSystem, xMini + G.lx - 42 + 16 * I, PanelHeight - 26, 5062 8, 8, 121 + I * 9, 61); 4388 5063 4389 5064 if ClientMode = cEditMap then 4390 5065 begin 4391 for i:= 0 to TrRow - 1 do4392 trix[ i] := -1;5066 for I := 0 to TrRow - 1 do 5067 trix[I] := -1; 4393 5068 Count := 0; 4394 for i:= 0 to nBrushTypes - 1 do5069 for I := 0 to nBrushTypes - 1 do 4395 5070 begin // display terrain types 4396 5071 if (Count >= TrRow * sb.Position) and (Count < TrRow * (sb.Position + 1)) 4397 5072 then 4398 5073 begin 4399 trix[Count - TrRow * sb.Position] := BrushTypes[ i];4400 x:= (Count - TrRow * sb.Position) * TrPitch;5074 trix[Count - TrRow * sb.Position] := BrushTypes[I]; 5075 X := (Count - TrRow * sb.Position) * TrPitch; 4401 5076 xSrcBase := -1; 4402 case BrushTypes[ i] of5077 case BrushTypes[I] of 4403 5078 0 .. 8: 4404 5079 begin 4405 xSrc := BrushTypes[ i];5080 xSrc := BrushTypes[I]; 4406 5081 ySrc := 0 4407 5082 end; … … 4411 5086 ySrcBase := 2; 4412 5087 xSrc := 0; 4413 ySrc := 2 * integer(BrushTypes[i]) - 155088 ySrc := 2 * Integer(BrushTypes[I]) - 15 4414 5089 end; 4415 5090 fRiver: … … 4444 5119 ySrcBase := 2; 4445 5120 xSrc := 8; 4446 ySrc := 12 + BrushTypes[ i] shr 25;5121 ySrc := 12 + BrushTypes[I] shr 25; 4447 5122 end; 4448 5123 tiIrrigation, tiFarm, tiMine, tiBase: 4449 5124 begin 4450 xSrc := BrushTypes[ i] shr 12 - 1;5125 xSrc := BrushTypes[I] shr 12 - 1; 4451 5126 ySrc := 12 4452 5127 end; … … 4471 5146 with MainMap do begin 4472 5147 if xSrcBase >= 0 then 4473 Sprite(Panel, HGrTerrain, xTroop + 2 + x, yTroop + 9 - yyt, xxt * 2,5148 Sprite(Panel, HGrTerrain, xTroop + 2 + X, yTroop + 9 - yyt, xxt * 2, 4474 5149 yyt * 3, 1 + xSrcBase * (xxt * 2 + 1), 4475 5150 1 + ySrcBase * (yyt * 3 + 1)); 4476 Sprite(Panel, HGrTerrain, xTroop + 2 + x, yTroop + 9 - yyt, xxt * 2,5151 Sprite(Panel, HGrTerrain, xTroop + 2 + X, yTroop + 9 - yyt, xxt * 2, 4477 5152 yyt * 3, 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 4478 if BrushTypes[ i] = BrushType then begin4479 ScreenTools.Frame(Panel.Canvas, xTroop + 2 + x,4480 yTroop + 7 - yyt div 2, xTroop + 2 * xxt + x,5153 if BrushTypes[I] = BrushType then begin 5154 ScreenTools.Frame(Panel.Canvas, xTroop + 2 + X, 5155 yTroop + 7 - yyt div 2, xTroop + 2 * xxt + X, 4481 5156 yTroop + 2 * yyt + 11, $000000, $000000); 4482 ScreenTools.Frame(Panel.Canvas, xTroop + 1 + x,4483 yTroop + 6 - yyt div 2, xTroop + 2 * xxt - 1 + x,5157 ScreenTools.Frame(Panel.Canvas, xTroop + 1 + X, 5158 yTroop + 6 - yyt div 2, xTroop + 2 * xxt - 1 + X, 4484 5159 yTroop + 2 * yyt + 10, MainTexture.ColorMark, MainTexture.ColorMark); 4485 5160 end; 4486 5161 end; 4487 5162 end; 4488 inc(Count)5163 Inc(Count) 4489 5164 end; 4490 5165 case BrushType of 4491 5166 fDesert, fPrairie, fTundra, fArctic, fSwamp, fHills, fMountains: 4492 s:= Phrases.Lookup('TERRAIN', BrushType);5167 S := Phrases.Lookup('TERRAIN', BrushType); 4493 5168 fShore: 4494 s:= Format(Phrases.Lookup('TWOTERRAINS'),5169 S := Format(Phrases.Lookup('TWOTERRAINS'), 4495 5170 [Phrases.Lookup('TERRAIN', fOcean), Phrases.Lookup('TERRAIN', 4496 5171 fShore)]); 4497 5172 fGrass: 4498 s:= Format(Phrases.Lookup('TWOTERRAINS'),5173 S := Format(Phrases.Lookup('TWOTERRAINS'), 4499 5174 [Phrases.Lookup('TERRAIN', fGrass), Phrases.Lookup('TERRAIN', 4500 5175 fGrass + 12)]); 4501 5176 fForest: 4502 s:= Format(Phrases.Lookup('TWOTERRAINS'),5177 S := Format(Phrases.Lookup('TWOTERRAINS'), 4503 5178 [Phrases.Lookup('TERRAIN', fForest), Phrases.Lookup('TERRAIN', 4504 5179 fJungle)]); 4505 5180 fRiver: 4506 s:= Phrases.Lookup('RIVER');5181 S := Phrases.Lookup('RIVER'); 4507 5182 fDeadLands, fDeadLands or fCobalt, fDeadLands or fUranium, 4508 5183 fDeadLands or fMercury: 4509 s:= Phrases.Lookup('TERRAIN', 3 * 12 + BrushType shr 25);5184 S := Phrases.Lookup('TERRAIN', 3 * 12 + BrushType shr 25); 4510 5185 fPrefStartPos: 4511 s:= Phrases.Lookup('MAP_PREFSTART');5186 S := Phrases.Lookup('MAP_PREFSTART'); 4512 5187 fStartPos: 4513 s:= Phrases.Lookup('MAP_START');5188 S := Phrases.Lookup('MAP_START'); 4514 5189 fPoll: 4515 s:= Phrases.Lookup('POLL');5190 S := Phrases.Lookup('POLL'); 4516 5191 else // terrain improvements 4517 5192 begin 4518 5193 case BrushType of 4519 5194 fRoad: 4520 i:= 1;5195 I := 1; 4521 5196 fRR: 4522 i:= 2;5197 I := 2; 4523 5198 tiIrrigation: 4524 i:= 4;5199 I := 4; 4525 5200 tiFarm: 4526 i:= 5;5201 I := 5; 4527 5202 tiMine: 4528 i:= 7;5203 I := 7; 4529 5204 fCanal: 4530 i:= 8;5205 I := 8; 4531 5206 tiFort: 4532 i:= 10;5207 I := 10; 4533 5208 tiBase: 4534 i:= 12;5209 I := 12; 4535 5210 end; 4536 s := Phrases.Lookup('JOBRESULT', i);5211 S := Phrases.Lookup('JOBRESULT', I); 4537 5212 end 4538 5213 end; 4539 5214 LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 1, 4540 PanelHeight - 19, s);5215 PanelHeight - 19, S); 4541 5216 end 4542 5217 else if TroopLoc >= 0 then … … 4544 5219 Brush.Style := bsClear; 4545 5220 if UnFocus >= 0 then 4546 with MyUn [UnFocus] do4547 with MyModel [mix] do5221 with MyUn^[UnFocus] do 5222 with MyModel^[mix] do 4548 5223 begin { display info about selected unit } 4549 5224 if Job = jCity then … … 4551 5226 else 4552 5227 mixShow := mix; 4553 with Tribe[ me].ModelPicture[mixShow] do5228 with Tribe[Me].ModelPicture[mixShow] do 4554 5229 begin 4555 5230 Sprite(Panel, HGr, xMidPanel + 7 + 12, yTroop + 1, 64, 48, … … 4561 5236 4562 5237 MakeBlue(Panel, xMidPanel + 7 + 12 + 10, yTroop - 13, 44, 12); 4563 s:= MovementToString(MyUn[UnFocus]);5238 S := MovementToString(MyUn[UnFocus]); 4564 5239 RisedTextOut(Panel.Canvas, xMidPanel + 7 + 12 + 32 - 4565 BiColorTextWidth(Panel.Canvas, s) div 2, yTroop - 16, s);4566 4567 s:= IntToStr(Health) + '%';5240 BiColorTextWidth(Panel.Canvas, S) div 2, yTroop - 16, S); 5241 5242 S := IntToStr(Health) + '%'; 4568 5243 LightGradient(Panel.Canvas, xMidPanel + 7 + 12 + 7, PanelHeight - 22, 4569 5244 (Health + 1) div 2, (ColorOfHealth(Health) and $FEFEFE shr 2) * 3); … … 4572 5247 div 2, PanelHeight - 22, 50 - (Health + 1) div 2, $000000); 4573 5248 RisedTextOut(Panel.Canvas, xMidPanel + 7 + 12 + 32 - 4574 BiColorTextWidth(Panel.Canvas, s) div 2, PanelHeight - 23, s);5249 BiColorTextWidth(Panel.Canvas, S) div 2, PanelHeight - 23, S); 4575 5250 4576 5251 FrameImage(Panel.Canvas, HGrSystem.Data, … … 4578 5253 121 + Exp div ExpCost * 13, 28); 4579 5254 if Job = jCity then 4580 s := Tribe[me].ModelName[-1]5255 S := Tribe[Me].ModelName[-1] 4581 5256 else 4582 s := Tribe[me].ModelName[mix];5257 S := Tribe[Me].ModelName[mix]; 4583 5258 if Home >= 0 then 4584 5259 begin 4585 5260 LoweredTextOut(Panel.Canvas, -1, MainTexture, 4586 xMidPanel + 7 + xUnitText + 18, yTroop + 5, s);5261 xMidPanel + 7 + xUnitText + 18, yTroop + 5, S); 4587 5262 LoweredTextOut(Panel.Canvas, -1, MainTexture, 4588 5263 xMidPanel + 7 + xUnitText + 18, yTroop + 21, … … 4591 5266 else 4592 5267 LoweredTextOut(Panel.Canvas, -1, MainTexture, 4593 xMidPanel + 7 + xUnitText + 18, yTroop + 13, s);5268 xMidPanel + 7 + xUnitText + 18, yTroop + 13, S); 4594 5269 end; 4595 5270 4596 5271 if (UnFocus >= 0) and (MyUn[UnFocus].Loc <> TroopLoc) then 4597 5272 begin // divide panel 4598 if SmallScreen and not supervising then4599 x:= xTroop - 85273 if SmallScreen and not Supervising then 5274 X := xTroop - 8 4600 5275 else 4601 x:= xTroop - 152;5276 X := xTroop - 152; 4602 5277 Pen.Color := MainTexture.ColorBevelShade; 4603 MoveTo( x- 1, PanelHeight - MidPanelHeight + 2);4604 LineTo( x- 1, PanelHeight);5278 MoveTo(X - 1, PanelHeight - MidPanelHeight + 2); 5279 LineTo(X - 1, PanelHeight); 4605 5280 Pen.Color := MainTexture.ColorBevelLight; 4606 MoveTo( x, PanelHeight - MidPanelHeight + 2);4607 LineTo( x, PanelHeight);4608 end; 4609 4610 for i:= 0 to 23 do4611 trix[ i] := -1;5281 MoveTo(X, PanelHeight - MidPanelHeight + 2); 5282 LineTo(X, PanelHeight); 5283 end; 5284 5285 for I := 0 to 23 do 5286 trix[I] := -1; 4612 5287 if MyMap[TroopLoc] and fUnit <> 0 then 4613 5288 begin … … 4619 5294 LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 10, 4620 5295 PanelHeight - 24, Phrases.Lookup('PRESENT')); 4621 Server(sGetDefender, me, TroopLoc, uixDefender);5296 Server(sGetDefender, Me, TroopLoc, uixDefender); 4622 5297 Count := 0; 4623 for Prio := true downto false do5298 for Prio := True downto False do 4624 5299 for uix := 0 to MyRO.nUn - 1 do 4625 5300 if (uix = uixDefender) = Prio then … … 4632 5307 begin 4633 5308 trix[Count - TrRow * sb.Position] := uix; 4634 MakeUnitInfo( me, unx, UnitInfo);4635 x:= (Count - TrRow * sb.Position) * TrPitch;5309 MakeUnitInfo(Me, unx, UnitInfo); 5310 X := (Count - TrRow * sb.Position) * TrPitch; 4636 5311 if uix = UnFocus then 4637 5312 begin 4638 ScreenTools.Frame(Panel.Canvas, xTroop + 4 + x,4639 yTroop + 3, xTroop + 64 + x, yTroop + 47,5313 ScreenTools.Frame(Panel.Canvas, xTroop + 4 + X, 5314 yTroop + 3, xTroop + 64 + X, yTroop + 47, 4640 5315 $000000, $000000); 4641 ScreenTools.Frame(Panel.Canvas, xTroop + 3 + x,4642 yTroop + 2, xTroop + 63 + x, yTroop + 46,5316 ScreenTools.Frame(Panel.Canvas, xTroop + 3 + X, 5317 yTroop + 2, xTroop + 63 + X, yTroop + 46, 4643 5318 MainTexture.ColorMark, MainTexture.ColorMark); 4644 5319 end 4645 5320 else if (unx.Master >= 0) and (unx.Master = UnFocus) then 4646 5321 begin 4647 CFrame(Panel.Canvas, xTroop + 4 + x, yTroop + 3,4648 xTroop + 64 + x, yTroop + 47, 8, $000000);4649 CFrame(Panel.Canvas, xTroop + 3 + x, yTroop + 2,4650 xTroop + 63 + x, yTroop + 46, 8, MainTexture.ColorMark);5322 CFrame(Panel.Canvas, xTroop + 4 + X, yTroop + 3, 5323 xTroop + 64 + X, yTroop + 47, 8, $000000); 5324 CFrame(Panel.Canvas, xTroop + 3 + X, yTroop + 2, 5325 xTroop + 63 + X, yTroop + 46, 8, MainTexture.ColorMark); 4651 5326 end; 4652 5327 NoMapPanel.SetOutput(Panel); 4653 NoMapPanel.PaintUnit(xTroop + 2 + x, yTroop + 1, UnitInfo,5328 NoMapPanel.PaintUnit(xTroop + 2 + X, yTroop + 1, UnitInfo, 4654 5329 unx.Status); 4655 5330 if (ClientMode < scContact) and … … 4657 5332 (unx.Status and (usStay or usRecover or usGoto) <> 0)) 4658 5333 then 4659 Sprite(Panel, HGrSystem, xTroop + 2 + 60 - 20 + x,5334 Sprite(Panel, HGrSystem, xTroop + 2 + 60 - 20 + X, 4660 5335 yTroop + 35, 20, 20, 81, 25); 4661 5336 4662 if not supervising then5337 if not Supervising then 4663 5338 begin 4664 MakeBlue(Panel, xTroop + 2 + 10 + x,5339 MakeBlue(Panel, xTroop + 2 + 10 + X, 4665 5340 yTroop - 13, 44, 12); 4666 s:= MovementToString(unx);5341 S := MovementToString(unx); 4667 5342 RisedTextOut(Panel.Canvas, 4668 xTroop + x + 34 - BiColorTextWidth(Panel.Canvas, s)4669 div 2, yTroop - 16, s);5343 xTroop + X + 34 - BiColorTextWidth(Panel.Canvas, S) 5344 div 2, yTroop - 16, S); 4670 5345 end; 4671 5346 end; 4672 inc(Count)5347 Inc(Count) 4673 5348 end; 4674 5349 end; // for uix:=0 to MyRO.nUn-1 4675 assert(Count = TrCnt);5350 Assert(Count = TrCnt); 4676 5351 end; 4677 5352 end … … 4680 5355 LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 8, 4681 5356 PanelHeight - 24, Phrases.Lookup('PRESENT')); 4682 Server(sGetUnits, me, TroopLoc, Count);4683 for i:= 0 to Count - 1 do4684 if ( i >= TrRow * sb.Position) and (i< TrRow * (sb.Position + 1)) then5357 Server(sGetUnits, Me, TroopLoc, Count); 5358 for I := 0 to Count - 1 do 5359 if (I >= TrRow * sb.Position) and (I < TrRow * (sb.Position + 1)) then 4685 5360 begin // display enemy units 4686 trix[ i - TrRow * sb.Position] := i;4687 x := (i- TrRow * sb.Position) * TrPitch;5361 trix[I - TrRow * sb.Position] := I; 5362 X := (I - TrRow * sb.Position) * TrPitch; 4688 5363 NoMapPanel.SetOutput(Panel); 4689 NoMapPanel.PaintUnit(xTroop + 2 + x, yTroop + 1,4690 MyRO.EnemyUn[MyRO.nEnemyUn + i], 0);5364 NoMapPanel.PaintUnit(xTroop + 2 + X, yTroop + 1, 5365 MyRO.EnemyUn[MyRO.nEnemyUn + I], 0); 4691 5366 end; 4692 5367 end; 4693 5368 end; 4694 if not SmallScreen or supervising then5369 if not SmallScreen or Supervising then 4695 5370 begin // show terrain and improvements 4696 5371 with NoMapPanel do … … 4698 5373 if (UnFocus >= 0) and (MyUn[UnFocus].Job <> jNone) then begin 4699 5374 JobFocus := MyUn[UnFocus].Job; 4700 Server(sGetJobProgress, me, MyUn[UnFocus].Loc, JobProgressData);5375 Server(sGetJobProgress, Me, MyUn[UnFocus].Loc, JobProgressData); 4701 5376 MakeBlue(Panel, xTerrain - 72, 148 - 17, 144, 31); 4702 5377 PaintRelativeProgressBar(Panel.Canvas, 3, xTerrain - 68, 148 + 3, 63, 4703 5378 JobProgressData[JobFocus].Done, 4704 5379 JobProgressData[JobFocus].NextTurnPlus, 4705 JobProgressData[JobFocus].Required, true, MainTexture);4706 s:= Format('%s/%s',5380 JobProgressData[JobFocus].Required, True, MainTexture); 5381 S := Format('%s/%s', 4707 5382 [ScreenTools.MovementToString(JobProgressData[JobFocus].Done), 4708 5383 ScreenTools.MovementToString(JobProgressData[JobFocus].Required)]); 4709 RisedTextOut(Panel.Canvas, xTerrain + 6, 148 - 3, s);5384 RisedTextOut(Panel.Canvas, xTerrain + 6, 148 - 3, S); 4710 5385 Tile := MyMap[MyUn[UnFocus].Loc]; 4711 5386 if (JobFocus = jRoad) and (Tile and fRiver <> 0) then … … 4722 5397 JobFocus := nJob + 4 4723 5398 end; 4724 s:= Phrases.Lookup('JOBRESULT', JobFocus);5399 S := Phrases.Lookup('JOBRESULT', JobFocus); 4725 5400 RisedTextOut(Panel.Canvas, xTerrain - BiColorTextWidth(Panel.Canvas, 4726 s) div 2, 148 - 19, s);5401 S) div 2, 148 - 19, S); 4727 5402 end; 4728 5403 if MyMap[TroopLoc] and (fTerrain or fSpecial) = fGrass or fSpecial1 then 4729 s:= Phrases.Lookup('TERRAIN', fGrass + 12)5404 S := Phrases.Lookup('TERRAIN', fGrass + 12) 4730 5405 else if MyMap[TroopLoc] and fDeadLands <> 0 then 4731 s:= Phrases.Lookup('TERRAIN', 3 * 12)5406 S := Phrases.Lookup('TERRAIN', 3 * 12) 4732 5407 else if (MyMap[TroopLoc] and fTerrain = fForest) and 4733 5408 IsJungle(TroopLoc div G.lx) then 4734 s:= Phrases.Lookup('TERRAIN', fJungle)5409 S := Phrases.Lookup('TERRAIN', fJungle) 4735 5410 else 4736 s:= Phrases.Lookup('TERRAIN', MyMap[TroopLoc] and fTerrain);4737 RisedTextOut(Panel.Canvas, xTerrain - BiColorTextWidth(Panel.Canvas, s)4738 div 2, 99, s);5411 S := Phrases.Lookup('TERRAIN', MyMap[TroopLoc] and fTerrain); 5412 RisedTextOut(Panel.Canvas, xTerrain - BiColorTextWidth(Panel.Canvas, S) 5413 div 2, 99, S); 4739 5414 end; 4740 5415 … … 4747 5422 end; 4748 5423 4749 for i:= 0 to ControlCount - 1 do4750 if Controls[ i] is TButtonB then4751 with TButtonB(Controls[ i]) do5424 for I := 0 to ControlCount - 1 do 5425 if Controls[I] is TButtonB then 5426 with TButtonB(Controls[I]) do 4752 5427 begin 4753 5428 if Visible then … … 4765 5440 if ClientMode <> cEditMap then 4766 5441 begin 4767 for i:= 0 to ControlCount - 1 do4768 if Controls[ i] is TButtonC then4769 with TButtonC(Controls[ i]) do5442 for I := 0 to ControlCount - 1 do 5443 if Controls[I] is TButtonC then 5444 with TButtonC(Controls[I]) do 4770 5445 begin 4771 5446 Dump(Panel, HGrSystem, Left, Top - self.ClientHeight + PanelHeight, … … 4807 5482 TrueMoney := MyRO.Money; 4808 5483 TrueResearch := MyRO.Research; 4809 if supervising then5484 if Supervising then 4810 5485 begin // normalize values from after-turn state 4811 dec(TrueMoney, TaxSum);5486 Dec(TrueMoney, TaxSum); 4812 5487 if TrueMoney < 0 then 4813 5488 TrueMoney := 0; // shouldn't happen 4814 dec(TrueResearch, ScienceSum);5489 Dec(TrueResearch, ScienceSum); 4815 5490 if TrueResearch < 0 then 4816 5491 TrueResearch := 0; // shouldn't happen … … 4820 5495 ImageOp_BCC(TopBar, Templates.Data, Point(xTreasurySection + 8, 1), TreasuryIcon.BoundsRect, 4821 5496 $40A040, $4030C0); 4822 s:= IntToStr(TrueMoney);5497 S := IntToStr(TrueMoney); 4823 5498 LoweredTextOut(TopBar.Canvas, -1, MainTexture, xTreasurySection + 48, 0, 4824 s+ '%c');5499 S + '%c'); 4825 5500 if MyRO.Government <> gAnarchy then 4826 5501 begin … … 4828 5503 $0000C0, $0080C0); 4829 5504 if TaxSum >= 0 then 4830 s:= Format(Phrases.Lookup('MONEYGAINPOS'), [TaxSum])5505 S := Format(Phrases.Lookup('MONEYGAINPOS'), [TaxSum]) 4831 5506 else 4832 s:= Format(Phrases.Lookup('MONEYGAINNEG'), [TaxSum]);5507 S := Format(Phrases.Lookup('MONEYGAINNEG'), [TaxSum]); 4833 5508 LoweredTextOut(TopBar.Canvas, -1, MainTexture, xTreasurySection + 48 + 4834 15, 18, s);5509 15, 18, S); 4835 5510 end; 4836 5511 … … 4852 5527 else 4853 5528 CostFactor := 2; 4854 Server(sGetTechCost, me, 0, i);5529 Server(sGetTechCost, Me, 0, I); 4855 5530 CostFactor := CostFactor * 22; // length of progress bar 4856 5531 PaintRelativeProgressBar(TopBar.Canvas, 2, xResearchSection + 48 + 1, 26, 4857 CostFactor, TrueResearch, ScienceSum, i, true, MainTexture);5532 CostFactor, TrueResearch, ScienceSum, I, True, MainTexture); 4858 5533 4859 5534 if MyRO.ResearchTech < 0 then 4860 s:= Phrases.Lookup('SCIENCE')5535 S := Phrases.Lookup('SCIENCE') 4861 5536 else if MyRO.ResearchTech = adMilitary then 4862 s:= Phrases.Lookup('INITUNIT')5537 S := Phrases.Lookup('INITUNIT') 4863 5538 else 4864 5539 begin 4865 s:= Phrases.Lookup('ADVANCES', MyRO.ResearchTech);5540 S := Phrases.Lookup('ADVANCES', MyRO.ResearchTech); 4866 5541 if MyRO.ResearchTech in FutureTech then 4867 5542 if MyRO.Tech[MyRO.ResearchTech] >= 1 then 4868 s := s+ ' ' + IntToStr(MyRO.Tech[MyRO.ResearchTech] + 1)5543 S := S + ' ' + IntToStr(MyRO.Tech[MyRO.ResearchTech] + 1) 4869 5544 else 4870 s := s+ ' 1';5545 S := S + ' 1'; 4871 5546 end; 4872 5547 if ScienceSum > 0 then 4873 5548 begin 4874 5549 { j:=(i-MyRO.Research-1) div ScienceSum +1; 4875 if j<1 then j:=1;4876 if j>1 then4877 s:=Format(Phrases.Lookup('TECHWAIT'),[s,j]); }5550 if J<1 then J:=1; 5551 if J>1 then 5552 S:=Format(Phrases.Lookup('TECHWAIT'),[S,J]); } 4878 5553 LoweredTextOut(TopBar.Canvas, -1, MainTexture, 4879 xResearchSection + 48, 0, s);5554 xResearchSection + 48, 0, S); 4880 5555 end 4881 5556 else 4882 5557 LoweredTextOut(TopBar.Canvas, -1, MainTexture, 4883 xResearchSection + 48, 0, s);5558 xResearchSection + 48, 0, S); 4884 5559 end 4885 5560 else … … 4889 5564 ImageOp_BCC(TopBar, Templates.Data, Point(xResearchSection + 48 + CostFactor + 11, 4890 5565 22), ChangeIcon.BoundsRect, $0000C0, $0080C0); 4891 s:= Format(Phrases.Lookup('TECHGAIN'), [ScienceSum]);5566 S := Format(Phrases.Lookup('TECHGAIN'), [ScienceSum]); 4892 5567 LoweredTextOut(TopBar.Canvas, -1, MainTexture, xResearchSection + 48 + 4893 CostFactor + 26, 18, s);5568 CostFactor + 26, 18, S); 4894 5569 end; 4895 5570 end; … … 4897 5572 begin 4898 5573 TopBar.Canvas.Font.Assign(UniFont[ftCaption]); 4899 s:= TurnToString(MyRO.Turn);5574 S := TurnToString(MyRO.Turn); 4900 5575 RisedTextOut(TopBar.Canvas, 4901 40 + (xTreasurySection - 40 - BiColorTextWidth(TopBar.Canvas, s))4902 div 2, 6, s);5576 40 + (xTreasurySection - 40 - BiColorTextWidth(TopBar.Canvas, S)) 5577 div 2, 6, S); 4903 5578 TopBar.Canvas.Font.Assign(UniFont[ftNormal]); 4904 5579 end; … … 4908 5583 procedure TMainScreen.FocusNextUnit(Dir: Integer); 4909 5584 var 4910 i, uix, NewFocus: Integer;5585 I, uix, NewFocus: Integer; 4911 5586 begin 4912 5587 if ClientMode >= scContact then … … 4915 5590 PaintDestination; 4916 5591 NewFocus := -1; 4917 for i:= 1 to MyRO.nUn do begin4918 uix := (UnFocus + i* Dir + MyRO.nUn) mod MyRO.nUn;5592 for I := 1 to MyRO.nUn do begin 5593 uix := (UnFocus + I * Dir + MyRO.nUn) mod MyRO.nUn; 4919 5594 if (MyUn[uix].Loc >= 0) and (MyUn[uix].Status and usStay = 0) then begin 4920 5595 NewFocus := uix; … … 4929 5604 end; 4930 5605 4931 procedure TMainScreen.FocusOnLoc(Loc: integer; Options: integer = 0);5606 procedure TMainScreen.FocusOnLoc(Loc: Integer; Options: Integer = 0); 4932 5607 var 4933 dx: integer;4934 Outside, Changed: boolean;5608 dx: Integer; 5609 Outside, Changed: Boolean; 4935 5610 begin 4936 5611 with MainMap do begin … … 4940 5615 (Loc div G.lx >= yw + (MapHeight - 1) div yyt - 2)); 4941 5616 end; 4942 Changed := true;5617 Changed := True; 4943 5618 if Outside then begin 4944 5619 Centre(Loc); … … 4948 5623 PaintAllMaps 4949 5624 else 4950 Changed := false;5625 Changed := False; 4951 5626 if Options and flRepaintPanel <> 0 then 4952 5627 PanelPaint; … … 4958 5633 var 4959 5634 Dist, TestDist: Single; 4960 i, uix, NewFocus: Integer;5635 I, uix, NewFocus: Integer; 4961 5636 GotoOnly: Boolean; 4962 5637 begin … … 4968 5643 for GotoOnly := GoOnPhase downto False do begin 4969 5644 NewFocus := -1; 4970 for i:= 1 to MyRO.nUn do begin4971 uix := (UnFocus + i) mod MyRO.nUn;5645 for I := 1 to MyRO.nUn do begin 5646 uix := (UnFocus + I) mod MyRO.nUn; 4972 5647 if (MyUn[uix].Loc >= 0) and (MyUn[uix].Job = jNone) and 4973 5648 (MyUn[uix].Status and (usStay or usRecover or usWaiting) = usWaiting) … … 5008 5683 end; 5009 5684 5010 procedure TMainScreen.Scroll(dx, dy: integer);5685 procedure TMainScreen.Scroll(dx, dy: Integer); 5011 5686 begin 5012 5687 xw := (xw + G.lx + dx) mod G.lx; … … 5032 5707 procedure TMainScreen.Timer1Timer(Sender: TObject); 5033 5708 var 5034 dx, dy, ScrollSpeed: integer;5035 begin 5036 if idle and (me >= 0) and (GameMode <> cMovie) then5709 dx, dy, ScrollSpeed: Integer; 5710 begin 5711 if Idle and (Me >= 0) and (GameMode <> cMovie) then 5037 5712 if (fsModal in DpiScreen.ActiveForm.FormState) or 5038 5713 (DpiScreen.ActiveForm is TBufferedDrawDlg) and … … 5042 5717 if not BlinkON then 5043 5718 begin 5044 BlinkON := true;5719 BlinkON := True; 5045 5720 if UnFocus >= 0 then 5046 5721 PaintLocTemp(MyUn[UnFocus].Loc) 5047 else if TurnComplete and not supervising then5722 else if TurnComplete and not Supervising then 5048 5723 EOT.SetButtonIndexFast(eotBlinkOn); 5049 5724 end; … … 5057 5732 dx := 0; 5058 5733 dy := 0; 5059 if DpiMouse.CursorPos. y< DpiScreen.height - PanelHeight then5060 if DpiMouse.CursorPos. x= 0 then5734 if DpiMouse.CursorPos.Y < DpiScreen.height - PanelHeight then 5735 if DpiMouse.CursorPos.X = 0 then 5061 5736 dx := -ScrollSpeed // scroll left 5062 else if DpiMouse.CursorPos. x= DpiScreen.width - 1 then5737 else if DpiMouse.CursorPos.X = DpiScreen.width - 1 then 5063 5738 dx := ScrollSpeed; // scroll right 5064 if DpiMouse.CursorPos. y= 0 then5739 if DpiMouse.CursorPos.Y = 0 then 5065 5740 dy := -ScrollSpeed // scroll up 5066 else if (DpiMouse.CursorPos. y= DpiScreen.height - 1) and5067 (DpiMouse.CursorPos. x>= TerrainBtn.Left + TerrainBtn.width) and5068 (DpiMouse.CursorPos. x< xRightPanel + 10 - 8) then5741 else if (DpiMouse.CursorPos.Y = DpiScreen.height - 1) and 5742 (DpiMouse.CursorPos.X >= TerrainBtn.Left + TerrainBtn.width) and 5743 (DpiMouse.CursorPos.X < xRightPanel + 10 - 8) then 5069 5744 dy := ScrollSpeed; // scroll down 5070 5745 if (dx <> 0) or (dy <> 0) then … … 5079 5754 BlinkTime := (BlinkTime + 1) mod (BlinkOnTime + BlinkOffTime); 5080 5755 BlinkON := BlinkTime >= BlinkOffTime; 5081 DestinationMarkON := true;5756 DestinationMarkON := True; 5082 5757 if UnFocus >= 0 then 5083 5758 begin … … 5090 5765 end; 5091 5766 end 5092 else if TurnComplete and not supervising then5767 else if TurnComplete and not Supervising then 5093 5768 begin 5094 5769 if BlinkTime = 0 then … … 5100 5775 end; 5101 5776 5102 procedure TMainScreen.SetMapPos(Loc: integer; MapPos: TPoint);5777 procedure TMainScreen.SetMapPos(Loc: Integer; MapPos: TPoint); 5103 5778 begin 5104 5779 with MainMap do begin … … 5118 5793 end; 5119 5794 5120 procedure TMainScreen.Centre(Loc: integer);5795 procedure TMainScreen.Centre(Loc: Integer); 5121 5796 begin 5122 5797 SetMapPos(Loc, Point(MapWidth div 2, MapHeight div 2)); 5123 5798 end; 5124 5799 5125 function TMainScreen.ZoomToCity(Loc: integer; NextUnitOnClose: boolean = false;5126 ShowEvent: integer = 0): boolean;5127 begin 5128 result := MyMap[Loc] and (fOwned or fSpiedOut) <> 0;5129 if result then5800 function TMainScreen.ZoomToCity(Loc: Integer; NextUnitOnClose: Boolean = False; 5801 ShowEvent: Integer = 0): Boolean; 5802 begin 5803 Result := MyMap[Loc] and (fOwned or fSpiedOut) <> 0; 5804 if Result then 5130 5805 with CityDlg do 5131 5806 begin … … 5153 5828 end; 5154 5829 5155 function TMainScreen.LocationOfScreenPixel( x, y: integer): Integer;5830 function TMainScreen.LocationOfScreenPixel(X, Y: Integer): Integer; 5156 5831 var 5157 qx, qy: integer;5832 qx, qy: Integer; 5158 5833 begin 5159 5834 with MainMap do begin 5160 qx := ( x * (yyt * 2) + y* (xxt * 2) + xxt * yyt * 2) div (xxt * yyt * 4) - 1;5161 qy := ( y * (xxt * 2) - x* (yyt * 2) - xxt * yyt * 2 + 4000 * xxt * yyt)5835 qx := (X * (yyt * 2) + Y * (xxt * 2) + xxt * yyt * 2) div (xxt * yyt * 4) - 1; 5836 qy := (Y * (xxt * 2) - X * (yyt * 2) - xxt * yyt * 2 + 4000 * xxt * yyt) 5162 5837 div (xxt * yyt * 4) - 999; 5163 5838 Result := (xw + (qx - qy + 2048) div 2 - 1024 + G.lx) mod G.lx + G.lx * … … 5173 5848 5174 5849 procedure TMainScreen.MapBoxMouseDown(Sender: TObject; Button: TMouseButton; 5175 Shift: TShiftState; x, y: integer);5850 Shift: TShiftState; X, Y: Integer); 5176 5851 var 5177 i, uix, emix, p1, dx, dy, MouseLoc: integer;5852 I, uix, emix, p1, dx, dy, MouseLoc: Integer; 5178 5853 EditTileData: TEditTileData; 5179 m, m2: TDpiMenuItem;5854 M, m2: TDpiMenuItem; 5180 5855 MoveAdviceData: TMoveAdviceData; 5181 DoCenter: boolean;5856 DoCenter: Boolean; 5182 5857 begin 5183 5858 if GameMode = cMovie then 5184 exit;5185 5186 if CityDlg.Visible then5859 Exit; 5860 5861 if Assigned(FCityDlg) and CityDlg.Visible then 5187 5862 CityDlg.Close; 5188 if UnitStatDlg.Visible then5863 if Assigned(FUnitStatDlg) and UnitStatDlg.Visible then 5189 5864 UnitStatDlg.Close; 5190 MouseLoc := LocationOfScreenPixel( x, y);5865 MouseLoc := LocationOfScreenPixel(X, Y); 5191 5866 if (MouseLoc < 0) or (MouseLoc >= G.lx * G.ly) then 5192 exit;5867 Exit; 5193 5868 if (Button = mbLeft) and not(ssShift in Shift) then 5194 5869 begin 5195 DoCenter := true;5870 DoCenter := True; 5196 5871 if ClientMode = cEditMap then 5197 5872 begin 5198 DoCenter := false;5873 DoCenter := False; 5199 5874 EditTileData.Loc := MouseLoc; 5200 5875 if ssCtrl in Shift then // toggle special resource … … 5234 5909 else 5235 5910 EditTileData.NewTile := MyMap[MouseLoc] xor BrushType; 5236 Server(sEditTile, me, 0, EditTileData);5237 Edited := true;5911 Server(sEditTile, Me, 0, EditTileData); 5912 Edited := True; 5238 5913 BrushLoc := MouseLoc; 5239 5914 PaintLoc(MouseLoc, 2); 5240 5915 MiniMapPaint; 5241 DpiBit Canvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly,5916 DpiBitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 5242 5917 MiniMap.Bitmap.Canvas, 0, 0); 5243 5918 with MainMap do begin … … 5261 5936 begin 5262 5937 ZoomToCity(MouseLoc); 5263 DoCenter := false;5938 DoCenter := False; 5264 5939 end 5265 5940 else 5266 5941 begin 5267 5942 UnitStatDlg.ShowNewContent_EnemyCity(wmPersistent, MouseLoc); 5268 DoCenter := false;5943 DoCenter := False; 5269 5944 end; 5270 5945 end … … 5272 5947 if MyMap[MouseLoc] and fOwned <> 0 then 5273 5948 begin 5274 DoCenter := false;5275 if not supervising and (ClientMode < scContact) then5949 DoCenter := False; 5950 if not Supervising and (ClientMode < scContact) then 5276 5951 begin // not in negotiation mode 5277 5952 if (UnFocus >= 0) and (MyUn[UnFocus].Loc = MouseLoc) then 5278 5953 begin // rotate 5279 5954 uix := (UnFocus + 1) mod MyRO.nUn; 5280 i:= MyRO.nUn - 1;5281 while i> 0 do5955 I := MyRO.nUn - 1; 5956 while I > 0 do 5282 5957 begin 5283 5958 if (MyUn[uix].Loc = MouseLoc) and (MyUn[uix].Job = jNone) and … … 5285 5960 usWaiting) = usWaiting) then 5286 5961 Break; 5287 dec(i);5962 Dec(I); 5288 5963 uix := (uix + 1) mod MyRO.nUn; 5289 5964 end; 5290 if i= 0 then5965 if I = 0 then 5291 5966 uix := UnFocus; 5292 5967 end 5293 5968 else 5294 Server(sGetDefender, me, MouseLoc, uix);5969 Server(sGetDefender, Me, MouseLoc, uix); 5295 5970 if uix <> UnFocus then 5296 5971 SetUnFocus(uix); 5297 TurnComplete := false;5972 TurnComplete := False; 5298 5973 EOT.ButtonIndex := eotGray; 5299 5974 end; … … 5303 5978 else if (MyMap[MouseLoc] and fSpiedOut <> 0) and not(ssCtrl in Shift) then 5304 5979 begin 5305 DoCenter := false;5980 DoCenter := False; 5306 5981 SetTroopLoc(MouseLoc); 5307 5982 PanelPaint; … … 5309 5984 else 5310 5985 begin 5311 DoCenter := false;5986 DoCenter := False; 5312 5987 UnitStatDlg.ShowNewContent_EnemyLoc(wmPersistent, MouseLoc); 5313 5988 end; … … 5321 5996 not(ssShift in Shift) then 5322 5997 begin 5323 if supervising then5998 if Supervising then 5324 5999 begin 5325 6000 EditLoc := MouseLoc; 5326 Server(sGetModels, me, 0, nil^);6001 Server(sGetModels, Me, 0, nil^); 5327 6002 EmptyMenu(mCreateUnit); 5328 6003 for p1 := 0 to nPl - 1 do 5329 6004 if 1 shl p1 and MyRO.Alive <> 0 then 5330 6005 begin 5331 m:= TDpiMenuItem.Create(mCreateUnit);5332 m.Caption := Tribe[p1].TPhrase('SHORTNAME');6006 M := TDpiMenuItem.Create(mCreateUnit); 6007 M.Caption := Tribe[p1].TPhrase('SHORTNAME'); 5333 6008 for emix := MyRO.nEnemyModel - 1 downto 0 do 5334 6009 if (MyRO.EnemyModel[emix].Owner = p1) and 5335 (Server(sCreateUnit - sExecute + p1 shl 4, me,6010 (Server(sCreateUnit - sExecute + p1 shl 4, Me, 5336 6011 MyRO.EnemyModel[emix].mix, MouseLoc) >= rExecuted) then 5337 6012 begin 5338 6013 if not Assigned(Tribe[p1].ModelPicture[MyRO.EnemyModel[emix].mix].HGr) then 5339 6014 InitEnemyModel(emix); 5340 m2 := TDpiMenuItem.Create( m);6015 m2 := TDpiMenuItem.Create(M); 5341 6016 m2.Caption := Tribe[p1].ModelName[MyRO.EnemyModel[emix].mix]; 5342 6017 m2.Tag := p1 shl 16 + MyRO.EnemyModel[emix].mix; 5343 6018 m2.OnClick := CreateUnitClick; 5344 m.Add(m2);6019 M.Add(m2); 5345 6020 end; 5346 m.Visible := m.Count > 0;5347 mCreateUnit.Add( m);6021 M.Visible := M.Count > 0; 6022 mCreateUnit.Add(M); 5348 6023 end; 5349 6024 if FullScreen then 5350 EditPopup.Popup(Left + x, Top + y)6025 EditPopup.Popup(Left + X, Top + Y) 5351 6026 else 5352 EditPopup.Popup(Left + x+ 4,5353 Top + y+ DpiGetSystemMetrics(SM_CYCAPTION) + 4);6027 EditPopup.Popup(Left + X + 4, 6028 Top + Y + DpiGetSystemMetrics(SM_CYCAPTION) + 4); 5354 6029 end 5355 6030 else if (UnFocus >= 0) and (MyUn[UnFocus].Loc <> MouseLoc) then … … 5362 6037 if abs(dx) + abs(dy) < 3 then 5363 6038 begin 5364 DestinationMarkON := false;6039 DestinationMarkON := False; 5365 6040 PaintDestination; 5366 6041 Status := Status and ($FFFF - usStay - usRecover - usGoto - usEnhance) … … 5375 6050 with MyUn[UnFocus], BattleDlg.Forecast do 5376 6051 begin 5377 pAtt := me;6052 pAtt := Me; 5378 6053 mixAtt := mix; 5379 6054 HealthAtt := Health; … … 5382 6057 end; 5383 6058 BattleDlg.Forecast.Movement := MyUn[UnFocus].Movement; 5384 if (Server(sGetBattleForecastEx, me, MouseLoc, BattleDlg.Forecast)6059 if (Server(sGetBattleForecastEx, Me, MouseLoc, BattleDlg.Forecast) 5385 6060 >= rExecuted) and (BattleDlg.Forecast.EndHealthAtt <= 0) then 5386 6061 begin 5387 6062 BattleDlg.uix := UnFocus; 5388 6063 BattleDlg.ToLoc := MouseLoc; 5389 BattleDlg.IsSuicideQuery := true;6064 BattleDlg.IsSuicideQuery := True; 5390 6065 BattleDlg.ShowModal; 5391 6066 if BattleDlg.ModalResult <> mrOK then 5392 exit;6067 Exit; 5393 6068 end; 5394 6069 end; 5395 DestinationMarkON := false;6070 DestinationMarkON := False; 5396 6071 PaintDestination; 5397 6072 Status := Status and not(usStay or usRecover or usEnhance) or 5398 6073 usWaiting; 5399 MoveToLoc(MouseLoc, false); { goto }6074 MoveToLoc(MouseLoc, False); { goto } 5400 6075 end; 5401 6076 end; … … 5404 6079 (MyModel[MyUn[UnFocus].mix].Kind in [mkSettler, mkSlaves]) then 5405 6080 begin 5406 DestinationMarkON := false;6081 DestinationMarkON := False; 5407 6082 PaintDestination; 5408 6083 MyUn[UnFocus].Status := MyUn[UnFocus].Status and … … 5410 6085 uix := UnFocus; 5411 6086 if MouseLoc <> MyUn[uix].Loc then 5412 MoveToLoc(MouseLoc, true); { goto }6087 MoveToLoc(MouseLoc, True); { goto } 5413 6088 if (UnFocus = uix) and (MyUn[uix].Loc = MouseLoc) then 5414 MenuClick(mEnhance);6089 mEnhance.Click; 5415 6090 end 5416 6091 else if (Button = mbLeft) and (ssShift in Shift) and … … 5423 6098 with MyUn[UnFocus], BattleDlg.Forecast do 5424 6099 begin 5425 pAtt := me;6100 pAtt := Me; 5426 6101 mixAtt := mix; 5427 6102 HealthAtt := Health; … … 5430 6105 end; 5431 6106 BattleDlg.Forecast.Movement := MyUn[UnFocus].Movement; 5432 if Server(sGetBattleForecastEx, me, MouseLoc, BattleDlg.Forecast) >= rExecuted6107 if Server(sGetBattleForecastEx, Me, MouseLoc, BattleDlg.Forecast) >= rExecuted 5433 6108 then 5434 6109 begin 5435 6110 BattleDlg.uix := UnFocus; 5436 6111 BattleDlg.ToLoc := MouseLoc; 5437 BattleDlg.Left := x- BattleDlg.width div 2;6112 BattleDlg.Left := X - BattleDlg.width div 2; 5438 6113 if BattleDlg.Left < 0 then 5439 6114 BattleDlg.Left := 0 5440 6115 else if BattleDlg.Left + BattleDlg.width > DpiScreen.width then 5441 6116 BattleDlg.Left := DpiScreen.width - BattleDlg.width; 5442 BattleDlg.Top := y- BattleDlg.height div 2;6117 BattleDlg.Top := Y - BattleDlg.height div 2; 5443 6118 if BattleDlg.Top < 0 then 5444 6119 BattleDlg.Top := 0 5445 6120 else if BattleDlg.Top + BattleDlg.height > DpiScreen.height then 5446 6121 BattleDlg.Top := DpiScreen.height - BattleDlg.height; 5447 BattleDlg.IsSuicideQuery := false;6122 BattleDlg.IsSuicideQuery := False; 5448 6123 BattleDlg.Show; 5449 6124 end; … … 5451 6126 end; 5452 6127 5453 function TMainScreen.MoveUnit(dx, dy: integer; Options: integer): integer;6128 function TMainScreen.MoveUnit(dx, dy: Integer; Options: Integer): Integer; 5454 6129 // move focused unit to adjacent tile 5455 6130 var 5456 i, cix, uix, euix, FromLoc, ToLoc, DirCode, UnFocus0, Defender, Mission, p1,5457 NewTiles, cixChanged: integer;6131 I, cix, uix, euix, FromLoc, ToLoc, DirCode, UnFocus0, Defender, Mission, p1, 6132 NewTiles, cixChanged: Integer; 5458 6133 OldToTile: Cardinal; 5459 6134 CityCaptured, IsAttack, OldUnrest, NewUnrest, NeedEcoUpdate, NeedRepaintPanel, 5460 ToTransport, ToShip: boolean;6135 ToTransport, ToShip: Boolean; 5461 6136 PlaneReturnData: TPlaneReturnData; 5462 6137 QueryItem: string; 5463 6138 begin 5464 result := eInvalid;6139 Result := eInvalid; 5465 6140 UnFocus0 := UnFocus; 5466 6141 FromLoc := MyUn[UnFocus].Loc; … … 5468 6143 if (ToLoc < 0) or (ToLoc >= G.lx * G.ly) then 5469 6144 begin 5470 result := eInvalid;5471 exit;6145 Result := eInvalid; 6146 Exit; 5472 6147 end; 5473 6148 if MyMap[ToLoc] and fStealthUnit <> 0 then 5474 6149 begin 5475 6150 SoundMessage(Phrases.Lookup('ATTACKSTEALTH'), ''); 5476 exit;6151 Exit; 5477 6152 end; 5478 6153 if MyMap[ToLoc] and fHiddenUnit <> 0 then 5479 6154 begin 5480 6155 SoundMessage(Phrases.Lookup('ATTACKSUB'), ''); 5481 exit;6156 Exit; 5482 6157 end; 5483 6158 … … 5489 6164 begin 5490 6165 SoundMessage(Phrases.Lookup('NOATTACKER'), ''); 5491 exit;6166 Exit; 5492 6167 end; 5493 6168 euix := MyRO.nEnemyUn - 1; 5494 6169 while (euix >= 0) and (MyRO.EnemyUn[euix].Loc <> ToLoc) do 5495 dec(euix);6170 Dec(euix); 5496 6171 end; 5497 6172 5498 6173 DirCode := dx and 7 shl 4 + dy and 7 shl 7; 5499 result := Server(sMoveUnit - sExecute + DirCode, me, UnFocus, nil^);5500 if ( result < rExecuted) and (MyUn[UnFocus].Job > jNone) then5501 Server(sStartJob + jNone shl 4, me, UnFocus, nil^);5502 if ( result < rExecuted) and (result <> eNoTime_Move) then5503 begin 5504 case result of6174 Result := Server(sMoveUnit - sExecute + DirCode, Me, UnFocus, nil^); 6175 if (Result < rExecuted) and (MyUn[UnFocus].Job > jNone) then 6176 Server(sStartJob + jNone shl 4, Me, UnFocus, nil^); 6177 if (Result < rExecuted) and (Result <> eNoTime_Move) then 6178 begin 6179 case Result of 5505 6180 eNoTime_Load: 5506 6181 if MyModel[MyUn[UnFocus].mix].Domain = dAir then … … 5538 6213 (MyMap[ToLoc] and (fUnit or fOwned) = fUnit or fOwned) then 5539 6214 begin // false load attempt 5540 ToShip := false;5541 ToTransport := false;6215 ToShip := False; 6216 ToTransport := False; 5542 6217 for uix := 0 to MyRO.nUn - 1 do 5543 6218 if (MyUn[uix].Loc = ToLoc) and 5544 6219 (MyModel[MyUn[uix].mix].Domain = dSea) then 5545 6220 begin 5546 ToShip := true;6221 ToShip := True; 5547 6222 if MyModel[MyUn[uix].mix].Cap[mcSeaTrans] > 0 then 5548 ToTransport := true;6223 ToTransport := True; 5549 6224 end; 5550 6225 if ToTransport then … … 5561 6236 Play('NOMOVE_DEFAULT'); 5562 6237 end; 5563 exit;5564 end; 5565 5566 if (( result = eWon) or (result = eLost) or (result = eBloody)) and6238 Exit; 6239 end; 6240 6241 if ((Result = eWon) or (Result = eLost) or (Result = eBloody)) and 5567 6242 (MyUn[UnFocus].Movement < 100) and 5568 6243 (MyModel[MyUn[UnFocus].mix].Cap[mcWill] = 0) then … … 5571 6246 [MyUn[UnFocus].Movement]), 'NOMOVE_TIME') <> mrOK then 5572 6247 begin 5573 result := eInvalid;5574 exit;6248 Result := eInvalid; 6249 Exit; 5575 6250 end; 5576 6251 Update; // remove message box from screen 5577 6252 end; 5578 6253 5579 OldUnrest := false;5580 NewUnrest := false;5581 if ( result >= rExecuted) and (result and rUnitRemoved = 0) and6254 OldUnrest := False; 6255 NewUnrest := False; 6256 if (Result >= rExecuted) and (Result and rUnitRemoved = 0) and 5582 6257 (MyMap[ToLoc] and (fUnit or fOwned) <> fUnit) then 5583 6258 begin … … 5589 6264 begin 5590 6265 QueryItem := 'UNREST_NOTOWN'; 5591 p1 := me;6266 p1 := Me; 5592 6267 end 5593 6268 else … … 5606 6281 if ModalResult <> mrOK then 5607 6282 begin 5608 result := eInvalid;5609 exit;6283 Result := eInvalid; 6284 Exit; 5610 6285 end; 5611 6286 end; 5612 6287 Update; // remove message box from screen 5613 end 5614 end; 5615 5616 if ( result >= rExecuted) and (MyModel[MyUn[UnFocus].mix].Domain = dAir) and6288 end; 6289 end; 6290 6291 if (Result >= rExecuted) and (MyModel[MyUn[UnFocus].mix].Domain = dAir) and 5617 6292 (MyUn[UnFocus].Status and usToldNoReturn = 0) then 5618 6293 begin // can plane return? … … 5634 6309 PlaneReturnData.Movement := MyUn[UnFocus].Movement - 150; 5635 6310 end; 5636 if Server(sGetPlaneReturn, me, UnFocus, PlaneReturnData) = eNoWay then6311 if Server(sGetPlaneReturn, Me, UnFocus, PlaneReturnData) = eNoWay then 5637 6312 begin 5638 6313 if MyModel[MyUn[UnFocus].mix].Kind = mkSpecial_Glider then … … 5643 6318 <> mrOK then 5644 6319 begin 5645 result := eInvalid;5646 exit;6320 Result := eInvalid; 6321 Exit; 5647 6322 end; 5648 6323 Update; // remove message box from screen 5649 6324 MyUn[UnFocus].Status := MyUn[UnFocus].Status or usToldNoReturn; 5650 end 5651 end; 5652 5653 if result = eMissionDone then6325 end; 6326 end; 6327 6328 if Result = eMissionDone then 5654 6329 begin 5655 6330 ModalSelectDlg.ShowNewContent(wmModal, kMission); 5656 6331 Update; // dialog still on screen 5657 Mission := ModalSelectDlg. result;6332 Mission := ModalSelectDlg.Result; 5658 6333 if Mission < 0 then 5659 exit;5660 Server(sSetSpyMission + Mission shl 4, me, 0, nil^);5661 end; 5662 5663 CityCaptured := false;5664 if result = eNoTime_Move then6334 Exit; 6335 Server(sSetSpyMission + Mission shl 4, Me, 0, nil^); 6336 end; 6337 6338 CityCaptured := False; 6339 if Result = eNoTime_Move then 5665 6340 Play('NOMOVE_TIME') 5666 6341 else 5667 6342 begin 5668 NeedEcoUpdate := false;5669 DestinationMarkON := false;6343 NeedEcoUpdate := False; 6344 DestinationMarkON := False; 5670 6345 PaintDestination; 5671 if result and rUnitRemoved <> 0 then6346 if Result and rUnitRemoved <> 0 then 5672 6347 CityOptimizer_BeforeRemoveUnit(UnFocus); 5673 IsAttack := ( result = eBombarded) or (result <> eMissionDone) and6348 IsAttack := (Result = eBombarded) or (Result <> eMissionDone) and 5674 6349 (MyMap[ToLoc] and (fUnit or fOwned) = fUnit); 5675 6350 if not IsAttack then … … 5677 6352 cix := MyRO.nCity - 1; { look for own city at dest location } 5678 6353 while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do 5679 dec(cix);5680 if ( result <> eMissionDone) and (MyMap[ToLoc] and fCity <> 0) and (cix < 0)6354 Dec(cix); 6355 if (Result <> eMissionDone) and (MyMap[ToLoc] and fCity <> 0) and (cix < 0) 5681 6356 then 5682 CityCaptured := true;5683 result := Server(sMoveUnit + DirCode, me, UnFocus, nil^);5684 case result of6357 CityCaptured := True; 6358 Result := Server(sMoveUnit + DirCode, Me, UnFocus, nil^); 6359 case Result of 5685 6360 eHiddenUnit: 5686 6361 begin 5687 6362 Play('NOMOVE_SUBMARINE'); 5688 PaintLoc(ToLoc) 6363 PaintLoc(ToLoc); 5689 6364 end; 5690 6365 eStealthUnit: 5691 6366 begin 5692 6367 Play('NOMOVE_STEALTH'); 5693 PaintLoc(ToLoc) 6368 PaintLoc(ToLoc); 5694 6369 end; 5695 6370 eZOC_EnemySpotted: 5696 6371 begin 5697 6372 Play('NOMOVE_ZOC'); 5698 PaintLoc(ToLoc, 1) 6373 PaintLoc(ToLoc, 1); 5699 6374 end; 5700 rExecuted .. maxint:6375 rExecuted..MaxInt: 5701 6376 begin 5702 if result and rUnitRemoved <> 0 then6377 if Result and rUnitRemoved <> 0 then 5703 6378 UnFocus := -1 // unit died 5704 6379 else 5705 6380 begin 5706 assert(UnFocus >= 0);6381 Assert(UnFocus >= 0); 5707 6382 MyUn[UnFocus].Status := MyUn[UnFocus].Status and 5708 6383 not(usStay or usRecover); … … 5714 6389 begin // borders have moved, unrest might have changed in any city 5715 6390 CityOptimizer_BeginOfTurn; 5716 NeedEcoUpdate := true;6391 NeedEcoUpdate := True; 5717 6392 end 5718 6393 else … … 5724 6399 if MyUn[uix].Master = UnFocus then 5725 6400 CityOptimizer_CityChange(MyUn[uix].Home); 5726 NeedEcoUpdate := true;6401 NeedEcoUpdate := True; 5727 6402 end; 5728 6403 if (MyRO.Government = gDespotism) and … … 5734 6409 while (cixChanged >= 0) and 5735 6410 (MyCity[cixChanged].Loc <> FromLoc) do 5736 dec(cixChanged);5737 assert(cixChanged >= 0);6411 Dec(cixChanged); 6412 Assert(cixChanged >= 0); 5738 6413 if cixChanged >= 0 then 5739 6414 begin 5740 6415 CityOptimizer_CityChange(cixChanged); 5741 NeedEcoUpdate := true;6416 NeedEcoUpdate := True; 5742 6417 end; 5743 6418 end; … … 5747 6422 while (cixChanged >= 0) and 5748 6423 (MyCity[cixChanged].Loc <> ToLoc) do 5749 dec(cixChanged);5750 assert(cixChanged >= 0);6424 Dec(cixChanged); 6425 Assert(cixChanged >= 0); 5751 6426 if cixChanged >= 0 then 5752 6427 begin 5753 6428 CityOptimizer_CityChange(cixChanged); 5754 NeedEcoUpdate := true;6429 NeedEcoUpdate := True; 5755 6430 end; 5756 6431 end; … … 5760 6435 end; 5761 6436 else 5762 assert(false);6437 Assert(False); 5763 6438 end; 5764 6439 SetTroopLoc(ToLoc); … … 5766 6441 else 5767 6442 begin { enemy unit -- attack } 5768 if result = eBombarded then6443 if Result = eBombarded then 5769 6444 Defender := MyRO.Territory[ToLoc] 5770 6445 else … … 5773 6448 if SimpleQuery(mkYesNo,Phrases.Lookup('FRCANCELQUERY_CEASEFIRE'), 5774 6449 'MSG_DEFAULT')<>mrOK then 5775 exit; }5776 if (Options and muNoSuicideCheck = 0) and ( result and rUnitRemoved <> 0)5777 and ( result <> eMissionDone) then6450 Exit; } 6451 if (Options and muNoSuicideCheck = 0) and (Result and rUnitRemoved <> 0) 6452 and (Result <> eMissionDone) then 5778 6453 begin // suicide query 5779 6454 with MyUn[UnFocus], BattleDlg.Forecast do 5780 6455 begin 5781 pAtt := me;6456 pAtt := Me; 5782 6457 mixAtt := mix; 5783 6458 HealthAtt := Health; … … 5786 6461 end; 5787 6462 BattleDlg.Forecast.Movement := MyUn[UnFocus].Movement; 5788 Server(sGetBattleForecastEx, me, ToLoc, BattleDlg.Forecast);6463 Server(sGetBattleForecastEx, Me, ToLoc, BattleDlg.Forecast); 5789 6464 BattleDlg.uix := UnFocus; 5790 6465 BattleDlg.ToLoc := ToLoc; 5791 BattleDlg.IsSuicideQuery := true;6466 BattleDlg.IsSuicideQuery := True; 5792 6467 BattleDlg.ShowModal; 5793 6468 if BattleDlg.ModalResult <> mrOK then 5794 exit;6469 Exit; 5795 6470 end; 5796 6471 5797 6472 cixChanged := -1; 5798 if ( result and rUnitRemoved <> 0) and (MyRO.Government = gDespotism) and6473 if (Result and rUnitRemoved <> 0) and (MyRO.Government = gDespotism) and 5799 6474 (MyModel[MyUn[UnFocus].mix].Kind = mkSpecial_TownGuard) and 5800 6475 (MyMap[FromLoc] and fCity <> 0) then … … 5802 6477 cixChanged := MyRO.nCity - 1; 5803 6478 while (cixChanged >= 0) and (MyCity[cixChanged].Loc <> FromLoc) do 5804 dec(cixChanged);5805 assert(cixChanged >= 0);5806 end; 5807 5808 for i:= 0 to MyRO.nEnemyModel - 1 do5809 LostArmy[ i] := MyRO.EnemyModel[i].Lost;6479 Dec(cixChanged); 6480 Assert(cixChanged >= 0); 6481 end; 6482 6483 for I := 0 to MyRO.nEnemyModel - 1 do 6484 LostArmy[I] := MyRO.EnemyModel[I].Lost; 5810 6485 OldToTile := MyMap[ToLoc]; 5811 result := Server(sMoveUnit + DirCode, me, UnFocus, nil^);6486 Result := Server(sMoveUnit + DirCode, Me, UnFocus, nil^); 5812 6487 nLostArmy := 0; 5813 for i:= 0 to MyRO.nEnemyModel - 1 do6488 for I := 0 to MyRO.nEnemyModel - 1 do 5814 6489 begin 5815 LostArmy[ i] := MyRO.EnemyModel[i].Lost - LostArmy[i];5816 inc(nLostArmy, LostArmy[i])5817 end; 5818 if result and rUnitRemoved <> 0 then6490 LostArmy[I] := MyRO.EnemyModel[I].Lost - LostArmy[I]; 6491 Inc(nLostArmy, LostArmy[I]); 6492 end; 6493 if Result and rUnitRemoved <> 0 then 5819 6494 begin 5820 6495 UnFocus := -1; … … 5825 6500 begin // city was destroyed, borders have moved, unrest might have changed in any city 5826 6501 CityOptimizer_BeginOfTurn; 5827 NeedEcoUpdate := true; 5828 end 5829 else 5830 begin 6502 NeedEcoUpdate := True; 6503 end else begin 5831 6504 if cixChanged >= 0 then 5832 6505 begin 5833 6506 CityOptimizer_CityChange(cixChanged); 5834 NeedEcoUpdate := true;6507 NeedEcoUpdate := True; 5835 6508 end; 5836 if ( result = eWon) or (result = eBloody) or (result = eExpelled) then6509 if (Result = eWon) or (Result = eBloody) or (Result = eExpelled) then 5837 6510 begin 5838 6511 CityOptimizer_TileBecomesAvailable(ToLoc); 5839 NeedEcoUpdate := true;6512 NeedEcoUpdate := True; 5840 6513 end; 5841 6514 end; … … 5849 6522 MyRO.EnemyModel[MyRO.EnemyUn[euix].emix].Domain)); 5850 6523 ShowModal; 5851 end 5852 end 5853 end; 5854 if result and rUnitRemoved <> 0 then6524 end; 6525 end; 6526 end; 6527 if Result and rUnitRemoved <> 0 then 5855 6528 begin 5856 6529 CityOptimizer_AfterRemoveUnit; 5857 6530 ListDlg.RemoveUnit; 5858 NeedEcoUpdate := true;6531 NeedEcoUpdate := True; 5859 6532 end; 5860 6533 if NeedEcoUpdate then 5861 6534 begin 5862 UpdateViews( true);5863 Update 5864 end 5865 end; 5866 5867 if result = eMissionDone then6535 UpdateViews(True); 6536 Update; 6537 end; 6538 end; 6539 6540 if Result = eMissionDone then 5868 6541 begin 5869 6542 p1 := MyRO.Territory[ToLoc]; … … 5871 6544 smStealMap: 5872 6545 begin 5873 MapValid := false;6546 MapValid := False; 5874 6547 PaintAllMaps 5875 6548 end; … … 5884 6557 CheckToldNoReturn(UnFocus); 5885 6558 5886 NeedRepaintPanel := false;5887 if result >= rExecuted then6559 NeedRepaintPanel := False; 6560 if Result >= rExecuted then 5888 6561 begin 5889 6562 if CityCaptured and (MyMap[ToLoc] and fCity = 0) then 5890 6563 begin // city destroyed 5891 for i:= 0 to nWonder - 1 do { tell about destroyed wonders }5892 if (MyRO.Wonder[ i].CityID = WonderDestroyed) and (MyData.ToldWonders[i].CityID <> WonderDestroyed)6564 for I := 0 to nWonder - 1 do { tell about destroyed wonders } 6565 if (MyRO.Wonder[I].CityID = WonderDestroyed) and (MyData.ToldWonders[I].CityID <> WonderDestroyed) 5893 6566 then 5894 6567 with MessgExDlg do 5895 6568 begin 5896 6569 if WondersDlg.Visible then 5897 WondersDlg.SmartUpdateContent( false);6570 WondersDlg.SmartUpdateContent(False); 5898 6571 OpenSound := 'WONDER_DESTROYED'; 5899 6572 MessgText := Format(Phrases.Lookup('WONDERDEST'), 5900 [Phrases.Lookup('IMPROVEMENTS', i)]);6573 [Phrases.Lookup('IMPROVEMENTS', I)]); 5901 6574 Kind := mkOkHelp; 5902 6575 HelpKind := hkImp; 5903 HelpNo := i;6576 HelpNo := I; 5904 6577 IconKind := mikImp; 5905 IconIndex := i;6578 IconIndex := I; 5906 6579 ShowModal; 5907 MyData.ToldWonders[ i] := MyRO.Wonder[i];5908 end 6580 MyData.ToldWonders[I] := MyRO.Wonder[I]; 6581 end; 5909 6582 end; 5910 6583 if CityCaptured and (MyMap[ToLoc] and fCity <> 0) then 5911 6584 begin // city captured 5912 6585 ListDlg.AddCity; 5913 for i:= 0 to nWonder - 1 do { tell about capture of wonders }5914 if MyRO.City[MyRO.nCity - 1].Built[ i] > 0 then6586 for I := 0 to nWonder - 1 do { tell about capture of wonders } 6587 if MyRO.City[MyRO.nCity - 1].Built[I] > 0 then 5915 6588 with MessgExDlg do 5916 6589 begin 5917 6590 if WondersDlg.Visible then 5918 WondersDlg.SmartUpdateContent( false);6591 WondersDlg.SmartUpdateContent(False); 5919 6592 OpenSound := 'WONDER_CAPTURED'; 5920 MessgText := Format(Tribe[ me].TPhrase('WONDERCAPTOWN'),5921 [Phrases.Lookup('IMPROVEMENTS', i)]);6593 MessgText := Format(Tribe[Me].TPhrase('WONDERCAPTOWN'), 6594 [Phrases.Lookup('IMPROVEMENTS', I)]); 5922 6595 Kind := mkOkHelp; 5923 6596 HelpKind := hkImp; 5924 HelpNo := i;6597 HelpNo := I; 5925 6598 IconKind := mikImp; 5926 IconIndex := i;6599 IconIndex := I; 5927 6600 ShowModal; 5928 MyData.ToldWonders[ i] := MyRO.Wonder[i];6601 MyData.ToldWonders[I] := MyRO.Wonder[I]; 5929 6602 end; 5930 6603 … … 5932 6605 begin { Temple of Zeus -- choose advance to steal } 5933 6606 ModalSelectDlg.ShowNewContent(wmModal, kStealTech); 5934 Server(sStealTech, me, ModalSelectDlg.result, nil^);6607 Server(sStealTech, Me, ModalSelectDlg.Result, nil^); 5935 6608 end; 5936 6609 TellNewModels; … … 5938 6611 cix := MyRO.nCity - 1; 5939 6612 while (cix >= 0) and (MyCity[cix].Loc <> ToLoc) do 5940 dec(cix);5941 assert(cix >= 0);6613 Dec(cix); 6614 Assert(cix >= 0); 5942 6615 MyCity[cix].Status := MyCity[cix].Status and not csResourceWeightsMask or 5943 6616 (3 shl 4); 5944 6617 // captured city, set to maximum growth 5945 6618 NewTiles := 1 shl 13; { exploit central tile only } 5946 Server(sSetCityTiles, me, cix, NewTiles);6619 Server(sSetCityTiles, Me, cix, NewTiles); 5947 6620 end 5948 6621 else 5949 NeedRepaintPanel := true;6622 NeedRepaintPanel := True; 5950 6623 end; 5951 6624 TellNewContacts; … … 5961 6634 if Options and (muAutoNoWait or muAutoNext) <> 0 then 5962 6635 begin 5963 if (UnFocus >= 0) and (( result = eNoTime_Move) or UnitExhausted(UnFocus) or6636 if (UnFocus >= 0) and ((Result = eNoTime_Move) or UnitExhausted(UnFocus) or 5964 6637 (MyUn[UnFocus].Master >= 0) or (MyModel[MyUn[UnFocus].mix].Domain = dAir) 5965 6638 and ((MyMap[MyUn[UnFocus].Loc] and fCity <> 0) … … 5975 6648 end 5976 6649 else 5977 NextUnit(UnStartLoc, true);6650 NextUnit(UnStartLoc, True); 5978 6651 end 5979 6652 else if (UnFocus < 0) and (Options and muAutoNext <> 0) then 5980 NextUnit(UnStartLoc, result <> eMissionDone);6653 NextUnit(UnStartLoc, Result <> eMissionDone); 5981 6654 end; 5982 6655 … … 5986 6659 else 5987 6660 begin 5988 assert(result <> eMissionDone);6661 Assert(Result <> eMissionDone); 5989 6662 CheckTerrainBtnVisible; 5990 FocusOnLoc(ToLoc, flRepaintPanel or flImmUpdate) 5991 end; 5992 5993 if ( result >= rExecuted) and CityCaptured and (MyMap[ToLoc] and fCity <> 0)6663 FocusOnLoc(ToLoc, flRepaintPanel or flImmUpdate); 6664 end; 6665 6666 if (Result >= rExecuted) and CityCaptured and (MyMap[ToLoc] and fCity <> 0) 5994 6667 then 5995 6668 ZoomToCity(ToLoc, UnFocus < 0, chCaptured); // show captured city 5996 end; // moveunit6669 end; 5997 6670 5998 6671 procedure TMainScreen.MoveOnScreen(ShowMove: TShowMove; 5999 Step0, Step1, nStep: integer; Restore: boolean = true);6672 Step0, Step1, nStep: Integer; Restore: Boolean = True); 6000 6673 var 6001 6674 ToLoc, xFromLoc, yFromLoc, xToLoc, yToLoc, xFrom, yFrom, xTo, yTo, xMin, yMin, 6002 xRange, yRange, xw1, Step, xMoving, yMoving, SliceCount: integer;6675 xRange, yRange, xw1, Step, xMoving, yMoving, SliceCount: Integer; 6003 6676 UnitInfo: TUnitInfo; 6004 6677 Ticks0, Ticks: TDateTime; 6005 6678 begin 6006 Timer1.Enabled := false;6679 Timer1.Enabled := False; 6007 6680 Ticks0 := NowPrecise; 6008 6681 with ShowMove do … … 6013 6686 UnitInfo.Job := jNone; 6014 6687 UnitInfo.Flags := Flags; 6015 if Owner <> me then6688 if Owner <> Me then 6016 6689 UnitInfo.emix := emix; 6017 6690 … … 6032 6705 * xxt - MapWidth) < abs(((xFromLoc - xw1) * 2 + yFromLoc and 1 + 1) * xxt 6033 6706 * 2 + dx * xxt - MapWidth) do 6034 dec(xw1, G.lx);6707 Dec(xw1, G.lx); 6035 6708 6036 6709 xTo := (xToLoc - xw1) * (xxt * 2) + yToLoc and 1 * xxt + (xxt - xxu); … … 6040 6713 if xFrom < xTo then begin 6041 6714 xMin := xFrom; 6042 xRange := xTo - xFrom 6715 xRange := xTo - xFrom; 6043 6716 end else begin 6044 6717 xMin := xTo; 6045 xRange := xFrom - xTo 6718 xRange := xFrom - xTo; 6046 6719 end; 6047 6720 if yFrom < yTo then begin 6048 6721 yMin := yFrom; 6049 yRange := yTo - yFrom 6722 yRange := yTo - yFrom; 6050 6723 end else begin 6051 6724 yMin := yTo; 6052 yRange := yFrom - yTo 6053 end; 6054 inc(xRange, xxt * 2);6055 inc(yRange, yyt * 3);6725 yRange := yFrom - yTo; 6726 end; 6727 Inc(xRange, xxt * 2); 6728 Inc(yRange, yyt * 3); 6056 6729 end; 6057 6730 … … 6061 6734 for Step := 0 to abs(Step1 - Step0) do 6062 6735 begin 6063 DpiBit Canvas(Buffer.Canvas, 0, 0, xRange, yRange,6064 offscreen.Canvas, xMin, yMin);6736 DpiBitBltCanvas(Buffer.Canvas, 0, 0, xRange, yRange, 6737 Offscreen.Canvas, xMin, yMin); 6065 6738 if Step1 <> Step0 then 6066 6739 begin … … 6079 6752 NoMap.PaintUnit(xMoving - xMin, yMoving - yMin, UnitInfo, 0); 6080 6753 PaintBufferToScreen(xMin, yMin, xRange, yRange); 6081 {$IFDEF LINUX}6082 // TODO: Force animation under linux6754 {$IFDEF UNIX} 6755 // TODO: Force animation under UNIX 6083 6756 DpiApplication.ProcessMessages; 6084 6757 {$ENDIF} … … 6091 6764 < MoveTime) then 6092 6765 begin 6093 if not idle or (GameMode = cMovie) then6766 if not Idle or (GameMode = cMovie) then 6094 6767 DpiApplication.ProcessMessages; 6095 6768 Sleep(1); 6096 inc(SliceCount)6769 Inc(SliceCount) 6097 6770 end; 6098 6771 Ticks := NowPrecise; 6099 6772 until (((Ticks - Ticks0) * 12) / OneMillisecond) >= MoveTime; 6100 Ticks0 := Ticks 6773 Ticks0 := Ticks; 6101 6774 end; 6102 6775 end; 6103 6776 if Restore then 6104 6777 begin 6105 DpiBit Canvas(Buffer.Canvas, 0, 0, xRange, yRange, offscreen.Canvas, xMin, yMin);6778 DpiBitBltCanvas(Buffer.Canvas, 0, 0, xRange, yRange, Offscreen.Canvas, xMin, yMin); 6106 6779 PaintBufferToScreen(xMin, yMin, xRange, yRange); 6107 6780 end; 6108 6781 BlinkTime := -1; 6109 Timer1.Enabled := true;6110 end; 6111 6112 procedure TMainScreen.MoveToLoc(Loc: integer; CheckSuicide: boolean);6782 Timer1.Enabled := True; 6783 end; 6784 6785 procedure TMainScreen.MoveToLoc(Loc: Integer; CheckSuicide: Boolean); 6113 6786 // path finder: move focused unit to loc, start multi-turn goto if too far 6114 6787 var 6115 uix, i, MoveOptions, NextLoc, MoveResult: integer;6788 uix, I, MoveOptions, NextLoc, MoveResult: Integer; 6116 6789 MoveAdviceData: TMoveAdviceData; 6117 6790 StopReason: (None, Arrived, Dead, NoTime, EnemySpotted, MoveError); 6118 6791 begin 6119 6792 if MyUn[UnFocus].Job > jNone then 6120 Server(sStartJob + jNone shl 4, me, UnFocus, nil^);6793 Server(sStartJob + jNone shl 4, Me, UnFocus, nil^); 6121 6794 if GetMoveAdvice(UnFocus, Loc, MoveAdviceData) >= rExecuted then 6122 6795 begin … … 6124 6797 StopReason := None; 6125 6798 repeat 6126 for i:= 0 to MoveAdviceData.nStep - 1 do6799 for I := 0 to MoveAdviceData.nStep - 1 do 6127 6800 begin 6128 if i= MoveAdviceData.nStep - 1 then6801 if I = MoveAdviceData.nStep - 1 then 6129 6802 MoveOptions := muAutoNext 6130 6803 else 6131 6804 MoveOptions := 0; 6132 NextLoc := dLoc(MyUn[uix].Loc, MoveAdviceData.dx[ i],6133 MoveAdviceData.dy[ i]);6805 NextLoc := dLoc(MyUn[uix].Loc, MoveAdviceData.dx[I], 6806 MoveAdviceData.dy[I]); 6134 6807 if (NextLoc = Loc) or (Loc = maNextCity) and 6135 6808 (MyMap[NextLoc] and fCity <> 0) then … … 6137 6810 if not CheckSuicide and (NextLoc = Loc) then 6138 6811 MoveOptions := MoveOptions or muNoSuicideCheck; 6139 MoveResult := MoveUnit(MoveAdviceData.dx[ i], MoveAdviceData.dy[i],6812 MoveResult := MoveUnit(MoveAdviceData.dx[I], MoveAdviceData.dy[I], 6140 6813 MoveOptions); 6141 6814 if MoveResult < rExecuted then … … 6149 6822 end; 6150 6823 if (StopReason = None) and ((MoveAdviceData.nStep < 25) or 6151 (MyRO.Wonder[woShinkansen].EffectiveOwner <> me)) then6824 (MyRO.Wonder[woShinkansen].EffectiveOwner <> Me)) then 6152 6825 StopReason := NoTime; 6153 6826 if StopReason <> None then … … 6155 6828 if GetMoveAdvice(UnFocus, Loc, MoveAdviceData) < rExecuted then 6156 6829 begin 6157 assert(false);6830 Assert(False); 6158 6831 Break; 6159 6832 end; 6160 until false;6833 until False; 6161 6834 6162 6835 case StopReason of 6163 6836 None: 6164 assert(false);6837 Assert(False); 6165 6838 Arrived: 6166 6839 MyUn[uix].Status := MyUn[uix].Status and ($FFFF - usGoto); 6167 6840 Dead: 6168 6841 if UnFocus < 0 then 6169 NextUnit(UnStartLoc, false);6842 NextUnit(UnStartLoc, False); 6170 6843 else 6171 6844 begin // multi-turn goto … … 6180 6853 begin 6181 6854 MyUn[uix].Status := MyUn[uix].Status and not usWaiting; 6182 NextUnit(UnStartLoc, true);6855 NextUnit(UnStartLoc, True); 6183 6856 end; 6184 6857 end; … … 6188 6861 6189 6862 procedure TMainScreen.PanelBoxMouseDown(Sender: TObject; Button: TMouseButton; 6190 Shift: TShiftState; x, y: integer);6863 Shift: TShiftState; X, Y: Integer); 6191 6864 var 6192 i, xMouse, MouseLoc, p1: integer;6865 I, xMouse, MouseLoc, p1: Integer; 6193 6866 begin 6194 6867 if GameMode = cMovie then 6195 exit;6868 Exit; 6196 6869 6197 6870 if Button = mbLeft then 6198 6871 begin 6199 if ( x >= xMini + 2) and (y >= yMini + 2) and (x< xMini + 2 + 2 * G.lx) and6200 ( y< yMini + 2 + G.ly) then6872 if (X >= xMini + 2) and (Y >= yMini + 2) and (X < xMini + 2 + 2 * G.lx) and 6873 (Y < yMini + 2 + G.ly) then 6201 6874 if ssShift in Shift then 6202 6875 begin 6203 6876 with MainMap do 6204 xMouse := (xwMini + ( x- (xMini + 2) + MapWidth div (xxt * 2) + G.lx)6877 xMouse := (xwMini + (X - (xMini + 2) + MapWidth div (xxt * 2) + G.lx) 6205 6878 div 2) mod G.lx; 6206 MouseLoc := xMouse + G.lx * ( y- (yMini + 2));6879 MouseLoc := xMouse + G.lx * (Y - (yMini + 2)); 6207 6880 if MyMap[MouseLoc] and fTerrain <> fUNKNOWN then 6208 6881 begin 6209 6882 p1 := MyRO.Territory[MouseLoc]; 6210 if (p1 = me) or (p1 >= 0) and (MyRO.Treaty[p1] >= trNone) then6883 if (p1 = Me) or (p1 >= 0) and (MyRO.Treaty[p1] >= trNone) then 6211 6884 NatStatDlg.ShowNewContent(wmPersistent, p1); 6212 6885 end; … … 6218 6891 if UnitStatDlg.Visible then 6219 6892 UnitStatDlg.Close; 6220 Tracking := true;6221 PanelBoxMouseMove(Sender, Shift + [ssLeft], x, y);6893 Tracking := True; 6894 PanelBoxMouseMove(Sender, Shift + [ssLeft], X, Y); 6222 6895 end 6223 else if (ClientMode <> cEditMap) and ( x>= ClientWidth - xPalace) and6224 ( y >= yPalace) and (x< ClientWidth - xPalace + xSizeBig) and6225 ( y< yPalace + ySizeBig) then6896 else if (ClientMode <> cEditMap) and (X >= ClientWidth - xPalace) and 6897 (Y >= yPalace) and (X < ClientWidth - xPalace + xSizeBig) and 6898 (Y < yPalace + ySizeBig) then 6226 6899 begin 6227 6900 InitPopup(StatPopup); … … 6234 6907 DpiGetSystemMetrics(SM_CYCAPTION) + 3) 6235 6908 end 6236 (* else if ( x>=xAdvisor-3) and (y>=yAdvisor-3)6237 and ( x<xAdvisor+16+3) and (y<yAdvisor+16+3) and HaveStrategyAdvice then6909 (* else if (X>=xAdvisor-3) and (Y>=yAdvisor-3) 6910 and (X<xAdvisor+16+3) and (Y<yAdvisor+16+3) and HaveStrategyAdvice then 6238 6911 AdviceBtnClick *) 6239 else if ( x >= xTroop + 1) and (y>= yTroop + 1) and6240 ( x < xTroop + TrRow * TrPitch) and (y<= yTroop + 55) then6912 else if (X >= xTroop + 1) and (Y >= yTroop + 1) and 6913 (X < xTroop + TrRow * TrPitch) and (Y <= yTroop + 55) then 6241 6914 begin 6242 i := (x- xTroop - 1) div TrPitch;6243 if trix[ i] >= 0 then6915 I := (X - xTroop - 1) div TrPitch; 6916 if trix[I] >= 0 then 6244 6917 if ClientMode = cEditMap then 6245 6918 begin 6246 BrushType := trix[ i];6247 PanelPaint 6919 BrushType := trix[I]; 6920 PanelPaint; 6248 6921 end 6249 6922 else if (TroopLoc >= 0) then … … 6252 6925 if ssShift in Shift then 6253 6926 UnitStatDlg.ShowNewContent_OwnModel(wmPersistent, 6254 MyUn[trix[ i]].mix)6255 else if not supervising and (ClientMode < scContact) and6256 ( x - xTroop - 1 - i * TrPitch >= 60 - 20) and (y>= yTroop + 35)6257 and ((MyUn[trix[ i]].Job > jNone) or (MyUn[trix[i]].Status and6927 MyUn[trix[I]].mix) 6928 else if not Supervising and (ClientMode < scContact) and 6929 (X - xTroop - 1 - I * TrPitch >= 60 - 20) and (Y >= yTroop + 35) 6930 and ((MyUn[trix[I]].Job > jNone) or (MyUn[trix[I]].Status and 6258 6931 (usStay or usRecover or usGoto) <> 0)) then 6259 6932 begin // wake up 6260 MyUn[trix[ i]].Status := MyUn[trix[i]].Status and6933 MyUn[trix[I]].Status := MyUn[trix[I]].Status and 6261 6934 ($FFFF - usStay - usRecover - usGoto - usEnhance) or usWaiting; 6262 if MyUn[trix[ i]].Job > jNone then6263 Server(sStartJob + jNone shl 4, me, trix[i], nil^);6935 if MyUn[trix[I]].Job > jNone then 6936 Server(sStartJob + jNone shl 4, Me, trix[I], nil^); 6264 6937 if (UnFocus < 0) and not CityDlg.Visible then 6265 6938 begin 6266 SetUnFocus(trix[ i]);6267 SetTroopLoc(MyUn[trix[ i]].Loc);6939 SetUnFocus(trix[I]); 6940 SetTroopLoc(MyUn[trix[I]].Loc); 6268 6941 FocusOnLoc(TroopLoc, flRepaintPanel) 6269 6942 end … … 6271 6944 begin 6272 6945 if CityDlg.Visible and (CityDlg.RestoreUnFocus < 0) then 6273 CityDlg.RestoreUnFocus := trix[ i];6946 CityDlg.RestoreUnFocus := trix[I]; 6274 6947 PanelPaint; 6275 6948 end … … 6277 6950 else if (ClientMode < scContact) then 6278 6951 begin 6279 if supervising then6280 UnitStatDlg.ShowNewContent_OwnUnit(wmPersistent, trix[ i])6952 if Supervising then 6953 UnitStatDlg.ShowNewContent_OwnUnit(wmPersistent, trix[I]) 6281 6954 else if CityDlg.Visible then 6282 6955 begin … … 6284 6957 CityDlg.Close; 6285 6958 SumCities(TaxSum, ScienceSum); 6286 SetUnFocus(trix[ i]);6959 SetUnFocus(trix[I]); 6287 6960 end 6288 6961 else 6289 6962 begin 6290 DestinationMarkON := false;6963 DestinationMarkON := False; 6291 6964 PaintDestination; 6292 UnFocus := trix[ i];6965 UnFocus := trix[I]; 6293 6966 UnStartLoc := TroopLoc; 6294 6967 BlinkTime := 0; 6295 BlinkON := false;6968 BlinkON := False; 6296 6969 PaintLoc(TroopLoc); 6297 6970 end; 6298 6971 if UnFocus >= 0 then 6299 6972 begin 6300 UnitInfoBtn.Visible := true;6301 UnitBtn.Visible := true;6302 TurnComplete := false;6973 UnitInfoBtn.Visible := True; 6974 UnitBtn.Visible := True; 6975 TurnComplete := False; 6303 6976 EOT.ButtonIndex := eotGray; 6304 6977 end; … … 6307 6980 end; 6308 6981 end 6309 else if Server(sGetUnits, me, TroopLoc, TrCnt) >= rExecuted then6982 else if Server(sGetUnits, Me, TroopLoc, TrCnt) >= rExecuted then 6310 6983 if ssShift in Shift then 6311 6984 UnitStatDlg.ShowNewContent_EnemyModel(wmPersistent, 6312 MyRO.EnemyUn[MyRO.nEnemyUn + trix[ i]].emix) // model info6985 MyRO.EnemyUn[MyRO.nEnemyUn + trix[I]].emix) // model info 6313 6986 else 6314 6987 UnitStatDlg.ShowNewContent_EnemyUnit(wmPersistent, 6315 MyRO.nEnemyUn + trix[ i]); // unit info6316 end; 6317 end; 6318 end; 6319 6320 procedure TMainScreen.SetTroopLoc(Loc: integer);6988 MyRO.nEnemyUn + trix[I]); // unit info 6989 end; 6990 end; 6991 end; 6992 6993 procedure TMainScreen.SetTroopLoc(Loc: Integer); 6321 6994 var 6322 trixFocus, uix, uixDefender: integer;6323 Prio: boolean;6995 trixFocus, uix, uixDefender: Integer; 6996 Prio: Boolean; 6324 6997 begin 6325 6998 TroopLoc := Loc; … … 6333 7006 if MyMap[Loc] and fOwned <> 0 then 6334 7007 begin // count own units here 6335 Server(sGetDefender, me, TroopLoc, uixDefender);6336 for Prio := true downto false do7008 Server(sGetDefender, Me, TroopLoc, uixDefender); 7009 for Prio := True downto False do 6337 7010 for uix := 0 to MyRO.nUn - 1 do 6338 7011 if ((uix = uixDefender) = Prio) and (MyUn[uix].Loc = Loc) then … … 6340 7013 if uix = UnFocus then 6341 7014 trixFocus := TrCnt; 6342 inc(TrCnt);7015 Inc(TrCnt); 6343 7016 end; 6344 7017 end 6345 7018 else // count enemy units here 6346 Server(sGetUnits, me, Loc, TrCnt);7019 Server(sGetUnits, Me, Loc, TrCnt); 6347 7020 if TrCnt = 0 then 6348 7021 sb.Init(0, 1) … … 6355 7028 end; 6356 7029 6357 (* procedure TMainScreen.ShowMoveHint(ToLoc: integer; Force: boolean = false);7030 (* procedure TMainScreen.ShowMoveHint(ToLoc: Integer; Force: Boolean = False); 6358 7031 var 6359 Step,Loc,x0,y0,xs,ys: integer;7032 Step,Loc,x0,y0,xs,ys: Integer; 6360 7033 Info: string; 6361 7034 InfoSize: TSize; … … 6370 7043 MoveAdvice.MoreTurns:=0; 6371 7044 MoveAdvice.MaxHostile_MovementLeft:=MyUn[UnFocus].Health-50; 6372 if Server(sGetMoveAdvice, me,UnFocus,MoveAdvice)<rExecuted then7045 if Server(sGetMoveAdvice,Me,UnFocus,MoveAdvice)<rExecuted then 6373 7046 ToLoc:=-1 6374 7047 end; 6375 if (ToLoc=MoveHintToLoc) and not Force then exit;7048 if (ToLoc=MoveHintToLoc) and not Force then Exit; 6376 7049 if (ToLoc<>MoveHintToLoc) and (MoveHintToLoc>=0) then 6377 7050 begin invalidate; update end; // clear old hint from screen 6378 7051 MoveHintToLoc:=ToLoc; 6379 if ToLoc<0 then exit;6380 6381 with canvas do7052 if ToLoc<0 then Exit; 7053 7054 with Canvas do 6382 7055 begin 6383 7056 Pen.Color:=$80C0FF; … … 6390 7063 xs:=(x0-xw)*66+y0 and 1*33-G.lx*66; 6391 7064 while abs(2*(xs+G.lx*66)-MapWidth)<abs(2*xs-MapWidth) do 6392 inc(xs,G.lx*66);7065 Inc(xs,G.lx*66); 6393 7066 ys:=(y0-yw)*16; 6394 7067 if Step=0 then moveto(xs+33,ys+16) … … 6398 7071 end; 6399 7072 Brush.Color:=$80C0FF; 6400 Info:=' '+ inttostr(88)+' ';7073 Info:=' '+IntToStr(88)+' '; 6401 7074 InfoSize:=TextExtent(Info); 6402 7075 TextOut(xs+33-InfoSize.cx div 2, ys+16-InfoSize.cy div 2, Info); … … 6405 7078 end; *) 6406 7079 6407 procedure TMainScreen.SetDebugMap( p: integer);6408 begin 6409 MainMap.pDebugMap := p;7080 procedure TMainScreen.SetDebugMap(P: Integer); 7081 begin 7082 MainMap.pDebugMap := P; 6410 7083 MapOptions := MapOptions - [moLocCodes]; 6411 mLocCodes.Checked := false;6412 MapValid := false;7084 mLocCodes.Checked := False; 7085 MapValid := False; 6413 7086 MainOffscreenPaint; 6414 7087 end; 6415 7088 6416 procedure TMainScreen.SetViewpoint( p: integer);7089 procedure TMainScreen.SetViewpoint(P: Integer); 6417 7090 var 6418 i: Integer; 6419 begin 6420 if supervising and (G.RO[0].Turn > 0) and 6421 ((p = 0) or (1 shl p and G.RO[0].Alive <> 0)) then 6422 begin 6423 for i := 0 to DpiScreen.FormCount - 1 do 6424 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then 6425 DpiScreen.Forms[i].Close; // close windows 6426 ItsMeAgain(p); 7091 I: Integer; 7092 begin 7093 if Supervising and (G.RO[0].Turn > 0) and 7094 ((P = 0) or (1 shl P and G.RO[0].Alive <> 0)) then 7095 begin 7096 ApplyToVisibleForms(faClose); 7097 ItsMeAgain(P); 6427 7098 SumCities(TaxSum, ScienceSum); 6428 for i:= 0 to MyRO.nModel - 1 do6429 if not Assigned(Tribe[ me].ModelPicture[i].HGr) then6430 InitMyModel( i, True);7099 for I := 0 to MyRO.nModel - 1 do 7100 if not Assigned(Tribe[Me].ModelPicture[I].HGr) then 7101 InitMyModel(I, True); 6431 7102 6432 7103 SetTroopLoc(-1); … … 6481 7152 MTrans.ShortCut := BTrans.ShortCut; 6482 7153 mPollution.ShortCut := BPollution.ShortCut; 6483 mR R.ShortCut := BRailRoad.ShortCut;7154 mRailRoad.ShortCut := BRailRoad.ShortCut; 6484 7155 mRoad.ShortCut := BRailRoad.ShortCut; 6485 7156 mUnload.ShortCut := BUnload.ShortCut; … … 6516 7187 end; 6517 7188 6518 procedure TMainScreen.FormKeyDown(Sender: TObject; var Key: word;7189 procedure TMainScreen.FormKeyDown(Sender: TObject; var Key: Word; 6519 7190 Shift: TShiftState); 6520 7191 … … 6523 7194 InitPopup(Popup); 6524 7195 if Item.Visible and Item.Enabled then 6525 MenuClick(Item);6526 end; 6527 6528 procedure SetViewpointMe( p: Integer);6529 begin 6530 if p = me then SetViewpoint(p)6531 else SetViewpoint( p);7196 Item.Click; 7197 end; 7198 7199 procedure SetViewpointMe(P: Integer); 7200 begin 7201 if P = Me then SetViewpoint(P) 7202 else SetViewpoint(P); 6532 7203 end; 6533 7204 … … 6558 7229 6559 7230 if ClientMode = cEditMap then begin 6560 if BResign.Test(ShortCut) then MenuClick(mResign)6561 else if BRandomMap.Test(ShortCut) then MenuClick(mRandomMap)6562 else if BHelp.Test(ShortCut) then MenuClick(mHelp);7231 if BResign.Test(ShortCut) then mResign.Click 7232 else if BRandomMap.Test(ShortCut) then mRandomMap.Click 7233 else if BHelp.Test(ShortCut) then mHelp.Click; 6563 7234 (*if Shift = [ssCtrl] then 6564 7235 case char(Key) of 6565 7236 'A': 6566 7237 begin // auto symmetry 6567 Server($7F0, me,0,nil^);6568 MapValid:= false;7238 Server($7F0,Me,0,nil^); 7239 MapValid:=False; 6569 7240 PaintAll; 6570 7241 end; … … 6573 7244 dy:=0; 6574 7245 for dx:=G.lx to G.lx*(G.ly-1)-1 do 6575 if MyMap[dx] and fTerrain>=fGrass then inc(dy);7246 if MyMap[dx] and fTerrain>=fGrass then Inc(dy); 6576 7247 dy:=dy 6577 7248 end; … … 6586 7257 SetFullScreen(FullScreen); 6587 7258 end 6588 else if BHelp.Test(ShortCut) then MenuClick(mHelp)7259 else if BHelp.Test(ShortCut) then mHelp.Click 6589 7260 else if BUnitStat.Test(ShortCut) then MenuClick_Check(StatPopup, mUnitStat) 6590 7261 else if BCityStat.Test(ShortCut) then MenuClick_Check(StatPopup, mCityStat) … … 6608 7279 else if BSetDebugMap9.Test(ShortCut) then SetDebugMap(9) 6609 7280 6610 else if BJump.Test(ShortCut) then MenuClick(mJump)7281 else if BJump.Test(ShortCut) then mJump.Click 6611 7282 else if BDebugMap.Test(ShortCut) then mShowClick(mDebugMap) 6612 7283 else if BLocCodes.Test(ShortCut) then mShowClick(mLocCodes) … … 6617 7288 else if BNames.Test(ShortCut) then mNamesClick(mNames) 6618 7289 else if BResign.Test(ShortCut) then MenuClick_Check(GamePopup, mResign) 6619 else if BRun.Test(ShortCut) then MenuClick(mRun)7290 else if BRun.Test(ShortCut) then mRun.Click 6620 7291 else if BTestMapRepaint.Test(ShortCut) then begin // test map repaint time 6621 7292 Time0 := NowPrecise; … … 6642 7313 else if BMapBtn5.Test(ShortCut) then MapBtnClick(MapBtn5) 6643 7314 else if BMapBtn6.Test(ShortCut) then MapBtnClick(MapBtn6) 6644 else if BTechTree.Test(ShortCut) then MenuClick(mTechTree)6645 else if BWait.Test(ShortCut) then MenuClick(mWait);7315 else if BTechTree.Test(ShortCut) then mTechTree.Click 7316 else if BWait.Test(ShortCut) then mWait.Click; 6646 7317 6647 7318 if UnFocus >= 0 then begin 6648 if BDisbandUnit.Test(ShortCut) then MenuClick(mDisband)7319 if BDisbandUnit.Test(ShortCut) then mDisband.Click 6649 7320 else if BFortify.Test(ShortCut) then MenuClick_Check(TerrainPopup, mFort) 6650 else if BCenterUnit.Test(ShortCut) then MenuClick(mCentre)6651 else if BStay.Test(ShortCut) then MenuClick(mStay)6652 else if BNoOrders.Test(ShortCut) then MenuClick(mNoOrders)6653 else if BPrevUnit.Test(ShortCut) then MenuClick(mPrevUnit)6654 else if BNextUnit.Test(ShortCut) then MenuClick(mNextUnit)7321 else if BCenterUnit.Test(ShortCut) then mCentre.Click 7322 else if BStay.Test(ShortCut) then mStay.Click 7323 else if BNoOrders.Test(ShortCut) then mNoOrders.Click 7324 else if BPrevUnit.Test(ShortCut) then mPrevUnit.Click 7325 else if BNextUnit.Test(ShortCut) then mNextUnit.Click 6655 7326 else if BCancel.Test(ShortCut) then MenuClick_Check(UnitPopup, mCancel) 6656 7327 else if BPillage.Test(ShortCut) then MenuClick_Check(UnitPopup, mPillage) … … 6660 7331 else if BEnhance.Test(ShortCut) then begin 6661 7332 InitPopup(TerrainPopup); 6662 if mEnhance.Visible and mEnhance.Enabled then MenuClick(mEnhance)6663 else MenuClick(mEnhanceDef)7333 if mEnhance.Visible and mEnhance.Enabled then mEnhance.Click 7334 else mEnhanceDef.Click 6664 7335 end 6665 7336 else if BGoOn.Test(ShortCut) then MenuClick_Check(UnitPopup, mGoOn) … … 6667 7338 else if BFarmClearIrrigation.Test(ShortCut) then begin 6668 7339 if JobTest(UnFocus, jFarm, [eTreaty]) then 6669 MenuClick(mFarm)7340 mFarm.Click 6670 7341 else if JobTest(UnFocus, jClear, [eTreaty]) then 6671 MenuClick(mClear)7342 mClear.Click 6672 7343 else MenuClick_Check(TerrainPopup, mIrrigation); 6673 7344 end 6674 7345 else if BLoad.Test(ShortCut) then MenuClick_Check(UnitPopup, mLoad) 6675 7346 else if BAfforestMine.Test(ShortCut) then begin 6676 if JobTest(UnFocus, jAfforest, [eTreaty]) then MenuClick(mAfforest)7347 if JobTest(UnFocus, jAfforest, [eTreaty]) then mAfforest.Click 6677 7348 else MenuClick_Check(TerrainPopup, mMine); 6678 7349 end … … 6681 7352 else if BPollution.Test(ShortCut) then MenuClick_Check(TerrainPopup, mPollution) 6682 7353 else if BRailRoad.Test(ShortCut) then begin 6683 if JobTest(UnFocus, jRR, [eTreaty]) then MenuClick(mRR)7354 if JobTest(UnFocus, jRR, [eTreaty]) then mRailRoad.Click 6684 7355 else MenuClick_Check(TerrainPopup, mRoad); 6685 7356 end … … 6698 7369 end; 6699 7370 6700 procedure TMainScreen.MenuClick(Sender: TObject); 6701 6702 function DoJob(j0: integer): integer; 6703 var 6704 Loc0, Movement0: integer; 6705 begin 6706 with MyUn[UnFocus] do 7371 function TMainScreen.DoJob(j0: Integer): Integer; 7372 var 7373 Loc0, Movement0: Integer; 7374 begin 7375 with MyUn[UnFocus] do 7376 begin 7377 DestinationMarkON := False; 7378 PaintDestination; 7379 Loc0 := Loc; 7380 Movement0 := Movement; 7381 if j0 < 0 then 7382 Result := ProcessEnhancement(UnFocus, MyData.EnhancementJobs) 7383 // terrain enhancement 7384 else 7385 Result := Server(sStartJob + j0 shl 4, Me, UnFocus, nil^); 7386 if Result >= rExecuted then 6707 7387 begin 6708 DestinationMarkON := false; 6709 PaintDestination; 6710 Loc0 := Loc; 6711 Movement0 := Movement; 6712 if j0 < 0 then 6713 result := ProcessEnhancement(UnFocus, MyData.EnhancementJobs) 6714 // terrain enhancement 6715 else 6716 result := Server(sStartJob + j0 shl 4, me, UnFocus, nil^); 6717 if result >= rExecuted then 7388 if Result = eDied then 7389 UnFocus := -1; 7390 PaintLoc(Loc0); 7391 if UnFocus >= 0 then 6718 7392 begin 6719 if result = eDied then 6720 UnFocus := -1; 6721 PaintLoc(Loc0); 6722 if UnFocus >= 0 then 7393 if (j0 < 0) and (Result <> eJobDone) then 7394 // multi-turn terrain enhancement 7395 Status := Status and ($FFFF - usStay - usRecover - usGoto) or 7396 usEnhance 7397 else 7398 Status := Status and 7399 ($FFFF - usStay - usRecover - usGoto - usEnhance); 7400 if (Job <> jNone) or (Movement0 < 100) then 6723 7401 begin 6724 if (j0 < 0) and (result <> eJobDone) then 6725 // multi-turn terrain enhancement 6726 Status := Status and ($FFFF - usStay - usRecover - usGoto) or 6727 usEnhance 6728 else 6729 Status := Status and 6730 ($FFFF - usStay - usRecover - usGoto - usEnhance); 6731 if (Job <> jNone) or (Movement0 < 100) then 6732 begin 6733 Status := Status and not usWaiting; 6734 NextUnit(UnStartLoc, true); 6735 end 6736 else 6737 PanelPaint; 7402 Status := Status and not usWaiting; 7403 NextUnit(UnStartLoc, True); 6738 7404 end 6739 7405 else 6740 NextUnit(UnStartLoc, true); 6741 end; 6742 end; 6743 case result of 6744 eNoBridgeBuilding: 6745 SoundMessage(Phrases.Lookup('NOBB'), 'INVALID'); 6746 eNoCityTerrain: 6747 SoundMessage(Phrases.Lookup('NOCITY'), 'INVALID'); 6748 eTreaty: 6749 SoundMessage(Tribe[MyRO.Territory[Loc0]].TPhrase('PEACE_NOWORK'), 6750 'NOMOVE_TREATY'); 6751 else 6752 if result < rExecuted then 6753 Play('INVALID') 6754 end; 6755 end; 6756 6757 var 6758 i, uix, NewFocus, Loc0, OldMaster, Destination, cix, cixOldHome, 6759 ServerResult: integer; 6760 AltGovs, RevolutionChanged: boolean; 6761 QueryText: string; 6762 6763 begin 6764 if Sender = mResign then 6765 if ClientMode = cEditMap then 6766 begin 6767 if Edited then 6768 begin 6769 QueryText := Phrases.Lookup('MAP_CLOSE'); 6770 case SimpleQuery(mkYesNoCancel, QueryText, '') of 6771 mrIgnore: 6772 Server(sAbandonMap, me, 0, nil^); 6773 mrOK: 6774 Server(sSaveMap, me, 0, nil^); 6775 end 7406 PanelPaint; 6776 7407 end 6777 7408 else 6778 Server(sAbandonMap, me, 0, nil^) 6779 end 7409 NextUnit(UnStartLoc, True); 7410 end; 7411 end; 7412 case Result of 7413 eNoBridgeBuilding: 7414 SoundMessage(Phrases.Lookup('NOBB'), 'INVALID'); 7415 eNoCityTerrain: 7416 SoundMessage(Phrases.Lookup('NOCITY'), 'INVALID'); 7417 eTreaty: 7418 SoundMessage(Tribe[MyRO.Territory[Loc0]].TPhrase('PEACE_NOWORK'), 7419 'NOMOVE_TREATY'); 7420 else 7421 if Result < rExecuted then 7422 Play('INVALID'); 7423 end; 7424 end; 7425 7426 function TMainScreen.GetBattleDlg: TBattleDlg; 7427 begin 7428 if not Assigned(FBattleDlg) then FBattleDlg := TBattleDlg.Create(nil); 7429 Result := FBattleDlg; 7430 end; 7431 7432 function TMainScreen.GetCityDlg: TCityDlg; 7433 begin 7434 if not Assigned(FCityDlg) then begin 7435 FCityDlg := TCityDlg.Create(nil); 7436 FCityDlg.CheckAge; 7437 end; 7438 Result := FCityDlg; 7439 end; 7440 7441 function TMainScreen.GetCityTypeDlg: TCityTypeDlg; 7442 begin 7443 if not Assigned(FCityTypeDlg) then FCityTypeDlg := TCityTypeDlg.Create(nil); 7444 Result := FCityTypeDlg; 7445 end; 7446 7447 function TMainScreen.GetDiaDlg: TDiaDlg; 7448 begin 7449 if not Assigned(FDiaDlg) then begin 7450 FDiaDlg := TDiaDlg.Create(nil); 7451 ArrangeDialog(FDiaDlg); 7452 end; 7453 Result := FDiaDlg; 7454 end; 7455 7456 function TMainScreen.GetDraftDlg: TDraftDlg; 7457 begin 7458 if not Assigned(FDraftDlg) then FDraftDlg := TDraftDlg.Create(nil); 7459 Result := FDraftDlg; 7460 end; 7461 7462 function TMainScreen.GetEnhanceDlg: TEnhanceDlg; 7463 begin 7464 if not Assigned(FEnhanceDlg) then FEnhanceDlg := TEnhanceDlg.Create(nil); 7465 Result := FEnhanceDlg; 7466 end; 7467 7468 function TMainScreen.GetHelpDlg: THelpDlg; 7469 begin 7470 if not Assigned(FHelpDlg) then begin 7471 FHelpDlg := THelpDlg.Create(nil); 7472 ArrangeDialog(FHelpDlg); 7473 FHelpDlg.Difficulty := G.Difficulty[Me]; 7474 end; 7475 Result := FHelpDlg; 7476 end; 7477 7478 function TMainScreen.GetListDlg: TListDlg; 7479 begin 7480 if not Assigned(FListDlg) then begin 7481 FListDlg := TListDlg.Create(nil); 7482 ArrangeDialog(FListDlg); 7483 end; 7484 Result := FListDlg; 7485 end; 7486 7487 function TMainScreen.GetMessgExDlg: TMessgExDlg; 7488 begin 7489 if not Assigned(FMessgExDlg) then FMessgExDlg := TMessgExDlg.Create(nil); 7490 Result := FMessgExDlg; 7491 end; 7492 7493 function TMainScreen.GetModalSelectDlg: TModalSelectDlg; 7494 begin 7495 if not Assigned(FModalSelectDlg) then FModalSelectDlg := TModalSelectDlg.Create(nil); 7496 Result := FModalSelectDlg; 7497 end; 7498 7499 function TMainScreen.GetNatStatDlg: TNatStatDlg; 7500 begin 7501 if not Assigned(FNatStatDlg) then begin 7502 FNatStatDlg := TNatStatDlg.Create(nil); 7503 ArrangeDialog(FNatStatDlg); 7504 FNatStatDlg.CheckAge; 7505 end; 7506 Result := FNatStatDlg; 7507 end; 7508 7509 function TMainScreen.GetNegoDlg: TNegoDlg; 7510 begin 7511 if not Assigned(FNegoDlg) then FNegoDlg := TNegoDlg.Create(nil); 7512 Result := FNegoDlg; 7513 end; 7514 7515 function TMainScreen.GetRatesDlg: TRatesDlg; 7516 begin 7517 if not Assigned(FRatesDlg) then begin 7518 //FRatesDlg := TRatesDlg.Create(nil); 7519 DpiApplication.CreateForm(TRatesDlg, FRatesDlg); 7520 FRatesDlg.Show; 7521 end; 7522 Result := FRatesDlg; 7523 end; 7524 7525 function TMainScreen.GetTechTreeDlg: TTechTreeDlg; 7526 begin 7527 if not Assigned(FTechTreeDlg) then FTechTreeDlg := TTechTreeDlg.Create(nil); 7528 Result := FTechTreeDlg; 7529 end; 7530 7531 procedure TMainScreen.mDisbandOrUtilizeClick(Sender: TObject); 7532 var 7533 Loc0: Integer; 7534 begin 7535 if UnFocus >= 0 then 7536 with TUn(MyUn[UnFocus]) do begin 7537 if (Sender = mUtilize) and 7538 not(Server(sRemoveUnit - sExecute, Me, UnFocus, nil^) = eUtilized) then 7539 begin 7540 SimpleMessage(Phrases2.Lookup('SHIP_UTILIZE')); 7541 // freight for colony ship is the only case in which the command is 7542 // available to player though not valid 7543 Exit; 7544 end; 7545 if (Sender = mUtilize) and (Health < 100) then 7546 if SimpleQuery(mkYesNo, Phrases.Lookup('DAMAGED_UTILIZE'), '') <> mrOK 7547 then 7548 Exit; 7549 Loc0 := Loc; 7550 CityOptimizer_BeforeRemoveUnit(UnFocus); 7551 if Server(sRemoveUnit, Me, UnFocus, nil^) = eUtilized then 7552 Play('CITY_UTILIZE') 6780 7553 else 6781 begin 6782 if Server(sGetGameChanged, 0, 0, nil^) = eOK then 6783 begin 6784 QueryText := Phrases.Lookup('RESIGN'); 6785 case SimpleQuery(mkYesNoCancel, QueryText, '') of 6786 mrIgnore: 6787 Server(sResign, 0, 0, nil^); 6788 mrOK: 6789 Server(sBreak, 0, 0, nil^) 6790 end 6791 end 6792 else 6793 Server(sResign, 0, 0, nil^) 6794 end 6795 else if Sender = mEmpire then 6796 RatesDlg.ShowNewContent(wmPersistent) 6797 else if Sender = mRevolution then 6798 begin 6799 AltGovs := false; 6800 for i := 2 to nGov - 1 do 6801 if (GovPreq[i] <> preNA) and 6802 ((GovPreq[i] = preNone) or (MyRO.Tech[GovPreq[i]] >= tsApplicable)) then 6803 AltGovs := true; 6804 6805 if not AltGovs then 6806 SoundMessage(Phrases.Lookup('NOALTGOVS'), 'MSG_DEFAULT') 6807 else 6808 begin 6809 RevolutionChanged := false; 6810 if MyRO.Happened and phChangeGov <> 0 then 6811 begin 6812 ModalSelectDlg.ShowNewContent(wmModal, kGov); 6813 if ModalSelectDlg.result >= 0 then 6814 begin 6815 Play('NEWGOV'); 6816 Server(sSetGovernment, me, ModalSelectDlg.result, nil^); 6817 CityOptimizer_BeginOfTurn; 6818 RevolutionChanged := true; 6819 end 6820 end 6821 else 6822 with MessgExDlg do 6823 begin // revolution! 6824 MessgExDlg.MessgText := Tribe[me].TPhrase('REVOLUTION'); 6825 MessgExDlg.Kind := mkYesNo; 6826 MessgExDlg.IconKind := mikPureIcon; 6827 MessgExDlg.IconIndex := 72; // anarchy palace 6828 MessgExDlg.ShowModal; 6829 if ModalResult = mrOK then 6830 begin 6831 Play('REVOLUTION'); 6832 Server(sRevolution, me, 0, nil^); 6833 RevolutionChanged := true; 6834 if NatStatDlg.Visible then 6835 NatStatDlg.Close; 6836 if CityDlg.Visible then 6837 CityDlg.Close; 6838 end 6839 end; 6840 if RevolutionChanged then 6841 UpdateViews(true); 6842 end 6843 end 6844 else if Sender = mWebsite then 6845 OpenURL(CevoHomepage) 6846 else if Sender = mRandomMap then 6847 begin 6848 if not Edited or (SimpleQuery(mkYesNo, Phrases.Lookup('MAP_RANDOM'), '') 6849 = mrOK) then 6850 begin 6851 Server(sRandomMap, me, 0, nil^); 6852 Edited := true; 6853 MapValid := false; 6854 PaintAllMaps; 6855 end 6856 end 6857 else if Sender = mJump then 6858 begin 6859 if supervising then 6860 Jump[0] := 20 6861 else 6862 Jump[me] := 20; 6863 EndTurn(true); 6864 end 6865 else if Sender = mRun then 6866 begin 6867 if supervising then 6868 Jump[0] := 999999 6869 else 6870 Jump[me] := 999999; 6871 EndTurn(true); 6872 end 6873 else if Sender = mEnhanceDef then 6874 begin 6875 if UnFocus >= 0 then 6876 EnhanceDlg.ShowNewContent(wmPersistent, 6877 MyMap[MyUn[UnFocus].Loc] and fTerrain) 6878 else 6879 EnhanceDlg.ShowNewContent(wmPersistent) 6880 end 6881 else if Sender = mCityTypes then 6882 CityTypeDlg.ShowNewContent(wmModal) 6883 // must be modal because types are not saved before closing 6884 else if Sender = mUnitStat then 6885 begin 6886 if G.Difficulty[me] > 0 then 6887 ListDlg.ShowNewContent_MilReport(wmPersistent, me) 6888 else 6889 begin 6890 i := 1; 6891 while (i < nPl) and (1 shl i and MyRO.Alive = 0) do 6892 inc(i); 6893 if i < nPl then 6894 ListDlg.ShowNewContent_MilReport(wmPersistent, i); 6895 end; 6896 end 6897 else if Sender = mEUnitStat then 6898 begin 6899 if MyRO.nEnemyModel > 0 then 6900 ListDlg.ShowNewContent(wmPersistent, kAllEModels); 6901 end 6902 else if Sender = mCityStat then 6903 ListDlg.ShowNewContent(wmPersistent, kCities) 6904 else if Sender = mScienceStat then 6905 ListDlg.ShowNewContent(wmPersistent, kScience) 6906 else if Sender = mNations then 6907 NatStatDlg.ShowNewContent(wmPersistent) 6908 else if Sender = mHelp then 6909 if ClientMode = cEditMap then 6910 HelpDlg.ShowNewContent(wmPersistent, hkText, HelpDlg.TextIndex('MAPEDIT')) 6911 else 6912 HelpDlg.ShowNewContent(wmPersistent, hkMisc, miscMain) 6913 else if Sender = mTechTree then 6914 TechTreeDlg.ShowModal 6915 else if Sender = mWonders then 6916 WondersDlg.ShowNewContent(wmPersistent) 6917 else if Sender = mDiagram then 6918 DiaDlg.ShowNewContent_Charts(wmPersistent) 6919 else if Sender = mShips then 6920 DiaDlg.ShowNewContent_Ship(wmPersistent) 6921 else if Sender = mWait then 6922 begin 6923 if UnFocus >= 0 then 6924 begin 6925 DestinationMarkON := false; 6926 PaintDestination; 6927 MyUn[UnFocus].Status := MyUn[UnFocus].Status and 6928 ($FFFF - usStay - usRecover - usGoto - usEnhance) or usWaiting; 6929 end; 6930 NextUnit(-1, false); 6931 end 6932 else if UnFocus >= 0 then 6933 with TUn(MyUn[UnFocus]) do 6934 if Sender = mGoOn then 6935 begin 6936 if Status shr 16 = $7FFF then 6937 Destination := maNextCity 6938 else 6939 Destination := Status shr 16; 6940 Status := Status and not(usStay or usRecover) or usWaiting; 6941 MoveToLoc(Destination, true); 6942 end 6943 else if Sender = mHome then 6944 if MyMap[Loc] and fCity <> 0 then 6945 begin 6946 cixOldHome := Home; 6947 if Server(sSetUnitHome, me, UnFocus, nil^) >= rExecuted then 6948 begin 6949 CityOptimizer_CityChange(cixOldHome); 6950 CityOptimizer_CityChange(Home); 6951 UpdateViews(true); 6952 end 6953 else 6954 Play('INVALID'); 6955 end 6956 else 6957 begin 6958 Status := Status and not(usStay or usRecover or usEnhance); 6959 MoveToLoc(maNextCity, true) 6960 end 6961 else if Sender = mCentre then 6962 begin 6963 Centre(Loc); 6964 PaintAllMaps; 6965 end 6966 else if Sender = mCity then 6967 begin 6968 Loc0 := Loc; 6969 if MyMap[Loc] and fCity = 0 then 6970 begin // build city 6971 if DoJob(jCity) = eCity then 6972 begin 6973 MapValid := false; 6974 PaintAll; 6975 ZoomToCity(Loc0, true, chFounded); 6976 end; 6977 end 6978 else 6979 begin 6980 CityOptimizer_BeforeRemoveUnit(UnFocus); 6981 ServerResult := Server(sAddToCity, me, UnFocus, nil^); 6982 if ServerResult >= rExecuted then 6983 begin 6984 cix := MyRO.nCity - 1; 6985 while (cix >= 0) and (MyCity[cix].Loc <> Loc0) do 6986 dec(cix); 6987 assert(cix >= 0); 6988 CityOptimizer_CityChange(cix); 6989 CityOptimizer_AfterRemoveUnit; // does nothing here 6990 SetTroopLoc(Loc0); 6991 UpdateViews(true); 6992 DestinationMarkON := false; 6993 PaintDestination; 6994 UnFocus := -1; 6995 PaintLoc(Loc0); 6996 NextUnit(UnStartLoc, true); 6997 end 6998 else if ServerResult = eMaxSize then 6999 SimpleMessage(Phrases.Lookup('ADDTOMAXSIZE')); 7000 end 7001 end 7002 else if Sender = mRoad then 7003 DoJob(jRoad) 7004 else if Sender = mRR then 7005 DoJob(jRR) 7006 else if Sender = mClear then 7007 DoJob(jClear) 7008 else if Sender = mIrrigation then 7009 DoJob(jIrr) 7010 else if Sender = mFarm then 7011 DoJob(jFarm) 7012 else if Sender = mAfforest then 7013 DoJob(jAfforest) 7014 else if Sender = mMine then 7015 DoJob(jMine) 7016 else if Sender = mCanal then 7017 DoJob(jCanal) 7018 else if Sender = MTrans then 7019 DoJob(jTrans) 7020 else if Sender = mFort then 7021 DoJob(jFort) 7022 else if Sender = mAirBase then 7023 DoJob(jBase) 7024 else if Sender = mPollution then 7025 DoJob(jPoll) 7026 else if Sender = mPillage then 7027 DoJob(jPillage) 7028 else if Sender = mEnhance then 7029 DoJob(-1) 7030 else if Sender = mStay then 7031 begin 7032 DestinationMarkON := false; 7033 PaintDestination; 7034 Status := Status and ($FFFF - usRecover - usGoto - usEnhance) or usStay; 7035 if Job > jNone then 7036 Server(sStartJob + jNone shl 4, me, UnFocus, nil^); 7037 NextUnit(UnStartLoc, true); 7038 end 7039 else if Sender = mRecover then 7040 begin 7041 DestinationMarkON := false; 7042 PaintDestination; 7043 Status := Status and ($FFFF - usStay - usGoto - usEnhance) or usRecover; 7044 if Job > jNone then 7045 Server(sStartJob + jNone shl 4, me, UnFocus, nil^); 7046 NextUnit(UnStartLoc, true); 7047 end 7048 else if Sender = mNoOrders then 7049 begin 7050 Status := Status and not usWaiting; 7051 NextUnit(UnStartLoc, true); 7052 end 7053 else if Sender = mPrevUnit then 7054 begin 7055 Status := Status and not usWaiting; 7056 FocusNextUnit(-1); 7057 end 7058 else if Sender = mNextUnit then 7059 begin 7060 Status := Status and not usWaiting; 7061 FocusNextUnit(1); 7062 end 7063 else if Sender = mCancel then 7064 begin 7065 DestinationMarkON := false; 7066 PaintDestination; 7067 Status := Status and ($FFFF - usRecover - usGoto - usEnhance); 7068 if Job > jNone then 7069 Server(sStartJob + jNone shl 4, me, UnFocus, nil^); 7070 end 7071 else if (Sender = mDisband) or (Sender = mUtilize) then 7072 begin 7073 if (Sender = mUtilize) and 7074 not(Server(sRemoveUnit - sExecute, me, UnFocus, nil^) = eUtilized) 7075 then 7076 begin 7077 SimpleMessage(Phrases2.Lookup('SHIP_UTILIZE')); 7078 // freight for colony ship is the only case in which the command is 7079 // available to player though not valid 7080 exit 7081 end; 7082 if (Sender = mUtilize) and (Health < 100) then 7083 if SimpleQuery(mkYesNo, Phrases.Lookup('DAMAGED_UTILIZE'), '') <> mrOK 7084 then 7085 exit; 7086 Loc0 := Loc; 7087 CityOptimizer_BeforeRemoveUnit(UnFocus); 7088 if Server(sRemoveUnit, me, UnFocus, nil^) = eUtilized then 7089 Play('CITY_UTILIZE') 7090 else 7091 Play('DISBAND'); 7092 CityOptimizer_AfterRemoveUnit; 7093 SetTroopLoc(Loc0); 7094 UpdateViews(true); 7095 DestinationMarkON := false; 7096 PaintDestination; 7097 UnFocus := -1; 7098 PaintLoc(Loc0); 7099 NextUnit(UnStartLoc, true); 7100 end 7101 else if Sender = mLoad then 7102 begin 7103 i := Server(sLoadUnit, me, UnFocus, nil^); 7104 if i >= rExecuted then 7105 begin 7106 if MyModel[mix].Domain = dAir then 7107 Play('MOVE_PLANELANDING') 7108 else 7109 Play('MOVE_LOAD'); 7110 DestinationMarkON := false; 7111 PaintDestination; 7112 Status := Status and ($FFFF - usWaiting - usStay - usRecover - usGoto 7113 - usEnhance); 7114 NextUnit(UnStartLoc, true); 7115 end 7116 else if i = eNoTime_Load then 7117 if MyModel[mix].Domain = dAir then 7118 SoundMessage(Phrases.Lookup('NOTIMELOADAIR'), 'NOMOVE_TIME') 7119 else 7120 SoundMessage(Format(Phrases.Lookup('NOTIMELOADGROUND'), 7121 [MovementToString(MyModel[mix].speed)]), 'NOMOVE_TIME'); 7122 end 7123 else if Sender = mUnload then 7124 if Master >= 0 then 7125 begin 7126 OldMaster := Master; 7127 i := Server(sUnloadUnit, me, UnFocus, nil^); 7128 if i >= rExecuted then 7129 begin 7130 if MyModel[mix].Domain = dAir then 7131 Play('MOVE_PLANESTART') 7132 else if (MyModel[MyUn[OldMaster].mix].Domain = dAir) and 7133 (MyMap[Loc] and fCity = 0) and (MyMap[Loc] and fTerImp <> tiBase) 7134 then 7135 Play('MOVE_PARACHUTE') 7136 else 7137 Play('MOVE_UNLOAD'); 7138 Status := Status and not usWaiting; 7139 if MyModel[mix].Domain <> dAir then 7140 NextUnit(Loc, true) 7141 else 7142 PanelPaint; 7143 end 7144 else if i = eNoTime_Load then 7145 if MyModel[mix].Domain = dAir then 7146 SoundMessage(Phrases.Lookup('NOTIMELOADAIR'), 'NOMOVE_TIME') 7147 else 7148 SoundMessage(Format(Phrases.Lookup('NOTIMELOADGROUND'), 7149 [MovementToString(MyModel[mix].speed)]), 'NOMOVE_TIME'); 7150 end 7151 else 7152 begin 7153 NewFocus := -1; 7154 uix := UnFocus; 7155 for i := 1 to MyRO.nUn - 1 do 7156 begin 7157 uix := (uix + MyRO.nUn - 1) mod MyRO.nUn; 7158 if (MyUn[uix].Master = UnFocus) and 7159 (MyUn[uix].Movement = integer(MyModel[MyUn[uix].mix].speed)) then 7160 begin 7161 MyUn[uix].Status := MyUn[uix].Status or usWaiting; 7162 NewFocus := uix 7163 end; 7164 end; 7165 if NewFocus >= 0 then 7166 begin 7167 SetUnFocus(NewFocus); 7168 SetTroopLoc(Loc); 7169 PanelPaint 7170 end; 7171 end 7172 else if Sender = mSelectTransport then 7173 Server(sSelectTransport, me, UnFocus, nil^) 7554 Play('DISBAND'); 7555 CityOptimizer_AfterRemoveUnit; 7556 SetTroopLoc(Loc0); 7557 UpdateViews(True); 7558 DestinationMarkON := False; 7559 PaintDestination; 7560 UnFocus := -1; 7561 PaintLoc(Loc0); 7562 NextUnit(UnStartLoc, True); 7563 end; 7174 7564 end; 7175 7565 7176 7566 procedure TMainScreen.InitPopup(Popup: TDpiPopupMenu); 7177 7567 var 7178 i, p1, Tile, Test: integer;7179 NoSuper, extended, Multi, NeedSep, HaveCities: boolean;7180 LastSep, m: TDpiMenuItem;7568 I, p1, Tile, Test: Integer; 7569 NoSuper, Extended, Multi, NeedSep, HaveCities: Boolean; 7570 LastSep, M: TDpiMenuItem; 7181 7571 mox: ^TModel; 7182 7572 begin 7183 NoSuper := not supervising and (1 shl me and MyRO.Alive <> 0);7184 HaveCities := false;7185 for i:= 0 to MyRO.nCity - 1 do7186 if MyCity[ i].Loc >= 0 then7573 NoSuper := not Supervising and (1 shl Me and MyRO.Alive <> 0); 7574 HaveCities := False; 7575 for I := 0 to MyRO.nCity - 1 do 7576 if MyCity[I].Loc >= 0 then 7187 7577 begin 7188 HaveCities := true;7578 HaveCities := True; 7189 7579 Break; 7190 7580 end; … … 7192 7582 begin 7193 7583 mTechTree.Visible := ClientMode <> cEditMap; 7194 mResign.Enabled := supervising or (me = 0) and (ClientMode < scContact);7584 mResign.Enabled := Supervising or (Me = 0) and (ClientMode < scContact); 7195 7585 mRandomMap.Visible := (ClientMode = cEditMap) and 7196 (Server(sMapGeneratorRequest, me, 0, nil^) = eOK);7586 (Server(sMapGeneratorRequest, Me, 0, nil^) = eOK); 7197 7587 mOptions.Visible := ClientMode <> cEditMap; 7198 7588 mManip.Visible := ClientMode <> cEditMap; … … 7208 7598 case SoundMode of 7209 7599 smOff: 7210 mSoundOff.Checked := true;7600 mSoundOff.Checked := True; 7211 7601 smOn: 7212 mSoundOn.Checked := true;7602 mSoundOn.Checked := True; 7213 7603 smOnAlt: 7214 mSoundOnAlt.Checked := true;7215 end; 7216 7217 for i:= 0 to nTestFlags - 1 do7218 mManip[ i].Checked := MyRO.TestFlags and (1 shl i) <> 0;7219 mManip.Enabled := supervising or (me = 0);7220 7221 Multi := false;7604 mSoundOnAlt.Checked := True; 7605 end; 7606 7607 for I := 0 to nTestFlags - 1 do 7608 mManip[I].Checked := MyRO.TestFlags and (1 shl I) <> 0; 7609 mManip.Enabled := Supervising or (Me = 0); 7610 7611 Multi := False; 7222 7612 for p1 := 1 to nPl - 1 do 7223 7613 if G.RO[p1] <> nil then 7224 Multi := true;7614 Multi := True; 7225 7615 mEnemyMovement.Visible := not Multi; 7226 7616 end; … … 7228 7618 if NoSuper and (ClientMode < scContact) then 7229 7619 begin 7230 mCityTypes.Enabled := false;7620 mCityTypes.Enabled := False; 7231 7621 // check if city types already usefull: 7232 7622 if MyRO.nCity > 0 then 7233 for i:= nWonder to nImp - 1 do7234 if ( i <> imTrGoods) and (Imp[i].Kind = ikCommon) and7235 (Imp[ i].Preq <> preNA) and7236 ((Imp[ i].Preq = preNone) or (MyRO.Tech[Imp[i].Preq] >= tsApplicable))7623 for I := nWonder to nImp - 1 do 7624 if (I <> imTrGoods) and (Imp[I].Kind = ikCommon) and 7625 (Imp[I].Preq <> preNA) and 7626 ((Imp[I].Preq = preNone) or (MyRO.Tech[Imp[I].Preq] >= tsApplicable)) 7237 7627 then 7238 7628 begin 7239 mCityTypes.Enabled := true;7629 mCityTypes.Enabled := True; 7240 7630 Break 7241 7631 end; 7242 7632 end; 7243 mViewpoint.Visible := (ClientMode <> cEditMap) and supervising;7633 mViewpoint.Visible := (ClientMode <> cEditMap) and Supervising; 7244 7634 mViewpoint.Enabled := G.RO[0].Turn > 0; 7245 if supervising then7635 if Supervising then 7246 7636 begin 7247 7637 EmptyMenu(mViewpoint); … … 7249 7639 if (p1 = 0) or (1 shl p1 and G.RO[0].Alive <> 0) then 7250 7640 begin 7251 m:= TDpiMenuItem.Create(mViewpoint);7641 M := TDpiMenuItem.Create(mViewpoint); 7252 7642 if p1 = 0 then 7253 m.Caption := Phrases.Lookup('SUPER')7643 M.Caption := Phrases.Lookup('SUPER') 7254 7644 else 7255 m.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG'));7256 m.Tag := p1;7257 m.OnClick := ViewpointClick;7645 M.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG')); 7646 M.Tag := p1; 7647 M.OnClick := ViewpointClick; 7258 7648 if p1 < 10 then 7259 m.ShortCut := ShortCut(48 + p1, [ssCtrl]);7260 m.RadioItem := true;7261 if p1 = me then7262 m.Checked := true;7263 mViewpoint.Add( m);7649 M.ShortCut := ShortCut(48 + p1, [ssCtrl]); 7650 M.RadioItem := True; 7651 if p1 = Me then 7652 M.Checked := True; 7653 mViewpoint.Add(M); 7264 7654 end 7265 7655 end; 7266 mDebugMap.Visible := (ClientMode <> cEditMap) and supervising;7267 if supervising then7656 mDebugMap.Visible := (ClientMode <> cEditMap) and Supervising; 7657 if Supervising then 7268 7658 begin 7269 7659 EmptyMenu(mDebugMap); … … 7271 7661 if (p1 = 0) or (1 shl p1 and G.RO[0].Alive <> 0) then 7272 7662 begin 7273 m:= TDpiMenuItem.Create(mDebugMap);7663 M := TDpiMenuItem.Create(mDebugMap); 7274 7664 if p1 = 0 then 7275 m.Caption := Phrases2.Lookup('MENU_DEBUGMAPOFF')7665 M.Caption := Phrases2.Lookup('MENU_DEBUGMAPOFF') 7276 7666 else 7277 m.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG'));7667 M.Caption := Tribe[p1].TString(Phrases2.Lookup('BELONG')); 7278 7668 if p1 = 0 then 7279 m.Tag := -17669 M.Tag := -1 7280 7670 else 7281 m.Tag := p1;7282 m.OnClick := DebugMapClick;7671 M.Tag := p1; 7672 M.OnClick := DebugMapClick; 7283 7673 if p1 < 10 then 7284 m.ShortCut := ShortCut(48 + p1, [ssAlt]);7285 m.RadioItem := true;7286 if m.Tag = MainMap.pDebugMap then7287 m.Checked := true;7288 mDebugMap.Add( m);7674 M.ShortCut := ShortCut(48 + p1, [ssAlt]); 7675 M.RadioItem := True; 7676 if M.Tag = MainMap.pDebugMap then 7677 M.Checked := True; 7678 mDebugMap.Add(M); 7289 7679 end; 7290 7680 end; … … 7301 7691 (ClientMode < scContact); 7302 7692 mUnitStat.Enabled := NoSuper or (MyRO.Turn > 0); 7303 mCityStat.Visible := 1 shl me and MyRO.Alive <> 0;7693 mCityStat.Visible := 1 shl Me and MyRO.Alive <> 0; 7304 7694 mCityStat.Enabled := HaveCities; 7305 mScienceStat.Visible := true;7695 mScienceStat.Visible := True; 7306 7696 mScienceStat.Enabled := not NoSuper or (MyRO.ResearchTech >= 0) or 7307 7697 (MyRO.Happened and phTech <> 0) or (MyRO.Happened and phGameEnd <> 0) … … 7310 7700 mEUnitStat.Enabled := MyRO.nEnemyModel > 0; 7311 7701 { mWonders.Enabled:= false; 7312 for i:=0 to nWonder - 1 do if MyRO.Wonder[i].CityID <> WonderNotBuiltYet then7313 mWonders.Enabled:= true; }7702 for I:=0 to nWonder - 1 do if MyRO.Wonder[I].CityID <> WonderNotBuiltYet then 7703 mWonders.Enabled:=True; } 7314 7704 mDiagram.Enabled := MyRO.Turn >= 2; 7315 mShips.Enabled := false;7705 mShips.Enabled := False; 7316 7706 for p1 := 0 to nPl - 1 do 7317 7707 if MyRO.Ship[p1].Parts[spComp] + MyRO.Ship[p1].Parts[spPow] + 7318 7708 MyRO.Ship[p1].Parts[spHab] > 0 then 7319 mShips.Enabled := true;7709 mShips.Enabled := True; 7320 7710 end 7321 7711 else if Popup = UnitPopup then … … 7323 7713 mox := @MyModel[MyUn[UnFocus].mix]; 7324 7714 Tile := MyMap[MyUn[UnFocus].Loc]; 7325 extended := Tile and fCity = 0;7326 if extended then7715 Extended := Tile and fCity = 0; 7716 if Extended then 7327 7717 begin 7328 7718 mCity.Caption := Phrases.Lookup('BTN_FOUND'); … … 7335 7725 end; 7336 7726 7337 extended := extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves)7727 Extended := Extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves) 7338 7728 and (MyRO.Wonder[woPyramids].EffectiveOwner >= 0)) and 7339 7729 (MyUn[UnFocus].Master < 0) and (Tile and fDeadLands = 0); 7340 7730 if (mox.Kind = mkFreight) and (Tile and fCity <> 0) and 7341 7731 not Phrases2FallenBackToEnglish or 7342 (Server(sRemoveUnit - sExecute, me, UnFocus, nil^) = eUtilized) then7732 (Server(sRemoveUnit - sExecute, Me, UnFocus, nil^) = eUtilized) then 7343 7733 begin 7344 mDisband.Visible := false;7345 mUtilize.Visible := true;7734 mDisband.Visible := False; 7735 mUtilize.Visible := True; 7346 7736 if mox.Kind = mkFreight then 7347 7737 mUtilize.Caption := Phrases.Lookup('UTILIZE') … … 7351 7741 else 7352 7742 begin 7353 mDisband.Visible := true;7354 mUtilize.Visible := false7743 mDisband.Visible := True; 7744 mUtilize.Visible := False 7355 7745 end; 7356 7746 mGoOn.Visible := MyUn[UnFocus].Status and (usGoto or usWaiting) = usGoto or … … 7359 7749 mRecover.Visible := (MyUn[UnFocus].Health < 100) and 7360 7750 (Tile and fTerrain >= fGrass) and 7361 ((MyRO.Wonder[woGardens].EffectiveOwner = me) or7751 ((MyRO.Wonder[woGardens].EffectiveOwner = Me) or 7362 7752 (Tile and fTerrain <> fArctic) and (Tile and fTerrain <> fDesert)) and 7363 7753 not((mox.Domain = dAir) and (Tile and fCity = 0) and … … 7365 7755 mStay.Visible := not((mox.Domain = dAir) and (Tile and fCity = 0) and 7366 7756 (Tile and fTerImp <> tiBase)); 7367 mCity.Visible := extended and (mox.Kind = mkSettler) or7757 mCity.Visible := Extended and (mox.Kind = mkSettler) or 7368 7758 (Tile and fCity <> 0) and ((mox.Kind in [mkSettler, mkSlaves]) or 7369 7759 (MyUn[UnFocus].Flags and unConscripts <> 0)); … … 7373 7763 (MyUn[UnFocus].Status and (usRecover or usGoto) <> 0); 7374 7764 7375 Test := Server(sLoadUnit - sExecute, me, UnFocus, nil^);7765 Test := Server(sLoadUnit - sExecute, Me, UnFocus, nil^); 7376 7766 mLoad.Visible := (Test >= rExecuted) or (Test = eNoTime_Load); 7377 7767 mUnload.Visible := (MyUn[UnFocus].Master >= 0) or 7378 7768 (MyUn[UnFocus].TroopLoad + MyUn[UnFocus].AirLoad > 0); 7379 mSelectTransport.Visible := Server(sSelectTransport - sExecute, me, UnFocus,7769 mSelectTransport.Visible := Server(sSelectTransport - sExecute, Me, UnFocus, 7380 7770 nil^) >= rExecuted; 7381 7771 end … … 7384 7774 mox := @MyModel[MyUn[UnFocus].mix]; 7385 7775 Tile := MyMap[MyUn[UnFocus].Loc]; 7386 extended := Tile and fCity = 0;7776 Extended := Tile and fCity = 0; 7387 7777 7388 7778 if (Tile and fRiver <> 0) and (MyRO.Tech[adBridgeBuilding] >= tsApplicable) … … 7390 7780 begin 7391 7781 mRoad.Caption := Phrases.Lookup('BTN_BUILDBRIDGE'); 7392 mR R.Caption := Phrases.Lookup('BTN_BUILDRRBRIDGE');7782 mRailRoad.Caption := Phrases.Lookup('BTN_BUILDRRBRIDGE'); 7393 7783 end 7394 7784 else 7395 7785 begin 7396 7786 mRoad.Caption := Phrases.Lookup('BTN_BUILDROAD'); 7397 mR R.Caption := Phrases.Lookup('BTN_BUILDRR');7787 mRailRoad.Caption := Phrases.Lookup('BTN_BUILDRR'); 7398 7788 end; 7399 7789 if Tile and fTerrain = fForest then … … 7404 7794 mClear.Caption := Phrases.Lookup('BTN_DRAIN'); 7405 7795 7406 extended := extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves)7796 Extended := Extended and ((mox.Kind = mkSettler) or (mox.Kind = mkSlaves) 7407 7797 and (MyRO.Wonder[woPyramids].EffectiveOwner >= 0)) and 7408 7798 (MyUn[UnFocus].Master < 0); 7409 if extended then7799 if Extended then 7410 7800 begin 7411 7801 mRoad.Visible := JobTest(UnFocus, jRoad, [eNoBridgeBuilding, eTreaty]); 7412 mR R.Visible := JobTest(UnFocus, jRR, [eNoBridgeBuilding, eTreaty]);7802 mRailRoad.Visible := JobTest(UnFocus, jRR, [eNoBridgeBuilding, eTreaty]); 7413 7803 mClear.Visible := JobTest(UnFocus, jClear, [eTreaty]); 7414 7804 mIrrigation.Visible := JobTest(UnFocus, jIrr, [eTreaty]); … … 7427 7817 else 7428 7818 begin 7429 for i:= 0 to Popup.Items.Count - 1 do7430 Popup.Items[ i].Visible := false;7819 for I := 0 to Popup.Items.Count - 1 do 7820 Popup.Items[I].Visible := False; 7431 7821 end; 7432 7822 end; … … 7434 7824 // set menu seperators 7435 7825 LastSep := nil; 7436 NeedSep := false;7437 for i:= 0 to Popup.Items.Count - 1 do7438 if Popup.Items[ i].Caption = '-' then7826 NeedSep := False; 7827 for I := 0 to Popup.Items.Count - 1 do 7828 if Popup.Items[I].Caption = '-' then 7439 7829 begin 7440 Popup.Items[ i].Visible := NeedSep;7830 Popup.Items[I].Visible := NeedSep; 7441 7831 if NeedSep then 7442 LastSep := Popup.Items[ i];7443 NeedSep := false7832 LastSep := Popup.Items[I]; 7833 NeedSep := False 7444 7834 end 7445 else if Popup.Items[ i].Visible then7446 NeedSep := true;7835 else if Popup.Items[I].Visible then 7836 NeedSep := True; 7447 7837 if (LastSep <> nil) and not NeedSep then 7448 LastSep.Visible := false7838 LastSep.Visible := False 7449 7839 end; 7450 7840 … … 7465 7855 end; 7466 7856 7467 procedure TMainScreen.CityClosed(Activateuix: integer; StepFocus: boolean;7468 SelectFocus: boolean);7469 begin 7470 if supervising then7857 procedure TMainScreen.CityClosed(Activateuix: Integer; StepFocus: Boolean; 7858 SelectFocus: Boolean); 7859 begin 7860 if Supervising then 7471 7861 begin 7472 7862 SetTroopLoc(-1); … … 7485 7875 end 7486 7876 else if StepFocus then 7487 NextUnit(TroopLoc, true)7877 NextUnit(TroopLoc, True) 7488 7878 else 7489 7879 begin … … 7496 7886 procedure TMainScreen.Toggle(Sender: TObject); 7497 7887 begin 7498 TDpiMenuItem(Sender).Checked := not TDpiMenuItem(Sender).Checked 7888 TDpiMenuItem(Sender).Checked := not TDpiMenuItem(Sender).Checked; 7499 7889 end; 7500 7890 7501 7891 procedure TMainScreen.PanelBoxMouseMove(Sender: TObject; Shift: TShiftState; 7502 x, y: integer);7892 X, Y: Integer); 7503 7893 var 7504 xCentre, yCentre: integer;7894 xCentre, yCentre: Integer; 7505 7895 begin 7506 7896 if Tracking and (ssLeft in Shift) then 7507 7897 with MainMap do begin 7508 if ( x >= xMini + 2) and (y >= yMini + 2) and (x< xMini + 2 + 2 * G.lx) and7509 ( y< yMini + 2 + G.ly) then7898 if (X >= xMini + 2) and (Y >= yMini + 2) and (X < xMini + 2 + 2 * G.lx) and 7899 (Y < yMini + 2 + G.ly) then 7510 7900 begin 7511 xCentre := (xwMini + ( x- xMini - 2) div 2 + G.lx div 2 +7901 xCentre := (xwMini + (X - xMini - 2) div 2 + G.lx div 2 + 7512 7902 MapWidth div (xxt * 4)) mod G.lx; 7513 yCentre := ( y- yMini - 2);7903 yCentre := (Y - yMini - 2); 7514 7904 xw := (xCentre - MapWidth div (xxt * 4) + G.lx) mod G.lx; 7515 7905 if ywmax <= 0 then … … 7523 7913 yw := ywmax; 7524 7914 end; 7525 DpiBit Canvas(Buffer.Canvas, 0, 0, G.lx * 2, G.ly, MiniMap.Bitmap.Canvas, 0, 0);7915 DpiBitBltCanvas(Buffer.Canvas, 0, 0, G.lx * 2, G.ly, MiniMap.Bitmap.Canvas, 0, 0); 7526 7916 if ywmax <= 0 then 7527 Frame(Buffer.Canvas, x- xMini - 2 - MapWidth div (xxt * 2), 0,7528 x- xMini - 2 + MapWidth div (xxt * 2) - 1, G.ly - 1,7917 Frame(Buffer.Canvas, X - xMini - 2 - MapWidth div (xxt * 2), 0, 7918 X - xMini - 2 + MapWidth div (xxt * 2) - 1, G.ly - 1, 7529 7919 MainTexture.ColorMark, MainTexture.ColorMark) 7530 7920 else 7531 Frame(Buffer.Canvas, x- xMini - 2 - MapWidth div (xxt * 2), yw,7532 x- xMini - 2 + MapWidth div (xxt * 2) - 1, yw + MapHeight div yyt -7921 Frame(Buffer.Canvas, X - xMini - 2 - MapWidth div (xxt * 2), yw, 7922 X - xMini - 2 + MapWidth div (xxt * 2) - 1, yw + MapHeight div yyt - 7533 7923 2, MainTexture.ColorMark, MainTexture.ColorMark); 7534 DpiBit Canvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly,7924 DpiBitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 7535 7925 Buffer.Canvas, 0, 0); 7536 7926 MainOffscreenPaint; … … 7542 7932 end 7543 7933 else 7544 Tracking := false;7934 Tracking := False; 7545 7935 end; 7546 7936 7547 7937 procedure TMainScreen.PanelBoxMouseUp(Sender: TObject; Button: TMouseButton; 7548 Shift: TShiftState; x, y: integer);7938 Shift: TShiftState; X, Y: Integer); 7549 7939 begin 7550 7940 if Tracking then 7551 7941 begin 7552 Tracking := false;7942 Tracking := False; 7553 7943 xwMini := xw; 7554 7944 ywMini := yw; … … 7559 7949 7560 7950 procedure TMainScreen.MapBoxMouseMove(Sender: TObject; Shift: TShiftState; 7561 x, y: integer);7951 X, Y: Integer); 7562 7952 var 7563 MouseLoc: integer;7564 begin 7565 xMouse := x;7566 yMouse := y;7953 MouseLoc: Integer; 7954 begin 7955 xMouse := X; 7956 yMouse := Y; 7567 7957 if (ClientMode = cEditMap) and (ssLeft in Shift) and not Tracking then 7568 7958 begin 7569 MouseLoc := LocationOfScreenPixel( x, y);7959 MouseLoc := LocationOfScreenPixel(X, Y); 7570 7960 if MouseLoc <> BrushLoc then 7571 MapBoxMouseDown(nil, mbLeft, Shift, x, y);7961 MapBoxMouseDown(nil, mbLeft, Shift, X, Y); 7572 7962 end 7573 (* else if idle and (UnFocus>=0) then7963 (* else if Idle and (UnFocus>=0) then 7574 7964 begin 7575 7965 qx:=(xMouse*32+yMouse*66+16*66) div(32*66)-1; … … 7584 7974 TDpiMenuItem(Sender).Checked := not TDpiMenuItem(Sender).Checked; 7585 7975 SetMapOptions; 7586 MapValid := false;7976 MapValid := False; 7587 7977 PaintAllMaps; 7588 7978 end; … … 7590 7980 procedure TMainScreen.mNamesClick(Sender: TObject); 7591 7981 var 7592 p1: integer;7982 p1: Integer; 7593 7983 begin 7594 7984 mNames.Checked := not mNames.Checked; … … 7600 7990 else 7601 7991 Tribe[p1].NumberName := p1; 7602 MapValid := false;7992 MapValid := False; 7603 7993 PaintAll; 7604 7994 end; 7605 7995 7606 function TMainScreen.IsPanelPixel( x, y: integer): boolean;7607 begin 7608 result := (y >= TopBarHeight + MapHeight) or (y>= ClientHeight - PanelHeight)7609 and (( x < xMidPanel) or (x>= xRightPanel));7996 function TMainScreen.IsPanelPixel(X, Y: Integer): Boolean; 7997 begin 7998 Result := (Y >= TopBarHeight + MapHeight) or (Y >= ClientHeight - PanelHeight) 7999 and ((X < xMidPanel) or (X >= xRightPanel)); 7610 8000 end; 7611 8001 7612 8002 procedure TMainScreen.FormMouseDown(Sender: TObject; Button: TMouseButton; 7613 Shift: TShiftState; x, y: integer);7614 begin 7615 if idle then7616 if ( x < 40) and (y< 40) then8003 Shift: TShiftState; X, Y: Integer); 8004 begin 8005 if Idle then 8006 if (X < 40) and (Y < 40) then 7617 8007 begin 7618 8008 if GameMode <> cMovie then … … 7626 8016 end; 7627 8017 end 7628 else if IsPanelPixel( x, y) then7629 PanelBoxMouseDown(Sender, Button, Shift, x,7630 y- (ClientHeight - PanelHeight))7631 else if ( y >= TopBarHeight) and (x>= MapOffset) and7632 ( x< MapOffset + MapWidth) then7633 MapBoxMouseDown(Sender, Button, Shift, x - MapOffset, y- TopBarHeight)8018 else if IsPanelPixel(X, Y) then 8019 PanelBoxMouseDown(Sender, Button, Shift, X, 8020 Y - (ClientHeight - PanelHeight)) 8021 else if (Y >= TopBarHeight) and (X >= MapOffset) and 8022 (X < MapOffset + MapWidth) then 8023 MapBoxMouseDown(Sender, Button, Shift, X - MapOffset, Y - TopBarHeight) 7634 8024 end; 7635 8025 7636 8026 procedure TMainScreen.FormMouseMove(Sender: TObject; Shift: TShiftState; 7637 x, y: integer);7638 begin 7639 if idle then7640 if IsPanelPixel( x, y) then7641 PanelBoxMouseMove(Sender, Shift, x, y- (ClientHeight - PanelHeight))7642 else if ( y >= TopBarHeight) and (x>= MapOffset) and7643 ( x< MapOffset + MapWidth) then7644 MapBoxMouseMove(Sender, Shift, x - MapOffset, y- TopBarHeight);8027 X, Y: Integer); 8028 begin 8029 if Idle then 8030 if IsPanelPixel(X, Y) then 8031 PanelBoxMouseMove(Sender, Shift, X, Y - (ClientHeight - PanelHeight)) 8032 else if (Y >= TopBarHeight) and (X >= MapOffset) and 8033 (X < MapOffset + MapWidth) then 8034 MapBoxMouseMove(Sender, Shift, X - MapOffset, Y - TopBarHeight); 7645 8035 end; 7646 8036 7647 8037 procedure TMainScreen.FormMouseUp(Sender: TObject; Button: TMouseButton; 7648 Shift: TShiftState; x, y: integer);7649 begin 7650 if idle then7651 PanelBoxMouseUp(Sender, Button, Shift, x, y- (ClientHeight - PanelHeight));8038 Shift: TShiftState; X, Y: Integer); 8039 begin 8040 if Idle then 8041 PanelBoxMouseUp(Sender, Button, Shift, X, Y - (ClientHeight - PanelHeight)); 7652 8042 end; 7653 8043 … … 7658 8048 with Canvas do 7659 8049 begin // pillarbox, make left and right border black 7660 if me < 0 then8050 if Me < 0 then 7661 8051 Brush.Color := $000000 7662 8052 else … … 7684 8074 Brush.Style := bsClear; 7685 8075 end; 7686 DpiBit Canvas(Canvas, MapOffset, TopBarHeight, MapWidth, MapHeight - overlap,7687 offscreen.Canvas, 0, 0);7688 DpiBit Canvas(Canvas, 0, 0, ClientWidth, TopBarHeight, TopBar.Canvas,8076 DpiBitBltCanvas(Canvas, MapOffset, TopBarHeight, MapWidth, MapHeight - overlap, 8077 Offscreen.Canvas, 0, 0); 8078 DpiBitBltCanvas(Canvas, 0, 0, ClientWidth, TopBarHeight, TopBar.Canvas, 7689 8079 0, 0); 7690 8080 if xMidPanel > MapOffset then 7691 DpiBit Canvas(Canvas, xMidPanel, TopBarHeight + MapHeight - overlap,7692 ClientWidth div 2 - xMidPanel, overlap, offscreen.Canvas,8081 DpiBitBltCanvas(Canvas, xMidPanel, TopBarHeight + MapHeight - overlap, 8082 ClientWidth div 2 - xMidPanel, overlap, Offscreen.Canvas, 7693 8083 xMidPanel - MapOffset, MapHeight - overlap) 7694 8084 else 7695 DpiBit Canvas(Canvas, MapOffset, TopBarHeight + MapHeight - overlap,7696 ClientWidth div 2 - MapOffset, overlap, offscreen.Canvas, 0,8085 DpiBitBltCanvas(Canvas, MapOffset, TopBarHeight + MapHeight - overlap, 8086 ClientWidth div 2 - MapOffset, overlap, Offscreen.Canvas, 0, 7697 8087 MapHeight - overlap); 7698 8088 if xRightPanel < MapOffset + MapWidth then 7699 DpiBit Canvas(Canvas, ClientWidth div 2, TopBarHeight + MapHeight - overlap,7700 xRightPanel - ClientWidth div 2, overlap, offscreen.Canvas,8089 DpiBitBltCanvas(Canvas, ClientWidth div 2, TopBarHeight + MapHeight - overlap, 8090 xRightPanel - ClientWidth div 2, overlap, Offscreen.Canvas, 7701 8091 ClientWidth div 2 - MapOffset, MapHeight - overlap) 7702 8092 else 7703 DpiBit Canvas(Canvas, ClientWidth div 2, TopBarHeight + MapHeight - overlap,8093 DpiBitBltCanvas(Canvas, ClientWidth div 2, TopBarHeight + MapHeight - overlap, 7704 8094 MapOffset + MapWidth - ClientWidth div 2, overlap, 7705 offscreen.Canvas, ClientWidth div 2 - MapOffset,8095 Offscreen.Canvas, ClientWidth div 2 - MapOffset, 7706 8096 MapHeight - overlap); 7707 DpiBit Canvas(Canvas, 0, TopBarHeight + MapHeight - overlap, xMidPanel,8097 DpiBitBltCanvas(Canvas, 0, TopBarHeight + MapHeight - overlap, xMidPanel, 7708 8098 overlap, Panel.Canvas, 0, 0); 7709 DpiBit Canvas(Canvas, xRightPanel, TopBarHeight + MapHeight - overlap,8099 DpiBitBltCanvas(Canvas, xRightPanel, TopBarHeight + MapHeight - overlap, 7710 8100 Panel.width - xRightPanel, overlap, Panel.Canvas, xRightPanel, 0); 7711 DpiBit Canvas(Canvas, 0, TopBarHeight + MapHeight, Panel.width,8101 DpiBitBltCanvas(Canvas, 0, TopBarHeight + MapHeight, Panel.width, 7712 8102 PanelHeight - overlap, Panel.Canvas, 0, overlap); 7713 8103 if (pLogo >= 0) and (G.RO[pLogo] = nil) and (AILogo[pLogo] <> nil) then 7714 DpiBit Canvas(Canvas, xRightPanel + 10 - (16 + 64),8104 DpiBitBltCanvas(Canvas, xRightPanel + 10 - (16 + 64), 7715 8105 ClientHeight - PanelHeight, 64, 64, AILogo[pLogo].Canvas, 0, 0); 7716 8106 end; 7717 8107 7718 procedure TMainScreen.RectInvalidate(Left, Top, Rigth, Bottom: integer);8108 procedure TMainScreen.RectInvalidate(Left, Top, Rigth, Bottom: Integer); 7719 8109 var 7720 8110 r0: HRgn; 7721 8111 begin 7722 8112 r0 := DpiCreateRectRgn(Left, Top, Rigth, Bottom); 7723 InvalidateRgn(Handle, r0, false);8113 InvalidateRgn(Handle, r0, False); 7724 8114 DeleteObject(r0); 7725 8115 end; 7726 8116 7727 procedure TMainScreen.SmartRectInvalidate(Left, Top, Rigth, Bottom: integer);8117 procedure TMainScreen.SmartRectInvalidate(Left, Top, Rigth, Bottom: Integer); 7728 8118 var 7729 i: integer;8119 I: Integer; 7730 8120 r0, r1: HRgn; 7731 8121 begin 7732 8122 r0 := DpiCreateRectRgn(Left, Top, Rigth, Bottom); 7733 for i:= 0 to ControlCount - 1 do7734 if not(Controls[ i] is TArea) and Controls[i].Visible then8123 for I := 0 to ControlCount - 1 do 8124 if not(Controls[I] is TArea) and Controls[I].Visible then 7735 8125 begin 7736 with Controls[ i].BoundsRect do8126 with Controls[I].BoundsRect do 7737 8127 r1 := DpiCreateRectRgn(Left, Top, Right, Bottom); 7738 8128 CombineRgn(r0, r0, r1, RGN_DIFF); 7739 8129 DeleteObject(r1); 7740 8130 end; 7741 InvalidateRgn(Handle, r0, false);8131 InvalidateRgn(Handle, r0, False); 7742 8132 DeleteObject(r0); 7743 8133 end; … … 7804 8194 procedure TMainScreen.FormClose(Sender: TObject; var Action: TCloseAction); 7805 8195 begin 7806 Timer1.Enabled := false;8196 Timer1.Enabled := False; 7807 8197 end; 7808 8198 7809 8199 procedure TMainScreen.Radio(Sender: TObject); 7810 8200 begin 7811 TDpiMenuItem(Sender).Checked := true;8201 TDpiMenuItem(Sender).Checked := True; 7812 8202 end; 7813 8203 7814 8204 procedure TMainScreen.mManipClick(Sender: TObject); 7815 8205 var 7816 Flag: integer;8206 Flag: Integer; 7817 8207 begin 7818 8208 with TDpiMenuItem(Sender) do … … 7826 8216 Play('CHEAT'); 7827 8217 end; 7828 if not supervising then8218 if not Supervising then 7829 8219 begin 7830 8220 if Flag = tfUncover then 7831 8221 begin 7832 MapValid := false;8222 MapValid := False; 7833 8223 PaintAllMaps; 7834 8224 end … … 7854 8244 else 7855 8245 begin 7856 MapValid := false;8246 MapValid := False; 7857 8247 PaintAllMaps; 7858 8248 end; // update main map … … 7873 8263 end; 7874 8264 SetMapOptions; 7875 MapValid := false;8265 MapValid := False; 7876 8266 PaintAllMaps; 7877 8267 end; … … 7891 8281 end; 7892 8282 SetMapOptions; 7893 MapValid := false;8283 MapValid := False; 7894 8284 PaintAllMaps; 7895 8285 end; 7896 8286 7897 procedure TMainScreen.FormKeyUp(Sender: TObject; var Key: word;8287 procedure TMainScreen.FormKeyUp(Sender: TObject; var Key: Word; 7898 8288 Shift: TShiftState); 7899 8289 begin 7900 if idle and (Key = VK_APPS) then8290 if Idle and (Key = VK_APPS) then 7901 8291 begin 7902 8292 InitPopup(GamePopup); … … 7906 8296 GamePopup.Popup(Left + 4, Top + DpiGetSystemMetrics(SM_CYCAPTION) + 4 + 7907 8297 TopBarHeight - 1); 7908 exit;8298 Exit; 7909 8299 end; // windows menu button calls game menu 7910 8300 end; … … 7912 8302 procedure TMainScreen.CreateUnitClick(Sender: TObject); 7913 8303 var 7914 p1, mix: integer;8304 p1, mix: Integer; 7915 8305 begin 7916 8306 p1 := TComponent(Sender).Tag shr 16; 7917 8307 mix := TComponent(Sender).Tag and $FFFF; 7918 if Server(sCreateUnit + p1 shl 4, me, mix, EditLoc) >= rExecuted then8308 if Server(sCreateUnit + p1 shl 4, Me, mix, EditLoc) >= rExecuted then 7919 8309 PaintLoc(EditLoc); 7920 8310 end; … … 7934 8324 SoundMode := smOnAlt; 7935 8325 end; 7936 7937 { procedure TMainScreen.AdviceBtnClick;7938 var7939 OldAdviceLoc: integer;7940 begin7941 DestinationMarkON:=false;7942 PaintDestination;7943 AdvisorDlg.GiveStrategyAdvice;7944 OldAdviceLoc:=MainMap.AdviceLoc;7945 MainMap.AdviceLoc:=-1;7946 PaintLoc(OldAdviceLoc);7947 end; }7948 7949 { procedure TMainScreen.SetAdviceLoc(Loc: integer; AvoidRect: TRect);7950 var7951 OldAdviceLoc,x,y: integer;7952 begin7953 if Loc<>MainMap.AdviceLoc then7954 begin7955 if Loc>=0 then7956 begin // center7957 y:=Loc div G.lx;7958 x:=(Loc+G.lx - AvoidRect.Right div (2*66)) mod G.lx;7959 Centre(y*G.lx+x);7960 PaintAllMaps;7961 end;7962 OldAdviceLoc:=MainMap.AdviceLoc;7963 MainMap.AdviceLoc:=Loc;7964 PaintLoc(OldAdviceLoc);7965 PaintLoc(MainMap.AdviceLoc);7966 end;7967 end; }7968 8326 7969 8327 procedure TMainScreen.UnitInfoBtnClick(Sender: TObject); … … 8004 8362 8005 8363 procedure TMainScreen.SetTileSize(TileSize: TTileSize; Loc: Integer; MapPos: TPoint); 8006 var8007 i: integer;8008 8364 begin 8009 8365 MainMap.TileSize := TileSize; … … 8012 8368 SetMapPos(Loc, MapPos); 8013 8369 PaintAllMaps; 8014 for i := 0 to DpiScreen.FormCount - 1 do 8015 if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then 8016 TBufferedDrawDlg(DpiScreen.Forms[i]).SmartUpdateContent(false); 8370 ApplyToVisibleForms(faSmartUpdateContent); 8017 8371 end; 8018 8372 8019 8373 procedure TMainScreen.SaveMenuItemsState; 8020 8374 var 8021 i, j: integer;8375 I, J: Integer; 8022 8376 begin 8023 8377 if soTellAI in OptionChecked then OptionChecked := [soTellAI] 8024 8378 else OptionChecked := []; 8025 for i:= 0 to ComponentCount - 1 do8026 if Components[ i] is TDpiMenuItem then8027 for j:= 0 to Length(SaveOption) - 1 do8028 if TDpiMenuItem(Components[ i]).Checked and8029 (TDpiMenuItem(Components[ i]).Tag = SaveOption[j]) then8030 OptionChecked := OptionChecked + [TSaveOption( j)];8379 for I := 0 to ComponentCount - 1 do 8380 if Components[I] is TDpiMenuItem then 8381 for J := 0 to Length(SaveOption) - 1 do 8382 if TDpiMenuItem(Components[I]).Checked and 8383 (TDpiMenuItem(Components[I]).Tag = SaveOption[J]) then 8384 OptionChecked := OptionChecked + [TSaveOption(J)]; 8031 8385 end; 8032 8386 … … 8040 8394 with Reg do 8041 8395 try 8042 OpenKey(AppRegistryKey, true);8396 OpenKey(AppRegistryKey, True); 8043 8397 WriteInteger('TileSize', Integer(MainMap.TileSize)); 8044 8398 WriteInteger('OptionChecked', Integer(OptionChecked)); 8045 8399 WriteInteger('MapOptionChecked', Integer(MapOptionChecked)); 8046 WriteInteger('CityReport', integer(CityRepMask));8400 WriteInteger('CityReport', Integer(CityRepMask)); 8047 8401 finally 8048 8402 Free; … … 8056 8410 end; 8057 8411 8412 procedure TMainScreen.ArrangeDialogs; 8413 begin 8414 ArrangeDialog(FListDlg); 8415 ArrangeDialog(FHelpDlg); 8416 ArrangeDialog(FUnitStatDlg); 8417 ArrangeDialog(FDiaDlg); 8418 ArrangeDialog(FNatStatDlg); 8419 end; 8420 8421 procedure TMainScreen.ArrangeDialog(Form: TBufferedDrawDlg); 8422 begin 8423 if not Assigned(Form) then Exit; 8424 8425 if Form is TListDlg then begin; 8426 ListDlg.UserLeft := 8; 8427 ListDlg.UserTop := TopBarHeight + 8; 8428 end; 8429 if Form is THelpDlg then begin 8430 HelpDlg.UserLeft := DpiScreen.Width - HelpDlg.Width - 8; 8431 HelpDlg.UserTop := TopBarHeight + 8; 8432 end; 8433 if Form is TUnitStatDlg then begin 8434 UnitStatDlg.UserLeft := 397; 8435 UnitStatDlg.UserTop := TopBarHeight + 64; 8436 end; 8437 if Form is TDiaDlg then begin 8438 DiaDlg.UserLeft := (DpiScreen.Width - DiaDlg.Width) div 2; 8439 DiaDlg.UserTop := (DpiScreen.Height - DiaDlg.Height) div 2; 8440 end; 8441 if Form is TNatStatDlg then begin 8442 NatStatDlg.UserLeft := DpiScreen.Width - NatStatDlg.Width - 8; 8443 NatStatDlg.UserTop := DpiScreen.Height - PanelHeight - NatStatDlg.Height - 8; 8444 if NatStatDlg.UserTop < 8 then 8445 NatStatDlg.UserTop := 8; 8446 end; 8447 end; 8448 8058 8449 procedure TMainScreen.ScrollBarUpdate(Sender: TObject); 8059 8450 begin -
TabularUnified branches/highdpi/LocalPlayer/Tribes.pas ¶
r349 r465 6 6 uses 7 7 Protocol, ScreenTools, LazFileUtils, Classes, Graphics, SysUtils, Global, 8 UGraphicSet;8 GraphicSet; 9 9 10 10 type … … 20 20 yShield: Integer; 21 21 end; 22 23 { TModelPictureInfo } 22 24 23 25 TModelPictureInfo = record … … 27 29 Hash: Integer; 28 30 GrName: ShortString; 31 function GetCommandDataSize: Byte; 29 32 end; 30 33 … … 46 49 constructor Create(FileName: string); 47 50 destructor Destroy; override; 48 function GetCityName( i: Integer): string;49 {$IFNDEF SCR} procedure SetCityName( i: Integer; NewName: string); {$ENDIF}51 function GetCityName(I: Integer): string; 52 {$IFNDEF SCR} procedure SetCityName(I: Integer; NewName: string); {$ENDIF} 50 53 {$IFNDEF SCR} function TString(Template: string): string; 51 54 function TPhrase(Item: string): string; {$ENDIF} … … 69 72 function CityName(Founder: Integer): string; 70 73 function ModelCode(const ModelInfo: TModelInfo): Integer; 71 procedure FindStdModelPicture(Code: Integer; var pix: Integer; varName: string);74 procedure FindStdModelPicture(Code: Integer; out pix: Integer; out Name: string); 72 75 function GetTribeInfo(FileName: string; var Name: string; var Color: TColor): Boolean; 73 procedure FindPosition(HGr: TGraphicSet; x, y, xmax, ymax: Integer; Mark: TColor;76 procedure FindPosition(HGr: TGraphicSet; X, Y, xmax, ymax: Integer; Mark: TColor; 74 77 var xp, yp: Integer); 75 78 … … 212 215 function Get: string; 213 216 var 214 p: Integer;217 P: Integer; 215 218 begin 216 219 while (Input <> '') and ((Input[1] = ' ') or (Input[1] = #9)) do 217 220 Delete(Input, 1, 1); 218 p:= Pos(',', Input);219 if p= 0 then220 p:= Length(Input) + 1;221 Result := Copy(Input, 1, p- 1);222 Delete(Input, 1, p);221 P := Pos(',', Input); 222 if P = 0 then 223 P := Length(Input) + 1; 224 Result := Copy(Input, 1, P - 1); 225 Delete(Input, 1, P); 223 226 end; 224 227 225 228 function GetNum: Integer; 226 229 var 227 i: Integer;228 begin 229 Val(Get, Result, i);230 if i<> 0 then230 I: Integer; 231 begin 232 Val(Get, Result, I); 233 if I <> 0 then 231 234 Result := 0; 232 235 end; 233 236 234 procedure FindStdModelPicture(Code: Integer; var pix: Integer; varName: string);235 var 236 i: Integer;237 begin 238 for i:= 0 to StdUnitScript.Count - 1 do237 procedure FindStdModelPicture(Code: Integer; out pix: Integer; out Name: string); 238 var 239 I: Integer; 240 begin 241 for I := 0 to StdUnitScript.Count - 1 do 239 242 begin // look through StdUnits 240 Input := StdUnitScript[ i];243 Input := StdUnitScript[I]; 241 244 pix := GetNum; 242 245 if Code = GetNum then … … 281 284 CloseFile(TribeScript); 282 285 Result := Found = 3; 286 end; 287 288 { TModelPictureInfo } 289 290 function TModelPictureInfo.GetCommandDataSize: Byte; 291 begin 292 Result := SizeOf(trix) + SizeOf(mix) + SizeOf(pix) + SizeOf(Hash) + 1 + 293 Length(GrName); 283 294 end; 284 295 … … 329 340 end; 330 341 331 procedure FindPosition(HGr: TGraphicSet; x, y, xmax, ymax: Integer; Mark: TColor;342 procedure FindPosition(HGr: TGraphicSet; X, Y, xmax, ymax: Integer; Mark: TColor; 332 343 var xp, yp: Integer); 333 344 begin 334 345 xp := 0; 335 while (xp < xmax) and (HGr.Data.Canvas.Pixels[ x + 1 + xp, y] <> Mark) do346 while (xp < xmax) and (HGr.Data.Canvas.Pixels[X + 1 + xp, Y] <> Mark) do 336 347 Inc(xp); 337 348 yp := 0; 338 while (yp < ymax) and (HGr.Data.Canvas.Pixels[ x, y+ 1 + yp] <> Mark) do349 while (yp < ymax) and (HGr.Data.Canvas.Pixels[X, Y + 1 + yp] <> Mark) do 339 350 Inc(yp); 340 351 end; 341 352 342 function TTribe.GetCityName( i: Integer): string;353 function TTribe.GetCityName(I: Integer): string; 343 354 begin 344 355 Result := ''; 345 if nCityLines > ithen346 begin 347 Result := Script[CityLine0 + i];356 if nCityLines > I then 357 begin 358 Result := Script[CityLine0 + I]; 348 359 while (Result <> '') and ((Result[1] = ' ') or (Result[1] = #9)) do 349 360 Delete(Result, 1, 1); … … 351 362 {$IFNDEF SCR} 352 363 else 353 Result := Format(TPhrase('GENCITY'), [ i+ 1]);364 Result := Format(TPhrase('GENCITY'), [I + 1]); 354 365 {$ENDIF} 355 366 end; 356 367 357 368 {$IFNDEF SCR} 358 procedure TTribe.SetCityName( i: Integer; NewName: string);359 begin 360 while nCityLines <= ido369 procedure TTribe.SetCityName(I: Integer; NewName: string); 370 begin 371 while nCityLines <= I do 361 372 begin 362 373 Script.Insert(CityLine0 + nCityLines, Format(TPhrase('GENCITY'), … … 364 375 Inc(nCityLines); 365 376 end; 366 Script[CityLine0 + i] := NewName;377 Script[CityLine0 + I] := NewName; 367 378 end; 368 379 369 380 function TTribe.TString(Template: string): string; 370 381 var 371 p: Integer;382 P: Integer; 372 383 Variant: Char; 373 384 CaseUp: Boolean; 374 385 begin 375 386 repeat 376 p := pos('#', Template);377 if ( p = 0) or (p= Length(Template)) then387 P := Pos('#', Template); 388 if (P = 0) or (P = Length(Template)) then 378 389 Break; 379 Variant := Template[ p+ 1];390 Variant := Template[P + 1]; 380 391 CaseUp := Variant in ['A' .. 'Z']; 381 392 if CaseUp then 382 393 Inc(Variant, 32); 383 Delete(Template, p, 2);394 Delete(Template, P, 2); 384 395 if Variant in ['a' .. 'z'] then 385 396 begin 386 397 if NumberName < 0 then 387 Insert(Name[Variant], Template, p)398 Insert(Name[Variant], Template, P) 388 399 else 389 Insert(Format('P%d', [NumberName]), Template, p);390 if CaseUp and (Length(Template) >= p) and391 (Template[ p] in ['a' .. 'z', #$E0 .. #$FF]) then392 Dec(Template[ p], 32);400 Insert(Format('P%d', [NumberName]), Template, P); 401 if CaseUp and (Length(Template) >= P) and 402 (Template[P] in ['a' .. 'z', #$E0 .. #$FF]) then 403 Dec(Template[P], 32); 393 404 end 394 405 until False; … … 407 418 TLine = array [0 .. 649, 0 .. 2] of Byte; 408 419 var 409 i, x, Gray: Integer;420 I, X, Gray: Integer; 410 421 Item: string; 411 422 begin … … 415 426 with Script do 416 427 begin 417 i:= 0;418 while ( i < Count) and (Copy(Strings[i], 1, 6) <>428 I := 0; 429 while (I < Count) and (Copy(Strings[I], 1, 6) <> 419 430 '#AGE' + char(48 + Age) + ' ') do 420 Inc( i);421 if i< Count then422 begin 423 Input := Strings[ i];431 Inc(I); 432 if I < Count then 433 begin 434 Input := Strings[I]; 424 435 system.Delete(Input, 1, 6); 425 436 Item := Get; … … 430 441 if CompareText(Item, 'stdcities') = 0 then 431 442 case cpix of 432 3: 433 cpix := 0; 434 6: 435 begin 443 3: cpix := 0; 444 6: begin 436 445 cpix := 0; 437 446 Item := 'Nation2'; 438 end 447 end; 439 448 end; 440 449 cHGr := LoadGraphicSet(Item + '.png'); 441 for x := 0 to 3 do 442 with CityPicture[x] do 443 begin 444 FindPosition(cHGr, x * 65, cpix * 49, 63, 47, $00FFFF, 450 for X := 0 to 3 do 451 with CityPicture[X] do begin 452 FindPosition(cHGr, X * 65, cpix * 49, 63, 47, $00FFFF, 445 453 xShield, yShield); 446 454 // FindPosition(cHGr,x*65,cpix*49,$FFFFFF,xf,yf); … … 478 486 procedure TTribe.SetModelPicture(const Info: TModelPictureInfo; IsNew: Boolean); 479 487 var 480 i: Integer;488 I: Integer; 481 489 ok: Boolean; 482 490 begin … … 485 493 if not IsNew then 486 494 begin 487 i:= nPictureList - 1;488 while ( i >= 0) and (PictureList[i].Hash <> Info.Hash) do489 Dec( i);490 assert(i>= 0);491 assert(PictureList[i].HGr = LoadGraphicSet(GrName));492 assert(PictureList[i].pix = pix);493 ModelPicture[mix].HGr := PictureList[ i].HGr;494 ModelPicture[mix].pix := PictureList[ i].pix;495 ModelName[mix] := PictureList[ i].ModelName;495 I := nPictureList - 1; 496 while (I >= 0) and (PictureList[I].Hash <> Info.Hash) do 497 Dec(I); 498 Assert(I >= 0); 499 Assert(PictureList[I].HGr = LoadGraphicSet(GrName)); 500 Assert(PictureList[I].pix = pix); 501 ModelPicture[mix].HGr := PictureList[I].HGr; 502 ModelPicture[mix].pix := PictureList[I].pix; 503 ModelName[mix] := PictureList[I].ModelName; 496 504 end 497 505 else … … 507 515 // read model name from tribe script 508 516 ok := False; 509 for i:= 0 to Script.Count - 1 do510 begin 511 Input := Script[ i];517 for I := 0 to Script.Count - 1 do 518 begin 519 Input := Script[I]; 512 520 if Input = '#UNITS ' + ExtractFileNameOnly(GrName) then 513 521 ok := True … … 523 531 if ModelName[mix] = '' then 524 532 begin // read model name from StdUnits.txt 525 for i:= 0 to StdUnitScript.Count - 1 do533 for I := 0 to StdUnitScript.Count - 1 do 526 534 begin 527 Input := StdUnitScript[ i];535 Input := StdUnitScript[I]; 528 536 if GetNum = pix then 529 537 begin … … 559 567 Code, Turn: Integer; ForceNew: Boolean): Boolean; 560 568 var 561 i: Integer;569 I: Integer; 562 570 Cnt: Integer; 563 571 HGr: TGraphicSet; … … 598 606 if not ForceNew and (Picture.Hash > 0) then 599 607 begin 600 for i:= 0 to nPictureList - 1 do601 if PictureList[ i].Hash = Picture.Hash then602 begin 603 Picture.GrName := PictureList[ i].HGr.Name;604 Picture.pix := PictureList[ i].pix;608 for I := 0 to nPictureList - 1 do 609 if PictureList[I].Hash = Picture.Hash then 610 begin 611 Picture.GrName := PictureList[I].HGr.Name; 612 Picture.pix := PictureList[I].pix; 605 613 Result := False; 606 614 Exit; … … 614 622 TestPic.GrName := 'StdUnits.png'; 615 623 HGr := HGrStdUnits; 616 for i:= 0 to StdUnitScript.Count - 1 do624 for I := 0 to StdUnitScript.Count - 1 do 617 625 begin // look through StdUnits 618 Input := StdUnitScript[ i];626 Input := StdUnitScript[I]; 619 627 Check; 620 628 end; 621 629 622 630 ok := False; 623 for i:= 0 to Script.Count - 1 do631 for I := 0 to Script.Count - 1 do 624 632 begin // look through units defined in tribe script 625 Input := Script[ i];633 Input := Script[I]; 626 634 if Copy(Input, 1, 6) = '#UNITS' then 627 635 begin -
TabularUnified branches/highdpi/LocalPlayer/UnitStat.pas ¶
r405 r465 5 5 6 6 uses 7 UDpiControls, Protocol, ClientTools, Term, ScreenTools, BaseWin, 8 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, 9 ButtonB, ButtonC, IsoEngine; 7 UDpiControls, Protocol, ClientTools, ScreenTools, BaseWin, LCLIntf, LCLType, SysUtils, 8 Classes, Graphics, Controls, Forms, ButtonB, ButtonC, IsoEngine; 10 9 11 10 type 11 TUnitStatDialogKind = (dkOwnModel, dkOwnUnit, dkEnemyModel, dkEnemyUnit, 12 dkEnemyCityDefense, dkEnemyCity); 13 12 14 TUnitStatDlg = class(TBufferedDrawDlg) 13 15 SwitchBtn: TButtonB; … … 26 28 private 27 29 NoMap: TIsoMap; 30 protected 31 mixShow, // for dkOwnModel 32 uixShow, euixShow, ecixShow, UnitLoc, AgePrepared: Integer; 33 // for dkEnemyUnit, euixShow=-1 -> 34 mox: ^TModelInfo; // for dkEnemyModel 35 Kind: TUnitStatDialogKind; 36 Back: TDpiBitmap; 37 Template: TDpiBitmap; 38 procedure OffscreenPaint; override; 28 39 public 29 40 procedure CheckAge; 30 procedure ShowNewContent_OwnModel(NewMode, mix: integer); 31 procedure ShowNewContent_OwnUnit(NewMode, uix: integer); 32 procedure ShowNewContent_EnemyUnit(NewMode, euix: integer); 33 procedure ShowNewContent_EnemyLoc(NewMode, Loc: integer); 34 procedure ShowNewContent_EnemyModel(NewMode, emix: integer); 35 procedure ShowNewContent_EnemyCity(NewMode, Loc: integer); 36 37 protected 38 mixShow, // for dkOwnModel 39 uixShow, euixShow, ecixShow, UnitLoc, AgePrepared: integer; 40 // for dkEnemyUnit, euixShow=-1 -> 41 mox: ^TModelInfo; // for dkEnemyModel 42 Kind: (dkOwnModel, dkOwnUnit, dkEnemyModel, dkEnemyUnit, dkEnemyCityDefense, 43 dkEnemyCity); 44 Back, Template: TDpiBitmap; 45 procedure OffscreenPaint; override; 46 end; 47 48 var 49 UnitStatDlg: TUnitStatDlg; 41 procedure ShowNewContent_OwnModel(NewMode: TWindowMode; mix: Integer); 42 procedure ShowNewContent_OwnUnit(NewMode: TWindowMode; uix: Integer); 43 procedure ShowNewContent_EnemyUnit(NewMode: TWindowMode; euix: Integer); 44 procedure ShowNewContent_EnemyLoc(NewMode: TWindowMode; Loc: Integer); 45 procedure ShowNewContent_EnemyModel(NewMode: TWindowMode; emix: Integer); 46 procedure ShowNewContent_EnemyCity(NewMode: TWindowMode; Loc: Integer); 47 end; 48 50 49 51 50 implementation 52 51 53 52 uses 54 T ribes, Help, Directories, UTexture;53 Term, Tribes, Help, Directories, Texture; 55 54 56 55 {$R *.lfm} … … 82 81 Back.PixelFormat := pf24bit; 83 82 Back.SetSize(5 * wCommon, hMax); 84 Back.Canvas.FillRect(0, 0, Back.Width, Back.Height);83 Back.Canvas.FillRect(0, 0, Back.Width, Back.Height); 85 84 Template := TDpiBitmap.Create; 86 85 Template.PixelFormat := pf24bit; … … 100 99 if MainTexture.Age <> AgePrepared then begin 101 100 AgePrepared := MainTexture.Age; 102 DpiBit Canvas(Back.Canvas, 0, 0, wCommon, hOwnModel,101 DpiBitBltCanvas(Back.Canvas, 0, 0, wCommon, hOwnModel, 103 102 MainTexture.Image.Canvas, (MainTexture.Width - wCommon) div 2, 104 103 (MainTexture.Height - hOwnModel) div 2); 105 DpiBit Canvas(Back.Canvas, wCommon, 0, wCommon, hEnemyModel,104 DpiBitBltCanvas(Back.Canvas, wCommon, 0, wCommon, hEnemyModel, 106 105 MainTexture.Image.Canvas, (MainTexture.Width - wCommon) div 2, 107 106 (MainTexture.Height - hEnemyModel) div 2); 108 DpiBit Canvas(Back.Canvas, 2 * wCommon, 0, wCommon, hEnemyUnit,107 DpiBitBltCanvas(Back.Canvas, 2 * wCommon, 0, wCommon, hEnemyUnit, 109 108 MainTexture.Image.Canvas, (MainTexture.Width - wCommon) div 2, 110 109 (MainTexture.Height - hEnemyUnit) div 2); 111 DpiBit Canvas(Back.Canvas, 3 * wCommon, 0, wCommon, hEnemyCityDefense,110 DpiBitBltCanvas(Back.Canvas, 3 * wCommon, 0, wCommon, hEnemyCityDefense, 112 111 MainTexture.Image.Canvas, (MainTexture.Width - wCommon) div 2, 113 112 (MainTexture.Height - hEnemyCityDefense) div 2); 114 DpiBit Canvas(Back.Canvas, 4 * wCommon, 0, wCommon, hEnemyCity,113 DpiBitBltCanvas(Back.Canvas, 4 * wCommon, 0, wCommon, hEnemyCity, 115 114 MainTexture.Image.Canvas, (MainTexture.Width - wCommon) div 2, 116 115 (MainTexture.Height - hEnemyCity) div 2); … … 121 120 procedure TUnitStatDlg.FormShow(Sender: TObject); 122 121 var 123 owner, mix: integer;124 IsSpecialUnit: boolean;122 Owner, mix: Integer; 123 IsSpecialUnit: Boolean; 125 124 begin 126 125 if Kind in [dkEnemyUnit, dkEnemyCityDefense, dkEnemyCity] then … … 132 131 euixShow := MyRO.nEnemyUn - 1; 133 132 while (euixShow >= 0) and (MyRO.EnemyUn[euixShow].Loc <> UnitLoc) do 134 dec(euixShow);135 assert(euixShow >= 0);133 Dec(euixShow); 134 Assert(euixShow >= 0); 136 135 end; 137 136 with MyRO.EnemyUn[euixShow] do 138 137 begin 139 138 mox := @MyRO.EnemyModel[emix]; 140 if not Assigned(Tribe[ owner].ModelPicture[mix].HGr) then139 if not Assigned(Tribe[Owner].ModelPicture[mix].HGr) then 141 140 InitEnemyModel(emix); 142 end 141 end; 143 142 end 144 143 else … … 148 147 ecixShow := MyRO.nEnemyCity - 1; 149 148 while (ecixShow >= 0) and (MyRO.EnemyCity[ecixShow].Loc <> UnitLoc) do 150 dec(ecixShow);151 assert(ecixShow >= 0);149 Dec(ecixShow); 150 Assert(ecixShow >= 0); 152 151 end; 153 152 end; 154 153 case Kind of 155 dkOwnModel: 156 ClientHeight := hOwnModel; 157 dkOwnUnit: 158 ClientHeight := hEnemyUnit; 159 dkEnemyModel: 160 ClientHeight := hEnemyModel; 161 dkEnemyUnit: 162 ClientHeight := hEnemyUnit; 163 dkEnemyCityDefense: 164 ClientHeight := hEnemyCityDefense; 165 dkEnemyCity: 166 ClientHeight := hEnemyCity; 154 dkOwnModel: ClientHeight := hOwnModel; 155 dkOwnUnit: ClientHeight := hEnemyUnit; 156 dkEnemyModel: ClientHeight := hEnemyModel; 157 dkEnemyUnit: ClientHeight := hEnemyUnit; 158 dkEnemyCityDefense: ClientHeight := hEnemyCityDefense; 159 dkEnemyCity: ClientHeight := hEnemyCity; 167 160 end; 168 161 … … 171 164 Left := UserLeft; 172 165 Top := UserTop; 173 end 174 else 175 begin 166 end else begin 176 167 Left := (DpiScreen.Width - Width) div 2; 177 168 Top := (DpiScreen.Height - Height) div 2; 178 169 end; 179 170 180 SwitchBtn.Visible := not supervising and (Kind = dkOwnModel);181 ConscriptsBtn.Visible := not supervising and (Kind = dkOwnModel) and171 SwitchBtn.Visible := not Supervising and (Kind = dkOwnModel); 172 ConscriptsBtn.Visible := not Supervising and (Kind = dkOwnModel) and 182 173 (MyRO.Tech[adConscription] >= tsApplicable) and 183 174 (MyModel[mixShow].Domain = dGround) and (MyModel[mixShow].Kind < mkScout); 184 IsSpecialUnit := false;175 IsSpecialUnit := False; 185 176 if Kind in [dkEnemyCity, dkEnemyCityDefense] then 186 177 Caption := CityName(MyRO.EnemyCity[ecixShow].ID) … … 188 179 begin 189 180 case Kind of 190 dkOwnModel: 191 begin 192 owner := me; 193 mix := mixShow; 194 IsSpecialUnit := MyModel[mix].Kind >= $10; 195 end; 196 dkOwnUnit: 197 begin 198 owner := me; 199 mix := MyUn[uixShow].mix; 200 IsSpecialUnit := MyModel[mix].Kind >= $10; 201 end 202 else 203 begin 204 owner := mox.owner; 181 dkOwnModel: begin 182 Owner := Me; 183 mix := mixShow; 184 IsSpecialUnit := MyModel[mix].Kind >= $10; 185 end; 186 dkOwnUnit: begin 187 Owner := Me; 188 mix := MyUn[uixShow].mix; 189 IsSpecialUnit := MyModel[mix].Kind >= $10; 190 end; 191 else begin 192 Owner := mox.Owner; 205 193 mix := mox.mix; 206 194 IsSpecialUnit := mox.Kind >= $10; … … 218 206 end; 219 207 220 procedure TUnitStatDlg.ShowNewContent_OwnModel(NewMode , mix: integer);208 procedure TUnitStatDlg.ShowNewContent_OwnModel(NewMode: TWindowMode; mix: Integer); 221 209 begin 222 210 Kind := dkOwnModel; … … 225 213 end; 226 214 227 procedure TUnitStatDlg.ShowNewContent_OwnUnit(NewMode , uix: integer);215 procedure TUnitStatDlg.ShowNewContent_OwnUnit(NewMode: TWindowMode; uix: Integer); 228 216 begin 229 217 Kind := dkOwnUnit; … … 232 220 end; 233 221 234 procedure TUnitStatDlg.ShowNewContent_EnemyUnit(NewMode , euix: integer);222 procedure TUnitStatDlg.ShowNewContent_EnemyUnit(NewMode: TWindowMode; euix: Integer); 235 223 begin 236 224 Kind := dkEnemyUnit; … … 240 228 end; 241 229 242 procedure TUnitStatDlg.ShowNewContent_EnemyLoc(NewMode , Loc: integer);230 procedure TUnitStatDlg.ShowNewContent_EnemyLoc(NewMode: TWindowMode; Loc: Integer); 243 231 begin 244 232 Kind := dkEnemyUnit; … … 248 236 end; 249 237 250 procedure TUnitStatDlg.ShowNewContent_EnemyModel(NewMode , emix: integer);238 procedure TUnitStatDlg.ShowNewContent_EnemyModel(NewMode: TWindowMode; emix: Integer); 251 239 begin 252 240 Kind := dkEnemyModel; … … 255 243 end; 256 244 257 procedure TUnitStatDlg.ShowNewContent_EnemyCity(NewMode , Loc: integer);245 procedure TUnitStatDlg.ShowNewContent_EnemyCity(NewMode: TWindowMode; Loc: Integer); 258 246 begin 259 247 if MyMap[Loc] and fUnit <> 0 then … … 271 259 begin 272 260 UserLeft := Left; 273 UserTop := Top 274 end; 275 if OffscreenUser = self then261 UserTop := Top; 262 end; 263 if OffscreenUser = Self then 276 264 OffscreenUser := nil; 277 265 end; … … 286 274 PPicture: ^TModelPicture; 287 275 288 function IsToCount(emix: integer): boolean;276 function IsToCount(emix: Integer): Boolean; 289 277 var 290 278 PTestPicture: ^TModelPicture; … … 294 282 PTestPicture := @Tribe[MyRO.EnemyModel[emix].owner].ModelPicture 295 283 [MyRO.EnemyModel[emix].mix]; 296 result := (PPicture.HGr = PTestPicture.HGr) and284 Result := (PPicture.HGr = PTestPicture.HGr) and 297 285 (PPicture.pix = PTestPicture.pix) and 298 286 (ModelHash(mox^) = ModelHash(MyRO.EnemyModel[emix])); 299 287 end 300 288 else 301 result := (MyRO.EnemyModel[emix].owner = mox.owner) and289 Result := (MyRO.EnemyModel[emix].owner = mox.owner) and 302 290 (MyRO.EnemyModel[emix].mix = mox.mix); 303 291 end; 304 292 305 procedure FeatureBar(dst: TDpiBitmap; x, y: integer; const mi: TModelInfo;293 procedure FeatureBar(dst: TDpiBitmap; X, Y: Integer; const mi: TModelInfo; 306 294 T: TTexture); 307 295 var 308 i, w, dx, num: integer;309 s: string;310 begin 311 DarkGradient(dst.Canvas, x - 6, y+ 1, 180, 1);296 I, W, dx, num: Integer; 297 S: string; 298 begin 299 DarkGradient(dst.Canvas, X - 6, Y + 1, 180, 1); 312 300 with dst.Canvas do 313 301 if mi.Kind >= $10 then 314 302 begin 315 s:= Phrases.Lookup('UNITSPECIAL');303 S := Phrases.Lookup('UNITSPECIAL'); 316 304 Font.Color := $000000; 317 Textout( x - 1, y + 1, s);305 Textout(X - 1, Y + 1, S); 318 306 Font.Color := $B0B0B0; 319 Textout( x - 2, y, s);307 Textout(X - 2, Y, S); 320 308 end 321 309 else … … 323 311 Font.Color := $000000; 324 312 dx := 2; 325 for i:= 3 to nFeature - 1 do313 for I := 3 to nFeature - 1 do 326 314 begin 327 315 num := 0; 328 case iof316 case I of 329 317 mcSeaTrans: 330 318 if mi.Domain = dSea then … … 342 330 num := mi.TTrans; 343 331 mcFirstNonCap .. nFeature - 1: 344 if mi.Cap and (1 shl ( i- mcFirstNonCap)) <> 0 then345 num := 1 332 if mi.Cap and (1 shl (I - mcFirstNonCap)) <> 0 then 333 num := 1; 346 334 end; 347 335 if (num > 0) and 348 (( i<> mcSE) or (mi.Cap and (1 shl (mcNP - mcFirstNonCap)) = 0))336 ((I <> mcSE) or (mi.Cap and (1 shl (mcNP - mcFirstNonCap)) = 0)) 349 337 then 350 338 begin 351 339 if num > 1 then 352 340 begin 353 s:= IntToStr(num);354 w := TextWidth(s);341 S := IntToStr(num); 342 W := TextWidth(S); 355 343 Brush.Color := $FFFFFF; 356 FillRect(Rect( x - 3 + dx, y + 2, x + w - 1 + dx, y+ 16));344 FillRect(Rect(X - 3 + dx, Y + 2, X + W - 1 + dx, Y + 16)); 357 345 Brush.Style := bsClear; 358 Textout( x - 3 + dx + 1, y, s);359 inc(dx, w + 1)346 Textout(X - 3 + dx + 1, Y, S); 347 Inc(dx, W + 1); 360 348 end; 361 349 Brush.Color := $C0C0C0; 362 FrameRect(Rect( x - 3 + dx, y + 2, x + 11 + dx, y+ 16));350 FrameRect(Rect(X - 3 + dx, Y + 2, X + 11 + dx, Y + 16)); 363 351 Brush.Style := bsClear; 364 Sprite(dst, HGrSystem, x - 1 + dx, y+ 4, 10, 10,365 66 + i mod 11 * 11, 137 + idiv 11 * 11);366 inc(dx, 15)352 Sprite(dst, HGrSystem, X - 1 + dx, Y + 4, 10, 10, 353 66 + I mod 11 * 11, 137 + I div 11 * 11); 354 Inc(dx, 15); 367 355 end; 368 356 end; 369 357 end; 370 end; { featurebar }371 372 procedure NumberBarS(dst: TDpiBitmap; x, y: integer; Cap, s: string; T: TTexture);373 begin 374 DLine(dst.Canvas, x - 2, x + 170, y+ 16, T.ColorBevelShade, T.ColorBevelLight);375 LoweredTextOut(dst.Canvas, -1, T, x - 2, y, Cap);376 RisedTextout(dst.Canvas, x + 170 - BiColorTextWidth(dst.Canvas, s), y, s);358 end; 359 360 procedure NumberBarS(dst: TDpiBitmap; X, Y: Integer; Cap, S: string; T: TTexture); 361 begin 362 DLine(dst.Canvas, X - 2, X + 170, Y + 16, T.ColorBevelShade, T.ColorBevelLight); 363 LoweredTextOut(dst.Canvas, -1, T, X - 2, Y, Cap); 364 RisedTextout(dst.Canvas, X + 170 - BiColorTextWidth(dst.Canvas, S), Y, S); 377 365 end; 378 366 379 367 var 380 i, j, x, y, cix, uix, emix, InProd, Available, Destroyed, Loc, Cnt, yView,381 yTotal, yCaption: integer;382 s: string;368 I, J, X, Y, cix, uix, emix, InProd, Available, Destroyed, Loc, Cnt, yView, 369 yTotal, yCaption: Integer; 370 S: string; 383 371 ui: TUnitInfo; 384 372 mi: TModelInfo; … … 387 375 388 376 case Kind of 389 dkOwnModel: 390 begin 391 DpiBitCanvas(offscreen.Canvas, 0, 0, wCommon, hOwnModel, 392 Back.Canvas, 0, 0); 393 yView := 13; 394 yTotal := 92; 395 end; 396 dkEnemyModel: 397 begin 398 DpiBitCanvas(offscreen.Canvas, 0, 0, wCommon, hEnemyModel, 399 Back.Canvas, wCommon, 0); 400 yView := 13; 401 yTotal := 92; 402 end; 403 dkEnemyUnit, dkOwnUnit: 404 begin 405 DpiBitCanvas(offscreen.Canvas, 0, 0, wCommon, hEnemyUnit, 406 Back.Canvas, 2 * wCommon, 0); 407 yView := 13; 408 yTotal := 123; 409 end; 410 dkEnemyCityDefense: 411 begin 412 DpiBitCanvas(offscreen.Canvas, 0, 0, wCommon, hEnemyCityDefense, 413 Back.Canvas, 3 * wCommon, 0); 414 yView := 171; 415 yTotal := 231; 416 end; 417 dkEnemyCity: 418 begin 419 DpiBitCanvas(offscreen.Canvas, 0, 0, wCommon, hEnemyCity, 420 Back.Canvas, 4 * wCommon, 0); 421 end; 377 dkOwnModel: begin 378 DpiBitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hOwnModel, 379 Back.Canvas, 0, 0); 380 yView := 13; 381 yTotal := 92; 382 end; 383 dkEnemyModel: begin 384 DpiBitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyModel, 385 Back.Canvas, wCommon, 0); 386 yView := 13; 387 yTotal := 92; 388 end; 389 dkEnemyUnit, dkOwnUnit: begin 390 DpiBitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyUnit, 391 Back.Canvas, 2 * wCommon, 0); 392 yView := 13; 393 yTotal := 123; 394 end; 395 dkEnemyCityDefense: begin 396 DpiBitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyCityDefense, 397 Back.Canvas, 3 * wCommon, 0); 398 yView := 171; 399 yTotal := 231; 400 end; 401 dkEnemyCity: begin 402 DpiBitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyCity, 403 Back.Canvas, 4 * wCommon, 0); 404 end; 422 405 end; 423 406 MarkUsedOffscreen(ClientWidth, ClientHeight); … … 427 410 begin // show city defense facilities 428 411 Cnt := 0; 429 for i:= 0 to 3 do430 if MyRO.EnemyCity[ecixShow].Flags and (2 shl i) <> 0 then431 inc(Cnt);432 x:= (wCommon - Cnt * xSizeSmall) div 2 - (Cnt - 1) * 2;433 for i:= 0 to 3 do434 if MyRO.EnemyCity[ecixShow].Flags and (2 shl i) <> 0 then435 begin 436 case iof437 0: j:= imWalls;438 1: j:= imCoastalFort;439 2: j:= imMissileBat;440 3: j := imBunker412 for I := 0 to 3 do 413 if MyRO.EnemyCity[ecixShow].Flags and (2 shl I) <> 0 then 414 Inc(Cnt); 415 X := (wCommon - Cnt * xSizeSmall) div 2 - (Cnt - 1) * 2; 416 for I := 0 to 3 do 417 if MyRO.EnemyCity[ecixShow].Flags and (2 shl I) <> 0 then 418 begin 419 case I of 420 0: J := imWalls; 421 1: J := imCoastalFort; 422 2: J := imMissileBat; 423 3: J := imBunker; 441 424 end; 442 Frame( offscreen.Canvas, x - 1, yImp - 1, x+ xSizeSmall,425 Frame(Offscreen.Canvas, X - 1, yImp - 1, X + xSizeSmall, 443 426 yImp + ySizeSmall, MainTexture.ColorBevelLight, 444 427 MainTexture.ColorBevelShade); 445 DpiBit Canvas(offscreen.Canvas, x, yImp, xSizeSmall, ySizeSmall,446 SmallImp.Canvas, jmod 7 * xSizeSmall,447 ( j+ SystemIconLines * 7) div 7 * ySizeSmall);448 inc(x, xSizeSmall + 4);428 DpiBitBltCanvas(Offscreen.Canvas, X, yImp, xSizeSmall, ySizeSmall, 429 SmallImp.Canvas, J mod 7 * xSizeSmall, 430 (J + SystemIconLines * 7) div 7 * ySizeSmall); 431 Inc(X, xSizeSmall + 4); 449 432 end; 450 433 end; … … 454 437 PPicture := @Tribe[mox.owner].ModelPicture[mox.mix]; 455 438 Available := 0; 456 if G.Difficulty[ me] = 0 then // supervisor -- count stacked units too439 if G.Difficulty[Me] = 0 then // supervisor -- count stacked units too 457 440 for Loc := 0 to G.lx * G.ly - 1 do 458 441 begin 459 442 if MyMap[Loc] and fUnit <> 0 then 460 443 begin 461 Server(sGetUnits, me, Loc, Cnt);444 Server(sGetUnits, Me, Loc, Cnt); 462 445 for uix := 0 to Cnt - 1 do 463 446 if IsToCount(MyRO.EnemyUn[MyRO.nEnemyUn + uix].emix) then 464 inc(Available);447 Inc(Available); 465 448 end; 466 449 end … … 469 452 if (MyRO.EnemyUn[uix].Loc >= 0) and IsToCount(MyRO.EnemyUn[uix].emix) 470 453 then 471 inc(Available);454 Inc(Available); 472 455 Destroyed := 0; 473 456 for emix := 0 to MyRO.nEnemyModel - 1 do 474 457 if IsToCount(emix) then 475 inc(Destroyed, MyRO.EnemyModel[emix].Lost);458 Inc(Destroyed, MyRO.EnemyModel[emix].Lost); 476 459 end 477 460 else … … 480 463 for uix := 0 to MyRO.nUn - 1 do 481 464 if (MyUn[uix].Loc >= 0) and (MyUn[uix].mix = mixShow) then 482 inc(Available);465 Inc(Available); 483 466 InProd := 0; 484 467 for cix := 0 to MyRO.nCity - 1 do 485 468 if (MyCity[cix].Loc >= 0) and 486 469 (MyCity[cix].Project and (cpImp + cpIndex) = mixShow) then 487 inc(InProd);488 end; 489 490 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);470 Inc(InProd); 471 end; 472 473 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 491 474 if Kind in [dkEnemyCityDefense, dkEnemyCity] then 492 475 begin 493 NoMap.SetOutput( offscreen);494 NoMap.PaintCity(ClientWidth div 2, 53, MyRO.EnemyCity[ecixShow], false);495 496 s:= Tribe[MyRO.EnemyCity[ecixShow].owner].TPhrase('UNITOWNER');497 LoweredTextOut( offscreen.Canvas, -1, MainTexture,498 (ClientWidth - BiColorTextWidth( offscreen.Canvas, s)) div 2, 105, s);476 NoMap.SetOutput(Offscreen); 477 NoMap.PaintCity(ClientWidth div 2, 53, MyRO.EnemyCity[ecixShow], False); 478 479 S := Tribe[MyRO.EnemyCity[ecixShow].owner].TPhrase('UNITOWNER'); 480 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, 481 (ClientWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2, 105, S); 499 482 end; 500 483 … … 502 485 begin // show unit stats 503 486 if Kind = dkOwnModel then 504 MakeModelInfo( me, mixShow, MyModel[mixShow], mi)487 MakeModelInfo(Me, mixShow, MyModel[mixShow], mi) 505 488 else if Kind = dkOwnUnit then 506 489 begin 507 MakeUnitInfo( me, MyUn[uixShow], ui);508 MakeModelInfo( me, MyUn[uixShow].mix, MyModel[MyUn[uixShow].mix], mi);490 MakeUnitInfo(Me, MyUn[uixShow], ui); 491 MakeModelInfo(Me, MyUn[uixShow].mix, MyModel[MyUn[uixShow].mix], mi); 509 492 end 510 493 else … … 522 505 { Frame(offscreen.canvas,xView-1,yView-1,xView+64,yView+48, 523 506 MainTexture.ColorBevelShade,MainTexture.ColorBevelLight); 524 RFrame( offscreen.canvas,xView-2,yView-2,xView+65,yView+49,507 RFrame(Offscreen.Canvas,xView-2,yView-2,xView+65,yView+49, 525 508 MainTexture.ColorBevelShade,MainTexture.ColorBevelLight); } 526 with offscreen.Canvas do509 with Offscreen.Canvas do 527 510 begin 528 511 Brush.Color := HGrSystem.Data.Canvas.Pixels[98, 67]; 529 offscreen.Canvas.FillRect(Rect(xView, yView, xView + 64,512 Offscreen.Canvas.FillRect(Rect(xView, yView, xView + 64, 530 513 yView + 16)); 531 514 Brush.Style := bsClear; … … 534 517 if MyMap[Loc] and fTerrain >= fForest then 535 518 begin 536 x:= 1 + 2 * (xxt * 2 + 1);537 y:= 1 + yyt + 2 * (yyt * 3 + 1);519 X := 1 + 2 * (xxt * 2 + 1); 520 Y := 1 + yyt + 2 * (yyt * 3 + 1); 538 521 end 539 522 else 540 523 begin 541 x := integer(MyMap[Loc] and fTerrain) * (xxt * 2 + 1) + 1;542 y:= 1 + yyt;524 X := Integer(MyMap[Loc] and fTerrain) * (xxt * 2 + 1) + 1; 525 Y := 1 + yyt; 543 526 end; 544 for j:= -1 to 1 do545 for i:= -1 to 1 do546 if ( i + j) and 1 = 0 then527 for J := -1 to 1 do 528 for I := -1 to 1 do 529 if (I + J) and 1 = 0 then 547 530 begin 548 Sprite(Buffer, HGrTerrain, i * xxt, j* yyt, xxt * 2,549 yyt * 2, x, y);531 Sprite(Buffer, HGrTerrain, I * xxt, J * yyt, xxt * 2, 532 yyt * 2, X, Y); 550 533 if MyMap[Loc] and (fTerrain or fSpecial) = fGrass or fSpecial1 551 534 then 552 Sprite(Buffer, HGrTerrain, i * xxt, j* yyt, xxt * 2, yyt * 2,535 Sprite(Buffer, HGrTerrain, I * xxt, J * yyt, xxt * 2, yyt * 2, 553 536 1 + 2 * (xxt * 2 + 1), 1 + yyt + 1 * (yyt * 3 + 1)) 554 537 else if (MyMap[Loc] and fTerrain = fForest) and 555 538 IsJungle(Loc div G.lx) then 556 Sprite(Buffer, HGrTerrain, i * xxt, j* yyt, xxt * 2, yyt * 2,539 Sprite(Buffer, HGrTerrain, I * xxt, J * yyt, xxt * 2, yyt * 2, 557 540 1 + 7 * (xxt * 2 + 1), 1 + yyt + 19 * (yyt * 3 + 1)) 558 541 else if MyMap[Loc] and fTerrain >= fForest then 559 Sprite(Buffer, HGrTerrain, i * xxt, j* yyt, xxt * 2, yyt * 2,542 Sprite(Buffer, HGrTerrain, I * xxt, J * yyt, xxt * 2, yyt * 2, 560 543 1 + 7 * (xxt * 2 + 1), 561 1 + yyt + 2 * integer(2 + MyMap[Loc] and fTerrain - fForest)544 1 + yyt + 2 * Integer(2 + MyMap[Loc] and fTerrain - fForest) 562 545 * (yyt * 3 + 1)); 563 546 end; 564 DpiBit Canvas(offscreen.Canvas, xView, yView + 16, 64, 32,547 DpiBitBltCanvas(Offscreen.Canvas, xView, yView + 16, 64, 32, 565 548 Buffer.Canvas, 1, 0); 566 549 567 550 // show unit, experience and health 568 Sprite( offscreen, HGr, xView, yView, 64, 48, pix mod 10 * 65 + 1,551 Sprite(Offscreen, HGr, xView, yView, 64, 48, pix mod 10 * 65 + 1, 569 552 pix div 10 * 49 + 1); 570 553 if Flags and unFortified <> 0 then 571 Sprite( offscreen, HGrStdUnits, xView, yView, xxu * 2, yyu * 2,554 Sprite(Offscreen, HGrStdUnits, xView, yView, xxu * 2, yyu * 2, 572 555 1 + 6 * (xxu * 2 + 1), 1); 573 FrameImage( offscreen.Canvas, HGrSystem.Data, xView - 20,556 FrameImage(Offscreen.Canvas, HGrSystem.Data, xView - 20, 574 557 yView + 5, 12, 14, 121 + Exp div ExpCost * 13, 28); 575 558 if Health < 100 then 576 559 begin 577 s:= IntToStr(Health) + '%';578 LightGradient( offscreen.Canvas, xView - 45, yView + 24, 38,560 S := IntToStr(Health) + '%'; 561 LightGradient(Offscreen.Canvas, xView - 45, yView + 24, 38, 579 562 (ColorOfHealth(Health) and $FEFEFE shr 2) * 3); 580 RisedTextout( offscreen.Canvas, xView - 45 + 20 -581 BiColorTextWidth( offscreen.Canvas, s) div 2, yView + 23, s);563 RisedTextout(Offscreen.Canvas, xView - 45 + 20 - 564 BiColorTextWidth(Offscreen.Canvas, S) div 2, yView + 23, S); 582 565 end; 583 566 584 567 if Kind = dkEnemyUnit then 585 568 begin 586 s:= Tribe[mox.owner].TPhrase('UNITOWNER');587 LoweredTextOut( offscreen.Canvas, -1, MainTexture,588 (ClientWidth - BiColorTextWidth( offscreen.Canvas, s)) div 2,589 yView + 80, s);569 S := Tribe[mox.owner].TPhrase('UNITOWNER'); 570 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, 571 (ClientWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2, 572 yView + 80, S); 590 573 end; 591 574 end 592 575 else 593 576 begin 594 FrameImage( offscreen.Canvas, BigImp, xView + 4, yView, 56, 40, 0, 0);595 Sprite( offscreen, HGr, xView, yView - 4, 64, 44, pix mod 10 * 65 + 1,577 FrameImage(Offscreen.Canvas, BigImp, xView + 4, yView, 56, 40, 0, 0); 578 Sprite(Offscreen, HGr, xView, yView - 4, 64, 44, pix mod 10 * 65 + 1, 596 579 pix div 10 * 49 + 1); 597 580 end; 598 581 599 DarkGradient( offscreen.Canvas, xTotal - 6, yTotal + 1, 180, 2);600 RisedTextout( offscreen.Canvas, xTotal - 2, yTotal,582 DarkGradient(Offscreen.Canvas, xTotal - 6, yTotal + 1, 180, 2); 583 RisedTextout(Offscreen.Canvas, xTotal - 2, yTotal, 601 584 Phrases.Lookup('UNITSTRENGTH')); 602 s:= IntToStr(mi.Attack) + '/' + IntToStr(mi.Defense);603 RisedTextout( offscreen.Canvas,604 xTotal + 170 - BiColorTextWidth( offscreen.Canvas, s), yTotal, s);605 FeatureBar( offscreen, xTotal, yTotal + 19, mi, MainTexture);606 NumberBarS( offscreen, xTotal, yTotal + 38, Phrases.Lookup('UNITSPEED'),585 S := IntToStr(mi.Attack) + '/' + IntToStr(mi.Defense); 586 RisedTextout(Offscreen.Canvas, 587 xTotal + 170 - BiColorTextWidth(Offscreen.Canvas, S), yTotal, S); 588 FeatureBar(Offscreen, xTotal, yTotal + 19, mi, MainTexture); 589 NumberBarS(Offscreen, xTotal, yTotal + 38, Phrases.Lookup('UNITSPEED'), 607 590 MovementToString(mi.Speed), MainTexture); 608 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xTotal - 2, yTotal + 57,591 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, yTotal + 57, 609 592 Phrases.Lookup('UNITCOST')); 610 DLine( offscreen.Canvas, xTotal - 2, xTotal + 170, yTotal + 57 + 16,593 DLine(Offscreen.Canvas, xTotal - 2, xTotal + 170, yTotal + 57 + 16, 611 594 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 612 if G.Difficulty[ me] = 0 then613 s:= IntToStr(mi.cost)595 if G.Difficulty[Me] = 0 then 596 S := IntToStr(mi.cost) 614 597 else 615 s := IntToStr(mi.cost * BuildCostMod[G.Difficulty[me]] div 12);616 RisedTextout( offscreen.Canvas,617 xTotal + 159 - BiColorTextWidth( offscreen.Canvas, s), yTotal + 57, s);618 Sprite( offscreen, HGrSystem, xTotal + 160, yTotal + 57 + 5, 10,598 S := IntToStr(mi.cost * BuildCostMod[G.Difficulty[Me]] div 12); 599 RisedTextout(Offscreen.Canvas, 600 xTotal + 159 - BiColorTextWidth(Offscreen.Canvas, S), yTotal + 57, S); 601 Sprite(Offscreen, HGrSystem, xTotal + 160, yTotal + 57 + 5, 10, 619 602 10, 88, 115); 620 603 … … 624 607 begin 625 608 if MyModel[mixShow].Kind = mkEnemyDeveloped then 626 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xTotal - 2,609 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, 627 610 (yTotal + StatDown - 19), Phrases.Lookup('UNITADOPT')) 628 611 else 629 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xTotal - 2,612 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, 630 613 (yTotal + StatDown - 19), Phrases.Lookup('UNITINTRO')); 631 DLine( offscreen.Canvas, xTotal - 2, xTotal + 170,614 DLine(Offscreen.Canvas, xTotal - 2, xTotal + 170, 632 615 (yTotal + StatDown - 19) + 16, MainTexture.ColorTextShade, 633 616 MainTexture.ColorTextLight); 634 s:= TurnToString(MyModel[mixShow].IntroTurn);635 RisedTextout( offscreen.Canvas,636 xTotal + 170 - BiColorTextWidth( offscreen.Canvas, s),637 (yTotal + StatDown - 19), s);617 S := TurnToString(MyModel[mixShow].IntroTurn); 618 RisedTextout(Offscreen.Canvas, 619 xTotal + 170 - BiColorTextWidth(Offscreen.Canvas, S), 620 (yTotal + StatDown - 19), S); 638 621 end; 639 622 640 NumberBar( offscreen, xTotal, yTotal + StatDown,623 NumberBar(Offscreen, xTotal, yTotal + StatDown, 641 624 Phrases.Lookup('UNITBUILT'), MyModel[mixShow].Built, MainTexture); 642 625 if MyModel[mixShow].Lost > 0 then 643 NumberBar( offscreen, xTotal, yTotal + StatDown + 19,626 NumberBar(Offscreen, xTotal, yTotal + StatDown + 19, 644 627 Phrases.Lookup('UNITLOST'), MyModel[mixShow].Lost, MainTexture); 645 628 if InProd > 0 then 646 NumberBar( offscreen, xTotal, yTotal + StatDown + 57,629 NumberBar(Offscreen, xTotal, yTotal + StatDown + 57, 647 630 Phrases.Lookup('UNITINPROD'), InProd, MainTexture); 648 631 if Available > 0 then 649 NumberBar( offscreen, xTotal, yTotal + StatDown + 38,632 NumberBar(Offscreen, xTotal, yTotal + StatDown + 38, 650 633 Phrases.Lookup('UNITAVAILABLE'), Available, MainTexture); 651 634 … … 674 657 begin 675 658 if Destroyed > 0 then 676 NumberBar( offscreen, xTotal, yTotal + StatDown - 19,659 NumberBar(Offscreen, xTotal, yTotal + StatDown - 19, 677 660 Phrases.Lookup('UNITDESTROYED'), Destroyed, MainTexture); 678 661 if Available > 0 then 679 NumberBar( offscreen, xTotal, yTotal + StatDown,662 NumberBar(Offscreen, xTotal, yTotal + StatDown, 680 663 Phrases.Lookup('UNITKNOWN'), Available, MainTexture); 681 664 end; … … 683 666 end; 684 667 685 offscreen.Canvas.Font.Assign(UniFont[ftNormal]);668 Offscreen.Canvas.Font.Assign(UniFont[ftNormal]); 686 669 case Kind of 687 670 dkOwnModel, dkEnemyModel: … … 692 675 yCaption := 79; 693 676 end; 694 RisedTextout( offscreen.Canvas,695 (ClientWidth - BiColorTextWidth( offscreen.Canvas, Caption)) div 2,677 RisedTextout(Offscreen.Canvas, 678 (ClientWidth - BiColorTextWidth(Offscreen.Canvas, Caption)) div 2, 696 679 yCaption, Caption); 697 end; { OffscreenPaint }680 end; 698 681 699 682 procedure TUnitStatDlg.ModelBoxChange(Sender: TObject); … … 734 717 procedure TUnitStatDlg.HelpBtnClick(Sender: TObject); 735 718 begin 736 HelpDlg.ShowNewContent(wmPersistent, hkModel, 0);719 MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkModel, 0); 737 720 end; 738 721 -
TabularUnified branches/highdpi/LocalPlayer/Wonders.pas ¶
r361 r465 23 23 Selection: Integer; 24 24 Center: TPoint; 25 procedure DarkIcon( i: Integer);26 procedure Glow( i, GlowColor: Integer);25 procedure DarkIcon(I: Integer); 26 procedure Glow(I, GlowColor: Integer); 27 27 procedure PaintBackgroundShape; 28 28 public 29 29 procedure OffscreenPaint; override; 30 procedure ShowNewContent(NewMode: Integer); 31 end; 32 33 var 34 WondersDlg: TWondersDlg; 30 procedure ShowNewContent(NewMode: TWindowMode); 31 end; 35 32 36 33 … … 38 35 39 36 uses 40 Term, ClientTools, Help, Tribes, UPixelPointer;37 Term, ClientTools, Help, Tribes, PixelPointer; 41 38 42 39 {$R *.lfm} … … 76 73 procedure TWondersDlg.FormShow(Sender: TObject); 77 74 begin 75 Caption := Phrases.Lookup('TITLE_WONDERS'); 78 76 Selection := -1; 79 77 OffscreenPaint; 80 78 end; 81 79 82 procedure TWondersDlg.ShowNewContent(NewMode: Integer);80 procedure TWondersDlg.ShowNewContent(NewMode: TWindowMode); 83 81 begin 84 82 inherited ShowNewContent(NewMode); … … 109 107 Height := ScaleToNative(128); 110 108 Offscreen.BeginUpdate; 111 Line[0] := PixelPointer(Offscreen, ScaleToNative(Center.X), ScaleToNative(Center.Y));112 Line[1] := PixelPointer(Offscreen, ScaleToNative(Center.X), ScaleToNative(Center.Y) - 1);113 Line[2] := PixelPointer(Offscreen, ScaleToNative(Center.X) - 1, ScaleToNative(Center.Y));114 Line[3] := PixelPointer(Offscreen, ScaleToNative(Center.X) - 1, ScaleToNative(Center.Y) - 1);109 Line[0] := TPixelPointer.Create(Offscreen, ScaleToNative(Center.X), ScaleToNative(Center.Y)); 110 Line[1] := TPixelPointer.Create(Offscreen, ScaleToNative(Center.X), ScaleToNative(Center.Y) - 1); 111 Line[2] := TPixelPointer.Create(Offscreen, ScaleToNative(Center.X) - 1, ScaleToNative(Center.Y)); 112 Line[3] := TPixelPointer.Create(Offscreen, ScaleToNative(Center.X) - 1, ScaleToNative(Center.Y) - 1); 115 113 for Y := 0 to Height - 1 do begin 116 114 for X := 0 to Width - 1 do begin 117 r:= X * X * ((Height div 4) * (Height div 4)) + Y * Y * ((Width div 4) * (Width div 4));115 R := X * X * ((Height div 4) * (Height div 4)) + Y * Y * ((Width div 4) * (Width div 4)); 118 116 ax := ((1 shl 16 div (Height div 4)) * (Width div 4)) * Y; 119 if ( r< ScaleToNative(8) * Height * Width * Width) and120 (( r>= (Height div 4) * (Height div 2) * (Width div 2) * (Width div 2)) and (ax < amax2 * X) and117 if (R < ScaleToNative(8) * Height * Width * Width) and 118 ((R >= (Height div 4) * (Height div 2) * (Width div 2) * (Width div 2)) and (ax < amax2 * X) and 121 119 ((ax < amax0 * X) or (ax > amin2 * X)) or (ax > amin1 * X) and 122 120 ((ax < amax1 * X) or (ax > amin3 * X))) then begin 123 121 for ch := 0 to 2 do begin 124 c:= Line[0].Pixel^.Planes[ch] - Darken;125 if c< 0 then Line[0].Pixel^.Planes[ch] := 0126 else Line[0].Pixel^.Planes[ch] := c;127 c:= Line[1].Pixel^.Planes[ch] - Darken;128 if c< 0 then Line[1].Pixel^.Planes[ch] := 0129 else Line[1].Pixel^.Planes[ch] := c;130 c:= Line[2].Pixel^.Planes[ch] - Darken;131 if c< 0 then Line[2].Pixel^.Planes[ch] := 0132 else Line[2].Pixel^.Planes[ch] := c;133 c:= Line[3].Pixel^.Planes[ch] - Darken;134 if c< 0 then Line[3].Pixel^.Planes[ch] := 0135 else Line[3].Pixel^.Planes[ch] := c;122 C := Line[0].Pixel^.Planes[ch] - Darken; 123 if C < 0 then Line[0].Pixel^.Planes[ch] := 0 124 else Line[0].Pixel^.Planes[ch] := C; 125 C := Line[1].Pixel^.Planes[ch] - Darken; 126 if C < 0 then Line[1].Pixel^.Planes[ch] := 0 127 else Line[1].Pixel^.Planes[ch] := C; 128 C := Line[2].Pixel^.Planes[ch] - Darken; 129 if C < 0 then Line[2].Pixel^.Planes[ch] := 0 130 else Line[2].Pixel^.Planes[ch] := C; 131 C := Line[3].Pixel^.Planes[ch] - Darken; 132 if C < 0 then Line[3].Pixel^.Planes[ch] := 0 133 else Line[3].Pixel^.Planes[ch] := C; 136 134 end; 137 135 end; … … 149 147 end; 150 148 151 procedure TWondersDlg.DarkIcon( i: Integer);149 procedure TWondersDlg.DarkIcon(I: Integer); 152 150 var 153 X, Y, ch, x0Dst, y0Dst, x0Src, y0Src, darken, c: Integer;151 X, Y, ch, x0Dst, y0Dst, x0Src, y0Src, darken, C: Integer; 154 152 Src, Dst: TPixelPointer; 155 153 begin 156 154 Offscreen.BeginUpdate; 157 x0Dst := ClientWidth div 2 - xSizeBig div 2 + RingPosition[ i].X;158 y0Dst := ClientHeight div 2 - ySizeBig div 2 + RingPosition[ i].Y;159 x0Src := ( imod 7) * xSizeBig;160 y0Src := ( idiv 7 + SystemIconLines) * ySizeBig;161 Src := PixelPointer(BigImp, ScaleToNative(x0Src), ScaleToNative(y0Src));162 Dst := PixelPointer(Offscreen, ScaleToNative(x0Dst), ScaleToNative(y0Dst));155 x0Dst := ClientWidth div 2 - xSizeBig div 2 + RingPosition[I].X; 156 y0Dst := ClientHeight div 2 - ySizeBig div 2 + RingPosition[I].Y; 157 x0Src := (I mod 7) * xSizeBig; 158 y0Src := (I div 7 + SystemIconLines) * ySizeBig; 159 Src := TPixelPointer.Create(BigImp, ScaleToNative(x0Src), ScaleToNative(y0Src)); 160 Dst := TPixelPointer.Create(Offscreen, ScaleToNative(x0Dst), ScaleToNative(y0Dst)); 163 161 for Y := 0 to ScaleToNative(ySizeBig) - 1 do begin 164 162 for X := 0 to ScaleToNative(xSizeBig) - 1 do begin … … 166 164 15 + (255 - Src.Pixel^.R) * 9) div 128; 167 165 for ch := 0 to 2 do begin 168 c:= Dst.Pixel^.Planes[ch] - Darken;169 if c< 0 then Dst.Pixel^.Planes[ch] := 0170 else Dst.Pixel^.Planes[ch] := c;166 C := Dst.Pixel^.Planes[ch] - Darken; 167 if C < 0 then Dst.Pixel^.Planes[ch] := 0 168 else Dst.Pixel^.Planes[ch] := C; 171 169 end; 172 170 Src.NextPixel; … … 179 177 end; 180 178 181 procedure TWondersDlg.Glow( i, GlowColor: Integer);179 procedure TWondersDlg.Glow(I, GlowColor: Integer); 182 180 begin 183 181 GlowFrame(Offscreen, 184 ClientWidth div 2 - xSizeBig div 2 + RingPosition[ i].X,185 ClientHeight div 2 - ySizeBig div 2 + RingPosition[ i].Y,182 ClientWidth div 2 - xSizeBig div 2 + RingPosition[I].X, 183 ClientHeight div 2 - ySizeBig div 2 + RingPosition[I].Y, 186 184 xSizeBig, ySizeBig, GlowColor); 187 185 end; … … 235 233 WonderDestroyed: begin 236 234 HaveWonder := True; 237 DpiBit Canvas(Offscreen.Canvas,235 DpiBitBltCanvas(Offscreen.Canvas, 238 236 Center.X - xSizeBig div 2 + RingPosition[I].X, 239 237 Center.Y - ySizeBig div 2 + RingPosition[I].Y, xSizeBig, … … 243 241 else begin 244 242 HaveWonder := True; 245 DpiBit Canvas(Offscreen.Canvas,243 DpiBitBltCanvas(Offscreen.Canvas, 246 244 Center.X - xSizeBig div 2 + RingPosition[I].X, 247 245 Center.Y - ySizeBig div 2 + RingPosition[I].Y, xSizeBig, ySizeBig, … … 280 278 281 279 MarkUsedOffscreen(ClientWidth, ClientHeight); 282 end; { OffscreenPaint }280 end; 283 281 284 282 procedure TWondersDlg.CloseBtnClick(Sender: TObject); … … 350 348 begin 351 349 if Selection >= 0 then 352 HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkImp, Selection);350 MainScreen.HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkImp, Selection); 353 351 end; 354 352
Note:
See TracChangeset
for help on using the changeset viewer.