workaround for card board not being able to repopulate

This commit is contained in:
betalars 2023-07-19 13:52:01 +02:00
parent 1c6e752237
commit 6b5c758e7f
2 changed files with 24 additions and 5 deletions

View File

@ -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()
@ -230,6 +235,13 @@ func attach_postit_to_card(postit: Area2D, card: Area2D, update_dict = false):
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
func handle_hover(to_handle: Area2D):
@ -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)

View File

@ -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