Changeset 199 for trunk


Ignore:
Timestamp:
May 16, 2018, 2:48:57 PM (7 years ago)
Author:
chronos
Message:
  • Modified: Initial game setting made independent to current game settings. So last game can be automatically loaded on start and initial setting will be intact.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormChat.lfm

    r179 r199  
    88  ClientWidth = 527
    99  DesignTimePPI = 120
    10   LCLVersion = '1.8.0.6'
     10  LCLVersion = '1.8.2.0'
    1111  object MemoChat: TMemo
    1212    Left = 8
  • trunk/Forms/UFormChat.pas

    r185 r199  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   UGame, UGameClient, SpecializedList;
     9  UGame, UGameClient;
    1010
    1111type
  • trunk/Forms/UFormNew.pas

    r198 r199  
    132132  private
    133133    Players: TPlayers;
     134    ServerList: TServerList;
    134135  public
    135     ServerList: TServerList;
    136136    procedure Translate;
    137137    procedure ReloadView;
     
    334334  AServerAdd.Enabled := RadioButtonModeNetworkClient.Checked;
    335335  AServerModify.Enabled := RadioButtonModeNetworkClient.Checked;
     336  PageControl2.TabIndex := ComboBoxWinObjective.ItemIndex;
    336337end;
    337338
     
    359360begin
    360361  Players := TPlayers.Create;
     362  ServerList := TServerList.Create;
    361363  FormChat := TFormChat.Create(nil);
    362364  FormChat.ManualDock(PanelChat, nil, alClient);
     
    383385procedure TFormNew.ComboBoxWinObjectiveChange(Sender: TObject);
    384386begin
    385   PageControl2.TabIndex := ComboBoxWinObjective.ItemIndex;
     387  UpdateInterface;
    386388end;
    387389
     
    483485procedure TFormNew.FormDestroy(Sender: TObject);
    484486begin
     487  FreeAndNil(ServerList);
    485488  FreeAndNil(Players);
    486489  FreeAndNil(FormChat);
     
    490493begin
    491494  with Server do begin
    492     CheckBoxSymetricMap.Checked := Game.SymetricMap;
    493     CheckBoxVoid.Checked := Game.VoidEnabled;
    494     SpinEditVoidPercent.Value := Game.VoidPercentage;
    495     SpinEditVoidPercent.Enabled := Game.VoidEnabled;
    496     Players.Assign(Game.PlayersSetting);
    497     CheckBoxCity.Checked := Game.CityEnabled;
    498     SpinEditCityPercent.Value := Game.CityPercentage;
    499     SpinEditMapSizeX.Value := Game.Map.Size.X;
    500     SpinEditMapSizeY.Value := Game.Map.Size.Y;
    501     TrackBarSizeX.Position := Game.Map.Size.X;
    502     TrackBarSizeY.Position := Game.Map.Size.Y;
    503     RadioGroupGrowAmount.ItemIndex := Integer(Game.GrowAmount);
    504     RadioGroupGrowCells.ItemIndex := Integer(Game.GrowCells);
    505     ComboBoxGridType.ItemIndex := Integer(Game.MapType) - 1;
    506     ComboBoxWinObjective.ItemIndex := Integer(Game.WinObjective);
    507     SpinEditNeutralUnits.Value := Game.MaxNeutralUnits;
    508     ComboBoxMapShape.ItemIndex := Integer(Game.Map.Shape);
    509     EditImageFile.Text := Game.MapImageFileName;
    510     CheckBoxFogOfWar.Checked := Game.FogOfWar;
    511     CheckBoxBridges.Checked := Game.BridgeEnabled;
    512495    RadioButtonModeLocal.Checked := Mode = smLocal;
    513496    RadioButtonModeNetworkClient.Checked := Mode = smNetworkClient;
     
    515498    EditServerAddress.Text := LocalNetworkAddress;
    516499    SpinEditServerPort.Value := LocalNetworkPort;
    517     SpinEditMaxPower.Value := Game.MaxPower;
    518     SpinEditTurns.Value := Game.StayAliveForDefinedTurns;
    519     SpinEditSpecialCells.Value := Game.SpecialCaptureCellCount;
     500  end;
     501  ServerList.Assign(Core.ServerList);
     502  Players.Assign(Core.GameSettings.Players);
     503  with Core.GameSettings do begin
     504    CheckBoxSymetricMap.Checked := SymetricMap;
     505    CheckBoxVoid.Checked := VoidEnabled;
     506    SpinEditVoidPercent.Value := VoidPercentage;
     507    SpinEditVoidPercent.Enabled := VoidEnabled;
     508    CheckBoxCity.Checked := CityEnabled;
     509    SpinEditCityPercent.Value := CityPercentage;
     510    SpinEditMapSizeX.Value := Map.Size.X;
     511    SpinEditMapSizeY.Value := Map.Size.Y;
     512    TrackBarSizeX.Position := Map.Size.X;
     513    TrackBarSizeY.Position := Map.Size.Y;
     514    RadioGroupGrowAmount.ItemIndex := Integer(GrowAmount);
     515    RadioGroupGrowCells.ItemIndex := Integer(GrowCells);
     516    ComboBoxGridType.ItemIndex := Integer(MapType) - 1;
     517    ComboBoxWinObjective.ItemIndex := Integer(WinObjective);
     518    SpinEditNeutralUnits.Value := MaxNeutralUnits;
     519    ComboBoxMapShape.ItemIndex := Integer(Map.Shape);
     520    EditImageFile.Text := MapImageFileName;
     521    CheckBoxFogOfWar.Checked := FogOfWar;
     522    CheckBoxBridges.Checked := BridgeEnabled;
     523    SpinEditMaxPower.Value := MaxPower;
     524    SpinEditTurns.Value := StayAliveForDefinedTurns;
     525    SpinEditSpecialCells.Value := SpecialCaptureCellCount;
    520526  end;
    521527end;
     
    536542      RemoteNetworkPort := 0;
    537543    end;
    538     Game.PlayersSetting.Assign(Players);
    539     Game.SymetricMap := CheckBoxSymetricMap.Checked;
    540     Game.VoidEnabled := CheckBoxVoid.Checked;
    541     Game.VoidPercentage := SpinEditVoidPercent.Value;
    542     Game.CityEnabled := CheckBoxCity.Checked;
    543     Game.CityPercentage := SpinEditCityPercent.Value;
    544     Game.Map.Size := TPoint.Create(SpinEditMapSizeX.Value, SpinEditMapSizeY.Value);
    545     Game.GrowAmount := TGrowAmount(RadioGroupGrowAmount.ItemIndex);
    546     Game.GrowCells := TGrowCells(RadioGroupGrowCells.ItemIndex);
    547     Game.MapType := TMapType(ComboBoxGridType.ItemIndex + 1);
    548     Game.WinObjective := TWinObjective(ComboBoxWinObjective.ItemIndex);
    549     Game.MaxNeutralUnits := SpinEditNeutralUnits.Value;
    550     Game.Map.Shape := TMapShape(ComboBoxMapShape.ItemIndex);
    551     Game.MapImageFileName := EditImageFile.Text;
    552     Game.FogOfWar := CheckBoxFogOfWar.Checked;
    553     Game.BridgeEnabled := CheckBoxBridges.Checked;
    554     Game.MaxPower := SpinEditMaxPower.Value;
    555     Game.StayAliveForDefinedTurns := SpinEditTurns.Value;
    556     Game.SpecialCaptureCellCount := SpinEditSpecialCells.Value;
     544  end;
     545  Core.GameSettings.Players.Assign(Players);
     546  Core.ServerList.Assign(ServerList);
     547  with Core.GameSettings do begin
     548    SymetricMap := CheckBoxSymetricMap.Checked;
     549    VoidEnabled := CheckBoxVoid.Checked;
     550    VoidPercentage := SpinEditVoidPercent.Value;
     551    CityEnabled := CheckBoxCity.Checked;
     552    CityPercentage := SpinEditCityPercent.Value;
     553    Map.Size := TPoint.Create(SpinEditMapSizeX.Value, SpinEditMapSizeY.Value);
     554    GrowAmount := TGrowAmount(RadioGroupGrowAmount.ItemIndex);
     555    GrowCells := TGrowCells(RadioGroupGrowCells.ItemIndex);
     556    MapType := TMapType(ComboBoxGridType.ItemIndex + 1);
     557    WinObjective := TWinObjective(ComboBoxWinObjective.ItemIndex);
     558    MaxNeutralUnits := SpinEditNeutralUnits.Value;
     559    Map.Shape := TMapShape(ComboBoxMapShape.ItemIndex);
     560    MapImageFileName := EditImageFile.Text;
     561    FogOfWar := CheckBoxFogOfWar.Checked;
     562    BridgeEnabled := CheckBoxBridges.Checked;
     563    MaxPower := SpinEditMaxPower.Value;
     564    StayAliveForDefinedTurns := SpinEditTurns.Value;
     565    SpecialCaptureCellCount := SpinEditSpecialCells.Value;
    557566  end;
    558567end;
  • trunk/UCore.pas

    r197 r199  
    8383  public
    8484    Game: TGame;
     85    GameSettings: TGame;
    8586    Server: TServer;
    8687    UseSingleView: Boolean;
     
    312313  try
    313314    FormNew.Load(Server);
    314     FormNew.ServerList := ServerList;
    315315    if FormNew.ShowModal = mrOk then begin
    316316      FormNew.Save(Server);
     317      Game.Assign(GameSettings);
    317318      StartNewGame;
    318319      GameLoaded := False;
     
    399400  Server := TServer.Create;
    400401  Clients := TClients.Create;
     402  GameSettings := TGame.Create;
    401403  Game := TGame.Create;
    402404  Game.OnMoveUpdated := DoMoveUpdated;
     
    424426  FreeAndNil(Clients);
    425427  FreeAndNil(Game);
     428  FreeAndNil(GameSettings);
    426429end;
    427430
     
    557560
    558561    // Update translated default player names
    559     Game.PlayersSetting[0].Name := SPlayer + ' 1';
    560     Game.PlayersSetting[1].Name := SPlayer + ' 2';
     562    GameSettings.Players[0].Name := SPlayer + ' 1';
     563    GameSettings.Players[1].Name := SPlayer + ' 2';
    561564
    562565    LoadConfig;
    563     Game.LoadConfig(XMLConfig1, 'Game');
     566    GameSettings.LoadConfig(XMLConfig1, 'Game');
    564567    Server.LoadConfig(XMLConfig1, 'Server');
    565568    ServerList.LoadConfig(XmlConfig1, 'ServerList');
     
    576579procedure TCore.Done;
    577580begin
    578   Game.SaveConfig(XMLConfig1, 'Game');
     581  GameSettings.SaveConfig(XMLConfig1, 'Game');
    579582  Server.SaveConfig(XMLConfig1, 'Server');
    580583  ServerList.SaveConfig(XmlConfig1, 'ServerList');
  • trunk/UGame.pas

    r198 r199  
    329329    Moves: TUnitMoves;
    330330    Computer: TComputer;
     331    procedure Reset;
    331332    function IsAlive: Boolean;
    332333    procedure Clear;
     
    442443    procedure CalculatePlayersDistance;
    443444    procedure PropagatePlayerDistance(List: TCells);
    444     procedure InitDefaultPlayersSetting;
     445    procedure InitDefaultPlayers;
    445446    procedure WinObjectiveMapPrepare;
    446447  public
    447448    DevelMode: Boolean;
    448449    Players: TPlayers;
    449     PlayersSetting: TPlayers;
    450450    Map: TMap;
    451451    MapImageFileName: string;
     
    467467    BridgeEnabled: Boolean;
    468468    MaxPower: Integer;
     469    procedure Assign(Source: TGame);
    469470    function AttackProbability(AttackCount, DefendCount: Integer): Double;
    470471    procedure LoadConfig(Config: TXmlConfig; Path: string);
     
    28092810end;
    28102811
     2812procedure TPlayer.Reset;
     2813begin
     2814  Moves.Clear;
     2815  PlayerMap.Cells.Clear;
     2816  TotalUnits := 0;
     2817  TotalCells := 0;
     2818  TotalCities := 0;
     2819  TotalDiscovered := 0;
     2820  TurnStats.Clear;
     2821  StartCell := nil;
     2822end;
     2823
    28112824function TPlayer.IsAlive: Boolean;
    28122825begin
     
    31993212end;
    32003213
    3201 procedure TGame.InitDefaultPlayersSetting;
    3202 begin
    3203   PlayersSetting.Clear;
    3204   PlayersSetting.New(SPlayer + ' 1', clBlue, pmHuman);
    3205   PlayersSetting.New(SPlayer + ' 2', clRed, pmComputer);
     3214procedure TGame.InitDefaultPlayers;
     3215begin
     3216  Players.Clear;
     3217  Players.New(SPlayer + ' 1', clBlue, pmHuman);
     3218  Players.New(SPlayer + ' 2', clRed, pmComputer);
    32063219end;
    32073220
     
    32263239    Cells.Free;
    32273240  end;
     3241end;
     3242
     3243procedure TGame.Assign(Source: TGame);
     3244begin
     3245  DevelMode := Source.DevelMode;
     3246  Players.Assign(Source.Players);
     3247  MapType := Source.MapType;
     3248  Map.Assign(Source.Map);
     3249  MapImageFileName := Source.MapImageFileName;
     3250  VoidEnabled := Source.VoidEnabled;
     3251  VoidPercentage := Source.VoidPercentage;
     3252  SymetricMap := Source.SymetricMap;
     3253  GrowCells := Source.GrowCells;
     3254  GrowAmount := Source.GrowAmount;
     3255  CityEnabled := Source.CityEnabled;
     3256  CityPercentage := Source.CityPercentage;
     3257  TurnCounter := Source.TurnCounter;
     3258  WinObjective := Source.WinObjective;
     3259  SpecialCaptureCellCount := Source.SpecialCaptureCellCount;
     3260  StayAliveForDefinedTurns := Source.StayAliveForDefinedTurns;
     3261  MaxNeutralUnits := Source.MaxNeutralUnits;
     3262  FileName := Source.FileName;
     3263  FogOfWar := Source.FogOfWar;
     3264  BridgeEnabled := Source.BridgeEnabled;
     3265  MaxPower := Source.MaxPower;
    32283266end;
    32293267
     
    32483286    SetValue(DOMString(Path + '/StayAliveForDefinedTurns'), StayAliveForDefinedTurns);
    32493287    SetValue(DOMString(Path + '/SpecialCaptureCellCount'), SpecialCaptureCellCount);
    3250     PlayersSetting.SaveConfig(Config, Path + '/Players');
     3288    Players.SaveConfig(Config, Path + '/Players');
    32513289  end;
    32523290end;
     
    32823320    StayAliveForDefinedTurns := GetValue(DOMString(Path + '/StayAliveForDefinedTurns'), 20);
    32833321    SpecialCaptureCellCount := GetValue(DOMString(Path + '/SpecialCaptureCellCount'), 1);
    3284     PlayersSetting.LoadConfig(Config, Path + '/Players');
     3322    Players.LoadConfig(Config, Path + '/Players');
    32853323  end;
    32863324end;
     
    34993537  Players := TPlayers.Create;
    35003538  Players.Game := Self;
    3501   PlayersSetting := TPlayers.Create;
    3502   PlayersSetting.Game := Self;
    35033539
    35043540  MapImageFileName := 'Images/Maps/WorldMap.png';
    35053541  Randomize;
    3506   InitDefaultPlayersSetting;
     3542  InitDefaultPlayers;
    35073543
    35083544  VoidEnabled := True;
     
    35173553destructor TGame.Destroy;
    35183554begin
    3519   FreeAndNil(PlayersSetting);
    35203555  FreeAndNil(Players);
    35213556  FreeAndNil(Map);
     
    35243559
    35253560procedure TGame.Clear;
    3526 begin
    3527   Players.Clear;
     3561var
     3562  I: Integer;
     3563begin
     3564  for I := 0 to Players.Count - 1 do Players[I].Clear;
    35283565  Map.Clear;
    35293566end;
     
    35513588  end;
    35523589
    3553   Players.Assign(PlayersSetting);
    35543590  for Player in Players do Player.StartCell := nil;
    35553591  I := 0;
  • trunk/UGameServer.pas

    r196 r199  
    66
    77uses
    8   Classes, SysUtils, UGame, UGameClient, DOM, XMLConf, fgl, SpecializedList,
     8  Classes, SysUtils, UGame, DOM, XMLConf, fgl,
    99  UGameProtocol;
    1010
  • trunk/UServerList.pas

    r196 r199  
    2121    MapName: string;
    2222    Latency: TTime;
     23    procedure Assign(Source: TServerInfo);
    2324    constructor Create;
    2425  end;
     
    3334    Address: string;
    3435    Items: TServerInfos;
     36    procedure Assign(Source: TServerList);
    3537    constructor Create;
    3638    destructor Destroy; override;
     
    4749{ TServerInfo }
    4850
     51procedure TServerInfo.Assign(Source: TServerInfo);
     52begin
     53  Name := Source.Name;
     54  Address := Source.Address;
     55  Port := Source.Port;
     56  PlayersCountCurrent := Source.PlayersCountCurrent;
     57  PlayersCountMax := Source.PlayersCountMax;
     58  Password := Source.Password;
     59  MapName := Source.MapName;
     60  Latency := Source.Latency;
     61end;
     62
    4963constructor TServerInfo.Create;
    5064begin
     
    5367
    5468{ TServerList }
     69
     70procedure TServerList.Assign(Source: TServerList);
     71var
     72  I: Integer;
     73begin
     74  while Items.Count > Source.Items.Count do
     75    Items.Delete(Items.Count - 1);
     76  while Items.Count < Source.Items.Count do
     77    Items.Add(TServerInfo.Create);
     78  for I := 0 to Items.Count - 1 do begin
     79    Items[I].Assign(Source.Items[I]);
     80  end;
     81end;
    5582
    5683constructor TServerList.Create;
  • trunk/xtactics.lpi

    r198 r199  
    279279    <Linking>
    280280      <Debugging>
     281        <UseHeaptrc Value="True"/>
    281282        <UseExternalDbgSyms Value="True"/>
    282283      </Debugging>
  • trunk/xtactics.lpr

    r198 r199  
    2525  // Heap trace
    2626  DeleteFile(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
    27   //SetHeapTraceOutput(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
     27  SetHeapTraceOutput(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
    2828  {$ENDIF}
    2929
Note: See TracChangeset for help on using the changeset viewer.