From 102f80b4e3cc4ee482278669ab39cc7120afe90a Mon Sep 17 00:00:00 2001 From: Ralty <78720179+Raltyro@users.noreply.github.com> Date: Sat, 19 Jul 2025 20:18:42 +0700 Subject: [PATCH] here u go frakits --- source/funkin/backend/system/MainState.hx | 19 ++++++- source/funkin/editors/ModConfigWarning.hx | 52 +++++++++---------- source/funkin/editors/ui/UIWarningSubstate.hx | 4 +- source/funkin/menus/MainMenuState.hx | 19 ------- 4 files changed, 46 insertions(+), 48 deletions(-) diff --git a/source/funkin/backend/system/MainState.hx b/source/funkin/backend/system/MainState.hx index 1f48d11e..bb734a22 100644 --- a/source/funkin/backend/system/MainState.hx +++ b/source/funkin/backend/system/MainState.hx @@ -5,8 +5,10 @@ import sys.FileSystem; #end import flixel.FlxState; import funkin.backend.assets.ModsFolder; +import funkin.backend.assets.ModsFolderLibrary; import funkin.backend.chart.EventsData; import funkin.backend.system.framerate.Framerate; +import funkin.editors.ModConfigWarning; import funkin.menus.TitleState; import haxe.io.Path; @@ -112,10 +114,23 @@ class MainState extends FlxState { if (Framerate.isLoaded) Framerate.instance.reload(); - FlxG.switchState(new TitleState()); - #if sys CoolUtil.safeAddAttributes('./.temp/', NativeAPI.FileAttribute.HIDDEN); #end + + if (Options.devMode) { + var lib:ModsFolderLibrary; + for (e in Paths.assetsTree.libraries) { + @:privateAccess if (!(e is openfl.utils.AssetLibrary) || !((lib = cast cast(e, openfl.utils.AssetLibrary).__proxy) is ModsFolderLibrary)) continue; + if (lib.modName == ModsFolder.currentModFolder) { + if (lib.exists(Paths.ini("config/modpack"), lime.utils.AssetType.TEXT)) break; + + FlxG.switchState(new ModConfigWarning(lib)); + return; + } + } + } + + FlxG.switchState(new TitleState()); } } \ No newline at end of file diff --git a/source/funkin/editors/ModConfigWarning.hx b/source/funkin/editors/ModConfigWarning.hx index 4aeebcdd..6e2c4bac 100644 --- a/source/funkin/editors/ModConfigWarning.hx +++ b/source/funkin/editors/ModConfigWarning.hx @@ -1,9 +1,15 @@ package funkin.editors; -class ModConfigWarning extends UIState { +import funkin.backend.assets.ModsFolderLibrary; +import flixel.FlxState; - var libraryToMakeConfigIn:Dynamic = null; - public static var defaultModConfigText = +class ModConfigWarning extends UIState { + public static var hadPopup:Bool = false; + + var library:ModsFolderLibrary = null; + var goToState:Class; + + public static inline var defaultModConfigText = '[Common] MOD_NAME="YOUR MOD NAME HERE" MOD_DESCRIPTION="YOUR MOD DESCRIPTION HERE" @@ -26,49 +32,43 @@ DISABLE_BETA_WARNING_SCREEN=true MOD_DISCORD_CLIENT_ID="" MOD_DISCORD_LOGO_KEY=""'; - public function new(library) { + public function new(library:ModsFolderLibrary, ?goToState:Class) { super(); - - libraryToMakeConfigIn = library; + this.library = library; + this.goToState = goToState != null ? goToState : funkin.menus.TitleState; } - override function create() { - super.create(); + override function createPost() { + super.createPost(); + hadPopup = true; - openSubState(new UIWarningSubstate("Missing mod config!", "Your mod is currently missing a mod config file!\n\n\nWould you like to automatically generate one?\n\n(PS: If this is not your mod please disable Developer mode to stop this popup from appearing.)", - [ + var substate = new UIWarningSubstate("Missing mod folder configuration!", "Your mod is currently missing a mod config file!\n\n\nWould you like to automatically generate one?\n\n(PS: If this is not your mod please disable Developer mode to stop this popup from appearing.)", [ { label: "Not Now", color: 0x969533, onClick: function (_) { - funkin.menus.MainMenuState.hadPopup = true; - MusicBeatState.skipTransIn = false; - MusicBeatState.skipTransOut = false; - FlxG.switchState(new funkin.menus.MainMenuState()); + MusicBeatState.skipTransOut = MusicBeatState.skipTransIn = false; + FlxG.switchState(cast Type.createInstance(goToState, [])); } }, { label: "Yes", onClick: function(_) { - trace(libraryToMakeConfigIn.getPath("data/config/modpack.ini")); - sys.io.File.saveContent(libraryToMakeConfigIn.getPath("data/config/modpack.ini"), defaultModConfigText); - openSubState(new UIWarningSubstate("Created mod config!", "Your mod config file has been created at " + libraryToMakeConfigIn.getPath("data/config/modpack.ini") + "!", [ + var path = '${library.folderPath}/data/config/modpack.ini'; + CoolUtil.safeSaveFile(path, defaultModConfigText); + openSubState(new UIWarningSubstate("Created mod config!", "Your mod config file has been created at " + path + "!", [ { label: "Ok", onClick: function (_) { - funkin.menus.MainMenuState.hadPopup = true; - MusicBeatState.skipTransIn = false; - MusicBeatState.skipTransOut = false; - FlxG.switchState(new funkin.menus.MainMenuState()); + MusicBeatState.skipTransOut = MusicBeatState.skipTransIn = false; + FlxG.switchState(cast Type.createInstance(goToState, [])); } }, ], false)); } } - ], false)); - } - - override function update(elapsed) { - super.update(elapsed); + ], false); + substate.bHeight = 300; + openSubState(substate); } } \ No newline at end of file diff --git a/source/funkin/editors/ui/UIWarningSubstate.hx b/source/funkin/editors/ui/UIWarningSubstate.hx index 4f4a0380..b29b6bce 100644 --- a/source/funkin/editors/ui/UIWarningSubstate.hx +++ b/source/funkin/editors/ui/UIWarningSubstate.hx @@ -32,6 +32,8 @@ class UIWarningSubstate extends MusicBeatSubstate { var warnCam:FlxCamera; + public var bHeight:Int = 232; + public override function onSubstateOpen() { super.onSubstateOpen(); parent.persistentUpdate = false; @@ -69,7 +71,7 @@ class UIWarningSubstate extends MusicBeatSubstate { warnCam.zoom = 0.1; FlxG.cameras.add(warnCam, false); - var spr = new UISliceSprite(0, 0, CoolUtil.maxInt(560, 30 + (170 * buttons.length)), 232, 'editors/ui/${isError ? "normal" : "grayscale"}-popup'); + var spr = new UISliceSprite(0, 0, CoolUtil.maxInt(560, 30 + (170 * buttons.length)), bHeight, 'editors/ui/${isError ? "normal" : "grayscale"}-popup'); spr.x = (FlxG.width - spr.bWidth) / 2; spr.y = (FlxG.height - spr.bHeight) / 2; spr.color = isError ? 0xFFFF0000 : 0xFFFFFF00; diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 51004b9c..3ae6be83 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -27,8 +27,6 @@ class MainMenuState extends MusicBeatState public var canAccessDebugMenus:Bool = !Flags.DISABLE_EDITORS; - public static var hadPopup = false; - override function create() { @@ -82,23 +80,6 @@ class MainMenuState extends MusicBeatState add(versionText); changeItem(); - - if (Options.devMode && !MainMenuState.hadPopup) - for (i in Paths.assetsTree.libraries) { - var l = i; - if (l is openfl.utils.AssetLibrary) { - @:privateAccess - l = cast(l, openfl.utils.AssetLibrary).__proxy; - } - if (cast(l, funkin.backend.assets.IModsAssetLibrary).modName == funkin.backend.assets.ModsFolder.currentModFolder) { - if (!l.exists(Paths.getPath("data/config/modpack.ini"), lime.utils.AssetType.TEXT)) { - MusicBeatState.skipTransIn = true; - MusicBeatState.skipTransOut = true; - FlxG.switchState(new funkin.editors.ModConfigWarning(l)); - } - break; - } - } } var selectedSomethin:Bool = false;