Added support for Mac file association; minor optimizations
This commit is contained in:
@@ -33,6 +33,18 @@
|
|||||||
<category android:name="android.intent.category.BROWSABLE"/>
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
<data android:mimeType="application/octet-stream"/>
|
<data android:mimeType="application/octet-stream"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.mmap" android:mimeType="*/*" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.msav" android:mimeType="*/*" />
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class AndroidLauncher extends AndroidApplication{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebug() {
|
public boolean isDebug() {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ project(":desktop") {
|
|||||||
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
||||||
compile "com.badlogicgames.gdx:gdx-controllers-lwjgl3:$gdxVersion"
|
compile "com.badlogicgames.gdx:gdx-controllers-lwjgl3:$gdxVersion"
|
||||||
compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.0'
|
compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.0'
|
||||||
//compile 'com.yuvimasory:orange-extensions:1.3.0'
|
compile 'com.yuvimasory:orange-extensions:1.3.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ public class OverlayRenderer {
|
|||||||
for(Player player : players) {
|
for(Player player : players) {
|
||||||
InputHandler input = control.input(player.playerIndex);
|
InputHandler input = control.input(player.playerIndex);
|
||||||
|
|
||||||
|
if(!input.isDrawing()) continue;
|
||||||
|
|
||||||
Shaders.outline.color.set(Palette.accent);
|
Shaders.outline.color.set(Palette.accent);
|
||||||
Graphics.beginShaders(Shaders.outline);
|
Graphics.beginShaders(Shaders.outline);
|
||||||
|
|
||||||
|
|||||||
@@ -215,6 +215,11 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
|||||||
}}.visible(() -> !state.is(State.menu)).end();
|
}}.visible(() -> !state.is(State.menu)).end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDrawing(){
|
||||||
|
return selection.size > 0 || removals.size > 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawBottom(){
|
public void drawBottom(){
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,11 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDrawing(){
|
||||||
|
return mode != none;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawBottom(){
|
public void drawBottom(){
|
||||||
Tile cursor = tileAt(control.gdxInput().getX(), control.gdxInput().getY());
|
Tile cursor = tileAt(control.gdxInput().getX(), control.gdxInput().getY());
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDrawing(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**Handles tile tap events that are not platform specific.*/
|
/**Handles tile tap events that are not platform specific.*/
|
||||||
public boolean tileTapped(Tile tile){
|
public boolean tileTapped(Tile tile){
|
||||||
tile = tile.target();
|
tile = tile.target();
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ public class CrashHandler {
|
|||||||
//TODO send full error report to server via HTTP
|
//TODO send full error report to server via HTTP
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//attempt to close connections, if applicable
|
//attempt to close connections, if applicable
|
||||||
try{
|
try{
|
||||||
Net.dispose();
|
Net.dispose();
|
||||||
|
|||||||
@@ -1,14 +1,27 @@
|
|||||||
package io.anuke.mindustry.desktop;
|
package io.anuke.mindustry.desktop;
|
||||||
|
|
||||||
|
import com.apple.eawt.Application;
|
||||||
import com.badlogic.gdx.Files.FileType;
|
import com.badlogic.gdx.Files.FileType;
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||||
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import io.anuke.kryonet.KryoClient;
|
import io.anuke.kryonet.KryoClient;
|
||||||
import io.anuke.kryonet.KryoServer;
|
import io.anuke.kryonet.KryoServer;
|
||||||
import io.anuke.mindustry.Mindustry;
|
import io.anuke.mindustry.Mindustry;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.Platform;
|
||||||
|
import io.anuke.mindustry.io.SaveIO;
|
||||||
|
import io.anuke.mindustry.io.Saves.SaveSlot;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
|
import io.anuke.ucore.util.Bundles;
|
||||||
import io.anuke.ucore.util.OS;
|
import io.anuke.ucore.util.OS;
|
||||||
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class DesktopLauncher {
|
public class DesktopLauncher {
|
||||||
|
|
||||||
@@ -20,6 +33,41 @@ public class DesktopLauncher {
|
|||||||
config.setWindowedMode(960, 540);
|
config.setWindowedMode(960, 540);
|
||||||
config.setWindowIcon("sprites/icon.png");
|
config.setWindowIcon("sprites/icon.png");
|
||||||
|
|
||||||
|
Application.getApplication().setOpenFileHandler(e -> {
|
||||||
|
List<File> list = e.getFiles();
|
||||||
|
|
||||||
|
File target = list.get(0);
|
||||||
|
|
||||||
|
Gdx.app.postRunnable(() -> {
|
||||||
|
FileHandle file = OS.getAppDataDirectory("Mindustry").child("tmp").child(target.getName());
|
||||||
|
|
||||||
|
Gdx.files.absolute(target.getAbsolutePath()).copyTo(file);
|
||||||
|
|
||||||
|
if(file.extension().equalsIgnoreCase(saveExtension)){ //open save
|
||||||
|
|
||||||
|
if(SaveIO.isSaveValid(file)){
|
||||||
|
try{
|
||||||
|
SaveSlot slot = control.getSaves().importSave(file);
|
||||||
|
ui.load.runLoadSave(slot);
|
||||||
|
}catch (IOException e2){
|
||||||
|
ui.showError(Bundles.format("text.save.import.fail", Strings.parseException(e2, false)));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
ui.showError("$text.save.import.invalid");
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(file.extension().equalsIgnoreCase(mapExtension)){ //open map
|
||||||
|
Gdx.app.postRunnable(() -> {
|
||||||
|
if (!ui.editor.isShown()) {
|
||||||
|
ui.editor.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.editor.beginEditMap(file.read());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if(OS.isMac) {
|
if(OS.isMac) {
|
||||||
config.setPreferencesConfig(OS.getAppDataDirectoryString("Mindustry"), FileType.Absolute);
|
config.setPreferencesConfig(OS.getAppDataDirectoryString("Mindustry"), FileType.Absolute);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user