extends Control var blocks = { "mane": $PickedCardListScroll/PickedCardList/Mane, "entry": $PickedCardListScroll/PickedCardList/Entry, "friend": $PickedCardListScroll/PickedCardList/Friends, "resource": $PickedCardListScroll/PickedCardList/Resources, "event": $PickedCardListScroll/PickedCardList/Events, "troublemaker": $PickedCardListScroll/PickedCardList/Troublemakers, "problem": $PickedCardListScroll/PickedCardList/Problems } var labels = { "mane": $PickedCardListScroll/PickedCardList/ManeLabel, "entry": $PickedCardListScroll/PickedCardList/EntryLabel, "friend": $PickedCardListScroll/PickedCardList/FriendsLabel, "resource": $PickedCardListScroll/PickedCardList/ResourcesLabel, "event": $PickedCardListScroll/PickedCardList/EventsLabel, "troublemaker": $PickedCardListScroll/PickedCardList/TroublemakersLabel, "problem": $PickedCardListScroll/PickedCardList/ProblemsLabel } var CardUI := preload("res://Scenes/DeckBuilder/UICard.tscn") func _ready(): add_card("pr1") add_card("pr10") add_card("pr20") add_card("pr30") add_card("pr166") add_card("pr171") add_card("pr16") add_card("pr171") add_card("pr1") add_card("pr10") add_card("pr20") add_card("pr30") func add_card(cardID: String): var card := CardUI.instance() card.cardID = cardID card.connect("card_selected", self, "_card_selected", [cardID]) card.connect("card_unselected", self, "_card_unselected") card.connect("card_hover", self, "_mouse_on_card", [card]) $Cards.add_child(card) func _card_selected(cardID: String): $CardZoom.cardID = cardID $CardZoom.fadein() func _card_unselected(): $CardZoom.fadeout() const yMargin = 5 const xEdge = 200 const yEdge = 10 func _mouse_on_card(position: Vector2, card: Control): # THIS IS A MESS # Should be cleaned but there are way too many scaling things to keep track of # and it's midnight right now var pos: Vector2 = card.rect_position * $Cards.rect_scale var cardpos: Vector2 = $Cards.rect_position + card.rect_position * $Cards.rect_scale if $CardZoom.rect_size.x > rect_size.x - cardpos.x - xEdge: pos.x -= $CardZoom.rect_size.x * $CardZoom.rect_scale.x else: pos.x += card.rect_size.x * $Cards.rect_scale.x pos.y -= ($CardZoom.rect_size.y * $CardZoom.rect_scale.y)/4 if pos.y < yMargin: pos.y = yMargin elif $CardZoom.rect_size.y > rect_size.y - cardpos.y - yEdge: pos.y = rect_size.y - $CardZoom.rect_size.y - yMargin $CardZoom.rect_position = $Cards.rect_position + pos