Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions gaf/src/com/catalystapps/gaf/core/ZipToGAFAssetConverter.as
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.catalystapps.gaf.core
{
import com.catalystapps.gaf.data.GAF;
import flash.display3D.Context3DTextureFormat;
import flash.utils.getDefinitionByName;
import deng.fzip.FZip;
Expand Down Expand Up @@ -199,6 +200,10 @@ package com.catalystapps.gaf.core

if (data is ByteArray)
{
if (GAF.restoreTexturesFromFile)
{
trace("WARNING: Restore textures from zip file is not supported. Texture sources will remain in memory.");
}
this._zip = new FZip();
this._zip.addEventListener(FZipErrorEvent.PARSE_ERROR, this.onParseError);
this._zip.loadBytes(data);
Expand Down Expand Up @@ -365,7 +370,7 @@ package com.catalystapps.gaf.core
}
}

private function findAllAtlasURLs(): void
private function findAllAtlasURLs(folderURL: String): void
{
this.atlasSourceURLs = [];

Expand All @@ -378,8 +383,6 @@ package com.catalystapps.gaf.core

for each (var config: GAFTimelineConfig in gafTimelineConfigs)
{
var folderURL: String = this.getFolderURL(id);

for each(var scale: CTextureAtlasScale in config.allTextureAtlases)
{
if (isNaN(this._defaultScale) || MathUtility.equals(scale.scale, this._defaultScale))
Expand All @@ -396,6 +399,7 @@ package com.catalystapps.gaf.core
&& this.atlasSourceURLs.indexOf(url) == -1)
{
this.atlasSourceURLs.push(url);
this.gfxData.addAtlasURL(scale.scale, csf.csf, source.id, url);
}
}
}
Expand Down Expand Up @@ -427,11 +431,11 @@ package com.catalystapps.gaf.core
}
else
{
url = url.substring(0, url.lastIndexOf(".png"));
file = new FileClass(url + ".atf");
url = url.substring(0, url.lastIndexOf(".png")) + ".atf";
file = new FileClass(url);
if (file["exists"])
{
this.loadATF(file["nativePath"]);
this.loadATF(url);
}
else
{
Expand Down Expand Up @@ -469,18 +473,11 @@ package com.catalystapps.gaf.core

private function finalizeParsing(): void
{
if (!Starling.handleLostContext)
if (GAF.restoreTexturesFromFile && !this._zip || !Starling.handleLostContext)
{
this.gfxData.removeImages();
for each (var bd: BitmapData in this.pngImgs)
{
bd.dispose();
}
for each (var ba: ByteArray in this.atfData)
{
ba.clear();
}
}
this.sounds = null;
this.pngImgs = null;
this.atfData = null;

Expand All @@ -499,12 +496,11 @@ package com.catalystapps.gaf.core
this._zip.close();
this._zip = null;
}
this.sounds = null;

this.dispatchEvent(new Event(Event.COMPLETE));
}

private function getFolderURL(url: String): String
private static function getFolderURL(url: String): String
{
var cutURL: String = url.split("?")[0];

Expand Down Expand Up @@ -788,6 +784,7 @@ package com.catalystapps.gaf.core
use namespace gaf_internal;

var configID: String = this.gafAssetsIDs[this.currentConfigIndex];
var folderURL: String = getFolderURL(configID);
var converter: BinGAFAssetConfigConverter = event.target as BinGAFAssetConfigConverter;
converter.removeEventListener(Event.COMPLETE, onConverted);
converter.removeEventListener(ErrorEvent.ERROR, onConvertError);
Expand All @@ -798,8 +795,7 @@ package com.catalystapps.gaf.core
{
for (var i: int = 0; i < sounds.length; i++)
{
var assetID: String = this.getFolderURL(configID);
sounds[i].source = assetID + sounds[i].source;
sounds[i].source = folderURL + sounds[i].source;
this.soundData.addSound(sounds[i], converter.config.id, this.sounds[sounds[i].source]);
}
}
Expand All @@ -810,7 +806,7 @@ package com.catalystapps.gaf.core
{
if (this.gafAssetsConfigURLs && gafAssetsConfigURLs.length)
{
this.findAllAtlasURLs();
this.findAllAtlasURLs(folderURL);
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions gaf/src/com/catalystapps/gaf/data/GAF.as
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ package com.catalystapps.gaf.data
*/
public static var useMipMaps: Boolean;

/** @private */
public static var restoreTexturesFromFile: Boolean;

/** @private */
gaf_internal static var useDeviceFonts: Boolean;

Expand Down
Loading