Changeset 287 for trunk


Ignore:
Timestamp:
Mar 24, 2019, 2:26:29 PM (6 years ago)
Author:
chronos
Message:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormNew.lfm

    r282 r287  
    11object FormNew: TFormNew
    2   Left = 546
     2  Left = 478
    33  Height = 745
    4   Top = 184
     4  Top = 526
    55  Width = 1211
    66  Caption = 'New game'
     
    1515  OnShow = FormShow
    1616  Position = poMainFormCenter
    17   LCLVersion = '1.8.4.0'
     17  LCLVersion = '2.0.0.4'
    1818  object PageControl1: TPageControl
    1919    Left = 4
     
    2121    Top = 60
    2222    Width = 806
    23     ActivePage = TabSheetMap
     23    ActivePage = TabSheetRules
    2424    Align = alClient
    2525    BorderSpacing.Around = 4
    26     TabIndex = 2
     26    TabIndex = 3
    2727    TabOrder = 0
    2828    OnChange = PageControl1Change
     
    258258        object ComboBoxGridType: TComboBox
    259259          Left = 146
    260           Height = 42
     260          Height = 38
    261261          Top = 104
    262262          Width = 304
     
    275275        object ComboBoxMapShape: TComboBox
    276276          Left = 146
    277           Height = 42
     277          Height = 38
    278278          Top = 144
    279279          Width = 304
     
    519519        object ComboBoxWinObjective: TComboBox
    520520          Left = 224
    521           Height = 42
     521          Height = 38
    522522          Top = 244
    523523          Width = 328
     
    579579          object TabSheetCaptureCells: TTabSheet
    580580            ClientHeight = 74
    581             ClientWidth = 769
     581            ClientWidth = 763
    582582            object Label14: TLabel
    583583              Left = 8
     
    601601          object TabSheetStayAliveTurns: TTabSheet
    602602            ClientHeight = 74
    603             ClientWidth = 769
     603            ClientWidth = 763
    604604            object Label13: TLabel
    605605              Left = 8
     
    647647      Caption = 'Ok'
    648648      ModalResult = 1
     649      OnClick = ButtonOkClick
    649650      TabOrder = 0
    650651    end
  • trunk/Forms/UFormNew.pas

    r282 r287  
    105105    procedure ButtonGameSystemsClick(Sender: TObject);
    106106    procedure ButtonImageBrowseClick(Sender: TObject);
     107    procedure ButtonOkClick(Sender: TObject);
    107108    procedure ButtonRandomizeClick(Sender: TObject);
    108109    procedure CheckBoxBridgesChange(Sender: TObject);
     
    138139    procedure TrackBarSizeXChange(Sender: TObject);
    139140  private
    140     Players: TPlayers;
     141    FServer: TServer;
    141142    ServerList: TServerList;
    142143    GamePreview: TGame;
     
    144145    NewRandSeed: Cardinal;
    145146    FormPlayers: TFormPlayers;
    146     GameSystem: TGameSystem;
    147147    procedure LoadGame(Game: TGame);
    148148    procedure SaveGame(Game: TGame);
     149    procedure Load(Server: TServer);
     150    procedure Save(Server: TServer);
    149151    procedure MapPreviewPaint;
    150152    procedure MapPreviewRedraw;
    151153    procedure ReloadGameSystemsMenu;
     154    procedure SetServer(AValue: TServer);
    152155  public
    153156    procedure Translate;
    154157    procedure ReloadView;
    155158    procedure UpdateInterface;
    156     procedure Load(Server: TServer);
    157     procedure Save(Server: TServer);
     159    property Server: TServer read FServer write SetServer;
    158160  end;
    159161
     
    278280procedure TFormNew.LoadGame(Game: TGame);
    279281begin
    280   FormPlayers.Players.Assign(Game.Players);
    281282  with Game do begin
    282283    CheckBoxSymetricMap.Checked := SymetricMap;
     
    303304    SpinEditTurns.Value := StayAliveForDefinedTurns;
    304305    SpinEditSpecialCells.Value := SpecialCaptureCellCount;
     306    GameSystem := Game.GameSystem;
    305307    ComboBoxGameSystem.ItemIndex := ComboBoxGameSystem.Items.IndexOf(GameSystemName);
     308    if (ComboBoxGameSystem.ItemIndex = -1) and (ComboBoxGameSystem.Items.Count > 0) then
     309      ComboBoxGameSystem.ItemIndex := 0;
    306310  end;
    307311end;
     
    309313procedure TFormNew.SaveGame(Game: TGame);
    310314begin
    311   Game.Players.Assign(FormPlayers.Players);
    312315  with Game do begin
    313316    StoredRandSeed := NewRandSeed;
     
    332335    StayAliveForDefinedTurns := SpinEditTurns.Value;
    333336    SpecialCaptureCellCount := SpinEditSpecialCells.Value;
    334     GameSystem := TGameSystem(ComboBoxGameSystem.Items.Objects[ComboBoxGameSystem.ItemIndex]);
    335     GameSystemName := GameSystem.GetName;
     337    if ComboBoxGameSystem.ItemIndex <> -1 then begin
     338      GameSystem := TGameSystem(ComboBoxGameSystem.Items.Objects[ComboBoxGameSystem.ItemIndex]);
     339      GameSystemName := GameSystem.GetName;
     340    end else begin
     341      GameSystem := nil;
     342      GameSystemName := '';
     343    end;
    336344  end;
    337345end;
     
    366374  finally
    367375    ComboBoxGameSystem.Items.EndUpdate;
     376  end;
     377  if (ComboBoxGameSystem.ItemIndex = -1) and (ComboBoxGameSystem.Items.Count > 0) then
     378    ComboBoxGameSystem.ItemIndex := 0;
     379end;
     380
     381procedure TFormNew.SetServer(AValue: TServer);
     382begin
     383  if FServer = AValue then Exit;
     384  FServer := AValue;
     385  if Assigned(FServer) then begin
     386    Load(FServer);
     387    FormPlayers.Players := FServer.Game.Players;
     388  end else begin
     389    FormPlayers.Players := nil;
    368390  end;
    369391end;
     
    452474  ListViewServers.Items.Count := ServerList.Items.Count;
    453475  ListViewServers.Refresh;
    454   Translate;
    455476  UpdateInterface;
    456477end;
     
    460481  WinObjective: TWinObjective;
    461482begin
    462   GameSystem := TGameSystem(ComboBoxGameSystem.Items.Objects[ComboBoxGameSystem.ItemIndex]);
    463   ComboBoxGridType.Enabled := GameSystem.PreferedMapType = mtNone;
    464   if GameSystem.PreferedMapType <> mtNone then
    465     ComboBoxGridType.ItemIndex := ComboBoxGridType.Items.IndexOfObject(TObject(GameSystem.PreferedMapType));
     483
     484  ComboBoxGridType.Enabled := FServer.Game.GameSystem.PreferedMapType = mtNone;
     485  if FServer.Game.GameSystem.PreferedMapType <> mtNone then
     486    ComboBoxGridType.ItemIndex := ComboBoxGridType.Items.IndexOfObject(TObject(FServer.Game.GameSystem.PreferedMapType));
    466487  EditImageFile.Enabled := ComboBoxMapShape.ItemIndex = Integer(msImage);
    467488  ButtonImageBrowse.Enabled := ComboBoxMapShape.ItemIndex = Integer(msImage);
     
    513534  FormChat.Align := alClient;
    514535  FormChat.Show;
    515   Players := TPlayers.Create;
    516   Players.Game := GamePreview;
    517536  FormPlayers := TFormPlayers.Create(nil);
    518537  FormPlayers.MinItemCount := MinPlayerCount;
    519538  FormPlayers.MaxItemCount := MaxPlayerCount;
    520   FormPlayers.Players := Players;
    521539  FormPlayers.ManualDock(Panel2, nil, alClient);
    522540  FormPlayers.Align := alClient;
     
    549567procedure TFormNew.ComboBoxGameSystemChange(Sender: TObject);
    550568begin
     569  FServer.Game.GameSystem := TGameSystem(ComboBoxGameSystem.Items.Objects[ComboBoxGameSystem.ItemIndex]);
    551570  UpdateInterface;
    552571  MapPreviewRedraw;
     
    641660end;
    642661
     662procedure TFormNew.ButtonOkClick(Sender: TObject);
     663begin
     664  Save(FServer);
     665end;
     666
    643667procedure TFormNew.ButtonRandomizeClick(Sender: TObject);
    644668begin
     
    657681  FreeAndNil(ServerList);
    658682  FreeAndNil(FormChat);
    659   FreeAndNil(Players);
    660683  FreeAndNil(FormPlayers);
    661684  FreeAndNil(GamePreview);
     
    673696  end;
    674697  ServerList.Assign(Core.ServerList);
    675   LoadGame(Core.GameSettings);
     698  LoadGame(Server.Game);
    676699end;
    677700
     
    693716  end;
    694717  Core.ServerList.Assign(ServerList);
    695   SaveGame(Core.GameSettings);
     718  SaveGame(Server.Game);
    696719end;
    697720
  • trunk/Forms/UFormPlayers.lfm

    r282 r287  
    1212  OnDestroy = FormDestroy
    1313  OnShow = FormShow
    14   LCLVersion = '1.8.4.0'
     14  LCLVersion = '2.0.0.4'
    1515  object ListView1: TListView
    1616    Left = 0
  • trunk/Forms/UFormUnitKind.lfm

    r277 r287  
    88  ClientWidth = 480
    99  DesignTimePPI = 144
    10   LCLVersion = '1.8.4.0'
     10  LCLVersion = '2.0.0.4'
    1111  object LabelName: TLabel
    1212    Left = 20
     
    5656    Caption = 'OK'
    5757    ModalResult = 1
     58    OnClick = ButtonOkClick
    5859    TabOrder = 3
    5960  end
  • trunk/Forms/UFormUnitKind.pas

    r277 r287  
    2020    LabelHealth: TLabel;
    2121    SpinEditHealth: TSpinEdit;
     22    procedure ButtonOkClick(Sender: TObject);
    2223  private
    23 
    24   public
     24    FUnitKind: TUnitKind;
    2525    procedure Load(UnitKind: TUnitKind);
    2626    procedure Save(UnitKind: TUnitKind);
     27    procedure SetUnitKind(AValue: TUnitKind);
     28  public
     29    property UnitKind: TUnitKind read FUnitKind write SetUnitKind;
    2730  end;
    2831
     
    4851end;
    4952
     53procedure TFormUnitKind.ButtonOkClick(Sender: TObject);
     54begin
     55  Save(FUnitKind);
     56end;
     57
     58procedure TFormUnitKind.SetUnitKind(AValue: TUnitKind);
     59begin
     60  if FUnitKind = AValue then Exit;
     61  FUnitKind := AValue;
     62  if Assigned(AValue) then Load(FUnitKind);
     63end;
     64
    5065end.
    5166
  • trunk/Forms/UFormUnitKinds.lfm

    r277 r287  
    1111  OnCreate = FormCreate
    1212  OnShow = FormShow
    13   LCLVersion = '1.8.4.0'
     13  LCLVersion = '2.0.0.4'
    1414  object ListView1: TListView
    1515    Left = 0
  • trunk/Forms/UFormUnitKinds.pas

    r284 r287  
    9898    FormUnitKind := TFormUnitKind.Create(Self);
    9999    try
    100       FormUnitKind.Load(TempEntry);
     100      FormUnitKind.UnitKind := TempEntry;
    101101      if FormUnitKind.ShowModal = mrOk then begin
    102         FormUnitKind.Save(TempEntry);
    103102        TUnitKind(ListView1.Selected.Data).Assign(TempEntry);
    104103        UpdateList;
     
    120119  try
    121120    TempEntry.Name := SNewUnitKind;
    122     FormUnitKind.Load(TempEntry);
     121    FormUnitKind.UnitKind := TempEntry;
    123122    if FormUnitKind.ShowModal = mrOk then begin
    124       FormUnitKind.Save(TempEntry);
    125123      UnitKinds.Add(TempEntry);
    126124      TempEntry := nil;
  • trunk/UCore.lfm

    r275 r287  
    44  OldCreateOrder = False
    55  Height = 811
    6   HorizontalOffset = 424
    7   VerticalOffset = 374
     6  HorizontalOffset = 417
     7  VerticalOffset = 418
    88  Width = 1258
    99  PPI = 144
  • trunk/UCore.pas

    r284 r287  
    353353
    354354procedure TCore.AGameNewExecute(Sender: TObject);
     355var
     356  NewServer: TServer;
    355357begin
    356358  FormNew := TFormNew.Create(nil);
    357359  try
    358     FormNew.Load(Server);
     360    NewServer := TServer.Create;
     361    NewServer.Assign(Server);
     362    NewServer.Game := TGame.Create;
     363    NewServer.Game.Assign(GameSettings);
     364    FormNew.Server := NewServer;
    359365    FormNew.PageControl1.TabIndex := FormNewTabIndex;
    360366    if FormNew.ShowModal = mrOk then begin
     367      Server.Assign(NewServer);
     368      Server.Game := Game;
    361369      Game.Running := False;
    362       FormNew.Save(Server);
    363       GameSettings.PostConfig;
    364       Game.Assign(GameSettings);
     370      Game.PostConfig;
     371      Game.Assign(NewServer.Game);
     372      GameSettings.Assign(NewServer.Game);
    365373      SaveConfigAll;
    366374      StartNewGame;
     
    368376    end;
    369377    FormNewTabIndex := FormNew.PageControl1.TabIndex;
     378    NewServer.Game.Free;
     379    NewServer.Game := nil;
     380    NewServer.Free;
    370381  finally
    371382    FormNew.Free;
  • trunk/UGame.pas

    r282 r287  
    730730  if FGameSystem = AValue then Exit;
    731731  FGameSystem := AValue;
     732  if Assigned(FGameSystem) then GameSystemName := FGameSystem.GetName
     733    else GameSystemName := '';
    732734end;
    733735
  • trunk/UGameServer.pas

    r231 r287  
    6464    constructor Create;
    6565    destructor Destroy; override;
     66    procedure Assign(Source: TServer);
    6667    property Game: TGame read FGame write SetGame;
    6768    property Mode: TServerMode read FServerMode write SetServerMode;
     
    142143begin
    143144  if FGame = AValue then Exit;
     145  if Assigned(FGame) then
     146    FGame.OnChange := nil;
    144147  FGame := AValue;
    145148  for I := 0 to Clients.Count - 1 do
     
    278281end;
    279282
     283procedure TServer.Assign(Source: TServer);
     284begin
     285  Mode := Source.Mode;
     286  Game := Source.Game;
     287  LocalNetworkAddress := Source.LocalNetworkAddress;
     288  LocalNetworkPort := Source.LocalNetworkPort;
     289  RemoteNetworkAddress := Source.RemoteNetworkAddress;
     290  RemoteNetworkPort := Source.RemoteNetworkPort;
     291  //Active := Source.Active;
     292end;
     293
    280294end.
    281295
  • trunk/xtactics.lpi

    r284 r287  
    22<CONFIG>
    33  <ProjectOptions>
    4     <Version Value="10"/>
     4    <Version Value="11"/>
    55    <General>
    66      <SessionStorage Value="InProjectDir"/>
     
    7878    </PublishOptions>
    7979    <RunParams>
    80       <local>
    81         <FormatVersion Value="1"/>
    82       </local>
     80      <FormatVersion Value="2"/>
     81      <Modes Count="1">
     82        <Mode0 Name="default"/>
     83      </Modes>
    8384    </RunParams>
    8485    <RequiredPackages Count="7">
Note: See TracChangeset for help on using the changeset viewer.