Changeset 465 for branches/highdpi/LocalPlayer/UnitStat.pas
- Timestamp:
- Nov 30, 2023, 10:16:14 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.