fix: trying to make cards a bit more robust
This commit is contained in:
parent
9749736e7d
commit
666df45e06
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dysgoaaesqjbg" path="res://dev-util/hardcoded_cards.gd" id="1_5kg6w"]
|
[ext_resource type="Script" uid="uid://dysgoaaesqjbg" path="res://dev-util/hardcoded_cards.gd" id="1_5kg6w"]
|
||||||
|
|
||||||
[node name="Node2D" type="PanelContainer"]
|
[node name="HardcodedCards" type="PanelContainer"]
|
||||||
process_mode = 4
|
process_mode = 4
|
||||||
visible = false
|
visible = false
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
|
@ -11,4 +11,6 @@ anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
focus_behavior_recursive = 1
|
focus_behavior_recursive = 1
|
||||||
|
mouse_filter = 2
|
||||||
|
mouse_behavior_recursive = 1
|
||||||
script = ExtResource("1_5kg6w")
|
script = ExtResource("1_5kg6w")
|
||||||
|
|
|
||||||
|
|
@ -256,12 +256,9 @@ func exchange_sticky_note_with(new_note: StickyNote) -> StickyNote:
|
||||||
|
|
||||||
# === DROP TARGET PATTERN IMPLEMENTATION ===
|
# === DROP TARGET PATTERN IMPLEMENTATION ===
|
||||||
|
|
||||||
## Temporary storage for exchanged sticky during drop operation
|
|
||||||
var _last_exchanged_sticky: StickyNote = null
|
|
||||||
|
|
||||||
## Checks if this card can accept the given draggable
|
## Checks if this card can accept the given draggable
|
||||||
func can_accept_drop(draggable: Draggable) -> bool:
|
func can_accept_drop(draggable: Draggable) -> bool:
|
||||||
return draggable is StickyNote
|
return draggable is StickyNote and draggable != self
|
||||||
|
|
||||||
## Handles dropping a sticky note onto this card
|
## Handles dropping a sticky note onto this card
|
||||||
## Returns DropResult indicating success, rejection, or exchange
|
## Returns DropResult indicating success, rejection, or exchange
|
||||||
|
|
@ -271,10 +268,10 @@ func handle_drop(draggable: StickyNote) -> int:
|
||||||
|
|
||||||
if has_sticky_note_attached():
|
if has_sticky_note_attached():
|
||||||
# Exchange: remove current, attach new, store old for retrieval
|
# Exchange: remove current, attach new, store old for retrieval
|
||||||
_last_exchanged_sticky = exchange_sticky_note_with(draggable)
|
exchange_sticky_note_with(draggable)
|
||||||
# Reset z_index for newly attached sticky
|
# Reset z_index for newly attached sticky
|
||||||
draggable.z_index = 0
|
draggable.z_index = 0
|
||||||
return Draggable.DropResult.EXCHANGED
|
return Draggable.DropResult.ACCEPTED
|
||||||
else:
|
else:
|
||||||
# Simple attach
|
# Simple attach
|
||||||
if attach_sticky_note(draggable):
|
if attach_sticky_note(draggable):
|
||||||
|
|
@ -285,13 +282,6 @@ func handle_drop(draggable: StickyNote) -> int:
|
||||||
# Attach failed (shouldn't happen, but handle it)
|
# Attach failed (shouldn't happen, but handle it)
|
||||||
return Draggable.DropResult.REJECTED
|
return Draggable.DropResult.REJECTED
|
||||||
|
|
||||||
## Retrieves the sticky that was exchanged during last drop
|
|
||||||
## Clears the reference after retrieval
|
|
||||||
func get_last_exchanged_sticky() -> StickyNote:
|
|
||||||
var result := _last_exchanged_sticky
|
|
||||||
_last_exchanged_sticky = null
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
# === DRAG LIFECYCLE OVERRIDES ===
|
# === DRAG LIFECYCLE OVERRIDES ===
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ extends Area2D
|
||||||
enum DropResult {
|
enum DropResult {
|
||||||
ACCEPTED, # Drop successful, item is now owned by target
|
ACCEPTED, # Drop successful, item is now owned by target
|
||||||
REJECTED, # Drop refused, item stays with previous owner
|
REJECTED, # Drop refused, item stays with previous owner
|
||||||
EXCHANGED # Swap occurred, exchanged item needs handling
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var mouse_over: bool = false
|
var mouse_over: bool = false
|
||||||
|
|
@ -66,14 +65,14 @@ func _get_board() -> Node:
|
||||||
## Override these in Card and StickyNote for specific behavior
|
## Override these in Card and StickyNote for specific behavior
|
||||||
|
|
||||||
func _on_mouse_entered() -> void:
|
func _on_mouse_entered() -> void:
|
||||||
prints("Draggable[base]._on_mouse_entered", self, self.name)
|
#prints("Draggable[base]._on_mouse_entered", self, self.name)
|
||||||
mouse_over = true
|
mouse_over = true
|
||||||
var handler := _get_hover_handler()
|
var handler := _get_hover_handler()
|
||||||
if handler: handler.handle_hover(self)
|
if handler: handler.handle_hover(self)
|
||||||
|
|
||||||
|
|
||||||
func _on_mouse_exited() -> void:
|
func _on_mouse_exited() -> void:
|
||||||
prints("Draggable[base]._on_mouse_exited", self, self.name)
|
#prints("Draggable[base]._on_mouse_exited", self, self.name)
|
||||||
mouse_over = false
|
mouse_over = false
|
||||||
var handler := _get_hover_handler()
|
var handler := _get_hover_handler()
|
||||||
if handler: handler.handle_hover(self)
|
if handler: handler.handle_hover(self)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue