Commit 3788015f authored by superblaubeere27's avatar superblaubeere27

Add version check + status Label

parent 3d9a1f60
......@@ -13,6 +13,7 @@ import net.ccbluex.LiquidLauncher.utils.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
......@@ -37,13 +38,12 @@ import java.util.zip.ZipFile;
public class LiquidLauncher {
public static final String LAUNCHER_NAME = "LiquidLauncher";
public static final String LAUNCHER_VERSION_STRING = "v1.0-SNAPSHOT";
public static final String LAUNCHER_AUTHOR = "CCBlueX";
public static final boolean DEVEL_VERSION = true;
public static final Logger LOGGER = Logger.getLogger(LAUNCHER_NAME);
public static final String LAUNCHER_OPENSOURCE_PROJECT = "https://git.liquidbounce.net/CCBlueX/LiquidLauncherV2";
private static final double LAUNCHER_VERSION = 1.0;
public static final String LAUNCHER_VERSION_STRING = "v" + LAUNCHER_VERSION + "-SNAPSHOT";
public static LiquidLauncher liquidLauncher;
public static MenuInterface menuInterface;
......@@ -104,16 +104,21 @@ public class LiquidLauncher {
LOGGER.info("Starting splashscreen...");
final JFrame startScreen = new JFrame("LiquidLauncher");
startScreen.setUndecorated(true);
startScreen.setContentPane(new JLabel(new ImageIcon(LiquidLauncher.class.getResource("/loading_screen.gif"))));
startScreen.setLayout(new BorderLayout());
startScreen.add(BorderLayout.CENTER, new JLabel(new ImageIcon(LiquidLauncher.class.getResource("/loading_screen.gif"))));
JLabel statusLabel = new JLabel("");
startScreen.add(BorderLayout.SOUTH, statusLabel);
try {
startScreen.setIconImage(ImageIO.read(LiquidLauncher.class.getResourceAsStream("/icon.png")));
} catch (Exception e) {
LOGGER.severe("Failed to read icon image");
}
startScreen.setBackground(new Color(0x262626));
statusLabel.setBackground(new Color(0x262626));
startScreen.pack();
startScreen.setLocationRelativeTo(null);
startScreen.setVisible(true);
statusLabel.setText("Detecting Minecraft directory...");
LOGGER.info("Detecting Minecraft directory...");
// Minecraft directory
switch (SystemUtils.getOS()) {
......@@ -134,6 +139,7 @@ public class LiquidLauncher {
System.exit(-1);
break;
}
statusLabel.setText("Detecting Launcher directory...");
// Launcher directory
LOGGER.info("Detecting Launcher directory...");
......@@ -161,6 +167,7 @@ public class LiquidLauncher {
if (!launcherDirectory.exists())
launcherDirectory.mkdirs();
statusLabel.setText("Loading LiquidBounce versions...");
try {
LOGGER.info("Loading liquidbounce versions...");
......@@ -174,7 +181,10 @@ public class LiquidLauncher {
fatalError("Failed to load LiquidBounce versions: " + e);
}
assetManager = new AssetManager(launcherDirectory);
statusLabel.setText("Checking for updates...");
checkForUpdate();
statusLabel.setText("Showing Menu...");
// TODO: Other init stuff
LOGGER.info("Show menu.");
menuInterface = new MenuInterface();
......@@ -355,6 +365,20 @@ public class LiquidLauncher {
}, "Launch thread").start();
}
private void checkForUpdate() {
try {
double latestVersion = Double.parseDouble(NetworkUtils.readContent("https://raw.githubusercontent.com/CCBlueX/FileCloud/master/LiquidLauncher/latestVersion.txt"));
if (LAUNCHER_VERSION < latestVersion) {
LOGGER.info("Launcher is not up to date");
JOptionPane.showMessageDialog(menuInterface, String.format("Your launcher is outdated: currentVersion: %s latestVersion: %s", LAUNCHER_VERSION, latestVersion), "Launcher is outdated", JOptionPane.INFORMATION_MESSAGE);
} else {
LOGGER.info("Launcher is up to date");
}
} catch (Exception e) {
LOGGER.severe("Failed to check for updates");
}
}
private String getMCJson(final String minecraftVersion) throws Exception {
final String s = new String(ByteStreams.toByteArray(new URL("https://launchermeta.mojang.com/mc/game/version_manifest.json").openStream()));
final JsonArray versions = jsonParser.parse(s).getAsJsonObject().getAsJsonArray("versions");
......
......@@ -12,12 +12,9 @@ public class Main {
public static void main(String args[]) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); // NECESSARY FOR LINUX COMPUTERS
} catch (final Exception e) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (final Exception ignored) {
}
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (final Exception ignored) {
}
// JavaFX installed check
......
......@@ -93,6 +93,7 @@ public class AddLiquidBounceDialog extends JDialog {
@Override
public void drop(DropTargetDropEvent dtde) {
dtde.acceptDrop(DnDConstants.ACTION_COPY);
Transferable t = dtde.getTransferable();
boolean accept = false;
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment