Dispose main menu screen when exiting to save space

This commit is contained in:
Yair Morgenstern 2020-07-06 23:25:11 +03:00
parent 58a8e358ea
commit 0516810571
3 changed files with 24 additions and 12 deletions

View File

@ -8,6 +8,8 @@ Fixed main menu crash when returning from certain modded games
Resolved #2794 - Save games and maps cannot have slashes/backslashes, to avoid foldername/filename confusion
Civ is properly destroyed when liberating the last city of the civ
By alkorolyov:
- Basic spectator functionality - POC
- Console mode for multiple game automation - POC

View File

@ -81,18 +81,22 @@ class MainMenuScreen: CameraStageBaseScreen() {
val newGameButton = getTableBlock("Start new game", "OtherIcons/New") {
game.setScreen(NewGameScreen(this))
dispose()
}
table.add(newGameButton).row()
if (GameSaver.getSaves(false).any()) {
val loadGameTable = getTableBlock("Load game","OtherIcons/Load") { game.setScreen(LoadGameScreen(this)) }
val loadGameTable = getTableBlock("Load game", "OtherIcons/Load")
{ game.setScreen(LoadGameScreen(this)) }
table.add(loadGameTable).row()
}
val multiplayerTable = getTableBlock("Multiplayer","OtherIcons/Multiplayer") { game.setScreen(MultiplayerScreen(this)) }
val multiplayerTable = getTableBlock("Multiplayer", "OtherIcons/Multiplayer")
{ game.setScreen(MultiplayerScreen(this)) }
table.add(multiplayerTable).row()
val mapEditorScreenTable = getTableBlock("Map editor","OtherIcons/MapEditor") { openMapEditorPopup() }
val mapEditorScreenTable = getTableBlock("Map editor", "OtherIcons/MapEditor")
{ openMapEditorPopup() }
table.add(mapEditorScreenTable)
// set the same width for all buttons
@ -100,7 +104,8 @@ class MainMenuScreen: CameraStageBaseScreen() {
table.children.filterIsInstance<Table>().forEach {
it.align(Align.left)
it.moveBy((it.width - table.width) / 2, 0f)
it.width = table.width }
it.width = table.width
}
table.pack()
val scroll = ScrollPane(table)
@ -119,7 +124,10 @@ class MainMenuScreen: CameraStageBaseScreen() {
val tableBackground = ImageGetter.getBackground(colorFromRGB(29, 102, 107))
val newMapButton = getTableBlock("New map", "OtherIcons/New") { game.setScreen(NewMapScreen()) }
val newMapButton = getTableBlock("New map", "OtherIcons/New") {
game.setScreen(NewMapScreen())
dispose()
}
newMapButton.background = tableBackground
mapEditorPopup.add(newMapButton).row()
@ -131,6 +139,7 @@ class MainMenuScreen: CameraStageBaseScreen() {
loadMapScreen.dispose()
}
game.setScreen(loadMapScreen)
dispose()
}
loadMapButton.background = tableBackground
@ -145,6 +154,7 @@ class MainMenuScreen: CameraStageBaseScreen() {
loadScenarioScreen.dispose()
}
game.setScreen(loadScenarioScreen)
dispose()
}
loadScenarioButton.background = tableBackground
@ -160,6 +170,7 @@ class MainMenuScreen: CameraStageBaseScreen() {
private fun autoLoadGame() {
try {
game.loadGame(autosave)
dispose()
}
catch (outOfMemory:OutOfMemoryError){
ResponsePopup("Not enough memory on phone to load game!", this)

View File

@ -437,7 +437,6 @@ class CityInfo {
return
}
val oldCiv = civInfo
diplomaticRepercussionsForLiberatingCity(conqueringCiv)