Changeset 318 for trunk


Ignore:
Timestamp:
Jun 21, 2024, 3:20:20 PM (5 months ago)
Author:
chronos
Message:
  • Modified: Code cleanup.
Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/ClientGUI.pas

    r317 r318  
    334334  end;
    335335end;
    336 
    337336
    338337procedure TClientGUI.DrawCells(Canvas: TCanvas; View: TView);
  • trunk/Core.pas

    r317 r318  
    420420  if not Assigned(FormMain.FormPlayersStats) then
    421421    FormMain.FormPlayersStats := TFormPlayersStats.Create(nil);
     422  FormMain.FormPlayersStats.OnSpectate := Spectate;
    422423  FormMain.FormPlayersStats.Show;
    423424end;
     
    446447  if not Assigned(FormMain.FormCharts) then
    447448    FormMain.FormCharts := TFormCharts.Create(nil);
     449  FormMain.FormCharts.Game := Game;
    448450  FormMain.FormCharts.Show;
    449451end;
     
    451453procedure TCore.AShowKeyShortcutsExecute(Sender: TObject);
    452454begin
    453   if not Assigned(FormMain.FormKeyShortcuts) then FormMain.FormKeyShortcuts := TFormKeyShortcuts.Create(nil);
    454   FormMain.FormKeyShortcuts.Show;
     455  if not Assigned(FormMain.FormKeyShortcuts) then
     456    FormMain.FormKeyShortcuts := TFormKeyShortcuts.Create(nil);
     457  with FormMain.FormKeyShortcuts do begin
     458    SourceComponents.Clear;
     459    SourceComponents.Add(Self);
     460    SourceComponents.Add(FormMain);
     461    Show;
     462  end;
    455463end;
    456464
     
    459467  if not Assigned(FormMain.FormUnitMoves) then
    460468    FormMain.FormUnitMoves := TFormUnitMoves.Create(nil);
     469  FormMain.FormUnitMoves.Game := Game;
    461470  FormMain.FormUnitMoves.Show;
    462471end;
  • trunk/Forms/FormCharts.pas

    r317 r318  
    55uses
    66  Classes, SysUtils, FileUtil, TAGraph, TASeries, Forms, Controls, Graphics,
    7   Dialogs, StdCtrls, FormEx;
     7  Dialogs, StdCtrls, FormEx, Game;
    88
    99type
     
    1616    procedure ComboBox1Change(Sender: TObject);
    1717    procedure FormShow(Sender: TObject);
     18  private
     19    FGame: TGame;
    1820  public
    1921    procedure Redraw;
    2022    procedure Translate;
     23    property Game: TGame read FGame write FGame;
    2124  end;
    2225
     
    2730
    2831uses
    29   Core, Game, Player;
     32  Player;
    3033
    3134resourcestring
     
    3538  SCitiesCount = 'Cities count';
    3639  SWinObjectiveCells = 'Win objective cells';
    37 
    3840
    3941{ TFormCharts }
     
    5961begin
    6062  Chart1.Series.Clear;
    61   for I := 0 to Core.Core.Game.Players.Count - 1 do
    62   with TPlayer(Core.Core.Game.Players[I]) do begin
     63  for I := 0 to Game.Players.Count - 1 do
     64  with TPlayer(Game.Players[I]) do begin
    6365    NewSeries := TLineSeries.Create(nil);
    6466    NewSeries.LinePen.Color := Color;
    6567    for X := 0 to TurnStats.Count - 1 do begin
    66       if ComboBox1.ItemIndex = 0 then NewSeries.AddXY(X, TGameTurnStat(TurnStats[X]).OccupiedCells)
    67       else if ComboBox1.ItemIndex = 1 then NewSeries.AddXY(X, TGameTurnStat(TurnStats[X]).Units)
    68       else if ComboBox1.ItemIndex = 2 then NewSeries.AddXY(X, TGameTurnStat(TurnStats[X]).DiscoveredCells)
    69       else if ComboBox1.ItemIndex = 3 then NewSeries.AddXY(X, TGameTurnStat(TurnStats[X]).Cities)
    70       else if ComboBox1.ItemIndex = 4 then NewSeries.AddXY(X, TGameTurnStat(TurnStats[X]).WinObjectiveCells);
     68      if ComboBox1.ItemIndex = 0 then NewSeries.AddXY(X, TurnStats[X].OccupiedCells)
     69      else if ComboBox1.ItemIndex = 1 then NewSeries.AddXY(X, TurnStats[X].Units)
     70      else if ComboBox1.ItemIndex = 2 then NewSeries.AddXY(X, TurnStats[X].DiscoveredCells)
     71      else if ComboBox1.ItemIndex = 3 then NewSeries.AddXY(X, TurnStats[X].Cities)
     72      else if ComboBox1.ItemIndex = 4 then NewSeries.AddXY(X, TurnStats[X].WinObjectiveCells);
    7173    end;
    7274    Chart1.AddSeries(NewSeries);
     
    7880  LastIndex: Integer;
    7981begin
    80   Core.Core.Translator1.TranslateComponentRecursive(Self);
     82  TFormEx.Translator.TranslateComponentRecursive(Self);
    8183  with ComboBox1 do begin
    8284    LastIndex := ItemIndex;
  • trunk/Forms/FormClient.pas

    r317 r318  
    168168    FormMove.ShowWinProbability := CellTo.MapCell.Player <> CellFrom.MapCell.Player;
    169169
     170    FormMove.Game := Client.Game;
    170171    if FormMove.ShowModal = mrOk then begin
    171172      CountOnce := FormMove.SpinEditOnce.Value;
  • trunk/Forms/FormGameSystems.lfm

    r317 r318  
    11object FormGameSystems: TFormGameSystems
    22  Left = 1080
    3   Height = 360
     3  Height = 300
    44  Top = 570
    5   Width = 480
     5  Width = 400
    66  Caption = 'Game systems'
    7   ClientHeight = 360
    8   ClientWidth = 480
     7  ClientHeight = 300
     8  ClientWidth = 400
    99  DesignTimePPI = 144
    1010  OnCreate = FormCreate
     
    1414  object ListView1: TListView
    1515    Left = 0
    16     Height = 322
     16    Height = 262
    1717    Top = 0
    18     Width = 480
     18    Width = 400
    1919    Align = alClient
    2020    Columns = <   
     
    3939    Left = 0
    4040    Height = 38
    41     Top = 322
    42     Width = 480
     41    Top = 262
     42    Width = 400
    4343    Align = alBottom
    4444    Images = Core.ImageListSmall
  • trunk/Forms/FormGameSystems.pas

    r317 r318  
    127127  finally
    128128    FreeAndNil(FormGameSystem);
    129   end;
    130   TempEntry.Free;
     129    FreeAndNil(TempEntry);
     130  end;
    131131end;
    132132
  • trunk/Forms/FormItem.pas

    r317 r318  
    3535
    3636{$R *.lfm}
    37 
    38 uses
    39   Core;
    4037
    4138{ TFormItem }
     
    204201    NewControl.Top := Y;
    205202    NewControl.Parent := Self;
    206     Core.Core.Translator1.TranslateComponent(NewControl);
    207     Core.Core.ThemeManager1.ApplyTheme(NewControl);
     203    TFormEx.Translator.TranslateComponent(NewControl);
     204    TFormEx.ThemeManager.ApplyTheme(NewControl);
    208205    NewControl.Visible := True;
    209206    DataControls.Add(NewControl);
  • trunk/Forms/FormKeyShortcuts.lfm

    r317 r318  
    11object FormKeyShortcuts: TFormKeyShortcuts
    22  Left = 1016
    3   Height = 524
     3  Height = 437
    44  Top = 501
    5   Width = 632
     5  Width = 527
    66  Caption = 'Key shortcuts'
    7   ClientHeight = 524
    8   ClientWidth = 632
     7  ClientHeight = 437
     8  ClientWidth = 527
    99  DesignTimePPI = 144
     10  OnCreate = FormCreate
     11  OnDestroy = FormDestroy
    1012  OnShow = FormShow
    1113  LCLVersion = '3.4.0.0'
    1214  object ListView1: TListView
    1315    Left = 5
    14     Height = 514
     16    Height = 427
    1517    Top = 5
    16     Width = 622
     18    Width = 517
    1719    Align = alClient
    1820    BorderSpacing.Around = 5
  • trunk/Forms/FormKeyShortcuts.pas

    r317 r318  
    55uses
    66  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
    7   ComCtrls, ActnList, LCLProc, Menus, FormEx;
     7  ComCtrls, ActnList, LCLProc, Menus, FormEx, Generics.Collections;
    88
    99type
     
    1515    MenuItem1: TMenuItem;
    1616    PopupMenu1: TPopupMenu;
     17    procedure FormCreate(Sender: TObject);
     18    procedure FormDestroy(Sender: TObject);
    1719    procedure FormShow(Sender: TObject);
    1820    procedure MenuItem1Click(Sender: TObject);
    1921  public
     22    SourceComponents: TObjectList<TComponent>;
    2023    procedure LoadFromComponent(C: TComponent);
    2124  end;
     
    2528
    2629uses
    27   FormMain, Core;
     30  FormMain;
    2831
    2932resourcestring
     
    3437
    3538procedure TFormKeyShortcuts.FormShow(Sender: TObject);
     39var
     40  I: Integer;
    3641begin
    3742  try
    3843    ListView1.BeginUpdate;
    3944    ListView1.Clear;
    40     LoadFromComponent(Core.Core);
    41     LoadFromComponent(Core.Core.FormMain);
     45    for I := 0 to SourceComponents.Count - 1 do
     46      LoadFromComponent(SourceComponents[I]);
    4247  finally
    4348    ListView1.EndUpdate;
    4449  end;
     50end;
     51
     52procedure TFormKeyShortcuts.FormCreate(Sender: TObject);
     53begin
     54  SourceComponents := TObjectList<TComponent>.Create;
     55  SourceComponents.OwnsObjects := False;
     56end;
     57
     58procedure TFormKeyShortcuts.FormDestroy(Sender: TObject);
     59begin
     60  FreeAndNil(SourceComponents);
    4561end;
    4662
  • trunk/Forms/FormMove.pas

    r317 r318  
    44
    55uses
    6   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Spin,
     6  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Spin, Game,
    77  StdCtrls, ComCtrls, FormEx;
    88
     
    4343    ShowWinProbability: Boolean;
    4444    AllowChangeOnce: Boolean;
     45    Game: TGame;
    4546    procedure UpdateView;
    4647  end;
     
    5051
    5152{$R *.lfm}
    52 
    53 uses
    54   Core;
    5553
    5654{ TFormMove }
     
    7371  Label3.Visible := ShowWinProbability;
    7472  LabelWinProbability.Caption :=
    75     IntToStr(Round(Core.Core.Game.AttackProbability(AttackCount + SpinEditOnce.Value,
     73    IntToStr(Round(Game.AttackProbability(AttackCount + SpinEditOnce.Value,
    7674    DefendCount) * 100)) + ' %';
    7775end;
  • trunk/Forms/FormPlayersStats.pas

    r317 r318  
    55uses
    66  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    7   Menus, ActnList, Game, ListViewSort, FormEx;
     7  Menus, ActnList, Game, ListViewSort, FormEx, Player;
    88
    99type
     
    2323    function ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
    2424    procedure ListViewSort1Filter(ListViewSort: TListViewSort);
     25  private
     26    FOnSpectate: TPlayerEvent;
    2527  public
     28    Game: TGame;
    2629    procedure ReloadList;
     30    property OnSpectate: TPlayerEvent read FOnSpectate write FOnSpectate;
    2731  end;
    2832
    2933
    3034implementation
    31 
    32 uses
    33   Core, Player;
    3435
    3536{$R *.lfm}
     
    3940procedure TFormPlayersStats.ListView1Data(Sender: TObject; Item: TListItem);
    4041begin
    41   with Core.Core.Game do
     42  with Game do
    4243  if Item.Index < ListViewSort1.List.Count then
    4344  with TPlayer(ListViewSort1.List[Item.Index]) do begin
     
    7778begin
    7879  ListViewSort1.List.Clear;
    79   for I := 0 to Core.Core.Game.Players.Count - 1 do begin
    80     ListViewSort1.List.Add(Core.Core.Game.Players[I]);
     80  for I := 0 to Game.Players.Count - 1 do begin
     81    ListViewSort1.List.Add(Game.Players[I]);
    8182  end;
    8283end;
     
    9091begin
    9192  if Assigned(ListView1.Selected) then
    92     Core.Core.Spectate(TPlayer(ListView1.Selected.Data));
     93    if Assigned(FOnSpectate) then
     94      FOnSpectate(TPlayer(ListView1.Selected.Data));
    9395end;
    9496
  • trunk/Forms/FormSettings.pas

    r317 r318  
    4141    procedure Save;
    4242  end;
    43 
    4443
    4544
  • trunk/Forms/FormUnitMoves.lfm

    r317 r318  
    11object FormUnitMoves: TFormUnitMoves
    22  Left = 879
    3   Height = 499
    4   Top = 514
    5   Width = 950
     3  Height = 418
     4  Top = 511
     5  Width = 802
    66  Caption = 'Unit moves'
    7   ClientHeight = 499
    8   ClientWidth = 950
     7  ClientHeight = 418
     8  ClientWidth = 802
    99  DesignTimePPI = 144
    1010  OnShow = FormShow
     
    1212  object ListView1: TListView
    1313    Left = 0
    14     Height = 499
     14    Height = 418
    1515    Top = 0
    16     Width = 950
     16    Width = 802
    1717    Align = alClient
    1818    Columns = <   
  • trunk/Forms/FormUnitMoves.pas

    r317 r318  
    55uses
    66  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    7   FormEx;
     7  FormEx, Game;
    88
    99type
     
    1616    procedure ListView1Data(Sender: TObject; Item: TListItem);
    1717  public
     18    Game: TGame;
    1819    procedure ReloadList;
    1920  end;
     
    2324
    2425uses
    25   Game, Core, Player;
     26  Player;
    2627
    2728{$R *.lfm}
     
    3132procedure TFormUnitMoves.ListView1Data(Sender: TObject; Item: TListItem);
    3233begin
    33   if Assigned(Core.Core.Game) and Assigned(Core.Core.Game.CurrentPlayer) then
    34   with Core.Core.Game.CurrentPlayer do
     34  if Assigned(Game) and Assigned(Game.CurrentPlayer) then
     35  with Game.CurrentPlayer do
    3536  if (Mode = pmHuman) and (Item.Index < Moves.Count) then
    3637  with TUnitMove(Moves[Item.Index]) do begin
     
    4950procedure TFormUnitMoves.ReloadList;
    5051begin
    51   if Assigned(Core.Core.Game) and Assigned(Core.Core.Game.CurrentPlayer) and
    52   (Core.Core.Game.CurrentPlayer.Mode = pmHuman) then
    53     ListView1.Items.Count := Core.Core.Game.CurrentPlayer.Moves.Count
     52  if Assigned(Game) and Assigned(Game.CurrentPlayer) and
     53  (Game.CurrentPlayer.Mode = pmHuman) then
     54    ListView1.Items.Count := Game.CurrentPlayer.Moves.Count
    5455  else ListView1.Items.Count := 0;
    5556  ListView1.Refresh;
  • trunk/GameClient.pas

    r317 r318  
    138138procedure TClient.ReceiveCmd(Command: TCommand; DataOut, DataIn: TStream);
    139139begin
    140 
    141140end;
    142141
     
    249248end;
    250249
    251 
    252250end.
    253251
  • trunk/GameSystem.pas

    r317 r318  
    8181begin
    8282  Files := TStringList.Create;
    83   FindAllFiles(Files, Dir, '*' + GameSystemExt, True, faAnyFile);
    84   for I := 0 to Files.Count - 1 do begin
    85     NewItem := TGameSystem.Create;
    86     NewItem.LoadFromFile(Files[I]);
    87     Add(NewItem);
    88   end;
    89   Files.Free;
     83  try
     84    FindAllFiles(Files, Dir, '*' + GameSystemExt, True, faAnyFile);
     85    for I := 0 to Files.Count - 1 do begin
     86      NewItem := TGameSystem.Create;
     87      NewItem.LoadFromFile(Files[I]);
     88      Add(NewItem);
     89    end;
     90  finally
     91    Files.Free;
     92  end;
    9093end;
    9194
  • trunk/Languages/xtactics.cs.po

    r317 r318  
    210210msgctxt "formlist.snew"
    211211msgid "New"
    212 msgstr "Nová"
     212msgstr "Nový"
    213213
    214214#: formlist.sremoveitems
  • trunk/Player.pas

    r317 r318  
    8686    procedure SaveToNode(Node: TDOMNode);
    8787  end;
    88 
    8988
    9089  { TPlayer }
     
    149148  end;
    150149
     150  TPlayerEvent = procedure (Player: TPlayer) of object;
    151151  TPlayerArray = array of TPlayer;
    152152
  • trunk/TCP.pas

    r317 r318  
    199199destructor TTCPClientThread.Destroy;
    200200begin
    201   Socket.Free;
     201  FreeAndNil(Socket);
    202202  inherited;
    203203end;
Note: See TracChangeset for help on using the changeset viewer.