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:
proteus-anguinus 2020-04-10 09:25:34 +02:00 committed by GitHub
parent 323613ba02
commit 226801bfbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()