Merge branch 'new-editors' into zoro-charterstuffs
This commit is contained in:
@@ -5,7 +5,7 @@ import openfl.display.BitmapData;
|
||||
import openfl.geom.Point;
|
||||
import openfl.geom.Rectangle;
|
||||
|
||||
class BitmapUtil {
|
||||
final class BitmapUtil {
|
||||
/**
|
||||
* Returns the most present color in a Bitmap.
|
||||
* @param bmap Bitmap
|
||||
|
||||
@@ -42,7 +42,7 @@ import flixel.math.FlxPoint;
|
||||
using StringTools;
|
||||
|
||||
@:allow(funkin.game.PlayState)
|
||||
class CoolUtil
|
||||
final class CoolUtil
|
||||
{
|
||||
public static function getLastExceptionStack():String {
|
||||
return CallStack.toString(CallStack.exceptionStack());
|
||||
|
||||
@@ -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
|
||||
@@ -16,7 +17,7 @@ import lime.app.Application;
|
||||
import sys.thread.Thread;
|
||||
#end
|
||||
|
||||
class DiscordUtil
|
||||
final class DiscordUtil
|
||||
{
|
||||
public static var currentID(default, set):String = null;
|
||||
public static var discordThread:#if DISCORD_RPC Thread #else Dynamic #end = null;
|
||||
@@ -107,14 +108,28 @@ class DiscordUtil
|
||||
|
||||
public static function loadScript()
|
||||
{
|
||||
#if DISCORD_RPC
|
||||
if (script != null)
|
||||
{
|
||||
call("destroy");
|
||||
script = FlxDestroyUtil.destroy(script);
|
||||
}
|
||||
script = Script.create(Paths.script('data/discord'));
|
||||
script.set("ActivityType", {
|
||||
Playing: ActivityType.Playing,
|
||||
PLAYING: ActivityType.Playing,
|
||||
Streaming: ActivityType.Streaming,
|
||||
STREAMING: ActivityType.Streaming,
|
||||
Watching: ActivityType.Watching,
|
||||
WATCHING: ActivityType.Watching,
|
||||
Listening: ActivityType.Listening,
|
||||
LISTENING: ActivityType.Listening,
|
||||
Competing: ActivityType.Competing,
|
||||
COMPETING: ActivityType.Competing
|
||||
});
|
||||
// script.setParent(DiscordUtil);
|
||||
script.load();
|
||||
#end
|
||||
}
|
||||
|
||||
public static function changePresence(details:String, state:String, ?smallImageKey:String)
|
||||
@@ -218,6 +233,8 @@ class DiscordUtil
|
||||
Utils.safeSetWrapper(dp.joinSecret, data.joinSecret, fixString);
|
||||
Utils.safeSetWrapper(dp.spectateSecret, data.spectateSecret, fixString);
|
||||
Utils.safeSet(dp.instance, data.instance);
|
||||
Utils.safeSet(dp.activityType, data.activityType);
|
||||
Utils.safeSetWrapper(dp.streamUrl, data.streamUrl, fixString);
|
||||
if (data.matchSecret == null && data.joinSecret == null && data.spectateSecret == null)
|
||||
{
|
||||
Utils.safeSetWrapper(dp.button1Label, data.button1Label, fixString);
|
||||
@@ -252,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;
|
||||
|
||||
@@ -351,7 +369,38 @@ class DiscordUtil
|
||||
var req:DUser = DUser.initRaw(request);
|
||||
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
|
||||
|
||||
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 =
|
||||
@@ -476,6 +525,8 @@ typedef DPresence =
|
||||
var ?button1Url:String; /* max 512 bytes */
|
||||
var ?button2Label:String; /* max 32 bytes */
|
||||
var ?button2Url:String; /* max 512 bytes */
|
||||
var ?activityType:ActivityType;
|
||||
var ?streamUrl:String; /* max 512 bytes */
|
||||
}
|
||||
|
||||
typedef DEvents =
|
||||
|
||||
@@ -4,7 +4,7 @@ import flixel.util.FlxColor;
|
||||
import flixel.math.FlxAngle;
|
||||
import flixel.math.FlxPoint;
|
||||
|
||||
class DrawUtil {
|
||||
final class DrawUtil {
|
||||
public static var line:FlxSprite = null;
|
||||
public static var dot:FlxSprite = null;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package funkin.backend.utils;
|
||||
import funkin.backend.scripting.MultiThreadedScript;
|
||||
import funkin.backend.scripting.Script;
|
||||
|
||||
class EngineUtil {
|
||||
final class EngineUtil {
|
||||
/**
|
||||
* Starts a new multithreaded script.
|
||||
* This script will share all the variables with the current one, which means already existing callbacks will be replaced by new ones on conflict.
|
||||
|
||||
@@ -2,7 +2,7 @@ package funkin.backend.utils;
|
||||
|
||||
import haxe.Http;
|
||||
|
||||
class HttpUtil
|
||||
final class HttpUtil
|
||||
{
|
||||
public static var userAgent:String = "request";
|
||||
public static function requestText(url:String)
|
||||
|
||||
@@ -3,7 +3,7 @@ package funkin.backend.utils;
|
||||
/**
|
||||
* DOESNT SUPPORT CATEGORIES YET!!
|
||||
*/
|
||||
class IniUtil {
|
||||
final class IniUtil {
|
||||
public static inline function parseAsset(assetPath:String, ?defaultVariables:Map<String, String>)
|
||||
return parseString(Assets.getText(assetPath), defaultVariables);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package funkin.backend.utils;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.util.FlxColor;
|
||||
|
||||
class MarkdownUtil {
|
||||
final class MarkdownUtil {
|
||||
public static function applyMarkdownText(text:FlxText, str:String) {
|
||||
text.textField.htmlText = Markdown.markdownToHtml(prepareMarkdown(str));
|
||||
var changes:Array<FlxTextFormatMarkerPair> = [
|
||||
|
||||
@@ -2,7 +2,7 @@ package funkin.backend.utils;
|
||||
|
||||
import haxe.macro.Expr;
|
||||
|
||||
class MathUtil {
|
||||
final class MathUtil {
|
||||
/**
|
||||
* Returns the maximum value in the arguments.
|
||||
* @param args Array of values
|
||||
|
||||
@@ -9,7 +9,7 @@ interface IPrePostDraw {
|
||||
public function postDraw():Void;
|
||||
}
|
||||
|
||||
class MatrixUtil {
|
||||
final class MatrixUtil {
|
||||
public static function getMatrixPosition(sprite:FlxSprite, points:OneOfTwo<FlxPoint, Array<FlxPoint>>, ?camera:FlxCamera, _width:Float = 1, _height:Float = 1):Array<FlxPoint>
|
||||
{
|
||||
//if(_width == -1) _width = sprite.width;
|
||||
|
||||
@@ -14,7 +14,7 @@ import openfl.system.System;
|
||||
|
||||
using StringTools;
|
||||
|
||||
class MemoryUtil {
|
||||
final class MemoryUtil {
|
||||
public static var disableCount:Int = 0;
|
||||
|
||||
public static function askDisable() {
|
||||
|
||||
@@ -14,7 +14,7 @@ package funkin.backend.utils;
|
||||
* - The Function cannot be found in the NDLL
|
||||
* then an empty function will be returned instead, and a message will be shown in logs.
|
||||
*/
|
||||
class NdllUtil {
|
||||
final class NdllUtil {
|
||||
#if NDLLS_SUPPORTED
|
||||
#if windows public static final os:String = "windows"; #end
|
||||
#if linux public static final os:String = "linux"; #end
|
||||
|
||||
@@ -2,7 +2,7 @@ package funkin.backend.utils;
|
||||
|
||||
import openfl.display.Sprite;
|
||||
|
||||
class ShaderResizeFix {
|
||||
final class ShaderResizeFix {
|
||||
public static var doResizeFix:Bool = true;
|
||||
|
||||
public static function init() {
|
||||
|
||||
@@ -3,7 +3,7 @@ package funkin.backend.utils;
|
||||
/**
|
||||
* All types of utils only usable in a sorted array.
|
||||
*/
|
||||
class SortedArrayUtil {
|
||||
final class SortedArrayUtil {
|
||||
/**
|
||||
* Gets the index of a possible new element of an Array of T using an efficient algorithm.
|
||||
* @param array Array of T to check in
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package funkin.backend.utils;
|
||||
|
||||
#if ALLOW_MULTITHREADING
|
||||
class ThreadUtil {
|
||||
final class ThreadUtil {
|
||||
/**
|
||||
* Creates a new Thread with an error handler.
|
||||
* @param func Function to execute
|
||||
|
||||
@@ -2,7 +2,7 @@ package funkin.backend.utils;
|
||||
|
||||
import openfl.Lib;
|
||||
|
||||
class WindowUtils {
|
||||
final class WindowUtils {
|
||||
public static var winTitle(default, set):String;
|
||||
private static function set_winTitle(value:String):String {
|
||||
winTitle = value;
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef TextFormat = { text:String, format:Dynamic }
|
||||
/**
|
||||
* Class made to make XML parsing easier.
|
||||
*/
|
||||
class XMLUtil {
|
||||
final class XMLUtil {
|
||||
|
||||
/**
|
||||
* Applies a property XML node to an object.
|
||||
|
||||
@@ -23,7 +23,7 @@ using StringTools;
|
||||
// import ZipUtils; ZipUtils.uncompressZip(ZipUtils.openZip("E:\\Desktop\\test\\termination lua.ycemod"), "E:\\Desktop\\test\\uncompressed\\");
|
||||
// import ZipUtils; var e = ZipUtils.createZipFile("gjnsdghs.ycemod"); ZipUtils.writeFolderToZip(e, "./mods/Friday Night Funkin'/", "Friday Night Funkin'/"); e.flush(); e.close();
|
||||
|
||||
class ZipUtil {
|
||||
final class ZipUtil {
|
||||
public static var bannedNames:Array<String> = [".git", ".gitignore", ".github", ".vscode", ".gitattributes", "readme.txt"];
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,8 @@ package funkin.backend.utils.native;
|
||||
|
||||
#if linux
|
||||
@:cppFileCode("#include <stdio.h>")
|
||||
class Linux {
|
||||
@:dox(hide)
|
||||
final class Linux {
|
||||
@:functionCode('
|
||||
FILE *meminfo = fopen("/proc/meminfo", "r");
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ import funkin.backend.utils.NativeAPI.CodeCursor;
|
||||
import openfl.ui.Mouse;
|
||||
|
||||
@:headerInclude('sys/sysctl.h')
|
||||
class Mac
|
||||
@:dox(hide)
|
||||
final class Mac
|
||||
{
|
||||
@:functionCode('
|
||||
int mib [] = { CTL_HW, HW_MEMSIZE };
|
||||
|
||||
@@ -114,7 +114,7 @@ class AudioFixClient : public IMMNotificationClient {
|
||||
AudioFixClient *curAudioFix;
|
||||
')
|
||||
@:dox(hide)
|
||||
class Windows {
|
||||
final class Windows {
|
||||
|
||||
public static var __audioChangeCallback:Void->Void = function() {
|
||||
trace("test");
|
||||
|
||||
Reference in New Issue
Block a user