From c4838f5fded765591cad4224c90df6d49846d2c2 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 5 Sep 2018 17:51:24 +0300 Subject: [PATCH] Added icon toggles to the world screen --- .../ui/worldscreen/bottombar/TileInfoTable.kt | 33 +++++++++++++++++++ .../bottombar/WorldScreenBottomBar.kt | 3 +- .../WorldScreenDisplayOptionsTable.kt | 3 ++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt index 5ad95b48c8..7f3fdefae5 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt @@ -1,7 +1,10 @@ package com.unciv.ui.worldscreen.bottombar +import com.badlogic.gdx.scenes.scene2d.Actor +import com.badlogic.gdx.scenes.scene2d.ui.CheckBox import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Table +import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener import com.badlogic.gdx.utils.Align import com.unciv.UnCivGame import com.unciv.logic.map.TileInfo @@ -19,6 +22,7 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table() { val civInfo = worldScreen.civInfo columnDefaults(0).padRight(10f) + add(getCheckboxTable()) if (civInfo.exploredTiles.contains(tile.position) || UnCivGame.Current.viewEntireMapForDebug) { add(getStatsTable(tile)).pad(10f) add(Label(tile.toString(), skin)).colspan(2) @@ -29,6 +33,35 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table() { setPosition(worldScreen.stage.width - 10f - width, 10f) } + fun getCheckboxTable(): Table { + val settings = UnCivGame.Current.settings + val table=Table() + + val populationCheckbox = CheckBox("",CameraStageBaseScreen.skin) + populationCheckbox.add(ImageGetter.getStatIcon("Population")).size(20f) + populationCheckbox.isChecked = settings.showWorkedTiles + populationCheckbox.addListener(object : ChangeListener(){ + override fun changed(event: ChangeEvent?, actor: Actor?) { + settings.showWorkedTiles = populationCheckbox.isChecked + worldScreen.update() + } + }) + table.add(populationCheckbox).row() + + val resourceCheckbox = CheckBox("",CameraStageBaseScreen.skin) + resourceCheckbox.add(ImageGetter.getResourceImage("Cattle",20f)) + resourceCheckbox.isChecked = settings.showResourcesAndImprovements + resourceCheckbox.addListener(object : ChangeListener(){ + override fun changed(event: ChangeEvent?, actor: Actor?) { + settings.showResourcesAndImprovements = resourceCheckbox.isChecked + worldScreen.update() + } + }) + table.add(resourceCheckbox).row() + + return table + } + fun getStatsTable(tile: TileInfo):Table{ val table=Table() table.pad(10f) diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/WorldScreenBottomBar.kt b/core/src/com/unciv/ui/worldscreen/bottombar/WorldScreenBottomBar.kt index 18dfff4d32..8dddc107d5 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/WorldScreenBottomBar.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/WorldScreenBottomBar.kt @@ -1,6 +1,7 @@ package com.unciv.ui.worldscreen.bottombar import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.scenes.scene2d.Touchable import com.badlogic.gdx.scenes.scene2d.ui.Table import com.unciv.logic.map.TileInfo import com.unciv.ui.utils.ImageGetter @@ -13,7 +14,7 @@ class WorldScreenBottomBar(val worldScreen: WorldScreen) : Table(){ val tileInfoTable = TileInfoTable(worldScreen) init { - + touchable= Touchable.enabled add(unitTable).width(worldScreen.stage.width/3) add(battleTable).width(worldScreen.stage.width/3).fill() // so that background fills entire middle third add(tileInfoTable).width(worldScreen.stage.width/3).fill() diff --git a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenDisplayOptionsTable.kt b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenDisplayOptionsTable.kt index 0fec905642..d63723781c 100644 --- a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenDisplayOptionsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenDisplayOptionsTable.kt @@ -1,11 +1,13 @@ package com.unciv.ui.worldscreen.optionstable import com.badlogic.gdx.scenes.scene2d.Actor +import com.badlogic.gdx.scenes.scene2d.ui.CheckBox import com.badlogic.gdx.scenes.scene2d.ui.SelectBox import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener import com.unciv.UnCivGame import com.unciv.models.gamebasics.GameBasics import com.unciv.ui.utils.CameraStageBaseScreen +import com.unciv.ui.utils.ImageGetter import com.unciv.ui.utils.center import com.unciv.ui.worldscreen.WorldScreen @@ -26,6 +28,7 @@ class WorldScreenDisplayOptionsTable() : PopupTable(){ addButton("{Hide} {resources and improvements}") { settings.showResourcesAndImprovements = false; update() } else addButton("{Show} {resources and improvements}") { settings.showResourcesAndImprovements = true; update() } + val languageSelectBox = SelectBox(CameraStageBaseScreen.skin) val languageArray = com.badlogic.gdx.utils.Array() GameBasics.Translations.getLanguages().forEach { languageArray.add(it) }