remove dragableType and replace it with meta-type
This commit is contained in:
parent
c2188316ab
commit
45fb225e54
|
|
@ -54,7 +54,7 @@ func is_in_dropzone(to_check: Node) -> bool:
|
|||
else:
|
||||
return true
|
||||
|
||||
func handle_mouse_button(to_handle: Area2D, input: InputEvent, dragableType: int):
|
||||
func handle_mouse_button(to_handle: Area2D, input: InputEvent):
|
||||
|
||||
# No two areas can be dragged at the same time.
|
||||
# Make sure that only the same area is dragged.
|
||||
|
|
@ -70,14 +70,13 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent, dragableType: int
|
|||
# TODO: We need a better way to recognize whether "to_handle" is a Card or a Post-It.
|
||||
# (Tried checking for a script, didn't work, because script has no name attached.
|
||||
# Alternative might be to check for specific values within the script ("is_card" f.e))
|
||||
match dragableType:
|
||||
1: # 1 = Card
|
||||
match to_handle.get_meta("type"):
|
||||
"card": # 1 = Card
|
||||
if input.is_pressed():
|
||||
# TODO: Add function to rearrange the array based on positions in the dropzone
|
||||
print_debug(":)")
|
||||
reorder_areas("dropzone_content")
|
||||
else:
|
||||
currently_dragged_area = null
|
||||
2: # 2 = PostIt
|
||||
"post-it": # 2 = PostIt
|
||||
if input.is_pressed():
|
||||
to_handle.reparent(dropzone)
|
||||
to_handle.set_owner(self) # needs to be here otherwise the owner disappears
|
||||
|
|
|
|||
|
|
@ -111,5 +111,5 @@ func _on_input_event(viewport, event, shape_idx):
|
|||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if is_dragable and "handle_mouse_button" in owner:
|
||||
owner.handle_mouse_button(self, event, 1)
|
||||
owner.handle_mouse_button(self, event)
|
||||
|
||||
|
|
|
|||
|
|
@ -86,5 +86,5 @@ func _on_input_event(viewport, event, shape_idx):
|
|||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if is_dragable and "handle_mouse_button" in owner:
|
||||
owner.handle_mouse_button(self, event, 2)
|
||||
owner.handle_mouse_button(self, event)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue