From c12906f63ba5e432391665f3ab349830aa6755d6 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 3 Dec 2018 17:42:41 +0200 Subject: [PATCH] Removed old StatExplainer code --- .../src/com/unciv/ui/cityscreen/CityScreen.kt | 40 +------------------ .../pickerscreens/GreatPersonPickerScreen.kt | 7 ++-- 2 files changed, 4 insertions(+), 43 deletions(-) diff --git a/core/src/com/unciv/ui/cityscreen/CityScreen.kt b/core/src/com/unciv/ui/cityscreen/CityScreen.kt index 380d94152f..993ef08d40 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreen.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreen.kt @@ -9,7 +9,6 @@ import com.unciv.UnCivGame import com.unciv.logic.HexMath import com.unciv.logic.city.CityInfo import com.unciv.logic.map.TileInfo -import com.unciv.models.stats.Stats import com.unciv.ui.utils.* import java.util.* @@ -19,7 +18,6 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { private var tileTable = Table() private var buildingsTable = BuildingsTable(this) private var cityStatsTable = CityStatsTable(this) - private var statExplainer = Table(skin) private var cityPickerTable = Table() private var goToWorldButton = TextButton("Exit city".tr(), CameraStageBaseScreen.skin) private var tileGroups = ArrayList() @@ -58,47 +56,11 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { buildingsTable.update() updateCityPickerTable() cityStatsTable.update() - updateStatExplainer() updateGoToWorldButton() updateTileTable() updateTileGroups() } - private fun updateStatExplainer() { - statExplainer.defaults().pad(5f) - statExplainer.clear() - statExplainer.add() - statExplainer.add("Production") - statExplainer.add("Food") - statExplainer.add("Science") - statExplainer.add("Gold") - statExplainer.add("Culture") - statExplainer.add("Happiness") - - val unifiedStatList = LinkedHashMap(city.cityStats.baseStatList) - for(entry in city.cityStats.happinessList.filter { it.value!=0f }){ - if(!unifiedStatList.containsKey(entry.key)) unifiedStatList[entry.key]= Stats() - unifiedStatList[entry.key]!!.happiness=entry.value - } - - for (entry in unifiedStatList){ - if(entry.value.toHashMap().values.all { it==0f }) continue //irrelevant! - statExplainer.row() - statExplainer.add(entry.key) - statExplainer.add(entry.value.production.toInt().toString()) - statExplainer.add(entry.value.food.toInt().toString()) - statExplainer.add(entry.value.science.toInt().toString()) - statExplainer.add(entry.value.gold.toInt().toString()) - statExplainer.add(entry.value.culture.toInt().toString()) - statExplainer.add(entry.value.happiness.toInt().toString()) - } - statExplainer.pack() - statExplainer.isTransform=true - statExplainer.setScale(0.8f) - statExplainer.setPosition(5f,cityStatsTable.top + 10) - } - - private fun updateTileGroups() { val nextTile = city.expansion.chooseNewTileToOwn() for (tileGroup in tileGroups) { @@ -231,7 +193,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { scrollPane.setOrigin(stage.width / 2, stage.height / 2) scrollPane.addListener(object : ActorGestureListener() { var lastScale = 1f - internal var lastInitialDistance = 0f + var lastInitialDistance = 0f override fun zoom(event: InputEvent?, initialDistance: Float, distance: Float) { if (lastInitialDistance != initialDistance) { diff --git a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt index 58ad4166ed..c6a06698f0 100644 --- a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.ui.Button import com.badlogic.gdx.scenes.scene2d.ui.Label import com.unciv.UnCivGame +import com.unciv.logic.civilization.GreatPersonManager import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.unit.BaseUnit import com.unciv.ui.utils.ImageGetter @@ -16,10 +17,8 @@ class GreatPersonPickerScreen : PickerScreen() { init { closeButton.isVisible=false rightSideButton.setText("Choose a free great person") - for (unit in GameBasics.Units.values.filter { it.name.startsWith("Great Scientist") - || it.name.startsWith("Great Artist") - || it.name.startsWith("Great Engineer") - || it.name.startsWith("Great Merchant") }) + for (unit in GameBasics.Units.values + .filter { it.name in GreatPersonManager().statToGreatPersonMapping.values}) { val button = Button(skin)