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 @Override
public void run() { public void run() {
//see if app or assets need updating //see if app or assets need updating
AssetsDownloader.checkForUpdates(splashScreen.getProgressBar()); AssetsDownloader.checkForUpdates(splashScreen);
FModel.initialize(splashScreen.getProgressBar()); FModel.initialize(splashScreen.getProgressBar());

View File

@@ -21,13 +21,14 @@ import com.esotericsoftware.minlog.Log;
import forge.FThreads; import forge.FThreads;
import forge.Forge; import forge.Forge;
import forge.properties.ForgeConstants; import forge.properties.ForgeConstants;
import forge.screens.SplashScreen;
import forge.toolbox.FProgressBar; import forge.toolbox.FProgressBar;
import forge.util.FileUtil; import forge.util.FileUtil;
import forge.util.TextUtil; import forge.util.TextUtil;
public class AssetsDownloader { public class AssetsDownloader {
//if not forge-gui-mobile-dev, check whether assets are up to date //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; } //if (Gdx.app.getType() == ApplicationType.Desktop) { return; }
//TODO see if app needs updating //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 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 //save version string to file once assets finish downloading
//so they don't need to be re-downloaded until you upgrade again //so they don't need to be re-downloaded until you upgrade again
@@ -138,14 +147,16 @@ public class AssetsDownloader {
while (entries.hasMoreElements()) { while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry)entries.nextElement(); ZipEntry entry = (ZipEntry)entries.nextElement();
String path = ForgeConstants.ASSETS_DIR + entry.getName();
if (entry.isDirectory()) { if (entry.isDirectory()) {
(new File(entry.getName())).mkdir(); new File(path).mkdir();
continue; continue;
} }
copyInputStream(zipFile.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(entry.getName()))); copyInputStream(zipFile.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(path)));
} }
zipFile.close(); zipFile.close();
fileDest.delete();
} }
catch (Exception e) { catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block

View File

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