Changeset 418 for trunk


Ignore:
Timestamp:
Nov 17, 2021, 11:31:18 AM (3 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.
Location:
trunk
Files:
2 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
  • trunk/Packages/Common/UTranslator.pas

    r416 r418  
    316316begin
    317317  with Strings do begin
    318     Clear;
    319     for I := 0 to Languages.Count - 1 do
    320     with TLanguage(Languages[I]) do
    321       if Available then begin
    322         ItemName := Name;
    323         if WithCode and (Code <> '') then ItemName := ItemName + ' (' + Code + ')';
    324         AddObject(ItemName, Languages[I]);
    325       end;
     318    BeginUpdate;
     319    try
     320      Clear;
     321      for I := 0 to Languages.Count - 1 do
     322      with Languages[I] do
     323        if Available then begin
     324          ItemName := Name;
     325          if WithCode and (Code <> '') then ItemName := ItemName + ' (' + Code + ')';
     326          AddObject(ItemName, Languages[I]);
     327        end;
     328    finally
     329      EndUpdate;
     330    end;
    326331  end;
    327332end;
     
    375380
    376381  for I := 1 to Languages.Count - 1 do
    377   with TLanguage(Languages[I]) do begin
     382  with Languages[I] do begin
    378383    Available := FileExists(LangDir + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) +
    379384      '.' + Code + ExtensionSeparator + 'po') or (Code = 'en');
Note: See TracChangeset for help on using the changeset viewer.