Skip to content

Commit

Permalink
FlxG.console: add registerEnum()
Browse files Browse the repository at this point in the history
  • Loading branch information
Gama11 committed Sep 3, 2017
1 parent 9561538 commit 24905c4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
15 changes: 13 additions & 2 deletions flixel/system/debug/console/Console.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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<Dynamic>)
{
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<Dynamic>)
{
registerObject(FlxStringUtil.getEnumName(e, true), e);
}

override public function destroy()
{
Expand Down
3 changes: 2 additions & 1 deletion flixel/system/debug/console/ConsoleCommands.hx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class ConsoleCommands
console.registerClass(FlxPoint);
console.registerClass(FlxRect);

console.registerObject("FlxDebuggerLayout", FlxDebuggerLayout);
console.registerEnum(FlxDebuggerLayout);

console.registerObject("selection", null);
}

Expand Down
14 changes: 12 additions & 2 deletions flixel/system/frontEnds/ConsoleFrontEnd.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dynamic>):Void
{
Expand All @@ -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<Dynamic>):Void
{
#if FLX_DEBUG
FlxG.game.debugger.console.registerEnum(e);
#end
}

@:allow(flixel.FlxG)
private function new() {}
}

0 comments on commit 24905c4

Please sign in to comment.