Changeset 110 for trunk/Forms/FormScore.pas
- Timestamp:
- Dec 10, 2024, 11:05:12 AM (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.