info page and notification on update available

This commit is contained in:
sirjonasxx 2018-11-07 15:45:39 +01:00
parent 3a2178337a
commit 0c7f538dca
7 changed files with 185 additions and 40 deletions

View File

@ -78,5 +78,10 @@
<artifactId>richtextfx</artifactId> <artifactId>richtextfx</artifactId>
<version>0.9.1</version> <version>0.9.1</version>
</dependency> </dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.2</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -3,30 +3,49 @@ package gearth;
import gearth.misc.AdminValidator; import gearth.misc.AdminValidator;
import javafx.application.Application; import javafx.application.Application;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType; 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.layout.Region;
import javafx.scene.web.WebView;
import javafx.stage.Stage; import javafx.stage.Stage;
import gearth.ui.GEarthController; 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 // 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 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 @Override
public void start(Stage primaryStage) throws Exception{ public void start(Stage primaryStage) throws Exception{
main = this;
FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/G-Earth.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/G-Earth.fxml"));
Parent root = loader.load(); Parent root = loader.load();
GEarthController companion = loader.getController(); GEarthController companion = loader.getController();
companion.setStage(primaryStage); companion.setStage(primaryStage);
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/gearth/G-EarthLogoSmaller.png")));
primaryStage.setResizable(false); primaryStage.setResizable(false);
//primaryStage.initStyle(StageStyle.UNDECORATED); //primaryStage.initStyle(StageStyle.UNDECORATED);
primaryStage.setTitle("G-Earth"); primaryStage.setTitle("G-Earth " + version);
primaryStage.setScene(new Scene(root, 620, 295)); primaryStage.setScene(new Scene(root, 620, 295));
primaryStage.show(); primaryStage.show();
primaryStage.getScene().getStylesheets().add(getClass().getResource("/gearth/ui/bootstrap3.css").toExternalForm()); primaryStage.getScene().getStylesheets().add(getClass().getResource("/gearth/ui/bootstrap3.css").toExternalForm());
@ -50,6 +69,41 @@ public class Main extends Application {
} }
}).start(); }).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("<html>A new version of G-Earth has been found ("+gitv+")<br><br>Update to the latest version:<br><a href=\"https://github.com/sirjonasxx/G-Earth/releases\">https://github.com/sirjonasxx/G-Earth/releases</a></html>");
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; public static String[] args;

View File

@ -1,43 +1,73 @@
package gearth.ui.info; 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 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. * Created by Jonas on 06/04/18.
*/ */
public class Info extends SubForm { 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 // this is a TEMPORARY info tab
public void initialize() { private void activateHyperlink(Hyperlink link) {
String[] lines = { link.setOnAction((ActionEvent event) -> {
"G-Earth 0.1.1", Hyperlink h = (Hyperlink) event.getTarget();
"Linux Habbo Packet Manipulator", String s = h.getTooltip().getText();
"", Main.main.getHostServices().showDocument(s);
"Made by:", event.consume();
"sirjonasxx", });
"",
"Contributors:",
"XePeleato (Windows & Mac support)",
"Scott Stamp",
"LittleJ",
"ArachisH",
"",
"Check out:",
"sngforum.info",
"darkbox.nl"
};
StringBuilder all = new StringBuilder(lines[0]);
for (int i = 1; i < lines.length; i++) {
all.append(System.lineSeparator()).append(lines[i]);
} }
public void initialize() {
version.setText(version.getText().replace("$version", Main.version));
text.setText( img_logo.setImage(new Image("/gearth/G-EarthLogo.png"));
all.toString()
); 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"));
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"
// };
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

@ -1,24 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?> <?import javafx.scene.control.Hyperlink?>
<?import javafx.scene.control.TextArea?> <?import javafx.scene.control.Label?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?> <?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0" <GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0" xmlns="http://javafx.com/javafx/8.0.131" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.info.Info">
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="gearth.ui.info.Info">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="367.0" minWidth="10.0" prefWidth="332.0"/> <ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="332.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="233.0"/>
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<TextArea fx:id="text" editable="false" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1"> <AnchorPane prefHeight="200.0" prefWidth="200.0">
<GridPane.margin> <children>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/> <ImageView fx:id="img_logo" fitHeight="228.0" fitWidth="217.0" layoutX="23.0" layoutY="23.0" pickOnBounds="true" preserveRatio="true" />
</GridPane.margin> <Label fx:id="version" layoutX="260.0" layoutY="23.0" text="G-Earth $version" textFill="#000000b2">
</TextArea> <font>
<Font size="18.0" />
</font>
</Label>
<Label layoutX="260.0" layoutY="50.0" text="Habbo packet manipulator for Linux &amp; Windows" textFill="#000000b2">
<font>
<Font size="14.0" />
</font>
</Label>
<Label layoutX="260.0" layoutY="86.0" text="Made by:" textFill="#000000b2">
<font>
<Font name="System Bold" size="14.0" />
</font>
</Label>
<Label layoutX="260.0" layoutY="106.0" text="sirjonasxx" textFill="#000000b2">
<font>
<Font size="14.0" />
</font>
</Label>
<Label layoutX="260.0" layoutY="142.0" text="Contributors:" textFill="#000000b2">
<font>
<Font name="System Bold" size="14.0" />
</font>
</Label>
<Label layoutX="260.0" layoutY="162.0" text="XePeleato" textFill="#000000b2">
<font>
<Font size="14.0" />
</font>
</Label>
<Label layoutX="260.0" layoutY="182.0" text="Scott Stamp" textFill="#000000b2">
<font>
<Font size="14.0" />
</font>
</Label>
<Label layoutX="260.0" layoutY="202.0" text="LittleJ" textFill="#000000b2">
<font>
<Font size="14.0" />
</font>
</Label>
<Label layoutX="260.0" layoutY="222.0" text="ArachisH" textFill="#000000b2">
<font>
<Font size="14.0" />
</font>
</Label>
<Label layoutX="400.0" layoutY="101.0" text="Links:" textFill="#000000b2">
<font>
<Font name="System Bold" size="14.0" />
</font>
</Label>
<Hyperlink fx:id="link_sng" layoutX="400.0" layoutY="121.0" text="SNG Forum" />
<Hyperlink fx:id="link_darkbox" layoutX="400.0" layoutY="141.0" text="Darkbox" />
<Hyperlink fx:id="link_d_harble" layoutX="400.0" layoutY="201.0" text="Discord - Harble" />
<Hyperlink fx:id="link_g_gearth" layoutX="400.0" layoutY="161.0" text="Github - G-Earth" />
<Hyperlink fx:id="link_g_tanji" layoutX="400.0" layoutY="181.0" text="Github - Tanji" />
<Hyperlink fx:id="link_d_bonnie" layoutX="400.0" layoutY="221.0" text="Discord - BonnieScripting (pt/br)" />
</children>
</AnchorPane>
</GridPane> </GridPane>