mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-22 12:38:05 +07:00
more iOS mess-fixing
This commit is contained in:
parent
6f2fc00045
commit
a12af852ab
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -71,32 +71,10 @@
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>io.anuke.mindustry.mapfile</string>
|
||||
<string>io.anuke.mindustry.savefile</string>
|
||||
</array>
|
||||
</dict>
|
||||
</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>
|
||||
<array>
|
||||
<dict>
|
||||
@ -111,9 +89,9 @@
|
||||
<key>UTTypeTagSpecification</key>
|
||||
<dict>
|
||||
<key>public.filename-extension</key>
|
||||
<string>mmap</string>
|
||||
<string>msav</string>
|
||||
<key>public.mime-type</key>
|
||||
<string>mindustry/mmap</string>
|
||||
<string>mindustry/msav</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
|
@ -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
|
||||
|
@ -33,6 +33,7 @@
|
||||
<pattern>com.android.org.bouncycastle.crypto.digests.AndroidDigestFactoryOpenSSL</pattern>
|
||||
<pattern>org.apache.harmony.security.provider.cert.DRLCertFactory</pattern>
|
||||
<pattern>org.apache.harmony.security.provider.crypto.CryptoProvider</pattern>
|
||||
<pattern>org.robovm.apple.foundation.NSKeyValueCoder</pattern>
|
||||
</forceLinkClasses>
|
||||
<libs>
|
||||
<lib>z</lib>
|
||||
|
@ -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){
|
||||
|
Loading…
Reference in New Issue
Block a user