mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-12-30 20:02:18 +00:00
android attempt fixes
This commit is contained in:
parent
e8b8a422f7
commit
abd0f4709a
6 changed files with 88 additions and 26 deletions
|
|
@ -6,6 +6,7 @@ import gui.ReplayCenterGui;
|
|||
#end
|
||||
import gui.ReplayNameDlg;
|
||||
import gui.ConsoleDlg;
|
||||
import gui.MessageBoxOkDlg;
|
||||
import src.Replay;
|
||||
import touch.TouchInput;
|
||||
import src.ResourceLoader;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import gui.MainMenuGui;
|
|||
import gui.ReplayCenterGui;
|
||||
#end
|
||||
import gui.ReplayNameDlg;
|
||||
import gui.MessageBoxOkDlg;
|
||||
import collision.Collision;
|
||||
import shapes.MegaMarble;
|
||||
import shapes.Blast;
|
||||
|
|
@ -254,11 +255,11 @@ class MarbleWorld extends Scheduler {
|
|||
scanMission(this.mission.root);
|
||||
this.resourceLoadFuncs.push(fwd -> this.initScene(fwd));
|
||||
this.resourceLoadFuncs.push(fwd -> this.initMarble(fwd));
|
||||
this.resourceLoadFuncs.push(fwd -> {
|
||||
this.addSimGroup(this.mission.root);
|
||||
this._loadingLength = resourceLoadFuncs.length;
|
||||
fwd();
|
||||
});
|
||||
// this.resourceLoadFuncs.push(fwd -> {
|
||||
// this.addSimGroup(this.mission.root);
|
||||
// this._loadingLength = resourceLoadFuncs.length;
|
||||
// fwd();
|
||||
// });
|
||||
this.resourceLoadFuncs.push(fwd -> this.loadMusic(fwd));
|
||||
this._loadingLength = resourceLoadFuncs.length;
|
||||
}
|
||||
|
|
@ -280,7 +281,8 @@ class MarbleWorld extends Scheduler {
|
|||
var musicFileName = 'data/sound/music/' + this.mission.missionInfo.music;
|
||||
AudioManager.playMusic(ResourceLoader.getResource(musicFileName, ResourceLoader.getAudio, this.soundResources), this.mission.missionInfo.music);
|
||||
MarbleGame.canvas.clearContent();
|
||||
this.endPad.generateCollider();
|
||||
if (this.endPad != null)
|
||||
this.endPad.generateCollider();
|
||||
this.playGui.formatGemCounter(this.gemCount, this.totalGems);
|
||||
Console.log("MISSION LOADED");
|
||||
start();
|
||||
|
|
@ -1103,11 +1105,21 @@ class MarbleWorld extends Scheduler {
|
|||
var func = this.resourceLoadFuncs.shift();
|
||||
lock = true;
|
||||
#if hl
|
||||
func(() -> {
|
||||
try {
|
||||
func(() -> {
|
||||
lock = false;
|
||||
this._resourcesLoaded++;
|
||||
this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength));
|
||||
});
|
||||
} catch (e) {
|
||||
lock = false;
|
||||
this._resourcesLoaded++;
|
||||
this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength));
|
||||
});
|
||||
var errorTxt = new h2d.Text(hxd.res.DefaultFont.get());
|
||||
errorTxt.setPosition(20, 20);
|
||||
errorTxt.text = e.toString();
|
||||
errorTxt.textColor = 0xFFFFFF;
|
||||
MarbleGame.canvas.scene2d.addChild(errorTxt);
|
||||
}
|
||||
#end
|
||||
#if js
|
||||
func(() -> {
|
||||
|
|
|
|||
|
|
@ -62,12 +62,12 @@ class ResourceLoader {
|
|||
#if (js || android)
|
||||
var mfileSystem = ManifestBuilder.create("data");
|
||||
var mloader:ManifestLoader = new ManifestLoader(mfileSystem);
|
||||
|
||||
var preloader = new ManifestProgress(mloader, () -> {
|
||||
loader = mloader;
|
||||
fileSystem = mfileSystem;
|
||||
onLoadedFunc();
|
||||
}, scene2d);
|
||||
#if js
|
||||
loader = mloader;
|
||||
fileSystem = mfileSystem;
|
||||
var loadg = new h2d.Text(hxd.res.DefaultFont.get());
|
||||
|
|
@ -109,7 +109,10 @@ class ResourceLoader {
|
|||
fwd();
|
||||
});
|
||||
worker.run();
|
||||
// preloader.start();
|
||||
#end
|
||||
#if android
|
||||
preloader.start();
|
||||
#end
|
||||
#end
|
||||
#if (hl && !android)
|
||||
onLoadedFunc();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package src;
|
||||
|
||||
import gui.MessageBoxOkDlg;
|
||||
import src.ResourceLoader;
|
||||
import src.MarbleGame;
|
||||
|
||||
class ResourceLoaderWorker {
|
||||
var tasks:Array<(() -> Void)->Void> = [];
|
||||
|
|
@ -20,7 +22,11 @@ class ResourceLoaderWorker {
|
|||
}
|
||||
|
||||
public function addTaskParallel(task:(() -> Void)->Void) {
|
||||
#if (!android)
|
||||
paralleltasks.push(task);
|
||||
#else
|
||||
tasks.push(task);
|
||||
#end
|
||||
}
|
||||
|
||||
public function run() {
|
||||
|
|
@ -41,19 +47,59 @@ class ResourceLoaderWorker {
|
|||
|
||||
if (tasks.length > 0) {
|
||||
var task = tasks.shift();
|
||||
task(() -> {
|
||||
if (tasks.length > 0) {
|
||||
run();
|
||||
} else {
|
||||
onFinish();
|
||||
}
|
||||
});
|
||||
try {
|
||||
task(() -> {
|
||||
if (tasks.length > 0) {
|
||||
run();
|
||||
} else {
|
||||
onFinish();
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
var errorTxt = new h2d.Text(hxd.res.DefaultFont.get());
|
||||
errorTxt.setPosition(20, 20);
|
||||
errorTxt.text = e.toString();
|
||||
errorTxt.textColor = 0xFFFFFF;
|
||||
MarbleGame.canvas.scene2d.addChild(errorTxt);
|
||||
}
|
||||
} else {
|
||||
onFinish();
|
||||
try {
|
||||
onFinish();
|
||||
} catch (e) {
|
||||
var errorTxt = new h2d.Text(hxd.res.DefaultFont.get());
|
||||
errorTxt.setPosition(20, 20);
|
||||
errorTxt.text = e.toString();
|
||||
errorTxt.textColor = 0xFFFFFF;
|
||||
MarbleGame.canvas.scene2d.addChild(errorTxt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function loadFile(path:String) {
|
||||
paralleltasks.push(fwd -> ResourceLoader.load(path).entry.load(fwd));
|
||||
#if (!android)
|
||||
paralleltasks.push(fwd -> {
|
||||
try {
|
||||
ResourceLoader.load(path).entry.load(fwd);
|
||||
} catch (e) {
|
||||
var errorTxt = new h2d.Text(hxd.res.DefaultFont.get());
|
||||
errorTxt.setPosition(20, 20);
|
||||
errorTxt.text = e.toString();
|
||||
errorTxt.textColor = 0xFFFFFF;
|
||||
MarbleGame.canvas.scene2d.addChild(errorTxt);
|
||||
}
|
||||
});
|
||||
#else
|
||||
tasks.push(fwd -> {
|
||||
try {
|
||||
ResourceLoader.load(path).entry.load(fwd);
|
||||
} catch (e) {
|
||||
var errorTxt = new h2d.Text(hxd.res.DefaultFont.get());
|
||||
errorTxt.setPosition(20, 20);
|
||||
errorTxt.text = e.toString();
|
||||
errorTxt.textColor = 0xFFFFFF;
|
||||
MarbleGame.canvas.scene2d.addChild(errorTxt);
|
||||
}
|
||||
});
|
||||
#end
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,13 +130,13 @@ class ManifestBuilder {
|
|||
// try later with another fs
|
||||
if (!StringTools.startsWith(file.fullPath, basePath))
|
||||
continue;
|
||||
var info = {path: file.relPath.toLowerCase(), original: file.relPath};
|
||||
var info = {path: file.relPath, original: file.relPath};
|
||||
out.push(info);
|
||||
var f = fs.get(file.relPath); // convert
|
||||
if (f.originalFile != null && f.originalFile != f.file) {
|
||||
info.original = f.relPath;
|
||||
info.path = StringTools.startsWith(f.file, fs.baseDir) ? f.file.substr(fs.baseDir.length) : f.file;
|
||||
info.path = info.path.toLowerCase();
|
||||
info.path = info.path;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ class ManifestFileSystem implements FileSystem {
|
|||
}
|
||||
var entry:ManifestEntry = new ManifestEntry(this, Path.withoutDirectory(original), original, file, original);
|
||||
r.contents.push(entry);
|
||||
manifest.set(path.toLowerCase(), entry);
|
||||
manifest.set(path, entry);
|
||||
}
|
||||
|
||||
switch (_manifest.get(0)) {
|
||||
|
|
@ -298,7 +298,7 @@ class ManifestFileSystem implements FileSystem {
|
|||
// JSON
|
||||
var json:Array<{path:String, original:String}> = haxe.Json.parse(_manifest.toString());
|
||||
for (entry in json) {
|
||||
insert(entry.path.toLowerCase(), baseDir + entry.path, entry.original);
|
||||
insert(entry.path, baseDir + entry.path, entry.original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -322,11 +322,11 @@ class ManifestFileSystem implements FileSystem {
|
|||
}
|
||||
|
||||
public function exists(path:String) {
|
||||
return find(path.toLowerCase()) != null;
|
||||
return find(path) != null;
|
||||
}
|
||||
|
||||
public function get(path:String) {
|
||||
var entry:ManifestEntry = find(path.toLowerCase());
|
||||
var entry:ManifestEntry = find(path);
|
||||
if (entry == null)
|
||||
throw new NotFound(path);
|
||||
return entry;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue