Ignore:
Timestamp:
Nov 30, 2023, 10:16:14 PM (5 months ago)
Author:
chronos
Message:
  • Modified: Updated high dpi branch from trunk.
  • Modified: Use generics.collections instead of fgl.
  • Modified: Compile with Delphi syntax.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/LocalPlayer/UnitStat.pas

    r405 r465  
    55
    66uses
    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;
    109
    1110type
     11  TUnitStatDialogKind = (dkOwnModel, dkOwnUnit, dkEnemyModel, dkEnemyUnit,
     12    dkEnemyCityDefense, dkEnemyCity);
     13
    1214  TUnitStatDlg = class(TBufferedDrawDlg)
    1315    SwitchBtn: TButtonB;
     
    2628  private
    2729    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;
    2839  public
    2940    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
    5049
    5150implementation
    5251
    5352uses
    54   Tribes, Help, Directories, UTexture;
     53  Term, Tribes, Help, Directories, Texture;
    5554
    5655{$R *.lfm}
     
    8281  Back.PixelFormat := pf24bit;
    8382  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);
    8584  Template := TDpiBitmap.Create;
    8685  Template.PixelFormat := pf24bit;
     
    10099  if MainTexture.Age <> AgePrepared then begin
    101100    AgePrepared := MainTexture.Age;
    102     DpiBitCanvas(Back.Canvas, 0, 0, wCommon, hOwnModel,
     101    DpiBitBltCanvas(Back.Canvas, 0, 0, wCommon, hOwnModel,
    103102      MainTexture.Image.Canvas, (MainTexture.Width - wCommon) div 2,
    104103      (MainTexture.Height - hOwnModel) div 2);
    105     DpiBitCanvas(Back.Canvas, wCommon, 0, wCommon, hEnemyModel,
     104    DpiBitBltCanvas(Back.Canvas, wCommon, 0, wCommon, hEnemyModel,
    106105      MainTexture.Image.Canvas, (MainTexture.Width - wCommon) div 2,
    107106      (MainTexture.Height - hEnemyModel) div 2);
    108     DpiBitCanvas(Back.Canvas, 2 * wCommon, 0, wCommon, hEnemyUnit,
     107    DpiBitBltCanvas(Back.Canvas, 2 * wCommon, 0, wCommon, hEnemyUnit,
    109108      MainTexture.Image.Canvas, (MainTexture.Width - wCommon) div 2,
    110109      (MainTexture.Height - hEnemyUnit) div 2);
    111     DpiBitCanvas(Back.Canvas, 3 * wCommon, 0, wCommon, hEnemyCityDefense,
     110    DpiBitBltCanvas(Back.Canvas, 3 * wCommon, 0, wCommon, hEnemyCityDefense,
    112111      MainTexture.Image.Canvas, (MainTexture.Width - wCommon) div 2,
    113112      (MainTexture.Height - hEnemyCityDefense) div 2);
    114     DpiBitCanvas(Back.Canvas, 4 * wCommon, 0, wCommon, hEnemyCity,
     113    DpiBitBltCanvas(Back.Canvas, 4 * wCommon, 0, wCommon, hEnemyCity,
    115114      MainTexture.Image.Canvas, (MainTexture.Width - wCommon) div 2,
    116115      (MainTexture.Height - hEnemyCity) div 2);
     
    121120procedure TUnitStatDlg.FormShow(Sender: TObject);
    122121var
    123   owner, mix: integer;
    124   IsSpecialUnit: boolean;
     122  Owner, mix: Integer;
     123  IsSpecialUnit: Boolean;
    125124begin
    126125  if Kind in [dkEnemyUnit, dkEnemyCityDefense, dkEnemyCity] then
     
    132131        euixShow := MyRO.nEnemyUn - 1;
    133132        while (euixShow >= 0) and (MyRO.EnemyUn[euixShow].Loc <> UnitLoc) do
    134           dec(euixShow);
    135         assert(euixShow >= 0);
     133          Dec(euixShow);
     134        Assert(euixShow >= 0);
    136135      end;
    137136      with MyRO.EnemyUn[euixShow] do
    138137      begin
    139138        mox := @MyRO.EnemyModel[emix];
    140         if not Assigned(Tribe[owner].ModelPicture[mix].HGr) then
     139        if not Assigned(Tribe[Owner].ModelPicture[mix].HGr) then
    141140          InitEnemyModel(emix);
    142       end
     141      end;
    143142    end
    144143    else
     
    148147      ecixShow := MyRO.nEnemyCity - 1;
    149148      while (ecixShow >= 0) and (MyRO.EnemyCity[ecixShow].Loc <> UnitLoc) do
    150         dec(ecixShow);
    151       assert(ecixShow >= 0);
     149        Dec(ecixShow);
     150      Assert(ecixShow >= 0);
    152151    end;
    153152  end;
    154153  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;
    167160  end;
    168161
     
    171164    Left := UserLeft;
    172165    Top := UserTop;
    173   end
    174   else
    175   begin
     166  end else begin
    176167    Left := (DpiScreen.Width - Width) div 2;
    177168    Top := (DpiScreen.Height - Height) div 2;
    178169  end;
    179170
    180   SwitchBtn.Visible := not supervising and (Kind = dkOwnModel);
    181   ConscriptsBtn.Visible := not supervising and (Kind = dkOwnModel) and
     171  SwitchBtn.Visible := not Supervising and (Kind = dkOwnModel);
     172  ConscriptsBtn.Visible := not Supervising and (Kind = dkOwnModel) and
    182173    (MyRO.Tech[adConscription] >= tsApplicable) and
    183174    (MyModel[mixShow].Domain = dGround) and (MyModel[mixShow].Kind < mkScout);
    184   IsSpecialUnit := false;
     175  IsSpecialUnit := False;
    185176  if Kind in [dkEnemyCity, dkEnemyCityDefense] then
    186177    Caption := CityName(MyRO.EnemyCity[ecixShow].ID)
     
    188179  begin
    189180    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;
    205193        mix := mox.mix;
    206194        IsSpecialUnit := mox.Kind >= $10;
     
    218206end;
    219207
    220 procedure TUnitStatDlg.ShowNewContent_OwnModel(NewMode, mix: integer);
     208procedure TUnitStatDlg.ShowNewContent_OwnModel(NewMode: TWindowMode; mix: Integer);
    221209begin
    222210  Kind := dkOwnModel;
     
    225213end;
    226214
    227 procedure TUnitStatDlg.ShowNewContent_OwnUnit(NewMode, uix: integer);
     215procedure TUnitStatDlg.ShowNewContent_OwnUnit(NewMode: TWindowMode; uix: Integer);
    228216begin
    229217  Kind := dkOwnUnit;
     
    232220end;
    233221
    234 procedure TUnitStatDlg.ShowNewContent_EnemyUnit(NewMode, euix: integer);
     222procedure TUnitStatDlg.ShowNewContent_EnemyUnit(NewMode: TWindowMode; euix: Integer);
    235223begin
    236224  Kind := dkEnemyUnit;
     
    240228end;
    241229
    242 procedure TUnitStatDlg.ShowNewContent_EnemyLoc(NewMode, Loc: integer);
     230procedure TUnitStatDlg.ShowNewContent_EnemyLoc(NewMode: TWindowMode; Loc: Integer);
    243231begin
    244232  Kind := dkEnemyUnit;
     
    248236end;
    249237
    250 procedure TUnitStatDlg.ShowNewContent_EnemyModel(NewMode, emix: integer);
     238procedure TUnitStatDlg.ShowNewContent_EnemyModel(NewMode: TWindowMode; emix: Integer);
    251239begin
    252240  Kind := dkEnemyModel;
     
    255243end;
    256244
    257 procedure TUnitStatDlg.ShowNewContent_EnemyCity(NewMode, Loc: integer);
     245procedure TUnitStatDlg.ShowNewContent_EnemyCity(NewMode: TWindowMode; Loc: Integer);
    258246begin
    259247  if MyMap[Loc] and fUnit <> 0 then
     
    271259  begin
    272260    UserLeft := Left;
    273     UserTop := Top
    274   end;
    275   if OffscreenUser = self then
     261    UserTop := Top;
     262  end;
     263  if OffscreenUser = Self then
    276264    OffscreenUser := nil;
    277265end;
     
    286274  PPicture: ^TModelPicture;
    287275
    288   function IsToCount(emix: integer): boolean;
     276  function IsToCount(emix: Integer): Boolean;
    289277  var
    290278    PTestPicture: ^TModelPicture;
     
    294282      PTestPicture := @Tribe[MyRO.EnemyModel[emix].owner].ModelPicture
    295283        [MyRO.EnemyModel[emix].mix];
    296       result := (PPicture.HGr = PTestPicture.HGr) and
     284      Result := (PPicture.HGr = PTestPicture.HGr) and
    297285        (PPicture.pix = PTestPicture.pix) and
    298286        (ModelHash(mox^) = ModelHash(MyRO.EnemyModel[emix]));
    299287    end
    300288    else
    301       result := (MyRO.EnemyModel[emix].owner = mox.owner) and
     289      Result := (MyRO.EnemyModel[emix].owner = mox.owner) and
    302290        (MyRO.EnemyModel[emix].mix = mox.mix);
    303291  end;
    304292
    305   procedure FeatureBar(dst: TDpiBitmap; x, y: integer; const mi: TModelInfo;
     293  procedure FeatureBar(dst: TDpiBitmap; X, Y: Integer; const mi: TModelInfo;
    306294    T: TTexture);
    307295  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);
    312300    with dst.Canvas do
    313301      if mi.Kind >= $10 then
    314302      begin
    315         s := Phrases.Lookup('UNITSPECIAL');
     303        S := Phrases.Lookup('UNITSPECIAL');
    316304        Font.Color := $000000;
    317         Textout(x - 1, y + 1, s);
     305        Textout(X - 1, Y + 1, S);
    318306        Font.Color := $B0B0B0;
    319         Textout(x - 2, y, s);
     307        Textout(X - 2, Y, S);
    320308      end
    321309      else
     
    323311        Font.Color := $000000;
    324312        dx := 2;
    325         for i := 3 to nFeature - 1 do
     313        for I := 3 to nFeature - 1 do
    326314        begin
    327315          num := 0;
    328           case i of
     316          case I of
    329317            mcSeaTrans:
    330318              if mi.Domain = dSea then
     
    342330                num := mi.TTrans;
    343331            mcFirstNonCap .. nFeature - 1:
    344               if mi.Cap and (1 shl (i - mcFirstNonCap)) <> 0 then
    345                 num := 1
     332              if mi.Cap and (1 shl (I - mcFirstNonCap)) <> 0 then
     333                num := 1;
    346334          end;
    347335          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))
    349337          then
    350338          begin
    351339            if num > 1 then
    352340            begin
    353               s := IntToStr(num);
    354               w := TextWidth(s);
     341              S := IntToStr(num);
     342              W := TextWidth(S);
    355343              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));
    357345              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);
    360348            end;
    361349            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));
    363351            Brush.Style := bsClear;
    364             Sprite(dst, HGrSystem, x - 1 + dx, y + 4, 10, 10,
    365               66 + i mod 11 * 11, 137 + i div 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);
    367355          end;
    368356        end;
    369357      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);
    377365  end;
    378366
    379367var
    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;
    383371  ui: TUnitInfo;
    384372  mi: TModelInfo;
     
    387375
    388376  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;
    422405  end;
    423406  MarkUsedOffscreen(ClientWidth, ClientHeight);
     
    427410  begin // show city defense facilities
    428411    Cnt := 0;
    429     for i := 0 to 3 do
    430       if MyRO.EnemyCity[ecixShow].Flags and (2 shl i) <> 0 then
    431         inc(Cnt);
    432     x := (wCommon - Cnt * xSizeSmall) div 2 - (Cnt - 1) * 2;
    433     for i := 0 to 3 do
    434       if MyRO.EnemyCity[ecixShow].Flags and (2 shl i) <> 0 then
    435       begin
    436         case i of
    437           0: j := imWalls;
    438           1: j := imCoastalFort;
    439           2: j := imMissileBat;
    440           3: j := imBunker
     412    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;
    441424        end;
    442         Frame(offscreen.Canvas, x - 1, yImp - 1, x + xSizeSmall,
     425        Frame(Offscreen.Canvas, X - 1, yImp - 1, X + xSizeSmall,
    443426          yImp + ySizeSmall, MainTexture.ColorBevelLight,
    444427          MainTexture.ColorBevelShade);
    445         DpiBitCanvas(offscreen.Canvas, x, yImp, xSizeSmall, ySizeSmall,
    446           SmallImp.Canvas, j mod 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);
    449432      end;
    450433  end;
     
    454437    PPicture := @Tribe[mox.owner].ModelPicture[mox.mix];
    455438    Available := 0;
    456     if G.Difficulty[me] = 0 then // supervisor -- count stacked units too
     439    if G.Difficulty[Me] = 0 then // supervisor -- count stacked units too
    457440      for Loc := 0 to G.lx * G.ly - 1 do
    458441      begin
    459442        if MyMap[Loc] and fUnit <> 0 then
    460443        begin
    461           Server(sGetUnits, me, Loc, Cnt);
     444          Server(sGetUnits, Me, Loc, Cnt);
    462445          for uix := 0 to Cnt - 1 do
    463446            if IsToCount(MyRO.EnemyUn[MyRO.nEnemyUn + uix].emix) then
    464               inc(Available);
     447              Inc(Available);
    465448        end;
    466449      end
     
    469452        if (MyRO.EnemyUn[uix].Loc >= 0) and IsToCount(MyRO.EnemyUn[uix].emix)
    470453        then
    471           inc(Available);
     454          Inc(Available);
    472455    Destroyed := 0;
    473456    for emix := 0 to MyRO.nEnemyModel - 1 do
    474457      if IsToCount(emix) then
    475         inc(Destroyed, MyRO.EnemyModel[emix].Lost);
     458        Inc(Destroyed, MyRO.EnemyModel[emix].Lost);
    476459  end
    477460  else
     
    480463    for uix := 0 to MyRO.nUn - 1 do
    481464      if (MyUn[uix].Loc >= 0) and (MyUn[uix].mix = mixShow) then
    482         inc(Available);
     465        Inc(Available);
    483466    InProd := 0;
    484467    for cix := 0 to MyRO.nCity - 1 do
    485468      if (MyCity[cix].Loc >= 0) and
    486469        (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]);
    491474  if Kind in [dkEnemyCityDefense, dkEnemyCity] then
    492475  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);
    499482  end;
    500483
     
    502485  begin // show unit stats
    503486    if Kind = dkOwnModel then
    504       MakeModelInfo(me, mixShow, MyModel[mixShow], mi)
     487      MakeModelInfo(Me, mixShow, MyModel[mixShow], mi)
    505488    else if Kind = dkOwnUnit then
    506489    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);
    509492    end
    510493    else
     
    522505          { Frame(offscreen.canvas,xView-1,yView-1,xView+64,yView+48,
    523506            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,
    525508            MainTexture.ColorBevelShade,MainTexture.ColorBevelLight); }
    526           with offscreen.Canvas do
     509          with Offscreen.Canvas do
    527510          begin
    528511            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,
    530513              yView + 16));
    531514            Brush.Style := bsClear;
     
    534517          if MyMap[Loc] and fTerrain >= fForest then
    535518          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);
    538521          end
    539522          else
    540523          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;
    543526          end;
    544           for j := -1 to 1 do
    545             for i := -1 to 1 do
    546               if (i + j) and 1 = 0 then
     527          for J := -1 to 1 do
     528            for I := -1 to 1 do
     529              if (I + J) and 1 = 0 then
    547530              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);
    550533                if MyMap[Loc] and (fTerrain or fSpecial) = fGrass or fSpecial1
    551534                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,
    553536                    1 + 2 * (xxt * 2 + 1), 1 + yyt + 1 * (yyt * 3 + 1))
    554537                else if (MyMap[Loc] and fTerrain = fForest) and
    555538                  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,
    557540                    1 + 7 * (xxt * 2 + 1), 1 + yyt + 19 * (yyt * 3 + 1))
    558541                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,
    560543                    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)
    562545                    * (yyt * 3 + 1));
    563546              end;
    564           DpiBitCanvas(offscreen.Canvas, xView, yView + 16, 64, 32,
     547          DpiBitBltCanvas(Offscreen.Canvas, xView, yView + 16, 64, 32,
    565548            Buffer.Canvas, 1, 0);
    566549
    567550          // 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,
    569552            pix div 10 * 49 + 1);
    570553          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,
    572555              1 + 6 * (xxu * 2 + 1), 1);
    573           FrameImage(offscreen.Canvas, HGrSystem.Data, xView - 20,
     556          FrameImage(Offscreen.Canvas, HGrSystem.Data, xView - 20,
    574557            yView + 5, 12, 14, 121 + Exp div ExpCost * 13, 28);
    575558          if Health < 100 then
    576559          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,
    579562              (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);
    582565          end;
    583566
    584567          if Kind = dkEnemyUnit then
    585568          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);
    590573          end;
    591574        end
    592575      else
    593576      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,
    596579          pix div 10 * 49 + 1);
    597580      end;
    598581
    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,
    601584        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'),
    607590        MovementToString(mi.Speed), MainTexture);
    608       LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2, yTotal + 57,
     591      LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, yTotal + 57,
    609592        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,
    611594        MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    612       if G.Difficulty[me] = 0 then
    613         s := IntToStr(mi.cost)
     595      if G.Difficulty[Me] = 0 then
     596        S := IntToStr(mi.cost)
    614597      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,
    619602        10, 88, 115);
    620603
     
    624607        begin
    625608          if MyModel[mixShow].Kind = mkEnemyDeveloped then
    626             LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2,
     609            LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2,
    627610              (yTotal + StatDown - 19), Phrases.Lookup('UNITADOPT'))
    628611          else
    629             LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2,
     612            LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2,
    630613              (yTotal + StatDown - 19), Phrases.Lookup('UNITINTRO'));
    631           DLine(offscreen.Canvas, xTotal - 2, xTotal + 170,
     614          DLine(Offscreen.Canvas, xTotal - 2, xTotal + 170,
    632615            (yTotal + StatDown - 19) + 16, MainTexture.ColorTextShade,
    633616            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);
    638621        end;
    639622
    640         NumberBar(offscreen, xTotal, yTotal + StatDown,
     623        NumberBar(Offscreen, xTotal, yTotal + StatDown,
    641624          Phrases.Lookup('UNITBUILT'), MyModel[mixShow].Built, MainTexture);
    642625        if MyModel[mixShow].Lost > 0 then
    643           NumberBar(offscreen, xTotal, yTotal + StatDown + 19,
     626          NumberBar(Offscreen, xTotal, yTotal + StatDown + 19,
    644627            Phrases.Lookup('UNITLOST'), MyModel[mixShow].Lost, MainTexture);
    645628        if InProd > 0 then
    646           NumberBar(offscreen, xTotal, yTotal + StatDown + 57,
     629          NumberBar(Offscreen, xTotal, yTotal + StatDown + 57,
    647630            Phrases.Lookup('UNITINPROD'), InProd, MainTexture);
    648631        if Available > 0 then
    649           NumberBar(offscreen, xTotal, yTotal + StatDown + 38,
     632          NumberBar(Offscreen, xTotal, yTotal + StatDown + 38,
    650633            Phrases.Lookup('UNITAVAILABLE'), Available, MainTexture);
    651634
     
    674657      begin
    675658        if Destroyed > 0 then
    676           NumberBar(offscreen, xTotal, yTotal + StatDown - 19,
     659          NumberBar(Offscreen, xTotal, yTotal + StatDown - 19,
    677660            Phrases.Lookup('UNITDESTROYED'), Destroyed, MainTexture);
    678661        if Available > 0 then
    679           NumberBar(offscreen, xTotal, yTotal + StatDown,
     662          NumberBar(Offscreen, xTotal, yTotal + StatDown,
    680663            Phrases.Lookup('UNITKNOWN'), Available, MainTexture);
    681664      end;
     
    683666  end;
    684667
    685   offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
     668  Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
    686669  case Kind of
    687670    dkOwnModel, dkEnemyModel:
     
    692675      yCaption := 79;
    693676  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,
    696679    yCaption, Caption);
    697 end; { OffscreenPaint }
     680end;
    698681
    699682procedure TUnitStatDlg.ModelBoxChange(Sender: TObject);
     
    734717procedure TUnitStatDlg.HelpBtnClick(Sender: TObject);
    735718begin
    736   HelpDlg.ShowNewContent(wmPersistent, hkModel, 0);
     719  MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkModel, 0);
    737720end;
    738721
Note: See TracChangeset for help on using the changeset viewer.