mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-04 15:27:19 +07:00
Added support for Mac file association; minor optimizations
This commit is contained in:
@ -33,6 +33,18 @@
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:mimeType="application/octet-stream"/>
|
||||
</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>
|
||||
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
|
||||
@Override
|
||||
public boolean isDebug() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,7 +86,7 @@ project(":desktop") {
|
||||
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
||||
compile "com.badlogicgames.gdx:gdx-controllers-lwjgl3:$gdxVersion"
|
||||
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) {
|
||||
InputHandler input = control.input(player.playerIndex);
|
||||
|
||||
if(!input.isDrawing()) continue;
|
||||
|
||||
Shaders.outline.color.set(Palette.accent);
|
||||
Graphics.beginShaders(Shaders.outline);
|
||||
|
||||
|
@ -215,6 +215,11 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
||||
}}.visible(() -> !state.is(State.menu)).end();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDrawing(){
|
||||
return selection.size > 0 || removals.size > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBottom(){
|
||||
|
||||
|
@ -60,6 +60,11 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDrawing(){
|
||||
return mode != none;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBottom(){
|
||||
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.*/
|
||||
public boolean tileTapped(Tile tile){
|
||||
tile = tile.target();
|
||||
|
@ -14,6 +14,8 @@ public class CrashHandler {
|
||||
//TODO send full error report to server via HTTP
|
||||
e.printStackTrace();
|
||||
|
||||
|
||||
|
||||
//attempt to close connections, if applicable
|
||||
try{
|
||||
Net.dispose();
|
||||
|
@ -1,14 +1,27 @@
|
||||
package io.anuke.mindustry.desktop;
|
||||
|
||||
import com.apple.eawt.Application;
|
||||
import com.badlogic.gdx.Files.FileType;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import io.anuke.kryonet.KryoClient;
|
||||
import io.anuke.kryonet.KryoServer;
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
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.ucore.util.Bundles;
|
||||
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 {
|
||||
|
||||
@ -20,6 +33,41 @@ public class DesktopLauncher {
|
||||
config.setWindowedMode(960, 540);
|
||||
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) {
|
||||
config.setPreferencesConfig(OS.getAppDataDirectoryString("Mindustry"), FileType.Absolute);
|
||||
}
|
||||
|
Reference in New Issue
Block a user