diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index bce8d52e09..6ade6ad7c1 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -160,7 +160,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() { // Borders if(tileInfo.owner!=null){ - for(border in borderImages) border.remove() + for (border in borderImages) border.remove() for (neighbor in tileInfo.neighbors.filter { it.owner!=tileInfo.owner }){ val image = ImageGetter.getImage(ImageGetter.WhiteDot) diff --git a/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt b/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt index 41966a708b..918371ec7b 100644 --- a/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt @@ -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) } diff --git a/core/src/com/unciv/ui/worldscreen/CivStatsTable.kt b/core/src/com/unciv/ui/worldscreen/CivStatsTable.kt index 85b572431c..4349177d88 100644 --- a/core/src/com/unciv/ui/worldscreen/CivStatsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/CivStatsTable.kt @@ -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) } } \ No newline at end of file diff --git a/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt b/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt index b097313898..0cfaa4df1c 100644 --- a/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt +++ b/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt @@ -39,8 +39,6 @@ class NotificationsScroll(private val notifications: List, interna } notificationsTable.pack() - setSize(worldScreen.stage.width / 3, - Math.min(notificationsTable.height, worldScreen.stage.height / 3)) } } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 3cfb3c946c..ac6feaa3b8 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -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) { diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt index 9cf6b7b277..cf66484d8f 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt @@ -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) {