diff --git a/core/src/com/unciv/UnCivGame.kt b/core/src/com/unciv/UnCivGame.kt index 00f813b4e9..08109ee1de 100644 --- a/core/src/com/unciv/UnCivGame.kt +++ b/core/src/com/unciv/UnCivGame.kt @@ -11,6 +11,7 @@ import com.unciv.models.gamebasics.GameBasics import com.unciv.models.metadata.GameParameters import com.unciv.models.metadata.GameSettings import com.unciv.ui.LanguagePickerScreen +import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.ImageGetter import com.unciv.ui.worldscreen.WorldScreen import java.util.* @@ -18,7 +19,6 @@ import java.util.* class UnCivGame(val version: String) : Game() { var gameInfo: GameInfo = GameInfo() lateinit var settings : GameSettings - /** * This exists so that when debugging we can see the entire map. * Remember to turn this to false before commit and upload! @@ -48,7 +48,12 @@ class UnCivGame(val version: String) : Game() { startNewGame() } } - else screen= LanguagePickerScreen() + else setScreen(LanguagePickerScreen()) + } + + fun setScreen(screen: CameraStageBaseScreen) { + Gdx.input.inputProcessor = screen.stage + super.setScreen(screen) } fun loadGame(gameInfo:GameInfo){ @@ -70,7 +75,6 @@ class UnCivGame(val version: String) : Game() { fun setWorldScreen() { if(screen != null && screen != worldScreen) screen.dispose() setScreen(worldScreen) - Gdx.input.inputProcessor = worldScreen.stage worldScreen.shouldUpdate=true // This can set the screen to the policy picker or tech picker screen, so the input processor must come before } diff --git a/core/src/com/unciv/logic/civilization/Notification.kt b/core/src/com/unciv/logic/civilization/Notification.kt index 8f083f3776..a7deaaf57a 100644 --- a/core/src/com/unciv/logic/civilization/Notification.kt +++ b/core/src/com/unciv/logic/civilization/Notification.kt @@ -42,7 +42,7 @@ data class LocationAction(var locations: ArrayList = ArrayList()) : Not class TechAction(val techName: String = "") : NotificationAction { override fun execute(worldScreen: WorldScreen) { val tech = GameBasics.Technologies[techName] - worldScreen.game.screen = TechPickerScreen(worldScreen.viewingCiv, true, tech) + worldScreen.game.setScreen(TechPickerScreen(worldScreen.viewingCiv, true, tech)) } } @@ -51,7 +51,7 @@ data class CityAction(val city: Vector2 = Vector2.Zero): NotificationAction { override fun execute(worldScreen: WorldScreen) { worldScreen.tileMapHolder.tileMap[city].getCity()?.let { - worldScreen.game.screen = CityScreen(it) + worldScreen.game.setScreen(CityScreen(it)) } } diff --git a/core/src/com/unciv/ui/VictoryScreen.kt b/core/src/com/unciv/ui/VictoryScreen.kt index 21b166db3d..7908e55664 100644 --- a/core/src/com/unciv/ui/VictoryScreen.kt +++ b/core/src/com/unciv/ui/VictoryScreen.kt @@ -13,8 +13,10 @@ import com.unciv.ui.newgamescreen.NewGameScreen import com.unciv.ui.pickerscreens.PickerScreen import com.unciv.ui.pickerscreens.PolicyPickerScreen import com.unciv.ui.pickerscreens.TechPickerScreen -import com.unciv.ui.utils.* -import com.unciv.ui.worldscreen.WorldScreen +import com.unciv.ui.utils.addSeparator +import com.unciv.ui.utils.enable +import com.unciv.ui.utils.onClick +import com.unciv.ui.utils.toLabel class VictoryScreen : PickerScreen() { @@ -86,7 +88,7 @@ class VictoryScreen : PickerScreen() { rightSideButton.isVisible = true rightSideButton.enable() rightSideButton.onClick { - UnCivGame.Current.screen= NewGameScreen() + UnCivGame.Current.setScreen(NewGameScreen()) } closeButton.setText("One more turn...!".tr()) @@ -204,7 +206,7 @@ class VictoryScreen : PickerScreen() { policyVictoryColumn.add(civToBranchesHaveCompleted).row() civToBranchesHaveCompleted.touchable= Touchable.enabled civToBranchesHaveCompleted.onClick { - game.screen = PolicyPickerScreen(UnCivGame.Current.worldScreen,entry.civ, false) + game.setScreen(PolicyPickerScreen(UnCivGame.Current.worldScreen,entry.civ, false)) dispose() } } @@ -228,7 +230,7 @@ class VictoryScreen : PickerScreen() { scientificVictoryColumn.add(civToPartsBeRemaining).row() civToPartsBeRemaining.touchable= Touchable.enabled civToPartsBeRemaining.onClick { - game.screen = TechPickerScreen(entry.civ, false) + game.setScreen(TechPickerScreen(entry.civ, false)) dispose() } } diff --git a/core/src/com/unciv/ui/cityscreen/CityScreenCityPickerTable.kt b/core/src/com/unciv/ui/cityscreen/CityScreenCityPickerTable.kt index 8a7d690683..9010142cc4 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreenCityPickerTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreenCityPickerTable.kt @@ -22,7 +22,7 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){ prevCityButton.onClick { val indexOfCity = civInfo.cities.indexOf(city) val indexOfNextCity = if (indexOfCity == 0) civInfo.cities.size - 1 else indexOfCity - 1 - cityScreen.game.screen = CityScreen(civInfo.cities[indexOfNextCity]) + cityScreen.game.setScreen(CityScreen(civInfo.cities[indexOfNextCity])) } add(prevCityButton).pad(20f) } else add() @@ -59,7 +59,7 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){ editCityNamePopup.addCloseButton() editCityNamePopup.addButton("Save".tr()){ city.name = textArea.text - cityScreen.game.screen = CityScreen(city) + cityScreen.game.setScreen(CityScreen(city)) } editCityNamePopup.open() } @@ -74,7 +74,7 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){ nextCityButton.onClick { val indexOfCity = civInfo.cities.indexOf(city) val indexOfNextCity = if (indexOfCity == civInfo.cities.size - 1) 0 else indexOfCity + 1 - cityScreen.game.screen = CityScreen(civInfo.cities[indexOfNextCity]) + cityScreen.game.setScreen(CityScreen(civInfo.cities[indexOfNextCity])) } add(nextCityButton).pad(20f) } else add() diff --git a/core/src/com/unciv/ui/cityscreen/CityScreenTileTable.kt b/core/src/com/unciv/ui/cityscreen/CityScreenTileTable.kt index f440a45e2a..7e42f03c00 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreenTileTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreenTileTable.kt @@ -51,16 +51,19 @@ class CityScreenTileTable(val city: CityInfo): Table(){ val buyTileButton = TextButton("Buy for [$goldCostOfTile] gold".tr(), CameraStageBaseScreen.skin) buyTileButton.onClick("coin") { city.expansion.buyTile(selectedTile) - UnCivGame.Current.screen = CityScreen(city) + UnCivGame.Current.setScreen(CityScreen(city)) } if(goldCostOfTile>city.civInfo.gold || city.isPuppet || !UnCivGame.Current.worldScreen.isPlayersTurn) buyTileButton.disable() innerTable.add(buyTileButton) } - if(city.canAcquireTile(selectedTile)){ + if(city.canAcquireTile(selectedTile)) { val acquireTileButton = TextButton("Acquire".tr(), CameraStageBaseScreen.skin) - acquireTileButton.onClick { city.expansion.takeOwnership(selectedTile); UnCivGame.Current.screen = CityScreen(city) } + acquireTileButton.onClick { + city.expansion.takeOwnership(selectedTile) + UnCivGame.Current.setScreen(CityScreen(city)) + } innerTable.add(acquireTileButton) } innerTable.pack() diff --git a/core/src/com/unciv/ui/mapeditor/MapEditorOptionsTable.kt b/core/src/com/unciv/ui/mapeditor/MapEditorOptionsTable.kt index 90c84c4048..910541f4d8 100644 --- a/core/src/com/unciv/ui/mapeditor/MapEditorOptionsTable.kt +++ b/core/src/com/unciv/ui/mapeditor/MapEditorOptionsTable.kt @@ -59,7 +59,7 @@ class MapEditorOptionsTable(mapEditorScreen: MapEditorScreen): PopupTable(mapEdi val loadMapButton = TextButton("Load".tr(), skin) loadMapButton.onClick { - UnCivGame.Current.screen = LoadMapScreen(mapEditorScreen.tileMap) + UnCivGame.Current.setScreen(LoadMapScreen(mapEditorScreen.tileMap)) } add(loadMapButton).row() @@ -123,7 +123,7 @@ class MapDownloadTable(mapEditorScreen: MapEditorScreen):PopupTable(mapEditorScr val decodedMapJson = Gzip.unzip(mapJsonGzipped) val mapObject = MapSaver().mapFromJson(decodedMapJson) MapSaver().saveMap(downloadableMap.name, mapObject) - UnCivGame.Current.screen = MapEditorScreen(mapObject) + UnCivGame.Current.setScreen(MapEditorScreen(mapObject)) } scrollableMapTable.add(downloadMapButton).row() } diff --git a/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.kt index dcd7c5aa5f..c5b11bc64d 100644 --- a/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.kt @@ -38,7 +38,7 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo game.setWorldScreen() dispose() } - else game.screen = PolicyPickerScreen(worldScreen) // update policies + else game.setScreen(PolicyPickerScreen(worldScreen)) // update policies } if(!UnCivGame.Current.worldScreen.isPlayersTurn) rightSideButton.disable() diff --git a/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt index 4bf0a02a5e..e82af34271 100644 --- a/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt @@ -20,7 +20,7 @@ class PromotionPickerScreen(val mapUnit: MapUnit) : PickerScreen() { fun acceptPromotion(promotion: Promotion?) { mapUnit.promotions.addPromotion(promotion!!.name) - if(mapUnit.promotions.canBePromoted()) game.screen = PromotionPickerScreen(mapUnit) + if(mapUnit.promotions.canBePromoted()) game.setScreen(PromotionPickerScreen(mapUnit)) else game.setWorldScreen() dispose() game.worldScreen.shouldUpdate=true diff --git a/core/src/com/unciv/ui/saves/LoadGameScreen.kt b/core/src/com/unciv/ui/saves/LoadGameScreen.kt index daf1d5f1c3..50bd954119 100644 --- a/core/src/com/unciv/ui/saves/LoadGameScreen.kt +++ b/core/src/com/unciv/ui/saves/LoadGameScreen.kt @@ -72,7 +72,7 @@ class LoadGameScreen : PickerScreen() { deleteSaveButton.onClick { GameSaver().deleteSave(selectedSave) - UnCivGame.Current.screen = LoadGameScreen() + UnCivGame.Current.setScreen(LoadGameScreen()) } deleteSaveButton.disable() rightSideTable.add(deleteSaveButton).row() diff --git a/core/src/com/unciv/ui/saves/LoadMapScreen.kt b/core/src/com/unciv/ui/saves/LoadMapScreen.kt index fac21405fa..00e3f8ed5d 100644 --- a/core/src/com/unciv/ui/saves/LoadMapScreen.kt +++ b/core/src/com/unciv/ui/saves/LoadMapScreen.kt @@ -21,7 +21,7 @@ class LoadMapScreen(previousMap: TileMap) : PickerScreen(){ init { rightSideButton.setText("Load map".tr()) rightSideButton.onClick { - UnCivGame.Current.screen = MapEditorScreen(chosenMap) + UnCivGame.Current.setScreen(MapEditorScreen(chosenMap)) dispose() } @@ -46,7 +46,7 @@ class LoadMapScreen(previousMap: TileMap) : PickerScreen(){ try { val decoded = Gzip.unzip(clipboardContentsString) val loadedMap = MapSaver().mapFromJson(decoded) - UnCivGame.Current.screen = MapEditorScreen(loadedMap) + UnCivGame.Current.setScreen(MapEditorScreen(loadedMap)) } catch (ex:Exception){ couldNotLoadMapLabel.isVisible=true @@ -58,7 +58,7 @@ class LoadMapScreen(previousMap: TileMap) : PickerScreen(){ deleteMapButton.onClick { YesNoPopupTable("Are you sure you want to delete this map?", { MapSaver().deleteMap(chosenMap) - UnCivGame.Current.screen = LoadMapScreen(previousMap) + UnCivGame.Current.setScreen(LoadMapScreen(previousMap)) }, this) } deleteMapButton.disable() @@ -66,6 +66,6 @@ class LoadMapScreen(previousMap: TileMap) : PickerScreen(){ rightSideTable.add(deleteMapButton).row() topTable.add(rightSideTable) - closeButton.onClick { UnCivGame.Current.screen = MapEditorScreen(previousMap) } + closeButton.onClick { UnCivGame.Current.setScreen(MapEditorScreen(previousMap)) } } } \ No newline at end of file diff --git a/core/src/com/unciv/ui/tilegroups/CityButton.kt b/core/src/com/unciv/ui/tilegroups/CityButton.kt index ec8407a485..1eda3f6210 100644 --- a/core/src/com/unciv/ui/tilegroups/CityButton.kt +++ b/core/src/com/unciv/ui/tilegroups/CityButton.kt @@ -72,7 +72,7 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski // second tap on the button will go to the city screen onClick { if (isButtonMoved) { - UnCivGame.Current.screen = CityScreen(city) + UnCivGame.Current.setScreen(CityScreen(city)) } else { moveButtonDown() if (unitTable.selectedUnit == null || unitTable.selectedUnit!!.currentMovement == 0f) diff --git a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt index 74546c0b00..86b4a9e686 100644 --- a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt +++ b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt @@ -24,7 +24,6 @@ open class CameraStageBaseScreen : Screen { init { val resolutions: List = game.settings.resolution.split("x").map { it.toInt().toFloat() } stage = Stage(ExtendViewport(resolutions[0], resolutions[1]), batch)// FitViewport(1000,600) - Gdx.input.inputProcessor = stage } diff --git a/core/src/com/unciv/ui/worldscreen/TradePopup.kt b/core/src/com/unciv/ui/worldscreen/TradePopup.kt index 5f8dbdf172..4e1870bf58 100644 --- a/core/src/com/unciv/ui/worldscreen/TradePopup.kt +++ b/core/src/com/unciv/ui/worldscreen/TradePopup.kt @@ -84,7 +84,7 @@ class TradePopup(worldScreen: WorldScreen): PopupTable(worldScreen){ val tradeTable = diplomacyScreen.setTrade(requestingCiv) tradeTable.tradeLogic.currentTrade.set(trade) tradeTable.offerColumnsTable.update() - worldScreen.game.screen=diplomacyScreen + worldScreen.game.setScreen(diplomacyScreen) worldScreen.shouldUpdate=true } open() diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index a23381e502..e0550bdaa8 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -68,7 +68,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { techButtonHolder.touchable=Touchable.enabled techButtonHolder.onClick("paper") { - game.screen = TechPickerScreen(viewingCiv) + game.setScreen(TechPickerScreen(viewingCiv)) } techPolicyandVictoryHolder.add(techButtonHolder) @@ -76,7 +76,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { if(viewingCiv.policies.adoptedPolicies.isNotEmpty() || viewingCiv.policies.canAdoptPolicy()) { val policyScreenButton = Button(skin) policyScreenButton.add(ImageGetter.getImage("PolicyIcons/Constitution")).size(30f).pad(15f) - policyScreenButton.onClick { game.screen = PolicyPickerScreen(this) } + policyScreenButton.onClick { game.setScreen(PolicyPickerScreen(this)) } techPolicyandVictoryHolder.add(policyScreenButton).pad(10f) } @@ -189,9 +189,9 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { || alertPopupIsOpen if(!isSomethingOpen && isPlayersTurn) { when { - !gameInfo.oneMoreTurnMode && gameInfo.civilizations.any { it.victoryManager.hasWon() } -> game.screen = VictoryScreen() - viewingCiv.policies.freePolicies > 0 -> game.screen = PolicyPickerScreen(this) - viewingCiv.greatPeople.freeGreatPeople > 0 -> game.screen = GreatPersonPickerScreen() + !gameInfo.oneMoreTurnMode && gameInfo.civilizations.any { it.victoryManager.hasWon() } -> game.setScreen(VictoryScreen()) + viewingCiv.policies.freePolicies > 0 -> game.setScreen(PolicyPickerScreen(this)) + viewingCiv.greatPeople.freeGreatPeople > 0 -> game.setScreen(GreatPersonPickerScreen()) viewingCiv.popupAlerts.any() -> AlertPopup(this, viewingCiv.popupAlerts.first()) viewingCiv.tradeRequests.isNotEmpty() -> TradePopup(this) } @@ -240,7 +240,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { .any()) { displayTutorials("_OtherCivEncountered") val btn = TextButton("Diplomacy".tr(), skin) - btn.onClick { UnCivGame.Current.screen = DiplomacyScreen(viewingCiv) } + btn.onClick { UnCivGame.Current.setScreen(DiplomacyScreen(viewingCiv)) } btn.label.setFontSize(30) btn.labelCell.pad(10f) diplomacyButtonWrapper.add(btn) @@ -299,15 +299,15 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { val cityWithNoProductionSet = viewingCiv.cities .firstOrNull{it.cityConstructions.currentConstruction==""} if(cityWithNoProductionSet!=null){ - game.screen = CityScreen(cityWithNoProductionSet) + game.setScreen(CityScreen(cityWithNoProductionSet)) return@onClick } if (viewingCiv.shouldOpenTechPicker()) { - game.screen = TechPickerScreen(viewingCiv.tech.freeTechs != 0, viewingCiv) + game.setScreen(TechPickerScreen(viewingCiv.tech.freeTechs != 0, viewingCiv)) return@onClick } else if (viewingCiv.policies.shouldOpenPolicyPicker) { - game.screen = PolicyPickerScreen(this) + game.setScreen(PolicyPickerScreen(this)) viewingCiv.policies.shouldOpenPolicyPicker = false return@onClick } @@ -369,7 +369,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { if (gameInfoClone.currentPlayerCiv.civName != viewingCiv.civName && !gameInfoClone.gameParameters.isOnlineMultiplayer) - UnCivGame.Current.screen = PlayerReadyScreen(gameInfoClone.getCurrentPlayerCivilization()) + UnCivGame.Current.setScreen(PlayerReadyScreen(gameInfoClone.getCurrentPlayerCivilization())) else { createNewWorldScreen() } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt b/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt index f82e3f6b08..4a4e92b91f 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt @@ -48,7 +48,7 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() { val overviewButton = TextButton("Overview".tr(),CameraStageBaseScreen.skin) overviewButton.labelCell.pad(10f) overviewButton.pack() - overviewButton.onClick { UnCivGame.Current.screen = EmpireOverviewScreen() } + overviewButton.onClick { UnCivGame.Current.setScreen(EmpireOverviewScreen()) } overviewButton.center(this) overviewButton.x = screen.stage.width-overviewButton.width-10 addActor(overviewButton) diff --git a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenMenuTable.kt b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenMenuTable.kt index 77349428cc..53529f92ed 100644 --- a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenMenuTable.kt +++ b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenMenuTable.kt @@ -35,37 +35,37 @@ class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScree tile.turnsToImprovement=0 tile.roadStatus=RoadStatus.None } - UnCivGame.Current.screen = MapEditorScreen(tileMapClone) + UnCivGame.Current.setScreen(MapEditorScreen(tileMapClone)) remove() }.size(width,height) addSeparator() addSquareButton("Civilopedia".tr()){ - UnCivGame.Current.screen = CivilopediaScreen() + UnCivGame.Current.setScreen(CivilopediaScreen()) remove() }.size(width,height) addSeparator() addSquareButton("Load game".tr()){ - UnCivGame.Current.screen = LoadGameScreen() + UnCivGame.Current.setScreen(LoadGameScreen()) remove() }.size(width,height) addSeparator() addSquareButton("Save game".tr()) { - UnCivGame.Current.screen = SaveGameScreen() + UnCivGame.Current.setScreen(SaveGameScreen()) remove() }.size(width,height) addSeparator() - addSquareButton("Start new game".tr()){ UnCivGame.Current.screen = NewGameScreen() }.size(width,height) + addSquareButton("Start new game".tr()){ UnCivGame.Current.setScreen(NewGameScreen()) }.size(width,height) addSeparator() addSquareButton("Multiplayer".tr()) { openMultiplayerPopup() }.size(width,height) addSeparator() - addSquareButton("Victory status".tr()) { UnCivGame.Current.screen = VictoryScreen() }.size(width,height) + addSquareButton("Victory status".tr()) { UnCivGame.Current.setScreen(VictoryScreen()) }.size(width,height) addSeparator() addSquareButton("Options".tr()){ diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 72c0a33999..743c1ac7f9 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -72,7 +72,7 @@ class UnitActions { if(!unit.type.isCivilian() && unit.promotions.canBePromoted()) { // promotion does not consume movement points, so we can do it always actionList += UnitAction("Promote", true) { - UnCivGame.Current.screen = PromotionPickerScreen(unit) + UnCivGame.Current.setScreen(PromotionPickerScreen(unit)) }.sound("promote") } @@ -146,7 +146,7 @@ class UnitActions { && !tile.isCityCenter() && GameBasics.TileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) }, currentAction = unit.currentTile.hasImprovementInProgress() - ) { worldScreen.game.screen = ImprovementPickerScreen(tile) { unitTable.selectedUnit = null } } + ) { worldScreen.game.setScreen(ImprovementPickerScreen(tile) { unitTable.selectedUnit = null }) } if(Constants.unitActionAutomation == unit.action){ actionList += UnitAction("Stop automation", true) {unit.action = null} @@ -202,7 +202,7 @@ class UnitActions { ) { unit.civInfo.tech.freeTechs += 1 unit.destroy() - worldScreen.game.screen = TechPickerScreen(true, unit.civInfo) + worldScreen.game.setScreen(TechPickerScreen(true, unit.civInfo)) }.sound("chimes") } diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt index 5e63b93c08..9b6ad8d6a5 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt @@ -55,7 +55,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ if (selectedUnit != null) { pedia.select("Units", selectedUnit?.name) } - UnCivGame.Current.screen = pedia + UnCivGame.Current.setScreen(pedia) } addActor(helpUnitButton)