fix: sorting was not applied + context was not switched correctly
This commit is contained in:
parent
44a5d653fb
commit
45b1fe3f14
|
|
@ -2,7 +2,8 @@ extends PanelContainer
|
||||||
|
|
||||||
var area_dict = {
|
var area_dict = {
|
||||||
"dropzone_content": [],
|
"dropzone_content": [],
|
||||||
"post_its_in_list": []
|
"post_its_in_list": [],
|
||||||
|
"post_it_panels": []
|
||||||
}
|
}
|
||||||
enum ui_context {DROPZONE, POST_IT_LIST, ASSIGN_POST_IT}
|
enum ui_context {DROPZONE, POST_IT_LIST, ASSIGN_POST_IT}
|
||||||
|
|
||||||
|
|
@ -15,7 +16,6 @@ var has_stage = false:
|
||||||
has_stage = false
|
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 ...
|
|
||||||
for child in area_dict["dropzone_content"]+area_dict["post_its_in_list"]:
|
for child in area_dict["dropzone_content"]+area_dict["post_its_in_list"]:
|
||||||
if focus:
|
if focus:
|
||||||
child.process_mode = Node.PROCESS_MODE_INHERIT
|
child.process_mode = Node.PROCESS_MODE_INHERIT
|
||||||
|
|
@ -40,7 +40,7 @@ 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)
|
||||||
|
|
@ -57,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
|
||||||
|
|
||||||
|
# we should maybe consider moving this to _input() for consistency
|
||||||
if Input.is_action_just_pressed("ui_cancel"):
|
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"])
|
populate_board(["c_Joy","p_effort","c_backlash","c_body","c_hit","p_slut","p_worried_mother","p_cross_friend"])
|
||||||
|
|
||||||
|
|
@ -114,6 +116,10 @@ func populate_board(card_names: Array):
|
||||||
break
|
break
|
||||||
|
|
||||||
currently_selected_node = area_dict["dropzone_content"][0] # set first Card as currently selected node by default
|
currently_selected_node = area_dict["dropzone_content"][0] # set first Card as currently selected node by default
|
||||||
|
|
||||||
|
reorder_areas("dropzone_content")
|
||||||
|
reorder_areas("post_its_in_list")
|
||||||
|
|
||||||
|
|
||||||
# Handy function to filter an array of areas by the name of a card
|
# Handy function to filter an array of areas by the name of a card
|
||||||
func _find_area_by_string(area_arr: Array, name: String) -> Area2D:
|
func _find_area_by_string(area_arr: Array, name: String) -> Area2D:
|
||||||
|
|
@ -211,15 +217,17 @@ func handle_hover(to_handle: Area2D):
|
||||||
func reorder_areas(reorder: String):
|
func reorder_areas(reorder: String):
|
||||||
var old_order = area_dict[reorder]
|
var old_order = area_dict[reorder]
|
||||||
var new_order = Array()
|
var new_order = Array()
|
||||||
|
|
||||||
for obj in old_order:
|
for obj in old_order:
|
||||||
var i = 0
|
var i = 0
|
||||||
if !new_order.is_empty():
|
if !new_order.is_empty():
|
||||||
for obj_2 in new_order:
|
for obj_2 in new_order:
|
||||||
if obj_2.position.y < obj.position.y:
|
if obj_2.global_position.y < obj.global_position.y:
|
||||||
i += 1
|
i += 1
|
||||||
new_order.insert(i, obj)
|
new_order.insert(i, obj)
|
||||||
|
|
||||||
|
area_dict[reorder] = new_order
|
||||||
|
|
||||||
|
|
||||||
# Takes the inputs for control inputs
|
# Takes the inputs for control inputs
|
||||||
func _input(event):
|
func _input(event):
|
||||||
|
|
@ -246,12 +254,12 @@ func _input(event):
|
||||||
|
|
||||||
elif event.is_action_pressed("ui_left"): # left to switch context to the left
|
elif event.is_action_pressed("ui_left"): # left to switch context to the left
|
||||||
active_context -= 1
|
active_context -= 1
|
||||||
if active_context < 0:
|
if active_context < -1:
|
||||||
active_context = ui_context.POST_IT_LIST
|
active_context = ui_context.POST_IT_LIST
|
||||||
|
|
||||||
elif event.is_action_pressed("ui_right"): # right to switch context to the right
|
elif event.is_action_pressed("ui_right"): # right to switch context to the right
|
||||||
active_context += 1
|
active_context += 1
|
||||||
if active_context > 2:
|
if active_context > 1:
|
||||||
active_context = ui_context.DROPZONE
|
active_context = ui_context.DROPZONE
|
||||||
|
|
||||||
elif event.is_action_pressed("ui_accept"): # select the selected post it
|
elif event.is_action_pressed("ui_accept"): # select the selected post it
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue