- Timestamp:
- Dec 10, 2024, 11:05:12 AM (5 weeks ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/FormScore.lfm
r109 r110 1 1 object FormScore: TFormScore 2 Left = 7412 Left = 669 3 3 Height = 352 4 Top = 49 65 Width = 6294 Top = 492 5 Width = 706 6 6 Caption = 'Score' 7 7 ClientHeight = 352 8 ClientWidth = 6298 ClientWidth = 706 9 9 DesignTimePPI = 144 10 10 OnShow = FormShow … … 14 14 Height = 296 15 15 Top = 8 16 Width = 6 1616 Width = 693 17 17 Anchors = [akTop, akLeft, akRight, akBottom] 18 18 Columns = < … … 61 61 end 62 62 object ButtonClose: TButton 63 Left = 5 1263 Left = 589 64 64 Height = 38 65 65 Top = 312 … … 80 80 OnClick = ButtonClearClick 81 81 end 82 object ListViewSort1: TListViewSort 83 ListView = ListView1 84 OnCompareItem = ListViewSort1CompareItem 85 OnFilter = ListViewSort1Filter 86 Column = 2 87 Order = soDown 88 Left = 253 89 Top = 153 90 end 82 91 end -
trunk/Forms/FormScore.pas
r109 r110 5 5 uses 6 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls, 7 FormEx, Score;7 FormEx, ListViewSort, Score, DateUtils, Generics.Collections; 8 8 9 9 type … … 15 15 ButtonClear: TButton; 16 16 ListView1: TListView; 17 ListViewSort1: TListViewSort; 17 18 procedure ButtonClearClick(Sender: TObject); 18 19 procedure FormShow(Sender: TObject); 19 20 procedure ListView1Data(Sender: TObject; Item: TListItem); 21 function ListViewSort1CompareItem(Item1, Item2: TObject): Integer; 22 procedure ListViewSort1Filter(ListViewSort: TListViewSort); 20 23 private 21 24 FScores: TScores; 22 25 procedure SetScores(AValue: TScores); 26 procedure FilterList(List: TObjectList<TObject>); 23 27 public 24 28 procedure ReloadList; … … 35 39 SClearQuery = 'Do you really want to clear score history?'; 36 40 37 38 41 { TFormScore } 39 42 40 43 procedure TFormScore.ListView1Data(Sender: TObject; Item: TListItem); 41 44 begin 42 if Item.Index < FScores.Count then43 with FScores[Item.Index]do begin45 if Item.Index < ListViewSort1.List.Count then 46 with TScore(ListViewSort1.List[Item.Index]) do begin 44 47 Item.Caption := DateTimeToStr(StartTime); 48 Item.Data := ListViewSort1.List[Item.Index]; 45 49 Item.SubItems.Add(BoardSize); 46 50 Item.SubItems.Add(IntToStr(Score)); … … 52 56 Item.SubItems.Add(TimeToStr(Duration)); 53 57 end; 58 end; 59 60 function TFormScore.ListViewSort1CompareItem(Item1, Item2: TObject): Integer; 61 var 62 Score1, Score2: TScore; 63 begin 64 Result := 0; 65 if Assigned(Item1) and Assigned(Item2) and (ListViewSort1.Order <> soNone) then begin 66 Score1 := TScore(Item1); 67 Score2 := TScore(Item2); 68 with ListViewSort1 do 69 case Column of 70 0: Result := CompareDateTime(Score1.StartTime, Score2.StartTime); 71 1: Result := CompareString(Score1.BoardSize, Score2.BoardSize); 72 2: Result := CompareInteger(Score1.Score, Score2.Score); 73 3: Result := CompareInteger(Score1.BiggestTile, Score2.BiggestTile); 74 4: Result := CompareInteger(Score1.Moves, Score2.Moves); 75 5: Result := CompareInteger(Score1.UsedUndos, Score2.UsedUndos); 76 6: Result := CompareInteger(Score1.DisabledTiles, Score2.DisabledTiles); 77 7: Result := CompareInteger(Score1.UnmergeableTiles, Score2.UnmergeableTiles); 78 8: Result := CompareDateTime(Score1.Duration, Score2.Duration); 79 end; 80 if ListViewSort1.Order = soDown then Result := -Result; 81 end else Result := 0; 82 end; 83 84 procedure TFormScore.ListViewSort1Filter(ListViewSort: TListViewSort); 85 begin 86 if Assigned(Scores) then Scores.AssignToList(ListViewSort1.List) 87 else begin 88 ListViewSort1.List.Clear; 89 end; 90 FilterList(ListViewSort1.List); 54 91 end; 55 92 … … 74 111 end; 75 112 113 procedure TFormScore.FilterList(List: TObjectList<TObject>); 114 begin 115 end; 116 76 117 procedure TFormScore.ReloadList; 77 118 begin 78 if Assigned(FScores) then begin 79 ListView1.Items.Count := FScores.Count; 80 end else ListView1.Items.Count := 0; 81 ListView1.Refresh; 119 ListViewSort1.Refresh; 82 120 end; 83 121 -
trunk/Score.pas
r109 r110 4 4 5 5 uses 6 Classes, SysUtils, Generics.Collections, RegistryEx ;6 Classes, SysUtils, Generics.Collections, RegistryEx, ListViewSort; 7 7 8 8 type … … 31 31 procedure SaveToRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 32 32 procedure LoadFromRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 33 procedure AssignToList(List: TObjects); 33 34 end; 34 35 … … 121 122 end; 122 123 124 procedure TScores.AssignToList(List: TObjects); 125 var 126 I: Integer; 127 begin 128 while List.Count > Count do List.Delete(List.Count - 1); 129 for I := 0 to List.Count - 1 do List[I] := Items[I]; 130 while List.Count < Count do List.Add(Items[List.Count]); 131 end; 132 123 133 end. 124 134
Note:
See TracChangeset
for help on using the changeset viewer.