Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause gameplay while popups are visible #367

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions addons/popochiu/engine/cursor/cursor.gd
Original file line number Diff line number Diff line change
@@ -29,6 +29,8 @@ var is_blocked := false
#region Godot ######################################################################################
func _init() -> void:
Engine.register_singleton(&"Cursor", self)
# Allow cursor processing during gameplay pause
process_mode = PROCESS_MODE_ALWAYS


func _ready():
Original file line number Diff line number Diff line change
@@ -52,6 +52,8 @@ func _open() -> void:
func _close() -> void:
for c in lines_list.get_children():
(c as Control).queue_free()
# Unpause gameplay
get_tree().paused = false


#endregion
Original file line number Diff line number Diff line change
@@ -31,6 +31,8 @@ func _ready() -> void:
# Connect to singleton signals
PopochiuUtils.g.popup_requested.connect(_on_popup_requested)

# Don't pause popup processing during gameplay pause
process_mode = PROCESS_MODE_ALWAYS
close()


@@ -72,6 +74,8 @@ func open() -> void:
PopochiuUtils.e.gui.popups_stack.append(self)

show()
# Pause gameplay when a popup appears
get_tree().paused = true


## Closes the popup unlocking interactions with the graphic interface.
Original file line number Diff line number Diff line change
@@ -52,7 +52,10 @@ func _open() -> void:


func _close() -> void:
if not _slot: return
if not _slot:
# Unpause gameplay
get_tree().paused = false
return

slot_selected.emit()

Original file line number Diff line number Diff line change
@@ -11,6 +11,12 @@ func _open() -> void:

func _on_cancel() -> void:
sound_volumes.restore_last_volumes()
# Unpause gameplay
get_tree().paused = false


func _on_ok() -> void:
# Unpause gameplay
get_tree().paused = false

#endregion
Original file line number Diff line number Diff line change
@@ -37,4 +37,8 @@ func _on_continue_mode_toggled(toggled_on: bool) -> void:
PopochiuUtils.e.settings.auto_continue_text = toggled_on


func _on_cancel() -> void:
# Unpause gameplay
get_tree().paused = false

#endregion
Original file line number Diff line number Diff line change
@@ -200,12 +200,16 @@ func _on_inventory_item_selected(item: PopochiuInventoryItem) -> void:
## Called when the game is saved. By default, it shows [code]Game saved[/code] in the SystemText
## component.
func _on_game_saved() -> void:
# Unpause gameplay
get_tree().paused = false
PopochiuUtils.g.show_system_text("Game saved")


## Called when a game is loaded. [param loaded_game] has the loaded data. By default, it shows
## [code]Game loaded[/code] in the SystemText component.
func _on_game_loaded(loaded_game: Dictionary) -> void:
# Unpause gameplay
get_tree().paused = false
await PopochiuUtils.g.show_system_text("Game loaded")

super(loaded_game)
Original file line number Diff line number Diff line change
@@ -135,12 +135,16 @@ func _on_inventory_item_selected(item: PopochiuInventoryItem) -> void:
## Called when the game is saved. By default, it shows [code]Game saved[/code] in the SystemText
## component.
func _on_game_saved() -> void:
# Unpause gameplay
get_tree().paused = false
PopochiuUtils.g.show_system_text("Game saved")


## Called when a game is loaded. [param loaded_game] has the loaded data. By default, it shows
## [code]Game loaded[/code] in the SystemText component.
func _on_game_loaded(loaded_game: Dictionary) -> void:
# Unpause gameplay
get_tree().paused = false
await PopochiuUtils.g.show_system_text("Game loaded")

super(loaded_game)
Original file line number Diff line number Diff line change
@@ -182,12 +182,16 @@ func _on_inventory_item_selected(item: PopochiuInventoryItem) -> void:
## Called when the game is saved. By default, it shows [code]Game saved[/code] in the SystemText
## component.
func _on_game_saved() -> void:
# Unpause gameplay
get_tree().paused = false
PopochiuUtils.g.show_system_text("Game saved")


## Called when a game is loaded. [param loaded_game] has the loaded data. By default, it shows
## [code]Game loaded[/code] in the SystemText component.
func _on_game_loaded(loaded_game: Dictionary) -> void:
# Unpause gameplay
get_tree().paused = false
await PopochiuUtils.g.show_system_text("Game loaded")

super(loaded_game)
Original file line number Diff line number Diff line change
@@ -27,6 +27,8 @@ func _ready() -> void:
# Connect to childrens' signals
$AnimationPlayer.animation_finished.connect(_transition_finished)
$Curtain.modulate = PopochiuUtils.e.settings.fade_color
# Allow fades for save/load while gameplay is paused
process_mode = PROCESS_MODE_ALWAYS

# Make sure the transition layer is ready
# if it has to be visible in the first room