Skip to content
Merged
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
22 changes: 17 additions & 5 deletions scenes/ui_elements/input_hints/components/input_hud.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
extends CanvasLayer

var player: Player
var sokoban_ruleset: RuleEngine

@onready var normal_controls := %NormalControls
@onready var interact_input_hint := %InteractInputHint
Expand All @@ -17,6 +18,9 @@ var player: Player
func _ready() -> void:
get_tree().scene_changed.connect(_on_scene_changed)

Transitions.started.connect(_update_visibility)
Transitions.finished.connect(_update_visibility)

# When running a scene that contains a player directly, this node becomes
# ready before the player. Defer the initial setup so that we can assume the
# whole scene (and in particular the player) is ready in
Expand All @@ -28,10 +32,11 @@ func _ready() -> void:

func _on_scene_changed() -> void:
player = get_tree().get_first_node_in_group("player")
var sokoban_ruleset: RuleEngine = get_tree().get_first_node_in_group("sokoban_ruleset")
sokoban_ruleset = get_tree().get_first_node_in_group("sokoban_ruleset")

_update_visibility()

if player:
visible = true
normal_controls.visible = true

player.player_interaction.can_interact_changed.connect(_update_player_state)
Expand All @@ -40,12 +45,19 @@ func _on_scene_changed() -> void:

_update_player_state()
elif sokoban_ruleset:
visible = true
sokoban_controls.visible = true
skip_input_hint.visible = false
sokoban_ruleset.skip_enabled.connect(_display_skip)
else:
visible = false


func _update_visibility() -> void:
visible = not get_tree().paused and not Transitions.is_running() and (player or sokoban_ruleset)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍



func _notification(what: int) -> void:
match what:
NOTIFICATION_PAUSED, NOTIFICATION_UNPAUSED:
_update_visibility()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware of these notifications, nice. This does the job.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nor was I, till I searched while writing this. I like this because it keeps InputHud & PauseOverlay ignorant of each other.

Of course… you might imagine in future we could put the InputHud over the PauseOverlay and show the arrow keys plus "[ space ] Click" or something. Another day.



func _update_player_state() -> void:
Expand Down
Loading