changing chekc using metadata to use class info
This commit is contained in:
parent
71a22dccef
commit
4d51a21876
|
|
@ -174,8 +174,8 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
|
|||
# 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 to_handle.get_meta("type"):
|
||||
"card": # 1 = Card
|
||||
if to_handle is Card:
|
||||
|
||||
active_context = ui_context.DROPZONE
|
||||
if input.is_pressed():
|
||||
reorder_areas("dropzone_content")
|
||||
|
|
@ -183,7 +183,7 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
|
|||
else:
|
||||
dropzone.move_child(currently_dragged_area, -1)
|
||||
currently_dragged_area = null
|
||||
"post-it": # 2 = PostIt
|
||||
elif to_handle is PostIt:
|
||||
if input.is_pressed():
|
||||
to_handle.reparent(dropzone)
|
||||
to_handle.on_board = true
|
||||
|
|
@ -195,7 +195,7 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
|
|||
if is_in_dropzone(to_handle):
|
||||
if to_handle.has_overlapping_areas():
|
||||
for area in to_handle.get_overlapping_areas():
|
||||
if area.get_meta("type") == "card":
|
||||
if area is Card:
|
||||
if !area.has_postit_attached():
|
||||
attach_postit_to_card(to_handle, area)
|
||||
else:
|
||||
|
|
@ -346,7 +346,7 @@ func _input(event):
|
|||
# Sets everything up to enter the context where postits can be assigned via button controls
|
||||
func _enter_assignment_context():
|
||||
# cards are currently not moved, only post its. Exit function if a card should be moved.
|
||||
if currently_selected_node == null or currently_selected_node.get_meta("type") != "post-it" : return
|
||||
if currently_selected_node == null or not currently_selected_node is PostIt : return
|
||||
|
||||
# if the postit is already attached, remove it and return it to the post it panels
|
||||
if currently_selected_node.is_postit_attached():
|
||||
|
|
|
|||
|
|
@ -65,8 +65,6 @@ var mouse_offset: Vector2
|
|||
|
||||
func _ready():
|
||||
|
||||
self.set_meta("type", "card") # set type information to find out if this node is a card
|
||||
|
||||
_handle_wiggle(0)
|
||||
if not Engine.is_editor_hint() and is_inside_tree():
|
||||
for postit in self.get_children():
|
||||
|
|
@ -155,7 +153,7 @@ func _move_card():
|
|||
func has_postit_attached() -> bool:
|
||||
var all_children = get_children()
|
||||
for child in all_children:
|
||||
if child.get_meta("type") == "post-it":
|
||||
if child is PostIt:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ var on_board = false
|
|||
|
||||
func _ready() -> void:
|
||||
|
||||
self.set_meta("type", "post-it") # set type information to find out if this node is a post-it
|
||||
|
||||
$Content/Label.text = self.text
|
||||
$Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)
|
||||
|
||||
|
|
@ -118,7 +116,7 @@ func _move_post_it():
|
|||
position += (get_viewport().get_mouse_position() - position) - mouse_offset
|
||||
|
||||
func is_postit_attached() -> bool:
|
||||
if self.get_parent().get_meta("type") == "card":
|
||||
if self.get_parent() is Card:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue