semicolons begone

This commit is contained in:
Anuken
2021-12-22 00:05:02 -05:00
parent 45b81fae37
commit d0c30147d8
2 changed files with 64 additions and 87 deletions

View File

@@ -402,7 +402,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
public SteamConnection(SteamID sid){ public SteamConnection(SteamID sid){
super(sid.getAccountID() + ""); super(sid.getAccountID() + "");
this.sid = sid; this.sid = sid;
Log.info("Create STEAM client @", sid.getAccountID()); Log.info("Created STEAM connection: @", sid.getAccountID());
} }
@Override @Override

View File

@@ -1,14 +1,13 @@
sourceSets.main.java.srcDirs = ["src/"] sourceSets.main.java.srcDirs = ["src/"]
import arc.files.Fi import arc.files.Fi
import arc.files.ZipFi import arc.files.ZipFi
import arc.func.Func2 import arc.func.Func2
import arc.graphics.Color import arc.graphics.Color
import arc.graphics.Pixmap import arc.graphics.Pixmap
import arc.packer.TexturePacker import arc.packer.TexturePacker
import arc.struct.IntIntMap
import arc.struct.IntMap
import arc.struct.ObjectMap import arc.struct.ObjectMap
import arc.struct.OrderedMap import arc.struct.OrderedMap
import arc.struct.Seq import arc.struct.Seq
@@ -24,33 +23,11 @@ import java.util.concurrent.Executors
def genFolder = "../core/assets-raw/sprites_out/generated/" def genFolder = "../core/assets-raw/sprites_out/generated/"
def doAntialias = !project.hasProperty("disableAntialias") def doAntialias = !project.hasProperty("disableAntialias")
def colorMap = new IntMap<List<Color>>(), colorIndexMap = new IntIntMap()
def enableAA = true def enableAA = true
//on my machine, I have a native Nim AA implementation that is ~10x faster //on my machine, I have a native Nim AA implementation that is ~10x faster
//it's not compiled for other platforms so they don't get it //it's not compiled for other platforms so they don't get it
def useFastAA = project.hasProperty("fastAA") || System.getProperty("user.name") == "anuke" def useFastAA = project.hasProperty("fastAA") || System.getProperty("user.name") == "anuke"
def transformColors = { List<List<String>> list ->
list.each{ colors ->
def newColors = []
colors.each{ hexc ->
newColors += Color.valueOf(hexc)
}
newColors.each{ color ->
colorMap.put(color.rgba(), newColors)
colorIndexMap.put(color.rgba(), newColors.indexOf(color))
}
}
}
//TODO implementing this in gradle is a bad idea
//d4816b
transformColors([["4a4b53", "6e7080", "989aa4"], ["3a5651", "3a8f64", "92dd7e"], ["bf92f9", "8a73c6", "665c9f"]/*, ["6e7080", "989aa4", "b0bac0"]*/, ["bc5452", "ea8878", "feb380"],
["de9458", "f8c266", "ffe18f"], ["feb380", "ea8878", "bc5452"], ["d4816b", "eab678", "ffd37f"], ["d57c65", "e3ae6f", "f7e97e"],
["ffffff", "dcc6c6", "9d7f7f"], ["df7646", "b23a4d", "752249"], ["3c3837", "515151", "646567"],
["5757c1", "6f80e8", "88a4ff"], ["8f665b", "b28768", "c9a58f"], ["4c5878", "768a9a", "a0b0c8"], ["62ae7f", "62ae7f", "84f491"]])
def antialias = { File file -> def antialias = { File file ->
if(!doAntialias) return if(!doAntialias) return
@@ -236,29 +213,29 @@ task fontgen(dependsOn: classes, type: JavaExec){
4. use json to generate a file with constants for every icon size+type (during annotation processing) 4. use json to generate a file with constants for every icon size+type (during annotation processing)
*/ */
doLast{ doLast{
Fi folder = Fi.get("core/assets-raw/fontgen/out/"); Fi folder = Fi.get("core/assets-raw/fontgen/out/")
folder.mkdirs(); folder.mkdirs()
Log.info("Session..."); Log.info("Session...")
OS.exec("curl", "--fail", "--output", "core/assets-raw/fontgen/out/session", "--form", "config=@core/assets-raw/fontgen/config.json", "https://fontello.com"); OS.exec("curl", "--fail", "--output", "core/assets-raw/fontgen/out/session", "--form", "config=@core/assets-raw/fontgen/config.json", "https://fontello.com")
Log.info("Zip..."); Log.info("Zip...")
String session = folder.child("session").readString(); String session = folder.child("session").readString()
Http.get("https://fontello.com/" + session + "/get").block(result -> { Http.get("https://fontello.com/" + session + "/get").block(result -> {
Streams.copy(result.getResultAsStream(), folder.child("font.zip").write()); Streams.copy(result.getResultAsStream(), folder.child("font.zip").write())
}); })
Log.info("Icon font..."); Log.info("Icon font...")
ZipFi zip = new ZipFi(folder.child("font.zip")); ZipFi zip = new ZipFi(folder.child("font.zip"))
Fi dest = folder.child("font.woff"); Fi dest = folder.child("font.woff")
zip.list()[0].child("font").child("fontello.ttf").copyTo(dest); zip.list()[0].child("font").child("fontello.ttf").copyTo(dest)
dest.copyTo(Fi.get("core/assets/fonts/icon.ttf")); dest.copyTo(Fi.get("core/assets/fonts/icon.ttf"))
Log.info("Merge..."); Log.info("Merge...")
//TODO this is broken //TODO this is broken
@@ -266,9 +243,9 @@ task fontgen(dependsOn: classes, type: JavaExec){
Fi.get("core/assets-raw/fontgen/merge.pe").absolutePath(), Fi.get("core/assets-raw/fontgen/merge.pe").absolutePath(),
Fi.get("core/assets/fonts/font.woff").absolutePath(), Fi.get("core/assets/fonts/font.woff").absolutePath(),
Fi.get("core/assets-raw/fontgen/out/font.woff").absolutePath()) Fi.get("core/assets-raw/fontgen/out/font.woff").absolutePath())
); )
Log.info("Done."); Log.info("Done.")
} }
} }
@@ -289,104 +266,104 @@ task updateScripts(dependsOn: classes, type: JavaExec){
task updateBundles{ task updateBundles{
doLast{ doLast{
def uniEscape = { String string -> def uniEscape = { String string ->
StringBuilder outBuffer = new StringBuilder(); StringBuilder outBuffer = new StringBuilder()
int len = string.length(); int len = string.length()
for(int i = 0; i < len; i++){ for(int i = 0; i < len; i++){
char ch = string.charAt(i); char ch = string.charAt(i)
if((ch > 61) && (ch < 127)){ if((ch > 61) && (ch < 127)){
outBuffer.append(ch == '\\' ? "\\\\" : ch); outBuffer.append(ch == (char)'\\' ? "\\\\" : ch)
continue; continue
} }
if(ch >= 0xE000 && ch <= 0xF8FF){ if(ch >= 0xE000 && ch <= 0xF8FF){
String hex = Integer.toHexString((int)ch); String hex = Integer.toHexString((int)ch)
outBuffer.append("\\u"); outBuffer.append("\\u")
for(int j = 0; j < 4 - hex.length(); j++){ for(int j = 0; j < 4 - hex.length(); j++){
outBuffer.append('0'); outBuffer.append('0')
} }
outBuffer.append(hex); outBuffer.append(hex)
}else{ }else{
outBuffer.append(ch); outBuffer.append(ch)
} }
} }
return outBuffer.toString(); return outBuffer.toString()
} }
OrderedMap<String, String> base = new OrderedMap<>(); OrderedMap<String, String> base = new OrderedMap<>()
PropertiesUtils.load(base, Fi.get("core/assets/bundles/bundle.properties").reader()); PropertiesUtils.load(base, Fi.get("core/assets/bundles/bundle.properties").reader())
Seq<String> removals = new Seq<>(); Seq<String> removals = new Seq<>()
Log.info("Updating bundles..."); Log.info("Updating bundles...")
Fi.get("core/assets/bundles").walk(child -> { Fi.get("core/assets/bundles").walk(child -> {
if(child.name().equals("bundle.properties") || child.toString().contains("output")) return; if(child.name().equals("bundle.properties") || child.toString().contains("output")) return
Log.info("| @", child.nameWithoutExtension()); Log.info("| @", child.nameWithoutExtension())
OrderedMap<String, String> other = new OrderedMap<>(); OrderedMap<String, String> other = new OrderedMap<>()
//find the last known comment of each line //find the last known comment of each line
ObjectMap<String, String> comments = new ObjectMap<>(); ObjectMap<String, String> comments = new ObjectMap<>()
StringBuilder curComment = new StringBuilder(); StringBuilder curComment = new StringBuilder()
for(String line : Seq.with(child.readString().split("\n", -1))){ for(String line : Seq.with(child.readString().split("\n", -1))){
if(line.startsWith("#") || line.isEmpty()){ if(line.startsWith("#") || line.isEmpty()){
curComment.append(line).append("\n"); curComment.append(line).append("\n")
}else if(line.contains("=")){ }else if(line.contains("=")){
String lastKey = line.substring(0, line.indexOf("=")).trim(); String lastKey = line.substring(0, line.indexOf("=")).trim()
if(curComment.length() != 0){ if(curComment.length() != 0){
comments.put(lastKey, curComment.toString()); comments.put(lastKey, curComment.toString())
curComment.setLength(0); curComment.setLength(0)
} }
} }
} }
ObjectMap<String, String> extras = new OrderedMap<>(); ObjectMap<String, String> extras = new OrderedMap<>()
PropertiesUtils.load(other, child.reader()); PropertiesUtils.load(other, child.reader())
removals.clear(); removals.clear()
for(String key : other.orderedKeys()){ for(String key : other.orderedKeys()){
if(!base.containsKey(key) && key.contains(".details")){ if(!base.containsKey(key) && key.contains(".details")){
extras.put(key, other.get(key)); extras.put(key, other.get(key))
}else if(!base.containsKey(key)){ }else if(!base.containsKey(key)){
removals.add(key); removals.add(key)
Log.info("&lr- Removing unused key '@'...", key); Log.info("&lr- Removing unused key '@'...", key)
} }
} }
if(removals.size > 0) Log.info("&lr@ keys removed.", removals.size); if(removals.size > 0) Log.info("&lr@ keys removed.", removals.size)
for(String s : removals){ for(String s : removals){
other.remove(s); other.remove(s)
} }
int added = 0; int added = 0
for(String key : base.orderedKeys()){ for(String key : base.orderedKeys()){
if(other.get(key) == null || other.get(key).trim().isEmpty()){ if(other.get(key) == null || other.get(key).trim().isEmpty()){
other.put(key, base.get(key)); other.put(key, base.get(key))
added++; added++
Log.info("&lc- Adding missing key '@'...", key); Log.info("&lc- Adding missing key '@'...", key)
} }
} }
Func2<String, String, String> processor = (key, value) -> Func2<String, String, String> processor = (key, value) ->
(comments.containsKey(key) ? comments.get(key) : "") + //append last known comment if present (comments.containsKey(key) ? comments.get(key) : "") + //append last known comment if present
(key + " =" + (value.trim().isEmpty() ? "" : " ") + uniEscape(value)).replace("\n", "\\n") + "\n"; (key + " =" + (value.trim().isEmpty() ? "" : " ") + uniEscape(value)).replace("\n", "\\n") + "\n"
Fi output = child.sibling("output/" + child.name()); Fi output = child.sibling("output/" + child.name())
if(added > 0) Log.info("&lc@ keys added.", added); if(added > 0) Log.info("&lc@ keys added.", added)
if(removals.size + added > 0) Log.info("Writing bundle to @", output); if(removals.size + added > 0) Log.info("Writing bundle to @", output)
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder()
//add everything ordered //add everything ordered
for(String key : base.orderedKeys().copy().and(extras.keys().toSeq())){ for(String key : base.orderedKeys().copy().and(extras.keys().toSeq())){
if(other.get(key) == null) continue; if(other.get(key) == null) continue
result.append(processor.get(key, other.get(key))); result.append(processor.get(key, other.get(key)))
other.remove(key); other.remove(key)
} }
child.writeString(result.toString()); child.writeString(result.toString())
}); })
} }
} }