mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-06-11 02:51:04 +00:00
fix this filename and this texture, also add slightly faster texture loading for js
This commit is contained in:
parent
4b10d198a3
commit
32bad2cd57
5 changed files with 38 additions and 4 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 6.7 KiB |
|
|
@ -151,7 +151,17 @@ class ResourceLoader {
|
|||
}
|
||||
var worker = new ResourceLoaderWorker(onFinish);
|
||||
for (file in toloadfiles) {
|
||||
worker.addTaskParallel((fwd) -> file.load(fwd));
|
||||
worker.addTaskParallel((fwd) -> {
|
||||
// if its a jpg, png or gif, load it as bitmap else load as file
|
||||
var fileExtension = file.extension.toLowerCase();
|
||||
if (fileExtension == "jpg" || fileExtension == "png" || fileExtension == "bmp") {
|
||||
file.loadBitmap(v -> {
|
||||
fwd();
|
||||
});
|
||||
} else {
|
||||
file.load(fwd);
|
||||
}
|
||||
});
|
||||
}
|
||||
worker.run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,22 @@ class ResourceLoaderWorker {
|
|||
public function loadFile(path:String) {
|
||||
if (ResourceLoader.loadedFiles.exists(path))
|
||||
return;
|
||||
paralleltasks.push(fwd -> ResourceLoader.load(path).entry.load(fwd));
|
||||
// if its a jpg, png or gif, load it as bitmap else load as file
|
||||
var fileExtension = path.split('.').pop();
|
||||
if (fileExtension != null) {
|
||||
fileExtension = fileExtension.toLowerCase();
|
||||
if (fileExtension == "jpg" || fileExtension == "png" || fileExtension == "bmp") {
|
||||
paralleltasks.push(fwd -> {
|
||||
var file = ResourceLoader.load(path);
|
||||
file.entry.loadBitmap(v -> {
|
||||
fwd();
|
||||
});
|
||||
});
|
||||
} else if (fileExtension != "") {
|
||||
paralleltasks.push(fwd -> ResourceLoader.load(path).entry.load(fwd));
|
||||
}
|
||||
} else {
|
||||
paralleltasks.push(fwd -> ResourceLoader.load(path).entry.load(fwd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ class ManifestEntry extends FileEntry {
|
|||
private var bytes:Bytes;
|
||||
private var readPos:Int;
|
||||
private var loaded:Bool;
|
||||
var loadedBmp:LoadedBitmap;
|
||||
#end
|
||||
|
||||
public function new(fs:ManifestFileSystem, name:String, relPath:String, file:String, ?originalFile:String) {
|
||||
|
|
@ -170,9 +171,16 @@ class ManifestEntry extends FileEntry {
|
|||
var bmp = new hxd.res.Image(this).toBitmap();
|
||||
onLoaded(new hxd.fs.LoadedBitmap(bmp));
|
||||
#elseif js
|
||||
if (loadedBmp != null) {
|
||||
onLoaded(loadedBmp);
|
||||
return;
|
||||
}
|
||||
load(() -> {
|
||||
var img:js.html.Image = new js.html.Image();
|
||||
img.onload = (_) -> onLoaded(new LoadedBitmap(img));
|
||||
img.onload = (_) -> {
|
||||
loadedBmp = new LoadedBitmap(img);
|
||||
onLoaded(loadedBmp);
|
||||
};
|
||||
img.src = file;
|
||||
});
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class PresentsGui extends GuiImage {
|
|||
this.position = new Vector();
|
||||
this.extent = new Vector(640, 480);
|
||||
|
||||
var ggLogo = new GuiImage(ResourceLoader.getResource('data/ui/GG_logo.png', ResourceLoader.getImage, this.imageResources).toTile());
|
||||
var ggLogo = new GuiImage(ResourceLoader.getResource('data/ui/GG_Logo.png', ResourceLoader.getImage, this.imageResources).toTile());
|
||||
ggLogo.horizSizing = Center;
|
||||
ggLogo.vertSizing = Center;
|
||||
ggLogo.position = new Vector(69, 99);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue