v1.2.0: fixed URI's failing to open on macOS

This commit is contained in:
Evan Debenham
2022-01-26 19:55:54 -05:00
parent c6189e32dc
commit 17d4dda402
7 changed files with 41 additions and 10 deletions
@@ -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