Changeset 287 for trunk/Forms/UFormNew.pas
- Timestamp:
- Mar 24, 2019, 2:26:29 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormNew.pas
r282 r287 105 105 procedure ButtonGameSystemsClick(Sender: TObject); 106 106 procedure ButtonImageBrowseClick(Sender: TObject); 107 procedure ButtonOkClick(Sender: TObject); 107 108 procedure ButtonRandomizeClick(Sender: TObject); 108 109 procedure CheckBoxBridgesChange(Sender: TObject); … … 138 139 procedure TrackBarSizeXChange(Sender: TObject); 139 140 private 140 Players: TPlayers;141 FServer: TServer; 141 142 ServerList: TServerList; 142 143 GamePreview: TGame; … … 144 145 NewRandSeed: Cardinal; 145 146 FormPlayers: TFormPlayers; 146 GameSystem: TGameSystem;147 147 procedure LoadGame(Game: TGame); 148 148 procedure SaveGame(Game: TGame); 149 procedure Load(Server: TServer); 150 procedure Save(Server: TServer); 149 151 procedure MapPreviewPaint; 150 152 procedure MapPreviewRedraw; 151 153 procedure ReloadGameSystemsMenu; 154 procedure SetServer(AValue: TServer); 152 155 public 153 156 procedure Translate; 154 157 procedure ReloadView; 155 158 procedure UpdateInterface; 156 procedure Load(Server: TServer); 157 procedure Save(Server: TServer); 159 property Server: TServer read FServer write SetServer; 158 160 end; 159 161 … … 278 280 procedure TFormNew.LoadGame(Game: TGame); 279 281 begin 280 FormPlayers.Players.Assign(Game.Players);281 282 with Game do begin 282 283 CheckBoxSymetricMap.Checked := SymetricMap; … … 303 304 SpinEditTurns.Value := StayAliveForDefinedTurns; 304 305 SpinEditSpecialCells.Value := SpecialCaptureCellCount; 306 GameSystem := Game.GameSystem; 305 307 ComboBoxGameSystem.ItemIndex := ComboBoxGameSystem.Items.IndexOf(GameSystemName); 308 if (ComboBoxGameSystem.ItemIndex = -1) and (ComboBoxGameSystem.Items.Count > 0) then 309 ComboBoxGameSystem.ItemIndex := 0; 306 310 end; 307 311 end; … … 309 313 procedure TFormNew.SaveGame(Game: TGame); 310 314 begin 311 Game.Players.Assign(FormPlayers.Players);312 315 with Game do begin 313 316 StoredRandSeed := NewRandSeed; … … 332 335 StayAliveForDefinedTurns := SpinEditTurns.Value; 333 336 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; 336 344 end; 337 345 end; … … 366 374 finally 367 375 ComboBoxGameSystem.Items.EndUpdate; 376 end; 377 if (ComboBoxGameSystem.ItemIndex = -1) and (ComboBoxGameSystem.Items.Count > 0) then 378 ComboBoxGameSystem.ItemIndex := 0; 379 end; 380 381 procedure TFormNew.SetServer(AValue: TServer); 382 begin 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; 368 390 end; 369 391 end; … … 452 474 ListViewServers.Items.Count := ServerList.Items.Count; 453 475 ListViewServers.Refresh; 454 Translate;455 476 UpdateInterface; 456 477 end; … … 460 481 WinObjective: TWinObjective; 461 482 begin 462 GameSystem := TGameSystem(ComboBoxGameSystem.Items.Objects[ComboBoxGameSystem.ItemIndex]); 463 ComboBoxGridType.Enabled := GameSystem.PreferedMapType = mtNone;464 if GameSystem.PreferedMapType <> mtNone then465 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)); 466 487 EditImageFile.Enabled := ComboBoxMapShape.ItemIndex = Integer(msImage); 467 488 ButtonImageBrowse.Enabled := ComboBoxMapShape.ItemIndex = Integer(msImage); … … 513 534 FormChat.Align := alClient; 514 535 FormChat.Show; 515 Players := TPlayers.Create;516 Players.Game := GamePreview;517 536 FormPlayers := TFormPlayers.Create(nil); 518 537 FormPlayers.MinItemCount := MinPlayerCount; 519 538 FormPlayers.MaxItemCount := MaxPlayerCount; 520 FormPlayers.Players := Players;521 539 FormPlayers.ManualDock(Panel2, nil, alClient); 522 540 FormPlayers.Align := alClient; … … 549 567 procedure TFormNew.ComboBoxGameSystemChange(Sender: TObject); 550 568 begin 569 FServer.Game.GameSystem := TGameSystem(ComboBoxGameSystem.Items.Objects[ComboBoxGameSystem.ItemIndex]); 551 570 UpdateInterface; 552 571 MapPreviewRedraw; … … 641 660 end; 642 661 662 procedure TFormNew.ButtonOkClick(Sender: TObject); 663 begin 664 Save(FServer); 665 end; 666 643 667 procedure TFormNew.ButtonRandomizeClick(Sender: TObject); 644 668 begin … … 657 681 FreeAndNil(ServerList); 658 682 FreeAndNil(FormChat); 659 FreeAndNil(Players);660 683 FreeAndNil(FormPlayers); 661 684 FreeAndNil(GamePreview); … … 673 696 end; 674 697 ServerList.Assign(Core.ServerList); 675 LoadGame( Core.GameSettings);698 LoadGame(Server.Game); 676 699 end; 677 700 … … 693 716 end; 694 717 Core.ServerList.Assign(ServerList); 695 SaveGame( Core.GameSettings);718 SaveGame(Server.Game); 696 719 end; 697 720
Note:
See TracChangeset
for help on using the changeset viewer.