Skip to content

Commit 24905c4

Browse files
committed
FlxG.console: add registerEnum()
1 parent 9561538 commit 24905c4

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

flixel/system/debug/console/Console.hx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ using StringTools;
2525
/**
2626
* A powerful console for the flixel debugger screen with supports custom commands, registering
2727
* objects and functions and saves the last 25 commands used. Inspired by Eric Smith's "CoolConsole".
28-
* @link http://www.youtube.com/watch?v=QWfpw7elWk8
28+
* @see http://www.youtube.com/watch?v=QWfpw7elWk8
2929
*/
3030
class Console extends Window
3131
{
@@ -306,12 +306,23 @@ class Console extends Window
306306
/**
307307
* Register a new class to use in any command.
308308
*
309-
* @param cl The class to register.
309+
* @param cl The class to register.
310310
*/
311311
public inline function registerClass(cl:Class<Dynamic>)
312312
{
313313
registerObject(FlxStringUtil.getClassName(cl, true), cl);
314314
}
315+
316+
/**
317+
* Register a new enum to use in any command.
318+
*
319+
* @param e The enum to register.
320+
* @since 4.4.0
321+
*/
322+
public inline function registerEnum(e:Enum<Dynamic>)
323+
{
324+
registerObject(FlxStringUtil.getEnumName(e, true), e);
325+
}
315326

316327
override public function destroy()
317328
{

flixel/system/debug/console/ConsoleCommands.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class ConsoleCommands
6767
console.registerClass(FlxPoint);
6868
console.registerClass(FlxRect);
6969

70-
console.registerObject("FlxDebuggerLayout", FlxDebuggerLayout);
70+
console.registerEnum(FlxDebuggerLayout);
71+
7172
console.registerObject("selection", null);
7273
}
7374

flixel/system/frontEnds/ConsoleFrontEnd.hx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ConsoleFrontEnd
4646
/**
4747
* Register a new class to use in any command.
4848
*
49-
* @param cl The class to register.
49+
* @param cl The class to register.
5050
*/
5151
public inline function registerClass(cl:Class<Dynamic>):Void
5252
{
@@ -56,8 +56,18 @@ class ConsoleFrontEnd
5656
}
5757

5858
/**
59-
* Just needed to create an instance.
59+
* Register a new enum to use in any command.
60+
*
61+
* @param e The enum to register.
62+
* @since 4.4.0
6063
*/
64+
public inline function registerEnum(e:Enum<Dynamic>):Void
65+
{
66+
#if FLX_DEBUG
67+
FlxG.game.debugger.console.registerEnum(e);
68+
#end
69+
}
70+
6171
@:allow(flixel.FlxG)
6272
private function new() {}
6373
}

0 commit comments

Comments
 (0)