You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
951 B
27 lines
951 B
class_name EscapeMenuAppearance |
|
extends CenterContainer |
|
|
|
@export var display_name : LineEdit |
|
@export var color_preview : TextureRect |
|
@export var color_slider : Slider |
|
|
|
var INVALID_CHARS := RegEx.create_from_string("\\s") |
|
|
|
func _ready() -> void: |
|
color_slider.value = randf() |
|
color_preview.modulate = Color.from_hsv(color_slider.value, 1.0, 1.0) |
|
|
|
func _on_display_name_text_changed(new_text: String) -> void: |
|
var valid_text := INVALID_CHARS.sub(new_text, "", true) |
|
if valid_text == new_text: return |
|
|
|
var previous_caret_column = display_name.caret_column |
|
display_name.text = valid_text |
|
display_name.caret_column = previous_caret_column - (new_text.length() - valid_text.length()) |
|
|
|
func _on_hue_value_changed(value: float) -> void: |
|
color_preview.modulate = Color.from_hsv(color_slider.value, 1.0, 1.0) |
|
|
|
func _on_visibility_changed() -> void: |
|
if is_visible_in_tree(): return # only run when hiding |
|
# TODO: Apply name and color to local player.
|
|
|