mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-12-24 00:42:46 +00:00
make compatible with discord
This commit is contained in:
parent
efdf4c7002
commit
5fd2fd5c5e
4 changed files with 16 additions and 12 deletions
|
|
@ -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<haxe.zip.Entry> = null;
|
||||
|
|
|
|||
12
src/Main.hx
12
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;
|
||||
|
|
|
|||
|
|
@ -70,8 +70,6 @@ class MarbleGame {
|
|||
|
||||
var replayExitGui:Class<GuiControl>;
|
||||
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ class ManifestEntry extends FileEntry {
|
|||
onReady();
|
||||
} else {
|
||||
var prefix = "";
|
||||
if (MarbleGame.instance.isDiscord) {
|
||||
if (Main.isDiscord) {
|
||||
prefix = ".proxy/";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue