69 lines
2.0 KiB
GDScript
69 lines
2.0 KiB
GDScript
@tool
|
|
class_name DialogueActionNode
|
|
extends "res://addons/cutscene_editor/editor/nodes/BaseGraphNode.gd"
|
|
|
|
# Node for DialogueAction
|
|
|
|
func _init() -> void:
|
|
node_type = "dialogue"
|
|
node_id = "dialogue_" + str(randi())
|
|
title = "Dialogue"
|
|
modulate = Color(1.0, 1.0, 0.5) # Yellow
|
|
resizable=true
|
|
# One input and one output connection
|
|
var slot = 0
|
|
set_slot(slot, true, 0, Color(0, 0, 0), true, 0, Color(0, 0, 0))
|
|
|
|
func _ready() -> void:
|
|
super._ready()
|
|
# Initialize default parameters
|
|
action_parameters["character"] = ""
|
|
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_duration_changed(new_text: String) -> void:
|
|
var value = float(new_text) if new_text.is_valid_float() else 0.0
|
|
set_parameter("duration", value)
|