169 lines
4.6 KiB
Markdown
Executable File
169 lines
4.6 KiB
Markdown
Executable File
# CutsceneGraphEdit Changes for New Resource Structure
|
|
|
|
## Overview
|
|
|
|
This document describes the changes needed in CutsceneGraphEdit.gd to work with the new CutsceneResource data structure.
|
|
|
|
## Current Issues
|
|
|
|
The current CutsceneGraphEdit.gd has several areas that need updating:
|
|
1. Uses old node structure with "name" instead of "id"
|
|
2. Uses old connection structure
|
|
3. Has methods for parallel connections that are no longer needed
|
|
4. Save/load methods use the old structure
|
|
|
|
## Required Changes
|
|
|
|
### 1. Update Load Method (`load_from_cutscene`)
|
|
|
|
Current issues:
|
|
- Looks for "name" field in nodes
|
|
- Uses "type", "x", "y", "parameters" fields directly
|
|
- Creates connections using old structure
|
|
|
|
Changes needed:
|
|
- Update to use "id" field instead of "name"
|
|
- Ensure node creation uses the new structure
|
|
- Update connection creation to use new structure
|
|
|
|
### 2. Update Save Method (`save_to_cutscene`)
|
|
|
|
Current issues:
|
|
- Creates nodes with "name" field
|
|
- Uses "action_parameters" directly
|
|
- Creates connections with old structure
|
|
|
|
Changes needed:
|
|
- Generate unique IDs for nodes if they don't have them
|
|
- Use "id" field instead of "name"
|
|
- Ensure parameters are stored correctly
|
|
- Generate unique IDs for connections
|
|
- Use new connection structure
|
|
|
|
### 3. Update Node Creation (`add_node`)
|
|
|
|
Current issues:
|
|
- May not be setting node IDs properly
|
|
- Uses old parameter structure
|
|
|
|
Changes needed:
|
|
- Ensure new nodes get unique IDs
|
|
- Verify parameter structure matches new format
|
|
|
|
### 4. Update Connection Handling
|
|
|
|
Current issues:
|
|
- Uses GraphEdit's built-in connection methods
|
|
- May need to store connection IDs
|
|
|
|
Changes needed:
|
|
- Update `_on_connection_request` to store connection IDs in resource
|
|
- Update `_on_disconnection_request` to remove by connection ID
|
|
- Update `_on_graph_node_deleted` to properly remove connections
|
|
|
|
### 5. Remove Parallel Connection Methods
|
|
|
|
Methods to remove or modify:
|
|
- Any methods specifically handling parallel connections
|
|
- Update validation to work with new structure
|
|
|
|
## Implementation Plan
|
|
|
|
### 1. Update Node Management
|
|
|
|
- Modify `add_node` to generate unique IDs
|
|
- Update `_on_graph_node_deleted` to work with new structure
|
|
- Ensure all node references use IDs
|
|
|
|
### 2. Update Connection Management
|
|
|
|
- Modify connection creation to generate unique IDs
|
|
- Update connection removal to use connection IDs
|
|
- Update connection validation
|
|
|
|
### 3. Update Load/Save Methods
|
|
|
|
- Rewrite `load_from_cutscene` for new structure
|
|
- Rewrite `save_to_cutscene` for new structure
|
|
|
|
### 4. Update Helper Methods
|
|
|
|
- Update any helper methods that reference node names
|
|
- Update methods that handle connections
|
|
|
|
## Specific Code Changes
|
|
|
|
### In `load_from_cutscene`:
|
|
|
|
```gdscript
|
|
# OLD
|
|
for node_data in cutscene.nodes:
|
|
var node = add_node(node_data["type"], Vector2(node_data["x"], node_data["y"]))
|
|
if node:
|
|
node.name = node_data["name"]
|
|
# Set node parameters
|
|
for param_name in node_data["parameters"]:
|
|
node.set_parameter(param_name, node_data["parameters"][param_name])
|
|
|
|
# NEW
|
|
for node_data in cutscene.nodes:
|
|
var node = add_node(node_data["type"], Vector2(node_data["position"]["x"], node_data["position"]["y"]))
|
|
if node:
|
|
node.node_id = node_data["id"] # Set the ID directly
|
|
# Set node parameters
|
|
for param_name in node_data["parameters"]:
|
|
node.set_parameter(param_name, node_data["parameters"][param_name])
|
|
```
|
|
|
|
### In `save_to_cutscene`:
|
|
|
|
```gdscript
|
|
# OLD
|
|
var node_data = {
|
|
"name": child.name,
|
|
"type": child.node_type,
|
|
"x": child.position_offset.x,
|
|
"y": child.position_offset.y,
|
|
"parameters": child.action_parameters
|
|
}
|
|
|
|
# NEW
|
|
var node_data = {
|
|
"id": child.node_id,
|
|
"type": child.node_type,
|
|
"position": {
|
|
"x": child.position_offset.x,
|
|
"y": child.position_offset.y
|
|
},
|
|
"parameters": child.action_parameters
|
|
}
|
|
```
|
|
|
|
### Connection Updates:
|
|
|
|
```gdscript
|
|
# OLD
|
|
for connection in get_connection_list():
|
|
var connection_data = {
|
|
"from_node": connection["from_node"],
|
|
"from_port": connection["from_port"],
|
|
"to_node": connection["to_node"],
|
|
"to_port": connection["to_port"]
|
|
}
|
|
|
|
# NEW
|
|
for connection in get_connection_list():
|
|
var connection_data = {
|
|
"id": generate_unique_connection_id(), # New helper method
|
|
"from_node": connection["from_node"],
|
|
"from_port": connection["from_port"],
|
|
"to_node": connection["to_node"],
|
|
"to_port": connection["to_port"]
|
|
}
|
|
```
|
|
|
|
## Compatibility Considerations
|
|
|
|
- Need to handle loading of old format resources
|
|
- Should provide migration path in the resource itself
|
|
- May need version checking when loading resources |