Fix Spectator stats when viewing another civ (#10985)

This commit is contained in:
SeventhM 2024-01-24 13:44:02 -08:00 committed by GitHub
parent e576b03fc6
commit 5e1a0f6da9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View File

@ -360,6 +360,8 @@ class WorldScreen(
if (fogOfWar) minimapWrapper.update(selectedCiv)
else minimapWrapper.update(viewingCiv)
if (fogOfWar) bottomTileInfoTable.selectedCiv = selectedCiv
else bottomTileInfoTable.selectedCiv = viewingCiv
bottomTileInfoTable.updateTileTable(mapHolder.selectedTile)
bottomTileInfoTable.x = stage.width - bottomTileInfoTable.width
bottomTileInfoTable.y = if (game.settings.showMinimap) minimapWrapper.height else 0f

View File

@ -23,7 +23,7 @@ import com.unciv.ui.screens.worldscreen.WorldScreen
import com.unciv.utils.DebugUtils
class TileInfoTable(private val worldScreen: WorldScreen) : Table(BaseScreen.skin) {
val viewingCiv = worldScreen.viewingCiv
var selectedCiv = worldScreen.selectedCiv
init {
background = BaseScreen.skinStrings.getUiBackground(
@ -35,10 +35,10 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(BaseScreen.ski
internal fun updateTileTable(tile: Tile?) {
clearChildren()
if (tile != null && (DebugUtils.VISIBLE_MAP || viewingCiv.hasExplored(tile)) ) {
if (tile != null && (DebugUtils.VISIBLE_MAP || selectedCiv.hasExplored(tile)) ) {
add(getStatsTable(tile))
add(MarkupRenderer.render(TileDescription.toMarkup(tile, viewingCiv), padding = 0f, iconDisplay = IconDisplay.None) {
UncivGame.Current.pushScreen(CivilopediaScreen(viewingCiv.gameInfo.ruleset, link = it))
add(MarkupRenderer.render(TileDescription.toMarkup(tile, selectedCiv), padding = 0f, iconDisplay = IconDisplay.None) {
UncivGame.Current.pushScreen(CivilopediaScreen(selectedCiv.gameInfo.ruleset, link = it))
} ).pad(5f).row()
if (DebugUtils.VISIBLE_MAP)
add(tile.position.toPrettyString().toLabel()).colspan(2).pad(5f)
@ -54,7 +54,7 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(BaseScreen.ski
// padLeft = padRight + 5: for symmetry. An extra 5 for the distance yield number to
// tile text comes from the pad up there in updateTileTable
for ((key, value) in tile.stats.getTileStats(viewingCiv)) {
for ((key, value) in tile.stats.getTileStats(selectedCiv)) {
table.add(ImageGetter.getStatIcon(key.name))
.size(20f).align(Align.right).padLeft(10f)
table.add(value.toInt().toLabel())
@ -64,7 +64,7 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(BaseScreen.ski
table.touchable = Touchable.enabled
table.onClick {
Popup(worldScreen).apply {
for ((name, stats) in tile.stats.getTileStatsBreakdown(tile.getCity(), viewingCiv))
for ((name, stats) in tile.stats.getTileStatsBreakdown(tile.getCity(), selectedCiv))
add("${name.tr()}: {${stats.clone()}}".toLabel()).row()
addCloseButton()
}.open()