mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-11 18:39:16 +07:00
iOS map imports
This commit is contained in:
parent
a74722aea5
commit
5e0e3f4522
@ -67,55 +67,54 @@ public class MapsDialog extends FloatingDialog{
|
|||||||
});
|
});
|
||||||
}).size(210f, 64f);
|
}).size(210f, 64f);
|
||||||
|
|
||||||
if(!ios){
|
buttons.addImageTextButton("$editor.importmap", Icon.load, () -> {
|
||||||
buttons.addImageTextButton("$editor.importmap", Icon.load, () -> {
|
platform.showFileChooser(true, mapExtension, file -> {
|
||||||
platform.showFileChooser(true, mapExtension, file -> {
|
ui.loadAnd(() -> {
|
||||||
ui.loadAnd(() -> {
|
maps.tryCatchMapError(() -> {
|
||||||
maps.tryCatchMapError(() -> {
|
if(MapIO.isImage(file)){
|
||||||
if(MapIO.isImage(file)){
|
ui.showErrorMessage("$editor.errorimage");
|
||||||
ui.showErrorMessage("$editor.errorimage");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Map map = MapIO.createMap(file, true);
|
Map map = MapIO.createMap(file, true);
|
||||||
|
|
||||||
|
|
||||||
//when you attempt to import a save, it will have no name, so generate one
|
//when you attempt to import a save, it will have no name, so generate one
|
||||||
String name = map.tags.getOr("name", () -> {
|
String name = map.tags.getOr("name", () -> {
|
||||||
String result = "unknown";
|
String result = "unknown";
|
||||||
int number = 0;
|
int number = 0;
|
||||||
while(maps.byName(result + number++) != null);
|
while(maps.byName(result + number++) != null);
|
||||||
return result + number;
|
return result + number;
|
||||||
});
|
|
||||||
|
|
||||||
//this will never actually get called, but it remains just in case
|
|
||||||
if(name == null){
|
|
||||||
ui.showErrorMessage("$editor.errorname");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map conflict = maps.all().find(m -> m.name().equals(name));
|
|
||||||
|
|
||||||
if(conflict != null && !conflict.custom){
|
|
||||||
ui.showInfo(Core.bundle.format("editor.import.exists", name));
|
|
||||||
}else if(conflict != null){
|
|
||||||
ui.showConfirm("$confirm", "$editor.overwrite.confirm", () -> {
|
|
||||||
maps.tryCatchMapError(() -> {
|
|
||||||
maps.removeMap(conflict);
|
|
||||||
maps.importMap(map.file);
|
|
||||||
setup();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
maps.importMap(map.file);
|
|
||||||
setup();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//this will never actually get called, but it remains just in case
|
||||||
|
if(name == null){
|
||||||
|
ui.showErrorMessage("$editor.errorname");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map conflict = maps.all().find(m -> m.name().equals(name));
|
||||||
|
|
||||||
|
if(conflict != null && !conflict.custom){
|
||||||
|
ui.showInfo(Core.bundle.format("editor.import.exists", name));
|
||||||
|
}else if(conflict != null){
|
||||||
|
ui.showConfirm("$confirm", "$editor.overwrite.confirm", () -> {
|
||||||
|
maps.tryCatchMapError(() -> {
|
||||||
|
maps.removeMap(conflict);
|
||||||
|
maps.importMap(map.file);
|
||||||
|
setup();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
maps.importMap(map.file);
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).size(210f, 64f);
|
});
|
||||||
}
|
}).size(210f, 64f);
|
||||||
|
|
||||||
|
|
||||||
cont.clear();
|
cont.clear();
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=e40247177befbc2c6e312d67d6f5edad5817edca
|
archash=151dc8b70276b74c612d23b01573f7a8452c2b69
|
||||||
|
@ -58,9 +58,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||||||
if(documentURLs.size() < 1) return;
|
if(documentURLs.size() < 1) return;
|
||||||
|
|
||||||
cont.dismissViewController(true, () -> {});
|
cont.dismissViewController(true, () -> {});
|
||||||
controller.importDocument(documentURLs.get(0), new NSURL(getDocumentsDirectory() + "/document"), UIDocumentBrowserImportMode.Copy, (url, error) -> {
|
controller.importDocument(documentURLs.get(0), new NSURL(getDocumentsDirectory() + "/document"), UIDocumentBrowserImportMode.Copy, (url, error) -> cons.accept(Core.files.absolute(url.getPath())));
|
||||||
cons.accept(Core.files.absolute(url.getPath()));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user