mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-13 12:27:40 +07:00
Added display options, to show/hide worked tiles and resources/tile improvements
This commit is contained in:
parent
145c908af2
commit
431c5449f3
@ -6,14 +6,13 @@ import com.unciv.logic.GameInfo
|
|||||||
import com.unciv.logic.GameSaver
|
import com.unciv.logic.GameSaver
|
||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.ui.GameSettings
|
import com.unciv.ui.GameSettings
|
||||||
import com.unciv.ui.NewGameScreen
|
|
||||||
import com.unciv.ui.worldscreen.WorldScreen
|
import com.unciv.ui.worldscreen.WorldScreen
|
||||||
|
|
||||||
class UnCivGame : Game() {
|
class UnCivGame : Game() {
|
||||||
var gameInfo: GameInfo = GameInfo()
|
var gameInfo: GameInfo = GameInfo()
|
||||||
var settings = GameSettings()
|
var settings = GameSettings()
|
||||||
|
|
||||||
var worldScreen: WorldScreen? = null
|
lateinit var worldScreen: WorldScreen
|
||||||
|
|
||||||
override fun create() {
|
override fun create() {
|
||||||
GameBasics.run { } // just to initialize
|
GameBasics.run { } // just to initialize
|
||||||
@ -48,8 +47,8 @@ class UnCivGame : Game() {
|
|||||||
|
|
||||||
fun setWorldScreen() {
|
fun setWorldScreen() {
|
||||||
setScreen(worldScreen)
|
setScreen(worldScreen)
|
||||||
worldScreen!!.update()
|
worldScreen.update()
|
||||||
Gdx.input.inputProcessor = worldScreen!!.stage
|
Gdx.input.inputProcessor = worldScreen.stage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.logic
|
|||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.files.FileHandle
|
import com.badlogic.gdx.files.FileHandle
|
||||||
import com.badlogic.gdx.utils.Json
|
import com.badlogic.gdx.utils.Json
|
||||||
|
import com.unciv.ui.GameSettings
|
||||||
|
|
||||||
class GameSaver {
|
class GameSaver {
|
||||||
private val saveFilesFolder = "SaveFiles"
|
private val saveFilesFolder = "SaveFiles"
|
||||||
@ -28,4 +29,12 @@ class GameSaver {
|
|||||||
fun deleteSave(GameName: String){
|
fun deleteSave(GameName: String){
|
||||||
getSave(GameName).delete()
|
getSave(GameName).delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getGeneralSettings():GameSettings{
|
||||||
|
return Json().fromJson(GameSettings::class.java, Gdx.files.local("GameSettings.json"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setGeneralSettings(gameSettings: GameSettings){
|
||||||
|
Gdx.files.local("GameSettings.json").writeString(Json().toJson(gameSettings), false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,22 @@
|
|||||||
package com.unciv.ui
|
package com.unciv.ui
|
||||||
|
|
||||||
class GameSettings {
|
class GameSettings : LinkedHashMap<String, String>() {
|
||||||
var labelScale = 1.5f
|
|
||||||
var buttonScale = 0.9f
|
var showWorkedTiles:Boolean
|
||||||
var tilesZoom = 1f
|
get() {
|
||||||
var cityTilesX = 0f
|
if(this.containsKey("ShowWorkedTiles")) return get("ShowWorkedTiles")!!.toBoolean()
|
||||||
var cityTilesY = 0f
|
else return true
|
||||||
internal var worldScrollX = 0f
|
}
|
||||||
internal var worldScrollY = 0f
|
set(value) {
|
||||||
|
this["ShowWorkedTiles"]=value.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
var showResourcesAndImprovements:Boolean
|
||||||
|
get() {
|
||||||
|
if(this.containsKey("ShowResourcesAndImprovements")) return get("ShowResourcesAndImprovements")!!.toBoolean()
|
||||||
|
else return true
|
||||||
|
}
|
||||||
|
set(value) {
|
||||||
|
this["ShowResourcesAndImprovements"]=value.toString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
private var tileGroups = ArrayList<CityTileGroup>()
|
private var tileGroups = ArrayList<CityTileGroup>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
Label("", CameraStageBaseScreen.skin).style.font.data.setScale(game.settings.labelScale)
|
Label("", CameraStageBaseScreen.skin).style.font.data.setScale(1.5f)
|
||||||
|
|
||||||
addTiles()
|
addTiles()
|
||||||
stage.addActor(tileTable)
|
stage.addActor(tileTable)
|
||||||
@ -169,7 +169,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
goToWorldButton.clearListeners()
|
goToWorldButton.clearListeners()
|
||||||
goToWorldButton.addClickListener {
|
goToWorldButton.addClickListener {
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
game.worldScreen!!.tileMapHolder.setCenterPosition(city.location)
|
game.worldScreen.tileMapHolder.setCenterPosition(city.location)
|
||||||
dispose()
|
dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
val scrollPane = ScrollPane(allTiles)
|
val scrollPane = ScrollPane(allTiles)
|
||||||
scrollPane.setFillParent(true)
|
scrollPane.setFillParent(true)
|
||||||
scrollPane.setPosition(game.settings.cityTilesX, game.settings.cityTilesY)
|
scrollPane.setPosition(cityTilesX, cityTilesY)
|
||||||
scrollPane.setOrigin(stage.width / 2, stage.height / 2)
|
scrollPane.setOrigin(stage.width / 2, stage.height / 2)
|
||||||
scrollPane.addListener(object : ActorGestureListener() {
|
scrollPane.addListener(object : ActorGestureListener() {
|
||||||
var lastScale = 1f
|
var lastScale = 1f
|
||||||
@ -231,8 +231,8 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
override fun pan(event: InputEvent?, x: Float, y: Float, deltaX: Float, deltaY: Float) {
|
override fun pan(event: InputEvent?, x: Float, y: Float, deltaX: Float, deltaY: Float) {
|
||||||
scrollPane.moveBy(deltaX * scrollPane.scaleX, deltaY * scrollPane.scaleX)
|
scrollPane.moveBy(deltaX * scrollPane.scaleX, deltaY * scrollPane.scaleX)
|
||||||
game.settings.cityTilesX = scrollPane.x
|
cityTilesX = scrollPane.x
|
||||||
game.settings.cityTilesY = scrollPane.y
|
cityTilesY = scrollPane.y
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
stage.addActor(scrollPane)
|
stage.addActor(scrollPane)
|
||||||
@ -264,5 +264,9 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
tileTable.setPosition(stage.width - 10f - tileTable.width, 10f)
|
tileTable.setPosition(stage.width - 10f - tileTable.width, 10f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@Transient var cityTilesX = 0f
|
||||||
|
@Transient var cityTilesY = 0f
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import java.util.*
|
|||||||
class CityStatsTable(val cityScreen: CityScreen) : Table(){
|
class CityStatsTable(val cityScreen: CityScreen) : Table(){
|
||||||
fun update() {
|
fun update() {
|
||||||
val city = cityScreen.city
|
val city = cityScreen.city
|
||||||
val buttonScale = cityScreen.game.settings.buttonScale
|
val buttonScale = 0.9f
|
||||||
val stats = city.cityStats.currentCityStats
|
val stats = city.cityStats.currentCityStats
|
||||||
pad(20f)
|
pad(20f)
|
||||||
columnDefaults(0).padRight(10f)
|
columnDefaults(0).padRight(10f)
|
||||||
|
@ -29,7 +29,7 @@ open class PickerScreen : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
descriptionLabel = Label("", CameraStageBaseScreen.skin)
|
descriptionLabel = Label("", CameraStageBaseScreen.skin)
|
||||||
descriptionLabel.setWrap(true)
|
descriptionLabel.setWrap(true)
|
||||||
descriptionLabel.setFontScale(game.settings.labelScale)
|
descriptionLabel.setFontScale(1.5f)
|
||||||
val labelScroll = ScrollPane(descriptionLabel)
|
val labelScroll = ScrollPane(descriptionLabel)
|
||||||
bottomTable.add(labelScroll).pad(5f).width(stage.width / 2)
|
bottomTable.add(labelScroll).pad(5f).width(stage.width / 2)
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.scenes.scene2d.Group
|
import com.badlogic.gdx.scenes.scene2d.Group
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.logic.HexMath
|
import com.unciv.logic.HexMath
|
||||||
import com.unciv.logic.map.MapUnit
|
import com.unciv.logic.map.MapUnit
|
||||||
import com.unciv.logic.map.RoadStatus
|
import com.unciv.logic.map.RoadStatus
|
||||||
@ -25,7 +26,6 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
|
|
||||||
protected var resourceImage: Image? = null
|
protected var resourceImage: Image? = null
|
||||||
protected var improvementImage: Image? =null
|
protected var improvementImage: Image? =null
|
||||||
private var improvementType: String? = null
|
|
||||||
var populationImage: Image? = null
|
var populationImage: Image? = null
|
||||||
private val roadImages = HashMap<String, Image>()
|
private val roadImages = HashMap<String, Image>()
|
||||||
private val borderImages = ArrayList<Image>()
|
private val borderImages = ArrayList<Image>()
|
||||||
@ -78,9 +78,11 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected fun removePopulationIcon() {
|
protected fun removePopulationIcon() {
|
||||||
|
if(populationImage!=null) {
|
||||||
populationImage!!.remove()
|
populationImage!!.remove()
|
||||||
populationImage = null
|
populationImage = null
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
open fun update(isViewable: Boolean) {
|
open fun update(isViewable: Boolean) {
|
||||||
@ -97,6 +99,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
updateResourceImage(isViewable)
|
updateResourceImage(isViewable)
|
||||||
updateImprovementImage(isViewable)
|
updateImprovementImage(isViewable)
|
||||||
|
|
||||||
|
|
||||||
civilianUnitImage = newUnitImage(tileInfo.civilianUnit,civilianUnitImage,isViewable,-20f)
|
civilianUnitImage = newUnitImage(tileInfo.civilianUnit,civilianUnitImage,isViewable,-20f)
|
||||||
militaryUnitImage = newUnitImage(tileInfo.militaryUnit,militaryUnitImage,isViewable,20f)
|
militaryUnitImage = newUnitImage(tileInfo.militaryUnit,militaryUnitImage,isViewable,20f)
|
||||||
|
|
||||||
@ -188,7 +191,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
addActor(terrainFeatureImage)
|
addActor(terrainFeatureImage)
|
||||||
terrainFeatureImage!!.run {
|
terrainFeatureImage!!.run {
|
||||||
setSize(30f, 30f)
|
setSize(30f, 30f)
|
||||||
setColor(1f, 1f, 1f, 0.5f)
|
//setColor(1f, 1f, 1f, 0.5f)
|
||||||
center(this@TileGroup)
|
center(this@TileGroup)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +203,12 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateImprovementImage(viewable: Boolean) {
|
private fun updateImprovementImage(viewable: Boolean) {
|
||||||
if (tileInfo.improvement != null && tileInfo.improvement != improvementType) {
|
if(improvementImage!=null){
|
||||||
|
improvementImage!!.remove()
|
||||||
|
improvementImage=null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tileInfo.improvement != null && UnCivGame.Current.settings.showResourcesAndImprovements) {
|
||||||
improvementImage = ImageGetter.getImprovementIcon(tileInfo.improvement!!)
|
improvementImage = ImageGetter.getImprovementIcon(tileInfo.improvement!!)
|
||||||
addActor(improvementImage)
|
addActor(improvementImage)
|
||||||
improvementImage!!.run {
|
improvementImage!!.run {
|
||||||
@ -209,7 +217,6 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
this.x -= 22 // left
|
this.x -= 22 // left
|
||||||
this.y -= 10 // bottom
|
this.y -= 10 // bottom
|
||||||
}
|
}
|
||||||
improvementType = tileInfo.improvement
|
|
||||||
}
|
}
|
||||||
if(improvementImage!=null){
|
if(improvementImage!=null){
|
||||||
if(viewable) improvementImage!!.color= Color.WHITE
|
if(viewable) improvementImage!!.color= Color.WHITE
|
||||||
@ -218,7 +225,13 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateResourceImage(viewable: Boolean) {
|
private fun updateResourceImage(viewable: Boolean) {
|
||||||
if (tileInfo.hasViewableResource(tileInfo.tileMap.gameInfo.getPlayerCivilization()) && resourceImage == null) { // Need to add the resource image!
|
if(resourceImage!=null){
|
||||||
|
resourceImage!!.remove()
|
||||||
|
resourceImage=null
|
||||||
|
}
|
||||||
|
|
||||||
|
if(UnCivGame.Current.settings.showResourcesAndImprovements
|
||||||
|
&& tileInfo.hasViewableResource(tileInfo.tileMap.gameInfo.getPlayerCivilization())) { // Need to add the resource image!
|
||||||
val fileName = "ResourceIcons/" + tileInfo.resource + "_(Civ5).png"
|
val fileName = "ResourceIcons/" + tileInfo.resource + "_(Civ5).png"
|
||||||
resourceImage = ImageGetter.getImage(fileName)
|
resourceImage = ImageGetter.getImage(fileName)
|
||||||
resourceImage!!.setSize(20f, 20f)
|
resourceImage!!.setSize(20f, 20f)
|
||||||
|
@ -36,7 +36,10 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
|||||||
override fun update(isViewable: Boolean) {
|
override fun update(isViewable: Boolean) {
|
||||||
|
|
||||||
val city = tileInfo.getCity()
|
val city = tileInfo.getCity()
|
||||||
if (isViewable && tileInfo.isWorked() && city!!.civInfo.isPlayerCivilization() && populationImage == null)
|
|
||||||
|
removePopulationIcon()
|
||||||
|
if (isViewable && tileInfo.isWorked() && UnCivGame.Current.settings.showWorkedTiles
|
||||||
|
&& city!!.civInfo.isPlayerCivilization())
|
||||||
addPopulationIcon()
|
addPopulationIcon()
|
||||||
|
|
||||||
if (tileInfo.tileMap.gameInfo.getPlayerCivilization().exploredTiles.contains(tileInfo.position)
|
if (tileInfo.tileMap.gameInfo.getPlayerCivilization().exploredTiles.contains(tileInfo.position)
|
||||||
|
@ -17,7 +17,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
val tileMapHolder: TileMapHolder = TileMapHolder(this, gameInfo.tileMap, civInfo)
|
val tileMapHolder: TileMapHolder = TileMapHolder(this, gameInfo.tileMap, civInfo)
|
||||||
|
|
||||||
internal var buttonScale = game.settings.buttonScale
|
internal var buttonScale = 0.9f
|
||||||
private val topBar = WorldScreenTopBar(this)
|
private val topBar = WorldScreenTopBar(this)
|
||||||
val bottomBar = WorldScreenBottomBar(this)
|
val bottomBar = WorldScreenBottomBar(this)
|
||||||
val unitActionsTable = UnitActionsTable(this)
|
val unitActionsTable = UnitActionsTable(this)
|
||||||
@ -25,7 +25,6 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
private val techButton = TextButton("", CameraStageBaseScreen.skin)
|
private val techButton = TextButton("", CameraStageBaseScreen.skin)
|
||||||
private val nextTurnButton = createNextTurnButton()
|
private val nextTurnButton = createNextTurnButton()
|
||||||
|
|
||||||
internal val optionsTable: WorldScreenOptionsTable
|
|
||||||
private val notificationsScroll: NotificationsScroll
|
private val notificationsScroll: NotificationsScroll
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -36,8 +35,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
topBar.y - nextTurnButton.height - 10f)
|
topBar.y - nextTurnButton.height - 10f)
|
||||||
notificationsScroll = NotificationsScroll(gameInfo.notifications, this)
|
notificationsScroll = NotificationsScroll(gameInfo.notifications, this)
|
||||||
notificationsScroll.width = stage.width/3
|
notificationsScroll.width = stage.width/3
|
||||||
optionsTable = WorldScreenOptionsTable(this, civInfo)
|
Label("", skin).style.font.data.setScale(1.5f)
|
||||||
Label("", CameraStageBaseScreen.skin).style.font.data.setScale(game.settings.labelScale)
|
|
||||||
|
|
||||||
|
|
||||||
tileMapHolder.addTiles()
|
tileMapHolder.addTiles()
|
||||||
@ -56,7 +54,6 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
tileMapHolder.setCenterPosition(Vector2.Zero)
|
tileMapHolder.setCenterPosition(Vector2.Zero)
|
||||||
createNextTurnButton() // needs civ table to be positioned
|
createNextTurnButton() // needs civ table to be positioned
|
||||||
stage.addActor(optionsTable)
|
|
||||||
displayTutorials("NewGame")
|
displayTutorials("NewGame")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,68 +3,88 @@ package com.unciv.ui.worldscreen
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.ui.*
|
import com.unciv.ui.LoadScreen
|
||||||
|
import com.unciv.ui.NewGameScreen
|
||||||
|
import com.unciv.ui.SaveScreen
|
||||||
|
import com.unciv.ui.VictoryScreen
|
||||||
import com.unciv.ui.cityscreen.addClickListener
|
import com.unciv.ui.cityscreen.addClickListener
|
||||||
import com.unciv.ui.pickerscreens.PolicyPickerScreen
|
import com.unciv.ui.pickerscreens.PolicyPickerScreen
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
import com.unciv.ui.utils.center
|
import com.unciv.ui.utils.center
|
||||||
|
|
||||||
class WorldScreenOptionsTable internal constructor(worldScreen: WorldScreen, private val civInfo: CivilizationInfo) : Table() {
|
class WorldScreenOptionsTable internal constructor() : OptionsTable() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
addButton("Load game"){
|
||||||
|
UnCivGame.Current.screen = LoadScreen()
|
||||||
|
remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
addButton("Save game") {
|
||||||
|
UnCivGame.Current.screen = SaveScreen()
|
||||||
|
remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
addButton("Start new game"){ UnCivGame.Current.screen = NewGameScreen() }
|
||||||
|
|
||||||
|
addButton("Victory status") { UnCivGame.Current.screen = VictoryScreen() }
|
||||||
|
|
||||||
|
addButton("Social Policies"){
|
||||||
|
UnCivGame.Current.screen = PolicyPickerScreen(UnCivGame.Current.gameInfo.getPlayerCivilization())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
addButton("Display options"){
|
||||||
|
UnCivGame.Current.worldScreen.stage.addActor(WorldScreenDisplayOptionsTable())
|
||||||
|
remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
addButton("Close"){ remove() }
|
||||||
|
|
||||||
|
pack() // Needed to show the background.
|
||||||
|
center(UnCivGame.Current.worldScreen.stage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class OptionsTable:Table(){
|
||||||
init {
|
init {
|
||||||
val tileTableBackground = ImageGetter.getDrawable("skin/whiteDot.png")
|
val tileTableBackground = ImageGetter.getDrawable("skin/whiteDot.png")
|
||||||
.tint(Color(0x004085bf))
|
.tint(Color(0x004085bf))
|
||||||
background = tileTableBackground
|
background = tileTableBackground
|
||||||
isVisible = false
|
|
||||||
|
|
||||||
pad(20f)
|
this.pad(20f)
|
||||||
defaults().pad(5f)
|
this.defaults().pad(5f)
|
||||||
|
|
||||||
val openCivilopediaButton = TextButton("Civilopedia", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue(); background=null }
|
|
||||||
openCivilopediaButton.addClickListener {
|
|
||||||
worldScreen.game.screen = CivilopediaScreen()
|
|
||||||
isVisible = false
|
|
||||||
}
|
}
|
||||||
add(openCivilopediaButton).row()
|
|
||||||
|
|
||||||
val loadGameButton = TextButton("Load game", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
fun addButton(text:String, action:()->Unit){
|
||||||
loadGameButton .addClickListener {
|
val button = TextButton(text, CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
||||||
worldScreen.game.screen = LoadScreen()
|
button.addClickListener(action)
|
||||||
isVisible=false
|
add(button).row()
|
||||||
}
|
}
|
||||||
add(loadGameButton ).row()
|
}
|
||||||
|
|
||||||
|
class WorldScreenDisplayOptionsTable() : OptionsTable(){
|
||||||
val saveGameButton = TextButton("Save game", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
init {
|
||||||
saveGameButton .addClickListener {
|
update()
|
||||||
worldScreen.game.screen = SaveScreen()
|
}
|
||||||
isVisible=false
|
|
||||||
}
|
fun update(){
|
||||||
add(saveGameButton ).row()
|
clear()
|
||||||
|
val tileMapHolder=UnCivGame.Current.worldScreen.tileMapHolder
|
||||||
val startNewGameButton = TextButton("Start new game", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
val settings = UnCivGame.Current.settings
|
||||||
startNewGameButton.addClickListener { worldScreen.game.screen = NewGameScreen() }
|
if(settings.showWorkedTiles) addButton("Hide worked tiles") {settings.showWorkedTiles=false; update()}
|
||||||
add(startNewGameButton).row()
|
else addButton("Show worked tiles") {settings.showWorkedTiles=true; update()}
|
||||||
|
|
||||||
val openVictoryScreen = TextButton("Victory status", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
if(settings.showResourcesAndImprovements)
|
||||||
openVictoryScreen.addClickListener {
|
addButton("Hide resources and improvements") {settings.showResourcesAndImprovements=false; update()}
|
||||||
worldScreen.game.screen = VictoryScreen()
|
else addButton("Show resources and improvements") {settings.showResourcesAndImprovements=true; update()}
|
||||||
}
|
|
||||||
add(openVictoryScreen).row()
|
addButton("Close"){ remove() }
|
||||||
|
|
||||||
val openPolicyPickerScreen = TextButton("Social Policies", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
pack() // Needed to show the background.
|
||||||
openPolicyPickerScreen.addClickListener {
|
center(UnCivGame.Current.worldScreen.stage)
|
||||||
worldScreen.game.screen = PolicyPickerScreen(this@WorldScreenOptionsTable.civInfo)
|
tileMapHolder.updateTiles()
|
||||||
}
|
|
||||||
add(openPolicyPickerScreen).row()
|
|
||||||
|
|
||||||
val closeButton = TextButton("Close", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
|
||||||
closeButton.addClickListener { isVisible = false }
|
|
||||||
add(closeButton)
|
|
||||||
|
|
||||||
pack() // Needed to show the background.
|
|
||||||
center(worldScreen.stage)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -79,7 +79,7 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() {
|
|||||||
.apply { setSize(50f, 50f) }
|
.apply { setSize(50f, 50f) }
|
||||||
menuButton.color = Color.WHITE
|
menuButton.color = Color.WHITE
|
||||||
menuButton.addClickListener {
|
menuButton.addClickListener {
|
||||||
screen.optionsTable.isVisible = !screen.optionsTable.isVisible
|
screen.stage.addActor(WorldScreenOptionsTable())
|
||||||
}
|
}
|
||||||
menuButton.centerY(this)
|
menuButton.centerY(this)
|
||||||
menuButton.x = menuButton.y
|
menuButton.x = menuButton.y
|
||||||
|
Loading…
Reference in New Issue
Block a user