| 1 | {$INCLUDE switches}
|
|---|
| 2 | unit UnitStat;
|
|---|
| 3 |
|
|---|
| 4 | interface
|
|---|
| 5 |
|
|---|
| 6 | uses
|
|---|
| 7 | Protocol, ClientTools, Term, ScreenTools, BaseWin,
|
|---|
| 8 |
|
|---|
| 9 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, ButtonA,
|
|---|
| 10 | ButtonB,
|
|---|
| 11 | ButtonBase, ButtonC;
|
|---|
| 12 |
|
|---|
| 13 | type
|
|---|
| 14 | TUnitStatDlg = class(TBufferedDrawDlg)
|
|---|
| 15 | SwitchBtn: TButtonB;
|
|---|
| 16 | CloseBtn: TButtonB;
|
|---|
| 17 | ConscriptsBtn: TButtonB;
|
|---|
| 18 | HelpBtn: TButtonC;
|
|---|
| 19 | procedure FormShow(Sender: TObject);
|
|---|
| 20 | procedure CloseBtnClick(Sender: TObject);
|
|---|
| 21 | procedure FormCreate(Sender: TObject);
|
|---|
| 22 | procedure ModelBoxChange(Sender: TObject);
|
|---|
| 23 | procedure SwitchBtnClick(Sender: TObject);
|
|---|
| 24 | procedure ConscriptsBtnClick(Sender: TObject);
|
|---|
| 25 | procedure FormDestroy(Sender: TObject);
|
|---|
| 26 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|---|
| 27 | procedure HelpBtnClick(Sender: TObject);
|
|---|
| 28 |
|
|---|
| 29 | public
|
|---|
| 30 | procedure CheckAge;
|
|---|
| 31 | procedure ShowNewContent_OwnModel(NewMode, mix: integer);
|
|---|
| 32 | procedure ShowNewContent_OwnUnit(NewMode, uix: integer);
|
|---|
| 33 | procedure ShowNewContent_EnemyUnit(NewMode, euix: integer);
|
|---|
| 34 | procedure ShowNewContent_EnemyLoc(NewMode, Loc: integer);
|
|---|
| 35 | procedure ShowNewContent_EnemyModel(NewMode, emix: integer);
|
|---|
| 36 | procedure ShowNewContent_EnemyCity(NewMode, Loc: integer);
|
|---|
| 37 |
|
|---|
| 38 | protected
|
|---|
| 39 | mixShow, // for dkOwnModel
|
|---|
| 40 | uixShow, euixShow, ecixShow, UnitLoc, AgePrepared: integer;
|
|---|
| 41 | // for dkEnemyUnit, euixShow=-1 ->
|
|---|
| 42 | mox: ^TModelInfo; // for dkEnemyModel
|
|---|
| 43 | Kind: (dkOwnModel, dkOwnUnit, dkEnemyModel, dkEnemyUnit, dkEnemyCityDefense,
|
|---|
| 44 | dkEnemyCity);
|
|---|
| 45 | Back, Template: TBitmap;
|
|---|
| 46 | procedure OffscreenPaint; override;
|
|---|
| 47 | end;
|
|---|
| 48 |
|
|---|
| 49 | var
|
|---|
| 50 | UnitStatDlg: TUnitStatDlg;
|
|---|
| 51 |
|
|---|
| 52 | implementation
|
|---|
| 53 |
|
|---|
| 54 | uses Inp, Select, Tribes, IsoEngine, Help, Directories;
|
|---|
| 55 |
|
|---|
| 56 | {$R *.DFM}
|
|---|
| 57 |
|
|---|
| 58 | const
|
|---|
| 59 | xView = 71;
|
|---|
| 60 | xTotal = 20;
|
|---|
| 61 | StatDown = 112;
|
|---|
| 62 | yImp = 133;
|
|---|
| 63 |
|
|---|
| 64 | // window size
|
|---|
| 65 | wCommon = 208;
|
|---|
| 66 | hOwnModel = 293;
|
|---|
| 67 | hEnemyModel = 236;
|
|---|
| 68 | hEnemyUnit = 212;
|
|---|
| 69 | hEnemyCityDefense = 320;
|
|---|
| 70 | hEnemyCity = 166;
|
|---|
| 71 | hMax = 320;
|
|---|
| 72 |
|
|---|
| 73 | procedure TUnitStatDlg.FormCreate(Sender: TObject);
|
|---|
| 74 | begin
|
|---|
| 75 | inherited;
|
|---|
| 76 | AgePrepared := -2;
|
|---|
| 77 | TitleHeight := Screen.Height;
|
|---|
| 78 | InitButtons();
|
|---|
| 79 |
|
|---|
| 80 | Back := TBitmap.Create;
|
|---|
| 81 | Back.PixelFormat := pf24bit;
|
|---|
| 82 | Back.Width := 5 * wCommon;
|
|---|
| 83 | Back.Height := hMax;
|
|---|
| 84 | Template := TBitmap.Create;
|
|---|
| 85 | LoadGraphicFile(Template, HomeDir + 'Graphics\Unit', gfNoGamma);
|
|---|
| 86 | Template.PixelFormat := pf8bit;
|
|---|
| 87 | end;
|
|---|
| 88 |
|
|---|
| 89 | procedure TUnitStatDlg.FormDestroy(Sender: TObject);
|
|---|
| 90 | begin
|
|---|
| 91 | Template.Free;
|
|---|
| 92 | Back.Free;
|
|---|
| 93 | end;
|
|---|
| 94 |
|
|---|
| 95 | procedure TUnitStatDlg.CheckAge;
|
|---|
| 96 | begin
|
|---|
| 97 | if MainTextureAge <> AgePrepared then
|
|---|
| 98 | begin
|
|---|
| 99 | AgePrepared := MainTextureAge;
|
|---|
| 100 | bitblt(Back.Canvas.Handle, 0, 0, wCommon, hOwnModel,
|
|---|
| 101 | MainTexture.Image.Canvas.Handle, (wMainTexture - wCommon) div 2,
|
|---|
| 102 | (hMainTexture - hOwnModel) div 2, SRCCOPY);
|
|---|
| 103 | bitblt(Back.Canvas.Handle, wCommon, 0, wCommon, hEnemyModel,
|
|---|
| 104 | MainTexture.Image.Canvas.Handle, (wMainTexture - wCommon) div 2,
|
|---|
| 105 | (hMainTexture - hEnemyModel) div 2, SRCCOPY);
|
|---|
| 106 | bitblt(Back.Canvas.Handle, 2 * wCommon, 0, wCommon, hEnemyUnit,
|
|---|
| 107 | MainTexture.Image.Canvas.Handle, (wMainTexture - wCommon) div 2,
|
|---|
| 108 | (hMainTexture - hEnemyUnit) div 2, SRCCOPY);
|
|---|
| 109 | bitblt(Back.Canvas.Handle, 3 * wCommon, 0, wCommon, hEnemyCityDefense,
|
|---|
| 110 | MainTexture.Image.Canvas.Handle, (wMainTexture - wCommon) div 2,
|
|---|
| 111 | (hMainTexture - hEnemyCityDefense) div 2, SRCCOPY);
|
|---|
| 112 | bitblt(Back.Canvas.Handle, 4 * wCommon, 0, wCommon, hEnemyCity,
|
|---|
| 113 | MainTexture.Image.Canvas.Handle, (wMainTexture - wCommon) div 2,
|
|---|
| 114 | (hMainTexture - hEnemyCity) div 2, SRCCOPY);
|
|---|
| 115 | ImageOp_B(Back, Template, 0, 0, 0, 0, 5 * wCommon, hMax);
|
|---|
| 116 | end
|
|---|
| 117 | end;
|
|---|
| 118 |
|
|---|
| 119 | procedure TUnitStatDlg.FormShow(Sender: TObject);
|
|---|
| 120 | var
|
|---|
| 121 | owner, mix: integer;
|
|---|
| 122 | IsSpecialUnit: boolean;
|
|---|
| 123 | begin
|
|---|
| 124 | if Kind in [dkEnemyUnit, dkEnemyCityDefense, dkEnemyCity] then
|
|---|
| 125 | begin
|
|---|
| 126 | if MyMap[UnitLoc] and fUnit <> 0 then
|
|---|
| 127 | begin // find model
|
|---|
| 128 | if euixShow < 0 then
|
|---|
| 129 | begin
|
|---|
| 130 | euixShow := MyRO.nEnemyUn - 1;
|
|---|
| 131 | while (euixShow >= 0) and (MyRO.EnemyUn[euixShow].Loc <> UnitLoc) do
|
|---|
| 132 | dec(euixShow);
|
|---|
| 133 | assert(euixShow >= 0);
|
|---|
| 134 | end;
|
|---|
| 135 | with MyRO.EnemyUn[euixShow] do
|
|---|
| 136 | begin
|
|---|
| 137 | mox := @MyRO.EnemyModel[emix];
|
|---|
| 138 | if Tribe[owner].ModelPicture[mix].HGr = 0 then
|
|---|
| 139 | InitEnemyModel(emix);
|
|---|
| 140 | end
|
|---|
| 141 | end
|
|---|
| 142 | else
|
|---|
| 143 | mox := nil;
|
|---|
| 144 | if Kind in [dkEnemyCityDefense, dkEnemyCity] then
|
|---|
| 145 | begin
|
|---|
| 146 | ecixShow := MyRO.nEnemyCity - 1;
|
|---|
| 147 | while (ecixShow >= 0) and (MyRO.EnemyCity[ecixShow].Loc <> UnitLoc) do
|
|---|
| 148 | dec(ecixShow);
|
|---|
| 149 | assert(ecixShow >= 0);
|
|---|
| 150 | end
|
|---|
| 151 | end;
|
|---|
| 152 | case Kind of
|
|---|
| 153 | dkOwnModel:
|
|---|
| 154 | ClientHeight := hOwnModel;
|
|---|
| 155 | dkOwnUnit:
|
|---|
| 156 | ClientHeight := hEnemyUnit;
|
|---|
| 157 | dkEnemyModel:
|
|---|
| 158 | ClientHeight := hEnemyModel;
|
|---|
| 159 | dkEnemyUnit:
|
|---|
| 160 | ClientHeight := hEnemyUnit;
|
|---|
| 161 | dkEnemyCityDefense:
|
|---|
| 162 | ClientHeight := hEnemyCityDefense;
|
|---|
| 163 | dkEnemyCity:
|
|---|
| 164 | ClientHeight := hEnemyCity;
|
|---|
| 165 | end;
|
|---|
| 166 |
|
|---|
| 167 | if Kind in [dkOwnModel, dkEnemyModel] then
|
|---|
| 168 | begin
|
|---|
| 169 | Left := UserLeft;
|
|---|
| 170 | Top := UserTop;
|
|---|
| 171 | end
|
|---|
| 172 | else
|
|---|
| 173 | begin
|
|---|
| 174 | Left := (Screen.Width - Width) div 2;
|
|---|
| 175 | Top := (Screen.Height - Height) div 2;
|
|---|
| 176 | end;
|
|---|
| 177 |
|
|---|
| 178 | SwitchBtn.Visible := not supervising and (Kind = dkOwnModel);
|
|---|
| 179 | ConscriptsBtn.Visible := not supervising and (Kind = dkOwnModel) and
|
|---|
| 180 | (MyRO.Tech[adConscription] >= tsApplicable) and
|
|---|
| 181 | (MyModel[mixShow].Domain = dGround) and (MyModel[mixShow].Kind < mkScout);
|
|---|
| 182 | IsSpecialUnit := false;
|
|---|
| 183 | if Kind in [dkEnemyCity, dkEnemyCityDefense] then
|
|---|
| 184 | Caption := CityName(MyRO.EnemyCity[ecixShow].ID)
|
|---|
| 185 | else
|
|---|
| 186 | begin
|
|---|
| 187 | case Kind of
|
|---|
| 188 | dkOwnModel:
|
|---|
| 189 | begin
|
|---|
| 190 | owner := me;
|
|---|
| 191 | mix := mixShow;
|
|---|
| 192 | IsSpecialUnit := MyModel[mix].Kind >= $10;
|
|---|
| 193 | end;
|
|---|
| 194 | dkOwnUnit:
|
|---|
| 195 | begin
|
|---|
| 196 | owner := me;
|
|---|
| 197 | mix := MyUn[uixShow].mix;
|
|---|
| 198 | IsSpecialUnit := MyModel[mix].Kind >= $10;
|
|---|
| 199 | end
|
|---|
| 200 | else
|
|---|
| 201 | begin
|
|---|
| 202 | owner := mox.owner;
|
|---|
| 203 | mix := mox.mix;
|
|---|
| 204 | IsSpecialUnit := mox.Kind >= $10;
|
|---|
| 205 | end;
|
|---|
| 206 | end;
|
|---|
| 207 | if MainScreen.mNames.Checked then
|
|---|
| 208 | Caption := Tribe[owner].ModelName[mix]
|
|---|
| 209 | else
|
|---|
| 210 | Caption := Format(Tribe[owner].TPhrase('GENMODEL'), [mix])
|
|---|
| 211 | end;
|
|---|
| 212 | if IsSpecialUnit then
|
|---|
| 213 | HelpBtn.Hint := Phrases.Lookup('CONTROLS', 6);
|
|---|
| 214 | HelpBtn.Visible := IsSpecialUnit;
|
|---|
| 215 | OffscreenPaint;
|
|---|
| 216 | end;
|
|---|
| 217 |
|
|---|
| 218 | procedure TUnitStatDlg.ShowNewContent_OwnModel(NewMode, mix: integer);
|
|---|
| 219 | begin
|
|---|
| 220 | Kind := dkOwnModel;
|
|---|
| 221 | mixShow := mix;
|
|---|
| 222 | inherited ShowNewContent(NewMode);
|
|---|
| 223 | end;
|
|---|
| 224 |
|
|---|
| 225 | procedure TUnitStatDlg.ShowNewContent_OwnUnit(NewMode, uix: integer);
|
|---|
| 226 | begin
|
|---|
| 227 | Kind := dkOwnUnit;
|
|---|
| 228 | uixShow := uix;
|
|---|
| 229 | inherited ShowNewContent(NewMode);
|
|---|
| 230 | end;
|
|---|
| 231 |
|
|---|
| 232 | procedure TUnitStatDlg.ShowNewContent_EnemyUnit(NewMode, euix: integer);
|
|---|
| 233 | begin
|
|---|
| 234 | Kind := dkEnemyUnit;
|
|---|
| 235 | euixShow := euix;
|
|---|
| 236 | UnitLoc := MyRO.EnemyUn[euix].Loc;
|
|---|
| 237 | inherited ShowNewContent(NewMode);
|
|---|
| 238 | end;
|
|---|
| 239 |
|
|---|
| 240 | procedure TUnitStatDlg.ShowNewContent_EnemyLoc(NewMode, Loc: integer);
|
|---|
| 241 | begin
|
|---|
| 242 | Kind := dkEnemyUnit;
|
|---|
| 243 | UnitLoc := Loc;
|
|---|
| 244 | euixShow := -1;
|
|---|
| 245 | inherited ShowNewContent(NewMode);
|
|---|
| 246 | end;
|
|---|
| 247 |
|
|---|
| 248 | procedure TUnitStatDlg.ShowNewContent_EnemyModel(NewMode, emix: integer);
|
|---|
| 249 | begin
|
|---|
| 250 | Kind := dkEnemyModel;
|
|---|
| 251 | mox := @MyRO.EnemyModel[emix];
|
|---|
| 252 | inherited ShowNewContent(NewMode);
|
|---|
| 253 | end;
|
|---|
| 254 |
|
|---|
| 255 | procedure TUnitStatDlg.ShowNewContent_EnemyCity(NewMode, Loc: integer);
|
|---|
| 256 | begin
|
|---|
| 257 | if MyMap[Loc] and fUnit <> 0 then
|
|---|
| 258 | Kind := dkEnemyCityDefense
|
|---|
| 259 | else
|
|---|
| 260 | Kind := dkEnemyCity;
|
|---|
| 261 | UnitLoc := Loc;
|
|---|
| 262 | euixShow := -1;
|
|---|
| 263 | inherited ShowNewContent(NewMode);
|
|---|
| 264 | end;
|
|---|
| 265 |
|
|---|
| 266 | procedure TUnitStatDlg.FormClose(Sender: TObject; var Action: TCloseAction);
|
|---|
| 267 | begin
|
|---|
| 268 | if Kind in [dkOwnModel, dkEnemyModel] then
|
|---|
| 269 | begin
|
|---|
| 270 | UserLeft := Left;
|
|---|
| 271 | UserTop := Top
|
|---|
| 272 | end;
|
|---|
| 273 | if OffscreenUser = self then
|
|---|
| 274 | OffscreenUser := nil;
|
|---|
| 275 | end;
|
|---|
| 276 |
|
|---|
| 277 | procedure TUnitStatDlg.CloseBtnClick(Sender: TObject);
|
|---|
| 278 | begin
|
|---|
| 279 | Close
|
|---|
| 280 | end;
|
|---|
| 281 |
|
|---|
| 282 | procedure TUnitStatDlg.OffscreenPaint;
|
|---|
| 283 | var
|
|---|
| 284 | PPicture: ^TModelPicture;
|
|---|
| 285 |
|
|---|
| 286 | function IsToCount(emix: integer): boolean;
|
|---|
| 287 | var
|
|---|
| 288 | PTestPicture: ^TModelPicture;
|
|---|
| 289 | begin
|
|---|
| 290 | if MainScreen.mNames.Checked then
|
|---|
| 291 | begin
|
|---|
| 292 | PTestPicture := @Tribe[MyRO.EnemyModel[emix].owner].ModelPicture
|
|---|
| 293 | [MyRO.EnemyModel[emix].mix];
|
|---|
| 294 | result := (PPicture.HGr = PTestPicture.HGr) and
|
|---|
| 295 | (PPicture.pix = PTestPicture.pix) and
|
|---|
| 296 | (ModelHash(mox^) = ModelHash(MyRO.EnemyModel[emix]))
|
|---|
| 297 | end
|
|---|
| 298 | else
|
|---|
| 299 | result := (MyRO.EnemyModel[emix].owner = mox.owner) and
|
|---|
| 300 | (MyRO.EnemyModel[emix].mix = mox.mix)
|
|---|
| 301 | end;
|
|---|
| 302 |
|
|---|
| 303 | procedure FeatureBar(dst: TBitmap; x, y: integer; const mi: TModelInfo;
|
|---|
| 304 | const T: TTexture);
|
|---|
| 305 | var
|
|---|
| 306 | i, w, dx, num: integer;
|
|---|
| 307 | s: string;
|
|---|
| 308 | begin
|
|---|
| 309 | DarkGradient(dst.Canvas, x - 6, y + 1, 180, 1);
|
|---|
| 310 | with dst.Canvas do
|
|---|
| 311 | if mi.Kind >= $10 then
|
|---|
| 312 | begin
|
|---|
| 313 | s := Phrases.Lookup('UNITSPECIAL');
|
|---|
| 314 | Font.Color := $000000;
|
|---|
| 315 | Textout(x - 1, y + 1, s);
|
|---|
| 316 | Font.Color := $B0B0B0;
|
|---|
| 317 | Textout(x - 2, y, s);
|
|---|
| 318 | end
|
|---|
| 319 | else
|
|---|
| 320 | begin
|
|---|
| 321 | Font.Color := $000000;
|
|---|
| 322 | dx := 2;
|
|---|
| 323 | for i := 3 to nFeature - 1 do
|
|---|
| 324 | begin
|
|---|
| 325 | num := 0;
|
|---|
| 326 | case i of
|
|---|
| 327 | mcSeaTrans:
|
|---|
| 328 | if mi.Domain = dSea then
|
|---|
| 329 | num := mi.TTrans;
|
|---|
| 330 | mcCarrier:
|
|---|
| 331 | if mi.Domain = dSea then
|
|---|
| 332 | num := mi.ATrans_Fuel;
|
|---|
| 333 | mcBombs:
|
|---|
| 334 | num := mi.Bombs;
|
|---|
| 335 | mcFuel:
|
|---|
| 336 | if mi.Domain = dAir then
|
|---|
| 337 | num := mi.ATrans_Fuel;
|
|---|
| 338 | mcAirTrans:
|
|---|
| 339 | if mi.Domain = dAir then
|
|---|
| 340 | num := mi.TTrans;
|
|---|
| 341 | mcFirstNonCap .. nFeature - 1:
|
|---|
| 342 | if mi.Cap and (1 shl (i - mcFirstNonCap)) <> 0 then
|
|---|
| 343 | num := 1
|
|---|
| 344 | end;
|
|---|
| 345 | if (num > 0) and
|
|---|
| 346 | ((i <> mcSE) or (mi.Cap and (1 shl (mcNP - mcFirstNonCap)) = 0))
|
|---|
| 347 | then
|
|---|
| 348 | begin
|
|---|
| 349 | if num > 1 then
|
|---|
| 350 | begin
|
|---|
| 351 | s := IntToStr(num);
|
|---|
| 352 | w := TextWidth(s);
|
|---|
| 353 | Brush.Color := $FFFFFF;
|
|---|
| 354 | FillRect(Rect(x - 3 + dx, y + 2, x + w - 1 + dx, y + 16));
|
|---|
| 355 | Brush.Style := bsClear;
|
|---|
| 356 | Textout(x - 3 + dx + 1, y, s);
|
|---|
| 357 | inc(dx, w + 1)
|
|---|
| 358 | end;
|
|---|
| 359 | Brush.Color := $C0C0C0;
|
|---|
| 360 | FrameRect(Rect(x - 3 + dx, y + 2, x + 11 + dx, y + 16));
|
|---|
| 361 | Brush.Style := bsClear;
|
|---|
| 362 | Sprite(dst, HGrSystem, x - 1 + dx, y + 4, 10, 10,
|
|---|
| 363 | 66 + i mod 11 * 11, 137 + i div 11 * 11);
|
|---|
| 364 | inc(dx, 15)
|
|---|
| 365 | end;
|
|---|
| 366 | end
|
|---|
| 367 | end
|
|---|
| 368 | end; { featurebar }
|
|---|
| 369 |
|
|---|
| 370 | procedure NumberBarS(dst: TBitmap; x, y: integer; Cap, s: string;
|
|---|
| 371 | const T: TTexture);
|
|---|
| 372 | begin
|
|---|
| 373 | DLine(dst.Canvas, x - 2, x + 170, y + 16, T.clBevelShade, T.clBevelLight);
|
|---|
| 374 | LoweredTextOut(dst.Canvas, -1, T, x - 2, y, Cap);
|
|---|
| 375 | RisedTextout(dst.Canvas, x + 170 - BiColorTextWidth(dst.Canvas, s), y, s);
|
|---|
| 376 | end;
|
|---|
| 377 |
|
|---|
| 378 | var
|
|---|
| 379 | i, j, x, y, cix, uix, emix, InProd, Available, Destroyed, Loc, Cnt, yView,
|
|---|
| 380 | yTotal, yCaption: integer;
|
|---|
| 381 | s: string;
|
|---|
| 382 | ui: TUnitInfo;
|
|---|
| 383 | mi: TModelInfo;
|
|---|
| 384 | begin
|
|---|
| 385 | inherited;
|
|---|
| 386 |
|
|---|
| 387 | case Kind of
|
|---|
| 388 | dkOwnModel:
|
|---|
| 389 | begin
|
|---|
| 390 | bitblt(offscreen.Canvas.Handle, 0, 0, wCommon, hOwnModel,
|
|---|
| 391 | Back.Canvas.Handle, 0, 0, SRCCOPY);
|
|---|
| 392 | yView := 13;
|
|---|
| 393 | yTotal := 92;
|
|---|
| 394 | end;
|
|---|
| 395 | dkEnemyModel:
|
|---|
| 396 | begin
|
|---|
| 397 | bitblt(offscreen.Canvas.Handle, 0, 0, wCommon, hEnemyModel,
|
|---|
| 398 | Back.Canvas.Handle, wCommon, 0, SRCCOPY);
|
|---|
| 399 | yView := 13;
|
|---|
| 400 | yTotal := 92;
|
|---|
| 401 | end;
|
|---|
| 402 | dkEnemyUnit, dkOwnUnit:
|
|---|
| 403 | begin
|
|---|
| 404 | bitblt(offscreen.Canvas.Handle, 0, 0, wCommon, hEnemyUnit,
|
|---|
| 405 | Back.Canvas.Handle, 2 * wCommon, 0, SRCCOPY);
|
|---|
| 406 | yView := 13;
|
|---|
| 407 | yTotal := 123;
|
|---|
| 408 | end;
|
|---|
| 409 | dkEnemyCityDefense:
|
|---|
| 410 | begin
|
|---|
| 411 | bitblt(offscreen.Canvas.Handle, 0, 0, wCommon, hEnemyCityDefense,
|
|---|
| 412 | Back.Canvas.Handle, 3 * wCommon, 0, SRCCOPY);
|
|---|
| 413 | yView := 171;
|
|---|
| 414 | yTotal := 231;
|
|---|
| 415 | end;
|
|---|
| 416 | dkEnemyCity:
|
|---|
| 417 | begin
|
|---|
| 418 | bitblt(offscreen.Canvas.Handle, 0, 0, wCommon, hEnemyCity,
|
|---|
| 419 | Back.Canvas.Handle, 4 * wCommon, 0, SRCCOPY);
|
|---|
| 420 | end;
|
|---|
| 421 | end;
|
|---|
| 422 | MarkUsedOffscreen(ClientWidth, ClientHeight);
|
|---|
| 423 | HelpBtn.Top := yTotal + 22;
|
|---|
| 424 |
|
|---|
| 425 | if Kind in [dkEnemyCityDefense, dkEnemyCity] then
|
|---|
| 426 | begin // show city defense facilities
|
|---|
| 427 | Cnt := 0;
|
|---|
| 428 | for i := 0 to 3 do
|
|---|
| 429 | if MyRO.EnemyCity[ecixShow].Flags and (2 shl i) <> 0 then
|
|---|
| 430 | inc(Cnt);
|
|---|
| 431 | x := (wCommon - Cnt * xSizeSmall) div 2 - (Cnt - 1) * 2;
|
|---|
| 432 | for i := 0 to 3 do
|
|---|
| 433 | if MyRO.EnemyCity[ecixShow].Flags and (2 shl i) <> 0 then
|
|---|
| 434 | begin
|
|---|
| 435 | case i of
|
|---|
| 436 | 0:
|
|---|
| 437 | j := imWalls;
|
|---|
| 438 | 1:
|
|---|
| 439 | j := imCoastalFort;
|
|---|
| 440 | 2:
|
|---|
| 441 | j := imMissileBat;
|
|---|
| 442 | 3:
|
|---|
| 443 | j := imBunker
|
|---|
| 444 | end;
|
|---|
| 445 | Frame(offscreen.Canvas, x - 1, yImp - 1, x + xSizeSmall,
|
|---|
| 446 | yImp + ySizeSmall, MainTexture.clBevelLight,
|
|---|
| 447 | MainTexture.clBevelShade);
|
|---|
| 448 | bitblt(offscreen.Canvas.Handle, x, yImp, xSizeSmall, ySizeSmall,
|
|---|
| 449 | SmallImp.Canvas.Handle, j mod 7 * xSizeSmall,
|
|---|
| 450 | (j + SystemIconLines * 7) div 7 * ySizeSmall, SRCCOPY);
|
|---|
| 451 | inc(x, xSizeSmall + 4)
|
|---|
| 452 | end;
|
|---|
| 453 | end;
|
|---|
| 454 |
|
|---|
| 455 | if Kind = dkEnemyModel then
|
|---|
| 456 | begin
|
|---|
| 457 | PPicture := @Tribe[mox.owner].ModelPicture[mox.mix];
|
|---|
| 458 | Available := 0;
|
|---|
| 459 | if G.Difficulty[me] = 0 then // supervisor -- count stacked units too
|
|---|
| 460 | for Loc := 0 to G.lx * G.ly - 1 do
|
|---|
| 461 | begin
|
|---|
| 462 | if MyMap[Loc] and fUnit <> 0 then
|
|---|
| 463 | begin
|
|---|
| 464 | Server(sGetUnits, me, Loc, Cnt);
|
|---|
| 465 | for uix := 0 to Cnt - 1 do
|
|---|
| 466 | if IsToCount(MyRO.EnemyUn[MyRO.nEnemyUn + uix].emix) then
|
|---|
| 467 | inc(Available);
|
|---|
| 468 | end
|
|---|
| 469 | end
|
|---|
| 470 | else // no supervisor -- can only count stack top units
|
|---|
| 471 | for uix := 0 to MyRO.nEnemyUn - 1 do
|
|---|
| 472 | if (MyRO.EnemyUn[uix].Loc >= 0) and IsToCount(MyRO.EnemyUn[uix].emix)
|
|---|
| 473 | then
|
|---|
| 474 | inc(Available);
|
|---|
| 475 | Destroyed := 0;
|
|---|
| 476 | for emix := 0 to MyRO.nEnemyModel - 1 do
|
|---|
| 477 | if IsToCount(emix) then
|
|---|
| 478 | inc(Destroyed, MyRO.EnemyModel[emix].Lost);
|
|---|
| 479 | end
|
|---|
| 480 | else
|
|---|
| 481 | begin
|
|---|
| 482 | Available := 0;
|
|---|
| 483 | for uix := 0 to MyRO.nUn - 1 do
|
|---|
| 484 | if (MyUn[uix].Loc >= 0) and (MyUn[uix].mix = mixShow) then
|
|---|
| 485 | inc(Available);
|
|---|
| 486 | InProd := 0;
|
|---|
| 487 | for cix := 0 to MyRO.nCity - 1 do
|
|---|
| 488 | if (MyCity[cix].Loc >= 0) and
|
|---|
| 489 | (MyCity[cix].Project and (cpImp + cpIndex) = mixShow) then
|
|---|
| 490 | inc(InProd);
|
|---|
| 491 | end;
|
|---|
| 492 |
|
|---|
| 493 | offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
|
|---|
| 494 | if Kind in [dkEnemyCityDefense, dkEnemyCity] then
|
|---|
| 495 | begin
|
|---|
| 496 | NoMap.SetOutput(offscreen);
|
|---|
| 497 | NoMap.PaintCity(ClientWidth div 2, 53, MyRO.EnemyCity[ecixShow], false);
|
|---|
| 498 |
|
|---|
| 499 | s := Tribe[MyRO.EnemyCity[ecixShow].owner].TPhrase('UNITOWNER');
|
|---|
| 500 | LoweredTextOut(offscreen.Canvas, -1, MainTexture,
|
|---|
| 501 | (ClientWidth - BiColorTextWidth(offscreen.Canvas, s)) div 2, 105, s);
|
|---|
| 502 | end;
|
|---|
| 503 |
|
|---|
| 504 | if Kind <> dkEnemyCity then
|
|---|
| 505 | begin // show unit stats
|
|---|
| 506 | if Kind = dkOwnModel then
|
|---|
| 507 | MakeModelInfo(me, mixShow, MyModel[mixShow], mi)
|
|---|
| 508 | else if Kind = dkOwnUnit then
|
|---|
| 509 | begin
|
|---|
| 510 | MakeUnitInfo(me, MyUn[uixShow], ui);
|
|---|
| 511 | MakeModelInfo(me, MyUn[uixShow].mix, MyModel[MyUn[uixShow].mix], mi)
|
|---|
| 512 | end
|
|---|
| 513 | else
|
|---|
| 514 | begin
|
|---|
| 515 | mi := mox^;
|
|---|
| 516 | if Kind in [dkEnemyUnit, dkEnemyCityDefense] then
|
|---|
| 517 | ui := MyRO.EnemyUn[euixShow]
|
|---|
| 518 | end;
|
|---|
| 519 |
|
|---|
| 520 | with Tribe[mi.owner].ModelPicture[mi.mix] do
|
|---|
| 521 | begin
|
|---|
| 522 | if Kind in [dkOwnUnit, dkEnemyUnit, dkEnemyCityDefense] then
|
|---|
| 523 | with ui do
|
|---|
| 524 | begin
|
|---|
| 525 | { Frame(offscreen.canvas,xView-1,yView-1,xView+64,yView+48,
|
|---|
| 526 | MainTexture.clBevelShade,MainTexture.clBevelLight);
|
|---|
| 527 | RFrame(offscreen.canvas,xView-2,yView-2,xView+65,yView+49,
|
|---|
| 528 | MainTexture.clBevelShade,MainTexture.clBevelLight); }
|
|---|
| 529 | with offscreen.Canvas do
|
|---|
| 530 | begin
|
|---|
| 531 | Brush.Color := GrExt[HGrSystem].Data.Canvas.Pixels[98, 67];
|
|---|
| 532 | offscreen.Canvas.FillRect(Rect(xView, yView, xView + 64,
|
|---|
| 533 | yView + 16));
|
|---|
| 534 | Brush.Style := bsClear;
|
|---|
| 535 | end;
|
|---|
| 536 |
|
|---|
| 537 | if MyMap[Loc] and fTerrain >= fForest then
|
|---|
| 538 | begin
|
|---|
| 539 | x := 1 + 2 * (xxt * 2 + 1);
|
|---|
| 540 | y := 1 + yyt + 2 * (yyt * 3 + 1)
|
|---|
| 541 | end
|
|---|
| 542 | else
|
|---|
| 543 | begin
|
|---|
| 544 | x := integer(MyMap[Loc] and fTerrain) * (xxt * 2 + 1) + 1;
|
|---|
| 545 | y := 1 + yyt
|
|---|
| 546 | end;
|
|---|
| 547 | for j := -1 to 1 do
|
|---|
| 548 | for i := -1 to 1 do
|
|---|
| 549 | if (i + j) and 1 = 0 then
|
|---|
| 550 | begin
|
|---|
| 551 | Sprite(Buffer, HGrTerrain, i * xxt, j * yyt, xxt * 2,
|
|---|
| 552 | yyt * 2, x, y);
|
|---|
| 553 | if MyMap[Loc] and (fTerrain or fSpecial) = fGrass or fSpecial1
|
|---|
| 554 | then
|
|---|
| 555 | Sprite(Buffer, HGrTerrain, i * xxt, j * yyt, xxt * 2, yyt * 2,
|
|---|
| 556 | 1 + 2 * (xxt * 2 + 1), 1 + yyt + 1 * (yyt * 3 + 1))
|
|---|
| 557 | else if (MyMap[Loc] and fTerrain = fForest) and
|
|---|
| 558 | IsJungle(Loc div G.lx) then
|
|---|
| 559 | Sprite(Buffer, HGrTerrain, i * xxt, j * yyt, xxt * 2, yyt * 2,
|
|---|
| 560 | 1 + 7 * (xxt * 2 + 1), 1 + yyt + 19 * (yyt * 3 + 1))
|
|---|
| 561 | else if MyMap[Loc] and fTerrain >= fForest then
|
|---|
| 562 | Sprite(Buffer, HGrTerrain, i * xxt, j * yyt, xxt * 2, yyt * 2,
|
|---|
| 563 | 1 + 7 * (xxt * 2 + 1),
|
|---|
| 564 | 1 + yyt + 2 * integer(2 + MyMap[Loc] and fTerrain - fForest)
|
|---|
| 565 | * (yyt * 3 + 1));
|
|---|
| 566 | end;
|
|---|
| 567 | bitblt(offscreen.Canvas.Handle, xView, yView + 16, 64, 32,
|
|---|
| 568 | Buffer.Canvas.Handle, 1, 0, SRCCOPY);
|
|---|
| 569 |
|
|---|
| 570 | // show unit, experience and health
|
|---|
| 571 | Sprite(offscreen, HGr, xView, yView, 64, 48, pix mod 10 * 65 + 1,
|
|---|
| 572 | pix div 10 * 49 + 1);
|
|---|
| 573 | if Flags and unFortified <> 0 then
|
|---|
| 574 | Sprite(offscreen, HGrStdUnits, xView, yView, xxu * 2, yyu * 2,
|
|---|
| 575 | 1 + 6 * (xxu * 2 + 1), 1);
|
|---|
| 576 | FrameImage(offscreen.Canvas, GrExt[HGrSystem].Data, xView - 20,
|
|---|
| 577 | yView + 5, 12, 14, 121 + Exp div ExpCost * 13, 28);
|
|---|
| 578 | if Health < 100 then
|
|---|
| 579 | begin
|
|---|
| 580 | s := IntToStr(Health) + '%';
|
|---|
| 581 | LightGradient(offscreen.Canvas, xView - 45, yView + 24, 38,
|
|---|
| 582 | (ColorOfHealth(Health) and $FEFEFE shr 2) * 3);
|
|---|
| 583 | RisedTextout(offscreen.Canvas, xView - 45 + 20 -
|
|---|
| 584 | BiColorTextWidth(offscreen.Canvas, s) div 2, yView + 23, s);
|
|---|
| 585 | end;
|
|---|
| 586 |
|
|---|
| 587 | if Kind = dkEnemyUnit then
|
|---|
| 588 | begin
|
|---|
| 589 | s := Tribe[mox.owner].TPhrase('UNITOWNER');
|
|---|
| 590 | LoweredTextOut(offscreen.Canvas, -1, MainTexture,
|
|---|
| 591 | (ClientWidth - BiColorTextWidth(offscreen.Canvas, s)) div 2,
|
|---|
| 592 | yView + 80, s);
|
|---|
| 593 | end
|
|---|
| 594 | end
|
|---|
| 595 | else
|
|---|
| 596 | begin
|
|---|
| 597 | FrameImage(offscreen.Canvas, BigImp, xView + 4, yView, 56, 40, 0, 0);
|
|---|
| 598 | Sprite(offscreen, HGr, xView, yView - 4, 64, 44, pix mod 10 * 65 + 1,
|
|---|
| 599 | pix div 10 * 49 + 1);
|
|---|
| 600 | end;
|
|---|
| 601 |
|
|---|
| 602 | DarkGradient(offscreen.Canvas, xTotal - 6, yTotal + 1, 180, 2);
|
|---|
| 603 | RisedTextout(offscreen.Canvas, xTotal - 2, yTotal,
|
|---|
| 604 | Phrases.Lookup('UNITSTRENGTH'));
|
|---|
| 605 | s := IntToStr(mi.Attack) + '/' + IntToStr(mi.Defense);
|
|---|
| 606 | RisedTextout(offscreen.Canvas,
|
|---|
| 607 | xTotal + 170 - BiColorTextWidth(offscreen.Canvas, s), yTotal, s);
|
|---|
| 608 | FeatureBar(offscreen, xTotal, yTotal + 19, mi, MainTexture);
|
|---|
| 609 | NumberBarS(offscreen, xTotal, yTotal + 38, Phrases.Lookup('UNITSPEED'),
|
|---|
| 610 | MovementToString(mi.Speed), MainTexture);
|
|---|
| 611 | LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2, yTotal + 57,
|
|---|
| 612 | Phrases.Lookup('UNITCOST'));
|
|---|
| 613 | DLine(offscreen.Canvas, xTotal - 2, xTotal + 170, yTotal + 57 + 16,
|
|---|
| 614 | MainTexture.clBevelShade, MainTexture.clBevelLight);
|
|---|
| 615 | if G.Difficulty[me] = 0 then
|
|---|
| 616 | s := IntToStr(mi.cost)
|
|---|
| 617 | else
|
|---|
| 618 | s := IntToStr(mi.cost * BuildCostMod[G.Difficulty[me]] div 12);
|
|---|
| 619 | RisedTextout(offscreen.Canvas,
|
|---|
| 620 | xTotal + 159 - BiColorTextWidth(offscreen.Canvas, s), yTotal + 57, s);
|
|---|
| 621 | Sprite(offscreen, HGrSystem, xTotal + 160, yTotal + 57 + 5, 10,
|
|---|
| 622 | 10, 88, 115);
|
|---|
| 623 |
|
|---|
| 624 | if Kind = dkOwnModel then
|
|---|
| 625 | begin
|
|---|
| 626 | if MyModel[mixShow].IntroTurn > 0 then
|
|---|
| 627 | begin
|
|---|
| 628 | if MyModel[mixShow].Kind = mkEnemyDeveloped then
|
|---|
| 629 | LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2,
|
|---|
| 630 | (yTotal + StatDown - 19), Phrases.Lookup('UNITADOPT'))
|
|---|
| 631 | else
|
|---|
| 632 | LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2,
|
|---|
| 633 | (yTotal + StatDown - 19), Phrases.Lookup('UNITINTRO'));
|
|---|
| 634 | DLine(offscreen.Canvas, xTotal - 2, xTotal + 170,
|
|---|
| 635 | (yTotal + StatDown - 19) + 16, MainTexture.clTextShade,
|
|---|
| 636 | MainTexture.clTextLight);
|
|---|
| 637 | s := TurnToString(MyModel[mixShow].IntroTurn);
|
|---|
| 638 | RisedTextout(offscreen.Canvas,
|
|---|
| 639 | xTotal + 170 - BiColorTextWidth(offscreen.Canvas, s),
|
|---|
| 640 | (yTotal + StatDown - 19), s);
|
|---|
| 641 | end;
|
|---|
| 642 |
|
|---|
| 643 | NumberBar(offscreen, xTotal, yTotal + StatDown,
|
|---|
| 644 | Phrases.Lookup('UNITBUILT'), MyModel[mixShow].Built, MainTexture);
|
|---|
| 645 | if MyModel[mixShow].Lost > 0 then
|
|---|
| 646 | NumberBar(offscreen, xTotal, yTotal + StatDown + 19,
|
|---|
| 647 | Phrases.Lookup('UNITLOST'), MyModel[mixShow].Lost, MainTexture);
|
|---|
| 648 | if InProd > 0 then
|
|---|
| 649 | NumberBar(offscreen, xTotal, yTotal + StatDown + 57,
|
|---|
| 650 | Phrases.Lookup('UNITINPROD'), InProd, MainTexture);
|
|---|
| 651 | if Available > 0 then
|
|---|
| 652 | NumberBar(offscreen, xTotal, yTotal + StatDown + 38,
|
|---|
| 653 | Phrases.Lookup('UNITAVAILABLE'), Available, MainTexture);
|
|---|
| 654 |
|
|---|
| 655 | if MyModel[mixShow].Status and msObsolete <> 0 then
|
|---|
| 656 | begin
|
|---|
| 657 | SwitchBtn.ButtonIndex := 12;
|
|---|
| 658 | SwitchBtn.Hint := Phrases.Lookup('BTN_OBSOLETE');
|
|---|
| 659 | end
|
|---|
| 660 | else
|
|---|
| 661 | begin
|
|---|
| 662 | SwitchBtn.ButtonIndex := 11;
|
|---|
| 663 | SwitchBtn.Hint := Phrases.Lookup('BTN_NONOBSOLETE');
|
|---|
| 664 | end;
|
|---|
| 665 | if MyModel[mixShow].Status and msAllowConscripts = 0 then
|
|---|
| 666 | begin
|
|---|
| 667 | ConscriptsBtn.ButtonIndex := 30;
|
|---|
| 668 | ConscriptsBtn.Hint := Phrases.Lookup('BTN_NOCONSCRIPTS');
|
|---|
| 669 | end
|
|---|
| 670 | else
|
|---|
| 671 | begin
|
|---|
| 672 | ConscriptsBtn.ButtonIndex := 29;
|
|---|
| 673 | ConscriptsBtn.Hint := Phrases.Lookup('BTN_ALLOWCONSCRIPTS');
|
|---|
| 674 | end
|
|---|
| 675 | end
|
|---|
| 676 | else if Kind = dkEnemyModel then
|
|---|
| 677 | begin
|
|---|
| 678 | if Destroyed > 0 then
|
|---|
| 679 | NumberBar(offscreen, xTotal, yTotal + StatDown - 19,
|
|---|
| 680 | Phrases.Lookup('UNITDESTROYED'), Destroyed, MainTexture);
|
|---|
| 681 | if Available > 0 then
|
|---|
| 682 | NumberBar(offscreen, xTotal, yTotal + StatDown,
|
|---|
| 683 | Phrases.Lookup('UNITKNOWN'), Available, MainTexture);
|
|---|
| 684 | end
|
|---|
| 685 | end;
|
|---|
| 686 | end;
|
|---|
| 687 |
|
|---|
| 688 | offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
|
|---|
| 689 | case Kind of
|
|---|
| 690 | dkOwnModel, dkEnemyModel:
|
|---|
| 691 | yCaption := yView + 46;
|
|---|
| 692 | dkEnemyUnit, dkOwnUnit:
|
|---|
| 693 | yCaption := yView + 54;
|
|---|
| 694 | dkEnemyCityDefense, dkEnemyCity:
|
|---|
| 695 | yCaption := 79;
|
|---|
| 696 | end;
|
|---|
| 697 | RisedTextout(offscreen.Canvas,
|
|---|
| 698 | (ClientWidth - BiColorTextWidth(offscreen.Canvas, Caption)) div 2,
|
|---|
| 699 | yCaption, Caption);
|
|---|
| 700 | end; { OffscreenPaint }
|
|---|
| 701 |
|
|---|
| 702 | procedure TUnitStatDlg.ModelBoxChange(Sender: TObject);
|
|---|
| 703 | begin
|
|---|
| 704 | SmartUpdateContent
|
|---|
| 705 | end;
|
|---|
| 706 |
|
|---|
| 707 | procedure TUnitStatDlg.SwitchBtnClick(Sender: TObject);
|
|---|
| 708 | begin
|
|---|
| 709 | MyModel[mixShow].Status := MyModel[mixShow].Status xor msObsolete;
|
|---|
| 710 | if MyModel[mixShow].Status and msObsolete <> 0 then
|
|---|
| 711 | begin
|
|---|
| 712 | SwitchBtn.ButtonIndex := 12;
|
|---|
| 713 | SwitchBtn.Hint := Phrases.Lookup('BTN_OBSOLETE');
|
|---|
| 714 | end
|
|---|
| 715 | else
|
|---|
| 716 | begin
|
|---|
| 717 | SwitchBtn.ButtonIndex := 11;
|
|---|
| 718 | SwitchBtn.Hint := Phrases.Lookup('BTN_NONOBSOLETE');
|
|---|
| 719 | end
|
|---|
| 720 | end;
|
|---|
| 721 |
|
|---|
| 722 | procedure TUnitStatDlg.ConscriptsBtnClick(Sender: TObject);
|
|---|
| 723 | begin
|
|---|
| 724 | MyModel[mixShow].Status := MyModel[mixShow].Status xor msAllowConscripts;
|
|---|
| 725 | if MyModel[mixShow].Status and msAllowConscripts = 0 then
|
|---|
| 726 | begin
|
|---|
| 727 | ConscriptsBtn.ButtonIndex := 30;
|
|---|
| 728 | ConscriptsBtn.Hint := Phrases.Lookup('BTN_NOCONSCRIPTS');
|
|---|
| 729 | end
|
|---|
| 730 | else
|
|---|
| 731 | begin
|
|---|
| 732 | ConscriptsBtn.ButtonIndex := 29;
|
|---|
| 733 | ConscriptsBtn.Hint := Phrases.Lookup('BTN_ALLOWCONSCRIPTS');
|
|---|
| 734 | end
|
|---|
| 735 | end;
|
|---|
| 736 |
|
|---|
| 737 | procedure TUnitStatDlg.HelpBtnClick(Sender: TObject);
|
|---|
| 738 | begin
|
|---|
| 739 | HelpDlg.ShowNewContent(wmPersistent, hkModel, 0)
|
|---|
| 740 | end;
|
|---|
| 741 |
|
|---|
| 742 | end.
|
|---|