diff --git a/core/src/io/anuke/mindustry/io/SaveMeta.java b/core/src/io/anuke/mindustry/io/SaveMeta.java
index f88746605f..c3fd749024 100644
--- a/core/src/io/anuke/mindustry/io/SaveMeta.java
+++ b/core/src/io/anuke/mindustry/io/SaveMeta.java
@@ -1,5 +1,6 @@
package io.anuke.mindustry.io;
+import io.anuke.arc.collection.*;
import io.anuke.mindustry.game.Rules;
import io.anuke.mindustry.maps.Map;
@@ -13,8 +14,9 @@ public class SaveMeta{
public Map map;
public int wave;
public Rules rules;
+ public StringMap tags;
- public SaveMeta(int version, long timestamp, long timePlayed, int build, String map, int wave, Rules rules){
+ public SaveMeta(int version, long timestamp, long timePlayed, int build, String map, int wave, Rules rules, StringMap tags){
this.version = version;
this.build = build;
this.timestamp = timestamp;
@@ -22,5 +24,6 @@ public class SaveMeta{
this.map = world.maps.all().find(m -> m.name().equals(map));
this.wave = wave;
this.rules = rules;
+ this.tags = tags;
}
}
diff --git a/core/src/io/anuke/mindustry/io/SaveVersion.java b/core/src/io/anuke/mindustry/io/SaveVersion.java
index b4f700a582..90d3af2210 100644
--- a/core/src/io/anuke/mindustry/io/SaveVersion.java
+++ b/core/src/io/anuke/mindustry/io/SaveVersion.java
@@ -28,7 +28,7 @@ public abstract class SaveVersion extends SaveFileReader{
public SaveMeta getMeta(DataInput stream) throws IOException{
stream.readInt(); //length of data, doesn't matter here
StringMap map = readStringMap(stream);
- return new SaveMeta(map.getInt("version"), map.getLong("saved"), map.getLong("playtime"), map.getInt("build"), map.get("mapname"), map.getInt("wave"), JsonIO.read(Rules.class, map.get("rules", "{}")));
+ return new SaveMeta(map.getInt("version"), map.getLong("saved"), map.getLong("playtime"), map.getInt("build"), map.get("mapname"), map.getInt("wave"), JsonIO.read(Rules.class, map.get("rules", "{}")), map);
}
@Override
diff --git a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java
index 317e8e188e..1be2029876 100644
--- a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java
+++ b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java
@@ -109,8 +109,9 @@ public class MenuFragment extends Fragment{
container.add(play);
container.add(join);
container.add(custom);
+ if(ios) container.row();
container.add(maps);
- container.row();
+ if(!ios) container.row();
container.table(table -> {
table.defaults().set(container.defaults());
@@ -119,7 +120,7 @@ public class MenuFragment extends Fragment{
table.add(tools);
if(Platform.instance.canDonate()) table.add(donate);
- table.add(exit);
+ if(!ios) table.add(exit);
}).colspan(4);
}else{
container.marginTop(0f);
diff --git a/ios/Info.plist.xml b/ios/Info.plist.xml
index abd81b462c..4dee6ec646 100644
--- a/ios/Info.plist.xml
+++ b/ios/Info.plist.xml
@@ -71,32 +71,10 @@
LSItemContentTypes
io.anuke.mindustry.mapfile
- io.anuke.mindustry.savefile
- UTExportedTypeDeclarations
-
-
- UTTypeConformsTo
-
- public.data
-
- UTTypeDescription
- Mindustry Save File
- UTTypeIdentifier
- io.anuke.mindustry.savefile
- UTTypeTagSpecification
-
- public.filename-extension
- msav
- public.mime-type
- mindustry/msav
-
-
-
-
UTExportedTypeDeclarations
@@ -111,9 +89,9 @@
UTTypeTagSpecification
public.filename-extension
- mmap
+ msav
public.mime-type
- mindustry/mmap
+ mindustry/msav
diff --git a/ios/build.gradle b/ios/build.gradle
index 183a19a5b2..6fc88382bb 100644
--- a/ios/build.gradle
+++ b/ios/build.gradle
@@ -19,10 +19,12 @@ task copyAssets(){
}
exec{
+ ignoreExitValue true
commandLine "sh", "./convert_audio.sh", "assets/sounds"
}
exec{
+ ignoreExitValue true
commandLine "sh", "./convert_audio.sh", "assets/music"
}
@@ -34,10 +36,7 @@ task copyAssets(){
}
}
-createIPA.dependsOn copyAssets
-launchIPhoneSimulator.dependsOn copyAssets
-launchIOSDevice.dependsOn copyAssets
-launchIPadSimulator.dependsOn copyAssets
+build.dependsOn copyAssets
launchIPhoneSimulator.dependsOn build
launchIPadSimulator.dependsOn build
diff --git a/ios/robovm.xml b/ios/robovm.xml
index 2ce58a8572..a1ce5b92bc 100644
--- a/ios/robovm.xml
+++ b/ios/robovm.xml
@@ -33,6 +33,7 @@
com.android.org.bouncycastle.crypto.digests.AndroidDigestFactoryOpenSSL
org.apache.harmony.security.provider.cert.DRLCertFactory
org.apache.harmony.security.provider.crypto.CryptoProvider
+ org.robovm.apple.foundation.NSKeyValueCoder
z
diff --git a/ios/src/io/anuke/mindustry/IOSLauncher.java b/ios/src/io/anuke/mindustry/IOSLauncher.java
index 520fb4e494..fc3b581856 100644
--- a/ios/src/io/anuke/mindustry/IOSLauncher.java
+++ b/ios/src/io/anuke/mindustry/IOSLauncher.java
@@ -1,23 +1,22 @@
package io.anuke.mindustry;
-import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
-import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
-import io.anuke.arc.Core;
-import io.anuke.arc.files.FileHandle;
-import io.anuke.arc.scene.ui.layout.UnitScl;
-import io.anuke.arc.util.Strings;
-import io.anuke.mindustry.core.Platform;
-import io.anuke.mindustry.game.Saves.SaveSlot;
-import io.anuke.mindustry.io.SaveIO;
+import com.badlogic.gdx.backends.iosrobovm.*;
+import io.anuke.arc.*;
+import io.anuke.arc.files.*;
+import io.anuke.arc.scene.ui.layout.*;
+import io.anuke.arc.util.*;
+import io.anuke.arc.util.io.*;
+import io.anuke.mindustry.core.*;
+import io.anuke.mindustry.game.Saves.*;
+import io.anuke.mindustry.io.*;
import io.anuke.mindustry.net.Net;
-import io.anuke.mindustry.net.ArcNetClient;
-import io.anuke.mindustry.net.ArcNetServer;
-import org.robovm.apple.foundation.NSAutoreleasePool;
-import org.robovm.apple.foundation.NSURL;
+import io.anuke.mindustry.net.*;
+import org.robovm.apple.foundation.*;
import org.robovm.apple.uikit.*;
-import java.io.IOException;
-import java.util.Collections;
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
import static io.anuke.mindustry.Vars.*;
import static org.robovm.apple.foundation.NSPathUtilities.getDocumentsDirectory;
@@ -40,6 +39,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
@Override
public void shareFile(FileHandle file){
+ Log.info("Attempting to share file " + file);
FileHandle to = Core.files.absolute(getDocumentsDirectory()).child(file.name());
file.copyTo(to);
@@ -53,12 +53,20 @@ public class IOSLauncher extends IOSApplication.Delegate{
@Override
public void beginForceLandscape(){
+ Log.info("begin force landscape");
forced = true;
+ UINavigationController.attemptRotationToDeviceOrientation();
+ //UIDevice.getCurrentDevice().set
+
+ //UIApplication.getSharedApplication().
+ //getViewController(UIApplication.getSharedApplication()).atte
+ //UIApplication.getSharedApplication()
}
@Override
public void endForceLandscape(){
forced = false;
+ UINavigationController.attemptRotationToDeviceOrientation();
}
};
@@ -71,6 +79,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
return forced ? UIInterfaceOrientationMask.Landscape : UIInterfaceOrientationMask.All;
}
+
@Override
public boolean openURL(UIApplication app, NSURL url, UIApplicationOpenURLOptions options){
System.out.println("Opened URL: " + url.getPath());
@@ -87,22 +96,43 @@ public class IOSLauncher extends IOSApplication.Delegate{
openURL(((NSURL)options.get(UIApplicationLaunchOptions.Keys.URL())));
}
+ Core.app.post(() -> Core.app.post(() -> {
+ Core.scene.table("dialogDim", t -> {
+ t.visible(() -> {
+ if(!forced) return false;
+ t.toFront();
+ UIInterfaceOrientation o = UIApplication.getSharedApplication().getStatusBarOrientation();
+ return forced && (o == UIInterfaceOrientation.Portrait || o == UIInterfaceOrientation.PortraitUpsideDown);
+ });
+ t.add("Please rotate the phone to landscape mode to use the editor.").wrap().grow();
+ });
+ }));
+
return b;
}
void openURL(NSURL url){
- Core.app.post(() -> {
+ Core.app.post(() -> Core.app.post(() -> {
FileHandle file = Core.files.absolute(getDocumentsDirectory()).child(url.getLastPathComponent());
Core.files.absolute(url.getPath()).copyTo(file);
- //TODO detect if it's a map or save
if(file.extension().equalsIgnoreCase(saveExtension)){ //open save
if(SaveIO.isSaveValid(file)){
try{
- SaveSlot slot = control.saves.importSave(file);
- ui.load.runLoadSave(slot);
+ SaveMeta meta = SaveIO.getMeta(new DataInputStream(new InflaterInputStream(file.read(Streams.DEFAULT_BUFFER_SIZE))));
+ if(meta.tags.containsKey("name")){
+ //is map
+ if(!ui.editor.isShown()){
+ ui.editor.show();
+ }
+
+ ui.editor.beginEditMap(file);
+ }else{
+ SaveSlot slot = control.saves.importSave(file);
+ ui.load.runLoadSave(slot);
+ }
}catch(IOException e){
ui.showError(Core.bundle.format("save.import.fail", Strings.parseException(e, true)));
}
@@ -110,16 +140,8 @@ public class IOSLauncher extends IOSApplication.Delegate{
ui.showError("save.import.invalid");
}
- }else if(file.extension().equalsIgnoreCase(mapExtension)){ //open map
- Core.app.post(() -> {
- if(!ui.editor.isShown()){
- ui.editor.show();
- }
-
- ui.editor.beginEditMap(file);
- });
}
- });
+ }));
}
public static void main(String[] argv){