-
-
Notifications
You must be signed in to change notification settings - Fork 106
CardFront
Extends: Panel
This class contains details about layout of the card front and the various labels which compose it.
It also contains methods to adjust the text of the various labels, while keeping it inside its rect area.
var card_labels: Dictionary
Maps the location of the card front labels so that they're findable even when The card front is customized for games of different needs Each card_front scene should have its own script extending this class which set the dictionary to map to the necessary nodes
See "res://src/custom/CGFCardFront.gd" for an example.
var original_font_sizes: Dictionary
Maps the location of the card front labels so that they're findable even when The card front is customized for games of different needs Each card_front scene should have its own script extending this class which set the dictionary to map to the necessary nodes
See "res://src/custom/CGFCardFront.gd" for an example. Simply points to the container which holds all the labels It stores the font sizes as required by the developer. We keep it stored In order to be able to compare against it during scale_to()
This should be set by the develop in the script extending this for the card front
var font_sizes: Dictionary
Maps the location of the card front labels so that they're findable even when The card front is customized for games of different needs Each card_front scene should have its own script extending this class which set the dictionary to map to the necessary nodes
See "res://src/custom/CGFCardFront.gd" for an example. Simply points to the container which holds all the labels It stores the font sizes as required by the developer. We keep it stored In order to be able to compare against it during scale_to()
This should be set by the develop in the script extending this for the card front The font sizes as modified by the scale_to() method
var card_label_min_sizes: Dictionary
Maps the location of the card front labels so that they're findable even when The card front is customized for games of different needs Each card_front scene should have its own script extending this class which set the dictionary to map to the necessary nodes
See "res://src/custom/CGFCardFront.gd" for an example. Simply points to the container which holds all the labels It stores the font sizes as required by the developer. We keep it stored In order to be able to compare against it during scale_to()
This should be set by the develop in the script extending this for the card front The font sizes as modified by the scale_to() method The minimum label sizes. This is used by set_label_text() to calculate how much to shrink a label to fit within its current rect.
This should be set by the develop in the script extending this for the card front
var scaled_fonts: Dictionary
Maps the location of the card front labels so that they're findable even when The card front is customized for games of different needs Each card_front scene should have its own script extending this class which set the dictionary to map to the necessary nodes
See "res://src/custom/CGFCardFront.gd" for an example. Simply points to the container which holds all the labels It stores the font sizes as required by the developer. We keep it stored In order to be able to compare against it during scale_to()
This should be set by the develop in the script extending this for the card front The font sizes as modified by the scale_to() method The minimum label sizes. This is used by set_label_text() to calculate how much to shrink a label to fit within its current rect.
This should be set by the develop in the script extending this for the card front Stores the amount each font has been scaled to. We use this as a sort of boolean in order to avoid scaling the font again and again during process.
var bbcode_texts: Dictionary
Maps the location of the card front labels so that they're findable even when The card front is customized for games of different needs Each card_front scene should have its own script extending this class which set the dictionary to map to the necessary nodes
See "res://src/custom/CGFCardFront.gd" for an example. Simply points to the container which holds all the labels It stores the font sizes as required by the developer. We keep it stored In order to be able to compare against it during scale_to()
This should be set by the develop in the script extending this for the card front The font sizes as modified by the scale_to() method The minimum label sizes. This is used by set_label_text() to calculate how much to shrink a label to fit within its current rect.
This should be set by the develop in the script extending this for the card front Stores the amount each font has been scaled to. We use this as a sort of boolean in order to avoid scaling the font again and again during process.
var rich_text_font_size_variations: Dictionary
var resizing_labels: Array
var font_thread: Thread
var card_owner
Stores a reference to the Card that is hosting this node
func set_label_text(node: Label, value, scale: float = 1)
func _exit_tree(): font_thread.wait_to_finish() Set a label node's text. As the string becomes longer, the font size becomes smaller
func get_card_label_font(label: Label) -> Font
Returns the font used by the current label
We use an external function to get the font, to allow it to be overriden by classes extending this, to allow them to use their own methods (e.g. based on themes)
func set_card_label_font(label: Label, font: Font) -> void
Sets the font to be used by the current label
We use an external function to get the font, to allow it to be overriden by classes extending this, to allow them to use their own methods (e.g. based on themes)
func scale_to(scale_multiplier: float) -> var
We use this as an alternative to scaling the card using the "scale" property. This is typically used in the viewport focus only, to keep the text legible because scaling the card starts distoring the font.
For gameplay purposes (i.e. scaling while on the table etc), we keep using the .scale property, as that handles the Area2D size as well.
Typically each game would override this function to fit its layout.
func set_rich_label_text(node: RichTextLabel, value: String, is_resize: bool = false, scale: float = 1)
Set a label node's bbcode text. As the string becomes longer, the font size becomes smaller
func get_cached_font_size(label: Control, text: String, scale: float)