Added icon toggles to the world screen

This commit is contained in:
Yair Morgenstern
2018-09-05 17:51:24 +03:00
parent 68b64ca66f
commit c4838f5fde
3 changed files with 38 additions and 1 deletions

View File

@ -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)

View File

@ -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()

View File

@ -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<String>(CameraStageBaseScreen.skin)
val languageArray = com.badlogic.gdx.utils.Array<String>()
GameBasics.Translations.getLanguages().forEach { languageArray.add(it) }