mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Merge branch 'master' of https://github.com/yairm210/Unciv
This commit is contained in:
commit
6cc4db69b1
@ -3,10 +3,7 @@ package com.unciv.ui.worldscreen
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||||
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.*
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.models.metadata.GameSpeed
|
import com.unciv.models.metadata.GameSpeed
|
||||||
import com.unciv.models.ruleset.tile.ResourceType
|
import com.unciv.models.ruleset.tile.ResourceType
|
||||||
@ -24,7 +21,8 @@ import kotlin.math.roundToInt
|
|||||||
|
|
||||||
class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
||||||
|
|
||||||
private var selectedCivTable = Table()
|
private var selectedCivLabel = worldScreen.selectedCiv.civName.toLabel()
|
||||||
|
private var selectedCivIconHolder = Container<Actor>()
|
||||||
|
|
||||||
private val turnsLabel = "Turns: 0/400".toLabel()
|
private val turnsLabel = "Turns: 0/400".toLabel()
|
||||||
private val goldLabel = "Gold:".toLabel(colorFromRGB(225, 217, 71))
|
private val goldLabel = "Gold:".toLabel(colorFromRGB(225, 217, 71))
|
||||||
@ -51,7 +49,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
|||||||
pack()
|
pack()
|
||||||
addActor(getMenuButton()) // needs to be after pack
|
addActor(getMenuButton()) // needs to be after pack
|
||||||
|
|
||||||
addSelectedCivilizationTable()
|
addActor(getSelectedCivilizationTable())
|
||||||
|
|
||||||
addActor(getOverviewButton())
|
addActor(getOverviewButton())
|
||||||
}
|
}
|
||||||
@ -144,17 +142,29 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
|||||||
overviewButton.labelCell.pad(10f)
|
overviewButton.labelCell.pad(10f)
|
||||||
overviewButton.pack()
|
overviewButton.pack()
|
||||||
overviewButton.onClick { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.selectedCiv)) }
|
overviewButton.onClick { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.selectedCiv)) }
|
||||||
overviewButton.center(this)
|
overviewButton.centerY(this)
|
||||||
overviewButton.x = worldScreen.stage.width - overviewButton.width - 10
|
overviewButton.x = worldScreen.stage.width - overviewButton.width - 10
|
||||||
return overviewButton
|
return overviewButton
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addSelectedCivilizationTable() {
|
private fun getSelectedCivilizationTable(): Table {
|
||||||
|
val selectedCivTable = Table()
|
||||||
selectedCivTable.centerY(this)
|
selectedCivTable.centerY(this)
|
||||||
selectedCivTable.left()
|
selectedCivTable.left()
|
||||||
selectedCivTable.x = getMenuButton().width + 20f
|
selectedCivTable.x = getMenuButton().width + 20f
|
||||||
updateSelectedCivTabel()
|
|
||||||
addActor(selectedCivTable)
|
selectedCivLabel.setFontSize(25)
|
||||||
|
selectedCivLabel.onClick { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.selectedCiv)) }
|
||||||
|
|
||||||
|
val nation = worldScreen.gameInfo.ruleSet.nations[worldScreen.selectedCiv.civName]!!
|
||||||
|
val selectedCivIcon = ImageGetter.getNationIndicator(nation, 35f)
|
||||||
|
selectedCivIconHolder.actor = selectedCivIcon
|
||||||
|
selectedCivIconHolder.onClick { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.selectedCiv)) }
|
||||||
|
|
||||||
|
selectedCivTable.add(selectedCivLabel).padRight(10f)
|
||||||
|
selectedCivTable.add(selectedCivIconHolder)
|
||||||
|
return selectedCivTable
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun update(civInfo: CivilizationInfo) {
|
internal fun update(civInfo: CivilizationInfo) {
|
||||||
@ -199,17 +209,13 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSelectedCivTabel() {
|
private fun updateSelectedCivTabel() {
|
||||||
selectedCivTable.clear()
|
if (selectedCivLabel.text.toString() == worldScreen.selectedCiv.civName) return
|
||||||
|
|
||||||
val selectedCivLabel = worldScreen.selectedCiv.civName.toLabel()
|
selectedCivLabel.setText(worldScreen.selectedCiv.civName)
|
||||||
selectedCivLabel.setFontSize(25)
|
|
||||||
selectedCivLabel.onClick { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.selectedCiv)) }
|
|
||||||
selectedCivTable.add(selectedCivLabel).padRight(10f)
|
|
||||||
|
|
||||||
val nation = worldScreen.gameInfo.ruleSet.nations[worldScreen.selectedCiv.civName]!!
|
val nation = worldScreen.gameInfo.ruleSet.nations[worldScreen.selectedCiv.civName]!!
|
||||||
selectedCivTable.add(ImageGetter.getNationIndicator(nation, 35f).onClick {
|
val selectedCivIcon = ImageGetter.getNationIndicator(nation, 35f)
|
||||||
worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.selectedCiv))
|
selectedCivIconHolder.actor = selectedCivIcon
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCultureText(civInfo: CivilizationInfo, nextTurnStats: Stats): String {
|
private fun getCultureText(civInfo: CivilizationInfo, nextTurnStats: Stats): String {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user