mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-13 00:05:23 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
bd1ea41c0d
@ -38,7 +38,7 @@ allprojects{
|
||||
}
|
||||
|
||||
getArcHash = {
|
||||
return new Properties().with{ p -> p.load(new File((File)projectDir, 'gradle.properties').newReader()); return p }["archash"]
|
||||
return new Properties().with{ p -> p.load(file('gradle.properties').newReader()); return p }["archash"]
|
||||
}
|
||||
|
||||
arcModule = { String name ->
|
||||
@ -200,7 +200,7 @@ project(":core"){
|
||||
}
|
||||
|
||||
dependencies{
|
||||
if(System.properties["user.name"] == "anuke"){
|
||||
if(System.properties["user.name"] == "anuke2"){
|
||||
task cleanGen{
|
||||
doFirst{
|
||||
delete{
|
||||
|
@ -85,37 +85,35 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
|
||||
t.row();
|
||||
|
||||
if(!ios){
|
||||
t.addImageTextButton("$editor.import", Icon.loadMapSmall, () ->
|
||||
createDialog("$editor.import",
|
||||
"$editor.importmap", "$editor.importmap.description", Icon.loadMap, (Runnable)loadDialog::show,
|
||||
"$editor.importfile", "$editor.importfile.description", Icon.file, (Runnable)() ->
|
||||
platform.showFileChooser(true, mapExtension, file -> ui.loadAnd(() -> {
|
||||
maps.tryCatchMapError(() -> {
|
||||
if(MapIO.isImage(file)){
|
||||
ui.showInfo("$editor.errorimage");
|
||||
}else{
|
||||
editor.beginEdit(MapIO.createMap(file, true));
|
||||
}
|
||||
});
|
||||
})),
|
||||
|
||||
"$editor.importimage", "$editor.importimage.description", Icon.fileImage, (Runnable)() ->
|
||||
platform.showFileChooser(true, "png", file ->
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
Pixmap pixmap = new Pixmap(file);
|
||||
editor.beginEdit(pixmap);
|
||||
pixmap.dispose();
|
||||
}catch(Exception e){
|
||||
ui.showException("$editor.errorload", e);
|
||||
Log.err(e);
|
||||
t.addImageTextButton("$editor.import", Icon.loadMapSmall, () ->
|
||||
createDialog("$editor.import",
|
||||
"$editor.importmap", "$editor.importmap.description", Icon.loadMap, (Runnable)loadDialog::show,
|
||||
"$editor.importfile", "$editor.importfile.description", Icon.file, (Runnable)() ->
|
||||
platform.showFileChooser(true, mapExtension, file -> ui.loadAnd(() -> {
|
||||
maps.tryCatchMapError(() -> {
|
||||
if(MapIO.isImage(file)){
|
||||
ui.showInfo("$editor.errorimage");
|
||||
}else{
|
||||
editor.beginEdit(MapIO.createMap(file, true));
|
||||
}
|
||||
})))
|
||||
);
|
||||
}
|
||||
});
|
||||
})),
|
||||
|
||||
Cell cell = t.addImageTextButton("$editor.export", Icon.saveMapSmall, () -> {
|
||||
"$editor.importimage", "$editor.importimage.description", Icon.fileImage, (Runnable)() ->
|
||||
platform.showFileChooser(true, "png", file ->
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
Pixmap pixmap = new Pixmap(file);
|
||||
editor.beginEdit(pixmap);
|
||||
pixmap.dispose();
|
||||
}catch(Exception e){
|
||||
ui.showException("$editor.errorload", e);
|
||||
Log.err(e);
|
||||
}
|
||||
})))
|
||||
);
|
||||
|
||||
t.addImageTextButton("$editor.export", Icon.saveMapSmall, () -> {
|
||||
if(!ios){
|
||||
platform.showFileChooser(false, mapExtension, file -> {
|
||||
ui.loadAnd(() -> {
|
||||
@ -143,10 +141,6 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if(ios){
|
||||
cell.size(swidth * 2f + 10, 60f).colspan(2);
|
||||
}
|
||||
});
|
||||
|
||||
menu.cont.row();
|
||||
|
@ -126,24 +126,21 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
|
||||
t.row();
|
||||
|
||||
//iOS doesn't have a file chooser.
|
||||
//if(!ios){
|
||||
t.addButton("$data.import", style, () -> ui.showConfirm("$confirm", "$data.import.confirm", () -> platform.showFileChooser(true, "zip", file -> {
|
||||
try{
|
||||
data.importData(file);
|
||||
Core.app.exit();
|
||||
}catch(IllegalArgumentException e){
|
||||
t.addButton("$data.import", style, () -> ui.showConfirm("$confirm", "$data.import.confirm", () -> platform.showFileChooser(true, "zip", file -> {
|
||||
try{
|
||||
data.importData(file);
|
||||
Core.app.exit();
|
||||
}catch(IllegalArgumentException e){
|
||||
ui.showErrorMessage("$data.invalid");
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
if(e.getMessage() == null || !e.getMessage().contains("too short")){
|
||||
ui.showException(e);
|
||||
}else{
|
||||
ui.showErrorMessage("$data.invalid");
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
if(e.getMessage() == null || !e.getMessage().contains("too short")){
|
||||
ui.showException(e);
|
||||
}else{
|
||||
ui.showErrorMessage("$data.invalid");
|
||||
}
|
||||
}
|
||||
})));
|
||||
//}
|
||||
}
|
||||
})));
|
||||
});
|
||||
|
||||
ScrollPane pane = new ScrollPane(prefs);
|
||||
|
@ -74,22 +74,22 @@
|
||||
</array>
|
||||
</dict>
|
||||
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeIconFiles</key>
|
||||
<array>
|
||||
<string>icon-72.png</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Zip Data File</string>
|
||||
<key>LSHandlerRank</key>
|
||||
<string>Alternate</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>public.archive</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<dict>
|
||||
<key>CFBundleTypeIconFiles</key>
|
||||
<array>
|
||||
<string>icon-72.png</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Zip Game Data</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>LSHandlerRank</key>
|
||||
<string>Owner</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>public.archive</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
|
||||
<key>UTExportedTypeDeclarations</key>
|
||||
|
@ -13,6 +13,7 @@ import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import org.robovm.apple.foundation.*;
|
||||
import org.robovm.apple.uikit.*;
|
||||
import org.robovm.apple.uikit.UIBarButtonItem.*;
|
||||
import org.robovm.objc.block.*;
|
||||
|
||||
import java.io.*;
|
||||
@ -39,10 +40,15 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
||||
|
||||
@Override
|
||||
public void showFileChooser(boolean open, String extension, Consumer<FileHandle> cons){
|
||||
UIDocumentBrowserViewController cont = new UIDocumentBrowserViewController(NSArray.fromStrings("public.archive"));
|
||||
UIDocumentBrowserViewController cont = new UIDocumentBrowserViewController((NSArray)null);
|
||||
|
||||
cont.setAllowsDocumentCreation(false);
|
||||
cont.setDelegate(new UIDocumentBrowserViewControllerDelegate(){
|
||||
NSArray<UIBarButtonItem> arr = new NSArray<>(new UIBarButtonItem(Core.bundle.get("cancel"), UIBarButtonItemStyle.Plain,
|
||||
uiBarButtonItem -> cont.dismissViewController(true, () -> {})));
|
||||
|
||||
cont.setAllowsDocumentCreation(!open);
|
||||
cont.setAdditionalLeadingNavigationBarButtonItems(arr);
|
||||
|
||||
class ChooserDelegate extends NSObject implements UIDocumentBrowserViewControllerDelegate{
|
||||
@Override
|
||||
public void didPickDocumentURLs(UIDocumentBrowserViewController controller, NSArray<NSURL> documentURLs){
|
||||
|
||||
@ -50,7 +56,10 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
||||
|
||||
@Override
|
||||
public void didPickDocumentsAtURLs(UIDocumentBrowserViewController controller, NSArray<NSURL> documentURLs){
|
||||
if(documentURLs.size() < 1) return;
|
||||
|
||||
cont.dismissViewController(true, () -> {});
|
||||
cons.accept(Core.files.absolute(documentURLs.get(0).getPath()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -77,7 +86,9 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
||||
public void willPresentActivityViewController(UIDocumentBrowserViewController controller, UIActivityViewController activityViewController){
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
cont.setDelegate(new ChooserDelegate());
|
||||
UIApplication.getSharedApplication().getKeyWindow().getRootViewController().presentViewController(cont, true, () -> {
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user