From 20e1b9b9784e49d0f7f57cbf2d267806442b8871 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 17 Mar 2023 12:06:15 +0200 Subject: [PATCH] Tilesets: Separated unexplored tiles from not visible tiles --- .../unciv/ui/components/tilegroups/TileSetStrings.kt | 1 + .../components/tilegroups/layers/TileLayerOverlay.kt | 8 +++++--- docs/Modders/Creating-a-custom-tileset.md | 11 +++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/ui/components/tilegroups/TileSetStrings.kt b/core/src/com/unciv/ui/components/tilegroups/TileSetStrings.kt index 7710830a21..ed2fe6dd36 100644 --- a/core/src/com/unciv/ui/components/tilegroups/TileSetStrings.kt +++ b/core/src/com/unciv/ui/components/tilegroups/TileSetStrings.kt @@ -27,6 +27,7 @@ class TileSetStrings(tileSet: String = UncivGame.Current.settings.tileSet, unitS val hexagon: String by lazy { orFallback {tileSetLocation + "Hexagon"} } val hexagonList by lazy { listOf(hexagon) } val crosshatchHexagon by lazy { orFallback { tileSetLocation + "CrosshatchHexagon" } } + val unexploredTile by lazy { orFallback { tileSetLocation + "UnexploredTile" } } val crosshair by lazy { orFallback { getString(tileSetLocation, "Crosshair") } } val highlight by lazy { orFallback { getString(tileSetLocation, "Highlight") } } val roadsMap = RoadStatus.values() diff --git a/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerOverlay.kt b/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerOverlay.kt index ca5d25c25e..af9d89a494 100644 --- a/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerOverlay.kt +++ b/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerOverlay.kt @@ -3,10 +3,9 @@ package com.unciv.ui.components.tilegroups.layers import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.Actor import com.unciv.Constants -import com.unciv.UncivGame import com.unciv.logic.civilization.Civilization -import com.unciv.ui.images.ImageGetter import com.unciv.ui.components.tilegroups.TileGroup +import com.unciv.ui.images.ImageGetter class TileLayerOverlay(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, size) { @@ -16,6 +15,7 @@ class TileLayerOverlay(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, private val highlight = ImageGetter.getImage(strings().highlight).setHexagonSize() // for blue and red circles/emphasis on the tile private val crosshair = ImageGetter.getImage(strings().crosshair).setHexagonSize() // for when a unit is targeted private val fog = ImageGetter.getImage(strings().crosshatchHexagon ).setHexagonSize() + private val unexplored = ImageGetter.getImage(strings().unexploredTile ).setHexagonSize() init { @@ -24,6 +24,8 @@ class TileLayerOverlay(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, fog.isVisible = false fog.color = Color.WHITE.cpy().apply { a = 0.2f } + if (ImageGetter.imageExists(strings().unexploredTile)) + addActor(unexplored) addActor(highlight) addActor(fog) addActor(crosshair) @@ -64,13 +66,13 @@ class TileLayerOverlay(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, } override fun doUpdate(viewingCiv: Civilization?) { - val isViewable = viewingCiv == null || isViewable(viewingCiv) fog.isVisible = !isViewable && !tileGroup.isForceVisible if (viewingCiv == null) return + unexplored.isVisible = !viewingCiv.hasExplored(tile()) if (tile().getShownImprovement(viewingCiv) == Constants.barbarianEncampment && tile().isExplored(viewingCiv)) showHighlight(Color.RED) diff --git a/docs/Modders/Creating-a-custom-tileset.md b/docs/Modders/Creating-a-custom-tileset.md index 9aad8deb8a..340a12f1cf 100644 --- a/docs/Modders/Creating-a-custom-tileset.md +++ b/docs/Modders/Creating-a-custom-tileset.md @@ -100,6 +100,17 @@ The ruleVariants are the most powerful part of the tileset config. With this, yo An example is given in the code above. For the tile "Grassland+Jungle+Dyes+Trading post" we then use the images "Grassland", "JungleForGrasslandBack", "Dyes+Trading post" and "JungleForGrasslandFront" in that order. +## Fog and unexplored tiles + +Unciv distinguishes between "unexplored" tiles, which are tiles the Civ has never seen, +and "not visible" tiles, which are those that were seen once but now are not. + +Not visible tiles are grayed out by design, and on top of that have the `CrosshatchHexagon.png` image applied to them. + +Unexplored tiles display the `UnexploredTile.png` image, on top of which `CrosshatchHexagon.png` is applied. + +You can set the CrosshatchHexagon to be functionally invisible by replacing it with a 1px by 1px invisible image. + ## Unit images Unit images can be changed according to civ-specific styles (if a mod specifies a "style" variable for each civilization) and according to the owning civ's current era. Unciv attempts to load the unit images in the following order (where unitName is the unit name given in Units.json, styleName is optionally specified in Nations.json, and eraName is the era name given in Eras.json (including " era")).