From 9504af3ae6e0d5bf5f1f7e46ecd272a46d39e8de Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Sat, 10 Aug 2024 16:01:32 +0200 Subject: [PATCH 1/2] Allow more custom stuffs --- .../funkin/backend/scripting/GlobalScript.hx | 4 +++ source/funkin/backend/utils/DiscordUtil.hx | 33 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/source/funkin/backend/scripting/GlobalScript.hx b/source/funkin/backend/scripting/GlobalScript.hx index d2d9323f..1ca88772 100644 --- a/source/funkin/backend/scripting/GlobalScript.hx +++ b/source/funkin/backend/scripting/GlobalScript.hx @@ -11,7 +11,11 @@ import funkin.backend.system.Conductor; class GlobalScript { public static var scripts:ScriptPack; + private static var initalized:Bool = false; + public static function init() { + if(initalized) return; + initalized = true; #if MOD_SUPPORT ModsFolder.onModSwitch.add(onModSwitch); #end diff --git a/source/funkin/backend/utils/DiscordUtil.hx b/source/funkin/backend/utils/DiscordUtil.hx index 1b96071b..0ea8e5b3 100644 --- a/source/funkin/backend/utils/DiscordUtil.hx +++ b/source/funkin/backend/utils/DiscordUtil.hx @@ -1,5 +1,6 @@ package funkin.backend.utils; +import flixel.util.FlxSignal.FlxTypedSignal; import flixel.sound.FlxSound; import flixel.util.typeLimit.OneOfTwo; import funkin.backend.scripting.*; // lazy @@ -268,6 +269,7 @@ class DiscordUtil handlers.joinGame = cpp.Function.fromStaticFunction(onJoin); handlers.joinRequest = cpp.Function.fromStaticFunction(onJoinReq); handlers.spectateGame = cpp.Function.fromStaticFunction(onSpectate); + handlers.anyResponse = cpp.Function.fromStaticFunction(onAnyResponse); Discord.Initialize(id, cpp.RawPointer.addressOf(handlers), 1, null); stopThread = false; @@ -367,7 +369,38 @@ class DiscordUtil var req:DUser = DUser.initRaw(request); call("onJoinRequest", [req]); } + + public static var anyResponse:FlxTypedSignalVoid> = new FlxTypedSignalVoid>(); + + private static function onAnyResponse(data:cpp.ConstCharStar):Void + { + call("onAnyResponse", [data]); + anyResponse.dispatch(data); + } #end + + private static function getUUID():String { + var uuid = new StringBuf(); + for (i in 0...16) { + uuid.add(StringTools.hex(Math.floor(Math.random() * 16), 1)); + } + return uuid.toString(); + } + + public static function sendCustomCommand(data:Dynamic) { + #if DISCORD_RPC + if(data == null) return; + if(data.nonce == null) data.nonce = getUUID(); + var json = Json.stringify(data); + Discord.SendCustomCommand(json); + #end + } + + public static function setDebugMode(mode:Bool) { + #if DISCORD_RPC + Discord.SetDebugMode(mode); + #end + } } typedef DiscordJson = From 66da9eaac0f13582095faa4f48a9ecd1f0906ca8 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Fri, 16 Aug 2024 17:57:16 +0200 Subject: [PATCH 2/2] Disable lime until fork is fixed --- libs.xml | 10 ++++++---- setup-dev-branch.xml | 10 +++++----- setup-dev.xml | 6 +++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/libs.xml b/libs.xml index 0f9139d8..1f966d57 100644 --- a/libs.xml +++ b/libs.xml @@ -5,7 +5,8 @@ - + + @@ -41,11 +42,12 @@ - + + - + --> + diff --git a/setup-dev-branch.xml b/setup-dev-branch.xml index 82c27129..64fb0c03 100644 --- a/setup-dev-branch.xml +++ b/setup-dev-branch.xml @@ -2,7 +2,7 @@ Switching to branch 'time-fix'... - + @@ -12,7 +12,7 @@ Switching to branch 'dev'... - + @@ -20,7 +20,7 @@ Done! Make sure to switch the branch on Codename Engine to 'main' before compiling! - Rebuilding Lime... - - + + + diff --git a/setup-dev.xml b/setup-dev.xml index ba79d790..6299875b 100644 --- a/setup-dev.xml +++ b/setup-dev.xml @@ -27,7 +27,7 @@ - + + - + -->