Changeset 465 for branches/highdpi/LocalPlayer/KeyBindings.pas
- Timestamp:
- Nov 30, 2023, 10:16:14 PM (12 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/KeyBindings.pas
r464 r465 1 unit UKeyBindings; 2 3 {$mode delphi} 1 unit KeyBindings; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, fgl, LCLProc, LCLType, Menus, Registry; 6 Classes, SysUtils, Generics.Collections, Generics.Defaults, LCLProc, LCLType, 7 Menus, Registry; 9 8 10 9 type … … 26 25 { TKeyBindings } 27 26 28 TKeyBindings = class(T FPGObjectList<TKeyBinding>)27 TKeyBindings = class(TObjectList<TKeyBinding>) 29 28 private 30 29 public … … 38 37 procedure ResetToDefault; 39 38 procedure RemoveShortCut(ShortCut: TShortCut); 39 procedure SortAlpha; 40 40 end; 41 41 … … 241 241 Text: string; 242 242 begin 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); 251 257 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; 255 260 end; 256 261 end; … … 284 289 if Items[I].ShortCut2 = ShortCut then Items[I].ShortCut2 := 0; 285 290 end; 291 end; 292 293 function CompareAlpha(constref Item1, Item2: TKeyBinding): Integer; 294 begin 295 Result := CompareStr(Item1.FullName, Item2.FullName); 296 end; 297 298 procedure TKeyBindings.SortAlpha; 299 begin 300 Sort(TComparer<TKeyBinding>.Construct(CompareAlpha)); 286 301 end; 287 302 … … 372 387 BMoveLeftUp := AddItem('MoveLeftUp', 'Move unit left-up', 'Num7', 'Home'); 373 388 BMoveLeft := AddItem('MoveLeft', 'Move unit left', 'Num4', 'Left'); 389 SortAlpha; 374 390 end; 375 391 … … 381 397 end. 382 398 399
Note:
See TracChangeset
for help on using the changeset viewer.