Allow more custom stuffs
This commit is contained in:
@@ -11,7 +11,11 @@ import funkin.backend.system.Conductor;
|
|||||||
class GlobalScript {
|
class GlobalScript {
|
||||||
public static var scripts:ScriptPack;
|
public static var scripts:ScriptPack;
|
||||||
|
|
||||||
|
private static var initalized:Bool = false;
|
||||||
|
|
||||||
public static function init() {
|
public static function init() {
|
||||||
|
if(initalized) return;
|
||||||
|
initalized = true;
|
||||||
#if MOD_SUPPORT
|
#if MOD_SUPPORT
|
||||||
ModsFolder.onModSwitch.add(onModSwitch);
|
ModsFolder.onModSwitch.add(onModSwitch);
|
||||||
#end
|
#end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package funkin.backend.utils;
|
package funkin.backend.utils;
|
||||||
|
|
||||||
|
import flixel.util.FlxSignal.FlxTypedSignal;
|
||||||
import flixel.sound.FlxSound;
|
import flixel.sound.FlxSound;
|
||||||
import flixel.util.typeLimit.OneOfTwo;
|
import flixel.util.typeLimit.OneOfTwo;
|
||||||
import funkin.backend.scripting.*; // lazy
|
import funkin.backend.scripting.*; // lazy
|
||||||
@@ -268,6 +269,7 @@ final class DiscordUtil
|
|||||||
handlers.joinGame = cpp.Function.fromStaticFunction(onJoin);
|
handlers.joinGame = cpp.Function.fromStaticFunction(onJoin);
|
||||||
handlers.joinRequest = cpp.Function.fromStaticFunction(onJoinReq);
|
handlers.joinRequest = cpp.Function.fromStaticFunction(onJoinReq);
|
||||||
handlers.spectateGame = cpp.Function.fromStaticFunction(onSpectate);
|
handlers.spectateGame = cpp.Function.fromStaticFunction(onSpectate);
|
||||||
|
handlers.anyResponse = cpp.Function.fromStaticFunction(onAnyResponse);
|
||||||
Discord.Initialize(id, cpp.RawPointer.addressOf(handlers), 1, null);
|
Discord.Initialize(id, cpp.RawPointer.addressOf(handlers), 1, null);
|
||||||
stopThread = false;
|
stopThread = false;
|
||||||
|
|
||||||
@@ -367,7 +369,38 @@ final class DiscordUtil
|
|||||||
var req:DUser = DUser.initRaw(request);
|
var req:DUser = DUser.initRaw(request);
|
||||||
call("onJoinRequest", [req]);
|
call("onJoinRequest", [req]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static var anyResponse:FlxTypedSignal<String->Void> = new FlxTypedSignal<String->Void>();
|
||||||
|
|
||||||
|
private static function onAnyResponse(data:cpp.ConstCharStar):Void
|
||||||
|
{
|
||||||
|
call("onAnyResponse", [data]);
|
||||||
|
anyResponse.dispatch(data);
|
||||||
|
}
|
||||||
#end
|
#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 =
|
typedef DiscordJson =
|
||||||
|
|||||||
Reference in New Issue
Block a user