Skip to content

Commit 686b525

Browse files
committed
added .zip files support
ref #3
1 parent 4c70aa9 commit 686b525

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

Nesbox.as3proj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<libraryPaths>
5555
<element path="lib\as3corelib.swc" />
5656
<element path="lib\as3crypto.swc" />
57+
<element path="lib\fzip.swc" />
5758
</libraryPaths>
5859
<!-- External Libraries -->
5960
<externalLibraryPaths>

bin/Nesbox.swf

5.91 KB
Binary file not shown.

lib/fzip.swc

16.1 KB
Binary file not shown.

src/GameData.as

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package
22
{
3+
import deng.fzip.FZip;
4+
import deng.fzip.FZipFile;
35
import flash.display.Loader;
46
import flash.events.Event;
57
import flash.events.ProgressEvent;
@@ -34,6 +36,8 @@ package
3436
public static const Own:String = 'own';
3537
public static const Room:String = 'room';
3638

39+
private static const ZipExt:String = '.zip';
40+
3741
public function GameData(handler:IGameDataHandler, loaderUrl:String)
3842
{
3943
this.handler = handler;
@@ -100,6 +104,24 @@ package
100104

101105
public function parseOwnRomName(name:String):void
102106
{
107+
if (name.indexOf(ZipExt) != -1)
108+
{
109+
var zip:FZip = new FZip();
110+
111+
zip.addEventListener(Event.COMPLETE, function():void
112+
{
113+
var romFile:FZipFile = zip.getFileAt(0);
114+
115+
data = romFile.content;
116+
117+
parseOwnRomName(romFile.filename);
118+
});
119+
120+
zip.loadBytes(data);
121+
122+
return;
123+
}
124+
103125
const Modules:Object =
104126
{
105127
'nes':'nes.swf',
@@ -178,7 +200,24 @@ package
178200

179201
romLoader.addEventListener(Event.COMPLETE, function():void
180202
{
181-
data = romLoader.data;
203+
if (rom.indexOf(ZipExt) != -1)
204+
{
205+
var zip:FZip = new FZip();
206+
207+
zip.addEventListener(Event.COMPLETE, function():void
208+
{
209+
var romFile:FZipFile = zip.getFileAt(0);
210+
211+
data = romFile.content;
212+
});
213+
214+
zip.loadBytes(romLoader.data);
215+
}
216+
else
217+
{
218+
data = romLoader.data;
219+
}
220+
182221
handler.onLoadRom();
183222
});
184223

src/Nesbox.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ package
188188
{
189189
Analytics.trackOwnRomEvent();
190190

191-
var romsFilter:FileFilter = new FileFilter("Supported roms", "*.nes;*.smc;*.gen;*.gb;*.gbc;*.gba");
191+
var romsFilter:FileFilter = new FileFilter("Supported roms", "*.nes;*.smc;*.gen;*.gb;*.gbc;*.gba;*.zip");
192192
var ref:FileReference = new FileReference();
193193
ref.addEventListener(Event.SELECT, function():void
194194
{

0 commit comments

Comments
 (0)