mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-14 01:39:40 +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:
@ -58,14 +58,14 @@ internal object DesktopLauncher {
|
|||||||
settings.filterMin = Texture.TextureFilter.MipMapLinearLinear
|
settings.filterMin = Texture.TextureFilter.MipMapLinearLinear
|
||||||
|
|
||||||
if (File("../Images").exists()) // So we don't run this from within a fat JAR
|
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
|
// pack for mods as well
|
||||||
val modDirectory = File("mods")
|
val modDirectory = File("mods")
|
||||||
if(modDirectory.exists()) {
|
if(modDirectory.exists()) {
|
||||||
for (mod in modDirectory.listFiles()!!){
|
for (mod in modDirectory.listFiles()!!){
|
||||||
if (!mod.isHidden && File(mod.path + "/Images").exists())
|
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")
|
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) {
|
private fun tryActivateDiscord(game: UncivGame) {
|
||||||
try {
|
try {
|
||||||
val handlers = DiscordEventHandlers()
|
val handlers = DiscordEventHandlers()
|
||||||
|
Reference in New Issue
Block a user