From 6b5c758e7fefa7bc51ed64f3e057a5140d5e815b Mon Sep 17 00:00:00 2001 From: betalars Date: Wed, 19 Jul 2023 13:52:01 +0200 Subject: [PATCH] workaround for card board not being able to repopulate --- src/logic-scenes/board/card-board.gd | 27 +++++++++++++++++++---- src/logic-scenes/board/physics-board.tscn | 2 +- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index d10424c..93f1f3b 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -22,6 +22,7 @@ var has_stage = false: child.process_mode = Node.PROCESS_MODE_INHERIT else: child.process_mode = Node.PROCESS_MODE_DISABLED + visible = has_stage @onready var dropzone = $HBoxContainer/dropzone @onready var postit_container = $HBoxContainer/ScrollContainer/VBoxContainer @@ -52,6 +53,10 @@ var selected_dropzone_element: int = -1 var selected_postit_list_element: int = 0 var selected_card_for_assignment +var cache: Array = [] + +signal board_completed + # Called when the node enters the scene tree for the first time. func _ready(): @@ -73,15 +78,15 @@ func _process(delta): is_area_dragged = false currently_dragged_area = null - # we should maybe consider moving this to _input() for consistency - if Input.is_action_just_pressed("ui_cancel"): - populate_board(["c_Joy","p_effort","c_backlash","c_body","c_void","p_reward","p_worried_mother","p_cross_friend"]) - # Will be used later to spawn Cards and Post-Its and remember them in the dictionary func populate_board(card_names: Array): mementos_collected += 1 + cache.append(card_names) + + if mementos_collected < 4: return + else: card_names = cache var all_cards = Array() var all_postits = Array() @@ -229,6 +234,13 @@ func attach_postit_to_card(postit: Area2D, card: Area2D, update_dict = false): reorder_areas("dropzone_content") reorder_areas("cards") reorder_areas("post_its_in_list") + + if mementos_collected == 4: + for fluff in area_dict["dropzone_content"]: + if fluff is Card: + if not fluff.has_postit_attached(): + return + emit_signal("board_completed") # Mark area that was hovered over as currently selected @@ -264,6 +276,9 @@ func reorder_areas(reorder: String): # Takes the inputs for control inputs func _input(event): + + if event.is_action_pressed("ui_cancel"): + State.leave_stage(self) # Return, if the input is a mouse event (mouse events are handled separately) if event is InputEventMouse or !has_stage or not is_instance_valid(currently_selected_node): return @@ -390,4 +405,8 @@ func _return_postit_to_panels(post_it: Area2D): reorder_areas("post_its_in_list") break +func on_scene_skipped(i: int): + mementos_collected += i +func claim_focus(): + State.pass_stage_to(self) diff --git a/src/logic-scenes/board/physics-board.tscn b/src/logic-scenes/board/physics-board.tscn index c98f8c1..ed617c1 100644 --- a/src/logic-scenes/board/physics-board.tscn +++ b/src/logic-scenes/board/physics-board.tscn @@ -144,7 +144,7 @@ layout_mode = 2 [node name="cards_remaining" type="Label" parent="instructions_panel/HBoxContainer"] layout_mode = 2 size_flags_vertical = 0 -text = "Collect Mementos to fill the mind-board." +text = "Collect all four Mementos to fill the mind-board. " horizontal_alignment = 1 vertical_alignment = 1