From 1c6e7522379eb0969d779cb8e93bdf6f587b7ff7 Mon Sep 17 00:00:00 2001 From: betalars Date: Wed, 19 Jul 2023 13:51:26 +0200 Subject: [PATCH] implement skipping functionality --- .../collectable/collectable_ui.gd | 36 ++++++++++++++----- .../collectable/collectable_ui.tscn | 4 +++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/logic-scenes/collectable/collectable_ui.gd b/src/logic-scenes/collectable/collectable_ui.gd index 07da6c9..a102a24 100644 --- a/src/logic-scenes/collectable/collectable_ui.gd +++ b/src/logic-scenes/collectable/collectable_ui.gd @@ -21,7 +21,11 @@ class_name Collectable_Ui if collapse and has_stage: State.leave_stage(self) -@export var is_story: bool = false +@export var is_story: bool = false: + set(story): + is_story = story + if not story: + $Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "Order Thoughts" @export var has_stage: bool = false: set(focused): print("set focus of card to ", focused) @@ -29,14 +33,11 @@ class_name Collectable_Ui if has_stage == focused: return if focused: + owner.reveal() has_stage = true - print(visible) - if not visible: show() collapsed = false - if collected: - $Panel/Content/Buttons/VBoxContainer/put_back.grab_focus() - else: - $Panel/Content/Buttons/VBoxContainer/collect_or_listen.grab_focus() + if not visible: show() + $Panel/Content/Buttons/VBoxContainer/collect_or_listen.grab_focus() elif has_stage: has_stage = false get_viewport().gui_release_focus() @@ -72,6 +73,8 @@ class_name Collectable_Ui $Panel/Content/ContentNotes.text = new_notes signal card_collected +signal open_board +signal scene_skipped(i: int) # Called when the node enters the scene tree for the first time. func _ready(): @@ -82,6 +85,7 @@ func _ready(): item_name = item_name content_notes = content_notes + is_story = is_story func _hide_buttons(): if is_inside_tree(): @@ -108,6 +112,8 @@ func hide(): func show(): if !visible: + $Panel/Content/ContentNotes.visible = State.show_content_notes + $Panel/Content/Buttons/VBoxContainer/skip.visible = State.allow_skipping and is_story and not skipped if not collapsed: _show_buttons() modulate = Color() @@ -122,8 +128,22 @@ func _yoink_focus(): func _on_pick_button_pressed(): print("card collected!") if scene != null: - get_tree().call_group("animation_player", "play_scene", scene) + get_tree().call_group("animation_player", "play_scene", scene, collected) + if skipped: emit_signal("scene_skipped", -1) + collected = true + else: + emit_signal("open_board") State.leave_stage(self) func _on_pick_button_released(): hide() + + +func _on_skip_pressed(): + print("Scene skipped!") + if scene != null: + emit_signal("scene_skipped", 1) + skipped = true + $Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "collect (un-skip)" + + State.leave_stage(self) diff --git a/src/logic-scenes/collectable/collectable_ui.tscn b/src/logic-scenes/collectable/collectable_ui.tscn index 09070c1..57b30e7 100644 --- a/src/logic-scenes/collectable/collectable_ui.tscn +++ b/src/logic-scenes/collectable/collectable_ui.tscn @@ -137,18 +137,21 @@ text = "Collect" script = SubResource("GDScript_g0qhf") [node name="Summary" type="Button" parent="Panel/Content/Buttons/VBoxContainer"] +visible = false layout_mode = 2 tooltip_text = "Take this with you, but get a neutral description of it's story." text = "get neutral summary" script = SubResource("GDScript_g0qhf") [node name="skip" type="Button" parent="Panel/Content/Buttons/VBoxContainer"] +visible = false layout_mode = 2 tooltip_text = "Choose this to entirely skip this Item without being unable to progress in the story. Skipped Segments can still be interacted with via the Pause Screen, if you decide to change your mind." text = "skip" script = SubResource("GDScript_g0qhf") [node name="put_back" type="Button" parent="Panel/Content/Buttons/VBoxContainer"] +visible = false layout_mode = 2 text = "put back" script = SubResource("GDScript_g0qhf") @@ -172,4 +175,5 @@ libraries = { [connection signal="pressed" from="Panel/Content/Buttons/VBoxContainer/collect_or_listen" to="." method="_on_pick_button_pressed"] [connection signal="focus_entered" from="Panel/Content/Buttons/VBoxContainer/Summary" to="." method="_yoink_focus"] [connection signal="focus_entered" from="Panel/Content/Buttons/VBoxContainer/skip" to="." method="_yoink_focus"] +[connection signal="pressed" from="Panel/Content/Buttons/VBoxContainer/skip" to="." method="_on_skip_pressed"] [connection signal="focus_entered" from="Panel/Content/Buttons/VBoxContainer/put_back" to="." method="_yoink_focus"]