56 lines
1.8 KiB
GDScript
56 lines
1.8 KiB
GDScript
extends Control
|
|
|
|
@onready var logger: CoreLoggerInstance = get_node("/root/CORE").logger.get_instance("SUI/src/SuiTextButton.gd")
|
|
|
|
@export_category("Base Configuration")
|
|
@export_subgroup("Button")
|
|
@export var disabled: bool = false
|
|
@export var toggle_mode: bool = false
|
|
@export var button_pressed: bool = false
|
|
@export_subgroup("RichTextLabel")
|
|
@export var bbcode_support: bool = true
|
|
@export_multiline var text: String = "[center]SuiTextButton[/center]"
|
|
@export var font_size: int = 35
|
|
@export_category("Debugging")
|
|
@export var editor_process: bool = true
|
|
@export var runtime_process: bool = true
|
|
|
|
signal down
|
|
signal up
|
|
signal pressed
|
|
signal toggled
|
|
|
|
func _ready() -> void:
|
|
# Free unused children
|
|
logger.diag("<" + name + "> Freeing ToolScript")
|
|
get_child(0).queue_free()
|
|
|
|
# Add signals
|
|
logger.diag("<" + name + "> Adding signals")
|
|
$Button.connect("button_down", func() -> void: emit_signal("down"))
|
|
$Button.connect("button_up", func() -> void: emit_signal("up"))
|
|
$Button.connect("pressed", func() -> void: emit_signal("pressed"))
|
|
$Button.connect("toggled", func(toggled_on: bool) -> void: emit_signal("toggled", toggled_on))
|
|
|
|
func _process(_delta: float) -> void:
|
|
if !runtime_process: return
|
|
update_element()
|
|
|
|
func update_element() -> void:
|
|
# Update sizes
|
|
$Button.size = size
|
|
$Text.size = size
|
|
|
|
# Update Button stuff
|
|
$Button.disabled = disabled
|
|
$Button.toggle_mode = toggle_mode
|
|
button_pressed = $Button.button_pressed
|
|
|
|
# Update RichTextLabel stuff
|
|
$Text.bbcode_enabled = bbcode_support
|
|
$Text.text = text
|
|
$Text.add_theme_font_size_override("normal_font_size", font_size)
|
|
$Text.add_theme_font_size_override("bold_font_size", font_size)
|
|
$Text.add_theme_font_size_override("italics_font_size", font_size)
|
|
$Text.add_theme_font_size_override("bold_italics_font_size", font_size)
|
|
$Text.add_theme_font_size_override("mono_font_size", font_size)
|