Open Arcadia822 opened 1 month ago
Your question is pretty hard to follow, could you share the code for your custom dropzone? My guess is you need to add a super()
call to your code, something like:
class_name MyDropzone extends CardDropzone
func card_ui_dropped(card_ui: CardUI):
super(card_ui)
# your code goes here
do_something()
do_something_else()
Also note that you might not want to call super()
if you don't want to do exactly what it does, and in this case you might need to reimplement bits and pieces of its functionality. I'm working on a series of PRs to modularise a lot of the add-on, so it will be easier to hook in your own code.
In case you're not familiar with super()
, have a look at the Godot docs.
My custom CardDropzone
extends CardDropzone
@onready var game = get_parent()
func _ready():
pass # Replace with function body.
func card_ui_dropped(card_ui: CardUI):
super(card_ui)
# card_pile_ui.set_card_dropzone(card_ui, self)
game.play_card(card_ui.card_data)
Thanks for the reply. I checked card_ui_dropped
and found I didn't call it but insteadly manually called set_card_dropzone
.
Though replace it with super(card_ui)
didn't change the problem.
Also I checked the code inside set_card_dropzone
. It looks nothing to do with the signal card_hovered
, card_clicked
since they are connected inside card_pile_ui._create_card_ui
I take some screenshots and my codes.
@Arcadia822: ah, I see. Just to confirm, since you say "custom dropzone", does it work with stock CardDropzone
, without any of your modifications? Cards in dropzones generally don't respond to input at the moment, and my first instinct was to look at can_be_interacted_with()
, but you've already done and answered most of what I was going to ask, so good job there :)
Actually, I looked at your tree again, and I'm 90% sure I know what the issue is. Try dragging your CardPileUI
so that it's below any dropzones in the tree (and just above UI
in your case). The order of nodes is lower-on-top, ie. amongst siblings, the one that comes later will be the one on top. It's predictable, but can trip you up if you don't know it.
Actually, I looked at your tree again, and I'm 90% sure I know what the issue is. Try dragging your
CardPileUI
so that it's below any dropzones in the tree (and just aboveUI
in your case). The order of nodes is lower-on-top, ie. amongst siblings, the one that comes later will be the one on top. It's predictable, but can trip you up if you don't know it.
Instant fix. I even don't notice node order matters :joy: . Maybe I should read the docs again. Thanks a lot again.
I checked the Node / Signal section of godot docs and didn't find an explain.
This looks quite different from web / application development. Intuitively I thought script order should only affect execution order of setup hooks like _ready()
and frame loop process like _process()
. I don't understand why node order affect signal hooks.
It doesn't! Signals are received just fine regardless of where the node sits in the tree, it's just that for display and input purposes, the nodes are drawn from the top of the tree down, meaning the ones further down will be drawn in front of the ones up the tree. And the ones that are in front are also the ones that receive input from the engine (unless you change their z-index).
Here are the docs describing some of that, and the little pictorial description of how input processing is ordered:
It doesn't! Signals are received just fine regardless of where the node sits in the tree, it's just that for display and input purposes, the nodes are drawn from the top of the tree down, meaning the ones further down will be drawn in front of the ones up the tree. And the ones that are in front are also the ones that receive input from the engine (unless you change their z-index).
Here are the docs describing some of that, and the little pictorial description of how input processing is ordered:
That's pretty clear, Thanks. Now i'm trying to add some features to this project. Hope I could make some pr soon. Do I need to close this issue or leave it open?
I'd close it, since it's not an issue with the project, though a mention in the docs probably wouldn't hurt.
On Tue, 11 Jun 2024, 00:17 Arcadia, @.***> wrote:
It doesn't! Signals are received just fine regardless of where the node sits in the tree, it's just that for display and input purposes, the nodes are drawn from the top of the tree down, meaning the ones further down will be drawn in front of the ones up the tree. And the ones that are in front are also the ones that receive input from the engine (unless you change their z-index).
Here are the docs https://docs.godotengine.org/en/stable/tutorials/inputs/inputevent.html describing some of that, and the little pictorial description of how input processing is ordered:
That's pretty clear, Thanks. Now i'm trying to add some features to this project. Hope I could make some pr soon. Do I need to close this issue or leave it open?
— Reply to this email directly, view it on GitHub https://github.com/insideout-andrew/simple-card-pile-ui/issues/6#issuecomment-2159970941, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABL2H5ETEUAKM57WQVEVADZG2QB7AVCNFSM6AAAAABIWR7MNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJZHE3TAOJUGE . You are receiving this because you commented.Message ID: @.***>
I'm trying to make some custom
Dropzone
. Problem is any card dropped into custom dropzones lose ability to trigger_on_mouse_enter
or_on_gui_input
.card_ui_dropped
._create_card_ui
and put into custom dropzone cannot trigger too. (Put into internal piles is OK)What I figured out:
_card_can_be_interacted_with
function. The hook doesn't triggered at all.CardUI
norCardPileUI
work.PS: I'm new to Godot and feel like this is a noob question. Please help. Thanks.