From 1b73aab856696e0b3bc83bdbe01493c697615255 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 17 Jun 2020 19:56:20 +0300 Subject: [PATCH] Opening the New Game screen from within a game saves the previous game parameters, map generation parameters work again @alkorolyov --- core/src/com/unciv/ui/mapeditor/GameParametersScreen.kt | 2 +- core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt | 2 +- core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt | 6 +++--- core/src/com/unciv/ui/newgamescreen/MapOptionsTable.kt | 2 -- core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt | 5 +++-- .../com/unciv/ui/newgamescreen/PreviousScreenInterface.kt | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/src/com/unciv/ui/mapeditor/GameParametersScreen.kt b/core/src/com/unciv/ui/mapeditor/GameParametersScreen.kt index d18e02ef65..512fe03c49 100644 --- a/core/src/com/unciv/ui/mapeditor/GameParametersScreen.kt +++ b/core/src/com/unciv/ui/mapeditor/GameParametersScreen.kt @@ -17,7 +17,7 @@ import kotlin.concurrent.thread class GameParametersScreen(var mapEditorScreen: MapEditorScreen): PickerScreen() { var playerPickerTable = PlayerPickerTable(mapEditorScreen, mapEditorScreen.gameSetupInfo.gameParameters) - var gameOptionsTable = GameOptionsTable(mapEditorScreen) { desiredCiv: String -> playerPickerTable.update(desiredCiv) } + var gameOptionsTable = GameOptionsTable(mapEditorScreen.gameSetupInfo) { desiredCiv: String -> playerPickerTable.update(desiredCiv) } init { setDefaultCloseAction(mapEditorScreen) diff --git a/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt b/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt index 5232ad9692..f7f8083b5b 100644 --- a/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt +++ b/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt @@ -27,7 +27,7 @@ class MapEditorScreen(): PreviousScreenInterface, CameraStageBaseScreen() { var scenarioName = "" var scenario: Scenario? = null - override var gameSetupInfo = GameSetupInfo() + override val gameSetupInfo = GameSetupInfo() lateinit var mapHolder: EditorMapHolder val tileEditorOptions = TileEditorOptionsTable(this) diff --git a/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt b/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt index 28e5ce8a5b..47e981c160 100644 --- a/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt +++ b/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt @@ -10,10 +10,10 @@ import com.unciv.models.ruleset.VictoryType import com.unciv.models.translations.tr import com.unciv.ui.utils.* -class GameOptionsTable(previousScreen: PreviousScreenInterface, val updatePlayerPickerTable:(desiredCiv:String)->Unit) +class GameOptionsTable(gameSetupInfo: GameSetupInfo, val updatePlayerPickerTable:(desiredCiv:String)->Unit) : Table(CameraStageBaseScreen.skin) { - var gameParameters = previousScreen.gameSetupInfo.gameParameters - val ruleset = previousScreen.gameSetupInfo.ruleset + var gameParameters = gameSetupInfo.gameParameters + val ruleset = gameSetupInfo.ruleset var locked = false init { diff --git a/core/src/com/unciv/ui/newgamescreen/MapOptionsTable.kt b/core/src/com/unciv/ui/newgamescreen/MapOptionsTable.kt index 179b096dd1..0079a5f503 100644 --- a/core/src/com/unciv/ui/newgamescreen/MapOptionsTable.kt +++ b/core/src/com/unciv/ui/newgamescreen/MapOptionsTable.kt @@ -52,7 +52,6 @@ class MapOptionsTable(val newGameScreen: NewGameScreen): Table() { mapParameters.type = MapType.custom mapParameters.name = mapFileSelectBox.selected mapTypeSpecificTable.add(savedMapOptionsTable) - newGameScreen.gameSetupInfo = GameSetupInfo() newGameScreen.unlockTables() newGameScreen.updateTables() } else if (mapTypeSelectBox.selected.value == MapType.scenario) { @@ -69,7 +68,6 @@ class MapOptionsTable(val newGameScreen: NewGameScreen): Table() { mapParameters.name = "" mapParameters.type = generatedMapOptionsTable.mapTypeSelectBox.selected.value mapTypeSpecificTable.add(generatedMapOptionsTable) - newGameScreen.gameSetupInfo = GameSetupInfo() newGameScreen.unlockTables() newGameScreen.updateTables() } diff --git a/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt b/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt index 9a807fdcfd..c7f8eb6bc9 100644 --- a/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt +++ b/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt @@ -28,11 +28,12 @@ class GameSetupInfo(var gameId:String, var gameParameters: GameParameters, var m } class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSetupInfo?=null): PreviousScreenInterface, PickerScreen() { - override var gameSetupInfo: GameSetupInfo = _gameSetupInfo ?: GameSetupInfo() + override val gameSetupInfo = _gameSetupInfo ?: GameSetupInfo() var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters) - var newGameOptionsTable = GameOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) } + var newGameOptionsTable = GameOptionsTable(gameSetupInfo) { desiredCiv: String -> playerPickerTable.update(desiredCiv) } var mapOptionsTable = MapOptionsTable(this) + init { setDefaultCloseAction(previousScreen) scrollPane.setScrollingDisabled(true, true) diff --git a/core/src/com/unciv/ui/newgamescreen/PreviousScreenInterface.kt b/core/src/com/unciv/ui/newgamescreen/PreviousScreenInterface.kt index dee83c18e8..58659684c9 100644 --- a/core/src/com/unciv/ui/newgamescreen/PreviousScreenInterface.kt +++ b/core/src/com/unciv/ui/newgamescreen/PreviousScreenInterface.kt @@ -12,7 +12,7 @@ import com.unciv.ui.utils.CameraStageBaseScreen */ interface PreviousScreenInterface { - var gameSetupInfo: GameSetupInfo + val gameSetupInfo: GameSetupInfo var stage: Stage // added for compatibility with NewGameScreen: PickerScreen