more iOS mess-fixing
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.io;
|
package io.anuke.mindustry.io;
|
||||||
|
|
||||||
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.mindustry.game.Rules;
|
import io.anuke.mindustry.game.Rules;
|
||||||
import io.anuke.mindustry.maps.Map;
|
import io.anuke.mindustry.maps.Map;
|
||||||
|
|
||||||
@@ -13,8 +14,9 @@ public class SaveMeta{
|
|||||||
public Map map;
|
public Map map;
|
||||||
public int wave;
|
public int wave;
|
||||||
public Rules rules;
|
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.version = version;
|
||||||
this.build = build;
|
this.build = build;
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
@@ -22,5 +24,6 @@ public class SaveMeta{
|
|||||||
this.map = world.maps.all().find(m -> m.name().equals(map));
|
this.map = world.maps.all().find(m -> m.name().equals(map));
|
||||||
this.wave = wave;
|
this.wave = wave;
|
||||||
this.rules = rules;
|
this.rules = rules;
|
||||||
|
this.tags = tags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
public SaveMeta getMeta(DataInput stream) throws IOException{
|
public SaveMeta getMeta(DataInput stream) throws IOException{
|
||||||
stream.readInt(); //length of data, doesn't matter here
|
stream.readInt(); //length of data, doesn't matter here
|
||||||
StringMap map = readStringMap(stream);
|
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
|
@Override
|
||||||
|
|||||||
@@ -109,8 +109,9 @@ public class MenuFragment extends Fragment{
|
|||||||
container.add(play);
|
container.add(play);
|
||||||
container.add(join);
|
container.add(join);
|
||||||
container.add(custom);
|
container.add(custom);
|
||||||
|
if(ios) container.row();
|
||||||
container.add(maps);
|
container.add(maps);
|
||||||
container.row();
|
if(!ios) container.row();
|
||||||
|
|
||||||
container.table(table -> {
|
container.table(table -> {
|
||||||
table.defaults().set(container.defaults());
|
table.defaults().set(container.defaults());
|
||||||
@@ -119,7 +120,7 @@ public class MenuFragment extends Fragment{
|
|||||||
table.add(tools);
|
table.add(tools);
|
||||||
|
|
||||||
if(Platform.instance.canDonate()) table.add(donate);
|
if(Platform.instance.canDonate()) table.add(donate);
|
||||||
table.add(exit);
|
if(!ios) table.add(exit);
|
||||||
}).colspan(4);
|
}).colspan(4);
|
||||||
}else{
|
}else{
|
||||||
container.marginTop(0f);
|
container.marginTop(0f);
|
||||||
|
|||||||
@@ -71,32 +71,10 @@
|
|||||||
<key>LSItemContentTypes</key>
|
<key>LSItemContentTypes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>io.anuke.mindustry.mapfile</string>
|
<string>io.anuke.mindustry.mapfile</string>
|
||||||
<string>io.anuke.mindustry.savefile</string>
|
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
|
|
||||||
<key>UTExportedTypeDeclarations</key>
|
|
||||||
<array>
|
|
||||||
<dict>
|
|
||||||
<key>UTTypeConformsTo</key>
|
|
||||||
<array>
|
|
||||||
<string>public.data</string>
|
|
||||||
</array>
|
|
||||||
<key>UTTypeDescription</key>
|
|
||||||
<string>Mindustry Save File</string>
|
|
||||||
<key>UTTypeIdentifier</key>
|
|
||||||
<string>io.anuke.mindustry.savefile</string>
|
|
||||||
<key>UTTypeTagSpecification</key>
|
|
||||||
<dict>
|
|
||||||
<key>public.filename-extension</key>
|
|
||||||
<string>msav</string>
|
|
||||||
<key>public.mime-type</key>
|
|
||||||
<string>mindustry/msav</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
</array>
|
|
||||||
|
|
||||||
<key>UTExportedTypeDeclarations</key>
|
<key>UTExportedTypeDeclarations</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
@@ -111,9 +89,9 @@
|
|||||||
<key>UTTypeTagSpecification</key>
|
<key>UTTypeTagSpecification</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>public.filename-extension</key>
|
<key>public.filename-extension</key>
|
||||||
<string>mmap</string>
|
<string>msav</string>
|
||||||
<key>public.mime-type</key>
|
<key>public.mime-type</key>
|
||||||
<string>mindustry/mmap</string>
|
<string>mindustry/msav</string>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
|
|||||||
@@ -19,10 +19,12 @@ task copyAssets(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
exec{
|
exec{
|
||||||
|
ignoreExitValue true
|
||||||
commandLine "sh", "./convert_audio.sh", "assets/sounds"
|
commandLine "sh", "./convert_audio.sh", "assets/sounds"
|
||||||
}
|
}
|
||||||
|
|
||||||
exec{
|
exec{
|
||||||
|
ignoreExitValue true
|
||||||
commandLine "sh", "./convert_audio.sh", "assets/music"
|
commandLine "sh", "./convert_audio.sh", "assets/music"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,10 +36,7 @@ task copyAssets(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createIPA.dependsOn copyAssets
|
build.dependsOn copyAssets
|
||||||
launchIPhoneSimulator.dependsOn copyAssets
|
|
||||||
launchIOSDevice.dependsOn copyAssets
|
|
||||||
launchIPadSimulator.dependsOn copyAssets
|
|
||||||
|
|
||||||
launchIPhoneSimulator.dependsOn build
|
launchIPhoneSimulator.dependsOn build
|
||||||
launchIPadSimulator.dependsOn build
|
launchIPadSimulator.dependsOn build
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
<pattern>com.android.org.bouncycastle.crypto.digests.AndroidDigestFactoryOpenSSL</pattern>
|
<pattern>com.android.org.bouncycastle.crypto.digests.AndroidDigestFactoryOpenSSL</pattern>
|
||||||
<pattern>org.apache.harmony.security.provider.cert.DRLCertFactory</pattern>
|
<pattern>org.apache.harmony.security.provider.cert.DRLCertFactory</pattern>
|
||||||
<pattern>org.apache.harmony.security.provider.crypto.CryptoProvider</pattern>
|
<pattern>org.apache.harmony.security.provider.crypto.CryptoProvider</pattern>
|
||||||
|
<pattern>org.robovm.apple.foundation.NSKeyValueCoder</pattern>
|
||||||
</forceLinkClasses>
|
</forceLinkClasses>
|
||||||
<libs>
|
<libs>
|
||||||
<lib>z</lib>
|
<lib>z</lib>
|
||||||
|
|||||||
@@ -1,23 +1,22 @@
|
|||||||
package io.anuke.mindustry;
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
|
import com.badlogic.gdx.backends.iosrobovm.*;
|
||||||
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.files.*;
|
||||||
import io.anuke.arc.files.FileHandle;
|
import io.anuke.arc.scene.ui.layout.*;
|
||||||
import io.anuke.arc.scene.ui.layout.UnitScl;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.Strings;
|
import io.anuke.arc.util.io.*;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.*;
|
||||||
import io.anuke.mindustry.game.Saves.SaveSlot;
|
import io.anuke.mindustry.game.Saves.*;
|
||||||
import io.anuke.mindustry.io.SaveIO;
|
import io.anuke.mindustry.io.*;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.net.ArcNetClient;
|
import io.anuke.mindustry.net.*;
|
||||||
import io.anuke.mindustry.net.ArcNetServer;
|
import org.robovm.apple.foundation.*;
|
||||||
import org.robovm.apple.foundation.NSAutoreleasePool;
|
|
||||||
import org.robovm.apple.foundation.NSURL;
|
|
||||||
import org.robovm.apple.uikit.*;
|
import org.robovm.apple.uikit.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
|
import java.util.zip.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
import static org.robovm.apple.foundation.NSPathUtilities.getDocumentsDirectory;
|
import static org.robovm.apple.foundation.NSPathUtilities.getDocumentsDirectory;
|
||||||
@@ -40,6 +39,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shareFile(FileHandle file){
|
public void shareFile(FileHandle file){
|
||||||
|
Log.info("Attempting to share file " + file);
|
||||||
FileHandle to = Core.files.absolute(getDocumentsDirectory()).child(file.name());
|
FileHandle to = Core.files.absolute(getDocumentsDirectory()).child(file.name());
|
||||||
file.copyTo(to);
|
file.copyTo(to);
|
||||||
|
|
||||||
@@ -53,12 +53,20 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beginForceLandscape(){
|
public void beginForceLandscape(){
|
||||||
|
Log.info("begin force landscape");
|
||||||
forced = true;
|
forced = true;
|
||||||
|
UINavigationController.attemptRotationToDeviceOrientation();
|
||||||
|
//UIDevice.getCurrentDevice().set
|
||||||
|
|
||||||
|
//UIApplication.getSharedApplication().
|
||||||
|
//getViewController(UIApplication.getSharedApplication()).atte
|
||||||
|
//UIApplication.getSharedApplication()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endForceLandscape(){
|
public void endForceLandscape(){
|
||||||
forced = false;
|
forced = false;
|
||||||
|
UINavigationController.attemptRotationToDeviceOrientation();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,6 +79,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||||||
return forced ? UIInterfaceOrientationMask.Landscape : UIInterfaceOrientationMask.All;
|
return forced ? UIInterfaceOrientationMask.Landscape : UIInterfaceOrientationMask.All;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean openURL(UIApplication app, NSURL url, UIApplicationOpenURLOptions options){
|
public boolean openURL(UIApplication app, NSURL url, UIApplicationOpenURLOptions options){
|
||||||
System.out.println("Opened URL: " + url.getPath());
|
System.out.println("Opened URL: " + url.getPath());
|
||||||
@@ -87,22 +96,43 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||||||
openURL(((NSURL)options.get(UIApplicationLaunchOptions.Keys.URL())));
|
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;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void openURL(NSURL url){
|
void openURL(NSURL url){
|
||||||
|
|
||||||
Core.app.post(() -> {
|
Core.app.post(() -> Core.app.post(() -> {
|
||||||
FileHandle file = Core.files.absolute(getDocumentsDirectory()).child(url.getLastPathComponent());
|
FileHandle file = Core.files.absolute(getDocumentsDirectory()).child(url.getLastPathComponent());
|
||||||
Core.files.absolute(url.getPath()).copyTo(file);
|
Core.files.absolute(url.getPath()).copyTo(file);
|
||||||
|
|
||||||
//TODO detect if it's a map or save
|
|
||||||
if(file.extension().equalsIgnoreCase(saveExtension)){ //open save
|
if(file.extension().equalsIgnoreCase(saveExtension)){ //open save
|
||||||
|
|
||||||
if(SaveIO.isSaveValid(file)){
|
if(SaveIO.isSaveValid(file)){
|
||||||
try{
|
try{
|
||||||
SaveSlot slot = control.saves.importSave(file);
|
SaveMeta meta = SaveIO.getMeta(new DataInputStream(new InflaterInputStream(file.read(Streams.DEFAULT_BUFFER_SIZE))));
|
||||||
ui.load.runLoadSave(slot);
|
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){
|
}catch(IOException e){
|
||||||
ui.showError(Core.bundle.format("save.import.fail", Strings.parseException(e, true)));
|
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");
|
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){
|
public static void main(String[] argv){
|
||||||
|
|||||||
Reference in New Issue
Block a user