|
From: <ka...@us...> - 2011-01-25 01:29:29
|
Revision: 3477
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3477&view=rev
Author: kappa1
Date: 2011-01-25 01:29:22 +0000 (Tue, 25 Jan 2011)
Log Message:
-----------
AppletLoader - fix progress bar when extracting from multiple native jars
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-01-24 22:35:11 UTC (rev 3476)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2011-01-25 01:29:22 UTC (rev 3477)
@@ -1367,7 +1367,9 @@
protected void extractNatives(String path) throws Exception {
setState(STATE_EXTRACTING_PACKAGES);
-
+
+ float percentageParts = 20f/nativeJarCount; // parts for each native jar from 20%
+
// create native folder
File nativeFolder = new File(path + "natives");
if (!nativeFolder.exists()) {
@@ -1387,9 +1389,7 @@
certificate = jurl.getCertificates();
}
- for (int i = fileSizes.length - nativeJarCount; i < fileSizes.length; i++) {
-
- int initialPercentage = percentage;
+ for (int i = urlList.length - nativeJarCount; i < urlList.length; i++) {
// if a new native jar was not downloaded, no extracting needed
if (fileSizes[i] == -2) {
@@ -1406,7 +1406,8 @@
Enumeration entities = jarFile.entries();
totalSizeExtract = 0;
-
+ int jarNum = i - (urlList.length - nativeJarCount); // used for progressbar
+
// calculate the size of the files to extract for progress bar
while (entities.hasMoreElements()) {
JarEntry entry = (JarEntry) entities.nextElement();
@@ -1457,7 +1458,7 @@
currentSizeExtract += bufferSize;
// update progress bar
- percentage = initialPercentage + ((currentSizeExtract * 20) / totalSizeExtract);
+ percentage = 65 + (int)(percentageParts * (jarNum + currentSizeExtract/(float)totalSizeExtract));
subtaskMessage = "Extracting: " + entry.getName() + " " + ((currentSizeExtract * 100) / totalSizeExtract) + "%";
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|