diff --git a/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java b/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java index 0a38ee5..94e3a6c 100644 --- a/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java +++ b/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java @@ -1,30 +1,47 @@ package com.gpl.rpg.atcontentstudio; +import java.awt.Color; +import java.awt.Desktop; import java.awt.Dimension; +import java.awt.Font; import java.awt.Toolkit; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.io.BufferedReader; import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; import java.util.LinkedList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.JEditorPane; +import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; - -import prefuse.data.expression.parser.ExpressionParser; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; import com.gpl.rpg.atcontentstudio.model.Workspace; import com.gpl.rpg.atcontentstudio.ui.StudioFrame; import com.gpl.rpg.atcontentstudio.ui.WorkerDialog; import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector; +import prefuse.data.expression.parser.ExpressionParser; + public class ATContentStudio { public static final String APP_NAME = "Andor's Trail Content Studio"; public static final String APP_VERSION = "v0.6.3"; + + public static final String CHECK_UPDATE_URL = "https://andorstrail.com/static/ATCS_latest"; + public static final String DOWNLOAD_URL = "https://andorstrail.com/viewtopic.php?f=6&t=4806"; public static boolean STARTED = false; public static StudioFrame frame = null; @@ -74,6 +91,9 @@ public class ATContentStudio { WorkerDialog.showTaskMessage("Loading your workspace...", null, new Runnable(){ public void run() { Workspace.setActive(workspaceRoot); + new Thread() { + public void run() {checkUpdate();} + }.start(); frame = new StudioFrame(APP_NAME+" "+APP_VERSION); frame.setVisible(true); frame.setDefaultCloseOperation(StudioFrame.DO_NOTHING_ON_CLOSE); @@ -95,4 +115,65 @@ public class ATContentStudio { }); } + private static void checkUpdate() { + BufferedReader in = null; + try { + URL url = new URL(CHECK_UPDATE_URL); + in = new BufferedReader(new InputStreamReader(url.openStream())); + + String inputLine, lastLine = null; + while ((inputLine = in.readLine()) != null) {lastLine = inputLine;} + if (lastLine != null && !lastLine.equals(APP_VERSION)) { + + // for copying style + JLabel label = new JLabel(); + Font font = label.getFont(); + Color color = label.getBackground(); + + // create some css from the label's font + StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";"); + style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";"); + style.append("font-size:" + font.getSize() + "pt;"); + style.append("background-color: rgb("+color.getRed()+","+color.getGreen()+","+color.getBlue()+");"); + + JEditorPane ep = new JEditorPane("text/html", "
" + + "You are not running the latest ATCS version.