private void TabChanged(object sender, EventArgs e) { // TODO: warnings about not saving the changes inGame?.Dispose(); inGame = null; switch (typeGameChoiceTabControl.SelectedIndex) { case 0: // singleplayer LoadSingleplayerControls(); break; case 1: // multiplayer LoadMultiplayerControls(); break; case 2: // settings LoadSettingsControls(); break; default: return; } previousTabSelectedIndex = typeGameChoiceTabControl.SelectedIndex; }
/// <summary> /// Loads proper screens starting newly created game the game. /// </summary> /// <param name="game">Instance representing the game to be started.</param> private void LoadInGameScreen(Game game) { switch (game.GameType) { case GameType.SinglePlayer: // remove previous singleplayerGameOptionsControl?.Dispose(); singleplayerGameOptionsControl = null; // load game screen inGame = new InGameControl { Parent = singleplayerTabPage, Dock = DockStyle.Fill }; break; case GameType.MultiplayerHotseat: // remove previous hotseatGameOptionsControl?.Dispose(); hotseatGameOptionsControl = null; // load game screen inGame = new InGameControl { Parent = multiplayerTabPage, Dock = DockStyle.Fill }; break; case GameType.MultiplayerNetwork: // removes previous networkGameOptionsControl?.Dispose(); networkGameOptionsControl = null; // loads game screens inGame = new InGameControl { Parent = multiplayerTabPage, Dock = DockStyle.Fill }; break; } inGame.Initialize(game); inGame.Show(); }