Ignore:
Timestamp:
Nov 17, 2021, 11:31:18 AM (2 years ago)
Author:
chronos
Message:
  • Modified: Sort key bindings alphabetically in the settings dialog.
  • Modified: Use update locking for filling a list of languages and key bindings.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/UKeyBindings.pas

    r387 r418  
    3838    procedure ResetToDefault;
    3939    procedure RemoveShortCut(ShortCut: TShortCut);
     40    procedure SortAlpha;
    4041  end;
    4142
     
    241242  Text: string;
    242243begin
    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);
     244  Strings.BeginUpdate;
     245  try
     246    Strings.Clear;
     247    for I := 0 to Count - 1 do begin
     248      Text := '';
     249      if Items[I].ShortCut <> 0 then
     250        Text := Text + ShortCutToText(Items[I].ShortCut);
     251      if Items[I].ShortCut2 <> 0 then begin
     252        if Text <> '' then Text := Text + ', ';
     253        Text := Text + ShortCutToText(Items[I].ShortCut2);
     254      end;
     255      if Text <> '' then Text := Items[I].FullName + ' (' + Text + ')'
     256        else Text := Items[I].FullName;
     257      Strings.Add(Text);
    251258    end;
    252     if Text <> '' then Text := Items[I].FullName + ' (' + Text + ')'
    253       else Text := Items[I].FullName;
    254     Strings.Add(Text);
     259  finally
     260    Strings.EndUpdate;
    255261  end;
    256262end;
     
    284290    if Items[I].ShortCut2 = ShortCut then Items[I].ShortCut2 := 0;
    285291  end;
     292end;
     293
     294function CompareAlpha(const Item1, Item2: TKeyBinding): Integer;
     295begin
     296  Result := CompareStr(Item1.FullName, Item2.FullName);
     297end;
     298
     299procedure TKeyBindings.SortAlpha;
     300begin
     301  Sort(CompareAlpha);
    286302end;
    287303
     
    372388  BMoveLeftUp := AddItem('MoveLeftUp', 'Move unit left-up', 'Num7', 'Home');
    373389  BMoveLeft := AddItem('MoveLeft', 'Move unit left', 'Num4', 'Left');
     390  SortAlpha;
    374391end;
    375392
Note: See TracChangeset for help on using the changeset viewer.