Ignore:
Timestamp:
Mar 2, 2021, 10:16:54 PM (3 years ago)
Author:
chronos
Message:
  • Modified: Allow to redefine all action keys.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Term.pas

    r290 r291  
    64386438    MapValid := false;
    64396439    PaintAllMaps;
    6440   end
     6440  end;
    64416441end;
    64426442
     
    64606460  mStay.ShortCut := BStay.ShortCut;
    64616461  mNoOrders.ShortCut := BNoOrders.ShortCut;
     6462  mCancel.ShortCut := BCancel.ShortCut;
     6463  mPillage.ShortCut := BPillage.ShortCut;
    64626464  mTechTree.ShortCut := BTechTree.ShortCut;
    64636465  mWait.ShortCut := BWait.ShortCut;
    64646466  mJump.ShortCut := BJump.ShortCut;;
     6467  mDebugMap.ShortCut := BDebugMap.ShortCut;
     6468  mLocCodes.ShortCut := BLocCodes.ShortCut;
     6469  mNames.ShortCut := BNames.ShortCut;
     6470  mRun.ShortCut := BRun.ShortCut;
     6471  mAirBase.ShortCut := BAirBase.ShortCut;
     6472  mCity.ShortCut := BBuildCity.ShortCut;
     6473  mEnhance.ShortCut := BEnhance.ShortCut;
     6474  mGoOn.ShortCut := BGoOn.ShortCut;
     6475  mHome.ShortCut := BHome.ShortCut;
     6476  mFarm.ShortCut := BFarmClearIrrigation.ShortCut;
     6477  mClear.ShortCut := BFarmClearIrrigation.ShortCut;
     6478  mIrrigation.ShortCut := BFarmClearIrrigation.ShortCut;
     6479  mLoad.ShortCut := BLoad.ShortCut;
     6480  mAfforest.ShortCut := BAfforestMine.ShortCut;
     6481  mMine.ShortCut := BAfforestMine.ShortCut;
     6482  mCanal.ShortCut := BCanal.ShortCut;
     6483  MTrans.ShortCut := BTrans.ShortCut;
     6484  mPollution.ShortCut := BPollution.ShortCut;
     6485  mRR.ShortCut := BRailRoad.ShortCut;
     6486  mRoad.ShortCut := BRailRoad.ShortCut;
     6487  mUnload.ShortCut := BUnload.ShortCut;
     6488  mRecover.ShortCut := BRecover.ShortCut;
     6489  mUtilize.ShortCut := BUtilize.ShortCut;
    64656490end;
    64666491
     
    64756500  end;
    64766501
     6502  procedure SetViewpointMe(p: Integer);
     6503  begin
     6504    if p = me then SetViewpoint(p)
     6505      else SetViewpoint(p);
     6506  end;
     6507
     6508  procedure DoMoveUnit(X, Y: Integer);
     6509  begin
     6510    DestinationMarkON := False;
     6511    PaintDestination;
     6512    MyUn[UnFocus].Status := MyUn[UnFocus].Status and
     6513      ($FFFF - usStay - usRecover - usGoto - usEnhance) or usWaiting;
     6514    MoveUnit(X, Y, muAutoNext);
     6515  end;
     6516
    64776517var
    6478   dx, dy: integer;
    6479   time0, time1: TDateTime;
     6518  Time0, Time1: TDateTime;
    64806519  ShortCut: TShortCut;
    64816520begin
    64826521  ShortCut := KeyToShortCut(Key, Shift);
    64836522
    6484   if GameMode = cMovie then
    6485   begin
    6486     case Key of
    6487       VK_F4: MenuClick_Check(StatPopup, mScienceStat);
    6488       VK_F6: MenuClick_Check(StatPopup, mDiagram);
    6489       VK_F7: MenuClick_Check(StatPopup, mWonders);
    6490       VK_F8: MenuClick_Check(StatPopup, mShips);
    6491     end;
    6492     exit;
    6493   end;
    6494 
    6495   if not idle then exit;
     6523  if GameMode = cMovie then begin
     6524    if BScienceStat.Test(ShortCut) then MenuClick_Check(StatPopup, mScienceStat)
     6525    else if BDiagram.Test(ShortCut) then MenuClick_Check(StatPopup, mDiagram)
     6526    else if BWonders.Test(ShortCut) then MenuClick_Check(StatPopup, mWonders)
     6527    else if BShips.Test(ShortCut) then MenuClick_Check(StatPopup, mShips);
     6528    Exit;
     6529  end;
     6530
     6531  if not Idle then Exit;
    64966532
    64976533  if ClientMode = cEditMap then begin
    6498     if ShortCut = BResign.ShortCut then MenuClick(mResign)
    6499     else if ShortCut = BRandomMap.ShortCut then MenuClick(mRandomMap)
    6500     else if ShortCut = BHelp.ShortCut then MenuClick(mHelp);
     6534    if BResign.Test(ShortCut) then MenuClick(mResign)
     6535    else if BRandomMap.Test(ShortCut) then MenuClick(mRandomMap)
     6536    else if BHelp.Test(ShortCut) then MenuClick(mHelp);
    65016537    (*if Shift = [ssCtrl] then
    65026538      case char(Key) of
     
    65166552      end;
    65176553    *)
    6518 
    65196554    Exit;
    65206555  end;
    65216556
    6522   if ShortCut = BEndTurn.ShortCut then EndTurn
    6523   else if ShortCut = BHelp.ShortCut then MenuClick(mHelp)
    6524   else if ShortCut = BUnitStat.ShortCut then MenuClick_Check(StatPopup, mUnitStat)
    6525   else if ShortCut = BCityStat.ShortCut then MenuClick_Check(StatPopup, mCityStat)
    6526   else if ShortCut = BScienceStat.ShortCut then MenuClick_Check(StatPopup, mScienceStat)
    6527   else if ShortCut = BEUnitStat.ShortCut then MenuClick_Check(StatPopup, mEUnitStat)
    6528   else if ShortCut = BDiagram.ShortCut then MenuClick_Check(StatPopup, mDiagram)
    6529   else if ShortCut = BWonders.ShortCut then MenuClick_Check(StatPopup, mWonders)
    6530   else if ShortCut = BShips.ShortCut then MenuClick_Check(StatPopup, mShips)
    6531   else if ShortCut = BNations.ShortCut then MenuClick_Check(StatPopup, mNations)
    6532   else if ShortCut = BEmpire.ShortCut then MenuClick_Check(StatPopup, mEmpire);
    6533 
    6534   if Shift = [ssAlt] then begin
    6535     case char(Key) of
    6536       '0': SetDebugMap(-1);
    6537       '1'..'9': SetDebugMap(ord(Key) - 48);
     6557  if BEndTurn.Test(ShortCut) then EndTurn
     6558  else if BHelp.Test(ShortCut) then MenuClick(mHelp)
     6559  else if BUnitStat.Test(ShortCut) then MenuClick_Check(StatPopup, mUnitStat)
     6560  else if BCityStat.Test(ShortCut) then MenuClick_Check(StatPopup, mCityStat)
     6561  else if BScienceStat.Test(ShortCut) then MenuClick_Check(StatPopup, mScienceStat)
     6562  else if BEUnitStat.Test(ShortCut) then MenuClick_Check(StatPopup, mEUnitStat)
     6563  else if BDiagram.Test(ShortCut) then MenuClick_Check(StatPopup, mDiagram)
     6564  else if BWonders.Test(ShortCut) then MenuClick_Check(StatPopup, mWonders)
     6565  else if BShips.Test(ShortCut) then MenuClick_Check(StatPopup, mShips)
     6566  else if BNations.Test(ShortCut) then MenuClick_Check(StatPopup, mNations)
     6567  else if BEmpire.Test(ShortCut) then MenuClick_Check(StatPopup, mEmpire)
     6568
     6569  else if BSetDebugMap0.Test(ShortCut) then SetDebugMap(-1)
     6570  else if BSetDebugMap1.Test(ShortCut) then SetDebugMap(1)
     6571  else if BSetDebugMap2.Test(ShortCut) then SetDebugMap(2)
     6572  else if BSetDebugMap3.Test(ShortCut) then SetDebugMap(3)
     6573  else if BSetDebugMap4.Test(ShortCut) then SetDebugMap(4)
     6574  else if BSetDebugMap5.Test(ShortCut) then SetDebugMap(5)
     6575  else if BSetDebugMap6.Test(ShortCut) then SetDebugMap(6)
     6576  else if BSetDebugMap7.Test(ShortCut) then SetDebugMap(7)
     6577  else if BSetDebugMap8.Test(ShortCut) then SetDebugMap(8)
     6578  else if BSetDebugMap9.Test(ShortCut) then SetDebugMap(9)
     6579
     6580  else if BJump.Test(ShortCut) then MenuClick(mJump)
     6581  else if BDebugMap.Test(ShortCut) then mShowClick(mDebugMap)
     6582  else if BLocCodes.Test(ShortCut) then mShowClick(mLocCodes)
     6583  else if BLogDlg.Test(ShortCut) then begin
     6584    if LogDlg.Visible then LogDlg.Close
     6585      else LogDlg.Show;
     6586  end
     6587  else if BNames.Test(ShortCut) then mNamesClick(mNames)
     6588  else if BResign.Test(ShortCut) then MenuClick_Check(GamePopup, mResign)
     6589  else if BRun.Test(ShortCut) then MenuClick(mRun)
     6590  else if BTestMapRepaint.Test(ShortCut) then begin // test map repaint time
     6591    Time0 := NowPrecise;
     6592    MapValid := False;
     6593    MainOffscreenPaint;
     6594    Time1 := NowPrecise;
     6595    SimpleMessage(Format('Map repaint time: %.3f ms',
     6596      [(Time1 - Time0) / OneMillisecond]));
     6597  end
     6598  else if BSetViewpoint0.Test(ShortCut) then SetViewpointMe(0)
     6599  else if BSetViewpoint1.Test(ShortCut) then SetViewpointMe(1)
     6600  else if BSetViewpoint2.Test(ShortCut) then SetViewpointMe(2)
     6601  else if BSetViewpoint3.Test(ShortCut) then SetViewpointMe(3)
     6602  else if BSetViewpoint4.Test(ShortCut) then SetViewpointMe(4)
     6603  else if BSetViewpoint5.Test(ShortCut) then SetViewpointMe(5)
     6604  else if BSetViewpoint6.Test(ShortCut) then SetViewpointMe(6)
     6605  else if BSetViewpoint7.Test(ShortCut) then SetViewpointMe(7)
     6606  else if BSetViewpoint8.Test(ShortCut) then SetViewpointMe(8)
     6607  else if BSetViewpoint9.Test(ShortCut) then SetViewpointMe(9)
     6608
     6609  else if BMapBtn0.Test(ShortCut) then MapBtnClick(MapBtn0)
     6610  else if BMapBtn1.Test(ShortCut) then MapBtnClick(MapBtn1)
     6611  else if BMapBtn4.Test(ShortCut) then MapBtnClick(MapBtn4)
     6612  else if BMapBtn5.Test(ShortCut) then MapBtnClick(MapBtn5)
     6613  else if BMapBtn6.Test(ShortCut) then MapBtnClick(MapBtn6)
     6614  else if BTechTree.Test(ShortCut) then MenuClick(mTechTree)
     6615  else if BWait.Test(ShortCut) then MenuClick(mWait);
     6616
     6617  if UnFocus >= 0 then begin
     6618    if BDisbandUnit.Test(ShortCut) then MenuClick(mDisband)
     6619    else if BFortify.Test(ShortCut) then MenuClick_Check(TerrainPopup, mFort)
     6620    else if BCenterUnit.Test(ShortCut) then MenuClick(mCentre)
     6621    else if BStay.Test(ShortCut) then MenuClick(mStay)
     6622    else if BNoOrders.Test(ShortCut) then MenuClick(mNoOrders)
     6623    else if BCancel.Test(ShortCut) then MenuClick_Check(UnitPopup, mCancel)
     6624    else if BPillage.Test(ShortCut) then MenuClick_Check(UnitPopup, mPillage)
     6625    else if BSelectTransport.Test(ShortCut) then MenuClick_Check(UnitPopup, mSelectTransport)
     6626    else if BAirBase.Test(ShortCut) then MenuClick_Check(TerrainPopup, mAirBase)
     6627    else if BBuildCity.Test(ShortCut) then MenuClick_Check(UnitPopup, mCity)
     6628    else if BEnhance.Test(ShortCut) then begin
     6629      InitPopup(TerrainPopup);
     6630      if mEnhance.Visible and mEnhance.Enabled then MenuClick(mEnhance)
     6631        else MenuClick(mEnhanceDef)
    65386632    end
    6539   end else if Shift = [ssCtrl] then begin
    6540     if ShortCut = BJump.ShortCut then MenuClick(mJump);
    6541     case char(Key) of
    6542       'K': mShowClick(mDebugMap);
    6543       'L': mShowClick(mLocCodes);
    6544       'M': if LogDlg.Visible then LogDlg.Close
    6545         else LogDlg.Show;
    6546       'N': mNamesClick(mNames);
    6547       'Q': MenuClick_Check(GamePopup, mResign);
    6548       'R': MenuClick(mRun);
    6549       '0'..'9': begin
    6550           if ord(Key) - 48 = me then SetViewpoint(0)
    6551             else SetViewpoint(ord(Key) - 48);
    6552         end;
    6553       ' ': begin // test map repaint time
    6554           time0 := NowPrecise;
    6555           MapValid := false;
    6556           MainOffscreenPaint;
    6557           time1 := NowPrecise;
    6558           SimpleMessage(Format('Map repaint time: %.3f ms',
    6559             [(time1 - time0) / OneMillisecond]));
    6560         end;
     6633    else if BGoOn.Test(ShortCut) then MenuClick_Check(UnitPopup, mGoOn)
     6634    else if BHome.Test(ShortCut) then MenuClick_Check(UnitPopup, mHome)
     6635    else if BFarmClearIrrigation.Test(ShortCut) then begin
     6636      if JobTest(UnFocus, jFarm, [eTreaty]) then
     6637        MenuClick(mFarm)
     6638      else if JobTest(UnFocus, jClear, [eTreaty]) then
     6639        MenuClick(mClear)
     6640      else MenuClick_Check(TerrainPopup, mIrrigation);
    65616641    end
    6562   end else if Shift = [] then begin
    6563     case char(Key) of
    6564       '1': MapBtnClick(MapBtn0);
    6565       '2': MapBtnClick(MapBtn1);
    6566       '3': MapBtnClick(MapBtn4);
    6567       '4': MapBtnClick(MapBtn5);
    6568       '5': MapBtnClick(MapBtn6);
    6569     end;
    6570     if ShortCut = BTechTree.ShortCut then MenuClick(mTechTree)
    6571     else if ShortCut = BWait.ShortCut then MenuClick(mWait);
    6572   end;
    6573 
    6574   if UnFocus >= 0 then begin
    6575     if ShortCut = BDisbandUnit.ShortCut then MenuClick(mDisband)
    6576     else if ShortCut = BFortify.ShortCut then MenuClick_Check(TerrainPopup, mFort)
    6577     else if ShortCut = BCenterUnit.ShortCut then MenuClick(mCentre)
    6578     else if ShortCut = BStay.ShortCut then MenuClick(mStay)
    6579     else if ShortCut = BNoOrders.ShortCut then MenuClick(mNoOrders);
    6580 
    6581     if Shift = [ssCtrl] then begin
    6582       case char(Key) of
    6583         'C': MenuClick_Check(UnitPopup, mCancel);
    6584         'P': MenuClick_Check(UnitPopup, mPillage);
    6585         'T': MenuClick_Check(UnitPopup, mSelectTransport);
    6586       end;
    6587     end else if Shift = [] then begin
    6588       case char(Key) of
    6589         'A': MenuClick_Check(TerrainPopup, mAirBase);
    6590         'B': MenuClick_Check(UnitPopup, mCity);
    6591         'E': begin
    6592             InitPopup(TerrainPopup);
    6593             if mEnhance.Visible and mEnhance.Enabled then
    6594               MenuClick(mEnhance)
    6595             else MenuClick(mEnhanceDef)
    6596           end;
    6597         'G': MenuClick_Check(UnitPopup, mGoOn);
    6598         'H': MenuClick_Check(UnitPopup, mHome);
    6599         'I': if JobTest(UnFocus, jFarm, [eTreaty]) then
    6600             MenuClick(mFarm)
    6601           else if JobTest(UnFocus, jClear, [eTreaty]) then
    6602             MenuClick(mClear)
    6603           else MenuClick_Check(TerrainPopup, mIrrigation);
    6604         'L': MenuClick_Check(UnitPopup, mLoad);
    6605         'M': if JobTest(UnFocus, jAfforest, [eTreaty]) then
    6606             MenuClick(mAfforest)
    6607           else MenuClick_Check(TerrainPopup, mMine);
    6608         'N': MenuClick_Check(TerrainPopup, mCanal);
    6609         'O': MenuClick_Check(TerrainPopup, MTrans);
    6610         'P': MenuClick_Check(TerrainPopup, mPollution);
    6611         'R': if JobTest(UnFocus, jRR, [eTreaty]) then
    6612             MenuClick(mRR)
    6613           else MenuClick_Check(TerrainPopup, mRoad);
    6614         'U': MenuClick_Check(UnitPopup, mUnload);
    6615         'V': MenuClick_Check(UnitPopup, mRecover);
    6616         'Z': MenuClick_Check(UnitPopup, mUtilize);
    6617         #33 .. #40, #97 .. #100, #102 .. #105:
    6618           begin { arrow keys }
    6619             DestinationMarkON := false;
    6620             PaintDestination;
    6621             MyUn[UnFocus].Status := MyUn[UnFocus].Status and
    6622               ($FFFF - usStay - usRecover - usGoto - usEnhance) or usWaiting;
    6623             case Key of
    6624               VK_NUMPAD1, VK_END:
    6625                 begin
    6626                   dx := -1;
    6627                   dy := 1
    6628                 end;
    6629               VK_NUMPAD2, VK_DOWN:
    6630                 begin
    6631                   dx := 0;
    6632                   dy := 2
    6633                 end;
    6634               VK_NUMPAD3, VK_NEXT:
    6635                 begin
    6636                   dx := 1;
    6637                   dy := 1
    6638                 end;
    6639               VK_NUMPAD4, VK_LEFT:
    6640                 begin
    6641                   dx := -2;
    6642                   dy := 0
    6643                 end;
    6644               VK_NUMPAD6, VK_RIGHT:
    6645                 begin
    6646                   dx := 2;
    6647                   dy := 0
    6648                 end;
    6649               VK_NUMPAD7, VK_HOME:
    6650                 begin
    6651                   dx := -1;
    6652                   dy := -1
    6653                 end;
    6654               VK_NUMPAD8, VK_UP:
    6655                 begin
    6656                   dx := 0;
    6657                   dy := -2
    6658                 end;
    6659               VK_NUMPAD9, VK_PRIOR:
    6660                 begin
    6661                   dx := 1;
    6662                   dy := -1
    6663                 end;
    6664             end;
    6665             MoveUnit(dx, dy, muAutoNext)
    6666           end;
    6667       end;
    6668     end;
     6642    else if BLoad.Test(ShortCut) then MenuClick_Check(UnitPopup, mLoad)
     6643    else if BAfforestMine.Test(ShortCut) then begin
     6644      if JobTest(UnFocus, jAfforest, [eTreaty]) then MenuClick(mAfforest)
     6645        else MenuClick_Check(TerrainPopup, mMine);
     6646    end
     6647    else if BCanal.Test(ShortCut) then MenuClick_Check(TerrainPopup, mCanal)
     6648    else if BTrans.Test(ShortCut) then MenuClick_Check(TerrainPopup, MTrans)
     6649    else if BPollution.Test(ShortCut) then MenuClick_Check(TerrainPopup, mPollution)
     6650    else if BRailRoad.Test(ShortCut) then begin
     6651      if JobTest(UnFocus, jRR, [eTreaty]) then MenuClick(mRR)
     6652        else MenuClick_Check(TerrainPopup, mRoad);
     6653    end
     6654    else if BUnload.Test(ShortCut) then MenuClick_Check(UnitPopup, mUnload)
     6655    else if BRecover.Test(ShortCut) then MenuClick_Check(UnitPopup, mRecover)
     6656    else if BUtilize.Test(ShortCut) then MenuClick_Check(UnitPopup, mUtilize)
     6657    else if BMoveLeftDown.Test(ShortCut) then DoMoveUnit(-1, 1)
     6658    else if BMoveDown.Test(ShortCut) then DoMoveUnit(0, 2)
     6659    else if BMoveRightDown.Test(ShortCut) then DoMoveUnit(1, 1)
     6660    else if BMoveLeft.Test(ShortCut) then DoMoveUnit(-2, 0)
     6661    else if BMoveRight.Test(ShortCut) then DoMoveUnit(2, 0)
     6662    else if BMoveLeftUp.Test(ShortCut) then DoMoveUnit(-1, -1)
     6663    else if BMoveUp.Test(ShortCut) then  DoMoveUnit(0, -2)
     6664    else if BMoveRightUp.Test(ShortCut) then DoMoveUnit(1, -1);
    66696665  end;
    66706666end;
Note: See TracChangeset for help on using the changeset viewer.