From 24905c4b5aa57ae65ac1910417f3bc4840599923 Mon Sep 17 00:00:00 2001 From: Jens Fischer Date: Sun, 3 Sep 2017 16:07:10 +0200 Subject: [PATCH] FlxG.console: add registerEnum() --- flixel/system/debug/console/Console.hx | 15 +++++++++++++-- flixel/system/debug/console/ConsoleCommands.hx | 3 ++- flixel/system/frontEnds/ConsoleFrontEnd.hx | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/flixel/system/debug/console/Console.hx b/flixel/system/debug/console/Console.hx index 749e7d0c87..8fbf5fbd8d 100644 --- a/flixel/system/debug/console/Console.hx +++ b/flixel/system/debug/console/Console.hx @@ -25,7 +25,7 @@ using StringTools; /** * A powerful console for the flixel debugger screen with supports custom commands, registering * objects and functions and saves the last 25 commands used. Inspired by Eric Smith's "CoolConsole". - * @link http://www.youtube.com/watch?v=QWfpw7elWk8 + * @see http://www.youtube.com/watch?v=QWfpw7elWk8 */ class Console extends Window { @@ -306,12 +306,23 @@ class Console extends Window /** * Register a new class to use in any command. * - * @param cl The class to register. + * @param cl The class to register. */ public inline function registerClass(cl:Class) { registerObject(FlxStringUtil.getClassName(cl, true), cl); } + + /** + * Register a new enum to use in any command. + * + * @param e The enum to register. + * @since 4.4.0 + */ + public inline function registerEnum(e:Enum) + { + registerObject(FlxStringUtil.getEnumName(e, true), e); + } override public function destroy() { diff --git a/flixel/system/debug/console/ConsoleCommands.hx b/flixel/system/debug/console/ConsoleCommands.hx index 88f0b84f0c..28cb99bfd2 100644 --- a/flixel/system/debug/console/ConsoleCommands.hx +++ b/flixel/system/debug/console/ConsoleCommands.hx @@ -67,7 +67,8 @@ class ConsoleCommands console.registerClass(FlxPoint); console.registerClass(FlxRect); - console.registerObject("FlxDebuggerLayout", FlxDebuggerLayout); + console.registerEnum(FlxDebuggerLayout); + console.registerObject("selection", null); } diff --git a/flixel/system/frontEnds/ConsoleFrontEnd.hx b/flixel/system/frontEnds/ConsoleFrontEnd.hx index 3bd9be26fb..0f1c1ed86c 100644 --- a/flixel/system/frontEnds/ConsoleFrontEnd.hx +++ b/flixel/system/frontEnds/ConsoleFrontEnd.hx @@ -46,7 +46,7 @@ class ConsoleFrontEnd /** * Register a new class to use in any command. * - * @param cl The class to register. + * @param cl The class to register. */ public inline function registerClass(cl:Class):Void { @@ -56,8 +56,18 @@ class ConsoleFrontEnd } /** - * Just needed to create an instance. + * Register a new enum to use in any command. + * + * @param e The enum to register. + * @since 4.4.0 */ + public inline function registerEnum(e:Enum):Void + { + #if FLX_DEBUG + FlxG.game.debugger.console.registerEnum(e); + #end + } + @:allow(flixel.FlxG) private function new() {} } \ No newline at end of file