diff --git a/src/MPCustoms.hx b/src/MPCustoms.hx index 248f55f3..710d0350 100644 --- a/src/MPCustoms.hx +++ b/src/MPCustoms.hx @@ -23,7 +23,7 @@ class MPCustoms { public static function loadMissionList() { if (missionList.length == 0 && !_requestSent) { _requestSent = true; - Http.get("https://marbleblastultra.randomityguy.me/data/ultraCustom.json", (b) -> { + Http.get(Main.isDiscord ? ".proxy/data/ultraCustom.json" : "https://marbleblastultra.randomityguy.me/data/ultraCustom.json", (b) -> { var misList = Json.parse(b.toString()); missionList = misList; missionList.sort((a, b) -> { @@ -42,7 +42,8 @@ class MPCustoms { public static function download(mission:MPCustomEntry, onFinish:() -> Void, onFail:() -> Void) { var lastSlashIdx = mission.path.lastIndexOf('/'); - var dlPath = "https://marbleblastultra.randomityguy.me/" + StringTools.urlEncode(mission.path.substr(0, lastSlashIdx)) + ".zip"; + var dlHost = Main.isDiscord ? ".proxy/" : "https://marbleblastultra.randomityguy.me/"; + var dlPath = dlHost + StringTools.urlEncode(mission.path.substr(0, lastSlashIdx)) + ".zip"; Http.get(dlPath, (zipData) -> { var reader = new Reader(new BytesInput(zipData)); var entries:Array = null; diff --git a/src/Main.hx b/src/Main.hx index 6b4c6968..384e8398 100644 --- a/src/Main.hx +++ b/src/Main.hx @@ -27,6 +27,9 @@ import src.Gamepad; import src.Http; import src.Renderer; import src.MissionList; +import src.Analytics; +import net.MasterServerClient; +import src.Leaderboards; class Main extends hxd.App { var marbleGame:MarbleGame; @@ -35,6 +38,8 @@ class Main extends hxd.App { var frameByFrame:Bool = false; + public static var isDiscord:Bool = false; + // var timeAccumulator:Float = 0.0; override function init() { @@ -50,6 +55,13 @@ class Main extends hxd.App { #end #if js + isDiscord = js.Browser.window.location.href.indexOf("discord") != -1; + if (isDiscord) { + Analytics.setURL(".proxy/analytics/api/send"); + Leaderboards.setHost(".proxy/lb"); + MasterServerClient.setServerIp(".proxy/mbomaster"); + } + var zoomRatio = (Util.isTouchDevice() && !Util.isTablet()) ? js.Browser.window.screen.height * js.Browser.window.devicePixelRatio / 768 : js.Browser.window.devicePixelRatio; // js.Browser.window.devicePixelRatio; if (Util.isIPhone()) zoomRatio = 1.5; diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 36f2fa4f..157bceb9 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -70,8 +70,6 @@ class MarbleGame { var replayExitGui:Class; - var isDiscord:Bool = false; - public function new(scene2d:h2d.Scene, scene:h3d.scene.Scene) { Console.log("Initializing the game..."); canvas = new Canvas(scene2d, cast this); @@ -81,13 +79,6 @@ class MarbleGame { this.touchInput = new TouchInput(); #if js - isDiscord = js.Browser.window.location.href.indexOf("discord.com") != -1; - if (isDiscord) { - Analytics.setURL(".proxy/analytics/api/send"); - Leaderboards.setHost(".proxy/lb"); - MasterServerClient.setServerIp(".proxy/mbomaster"); - } - // Pause shit if (Util.isTouchDevice()) this.touchInput.registerTouchInput(); diff --git a/src/fs/ManifestFileSystem.hx b/src/fs/ManifestFileSystem.hx index 0cdf8849..a57829d2 100644 --- a/src/fs/ManifestFileSystem.hx +++ b/src/fs/ManifestFileSystem.hx @@ -132,7 +132,7 @@ class ManifestEntry extends FileEntry { onReady(); } else { var prefix = ""; - if (MarbleGame.instance.isDiscord) { + if (Main.isDiscord) { prefix = ".proxy/"; }