Palette swap / Blocks changed and renamed

This commit is contained in:
Anuken
2018-08-20 21:04:02 -04:00
parent 8ba2db6c58
commit 258ab87f6b
632 changed files with 631 additions and 592 deletions

View File

@@ -3,10 +3,47 @@ apply plugin: "java"
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.tools.texturepacker.TexturePacker
import javax.imageio.ImageIO
def textureFolder = "../core/assets-raw/sprites/generated/"
task swapColors(){
doLast{
if (project.hasProperty("colors")) {
def carr = new File(getProperty("colors")).text.split("\n");
def map = [:]
def swaps = 0
carr.each {str -> map[Color.argb8888(Color.valueOf(str.split("=")[0]))] = Color.argb8888(Color.valueOf(str.split("=")[1]))}
def tmpc = new Color()
fileTree(dir: '../core/assets-raw/sprites', include: "**/*.png").visit { file ->
if(file.isDirectory()) return;
swaps ++
def img = ImageIO.read(file.file)
for (x in (0..img.getWidth()-1)) {
for (y in (0..img.getHeight()-1)) {
def c = img.getRGB(x, y)
Color.argb8888ToColor(tmpc, c)
if(tmpc.a < 0.1f) continue;
if(map.containsKey(c)){
img.setRGB(x, y, (int)map.get(c))
}
}
}
ImageIO.write(img, "png", file.file)
}
println "Swapped $swaps images."
}else{
throw new InvalidUserDataException("No replacement colors specified. Use -Pcolors=\"<path to color file>\"");
}
}
}
task pack(){
dependsOn 'prePack'