Ignore:
Timestamp:
May 16, 2018, 2:48:57 PM (6 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.