From 335b7dc1e3b2271f4d3d63f48e7667629809a988 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 4 Jun 2018 12:29:02 +0300 Subject: [PATCH] Removed all opening of screens from within game logic, put in the WorldScreen login instead, so that the rendering screen remains the same (OpenGL context problems) --- .../src/com/unciv/logic/civilization/CivilizationInfo.kt | 2 +- .../com/unciv/logic/civilization/GreatPersonManager.kt | 1 + core/src/com/unciv/logic/civilization/PolicyManager.kt | 7 +------ core/src/com/unciv/models/gamebasics/Building.kt | 9 --------- core/src/com/unciv/ui/worldscreen/WorldScreen.kt | 3 +++ 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 7b10cc1e..10554761 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -30,7 +30,7 @@ class CivilizationInfo { var tech = TechManager() var policies = PolicyManager() var goldenAges = GoldenAgeManager() - private var greatPeople = GreatPersonManager() + var greatPeople = GreatPersonManager() var scienceVictory = ScienceVictoryManager() var cities = ArrayList() diff --git a/core/src/com/unciv/logic/civilization/GreatPersonManager.kt b/core/src/com/unciv/logic/civilization/GreatPersonManager.kt index d2361801..3d67720a 100644 --- a/core/src/com/unciv/logic/civilization/GreatPersonManager.kt +++ b/core/src/com/unciv/logic/civilization/GreatPersonManager.kt @@ -5,6 +5,7 @@ import com.unciv.models.stats.Stats class GreatPersonManager { private var pointsForNextGreatPerson = 100 private val greatPersonPoints = Stats() + var freeGreatPeople=0 fun getNewGreatPerson(): String? { var greatPerson: String? = null diff --git a/core/src/com/unciv/logic/civilization/PolicyManager.kt b/core/src/com/unciv/logic/civilization/PolicyManager.kt index f3fca6a3..f7181af7 100644 --- a/core/src/com/unciv/logic/civilization/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/PolicyManager.kt @@ -1,10 +1,7 @@ package com.unciv.logic.civilization -import com.unciv.UnCivGame import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.Policy -import com.unciv.ui.VictoryScreen -import com.unciv.ui.pickerscreens.GreatPersonPickerScreen import com.unciv.ui.utils.getRandom @@ -55,8 +52,6 @@ class PolicyManager { if (branch.policies.count { isAdopted(it.name) } == branch.policies.size - 1) { // All done apart from branch completion adopt(branch.policies.last(), true) // add branch completion! } - } else { - UnCivGame.Current.screen = VictoryScreen() } when (policy.name) { @@ -69,7 +64,7 @@ class PolicyManager { city.cityConstructions.addCultureBuilding() "Free Religion" -> freePolicies++ "Liberty Complete" -> { - if (civInfo.isPlayerCivilization()) UnCivGame.Current.screen = GreatPersonPickerScreen() // screw the victory screen! + if (civInfo.isPlayerCivilization()) civInfo.greatPeople.freeGreatPeople++ else civInfo.addGreatPerson(GameBasics.Units.keys.filter { it.startsWith("Great") }.getRandom()) } } diff --git a/core/src/com/unciv/models/gamebasics/Building.kt b/core/src/com/unciv/models/gamebasics/Building.kt index f2119eeb..09d9a32b 100644 --- a/core/src/com/unciv/models/gamebasics/Building.kt +++ b/core/src/com/unciv/models/gamebasics/Building.kt @@ -1,12 +1,9 @@ package com.unciv.models.gamebasics -import com.unciv.UnCivGame import com.unciv.logic.city.CityConstructions import com.unciv.logic.city.IConstruction import com.unciv.models.stats.NamedStats import com.unciv.models.stats.Stats -import com.unciv.ui.VictoryScreen -import com.unciv.ui.pickerscreens.PolicyPickerScreen class Building : NamedStats(), IConstruction{ private var baseDescription: String? = null @@ -189,7 +186,6 @@ class Building : NamedStats(), IConstruction{ if (unique == "Spaceship part") { civInfo.scienceVictory.currentParts.add(name, 1) - UnCivGame.Current.screen = VictoryScreen() return } construction.builtBuildings.add(name) @@ -197,9 +193,6 @@ class Building : NamedStats(), IConstruction{ if (providesFreeBuilding != null && !construction.builtBuildings.contains(providesFreeBuilding!!)) construction.builtBuildings.add(providesFreeBuilding!!) when (unique) { - "Enables construction of Spaceship parts" -> - if(construction.cityInfo.civInfo.isPlayerCivilization()) - UnCivGame.Current.screen = VictoryScreen() "Empire enters golden age" -> civInfo.goldenAges.enterGoldenAge() "Free Great Artist Appears" -> civInfo.addGreatPerson("Great Artist") "Worker construction increased 25%, provides 2 free workers" -> { @@ -208,8 +201,6 @@ class Building : NamedStats(), IConstruction{ } "Free Social Policy" -> { civInfo.policies.freePolicies++ - if(construction.cityInfo.civInfo.isPlayerCivilization()) - UnCivGame.Current.screen = PolicyPickerScreen(civInfo) } } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 349fae95..7a85dd93 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -75,6 +75,9 @@ class WorldScreen : CameraStageBaseScreen() { notificationsScroll.width = stage.width/3 notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f, nextTurnButton.y - notificationsScroll.height - 5f) + + if(civInfo.policies.freePolicies>0) game.screen = PolicyPickerScreen(civInfo) + else if(civInfo.greatPeople.freeGreatPeople>0) game.screen = GreatPersonPickerScreen() } private fun updateTechButton() {