mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 04:09:07 +07:00
Eliminated 8 characters
This commit is contained in:
parent
95a1474b9a
commit
0cf39bf5c3
@ -70,11 +70,11 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shareFile(FileHandle file){
|
||||
public void shareFile(Fi file){
|
||||
}
|
||||
|
||||
@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){
|
||||
Intent intent = new Intent(open ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_CREATE_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
@ -85,7 +85,7 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
|
||||
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
|
||||
public InputStream read(){
|
||||
try{
|
||||
@ -185,7 +185,7 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
Core.app.post(() -> Core.app.post(() -> {
|
||||
if(save){ //open 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);
|
||||
if(SaveIO.isSaveValid(file)){
|
||||
try{
|
||||
@ -198,7 +198,7 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
ui.showErrorMessage("$save.import.invalid");
|
||||
}
|
||||
}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);
|
||||
Core.app.post(() -> {
|
||||
System.out.println("Opening map.");
|
||||
|
@ -125,21 +125,21 @@ public class Vars implements Loadable{
|
||||
/** whether typing into the console is enabled - developers only */
|
||||
public static boolean enableConsole = false;
|
||||
/** application data directory, equivalent to {@link io.anuke.arc.Settings#getDataDirectory()} */
|
||||
public static FileHandle dataDirectory;
|
||||
public static Fi dataDirectory;
|
||||
/** data subdirectory used for screenshots */
|
||||
public static FileHandle screenshotDirectory;
|
||||
public static Fi screenshotDirectory;
|
||||
/** data subdirectory used for custom mmaps */
|
||||
public static FileHandle customMapDirectory;
|
||||
public static Fi customMapDirectory;
|
||||
/** data subdirectory used for custom mmaps */
|
||||
public static FileHandle mapPreviewDirectory;
|
||||
public static Fi mapPreviewDirectory;
|
||||
/** tmp subdirectory for map conversion */
|
||||
public static FileHandle tmpDirectory;
|
||||
public static Fi tmpDirectory;
|
||||
/** data subdirectory used for saves */
|
||||
public static FileHandle saveDirectory;
|
||||
public static Fi saveDirectory;
|
||||
/** data subdirectory used for mods */
|
||||
public static FileHandle modDirectory;
|
||||
public static Fi modDirectory;
|
||||
/** data subdirectory used for schematics */
|
||||
public static FileHandle schematicDirectory;
|
||||
public static Fi schematicDirectory;
|
||||
/** map file extension */
|
||||
public static final String mapExtension = "msav";
|
||||
/** save file extension */
|
||||
@ -317,7 +317,7 @@ public class Vars implements Loadable{
|
||||
|
||||
try{
|
||||
//try loading external bundle
|
||||
FileHandle handle = Core.files.local("bundle");
|
||||
Fi handle = Core.files.local("bundle");
|
||||
|
||||
Locale locale = Locale.ENGLISH;
|
||||
Core.bundle = I18NBundle.createBundle(handle, locale);
|
||||
@ -330,7 +330,7 @@ public class Vars implements Loadable{
|
||||
}catch(Throwable e){
|
||||
//no external bundle found
|
||||
|
||||
FileHandle handle = Core.files.internal("bundles/bundle");
|
||||
Fi handle = Core.files.internal("bundles/bundle");
|
||||
Locale locale;
|
||||
String loc = Core.settings.getString("locale");
|
||||
if(loc.equals("default")){
|
||||
|
@ -7,14 +7,14 @@ import io.anuke.arc.files.*;
|
||||
|
||||
/** Handles files in a modded context. */
|
||||
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);
|
||||
}
|
||||
|
||||
/** Gets an asset file.*/
|
||||
public FileHandle get(String path){
|
||||
public Fi get(String path){
|
||||
if(files.containsKey(path)){
|
||||
return files.get(path);
|
||||
}else if(files.containsKey("/" + path)){
|
||||
@ -30,7 +30,7 @@ public class FileTree implements FileHandleResolver{
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileHandle resolve(String fileName){
|
||||
public Fi resolve(String fileName){
|
||||
return get(fileName);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public interface Platform{
|
||||
default void viewListingID(String mapid){}
|
||||
|
||||
/** 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);
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ public interface Platform{
|
||||
}
|
||||
|
||||
/** 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 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 -> {
|
||||
if(!open){
|
||||
cons.get(file.parent().child(file.nameWithoutExtension() + "." + extension));
|
||||
|
@ -456,7 +456,7 @@ public class Renderer implements ApplicationListener{
|
||||
buffer.end();
|
||||
Pixmap fullPixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888);
|
||||
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);
|
||||
fullPixmap.dispose();
|
||||
ui.showInfoFade(Core.bundle.format("screenshot", file.toString()));
|
||||
|
@ -138,7 +138,7 @@ public class UI implements ApplicationListener, Loadable{
|
||||
Core.assets.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
|
||||
Core.assets.setLoader(BitmapFont.class, null, new FreetypeFontLoader(resolver){
|
||||
@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")){
|
||||
parameter.fontParameters.borderWidth = Scl.scl(2f);
|
||||
parameter.fontParameters.spaceX -= parameter.fontParameters.borderWidth;
|
||||
|
@ -27,7 +27,7 @@ public class Version{
|
||||
if(!enabled) return;
|
||||
|
||||
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<>();
|
||||
PropertiesUtils.load(map, file.reader());
|
||||
|
@ -54,7 +54,8 @@ public abstract class Content implements Comparable<Content>{
|
||||
/** The mod that loaded this piece of content. */
|
||||
public @Nullable LoadedMod mod;
|
||||
/** 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. */
|
||||
public @Nullable String error;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
|
||||
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.Boolf;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
}else{
|
||||
ui.loadAnd(() -> {
|
||||
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));
|
||||
platform.shareFile(result);
|
||||
}catch(Exception e){
|
||||
@ -381,7 +381,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
editor.renderer().dispose();
|
||||
}
|
||||
|
||||
public void beginEditMap(FileHandle file){
|
||||
public void beginEditMap(Fi file){
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
shownWithMap = true;
|
||||
|
@ -35,8 +35,8 @@ public class GlobalData{
|
||||
});
|
||||
}
|
||||
|
||||
public void exportData(FileHandle file) throws IOException{
|
||||
Array<FileHandle> files = new Array<>();
|
||||
public void exportData(Fi file) throws IOException{
|
||||
Array<Fi> files = new Array<>();
|
||||
files.add(Core.settings.getSettingsFile());
|
||||
files.addAll(customMapDirectory.list());
|
||||
files.addAll(saveDirectory.list());
|
||||
@ -46,7 +46,7 @@ public class GlobalData{
|
||||
String base = Core.settings.getDataDirectory().path();
|
||||
|
||||
try(OutputStream fos = file.write(false, 2048); ZipOutputStream zos = new ZipOutputStream(fos)){
|
||||
for(FileHandle add : files){
|
||||
for(Fi add : files){
|
||||
if(add.isDirectory()) continue;
|
||||
zos.putNextEntry(new ZipEntry(add.path().substring(base.length())));
|
||||
Streams.copyStream(add.read(), zos);
|
||||
@ -56,12 +56,12 @@ public class GlobalData{
|
||||
}
|
||||
}
|
||||
|
||||
public void importData(FileHandle file){
|
||||
FileHandle dest = Core.files.local("zipdata.zip");
|
||||
public void importData(Fi file){
|
||||
Fi dest = Core.files.local("zipdata.zip");
|
||||
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()){
|
||||
throw new IllegalArgumentException("Not valid save data.");
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class Saves{
|
||||
private AsyncExecutor previewExecutor = new AsyncExecutor(1);
|
||||
private boolean saving;
|
||||
private float time;
|
||||
private FileHandle zoneFile;
|
||||
private Fi zoneFile;
|
||||
|
||||
private long totalPlaytime;
|
||||
private long lastTimestamp;
|
||||
@ -48,7 +48,7 @@ public class Saves{
|
||||
saves.clear();
|
||||
zoneFile = saveDirectory.child("-1.msav");
|
||||
|
||||
for(FileHandle file : saveDirectory.list()){
|
||||
for(Fi file : saveDirectory.list()){
|
||||
if(!file.name().contains("backup") && SaveIO.isSaveValid(file)){
|
||||
SaveSlot slot = new SaveSlot(file);
|
||||
saves.add(slot);
|
||||
@ -121,7 +121,7 @@ public class Saves{
|
||||
return slot;
|
||||
}
|
||||
|
||||
public SaveSlot importSave(FileHandle file) throws IOException{
|
||||
public SaveSlot importSave(Fi file) throws IOException{
|
||||
SaveSlot slot = new SaveSlot(getNextSlotFile());
|
||||
slot.importFile(file);
|
||||
slot.setName(file.nameWithoutExtension());
|
||||
@ -136,9 +136,9 @@ public class Saves{
|
||||
return slot == null || slot.getZone() == null ? null : slot;
|
||||
}
|
||||
|
||||
public FileHandle getNextSlotFile(){
|
||||
public Fi getNextSlotFile(){
|
||||
int i = 0;
|
||||
FileHandle file;
|
||||
Fi file;
|
||||
while((file = saveDirectory.child(i + "." + saveExtension)).exists()){
|
||||
i ++;
|
||||
}
|
||||
@ -151,11 +151,11 @@ public class Saves{
|
||||
|
||||
public class SaveSlot{
|
||||
//public final int index;
|
||||
public final FileHandle file;
|
||||
public final Fi file;
|
||||
boolean requestedPreview;
|
||||
SaveMeta meta;
|
||||
|
||||
public SaveSlot(FileHandle file){
|
||||
public SaveSlot(Fi file){
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
@ -216,11 +216,11 @@ public class Saves{
|
||||
return file.nameWithoutExtension();
|
||||
}
|
||||
|
||||
private FileHandle previewFile(){
|
||||
private Fi previewFile(){
|
||||
return mapPreviewDirectory.child("save_slot_" + index() + ".png");
|
||||
}
|
||||
|
||||
private FileHandle loadPreviewFile(){
|
||||
private Fi loadPreviewFile(){
|
||||
return previewFile().sibling(previewFile().name() + ".spreview");
|
||||
}
|
||||
|
||||
@ -293,7 +293,7 @@ public class Saves{
|
||||
Core.settings.save();
|
||||
}
|
||||
|
||||
public void importFile(FileHandle from) throws IOException{
|
||||
public void importFile(Fi from) throws IOException{
|
||||
try{
|
||||
from.copyTo(file);
|
||||
}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{
|
||||
file.copyTo(to);
|
||||
}catch(Exception e){
|
||||
|
@ -16,7 +16,8 @@ public class Schematic implements Publishable, Comparable<Schematic>{
|
||||
public final Array<Stile> tiles;
|
||||
public StringMap tags;
|
||||
public int width, height;
|
||||
public @Nullable FileHandle file;
|
||||
public @Nullable
|
||||
Fi file;
|
||||
/** Associated mod. If null, no mod is associated with this schematic. */
|
||||
public @Nullable LoadedMod mod;
|
||||
|
||||
@ -94,15 +95,15 @@ public class Schematic implements Publishable, Comparable<Schematic>{
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileHandle createSteamFolder(String id){
|
||||
FileHandle directory = tmpDirectory.child("schematic_" + id).child("schematic." + schematicExtension);
|
||||
public Fi createSteamFolder(String id){
|
||||
Fi directory = tmpDirectory.child("schematic_" + id).child("schematic." + schematicExtension);
|
||||
file.copyTo(directory);
|
||||
return directory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileHandle createSteamPreview(String id){
|
||||
FileHandle preview = tmpDirectory.child("schematic_preview_" + id + ".png");
|
||||
public Fi createSteamPreview(String id){
|
||||
Fi preview = tmpDirectory.child("schematic_preview_" + id + ".png");
|
||||
schematics.savePreview(this, preview);
|
||||
return preview;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class Schematics implements Loadable{
|
||||
public void load(){
|
||||
all.clear();
|
||||
|
||||
for(FileHandle file : schematicDirectory.list()){
|
||||
for(Fi file : schematicDirectory.list()){
|
||||
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;
|
||||
|
||||
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);
|
||||
Draw.flush();
|
||||
buffer.begin();
|
||||
@ -272,7 +272,7 @@ public class Schematics implements Loadable{
|
||||
public void add(Schematic schematic){
|
||||
all.add(schematic);
|
||||
try{
|
||||
FileHandle file = schematicDirectory.child(Time.millis() + "." + schematicExtension);
|
||||
Fi file = schematicDirectory.child(Time.millis() + "." + schematicExtension);
|
||||
write(schematic, file);
|
||||
schematic.file = file;
|
||||
}catch(Exception e){
|
||||
@ -372,7 +372,7 @@ public class Schematics implements Loadable{
|
||||
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)));
|
||||
if(!s.tags.containsKey("name")){
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class LegacyMapIO{
|
||||
private static final Json json = new Json();
|
||||
|
||||
/* 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);
|
||||
|
||||
String waves = map.tags.get("waves", "[]");
|
||||
@ -45,7 +45,7 @@ public class LegacyMapIO{
|
||||
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))){
|
||||
StringMap tags = new StringMap();
|
||||
|
||||
@ -76,11 +76,11 @@ public class LegacyMapIO{
|
||||
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]);
|
||||
}
|
||||
|
||||
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)){
|
||||
|
||||
//read map
|
||||
|
@ -22,7 +22,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
public class MapIO{
|
||||
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)){
|
||||
for(int i1 : pngHeader){
|
||||
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)){
|
||||
SaveIO.readHeader(stream);
|
||||
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{
|
||||
SaveIO.write(file, map.tags);
|
||||
}catch(Exception e){
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.anuke.mindustry.io;
|
||||
|
||||
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.FastDeflaterOutputStream;
|
||||
import io.anuke.mindustry.Vars;
|
||||
@ -34,7 +34,7 @@ public class SaveIO{
|
||||
return versions.get(version);
|
||||
}
|
||||
|
||||
public static void save(FileHandle file){
|
||||
public static void save(Fi file){
|
||||
boolean exists = file.exists();
|
||||
if(exists) file.moveTo(backupFileFor(file));
|
||||
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)));
|
||||
}
|
||||
|
||||
public static DataInputStream getBackupStream(FileHandle file){
|
||||
public static DataInputStream getBackupStream(Fi file){
|
||||
return new DataInputStream(new InflaterInputStream(backupFileFor(file).read(bufferSize)));
|
||||
}
|
||||
|
||||
public static boolean isSaveValid(FileHandle file){
|
||||
public static boolean isSaveValid(Fi file){
|
||||
try{
|
||||
return isSaveValid(new DataInputStream(new InflaterInputStream(file.read(bufferSize))));
|
||||
}catch(Exception e){
|
||||
@ -71,7 +71,7 @@ public class SaveIO{
|
||||
}
|
||||
}
|
||||
|
||||
public static SaveMeta getMeta(FileHandle file){
|
||||
public static SaveMeta getMeta(Fi file){
|
||||
try{
|
||||
return getMeta(getStream(file));
|
||||
}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);
|
||||
}
|
||||
|
||||
public static FileHandle backupFileFor(FileHandle file){
|
||||
public static Fi backupFileFor(Fi file){
|
||||
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);
|
||||
}
|
||||
|
||||
public static void write(FileHandle file){
|
||||
public static void write(Fi file){
|
||||
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);
|
||||
}
|
||||
|
||||
public static void load(FileHandle file, WorldContext context) throws SaveException{
|
||||
public static void load(Fi file, WorldContext context) throws SaveException{
|
||||
try{
|
||||
//try and load; if any exception at all occurs
|
||||
load(new InflaterInputStream(file.read(bufferSize)), context);
|
||||
}catch(SaveException e){
|
||||
e.printStackTrace();
|
||||
FileHandle backup = file.sibling(file.name() + "-backup." + file.extension());
|
||||
Fi backup = file.sibling(file.name() + "-backup." + file.extension());
|
||||
if(backup.exists()){
|
||||
load(new InflaterInputStream(backup.read(bufferSize)), context);
|
||||
}else{
|
||||
|
@ -12,7 +12,7 @@ public class SavePreviewLoader extends TextureLoader{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAsync(AssetManager manager, String fileName, FileHandle file, TextureParameter parameter){
|
||||
public void loadAsync(AssetManager manager, String fileName, Fi file, TextureParameter parameter){
|
||||
try{
|
||||
super.loadAsync(manager, fileName, file.sibling(file.nameWithoutExtension()), parameter);
|
||||
}catch(Exception e){
|
||||
|
@ -22,7 +22,7 @@ public class Map implements Comparable<Map>, Publishable{
|
||||
/** Metadata. Author description, display name, etc. */
|
||||
public final StringMap tags;
|
||||
/** Base file of this map. File can be named anything at all. */
|
||||
public final FileHandle file;
|
||||
public final Fi file;
|
||||
/** Format version. */
|
||||
public final int version;
|
||||
/** 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. */
|
||||
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.tags = tags;
|
||||
this.file = file;
|
||||
@ -50,11 +50,11 @@ public class Map implements Comparable<Map>, Publishable{
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -70,11 +70,11 @@ public class Map implements Comparable<Map>, Publishable{
|
||||
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");
|
||||
}
|
||||
|
||||
public FileHandle cacheFile(){
|
||||
public Fi cacheFile(){
|
||||
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
|
||||
public FileHandle createSteamFolder(String id){
|
||||
FileHandle mapFile = tmpDirectory.child("map_" + id).child("map.msav");
|
||||
public Fi createSteamFolder(String id){
|
||||
Fi mapFile = tmpDirectory.child("map_" + id).child("map.msav");
|
||||
file.copyTo(mapFile);
|
||||
return mapFile.parent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileHandle createSteamPreview(String id){
|
||||
public Fi createSteamPreview(String id){
|
||||
return previewFile();
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class MapPreviewLoader extends TextureLoader{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAsync(AssetManager manager, String fileName, FileHandle file, TextureParameter parameter){
|
||||
public void loadAsync(AssetManager manager, String fileName, Fi file, TextureParameter parameter){
|
||||
try{
|
||||
super.loadAsync(manager, fileName, file.sibling(file.nameWithoutExtension()), parameter);
|
||||
}catch(Exception e){
|
||||
@ -28,7 +28,7 @@ public class MapPreviewLoader extends TextureLoader{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Texture loadSync(AssetManager manager, String fileName, FileHandle file, TextureParameter parameter){
|
||||
public Texture loadSync(AssetManager manager, String fileName, Fi file, TextureParameter parameter){
|
||||
try{
|
||||
return super.loadSync(manager, fileName, file, parameter);
|
||||
}catch(Throwable e){
|
||||
@ -43,7 +43,7 @@ public class MapPreviewLoader extends TextureLoader{
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class Maps{
|
||||
* Does not add this map to the map list.
|
||||
*/
|
||||
public Map loadInternalMap(String name){
|
||||
FileHandle file = tree.get("maps/" + name + "." + mapExtension);
|
||||
Fi file = tree.get("maps/" + name + "." + mapExtension);
|
||||
|
||||
try{
|
||||
return MapIO.createMap(file, false);
|
||||
@ -119,7 +119,7 @@ public class Maps{
|
||||
//defaults; must work
|
||||
try{
|
||||
for(String name : defaultMapNames){
|
||||
FileHandle file = Core.files.internal("maps/" + name + "." + mapExtension);
|
||||
Fi file = Core.files.internal("maps/" + name + "." + mapExtension);
|
||||
loadMap(file, false);
|
||||
}
|
||||
}catch(IOException e){
|
||||
@ -127,7 +127,7 @@ public class Maps{
|
||||
}
|
||||
|
||||
//custom
|
||||
for(FileHandle file : customMapDirectory.list()){
|
||||
for(Fi file : customMapDirectory.list()){
|
||||
try{
|
||||
if(file.extension().equalsIgnoreCase(mapExtension)){
|
||||
loadMap(file, true);
|
||||
@ -139,7 +139,7 @@ public class Maps{
|
||||
}
|
||||
|
||||
//workshop
|
||||
for(FileHandle file : platform.getWorkshopContent(Map.class)){
|
||||
for(Fi file : platform.getWorkshopContent(Map.class)){
|
||||
try{
|
||||
Map map = loadMap(file, false);
|
||||
map.workshop = true;
|
||||
@ -183,7 +183,7 @@ public class Maps{
|
||||
StringMap tags = new StringMap(baseTags);
|
||||
String name = tags.get("name");
|
||||
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
|
||||
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. */
|
||||
public void importMap(FileHandle file) throws IOException{
|
||||
FileHandle dest = findFile();
|
||||
public void importMap(Fi file) throws IOException{
|
||||
Fi dest = findFile();
|
||||
file.copyTo(dest);
|
||||
|
||||
Map map = loadMap(dest, true);
|
||||
@ -446,7 +446,7 @@ public class Maps{
|
||||
}
|
||||
|
||||
/** Find a new filename to put a map to. */
|
||||
private FileHandle findFile(){
|
||||
private Fi findFile(){
|
||||
//find a map name that isn't used.
|
||||
int i = maps.size;
|
||||
while(customMapDirectory.child("map_" + i + "." + mapExtension).exists()){
|
||||
@ -455,7 +455,7 @@ public class Maps{
|
||||
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);
|
||||
|
||||
if(map.name() == null){
|
||||
|
@ -405,7 +405,7 @@ public class ContentParser{
|
||||
* @param file file that this content is being parsed from
|
||||
* @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()){
|
||||
init();
|
||||
}
|
||||
@ -433,7 +433,7 @@ public class ContentParser{
|
||||
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.sourceFile = 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();
|
||||
builder.append("[lightgray]").append("File: ").append(file.name()).append("[]\n\n");
|
||||
|
||||
|
@ -6,7 +6,7 @@ import io.anuke.mindustry.*;
|
||||
|
||||
public class Mod{
|
||||
/** @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);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class Mods implements Loadable{
|
||||
private Json json = new Json();
|
||||
private @Nullable Scripts scripts;
|
||||
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 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.
|
||||
* Call this in init(). */
|
||||
public FileHandle getConfig(Mod mod){
|
||||
public Fi getConfig(Mod mod){
|
||||
ModMeta load = metas.get(mod.getClass());
|
||||
if(load == null) throw new IllegalArgumentException("Mod is not loaded yet (or missing)!");
|
||||
return modDirectory.child(load.name).child("config.json");
|
||||
}
|
||||
|
||||
/** 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 -> {
|
||||
FileHandle file = mod.root.child(directory);
|
||||
Fi file = mod.root.child(directory);
|
||||
if(file.exists()){
|
||||
for(FileHandle child : file.list()){
|
||||
for(Fi child : file.list()){
|
||||
cons.get(mod, child);
|
||||
}
|
||||
}
|
||||
@ -76,8 +76,8 @@ public class Mods implements Loadable{
|
||||
}
|
||||
|
||||
/** Imports an external mod file.*/
|
||||
public void importMod(FileHandle file) throws IOException{
|
||||
FileHandle dest = modDirectory.child(file.name());
|
||||
public void importMod(Fi file) throws IOException{
|
||||
Fi dest = modDirectory.child(file.name());
|
||||
if(dest.exists()){
|
||||
throw new IOException("A mod with the same filename already exists!");
|
||||
}
|
||||
@ -104,8 +104,8 @@ public class Mods implements Loadable{
|
||||
packer = new MultiPacker();
|
||||
|
||||
eachEnabled(mod -> {
|
||||
Array<FileHandle> 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> sprites = mod.root.child("sprites").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(overrides, mod, false);
|
||||
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());
|
||||
}
|
||||
|
||||
private void packSprites(Array<FileHandle> sprites, LoadedMod mod, boolean prefix){
|
||||
for(FileHandle file : sprites){
|
||||
private void packSprites(Array<Fi> sprites, LoadedMod mod, boolean prefix){
|
||||
for(Fi file : sprites){
|
||||
try(InputStream stream = file.read()){
|
||||
byte[] bytes = Streams.copyStreamToByteArray(stream, Math.max((int)file.length(), 512));
|
||||
Pixmap pixmap = new Pixmap(bytes, 0, bytes.length);
|
||||
@ -183,7 +183,7 @@ public class Mods implements Loadable{
|
||||
PageType.main;
|
||||
}
|
||||
|
||||
private PageType getPage(FileHandle file){
|
||||
private PageType getPage(Fi file){
|
||||
String parent = file.parent().name();
|
||||
return
|
||||
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. */
|
||||
public void removeMod(LoadedMod mod){
|
||||
if(mod.root instanceof ZipFileHandle){
|
||||
if(mod.root instanceof ZipFi){
|
||||
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.*/
|
||||
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;
|
||||
|
||||
Log.debug("[Mods] Loading mod {0}", file);
|
||||
@ -239,7 +239,7 @@ public class Mods implements Loadable{
|
||||
}
|
||||
|
||||
//load workshop mods now
|
||||
for(FileHandle file : platform.getWorkshopContent(LoadedMod.class)){
|
||||
for(Fi file : platform.getWorkshopContent(LoadedMod.class)){
|
||||
try{
|
||||
LoadedMod mod = loadMod(file);
|
||||
mods.add(mod);
|
||||
@ -311,7 +311,7 @@ public class Mods implements Loadable{
|
||||
for(LoadedMod mod : orderedMods()){
|
||||
boolean zipFolder = !mod.file.isDirectory() && mod.root.parent() != 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
|
||||
if(file.isDirectory() && !specialFolders.contains(file.name())){
|
||||
//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.
|
||||
FileHandle folder = mod.root.child("bundles");
|
||||
Fi folder = mod.root.child("bundles");
|
||||
if(folder.exists()){
|
||||
for(FileHandle file : folder.list()){
|
||||
for(Fi file : folder.list()){
|
||||
if(file.name().startsWith("bundle") && file.extension().equals("properties")){
|
||||
String name = file.nameWithoutExtension();
|
||||
bundles.getOr(name, Array::new).add(file);
|
||||
@ -337,7 +337,7 @@ public class Mods implements Loadable{
|
||||
while(bundle != null){
|
||||
String str = bundle.getLocale().toString();
|
||||
String locale = "bundle" + (str.isEmpty() ? "" : "_" + str);
|
||||
for(FileHandle file : bundles.getOr(locale, Array::new)){
|
||||
for(Fi file : bundles.getOr(locale, Array::new)){
|
||||
try{
|
||||
PropertiesUtils.load(bundle.getProperties(), file.reader());
|
||||
}catch(Exception e){
|
||||
@ -446,7 +446,7 @@ public class Mods implements Loadable{
|
||||
mod.scripts = mod.root.child("scripts").findAll(f -> f.extension().equals("js"));
|
||||
Log.debug("[{0}] Found {1} scripts.", mod.meta.name, mod.scripts.size);
|
||||
|
||||
for(FileHandle file : mod.scripts){
|
||||
for(Fi file : mod.scripts){
|
||||
try{
|
||||
if(scripts == null){
|
||||
scripts = platform.createScripts();
|
||||
@ -474,10 +474,10 @@ public class Mods implements Loadable{
|
||||
|
||||
class LoadRun implements Comparable<LoadRun>{
|
||||
final ContentType type;
|
||||
final FileHandle file;
|
||||
final Fi file;
|
||||
final LoadedMod mod;
|
||||
|
||||
public LoadRun(ContentType type, FileHandle file, LoadedMod mod){
|
||||
public LoadRun(ContentType type, Fi file, LoadedMod mod){
|
||||
this.type = type;
|
||||
this.file = file;
|
||||
this.mod = mod;
|
||||
@ -495,11 +495,11 @@ public class Mods implements Loadable{
|
||||
|
||||
for(LoadedMod mod : orderedMods()){
|
||||
if(mod.root.child("content").exists()){
|
||||
FileHandle contentRoot = mod.root.child("content");
|
||||
Fi contentRoot = mod.root.child("content");
|
||||
for(ContentType type : ContentType.all){
|
||||
FileHandle folder = contentRoot.child(type.name().toLowerCase() + "s");
|
||||
Fi folder = contentRoot.child(type.name().toLowerCase() + "s");
|
||||
if(folder.exists()){
|
||||
for(FileHandle file : folder.list()){
|
||||
for(Fi file : folder.list()){
|
||||
if(file.extension().equals("json") || file.extension().equals("hjson")){
|
||||
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.
|
||||
* Note that directories can be loaded as mods.*/
|
||||
private LoadedMod loadMod(FileHandle sourceFile) throws Exception{
|
||||
FileHandle zip = sourceFile.isDirectory() ? sourceFile : new ZipFileHandle(sourceFile);
|
||||
private LoadedMod loadMod(Fi sourceFile) throws Exception{
|
||||
Fi zip = sourceFile.isDirectory() ? sourceFile : new ZipFi(sourceFile);
|
||||
if(zip.list().length == 1 && zip.list()[0].isDirectory()){
|
||||
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()){
|
||||
Log.warn("Mod {0} doesn't have a 'mod.json'/'plugin.json'/'mod.js' file, skipping.", sourceFile);
|
||||
throw new IllegalArgumentException("No mod.json found.");
|
||||
@ -611,7 +611,7 @@ public class Mods implements Loadable{
|
||||
|
||||
Mod mainMod;
|
||||
|
||||
FileHandle mainFile = zip;
|
||||
Fi mainFile = zip;
|
||||
String[] path = (mainClass.replace('.', '/') + ".class").split("/");
|
||||
for(String str : path){
|
||||
if(!str.isEmpty()){
|
||||
@ -645,9 +645,9 @@ public class Mods implements Loadable{
|
||||
/** Represents a plugin that has been loaded from a jar file.*/
|
||||
public static class LoadedMod implements Publishable{
|
||||
/** 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. */
|
||||
public final FileHandle root;
|
||||
public final Fi root;
|
||||
/** The mod's main class; may be null. */
|
||||
public final @Nullable Mod main;
|
||||
/** Internal mod name. Used for textures. */
|
||||
@ -659,13 +659,13 @@ public class Mods implements Loadable{
|
||||
/** All missing dependencies of this mod as strings. */
|
||||
public Array<String> missingDependencies = new Array<>();
|
||||
/** Script files to run. */
|
||||
public Array<FileHandle> scripts = new Array<>();
|
||||
public Array<Fi> scripts = new Array<>();
|
||||
/** Content with intialization code. */
|
||||
public ObjectSet<Content> erroredContent = new ObjectSet<>();
|
||||
/** Current state of this mod. */
|
||||
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.file = file;
|
||||
this.main = main;
|
||||
@ -734,12 +734,12 @@ public class Mods implements Loadable{
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileHandle createSteamFolder(String id){
|
||||
public Fi createSteamFolder(String id){
|
||||
return file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileHandle createSteamPreview(String id){
|
||||
public Fi createSteamPreview(String id){
|
||||
return file.child("preview.png");
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class Scripts implements Disposable{
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ import static io.anuke.mindustry.Vars.net;
|
||||
public class CrashSender{
|
||||
|
||||
public static void send(Throwable exception, Cons<File> writeListener){
|
||||
|
||||
try{
|
||||
exception.printStackTrace();
|
||||
|
||||
@ -52,12 +53,11 @@ public class CrashSender{
|
||||
|
||||
try{
|
||||
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 FileHandle(file).writeString(parseException(exception));
|
||||
new Fi(OS.getAppDataDirectoryString(Vars.appName)).child("crashes").mkdirs();
|
||||
new Fi(file).writeString(parseException(exception));
|
||||
writeListener.get(file);
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
Log.err("Failed to save local crash report.");
|
||||
Log.err("Failed to save local crash report.", e);
|
||||
}
|
||||
|
||||
try{
|
||||
|
@ -20,9 +20,9 @@ public interface Publishable{
|
||||
/** @return the tag that this content has. e.g. 'schematic' or 'map'. */
|
||||
String steamTag();
|
||||
/** @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. */
|
||||
FileHandle createSteamPreview(String id);
|
||||
Fi createSteamPreview(String id);
|
||||
/** @return any extra tags to add to this item.*/
|
||||
default Array<String> extraTags(){
|
||||
return new Array<>(0);
|
||||
|
@ -18,20 +18,20 @@ import java.util.*;
|
||||
import static io.anuke.mindustry.Vars.platform;
|
||||
|
||||
public class FileChooser extends FloatingDialog{
|
||||
private static final FileHandle homeDirectory = Core.files.absolute(Core.files.getExternalStoragePath());
|
||||
private static FileHandle lastDirectory = homeDirectory;
|
||||
private static final Fi homeDirectory = Core.files.absolute(Core.files.getExternalStoragePath());
|
||||
private static Fi lastDirectory = homeDirectory;
|
||||
|
||||
private Table files;
|
||||
private FileHandle directory = lastDirectory;
|
||||
private Fi directory = lastDirectory;
|
||||
private ScrollPane pane;
|
||||
private TextField navigation, filefield;
|
||||
private TextButton ok;
|
||||
private FileHistory stack = new FileHistory();
|
||||
private Boolf<FileHandle> filter;
|
||||
private Cons<FileHandle> selectListener;
|
||||
private Boolf<Fi> filter;
|
||||
private Cons<Fi> selectListener;
|
||||
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);
|
||||
setFillParent(true);
|
||||
this.open = open;
|
||||
@ -154,8 +154,8 @@ public class FileChooser extends FloatingDialog{
|
||||
}
|
||||
}
|
||||
|
||||
private FileHandle[] getFileNames(){
|
||||
FileHandle[] handles = directory.list(file -> !file.getName().startsWith("."));
|
||||
private Fi[] getFileNames(){
|
||||
Fi[] handles = directory.list(file -> !file.getName().startsWith("."));
|
||||
|
||||
Arrays.sort(handles, (a, b) -> {
|
||||
if(a.isDirectory() && !b.isDirectory()) return -1;
|
||||
@ -183,7 +183,7 @@ public class FileChooser extends FloatingDialog{
|
||||
|
||||
files.clearChildren();
|
||||
files.top().left();
|
||||
FileHandle[] names = getFileNames();
|
||||
Fi[] names = getFileNames();
|
||||
|
||||
Image upimage = new Image(Icon.folderParentSmall);
|
||||
TextButton upbutton = new TextButton(".." + directory.toString(), Styles.clearTogglet);
|
||||
@ -204,7 +204,7 @@ public class FileChooser extends FloatingDialog{
|
||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||
group.setMinCheckCount(0);
|
||||
|
||||
for(FileHandle file : names){
|
||||
for(Fi file : names){
|
||||
if(!file.isDirectory() && !filter.get(file)) continue; //skip non-filtered files
|
||||
|
||||
String filename = file.name();
|
||||
@ -255,14 +255,14 @@ public class FileChooser extends FloatingDialog{
|
||||
}
|
||||
|
||||
public class FileHistory{
|
||||
private Array<FileHandle> history = new Array<>();
|
||||
private Array<Fi> history = new Array<>();
|
||||
private int index;
|
||||
|
||||
public FileHistory(){
|
||||
|
||||
}
|
||||
|
||||
public void push(FileHandle file){
|
||||
public void push(Fi file){
|
||||
if(index != history.size) history.truncate(index);
|
||||
history.add(file);
|
||||
index++;
|
||||
@ -296,7 +296,7 @@ public class FileChooser extends FloatingDialog{
|
||||
|
||||
System.out.println("\n\n\n\n\n\n");
|
||||
int i = 0;
|
||||
for(FileHandle file : history){
|
||||
for(Fi file : history){
|
||||
i++;
|
||||
if(index == i){
|
||||
System.out.println("[[" + file.toString() + "]]");
|
||||
|
@ -101,7 +101,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
});
|
||||
}else{
|
||||
try{
|
||||
FileHandle file = Core.files.local("save-" + slot.getName() + "." + saveExtension);
|
||||
Fi file = Core.files.local("save-" + slot.getName() + "." + saveExtension);
|
||||
slot.exportFile(file);
|
||||
platform.shareFile(file);
|
||||
}catch(Exception e){
|
||||
|
@ -46,7 +46,7 @@ public class ModsDialog extends FloatingDialog{
|
||||
ui.loadfrag.hide();
|
||||
}else{
|
||||
try{
|
||||
FileHandle file = tmpDirectory.child(text.replace("/", "") + ".zip");
|
||||
Fi file = tmpDirectory.child(text.replace("/", "") + ".zip");
|
||||
Streams.copyStream(result.getResultAsStream(), file.write(false));
|
||||
mods.importMod(file);
|
||||
file.delete();
|
||||
|
@ -95,7 +95,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
Core.settings.putAll(map);
|
||||
Core.settings.save();
|
||||
|
||||
for(FileHandle file : dataDirectory.list()){
|
||||
for(Fi file : dataDirectory.list()){
|
||||
file.deleteDirectory();
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
|
||||
t.addButton("$data.export", style, () -> {
|
||||
if(ios){
|
||||
FileHandle file = Core.files.local("mindustry-data-export.zip");
|
||||
Fi file = Core.files.local("mindustry-data-export.zip");
|
||||
try{
|
||||
data.exportData(file);
|
||||
}catch(Exception e){
|
||||
|
@ -77,8 +77,8 @@ public class DesktopLauncher extends ClientLauncher{
|
||||
|
||||
if(useSteam){
|
||||
//delete leftover dlls
|
||||
FileHandle file = new FileHandle(".");
|
||||
for(FileHandle other : file.parent().list()){
|
||||
Fi file = new Fi(".");
|
||||
for(Fi other : file.parent().list()){
|
||||
if(other.name().contains("steam") && (other.extension().equals("dll") || other.extension().equals("so") || other.extension().equals("dylib"))){
|
||||
other.delete();
|
||||
}
|
||||
@ -202,7 +202,7 @@ public class DesktopLauncher extends ClientLauncher{
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
public class SWorkshop implements SteamUGCCallback{
|
||||
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 Array<Cons<SteamPublishedFileID>> itemHandlers = new Array<>();
|
||||
private ObjectMap<SteamPublishedFileID, Runnable> updatedHandlers = new ObjectMap<>();
|
||||
@ -32,9 +32,9 @@ public class SWorkshop implements SteamUGCCallback{
|
||||
ItemInstallInfo info = new ItemInstallInfo();
|
||||
ugc.getSubscribedItems(ids);
|
||||
|
||||
Array<FileHandle> folders = Array.with(ids).map(f -> {
|
||||
Array<Fi> folders = Array.with(ids).map(f -> {
|
||||
ugc.getItemInstallInfo(f, info);
|
||||
return new FileHandle(info.getFolder());
|
||||
return new Fi(info.getFolder());
|
||||
}).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]));
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=60d97c3e52131d2d8be45a1d2f1bfe19c2e343a2
|
||||
archash=a2aebbf5ee64ebf4626962ca5e2288b1e051d311
|
||||
|
@ -38,7 +38,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
||||
return new IOSApplication(new ClientLauncher(){
|
||||
|
||||
@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);
|
||||
|
||||
|
||||
@ -64,8 +64,8 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
||||
try{
|
||||
coord.coordinateReadingItem(url, NSFileCoordinatorReadingOptions.ForUploading, result -> {
|
||||
|
||||
FileHandle src = Core.files.absolute(result.getAbsoluteURL().getPath());
|
||||
FileHandle dst = Core.files.absolute(getDocumentsDirectory()).child(src.name());
|
||||
Fi src = Core.files.absolute(result.getAbsoluteURL().getPath());
|
||||
Fi dst = Core.files.absolute(getDocumentsDirectory()).child(src.name());
|
||||
src.copyTo(dst);
|
||||
|
||||
Core.app.post(() -> {
|
||||
@ -116,10 +116,10 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shareFile(FileHandle file){
|
||||
public void shareFile(Fi file){
|
||||
try{
|
||||
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);
|
||||
|
||||
NSURL url = new NSURL(to.file());
|
||||
@ -196,7 +196,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
||||
void openURL(NSURL url){
|
||||
|
||||
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);
|
||||
|
||||
if(file.extension().equalsIgnoreCase(saveExtension)){ //open save
|
||||
|
@ -46,9 +46,9 @@ public class ServerControl implements ApplicationListener{
|
||||
protected static DateTimeFormatter dateTime = DateTimeFormatter.ofPattern("MM-dd-yyyy | HH:mm:ss");
|
||||
|
||||
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 Task lastTask;
|
||||
private Gamemode lastMode = Gamemode.survival;
|
||||
@ -746,7 +746,7 @@ public class ServerControl implements ApplicationListener{
|
||||
return;
|
||||
}
|
||||
|
||||
FileHandle file = saveDirectory.child(arg[0] + "." + saveExtension);
|
||||
Fi file = saveDirectory.child(arg[0] + "." + saveExtension);
|
||||
|
||||
if(!SaveIO.isSaveValid(file)){
|
||||
err("No (valid) save data found for slot.");
|
||||
@ -772,7 +772,7 @@ public class ServerControl implements ApplicationListener{
|
||||
return;
|
||||
}
|
||||
|
||||
FileHandle file = saveDirectory.child(arg[0] + "." + saveExtension);
|
||||
Fi file = saveDirectory.child(arg[0] + "." + saveExtension);
|
||||
|
||||
Core.app.post(() -> {
|
||||
SaveIO.save(file);
|
||||
@ -782,7 +782,7 @@ public class ServerControl implements ApplicationListener{
|
||||
|
||||
handler.register("saves", "List all saves in the save directory.", arg -> {
|
||||
info("Save files: ");
|
||||
for(FileHandle file : saveDirectory.list()){
|
||||
for(Fi file : saveDirectory.list()){
|
||||
if(file.extension().equals(saveExtension)){
|
||||
info("| &ly{0}", file.nameWithoutExtension());
|
||||
}
|
||||
|
@ -43,11 +43,11 @@ public class ServerLauncher implements ApplicationListener{
|
||||
loadLocales = false;
|
||||
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()){
|
||||
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();
|
||||
for(FileHandle file : plugins.list()){
|
||||
for(Fi file : plugins.list()){
|
||||
file.copyTo(plugins.sibling("mods"));
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class ScriptStubGenerator{
|
||||
ObjectSet<String> used = ObjectSet.with();
|
||||
|
||||
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){
|
||||
if(used.contains(type.getPackage().getName()) || nopackage.contains(s -> type.getName().startsWith(s))) continue;
|
||||
result.append("importPackage(Packages.").append(type.getPackage().getName()).append(")\n");
|
||||
@ -71,8 +71,8 @@ public class ScriptStubGenerator{
|
||||
|
||||
//Log.info(result);
|
||||
|
||||
new FileHandle("core/assets/scripts/global.js").writeString(result.toString());
|
||||
new FileHandle("core/src/io/anuke/mindustry/mod/ClassAccess.java").writeString(fileTemplate
|
||||
new Fi("core/assets/scripts/global.js").writeString(result.toString());
|
||||
new Fi("core/src/io/anuke/mindustry/mod/ClassAccess.java").writeString(fileTemplate
|
||||
.replace("$ALLOWED_CLASSES$", classes.toString(", ", type -> type.getName() + ".class"))
|
||||
.replace("$ALLOWED_CLASS_NAMES$", classes.toString(", ", type -> "\"" + type.getName() + "\"")));
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.anuke.mindustry.tools;
|
||||
|
||||
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.Pixmap;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
@ -19,7 +19,7 @@ public class SquareMarcher{
|
||||
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()];
|
||||
|
||||
for(int x = 0; x < pixmap.getWidth(); x++){
|
||||
|
@ -24,17 +24,17 @@ public class Upscaler{
|
||||
Core.batch = new SpriteBatch();
|
||||
Core.atlas = new TextureAtlas();
|
||||
Core.atlas.addRegion("white", Pixmaps.blankTextureRegion());
|
||||
FileHandle file = Core.files.local("");
|
||||
Fi file = Core.files.local("");
|
||||
|
||||
Log.info("Upscaling icons...");
|
||||
Time.mark();
|
||||
FileHandle[] list = file.list();
|
||||
Fi[] list = file.list();
|
||||
|
||||
for(IconSize size : IconSize.values()){
|
||||
String suffix = size == IconSize.def ? "" : "-" + size.name();
|
||||
SquareMarcher marcher = new SquareMarcher(size.size);
|
||||
|
||||
for(FileHandle img : list){
|
||||
for(Fi img : list){
|
||||
if(img.extension().equals("png")){
|
||||
marcher.render(new Pixmap(img), img.sibling(img.nameWithoutExtension() + suffix + ".png"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user