From 084adc33965cbafd4c58ed8ff121228a7260b4eb Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Tue, 1 Jun 2021 19:00:50 +0200 Subject: [PATCH] Patch ModManager exit to allow deactivating a selected tileset (#4029) --- core/src/com/unciv/logic/map/TileInfo.kt | 7 ++++--- .../unciv/ui/pickerscreens/ModManagementScreen.kt | 13 ++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index c594a28699..797a44eceb 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -449,17 +449,18 @@ open class TileInfo { /** Shows important properties of this tile for debugging _only_, it helps to see what you're doing */ override fun toString(): String { - val lineList = arrayListOf("TileInfo @($position)") + val lineList = arrayListOf("TileInfo @$position") + if (!this::baseTerrain.isInitialized) return lineList[0] + ", uninitialized" if (isCityCenter()) lineList += getCity()!!.name lineList += baseTerrain for (terrainFeature in terrainFeatures) lineList += terrainFeature - if (resource != null ) lineList += resource!! + if (resource != null) lineList += resource!! if (naturalWonder != null) lineList += naturalWonder!! if (roadStatus !== RoadStatus.None && !isCityCenter()) lineList += roadStatus.name if (improvement != null) lineList += improvement!! if (civilianUnit != null) lineList += civilianUnit!!.name + " - " + civilianUnit!!.civInfo.civName if (militaryUnit != null) lineList += militaryUnit!!.name + " - " + militaryUnit!!.civInfo.civName - if (isImpassible()) lineList += Constants.impassable + if (this::baseTerrainObject.isInitialized && isImpassible()) lineList += Constants.impassable return lineList.joinToString() } diff --git a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt index 843dc85ef3..9eb31a5719 100644 --- a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt @@ -104,7 +104,18 @@ class ModManagementScreen: PickerScreen(disableScroll = true) { init { - setDefaultCloseAction(MainMenuScreen()) + //setDefaultCloseAction(screen) // this would initialize the new MainMenuScreen immediately + val closeAction = { + val tileSets = ImageGetter.getAvailableTilesets() + if (game.settings.tileSet !in tileSets) { + game.settings.tileSet = tileSets.first() + } + game.setScreen(MainMenuScreen()) + dispose() + } + closeButton.onClick(closeAction) + onBackButtonClicked(closeAction) + refreshInstalledModTable() // Header row