-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove buildSrc since it breaks compiling now for some reason
- Loading branch information
1 parent
85597e0
commit dace346
Showing
11 changed files
with
136 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,6 @@ packr-out/ | |
config/ | ||
*.gif | ||
/tests/out | ||
/buildSrc/build | ||
|
||
/core/assets/basepartnames | ||
version.properties | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
@file:JvmName("Paletter") | ||
package mindustry.tools | ||
|
||
import arc.files.* | ||
import arc.graphics.* | ||
import arc.struct.* | ||
import kotlin.math.* | ||
|
||
fun main(vararg args: String) { | ||
val dir = Fi(if (args.isEmpty()) "core/assets-raw/sprites" else args[0]) | ||
// FINISHME: This isn't ported fully from groovy (see the commented block below) | ||
} | ||
|
||
// doLast{ | ||
//// def executor = Executors.newFixedThreadPool(OS.cores) | ||
// def dir = new Fi(project.getProperty("startdir")) | ||
// def paletter = new Paletter() | ||
// dir.walk { fi -> | ||
// var name = fi.name() | ||
// if (paletter.blacklist.contains(name) || name.startsWith("zzzzz-") || paletter.regexlist.any(regex -> regex.matches(name))) return | ||
// if (!name.endsWith(".png")) { | ||
// throw new IOException(name) | ||
// } | ||
//// executor.execute { | ||
// var pix = new Pixmap(fi) | ||
// paletter.mapColors(pix, name) | ||
// fi.sibling("zzzzz-" + name).writePng(pix) | ||
// pix.dispose() | ||
//// } | ||
// } | ||
// println("Missing: $paletter.missingCount | Similar: $paletter.similar.size") | ||
//// Threads.await(executor) | ||
// } | ||
|
||
private val blacklist = setOf( | ||
".DS_Store", "pack.json", "error.png", "logo.png", "alpha-bg.png", "alphaaaa.png", "clear.png", | ||
"particle.png", "hcircle.png", "clear-effect.png", "flarogus.png" | ||
) | ||
private val regexlist = arrayOf( | ||
".+-shadow[0-9]?\\.png", ".+-glow\\.png", ".+-vents\\.png", ".+-blur\\.png", ".+-heat(?:_full|-top)?\\.png", "fire[0-9]+\\.png", | ||
"circle-(?:mid|end|small)\\.png", ".+-cell\\.png", "edge(?:-stencil)?\\.png", | ||
).map { it.toRegex() } | ||
|
||
private val mapping = map( | ||
0x62AE7FFF, 0x50A9ADFF, | ||
0x84F491FF, 0x6DF5D7FF, | ||
0xB0BAC0FF, 0x757C80FF, | ||
0x989AA4FF, 0x5C5E64FF, | ||
0x6E7080FF, 0x373840FF, | ||
0xD3816BFF, 0xD48555FF, | ||
0xEA8778FF, 0xEB7360FF, | ||
0xFEB380FF, 0xFFA366FF, | ||
0x767a84FF, 0x4f5f85FF, | ||
0x8e9097FF, 0x737c96FF, | ||
0x3a3a50FF, 0x29294fFF, | ||
0x84f491FF, 0x58f56aFF, | ||
0xFF62AE7F, 0xFF3EAD68, | ||
) | ||
|
||
private val notFound = IntSet() // Colors not in mapping that we've already tried and are not similar and are therefore missing from the map | ||
private var missingCount = 0 | ||
private val similar = map() // Basically just additional keys for [mapping] entries for colors that are similar enough to be considered one of the mapped colors | ||
|
||
/** Horribly cursed way around having to spam [Long.toInt] calls everywhere */ | ||
private fun map(vararg values: Long) = IntIntMap.of(*values.map { it.toInt() }.toIntArray()) | ||
|
||
/** Not thread safe. */ | ||
private fun Pixmap.mapColors(fileName: String) { | ||
val colorCache = Color() | ||
val pc = Color() // pixelColor | ||
for (i in 0 until height * width * 4 step 4) { | ||
val pixel = pixels.getInt(i) | ||
if (pixel == 0) continue | ||
|
||
val mapped = mapping[pixel, -1] | ||
if (mapped != -1) { | ||
pixels.putInt(i, mapped) | ||
continue | ||
} | ||
|
||
val similarMapped = similar[pixel, -1] // This is *very* hacky | ||
if (similarMapped != -1) { | ||
pixels.putInt(i, similarMapped) | ||
continue | ||
} | ||
|
||
if (notFound.add(pixel) && !mapping.containsValue(pixel)) { // This is very slow | ||
pc.set(pixel) | ||
if (pc.a == 0F) continue | ||
pc.premultiplyAlpha() | ||
val values = mapping.values() | ||
var diff = Float.MAX_VALUE | ||
var min: Int = -1 | ||
while (values.hasNext()) { // minBy just doesn't work here and I can't be bothered to find out why. | ||
val e = values.next() | ||
val c = colorCache.set(e).premultiplyAlpha() | ||
val v = sqrt((c.r - pc.r) * (c.r - pc.r) + | ||
(c.g - pc.g) * (c.g - pc.g) + | ||
(c.b - pc.b) * (c.b - pc.b)) | ||
if (diff > v) { | ||
min = e | ||
diff = v | ||
} | ||
} | ||
|
||
if (diff < 0.01) { | ||
similar.put(pixel, min) | ||
pixels.putInt(i, min) | ||
} else { | ||
missingCount++ | ||
println("Missing 0x${Integer.toHexString(pixel).uppercase()} | Closest: 0x${Integer.toHexString(min).uppercase()} | File: $fileName | Diff: $diff") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters