Removed Path API usage

This commit is contained in:
Anuken
2019-12-15 21:12:41 -05:00
parent 0cf39bf5c3
commit e9ed0512f7
4 changed files with 87 additions and 115 deletions

View File

@ -7,8 +7,6 @@ import io.anuke.arc.files.*;
import io.anuke.arc.util.*;
import io.anuke.arc.util.io.*;
import java.io.*;
public class Version{
/** Build type. 'official' for official releases; 'custom' or 'bleeding edge' are also used. */
public static String type;
@ -26,7 +24,6 @@ public class Version{
public static void init(){
if(!enabled) return;
try{
Fi file = OS.isAndroid || OS.isIos ? Core.files.internal("version.properties") : new Fi("version.properties", FileType.Internal);
ObjectMap<String, String> map = new ObjectMap<>();
@ -47,8 +44,5 @@ public class Version{
}else{
build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1;
}
}catch(IOException e){
throw new RuntimeException(e);
}
}
}

View File

@ -1,14 +1,12 @@
package io.anuke.mindustry.tools;
import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.OrderedMap;
import io.anuke.arc.func.Func2;
import io.anuke.arc.util.Log;
import io.anuke.arc.util.Strings;
import io.anuke.arc.util.io.PropertiesUtils;
import io.anuke.arc.collection.*;
import io.anuke.arc.files.*;
import io.anuke.arc.func.*;
import io.anuke.arc.util.*;
import io.anuke.arc.util.io.*;
import java.io.*;
import java.nio.file.*;
public class BundleLauncher{
@ -17,16 +15,14 @@ public class BundleLauncher{
OrderedMap<String, String> base = new OrderedMap<>();
PropertiesUtils.load(base, new InputStreamReader(new FileInputStream(file)));
Array<String> removals = new Array<>();
Files.walk(Paths.get("")).forEach(child -> {
try{
if(child.getFileName().toString().equals("bundle.properties") || Files.isDirectory(child) || child.toString().contains("output"))
Fi.get("").walk(child -> {
if(child.name().equals("bundle.properties") || child.isDirectory() || child.toString().contains("output"))
return;
Log.info("Parsing bundle: {0}", child);
OrderedMap<String, String> other = new OrderedMap<>();
PropertiesUtils.load(other, Files.newBufferedReader(child, Strings.utf8));
PropertiesUtils.load(other, child.reader(2048, "UTF-8"));
removals.clear();
for(String key : other.orderedKeys()){
@ -52,7 +48,7 @@ public class BundleLauncher{
Func2<String, String, String> processor = (key, value) -> (key + " = " + value).replace("\\", "\\\\").replace("\n", "\\n") + "\n";
Path output = child.resolveSibling("output/" + child.getFileName());
Fi output = child.sibling("output/" + child.name());
Log.info("&lc{0} keys added.", added);
Log.info("Writing bundle to {0}", output);
@ -64,11 +60,7 @@ public class BundleLauncher{
other.remove(key);
}
Files.write(child, result.toString().getBytes(Strings.utf8));
}catch(IOException e){
throw new RuntimeException(e);
}
child.writeString(result.toString());
});
}

View File

@ -1,21 +1,19 @@
package io.anuke.mindustry.tools;
import io.anuke.arc.collection.*;
import io.anuke.arc.files.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.math.*;
import io.anuke.arc.util.*;
import io.anuke.arc.util.noise.*;
import io.anuke.mindustry.tools.ImagePacker.*;
import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.tools.ImagePacker.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.ui.*;
import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.*;
import java.io.*;
import java.nio.file.*;
import static io.anuke.mindustry.Vars.*;
public class Generators{
@ -73,18 +71,14 @@ public class Generators{
for(Block block : content.blocks()){
TextureRegion[] regions = block.getGeneratedIcons();
try{
if(block instanceof Floor){
block.load();
for(TextureRegion region : block.variantRegions()){
GenRegion gen = (GenRegion)region;
if(gen.path == null) continue;
Files.copy(gen.path, Paths.get("../editor/editor-" + gen.path.getFileName()));
gen.path.copyTo(Fi.get("../editor/editor-" + gen.path.name()));
}
}
}catch(IOException e){
throw new RuntimeException(e);
}
if(regions.length == 0){
continue;
@ -120,11 +114,7 @@ public class Generators{
}
}
try{
Files.delete(region.path);
}catch(IOException e){
e.printStackTrace();
}
region.path.delete();
out.save(block.name);
}

View File

@ -1,24 +1,24 @@
package io.anuke.mindustry.tools;
import io.anuke.arc.Core;
import io.anuke.arc.collection.ObjectMap;
import io.anuke.arc.*;
import io.anuke.arc.collection.*;
import io.anuke.arc.files.*;
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.Log.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.core.ContentLoader;
import io.anuke.mindustry.core.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.file.*;
import javax.imageio.*;
import java.awt.image.*;
import java.io.*;
public class ImagePacker{
static ObjectMap<String, TextureRegion> regionCache = 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;
Log.setLogger(new NoopLogHandler());
@ -26,14 +26,11 @@ public class ImagePacker{
Vars.content.createBaseContent();
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{
if(Files.isDirectory(path)) return;
String fname = path.getFileName().toString();
fname = fname.substring(0, fname.length() - 4);
BufferedImage image = ImageIO.read(path.toFile());
BufferedImage image = ImageIO.read(path.file());
GenRegion region = new GenRegion(fname, path){
@Override
@ -59,9 +56,8 @@ public class ImagePacker{
regionCache.put(fname, region);
imageCache.put(region, image);
}catch(IOException e){
e.printStackTrace();
throw new RuntimeException(e);
}
});
@ -134,9 +130,9 @@ public class ImagePacker{
static class GenRegion extends AtlasRegion{
String name;
boolean invalid;
Path path;
Fi path;
GenRegion(String name, Path path){
GenRegion(String name, Fi path){
this.name = name;
this.path = path;
}