wip: restructuring card board so it can handle being empty
This commit is contained in:
parent
fc1cd50430
commit
44a5d653fb
|
|
@ -1,6 +1,9 @@
|
||||||
extends PanelContainer
|
extends PanelContainer
|
||||||
|
|
||||||
var area_dict = {}
|
var area_dict = {
|
||||||
|
"dropzone_content": [],
|
||||||
|
"post_its_in_list": []
|
||||||
|
}
|
||||||
enum ui_context {DROPZONE, POST_IT_LIST, ASSIGN_POST_IT}
|
enum ui_context {DROPZONE, POST_IT_LIST, ASSIGN_POST_IT}
|
||||||
|
|
||||||
var has_stage = false:
|
var has_stage = false:
|
||||||
|
|
@ -40,8 +43,8 @@ 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")
|
||||||
active_context = ui_context.DROPZONE
|
active_context = ui_context.DROPZONE
|
||||||
|
|
||||||
has_stage = has_stage
|
has_stage = has_stage
|
||||||
|
|
@ -54,6 +57,8 @@ func _process(delta):
|
||||||
currently_dragged_area.is_dragged = false
|
currently_dragged_area.is_dragged = false
|
||||||
is_area_dragged = false
|
is_area_dragged = false
|
||||||
currently_dragged_area = null
|
currently_dragged_area = null
|
||||||
|
if Input.is_action_just_pressed("ui_cancel"):
|
||||||
|
populate_board(["c_Joy","p_effort","c_backlash","c_body","c_hit","p_slut","p_worried_mother","p_cross_friend"])
|
||||||
|
|
||||||
|
|
||||||
# Will be used later to spawn Cards and Post-Its and remember them in the dictionary
|
# Will be used later to spawn Cards and Post-Its and remember them in the dictionary
|
||||||
|
|
@ -61,10 +66,6 @@ func populate_board(card_names: Array):
|
||||||
var all_cards = Array()
|
var all_cards = Array()
|
||||||
var all_postits = Array()
|
var all_postits = Array()
|
||||||
|
|
||||||
# define entries in dictionary
|
|
||||||
area_dict["dropzone_content"] = Array()
|
|
||||||
area_dict["post_its_in_list"] = Array()
|
|
||||||
|
|
||||||
# to remember panel positions
|
# to remember panel positions
|
||||||
area_dict["post_it_panels"] = [base_postit_panel]
|
area_dict["post_it_panels"] = [base_postit_panel]
|
||||||
|
|
||||||
|
|
@ -95,10 +96,11 @@ func populate_board(card_names: Array):
|
||||||
for child in new_card.get_children(): # We need to clear all the post-its from the cards on the dev-board
|
for child in new_card.get_children(): # We need to clear all the post-its from the cards on the dev-board
|
||||||
if "p_" in child.name:
|
if "p_" in child.name:
|
||||||
new_card.remove_child(child) # dev-board has post-its attached to the cards, which need to be removed
|
new_card.remove_child(child) # dev-board has post-its attached to the cards, which need to be removed
|
||||||
|
new_card.position = Vector2(randi_range(0, dropzone.size.x), randi_range(0, dropzone.size.y))
|
||||||
dropzone.add_child(new_card)
|
dropzone.add_child(new_card)
|
||||||
new_card.set_owner(self)
|
new_card.set_owner(self)
|
||||||
area_dict["dropzone_content"].push_back(new_card)
|
area_dict["dropzone_content"].push_back(new_card)
|
||||||
new_card.global_position = Vector2(500, 500) # using hard-coded position because I'm lazy
|
#new_card.position = Vector2(randf_range(new_card.diameter, dropzone.size.x), randf_range(new_card.diameter, dropzone.size.y)) - Vector2(new_card.diameter/2, new_card.diameter/2)
|
||||||
new_card.is_dragable = true
|
new_card.is_dragable = true
|
||||||
if "p_" in card_name: # spawning a post-it
|
if "p_" in card_name: # spawning a post-it
|
||||||
var new_postit = _find_area_by_string(all_postits, card_name).duplicate()
|
var new_postit = _find_area_by_string(all_postits, card_name).duplicate()
|
||||||
|
|
@ -222,7 +224,7 @@ func reorder_areas(reorder: String):
|
||||||
# Takes the inputs for control inputs
|
# Takes the inputs for control inputs
|
||||||
func _input(event):
|
func _input(event):
|
||||||
# Return, if the input is a mouse event (mouse events are handled separately)
|
# Return, if the input is a mouse event (mouse events are handled separately)
|
||||||
if event is InputEventMouse or !has_stage: return
|
if event is InputEventMouse or !has_stage or not is_instance_valid(currently_selected_node): return
|
||||||
|
|
||||||
if event.is_action_pressed("ui_up"): # up to select an element above
|
if event.is_action_pressed("ui_up"): # up to select an element above
|
||||||
match active_context:
|
match active_context:
|
||||||
|
|
@ -252,7 +254,7 @@ func _input(event):
|
||||||
if active_context > 2:
|
if active_context > 2:
|
||||||
active_context = ui_context.DROPZONE
|
active_context = ui_context.DROPZONE
|
||||||
|
|
||||||
elif event.is_action_pressed("ui_select"): # select the selected post it
|
elif event.is_action_pressed("ui_accept"): # select the selected post it
|
||||||
if active_context == ui_context.ASSIGN_POST_IT: # to assign it to a card
|
if active_context == ui_context.ASSIGN_POST_IT: # to assign it to a card
|
||||||
attach_postit_to_card(currently_selected_node,
|
attach_postit_to_card(currently_selected_node,
|
||||||
currently_selected_card_for_assigning, true)
|
currently_selected_card_for_assigning, true)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue