Changeset 344 for trunk/Forms


Ignore:
Timestamp:
Dec 23, 2024, 8:16:05 AM (4 weeks ago)
Author:
chronos
Message:
  • Modified: Improved implementation of TItemList class to be generic class to avoid explicit typecasting.
Location:
trunk/Forms
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/FormCharts.pas

    r318 r344  
    6262  Chart1.Series.Clear;
    6363  for I := 0 to Game.Players.Count - 1 do
    64   with TPlayer(Game.Players[I]) do begin
     64  with Game.Players[I] do begin
    6565    NewSeries := TLineSeries.Create(nil);
    6666    NewSeries.LinePen.Color := Color;
  • trunk/Forms/FormGameSystem.lfm

    r330 r344  
    11object FormGameSystem: TFormGameSystem
    22  Left = 954
    3   Height = 482
     3  Height = 402
    44  Top = 479
    5   Width = 651
     5  Width = 542
    66  Caption = 'Game system'
    7   ClientHeight = 482
    8   ClientWidth = 651
    9   DesignTimePPI = 144
     7  ClientHeight = 402
     8  ClientWidth = 542
     9  DesignTimePPI = 120
    1010  OnCreate = FormCreate
    1111  OnDestroy = FormDestroy
    12   LCLVersion = '3.4.0.0'
     12  LCLVersion = '3.6.0.0'
    1313  object ButtonSave: TButton
    14     Left = 160
    15     Height = 38
    16     Top = 432
    17     Width = 113
     14    Left = 133
     15    Height = 32
     16    Top = 360
     17    Width = 94
    1818    Anchors = [akLeft, akBottom]
    1919    Caption = 'Save'
     
    2323  end
    2424  object ButtonLoad: TButton
    25     Left = 24
    26     Height = 38
    27     Top = 432
    28     Width = 113
     25    Left = 20
     26    Height = 32
     27    Top = 360
     28    Width = 94
    2929    Anchors = [akLeft, akBottom]
    3030    Caption = 'Load'
     
    3434  end
    3535  object ButtonCancel: TButton
    36     Left = 374
    37     Height = 38
    38     Top = 432
    39     Width = 113
     36    Left = 311
     37    Height = 32
     38    Top = 360
     39    Width = 94
    4040    Anchors = [akRight, akBottom]
    4141    Caption = 'Cancel'
     
    4545  end
    4646  object ButtonOk: TButton
    47     Left = 516
    48     Height = 38
    49     Top = 432
    50     Width = 113
     47    Left = 430
     48    Height = 32
     49    Top = 360
     50    Width = 94
    5151    Anchors = [akRight, akBottom]
    5252    Caption = 'OK'
     
    5656  end
    5757  object PageControl1: TPageControl
    58     Left = 16
    59     Height = 400
    60     Top = 16
    61     Width = 613
     58    Left = 13
     59    Height = 334
     60    Top = 13
     61    Width = 511
    6262    ActivePage = TabSheetGeneral
    6363    Anchors = [akTop, akLeft, akRight, akBottom]
     
    6767    object TabSheetGeneral: TTabSheet
    6868      Caption = 'General'
    69       ClientHeight = 362
    70       ClientWidth = 605
     69      ClientHeight = 301
     70      ClientWidth = 503
    7171      ParentFont = False
    7272      object CheckBoxEmptyCellsNeutral: TCheckBox
    73         Left = 16
    74         Height = 29
    75         Top = 16
    76         Width = 330
     73        Left = 13
     74        Height = 24
     75        Top = 13
     76        Width = 277
    7777        Caption = 'Set cells without player units as neutral'
    7878        ParentFont = False
     
    8080      end
    8181      object CheckBoxUnitsSplitMerge: TCheckBox
    82         Left = 16
    83         Height = 29
    84         Top = 55
    85         Width = 213
     82        Left = 13
     83        Height = 24
     84        Top = 46
     85        Width = 178
    8686        Caption = 'Units can split or merge'
    8787        ParentFont = False
     
    8989      end
    9090      object CheckBoxUnitsMoveImmediately: TCheckBox
    91         Left = 16
    92         Height = 29
    93         Top = 95
    94         Width = 217
     91        Left = 13
     92        Height = 24
     93        Top = 79
     94        Width = 182
    9595        Caption = 'Units move immediately'
    9696        ParentFont = False
     
    9898      end
    9999      object Label5: TLabel
    100         Left = 16
    101         Height = 25
    102         Top = 136
    103         Width = 153
     100        Left = 13
     101        Height = 20
     102        Top = 113
     103        Width = 128
    104104        Caption = 'Preferred grid type:'
    105105        ParentColor = False
     
    107107      end
    108108      object ComboBoxPreferredGridType: TComboBox
    109         Left = 272
    110         Height = 33
    111         Top = 136
    112         Width = 304
    113         ItemHeight = 25
     109        Left = 227
     110        Height = 28
     111        Top = 113
     112        Width = 253
     113        ItemHeight = 20
    114114        Items.Strings = (
    115115          'None'
     
    140140  end
    141141  object OpenDialog1: TOpenDialog
    142     Left = 440
    143     Top = 160
     142    Left = 367
     143    Top = 133
    144144  end
    145145  object SaveDialog1: TSaveDialog
    146     Left = 232
    147     Top = 160
     146    Left = 193
     147    Top = 133
    148148  end
    149149end
  • trunk/Forms/FormGameSystem.pas

    r330 r344  
    5151
    5252uses
    53   MapType;
     53  MapType, ItemList;
    5454
    5555resourcestring
  • trunk/Forms/FormItem.pas

    r321 r344  
    8080  J: Integer;
    8181  Control: TControl;
    82   ReferenceList: TItemList;
     82  ReferenceList: TItemList<TItem>;
    8383  ReferenceItem: TItem;
    8484begin
     
    106106      try
    107107        TComboBox(Control).Items.Clear;
    108         ReferenceList := Item.GetReferenceList(Index);
     108        ReferenceList := TItemList<TItem>(Item.GetReferenceList(Index));
    109109        if Assigned(ReferenceList) then
    110110          for J := 0 to ReferenceList.Count - 1 do
  • trunk/Forms/FormList.pas

    r317 r344  
    4646      Selected: Boolean);
    4747  private
    48     FList: TItemList;
    49     procedure SetList(AValue: TItemList);
     48    FList: IList<TItem>;
     49    procedure SetList(AValue: IList<TItem>);
    5050    procedure UpdateListViewColumns;
    5151  public
     
    5454    procedure UpdateInterface;
    5555    procedure UpdateList;
    56     property List: TItemList read FList write SetList;
     56    property List: IList<TItem> read FList write SetList;
    5757  end;
    5858
     
    9898  if Assigned(ListView1.Selected) then
    9999  with TItem(ListView1.Selected.Data) do begin
    100     TempEntry := List.CreateItem;
     100    TempEntry := List.CreateBaseItem;
    101101    TempEntry.Assign(TItem(ListView1.Selected.Data));
    102102    FormItem := TFormItem.Create(Self);
     
    122122  if (MaxItemCount <> -1) and (List.Count >= MaxItemCount) then Exit;
    123123
    124   TempEntry := List.CreateItem;
     124  TempEntry := List.CreateBaseItem;
    125125  FormItem := TFormItem.Create(Self);
    126126  try
    127     TempEntry.Name := List.GetNextAvailableName(SNew + ' ' + LowerCase(List.GetItemClass.GetClassName));
     127    TempEntry.Name := List.GetNextAvailableName(SNew + ' ' + LowerCase(List.GetName));
    128128    FormItem.Item := TempEntry;
    129129    if FormItem.ShowModal = mrOk then begin
     
    146146  if (MaxItemCount <> -1) and (List.Count >= MaxItemCount) then Exit;
    147147
    148   TempEntry := List.CreateItem;
     148  TempEntry := List.CreateBaseItem;
    149149  TempEntry.Assign(TItem(ListView1.Selected.Data));
    150150  FormItem := TFormItem.Create(Self);
     
    219219    //Item.Caption := GetName;
    220220    Item.Data := List[Item.Index];
    221     Fields := List.GetItemClass.GetFields;
     221    Fields := List.GetItemFields;
    222222    try
    223223      for I := 0 to Fields.Count - 1 do begin
     
    250250end;
    251251
    252 procedure TFormList.SetList(AValue: TItemList);
     252procedure TFormList.SetList(AValue: IList<TItem>);
    253253begin
    254254  if FList = AValue then Exit;
     
    261261  Fields: TItemFields;
    262262begin
    263   Fields := List.GetItemClass.GetFields;
     263  Fields := List.GetItemFields;
    264264  ListView1.Columns.BeginUpdate;
    265265  try
  • trunk/Forms/FormNew.pas

    r330 r344  
    388388  GamePreview.GeneratePlayers := False;
    389389  GamePreview.New;
    390   GamePreview.CurrentPlayer := TPlayer(GamePreview.Players.First);
     390  GamePreview.CurrentPlayer := GamePreview.Players.First;
    391391  Bitmap := Image1.Picture.Bitmap;
    392392  Bitmap.SetSize(Image1.Width, Image1.Height);
Note: See TracChangeset for help on using the changeset viewer.