cutscene progress.
This commit is contained in:
4
addons/cutscene_editor/editor/CutsceneGenerator.gd
Executable file → Normal file
4
addons/cutscene_editor/editor/CutsceneGenerator.gd
Executable file → Normal file
@@ -101,8 +101,8 @@ func _create_action_from_node(scene: Node, node_data: Dictionary):
|
||||
var turn_speed = parameters.get("turn_speed", 2.0)
|
||||
|
||||
# In a real implementation, we would resolve the paths to actual nodes
|
||||
var character_node = null # This would be resolved at runtime
|
||||
var target_node = null # This would be resolved at runtime
|
||||
var character_node = scene.find_child(character_path) # This would be resolved at runtime
|
||||
var target_node = scene.find_child(target) # This would be resolved at runtime
|
||||
|
||||
return TurnAction.new(character_node, target_node, turn_speed)
|
||||
|
||||
|
||||
19
addons/cutscene_editor/editor/CutsceneGraphEdit.gd
Executable file → Normal file
19
addons/cutscene_editor/editor/CutsceneGraphEdit.gd
Executable file → Normal file
@@ -85,7 +85,6 @@ func add_node(node_type: String, position: Vector2) -> BaseGraphNode:
|
||||
# Emit signal
|
||||
emit_signal("node_added", new_node)
|
||||
emit_signal("graph_changed")
|
||||
|
||||
return new_node
|
||||
|
||||
# Handle connection requests
|
||||
@@ -349,6 +348,7 @@ func load_from_cutscene(cutscene: CutsceneResource) -> void:
|
||||
# Set node parameters
|
||||
for param_name in node_data["parameters"]:
|
||||
node.set_parameter(param_name, node_data["parameters"][param_name])
|
||||
node._parameters_to_view()
|
||||
|
||||
# Create connections from cutscene data
|
||||
for connection_data in cutscene.connections:
|
||||
@@ -356,6 +356,7 @@ func load_from_cutscene(cutscene: CutsceneResource) -> void:
|
||||
connect_node(connection_data["from_node"], connection_data["from_port"],
|
||||
connection_data["to_node"], connection_data["to_port"])
|
||||
|
||||
|
||||
# Emit signal
|
||||
emit_signal("graph_changed")
|
||||
|
||||
@@ -372,7 +373,7 @@ func save_to_cutscene() -> CutsceneResource:
|
||||
for child in get_children():
|
||||
if child is BaseGraphNode:
|
||||
var node_data = {
|
||||
"id": str(child.name),
|
||||
"id": str(child.node_id),
|
||||
"type": child.node_type,
|
||||
"position": {
|
||||
"x": child.position_offset.x,
|
||||
@@ -380,15 +381,25 @@ func save_to_cutscene() -> CutsceneResource:
|
||||
},
|
||||
"parameters": child.action_parameters
|
||||
}
|
||||
print(node_data)
|
||||
current_cutscene.nodes.append(node_data)
|
||||
|
||||
# Save connections
|
||||
for connection in get_connection_list():
|
||||
|
||||
# Get actual node instances from node names to access node_id
|
||||
var from_node_instance = get_node_or_null(str(connection["from_node"]))
|
||||
var to_node_instance = get_node_or_null(str(connection["to_node"]))
|
||||
|
||||
# Skip if nodes don't exist (shouldn't happen, but safety check)
|
||||
if not from_node_instance or not to_node_instance:
|
||||
continue
|
||||
|
||||
var connection_data = {
|
||||
"id": _generate_unique_connection_id(),
|
||||
"from_node": str(connection["from_node"]),
|
||||
"from_node": str(from_node_instance.node_id),
|
||||
"from_port": connection["from_port"],
|
||||
"to_node": str(connection["to_node"]),
|
||||
"to_node": str(to_node_instance.node_id),
|
||||
"to_port": connection["to_port"]
|
||||
}
|
||||
current_cutscene.connections.append(connection_data)
|
||||
|
||||
2
addons/cutscene_editor/editor/nodes/AnimationActionNode.gd
Executable file → Normal file
2
addons/cutscene_editor/editor/nodes/AnimationActionNode.gd
Executable file → Normal file
@@ -6,7 +6,7 @@ extends "res://addons/cutscene_editor/editor/nodes/BaseGraphNode.gd"
|
||||
|
||||
func _init() -> void:
|
||||
node_type = "animation"
|
||||
name = "animation_" + str(randi())
|
||||
node_id = "animation_" + str(randi())
|
||||
title = "Animation"
|
||||
modulate = Color(0.8, 0.4, 0.8) # Purple
|
||||
|
||||
|
||||
3
addons/cutscene_editor/editor/nodes/BaseGraphNode.gd
Executable file → Normal file
3
addons/cutscene_editor/editor/nodes/BaseGraphNode.gd
Executable file → Normal file
@@ -21,6 +21,7 @@ enum NodeState {
|
||||
# Properties
|
||||
var node_type: String = "base"
|
||||
|
||||
var node_id: String
|
||||
var action_parameters: Dictionary = {} # Stores parameter values
|
||||
var current_state: int = NodeState.IDLE
|
||||
var error_message: String = ""
|
||||
@@ -282,3 +283,5 @@ func _clear_parameter_fields() -> void:
|
||||
editor.queue_free()
|
||||
|
||||
property_editors.clear()
|
||||
func _parameters_to_view() -> void:
|
||||
pass
|
||||
|
||||
2
addons/cutscene_editor/editor/nodes/DialogueActionNode.gd
Executable file → Normal file
2
addons/cutscene_editor/editor/nodes/DialogueActionNode.gd
Executable file → Normal file
@@ -6,7 +6,7 @@ extends "res://addons/cutscene_editor/editor/nodes/BaseGraphNode.gd"
|
||||
|
||||
func _init() -> void:
|
||||
node_type = "dialogue"
|
||||
name = "dialogue_" + str(randi())
|
||||
node_id = "dialogue_" + str(randi())
|
||||
title = "Dialogue"
|
||||
modulate = Color(1.0, 1.0, 0.5) # Yellow
|
||||
resizable=true
|
||||
|
||||
2
addons/cutscene_editor/editor/nodes/EntryNode.gd
Executable file → Normal file
2
addons/cutscene_editor/editor/nodes/EntryNode.gd
Executable file → Normal file
@@ -6,7 +6,7 @@ extends "res://addons/cutscene_editor/editor/nodes/BaseGraphNode.gd"
|
||||
|
||||
func _init() -> void:
|
||||
node_type = "entry"
|
||||
name = "entry_" + str(randi())
|
||||
node_id = "entry_" + str(randi())
|
||||
title = "Start"
|
||||
modulate = Color(0.5, 1.0, 0.5) # Light green
|
||||
|
||||
|
||||
2
addons/cutscene_editor/editor/nodes/ExitNode.gd
Executable file → Normal file
2
addons/cutscene_editor/editor/nodes/ExitNode.gd
Executable file → Normal file
@@ -6,7 +6,7 @@ extends "res://addons/cutscene_editor/editor/nodes/BaseGraphNode.gd"
|
||||
|
||||
func _init() -> void:
|
||||
node_type = "exit"
|
||||
name = "exit_" + str(randi())
|
||||
node_id = "exit_" + str(randi())
|
||||
title = "End"
|
||||
modulate = Color(1.0, 0.5, 0.5) # Light red
|
||||
|
||||
|
||||
31
addons/cutscene_editor/editor/nodes/MoveActionNode.gd
Executable file → Normal file
31
addons/cutscene_editor/editor/nodes/MoveActionNode.gd
Executable file → Normal file
@@ -6,46 +6,43 @@ extends "res://addons/cutscene_editor/editor/nodes/BaseGraphNode.gd"
|
||||
|
||||
func _init() -> void:
|
||||
node_type = "move"
|
||||
name = "move_" + str(randi())
|
||||
node_id = "move_" + str(randi())
|
||||
title = "Move"
|
||||
modulate = Color(0.4, 0.6, 1.0) # Blue
|
||||
|
||||
# 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["target_x"] = 0.0
|
||||
action_parameters["target_y"] = 0.0
|
||||
action_parameters["speed"] = 100.0
|
||||
|
||||
func set_parameter(pname, value) -> void:
|
||||
super.set_parameter(name, value)
|
||||
if pname == "character":
|
||||
$VBoxContainer/CharacterEDit.text = value
|
||||
elif pname == "target_x":
|
||||
$VBoxContainer/HBoxContainer/x.text = value
|
||||
elif pname == "target_y":
|
||||
$VBoxContainer/HBoxContainer/y.text = value
|
||||
elif pname == "speed":
|
||||
$VBoxContainer/speed.text = value
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
func _parameters_to_view() -> void:
|
||||
$VBoxContainer/CharacterEDit.text = action_parameters["character"]
|
||||
$VBoxContainer/HBoxContainer/x.text = str(action_parameters["target_x"])
|
||||
$VBoxContainer/HBoxContainer/y.text = str(action_parameters["target_y"])
|
||||
$VBoxContainer/speed.text = str(action_parameters["speed"])
|
||||
|
||||
func _on_character_changed(new_text: String) -> void:
|
||||
print("character" , new_text)
|
||||
set_parameter("character", new_text)
|
||||
|
||||
func _on_target_x_changed(new_text: String) -> void:
|
||||
print("target x" , new_text)
|
||||
var value = float(new_text) if new_text.is_valid_float() else 0.0
|
||||
set_parameter("target_x", value)
|
||||
|
||||
func _on_target_y_changed(new_text: String) -> void:
|
||||
print("toarget y")
|
||||
print("toarget y" , new_text)
|
||||
var value = float(new_text) if new_text.is_valid_float() else 0.0
|
||||
set_parameter("target_y", value)
|
||||
|
||||
func _on_speed_changed(new_text: String) -> void:
|
||||
|
||||
print("speed")
|
||||
print("speed", new_text)
|
||||
var value = float(new_text) if new_text.is_valid_float() else 100.0
|
||||
set_parameter("speed", value)
|
||||
|
||||
0
addons/cutscene_editor/editor/nodes/MoveActionNode.tscn
Executable file → Normal file
0
addons/cutscene_editor/editor/nodes/MoveActionNode.tscn
Executable file → Normal file
@@ -1,126 +0,0 @@
|
||||
@tool
|
||||
class_name ParallelGroupNode
|
||||
extends "res://addons/cutscene_editor/editor/nodes/BaseGraphNode.gd"
|
||||
|
||||
# Node for grouping parallel actions
|
||||
|
||||
# Special properties for parallel groups
|
||||
var input_connections: int = 3 # Number of input connection points
|
||||
var child_nodes: Array = [] # Child nodes contained within this group
|
||||
var is_container: bool = true # Flag to indicate this is a container node
|
||||
|
||||
# Visual properties
|
||||
var container_rect: PanelContainer # Visual container for child nodes
|
||||
|
||||
func _init() -> void:
|
||||
node_type = "parallel"
|
||||
name = "parallel_" + str(randi())
|
||||
title = "Parallel Group"
|
||||
modulate = Color(1.0, 0.6, 0.2) # Orange
|
||||
|
||||
# Set up slots for connections
|
||||
_setup_slots()
|
||||
|
||||
# Set up container for child nodes
|
||||
_setup_container()
|
||||
|
||||
# Set up connection slots
|
||||
func _setup_slots() -> void:
|
||||
# Multiple input connections for parallel actions
|
||||
for i in range(input_connections):
|
||||
set_slot(i, true, 0, Color(0, 0, 0), false, 0, Color(0, 0, 0, 0))
|
||||
|
||||
# Single output connection for sequential continuation
|
||||
var output_slot = input_connections
|
||||
set_slot(output_slot, false, 0, Color(0, 0, 0, 0), true, 0, Color(0, 0, 0))
|
||||
|
||||
# Set up visual container for child nodes
|
||||
func _setup_container() -> void:
|
||||
# Create container panel
|
||||
container_rect = PanelContainer.new()
|
||||
container_rect.name = "Container"
|
||||
container_rect.anchor_right = 1
|
||||
container_rect.anchor_bottom = 1
|
||||
container_rect.margin_top = 30 # Leave space for title bar
|
||||
container_rect.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
|
||||
# Set container style
|
||||
var style = StyleBoxFlat.new()
|
||||
style.bg_color = Color(0.9, 0.9, 0.9, 0.3)
|
||||
style.border_color = Color(0.5, 0.5, 0.5, 0.5)
|
||||
style.border_width_left = 1
|
||||
style.border_width_top = 1
|
||||
style.border_width_right = 1
|
||||
style.border_width_bottom = 1
|
||||
container_rect.add_theme_stylebox_override("panel", style)
|
||||
|
||||
add_child(container_rect)
|
||||
|
||||
# Create container for child nodes
|
||||
var child_container = VBoxContainer.new()
|
||||
child_container.name = "ChildContainer"
|
||||
child_container.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
container_rect.add_child(child_container)
|
||||
|
||||
# Add a child node to this parallel group
|
||||
func add_child_node(child_node: BaseGraphNode) -> void:
|
||||
# Add to child nodes array
|
||||
child_nodes.append(child_node)
|
||||
|
||||
# Add as child in scene tree
|
||||
if container_rect and container_rect.has_node("ChildContainer"):
|
||||
container_rect.get_node("ChildContainer").add_child(child_node)
|
||||
|
||||
# Update visual representation
|
||||
_update_container_size()
|
||||
|
||||
# Remove a child node from this parallel group
|
||||
func remove_child_node(child_node: BaseGraphNode) -> void:
|
||||
# Remove from child nodes array
|
||||
child_nodes.erase(child_node)
|
||||
|
||||
# Remove from scene tree
|
||||
if child_node.get_parent() == container_rect.get_node("ChildContainer"):
|
||||
container_rect.get_node("ChildContainer").remove_child(child_node)
|
||||
|
||||
# Update visual representation
|
||||
_update_container_size()
|
||||
|
||||
# Update container size based on child nodes
|
||||
func _update_container_size() -> void:
|
||||
# Calculate required size based on child nodes
|
||||
var required_height = 20 # Minimum height
|
||||
|
||||
if container_rect and container_rect.has_node("ChildContainer"):
|
||||
var child_container = container_rect.get_node("ChildContainer")
|
||||
for child in child_container.get_children():
|
||||
if child is BaseGraphNode:
|
||||
required_height += child.size.y + 5 # Add spacing
|
||||
|
||||
# Update container size
|
||||
container_rect.custom_minimum_size.y = required_height
|
||||
|
||||
# Handle node dragging
|
||||
func _on_node_dragged(from: Vector2, to: Vector2) -> void:
|
||||
# Update position
|
||||
position_offset = to
|
||||
|
||||
# Update child nodes if they're positioned relative to this node
|
||||
for child in child_nodes:
|
||||
# Child nodes should move with the parallel group
|
||||
pass
|
||||
|
||||
# Add more input connections if needed
|
||||
func add_input_connection() -> void:
|
||||
var slot_index = input_connections
|
||||
set_slot(slot_index, true, 0, Color(0, 0, 0), false, 0, Color(0, 0, 0, 0))
|
||||
input_connections += 1
|
||||
|
||||
# Get the output slot index
|
||||
func get_output_slot_index() -> int:
|
||||
return input_connections
|
||||
|
||||
# Check if a node can be added as a child
|
||||
func can_add_child_node(node: BaseGraphNode) -> bool:
|
||||
# Can't add entry, exit, or other parallel groups as children
|
||||
return node.node_type != "entry" and node.node_type != "exit" and node.node_type != "parallel"
|
||||
16
addons/cutscene_editor/editor/nodes/TurnActionNode.gd
Executable file → Normal file
16
addons/cutscene_editor/editor/nodes/TurnActionNode.gd
Executable file → Normal file
@@ -6,21 +6,27 @@ extends "res://addons/cutscene_editor/editor/nodes/BaseGraphNode.gd"
|
||||
|
||||
func _init() -> void:
|
||||
node_type = "turn"
|
||||
name = "turn_" + str(randi())
|
||||
node_id = "turn_" + str(randi())
|
||||
title = "Turn"
|
||||
modulate = Color(0.5, 1.0, 0.5) # Green
|
||||
|
||||
# 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["target"] = ""
|
||||
action_parameters["turn_speed"] = 2.0
|
||||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
# Initialize default parameters
|
||||
|
||||
|
||||
func _parameters_to_view() -> void:
|
||||
$VBoxContainer/character.text = action_parameters["character"]
|
||||
$VBoxContainer/target.text = action_parameters["target"]
|
||||
$VBoxContainer/turn_speed.text = str(action_parameters["turn_speed"])
|
||||
|
||||
func _on_character_changed(new_text: String) -> void:
|
||||
set_parameter("character", new_text)
|
||||
|
||||
|
||||
18
addons/cutscene_editor/editor/nodes/TurnActionNode.tscn
Executable file → Normal file
18
addons/cutscene_editor/editor/nodes/TurnActionNode.tscn
Executable file → Normal file
@@ -1,37 +1,49 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://turnactionnodetscn"]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dlndt313nnatt"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/cutscene_editor/editor/nodes/TurnActionNode.gd" id="1_turn"]
|
||||
|
||||
[node name="TurnActionNode" type="GraphNode"]
|
||||
modulate = Color(0.5, 1.0, 0.5, 1)
|
||||
modulate = Color(0.5, 1, 0.5, 1)
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
title = "Turn"
|
||||
slot/0/left_enabled = true
|
||||
slot/0/left_type = 0
|
||||
slot/0/left_color = Color(0, 0, 0, 1)
|
||||
slot/0/left_icon = null
|
||||
slot/0/right_enabled = true
|
||||
slot/0/right_type = 0
|
||||
slot/0/right_color = Color(0, 0, 0, 1)
|
||||
slot/0/right_icon = null
|
||||
slot/0/draw_stylebox = true
|
||||
script = ExtResource("1_turn")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Character" type="Label" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Character"
|
||||
|
||||
[node name="character" type="LineEdit" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
placeholder_text = "Character name"
|
||||
|
||||
[node name="Target" type="Label" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Target"
|
||||
|
||||
[node name="target" type="LineEdit" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
placeholder_text = "Target name"
|
||||
|
||||
[node name="TurnSpeed" type="Label" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Turn Speed"
|
||||
|
||||
[node name="turn_speed" type="LineEdit" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
placeholder_text = "Turn speed"
|
||||
|
||||
[connection signal="text_changed" from="VBoxContainer/character" to="." method="_on_character_changed"]
|
||||
[connection signal="text_changed" from="VBoxContainer/target" to="." method="_on_target_changed"]
|
||||
[connection signal="text_changed" from="VBoxContainer/turn_speed" to="." method="_on_turn_speed_changed"]
|
||||
[connection signal="text_changed" from="VBoxContainer/turn_speed" to="." method="_on_turn_speed_changed"]
|
||||
|
||||
3
addons/cutscene_editor/editor/nodes/WaitActionNode.gd
Executable file → Normal file
3
addons/cutscene_editor/editor/nodes/WaitActionNode.gd
Executable file → Normal file
@@ -6,10 +6,9 @@ extends "res://addons/cutscene_editor/editor/nodes/BaseGraphNode.gd"
|
||||
|
||||
func _init() -> void:
|
||||
node_type = "wait"
|
||||
node_id = "wait_" + str(randi())
|
||||
title = "Wait"
|
||||
modulate = Color(0.7, 0.7, 0.7) # Gray
|
||||
|
||||
node_id= "wait_" + str(randi())
|
||||
# One input and one output connection
|
||||
var slot = 0
|
||||
set_slot(slot, true, 0, Color(0, 0, 0), true, 0, Color(0, 0, 0))
|
||||
|
||||
Reference in New Issue
Block a user