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
|
||||
|
||||
enum class RankingType {
|
||||
Score,
|
||||
Population,
|
||||
Crop_Yield,
|
||||
Production,
|
||||
Gold,
|
||||
Territory,
|
||||
Force,
|
||||
Happiness,
|
||||
Technologies,
|
||||
Culture
|
||||
}
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
|
||||
enum class RankingType(val getImage: ()->Image?) {
|
||||
// production, gold, happiness, and culture already have icons added when the line is `tr()`anslated
|
||||
Score({ ImageGetter.getImage("OtherIcons/Cultured").apply { color = Color.FIREBRICK } }),
|
||||
Population({ ImageGetter.getStatIcon("Population") }),
|
||||
Crop_Yield({ ImageGetter.getStatIcon("Food") }),
|
||||
Production({ null }),
|
||||
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
|
||||
else -> playerCivInfo.gameInfo.ruleSet.victories[victoryType]!!.defeatString
|
||||
}
|
||||
|
||||
|
||||
descriptionLabel.setText(description.tr() + "\n" + endGameMessage.tr())
|
||||
|
||||
rightSideButton.setText("Start new game".tr())
|
||||
@ -103,21 +103,21 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
val ourVictoryStatusTable = Table()
|
||||
ourVictoryStatusTable.defaults().pad(10f)
|
||||
val victoriesToShow = gameInfo.getEnabledVictories()
|
||||
|
||||
|
||||
for (victory in victoriesToShow) {
|
||||
ourVictoryStatusTable.add("[${victory.key}] Victory".toLabel())
|
||||
}
|
||||
ourVictoryStatusTable.row()
|
||||
|
||||
|
||||
for (victory in victoriesToShow) {
|
||||
ourVictoryStatusTable.add(getOurVictoryColumn(victory.key))
|
||||
}
|
||||
ourVictoryStatusTable.row()
|
||||
|
||||
|
||||
for (victory in victoriesToShow) {
|
||||
ourVictoryStatusTable.add(victory.value.victoryScreenHeader.toLabel())
|
||||
}
|
||||
|
||||
|
||||
contentsTable.clear()
|
||||
contentsTable.add(ourVictoryStatusTable)
|
||||
}
|
||||
@ -148,7 +148,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
val majorCivs = gameInfo.civilizations.filter { it.isMajorCiv() }
|
||||
val globalVictoryTable = Table().apply { defaults().pad(10f) }
|
||||
val victoriesToShow = gameInfo.ruleSet.victories.filter { !it.value.hiddenInVictoryScreen && enabledVictoryTypes.contains(it.key) }
|
||||
|
||||
|
||||
for (victory in victoriesToShow) {
|
||||
globalVictoryTable.add(getGlobalVictoryColumn(majorCivs, victory.key))
|
||||
}
|
||||
@ -156,10 +156,10 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
contentsTable.clear()
|
||||
contentsTable.add(globalVictoryTable)
|
||||
}
|
||||
|
||||
|
||||
private fun getGlobalVictoryColumn(majorCivs: List<CivilizationInfo>, victory: String): Table {
|
||||
val victoryColumn = Table().apply { defaults().pad(10f) }
|
||||
|
||||
|
||||
victoryColumn.add("[$victory] Victory".toLabel()).row()
|
||||
victoryColumn.addSeparator()
|
||||
|
||||
@ -172,14 +172,14 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
val buttonText = civ.victoryManager.getNextMilestone(victory)?.getVictoryScreenButtonHeaderText(false, civ) ?: "Done!"
|
||||
victoryColumn.add(getCivGroup(civ, "\n" + buttonText.tr(), playerCivInfo)).fillX().row()
|
||||
}
|
||||
|
||||
|
||||
return victoryColumn
|
||||
}
|
||||
|
||||
private fun setCivRankingsTable() {
|
||||
val majorCivs = gameInfo.civilizations.filter { it.isMajorCiv() }
|
||||
contentsTable.clear()
|
||||
|
||||
|
||||
if (UncivGame.Current.settings.useDemographics) contentsTable.add(buildDemographicsTable(majorCivs))
|
||||
else contentsTable.add(buildRankingsTable(majorCivs))
|
||||
}
|
||||
@ -188,14 +188,14 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
private fun buildDemographicsTable(majorCivs: List<CivilizationInfo>): Table {
|
||||
val demographicsTable = Table().apply { defaults().pad(5f) }
|
||||
buildDemographicsHeaders(demographicsTable)
|
||||
|
||||
|
||||
for (rankLabel in RankLabels.values()) {
|
||||
demographicsTable.row()
|
||||
demographicsTable.add(rankLabel.name.toLabel())
|
||||
|
||||
for (category in RankingType.values()) {
|
||||
val aliveMajorCivsSorted = majorCivs.filter{ it.isAlive() }.sortedByDescending { it.getStatForRanking(category) }
|
||||
|
||||
|
||||
fun addRankCivGroup(civ: CivilizationInfo) { // local function for reuse of getting and formatting civ stats
|
||||
demographicsTable.add(getCivGroup(civ, ": " + civ.getStatForRanking(category).toString(), playerCivInfo)).fillX()
|
||||
}
|
||||
@ -213,7 +213,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
|
||||
return demographicsTable
|
||||
}
|
||||
|
||||
|
||||
private fun buildDemographicsHeaders(demographicsTable: Table) {
|
||||
val demoLabel = Table().apply { defaults().pad(5f) }
|
||||
|
||||
@ -223,8 +223,12 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
|
||||
for (category in RankingType.values()) {
|
||||
val headers = Table().apply { defaults().pad(5f) }
|
||||
headers.add(category.name.replace('_', ' ').toLabel()).row()
|
||||
headers.addSeparator().fillX()
|
||||
val textAndIcon = Table().apply { defaults() }
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -234,7 +238,11 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
|
||||
for (category in RankingType.values()) {
|
||||
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()
|
||||
|
||||
for (civ in majorCivs.sortedByDescending { it.getStatForRanking(category) }) {
|
||||
|
Loading…
Reference in New Issue
Block a user