From 21bf0c0a3799f7cefdf4d849d786e997d349394a Mon Sep 17 00:00:00 2001 From: Frakits Date: Sat, 3 Aug 2024 14:28:21 +0300 Subject: [PATCH 01/10] easier to softcode healthicons --- source/funkin/game/HealthIcon.hx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/funkin/game/HealthIcon.hx b/source/funkin/game/HealthIcon.hx index d55bf14b..92c38b8a 100644 --- a/source/funkin/game/HealthIcon.hx +++ b/source/funkin/game/HealthIcon.hx @@ -24,6 +24,11 @@ class HealthIcon extends FlxSprite */ public var healthSteps:Map = null; + /** + * current animation state + */ + public var curAnimState:Int = -1; + /** * Helper for HScript who can't make maps * @param steps Something like this: `[[0, 1], [20, 0]]` @@ -91,7 +96,14 @@ class HealthIcon extends FlxSprite i = icon; } } - if (i >= 0) animation.curAnim.curFrame = i; + if (i >= 0 && curAnimState != i) { + var event = EventManager.get(funkin.backend.scripting.events.AmountEvent).recycle(i); + funkin.backend.scripting.GlobalScript.event("onHealthIconAnimChange", event); + if (!event.cancelled) + animation.curAnim.curFrame = event.amount; + + curAnimState = event.amount; + } } } } From 67e965fbf9a5b3060bddb775951b9985885d2508 Mon Sep 17 00:00:00 2001 From: Frakits Date: Sat, 3 Aug 2024 15:04:16 +0300 Subject: [PATCH 02/10] oops --- .../scripting/events/HealthIconChangeEvent.hx | 13 +++++++++++++ source/funkin/game/HealthIcon.hx | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 source/funkin/backend/scripting/events/HealthIconChangeEvent.hx diff --git a/source/funkin/backend/scripting/events/HealthIconChangeEvent.hx b/source/funkin/backend/scripting/events/HealthIconChangeEvent.hx new file mode 100644 index 00000000..93a2a7dd --- /dev/null +++ b/source/funkin/backend/scripting/events/HealthIconChangeEvent.hx @@ -0,0 +1,13 @@ +package source.funkin.backend.scripting.events; + +final class AmountEvent extends CancellableEvent { + /** + * Amount + */ + public var amount:Int; + + /** + * The health icon + */ + public var healthIcon:HealthIcon; +} \ No newline at end of file diff --git a/source/funkin/game/HealthIcon.hx b/source/funkin/game/HealthIcon.hx index 92c38b8a..1c7bb59d 100644 --- a/source/funkin/game/HealthIcon.hx +++ b/source/funkin/game/HealthIcon.hx @@ -97,7 +97,7 @@ class HealthIcon extends FlxSprite } } if (i >= 0 && curAnimState != i) { - var event = EventManager.get(funkin.backend.scripting.events.AmountEvent).recycle(i); + var event = EventManager.get(funkin.backend.scripting.events.HealthIconChangeEvent).recycle(i, this); funkin.backend.scripting.GlobalScript.event("onHealthIconAnimChange", event); if (!event.cancelled) animation.curAnim.curFrame = event.amount; From 8b0d3c77204eeabab0886039c58af17a8e5c2a62 Mon Sep 17 00:00:00 2001 From: Frakits Date: Sat, 3 Aug 2024 15:21:45 +0300 Subject: [PATCH 03/10] oops --- .../backend/scripting/events/HealthIconChangeEvent.hx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/funkin/backend/scripting/events/HealthIconChangeEvent.hx b/source/funkin/backend/scripting/events/HealthIconChangeEvent.hx index 93a2a7dd..a98493ef 100644 --- a/source/funkin/backend/scripting/events/HealthIconChangeEvent.hx +++ b/source/funkin/backend/scripting/events/HealthIconChangeEvent.hx @@ -1,6 +1,6 @@ -package source.funkin.backend.scripting.events; +package funkin.backend.scripting.events; -final class AmountEvent extends CancellableEvent { +final class HealthIconChangeEvent extends CancellableEvent { /** * Amount */ @@ -9,5 +9,5 @@ final class AmountEvent extends CancellableEvent { /** * The health icon */ - public var healthIcon:HealthIcon; + public var healthIcon:funkin.game.HealthIcon; } \ No newline at end of file From 087959018bdb6ad39e675ef8b8a5e59ac54176d8 Mon Sep 17 00:00:00 2001 From: Frakits Date: Sat, 3 Aug 2024 15:42:43 +0300 Subject: [PATCH 04/10] oops --- source/funkin/game/HealthIcon.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/game/HealthIcon.hx b/source/funkin/game/HealthIcon.hx index 1c7bb59d..a7706a86 100644 --- a/source/funkin/game/HealthIcon.hx +++ b/source/funkin/game/HealthIcon.hx @@ -50,12 +50,12 @@ class HealthIcon extends FlxSprite public function new(char:String = 'bf', isPlayer:Bool = false) { - super(); health = 0.5; this.isPlayer = isPlayer; setIcon(char); scrollFactor.set(); + super(); } public function setIcon(char:String, width:Int = 150, height:Int = 150) { From 8a7917fce25a3c9eb57d9761cd67707c87574f12 Mon Sep 17 00:00:00 2001 From: Frakits Date: Sat, 3 Aug 2024 16:50:30 +0300 Subject: [PATCH 05/10] make my life easier --- source/funkin/game/HealthIcon.hx | 2 +- source/funkin/game/SplashHandler.hx | 5 ++++- source/funkin/game/Strum.hx | 2 ++ source/funkin/game/StrumLine.hx | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/funkin/game/HealthIcon.hx b/source/funkin/game/HealthIcon.hx index a7706a86..1c7bb59d 100644 --- a/source/funkin/game/HealthIcon.hx +++ b/source/funkin/game/HealthIcon.hx @@ -50,12 +50,12 @@ class HealthIcon extends FlxSprite public function new(char:String = 'bf', isPlayer:Bool = false) { + super(); health = 0.5; this.isPlayer = isPlayer; setIcon(char); scrollFactor.set(); - super(); } public function setIcon(char:String, width:Int = 150, height:Int = 150) { diff --git a/source/funkin/game/SplashHandler.hx b/source/funkin/game/SplashHandler.hx index dc6f7533..78ed86ce 100644 --- a/source/funkin/game/SplashHandler.hx +++ b/source/funkin/game/SplashHandler.hx @@ -40,7 +40,10 @@ class SplashHandler extends FlxTypedGroup { var __grp:SplashGroup; public function showSplash(name:String, strum:Strum) { __grp = getSplashGroup(name); - add(__grp.showOnStrum(strum)); + var event = funkin.backend.scripting.EventManager.get(funkin.backend.scripting.events.DynamicEvent).recycle(__grp.showOnStrum(strum), strum); + event = PlayState.instance.scripts.event("onSplashShown", event); + if (!event.cancelled) + add(__grp.showOnStrum(strum)); // max 8 rendered splashes while(members.length > 8) diff --git a/source/funkin/game/Strum.hx b/source/funkin/game/Strum.hx index 0e179f71..5a0299d8 100644 --- a/source/funkin/game/Strum.hx +++ b/source/funkin/game/Strum.hx @@ -14,6 +14,8 @@ class Strum extends FlxSprite { public var cpu = false; // Unused public var lastHit:Float = -5000; + public var strumLine = null; + public var scrollSpeed:Null = null; // custom scroll speed per strum public var noteAngle:Null = null; diff --git a/source/funkin/game/StrumLine.hx b/source/funkin/game/StrumLine.hx index d743dd79..e00e58f8 100644 --- a/source/funkin/game/StrumLine.hx +++ b/source/funkin/game/StrumLine.hx @@ -303,6 +303,7 @@ class StrumLine extends FlxTypedGroup { animPrefix = strumAnimPrefix[i % strumAnimPrefix.length]; var babyArrow:Strum = new Strum(startingPos.x + ((Note.swagWidth * strumScale) * i), startingPos.y); babyArrow.ID = i; + babyArrow.strumLine = this; if(data.scrollSpeed != null) babyArrow.scrollSpeed = data.scrollSpeed; From 82d50e50c8416e377abcd3d5276f2e69023e90f3 Mon Sep 17 00:00:00 2001 From: Frakits Date: Sat, 3 Aug 2024 16:53:38 +0300 Subject: [PATCH 06/10] PLLELASEEEEEEE --- source/funkin/game/SplashHandler.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/game/SplashHandler.hx b/source/funkin/game/SplashHandler.hx index 78ed86ce..1776bdb8 100644 --- a/source/funkin/game/SplashHandler.hx +++ b/source/funkin/game/SplashHandler.hx @@ -43,7 +43,7 @@ class SplashHandler extends FlxTypedGroup { var event = funkin.backend.scripting.EventManager.get(funkin.backend.scripting.events.DynamicEvent).recycle(__grp.showOnStrum(strum), strum); event = PlayState.instance.scripts.event("onSplashShown", event); if (!event.cancelled) - add(__grp.showOnStrum(strum)); + add(event.value1); // max 8 rendered splashes while(members.length > 8) From 6aaa9e1421230ef10eced39890fce4720ce09eac Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Mon, 5 Aug 2024 18:52:12 +0200 Subject: [PATCH 07/10] Fix bug with autoplay --- source/funkin/menus/FreeplayState.hx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/funkin/menus/FreeplayState.hx b/source/funkin/menus/FreeplayState.hx index 7eeef342..3d3a4d15 100644 --- a/source/funkin/menus/FreeplayState.hx +++ b/source/funkin/menus/FreeplayState.hx @@ -196,6 +196,10 @@ class FreeplayState extends MusicBeatState * Path to the currently playing song instrumental. */ public var curPlayingInst:String = null; + /** + * If it should play the song automatically. + */ + public var autoplayShouldPlay:Bool = true; #end override function update(elapsed:Float) @@ -236,7 +240,17 @@ class FreeplayState extends MusicBeatState autoplayElapsed += elapsed; if (!disableAutoPlay && !songInstPlaying && (autoplayElapsed > timeUntilAutoplay || FlxG.keys.justPressed.SPACE)) { if (curPlayingInst != (curPlayingInst = Paths.inst(songs[curSelected].name, songs[curSelected].difficulties[curDifficulty]))) { - var huh:Void->Void = function() FlxG.sound.playMusic(curPlayingInst, 0); + var huh:Void->Void = function() { + var soundPath = curPlayingInst; + var sound = null; + if (Assets.exists(soundPath, SOUND) || Assets.exists(soundPath, MUSIC)) + sound = Assets.getSound(soundPath); + else + FlxG.log.error('Could not find a Sound asset with an ID of \'$soundPath\'.'); + + if (sound != null && autoplayShouldPlay) + FlxG.sound.playMusic(sound, 0); + } if(!disableAsyncLoading) Main.execAsync(huh); else huh(); } @@ -289,6 +303,10 @@ class FreeplayState extends MusicBeatState if (event.cancelled) return; + #if PRELOAD_ALL + autoplayShouldPlay = false; + #end + Options.freeplayLastSong = songs[curSelected].name; Options.freeplayLastDifficulty = songs[curSelected].difficulties[curDifficulty]; From 363f82860d302032f39d6b352ce95937b86719ab Mon Sep 17 00:00:00 2001 From: haven <85509162+cookiesock@users.noreply.github.com> Date: Tue, 6 Aug 2024 12:01:43 -0500 Subject: [PATCH 08/10] character and stage type for events --- source/funkin/backend/chart/EventsData.hx | 4 ++++ .../funkin/editors/charter/CharterEventScreen.hx | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/source/funkin/backend/chart/EventsData.hx b/source/funkin/backend/chart/EventsData.hx index 05f35bde..eff3fd8e 100644 --- a/source/funkin/backend/chart/EventsData.hx +++ b/source/funkin/backend/chart/EventsData.hx @@ -70,6 +70,8 @@ class EventsData { hscriptInterp.variables.set("StrumLine", TStrumLine); hscriptInterp.variables.set("ColorWheel", TColorWheel); hscriptInterp.variables.set("DropDown", Reflect.makeVarArgs((args) -> {return args.length > 0 ? TDropDown([for (arg in args) Std.string(arg)]) : TDropDown(["null"]);})); + hscriptInterp.variables.set("Character", TCharacter); + hscriptInterp.variables.set("Stage", TStage); var hscriptParser:Parser = new Parser(); hscriptParser.allowJSON = hscriptParser.allowMetadata = false; @@ -127,4 +129,6 @@ enum EventParamType { TStrumLine; TColorWheel; TDropDown(?options:Array); + TCharacter; + TStage; } diff --git a/source/funkin/editors/charter/CharterEventScreen.hx b/source/funkin/editors/charter/CharterEventScreen.hx index ec9ce660..20d84715 100644 --- a/source/funkin/editors/charter/CharterEventScreen.hx +++ b/source/funkin/editors/charter/CharterEventScreen.hx @@ -5,6 +5,8 @@ import flixel.util.FlxColor; import funkin.backend.chart.ChartData.ChartEvent; import funkin.backend.chart.EventsData; import funkin.backend.system.Conductor; +import funkin.game.Character; +import funkin.game.Stage; using StringTools; @@ -163,6 +165,20 @@ class CharterEventScreen extends UISubstateWindow { var dropdown = new UIDropDown(eventName.x, y, 320, 32, options, Std.int(Math.abs(options.indexOf(cast value)))); paramsPanel.add(dropdown); paramsFields.push(dropdown); dropdown; + case TCharacter: + addLabel(); + var charFileList = Character.getList(false); + var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x, y, cast value); + textBox.suggestItems = charFileList; + paramsPanel.add(textBox); paramsFields.push(textBox); + textBox; + case TStage: + addLabel(); + var stageFileList = Stage.getList(false); + var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x, y, cast value); + textBox.suggestItems = stageFileList; + paramsPanel.add(textBox); paramsFields.push(textBox); + textBox; default: paramsFields.push(null); null; From 3ee946fe031f8986fde2d354b0fc48102d11d7de Mon Sep 17 00:00:00 2001 From: haven <85509162+cookiesock@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:28:53 -0500 Subject: [PATCH 09/10] death counter now increments lj saved codename engine from demise by reporting death counter bug --- source/funkin/game/PlayState.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 20e3ce7b..9bcc2ca6 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1423,6 +1423,8 @@ class PlayState extends MusicBeatState FlxG.sound.music.stop(); for (strumLine in strumLines.members) strumLine.vocals.stop(); + deathCounter++; + openSubState(new GameOverSubstate(event.x, event.y, event.deathCharID, event.isPlayer, event.gameOverSong, event.lossSFX, event.retrySFX)); scripts.event("onPostGameOver", event); From 7885e1a4c374ebe4d6ea1a5ca7db527a499c8c00 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Sat, 10 Aug 2024 14:42:38 +0200 Subject: [PATCH 10/10] Added activityType to Discord --- .../funkin/backend/system/macros/BuildInfo.hx | 1 + source/funkin/backend/utils/DiscordUtil.hx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/source/funkin/backend/system/macros/BuildInfo.hx b/source/funkin/backend/system/macros/BuildInfo.hx index f86d67e2..5c2afe95 100644 --- a/source/funkin/backend/system/macros/BuildInfo.hx +++ b/source/funkin/backend/system/macros/BuildInfo.hx @@ -5,6 +5,7 @@ using StringTools; #if macro class BuildInfo { public static function printBuildInfo() { + if(haxe.macro.Context.defined("display")) return; var haxeVersion = haxe.macro.Context.definedValue("haxe"); Sys.println('[ BUILD INFO ]'); Sys.println('Haxe Version: ${haxeVersion}'); diff --git a/source/funkin/backend/utils/DiscordUtil.hx b/source/funkin/backend/utils/DiscordUtil.hx index db3c20c4..1b96071b 100644 --- a/source/funkin/backend/utils/DiscordUtil.hx +++ b/source/funkin/backend/utils/DiscordUtil.hx @@ -107,14 +107,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 +232,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); @@ -476,6 +492,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 =