|
@@ -3,17 +3,11 @@ package hxd.res;
|
|
class Loader {
|
|
class Loader {
|
|
|
|
|
|
public var fs(default,null) : FileSystem;
|
|
public var fs(default,null) : FileSystem;
|
|
- var modelCache : Map<String,Model>;
|
|
|
|
- var imageCache : Map<String,Image>;
|
|
|
|
- var soundCache : Map<String,Sound>;
|
|
|
|
- var fontCache : Map<String,BitmapFont>;
|
|
|
|
|
|
+ var cache : Map<String,Dynamic>;
|
|
|
|
|
|
public function new(fs) {
|
|
public function new(fs) {
|
|
this.fs = fs;
|
|
this.fs = fs;
|
|
- modelCache = new Map();
|
|
|
|
- imageCache = new Map();
|
|
|
|
- soundCache = new Map();
|
|
|
|
- fontCache = new Map();
|
|
|
|
|
|
+ cache = new Map<String,Dynamic>();
|
|
}
|
|
}
|
|
|
|
|
|
public function exists( path : String ) : Bool {
|
|
public function exists( path : String ) : Bool {
|
|
@@ -24,29 +18,38 @@ class Loader {
|
|
return new Any(this, fs.get(path));
|
|
return new Any(this, fs.get(path));
|
|
}
|
|
}
|
|
|
|
|
|
- function loadModel( path : String ) : Model {
|
|
|
|
- var m = modelCache.get(path);
|
|
|
|
|
|
+ function loadFbxModel( path : String ) : FbxModel {
|
|
|
|
+ var m : FbxModel = cache.get(path);
|
|
if( m == null ) {
|
|
if( m == null ) {
|
|
- m = new Model(fs.get(path));
|
|
|
|
- modelCache.set(path, m);
|
|
|
|
|
|
+ m = new FbxModel(fs.get(path));
|
|
|
|
+ cache.set(path, m);
|
|
|
|
+ }
|
|
|
|
+ return m;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function loadAwdModel( path : String ) : AwdModel {
|
|
|
|
+ var m : AwdModel = cache.get(path);
|
|
|
|
+ if( m == null ) {
|
|
|
|
+ m = new AwdModel(fs.get(path));
|
|
|
|
+ cache.set(path, m);
|
|
}
|
|
}
|
|
return m;
|
|
return m;
|
|
}
|
|
}
|
|
|
|
|
|
function loadImage( path : String ) : Image {
|
|
function loadImage( path : String ) : Image {
|
|
- var t = imageCache.get(path);
|
|
|
|
- if( t == null ) {
|
|
|
|
- t = new Image(fs.get(path));
|
|
|
|
- imageCache.set(path, t);
|
|
|
|
|
|
+ var i : Image = cache.get(path);
|
|
|
|
+ if( i == null ) {
|
|
|
|
+ i = new Image(fs.get(path));
|
|
|
|
+ cache.set(path, i);
|
|
}
|
|
}
|
|
- return t;
|
|
|
|
|
|
+ return i;
|
|
}
|
|
}
|
|
|
|
|
|
function loadSound( path : String ) : Sound {
|
|
function loadSound( path : String ) : Sound {
|
|
- var s = soundCache.get(path);
|
|
|
|
|
|
+ var s : Sound = cache.get(path);
|
|
if( s == null ) {
|
|
if( s == null ) {
|
|
s = new Sound(fs.get(path));
|
|
s = new Sound(fs.get(path));
|
|
- soundCache.set(path, s);
|
|
|
|
|
|
+ cache.set(path, s);
|
|
}
|
|
}
|
|
return s;
|
|
return s;
|
|
}
|
|
}
|
|
@@ -57,10 +60,10 @@ class Loader {
|
|
}
|
|
}
|
|
|
|
|
|
function loadBitmapFont( path : String ) : BitmapFont {
|
|
function loadBitmapFont( path : String ) : BitmapFont {
|
|
- var f = fontCache.get(path);
|
|
|
|
|
|
+ var f : BitmapFont = cache.get(path);
|
|
if( f == null ) {
|
|
if( f == null ) {
|
|
f = new BitmapFont(this,fs.get(path));
|
|
f = new BitmapFont(this,fs.get(path));
|
|
- fontCache.set(path, f);
|
|
|
|
|
|
+ cache.set(path, f);
|
|
}
|
|
}
|
|
return f;
|
|
return f;
|
|
}
|
|
}
|