Opening the New Game screen from within a game saves the previous game parameters, map generation parameters work again

@alkorolyov
This commit is contained in:
Yair Morgenstern 2020-06-17 19:56:20 +03:00
parent 604a41ca6c
commit 1b73aab856
6 changed files with 9 additions and 10 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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 {

View file

@ -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()
}

View file

@ -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)

View file

@ -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