Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
Lets gooo
Browse files Browse the repository at this point in the history
  • Loading branch information
GuineaPigUuhh committed Feb 16, 2024
1 parent 7a19a31 commit e80d1f2
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 27 deletions.
8 changes: 6 additions & 2 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

<define name="MODS_ALLOWED" if="desktop" />
<define name="VIDEOS_ALLOWED" if="desktop || android" />
<define name="DISCORD_ALLOWED" if="desktop" />

<haxedef name="CAN_OPEN_LINKS" unless="switch"/>

Expand All @@ -70,11 +71,14 @@
<haxelib name="flixel-ui" />
<haxelib name="flixel-addons" />

<!-- Null Engine Libraries -->
<!-- Funkin -->
<haxelib name="polymod" if="MODS_ALLOWED"/>
<haxelib name="discord-rpc" if="DISCORD_ALLOWED"/>

<!-- Null Engine -->
<haxelib name="hscript"/>
<haxelib name="flxanimate"/>
<haxelib name="tjson"/>
<haxelib name="polymod" if="MODS_ALLOWED"/>
<haxelib name="hxCodec" if="VIDEOS_ALLOWED"/>

<!-- Debug -->
Expand Down
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
# To-do
- [] Custom HUD
- [] Mod Support
- [] new Editors
- [] Character Editor
- [] Stage Editor (Maybe?)
- [] Better Chart Editor
- [] Folder Organization (Source)
92 changes: 92 additions & 0 deletions source/Discord.hx
Original file line number Diff line number Diff line change
@@ -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<String>, ?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
}
4 changes: 2 additions & 2 deletions source/FreeplayState.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package;

#if discord_rpc
#if DISCORD_ALLOWED
import Discord.DiscordClient;
#end
import FNFManager.WeeksManager;
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions source/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import ui.Prompt;

using StringTools;

#if discord_rpc
#if DISCORD_ALLOWED
import Discord.DiscordClient;
#end
#if newgrounds
Expand All @@ -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

Expand Down
20 changes: 10 additions & 10 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions source/StoryMenuState.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package;

#if discord_rpc
#if DISCORD_ALLOWED
import Discord.DiscordClient;
#end
import FNFManager.WeeksManager;
Expand Down Expand Up @@ -93,7 +93,7 @@ class StoryMenuState extends MusicBeatState
grpLocks = new FlxTypedGroup<FlxSprite>();
add(grpLocks);

#if discord_rpc
#if DISCORD_ALLOWED
// Updating Discord Rich Presence
DiscordClient.changePresence("In the Menus", null);
#end
Expand Down

0 comments on commit e80d1f2

Please sign in to comment.