Changeset 190 for trunk/Forms
- Timestamp:
- Apr 22, 2018, 2:46:28 PM (7 years ago)
- Location:
- trunk/Forms
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormPlayersStats.lfm
r182 r190 1 1 object FormPlayersStats: TFormPlayersStats 2 Left = 4112 Left = 709 3 3 Height = 300 4 Top = 2374 Top = 637 5 5 Width = 697 6 6 Caption = 'Players stats' 7 7 ClientHeight = 300 8 8 ClientWidth = 697 9 DesignTimePPI = 12010 9 OnClose = FormClose 11 10 OnShow = FormShow 12 LCLVersion = '1.8.0. 6'11 LCLVersion = '1.8.0.4' 13 12 object ListView1: TListView 14 13 Left = 4 … … 41 40 item 42 41 Caption = 'Units' 43 Width = 1 0042 Width = 169 44 43 end> 45 44 OwnerData = True … … 66 65 end 67 66 end 67 object ListViewSort1: TListViewSort 68 ListView = ListView1 69 OnCompareItem = ListViewSort1CompareItem 70 OnFilter = ListViewSort1Filter 71 Column = 0 72 Order = soNone 73 left = 544 74 top = 110 75 end 68 76 end -
trunk/Forms/UFormPlayersStats.pas
r182 r190 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 Menus, ActnList, UGame ;9 Menus, ActnList, UGame, UListViewSort; 10 10 11 11 type … … 17 17 ActionList1: TActionList; 18 18 ListView1: TListView; 19 ListViewSort1: TListViewSort; 19 20 MenuItem1: TMenuItem; 20 21 PopupMenu1: TPopupMenu; … … 23 24 procedure FormShow(Sender: TObject); 24 25 procedure ListView1Data(Sender: TObject; Item: TListItem); 26 function ListViewSort1CompareItem(Item1, Item2: TObject): Integer; 27 procedure ListViewSort1Filter(ListViewSort: TListViewSort); 25 28 private 26 29 … … 45 48 begin 46 49 with Core.Game do 47 if Item.Index < Players.Count then48 with TPlayer( Players[Item.Index]) do begin50 if Item.Index < ListViewSort1.List.Count then 51 with TPlayer(ListViewSort1.List[Item.Index]) do begin 49 52 Item.Caption := Name; 50 Item.Data := Players[Item.Index];53 Item.Data := ListViewSort1.List[Item.Index]; 51 54 Item.SubItems.Add(PlayerModeText[Mode]); 52 55 Item.SubItems.Add(IntToStr(TotalCells)); … … 54 57 Item.SubItems.Add(IntToStr(TotalCities)); 55 58 Item.SubItems.Add(IntToStr(TotalUnits)); 59 end; 60 end; 61 62 function TFormPlayersStats.ListViewSort1CompareItem(Item1, Item2: TObject 63 ): Integer; 64 begin 65 Result := 0; 66 if Assigned(Item1) and Assigned(Item2) and (ListViewSort1.Order <> soNone) then begin 67 with ListViewSort1 do 68 case Column of 69 0: Result := CompareString(TPlayer(Item1).Name, TPlayer(Item2).Name); 70 1: Result := CompareString(PlayerModeText[TPlayer(Item1).Mode], PlayerModeText[TPlayer(Item2).Mode]); 71 2: Result := CompareInteger(TPlayer(Item1).TotalCells, TPlayer(Item2).TotalCells); 72 3: Result := CompareInteger(TPlayer(Item1).TotalDiscovered, TPlayer(Item2).TotalDiscovered); 73 4: Result := CompareInteger(TPlayer(Item1).TotalCities, TPlayer(Item2).TotalCities); 74 5: Result := CompareInteger(TPlayer(Item1).TotalUnits, TPlayer(Item2).TotalUnits); 75 end; 76 if ListViewSort1.Order = soDown then Result := -Result; 77 end else Result := 0; 78 end; 79 80 procedure TFormPlayersStats.ListViewSort1Filter(ListViewSort: TListViewSort); 81 var 82 I: Integer; 83 begin 84 ListViewSort1.List.Clear; 85 for I := 0 to Core.Game.Players.Count - 1 do begin 86 ListViewSort1.List.Add(Core.Game.Players[I]); 56 87 end; 57 88 end; … … 78 109 procedure TFormPlayersStats.ReloadList; 79 110 begin 80 ListView1.Items.Count := Core.Game.Players.Count; 81 ListView1.Refresh; 111 ListViewSort1.Refresh; 82 112 end; 83 113
Note:
See TracChangeset
for help on using the changeset viewer.