From cb8aa3d17557e8d470da150bd2db1c01a943a680 Mon Sep 17 00:00:00 2001 From: Jakkzero <50273567+Jakkzero@users.noreply.github.com> Date: Fri, 26 Feb 2021 12:27:32 +0000 Subject: [PATCH] Adding updated source files --- source/Discord.hx | 71 +++++++++++++++++++++++++++++++++ source/FreeplayState.hx | 14 +++++-- source/PlayState.hx | 85 +++++++++++++++++++++++----------------- source/StoryMenuState.hx | 7 ++++ source/TitleState.hx | 12 +++++- 5 files changed, 149 insertions(+), 40 deletions(-) create mode 100644 source/Discord.hx diff --git a/source/Discord.hx b/source/Discord.hx new file mode 100644 index 000000000..eb0c1f8d4 --- /dev/null +++ b/source/Discord.hx @@ -0,0 +1,71 @@ +package; + +import discord_rpc.DiscordRpc; +import haxe.Timer; + +using StringTools; + +class DiscordClient +{ + public function new() + { + trace("Discord Client starting..."); + DiscordRpc.start({ + clientID: "814588678700924999", + onReady: onReady, + onError: onError, + onDisconnected: onDisconnected + }); + trace("Discord Client started."); + + while (true) + { + trace("process called"); + DiscordRpc.process(); + trace("pre-delay"); + Timer.delay(continue, 2000); + trace("post-delay"); + } + + 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) + { + DiscordRpc.presence({ + details: details, + state: state, + largeImageKey: 'icon', + largeImageText: "Friday Night Funkin'" + }); + } +} diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index f8bb333e9..789897b20 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -1,5 +1,8 @@ package; +#if !html +import Discord.DiscordClient; +#end import flash.text.TextField; import flixel.FlxG; import flixel.FlxSprite; @@ -45,6 +48,11 @@ class FreeplayState extends MusicBeatState } */ + #if !html + // Updating Discord Rich Presence + DiscordClient.changePresence("In the menus.", null); + #end + var isDebug:Bool = false; #if debug @@ -229,9 +237,9 @@ class FreeplayState extends MusicBeatState function changeSelection(change:Int = 0) { - #if !switch - NGio.logEvent('Fresh'); - #end + // #if !switch + // NGio.logEvent('Fresh'); + // #end // NGio.logEvent('Fresh'); FlxG.sound.play(Paths.sound('scrollMenu'), 0.4); diff --git a/source/PlayState.hx b/source/PlayState.hx index aabb992f5..0356dd58a 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1,5 +1,8 @@ package; +#if !html +import Discord.DiscordClient; +#end import Section.SwagSection; import Song.SwagSong; import WiggleEffect.WiggleEffectType; @@ -124,7 +127,6 @@ class PlayState extends MusicBeatState override public function create() { - if (FlxG.sound.music != null) FlxG.sound.music.stop(); @@ -174,6 +176,29 @@ class PlayState extends MusicBeatState dialogue = CoolUtil.coolTextFile(Paths.txt('thorns/thornsDialogue')); } + #if !html + // Making difficulty text for Discord Rich Presence. + var storyDifficultyText = ""; + switch (storyDifficulty) + { + case 0: + storyDifficultyText = "Easy"; + case 1: + storyDifficultyText = "Normal"; + case 2: + storyDifficultyText = "Hard"; + } + // Updating Discord Rich Presence. + if (isStoryMode) + { + DiscordClient.changePresence("Story Mode: Week " + storyWeek, SONG.song + " (" + storyDifficultyText + ")"); + } + else + { + DiscordClient.changePresence("Freeplay", SONG.song + " (" + storyDifficultyText + ")"); + } + #end + if (SONG.song.toLowerCase() == 'spookeez' || SONG.song.toLowerCase() == 'monster' || SONG.song.toLowerCase() == 'south') { curStage = "spooky"; @@ -870,16 +895,8 @@ class PlayState extends MusicBeatState var introAssets:Map> = new Map>(); introAssets.set('default', ['ready', "set", "go"]); - introAssets.set('school', [ - 'weeb/pixelUI/ready-pixel', - 'weeb/pixelUI/set-pixel', - 'weeb/pixelUI/date-pixel' - ]); - introAssets.set('schoolEvil', [ - 'weeb/pixelUI/ready-pixel', - 'weeb/pixelUI/set-pixel', - 'weeb/pixelUI/date-pixel' - ]); + introAssets.set('school', ['weeb/pixelUI/ready-pixel', 'weeb/pixelUI/set-pixel', 'weeb/pixelUI/date-pixel']); + introAssets.set('schoolEvil', ['weeb/pixelUI/ready-pixel', 'weeb/pixelUI/set-pixel', 'weeb/pixelUI/date-pixel']); var introAlts:Array = introAssets.get('default'); var altSuffix:String = ""; @@ -1059,9 +1076,7 @@ class PlayState extends MusicBeatState { swagNote.x += FlxG.width / 2; // general offset } - else - { - } + else {} } daBeats += 1; } @@ -1920,29 +1935,29 @@ class PlayState extends MusicBeatState */ // trace(daNote.noteData); /* - switch (daNote.noteData) + switch (daNote.noteData) + { + case 2: // NOTES YOU JUST PRESSED + if (upP || rightP || downP || leftP) + noteCheck(upP, daNote); + case 3: + if (upP || rightP || downP || leftP) + noteCheck(rightP, daNote); + case 1: + if (upP || rightP || downP || leftP) + noteCheck(downP, daNote); + case 0: + if (upP || rightP || downP || leftP) + noteCheck(leftP, daNote); + } + + //this is already done in noteCheck / goodNoteHit + if (daNote.wasGoodHit) { - case 2: // NOTES YOU JUST PRESSED - if (upP || rightP || downP || leftP) - noteCheck(upP, daNote); - case 3: - if (upP || rightP || downP || leftP) - noteCheck(rightP, daNote); - case 1: - if (upP || rightP || downP || leftP) - noteCheck(downP, daNote); - case 0: - if (upP || rightP || downP || leftP) - noteCheck(leftP, daNote); + daNote.kill(); + notes.remove(daNote, true); + daNote.destroy(); } - - //this is already done in noteCheck / goodNoteHit - if (daNote.wasGoodHit) - { - daNote.kill(); - notes.remove(daNote, true); - daNote.destroy(); - } */ } else diff --git a/source/StoryMenuState.hx b/source/StoryMenuState.hx index 1156ccade..0e4b06558 100644 --- a/source/StoryMenuState.hx +++ b/source/StoryMenuState.hx @@ -1,5 +1,8 @@ package; +#if !html +import Discord.DiscordClient; +#end import flixel.FlxG; import flixel.FlxSprite; import flixel.addons.transition.FlxTransitionableState; @@ -109,6 +112,10 @@ class StoryMenuState extends MusicBeatState add(grpLocks); trace("Line 70"); + #if !html + // Updating Discord Rich Presence + DiscordClient.changePresence("In the menus.", null); + #end for (i in 0...weekData.length) { diff --git a/source/TitleState.hx b/source/TitleState.hx index 3a3041678..842e37fbf 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -1,5 +1,8 @@ package; +#if !html5 +import Discord.DiscordClient; +#end import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; @@ -23,6 +26,7 @@ import flixel.util.FlxTimer; import io.newgrounds.NG; import lime.app.Application; import openfl.Assets; +import sys.thread.Thread; using StringTools; @@ -45,7 +49,7 @@ class TitleState extends MusicBeatState #if polymod polymod.Polymod.init({modRoot: "mods", dirs: ['introMod']}); #end - + PlayerSettings.init(); curWacky = FlxG.random.getObject(getIntroTextShit()); @@ -89,6 +93,10 @@ class TitleState extends MusicBeatState startIntro(); }); #end + + #if !html + DiscordClient.initialize(); + #end } var logoBl:FlxSprite; @@ -282,12 +290,12 @@ class TitleState extends MusicBeatState if (version.trim() != NGio.GAME_VER_NUMS.trim() && !OutdatedSubState.leftState) { + FlxG.switchState(new OutdatedSubState()); trace('OLD VERSION!'); trace('old ver'); trace(version.trim()); trace('cur ver'); trace(NGio.GAME_VER_NUMS.trim()); - FlxG.switchState(new OutdatedSubState()); } else {