Fix so resource files unzipped properly and skin reloaded afterward

This commit is contained in:
drdev
2014-05-30 00:05:36 +00:00
parent 80070d5301
commit 69d546b83b
3 changed files with 23 additions and 6 deletions

View File

@@ -84,7 +84,7 @@ public class Forge implements ApplicationListener {
@Override
public void run() {
//see if app or assets need updating
AssetsDownloader.checkForUpdates(splashScreen.getProgressBar());
AssetsDownloader.checkForUpdates(splashScreen);
FModel.initialize(splashScreen.getProgressBar());

View File

@@ -21,13 +21,14 @@ import com.esotericsoftware.minlog.Log;
import forge.FThreads;
import forge.Forge;
import forge.properties.ForgeConstants;
import forge.screens.SplashScreen;
import forge.toolbox.FProgressBar;
import forge.util.FileUtil;
import forge.util.TextUtil;
public class AssetsDownloader {
//if not forge-gui-mobile-dev, check whether assets are up to date
public static void checkForUpdates(final FProgressBar progressBar) {
public static void checkForUpdates(final SplashScreen splashScreen) {
//if (Gdx.app.getType() == ApplicationType.Desktop) { return; }
//TODO see if app needs updating
@@ -48,7 +49,15 @@ public class AssetsDownloader {
return; //if version matches what had been previously saved and FSkin isn't requesting assets download, no need to download assets
}
downloadAssets(progressBar);
downloadAssets(splashScreen.getProgressBar());
//reload light version of skin of assets updated
FThreads.invokeInEdtAndWait(new Runnable() {
@Override
public void run() {
FSkin.reloadAfterAssetsDownload(splashScreen);
}
});
//save version string to file once assets finish downloading
//so they don't need to be re-downloaded until you upgrade again
@@ -138,14 +147,16 @@ public class AssetsDownloader {
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry)entries.nextElement();
String path = ForgeConstants.ASSETS_DIR + entry.getName();
if (entry.isDirectory()) {
(new File(entry.getName())).mkdir();
new File(path).mkdir();
continue;
}
copyInputStream(zipFile.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(entry.getName())));
copyInputStream(zipFile.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(path)));
}
zipFile.close();
fileDest.delete();
}
catch (Exception e) {
// TODO Auto-generated catch block

View File

@@ -238,6 +238,12 @@ public class FSkin {
return needReloadAfterAssetsDownloaded;
}
public static void reloadAfterAssetsDownload(SplashScreen splashScreen) {
needReloadAfterAssetsDownloaded = false;
allSkins = null;
loadLight(preferredName, splashScreen);
}
/**
* Gets the name.
*