mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-11 07:47:41 +07:00
Resolved #9177 - Tileset no longer reverts to default on Android after restarting game
This commit is contained in:
parent
f98f4e8c9b
commit
2fbd24231f
@ -189,8 +189,8 @@ open class UncivGame(val isConsoleMode: Boolean = false) : Game(), PlatformSpeci
|
||||
|
||||
ImageGetter.resetAtlases()
|
||||
ImageGetter.setNewRuleset(ImageGetter.ruleset) // This needs to come after the settings, since we may have default visual mods
|
||||
val availableTileSets = ImageGetter.getAvailableTilesets().toSet()
|
||||
.intersect(TileSetCache.getAvailableTilesets().toSet())
|
||||
val imageGetterTilesets = ImageGetter.getAvailableTilesets()
|
||||
val availableTileSets = TileSetCache.getAvailableTilesets(imageGetterTilesets)
|
||||
if (settings.tileSet !in availableTileSets) { // If the configured tileset is no longer available, default back
|
||||
settings.tileSet = Constants.defaultTileset
|
||||
}
|
||||
|
@ -82,18 +82,19 @@ object TileSetCache : HashMap<String, TileSet>() {
|
||||
}
|
||||
|
||||
/** Determines potentially available TileSets - by scanning for TileSet jsons.
|
||||
*
|
||||
* Available before initialization finishes.
|
||||
* To get more reliable info, either wait until `this` is fully initialized,
|
||||
* or intersect with [ImageGetter.getAvailableTilesets]
|
||||
*/
|
||||
fun getAvailableTilesets() = sequence<FileHandle> {
|
||||
yieldAll(FileHandle("jsons/TileSets").list().asIterable())
|
||||
for (modFolder in FileHandle("mods").list()) {
|
||||
if (!modFolder.isDirectory || modFolder.name().startsWith('.'))
|
||||
continue
|
||||
yieldAll(modFolder.child("jsons/TileSets").list().asIterable())
|
||||
}
|
||||
}.filter { it.exists() }
|
||||
.map { it.nameWithoutExtension().removeSuffix("Config") }
|
||||
fun getAvailableTilesets(imageGetterTilesets:Sequence<String>): Set<String> {
|
||||
val modTilesetConfigFiles = Gdx.files.local("mods").list().asSequence()
|
||||
.filter { it.isDirectory && !it.name().startsWith('.') }
|
||||
.flatMap { it.child("jsons/TileSets").list().asSequence() }
|
||||
|
||||
val builtinTilesetConfigFiles = imageGetterTilesets
|
||||
.map { Gdx.files.internal("jsons/TileSets/$it.json") }
|
||||
|
||||
return (builtinTilesetConfigFiles + modTilesetConfigFiles)
|
||||
.filter { it.exists() }
|
||||
.map { it.nameWithoutExtension().removeSuffix("Config") }
|
||||
.toSet()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user