diff --git a/G-Earth/pom.xml b/G-Earth/pom.xml index befca5b..476c8a8 100644 --- a/G-Earth/pom.xml +++ b/G-Earth/pom.xml @@ -78,5 +78,10 @@ richtextfx 0.9.1 + + org.jsoup + jsoup + 1.11.2 + \ No newline at end of file diff --git a/G-Earth/src/main/java/gearth/Main.java b/G-Earth/src/main/java/gearth/Main.java index 44a3881..6e2f28e 100644 --- a/G-Earth/src/main/java/gearth/Main.java +++ b/G-Earth/src/main/java/gearth/Main.java @@ -3,30 +3,49 @@ package gearth; import gearth.misc.AdminValidator; import javafx.application.Application; import javafx.application.Platform; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; +import javafx.scene.control.Hyperlink; +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.layout.FlowPane; import javafx.scene.layout.Region; +import javafx.scene.web.WebView; import javafx.stage.Stage; import gearth.ui.GEarthController; +import org.json.JSONObject; +import org.jsoup.Jsoup; +import org.omg.CORBA.Environment; + +import java.io.IOException; // run as root issue Invalid MIT-MAGIC-COOKIE-1 key fix: https://stackoverflow.com/questions/48139447/invalid-mit-magic-cookie-1-key public class Main extends Application { + public static Application main; + public static String version = "0.2"; + private static String gitApi = "https://api.github.com/repos/sirjonasxx/G-Earth/releases/latest"; + @Override public void start(Stage primaryStage) throws Exception{ + main = this; + FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/G-Earth.fxml")); Parent root = loader.load(); GEarthController companion = loader.getController(); companion.setStage(primaryStage); + primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/gearth/G-EarthLogoSmaller.png"))); primaryStage.setResizable(false); //primaryStage.initStyle(StageStyle.UNDECORATED); - primaryStage.setTitle("G-Earth"); + primaryStage.setTitle("G-Earth " + version); primaryStage.setScene(new Scene(root, 620, 295)); primaryStage.show(); primaryStage.getScene().getStylesheets().add(getClass().getResource("/gearth/ui/bootstrap3.css").toExternalForm()); @@ -50,6 +69,41 @@ public class Main extends Application { } }).start(); + new Thread(() -> { + try { + String s = Jsoup.connect(gitApi).ignoreContentType(true).get().body().toString(); + s = s.substring(6, s.length() - 7); + JSONObject object = new JSONObject(s); + String gitv = (String)object.get("tag_name"); + if (!gitv.equals(version)) { + Platform.runLater(() -> { + Alert alert = new Alert(Alert.AlertType.INFORMATION, "G-Earth is outdated!", ButtonType.OK); + + FlowPane fp = new FlowPane(); + Label lbl = new Label("A new version of G-Earth has been found ("+gitv+")" + System.lineSeparator()+ System.lineSeparator() + "Update to the latest version:"); + Hyperlink link = new Hyperlink("https://github.com/sirjonasxx/G-Earth/releases"); + fp.getChildren().addAll( lbl, link); + link.setOnAction(event -> { + Main.main.getHostServices().showDocument(link.getText()); + event.consume(); + }); + + + + WebView webView = new WebView(); + webView.getEngine().loadContent("A new version of G-Earth has been found ("+gitv+")

Update to the latest version:
https://github.com/sirjonasxx/G-Earth/releases"); + webView.setPrefSize(500, 200); + alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); + alert.getDialogPane().setContent(fp); + alert.show(); + }); + } + + } catch (IOException e) { +// e.printStackTrace(); + } + }).start(); + } public static String[] args; diff --git a/G-Earth/src/main/java/gearth/ui/info/Info.java b/G-Earth/src/main/java/gearth/ui/info/Info.java index 21eaac4..ebf6693 100644 --- a/G-Earth/src/main/java/gearth/ui/info/Info.java +++ b/G-Earth/src/main/java/gearth/ui/info/Info.java @@ -1,43 +1,73 @@ package gearth.ui.info; -import javafx.scene.control.TextArea; +import gearth.Main; +import javafx.event.ActionEvent; +import javafx.scene.control.Hyperlink; import gearth.ui.SubForm; +import javafx.scene.control.Label; +import javafx.scene.control.Tooltip; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; /** * Created by Jonas on 06/04/18. */ public class Info extends SubForm { - public TextArea text; + public ImageView img_logo; + public Hyperlink link_sng; + public Hyperlink link_darkbox; + public Hyperlink link_d_harble; + public Hyperlink link_g_gearth; + public Hyperlink link_g_tanji; + public Hyperlink link_d_bonnie; + public Label version; // this is a TEMPORARY info tab + private void activateHyperlink(Hyperlink link) { + link.setOnAction((ActionEvent event) -> { + Hyperlink h = (Hyperlink) event.getTarget(); + String s = h.getTooltip().getText(); + Main.main.getHostServices().showDocument(s); + event.consume(); + }); + } + public void initialize() { - String[] lines = { - "G-Earth 0.1.1", - "Linux Habbo Packet Manipulator", - "", - "Made by:", - "sirjonasxx", - "", - "Contributors:", - "XePeleato (Windows & Mac support)", - "Scott Stamp", - "LittleJ", - "ArachisH", - "", - "Check out:", - "sngforum.info", - "darkbox.nl" - }; + version.setText(version.getText().replace("$version", Main.version)); - StringBuilder all = new StringBuilder(lines[0]); - for (int i = 1; i < lines.length; i++) { - all.append(System.lineSeparator()).append(lines[i]); - } + img_logo.setImage(new Image("/gearth/G-EarthLogo.png")); + link_sng.setTooltip(new Tooltip("https://www.sngforum.info")); + link_darkbox.setTooltip(new Tooltip("https://darkbox.nl")); + link_g_gearth.setTooltip(new Tooltip("https://github.com/sirjonasxx/G-Earth")); + link_g_tanji.setTooltip(new Tooltip("https://github.com/ArachisH/Tanji")); + link_d_harble.setTooltip(new Tooltip("https://discord.gg/Vyc2gFC")); + link_d_bonnie.setTooltip(new Tooltip("https://discord.gg/KZa3rXD")); - text.setText( - all.toString() - ); + activateHyperlink(link_d_harble); + activateHyperlink(link_d_bonnie); + activateHyperlink(link_g_gearth); + activateHyperlink(link_g_tanji); + activateHyperlink(link_sng); + activateHyperlink(link_darkbox); + +// String[] lines = { +// "G-Earth 0.1.1", +// "Linux Habbo Packet Manipulator", +// "", +// "Made by:", +// "sirjonasxx", +// "", +// "Contributors:", +// "XePeleato (Windows & Mac support)", +// "Scott Stamp", +// "LittleJ", +// "ArachisH", +// "", +// "Check out:", +// "sngforum.info", +// "darkbox.nl" +// }; } } diff --git a/G-Earth/src/main/resources/gearth/G-EarthLogo.ico b/G-Earth/src/main/resources/gearth/G-EarthLogo.ico new file mode 100644 index 0000000..61583a8 Binary files /dev/null and b/G-Earth/src/main/resources/gearth/G-EarthLogo.ico differ diff --git a/G-Earth/src/main/resources/gearth/G-EarthLogo.png b/G-Earth/src/main/resources/gearth/G-EarthLogo.png new file mode 100644 index 0000000..93fd6bc Binary files /dev/null and b/G-Earth/src/main/resources/gearth/G-EarthLogo.png differ diff --git a/G-Earth/src/main/resources/gearth/G-EarthLogoSmaller.png b/G-Earth/src/main/resources/gearth/G-EarthLogoSmaller.png new file mode 100644 index 0000000..a6a0196 Binary files /dev/null and b/G-Earth/src/main/resources/gearth/G-EarthLogoSmaller.png differ diff --git a/G-Earth/src/main/resources/gearth/ui/info/Info.fxml b/G-Earth/src/main/resources/gearth/ui/info/Info.fxml index 10be5a0..fcf0afe 100644 --- a/G-Earth/src/main/resources/gearth/ui/info/Info.fxml +++ b/G-Earth/src/main/resources/gearth/ui/info/Info.fxml @@ -1,24 +1,80 @@ - - + + + + + - + - - + - + - + + + + + + + + + + + + + + + + + + + + +