mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 10:54:19 -04:00
Changed placement of notifications and unit commands in world screen for an unobstructed central view
This commit is contained in:
parent
c8c1ecc4da
commit
3959706ab9
@ -16,7 +16,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||
tileInfo.explored = true
|
||||
update()
|
||||
} else
|
||||
setColor(0f, 0f, 0f, 0.5f)
|
||||
setColor(0f, 0f, 0f, 0.6f)
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,59 +9,70 @@ import com.unciv.ui.cityscreen.addClickListener
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
|
||||
class CivStatsTable internal constructor() : Table() {
|
||||
init {
|
||||
class CivStatsTable : Table {
|
||||
|
||||
private val turnsLabel = Label("Turns: 0/400", CameraStageBaseScreen.skin)
|
||||
private val goldLabel = Label("Gold:",CameraStageBaseScreen.skin)
|
||||
private val scienceLabel = Label("Science:",CameraStageBaseScreen.skin)
|
||||
private val happinessLabel = Label("Happiness:",CameraStageBaseScreen.skin)
|
||||
private val cultureLabel = Label("Culture:",CameraStageBaseScreen.skin)
|
||||
|
||||
|
||||
internal constructor(screen: WorldScreen){
|
||||
val civBackground = ImageGetter.getDrawable("skin/civTableBackground.png")
|
||||
background = civBackground.tint(Color(0x004085bf))
|
||||
}
|
||||
|
||||
internal fun update(screen: WorldScreen) {
|
||||
val civInfo = screen.civInfo
|
||||
val skin = CameraStageBaseScreen.skin
|
||||
clear()
|
||||
row().pad(15f)
|
||||
|
||||
val civilopediaButton = TextButton("Menu", skin)
|
||||
civilopediaButton.addClickListener {
|
||||
screen.optionsTable.isVisible = !screen.optionsTable.isVisible
|
||||
}
|
||||
|
||||
|
||||
civilopediaButton.label.setFontScale(screen.buttonScale)
|
||||
add(civilopediaButton)
|
||||
.size(civilopediaButton.width * screen.buttonScale, civilopediaButton.height * screen.buttonScale)
|
||||
|
||||
add(Label("Turns: " + civInfo.gameInfo.turns + "/400", skin))
|
||||
|
||||
val nextTurnStats = civInfo.getStatsForNextTurn()
|
||||
|
||||
add(Label("Gold: " + Math.round(civInfo.gold.toFloat())
|
||||
+ "(" + (if (nextTurnStats.gold > 0) "+" else "") + Math.round(nextTurnStats.gold) + ")", skin))
|
||||
|
||||
val scienceLabel = Label("Science: +" + Math.round(nextTurnStats.science)
|
||||
+ "\r\n" + civInfo.tech.getAmountResearchedText(), skin)
|
||||
addCivilopediaButton(screen)
|
||||
add(turnsLabel)
|
||||
add(goldLabel)
|
||||
scienceLabel.setAlignment(Align.center)
|
||||
add(scienceLabel)
|
||||
var happinessText = "Happiness: " + civInfo.happiness
|
||||
if (civInfo.goldenAges.isGoldenAge())
|
||||
happinessText += "\r\n GOLDEN AGE (" + civInfo.goldenAges.turnsLeftForCurrentGoldenAge + ")"
|
||||
else
|
||||
happinessText += ("\r\n (" + civInfo.goldenAges.storedHappiness + "/"
|
||||
+ civInfo.goldenAges.happinessRequiredForNextGoldenAge() + ")")
|
||||
val happinessLabel = Label(happinessText, skin)
|
||||
happinessLabel.setAlignment(Align.center)
|
||||
add(happinessLabel)
|
||||
val cultureString = ("Culture: " + "+" + Math.round(nextTurnStats.culture) + "\r\n"
|
||||
+ "(" + civInfo.policies.storedCulture + "/" + civInfo.policies.getCultureNeededForNextPolicy() + ")")
|
||||
val cultureLabel = Label(cultureString, skin)
|
||||
cultureLabel.setAlignment(Align.center)
|
||||
add(cultureLabel)
|
||||
|
||||
pack()
|
||||
|
||||
setPosition(10f, screen.stage.height - 10f - height)
|
||||
width = screen.stage.width - 20
|
||||
}
|
||||
|
||||
internal fun addCivilopediaButton(screen: WorldScreen){
|
||||
row().pad(15f)
|
||||
val civilopediaButton = TextButton("Menu", CameraStageBaseScreen.skin)
|
||||
civilopediaButton.addClickListener {
|
||||
screen.optionsTable.isVisible = !screen.optionsTable.isVisible
|
||||
}
|
||||
civilopediaButton.label.setFontScale(screen.buttonScale)
|
||||
add(civilopediaButton)
|
||||
.size(civilopediaButton.width * screen.buttonScale, civilopediaButton.height * screen.buttonScale)
|
||||
}
|
||||
|
||||
|
||||
internal fun update(screen: WorldScreen) {
|
||||
val civInfo = screen.civInfo
|
||||
|
||||
turnsLabel.setText("Turns: " + civInfo.gameInfo.turns + "/400")
|
||||
|
||||
val nextTurnStats = civInfo.getStatsForNextTurn()
|
||||
|
||||
val goldPerTurn = "(" + (if (nextTurnStats.gold > 0) "+" else "") + Math.round(nextTurnStats.gold) + ")"
|
||||
goldLabel.setText("Gold: " + Math.round(civInfo.gold.toFloat()) + goldPerTurn)
|
||||
|
||||
scienceLabel.setText("Science: +" + Math.round(nextTurnStats.science)
|
||||
+ "\r\n" + civInfo.tech.getAmountResearchedText())
|
||||
|
||||
var happinessText = "Happiness: " + civInfo.happiness+"\r\n"
|
||||
if (civInfo.goldenAges.isGoldenAge())
|
||||
happinessText += "GOLDEN AGE (${civInfo.goldenAges.turnsLeftForCurrentGoldenAge})"
|
||||
else
|
||||
happinessText += ("(" + civInfo.goldenAges.storedHappiness + "/"
|
||||
+ civInfo.goldenAges.happinessRequiredForNextGoldenAge() + ")")
|
||||
|
||||
happinessLabel.setText(happinessText)
|
||||
|
||||
val cultureString = "Culture: " + "+" + Math.round(nextTurnStats.culture) + "\r\n" +
|
||||
"(" + civInfo.policies.storedCulture + "/" + civInfo.policies.getCultureNeededForNextPolicy() + ")"
|
||||
|
||||
cultureLabel.setText(cultureString)
|
||||
}
|
||||
|
||||
}
|
@ -39,8 +39,6 @@ class NotificationsScroll(private val notifications: List<Notification>, interna
|
||||
}
|
||||
notificationsTable.pack()
|
||||
|
||||
setSize(worldScreen.stage.width / 3,
|
||||
Math.min(notificationsTable.height, worldScreen.stage.height / 3))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,9 +18,9 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
|
||||
internal var buttonScale = game.settings.buttonScale
|
||||
private val tileInfoTable: TileInfoTable
|
||||
private val civTable = CivStatsTable()
|
||||
private val civTable = CivStatsTable(this)
|
||||
private val techButton = TextButton("", CameraStageBaseScreen.skin)
|
||||
|
||||
private val nextTurnButton = createNextTurnButton()
|
||||
|
||||
internal val optionsTable: WorldScreenOptionsTable
|
||||
private val notificationsScroll: NotificationsScroll
|
||||
@ -29,19 +29,30 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
init {
|
||||
val gameInfo = game.gameInfo
|
||||
this.civInfo = gameInfo.getPlayerCivilization()
|
||||
|
||||
unitTable.setPosition(5f, 5f)
|
||||
tileMapHolder = TileMapHolder(this, gameInfo.tileMap, civInfo)
|
||||
tileInfoTable = TileInfoTable(this, civInfo)
|
||||
civTable.setPosition(10f, stage.height - civTable.height - 10f )
|
||||
nextTurnButton.setPosition(stage.width - nextTurnButton.width - 10f,
|
||||
civTable.y - nextTurnButton.height - 10f)
|
||||
notificationsScroll = NotificationsScroll(gameInfo.notifications, this)
|
||||
notificationsScroll.setSize(stage.width/3,stage.height/4)
|
||||
notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f,
|
||||
nextTurnButton.y - notificationsScroll.height - 5f)
|
||||
optionsTable = WorldScreenOptionsTable(this, civInfo)
|
||||
Label("", CameraStageBaseScreen.skin).style.font.data.setScale(game.settings.labelScale)
|
||||
|
||||
tileMapHolder.addTiles()
|
||||
|
||||
stage.addActor(tileMapHolder)
|
||||
stage.addActor(tileInfoTable)
|
||||
stage.addActor(civTable)
|
||||
stage.addActor(nextTurnButton)
|
||||
stage.addActor(techButton)
|
||||
stage.addActor(notificationsScroll)
|
||||
stage.addActor(unitTable)
|
||||
|
||||
update()
|
||||
|
||||
tileMapHolder.setCenterPosition(Vector2.Zero)
|
||||
@ -81,7 +92,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
techButton.setPosition(10f, civTable.y - techButton.height - 5f)
|
||||
}
|
||||
|
||||
private fun createNextTurnButton() {
|
||||
private fun createNextTurnButton(): TextButton {
|
||||
val nextTurnButton = TextButton("Next turn", CameraStageBaseScreen.skin)
|
||||
nextTurnButton.addClickListener {
|
||||
if (civInfo.tech.freeTechs != 0) {
|
||||
@ -105,9 +116,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
displayTutorials("NextTurn")
|
||||
}
|
||||
|
||||
nextTurnButton.setPosition(stage.width - nextTurnButton.width - 10f,
|
||||
civTable.y - nextTurnButton.height - 10f)
|
||||
stage.addActor(nextTurnButton)
|
||||
return nextTurnButton
|
||||
}
|
||||
|
||||
override fun resize(width: Int, height: Int) {
|
||||
|
@ -50,7 +50,6 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
unitActionsTable.pack()
|
||||
pack()
|
||||
|
||||
setPosition(worldScreen.stage.width / 2 - width / 2, 5f)
|
||||
}
|
||||
|
||||
fun tileSelected(selectedTile: TileInfo) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user