Skip to content

Commit

Permalink
Console: only unpause if pausing didn't happen through the UI
Browse files Browse the repository at this point in the history
That way, the console doesn't "override the user's pause".
  • Loading branch information
Gama11 committed Mar 15, 2017
1 parent d354352 commit 56854fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions flixel/system/debug/VCR.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class VCR

public var runtime:Float = 0;

/**
* `true` if the pause happened via the debugger UI, `false` if it happened programmatically
* (or if the VCR is not paused at all right now).
*/
public var manualPause(default, null):Bool = false;

public var playbackToggleBtn:FlxSystemButton;
public var stepBtn:FlxSystemButton;
public var restartBtn:FlxSystemButton;
Expand All @@ -63,7 +69,7 @@ class VCR
openBtn.alpha = 0.3;
#end
#end
playbackToggleBtn = Debugger.addButton(CENTER, new GraphicPause(0, 0), FlxG.vcr.pause);
playbackToggleBtn = Debugger.addButton(CENTER, new GraphicPause(0, 0), onManualPause);
stepBtn = Debugger.addButton(CENTER, new GraphicStep(0, 0), onStep);

#if FLX_RECORD
Expand Down Expand Up @@ -130,12 +136,18 @@ class VCR
}
#end

private function onManualPause()
{
manualPause = true;
FlxG.vcr.pause();
}

/**
* Called when the user presses the Pause button.
* This is different from user-defined pause behavior, or focus lost behavior.
* Does NOT pause music playback!!
*/
public inline function onPause():Void
public function onPause():Void
{
playbackToggleBtn.upHandler = FlxG.vcr.resume;
playbackToggleBtn.changeIcon(new GraphicArrowRight(0, 0));
Expand All @@ -145,9 +157,10 @@ class VCR
* Called when the user presses the Play button.
* This is different from user-defined unpause behavior, or focus gained behavior.
*/
public inline function onResume():Void
public function onResume():Void
{
playbackToggleBtn.upHandler = FlxG.vcr.pause;
manualPause = false;
playbackToggleBtn.upHandler = onManualPause;
playbackToggleBtn.changeIcon(new GraphicPause(0, 0));
}

Expand Down
2 changes: 1 addition & 1 deletion flixel/system/debug/console/Console.hx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class Console extends Window

#if FLX_DEBUG
// Unpause game
if (FlxG.console.autoPause)
if (FlxG.console.autoPause && !FlxG.game.debugger.vcr.manualPause)
FlxG.vcr.resume();

// Unblock keyboard input
Expand Down

0 comments on commit 56854fc

Please sign in to comment.