From 17f5f949eb9153c85111668e03ff503dbb8fb98d Mon Sep 17 00:00:00 2001 From: yairm210 Date: Fri, 13 Dec 2024 11:56:44 +0200 Subject: [PATCH] TileInfoTable improvements - see #12591 --- .../unciv/ui/screens/worldscreen/WorldScreen.kt | 2 +- .../worldscreen/bottombar/TileInfoTable.kt | 15 +++++---------- .../ui/screens/worldscreen/minimap/Minimap.kt | 7 ++----- .../screens/worldscreen/minimap/MinimapHolder.kt | 5 ++++- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/core/src/com/unciv/ui/screens/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/screens/worldscreen/WorldScreen.kt index e08365d982..2d466aa1a4 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/WorldScreen.kt @@ -374,7 +374,7 @@ class WorldScreen( else bottomTileInfoTable.selectedCiv = viewingCiv bottomTileInfoTable.updateTileTable(mapHolder.selectedTile) bottomTileInfoTable.x = stage.width - bottomTileInfoTable.width - bottomTileInfoTable.y = if (game.settings.showMinimap) minimapWrapper.height else 0f + bottomTileInfoTable.y = if (game.settings.showMinimap) minimapWrapper.height + 5f else 0f battleTable.update() diff --git a/core/src/com/unciv/ui/screens/worldscreen/bottombar/TileInfoTable.kt b/core/src/com/unciv/ui/screens/worldscreen/bottombar/TileInfoTable.kt index 9452c9f502..50a84be476 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/bottombar/TileInfoTable.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/bottombar/TileInfoTable.kt @@ -12,7 +12,6 @@ import com.unciv.ui.components.extensions.darken import com.unciv.ui.components.extensions.toLabel import com.unciv.ui.components.extensions.toPrettyString import com.unciv.ui.components.input.onClick -import com.unciv.ui.images.ImageGetter import com.unciv.ui.popups.Popup import com.unciv.ui.screens.basescreen.BaseScreen import com.unciv.ui.screens.civilopediascreen.FormattedLine.IconDisplay @@ -32,12 +31,13 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(BaseScreen.ski internal fun updateTileTable(tile: Tile?) { clearChildren() + pad(5f) if (tile != null && (DebugUtils.VISIBLE_MAP || selectedCiv.hasExplored(tile)) ) { - add(getStatsTable(tile)) + add(getStatsTable(tile)).left().row() add(MarkupRenderer.render(TileDescription.toMarkup(tile, selectedCiv), padding = 0f, iconDisplay = IconDisplay.None) { worldScreen.openCivilopedia(it) - } ).pad(5f).row() + } ).padTop(5f).row() if (DebugUtils.VISIBLE_MAP) add(tile.position.toPrettyString().toLabel()).colspan(2).pad(5f) if (DebugUtils.SHOW_TILE_IMAGE_LOCATIONS){ val imagesString = "Images: " + worldScreen.mapHolder.tileGroups[tile]!!.layerTerrain.tileBaseImages.joinToString{"\n"+it.name} @@ -53,15 +53,10 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(BaseScreen.ski private fun getStatsTable(tile: Tile): Table { val table = Table() table.defaults().pad(2f) - - // 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(selectedCiv)) { - table.add(ImageGetter.getStatIcon(key.name)) - .size(20f).align(Align.right).padLeft(10f) - table.add(value.toInt().toLabel()) + table.add((key.character + value.toInt().toString()).toLabel()) .align(Align.left).padRight(5f) - table.row() } table.touchable = Touchable.enabled table.onClick { diff --git a/core/src/com/unciv/ui/screens/worldscreen/minimap/Minimap.kt b/core/src/com/unciv/ui/screens/worldscreen/minimap/Minimap.kt index f2dcebcc2f..14957787c6 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/minimap/Minimap.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/minimap/Minimap.kt @@ -135,11 +135,8 @@ class Minimap(val mapHolder: WorldMapHolder, minimapSize: Int, private val civIn // hex height = sqrt(3) / 2 * d / 2, number of rows = mapDiameter * 2 height *= minimapTileSize * sqrt(3f) * 0.5f // hex width = 0.75 * d - width = - if (mapParameters.worldWrap) - (width - 1f) * minimapTileSize * 0.75f - else - width * minimapTileSize * 0.75f + width = if (mapParameters.worldWrap) (width - 1f) * minimapTileSize * 0.75f + else width * minimapTileSize * 0.75f return Vector2(width, height) } diff --git a/core/src/com/unciv/ui/screens/worldscreen/minimap/MinimapHolder.kt b/core/src/com/unciv/ui/screens/worldscreen/minimap/MinimapHolder.kt index a362c5d0d4..f5f84c4f19 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/minimap/MinimapHolder.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/minimap/MinimapHolder.kt @@ -53,8 +53,10 @@ class MinimapHolder(val mapHolder: WorldMapHolder) : Table() { private fun rebuild(civInfo: Civilization?) { this.clear() minimap = Minimap(mapHolder, minimapSize, civInfo) + val wrappedMinimap = getWrappedMinimap() add(getToggleIcons()).align(Align.bottom) - add(getWrappedMinimap()) + .height(wrappedMinimap.height).padRight(5f) // Spread equally over the side + add(wrappedMinimap) pack() if (stage != null) x = stage.width - width } @@ -83,6 +85,7 @@ class MinimapHolder(val mapHolder: WorldMapHolder) : Table() { /** @return Layout table for the little green map overlay toggle buttons, show to the left of the minimap. */ private fun getToggleIcons(): Table { val toggleIconTable = Table() + toggleIconTable.defaults().padTop(5f) toggleIconTable.add(movementsImageButton).row() toggleIconTable.add(yieldImageButton).row()