mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
Merge pull request #2933 from Voxelstice/autocal-browse-fix
AUTOCAL "Desktop.browse" Linux function fix
This commit is contained in:
commit
bb688e2f4b
@ -3,11 +3,14 @@ package com.hbm.inventory.gui;
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
@ -37,6 +40,21 @@ public class GUIScreenRadioAUTOCAL extends GuiScreen {
|
||||
this.autocal = autocal;
|
||||
}
|
||||
|
||||
private void browse(URI uri) throws IOException {
|
||||
// workaround for Java not supporting all platforms, mostly for Linux
|
||||
if (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
Desktop.getDesktop().browse(uri);
|
||||
} else {
|
||||
if (Sys.getVersion().charAt(0) == '3') {
|
||||
// probably a LWJGL3ify user, open the folder instead since that somehow seems to work
|
||||
File uploadFolder = new File(MainRegistry.configDir.getParentFile(), "hbmComputerUpload");
|
||||
if (uploadFolder.exists()) Sys.openURL(uploadFolder.toString());
|
||||
} else {
|
||||
Sys.openURL(uri.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
@ -71,7 +89,7 @@ public class GUIScreenRadioAUTOCAL extends GuiScreen {
|
||||
if(!uploadFolder.exists()) uploadFolder.mkdir();
|
||||
if(!script.exists()) script.createNewFile();
|
||||
script.setExecutable(false);
|
||||
Desktop.getDesktop().browse(script.toURI());
|
||||
browse(script.toURI());
|
||||
} catch(Throwable ex) { MainRegistry.logger.error("Couldn't open link", ex); }
|
||||
}
|
||||
|
||||
@ -89,7 +107,7 @@ public class GUIScreenRadioAUTOCAL extends GuiScreen {
|
||||
printer.close();
|
||||
} catch(Throwable e) { }
|
||||
}
|
||||
Desktop.getDesktop().browse(doc.toURI());
|
||||
browse(doc.toURI());
|
||||
} catch(Throwable ex) { MainRegistry.logger.error("Couldn't open link", ex); }
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user