Changeset 190 for trunk


Ignore:
Timestamp:
Apr 22, 2018, 2:46:28 PM (7 years ago)
Author:
chronos
Message:
  • Added: Sorting by table columns in players stats form.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormPlayersStats.lfm

    r182 r190  
    11object FormPlayersStats: TFormPlayersStats
    2   Left = 411
     2  Left = 709
    33  Height = 300
    4   Top = 237
     4  Top = 637
    55  Width = 697
    66  Caption = 'Players stats'
    77  ClientHeight = 300
    88  ClientWidth = 697
    9   DesignTimePPI = 120
    109  OnClose = FormClose
    1110  OnShow = FormShow
    12   LCLVersion = '1.8.0.6'
     11  LCLVersion = '1.8.0.4'
    1312  object ListView1: TListView
    1413    Left = 4
     
    4140      item
    4241        Caption = 'Units'
    43         Width = 100
     42        Width = 169
    4443      end>
    4544    OwnerData = True
     
    6665    end
    6766  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
    6876end
  • trunk/Forms/UFormPlayersStats.pas

    r182 r190  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   Menus, ActnList, UGame;
     9  Menus, ActnList, UGame, UListViewSort;
    1010
    1111type
     
    1717    ActionList1: TActionList;
    1818    ListView1: TListView;
     19    ListViewSort1: TListViewSort;
    1920    MenuItem1: TMenuItem;
    2021    PopupMenu1: TPopupMenu;
     
    2324    procedure FormShow(Sender: TObject);
    2425    procedure ListView1Data(Sender: TObject; Item: TListItem);
     26    function ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
     27    procedure ListViewSort1Filter(ListViewSort: TListViewSort);
    2528  private
    2629
     
    4548begin
    4649  with Core.Game do
    47   if Item.Index < Players.Count then
    48   with TPlayer(Players[Item.Index]) do begin
     50  if Item.Index < ListViewSort1.List.Count then
     51  with TPlayer(ListViewSort1.List[Item.Index]) do begin
    4952    Item.Caption := Name;
    50     Item.Data := Players[Item.Index];
     53    Item.Data := ListViewSort1.List[Item.Index];
    5154    Item.SubItems.Add(PlayerModeText[Mode]);
    5255    Item.SubItems.Add(IntToStr(TotalCells));
     
    5457    Item.SubItems.Add(IntToStr(TotalCities));
    5558    Item.SubItems.Add(IntToStr(TotalUnits));
     59  end;
     60end;
     61
     62function TFormPlayersStats.ListViewSort1CompareItem(Item1, Item2: TObject
     63  ): Integer;
     64begin
     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;
     78end;
     79
     80procedure TFormPlayersStats.ListViewSort1Filter(ListViewSort: TListViewSort);
     81var
     82  I: Integer;
     83begin
     84  ListViewSort1.List.Clear;
     85  for I := 0 to Core.Game.Players.Count - 1 do begin
     86    ListViewSort1.List.Add(Core.Game.Players[I]);
    5687  end;
    5788end;
     
    78109procedure TFormPlayersStats.ReloadList;
    79110begin
    80   ListView1.Items.Count := Core.Game.Players.Count;
    81   ListView1.Refresh;
     111  ListViewSort1.Refresh;
    82112end;
    83113
  • trunk/Languages/xtactics.cs.po

    r185 r190  
    99"MIME-Version: 1.0\n"
    1010"Content-Transfer-Encoding: 8bit\n"
    11 "X-Generator: Poedit 1.8.8\n"
     11"X-Generator: Poedit 2.0.4\n"
    1212"Language: cs\n"
    1313
     
    543543#: tformplayersstats.listview1.columns[2].caption
    544544msgid "Cells"
    545 msgstr "Objevených"
     545msgstr "Buněk"
    546546
    547547#: tformplayersstats.listview1.columns[3].caption
    548548msgctxt "tformplayersstats.listview1.columns[3].caption"
    549549msgid "Discovered"
    550 msgstr "Města"
     550msgstr "Objevených"
    551551
    552552#: tformplayersstats.listview1.columns[4].caption
    553553msgctxt "tformplayersstats.listview1.columns[4].caption"
    554554msgid "Cities"
    555 msgstr "Jednotky"
     555msgstr "Města"
    556556
    557557#: tformplayersstats.listview1.columns[5].caption
     
    883883msgid "64-bit UInt read overflow."
    884884msgstr ""
    885 
  • trunk/xtactics.lpi

    r185 r190  
    213213        <IsPartOfProject Value="True"/>
    214214        <ComponentName Value="FormPlayersStats"/>
     215        <HasResources Value="True"/>
    215216        <ResourceBaseClass Value="Form"/>
    216217      </Unit17>
Note: See TracChangeset for help on using the changeset viewer.