|
From: <ka...@us...> - 2011-08-14 17:07:29
|
Revision: 3614
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3614&view=rev
Author: kappa1
Date: 2011-08-14 17:07:23 +0000 (Sun, 14 Aug 2011)
Log Message:
-----------
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 :)
Modified Paths:
--------------
trunk/LWJGL/applet/advance/appletloader.html
trunk/LWJGL/applet/basic/basicapplet.html
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/applet/advance/appletloader.html
===================================================================
--- trunk/LWJGL/applet/advance/appletloader.html 2011-08-14 10:46:00 UTC (rev 3613)
+++ trunk/LWJGL/applet/advance/appletloader.html 2011-08-14 17:07:23 UTC (rev 3614)
@@ -32,12 +32,12 @@
<!-- Tags under here are optional -->
- <!-- Version of Applet, important otherwise applet won't be cached, version change will update applet, must be int or float -->
- <!-- <param name="al_version" value="0.1"> -->
-
<!-- whether to use cache - defaults to true -->
<!-- <param name="al_cache" value="true"> -->
+ <!-- Version of Applet (case insensitive String), applet files not redownloaded if same version already in cache -->
+ <!-- <param name="al_version" value="0.1"> -->
+
<!-- background color to paint with, defaults to white -->
<!-- <param name="boxbgcolor" value="#000000"> -->
Modified: trunk/LWJGL/applet/basic/basicapplet.html
===================================================================
--- trunk/LWJGL/applet/basic/basicapplet.html 2011-08-14 10:46:00 UTC (rev 3613)
+++ trunk/LWJGL/applet/basic/basicapplet.html 2011-08-14 17:07:23 UTC (rev 3614)
@@ -32,12 +32,12 @@
<!-- Tags under here are optional -->
- <!-- Version of Applet, important otherwise applet won't be cached, version change will update applet, must be int or float -->
- <!-- <param name="al_version" value="0.1"> -->
-
<!-- whether to use cache - defaults to true -->
<!-- <param name="al_cache" value="true"> -->
+ <!-- Version of Applet (case insensitive String), applet files not redownloaded if same version already in cache -->
+ <!-- <param name="al_version" value="0.1"> -->
+
<!-- background color to paint with, defaults to white -->
<!-- <param name="boxbgcolor" value="#000000"> -->
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-08-14 10:46:00 UTC (rev 3613)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-08-14 17:07:23 UTC (rev 3614)
@@ -144,6 +144,7 @@
* <li>Bobjob</li>
* <li>Dashiva</li>
* <li>Dr_evil</li>
+ * <li>Elias Naur</li>
* <li>Kevin Glass</li>
* <li>Matthias Mann</li>
* <li>Mickelukas</li>
@@ -808,14 +809,12 @@
// 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 @@
// 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 @@
/**
* 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 @@
}
/**
- * 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;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|