Eliminated 8 characters

This commit is contained in:
Anuken
2019-12-15 20:01:06 -05:00
parent 95a1474b9a
commit 0cf39bf5c3
40 changed files with 195 additions and 193 deletions

View File

@@ -70,11 +70,11 @@ public class AndroidLauncher extends AndroidApplication{
} }
@Override @Override
public void shareFile(FileHandle file){ public void shareFile(Fi file){
} }
@Override @Override
public void showFileChooser(boolean open, String extension, Cons<FileHandle> cons){ public void showFileChooser(boolean open, String extension, Cons<Fi> cons){
if(VERSION.SDK_INT >= VERSION_CODES.Q){ if(VERSION.SDK_INT >= VERSION_CODES.Q){
Intent intent = new Intent(open ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_CREATE_DOCUMENT); Intent intent = new Intent(open ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE); intent.addCategory(Intent.CATEGORY_OPENABLE);
@@ -85,7 +85,7 @@ public class AndroidLauncher extends AndroidApplication{
if(uri.getPath().contains("(invalid)")) return; if(uri.getPath().contains("(invalid)")) return;
Core.app.post(() -> Core.app.post(() -> cons.get(new FileHandle(uri.getPath()){ Core.app.post(() -> Core.app.post(() -> cons.get(new Fi(uri.getPath()){
@Override @Override
public InputStream read(){ public InputStream read(){
try{ try{
@@ -185,7 +185,7 @@ public class AndroidLauncher extends AndroidApplication{
Core.app.post(() -> Core.app.post(() -> { Core.app.post(() -> Core.app.post(() -> {
if(save){ //open save if(save){ //open save
System.out.println("Opening save."); System.out.println("Opening save.");
FileHandle file = Core.files.local("temp-save." + saveExtension); Fi file = Core.files.local("temp-save." + saveExtension);
file.write(inStream, false); file.write(inStream, false);
if(SaveIO.isSaveValid(file)){ if(SaveIO.isSaveValid(file)){
try{ try{
@@ -198,7 +198,7 @@ public class AndroidLauncher extends AndroidApplication{
ui.showErrorMessage("$save.import.invalid"); ui.showErrorMessage("$save.import.invalid");
} }
}else if(map){ //open map }else if(map){ //open map
FileHandle file = Core.files.local("temp-map." + mapExtension); Fi file = Core.files.local("temp-map." + mapExtension);
file.write(inStream, false); file.write(inStream, false);
Core.app.post(() -> { Core.app.post(() -> {
System.out.println("Opening map."); System.out.println("Opening map.");

View File

@@ -125,21 +125,21 @@ public class Vars implements Loadable{
/** whether typing into the console is enabled - developers only */ /** whether typing into the console is enabled - developers only */
public static boolean enableConsole = false; public static boolean enableConsole = false;
/** application data directory, equivalent to {@link io.anuke.arc.Settings#getDataDirectory()} */ /** application data directory, equivalent to {@link io.anuke.arc.Settings#getDataDirectory()} */
public static FileHandle dataDirectory; public static Fi dataDirectory;
/** data subdirectory used for screenshots */ /** data subdirectory used for screenshots */
public static FileHandle screenshotDirectory; public static Fi screenshotDirectory;
/** data subdirectory used for custom mmaps */ /** data subdirectory used for custom mmaps */
public static FileHandle customMapDirectory; public static Fi customMapDirectory;
/** data subdirectory used for custom mmaps */ /** data subdirectory used for custom mmaps */
public static FileHandle mapPreviewDirectory; public static Fi mapPreviewDirectory;
/** tmp subdirectory for map conversion */ /** tmp subdirectory for map conversion */
public static FileHandle tmpDirectory; public static Fi tmpDirectory;
/** data subdirectory used for saves */ /** data subdirectory used for saves */
public static FileHandle saveDirectory; public static Fi saveDirectory;
/** data subdirectory used for mods */ /** data subdirectory used for mods */
public static FileHandle modDirectory; public static Fi modDirectory;
/** data subdirectory used for schematics */ /** data subdirectory used for schematics */
public static FileHandle schematicDirectory; public static Fi schematicDirectory;
/** map file extension */ /** map file extension */
public static final String mapExtension = "msav"; public static final String mapExtension = "msav";
/** save file extension */ /** save file extension */
@@ -317,7 +317,7 @@ public class Vars implements Loadable{
try{ try{
//try loading external bundle //try loading external bundle
FileHandle handle = Core.files.local("bundle"); Fi handle = Core.files.local("bundle");
Locale locale = Locale.ENGLISH; Locale locale = Locale.ENGLISH;
Core.bundle = I18NBundle.createBundle(handle, locale); Core.bundle = I18NBundle.createBundle(handle, locale);
@@ -330,7 +330,7 @@ public class Vars implements Loadable{
}catch(Throwable e){ }catch(Throwable e){
//no external bundle found //no external bundle found
FileHandle handle = Core.files.internal("bundles/bundle"); Fi handle = Core.files.internal("bundles/bundle");
Locale locale; Locale locale;
String loc = Core.settings.getString("locale"); String loc = Core.settings.getString("locale");
if(loc.equals("default")){ if(loc.equals("default")){

View File

@@ -7,14 +7,14 @@ import io.anuke.arc.files.*;
/** Handles files in a modded context. */ /** Handles files in a modded context. */
public class FileTree implements FileHandleResolver{ public class FileTree implements FileHandleResolver{
private ObjectMap<String, FileHandle> files = new ObjectMap<>(); private ObjectMap<String, Fi> files = new ObjectMap<>();
public void addFile(String path, FileHandle f){ public void addFile(String path, Fi f){
files.put(path, f); files.put(path, f);
} }
/** Gets an asset file.*/ /** Gets an asset file.*/
public FileHandle get(String path){ public Fi get(String path){
if(files.containsKey(path)){ if(files.containsKey(path)){
return files.get(path); return files.get(path);
}else if(files.containsKey("/" + path)){ }else if(files.containsKey("/" + path)){
@@ -30,7 +30,7 @@ public class FileTree implements FileHandleResolver{
} }
@Override @Override
public FileHandle resolve(String fileName){ public Fi resolve(String fileName){
return get(fileName); return get(fileName);
} }
} }

View File

@@ -35,7 +35,7 @@ public interface Platform{
default void viewListingID(String mapid){} default void viewListingID(String mapid){}
/** Steam: Return external workshop maps to be loaded.*/ /** Steam: Return external workshop maps to be loaded.*/
default Array<FileHandle> getWorkshopContent(Class<? extends Publishable> type){ default Array<Fi> getWorkshopContent(Class<? extends Publishable> type){
return new Array<>(0); return new Array<>(0);
} }
@@ -100,7 +100,7 @@ public interface Platform{
} }
/** Only used for iOS or android: open the share menu for a map or save. */ /** Only used for iOS or android: open the share menu for a map or save. */
default void shareFile(FileHandle file){ default void shareFile(Fi file){
} }
/** /**
@@ -109,7 +109,7 @@ public interface Platform{
* @param open Whether to open or save files * @param open Whether to open or save files
* @param extension File extension to filter * @param extension File extension to filter
*/ */
default void showFileChooser(boolean open, String extension, Cons<FileHandle> cons){ default void showFileChooser(boolean open, String extension, Cons<Fi> cons){
new FileChooser(open ? "$open" : "$save", file -> file.extension().toLowerCase().equals(extension), open, file -> { new FileChooser(open ? "$open" : "$save", file -> file.extension().toLowerCase().equals(extension), open, file -> {
if(!open){ if(!open){
cons.get(file.parent().child(file.nameWithoutExtension() + "." + extension)); cons.get(file.parent().child(file.nameWithoutExtension() + "." + extension));

View File

@@ -456,7 +456,7 @@ public class Renderer implements ApplicationListener{
buffer.end(); buffer.end();
Pixmap fullPixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888); Pixmap fullPixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888);
BufferUtils.copy(lines, 0, fullPixmap.getPixels(), lines.length); BufferUtils.copy(lines, 0, fullPixmap.getPixels(), lines.length);
FileHandle file = screenshotDirectory.child("screenshot-" + Time.millis() + ".png"); Fi file = screenshotDirectory.child("screenshot-" + Time.millis() + ".png");
PixmapIO.writePNG(file, fullPixmap); PixmapIO.writePNG(file, fullPixmap);
fullPixmap.dispose(); fullPixmap.dispose();
ui.showInfoFade(Core.bundle.format("screenshot", file.toString())); ui.showInfoFade(Core.bundle.format("screenshot", file.toString()));

View File

@@ -138,7 +138,7 @@ public class UI implements ApplicationListener, Loadable{
Core.assets.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver)); Core.assets.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
Core.assets.setLoader(BitmapFont.class, null, new FreetypeFontLoader(resolver){ Core.assets.setLoader(BitmapFont.class, null, new FreetypeFontLoader(resolver){
@Override @Override
public BitmapFont loadSync(AssetManager manager, String fileName, FileHandle file, FreeTypeFontLoaderParameter parameter){ public BitmapFont loadSync(AssetManager manager, String fileName, Fi file, FreeTypeFontLoaderParameter parameter){
if(fileName.equals("outline")){ if(fileName.equals("outline")){
parameter.fontParameters.borderWidth = Scl.scl(2f); parameter.fontParameters.borderWidth = Scl.scl(2f);
parameter.fontParameters.spaceX -= parameter.fontParameters.borderWidth; parameter.fontParameters.spaceX -= parameter.fontParameters.borderWidth;

View File

@@ -27,7 +27,7 @@ public class Version{
if(!enabled) return; if(!enabled) return;
try{ try{
FileHandle file = OS.isAndroid || OS.isIos ? Core.files.internal("version.properties") : new FileHandle("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());

View File

@@ -54,7 +54,8 @@ public abstract class Content implements Comparable<Content>{
/** The mod that loaded this piece of content. */ /** The mod that loaded this piece of content. */
public @Nullable LoadedMod mod; public @Nullable LoadedMod mod;
/** File that this content was loaded from. */ /** File that this content was loaded from. */
public @Nullable FileHandle sourceFile; public @Nullable
Fi sourceFile;
/** The error that occurred during loading, if applicable. Null if no error occurred. */ /** The error that occurred during loading, if applicable. Null if no error occurred. */
public @Nullable String error; public @Nullable String error;
} }

View File

@@ -1,7 +1,7 @@
package io.anuke.mindustry.editor; package io.anuke.mindustry.editor;
import io.anuke.arc.collection.StringMap; import io.anuke.arc.collection.StringMap;
import io.anuke.arc.files.FileHandle; import io.anuke.arc.files.Fi;
import io.anuke.arc.func.Cons; import io.anuke.arc.func.Cons;
import io.anuke.arc.func.Boolf; import io.anuke.arc.func.Boolf;
import io.anuke.arc.graphics.Pixmap; import io.anuke.arc.graphics.Pixmap;
@@ -109,7 +109,7 @@ public class MapEditor{
} }
} }
public Map createMap(FileHandle file){ public Map createMap(Fi file){
return new Map(file, width(), height(), new StringMap(tags), true); return new Map(file, width(), height(), new StringMap(tags), true);
} }

View File

@@ -133,7 +133,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
}else{ }else{
ui.loadAnd(() -> { ui.loadAnd(() -> {
try{ try{
FileHandle result = Core.files.local(editor.getTags().get("name", "unknown") + "." + mapExtension); Fi result = Core.files.local(editor.getTags().get("name", "unknown") + "." + mapExtension);
MapIO.writeMap(result, editor.createMap(result)); MapIO.writeMap(result, editor.createMap(result));
platform.shareFile(result); platform.shareFile(result);
}catch(Exception e){ }catch(Exception e){
@@ -381,7 +381,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
editor.renderer().dispose(); editor.renderer().dispose();
} }
public void beginEditMap(FileHandle file){ public void beginEditMap(Fi file){
ui.loadAnd(() -> { ui.loadAnd(() -> {
try{ try{
shownWithMap = true; shownWithMap = true;

View File

@@ -35,8 +35,8 @@ public class GlobalData{
}); });
} }
public void exportData(FileHandle file) throws IOException{ public void exportData(Fi file) throws IOException{
Array<FileHandle> files = new Array<>(); Array<Fi> files = new Array<>();
files.add(Core.settings.getSettingsFile()); files.add(Core.settings.getSettingsFile());
files.addAll(customMapDirectory.list()); files.addAll(customMapDirectory.list());
files.addAll(saveDirectory.list()); files.addAll(saveDirectory.list());
@@ -46,7 +46,7 @@ public class GlobalData{
String base = Core.settings.getDataDirectory().path(); String base = Core.settings.getDataDirectory().path();
try(OutputStream fos = file.write(false, 2048); ZipOutputStream zos = new ZipOutputStream(fos)){ try(OutputStream fos = file.write(false, 2048); ZipOutputStream zos = new ZipOutputStream(fos)){
for(FileHandle add : files){ for(Fi add : files){
if(add.isDirectory()) continue; if(add.isDirectory()) continue;
zos.putNextEntry(new ZipEntry(add.path().substring(base.length()))); zos.putNextEntry(new ZipEntry(add.path().substring(base.length())));
Streams.copyStream(add.read(), zos); Streams.copyStream(add.read(), zos);
@@ -56,12 +56,12 @@ public class GlobalData{
} }
} }
public void importData(FileHandle file){ public void importData(Fi file){
FileHandle dest = Core.files.local("zipdata.zip"); Fi dest = Core.files.local("zipdata.zip");
file.copyTo(dest); file.copyTo(dest);
FileHandle zipped = new ZipFileHandle(dest); Fi zipped = new ZipFi(dest);
FileHandle base = Core.settings.getDataDirectory(); Fi base = Core.settings.getDataDirectory();
if(!zipped.child("settings.bin").exists()){ if(!zipped.child("settings.bin").exists()){
throw new IllegalArgumentException("Not valid save data."); throw new IllegalArgumentException("Not valid save data.");
} }

View File

@@ -27,7 +27,7 @@ public class Saves{
private AsyncExecutor previewExecutor = new AsyncExecutor(1); private AsyncExecutor previewExecutor = new AsyncExecutor(1);
private boolean saving; private boolean saving;
private float time; private float time;
private FileHandle zoneFile; private Fi zoneFile;
private long totalPlaytime; private long totalPlaytime;
private long lastTimestamp; private long lastTimestamp;
@@ -48,7 +48,7 @@ public class Saves{
saves.clear(); saves.clear();
zoneFile = saveDirectory.child("-1.msav"); zoneFile = saveDirectory.child("-1.msav");
for(FileHandle file : saveDirectory.list()){ for(Fi file : saveDirectory.list()){
if(!file.name().contains("backup") && SaveIO.isSaveValid(file)){ if(!file.name().contains("backup") && SaveIO.isSaveValid(file)){
SaveSlot slot = new SaveSlot(file); SaveSlot slot = new SaveSlot(file);
saves.add(slot); saves.add(slot);
@@ -121,7 +121,7 @@ public class Saves{
return slot; return slot;
} }
public SaveSlot importSave(FileHandle file) throws IOException{ public SaveSlot importSave(Fi file) throws IOException{
SaveSlot slot = new SaveSlot(getNextSlotFile()); SaveSlot slot = new SaveSlot(getNextSlotFile());
slot.importFile(file); slot.importFile(file);
slot.setName(file.nameWithoutExtension()); slot.setName(file.nameWithoutExtension());
@@ -136,9 +136,9 @@ public class Saves{
return slot == null || slot.getZone() == null ? null : slot; return slot == null || slot.getZone() == null ? null : slot;
} }
public FileHandle getNextSlotFile(){ public Fi getNextSlotFile(){
int i = 0; int i = 0;
FileHandle file; Fi file;
while((file = saveDirectory.child(i + "." + saveExtension)).exists()){ while((file = saveDirectory.child(i + "." + saveExtension)).exists()){
i ++; i ++;
} }
@@ -151,11 +151,11 @@ public class Saves{
public class SaveSlot{ public class SaveSlot{
//public final int index; //public final int index;
public final FileHandle file; public final Fi file;
boolean requestedPreview; boolean requestedPreview;
SaveMeta meta; SaveMeta meta;
public SaveSlot(FileHandle file){ public SaveSlot(Fi file){
this.file = file; this.file = file;
} }
@@ -216,11 +216,11 @@ public class Saves{
return file.nameWithoutExtension(); return file.nameWithoutExtension();
} }
private FileHandle previewFile(){ private Fi previewFile(){
return mapPreviewDirectory.child("save_slot_" + index() + ".png"); return mapPreviewDirectory.child("save_slot_" + index() + ".png");
} }
private FileHandle loadPreviewFile(){ private Fi loadPreviewFile(){
return previewFile().sibling(previewFile().name() + ".spreview"); return previewFile().sibling(previewFile().name() + ".spreview");
} }
@@ -293,7 +293,7 @@ public class Saves{
Core.settings.save(); Core.settings.save();
} }
public void importFile(FileHandle from) throws IOException{ public void importFile(Fi from) throws IOException{
try{ try{
from.copyTo(file); from.copyTo(file);
}catch(Exception e){ }catch(Exception e){
@@ -301,7 +301,7 @@ public class Saves{
} }
} }
public void exportFile(FileHandle to) throws IOException{ public void exportFile(Fi to) throws IOException{
try{ try{
file.copyTo(to); file.copyTo(to);
}catch(Exception e){ }catch(Exception e){

View File

@@ -16,7 +16,8 @@ public class Schematic implements Publishable, Comparable<Schematic>{
public final Array<Stile> tiles; public final Array<Stile> tiles;
public StringMap tags; public StringMap tags;
public int width, height; public int width, height;
public @Nullable FileHandle file; public @Nullable
Fi file;
/** Associated mod. If null, no mod is associated with this schematic. */ /** Associated mod. If null, no mod is associated with this schematic. */
public @Nullable LoadedMod mod; public @Nullable LoadedMod mod;
@@ -94,15 +95,15 @@ public class Schematic implements Publishable, Comparable<Schematic>{
} }
@Override @Override
public FileHandle createSteamFolder(String id){ public Fi createSteamFolder(String id){
FileHandle directory = tmpDirectory.child("schematic_" + id).child("schematic." + schematicExtension); Fi directory = tmpDirectory.child("schematic_" + id).child("schematic." + schematicExtension);
file.copyTo(directory); file.copyTo(directory);
return directory; return directory;
} }
@Override @Override
public FileHandle createSteamPreview(String id){ public Fi createSteamPreview(String id){
FileHandle preview = tmpDirectory.child("schematic_preview_" + id + ".png"); Fi preview = tmpDirectory.child("schematic_preview_" + id + ".png");
schematics.savePreview(this, preview); schematics.savePreview(this, preview);
return preview; return preview;
} }

View File

@@ -69,7 +69,7 @@ public class Schematics implements Loadable{
public void load(){ public void load(){
all.clear(); all.clear();
for(FileHandle file : schematicDirectory.list()){ for(Fi file : schematicDirectory.list()){
loadFile(file); loadFile(file);
} }
@@ -111,7 +111,7 @@ public class Schematics implements Loadable{
} }
} }
private @Nullable Schematic loadFile(FileHandle file){ private @Nullable Schematic loadFile(Fi file){
if(!file.extension().equals(schematicExtension)) return null; if(!file.extension().equals(schematicExtension)) return null;
try{ try{
@@ -144,7 +144,7 @@ public class Schematics implements Loadable{
} }
} }
public void savePreview(Schematic schematic, FileHandle file){ public void savePreview(Schematic schematic, Fi file){
FrameBuffer buffer = getBuffer(schematic); FrameBuffer buffer = getBuffer(schematic);
Draw.flush(); Draw.flush();
buffer.begin(); buffer.begin();
@@ -272,7 +272,7 @@ public class Schematics implements Loadable{
public void add(Schematic schematic){ public void add(Schematic schematic){
all.add(schematic); all.add(schematic);
try{ try{
FileHandle file = schematicDirectory.child(Time.millis() + "." + schematicExtension); Fi file = schematicDirectory.child(Time.millis() + "." + schematicExtension);
write(schematic, file); write(schematic, file);
schematic.file = file; schematic.file = file;
}catch(Exception e){ }catch(Exception e){
@@ -372,7 +372,7 @@ public class Schematics implements Loadable{
return read(new ByteArrayInputStream(Base64Coder.decode(schematic))); return read(new ByteArrayInputStream(Base64Coder.decode(schematic)));
} }
public static Schematic read(FileHandle file) throws IOException{ public static Schematic read(Fi file) throws IOException{
Schematic s = read(new DataInputStream(file.read(1024))); Schematic s = read(new DataInputStream(file.read(1024)));
if(!s.tags.containsKey("name")){ if(!s.tags.containsKey("name")){
s.tags.put("name", file.nameWithoutExtension()); s.tags.put("name", file.nameWithoutExtension());
@@ -425,7 +425,7 @@ public class Schematics implements Loadable{
} }
} }
public static void write(Schematic schematic, FileHandle file) throws IOException{ public static void write(Schematic schematic, Fi file) throws IOException{
write(schematic, file.write(false, 1024)); write(schematic, file.write(false, 1024));
} }

View File

@@ -26,7 +26,7 @@ public class LegacyMapIO{
private static final Json json = new Json(); private static final Json json = new Json();
/* Convert a map from the old format to the new format. */ /* Convert a map from the old format to the new format. */
public static void convertMap(FileHandle in, FileHandle out) throws IOException{ public static void convertMap(Fi in, Fi out) throws IOException{
Map map = readMap(in, true); Map map = readMap(in, true);
String waves = map.tags.get("waves", "[]"); String waves = map.tags.get("waves", "[]");
@@ -45,7 +45,7 @@ public class LegacyMapIO{
MapIO.writeMap(out, map); MapIO.writeMap(out, map);
} }
public static Map readMap(FileHandle file, boolean custom) throws IOException{ public static Map readMap(Fi file, boolean custom) throws IOException{
try(DataInputStream stream = new DataInputStream(file.read(1024))){ try(DataInputStream stream = new DataInputStream(file.read(1024))){
StringMap tags = new StringMap(); StringMap tags = new StringMap();
@@ -76,11 +76,11 @@ public class LegacyMapIO{
readTiles(map.file, map.width, map.height, tiles); readTiles(map.file, map.width, map.height, tiles);
} }
private static void readTiles(FileHandle file, int width, int height, Tile[][] tiles) throws IOException{ private static void readTiles(Fi file, int width, int height, Tile[][] tiles) throws IOException{
readTiles(file, width, height, (x, y) -> tiles[x][y]); readTiles(file, width, height, (x, y) -> tiles[x][y]);
} }
private static void readTiles(FileHandle file, int width, int height, TileProvider tiles) throws IOException{ private static void readTiles(Fi file, int width, int height, TileProvider tiles) throws IOException{
try(BufferedInputStream input = file.read(bufferSize)){ try(BufferedInputStream input = file.read(bufferSize)){
//read map //read map

View File

@@ -22,7 +22,7 @@ import static io.anuke.mindustry.Vars.*;
public class MapIO{ public class MapIO{
private static final int[] pngHeader = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; private static final int[] pngHeader = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A};
public static boolean isImage(FileHandle file){ public static boolean isImage(Fi file){
try(InputStream stream = file.read(32)){ try(InputStream stream = file.read(32)){
for(int i1 : pngHeader){ for(int i1 : pngHeader){
if(stream.read() != i1){ if(stream.read() != i1){
@@ -35,7 +35,7 @@ public class MapIO{
} }
} }
public static Map createMap(FileHandle file, boolean custom) throws IOException{ public static Map createMap(Fi file, boolean custom) throws IOException{
try(InputStream is = new InflaterInputStream(file.read(bufferSize)); CounterInputStream counter = new CounterInputStream(is); DataInputStream stream = new DataInputStream(counter)){ try(InputStream is = new InflaterInputStream(file.read(bufferSize)); CounterInputStream counter = new CounterInputStream(is); DataInputStream stream = new DataInputStream(counter)){
SaveIO.readHeader(stream); SaveIO.readHeader(stream);
int version = stream.readInt(); int version = stream.readInt();
@@ -46,7 +46,7 @@ public class MapIO{
} }
} }
public static void writeMap(FileHandle file, Map map) throws IOException{ public static void writeMap(Fi file, Map map) throws IOException{
try{ try{
SaveIO.write(file, map.tags); SaveIO.write(file, map.tags);
}catch(Exception e){ }catch(Exception e){

View File

@@ -1,7 +1,7 @@
package io.anuke.mindustry.io; package io.anuke.mindustry.io;
import io.anuke.arc.collection.*; import io.anuke.arc.collection.*;
import io.anuke.arc.files.FileHandle; import io.anuke.arc.files.Fi;
import io.anuke.arc.util.io.CounterInputStream; import io.anuke.arc.util.io.CounterInputStream;
import io.anuke.arc.util.io.FastDeflaterOutputStream; import io.anuke.arc.util.io.FastDeflaterOutputStream;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
@@ -34,7 +34,7 @@ public class SaveIO{
return versions.get(version); return versions.get(version);
} }
public static void save(FileHandle file){ public static void save(Fi file){
boolean exists = file.exists(); boolean exists = file.exists();
if(exists) file.moveTo(backupFileFor(file)); if(exists) file.moveTo(backupFileFor(file));
try{ try{
@@ -45,15 +45,15 @@ public class SaveIO{
} }
} }
public static DataInputStream getStream(FileHandle file){ public static DataInputStream getStream(Fi file){
return new DataInputStream(new InflaterInputStream(file.read(bufferSize))); return new DataInputStream(new InflaterInputStream(file.read(bufferSize)));
} }
public static DataInputStream getBackupStream(FileHandle file){ public static DataInputStream getBackupStream(Fi file){
return new DataInputStream(new InflaterInputStream(backupFileFor(file).read(bufferSize))); return new DataInputStream(new InflaterInputStream(backupFileFor(file).read(bufferSize)));
} }
public static boolean isSaveValid(FileHandle file){ public static boolean isSaveValid(Fi file){
try{ try{
return isSaveValid(new DataInputStream(new InflaterInputStream(file.read(bufferSize)))); return isSaveValid(new DataInputStream(new InflaterInputStream(file.read(bufferSize))));
}catch(Exception e){ }catch(Exception e){
@@ -71,7 +71,7 @@ public class SaveIO{
} }
} }
public static SaveMeta getMeta(FileHandle file){ public static SaveMeta getMeta(Fi file){
try{ try{
return getMeta(getStream(file)); return getMeta(getStream(file));
}catch(Exception e){ }catch(Exception e){
@@ -92,19 +92,19 @@ public class SaveIO{
} }
} }
public static FileHandle fileFor(int slot){ public static Fi fileFor(int slot){
return saveDirectory.child(slot + "." + Vars.saveExtension); return saveDirectory.child(slot + "." + Vars.saveExtension);
} }
public static FileHandle backupFileFor(FileHandle file){ public static Fi backupFileFor(Fi file){
return file.sibling(file.name() + "-backup." + file.extension()); return file.sibling(file.name() + "-backup." + file.extension());
} }
public static void write(FileHandle file, StringMap tags){ public static void write(Fi file, StringMap tags){
write(new FastDeflaterOutputStream(file.write(false, bufferSize)), tags); write(new FastDeflaterOutputStream(file.write(false, bufferSize)), tags);
} }
public static void write(FileHandle file){ public static void write(Fi file){
write(file, null); write(file, null);
} }
@@ -122,17 +122,17 @@ public class SaveIO{
} }
} }
public static void load(FileHandle file) throws SaveException{ public static void load(Fi file) throws SaveException{
load(file, world.context); load(file, world.context);
} }
public static void load(FileHandle file, WorldContext context) throws SaveException{ public static void load(Fi file, WorldContext context) throws SaveException{
try{ try{
//try and load; if any exception at all occurs //try and load; if any exception at all occurs
load(new InflaterInputStream(file.read(bufferSize)), context); load(new InflaterInputStream(file.read(bufferSize)), context);
}catch(SaveException e){ }catch(SaveException e){
e.printStackTrace(); e.printStackTrace();
FileHandle backup = file.sibling(file.name() + "-backup." + file.extension()); Fi backup = file.sibling(file.name() + "-backup." + file.extension());
if(backup.exists()){ if(backup.exists()){
load(new InflaterInputStream(backup.read(bufferSize)), context); load(new InflaterInputStream(backup.read(bufferSize)), context);
}else{ }else{

View File

@@ -12,7 +12,7 @@ public class SavePreviewLoader extends TextureLoader{
} }
@Override @Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file, TextureParameter parameter){ public void loadAsync(AssetManager manager, String fileName, Fi file, TextureParameter parameter){
try{ try{
super.loadAsync(manager, fileName, file.sibling(file.nameWithoutExtension()), parameter); super.loadAsync(manager, fileName, file.sibling(file.nameWithoutExtension()), parameter);
}catch(Exception e){ }catch(Exception e){

View File

@@ -22,7 +22,7 @@ public class Map implements Comparable<Map>, Publishable{
/** Metadata. Author description, display name, etc. */ /** Metadata. Author description, display name, etc. */
public final StringMap tags; public final StringMap tags;
/** Base file of this map. File can be named anything at all. */ /** Base file of this map. File can be named anything at all. */
public final FileHandle file; public final Fi file;
/** Format version. */ /** Format version. */
public final int version; public final int version;
/** Whether this map is managed, e.g. downloaded from the Steam workshop.*/ /** Whether this map is managed, e.g. downloaded from the Steam workshop.*/
@@ -40,7 +40,7 @@ public class Map implements Comparable<Map>, Publishable{
/** Associated mod. If null, no mod is associated. */ /** Associated mod. If null, no mod is associated. */
public @Nullable LoadedMod mod; public @Nullable LoadedMod mod;
public Map(FileHandle file, int width, int height, StringMap tags, boolean custom, int version, int build){ public Map(Fi file, int width, int height, StringMap tags, boolean custom, int version, int build){
this.custom = custom; this.custom = custom;
this.tags = tags; this.tags = tags;
this.file = file; this.file = file;
@@ -50,11 +50,11 @@ public class Map implements Comparable<Map>, Publishable{
this.build = build; this.build = build;
} }
public Map(FileHandle file, int width, int height, StringMap tags, boolean custom, int version){ public Map(Fi file, int width, int height, StringMap tags, boolean custom, int version){
this(file, width, height, tags, custom, version, -1); this(file, width, height, tags, custom, version, -1);
} }
public Map(FileHandle file, int width, int height, StringMap tags, boolean custom){ public Map(Fi file, int width, int height, StringMap tags, boolean custom){
this(file, width, height, tags, custom, -1); this(file, width, height, tags, custom, -1);
} }
@@ -70,11 +70,11 @@ public class Map implements Comparable<Map>, Publishable{
return texture == null ? Core.assets.get("sprites/error.png") : texture; return texture == null ? Core.assets.get("sprites/error.png") : texture;
} }
public FileHandle previewFile(){ public Fi previewFile(){
return Vars.mapPreviewDirectory.child((workshop ? file.parent().name() : file.nameWithoutExtension()) + ".png"); return Vars.mapPreviewDirectory.child((workshop ? file.parent().name() : file.nameWithoutExtension()) + ".png");
} }
public FileHandle cacheFile(){ public Fi cacheFile(){
return Vars.mapPreviewDirectory.child(workshop ? file.parent().name() + "-workshop-cache.dat" : file.nameWithoutExtension() + "-cache.dat"); return Vars.mapPreviewDirectory.child(workshop ? file.parent().name() + "-workshop-cache.dat" : file.nameWithoutExtension() + "-cache.dat");
} }
@@ -184,14 +184,14 @@ public class Map implements Comparable<Map>, Publishable{
} }
@Override @Override
public FileHandle createSteamFolder(String id){ public Fi createSteamFolder(String id){
FileHandle mapFile = tmpDirectory.child("map_" + id).child("map.msav"); Fi mapFile = tmpDirectory.child("map_" + id).child("map.msav");
file.copyTo(mapFile); file.copyTo(mapFile);
return mapFile.parent(); return mapFile.parent();
} }
@Override @Override
public FileHandle createSteamPreview(String id){ public Fi createSteamPreview(String id){
return previewFile(); return previewFile();
} }

View File

@@ -17,7 +17,7 @@ public class MapPreviewLoader extends TextureLoader{
} }
@Override @Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file, TextureParameter parameter){ public void loadAsync(AssetManager manager, String fileName, Fi file, TextureParameter parameter){
try{ try{
super.loadAsync(manager, fileName, file.sibling(file.nameWithoutExtension()), parameter); super.loadAsync(manager, fileName, file.sibling(file.nameWithoutExtension()), parameter);
}catch(Exception e){ }catch(Exception e){
@@ -28,7 +28,7 @@ public class MapPreviewLoader extends TextureLoader{
} }
@Override @Override
public Texture loadSync(AssetManager manager, String fileName, FileHandle file, TextureParameter parameter){ public Texture loadSync(AssetManager manager, String fileName, Fi file, TextureParameter parameter){
try{ try{
return super.loadSync(manager, fileName, file, parameter); return super.loadSync(manager, fileName, file, parameter);
}catch(Throwable e){ }catch(Throwable e){
@@ -43,7 +43,7 @@ public class MapPreviewLoader extends TextureLoader{
} }
@Override @Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureParameter parameter){ public Array<AssetDescriptor> getDependencies(String fileName, Fi file, TextureParameter parameter){
return Array.with(new AssetDescriptor<>("contentcreate", Content.class)); return Array.with(new AssetDescriptor<>("contentcreate", Content.class));
} }

View File

@@ -105,7 +105,7 @@ public class Maps{
* Does not add this map to the map list. * Does not add this map to the map list.
*/ */
public Map loadInternalMap(String name){ public Map loadInternalMap(String name){
FileHandle file = tree.get("maps/" + name + "." + mapExtension); Fi file = tree.get("maps/" + name + "." + mapExtension);
try{ try{
return MapIO.createMap(file, false); return MapIO.createMap(file, false);
@@ -119,7 +119,7 @@ public class Maps{
//defaults; must work //defaults; must work
try{ try{
for(String name : defaultMapNames){ for(String name : defaultMapNames){
FileHandle file = Core.files.internal("maps/" + name + "." + mapExtension); Fi file = Core.files.internal("maps/" + name + "." + mapExtension);
loadMap(file, false); loadMap(file, false);
} }
}catch(IOException e){ }catch(IOException e){
@@ -127,7 +127,7 @@ public class Maps{
} }
//custom //custom
for(FileHandle file : customMapDirectory.list()){ for(Fi file : customMapDirectory.list()){
try{ try{
if(file.extension().equalsIgnoreCase(mapExtension)){ if(file.extension().equalsIgnoreCase(mapExtension)){
loadMap(file, true); loadMap(file, true);
@@ -139,7 +139,7 @@ public class Maps{
} }
//workshop //workshop
for(FileHandle file : platform.getWorkshopContent(Map.class)){ for(Fi file : platform.getWorkshopContent(Map.class)){
try{ try{
Map map = loadMap(file, false); Map map = loadMap(file, false);
map.workshop = true; map.workshop = true;
@@ -183,7 +183,7 @@ public class Maps{
StringMap tags = new StringMap(baseTags); StringMap tags = new StringMap(baseTags);
String name = tags.get("name"); String name = tags.get("name");
if(name == null) throw new IllegalArgumentException("Can't save a map with no name. How did this happen?"); if(name == null) throw new IllegalArgumentException("Can't save a map with no name. How did this happen?");
FileHandle file; Fi file;
//find map with the same exact display name //find map with the same exact display name
Map other = maps.find(m -> m.name().equals(name)); Map other = maps.find(m -> m.name().equals(name));
@@ -244,8 +244,8 @@ public class Maps{
} }
/** Import a map, then save it. This updates all values and stored data necessary. */ /** Import a map, then save it. This updates all values and stored data necessary. */
public void importMap(FileHandle file) throws IOException{ public void importMap(Fi file) throws IOException{
FileHandle dest = findFile(); Fi dest = findFile();
file.copyTo(dest); file.copyTo(dest);
Map map = loadMap(dest, true); Map map = loadMap(dest, true);
@@ -446,7 +446,7 @@ public class Maps{
} }
/** Find a new filename to put a map to. */ /** Find a new filename to put a map to. */
private FileHandle findFile(){ private Fi findFile(){
//find a map name that isn't used. //find a map name that isn't used.
int i = maps.size; int i = maps.size;
while(customMapDirectory.child("map_" + i + "." + mapExtension).exists()){ while(customMapDirectory.child("map_" + i + "." + mapExtension).exists()){
@@ -455,7 +455,7 @@ public class Maps{
return customMapDirectory.child("map_" + i + "." + mapExtension); return customMapDirectory.child("map_" + i + "." + mapExtension);
} }
private Map loadMap(FileHandle file, boolean custom) throws IOException{ private Map loadMap(Fi file, boolean custom) throws IOException{
Map map = MapIO.createMap(file, custom); Map map = MapIO.createMap(file, custom);
if(map.name() == null){ if(map.name() == null){

View File

@@ -405,7 +405,7 @@ public class ContentParser{
* @param file file that this content is being parsed from * @param file file that this content is being parsed from
* @return the content that was parsed * @return the content that was parsed
*/ */
public Content parse(LoadedMod mod, String name, String json, FileHandle file, ContentType type) throws Exception{ public Content parse(LoadedMod mod, String name, String json, Fi file, ContentType type) throws Exception{
if(contentTypes.isEmpty()){ if(contentTypes.isEmpty()){
init(); init();
} }
@@ -433,7 +433,7 @@ public class ContentParser{
return c; return c;
} }
public void markError(Content content, LoadedMod mod, FileHandle file, Throwable error){ public void markError(Content content, LoadedMod mod, Fi file, Throwable error){
content.minfo.mod = mod; content.minfo.mod = mod;
content.minfo.sourceFile = file; content.minfo.sourceFile = file;
content.minfo.error = makeError(error, file); content.minfo.error = makeError(error, file);
@@ -448,7 +448,7 @@ public class ContentParser{
} }
} }
private String makeError(Throwable t, FileHandle file){ private String makeError(Throwable t, Fi file){
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("[lightgray]").append("File: ").append(file.name()).append("[]\n\n"); builder.append("[lightgray]").append("File: ").append(file.name()).append("[]\n\n");

View File

@@ -6,7 +6,7 @@ import io.anuke.mindustry.*;
public class Mod{ public class Mod{
/** @return the config file for this plugin, as the file 'mods/[plugin-name]/config.json'.*/ /** @return the config file for this plugin, as the file 'mods/[plugin-name]/config.json'.*/
public FileHandle getConfig(){ public Fi getConfig(){
return Vars.mods.getConfig(this); return Vars.mods.getConfig(this);
} }

View File

@@ -35,7 +35,7 @@ public class Mods implements Loadable{
private Json json = new Json(); private Json json = new Json();
private @Nullable Scripts scripts; private @Nullable Scripts scripts;
private ContentParser parser = new ContentParser(); private ContentParser parser = new ContentParser();
private ObjectMap<String, Array<FileHandle>> bundles = new ObjectMap<>(); private ObjectMap<String, Array<Fi>> bundles = new ObjectMap<>();
private ObjectSet<String> specialFolders = ObjectSet.with("bundles", "sprites", "sprites-override"); private ObjectSet<String> specialFolders = ObjectSet.with("bundles", "sprites", "sprites-override");
private int totalSprites; private int totalSprites;
@@ -52,18 +52,18 @@ public class Mods implements Loadable{
/** Returns a file named 'config.json' in a special folder for the specified plugin. /** Returns a file named 'config.json' in a special folder for the specified plugin.
* Call this in init(). */ * Call this in init(). */
public FileHandle getConfig(Mod mod){ public Fi getConfig(Mod mod){
ModMeta load = metas.get(mod.getClass()); ModMeta load = metas.get(mod.getClass());
if(load == null) throw new IllegalArgumentException("Mod is not loaded yet (or missing)!"); if(load == null) throw new IllegalArgumentException("Mod is not loaded yet (or missing)!");
return modDirectory.child(load.name).child("config.json"); return modDirectory.child(load.name).child("config.json");
} }
/** Returns a list of files per mod subdirectory. */ /** Returns a list of files per mod subdirectory. */
public void listFiles(String directory, Cons2<LoadedMod, FileHandle> cons){ public void listFiles(String directory, Cons2<LoadedMod, Fi> cons){
eachEnabled(mod -> { eachEnabled(mod -> {
FileHandle file = mod.root.child(directory); Fi file = mod.root.child(directory);
if(file.exists()){ if(file.exists()){
for(FileHandle child : file.list()){ for(Fi child : file.list()){
cons.get(mod, child); cons.get(mod, child);
} }
} }
@@ -76,8 +76,8 @@ public class Mods implements Loadable{
} }
/** Imports an external mod file.*/ /** Imports an external mod file.*/
public void importMod(FileHandle file) throws IOException{ public void importMod(Fi file) throws IOException{
FileHandle dest = modDirectory.child(file.name()); Fi dest = modDirectory.child(file.name());
if(dest.exists()){ if(dest.exists()){
throw new IOException("A mod with the same filename already exists!"); throw new IOException("A mod with the same filename already exists!");
} }
@@ -104,8 +104,8 @@ public class Mods implements Loadable{
packer = new MultiPacker(); packer = new MultiPacker();
eachEnabled(mod -> { eachEnabled(mod -> {
Array<FileHandle> sprites = mod.root.child("sprites").findAll(f -> f.extension().equals("png")); Array<Fi> sprites = mod.root.child("sprites").findAll(f -> f.extension().equals("png"));
Array<FileHandle> overrides = mod.root.child("sprites-override").findAll(f -> f.extension().equals("png")); Array<Fi> overrides = mod.root.child("sprites-override").findAll(f -> f.extension().equals("png"));
packSprites(sprites, mod, true); packSprites(sprites, mod, true);
packSprites(overrides, mod, false); packSprites(overrides, mod, false);
Log.debug("Packed {0} images for mod '{1}'.", sprites.size + overrides.size, mod.meta.name); Log.debug("Packed {0} images for mod '{1}'.", sprites.size + overrides.size, mod.meta.name);
@@ -122,8 +122,8 @@ public class Mods implements Loadable{
Log.debug("Time to pack textures: {0}", Time.elapsed()); Log.debug("Time to pack textures: {0}", Time.elapsed());
} }
private void packSprites(Array<FileHandle> sprites, LoadedMod mod, boolean prefix){ private void packSprites(Array<Fi> sprites, LoadedMod mod, boolean prefix){
for(FileHandle file : sprites){ for(Fi file : sprites){
try(InputStream stream = file.read()){ try(InputStream stream = file.read()){
byte[] bytes = Streams.copyStreamToByteArray(stream, Math.max((int)file.length(), 512)); byte[] bytes = Streams.copyStreamToByteArray(stream, Math.max((int)file.length(), 512));
Pixmap pixmap = new Pixmap(bytes, 0, bytes.length); Pixmap pixmap = new Pixmap(bytes, 0, bytes.length);
@@ -183,7 +183,7 @@ public class Mods implements Loadable{
PageType.main; PageType.main;
} }
private PageType getPage(FileHandle file){ private PageType getPage(Fi file){
String parent = file.parent().name(); String parent = file.parent().name();
return return
parent.equals("environment") ? PageType.environment : parent.equals("environment") ? PageType.environment :
@@ -195,7 +195,7 @@ public class Mods implements Loadable{
/** Removes a mod file and marks it for requiring a restart. */ /** Removes a mod file and marks it for requiring a restart. */
public void removeMod(LoadedMod mod){ public void removeMod(LoadedMod mod){
if(mod.root instanceof ZipFileHandle){ if(mod.root instanceof ZipFi){
mod.root.delete(); mod.root.delete();
} }
@@ -225,7 +225,7 @@ public class Mods implements Loadable{
/** Loads all mods from the folder, but does not call any methods on them.*/ /** Loads all mods from the folder, but does not call any methods on them.*/
public void load(){ public void load(){
for(FileHandle file : modDirectory.list()){ for(Fi file : modDirectory.list()){
if(!file.extension().equals("jar") && !file.extension().equals("zip") && !(file.isDirectory() && (file.child("mod.json").exists() || file.child("mod.hjson").exists()))) continue; if(!file.extension().equals("jar") && !file.extension().equals("zip") && !(file.isDirectory() && (file.child("mod.json").exists() || file.child("mod.hjson").exists()))) continue;
Log.debug("[Mods] Loading mod {0}", file); Log.debug("[Mods] Loading mod {0}", file);
@@ -239,7 +239,7 @@ public class Mods implements Loadable{
} }
//load workshop mods now //load workshop mods now
for(FileHandle file : platform.getWorkshopContent(LoadedMod.class)){ for(Fi file : platform.getWorkshopContent(LoadedMod.class)){
try{ try{
LoadedMod mod = loadMod(file); LoadedMod mod = loadMod(file);
mods.add(mod); mods.add(mod);
@@ -311,7 +311,7 @@ public class Mods implements Loadable{
for(LoadedMod mod : orderedMods()){ for(LoadedMod mod : orderedMods()){
boolean zipFolder = !mod.file.isDirectory() && mod.root.parent() != null; boolean zipFolder = !mod.file.isDirectory() && mod.root.parent() != null;
String parentName = zipFolder ? mod.root.name() : null; String parentName = zipFolder ? mod.root.name() : null;
for(FileHandle file : mod.root.list()){ for(Fi file : mod.root.list()){
//ignore special folders like bundles or sprites //ignore special folders like bundles or sprites
if(file.isDirectory() && !specialFolders.contains(file.name())){ if(file.isDirectory() && !specialFolders.contains(file.name())){
//TODO calling child/parent on these files will give you gibberish; create wrapper class. //TODO calling child/parent on these files will give you gibberish; create wrapper class.
@@ -321,9 +321,9 @@ public class Mods implements Loadable{
} }
//load up bundles. //load up bundles.
FileHandle folder = mod.root.child("bundles"); Fi folder = mod.root.child("bundles");
if(folder.exists()){ if(folder.exists()){
for(FileHandle file : folder.list()){ for(Fi file : folder.list()){
if(file.name().startsWith("bundle") && file.extension().equals("properties")){ if(file.name().startsWith("bundle") && file.extension().equals("properties")){
String name = file.nameWithoutExtension(); String name = file.nameWithoutExtension();
bundles.getOr(name, Array::new).add(file); bundles.getOr(name, Array::new).add(file);
@@ -337,7 +337,7 @@ public class Mods implements Loadable{
while(bundle != null){ while(bundle != null){
String str = bundle.getLocale().toString(); String str = bundle.getLocale().toString();
String locale = "bundle" + (str.isEmpty() ? "" : "_" + str); String locale = "bundle" + (str.isEmpty() ? "" : "_" + str);
for(FileHandle file : bundles.getOr(locale, Array::new)){ for(Fi file : bundles.getOr(locale, Array::new)){
try{ try{
PropertiesUtils.load(bundle.getProperties(), file.reader()); PropertiesUtils.load(bundle.getProperties(), file.reader());
}catch(Exception e){ }catch(Exception e){
@@ -446,7 +446,7 @@ public class Mods implements Loadable{
mod.scripts = mod.root.child("scripts").findAll(f -> f.extension().equals("js")); mod.scripts = mod.root.child("scripts").findAll(f -> f.extension().equals("js"));
Log.debug("[{0}] Found {1} scripts.", mod.meta.name, mod.scripts.size); Log.debug("[{0}] Found {1} scripts.", mod.meta.name, mod.scripts.size);
for(FileHandle file : mod.scripts){ for(Fi file : mod.scripts){
try{ try{
if(scripts == null){ if(scripts == null){
scripts = platform.createScripts(); scripts = platform.createScripts();
@@ -474,10 +474,10 @@ public class Mods implements Loadable{
class LoadRun implements Comparable<LoadRun>{ class LoadRun implements Comparable<LoadRun>{
final ContentType type; final ContentType type;
final FileHandle file; final Fi file;
final LoadedMod mod; final LoadedMod mod;
public LoadRun(ContentType type, FileHandle file, LoadedMod mod){ public LoadRun(ContentType type, Fi file, LoadedMod mod){
this.type = type; this.type = type;
this.file = file; this.file = file;
this.mod = mod; this.mod = mod;
@@ -495,11 +495,11 @@ public class Mods implements Loadable{
for(LoadedMod mod : orderedMods()){ for(LoadedMod mod : orderedMods()){
if(mod.root.child("content").exists()){ if(mod.root.child("content").exists()){
FileHandle contentRoot = mod.root.child("content"); Fi contentRoot = mod.root.child("content");
for(ContentType type : ContentType.all){ for(ContentType type : ContentType.all){
FileHandle folder = contentRoot.child(type.name().toLowerCase() + "s"); Fi folder = contentRoot.child(type.name().toLowerCase() + "s");
if(folder.exists()){ if(folder.exists()){
for(FileHandle file : folder.list()){ for(Fi file : folder.list()){
if(file.extension().equals("json") || file.extension().equals("hjson")){ if(file.extension().equals("json") || file.extension().equals("hjson")){
runs.add(new LoadRun(type, file, mod)); runs.add(new LoadRun(type, file, mod));
} }
@@ -588,13 +588,13 @@ public class Mods implements Loadable{
/** Loads a mod file+meta, but does not add it to the list. /** Loads a mod file+meta, but does not add it to the list.
* Note that directories can be loaded as mods.*/ * Note that directories can be loaded as mods.*/
private LoadedMod loadMod(FileHandle sourceFile) throws Exception{ private LoadedMod loadMod(Fi sourceFile) throws Exception{
FileHandle zip = sourceFile.isDirectory() ? sourceFile : new ZipFileHandle(sourceFile); Fi zip = sourceFile.isDirectory() ? sourceFile : new ZipFi(sourceFile);
if(zip.list().length == 1 && zip.list()[0].isDirectory()){ if(zip.list().length == 1 && zip.list()[0].isDirectory()){
zip = zip.list()[0]; zip = zip.list()[0];
} }
FileHandle metaf = zip.child("mod.json").exists() ? zip.child("mod.json") : zip.child("mod.hjson").exists() ? zip.child("mod.hjson") : zip.child("plugin.json"); Fi metaf = zip.child("mod.json").exists() ? zip.child("mod.json") : zip.child("mod.hjson").exists() ? zip.child("mod.hjson") : zip.child("plugin.json");
if(!metaf.exists()){ if(!metaf.exists()){
Log.warn("Mod {0} doesn't have a 'mod.json'/'plugin.json'/'mod.js' file, skipping.", sourceFile); Log.warn("Mod {0} doesn't have a 'mod.json'/'plugin.json'/'mod.js' file, skipping.", sourceFile);
throw new IllegalArgumentException("No mod.json found."); throw new IllegalArgumentException("No mod.json found.");
@@ -611,7 +611,7 @@ public class Mods implements Loadable{
Mod mainMod; Mod mainMod;
FileHandle mainFile = zip; Fi mainFile = zip;
String[] path = (mainClass.replace('.', '/') + ".class").split("/"); String[] path = (mainClass.replace('.', '/') + ".class").split("/");
for(String str : path){ for(String str : path){
if(!str.isEmpty()){ if(!str.isEmpty()){
@@ -645,9 +645,9 @@ public class Mods implements Loadable{
/** Represents a plugin that has been loaded from a jar file.*/ /** Represents a plugin that has been loaded from a jar file.*/
public static class LoadedMod implements Publishable{ public static class LoadedMod implements Publishable{
/** The location of this mod's zip file/folder on the disk. */ /** The location of this mod's zip file/folder on the disk. */
public final FileHandle file; public final Fi file;
/** The root zip file; points to the contents of this mod. In the case of folders, this is the same as the mod's file. */ /** The root zip file; points to the contents of this mod. In the case of folders, this is the same as the mod's file. */
public final FileHandle root; public final Fi root;
/** The mod's main class; may be null. */ /** The mod's main class; may be null. */
public final @Nullable Mod main; public final @Nullable Mod main;
/** Internal mod name. Used for textures. */ /** Internal mod name. Used for textures. */
@@ -659,13 +659,13 @@ public class Mods implements Loadable{
/** All missing dependencies of this mod as strings. */ /** All missing dependencies of this mod as strings. */
public Array<String> missingDependencies = new Array<>(); public Array<String> missingDependencies = new Array<>();
/** Script files to run. */ /** Script files to run. */
public Array<FileHandle> scripts = new Array<>(); public Array<Fi> scripts = new Array<>();
/** Content with intialization code. */ /** Content with intialization code. */
public ObjectSet<Content> erroredContent = new ObjectSet<>(); public ObjectSet<Content> erroredContent = new ObjectSet<>();
/** Current state of this mod. */ /** Current state of this mod. */
public ModState state = ModState.enabled; public ModState state = ModState.enabled;
public LoadedMod(FileHandle file, FileHandle root, Mod main, ModMeta meta){ public LoadedMod(Fi file, Fi root, Mod main, ModMeta meta){
this.root = root; this.root = root;
this.file = file; this.file = file;
this.main = main; this.main = main;
@@ -734,12 +734,12 @@ public class Mods implements Loadable{
} }
@Override @Override
public FileHandle createSteamFolder(String id){ public Fi createSteamFolder(String id){
return file; return file;
} }
@Override @Override
public FileHandle createSteamPreview(String id){ public Fi createSteamPreview(String id){
return file.child("preview.png"); return file.child("preview.png");
} }

View File

@@ -63,7 +63,7 @@ public class Scripts implements Disposable{
Log.log(level, "[{0}]: {1}", source, message); Log.log(level, "[{0}]: {1}", source, message);
} }
public void run(LoadedMod mod, FileHandle file){ public void run(LoadedMod mod, Fi file){
run(wrapper.replace("$SCRIPT_NAME$", mod.name + "/" + file.nameWithoutExtension()).replace("$CODE$", file.readString()).replace("$MOD_NAME$", mod.name), file.name()); run(wrapper.replace("$SCRIPT_NAME$", mod.name + "/" + file.nameWithoutExtension()).replace("$CODE$", file.readString()).replace("$MOD_NAME$", mod.name), file.name());
} }

View File

@@ -22,6 +22,7 @@ import static io.anuke.mindustry.Vars.net;
public class CrashSender{ public class CrashSender{
public static void send(Throwable exception, Cons<File> writeListener){ public static void send(Throwable exception, Cons<File> writeListener){
try{ try{
exception.printStackTrace(); exception.printStackTrace();
@@ -52,12 +53,11 @@ public class CrashSender{
try{ try{
File file = new File(OS.getAppDataDirectoryString(Vars.appName), "crashes/crash-report-" + new SimpleDateFormat("MM_dd_yyyy_HH_mm_ss").format(new Date()) + ".txt"); File file = new File(OS.getAppDataDirectoryString(Vars.appName), "crashes/crash-report-" + new SimpleDateFormat("MM_dd_yyyy_HH_mm_ss").format(new Date()) + ".txt");
new FileHandle(OS.getAppDataDirectoryString(Vars.appName)).child("crashes").mkdirs(); new Fi(OS.getAppDataDirectoryString(Vars.appName)).child("crashes").mkdirs();
new FileHandle(file).writeString(parseException(exception)); new Fi(file).writeString(parseException(exception));
writeListener.get(file); writeListener.get(file);
}catch(Throwable e){ }catch(Throwable e){
e.printStackTrace(); Log.err("Failed to save local crash report.", e);
Log.err("Failed to save local crash report.");
} }
try{ try{

View File

@@ -20,9 +20,9 @@ public interface Publishable{
/** @return the tag that this content has. e.g. 'schematic' or 'map'. */ /** @return the tag that this content has. e.g. 'schematic' or 'map'. */
String steamTag(); String steamTag();
/** @return a folder with everything needed for this piece of content in it; does not need to be a copy. */ /** @return a folder with everything needed for this piece of content in it; does not need to be a copy. */
FileHandle createSteamFolder(String id); Fi createSteamFolder(String id);
/** @return a preview file PNG. */ /** @return a preview file PNG. */
FileHandle createSteamPreview(String id); Fi createSteamPreview(String id);
/** @return any extra tags to add to this item.*/ /** @return any extra tags to add to this item.*/
default Array<String> extraTags(){ default Array<String> extraTags(){
return new Array<>(0); return new Array<>(0);

View File

@@ -18,20 +18,20 @@ import java.util.*;
import static io.anuke.mindustry.Vars.platform; import static io.anuke.mindustry.Vars.platform;
public class FileChooser extends FloatingDialog{ public class FileChooser extends FloatingDialog{
private static final FileHandle homeDirectory = Core.files.absolute(Core.files.getExternalStoragePath()); private static final Fi homeDirectory = Core.files.absolute(Core.files.getExternalStoragePath());
private static FileHandle lastDirectory = homeDirectory; private static Fi lastDirectory = homeDirectory;
private Table files; private Table files;
private FileHandle directory = lastDirectory; private Fi directory = lastDirectory;
private ScrollPane pane; private ScrollPane pane;
private TextField navigation, filefield; private TextField navigation, filefield;
private TextButton ok; private TextButton ok;
private FileHistory stack = new FileHistory(); private FileHistory stack = new FileHistory();
private Boolf<FileHandle> filter; private Boolf<Fi> filter;
private Cons<FileHandle> selectListener; private Cons<Fi> selectListener;
private boolean open; private boolean open;
public FileChooser(String title, Boolf<FileHandle> filter, boolean open, Cons<FileHandle> result){ public FileChooser(String title, Boolf<Fi> filter, boolean open, Cons<Fi> result){
super(title); super(title);
setFillParent(true); setFillParent(true);
this.open = open; this.open = open;
@@ -154,8 +154,8 @@ public class FileChooser extends FloatingDialog{
} }
} }
private FileHandle[] getFileNames(){ private Fi[] getFileNames(){
FileHandle[] handles = directory.list(file -> !file.getName().startsWith(".")); Fi[] handles = directory.list(file -> !file.getName().startsWith("."));
Arrays.sort(handles, (a, b) -> { Arrays.sort(handles, (a, b) -> {
if(a.isDirectory() && !b.isDirectory()) return -1; if(a.isDirectory() && !b.isDirectory()) return -1;
@@ -183,7 +183,7 @@ public class FileChooser extends FloatingDialog{
files.clearChildren(); files.clearChildren();
files.top().left(); files.top().left();
FileHandle[] names = getFileNames(); Fi[] names = getFileNames();
Image upimage = new Image(Icon.folderParentSmall); Image upimage = new Image(Icon.folderParentSmall);
TextButton upbutton = new TextButton(".." + directory.toString(), Styles.clearTogglet); TextButton upbutton = new TextButton(".." + directory.toString(), Styles.clearTogglet);
@@ -204,7 +204,7 @@ public class FileChooser extends FloatingDialog{
ButtonGroup<TextButton> group = new ButtonGroup<>(); ButtonGroup<TextButton> group = new ButtonGroup<>();
group.setMinCheckCount(0); group.setMinCheckCount(0);
for(FileHandle file : names){ for(Fi file : names){
if(!file.isDirectory() && !filter.get(file)) continue; //skip non-filtered files if(!file.isDirectory() && !filter.get(file)) continue; //skip non-filtered files
String filename = file.name(); String filename = file.name();
@@ -255,14 +255,14 @@ public class FileChooser extends FloatingDialog{
} }
public class FileHistory{ public class FileHistory{
private Array<FileHandle> history = new Array<>(); private Array<Fi> history = new Array<>();
private int index; private int index;
public FileHistory(){ public FileHistory(){
} }
public void push(FileHandle file){ public void push(Fi file){
if(index != history.size) history.truncate(index); if(index != history.size) history.truncate(index);
history.add(file); history.add(file);
index++; index++;
@@ -296,7 +296,7 @@ public class FileChooser extends FloatingDialog{
System.out.println("\n\n\n\n\n\n"); System.out.println("\n\n\n\n\n\n");
int i = 0; int i = 0;
for(FileHandle file : history){ for(Fi file : history){
i++; i++;
if(index == i){ if(index == i){
System.out.println("[[" + file.toString() + "]]"); System.out.println("[[" + file.toString() + "]]");

View File

@@ -101,7 +101,7 @@ public class LoadDialog extends FloatingDialog{
}); });
}else{ }else{
try{ try{
FileHandle file = Core.files.local("save-" + slot.getName() + "." + saveExtension); Fi file = Core.files.local("save-" + slot.getName() + "." + saveExtension);
slot.exportFile(file); slot.exportFile(file);
platform.shareFile(file); platform.shareFile(file);
}catch(Exception e){ }catch(Exception e){

View File

@@ -46,7 +46,7 @@ public class ModsDialog extends FloatingDialog{
ui.loadfrag.hide(); ui.loadfrag.hide();
}else{ }else{
try{ try{
FileHandle file = tmpDirectory.child(text.replace("/", "") + ".zip"); Fi file = tmpDirectory.child(text.replace("/", "") + ".zip");
Streams.copyStream(result.getResultAsStream(), file.write(false)); Streams.copyStream(result.getResultAsStream(), file.write(false));
mods.importMod(file); mods.importMod(file);
file.delete(); file.delete();

View File

@@ -95,7 +95,7 @@ public class SettingsMenuDialog extends SettingsDialog{
Core.settings.putAll(map); Core.settings.putAll(map);
Core.settings.save(); Core.settings.save();
for(FileHandle file : dataDirectory.list()){ for(Fi file : dataDirectory.list()){
file.deleteDirectory(); file.deleteDirectory();
} }
@@ -106,7 +106,7 @@ public class SettingsMenuDialog extends SettingsDialog{
t.addButton("$data.export", style, () -> { t.addButton("$data.export", style, () -> {
if(ios){ if(ios){
FileHandle file = Core.files.local("mindustry-data-export.zip"); Fi file = Core.files.local("mindustry-data-export.zip");
try{ try{
data.exportData(file); data.exportData(file);
}catch(Exception e){ }catch(Exception e){

View File

@@ -77,8 +77,8 @@ public class DesktopLauncher extends ClientLauncher{
if(useSteam){ if(useSteam){
//delete leftover dlls //delete leftover dlls
FileHandle file = new FileHandle("."); Fi file = new Fi(".");
for(FileHandle other : file.parent().list()){ for(Fi other : file.parent().list()){
if(other.name().contains("steam") && (other.extension().equals("dll") || other.extension().equals("so") || other.extension().equals("dylib"))){ if(other.name().contains("steam") && (other.extension().equals("dll") || other.extension().equals("so") || other.extension().equals("dylib"))){
other.delete(); other.delete();
} }
@@ -202,7 +202,7 @@ public class DesktopLauncher extends ClientLauncher{
} }
@Override @Override
public Array<FileHandle> getWorkshopContent(Class<? extends Publishable> type){ public Array<Fi> getWorkshopContent(Class<? extends Publishable> type){
return !steam ? super.getWorkshopContent(type) : SVars.workshop.getWorkshopFiles(type); return !steam ? super.getWorkshopContent(type) : SVars.workshop.getWorkshopFiles(type);
} }

View File

@@ -21,7 +21,7 @@ import static io.anuke.mindustry.Vars.*;
public class SWorkshop implements SteamUGCCallback{ public class SWorkshop implements SteamUGCCallback{
public final SteamUGC ugc = new SteamUGC(this); public final SteamUGC ugc = new SteamUGC(this);
private ObjectMap<Class<? extends Publishable>, Array<FileHandle>> workshopFiles = new ObjectMap<>(); private ObjectMap<Class<? extends Publishable>, Array<Fi>> workshopFiles = new ObjectMap<>();
private ObjectMap<SteamUGCQuery, Cons2<Array<SteamUGCDetails>, SteamResult>> detailHandlers = new ObjectMap<>(); private ObjectMap<SteamUGCQuery, Cons2<Array<SteamUGCDetails>, SteamResult>> detailHandlers = new ObjectMap<>();
private Array<Cons<SteamPublishedFileID>> itemHandlers = new Array<>(); private Array<Cons<SteamPublishedFileID>> itemHandlers = new Array<>();
private ObjectMap<SteamPublishedFileID, Runnable> updatedHandlers = new ObjectMap<>(); private ObjectMap<SteamPublishedFileID, Runnable> updatedHandlers = new ObjectMap<>();
@@ -32,9 +32,9 @@ public class SWorkshop implements SteamUGCCallback{
ItemInstallInfo info = new ItemInstallInfo(); ItemInstallInfo info = new ItemInstallInfo();
ugc.getSubscribedItems(ids); ugc.getSubscribedItems(ids);
Array<FileHandle> folders = Array.with(ids).map(f -> { Array<Fi> folders = Array.with(ids).map(f -> {
ugc.getItemInstallInfo(f, info); ugc.getItemInstallInfo(f, info);
return new FileHandle(info.getFolder()); return new Fi(info.getFolder());
}).select(f -> f != null && f.list().length > 0); }).select(f -> f != null && f.list().length > 0);
workshopFiles.put(Map.class, folders.select(f -> f.list().length == 1 && f.list()[0].extension().equals(mapExtension)).map(f -> f.list()[0])); workshopFiles.put(Map.class, folders.select(f -> f.list().length == 1 && f.list()[0].extension().equals(mapExtension)).map(f -> f.list()[0]));
@@ -50,7 +50,7 @@ public class SWorkshop implements SteamUGCCallback{
}); });
} }
public Array<FileHandle> getWorkshopFiles(Class<? extends Publishable> type){ public Array<Fi> getWorkshopFiles(Class<? extends Publishable> type){
return workshopFiles.getOr(type, () -> new Array<>(0)); return workshopFiles.getOr(type, () -> new Array<>(0));
} }

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=60d97c3e52131d2d8be45a1d2f1bfe19c2e343a2 archash=a2aebbf5ee64ebf4626962ca5e2288b1e051d311

View File

@@ -38,7 +38,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
return new IOSApplication(new ClientLauncher(){ return new IOSApplication(new ClientLauncher(){
@Override @Override
public void showFileChooser(boolean open, String extension, Cons<FileHandle> cons){ public void showFileChooser(boolean open, String extension, Cons<Fi> cons){
UIDocumentBrowserViewController cont = new UIDocumentBrowserViewController((NSArray<NSString>)null); UIDocumentBrowserViewController cont = new UIDocumentBrowserViewController((NSArray<NSString>)null);
@@ -64,8 +64,8 @@ public class IOSLauncher extends IOSApplication.Delegate{
try{ try{
coord.coordinateReadingItem(url, NSFileCoordinatorReadingOptions.ForUploading, result -> { coord.coordinateReadingItem(url, NSFileCoordinatorReadingOptions.ForUploading, result -> {
FileHandle src = Core.files.absolute(result.getAbsoluteURL().getPath()); Fi src = Core.files.absolute(result.getAbsoluteURL().getPath());
FileHandle dst = Core.files.absolute(getDocumentsDirectory()).child(src.name()); Fi dst = Core.files.absolute(getDocumentsDirectory()).child(src.name());
src.copyTo(dst); src.copyTo(dst);
Core.app.post(() -> { Core.app.post(() -> {
@@ -116,10 +116,10 @@ public class IOSLauncher extends IOSApplication.Delegate{
} }
@Override @Override
public void shareFile(FileHandle file){ public void shareFile(Fi file){
try{ try{
Log.info("Attempting to share file " + file); Log.info("Attempting to share file " + file);
FileHandle to = Core.files.absolute(getDocumentsDirectory()).child(file.name()); Fi to = Core.files.absolute(getDocumentsDirectory()).child(file.name());
file.copyTo(to); file.copyTo(to);
NSURL url = new NSURL(to.file()); NSURL url = new NSURL(to.file());
@@ -196,7 +196,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
void openURL(NSURL url){ void openURL(NSURL url){
Core.app.post(() -> Core.app.post(() -> { Core.app.post(() -> Core.app.post(() -> {
FileHandle file = Core.files.absolute(getDocumentsDirectory()).child(url.getLastPathComponent()); Fi file = Core.files.absolute(getDocumentsDirectory()).child(url.getLastPathComponent());
Core.files.absolute(url.getPath()).copyTo(file); Core.files.absolute(url.getPath()).copyTo(file);
if(file.extension().equalsIgnoreCase(saveExtension)){ //open save if(file.extension().equalsIgnoreCase(saveExtension)){ //open save

View File

@@ -46,9 +46,9 @@ public class ServerControl implements ApplicationListener{
protected static DateTimeFormatter dateTime = DateTimeFormatter.ofPattern("MM-dd-yyyy | HH:mm:ss"); protected static DateTimeFormatter dateTime = DateTimeFormatter.ofPattern("MM-dd-yyyy | HH:mm:ss");
private final CommandHandler handler = new CommandHandler(""); private final CommandHandler handler = new CommandHandler("");
private final FileHandle logFolder = Core.settings.getDataDirectory().child("logs/"); private final Fi logFolder = Core.settings.getDataDirectory().child("logs/");
private FileHandle currentLogFile; private Fi currentLogFile;
private boolean inExtraRound; private boolean inExtraRound;
private Task lastTask; private Task lastTask;
private Gamemode lastMode = Gamemode.survival; private Gamemode lastMode = Gamemode.survival;
@@ -746,7 +746,7 @@ public class ServerControl implements ApplicationListener{
return; return;
} }
FileHandle file = saveDirectory.child(arg[0] + "." + saveExtension); Fi file = saveDirectory.child(arg[0] + "." + saveExtension);
if(!SaveIO.isSaveValid(file)){ if(!SaveIO.isSaveValid(file)){
err("No (valid) save data found for slot."); err("No (valid) save data found for slot.");
@@ -772,7 +772,7 @@ public class ServerControl implements ApplicationListener{
return; return;
} }
FileHandle file = saveDirectory.child(arg[0] + "." + saveExtension); Fi file = saveDirectory.child(arg[0] + "." + saveExtension);
Core.app.post(() -> { Core.app.post(() -> {
SaveIO.save(file); SaveIO.save(file);
@@ -782,7 +782,7 @@ public class ServerControl implements ApplicationListener{
handler.register("saves", "List all saves in the save directory.", arg -> { handler.register("saves", "List all saves in the save directory.", arg -> {
info("Save files: "); info("Save files: ");
for(FileHandle file : saveDirectory.list()){ for(Fi file : saveDirectory.list()){
if(file.extension().equals(saveExtension)){ if(file.extension().equals(saveExtension)){
info("| &ly{0}", file.nameWithoutExtension()); info("| &ly{0}", file.nameWithoutExtension());
} }

View File

@@ -43,11 +43,11 @@ public class ServerLauncher implements ApplicationListener{
loadLocales = false; loadLocales = false;
headless = true; headless = true;
FileHandle plugins = Core.settings.getDataDirectory().child("plugins"); Fi plugins = Core.settings.getDataDirectory().child("plugins");
if(plugins.isDirectory() && plugins.list().length > 0 && !plugins.sibling("mods").exists()){ if(plugins.isDirectory() && plugins.list().length > 0 && !plugins.sibling("mods").exists()){
Log.warn("[IMPORTANT NOTICE] &lrPlugins have been detected.&ly Automatically moving all contents of the plugin folder into the 'mods' folder. The original folder will not be removed; please do so manually."); Log.warn("[IMPORTANT NOTICE] &lrPlugins have been detected.&ly Automatically moving all contents of the plugin folder into the 'mods' folder. The original folder will not be removed; please do so manually.");
plugins.sibling("mods").mkdirs(); plugins.sibling("mods").mkdirs();
for(FileHandle file : plugins.list()){ for(Fi file : plugins.list()){
file.copyTo(plugins.sibling("mods")); file.copyTo(plugins.sibling("mods"));
} }
} }

View File

@@ -62,7 +62,7 @@ public class ScriptStubGenerator{
ObjectSet<String> used = ObjectSet.with(); ObjectSet<String> used = ObjectSet.with();
StringBuilder result = new StringBuilder("//Generated class. Do not modify.\n"); StringBuilder result = new StringBuilder("//Generated class. Do not modify.\n");
result.append("\n").append(new FileHandle("core/assets/scripts/base.js").readString()).append("\n"); result.append("\n").append(new Fi("core/assets/scripts/base.js").readString()).append("\n");
for(Class type : classes){ for(Class type : classes){
if(used.contains(type.getPackage().getName()) || nopackage.contains(s -> type.getName().startsWith(s))) continue; if(used.contains(type.getPackage().getName()) || nopackage.contains(s -> type.getName().startsWith(s))) continue;
result.append("importPackage(Packages.").append(type.getPackage().getName()).append(")\n"); result.append("importPackage(Packages.").append(type.getPackage().getName()).append(")\n");
@@ -71,8 +71,8 @@ public class ScriptStubGenerator{
//Log.info(result); //Log.info(result);
new FileHandle("core/assets/scripts/global.js").writeString(result.toString()); new Fi("core/assets/scripts/global.js").writeString(result.toString());
new FileHandle("core/src/io/anuke/mindustry/mod/ClassAccess.java").writeString(fileTemplate new Fi("core/src/io/anuke/mindustry/mod/ClassAccess.java").writeString(fileTemplate
.replace("$ALLOWED_CLASSES$", classes.toString(", ", type -> type.getName() + ".class")) .replace("$ALLOWED_CLASSES$", classes.toString(", ", type -> type.getName() + ".class"))
.replace("$ALLOWED_CLASS_NAMES$", classes.toString(", ", type -> "\"" + type.getName() + "\""))); .replace("$ALLOWED_CLASS_NAMES$", classes.toString(", ", type -> "\"" + type.getName() + "\"")));
} }

View File

@@ -1,7 +1,7 @@
package io.anuke.mindustry.tools; package io.anuke.mindustry.tools;
import io.anuke.arc.Core; import io.anuke.arc.Core;
import io.anuke.arc.files.FileHandle; import io.anuke.arc.files.Fi;
import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.Pixmap; import io.anuke.arc.graphics.Pixmap;
import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.Draw;
@@ -19,7 +19,7 @@ public class SquareMarcher{
this.buffer = new FrameBuffer(resolution, resolution); this.buffer = new FrameBuffer(resolution, resolution);
} }
void render(Pixmap pixmap, FileHandle file){ void render(Pixmap pixmap, Fi file){
boolean[][] grid = new boolean[pixmap.getWidth()][pixmap.getHeight()]; boolean[][] grid = new boolean[pixmap.getWidth()][pixmap.getHeight()];
for(int x = 0; x < pixmap.getWidth(); x++){ for(int x = 0; x < pixmap.getWidth(); x++){

View File

@@ -24,17 +24,17 @@ public class Upscaler{
Core.batch = new SpriteBatch(); Core.batch = new SpriteBatch();
Core.atlas = new TextureAtlas(); Core.atlas = new TextureAtlas();
Core.atlas.addRegion("white", Pixmaps.blankTextureRegion()); Core.atlas.addRegion("white", Pixmaps.blankTextureRegion());
FileHandle file = Core.files.local(""); Fi file = Core.files.local("");
Log.info("Upscaling icons..."); Log.info("Upscaling icons...");
Time.mark(); Time.mark();
FileHandle[] list = file.list(); Fi[] list = file.list();
for(IconSize size : IconSize.values()){ for(IconSize size : IconSize.values()){
String suffix = size == IconSize.def ? "" : "-" + size.name(); String suffix = size == IconSize.def ? "" : "-" + size.name();
SquareMarcher marcher = new SquareMarcher(size.size); SquareMarcher marcher = new SquareMarcher(size.size);
for(FileHandle img : list){ for(Fi img : list){
if(img.extension().equals("png")){ if(img.extension().equals("png")){
marcher.render(new Pixmap(img), img.sibling(img.nameWithoutExtension() + suffix + ".png")); marcher.render(new Pixmap(img), img.sibling(img.nameWithoutExtension() + suffix + ".png"));
} }