Skip to content

Commit

Permalink
Resolved #12506 - debug option to show tile image locations
Browse files Browse the repository at this point in the history
  • Loading branch information
yairm210 committed Nov 25, 2024
1 parent 9dc1d5b commit d91319b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
override fun hit(x: Float, y: Float, touchable: Boolean): Actor? = null
override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha)

private val tileBaseImages: ArrayList<Image> = ArrayList()
val tileBaseImages: ArrayList<Image> = ArrayList()
private var tileImageIdentifiers = listOf<String>()
private var bottomRightRiverImage: Image? = null
private var bottomRiverImage: Image? = null
Expand Down Expand Up @@ -155,6 +155,7 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
val finalLocation = existingImages.random(
Random(tileGroup.tile.position.hashCode() + locationToCheck.hashCode()))
val image = ImageGetter.getImage(finalLocation)
image.name = finalLocation // for debug mode reveal

tileBaseImages.add(image)
addActor(image)
Expand Down
3 changes: 3 additions & 0 deletions core/src/com/unciv/ui/popups/options/DebugTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ fun debugTab(
add("Show coordinates on tiles".toCheckBox(DebugUtils.SHOW_TILE_COORDS) {
DebugUtils.SHOW_TILE_COORDS = it
}).colspan(2).row()
add("Show tile image locations".toCheckBox(DebugUtils.SHOW_TILE_IMAGE_LOCATIONS) {
DebugUtils.SHOW_TILE_IMAGE_LOCATIONS = it
}).colspan(2).row()

val curGameInfo = game.gameInfo
if (curGameInfo != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(BaseScreen.ski
add(MarkupRenderer.render(TileDescription.toMarkup(tile, selectedCiv), padding = 0f, iconDisplay = IconDisplay.None) {
worldScreen.openCivilopedia(it)
} ).pad(5f).row()
if (DebugUtils.VISIBLE_MAP)
add(tile.position.toPrettyString().toLabel()).colspan(2).pad(5f)
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}
add(imagesString.toLabel())
}

}

pack()
Expand Down
2 changes: 2 additions & 0 deletions core/src/com/unciv/utils/DebugUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ object DebugUtils {

/** This flag paints the tile coordinates directly onto the map tiles. */
var SHOW_TILE_COORDS: Boolean = false

var SHOW_TILE_IMAGE_LOCATIONS: Boolean = false

/** For when you need to test something in an advanced game and don't have time to faff around */
var SUPERCHARGED: Boolean = false
Expand Down

0 comments on commit d91319b

Please sign in to comment.