v1.2.0: fixed URI's failing to open on macOS
This commit is contained in:
+31
@@ -25,11 +25,14 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.g2d.PixmapPacker;
|
||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||
import com.badlogic.gdx.utils.SharedLibraryLoader;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.utils.PlatformSupport;
|
||||
import com.watabou.utils.Point;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -63,6 +66,34 @@ public class DesktopPlatformSupport extends PlatformSupport {
|
||||
public boolean connectedToUnmeteredNetwork() {
|
||||
return true; //no easy way to check this in desktop, just assume user doesn't care
|
||||
}
|
||||
|
||||
//TODO backported openURI fix from libGDX-1.10.1-SNAPSHOT, remove when updating libGDX
|
||||
public boolean openURI( String uri ){
|
||||
if (SharedLibraryLoader.isMac) {
|
||||
try {
|
||||
(new ProcessBuilder("open", (new URI(uri).toString()))).start();
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
}
|
||||
} else if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI(uri));
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
}
|
||||
} else if (SharedLibraryLoader.isLinux) {
|
||||
try {
|
||||
(new ProcessBuilder("xdg-open", (new URI(uri).toString()))).start();
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* FONT SUPPORT */
|
||||
|
||||
//custom pixel font, for use with Latin and Cyrillic languages
|
||||
|
||||
Reference in New Issue
Block a user