Ignore:
Timestamp:
Nov 30, 2023, 10:16:14 PM (6 months ago)
Author:
chronos
Message:
  • Modified: Updated high dpi branch from trunk.
  • Modified: Use generics.collections instead of fgl.
  • Modified: Compile with Delphi syntax.
File:
1 moved

Legend:

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

    r464 r465  
    1 unit UKeyBindings;
    2 
    3 {$mode delphi}
     1unit KeyBindings;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, fgl, LCLProc, LCLType, Menus, Registry;
     6  Classes, SysUtils, Generics.Collections, Generics.Defaults, LCLProc, LCLType,
     7  Menus, Registry;
    98
    109type
     
    2625  { TKeyBindings }
    2726
    28   TKeyBindings = class(TFPGObjectList<TKeyBinding>)
     27  TKeyBindings = class(TObjectList<TKeyBinding>)
    2928  private
    3029  public
     
    3837    procedure ResetToDefault;
    3938    procedure RemoveShortCut(ShortCut: TShortCut);
     39    procedure SortAlpha;
    4040  end;
    4141
     
    241241  Text: string;
    242242begin
    243   Strings.Clear;
    244   for I := 0 to Count - 1 do begin
    245     Text:= '';
    246     if Items[I].ShortCut <> 0 then
    247       Text:= Text + ShortCutToText(Items[I].ShortCut);
    248     if Items[I].ShortCut2 <> 0 then begin
    249       if Text <> '' then Text := Text + ', ';
    250       Text:= Text + ShortCutToText(Items[I].ShortCut2);
     243  Strings.BeginUpdate;
     244  try
     245    Strings.Clear;
     246    for I := 0 to Count - 1 do begin
     247      Text := '';
     248      if Items[I].ShortCut <> 0 then
     249        Text := Text + ShortCutToText(Items[I].ShortCut);
     250      if Items[I].ShortCut2 <> 0 then begin
     251        if Text <> '' then Text := Text + ', ';
     252        Text := Text + ShortCutToText(Items[I].ShortCut2);
     253      end;
     254      if Text <> '' then Text := Items[I].FullName + ' (' + Text + ')'
     255        else Text := Items[I].FullName;
     256      Strings.Add(Text);
    251257    end;
    252     if Text <> '' then Text := Items[I].FullName + ' (' + Text + ')'
    253       else Text := Items[I].FullName;
    254     Strings.Add(Text);
     258  finally
     259    Strings.EndUpdate;
    255260  end;
    256261end;
     
    284289    if Items[I].ShortCut2 = ShortCut then Items[I].ShortCut2 := 0;
    285290  end;
     291end;
     292
     293function CompareAlpha(constref Item1, Item2: TKeyBinding): Integer;
     294begin
     295  Result := CompareStr(Item1.FullName, Item2.FullName);
     296end;
     297
     298procedure TKeyBindings.SortAlpha;
     299begin
     300  Sort(TComparer<TKeyBinding>.Construct(CompareAlpha));
    286301end;
    287302
     
    372387  BMoveLeftUp := AddItem('MoveLeftUp', 'Move unit left-up', 'Num7', 'Home');
    373388  BMoveLeft := AddItem('MoveLeft', 'Move unit left', 'Num4', 'Left');
     389  SortAlpha;
    374390end;
    375391
     
    381397end.
    382398
     399
Note: See TracChangeset for help on using the changeset viewer.