From 873fed061390667a7486b48184b37d26526ac70b Mon Sep 17 00:00:00 2001 From: kappa1 Date: Sun, 14 Aug 2011 17:07:23 +0000 Subject: [PATCH] AppletLoader: al_version tag now uses a case insensitive String (instead of float), much nicer for specifying application versions (e.g. "10.3.3.1 Beta"), still backwards compatible too :) --- applet/advance/appletloader.html | 6 ++-- applet/basic/basicapplet.html | 6 ++-- .../org/lwjgl/util/applet/AppletLoader.java | 36 +++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/applet/advance/appletloader.html b/applet/advance/appletloader.html index 52abbcf8..aba582f7 100644 --- a/applet/advance/appletloader.html +++ b/applet/advance/appletloader.html @@ -32,12 +32,12 @@ - - - + + + diff --git a/applet/basic/basicapplet.html b/applet/basic/basicapplet.html index ced5ee6a..b8cf4a15 100644 --- a/applet/basic/basicapplet.html +++ b/applet/basic/basicapplet.html @@ -32,12 +32,12 @@ - - - + + + diff --git a/src/java/org/lwjgl/util/applet/AppletLoader.java b/src/java/org/lwjgl/util/applet/AppletLoader.java index 18653e2e..c4c586ed 100644 --- a/src/java/org/lwjgl/util/applet/AppletLoader.java +++ b/src/java/org/lwjgl/util/applet/AppletLoader.java @@ -144,6 +144,7 @@ import java.util.zip.ZipFile; *
  • Bobjob
  • *
  • Dashiva
  • *
  • Dr_evil
  • + *
  • Elias Naur
  • *
  • Kevin Glass
  • *
  • Matthias Mann
  • *
  • Mickelukas
  • @@ -808,14 +809,12 @@ public class AppletLoader extends Applet implements Runnable, AppletStub { // if specified applet version already available don't download anything boolean versionAvailable = false; - // version of applet + // version string of applet String version = getParameter("al_version"); - float latestVersion = 0; - + // if applet version specifed, compare with version in the cache if (version != null) { - latestVersion = Float.parseFloat(version); - versionAvailable = compareVersion(versionFile, latestVersion); + versionAvailable = compareVersion(versionFile, version.toLowerCase()); } // if jars not available or need updating download them @@ -838,7 +837,7 @@ public class AppletLoader extends Applet implements Runnable, AppletStub { // save version information once jars downloaded successfully if (version != null) { percentage = 90; - writeObjectFile(versionFile, latestVersion); + writeObjectFile(versionFile, version.toLowerCase()); } // save file names with last modified info once downloaded successfully @@ -883,21 +882,23 @@ public class AppletLoader extends Applet implements Runnable, AppletStub { /** * This method will return true if the version stored in the file - * matches the supplied float version. + * matches the supplied String version. * * @param versionFile - location to file containing version information - * @param version - float version that needs to be compared + * @param version - String version that needs to be compared * @return returns true if the version in file matches specified version */ - protected boolean compareVersion(File versionFile, float version) { + protected boolean compareVersion(File versionFile, String version) { // if version file exists if (versionFile.exists()) { + String s = readStringFile(versionFile); + // compare to version with file - if (version == readFloatFile(versionFile)) { + if (s != null && s.equals(version)) { percentage = 90; // not need to download cache files again if(debugMode) { - System.out.println("Loading Cached Applet Version " + version); + System.out.println("Loading Cached Applet Version: " + version); } debug_sleep(2000); @@ -980,22 +981,21 @@ public class AppletLoader extends Applet implements Runnable, AppletStub { } /** - * read float from File + * read String object from File * * @param file to be read - * @return the float stored in the file or 0 if it fails + * @return the String stored in the file or null if it fails */ - protected float readFloatFile(File file) { + protected String readStringFile(File file) { try { - Float version = (Float)readObjectFile(file); - return version.floatValue(); + return (String)readObjectFile(file); } catch (Exception e) { // failed to read version file e.printStackTrace(); } - // return 0 if failed to read file - return 0; + // return null if failed to read file + return null; } /**