From 119e689a75ea3ec8a30ae37f9cd667047e3c7649 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Mon, 31 Oct 2022 23:54:49 +0530 Subject: [PATCH] add support for native --- src/DifBuilder.hx | 4 ++-- src/MarbleWorld.hx | 10 +++++----- src/PathedInterior.hx | 2 +- src/ResourceLoader.hx | 8 ++++++++ src/ResourceLoaderWorker.hx | 2 +- src/gui/PlayMissionGui.hx | 5 +++++ src/shapes/AntiGravity.hx | 2 +- src/shapes/DuctFan.hx | 2 +- src/shapes/EndPad.hx | 2 +- src/shapes/Helicopter.hx | 2 +- src/shapes/LandMine.hx | 2 +- src/shapes/ShockAbsorber.hx | 2 +- src/shapes/SmallDuctFan.hx | 2 +- src/shapes/SuperBounce.hx | 2 +- src/shapes/SuperJump.hx | 4 ++-- src/shapes/SuperSpeed.hx | 4 ++-- src/shapes/TimeTravel.hx | 4 ++-- src/shapes/Tornado.hx | 2 +- src/shapes/Trapdoor.hx | 2 +- src/triggers/HelpTrigger.hx | 2 +- src/triggers/InBoundsTrigger.hx | 2 +- src/triggers/OutOfBoundsTrigger.hx | 2 +- 22 files changed, 41 insertions(+), 28 deletions(-) diff --git a/src/DifBuilder.hx b/src/DifBuilder.hx index 3673d1b7..1f0054d7 100644 --- a/src/DifBuilder.hx +++ b/src/DifBuilder.hx @@ -102,7 +102,7 @@ class DifBuilder { #if (js || android) path = StringTools.replace(path, "data/", ""); #end - ResourceLoader.loader.load(path).entry.load(() -> { + ResourceLoader.load(path).entry.load(() -> { var difresource = ResourceLoader.loadInterior(path); difresource.acquire(); var dif = difresource.resource; @@ -169,7 +169,7 @@ class DifBuilder { colliderSurface.originalIndices = []; colliderSurface.originalSurfaceIndex = surfaceindex; - for (k in(surface.windingStart + 2)...(surface.windingStart + surface.windingCount)) { + for (k in (surface.windingStart + 2)...(surface.windingStart + surface.windingCount)) { var p1, p2, p3; if ((k - (surface.windingStart + 2)) % 2 == 0) { p1 = points[geo.windings[k]]; diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index e98ad17a..c7efe6c8 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -852,17 +852,17 @@ class MarbleWorld extends Scheduler { var func = this.resourceLoadFuncs.shift(); lock = true; #if hl - func(); - lock = false; - this._resourcesLoaded++; - this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength)); + func(() -> { + lock = false; + this._resourcesLoaded++; + this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength)); + }); #end #if js func(() -> { lock = false; this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength)); this._resourcesLoaded++; - js.Browser.console.log('${func} is done'); }); #end } else { diff --git a/src/PathedInterior.hx b/src/PathedInterior.hx index 969471a8..82cdda4d 100644 --- a/src/PathedInterior.hx +++ b/src/PathedInterior.hx @@ -133,7 +133,7 @@ class PathedInterior extends InteriorObject { } if (this.element.datablock.toLowerCase() == "pathedmovingblock") { - ResourceLoader.loader.load("sound/movingblockloop.wav").entry.load(() -> { + ResourceLoader.load("sound/movingblockloop.wav").entry.load(() -> { this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/movingblockloop.wav", ResourceLoader.getAudio, this.soundResources), new Vector(), true); }); diff --git a/src/ResourceLoader.hx b/src/ResourceLoader.hx index 3b922e78..cd83f3ff 100644 --- a/src/ResourceLoader.hx +++ b/src/ResourceLoader.hx @@ -203,6 +203,14 @@ class ResourceLoader { worker.run(); } + public static function load(path:String) { + #if hl + if (!StringTools.startsWith(path, "data/")) + path = "data/" + path; + #end + return ResourceLoader.loader.load(path); + } + public static function loadInterior(path:String) { #if (js || android) path = StringTools.replace(path, "data/", ""); diff --git a/src/ResourceLoaderWorker.hx b/src/ResourceLoaderWorker.hx index 2d9fae1e..3ab93323 100644 --- a/src/ResourceLoaderWorker.hx +++ b/src/ResourceLoaderWorker.hx @@ -27,6 +27,6 @@ class ResourceLoaderWorker { } public function loadFile(path:String) { - addTask(fwd -> ResourceLoader.loader.load(path).entry.load(fwd)); + addTask(fwd -> ResourceLoader.load(path).entry.load(fwd)); } } diff --git a/src/gui/PlayMissionGui.hx b/src/gui/PlayMissionGui.hx index e7a1d18a..ae3e8bfb 100644 --- a/src/gui/PlayMissionGui.hx +++ b/src/gui/PlayMissionGui.hx @@ -491,6 +491,11 @@ class PlayMissionGui extends GuiImage { }, 75)); } #end + #if hl + currentMission.getPreviewImage(prevImg -> { + pmPreview.bmp.tile = prevImg; + }); // Shit be sync + #end levelBkgnd.text.text = currentCategory.charAt(0).toUpperCase() + currentCategory.substr(1) + ' Level ${currentSelection + 1}'; diff --git a/src/shapes/AntiGravity.hx b/src/shapes/AntiGravity.hx index f49027a0..c7ce72cf 100644 --- a/src/shapes/AntiGravity.hx +++ b/src/shapes/AntiGravity.hx @@ -37,7 +37,7 @@ class AntiGravity extends PowerUp { public override function init(level:MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/gravitychange.wav").entry.load(() -> { + ResourceLoader.load("sound/gravitychange.wav").entry.load(() -> { this.pickupSound = ResourceLoader.getResource("data/sound/gravitychange.wav", ResourceLoader.getAudio, this.soundResources); onFinish(); }); diff --git a/src/shapes/DuctFan.hx b/src/shapes/DuctFan.hx index dd11516d..b1ab2627 100644 --- a/src/shapes/DuctFan.hx +++ b/src/shapes/DuctFan.hx @@ -30,7 +30,7 @@ class DuctFan extends ForceObject { public override function init(level:src.MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/fan_loop.wav").entry.load(() -> { + ResourceLoader.load("sound/fan_loop.wav").entry.load(() -> { this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/fan_loop.wav", ResourceLoader.getAudio, this.soundResources), new Vector(1e8, 1e8, 1e8), true); onFinish(); diff --git a/src/shapes/EndPad.hx b/src/shapes/EndPad.hx index 297e900c..9383741e 100644 --- a/src/shapes/EndPad.hx +++ b/src/shapes/EndPad.hx @@ -39,7 +39,7 @@ class EndPad extends DtsObject { public override function init(level:MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/firewrks.wav").entry.load(onFinish); + ResourceLoader.load("sound/firewrks.wav").entry.load(onFinish); }); } diff --git a/src/shapes/Helicopter.hx b/src/shapes/Helicopter.hx index 23453e59..77601e8a 100644 --- a/src/shapes/Helicopter.hx +++ b/src/shapes/Helicopter.hx @@ -20,7 +20,7 @@ class Helicopter extends PowerUp { public override function init(level:MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/pugyrocoptervoice.wav").entry.load(() -> { + ResourceLoader.load("sound/pugyrocoptervoice.wav").entry.load(() -> { this.pickupSound = ResourceLoader.getResource("data/sound/pugyrocoptervoice.wav", ResourceLoader.getAudio, this.soundResources); onFinish(); }); diff --git a/src/shapes/LandMine.hx b/src/shapes/LandMine.hx index 23cfb997..e747a474 100644 --- a/src/shapes/LandMine.hx +++ b/src/shapes/LandMine.hx @@ -117,7 +117,7 @@ class LandMine extends DtsObject { public override function init(level:MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/explode1.wav").entry.load(onFinish); + ResourceLoader.load("sound/explode1.wav").entry.load(onFinish); }); } diff --git a/src/shapes/ShockAbsorber.hx b/src/shapes/ShockAbsorber.hx index 36d59c57..decf4514 100644 --- a/src/shapes/ShockAbsorber.hx +++ b/src/shapes/ShockAbsorber.hx @@ -18,7 +18,7 @@ class ShockAbsorber extends PowerUp { public override function init(level:MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/pushockabsorbervoice.wav").entry.load(() -> { + ResourceLoader.load("sound/pushockabsorbervoice.wav").entry.load(() -> { this.pickupSound = ResourceLoader.getResource("data/sound/pushockabsorbervoice.wav", ResourceLoader.getAudio, this.soundResources); onFinish(); }); diff --git a/src/shapes/SmallDuctFan.hx b/src/shapes/SmallDuctFan.hx index 4984d0ca..901382a3 100644 --- a/src/shapes/SmallDuctFan.hx +++ b/src/shapes/SmallDuctFan.hx @@ -30,7 +30,7 @@ class SmallDuctFan extends ForceObject { public override function init(level:src.MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/fan_loop.wav").entry.load(() -> { + ResourceLoader.load("sound/fan_loop.wav").entry.load(() -> { this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/fan_loop.wav", ResourceLoader.getAudio, this.soundResources), new Vector(1e8, 1e8, 1e8), true); onFinish(); diff --git a/src/shapes/SuperBounce.hx b/src/shapes/SuperBounce.hx index 26516aff..233f32cc 100644 --- a/src/shapes/SuperBounce.hx +++ b/src/shapes/SuperBounce.hx @@ -22,7 +22,7 @@ class SuperBounce extends PowerUp { public override function init(level:MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/pusuperbouncevoice.wav").entry.load(() -> { + ResourceLoader.load("sound/pusuperbouncevoice.wav").entry.load(() -> { this.pickupSound = ResourceLoader.getResource("data/sound/pusuperbouncevoice.wav", ResourceLoader.getAudio, this.soundResources); onFinish(); }); diff --git a/src/shapes/SuperJump.hx b/src/shapes/SuperJump.hx index d8284383..012b4bd4 100644 --- a/src/shapes/SuperJump.hx +++ b/src/shapes/SuperJump.hx @@ -50,9 +50,9 @@ class SuperJump extends PowerUp { public override function init(level:MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/pusuperjumpvoice.wav").entry.load(() -> { + ResourceLoader.load("sound/pusuperjumpvoice.wav").entry.load(() -> { this.pickupSound = ResourceLoader.getResource("sound/pusuperjumpvoice.wav", ResourceLoader.getAudio, this.soundResources); - ResourceLoader.loader.load("sound/dosuperjump.wav").entry.load(onFinish); + ResourceLoader.load("sound/dosuperjump.wav").entry.load(onFinish); }); }); } diff --git a/src/shapes/SuperSpeed.hx b/src/shapes/SuperSpeed.hx index d9d85d18..df7528f0 100644 --- a/src/shapes/SuperSpeed.hx +++ b/src/shapes/SuperSpeed.hx @@ -56,9 +56,9 @@ class SuperSpeed extends PowerUp { public override function init(level:MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/pusuperspeedvoice.wav").entry.load(() -> { + ResourceLoader.load("sound/pusuperspeedvoice.wav").entry.load(() -> { this.pickupSound = ResourceLoader.getResource("data/sound/pusuperspeedvoice.wav", ResourceLoader.getAudio, this.soundResources); - ResourceLoader.loader.load("sound/dosuperspeed.wav").entry.load(onFinish); + ResourceLoader.load("sound/dosuperspeed.wav").entry.load(onFinish); }); }); } diff --git a/src/shapes/TimeTravel.hx b/src/shapes/TimeTravel.hx index f85038e7..2cef364b 100644 --- a/src/shapes/TimeTravel.hx +++ b/src/shapes/TimeTravel.hx @@ -28,9 +28,9 @@ class TimeTravel extends PowerUp { public override function init(level:MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/putimetravelvoice.wav").entry.load(() -> { + ResourceLoader.load("sound/putimetravelvoice.wav").entry.load(() -> { this.pickupSound = ResourceLoader.getResource("data/sound/putimetravelvoice.wav", ResourceLoader.getAudio, this.soundResources); - ResourceLoader.loader.load("sound/timetravelactive.wav").entry.load(onFinish); + ResourceLoader.load("sound/timetravelactive.wav").entry.load(onFinish); }); }); } diff --git a/src/shapes/Tornado.hx b/src/shapes/Tornado.hx index dac2f914..67a8a260 100644 --- a/src/shapes/Tornado.hx +++ b/src/shapes/Tornado.hx @@ -47,7 +47,7 @@ class Tornado extends ForceObject { public override function init(level:src.MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/tornado.wav").entry.load(() -> { + ResourceLoader.load("sound/tornado.wav").entry.load(() -> { this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/tornado.wav", ResourceLoader.getAudio, this.soundResources), new Vector(1e8, 1e8, 1e8), true); for (material in this.materials) { diff --git a/src/shapes/Trapdoor.hx b/src/shapes/Trapdoor.hx index 6c639dc2..1102ab3a 100644 --- a/src/shapes/Trapdoor.hx +++ b/src/shapes/Trapdoor.hx @@ -28,7 +28,7 @@ class Trapdoor extends DtsObject { public override function init(level:MarbleWorld, onFinish:Void->Void) { super.init(level, () -> { - ResourceLoader.loader.load("sound/trapdooropen.wav").entry.load(onFinish); + ResourceLoader.load("sound/trapdooropen.wav").entry.load(onFinish); }); } diff --git a/src/triggers/HelpTrigger.hx b/src/triggers/HelpTrigger.hx index aade4a7e..a5282f86 100644 --- a/src/triggers/HelpTrigger.hx +++ b/src/triggers/HelpTrigger.hx @@ -12,6 +12,6 @@ class HelpTrigger extends Trigger { } public override function init(onFinish:Void->Void) { - ResourceLoader.loader.load("sound/infotutorial.wav").entry.load(onFinish); + ResourceLoader.load("sound/infotutorial.wav").entry.load(onFinish); } } diff --git a/src/triggers/InBoundsTrigger.hx b/src/triggers/InBoundsTrigger.hx index 2430f0e9..a4160f09 100644 --- a/src/triggers/InBoundsTrigger.hx +++ b/src/triggers/InBoundsTrigger.hx @@ -10,6 +10,6 @@ class InBoundsTrigger extends Trigger { } public override function init(onFinish:Void->Void) { - ResourceLoader.loader.load("sound/whoosh.wav").entry.load(onFinish); + ResourceLoader.load("sound/whoosh.wav").entry.load(onFinish); } } diff --git a/src/triggers/OutOfBoundsTrigger.hx b/src/triggers/OutOfBoundsTrigger.hx index b1411350..22c976c0 100644 --- a/src/triggers/OutOfBoundsTrigger.hx +++ b/src/triggers/OutOfBoundsTrigger.hx @@ -10,6 +10,6 @@ class OutOfBoundsTrigger extends Trigger { } public override function init(onFinish:Void->Void) { - ResourceLoader.loader.load("sound/whoosh.wav").entry.load(onFinish); + ResourceLoader.load("sound/whoosh.wav").entry.load(onFinish); } }