improvement
This commit is contained in:
@@ -21,47 +21,11 @@ func _ready() -> void:
|
||||
action_parameters["text"] = ""
|
||||
action_parameters["duration"] = 0.0
|
||||
|
||||
func _setup_parameter_fields() -> void:
|
||||
# Character field
|
||||
var x = VBoxContainer.new()
|
||||
add_child(x)
|
||||
var char_label = Label.new()
|
||||
char_label.text = "Character:"
|
||||
char_label.hide()
|
||||
x.add_child(char_label)
|
||||
|
||||
var char_field = LineEdit.new()
|
||||
char_field.text = action_parameters["character"]
|
||||
char_field.connect("text_changed", _on_character_changed)
|
||||
x.add_child(char_field)
|
||||
|
||||
# Text field
|
||||
var text_label = Label.new()
|
||||
text_label.text = "Text:"
|
||||
x.add_child(text_label)
|
||||
|
||||
var text_field = TextEdit.new()
|
||||
text_field.text = action_parameters["text"]
|
||||
text_field.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
text_field.connect("text_changed", _on_text_changed)
|
||||
x.add_child(text_field)
|
||||
|
||||
# Duration field
|
||||
var duration_label = Label.new()
|
||||
duration_label.text = "Duration:"
|
||||
x.add_child(duration_label)
|
||||
|
||||
var duration_field = LineEdit.new()
|
||||
duration_field.text = str(action_parameters["duration"])
|
||||
duration_field.connect("text_changed", _on_duration_changed)
|
||||
x.add_child(duration_field)
|
||||
|
||||
func _on_character_changed(new_text: String) -> void:
|
||||
set_parameter("character", new_text)
|
||||
|
||||
func _on_text_changed() -> void:
|
||||
var text_edit = get_child(get_child_count() - 2) # TextEdit is second to last child
|
||||
set_parameter("text", text_edit.text)
|
||||
func _on_text_changed(new_text: String) -> void:
|
||||
set_parameter("text", new_text)
|
||||
|
||||
func _on_duration_changed(new_text: String) -> void:
|
||||
var value = float(new_text) if new_text.is_valid_float() else 0.0
|
||||
|
||||
Reference in New Issue
Block a user