Move the crash keybind into a global plugin.

This commit is contained in:
EliteMasterEric 2024-02-22 01:47:35 -05:00
parent 744e2f95bd
commit 0b49a88cdd
4 changed files with 49 additions and 9 deletions

View File

@ -202,8 +202,9 @@ class InitState extends FlxState
//
// Plugins provide a useful interface for globally active Flixel objects,
// that receive update events regardless of the current state.
// TODO: Move Module behavior to a Flixel plugin.
// TODO: Move scripted Module behavior to a Flixel plugin.
funkin.util.plugins.EvacuateDebugPlugin.initialize();
funkin.util.plugins.ForceCrashPlugin.initialize();
funkin.util.plugins.ReloadAssetsDebugPlugin.initialize();
funkin.util.plugins.ScreenshotPlugin.initialize();
funkin.util.plugins.VolumePlugin.initialize();

View File

@ -5258,14 +5258,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
{
// F1 = Open Help
if (FlxG.keys.justPressed.F1) this.openUserGuideDialog();
// DEBUG KEYBIND: Ctrl + Alt + Shift + L = Crash the game.
#if debug
if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.ALT && FlxG.keys.pressed.SHIFT && FlxG.keys.justPressed.L)
{
throw "DEBUG: Crashing the chart editor!";
}
#end
}
function handleQuickWatch():Void

View File

@ -133,6 +133,16 @@ class CrashHandler
fullContents += '=====================\n';
fullContents += '\n';
fullContents += 'Flixel Current State: ${Type.getClassName(Type.getClass(FlxG.state))}\n';
fullContents += '\n';
fullContents += '=====================\n';
fullContents += '\n';
fullContents += 'Haxelibs: \n';
for (lib in Constants.LIBRARY_VERSIONS)

View File

@ -0,0 +1,37 @@
package funkin.util.plugins;
import flixel.FlxBasic;
/**
* A plugin which forcibly crashes the application.
* TODO: Should we disable this in release builds?
*/
class ForceCrashPlugin extends FlxBasic
{
public function new()
{
super();
}
public static function initialize():Void
{
FlxG.plugins.addPlugin(new ForceCrashPlugin());
}
public override function update(elapsed:Float):Void
{
super.update(elapsed);
// Ctrl + Alt + Shift + L = Crash the game for debugging purposes
if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.ALT && FlxG.keys.pressed.SHIFT && FlxG.keys.justPressed.L)
{
// TODO: Make this message 87% funnier.
throw "DEBUG: Crashing the game via debug keybind!";
}
}
public override function destroy():Void
{
super.destroy();
}
}