spawning panels by the amount of post its

This commit is contained in:
Adrian Schmid 2023-07-14 21:19:44 +02:00
parent 1a21997e82
commit 191882e991
1 changed files with 22 additions and 7 deletions

View File

@ -13,14 +13,16 @@ var has_stage = false:
self.mouse_filter = Control.MOUSE_FILTER_IGNORE self.mouse_filter = Control.MOUSE_FILTER_IGNORE
if is_node_ready(): if is_node_ready():
#fixme: thie should be replaced by a reference that holds all children ... #fixme: thie should be replaced by a reference that holds all children ...
for child in dropzone.get_children(): for child in area_dict["dropzone_content"]+area_dict["post_its_in_list"]:
child.on_stage = has_stage if focus:
for child in postit_container.get_children(): child.process_mode = Node.PROCESS_MODE_INHERIT
child.get_child(1).on_stage = has_stage else:
child.process_mode = Node.PROCESS_MODE_DISABLED
@onready var dropzone = $HBoxContainer/dropzone @onready var dropzone = $HBoxContainer/dropzone
@onready var postit_container = $HBoxContainer/ScrollContainer/VBoxContainer @onready var postit_container = $HBoxContainer/ScrollContainer/VBoxContainer
@onready var board_of_devs = $"board of devs" @onready var board_of_devs = $"board of devs"
@onready var base_postit_panel = $HBoxContainer/ScrollContainer/VBoxContainer/Panel
@onready var active_context = ui_context.DROPZONE # 0 = dropzone, 1 = post it list @onready var active_context = ui_context.DROPZONE # 0 = dropzone, 1 = post it list
var currently_selected_node: Area2D = null var currently_selected_node: Area2D = null
@ -35,8 +37,8 @@ var selected_card_for_assignment
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
#var test_arr = ["c_Joy","p_effort","c_backlash","c_body","c_hit","p_slut","p_worried_mother","p_cross_friend"] var test_arr = ["c_Joy","p_effort","c_backlash","c_body","c_hit","p_slut","p_worried_mother","p_cross_friend"]
var test_arr = ["c_Joy","c_body","c_hit"] #var test_arr = ["c_Joy","c_body","c_hit"]
populate_board(test_arr) populate_board(test_arr)
reorder_areas("dropzone_content") reorder_areas("dropzone_content")
@ -64,7 +66,19 @@ func populate_board(card_names: Array):
area_dict["post_its_in_list"] = Array() area_dict["post_its_in_list"] = Array()
# to remember panel positions # to remember panel positions
area_dict["post_it_panels"] = get_child(0).get_child(1).get_child(0).get_children() area_dict["post_it_panels"] = [base_postit_panel]
# check how many post-it panels we need
var amount = -1 # starting with -1 to compensate for the base panel
for card_name in card_names:
if "p_" in card_name:
amount += 1
while amount > 0: # creating panels up to the number of post-its
var new_panel = base_postit_panel.duplicate()
postit_container.add_child(new_panel)
new_panel.set_owner(self)
area_dict["post_it_panels"].push_back(new_panel)
amount -= 1
# get all the cards and post-its from the board of devs # get all the cards and post-its from the board of devs
for child in board_of_devs.get_children(): for child in board_of_devs.get_children():
@ -137,6 +151,7 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
if input.is_pressed(): if input.is_pressed():
reorder_areas("dropzone_content") reorder_areas("dropzone_content")
else: else:
dropzone.move_child(currently_dragged_area, -1)
currently_dragged_area = null currently_dragged_area = null
"post-it": # 2 = PostIt "post-it": # 2 = PostIt
if input.is_pressed(): if input.is_pressed():