diff --git a/core/src/com/unciv/ui/components/fonts/FontRulesetIcons.kt b/core/src/com/unciv/ui/components/fonts/FontRulesetIcons.kt index bcfde403a1..976c5cc338 100644 --- a/core/src/com/unciv/ui/components/fonts/FontRulesetIcons.kt +++ b/core/src/com/unciv/ui/components/fonts/FontRulesetIcons.kt @@ -8,7 +8,9 @@ import com.badlogic.gdx.graphics.glutils.FrameBuffer import com.badlogic.gdx.math.Matrix4 import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.Group +import com.unciv.UncivGame import com.unciv.models.ruleset.Ruleset +import com.unciv.models.tilesets.TileSetCache import com.unciv.ui.components.extensions.center import com.unciv.ui.components.extensions.setSize import com.unciv.ui.components.fonts.FontRulesetIcons.getPixmapFromActor @@ -75,15 +77,18 @@ object FontRulesetIcons { addChar(policy.name, ImageGetter.getImage(fileLocation).apply { setSize(Fonts.ORIGINAL_FONT_SIZE) }) } - for (terrain in ruleset.terrains.values) { - // These ensure that the font icons are correctly sized - tilegroup rendering works differently than others, to account for clickability vs rendered areas - val tileGroup = CivilopediaImageGetters.terrainImage(terrain, ruleset, Fonts.ORIGINAL_FONT_SIZE) - tileGroup.width *= 1.5f - tileGroup.height *= 1.5f - for (layer in tileGroup.children) layer.center(tileGroup) - - addChar(terrain.name, tileGroup) - } + // Upon *game initialization* we can get here without the tileset being loaded yet + // in which case we can't add terrain icons + if (TileSetCache.containsKey(UncivGame.Current.settings.tileSet)) + for (terrain in ruleset.terrains.values) { + // These ensure that the font icons are correctly sized - tilegroup rendering works differently than others, to account for clickability vs rendered areas + val tileGroup = CivilopediaImageGetters.terrainImage(terrain, ruleset, Fonts.ORIGINAL_FONT_SIZE) + tileGroup.width *= 1.5f + tileGroup.height *= 1.5f + for (layer in tileGroup.children) layer.center(tileGroup) + + addChar(terrain.name, tileGroup) + } } diff --git a/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerMisc.kt b/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerMisc.kt index b0ed59d4be..41be98a720 100644 --- a/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerMisc.kt +++ b/core/src/com/unciv/ui/components/tilegroups/layers/TileLayerMisc.kt @@ -49,7 +49,7 @@ private class MapArrow(val targetTile: Tile, val arrowType: MapArrowType, val st class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, size) { // For different unit views, we want to effectively "ignore" the terrain and color it by special view - private val terrainOverlay = ImageGetter.getImage(strings().hexagon ).setHexagonSize() + private val terrainOverlay = ImageGetter.getImage(strings().hexagon).setHexagonSize() init { terrainOverlay.isVisible = false