Ignore:
Timestamp:
Nov 28, 2023, 3:16:24 PM (6 months ago)
Author:
chronos
Message:
  • Modified: Do not initialize all local player windows at the start of the game but later when they are really opened. This also fixes window initialization under Qt5 widgetset.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/UnitStat.pas

    r456 r460  
    55
    66uses
    7   Protocol, ClientTools, Term, ScreenTools, BaseWin,
    8   LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms,
    9   ButtonB, ButtonC, IsoEngine;
     7  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: TBitmap;
     37    Template: TBitmap;
     38    procedure OffscreenPaint; override;
    2839  public
    2940    procedure CheckAge;
     
    3445    procedure ShowNewContent_EnemyModel(NewMode: TWindowMode; emix: Integer);
    3546    procedure ShowNewContent_EnemyCity(NewMode: TWindowMode; 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: TBitmap;
    45     procedure OffscreenPaint; override;
    46   end;
    47 
    48 var
    49   UnitStatDlg: TUnitStatDlg;
     47  end;
     48
    5049
    5150implementation
    5251
    5352uses
    54   Tribes, Help, Directories, Texture;
     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 := TBitmap.Create;
    8685  Template.PixelFormat := pf24bit;
     
    121120procedure TUnitStatDlg.FormShow(Sender: TObject);
    122121var
    123   owner, mix: Integer;
     122  Owner, mix: Integer;
    124123  IsSpecialUnit: Boolean;
    125124begin
     
    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
     
    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 := (Screen.Width - Width) div 2;
    177168    Top := (Screen.Height - Height) div 2;
     
    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;
     
    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;
     
    343331            mcFirstNonCap .. nFeature - 1:
    344332              if mi.Cap and (1 shl (I - mcFirstNonCap)) <> 0 then
    345                 num := 1
     333                num := 1;
    346334          end;
    347335          if (num > 0) and
     
    357345              Brush.Style := bsClear;
    358346              Textout(X - 3 + dx + 1, Y, S);
    359               Inc(dx, W + 1)
     347              Inc(dx, W + 1);
    360348            end;
    361349            Brush.Color := $C0C0C0;
     
    364352            Sprite(dst, HGrSystem, X - 1 + dx, Y + 4, 10, 10,
    365353              66 + I mod 11 * 11, 137 + I div 11 * 11);
    366             Inc(dx, 15)
     354            Inc(dx, 15);
    367355          end;
    368356        end;
    369357      end;
    370   end; { featurebar }
     358  end;
    371359
    372360  procedure NumberBarS(dst: TBitmap; X, Y: Integer; Cap, S: string; T: TTexture);
     
    387375
    388376  case Kind of
    389     dkOwnModel:
    390       begin
    391         BitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hOwnModel,
    392           Back.Canvas, 0, 0);
    393         yView := 13;
    394         yTotal := 92;
    395       end;
    396     dkEnemyModel:
    397       begin
    398         BitBltCanvas(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         BitBltCanvas(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         BitBltCanvas(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         BitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyCity,
    420           Back.Canvas, 4 * wCommon, 0);
    421       end;
     377    dkOwnModel: begin
     378      BitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hOwnModel,
     379        Back.Canvas, 0, 0);
     380      yView := 13;
     381      yTotal := 92;
     382    end;
     383    dkEnemyModel: begin
     384      BitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyModel,
     385        Back.Canvas, wCommon, 0);
     386      yView := 13;
     387      yTotal := 92;
     388    end;
     389    dkEnemyUnit, dkOwnUnit: begin
     390      BitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyUnit,
     391        Back.Canvas, 2 * wCommon, 0);
     392      yView := 13;
     393      yTotal := 123;
     394    end;
     395    dkEnemyCityDefense: begin
     396      BitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyCityDefense,
     397        Back.Canvas, 3 * wCommon, 0);
     398      yView := 171;
     399      yTotal := 231;
     400    end;
     401    dkEnemyCity: begin
     402      BitBltCanvas(Offscreen.Canvas, 0, 0, wCommon, hEnemyCity,
     403        Back.Canvas, 4 * wCommon, 0);
     404    end;
    422405  end;
    423406  MarkUsedOffscreen(ClientWidth, ClientHeight);
     
    438421          1: J := imCoastalFort;
    439422          2: J := imMissileBat;
    440           3: J := imBunker
     423          3: J := imBunker;
    441424        end;
    442425        Frame(Offscreen.Canvas, X - 1, yImp - 1, X + xSizeSmall,
     
    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.