Changeset 261 for trunk


Ignore:
Timestamp:
Jun 11, 2020, 12:40:26 AM (4 years ago)
Author:
chronos
Message:
  • Added: Partial support for key bindings configuration.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Integrated.lpi

    r259 r261  
    9595      </Item2>
    9696    </RequiredPackages>
    97     <Units Count="41">
     97    <Units Count="42">
    9898      <Unit0>
    9999        <Filename Value="Integrated.lpr"/>
     
    332332        <IsPartOfProject Value="True"/>
    333333      </Unit40>
     334      <Unit41>
     335        <Filename Value="UKeyBindings.pas"/>
     336        <IsPartOfProject Value="True"/>
     337      </Unit41>
    334338    </Units>
    335339  </ProjectOptions>
  • trunk/LocalPlayer/Help.pas

    r245 r261  
    127127
    128128uses
    129   Directories, ClientTools, Term, Tribes, Inp, Messg, UPixelPointer, Global;
     129  Directories, ClientTools, Term, Tribes, Inp, Messg, UPixelPointer, Global,
     130  UKeyBindings;
    130131
    131132{$R *.lfm}
     
    20102011  Shift: TShiftState);
    20112012begin
    2012   if Key = VK_F1 then // my key
     2013  if KeyToShortCut(Key, Shift) = BHelp.ShortCut then // my key
    20132014  else
    2014     inherited
     2015    inherited;
    20152016end;
    20162017
  • trunk/LocalPlayer/Term.pas

    r260 r261  
    481481  Directories, IsoEngine, CityScreen, Draft, MessgEx, Select, CityType, Help,
    482482  UnitStat, Log, Diagram, NatStat, Wonders, Enhance, Nego, UPixelPointer, Sound,
    483   Battle, Rates, TechTree, Registry, Global;
     483  Battle, Rates, TechTree, Registry, Global, UKeyBindings;
    484484
    485485{$R *.lfm}
     
    64536453  dx, dy: integer;
    64546454  time0, time1: TDateTime;
    6455 begin
     6455  ShortCut: TShortCut;
     6456begin
     6457  ShortCut := KeyToShortCut(Key, Shift);
     6458
    64566459  if GameMode = cMovie then
    64576460  begin
     
    64936496        'R':
    64946497          MenuClick(mRandomMap);
    6495       end
    6496     else if Shift = [] then
    6497       case char(Key) of
    6498         char(VK_F1):
    6499           MenuClick(mHelp);
    65006498      end;
    6501     exit;
    6502   end;
     6499    if ShortCut = BHelp.ShortCut then MenuClick(mHelp);
     6500    Exit;
     6501  end;
     6502
     6503  if ShortCut = BEndTurn.ShortCut then EndTurn
     6504  else if ShortCut = BHelp.ShortCut then MenuClick(mHelp)
     6505  else if ShortCut = BUnitStat.ShortCut then MenuClick_Check(StatPopup, mUnitStat)
     6506  else if ShortCut = BCityStat.ShortCut then MenuClick_Check(StatPopup, mCityStat)
     6507  else if ShortCut = BScienceStat.ShortCut then MenuClick_Check(StatPopup, mScienceStat)
     6508  else if ShortCut = BEUnitStat.ShortCut then MenuClick_Check(StatPopup, mEUnitStat)
     6509  else if ShortCut = BDiagram.ShortCut then MenuClick_Check(StatPopup, mDiagram)
     6510  else if ShortCut = BWonders.ShortCut then MenuClick_Check(StatPopup, mWonders)
     6511  else if ShortCut = BShips.ShortCut then MenuClick_Check(StatPopup, mShips)
     6512  else if ShortCut = BNations.ShortCut then MenuClick_Check(StatPopup, mNations)
     6513  else if ShortCut = BEmpire.ShortCut then MenuClick_Check(StatPopup, mEmpire);
    65036514
    65046515  if Shift = [ssAlt] then
     
    65476558  else if Shift = [] then
    65486559    case char(Key) of
    6549       char(VK_F1):
    6550         MenuClick(mHelp);
    6551       char(VK_F2):
    6552         MenuClick_Check(StatPopup, mUnitStat);
    6553       char(VK_F3):
    6554         MenuClick_Check(StatPopup, mCityStat);
    6555       char(VK_F4):
    6556         MenuClick_Check(StatPopup, mScienceStat);
    6557       char(VK_F5):
    6558         MenuClick_Check(StatPopup, mEUnitStat);
    6559       char(VK_F6):
    6560         MenuClick_Check(StatPopup, mDiagram);
    6561       char(VK_F7):
    6562         MenuClick_Check(StatPopup, mWonders);
    6563       char(VK_F8):
    6564         MenuClick_Check(StatPopup, mShips);
    6565       char(VK_F9):
    6566         MenuClick_Check(StatPopup, mNations);
    6567       char(VK_F10):
    6568         MenuClick_Check(StatPopup, mEmpire);
    6569       char(VK_ADD):
    6570         EndTurn;
    65716560      '1':
    65726561        MapBtnClick(MapBtn0);
  • trunk/Start.pas

    r259 r261  
    165165
    166166uses
    167   Global, Directories, Direct, ScreenTools, Inp, Back, Settings, UPixelPointer;
     167  Global, Directories, Direct, ScreenTools, Inp, Back, Settings, UPixelPointer,
     168  UKeyBindings;
    168169
    169170{$R *.lfm}
     
    224225  PlayerAutoDiff: array [1 .. 5] of integer = (1, 1, 2, 2, 3);
    225226  EnemyAutoDiff: array [1 .. 5] of integer = (4, 3, 2, 1, 1);
     227  KeyBindingsFileName = 'KeyBindings.txt';
    226228
    227229{ TMiniMap }
     
    435437  PlayerSlot: TPlayerSlot;
    436438  AIBrains: TBrains;
     439  KeyBindingsAbsoluteFileName: string;
    437440begin
    438441  PlayerSlots := TPlayerSlots.Create;
     
    445448  LoadConfig;
    446449  LoadAssets;
     450  KeyBindingsAbsoluteFileName := DataDir + DirectorySeparator + KeyBindingsFileName;
     451  if FileExists(KeyBindingsAbsoluteFileName) then KeyBindings.LoadFromFile(KeyBindingsAbsoluteFileName)
     452    else begin
     453      ForceDirectories(ExtractFileDir(KeyBindingsAbsoluteFileName));
     454      KeyBindings.SaveToFile(KeyBindingsAbsoluteFileName);
     455    end;
    447456
    448457  ActionsOffered := [maConfig, maManual, maCredits, maWeb];
     
    19631972  Shift: TShiftState);
    19641973begin
    1965   if (Shift = []) and (Key = VK_F1) then
     1974  if KeyToShortCut(Key, Shift) = BHelp.ShortCut then
    19661975    DirectHelp(cStartHelp);
    19671976end;
Note: See TracChangeset for help on using the changeset viewer.