From fbe3573246d426f63a3f208abb2ce31bd726b02e Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 19:25:44 -0600 Subject: [PATCH 01/14] editable events in titlestate added events for startIntro(), getIntroText(), pressEnter(), and numerous other functions --- source/funkin/menus/TitleState.hx | 186 +++++++++++++++++------------- 1 file changed, 109 insertions(+), 77 deletions(-) diff --git a/source/funkin/menus/TitleState.hx b/source/funkin/menus/TitleState.hx index 4aca30dbf..863f1c7f3 100644 --- a/source/funkin/menus/TitleState.hx +++ b/source/funkin/menus/TitleState.hx @@ -2,6 +2,11 @@ package funkin.menus; import funkin.backend.MusicBeatGroup; import funkin.backend.utils.XMLUtil; +import funkin.backend.scripting.EventManager; +import funkin.backend.scripting.events.StartIntroEvent; +import funkin.backend.scripting.events.NameEvent; +import funkin.backend.scripting.events.EnterPressedEvent; +import funkin.backend.scripting.events.CancellableEvent; import flixel.util.typeLimit.OneOfTwo; import flixel.group.FlxGroup; import flixel.input.gamepad.FlxGamepad; @@ -48,69 +53,77 @@ class TitleState extends MusicBeatState function startIntro() { - if (!initialized) - CoolUtil.playMenuSong(true); + var event = scripts.event("onStartIntro", EventManager.get(StartIntroEvent).recycle(true, true, 'menus/titlescreen/titleEnter', 'newgrounds_logo', false)); + if (!event.cancelled) { + if (!initialized && event.playMenuSong) + CoolUtil.playMenuSong(true); - persistentUpdate = true; + persistentUpdate = true; - var bg:FlxSprite = new FlxSprite().makeSolid(FlxG.width, FlxG.height, FlxColor.BLACK); - add(bg); + var bg:FlxSprite = new FlxSprite().makeSolid(FlxG.width, FlxG.height, FlxColor.BLACK); + add(bg); - #if TITLESCREEN_XML - titleScreenSprites = new MusicBeatGroup(); - add(titleScreenSprites); - loadXML(); - #end + #if TITLESCREEN_XML + if (event.titleScreenXML) { + titleScreenSprites = new MusicBeatGroup(); + add(titleScreenSprites); + loadXML(); + } + #end - if (titleText == null) { - titleText = new FlxSprite(100, FlxG.height * 0.8); - titleText.frames = Paths.getFrames('menus/titlescreen/titleEnter'); - titleText.animation.addByPrefix('idle', "Press Enter to Begin", 24); - titleText.animation.addByPrefix('press', "ENTER PRESSED", 24); - titleText.antialiasing = true; - titleText.animation.play('idle'); - titleText.updateHitbox(); - } - add(titleText); + if (titleText == null) { + titleText = new FlxSprite(100, FlxG.height * 0.8); + titleText.frames = Paths.getFrames(event.titleSprite); + titleText.animation.addByPrefix('idle', "Press Enter to Begin", 24); + titleText.animation.addByPrefix('press', "ENTER PRESSED", 24); + titleText.antialiasing = true; + titleText.animation.play('idle'); + titleText.updateHitbox(); + } + add(titleText); - textGroup = new FlxGroup(); + textGroup = new FlxGroup(); - blackScreen = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK); - add(blackScreen); + blackScreen = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK); + add(blackScreen); - #if !TITLESCREEN_XML - ngSpr = new FlxSprite(0, FlxG.height * 0.52).loadAnimatedGraphic(Paths.image('newgrounds_logo')); - add(ngSpr); - ngSpr.visible = false; - ngSpr.setGraphicSize(Std.int(ngSpr.width * 0.8)); - ngSpr.updateHitbox(); - ngSpr.screenCenter(X); - ngSpr.antialiasing = true; - #end + #if !TITLESCREEN_XML + ngSpr = new FlxSprite(0, FlxG.height * 0.52).loadAnimatedGraphic(Paths.image(event.ngSprite)); + add(ngSpr); + ngSpr.visible = false; + ngSpr.setGraphicSize(Std.int(ngSpr.width * 0.8)); + ngSpr.updateHitbox(); + ngSpr.screenCenter(X); + ngSpr.antialiasing = true; + #end - FlxG.mouse.visible = false; + FlxG.mouse.visible = event.showMouse; - if (initialized) - skipIntro(); - else - initialized = true; + if (initialized) + skipIntro(); + else + initialized = true; - add(textGroup); + add(textGroup); + } } - + public function getIntroTextShit():Array> { - var fullText:String = Assets.getText(Paths.txt('titlescreen/introText')); + var event = scripts.event("onGetIntroText", EventManager.get(NameEvent).recycle('introText')); + if (!event.cancelled) { + var fullText:String = Assets.getText(Paths.txt('titlescreen/${event.name}' || 'titlescreen/introText')); - var firstArray:Array = fullText.split('\n'); - var swagGoodArray:Array> = []; + var firstArray:Array = fullText.split('\n'); + var swagGoodArray:Array> = []; - for (i in firstArray) - { - swagGoodArray.push(i.split('--')); - } + for (i in firstArray) + { + swagGoodArray.push(i.split('--')); + } - return swagGoodArray; + return swagGoodArray; + } } var transitioning:Bool = false; @@ -161,15 +174,18 @@ class TitleState extends MusicBeatState } public function pressEnter() { - titleText.animation.play('press'); + var event = scripts.event("onEnterPressed", EventManager.get(EnterPressedEvent).recycle(true, 0xFFFFFFFF, true, CONFIRM, 2)); + if (!event.cancelled) { + titleText.animation.play('press'); - FlxG.camera.flash(FlxColor.WHITE, 1); - CoolUtil.playMenuSFX(CONFIRM, 0.7); + if (event.flash) FlxG.camera.flash(event.flashColor, 1); + if (event.playSfx) CoolUtil.playMenuSFX(event.menuSound, 0.7); - transitioning = true; - // FlxG.sound.music.stop(); + transitioning = true; + // FlxG.sound.music.stop(); - new FlxTimer().start(2, (_) -> goToMainMenu()); + new FlxTimer().start(event.timerLength, (_) -> goToMainMenu()); + } } function goToMainMenu() { @@ -189,27 +205,40 @@ class TitleState extends MusicBeatState public function createCoolText(textArray:Array) { - for (i=>text in textArray) - { - if (text == "" || text == null) continue; - var money:Alphabet = new Alphabet(0, (i * 60) + 200, text, true, false); - money.screenCenter(X); - textGroup.add(money); + var money:Alphabet; + + var event = scripts.event("onCreateText", new CancellableEvent()); + if (!event.cancelled) { + for (i=>text in textArray) + { + if (text == "" || text == null) continue; + money = new Alphabet(0, (i * 60) + 200, text, true, false); + money.screenCenter(X); + textGroup.add(money); + } } } public function addMoreText(text:String) { - var coolText:Alphabet = new Alphabet(0, (textGroup.length * 60) + 200, text, true, false); - coolText.screenCenter(X); - textGroup.add(coolText); + var coolText:Alphabet; + + var event = scripts.event("onMoreText", new CancellableEvent()); + if (!event.cancelled) { + coolText = new Alphabet(0, (textGroup.length * 60) + 200, text, true, false); + coolText.screenCenter(X); + textGroup.add(coolText); + } } public function deleteCoolText() { - while (textGroup.members.length > 0) { - textGroup.members[0].destroy(); - textGroup.remove(textGroup.members[0], true); + var event = scripts.event("onDeleteText", new CancellableEvent()); + if (!event.cancelled) { + while (textGroup.members.length > 0) { + textGroup.members[0].destroy(); + textGroup.remove(textGroup.members[0], true); + } } } @@ -326,17 +355,20 @@ class TitleState extends MusicBeatState public function skipIntro():Void { - if (!skippedIntro) - { - #if !TITLESCREEN_XML - remove(ngSpr); - #end - - FlxG.camera.flash(FlxColor.WHITE, 4); - remove(blackScreen); - blackScreen.destroy(); - remove(textGroup); - skippedIntro = true; + var event = scripts.event("onIntroSkipped", new CancellableEvent()); + if (!event.cancelled) { + if (!skippedIntro) + { + #if !TITLESCREEN_XML + remove(ngSpr); + #end + + FlxG.camera.flash(FlxColor.WHITE, 4); + remove(blackScreen); + blackScreen.destroy(); + remove(textGroup); + skippedIntro = true; + } } } } @@ -387,4 +419,4 @@ typedef TitleStateImage = { @:optional var scale:Null; @:optional var flipX:Null; @:optional var flipY:Null; -} \ No newline at end of file +} From 1f6313112cf2489aecbc1aaa0340daf36cd2a00d Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 19:39:33 -0600 Subject: [PATCH 02/14] Create StartIntroEvent --- .../scripting/events/StartIntroEvent.hx | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 source/funkin/backend/scripting/events/StartIntroEvent.hx diff --git a/source/funkin/backend/scripting/events/StartIntroEvent.hx b/source/funkin/backend/scripting/events/StartIntroEvent.hx new file mode 100644 index 000000000..8d248b76b --- /dev/null +++ b/source/funkin/backend/scripting/events/StartIntroEvent.hx @@ -0,0 +1,30 @@ +package funkin.backend.scripting.events; + + + +final class StartIntroEvent extends CancellableEvent { + /** + * Whether StoryMenuState should play the menu song + */ + public var playMenuSong:Bool; + + /** + * Whether StoryMenuState should use the title screen's XML file + */ + public var titleScreenXML:Bool; + + /** + * The path for the title sprite (PRESS ENTER TO PLAY) + */ + public var titleSprite:String; + + /** + * The path for the Newgrounds sprite + */ + public var ngSprite:String; + + /** + * Whether the mouse should be visible + */ + public var showMouse:Bool; +} From f32d5e0410d9c127f44001cb5f4e20ab8a1bf1d2 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 19:44:44 -0600 Subject: [PATCH 03/14] Create EnterPressedEvent i love zingers --- .../scripting/events/EnterPressedEvent.hx | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 source/funkin/backend/scripting/events/EnterPressedEvent.hx diff --git a/source/funkin/backend/scripting/events/EnterPressedEvent.hx b/source/funkin/backend/scripting/events/EnterPressedEvent.hx new file mode 100644 index 000000000..39b0e9c93 --- /dev/null +++ b/source/funkin/backend/scripting/events/EnterPressedEvent.hx @@ -0,0 +1,30 @@ +package funkin.backend.scripting.events; + +import funkin.backend.utils.CoolUtil.CoolSfx; + +final class EnterPressedEvent extends CancellableEvent { + /** + * Whether the screen should flash on PRESS ENTER TO START + */ + public var flash:Bool; + + /** + * The color that the screen flashes + */ + public var flashColor:FlxColor; + + /** + * Whether PRESS ENTER TO START should play a menu sfx + */ + public var playSfx:Bool; + + /** + * The menu sound to play + */ + public var menuSound:CoolSfx; + + /** + * The time between enter being pressed and the transition into MainMenuState + */ + public var timerLength:Float; +} From 250b3b149673578aac971c8e02fdef0bb7d1bde4 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 19:47:21 -0600 Subject: [PATCH 04/14] add flxcolor i might have eated a little bit --- source/funkin/backend/scripting/events/EnterPressedEvent.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/source/funkin/backend/scripting/events/EnterPressedEvent.hx b/source/funkin/backend/scripting/events/EnterPressedEvent.hx index 39b0e9c93..a273f6490 100644 --- a/source/funkin/backend/scripting/events/EnterPressedEvent.hx +++ b/source/funkin/backend/scripting/events/EnterPressedEvent.hx @@ -1,6 +1,7 @@ package funkin.backend.scripting.events; import funkin.backend.utils.CoolUtil.CoolSfx; +import flixel.util.FlxColor; final class EnterPressedEvent extends CancellableEvent { /** From 637130a6cffccd3a0c556eae0c1616ec0c64d850 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 19:53:23 -0600 Subject: [PATCH 05/14] oops --- source/funkin/menus/TitleState.hx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/funkin/menus/TitleState.hx b/source/funkin/menus/TitleState.hx index 863f1c7f3..730442ff5 100644 --- a/source/funkin/menus/TitleState.hx +++ b/source/funkin/menus/TitleState.hx @@ -53,7 +53,7 @@ class TitleState extends MusicBeatState function startIntro() { - var event = scripts.event("onStartIntro", EventManager.get(StartIntroEvent).recycle(true, true, 'menus/titlescreen/titleEnter', 'newgrounds_logo', false)); + var event = event("onStartIntro", EventManager.get(StartIntroEvent).recycle(true, true, 'menus/titlescreen/titleEnter', 'newgrounds_logo', false)); if (!event.cancelled) { if (!initialized && event.playMenuSong) CoolUtil.playMenuSong(true); @@ -110,7 +110,7 @@ class TitleState extends MusicBeatState public function getIntroTextShit():Array> { - var event = scripts.event("onGetIntroText", EventManager.get(NameEvent).recycle('introText')); + var event = event("onGetIntroText", EventManager.get(NameEvent).recycle('introText')); if (!event.cancelled) { var fullText:String = Assets.getText(Paths.txt('titlescreen/${event.name}' || 'titlescreen/introText')); @@ -174,7 +174,7 @@ class TitleState extends MusicBeatState } public function pressEnter() { - var event = scripts.event("onEnterPressed", EventManager.get(EnterPressedEvent).recycle(true, 0xFFFFFFFF, true, CONFIRM, 2)); + var event = event("onEnterPressed", EventManager.get(EnterPressedEvent).recycle(true, 0xFFFFFFFF, true, CONFIRM, 2)); if (!event.cancelled) { titleText.animation.play('press'); @@ -207,7 +207,7 @@ class TitleState extends MusicBeatState { var money:Alphabet; - var event = scripts.event("onCreateText", new CancellableEvent()); + var event = event("onCreateText", new CancellableEvent()); if (!event.cancelled) { for (i=>text in textArray) { @@ -223,7 +223,7 @@ class TitleState extends MusicBeatState { var coolText:Alphabet; - var event = scripts.event("onMoreText", new CancellableEvent()); + var event = event("onMoreText", new CancellableEvent()); if (!event.cancelled) { coolText = new Alphabet(0, (textGroup.length * 60) + 200, text, true, false); coolText.screenCenter(X); @@ -233,7 +233,7 @@ class TitleState extends MusicBeatState public function deleteCoolText() { - var event = scripts.event("onDeleteText", new CancellableEvent()); + var event = event("onDeleteText", new CancellableEvent()); if (!event.cancelled) { while (textGroup.members.length > 0) { textGroup.members[0].destroy(); @@ -355,7 +355,7 @@ class TitleState extends MusicBeatState public function skipIntro():Void { - var event = scripts.event("onIntroSkipped", new CancellableEvent()); + var event = event("onIntroSkipped", new CancellableEvent()); if (!event.cancelled) { if (!skippedIntro) { From 131e117f280b01c2415ce6c1329e9a23e07486b7 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 19:57:33 -0600 Subject: [PATCH 06/14] fix random error haxe typo --- source/funkin/menus/TitleState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/menus/TitleState.hx b/source/funkin/menus/TitleState.hx index 730442ff5..8eba2208c 100644 --- a/source/funkin/menus/TitleState.hx +++ b/source/funkin/menus/TitleState.hx @@ -112,7 +112,7 @@ class TitleState extends MusicBeatState { var event = event("onGetIntroText", EventManager.get(NameEvent).recycle('introText')); if (!event.cancelled) { - var fullText:String = Assets.getText(Paths.txt('titlescreen/${event.name}' || 'titlescreen/introText')); + var fullText:String = Assets.getText(Paths.txt(Assets.exists(Paths.txt('titlescreen/${event.name}')) ? 'titlescreen/${event.name}' : 'titlescreen/introText')); var firstArray:Array = fullText.split('\n'); var swagGoodArray:Array> = []; From 61afa0c72637188e497eb3ca6299c12225950df2 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 20:03:06 -0600 Subject: [PATCH 07/14] I believe this should fix it --- source/funkin/menus/TitleState.hx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source/funkin/menus/TitleState.hx b/source/funkin/menus/TitleState.hx index 8eba2208c..f77e5390c 100644 --- a/source/funkin/menus/TitleState.hx +++ b/source/funkin/menus/TitleState.hx @@ -110,20 +110,24 @@ class TitleState extends MusicBeatState public function getIntroTextShit():Array> { + var fullText:String; + var firstArray:Array; + var swagGoodArray:Array>; + var event = event("onGetIntroText", EventManager.get(NameEvent).recycle('introText')); if (!event.cancelled) { - var fullText:String = Assets.getText(Paths.txt(Assets.exists(Paths.txt('titlescreen/${event.name}')) ? 'titlescreen/${event.name}' : 'titlescreen/introText')); + fullText = Assets.getText(Paths.txt(Assets.exists(Paths.txt('titlescreen/${event.name}')) ? 'titlescreen/${event.name}' : 'titlescreen/introText')); - var firstArray:Array = fullText.split('\n'); - var swagGoodArray:Array> = []; + firstArray = fullText.split('\n'); + swagGoodArray = []; for (i in firstArray) { swagGoodArray.push(i.split('--')); } - - return swagGoodArray; } + + return swagGoodArray; } var transitioning:Bool = false; From c3e23fdd54b25258ddcafcc517443aa7cb8ea504 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 20:07:34 -0600 Subject: [PATCH 08/14] no more null --- source/funkin/menus/TitleState.hx | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/source/funkin/menus/TitleState.hx b/source/funkin/menus/TitleState.hx index f77e5390c..a770d53fb 100644 --- a/source/funkin/menus/TitleState.hx +++ b/source/funkin/menus/TitleState.hx @@ -109,22 +109,17 @@ class TitleState extends MusicBeatState } public function getIntroTextShit():Array> - { - var fullText:String; - var firstArray:Array; - var swagGoodArray:Array>; - + { var event = event("onGetIntroText", EventManager.get(NameEvent).recycle('introText')); - if (!event.cancelled) { - fullText = Assets.getText(Paths.txt(Assets.exists(Paths.txt('titlescreen/${event.name}')) ? 'titlescreen/${event.name}' : 'titlescreen/introText')); + + var fullText:String = Assets.getText(Paths.txt(Assets.exists(Paths.txt('titlescreen/${event.name}')) ? 'titlescreen/${event.name}' : 'titlescreen/introText')); - firstArray = fullText.split('\n'); - swagGoodArray = []; + var firstArray:Array = fullText.split('\n'); + var swagGoodArray:Array> = []; - for (i in firstArray) - { - swagGoodArray.push(i.split('--')); - } + for (i in firstArray) + { + swagGoodArray.push(i.split('--')); } return swagGoodArray; From bfb240cf5ffb176ae8fc6ee900fd5c6d72f31f21 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 23:26:05 -0600 Subject: [PATCH 09/14] Allow for changes before onSelecetItem this is annoying, please do this --- source/funkin/menus/MainMenuState.hx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 968494f17..606fe950d 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -150,13 +150,17 @@ class MainMenuState extends MusicBeatState } function selectItem() { - selectedSomethin = true; - CoolUtil.playMenuSFX(CONFIRM); + var primevent = event("onInitialSelection", EventManager.get(AmountEvent).recycle(1)); + if (!primevent.cancelled) { + selectedSomethin = true; + CoolUtil.playMenuSFX(CONFIRM); - if (Options.flashingMenu) FlxFlicker.flicker(magenta, 1.1, 0.15, false); + if (Options.flashingMenu) FlxFlicker.flicker(magenta, 1.1, 0.15, false); - FlxFlicker.flicker(menuItems.members[curSelected], 1, Options.flashingMenu ? 0.06 : 0.15, false, false, function(flick:FlxFlicker) - { + FlxFlicker.flicker(menuItems.members[curSelected], primevent.amount, Options.flashingMenu ? 0.06 : 0.15, false, false); + } + + new FlxTimer().start(primevent.amount, function(timer:FlxTimer) { var daChoice:String = optionShit[curSelected]; var event = event("onSelectItem", EventManager.get(NameEvent).recycle(daChoice)); @@ -169,6 +173,7 @@ class MainMenuState extends MusicBeatState case 'options': FlxG.switchState(new OptionsMenu()); } }); + } function changeItem(huh:Int = 0) { From ad4d4bec9b3118a4de160cc20e2bbf9c707882fe Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 23:28:34 -0600 Subject: [PATCH 10/14] oopsie i eated a bit of it :3 --- source/funkin/menus/MainMenuState.hx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 606fe950d..33fafd2f6 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -8,6 +8,7 @@ import flixel.effects.FlxFlicker; import flixel.text.FlxText; import flixel.tweens.FlxTween; import flixel.util.FlxColor; +import flixel.util.FlxTimer; import lime.app.Application; import funkin.backend.scripting.events.*; @@ -151,8 +152,9 @@ class MainMenuState extends MusicBeatState function selectItem() { var primevent = event("onInitialSelection", EventManager.get(AmountEvent).recycle(1)); - if (!primevent.cancelled) { + if (primevent.cancelled) return; selectedSomethin = true; + CoolUtil.playMenuSFX(CONFIRM); if (Options.flashingMenu) FlxFlicker.flicker(magenta, 1.1, 0.15, false); @@ -165,6 +167,7 @@ class MainMenuState extends MusicBeatState var event = event("onSelectItem", EventManager.get(NameEvent).recycle(daChoice)); if (event.cancelled) return; + switch (event.name) { case 'story mode': FlxG.switchState(new StoryMenuState()); From 98c059ed4d30f1c0ae25152f1765ac9f1e117b26 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 23:30:05 -0600 Subject: [PATCH 11/14] do it the codename way --- source/funkin/menus/TitleState.hx | 84 +++++++++++++++---------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/source/funkin/menus/TitleState.hx b/source/funkin/menus/TitleState.hx index a770d53fb..6b0f1a154 100644 --- a/source/funkin/menus/TitleState.hx +++ b/source/funkin/menus/TitleState.hx @@ -54,58 +54,58 @@ class TitleState extends MusicBeatState function startIntro() { var event = event("onStartIntro", EventManager.get(StartIntroEvent).recycle(true, true, 'menus/titlescreen/titleEnter', 'newgrounds_logo', false)); - if (!event.cancelled) { - if (!initialized && event.playMenuSong) - CoolUtil.playMenuSong(true); + if (event.cancelled) return; + + if (!initialized && event.playMenuSong) + CoolUtil.playMenuSong(true); - persistentUpdate = true; + persistentUpdate = true; - var bg:FlxSprite = new FlxSprite().makeSolid(FlxG.width, FlxG.height, FlxColor.BLACK); - add(bg); + var bg:FlxSprite = new FlxSprite().makeSolid(FlxG.width, FlxG.height, FlxColor.BLACK); + add(bg); - #if TITLESCREEN_XML - if (event.titleScreenXML) { - titleScreenSprites = new MusicBeatGroup(); - add(titleScreenSprites); - loadXML(); - } - #end + #if TITLESCREEN_XML + if (event.titleScreenXML) { + titleScreenSprites = new MusicBeatGroup(); + add(titleScreenSprites); + loadXML(); + } + #end - if (titleText == null) { - titleText = new FlxSprite(100, FlxG.height * 0.8); - titleText.frames = Paths.getFrames(event.titleSprite); - titleText.animation.addByPrefix('idle', "Press Enter to Begin", 24); - titleText.animation.addByPrefix('press', "ENTER PRESSED", 24); - titleText.antialiasing = true; - titleText.animation.play('idle'); - titleText.updateHitbox(); - } - add(titleText); + if (titleText == null) { + titleText = new FlxSprite(100, FlxG.height * 0.8); + titleText.frames = Paths.getFrames(event.titleSprite); + titleText.animation.addByPrefix('idle', "Press Enter to Begin", 24); + titleText.animation.addByPrefix('press', "ENTER PRESSED", 24); + titleText.antialiasing = true; + titleText.animation.play('idle'); + titleText.updateHitbox(); + } + add(titleText); - textGroup = new FlxGroup(); + textGroup = new FlxGroup(); - blackScreen = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK); - add(blackScreen); + blackScreen = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK); + add(blackScreen); - #if !TITLESCREEN_XML - ngSpr = new FlxSprite(0, FlxG.height * 0.52).loadAnimatedGraphic(Paths.image(event.ngSprite)); - add(ngSpr); - ngSpr.visible = false; - ngSpr.setGraphicSize(Std.int(ngSpr.width * 0.8)); - ngSpr.updateHitbox(); - ngSpr.screenCenter(X); - ngSpr.antialiasing = true; - #end + #if !TITLESCREEN_XML + ngSpr = new FlxSprite(0, FlxG.height * 0.52).loadAnimatedGraphic(Paths.image(event.ngSprite)); + add(ngSpr); + ngSpr.visible = false; + ngSpr.setGraphicSize(Std.int(ngSpr.width * 0.8)); + ngSpr.updateHitbox(); + ngSpr.screenCenter(X); + ngSpr.antialiasing = true; + #end - FlxG.mouse.visible = event.showMouse; + FlxG.mouse.visible = event.showMouse; - if (initialized) - skipIntro(); - else - initialized = true; + if (initialized) + skipIntro(); + else + initialized = true; - add(textGroup); - } + add(textGroup); } public function getIntroTextShit():Array> From 434d9b25e0412f664fad3122dfd9f1aa7ca6eec8 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 23:30:49 -0600 Subject: [PATCH 12/14] im a dumb fuck --- source/funkin/menus/MainMenuState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 33fafd2f6..f798a4e36 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -152,7 +152,7 @@ class MainMenuState extends MusicBeatState function selectItem() { var primevent = event("onInitialSelection", EventManager.get(AmountEvent).recycle(1)); - if (primevent.cancelled) return; + if (!primevent.cancelled) { selectedSomethin = true; CoolUtil.playMenuSFX(CONFIRM); From afe51adaff37ad0829c6557ad71fd54ab1b2c27c Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Sun, 9 Feb 2025 23:33:43 -0600 Subject: [PATCH 13/14] do it the codename way #2 --- source/funkin/menus/TitleState.hx | 78 +++++++++++++++---------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/source/funkin/menus/TitleState.hx b/source/funkin/menus/TitleState.hx index 6b0f1a154..828e12fa5 100644 --- a/source/funkin/menus/TitleState.hx +++ b/source/funkin/menus/TitleState.hx @@ -174,17 +174,17 @@ class TitleState extends MusicBeatState public function pressEnter() { var event = event("onEnterPressed", EventManager.get(EnterPressedEvent).recycle(true, 0xFFFFFFFF, true, CONFIRM, 2)); - if (!event.cancelled) { - titleText.animation.play('press'); + if (event.cancelled) return; + + titleText.animation.play('press'); - if (event.flash) FlxG.camera.flash(event.flashColor, 1); - if (event.playSfx) CoolUtil.playMenuSFX(event.menuSound, 0.7); + if (event.flash) FlxG.camera.flash(event.flashColor, 1); + if (event.playSfx) CoolUtil.playMenuSFX(event.menuSound, 0.7); - transitioning = true; - // FlxG.sound.music.stop(); + transitioning = true; + // FlxG.sound.music.stop(); - new FlxTimer().start(event.timerLength, (_) -> goToMainMenu()); - } + new FlxTimer().start(event.timerLength, (_) -> goToMainMenu()); } function goToMainMenu() { @@ -207,14 +207,14 @@ class TitleState extends MusicBeatState var money:Alphabet; var event = event("onCreateText", new CancellableEvent()); - if (!event.cancelled) { - for (i=>text in textArray) - { - if (text == "" || text == null) continue; - money = new Alphabet(0, (i * 60) + 200, text, true, false); - money.screenCenter(X); - textGroup.add(money); - } + if (!event.cancelled) return; + + for (i=>text in textArray) + { + if (text == "" || text == null) continue; + money = new Alphabet(0, (i * 60) + 200, text, true, false); + money.screenCenter(X); + textGroup.add(money); } } @@ -223,21 +223,21 @@ class TitleState extends MusicBeatState var coolText:Alphabet; var event = event("onMoreText", new CancellableEvent()); - if (!event.cancelled) { - coolText = new Alphabet(0, (textGroup.length * 60) + 200, text, true, false); - coolText.screenCenter(X); - textGroup.add(coolText); - } + if (event.cancelled) return; + + coolText = new Alphabet(0, (textGroup.length * 60) + 200, text, true, false); + coolText.screenCenter(X); + textGroup.add(coolText); } public function deleteCoolText() { var event = event("onDeleteText", new CancellableEvent()); - if (!event.cancelled) { - while (textGroup.members.length > 0) { - textGroup.members[0].destroy(); - textGroup.remove(textGroup.members[0], true); - } + if (event.cancelled) return; + + while (textGroup.members.length > 0) { + textGroup.members[0].destroy(); + textGroup.remove(textGroup.members[0], true); } } @@ -355,19 +355,19 @@ class TitleState extends MusicBeatState public function skipIntro():Void { var event = event("onIntroSkipped", new CancellableEvent()); - if (!event.cancelled) { - if (!skippedIntro) - { - #if !TITLESCREEN_XML - remove(ngSpr); - #end - - FlxG.camera.flash(FlxColor.WHITE, 4); - remove(blackScreen); - blackScreen.destroy(); - remove(textGroup); - skippedIntro = true; - } + if (event.cancelled) return; + + if (!skippedIntro) + { + #if !TITLESCREEN_XML + remove(ngSpr); + #end + + FlxG.camera.flash(FlxColor.WHITE, 4); + remove(blackScreen); + blackScreen.destroy(); + remove(textGroup); + skippedIntro = true; } } } From e7b10a30c4ddfa67d8f9eb55dc8bfa0ad916678f Mon Sep 17 00:00:00 2001 From: Microkat <89645987+THEkatinamicrowave@users.noreply.github.com> Date: Fri, 14 Feb 2025 11:17:49 -0500 Subject: [PATCH 14/14] make onSongEnd cancellable idk some rando asked for it --- source/funkin/game/PlayState.hx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 1e56aad1b..7e702e4f3 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1459,7 +1459,9 @@ class PlayState extends MusicBeatState */ public function endSong():Void { - scripts.call("onSongEnd"); + var event = scripts.event("onSongEnd", new CancellableEvent()); + if (event.cancelled) return; + canPause = false; inst.volume = 0; vocals.volume = 0;