Multi-Atlas / Image packer redo (#4959)

* Atlas reorg

* Atlas reorg - resulting atlases 1

* Atlas reorg - resulting atlases 2

* Atlas reorg - merge
This commit is contained in:
SomeTroglodyte
2021-08-24 06:31:21 +02:00
committed by GitHub
parent b93f93ea9b
commit cdc63f71e8
354 changed files with 2412 additions and 2389 deletions

View File

@ -61,21 +61,20 @@ object ImageGetter {
textureRegionDrawables[region.name] = drawable
}
for (singleImagesFolder in sequenceOf("BuildingIcons", "FlagIcons", "UnitIcons")) {
if (!atlases.containsKey(singleImagesFolder)) atlases[singleImagesFolder] = TextureAtlas("$singleImagesFolder.atlas")
val tempAtlas = atlases[singleImagesFolder]!!
// Load all other atlas files
for (file in Gdx.files.internal(".").list(".atlas")) {
val extraAtlas = file.nameWithoutExtension()
val tempAtlas = atlases[extraAtlas] // fetch if cached
?: TextureAtlas(file.name()).apply { // load if not
atlases[extraAtlas] = this // cache the freshly loaded
}
val prefix = if (extraAtlas == "Skin") "Skin/" else "" // Only Skin is packed without folder prefix
for (region in tempAtlas.regions) {
val drawable = TextureRegionDrawable(region)
textureRegionDrawables["$singleImagesFolder/" + region.name] = drawable
textureRegionDrawables[prefix + region.name] = drawable
}
}
if (!atlases.containsKey("Skin")) atlases["Skin"] = TextureAtlas("Skin.atlas")
for (region in atlases["Skin"]!!.regions) {
val drawable = TextureRegionDrawable(region)
textureRegionDrawables["Skin/" + region.name] = drawable
}
// These are from the mods
for (mod in UncivGame.Current.settings.visualMods + ruleset.mods) {
val modAtlasFile = Gdx.files.local("mods/$mod/game.atlas")
@ -132,10 +131,10 @@ object ImageGetter {
val layerNames = mutableListOf(baseFileName)
val layerList = arrayListOf<Image>()
var i = 1
while (imageExists("$baseFileName-$i")) {
layerNames.add("$baseFileName-$i")
++i
var number = 1
while (imageExists("$baseFileName-$number")) {
layerNames.add("$baseFileName-$number")
++number
}
for (i in layerNames.indices) {