diff --git a/src/Marble.hx b/src/Marble.hx index 3a93db2a..9a1a065f 100644 --- a/src/Marble.hx +++ b/src/Marble.hx @@ -717,7 +717,7 @@ class Marble extends GameObject { var soFar = 0.0; for (k in 0...contacts.length) { var dist = this._radius - contacts[k].contactDistance; - var timeToSeparate = 0.1; + var timeToSeparate = 0.016; var vel = this.velocity.sub(contacts[k].velocity); var outVel = vel.add(dir.multiply(soFar)).dot(contacts[k].normal); if (dist > timeToSeparate * outVel) { @@ -1508,7 +1508,7 @@ class Marble extends GameObject { } } - if (mode == Start) { + if (mode == Start && startPad != null) { var upVec = this.level.currentUp; var startpadNormal = startPad.getAbsPos().up(); this.velocity = upVec.multiply(this.velocity.dot(upVec)); diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index f7b028b3..81e1d904 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -1,5 +1,6 @@ package src; +import gui.MessageBoxOkDlg; import src.Replay; import touch.TouchInput; import src.ResourceLoader; diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index 07a8ec13..d6c60230 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -1,5 +1,6 @@ package src; +import gui.MessageBoxOkDlg; import collision.Collision; import shapes.MegaMarble; import shapes.Blast; @@ -198,7 +199,7 @@ class MarbleWorld extends Scheduler { public function initLoading() { this.loadingGui = new LoadingGui(this.mission.title, this.mission.game); - MarbleGame.canvas.setContent(this.loadingGui); + // MarbleGame.canvas.setContent(this.loadingGui); function scanMission(simGroup:MissionElementSimGroup) { for (element in simGroup.elements) { @@ -231,11 +232,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; } @@ -253,7 +254,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); start(); }); @@ -1249,11 +1251,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(() -> { @@ -1516,7 +1528,7 @@ class MarbleWorld extends Scheduler { } } - if (this.finishTime == null) { + if (this.finishTime == null && this.endPad != null) { if (spherebounds.collide(this.endPad.finishBounds)) { var padUp = this.endPad.getAbsPos().up(); padUp = padUp.multiply(10); diff --git a/src/ResourceLoader.hx b/src/ResourceLoader.hx index b0d3a4bb..3f223ad5 100644 --- a/src/ResourceLoader.hx +++ b/src/ResourceLoader.hx @@ -22,11 +22,11 @@ import src.Settings; class ResourceLoader { #if (hl && !android) - #if MACOS_BUNDLE + #if MACOS_BUNDLE public static var fileSystem:FileSystem = new TorqueFileSystem(Path.normalize(Path.join([Path.directory(Sys.programPath()), "..", "..", ".."])), null); - #else + #else public static var fileSystem:FileSystem = new TorqueFileSystem(".", null); - #end + #end #end #if (js || android) public static var fileSystem:FileSystem = null; @@ -53,12 +53,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()); @@ -100,7 +100,10 @@ class ResourceLoader { fwd(); }); worker.run(); - // preloader.start(); + #end + #if android + preloader.start(); + #end #end #if (hl && !android) onLoadedFunc(); diff --git a/src/ResourceLoaderWorker.hx b/src/ResourceLoaderWorker.hx index 3f192b6e..d7357398 100644 --- a/src/ResourceLoaderWorker.hx +++ b/src/ResourceLoaderWorker.hx @@ -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 } } diff --git a/src/fs/ManifestBuilder.hx b/src/fs/ManifestBuilder.hx index 577aaacb..b730e785 100644 --- a/src/fs/ManifestBuilder.hx +++ b/src/fs/ManifestBuilder.hx @@ -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; } } diff --git a/src/fs/ManifestFileSystem.hx b/src/fs/ManifestFileSystem.hx index ad099099..acbb47de 100644 --- a/src/fs/ManifestFileSystem.hx +++ b/src/fs/ManifestFileSystem.hx @@ -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;