diff --git a/core/src/com/unciv/MainMenuScreen.kt b/core/src/com/unciv/MainMenuScreen.kt index c0ec84d21f..91029af82b 100644 --- a/core/src/com/unciv/MainMenuScreen.kt +++ b/core/src/com/unciv/MainMenuScreen.kt @@ -82,7 +82,6 @@ class MainMenuScreen: CameraStageBaseScreen() { val newGameButton = getTableBlock("Start new game", "OtherIcons/New") { game.setScreen(NewGameScreen(this)) - dispose() } column1.add(newGameButton).row() diff --git a/core/src/com/unciv/ui/mapeditor/NewMapScreen.kt b/core/src/com/unciv/ui/mapeditor/NewMapScreen.kt index 1b555c33be..a7224af746 100644 --- a/core/src/com/unciv/ui/mapeditor/NewMapScreen.kt +++ b/core/src/com/unciv/ui/mapeditor/NewMapScreen.kt @@ -45,7 +45,6 @@ class NewMapScreen(val mapParameters: MapParameters = MapParameters()) : PickerS topTable.apply { add(ScrollPane(newMapScreenOptionsTable).apply { setOverscroll(false, false) }) - .height(topTable.parent.height) pack() setFillParent(true) } diff --git a/core/src/com/unciv/ui/mapeditor/SaveAndLoadMapScreen.kt b/core/src/com/unciv/ui/mapeditor/SaveAndLoadMapScreen.kt index 0f238e1545..5bab0e2c16 100644 --- a/core/src/com/unciv/ui/mapeditor/SaveAndLoadMapScreen.kt +++ b/core/src/com/unciv/ui/mapeditor/SaveAndLoadMapScreen.kt @@ -70,8 +70,7 @@ class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false) : PickerSc } } - topTable.add(ScrollPane(mapsTable)).height(stage.height * 2 / 3) - .maxWidth(stage.width / 2) + topTable.add(ScrollPane(mapsTable)).maxWidth(stage.width / 2) val rightSideTable = Table().apply { defaults().pad(10f) } diff --git a/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt b/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt index 5018f677ca..b183593617 100644 --- a/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt +++ b/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt @@ -5,7 +5,6 @@ import com.badlogic.gdx.files.FileHandle import com.badlogic.gdx.scenes.scene2d.ui.SelectBox import com.badlogic.gdx.scenes.scene2d.ui.Skin import com.badlogic.gdx.utils.Array -import com.unciv.UncivGame import com.unciv.logic.* import com.unciv.logic.civilization.PlayerType import com.unciv.logic.map.MapParameters @@ -37,13 +36,13 @@ class GameSetupInfo(var gameId:String, var gameParameters: GameParameters, var m } } -class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSetupInfo?=null): IPreviousScreen, PickerScreen() { +class NewGameScreen(private val previousScreen: CameraStageBaseScreen, _gameSetupInfo: GameSetupInfo?=null): IPreviousScreen, PickerScreen() { override val gameSetupInfo = _gameSetupInfo ?: GameSetupInfo() override var ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters.mods) // needs to be set because the gameoptionstable etc. depend on this var newGameOptionsTable = GameOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) } // Has to be defined before the mapOptionsTable, since the mapOptionsTable refers to it on init - var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters) + private var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters) var mapOptionsTable = MapOptionsTable(this) @@ -51,19 +50,16 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSe setDefaultCloseAction(previousScreen) scrollPane.setScrollingDisabled(true, true) - topTable.add(ScrollPane(newGameOptionsTable, skin).apply { setOverscroll(false, false) }) - .maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top() + topTable.add(ScrollPane(newGameOptionsTable).apply { setOverscroll(false, false) }) + .width(stage.width / 3).padTop(20f).top() topTable.addSeparatorVertical() - topTable.add(ScrollPane(mapOptionsTable, skin).apply { setOverscroll(false, false) }) - .maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top() + topTable.add(ScrollPane(mapOptionsTable).apply { setOverscroll(false, false) }) + .width(stage.width / 3).padTop(20f).top() topTable.addSeparatorVertical() - topTable.add(ScrollPane(playerPickerTable, skin) + topTable.add(ScrollPane(playerPickerTable) .apply { setOverscroll(false, false) } .apply { setScrollingDisabled(true, false) }) - .maxHeight(topTable.parent.height).width(stage.width / 3).padTop(20f).top() - - topTable.pack() - topTable.setFillParent(true) + .width(stage.width / 3).padTop(20f).top() updateRuleset() @@ -194,10 +190,18 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSe var newGame: GameInfo? = null override fun render(delta: Float) { - if (newGame != null) + if (newGame != null) { game.loadGame(newGame!!) + previousScreen.dispose() + } super.render(delta) } + + override fun resize(width: Int, height: Int) { + if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) { + game.setScreen(NewGameScreen(previousScreen, gameSetupInfo)) + } + } } class TranslatedSelectBox(values : Collection, default:String, skin: Skin) : SelectBox(skin) { diff --git a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt index b64bf3a9be..865049aab3 100644 --- a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt @@ -45,13 +45,13 @@ class ModManagementScreen: PickerScreen() { topTable.row() - topTable.add(ScrollPane(modTable)).height(scrollPane.height * 0.8f).pad(10f) + topTable.add(ScrollPane(modTable)).pad(10f) downloadTable.add(getDownloadButton()).row() tryDownloadPage(1) - topTable.add(ScrollPane(downloadTable)).height(scrollPane.height * 0.8f)//.size(downloadTable.width, topTable.height) + topTable.add(ScrollPane(downloadTable)) topTable.add(modActionTable) } diff --git a/core/src/com/unciv/ui/saves/LoadGameScreen.kt b/core/src/com/unciv/ui/saves/LoadGameScreen.kt index 774f6a973b..cada4308c9 100644 --- a/core/src/com/unciv/ui/saves/LoadGameScreen.kt +++ b/core/src/com/unciv/ui/saves/LoadGameScreen.kt @@ -31,7 +31,7 @@ class LoadGameScreen(previousScreen:CameraStageBaseScreen) : PickerScreen() { setDefaultCloseAction(previousScreen) resetWindowState() - topTable.add(ScrollPane(saveTable)).height(stage.height * 2 / 3) + topTable.add(ScrollPane(saveTable)) val rightSideTable = getRightSideTable() @@ -174,7 +174,7 @@ class LoadGameScreen(previousScreen:CameraStageBaseScreen) : PickerScreen() { val savedAt = Date(save.lastModified()) descriptionLabel.setText("Loading...".tr()) - textToSet += "\n{Saved at}: ".tr() + SimpleDateFormat("yyyy-MM-dd HH:mm").format(savedAt) + textToSet += "\n{Saved at}: ".tr() + SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US).format(savedAt) thread { // Even loading the game to get its metadata can take a long time on older phones try { val game = GameSaver.loadGameFromFile(save) diff --git a/core/src/com/unciv/ui/saves/SaveGameScreen.kt b/core/src/com/unciv/ui/saves/SaveGameScreen.kt index 5676a409cb..1b3462c19c 100644 --- a/core/src/com/unciv/ui/saves/SaveGameScreen.kt +++ b/core/src/com/unciv/ui/saves/SaveGameScreen.kt @@ -27,7 +27,7 @@ class SaveGameScreen(val gameInfo: GameInfo) : PickerScreen() { gameNameTextField.textFieldFilter = TextField.TextFieldFilter { _, char -> char != '\\' && char != '/' } currentSaves.add("Current saves".toLabel()).row() updateShownSaves(false) - topTable.add(ScrollPane(currentSaves)).height(stage.height * 2 / 3) + topTable.add(ScrollPane(currentSaves)) val newSave = Table() val defaultSaveName = gameInfo.currentPlayer + " - " + gameInfo.turns + " turns"