Skip to content

CardFront

Divided by Zer0 edited this page Mar 9, 2022 · 9 revisions

CardFront

Extends: Panel

Description

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.

Property Descriptions

card_labels

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.

original_font_sizes

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

font_sizes

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

card_label_min_sizes

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

scaled_fonts

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.

bbcode_texts

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.

rich_text_font_size_variations

var rich_text_font_size_variations: Dictionary

resizing_labels

var resizing_labels: Array

font_thread

var font_thread: Thread

card_owner

var card_owner

Stores a reference to the Card that is hosting this node

Method Descriptions

set_label_text

func set_label_text(node: Label, value, scale: float = 1)

Thread must be disposed (or "joined"), for portability.

func _exit_tree(): font_thread.wait_to_finish() Set a label node's text. As the string becomes longer, the font size becomes smaller

get_card_label_font

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)

set_card_label_font

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)

scale_to

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.

set_rich_label_text

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

get_cached_font_size

func get_cached_font_size(label: Control, text: String, scale: float)
Clone this wiki locally