Ignore:
Timestamp:
May 21, 2020, 6:42:45 PM (4 years ago)
Author:
chronos
Message:
  • Added: TDpiPopupMenu and TDpiMenuItem support.
File:
1 edited

Legend:

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

    r212 r244  
    2626
    2727  TMainScreen = class(TDrawDlg)
    28     mBigTiles: TMenuItem;
     28    mBigTiles: TDpiMenuItem;
    2929    Timer1: TTimer;
    30     GamePopup: TPopupMenu;
    31     UnitPopup: TPopupMenu;
    32     mIrrigation: TMenuItem;
    33     mCity: TMenuItem;
    34     mRoad: TMenuItem;
    35     mMine: TMenuItem;
    36     mPollution: TMenuItem;
    37     mHome: TMenuItem;
    38     mStay: TMenuItem;
    39     mDisband: TMenuItem;
    40     mWait: TMenuItem;
    41     mNoOrders: TMenuItem;
    42     MTrans: TMenuItem;
     30    GamePopup: TDpiPopupMenu;
     31    UnitPopup: TDpiPopupMenu;
     32    mIrrigation: TDpiMenuItem;
     33    mCity: TDpiMenuItem;
     34    mRoad: TDpiMenuItem;
     35    mMine: TDpiMenuItem;
     36    mPollution: TDpiMenuItem;
     37    mHome: TDpiMenuItem;
     38    mStay: TDpiMenuItem;
     39    mDisband: TDpiMenuItem;
     40    mWait: TDpiMenuItem;
     41    mNoOrders: TDpiMenuItem;
     42    MTrans: TDpiMenuItem;
    4343    UnitBtn: TButtonB;
    44     mResign: TMenuItem;
    45     mOptions: TMenuItem;
    46     mEnMoves: TMenuItem;
    47     mWaitTurn: TMenuItem;
    48     mRep: TMenuItem;
    49     mFort: TMenuItem;
    50     mCentre: TMenuItem;
    51     N1: TMenuItem;
    52     mAirBase: TMenuItem;
    53     N5: TMenuItem;
    54     mCityTypes: TMenuItem;
    55     mHelp: TMenuItem;
    56     mCanal: TMenuItem;
    57     mTest: TMenuItem;
    58     mLocCodes: TMenuItem;
    59     mLoad: TMenuItem;
    60     StatPopup: TPopupMenu;
    61     mCityStat: TMenuItem;
    62     mUnitStat: TMenuItem;
    63     mWonders: TMenuItem;
    64     mScienceStat: TMenuItem;
    65     mRR: TMenuItem;
    66     mClear: TMenuItem;
    67     mFarm: TMenuItem;
    68     mAfforest: TMenuItem;
    69     mRep0: TMenuItem;
    70     mRep1: TMenuItem;
    71     mRep2: TMenuItem;
    72     mRep3: TMenuItem;
    73     mRep4: TMenuItem;
    74     mRep5: TMenuItem;
    75     mRep7: TMenuItem;
    76     mRep8: TMenuItem;
    77     mRep9: TMenuItem;
    78     mRep15: TMenuItem;
    79     mCancel: TMenuItem;
    80     mLog: TMenuItem;
    81     mEUnitStat: TMenuItem;
    82     mRep10: TMenuItem;
    83     mEnAttacks: TMenuItem;
    84     mEnNoMoves: TMenuItem;
    85     mDiagram: TMenuItem;
    86     mJump: TMenuItem;
    87     mNations: TMenuItem;
    88     mManip: TMenuItem;
    89     mManip0: TMenuItem;
    90     mManip1: TMenuItem;
    91     mManip2: TMenuItem;
    92     mManip3: TMenuItem;
    93     mManip4: TMenuItem;
    94     mManip5: TMenuItem;
    95     mEnhanceDef: TMenuItem;
    96     mEnhance: TMenuItem;
    97     mShips: TMenuItem;
    98     mMacro: TMenuItem;
    99     mRun: TMenuItem;
    100     N10: TMenuItem;
    101     mRepList: TMenuItem;
    102     mRepScreens: TMenuItem;
    103     mRep11: TMenuItem;
    104     mNames: TMenuItem;
    105     mManip6: TMenuItem;
    106     mRep12: TMenuItem;
    107     mRandomMap: TMenuItem;
    108     mUnload: TMenuItem;
    109     mRecover: TMenuItem;
     44    mResign: TDpiMenuItem;
     45    mOptions: TDpiMenuItem;
     46    mEnMoves: TDpiMenuItem;
     47    mWaitTurn: TDpiMenuItem;
     48    mRep: TDpiMenuItem;
     49    mFort: TDpiMenuItem;
     50    mCentre: TDpiMenuItem;
     51    N1: TDpiMenuItem;
     52    mAirBase: TDpiMenuItem;
     53    N5: TDpiMenuItem;
     54    mCityTypes: TDpiMenuItem;
     55    mHelp: TDpiMenuItem;
     56    mCanal: TDpiMenuItem;
     57    mTest: TDpiMenuItem;
     58    mLocCodes: TDpiMenuItem;
     59    mLoad: TDpiMenuItem;
     60    StatPopup: TDpiPopupMenu;
     61    mCityStat: TDpiMenuItem;
     62    mUnitStat: TDpiMenuItem;
     63    mWonders: TDpiMenuItem;
     64    mScienceStat: TDpiMenuItem;
     65    mRR: TDpiMenuItem;
     66    mClear: TDpiMenuItem;
     67    mFarm: TDpiMenuItem;
     68    mAfforest: TDpiMenuItem;
     69    mRep0: TDpiMenuItem;
     70    mRep1: TDpiMenuItem;
     71    mRep2: TDpiMenuItem;
     72    mRep3: TDpiMenuItem;
     73    mRep4: TDpiMenuItem;
     74    mRep5: TDpiMenuItem;
     75    mRep7: TDpiMenuItem;
     76    mRep8: TDpiMenuItem;
     77    mRep9: TDpiMenuItem;
     78    mRep15: TDpiMenuItem;
     79    mCancel: TDpiMenuItem;
     80    mLog: TDpiMenuItem;
     81    mEUnitStat: TDpiMenuItem;
     82    mRep10: TDpiMenuItem;
     83    mEnAttacks: TDpiMenuItem;
     84    mEnNoMoves: TDpiMenuItem;
     85    mDiagram: TDpiMenuItem;
     86    mJump: TDpiMenuItem;
     87    mNations: TDpiMenuItem;
     88    mManip: TDpiMenuItem;
     89    mManip0: TDpiMenuItem;
     90    mManip1: TDpiMenuItem;
     91    mManip2: TDpiMenuItem;
     92    mManip3: TDpiMenuItem;
     93    mManip4: TDpiMenuItem;
     94    mManip5: TDpiMenuItem;
     95    mEnhanceDef: TDpiMenuItem;
     96    mEnhance: TDpiMenuItem;
     97    mShips: TDpiMenuItem;
     98    mMacro: TDpiMenuItem;
     99    mRun: TDpiMenuItem;
     100    N10: TDpiMenuItem;
     101    mRepList: TDpiMenuItem;
     102    mRepScreens: TDpiMenuItem;
     103    mRep11: TDpiMenuItem;
     104    mNames: TDpiMenuItem;
     105    mManip6: TDpiMenuItem;
     106    mRep12: TDpiMenuItem;
     107    mRandomMap: TDpiMenuItem;
     108    mUnload: TDpiMenuItem;
     109    mRecover: TDpiMenuItem;
    110110    MapBtn0: TButtonC;
    111111    MapBtn1: TButtonC;
    112112    MapBtn4: TButtonC;
    113113    MapBtn5: TButtonC;
    114     EditPopup: TPopupMenu;
    115     mCreateUnit: TMenuItem;
     114    EditPopup: TDpiPopupMenu;
     115    mCreateUnit: TDpiMenuItem;
    116116    MapBtn6: TButtonC;
    117     mDebugMap: TMenuItem;
    118     mUtilize: TMenuItem;
    119     mRep6: TMenuItem;
    120     mEnemyMovement: TMenuItem;
    121     mEnFastMoves: TMenuItem;
    122     mOwnMovement: TMenuItem;
    123     mSlowMoves: TMenuItem;
    124     mFastMoves: TMenuItem;
    125     mVeryFastMoves: TMenuItem;
    126     mGoOn: TMenuItem;
    127     mSound: TMenuItem;
    128     mSoundOn: TMenuItem;
    129     mSoundOnAlt: TMenuItem;
    130     mSoundOff: TMenuItem;
    131     N6: TMenuItem;
     117    mDebugMap: TDpiMenuItem;
     118    mUtilize: TDpiMenuItem;
     119    mRep6: TDpiMenuItem;
     120    mEnemyMovement: TDpiMenuItem;
     121    mEnFastMoves: TDpiMenuItem;
     122    mOwnMovement: TDpiMenuItem;
     123    mSlowMoves: TDpiMenuItem;
     124    mFastMoves: TDpiMenuItem;
     125    mVeryFastMoves: TDpiMenuItem;
     126    mGoOn: TDpiMenuItem;
     127    mSound: TDpiMenuItem;
     128    mSoundOn: TDpiMenuItem;
     129    mSoundOnAlt: TDpiMenuItem;
     130    mSoundOff: TDpiMenuItem;
     131    N6: TDpiMenuItem;
    132132    TerrainBtn: TButtonB;
    133     TerrainPopup: TPopupMenu;
    134     mScrolling: TMenuItem;
    135     mScrollSlow: TMenuItem;
    136     mScrollFast: TMenuItem;
    137     mScrollOff: TMenuItem;
    138     mPillage: TMenuItem;
    139     mSelectTransport: TMenuItem;
    140     mEmpire: TMenuItem;
    141     N4: TMenuItem;
    142     N2: TMenuItem;
    143     mWebsite: TMenuItem;
    144     N3: TMenuItem;
    145     mRevolution: TMenuItem;
    146     mRep13: TMenuItem;
     133    TerrainPopup: TDpiPopupMenu;
     134    mScrolling: TDpiMenuItem;
     135    mScrollSlow: TDpiMenuItem;
     136    mScrollFast: TDpiMenuItem;
     137    mScrollOff: TDpiMenuItem;
     138    mPillage: TDpiMenuItem;
     139    mSelectTransport: TDpiMenuItem;
     140    mEmpire: TDpiMenuItem;
     141    N4: TDpiMenuItem;
     142    N2: TDpiMenuItem;
     143    mWebsite: TDpiMenuItem;
     144    N3: TDpiMenuItem;
     145    mRevolution: TDpiMenuItem;
     146    mRep13: TDpiMenuItem;
    147147    UnitInfoBtn: TButtonB;
    148148    EOT: TEOTButton;
    149     mAllyMovement: TMenuItem;
    150     mAlSlowMoves: TMenuItem;
    151     mAlFastMoves: TMenuItem;
    152     N7: TMenuItem;
    153     mEffectiveMovesOnly: TMenuItem;
    154     N8: TMenuItem;
    155     mAlEffectiveMovesOnly: TMenuItem;
    156     mAlNoMoves: TMenuItem;
    157     N9: TMenuItem;
    158     mViewpoint: TMenuItem;
    159     mTileSize: TMenuItem;
    160     mNormalTiles: TMenuItem;
    161     mSmallTiles: TMenuItem;
    162     N11: TMenuItem;
     149    mAllyMovement: TDpiMenuItem;
     150    mAlSlowMoves: TDpiMenuItem;
     151    mAlFastMoves: TDpiMenuItem;
     152    N7: TDpiMenuItem;
     153    mEffectiveMovesOnly: TDpiMenuItem;
     154    N8: TDpiMenuItem;
     155    mAlEffectiveMovesOnly: TDpiMenuItem;
     156    mAlNoMoves: TDpiMenuItem;
     157    N9: TDpiMenuItem;
     158    mViewpoint: TDpiMenuItem;
     159    mTileSize: TDpiMenuItem;
     160    mNormalTiles: TDpiMenuItem;
     161    mSmallTiles: TDpiMenuItem;
     162    N11: TDpiMenuItem;
    163163    MenuArea: TArea;
    164164    TreasuryArea: TArea;
    165165    ResearchArea: TArea;
    166166    ManagementArea: TArea;
    167     mTechTree: TMenuItem;
     167    mTechTree: TDpiMenuItem;
    168168    MovieSpeed1Btn: TButtonB;
    169169    MovieSpeed2Btn: TButtonB;
    170170    MovieSpeed3Btn: TButtonB;
    171171    MovieSpeed4Btn: TButtonB;
    172     N12: TMenuItem;
    173     mRep14: TMenuItem;
     172    N12: TDpiMenuItem;
     173    mRep14: TDpiMenuItem;
    174174    procedure FormCreate(Sender: TObject);
    175175    procedure FormDestroy(Sender: TObject);
     
    266266    procedure EndNego;
    267267    function IsPanelPixel(x, y: integer): boolean;
    268     procedure InitPopup(Popup: TPopupMenu);
     268    procedure InitPopup(Popup: TDpiPopupMenu);
    269269    procedure SetMapOptions;
    270270    procedure CheckMovieSpeedBtnState;
     
    34483448  for i := 0 to ComponentCount - 1 do
    34493449    if Components[i].Tag and $FF <> 0 then
    3450       if Components[i] is TMenuItem then
    3451       begin
    3452         TMenuItem(Components[i]).Caption := Phrases.Lookup('CONTROLS',
     3450      if Components[i] is TDpiMenuItem then
     3451      begin
     3452        TDpiMenuItem(Components[i]).Caption := Phrases.Lookup('CONTROLS',
    34533453          -1 + Components[i].Tag and $FF);
    34543454        for j := 0 to nSaveOption - 1 do
    34553455          if Components[i].Tag and $FF = SaveOption[j] then
    3456             TMenuItem(Components[i]).Checked := ((1 shl j) and OptionChecked) <> 0;
     3456            TDpiMenuItem(Components[i]).Checked := ((1 shl j) and OptionChecked) <> 0;
    34573457      end
    34583458      else if Components[i] is TButtonBase then
     
    51885188  i, uix, emix, p1, dx, dy, MouseLoc: integer;
    51895189  EditTileData: TEditTileData;
    5190   m, m2: TMenuItem;
     5190  m, m2: TDpiMenuItem;
    51915191  MoveAdviceData: TMoveAdviceData;
    51925192  DoCenter: boolean;
     
    53385338        if 1 shl p1 and MyRO.Alive <> 0 then
    53395339        begin
    5340           m := TMenuItem.Create(mCreateUnit);
     5340          m := TDpiMenuItem.Create(mCreateUnit);
    53415341          m.Caption := Tribe[p1].TPhrase('SHORTNAME');
    53425342          for emix := MyRO.nEnemyModel - 1 downto 0 do
     
    53475347              if Tribe[p1].ModelPicture[MyRO.EnemyModel[emix].mix].HGr = 0 then
    53485348                InitEnemyModel(emix);
    5349               m2 := TMenuItem.Create(m);
     5349              m2 := TDpiMenuItem.Create(m);
    53505350              m2.Caption := Tribe[p1].ModelName[MyRO.EnemyModel[emix].mix];
    53515351              m2.Tag := p1 shl 16 + MyRO.EnemyModel[emix].mix;
     
    64526452  Shift: TShiftState);
    64536453
    6454   procedure MenuClick_Check(Popup: TPopupMenu; Item: TMenuItem);
     6454  procedure MenuClick_Check(Popup: TDpiPopupMenu; Item: TDpiMenuItem);
    64556455  begin
    64566456    InitPopup(Popup);
     
    71827182end;
    71837183
    7184 procedure TMainScreen.InitPopup(Popup: TPopupMenu);
     7184procedure TMainScreen.InitPopup(Popup: TDpiPopupMenu);
    71857185var
    71867186  i, p1, Tile, Test: integer;
    71877187  NoSuper, extended, Multi, NeedSep, HaveCities: boolean;
    7188   LastSep, m: TMenuItem;
     7188  LastSep, m: TDpiMenuItem;
    71897189  mox: ^TModel;
    71907190begin
     
    72577257        if (p1 = 0) or (1 shl p1 and G.RO[0].Alive <> 0) then
    72587258        begin
    7259           m := TMenuItem.Create(mViewpoint);
     7259          m := TDpiMenuItem.Create(mViewpoint);
    72607260          if p1 = 0 then
    72617261            m.Caption := Phrases.Lookup('SUPER')
     
    72797279        if (p1 = 0) or (1 shl p1 and G.RO[0].Alive <> 0) then
    72807280        begin
    7281           m := TMenuItem.Create(mDebugMap);
     7281          m := TDpiMenuItem.Create(mDebugMap);
    72827282          if p1 = 0 then
    72837283            m.Caption := Phrases2.Lookup('MENU_DEBUGMAPOFF')
     
    74597459procedure TMainScreen.PanelBtnClick(Sender: TObject);
    74607460var
    7461   Popup: TPopupMenu;
     7461  Popup: TDpiPopupMenu;
    74627462begin
    74637463  if Sender = UnitBtn then
     
    74677467  InitPopup(Popup);
    74687468  if FullScreen then
    7469     Popup.Popup(Left + TControl(Sender).Left, Top + TControl(Sender).Top)
     7469    Popup.Popup(Left + TDpiControl(Sender).Left, Top + TDpiControl(Sender).Top)
    74707470  else
    7471     Popup.Popup(Left + TControl(Sender).Left + 4, Top + TControl(Sender).Top +
     7471    Popup.Popup(Left + TDpiControl(Sender).Left + 4, Top + TDpiControl(Sender).Top +
    74727472      GetSystemMetrics(SM_CYCAPTION) + 4);
    74737473end;
     
    75047504procedure TMainScreen.Toggle(Sender: TObject);
    75057505begin
    7506   TMenuItem(Sender).Checked := not TMenuItem(Sender).Checked
     7506  TDpiMenuItem(Sender).Checked := not TDpiMenuItem(Sender).Checked
    75077507end;
    75087508
     
    75907590procedure TMainScreen.mShowClick(Sender: TObject);
    75917591begin
    7592   TMenuItem(Sender).Checked := not TMenuItem(Sender).Checked;
     7592  TDpiMenuItem(Sender).Checked := not TDpiMenuItem(Sender).Checked;
    75937593  SetMapOptions;
    75947594  MapValid := false;
     
    76287628        InitPopup(GamePopup);
    76297629        if FullScreen then
     7630          // GamePopup.FItems.Count
    76307631          GamePopup.Popup(Left, Top + TopBarHeight - 1)
    76317632        else
     
    77897790procedure TMainScreen.mRepClicked(Sender: TObject);
    77907791begin
    7791   with TMenuItem(Sender) do
     7792  with TDpiMenuItem(Sender) do
    77927793  begin
    77937794    Checked := not Checked;
     
    78187819procedure TMainScreen.Radio(Sender: TObject);
    78197820begin
    7820   TMenuItem(Sender).Checked := true;
     7821  TDpiMenuItem(Sender).Checked := true;
    78217822end;
    78227823
     
    78257826  Flag: integer;
    78267827begin
    7827   with TMenuItem(Sender) do
     7828  with TDpiMenuItem(Sender) do
    78287829  begin
    78297830    Flag := 1 shl (Tag shr 8);
     
    79847985procedure TMainScreen.ViewpointClick(Sender: TObject);
    79857986begin
    7986   SetViewpoint(TMenuItem(Sender).Tag);
     7987  SetViewpoint(TDpiMenuItem(Sender).Tag);
    79877988end;
    79887989
    79897990procedure TMainScreen.DebugMapClick(Sender: TObject);
    79907991begin
    7991   SetDebugMap(TMenuItem(Sender).Tag);
     7992  SetDebugMap(TDpiMenuItem(Sender).Tag);
    79927993end;
    79937994
     
    80298030  OptionChecked := OptionChecked and soExtraMask;
    80308031  for i := 0 to ComponentCount - 1 do
    8031     if Components[i] is TMenuItem then
     8032    if Components[i] is TDpiMenuItem then
    80328033      for j := 0 to nSaveOption - 1 do
    8033         if TMenuItem(Components[i]).Checked and
    8034           (TMenuItem(Components[i]).Tag = SaveOption[j]) then
     8034        if TDpiMenuItem(Components[i]).Checked and
     8035          (TDpiMenuItem(Components[i]).Tag = SaveOption[j]) then
    80358036          inc(OptionChecked, 1 shl j);
    80368037
Note: See TracChangeset for help on using the changeset viewer.