Unified civ display in Overview and Victory screens

This commit is contained in:
Yair Morgenstern 2019-06-19 19:20:25 +03:00
parent 227f6627be
commit a6d1cdc398
4 changed files with 35 additions and 29 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,006 KiB

After

Width:  |  Height:  |  Size: 1,006 KiB

View file

@ -311,27 +311,8 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
val civGroups = HashMap<String, Actor>() val civGroups = HashMap<String, Actor>()
for(i in 0..relevantCivs.lastIndex){ for(i in 0..relevantCivs.lastIndex){
val civ = relevantCivs[i] val civ = relevantCivs[i]
val civGroup = Table()
val civGroupBackground = ImageGetter.getDrawable("OtherIcons/civTableBackground.png")
var civNameText = civ.civName.tr() val civGroup = getCivGroup(civ, "", currentPlayerCivInfo)
if(civ.isDefeated()) civNameText += "\n({Defeated})".tr()
val label = civNameText.toLabel()
label.setAlignment(Align.center)
if (civ.isDefeated()) {
civGroup.background = civGroupBackground.tint(Color.LIGHT_GRAY)
label.setFontColor(Color.BLACK)
} else if (playerKnows(civ)) {
civGroup.background = civGroupBackground.tint(civ.getNation().getColor())
label.setFontColor(civ.getNation().getSecondaryColor())
} else {
civGroup.background = civGroupBackground.tint(Color.DARK_GRAY)
label.setText("???")
}
civGroup.add(label).pad(10f)
civGroup.pack()
val vector = HexMath().getVectorForAngle(2 * Math.PI.toFloat() *i / relevantCivs.size) val vector = HexMath().getVectorForAngle(2 * Math.PI.toFloat() *i / relevantCivs.size)
civGroup.center(group) civGroup.center(group)
@ -394,4 +375,32 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
return resourcesTable return resourcesTable
} }
companion object {
fun getCivGroup(civ: CivilizationInfo, afterCivNameText:String,currentPlayer:CivilizationInfo): Table {
val civGroup = Table()
val civGroupBackground = ImageGetter.getDrawable("OtherIcons/civTableBackground.png")
val civNameText = civ.civName.tr()+afterCivNameText
val label = civNameText.toLabel()
label.setAlignment(Align.center)
if (civ.isDefeated()) {
civGroup.background = civGroupBackground.tint(Color.LIGHT_GRAY)
civGroup.add(ImageGetter.getImage("OtherIcons/DisbandUnit")).size(30f)
label.setFontColor(Color.BLACK)
} else if (currentPlayer==civ || currentPlayer.knows(civ)) {
civGroup.background = civGroupBackground.tint(civ.getNation().getColor())
label.setFontColor(civ.getNation().getSecondaryColor())
} else {
civGroup.background = civGroupBackground.tint(Color.DARK_GRAY)
label.setText("???")
}
civGroup.add(ImageGetter.getNationIndicator(civ.getNation(), 30f))
civGroup.add(label).pad(10f)
civGroup.pack()
return civGroup
}
}
} }

View file

@ -167,13 +167,12 @@ class VictoryScreen : PickerScreen() {
dominationVictoryColumn.add("Undefeated civs".toLabel()).row() dominationVictoryColumn.add("Undefeated civs".toLabel()).row()
dominationVictoryColumn.addSeparator() dominationVictoryColumn.addSeparator()
for (civ in majorCivs.filter { !it.isDefeated() }) { for (civ in majorCivs.filter { !it.isDefeated() })
val civName = if(playerCivInfo.knows(civ) || playerCivInfo==civ) civ.civName.tr() else "???" dominationVictoryColumn.add(EmpireOverviewScreen.getCivGroup(civ, "", playerCivInfo)).row()
dominationVictoryColumn.add(TextButton(civName, skin).apply { color = Color.GREEN }).row()
}
for (civ in majorCivs.filter { it.isDefeated() }) for (civ in majorCivs.filter { it.isDefeated() })
dominationVictoryColumn.add(TextButton(civ.civName.tr(), skin).apply { color = Color.GRAY }).row() dominationVictoryColumn.add(EmpireOverviewScreen.getCivGroup(civ, "", playerCivInfo)).row()
return dominationVictoryColumn return dominationVictoryColumn
} }
@ -189,8 +188,7 @@ class VictoryScreen : PickerScreen() {
.sortedByDescending { it.branchesCompleted } .sortedByDescending { it.branchesCompleted }
for (entry in civsToBranchesCompleted) { for (entry in civsToBranchesCompleted) {
val civName = if(playerCivInfo.knows(entry.civ) || playerCivInfo==entry.civ) entry.civ.civName.tr() else "???" policyVictoryColumn.add(EmpireOverviewScreen.getCivGroup(entry.civ, " - " + entry.branchesCompleted, playerCivInfo)).row()
policyVictoryColumn.add(TextButton(civName + " - " + entry.branchesCompleted, skin)).row()
} }
return policyVictoryColumn return policyVictoryColumn
} }
@ -208,8 +206,7 @@ class VictoryScreen : PickerScreen() {
} }
for (entry in civsToPartsRemaining) { for (entry in civsToPartsRemaining) {
val civName = if(playerCivInfo.knows(entry.civ) || playerCivInfo==entry.civ) entry.civ.civName.tr() else "???" scientificVictoryColumn.add(EmpireOverviewScreen.getCivGroup(entry.civ, " - " + entry.partsRemaining, playerCivInfo)).row()
scientificVictoryColumn.add(TextButton(civName + " - " + entry.partsRemaining, skin)).row()
} }
return scientificVictoryColumn return scientificVictoryColumn
} }