mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-23 21:22:39 +07:00
Texture packer conditionally (#2373)
* Bring Incas into the main game (also changes slinger withdraw ability to inheritable) * Update Nations.json * Desktop debugging - skip unnecessary TexturePacker calls * Desktop debugging - skip unnecessary TexturePacker calls patch 1
This commit is contained in:
parent
323613ba02
commit
226801bfbd
@ -58,14 +58,14 @@ internal object DesktopLauncher {
|
||||
settings.filterMin = Texture.TextureFilter.MipMapLinearLinear
|
||||
|
||||
if (File("../Images").exists()) // So we don't run this from within a fat JAR
|
||||
TexturePacker.process(settings, "../Images", ".", "game")
|
||||
packImagesIfOutdated(settings, "../Images", ".", "game")
|
||||
|
||||
// pack for mods as well
|
||||
val modDirectory = File("mods")
|
||||
if(modDirectory.exists()) {
|
||||
for (mod in modDirectory.listFiles()!!){
|
||||
if (!mod.isHidden && File(mod.path + "/Images").exists())
|
||||
TexturePacker.process(settings, mod.path + "/Images", mod.path, "game")
|
||||
packImagesIfOutdated(settings, mod.path + "/Images", mod.path, "game")
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,6 +73,21 @@ internal object DesktopLauncher {
|
||||
println("Packing textures - "+texturePackingTime+"ms")
|
||||
}
|
||||
|
||||
private fun packImagesIfOutdated (settings: TexturePacker.Settings, input: String, output: String, packFileName: String) {
|
||||
fun File.listTree(): Sequence<File> = when {
|
||||
this.isFile -> sequenceOf(this)
|
||||
this.isDirectory -> this.listFiles().asSequence().flatMap { it.listTree() }
|
||||
else -> sequenceOf()
|
||||
}
|
||||
|
||||
val atlasFile = File("$output${File.separator}$packFileName.atlas")
|
||||
if (atlasFile.exists() && File("$output${File.separator}$packFileName.png").exists()) {
|
||||
val atlasModTime = atlasFile.lastModified()
|
||||
if (!File(input).listTree().any { it.extension in listOf("png","jpg","jpeg") && it.lastModified() > atlasModTime }) return
|
||||
}
|
||||
TexturePacker.process(settings, input, output, packFileName )
|
||||
}
|
||||
|
||||
private fun tryActivateDiscord(game: UncivGame) {
|
||||
try {
|
||||
val handlers = DiscordEventHandlers()
|
||||
|
Loading…
Reference in New Issue
Block a user