PankuConsole icon indicating copy to clipboard operation
PankuConsole copied to clipboard

Incorrect game unpause

Open aromancev opened this issue 1 year ago • 1 comments

Describe the bug Game unpauses if it was paused before the console was opened.

To Reproduce Steps to reproduce the behavior:

  1. Pause the game via code on startup.
  2. Open the console.
  3. Observe that the game was unpaused.

Expected behavior Game pause state should never change when pause_if_input is false.

Desktop (please complete the following information):

  • OS: Windows

Additional context More specifically, this code in res://addons/panku_console/modules/interactive_shell/module.gd:

if _is_gui_open and pause_if_input:
    _was_tree_paused = core.get_tree().paused
    core.get_tree().paused = true
else:
    if core.get_tree().paused:
        core.get_tree().paused = _was_tree_paused

Never sets the correct value for _was_tree_paused because pause_if_input is always false. It should probably be something like this instead:

if pause_if_input:
	if _is_gui_open:
		_was_tree_paused = core.get_tree().paused
		core.get_tree().paused = true
	else:
		if core.get_tree().paused:
			core.get_tree().paused = _was_tree_paused

Sorry, I don't have time to create a PR or check for unintended side effects of that change at the moment.

aromancev avatar Sep 21 '24 13:09 aromancev

Thanks for report, you solution seems good, no side effects I can see.

worron avatar Sep 21 '24 15:09 worron