Resolved race-condition error for loading terrain icons

This commit is contained in:
yairm210 2024-09-29 23:11:55 +03:00
parent 2a8f0be257
commit 660ae105c3
2 changed files with 15 additions and 10 deletions

View File

@ -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,6 +77,9 @@ object FontRulesetIcons {
addChar(policy.name, ImageGetter.getImage(fileLocation).apply { setSize(Fonts.ORIGINAL_FONT_SIZE) })
}
// 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)