From 21bd71320341d399821065b17a4c20f29191dc2a Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Mon, 10 Jun 2024 19:35:26 +0530 Subject: [PATCH] better fast load and sort customs by alphabetical --- src/MPCustoms.hx | 5 ++++ src/MarbleGame.hx | 2 +- src/MarbleWorld.hx | 59 +++++++++++++++++++++++++++++---------- src/Settings.hx | 2 +- src/gui/MiscOptionsGui.hx | 4 +-- 5 files changed, 54 insertions(+), 18 deletions(-) diff --git a/src/MPCustoms.hx b/src/MPCustoms.hx index ba4e6e68..248f55f3 100644 --- a/src/MPCustoms.hx +++ b/src/MPCustoms.hx @@ -26,6 +26,11 @@ class MPCustoms { Http.get("https://marbleblastultra.randomityguy.me/data/ultraCustom.json", (b) -> { var misList = Json.parse(b.toString()); missionList = misList; + missionList.sort((a, b) -> { + var a1 = a.title.toLowerCase(); + var b1 = b.title.toLowerCase(); + return a1 < b1 ? -1 : (a1 > b1 ? 1 : 0); + }); Console.log('Loaded ${misList.length} custom missions.'); _requestSent = false; }, (e) -> { diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 6f8e1525..ed6217b8 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -41,7 +41,7 @@ class MarbleGame { static var canvas:Canvas; static var instance:MarbleGame; - static var currentVersion = "1.0.2"; + static var currentVersion = "1.1.0"; var world:MarbleWorld; var previewWorld:PreviewWorld; diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index ce952276..e5b7267f 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -1779,20 +1779,51 @@ class MarbleWorld extends Scheduler { if (lock) return; - var func = this.resourceLoadFuncs.shift(); - lock = true; - #if hl - func(() -> { - lock = false; - this._resourcesLoaded++; - }); - #end - #if js - func(() -> { - lock = false; - this._resourcesLoaded++; - }); - #end + if (Settings.optionsSettings.fastLoad) { + #if hl + while (this.resourceLoadFuncs.length != 0) { + var func = this.resourceLoadFuncs.shift(); + lock = true; + func(() -> { + lock = false; + this._resourcesLoaded++; + }); + } + #end + #if js + lock = true; + + var func = this.resourceLoadFuncs.shift(); + + var consumeFn; + consumeFn = () -> { + this._resourcesLoaded++; + if (this.resourceLoadFuncs.length != 0) { + var fn = this.resourceLoadFuncs.shift(); + fn(consumeFn); + } else { + lock = false; + } + } + + func(consumeFn); + #end + } else { + var func = this.resourceLoadFuncs.shift(); + lock = true; + #if hl + func(() -> { + lock = false; + this._resourcesLoaded++; + }); + #end + #if js + func(() -> { + lock = false; + this._resourcesLoaded++; + }); + #end + } } else { if (!this._loadBegin || lock) return; diff --git a/src/Settings.hx b/src/Settings.hx index e477a2d3..c1ac37b1 100644 --- a/src/Settings.hx +++ b/src/Settings.hx @@ -136,7 +136,7 @@ class Settings { rewindTimescale: 1.0, reflectionDetail: 2, maxPixelRatio: 1, - vsync: true, + vsync: false, huntRandom: false, fastLoad: false }; diff --git a/src/gui/MiscOptionsGui.hx b/src/gui/MiscOptionsGui.hx index c898a807..1912ba0c 100644 --- a/src/gui/MiscOptionsGui.hx +++ b/src/gui/MiscOptionsGui.hx @@ -83,13 +83,13 @@ class MiscOptionsGui extends GuiImage { }, 0.5, 118); sgOpt.setCurrentOption(Settings.optionsSettings.huntRandom ? 0 : 1); - #if hl + // #if hl var flOpt = optionCollection.addOption(1, "Fast Loading", ["Disabled", "Enabled"], (idx) -> { Settings.optionsSettings.fastLoad = (idx == 1); return true; }, 0.5, 118); flOpt.setCurrentOption(Settings.optionsSettings.fastLoad ? 1 : 0); - #end + // #end var bottomBar = new GuiControl(); bottomBar.position = new Vector(0, 590);