diff --git a/core/src/io/anuke/mindustry/core/Platform.java b/core/src/io/anuke/mindustry/core/Platform.java index b508f66b4c..88b971cfca 100644 --- a/core/src/io/anuke/mindustry/core/Platform.java +++ b/core/src/io/anuke/mindustry/core/Platform.java @@ -64,7 +64,15 @@ public abstract class Platform { } /**Only used for iOS or android: open the share menu for a map or save.*/ public void shareFile(FileHandle file){} - /**Show a file chooser. Desktop only.*/ + + /**Show a file chooser. Desktop only. + * + * @param text File chooser title text + * @param content Type of files to be loaded + * @param cons Selection listener + * @param open Whether to open or save files. + * @param filetypes List of file extensions to filter. + */ public void showFileChooser(String text, String content, Consumer cons, boolean open, String... filetypes){} /**Use the default thread provider from the kryonet module for this.*/ public ThreadProvider getThreadProvider(){ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java index 9afe4b2736..2b20d42627 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java @@ -87,14 +87,14 @@ public class LoadDialog extends FloatingDialog{ if(!gwt) { t.addImageButton("icon-save", "empty", 14 * 3, () -> { if(!ios) { - new FileChooser("$text.save.export", false, file -> { - try { - slot.exportFile(file); - setup(); - } catch (IOException e) { - ui.showError(Bundles.format("text.save.export.fail", Strings.parseException(e, false))); - } - }).show(); + Platform.instance.showFileChooser(Bundles.get("text.save.export"), "Mindustry Save", file -> { + try { + slot.exportFile(file); + setup(); + } catch (IOException e) { + ui.showError(Bundles.format("text.save.export.fail", Strings.parseException(e, false))); + } + }, false, "mins"); }else{ try { FileHandle file = Gdx.files.local("save-" + slot.getName() + ".mins"); @@ -150,7 +150,7 @@ public class LoadDialog extends FloatingDialog{ if(gwt || ios) return; slots.addImageTextButton("$text.save.import", "icon-add", "clear", 14*3, () -> { - new FileChooser("$text.save.import", f -> f.extension().equals("mins"), true, file -> { + Platform.instance.showFileChooser(Bundles.get("text.save.import"), "Mindustry Save", file -> { if(SaveIO.isSaveValid(file)){ try{ control.getSaves().importSave(file); @@ -161,7 +161,7 @@ public class LoadDialog extends FloatingDialog{ }else{ ui.showError("$text.save.import.invalid"); } - }).show(); + }, true, "mins"); }).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4); } diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java b/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java index f018e35fd0..4c007bd4ad 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java @@ -20,8 +20,9 @@ public class DesktopLauncher { config.setMaximized(true); config.setWindowedMode(960, 540); config.setWindowIcon("sprites/icon.png"); + if(OS.isMac) { - config.setPreferencesConfig(UCore.getProperty("user.home") + "/Library/Application Support/", FileType.Absolute); + config.setPreferencesConfig(UCore.getProperty("user.home") + "/Library/Application Support/Mindustry", FileType.Absolute); } Platform.instance = new DesktopPlatform(arg); diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java index e9fa2400ab..46d7548be2 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java @@ -55,6 +55,7 @@ public class DesktopPlatform extends Platform { FxApp.cons = cons; FxApp.filter = filter; FxApp.open = open; + FxApp.content = content; FxApp.open(); }){{ setDaemon(true); @@ -208,7 +209,7 @@ public class DesktopPlatform extends Platform { file = chooser.showSaveDialog(null); } if (file != null) { - cons.accept(Gdx.files.absolute(file.getAbsolutePath())); + Gdx.app.postRunnable(() -> cons.accept(Gdx.files.absolute(file.getAbsolutePath()))); } } }