TileInfoTable improvements - see #12591
Some checks failed
Conflict marking / main (push) Failing after 14s
Detekt / detekt (ubuntu-latest) (push) Failing after 1m12s
Generate mkdocs from docs folder / deploy (push) Failing after 39s
Build and test / Check code and run unit tests (push) Failing after 5m48s
Close stale issues and PRs / stale (push) Successful in 16s
Docker / build (push) Failing after 52s

This commit is contained in:
yairm210 2024-12-13 11:56:44 +02:00
parent 212e7233b3
commit 17f5f949eb
4 changed files with 12 additions and 17 deletions

View File

@ -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()

View File

@ -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 {

View File

@ -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)
}

View File

@ -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()