Removed Path API usage
This commit is contained in:
@@ -7,8 +7,6 @@ import io.anuke.arc.files.*;
|
|||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.io.*;
|
import io.anuke.arc.util.io.*;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
public class Version{
|
public class Version{
|
||||||
/** Build type. 'official' for official releases; 'custom' or 'bleeding edge' are also used. */
|
/** Build type. 'official' for official releases; 'custom' or 'bleeding edge' are also used. */
|
||||||
public static String type;
|
public static String type;
|
||||||
@@ -26,29 +24,25 @@ public class Version{
|
|||||||
public static void init(){
|
public static void init(){
|
||||||
if(!enabled) return;
|
if(!enabled) return;
|
||||||
|
|
||||||
try{
|
Fi file = OS.isAndroid || OS.isIos ? Core.files.internal("version.properties") : new Fi("version.properties", FileType.Internal);
|
||||||
Fi file = OS.isAndroid || OS.isIos ? Core.files.internal("version.properties") : new Fi("version.properties", FileType.Internal);
|
|
||||||
|
|
||||||
ObjectMap<String, String> map = new ObjectMap<>();
|
ObjectMap<String, String> map = new ObjectMap<>();
|
||||||
PropertiesUtils.load(map, file.reader());
|
PropertiesUtils.load(map, file.reader());
|
||||||
|
|
||||||
type = map.get("type");
|
type = map.get("type");
|
||||||
number = Integer.parseInt(map.get("number", "4"));
|
number = Integer.parseInt(map.get("number", "4"));
|
||||||
modifier = map.get("modifier");
|
modifier = map.get("modifier");
|
||||||
if(map.get("build").contains(".")){
|
if(map.get("build").contains(".")){
|
||||||
String[] split = map.get("build").split("\\.");
|
String[] split = map.get("build").split("\\.");
|
||||||
try{
|
try{
|
||||||
build = Integer.parseInt(split[0]);
|
build = Integer.parseInt(split[0]);
|
||||||
revision = Integer.parseInt(split[1]);
|
revision = Integer.parseInt(split[1]);
|
||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
build = -1;
|
build = -1;
|
||||||
}
|
|
||||||
}else{
|
|
||||||
build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1;
|
|
||||||
}
|
}
|
||||||
}catch(IOException e){
|
}else{
|
||||||
throw new RuntimeException(e);
|
build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
package io.anuke.mindustry.tools;
|
package io.anuke.mindustry.tools;
|
||||||
|
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.collection.OrderedMap;
|
import io.anuke.arc.files.*;
|
||||||
import io.anuke.arc.func.Func2;
|
import io.anuke.arc.func.*;
|
||||||
import io.anuke.arc.util.Log;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.Strings;
|
import io.anuke.arc.util.io.*;
|
||||||
import io.anuke.arc.util.io.PropertiesUtils;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.*;
|
|
||||||
|
|
||||||
public class BundleLauncher{
|
public class BundleLauncher{
|
||||||
|
|
||||||
@@ -17,58 +15,52 @@ public class BundleLauncher{
|
|||||||
OrderedMap<String, String> base = new OrderedMap<>();
|
OrderedMap<String, String> base = new OrderedMap<>();
|
||||||
PropertiesUtils.load(base, new InputStreamReader(new FileInputStream(file)));
|
PropertiesUtils.load(base, new InputStreamReader(new FileInputStream(file)));
|
||||||
Array<String> removals = new Array<>();
|
Array<String> removals = new Array<>();
|
||||||
|
Fi.get("").walk(child -> {
|
||||||
|
if(child.name().equals("bundle.properties") || child.isDirectory() || child.toString().contains("output"))
|
||||||
|
return;
|
||||||
|
|
||||||
Files.walk(Paths.get("")).forEach(child -> {
|
Log.info("Parsing bundle: {0}", child);
|
||||||
try{
|
|
||||||
if(child.getFileName().toString().equals("bundle.properties") || Files.isDirectory(child) || child.toString().contains("output"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Log.info("Parsing bundle: {0}", child);
|
OrderedMap<String, String> other = new OrderedMap<>();
|
||||||
|
PropertiesUtils.load(other, child.reader(2048, "UTF-8"));
|
||||||
|
removals.clear();
|
||||||
|
|
||||||
OrderedMap<String, String> other = new OrderedMap<>();
|
for(String key : other.orderedKeys()){
|
||||||
PropertiesUtils.load(other, Files.newBufferedReader(child, Strings.utf8));
|
if(!base.containsKey(key)){
|
||||||
removals.clear();
|
removals.add(key);
|
||||||
|
Log.info("&lr- Removing unused key '{0}'...", key);
|
||||||
for(String key : other.orderedKeys()){
|
|
||||||
if(!base.containsKey(key)){
|
|
||||||
removals.add(key);
|
|
||||||
Log.info("&lr- Removing unused key '{0}'...", key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Log.info("&lr{0} keys removed.", removals.size);
|
|
||||||
for(String s : removals){
|
|
||||||
other.remove(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
int added = 0;
|
|
||||||
|
|
||||||
for(String key : base.orderedKeys()){
|
|
||||||
if(!other.containsKey(key) || other.get(key).trim().isEmpty()){
|
|
||||||
other.put(key, base.get(key));
|
|
||||||
added++;
|
|
||||||
Log.info("&lc- Adding missing key '{0}'...", key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Func2<String, String, String> processor = (key, value) -> (key + " = " + value).replace("\\", "\\\\").replace("\n", "\\n") + "\n";
|
|
||||||
|
|
||||||
Path output = child.resolveSibling("output/" + child.getFileName());
|
|
||||||
|
|
||||||
Log.info("&lc{0} keys added.", added);
|
|
||||||
Log.info("Writing bundle to {0}", output);
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
|
|
||||||
//add everything ordered
|
|
||||||
for(String key : base.orderedKeys()){
|
|
||||||
result.append(processor.get(key, other.get(key)));
|
|
||||||
other.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
Files.write(child, result.toString().getBytes(Strings.utf8));
|
|
||||||
|
|
||||||
}catch(IOException e){
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
|
Log.info("&lr{0} keys removed.", removals.size);
|
||||||
|
for(String s : removals){
|
||||||
|
other.remove(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
int added = 0;
|
||||||
|
|
||||||
|
for(String key : base.orderedKeys()){
|
||||||
|
if(!other.containsKey(key) || other.get(key).trim().isEmpty()){
|
||||||
|
other.put(key, base.get(key));
|
||||||
|
added++;
|
||||||
|
Log.info("&lc- Adding missing key '{0}'...", key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Func2<String, String, String> processor = (key, value) -> (key + " = " + value).replace("\\", "\\\\").replace("\n", "\\n") + "\n";
|
||||||
|
|
||||||
|
Fi output = child.sibling("output/" + child.name());
|
||||||
|
|
||||||
|
Log.info("&lc{0} keys added.", added);
|
||||||
|
Log.info("Writing bundle to {0}", output);
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
|
//add everything ordered
|
||||||
|
for(String key : base.orderedKeys()){
|
||||||
|
result.append(processor.get(key, other.get(key)));
|
||||||
|
other.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
child.writeString(result.toString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
package io.anuke.mindustry.tools;
|
package io.anuke.mindustry.tools;
|
||||||
|
|
||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
|
import io.anuke.arc.files.*;
|
||||||
import io.anuke.arc.graphics.*;
|
import io.anuke.arc.graphics.*;
|
||||||
import io.anuke.arc.graphics.g2d.*;
|
import io.anuke.arc.graphics.g2d.*;
|
||||||
import io.anuke.arc.math.*;
|
import io.anuke.arc.math.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.noise.*;
|
import io.anuke.arc.util.noise.*;
|
||||||
import io.anuke.mindustry.tools.ImagePacker.*;
|
|
||||||
import io.anuke.mindustry.ctype.*;
|
import io.anuke.mindustry.ctype.*;
|
||||||
|
import io.anuke.mindustry.tools.ImagePacker.*;
|
||||||
import io.anuke.mindustry.type.*;
|
import io.anuke.mindustry.type.*;
|
||||||
import io.anuke.mindustry.ui.*;
|
import io.anuke.mindustry.ui.*;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.nio.file.*;
|
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Generators{
|
public class Generators{
|
||||||
@@ -73,17 +71,13 @@ public class Generators{
|
|||||||
for(Block block : content.blocks()){
|
for(Block block : content.blocks()){
|
||||||
TextureRegion[] regions = block.getGeneratedIcons();
|
TextureRegion[] regions = block.getGeneratedIcons();
|
||||||
|
|
||||||
try{
|
if(block instanceof Floor){
|
||||||
if(block instanceof Floor){
|
block.load();
|
||||||
block.load();
|
for(TextureRegion region : block.variantRegions()){
|
||||||
for(TextureRegion region : block.variantRegions()){
|
GenRegion gen = (GenRegion)region;
|
||||||
GenRegion gen = (GenRegion)region;
|
if(gen.path == null) continue;
|
||||||
if(gen.path == null) continue;
|
gen.path.copyTo(Fi.get("../editor/editor-" + gen.path.name()));
|
||||||
Files.copy(gen.path, Paths.get("../editor/editor-" + gen.path.getFileName()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}catch(IOException e){
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(regions.length == 0){
|
if(regions.length == 0){
|
||||||
@@ -120,11 +114,7 @@ public class Generators{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
region.path.delete();
|
||||||
Files.delete(region.path);
|
|
||||||
}catch(IOException e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
out.save(block.name);
|
out.save(block.name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
package io.anuke.mindustry.tools;
|
package io.anuke.mindustry.tools;
|
||||||
|
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.collection.ObjectMap;
|
import io.anuke.arc.collection.*;
|
||||||
|
import io.anuke.arc.files.*;
|
||||||
import io.anuke.arc.graphics.g2d.*;
|
import io.anuke.arc.graphics.g2d.*;
|
||||||
import io.anuke.arc.graphics.g2d.TextureAtlas.AtlasRegion;
|
import io.anuke.arc.graphics.g2d.TextureAtlas.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.Log.*;
|
import io.anuke.arc.util.Log.*;
|
||||||
import io.anuke.mindustry.*;
|
import io.anuke.mindustry.*;
|
||||||
import io.anuke.mindustry.core.ContentLoader;
|
import io.anuke.mindustry.core.*;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.*;
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
import java.nio.file.*;
|
|
||||||
|
|
||||||
public class ImagePacker{
|
public class ImagePacker{
|
||||||
static ObjectMap<String, TextureRegion> regionCache = new ObjectMap<>();
|
static ObjectMap<String, TextureRegion> regionCache = new ObjectMap<>();
|
||||||
static ObjectMap<TextureRegion, BufferedImage> imageCache = new ObjectMap<>();
|
static ObjectMap<TextureRegion, BufferedImage> imageCache = new ObjectMap<>();
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException{
|
public static void main(String[] args){
|
||||||
Vars.headless = true;
|
Vars.headless = true;
|
||||||
|
|
||||||
Log.setLogger(new NoopLogHandler());
|
Log.setLogger(new NoopLogHandler());
|
||||||
@@ -26,14 +26,11 @@ public class ImagePacker{
|
|||||||
Vars.content.createBaseContent();
|
Vars.content.createBaseContent();
|
||||||
Log.setLogger(new DefaultLogHandler());
|
Log.setLogger(new DefaultLogHandler());
|
||||||
|
|
||||||
Files.walk(Paths.get("../../../assets-raw/sprites_out")).forEach(path -> {
|
Fi.get("../../../assets-raw/sprites_out").walk(path -> {
|
||||||
|
String fname = path.nameWithoutExtension();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if(Files.isDirectory(path)) return;
|
BufferedImage image = ImageIO.read(path.file());
|
||||||
|
|
||||||
String fname = path.getFileName().toString();
|
|
||||||
fname = fname.substring(0, fname.length() - 4);
|
|
||||||
|
|
||||||
BufferedImage image = ImageIO.read(path.toFile());
|
|
||||||
GenRegion region = new GenRegion(fname, path){
|
GenRegion region = new GenRegion(fname, path){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -59,9 +56,8 @@ public class ImagePacker{
|
|||||||
|
|
||||||
regionCache.put(fname, region);
|
regionCache.put(fname, region);
|
||||||
imageCache.put(region, image);
|
imageCache.put(region, image);
|
||||||
|
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
e.printStackTrace();
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -134,9 +130,9 @@ public class ImagePacker{
|
|||||||
static class GenRegion extends AtlasRegion{
|
static class GenRegion extends AtlasRegion{
|
||||||
String name;
|
String name;
|
||||||
boolean invalid;
|
boolean invalid;
|
||||||
Path path;
|
Fi path;
|
||||||
|
|
||||||
GenRegion(String name, Path path){
|
GenRegion(String name, Fi path){
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user