From 1574630166b5d0f18cdad3c885e1ddd11ff0caff Mon Sep 17 00:00:00 2001 From: Falkimore <86729768+Falkimore@users.noreply.github.com> Date: Fri, 31 May 2024 12:33:32 -0500 Subject: [PATCH] Format scripts formated scripts to make them nicer to read... --- scripts/modules/InitBootstrap.hxc | 128 ++++++++------ .../modules/api/AdaptiveMusicController.hxc | 69 ++++---- scripts/modules/api/BootStrapBinds.hxc | 39 +++-- .../modules/api/OptionsInjectorBootStrap.hxc | 143 +++++++++------- scripts/states/BaseTitleState.hxc | 10 +- scripts/states/BootStrapState.hxc | 161 +++++++++++------- scripts/states/FlxSplashLoader.hxc | 29 ++-- 7 files changed, 337 insertions(+), 242 deletions(-) diff --git a/scripts/modules/InitBootstrap.hxc b/scripts/modules/InitBootstrap.hxc index 01fb8a2..daebeea 100644 --- a/scripts/modules/InitBootstrap.hxc +++ b/scripts/modules/InitBootstrap.hxc @@ -1,21 +1,19 @@ import flixel.FlxG; - +import flixel.text.FlxText; +import flixel.tweens.FlxEase; +import flixel.tweens.FlxTween; +import flixel.util.FlxTimer; import funkin.Preferences; - import funkin.modding.base.ScriptedMusicBeatState; import funkin.modding.module.Module; -import flixel.tweens.FlxTween; +import funkin.modding.module.ModuleHandler; import funkin.save.Save; import funkin.ui.title.TitleState; import funkin.util.ReflectUtil; import funkin.util.WindowUtil; -import flixel.util.FlxTimer; -import flixel.tweens.FlxEase; -import flixel.text.FlxText; -import funkin.modding.module.ModuleHandler; - -class InitBootstrap extends Module { +class InitBootstrap extends Module +{ var initialized:Bool = false; var currentState:Dynamic; var version:String = '0.2.0'; @@ -28,33 +26,39 @@ class InitBootstrap extends Module { haxeflixel_splash: false } - public function new() { - super("InitBootStrap", -1000); - } + public function new() + { + super("InitBootStrap", -1000); + } - public function addOption(data:Dynamic) { + public function addOption(data:Dynamic) + { options.push(data); } - function refreshSettings() { + function refreshSettings() + { Save.instance.modOptions.set("ModBootstrapv2", settings); Save.instance.flush(); options = []; // clean up options array addOptions(); } - function set_current_mod(name) { + function set_current_mod(name) + { settings.current_mod = name; refreshSettings(); } - public function onCreate(event:ScriptEvent):Void { + public function onCreate(event:ScriptEvent):Void + { FlxG.mouse.set_visible(false); - if (Save.instance.modOptions.get("ModBootstrapv2") == null) { + if (Save.instance.modOptions.get("ModBootstrapv2") == null) + { Save.instance.modOptions.set("ModBootstrapv2", { // v2 bootstrap saves baby! current_mod: "Friday Night Funkin'", // Current mod, will be the mod that will load up on boot if load_menu_on_boot is disabled. - load_menu_on_boot: true, // wether or not to load the menu before the title screen shows up. otherwise it will allow you to press tab in TitleState to bootstrap instead + load_menu_on_boot: true, // wether or not to load the menu before the title screen shows up. otherwise it will allow you to press tab in TitleState to bootstrap instead play_music: true, // wether or not the menus should be able play music compact_mode: false, // Omits stuff like author and icons to make the tab thingies smaller haxeflixel_splash: false @@ -71,35 +75,46 @@ class InitBootstrap extends Module { settings.haxeflixel_splash = false; addOptions(); - ModuleHandler.getModule("BootStrapBinds").scriptCall("bind", [{ - name: "Friday Night Funkin'", - description: "Uh oh! Your tryin to kiss ur hot girlfriend, but her MEAN and EVIL dad is trying to KILL you! He's an ex-rockstar, the only way to get to his heart? The power of music...", - target: "BaseTitleState", - logo: 'base-game-logo', - bg: '', - icon: 'fnficon32', - author: "The Funkin' Crew", - color: 0xFFff2b77, - bg_group: (group) -> { - return; // do nothing. - }, - disclaimer: "This loads the vanilla game, mods that don't require this bootstrap will load as well." - }]); - } + ModuleHandler.getModule("BootStrapBinds").scriptCall("bind", [ + { + name: "Friday Night Funkin'", + description: "Uh oh! Your tryin to kiss ur hot girlfriend, but her MEAN and EVIL dad is trying to KILL you! He's an ex-rockstar, the only way to get to his heart? The power of music...", + target: "BaseTitleState", + logo: 'base-game-logo', + bg: '', + icon: 'fnficon32', + author: "The Funkin' Crew", + color: 0xFFff2b77, + bg_group: (group) -> + { + return; // do nothing. + }, + disclaimer: "This loads the vanilla game, mods that don't require this bootstrap will load as well." + } + ]); + } - public function onStateChangeEnd(event:StateChangeScriptEvent):Void { + public function onStateChangeEnd(event:StateChangeScriptEvent):Void + { currentState = event.targetState; - if (Std.isOfType(currentState, TitleState) && !initialized) { - if (settings.haxeflixel_splash) { + if (Std.isOfType(currentState, TitleState) && !initialized) + { + if (settings.haxeflixel_splash) + { FlxG.switchState(ScriptedMusicBeatState.init("FlxSplashLoader")); - } else if (settings.load_menu_on_boot) { + } + else if (settings.load_menu_on_boot) + { FlxG.switchState(ScriptedMusicBeatState.init("BootStrapState")); } initialized = true; - } else if (Std.isOfType(currentState, TitleState) && initialized) { + } + else if (Std.isOfType(currentState, TitleState) && initialized) + { var crazyText = new FlxText(4, 720 - 22, 0, "Press F8 to enter the ModBootstrap v" + version + ' menu at any time.', 16); crazyText.setFormat('VCR OSD Mono', 16, 0xFFFFFFFF, 'left'); - new FlxTimer().start(1.4, () -> { + new FlxTimer().start(1.4, () -> + { currentState.add(crazyText); crazyText.alpha = 0; FlxTween.tween(crazyText, {alpha: 1}, 0.7, {ease: FlxEase.quadOut}); @@ -107,26 +122,35 @@ class InitBootstrap extends Module { } } - public function onUpdate(e) { - if (FlxG.keys.justPressed.F8) { + public function onUpdate(e) + { + if (FlxG.keys.justPressed.F8) + { if (FlxG.sound.music != null) FlxG.sound.music.time = 0; - FlxG.sound.music.stop(); + FlxG.sound.music.stop(); FlxG.switchState(ScriptedMusicBeatState.init("BootStrapState")); } } - function addOptions() { + + function addOptions() + { // my mystical options api addOption({ name: "Play Music", description: "Wether or not the menus should play music.", variableToChange: settings.play_music, - action: function(val) { + action: function(val) + { settings.play_music = val; - if (ModuleHandler.getModule("OptionsInjectorBootStrap").scriptGet("fromBootStrapMenu")) { - if (val) { + if (ModuleHandler.getModule("OptionsInjectorBootStrap").scriptGet("fromBootStrapMenu")) + { + if (val) + { ModuleHandler.getModule("AdaptiveMusicController").scriptCall("play", ['modbootstrap-music-settings']); - } else { + } + else + { FlxG.sound.music.stop(); } } @@ -137,8 +161,8 @@ class InitBootstrap extends Module { name: "Compact mode", description: "Omits stuff like author and icons to make the tab thingies smaller.", variableToChange: settings.compact_mode, - action: function(val) { - + action: function(val) + { settings.compact_mode = val; refreshSettings(); } @@ -147,7 +171,8 @@ class InitBootstrap extends Module { name: "Load Menu on Boot", description: "", variableToChange: settings.load_menu_on_boot, - action: function(val) { + action: function(val) + { settings.load_menu_on_boot = val; refreshSettings(); } @@ -156,7 +181,8 @@ class InitBootstrap extends Module { name: "Haxeflixel Splash Screen", description: "", variableToChange: settings.haxeflixel_splash, - action: function(val) { + action: function(val) + { settings.haxeflixel_splash = val; refreshSettings(); } diff --git a/scripts/modules/api/AdaptiveMusicController.hxc b/scripts/modules/api/AdaptiveMusicController.hxc index ff48fce..8754b54 100644 --- a/scripts/modules/api/AdaptiveMusicController.hxc +++ b/scripts/modules/api/AdaptiveMusicController.hxc @@ -1,36 +1,43 @@ -import funkin.modding.module.Module; -import flixel.FlxG; -import funkin.modding.module.ModuleHandler; -import funkin.audio.FunkinSound; import StringTools; +import flixel.FlxG; import flixel.sound.FlxSoundGroup; +import funkin.audio.FunkinSound; +import funkin.modding.module.Module; +import funkin.modding.module.ModuleHandler; + +class AdaptiveMusicController extends Module +{ + var playTime:Float = 0; + var stopRecordingPlaytime:Bool = false; + + public function new() + { + super("AdaptiveMusicController", 23); + } -class AdaptiveMusicController extends Module { - var playTime:Float = 0; - var stopRecordingPlaytime:Bool = false; - public function new() { - super("AdaptiveMusicController", 23); - } + public function play(name) + { + if (FlxG.sound.music != null && !stopRecordingPlaytime) + { + playTime = FlxG.sound.music.time; + } + FunkinSound.playMusic(name, { + startingVolume: 0.7, + overrideExisting: true, + restartTrack: false, + loop: true + }); + FlxG.sound.music.pause(); + FlxG.sound.music.time = playTime; + FlxG.sound.music.resume(); + } - public function play(name) { - if (FlxG.sound.music != null && !stopRecordingPlaytime) { - playTime = FlxG.sound.music.time; - } - FunkinSound.playMusic(name, - { - startingVolume: 0.7, - overrideExisting: true, - restartTrack: false, - loop: true - }); - FlxG.sound.music.pause(); - FlxG.sound.music.time = playTime; - FlxG.sound.music.resume(); - } - public function onUpdate(e) { - if (FlxG.sound.music != null && !stopRecordingPlaytime) { - playTime = FlxG.sound.music.time; - } - super.onUpdate(e); - } + public function onUpdate(e) + { + if (FlxG.sound.music != null && !stopRecordingPlaytime) + { + playTime = FlxG.sound.music.time; + } + super.onUpdate(e); + } } diff --git a/scripts/modules/api/BootStrapBinds.hxc b/scripts/modules/api/BootStrapBinds.hxc index 64fa944..094bcfe 100644 --- a/scripts/modules/api/BootStrapBinds.hxc +++ b/scripts/modules/api/BootStrapBinds.hxc @@ -1,40 +1,45 @@ import funkin.modding.module.Module; -typedef Bind = { +typedef Bind = +{ // to pass into the `bind` function name:String, // name of your mod, `Save.instance.modOptions.get("ModBootstrap").selected_mod` will use this. target:String, // target `ScriptedMusicBeatState` class name to open after `on_init` bg:String, // path to the mod bg, if it is null, it will be set to the default. - icon:String, // path to the mod icon, if it is null, it will be set to the default. Advisable to be 32x32. - description:String, // Description of the mod. - logo:String, // path to the mod logo, used for the title in the middle, if null, it's replaced with a name. - author:String, // name of the ones who made the mod. + icon:String, // path to the mod icon, if it is null, it will be set to the default. Advisable to be 32x32. + description:String, // Description of the mod. + logo:String, // path to the mod logo, used for the title in the middle, if null, it's replaced with a name. + author:String, // name of the ones who made the mod. color:Int, disclaimer:String, - bg_group:Null<(Dynamic)->Void> + bg_group:Null<(Dynamic) -> Void> } -class BootStrapBinds extends Module { - public function new() { +class BootStrapBinds extends Module +{ + public function new() + { super("BootStrapBinds", -100); } - public function onCreate(event:ScriptEvent):Void { + public function onCreate(event:ScriptEvent):Void + { this.active = false; } public var binds:Array = []; - public function bind(data:Dynamic):Void { + public function bind(data:Dynamic):Void + { binds.push({ - name: data.name, + name: data.name, description: data.description, - target: data.target, - bg: data.bg, - icon: data.icon, - logo: data.logo, - author: data.author, - color: data.color, + target: data.target, + bg: data.bg, + icon: data.icon, + logo: data.logo, + author: data.author, + color: data.color, disclaimer: data.disclaimer, bg_group: data.bg_group }); diff --git a/scripts/modules/api/OptionsInjectorBootStrap.hxc b/scripts/modules/api/OptionsInjectorBootStrap.hxc index 1dcad75..953a41a 100644 --- a/scripts/modules/api/OptionsInjectorBootStrap.hxc +++ b/scripts/modules/api/OptionsInjectorBootStrap.hxc @@ -1,77 +1,94 @@ -import funkin.modding.module.Module; -import funkin.save.Save; import Std; -import funkin.ui.options.OptionsState; -import funkin.ui.mainmenu.MainMenuState; -import funkin.ui.options.PageName; -import flixel.util.FlxSave; -import flixel.tweens.FlxTween; +import flixel.FlxG; +import flixel.text.FlxText; import flixel.tweens.FlxEase; +import flixel.tweens.FlxTween; +import flixel.util.FlxSave; import funkin.modding.base.ScriptedMusicBeatState; -import flixel.FlxG; +import funkin.modding.module.Module; +import funkin.modding.module.ModuleHandler; import funkin.play.PlayState; +import funkin.save.Save; +import funkin.ui.mainmenu.MainMenuState; +import funkin.ui.options.OptionsState; +import funkin.ui.options.PageName; import funkin.ui.options.PreferencesMenu; import polymod.fs.SysFileSystem; -import flixel.text.FlxText; -import funkin.modding.module.ModuleHandler; class OptionsInjectorBootStrap extends Module { - // Modified version of NebulaZorua's optionsinjection script - public var fromBootStrapMenu:Bool = false; - public var songTime:Float = 0.0; // this is so the thing doesn't break - function new(){ - super("OptionsInjectorBootStrap", -100); - } - override function onStateChangeEnd(event){ - super.onStateChangeEnd(event); - inOptions = false; - if(Std.isOfType(event.targetState, OptionsState)){ - var prefs = event.targetState.pages.get(PageName.Preferences); - inOptions = true; - var state = event.targetState; - var options = event.targetState.pages.get(PageName.Options); - var exit = options.items.members[options.items.length - 1]; - exit.y += 100; - options.items.remove(exit); + // Modified version of NebulaZorua's optionsinjection script + public var fromBootStrapMenu:Bool = false; + public var songTime:Float = 0.0; // this is so the thing doesn't break - var item = options.items.createItem(0, exit.y - 100, "Mod Bootstrap", "bold", function(){ - options.onSwitch.dispatch(PageName.Colors); - }); - item.x = (FlxG.width - item.width) / 2; - options.items.add(exit); + function new() + { + super("OptionsInjectorBootStrap", -100); + } - var leech = event.targetState.addPage(PageName.Colors, new PreferencesMenu()); - leech.onExit.add(function(){ - state.switchPage(PageName.Options); - }); - for(shit in leech.items){ - shit.destroy(); - } - for(shit in leech.preferenceItems){ - shit.destroy(); - } - leech.items.clear(); - leech.preferenceItems.clear(); + override function onStateChangeEnd(event) + { + super.onStateChangeEnd(event); + inOptions = false; + if (Std.isOfType(event.targetState, OptionsState)) + { + var prefs = event.targetState.pages.get(PageName.Preferences); + inOptions = true; + var state = event.targetState; + var options = event.targetState.pages.get(PageName.Options); + var exit = options.items.members[options.items.length - 1]; + exit.y += 100; + options.items.remove(exit); + + var item = options.items.createItem(0, exit.y - 100, "Mod Bootstrap", "bold", function() + { + options.onSwitch.dispatch(PageName.Colors); + }); + item.x = (FlxG.width - item.width) / 2; + options.items.add(exit); + + var leech = event.targetState.addPage(PageName.Colors, new PreferencesMenu()); + leech.onExit.add(function() + { + state.switchPage(PageName.Options); + }); + for (shit in leech.items) + { + shit.destroy(); + } + for (shit in leech.preferenceItems) + { + shit.destroy(); + } + leech.items.clear(); + leech.preferenceItems.clear(); + + // basic options API + var options = ModuleHandler.getModule("InitBootStrap").scriptGet("options"); + for (i in options) + { + leech.createPrefItemCheckbox(i.name, i.description, function(value) + { + i.action(value); + }, i.variableToChange); + } + } + else if (fromBootStrapMenu && !Std.isOfType(event.targetState, OptionsState)) + { + FlxG.switchState(ScriptedMusicBeatState.init("BootStrapState")); + fromBootStrapMenu = false; + } + else if (Std.isOfType(event.targetState, ScriptedMusicBeatState)) + { + ModuleHandler.getModule("AdaptiveMusicController").scriptSet("stopRecordingPlaytime", false); + } + } - // basic options API - var options = ModuleHandler.getModule("InitBootStrap").scriptGet("options"); - for (i in options) { - leech.createPrefItemCheckbox(i.name, i.description, function(value){ - i.action(value); - }, i.variableToChange); - } - } else if(fromBootStrapMenu && !Std.isOfType(event.targetState, OptionsState)) + override function onStateChangeStart(event) + { + if (fromBootStrapMenu && Std.isOfType(event.targetState, MainMenuState)) { - FlxG.switchState(ScriptedMusicBeatState.init("BootStrapState")); - fromBootStrapMenu = false; - } else if (Std.isOfType(event.targetState, ScriptedMusicBeatState)) { - ModuleHandler.getModule("AdaptiveMusicController").scriptSet("stopRecordingPlaytime", false); - } - } - override function onStateChangeStart(event) { - if(fromBootStrapMenu && Std.isOfType(event.targetState, MainMenuState)) { - ModuleHandler.getModule("AdaptiveMusicController").scriptSet("stopRecordingPlaytime", true); - } - } + ModuleHandler.getModule("AdaptiveMusicController").scriptSet("stopRecordingPlaytime", true); + } + } } diff --git a/scripts/states/BaseTitleState.hxc b/scripts/states/BaseTitleState.hxc index 404a426..9a05527 100644 --- a/scripts/states/BaseTitleState.hxc +++ b/scripts/states/BaseTitleState.hxc @@ -1,15 +1,17 @@ import flixel.FlxG; - import funkin.Paths; import funkin.modding.base.ScriptedMusicBeatState; import funkin.ui.title.TitleState; -class BaseTitleState extends ScriptedMusicBeatState { - public function new() { +class BaseTitleState extends ScriptedMusicBeatState +{ + public function new() + { super(); } - public function create():Void { + public function create():Void + { super.create(); TitleState.initialized = false; diff --git a/scripts/states/BootStrapState.hxc b/scripts/states/BootStrapState.hxc index 3e6be56..ca97930 100644 --- a/scripts/states/BootStrapState.hxc +++ b/scripts/states/BootStrapState.hxc @@ -1,16 +1,13 @@ -import openfl.filters.ShaderFilter; - +import Main; import flixel.FlxG; +import flixel.FlxSprite; import flixel.addons.display.FlxBackdrop; import flixel.group.FlxTypedSpriteGroup; import flixel.math.FlxMath; import flixel.text.FlxText; -import flixel.tweens.FlxTween; import flixel.tweens.FlxEase; +import flixel.tweens.FlxTween; import flixel.util.FlxTimer; -import funkin.ui.options.OptionsState; -import flixel.FlxSprite; -import Main; import funkin.Paths; import funkin.PlayerSettings; import funkin.audio.FunkinSound; @@ -18,11 +15,14 @@ import funkin.modding.base.ScriptedMusicBeatState; import funkin.modding.module.ModuleHandler; import funkin.save.Save; import funkin.ui.freeplay.CapsuleText; +import funkin.ui.options.OptionsState; +import openfl.filters.ShaderFilter; -class BootStrapState extends ScriptedMusicBeatState { +class BootStrapState extends ScriptedMusicBeatState +{ var binds:Array; - var cur_select:Float = 0.0; // current selected mod index, float for math reasons. - var mods_rendered:Array = []; // This looks scary but i dont care nanna nanna boo boo!! + var cur_select:Float = 0.0; // current selected mod index, float for math reasons. + var mods_rendered:Array = []; // This looks scary but i dont care nanna nanna boo boo!! var mods_bg:Array = []; // collection of sprites if a mod has any. var intendedYs:Array = []; var intendedHandY:Float; @@ -43,29 +43,35 @@ class BootStrapState extends ScriptedMusicBeatState { var settings:Dynamic; var optionHeight:Int = 48; - public function new() { + public function new() + { super(); persistentUpdate = true; } - public function create():Void { + public function create():Void + { super.create(); settings = Save.instance.modOptions.get("ModBootstrapv2"); - if (settings.compact_mode) { + if (settings.compact_mode) + { optionHeight = 32; } // play music! - if (settings.play_music) { + if (settings.play_music) + { ModuleHandler.getModule("AdaptiveMusicController").scriptCall("play", ['modbootstrap-music-main']); - } else { + } + else + { if (FlxG.sound.music != null) FlxG.sound.music.stop(); } // set selected mod to nothin!!! - ModuleHandler.getModule("InitBootStrap").scriptCall("set_current_mod", ['']); + ModuleHandler.getModule("InitBootStrap").scriptCall("set_current_mod", ['']); // get da binds!!!!! - binds = ModuleHandler.getModule("BootStrapBinds").scriptGet("binds"); + binds = ModuleHandler.getModule("BootStrapBinds").scriptGet("binds"); // do da sexy note overlay thing bgOverlay = new FlxBackdrop(null, 0x01).loadGraphic(Paths.image('modloader-underlay')); @@ -75,7 +81,7 @@ class BootStrapState extends ScriptedMusicBeatState { bgOverlay.velocity.x = 30; // do da sexy bg thing - bg = new FlxSprite(0,0); + bg = new FlxSprite(0, 0); add(bg); handleBackgroundGroups(); @@ -88,63 +94,66 @@ class BootStrapState extends ScriptedMusicBeatState { Main.fpsCounter.alpha = 0; Main.memoryCounter.alpha = 0; - handSprite = new FlxSprite(340,0).loadGraphic(Paths.image('modloader-hand')); - handSprite.scale.set(2,2); + handSprite = new FlxSprite(340, 0).loadGraphic(Paths.image('modloader-hand')); + handSprite.scale.set(2, 2); add(handSprite); handSprite.flipX = true; handSprite.antialiasing = false; - logo = new FlxSprite(767,219).loadGraphic(Paths.image('base-game-logo')); + logo = new FlxSprite(767, 219).loadGraphic(Paths.image('base-game-logo')); add(logo); logo.screenCenter(); logo.x += 160; logo.y -= 40; - titleText = new FlxText(320,370,1280 - 320, "Friday Night Funkin", 64); + titleText = new FlxText(320, 370, 1280 - 320, "Friday Night Funkin", 64); titleText.setFormat('VCR OSD Mono', 64, 0xFFFFFFFF, 'center'); add(titleText); titleText.setBorderStyle(leftWatermarkText.borderStyle, 0xFF000000, 4); - disclaimerText = new FlxText(320,720 - 22,0, "Friday Night Funkin", 18); + disclaimerText = new FlxText(320, 720 - 22, 0, "Friday Night Funkin", 18); disclaimerText.setFormat('VCR OSD Mono', 18, 0xFFFFFFFF, 'left'); disclaimerText.setBorderStyle(leftWatermarkText.borderStyle, 0xFF000000, 1); add(disclaimerText); - descriptionTextBG = new FlxSprite(0,0).makeGraphic(1,1, 0xFF000000); - descriptionTextBG.alpha = 0.6; - add(descriptionTextBG); + descriptionTextBG = new FlxSprite(0, 0).makeGraphic(1, 1, 0xFF000000); + descriptionTextBG.alpha = 0.6; + add(descriptionTextBG); - descriptionText = new FlxText(360,540,1280 - 400, "Friday Night Funkin", 18); + descriptionText = new FlxText(360, 540, 1280 - 400, "Friday Night Funkin", 18); descriptionText.text = "Uh oh! Your tryin to kiss ur hot girlfriend, but her MEAN and EVIL dad is trying to KILL you! He's an ex-rockstar, the only way to get to his heart? The power of music..."; descriptionText.setFormat('VCR OSD Mono', 18, 0xFFFFFFFF, 'center'); add(descriptionText); updateTextBG(); handleBinds(); - - var modSelectTextBG = new FlxSprite(0,0).makeGraphic(320, 56, 0xFF101010); - add(modSelectTextBG); + var modSelectTextBG = new FlxSprite(0, 0).makeGraphic(320, 56, 0xFF101010); + add(modSelectTextBG); // do da sexy text thing - var modSelectText:CapsuleText = new CapsuleText(60,10, "MOD SELECT", 56); + var modSelectText:CapsuleText = new CapsuleText(60, 10, "MOD SELECT", 56); modSelectText.whiteText.setFormat('5by7', 36, 0xFFFFFFFF, 'center'); modSelectText.blurredText.setFormat('5by7', 36, 0xFF00ccff, 'center'); add(modSelectText); - var tooltipTextBG = new FlxSprite(0,720 - 48).makeGraphic(320, 48, 0xFF101010); - add(tooltipTextBG); + var tooltipTextBG = new FlxSprite(0, 720 - 48).makeGraphic(320, 48, 0xFF101010); + add(tooltipTextBG); // do da sexy text thing - var tooltipText:FlxText = new FlxText(8,720 - 46,320, "Press UP/DOWN to navigate.\nPress ACCEPT to enter.\nPress TAB to enter options.", 16); + var tooltipText:FlxText = new FlxText(8, 720 - 46, 320, "Press UP/DOWN to navigate.\nPress ACCEPT to enter.\nPress TAB to enter options.", 16); tooltipText.setFormat('VCR OSD Mono', 14, 0xFFFFFFFF, 'left'); add(tooltipText); } - public function updateTextBG() { - descriptionTextBG.setGraphicSize(Math.floor(descriptionText.fieldWidth + descriptionText.size/2), Math.floor(descriptionText.height + descriptionText.size/2)); + public function updateTextBG() + { + descriptionTextBG.setGraphicSize(Math.floor(descriptionText.fieldWidth + descriptionText.size / 2), + Math.floor(descriptionText.height + descriptionText.size / 2)); descriptionTextBG.updateHitbox(); } - public function handleBackgroundGroups() { - for (bind in binds) { - var bgGroup:FlxTypedSpriteGroup = new FlxTypedSpriteGroup(0,0); + public function handleBackgroundGroups() + { + for (bind in binds) + { + var bgGroup:FlxTypedSpriteGroup = new FlxTypedSpriteGroup(0, 0); add(bgGroup); mods_bg.push(bgGroup); bind.bg_group(bgGroup); @@ -152,28 +161,33 @@ class BootStrapState extends ScriptedMusicBeatState { } var columnHeight = 0.0; - public function handleBinds() { - for (bind in binds) { - var modRenderer:FlxTypedSpriteGroup = new FlxTypedSpriteGroup(8,0); + + public function handleBinds() + { + for (bind in binds) + { + var modRenderer:FlxTypedSpriteGroup = new FlxTypedSpriteGroup(8, 0); add(modRenderer); mods_rendered.push(modRenderer); var bindColor = bind.color; - var backgroundColor:FlxSprite = new FlxSprite(0,0).makeGraphic(312, optionHeight, bindColor); + var backgroundColor:FlxSprite = new FlxSprite(0, 0).makeGraphic(312, optionHeight, bindColor); modRenderer.add(backgroundColor); - var modText:FlxText = new FlxText(2,0,0, bind.name, 16); + var modText:FlxText = new FlxText(2, 0, 0, bind.name, 16); modText.setFormat('VCR OSD Mono', 24, 0xFFFFFFFF, 'left'); modRenderer.add(modText); - if (modText.fieldWidth >= 260) { + if (modText.fieldWidth >= 260) + { modText.scale.x = 260 / modText.fieldWidth; modText.updateHitbox(); } - if (!settings.compact_mode) { - var modTextAuthor:FlxText = new FlxText(4,24,0, 'By: "' + bind.author + '"', 14); + if (!settings.compact_mode) + { + var modTextAuthor:FlxText = new FlxText(4, 24, 0, 'By: "' + bind.author + '"', 14); modTextAuthor.setFormat('VCR OSD Mono', 14, 0xFFFFFFFF, 'left'); modRenderer.add(modTextAuthor); } - var modIcon:FlxSprite = new FlxSprite(312 - 36,optionHeight > 32 ? optionHeight / 8 : 0).loadGraphic(Paths.image(bind.icon)); + var modIcon:FlxSprite = new FlxSprite(312 - 36, optionHeight > 32 ? optionHeight / 8 : 0).loadGraphic(Paths.image(bind.icon)); modRenderer.add(modIcon); intendedYs.push(0); columnHeight += optionHeight + 4; @@ -183,53 +197,61 @@ class BootStrapState extends ScriptedMusicBeatState { updateSelection(0); } - function handleBindRender(e) { + function handleBindRender(e) + { var diffMult = 48 / optionHeight; var scrollY = 0; if (cur_select >= 4) FlxMath.bound(cur_select - 4, 0, (mods_rendered.length - 4) - (8.0 * diffMult)); - for (i in 0...mods_rendered.length) { + for (i in 0...mods_rendered.length) + { var modTitle = mods_rendered[i]; - intendedYs[i] = ((optionHeight + 4) * (i-scrollY)) + 58; + intendedYs[i] = ((optionHeight + 4) * (i - scrollY)) + 58; modTitle.y = FlxMath.lerp(modTitle.y, intendedYs[i], 0.2 - e); modTitle.color = (i != cur_select) ? 0xFFAFAFAF : 0xFFFFFFFF; } - descriptionTextBG.y = descriptionText.y - (descriptionText.size/4); - descriptionTextBG.x = descriptionText.x - (descriptionText.size/4); + descriptionTextBG.y = descriptionText.y - (descriptionText.size / 4); + descriptionTextBG.x = descriptionText.x - (descriptionText.size / 4); descriptionText.visible = descriptionTextBG.visible = (descriptionText.text != ''); } - public function update(e) { + public function update(e) + { super.update(e); handleBindRender(e); if (PlayerSettings.player1.controls.UI_DOWN_P && canMove) updateSelection(1); else if (PlayerSettings.player1.controls.UI_UP_P && canMove) updateSelection(-1); - else if (PlayerSettings.player1.controls.ACCEPT && canMove) { + else if (PlayerSettings.player1.controls.ACCEPT && canMove) + { FunkinSound.playOnce(Paths.sound("confirmMenu"), 0.75); canMove = false; FlxG.camera.flash(0xFFFFFFFF, 0.2); var version = ModuleHandler.getModule("InitBootStrap").scriptGet("version"); - var blackSprite = new FlxSprite(0,0).makeGraphic(1280,720,0xFF000000); + var blackSprite = new FlxSprite(0, 0).makeGraphic(1280, 720, 0xFF000000); add(blackSprite); var crazyText = new FlxText(4, 720 - 22, 0, "Press F8 to return to the ModBootstrap v" + version + ' menu at any time.', 16); crazyText.setFormat('VCR OSD Mono', 16, 0xFFFFFFFF, 'left'); add(crazyText); FlxG.sound.music.stop(); crazyText.scrollFactor.set(); - new FlxTimer().start(1.3, () -> { + new FlxTimer().start(1.3, () -> + { ModuleHandler.getModule("InitBootStrap").scriptCall("set_current_mod", [binds[cur_select].name]); Save.instance.flush(); FlxG.switchState(ScriptedMusicBeatState.init(binds[cur_select].target)); Main.fpsCounter.alpha = 1; Main.memoryCounter.alpha = 1; }); - } else if (FlxG.keys.justPressed.TAB && canMove) { + } + else if (FlxG.keys.justPressed.TAB && canMove) + { // openSubState(ScriptedMusicBeatState.init('BootStrapSettingsSubState')); // change of plans cuz substates hate me - if(settings.play_music) { + if (settings.play_music) + { ModuleHandler.getModule("AdaptiveMusicController").scriptCall("play", ['modbootstrap-music-settings']); } FlxG.switchState(new OptionsState()); @@ -239,10 +261,12 @@ class BootStrapState extends ScriptedMusicBeatState { intendedHandY = mods_rendered[cur_select].y + optionHeight / 4; handSprite.y = FlxMath.lerp(handSprite.y, intendedHandY, 0.4 - e); } - public function updateSelection(increment:Int) { + + public function updateSelection(increment:Int) + { if (increment != 0) FunkinSound.playOnce(Paths.sound("scrollMenu"), 0.75); - cur_select = FlxMath.wrap(cur_select+increment, 0, mods_rendered.length - 1); + cur_select = FlxMath.wrap(cur_select + increment, 0, mods_rendered.length - 1); // Animation shit. var logothing = binds[cur_select].logo; if (titleTween != null) @@ -253,14 +277,17 @@ class BootStrapState extends ScriptedMusicBeatState { bggTween.cancel(); if (descTween != null) descTween.cancel(); - if (logothing == '') { + if (logothing == '') + { logo.visible = false; titleText.visible = true; titleText.y = 350; titleText.alpha = 0; titleTween = FlxTween.tween(titleText, {y: titleText.y + 20, alpha: 1}, 0.2, {ease: FlxEase.quadOut}); titleText.text = binds[cur_select].name; - } else { + } + else + { logo.loadGraphic(Paths.image(logothing)); logo.visible = true; titleText.visible = false; @@ -270,17 +297,21 @@ class BootStrapState extends ScriptedMusicBeatState { logo.alpha = 0; titleTween = FlxTween.tween(logo, {y: logo.y + 20, alpha: 1}, 0.2, {ease: FlxEase.quadOut}); } - if (binds[cur_select].bg != '') { + if (binds[cur_select].bg != '') + { bg.visible = true; bg.x = 40; bg.alpha = 0; bg.loadGraphic(Paths.image(binds[cur_select].bg)); bgTween = FlxTween.tween(bg, {x: bg.x - 40, alpha: 1}, 0.2, {ease: FlxEase.quadOut}); - } else { + } + else + { bg.visible = false; } - for (i in 0...mods_bg.length) { + for (i in 0...mods_bg.length) + { mods_bg[i].visible = (i == cur_select); } mods_bg[cur_select].x = 40; diff --git a/scripts/states/FlxSplashLoader.hxc b/scripts/states/FlxSplashLoader.hxc index 5df981b..b53a3bd 100644 --- a/scripts/states/FlxSplashLoader.hxc +++ b/scripts/states/FlxSplashLoader.hxc @@ -1,23 +1,30 @@ import flixel.FlxG; import flixel.system.FlxSplash; -import funkin.save.Save; import funkin.Paths; import funkin.modding.base.ScriptedMusicBeatState; +import funkin.save.Save; import funkin.ui.title.TitleState; -class FlxSplashLoader extends ScriptedMusicBeatState { - var settings:Dynamic; - public function new() { +class FlxSplashLoader extends ScriptedMusicBeatState +{ + var settings:Dynamic; + + public function new() + { super(); } - public function create():Void { + public function create():Void + { super.create(); - settings = Save.instance.modOptions.get("ModBootstrapv2"); - if (settings.load_menu_on_boot) { - FlxG.switchState(new FlxSplash(ScriptedMusicBeatState.init("BootStrapState"))); - } else { - FlxG.switchState(new FlxSplash(new TitleState())); - } + settings = Save.instance.modOptions.get("ModBootstrapv2"); + if (settings.load_menu_on_boot) + { + FlxG.switchState(new FlxSplash(ScriptedMusicBeatState.init("BootStrapState"))); + } + else + { + FlxG.switchState(new FlxSplash(new TitleState())); + } } }