mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-26 23:58:43 +07:00
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:
@ -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) {
|
||||
|
Reference in New Issue
Block a user