mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-04 16:11:46 +07:00
More rankings & demographics screen icons (#7063)
* Add icons to demographics/rankings screen * Unused import * Some simplification * Reviews * Undelete atlas
This commit is contained in:
parent
e91c0ff212
commit
1312140793
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,19 @@
|
|||||||
package com.unciv.ui.victoryscreen
|
package com.unciv.ui.victoryscreen
|
||||||
|
|
||||||
enum class RankingType {
|
import com.badlogic.gdx.graphics.Color
|
||||||
Score,
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
Population,
|
import com.unciv.ui.images.ImageGetter
|
||||||
Crop_Yield,
|
|
||||||
Production,
|
enum class RankingType(val getImage: ()->Image?) {
|
||||||
Gold,
|
// production, gold, happiness, and culture already have icons added when the line is `tr()`anslated
|
||||||
Territory,
|
Score({ ImageGetter.getImage("OtherIcons/Cultured").apply { color = Color.FIREBRICK } }),
|
||||||
Force,
|
Population({ ImageGetter.getStatIcon("Population") }),
|
||||||
Happiness,
|
Crop_Yield({ ImageGetter.getStatIcon("Food") }),
|
||||||
Technologies,
|
Production({ null }),
|
||||||
Culture
|
Gold({ null }),
|
||||||
}
|
Territory({ ImageGetter.getImage("OtherIcons/Hexagon") }),
|
||||||
|
Force({ ImageGetter.getImage("OtherIcons/Shield") }),
|
||||||
|
Happiness({ null }),
|
||||||
|
Technologies({ ImageGetter.getStatIcon("Science") }),
|
||||||
|
Culture({ null })
|
||||||
|
}
|
||||||
|
@ -80,7 +80,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||||||
hasWon -> playerCivInfo.gameInfo.ruleSet.victories[victoryType]!!.victoryString
|
hasWon -> playerCivInfo.gameInfo.ruleSet.victories[victoryType]!!.victoryString
|
||||||
else -> playerCivInfo.gameInfo.ruleSet.victories[victoryType]!!.defeatString
|
else -> playerCivInfo.gameInfo.ruleSet.victories[victoryType]!!.defeatString
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptionLabel.setText(description.tr() + "\n" + endGameMessage.tr())
|
descriptionLabel.setText(description.tr() + "\n" + endGameMessage.tr())
|
||||||
|
|
||||||
rightSideButton.setText("Start new game".tr())
|
rightSideButton.setText("Start new game".tr())
|
||||||
@ -103,21 +103,21 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||||||
val ourVictoryStatusTable = Table()
|
val ourVictoryStatusTable = Table()
|
||||||
ourVictoryStatusTable.defaults().pad(10f)
|
ourVictoryStatusTable.defaults().pad(10f)
|
||||||
val victoriesToShow = gameInfo.getEnabledVictories()
|
val victoriesToShow = gameInfo.getEnabledVictories()
|
||||||
|
|
||||||
for (victory in victoriesToShow) {
|
for (victory in victoriesToShow) {
|
||||||
ourVictoryStatusTable.add("[${victory.key}] Victory".toLabel())
|
ourVictoryStatusTable.add("[${victory.key}] Victory".toLabel())
|
||||||
}
|
}
|
||||||
ourVictoryStatusTable.row()
|
ourVictoryStatusTable.row()
|
||||||
|
|
||||||
for (victory in victoriesToShow) {
|
for (victory in victoriesToShow) {
|
||||||
ourVictoryStatusTable.add(getOurVictoryColumn(victory.key))
|
ourVictoryStatusTable.add(getOurVictoryColumn(victory.key))
|
||||||
}
|
}
|
||||||
ourVictoryStatusTable.row()
|
ourVictoryStatusTable.row()
|
||||||
|
|
||||||
for (victory in victoriesToShow) {
|
for (victory in victoriesToShow) {
|
||||||
ourVictoryStatusTable.add(victory.value.victoryScreenHeader.toLabel())
|
ourVictoryStatusTable.add(victory.value.victoryScreenHeader.toLabel())
|
||||||
}
|
}
|
||||||
|
|
||||||
contentsTable.clear()
|
contentsTable.clear()
|
||||||
contentsTable.add(ourVictoryStatusTable)
|
contentsTable.add(ourVictoryStatusTable)
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||||||
val majorCivs = gameInfo.civilizations.filter { it.isMajorCiv() }
|
val majorCivs = gameInfo.civilizations.filter { it.isMajorCiv() }
|
||||||
val globalVictoryTable = Table().apply { defaults().pad(10f) }
|
val globalVictoryTable = Table().apply { defaults().pad(10f) }
|
||||||
val victoriesToShow = gameInfo.ruleSet.victories.filter { !it.value.hiddenInVictoryScreen && enabledVictoryTypes.contains(it.key) }
|
val victoriesToShow = gameInfo.ruleSet.victories.filter { !it.value.hiddenInVictoryScreen && enabledVictoryTypes.contains(it.key) }
|
||||||
|
|
||||||
for (victory in victoriesToShow) {
|
for (victory in victoriesToShow) {
|
||||||
globalVictoryTable.add(getGlobalVictoryColumn(majorCivs, victory.key))
|
globalVictoryTable.add(getGlobalVictoryColumn(majorCivs, victory.key))
|
||||||
}
|
}
|
||||||
@ -156,10 +156,10 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||||||
contentsTable.clear()
|
contentsTable.clear()
|
||||||
contentsTable.add(globalVictoryTable)
|
contentsTable.add(globalVictoryTable)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getGlobalVictoryColumn(majorCivs: List<CivilizationInfo>, victory: String): Table {
|
private fun getGlobalVictoryColumn(majorCivs: List<CivilizationInfo>, victory: String): Table {
|
||||||
val victoryColumn = Table().apply { defaults().pad(10f) }
|
val victoryColumn = Table().apply { defaults().pad(10f) }
|
||||||
|
|
||||||
victoryColumn.add("[$victory] Victory".toLabel()).row()
|
victoryColumn.add("[$victory] Victory".toLabel()).row()
|
||||||
victoryColumn.addSeparator()
|
victoryColumn.addSeparator()
|
||||||
|
|
||||||
@ -172,14 +172,14 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||||||
val buttonText = civ.victoryManager.getNextMilestone(victory)?.getVictoryScreenButtonHeaderText(false, civ) ?: "Done!"
|
val buttonText = civ.victoryManager.getNextMilestone(victory)?.getVictoryScreenButtonHeaderText(false, civ) ?: "Done!"
|
||||||
victoryColumn.add(getCivGroup(civ, "\n" + buttonText.tr(), playerCivInfo)).fillX().row()
|
victoryColumn.add(getCivGroup(civ, "\n" + buttonText.tr(), playerCivInfo)).fillX().row()
|
||||||
}
|
}
|
||||||
|
|
||||||
return victoryColumn
|
return victoryColumn
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setCivRankingsTable() {
|
private fun setCivRankingsTable() {
|
||||||
val majorCivs = gameInfo.civilizations.filter { it.isMajorCiv() }
|
val majorCivs = gameInfo.civilizations.filter { it.isMajorCiv() }
|
||||||
contentsTable.clear()
|
contentsTable.clear()
|
||||||
|
|
||||||
if (UncivGame.Current.settings.useDemographics) contentsTable.add(buildDemographicsTable(majorCivs))
|
if (UncivGame.Current.settings.useDemographics) contentsTable.add(buildDemographicsTable(majorCivs))
|
||||||
else contentsTable.add(buildRankingsTable(majorCivs))
|
else contentsTable.add(buildRankingsTable(majorCivs))
|
||||||
}
|
}
|
||||||
@ -188,14 +188,14 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||||||
private fun buildDemographicsTable(majorCivs: List<CivilizationInfo>): Table {
|
private fun buildDemographicsTable(majorCivs: List<CivilizationInfo>): Table {
|
||||||
val demographicsTable = Table().apply { defaults().pad(5f) }
|
val demographicsTable = Table().apply { defaults().pad(5f) }
|
||||||
buildDemographicsHeaders(demographicsTable)
|
buildDemographicsHeaders(demographicsTable)
|
||||||
|
|
||||||
for (rankLabel in RankLabels.values()) {
|
for (rankLabel in RankLabels.values()) {
|
||||||
demographicsTable.row()
|
demographicsTable.row()
|
||||||
demographicsTable.add(rankLabel.name.toLabel())
|
demographicsTable.add(rankLabel.name.toLabel())
|
||||||
|
|
||||||
for (category in RankingType.values()) {
|
for (category in RankingType.values()) {
|
||||||
val aliveMajorCivsSorted = majorCivs.filter{ it.isAlive() }.sortedByDescending { it.getStatForRanking(category) }
|
val aliveMajorCivsSorted = majorCivs.filter{ it.isAlive() }.sortedByDescending { it.getStatForRanking(category) }
|
||||||
|
|
||||||
fun addRankCivGroup(civ: CivilizationInfo) { // local function for reuse of getting and formatting civ stats
|
fun addRankCivGroup(civ: CivilizationInfo) { // local function for reuse of getting and formatting civ stats
|
||||||
demographicsTable.add(getCivGroup(civ, ": " + civ.getStatForRanking(category).toString(), playerCivInfo)).fillX()
|
demographicsTable.add(getCivGroup(civ, ": " + civ.getStatForRanking(category).toString(), playerCivInfo)).fillX()
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||||||
|
|
||||||
return demographicsTable
|
return demographicsTable
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildDemographicsHeaders(demographicsTable: Table) {
|
private fun buildDemographicsHeaders(demographicsTable: Table) {
|
||||||
val demoLabel = Table().apply { defaults().pad(5f) }
|
val demoLabel = Table().apply { defaults().pad(5f) }
|
||||||
|
|
||||||
@ -223,8 +223,12 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||||||
|
|
||||||
for (category in RankingType.values()) {
|
for (category in RankingType.values()) {
|
||||||
val headers = Table().apply { defaults().pad(5f) }
|
val headers = Table().apply { defaults().pad(5f) }
|
||||||
headers.add(category.name.replace('_', ' ').toLabel()).row()
|
val textAndIcon = Table().apply { defaults() }
|
||||||
headers.addSeparator().fillX()
|
val columnImage = category.getImage()
|
||||||
|
if (columnImage != null) textAndIcon.add(columnImage).center().size(Constants.defaultFontSize.toFloat() * 0.75f).padRight(2f).padTop(-2f)
|
||||||
|
textAndIcon.add(category.name.replace('_', ' ').toLabel()).row()
|
||||||
|
headers.add(textAndIcon)
|
||||||
|
headers.addSeparator()
|
||||||
demographicsTable.add(headers)
|
demographicsTable.add(headers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,7 +238,11 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||||||
|
|
||||||
for (category in RankingType.values()) {
|
for (category in RankingType.values()) {
|
||||||
val column = Table().apply { defaults().pad(5f) }
|
val column = Table().apply { defaults().pad(5f) }
|
||||||
column.add(category.name.replace('_' , ' ').toLabel()).row()
|
val textAndIcon = Table().apply { defaults() }
|
||||||
|
val columnImage = category.getImage()
|
||||||
|
if (columnImage != null) textAndIcon.add(columnImage).size(Constants.defaultFontSize.toFloat() * 0.75f).padRight(2f).padTop(-2f)
|
||||||
|
textAndIcon.add(category.name.replace('_' , ' ').toLabel()).row()
|
||||||
|
column.add(textAndIcon)
|
||||||
column.addSeparator()
|
column.addSeparator()
|
||||||
|
|
||||||
for (civ in majorCivs.sortedByDescending { it.getStatForRanking(category) }) {
|
for (civ in majorCivs.sortedByDescending { it.getStatForRanking(category) }) {
|
||||||
|
Loading…
Reference in New Issue
Block a user