Changeset 291 for trunk/UKeyBindings.pas


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

Legend:

Unmodified
Added
Removed
  • trunk/UKeyBindings.pas

    r290 r291  
    99
    1010type
     11
     12  { TKeyBinding }
     13
    1114  TKeyBinding = class
    1215    ShortName: string;
    1316    FullName: string;
    1417    ShortCut: TShortCut;
     18    ShortCut2: TShortCut;
     19    function Test(AShortCut: TShortCut): Boolean;
    1520  end;
    1621
     
    1823
    1924  TKeyBindings = class(TFPGObjectList<TKeyBinding>)
    20     function AddItem(const ShortName, FullName: string; ShortCut: TShortCut): TKeyBinding; overload;
    21     function AddItem(const ShortName, FullName: string; ShortCutText: string): TKeyBinding; overload;
     25    function AddItem(const ShortName, FullName: string; ShortCut: TShortCut; ShortCut2: TShortCut = 0): TKeyBinding; overload;
     26    function AddItem(const ShortName, FullName: string; ShortCutText: string; ShortCutText2: string = ''): TKeyBinding; overload;
    2227    function Search(ShortName: string): TKeyBinding;
    2328    procedure LoadFromFile(FileName: string);
     
    4550  BStay: TKeyBinding;
    4651  BNoOrders: TKeyBinding;
     52  BCancel: TKeyBinding;
     53  BPillage: TKeyBinding;
     54  BSelectTransport: TKeyBinding;
    4755  BTechTree: TKeyBinding;
    4856  BWait: TKeyBinding;
    4957  BJump: TKeyBinding;
     58  BMapBtn0: TKeyBinding;
     59  BMapBtn1: TKeyBinding;
     60  BMapBtn4: TKeyBinding;
     61  BMapBtn5: TKeyBinding;
     62  BMapBtn6: TKeyBinding;
     63  BSetDebugMap0: TKeyBinding;
     64  BSetDebugMap1: TKeyBinding;
     65  BSetDebugMap2: TKeyBinding;
     66  BSetDebugMap3: TKeyBinding;
     67  BSetDebugMap4: TKeyBinding;
     68  BSetDebugMap5: TKeyBinding;
     69  BSetDebugMap6: TKeyBinding;
     70  BSetDebugMap7: TKeyBinding;
     71  BSetDebugMap8: TKeyBinding;
     72  BSetDebugMap9: TKeyBinding;
     73  BDebugMap: TKeyBinding;
     74  BLocCodes: TKeyBinding;
     75  BLogDlg: TKeyBinding;
     76  BNames: TKeyBinding;
     77  BRun: TKeyBinding;
     78  BTestMapRepaint: TKeyBinding;
     79  BSetViewpoint0: TKeyBinding;
     80  BSetViewpoint1: TKeyBinding;
     81  BSetViewpoint2: TKeyBinding;
     82  BSetViewpoint3: TKeyBinding;
     83  BSetViewpoint4: TKeyBinding;
     84  BSetViewpoint5: TKeyBinding;
     85  BSetViewpoint6: TKeyBinding;
     86  BSetViewpoint7: TKeyBinding;
     87  BSetViewpoint8: TKeyBinding;
     88  BSetViewpoint9: TKeyBinding;
     89  BAirBase: TKeyBinding;
     90  BBuildCity: TKeyBinding;
     91  BEnhance: TKeyBinding;
     92  BGoOn: TKeyBinding;
     93  BHome: TKeyBinding;
     94  BFarmClearIrrigation: TKeyBinding;
     95  BLoad: TKeyBinding;
     96  BAfforestMine: TKeyBinding;
     97  BCanal: TKeyBinding;
     98  BTrans: TKeyBinding;
     99  BPollution: TKeyBinding;
     100  BRailRoad: TKeyBinding;
     101  BUnload: TKeyBinding;
     102  BRecover: TKeyBinding;
     103  BUtilize: TKeyBinding;
     104  BMoveLeftDown: TKeyBinding;
     105  BMoveDown: TKeyBinding;
     106  BMoveRightDown: TKeyBinding;
     107  BMoveRight: TKeyBinding;
     108  BMoveRightUp: TKeyBinding;
     109  BMoveUp: TKeyBinding;
     110  BMoveLeftUp: TKeyBinding;
     111  BMoveLeft: TKeyBinding;
    50112
    51113
    52114implementation
    53115
     116{ TKeyBinding }
     117
     118function TKeyBinding.Test(AShortCut: TShortCut): Boolean;
     119begin
     120  Result := (AShortCut = ShortCut) or (AShortCut = ShortCut2);
     121end;
     122
    54123{ TKeyBindings }
    55124
    56 function TKeyBindings.AddItem(const ShortName, FullName: string; ShortCut: TShortCut
    57   ): TKeyBinding;
     125function TKeyBindings.AddItem(const ShortName, FullName: string; ShortCut: TShortCut;
     126  ShortCut2: TShortCut = 0): TKeyBinding;
    58127begin
    59128  Result := TKeyBinding.Create;
     
    61130  Result.FullName := FullName;
    62131  Result.ShortCut := ShortCut;
     132  Result.ShortCut2 := ShortCut2;
    63133  Add(Result);
    64134end;
    65135
    66136function TKeyBindings.AddItem(const ShortName, FullName: string;
    67   ShortCutText: string): TKeyBinding;
    68 begin
    69   Result := AddItem(ShortName, FullName, TextToShortCut(ShortCutText));
     137  ShortCutText: string; ShortCutText2: string = ''): TKeyBinding;
     138begin
     139  Result := AddItem(ShortName, FullName, TextToShortCut(ShortCutText),
     140    TextToShortCut(ShortCutText2));
    70141end;
    71142
     
    141212  BStay := AddItem('Stay', 'Stay', 'S');
    142213  BNoOrders := AddItem('NoOrders', 'No orders', 'Space');
     214  BCancel := AddItem('Cancel', 'Cancel', 'Ctrl+C');
     215  BPillage := AddItem('Pillage', 'Pillage', 'Ctrl+P');
     216  BSelectTransport := AddItem('SelectTransport', 'Select transport', 'Ctrl+T');
    143217  BTechTree := AddItem('TechTree', 'Tech tree', 'T');
    144218  BWait := AddItem('Wait', 'Wait', 'W');
    145219  BJump := AddItem('Jump', 'Jump 20 turns', 'Ctrl+J');
     220  BMapBtn0 := AddItem('MapButton1', 'Map button 1', '1');
     221  BMapBtn1 := AddItem('MapButton2', 'Map button 2', '2');
     222  BMapBtn4 := AddItem('MapButton3', 'Map button 3', '3');
     223  BMapBtn5 := AddItem('MapButton4', 'Map button 4', '4');
     224  BMapBtn6 := AddItem('MapButton5', 'Map button 5', '5');
     225  BSetDebugMap0 := AddItem('SetDebugMap0', 'Set debug map 0', '0');
     226  BSetDebugMap1 := AddItem('SetDebugMap1', 'Set debug map 1', '1');
     227  BSetDebugMap2 := AddItem('SetDebugMap2', 'Set debug map 2', '2');
     228  BSetDebugMap3 := AddItem('SetDebugMap3', 'Set debug map 3', '3');
     229  BSetDebugMap4 := AddItem('SetDebugMap4', 'Set debug map 4', '4');
     230  BSetDebugMap5 := AddItem('SetDebugMap5', 'Set debug map 5', '5');
     231  BSetDebugMap6 := AddItem('SetDebugMap6', 'Set debug map 6', '6');
     232  BSetDebugMap7 := AddItem('SetDebugMap7', 'Set debug map 7', '7');
     233  BSetDebugMap8 := AddItem('SetDebugMap8', 'Set debug map 8', '8');
     234  BSetDebugMap9 := AddItem('SetDebugMap9', 'Set debug map 9', '9');
     235  BDebugMap := AddItem('DebugMap', 'Debug map', 'Ctrl+K');
     236  BLocCodes := AddItem('LocCodes', 'Location codes', 'Ctrl+L');
     237  BLogDlg := AddItem('LogDlg', 'Log dialog', 'Ctrl+M');
     238  BNames := AddItem('ShowNames', 'Show names', 'Ctrl+N');
     239  BRun := AddItem('Run', 'Run', 'Ctrl+R');
     240  BTestMapRepaint := AddItem('TestMapRepaint', 'Test map reapaint', 'Ctrl+Space');
     241  BSetViewpoint0 := AddItem('SetViewpoint0', 'Set viewpoint 0', 'Ctrl+0');
     242  BSetViewpoint1 := AddItem('SetViewpoint1', 'Set viewpoint 1', 'Ctrl+1');
     243  BSetViewpoint2 := AddItem('SetViewpoint2', 'Set viewpoint 2', 'Ctrl+2');
     244  BSetViewpoint3 := AddItem('SetViewpoint3', 'Set viewpoint 3', 'Ctrl+3');
     245  BSetViewpoint4 := AddItem('SetViewpoint4', 'Set viewpoint', 'Ctrl+4');
     246  BSetViewpoint5 := AddItem('SetViewpoint0', 'Set viewpoint', 'Ctrl+5');
     247  BSetViewpoint6 := AddItem('SetViewpoint1', 'Set viewpoint', 'Ctrl+6');
     248  BSetViewpoint7 := AddItem('SetViewpoint2', 'Set viewpoint', 'Ctrl+7');
     249  BSetViewpoint8 := AddItem('SetViewpoint3', 'Set viewpoint', 'Ctrl+8');
     250  BSetViewpoint9 := AddItem('SetViewpoint4', 'Set viewpoint', 'Ctrl+9');
     251  BAirBase := AddItem('AirBase', 'Air base', 'A');
     252  BBuildCity := AddItem('BuildCity', 'Build city', 'B');
     253  BEnhance := AddItem('Enhance', 'Enhance', 'E');
     254  BGoOn := AddItem('GoOn', 'Go on', 'G');
     255  BHome := AddItem('Home', 'Home', 'H');
     256  BFarmClearIrrigation := AddItem('FarmClearIrrigation', 'Farm/Clear/Irrigation', 'I');
     257  BLoad := AddItem('Load', 'Load', 'L');
     258  BAfforestMine := AddItem('AfforestMine', 'Afforest/Mine', 'M');
     259  BCanal := AddItem('Canal', 'Canal', 'N');
     260  BTrans := AddItem('Trans', 'Trans', 'O');
     261  BPollution := AddItem('Pollution', 'Pollution', 'P');
     262  BRailRoad := AddItem('RailRoad', 'Rails/Road', 'R');
     263  BUnload := AddItem('Unload', 'Unload', 'U');
     264  BRecover := AddItem('Recover', 'Recover', 'V');
     265  BUtilize := AddItem('Utilize', 'Utilize', 'Z');
     266  BMoveLeftDown := AddItem('MoveLeftDown', 'Move unit left-down', 'Num1', 'End');
     267  BMoveDown := AddItem('MoveDown', 'Move unit down', 'Num2', 'Down');
     268  BMoveRightDown := AddItem('MoveRightDown', 'Move unit right-down', 'Num3', 'PgDn');
     269  BMoveRight := AddItem('MoveRight', 'Move unit right', 'Num6', 'Right');
     270  BMoveRightUp := AddItem('MoveRightUp', 'Move unit right-up', 'Num9', 'PgUp');
     271  BMoveUp := AddItem('MoveUp', 'Move unit up', 'Num8', 'Up');
     272  BMoveLeftUp := AddItem('MoveLeftUp', 'Move unit left-up', 'Num7', 'Home');
     273  BMoveLeft := AddItem('MoveLeft', 'Move unit left', 'Num4', 'Left');
    146274end;
    147275
Note: See TracChangeset for help on using the changeset viewer.