From e802c61bc3151355dbd81ecfbc7b277ea6c07bfb Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 21 Aug 2016 15:53:07 -0400 Subject: [PATCH] Optional step after console command (#1910) + console cleanup --- flixel/system/debug/console/Console.hx | 9 +++------ flixel/system/debug/console/ConsoleCommands.hx | 11 +++++++---- flixel/system/frontEnds/ConsoleFrontEnd.hx | 6 ++++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/flixel/system/debug/console/Console.hx b/flixel/system/debug/console/Console.hx index e34ac1aa20..77600eeb37 100644 --- a/flixel/system/debug/console/Console.hx +++ b/flixel/system/debug/console/Console.hx @@ -149,11 +149,9 @@ class Console extends Window #end #if FLX_DEBUG - #if flash // Pause game if (FlxG.console.autoPause) FlxG.vcr.pause(); - #end // Block keyboard input #if FLX_KEYBOARD @@ -174,11 +172,10 @@ class Console extends Window #end #if FLX_DEBUG - #if flash // Unpause game if (FlxG.console.autoPause) FlxG.vcr.resume(); - #end + // Unblock keyboard input #if FLX_KEYBOARD FlxG.keys.enabled = true; @@ -246,8 +243,8 @@ class Console extends Window history.addCommand(input.text); // Step forward one frame to see the results of the command - #if (flash && FLX_DEBUG) - if (FlxG.vcr.paused) + #if FLX_DEBUG + if (FlxG.vcr.paused && FlxG.console.stepAfterCommand) FlxG.game.debugger.vcr.onStep(); #end diff --git a/flixel/system/debug/console/ConsoleCommands.hx b/flixel/system/debug/console/ConsoleCommands.hx index fe2b458f78..34fcd0d8c3 100644 --- a/flixel/system/debug/console/ConsoleCommands.hx +++ b/flixel/system/debug/console/ConsoleCommands.hx @@ -18,7 +18,6 @@ class ConsoleCommands public function new(console:Console):Void { - #if FLX_DEBUG _console = console; console.registerFunction("help", help, "Displays the help text of a registered object or function. See \"help\"."); @@ -32,6 +31,7 @@ class ConsoleCommands console.registerFunction("listObjects", listObjects, "Lists the aliases of all registered objects."); console.registerFunction("listFunctions", listFunctions, "Lists the aliases of all registered functions."); + console.registerFunction("step", step, "Steps the game forward one frame if currently paused. No effect if unpaused."); console.registerFunction("pause", pause, "Toggles the game between paused and unpaused."); console.registerFunction("clearBitmapLog", FlxG.bitmapLog.clear, "Clears the bitmapLog window."); @@ -58,7 +58,6 @@ class ConsoleCommands console.registerClass(FlxSprite); console.registerClass(FlxMath); console.registerClass(FlxTween); - #end } private function help(?Alias:String):String @@ -91,7 +90,6 @@ class ConsoleCommands } } - #if FLX_DEBUG private inline function close():Void { FlxG.debugger.visible = false; @@ -172,6 +170,11 @@ class ConsoleCommands ConsoleUtil.log("pause: Game paused"); } } - #end + + private function step():Void + { + if (FlxG.vcr.paused) + FlxG.game.debugger.vcr.onStep(); + } } #end diff --git a/flixel/system/frontEnds/ConsoleFrontEnd.hx b/flixel/system/frontEnds/ConsoleFrontEnd.hx index 5aa20fa5d4..39e8110ded 100644 --- a/flixel/system/frontEnds/ConsoleFrontEnd.hx +++ b/flixel/system/frontEnds/ConsoleFrontEnd.hx @@ -9,6 +9,12 @@ class ConsoleFrontEnd */ public var autoPause:Bool = true; + /** + * Whether the console should step() the game after a command is entered. + * Setting this to false allows inputting multiple console commands within the same frame. Use the "step()" command to step the game from the console. + */ + public var stepAfterCommand:Bool = true; + /** * Register a new function to use in any command. *