diff --git a/Project.xml b/Project.xml
index e37a6e9..0a4ea40 100644
--- a/Project.xml
+++ b/Project.xml
@@ -46,6 +46,7 @@
+
@@ -70,11 +71,14 @@
-
+
+
+
+
+
-
diff --git a/README.md b/README.md
index a18f721..4f20358 100644
--- a/README.md
+++ b/README.md
@@ -21,12 +21,19 @@
- Windows 10/11 SDK (any works)
4. run the [install.bat](https://github.com/GuineaPigUuhh/Funkin-NullEngine/blob/main/install-libs/install.bat) file inside the install-libs folder to install the libs that the engine needs
+# Features
+- [x] Modular System
+ - [x] Characters
+ - [x] Menu Characters
+ - [] Weeks (some things are missing)
+ - [x] Stages
+- [x] cool Tolerant Json Lib by [JWambaugh](https://github.com/JWambaugh)
-## To-do
-- [x] a better modular System of Characters, Stages, Weeks and Story Mode Menu Characters
-- [x] A system of Complete Scripts (the script system lacks some variables and some functions)
-- [ ] Folder Organization
-- [ ] Organization in Source Folders
-- [ ] new Editors
-- [ ] Support Mods
-- [x] Better README
\ No newline at end of file
+# To-do
+- [] Custom HUD
+- [] Mod Support
+- [] new Editors
+ - [] Character Editor
+ - [] Stage Editor (Maybe?)
+ - [] Better Chart Editor
+- [] Folder Organization (Source)
\ No newline at end of file
diff --git a/source/Discord.hx b/source/Discord.hx
new file mode 100644
index 0000000..0017761
--- /dev/null
+++ b/source/Discord.hx
@@ -0,0 +1,92 @@
+package;
+
+import Sys.sleep;
+
+using StringTools;
+
+#if DISCORD_ALLOWED
+import discord_rpc.DiscordRpc;
+#end
+
+class DiscordClient
+{
+ #if DISCORD_ALLOWED
+ public function new()
+ {
+ trace("Discord Client starting...");
+ DiscordRpc.start({
+ clientID: "814588678700924999",
+ onReady: onReady,
+ onError: onError,
+ onDisconnected: onDisconnected
+ });
+ trace("Discord Client started.");
+
+ while (true)
+ {
+ DiscordRpc.process();
+ sleep(2);
+ // trace("Discord Client Update");
+ }
+
+ DiscordRpc.shutdown();
+ }
+
+ public static function shutdown()
+ {
+ DiscordRpc.shutdown();
+ }
+
+ static function onReady()
+ {
+ DiscordRpc.presence({
+ details: "In the Menus",
+ state: null,
+ largeImageKey: 'icon',
+ largeImageText: "Friday Night Funkin'"
+ });
+ }
+
+ static function onError(_code:Int, _message:String)
+ {
+ trace('Error! $_code : $_message');
+ }
+
+ static function onDisconnected(_code:Int, _message:String)
+ {
+ trace('Disconnected! $_code : $_message');
+ }
+
+ public static function initialize()
+ {
+ var DiscordDaemon = sys.thread.Thread.create(() ->
+ {
+ new DiscordClient();
+ });
+ trace("Discord Client initialized");
+ }
+
+ public static function changePresence(details:String, state:Null, ?smallImageKey:String, ?hasStartTimestamp:Bool, ?endTimestamp:Float)
+ {
+ var startTimestamp:Float = if (hasStartTimestamp) Date.now().getTime() else 0;
+
+ if (endTimestamp > 0)
+ {
+ endTimestamp = startTimestamp + endTimestamp;
+ }
+
+ DiscordRpc.presence({
+ details: details,
+ state: state,
+ largeImageKey: 'icon',
+ largeImageText: "Friday Night Funkin'",
+ smallImageKey: smallImageKey,
+ // Obtained times are in milliseconds so they are divided so Discord can use it
+ startTimestamp: Std.int(startTimestamp / 1000),
+ endTimestamp: Std.int(endTimestamp / 1000)
+ });
+
+ // trace('Discord RPC Updated. Arguments: $details, $state, $smallImageKey, $hasStartTimestamp, $endTimestamp');
+ }
+ #end
+}
diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx
index ee92e75..1e5c473 100644
--- a/source/FreeplayState.hx
+++ b/source/FreeplayState.hx
@@ -1,6 +1,6 @@
package;
-#if discord_rpc
+#if DISCORD_ALLOWED
import Discord.DiscordClient;
#end
import FNFManager.WeeksManager;
@@ -41,7 +41,7 @@ class FreeplayState extends MusicBeatState
{
WeeksManager.load();
- #if discord_rpc
+ #if DISCORD_ALLOWED
// Updating Discord Rich Presence
DiscordClient.changePresence("In the Menus", null);
#end
diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx
index 525d897..f7d0ed3 100644
--- a/source/MainMenuState.hx
+++ b/source/MainMenuState.hx
@@ -23,7 +23,7 @@ import ui.Prompt;
using StringTools;
-#if discord_rpc
+#if DISCORD_ALLOWED
import Discord.DiscordClient;
#end
#if newgrounds
@@ -39,8 +39,7 @@ class MainMenuState extends MusicBeatState
override function create()
{
- #if discord_rpc
- // Updating Discord Rich Presence
+ #if DISCORD_ALLOWED // Updating Discord Rich Presence
DiscordClient.changePresence("In the Menus", null);
#end
diff --git a/source/PlayState.hx b/source/PlayState.hx
index 1821d77..a805263 100644
--- a/source/PlayState.hx
+++ b/source/PlayState.hx
@@ -51,7 +51,7 @@ import vlc.MP4Handler as FlxVideo; // Haxelib Hxcodec 2.5.1
using StringTools;
-#if discord_rpc
+#if DISCORD_ALLOWED
import Discord.DiscordClient;
#end
@@ -161,7 +161,7 @@ class PlayState extends MusicBeatState
var inCutscene:Bool = false;
- #if discord_rpc
+ #if DISCORD_ALLOWED
// Discord RPC variables
var iconRPC:String = "";
var detailsText:String = "";
@@ -220,7 +220,7 @@ class PlayState extends MusicBeatState
dialogue = CoolUtil.coolTextFile(AssetsHelper.getFilePath('songs/thorns/thornsDialogue', TEXT));
}
- #if discord_rpc
+ #if DISCORD_ALLOWED
initDiscord();
#end
storyDifficultyText = CoolUtil.difficultyString(storyDifficulty);
@@ -904,7 +904,7 @@ class PlayState extends MusicBeatState
function initDiscord():Void
{
- #if discord_rpc
+ #if DISCORD_ALLOWED
iconRPC = SONG.player2;
// To avoid having duplicate images in Discord assets
@@ -1163,7 +1163,7 @@ class PlayState extends MusicBeatState
// Song duration in a float, useful for the time left feature
songLength = FlxG.sound.music.length;
- #if discord_rpc
+ #if DISCORD_ALLOWED
// Updating Discord Rich Presence (with Time Left)
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength);
#end
@@ -1329,7 +1329,7 @@ class PlayState extends MusicBeatState
startTimer.active = true;
paused = false;
- #if discord_rpc
+ #if DISCORD_ALLOWED
if (startTimer.finished)
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength - Conductor.songPosition);
else
@@ -1340,7 +1340,7 @@ class PlayState extends MusicBeatState
super.closeSubState();
}
- #if discord_rpc
+ #if DISCORD_ALLOWED
override public function onFocus():Void
{
if (health > 0 && !paused && FlxG.autoPause)
@@ -1469,7 +1469,7 @@ class PlayState extends MusicBeatState
pauseSubState.camera = camHUD;
boyfriendPos.put();
- #if discord_rpc
+ #if DISCORD_ALLOWED
DiscordClient.changePresence(detailsPausedText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
#end
}
@@ -1478,7 +1478,7 @@ class PlayState extends MusicBeatState
{
FlxG.switchState(new ChartingState());
- #if discord_rpc
+ #if DISCORD_ALLOWED
DiscordClient.changePresence("Chart Editor", null, null, true);
#end
}
@@ -1585,7 +1585,7 @@ class PlayState extends MusicBeatState
// FlxG.switchState(new GameOverState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y));
- #if discord_rpc
+ #if DISCORD_ALLOWED
// Game Over doesn't get his own variable because it's only used here
DiscordClient.changePresence("Game Over - " + detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
#end
diff --git a/source/StoryMenuState.hx b/source/StoryMenuState.hx
index 378c76b..9835aa8 100644
--- a/source/StoryMenuState.hx
+++ b/source/StoryMenuState.hx
@@ -1,6 +1,6 @@
package;
-#if discord_rpc
+#if DISCORD_ALLOWED
import Discord.DiscordClient;
#end
import FNFManager.WeeksManager;
@@ -93,7 +93,7 @@ class StoryMenuState extends MusicBeatState
grpLocks = new FlxTypedGroup();
add(grpLocks);
- #if discord_rpc
+ #if DISCORD_ALLOWED
// Updating Discord Rich Presence
DiscordClient.changePresence("In the Menus", null);
#end