diff --git a/scenes/LevelGraphEditor.tscn b/scenes/LevelGraphEditor.tscn
index a6e08aa..a355b85 100644
--- a/scenes/LevelGraphEditor.tscn
+++ b/scenes/LevelGraphEditor.tscn
@@ -35,7 +35,6 @@ offset_bottom = 32.0
text = "level_graph_editor"
[node name="CreateOrEditorPanel" type="Panel" parent="."]
-visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
@@ -152,6 +151,16 @@ offset_right = 61.0
offset_bottom = 379.0
text = "tags"
+[node name="TagLineEdit" type="LineEdit" parent="CreateOrEditorPanel"]
+layout_mode = 1
+anchors_preset = 10
+anchor_right = 1.0
+offset_left = 16.0
+offset_top = 388.0
+offset_right = -15.0
+offset_bottom = 421.0
+grow_horizontal = 2
+
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 1
diff --git a/scripts/loader/uiLoader/LevelGraphEditorLoader.cs b/scripts/loader/uiLoader/LevelGraphEditorLoader.cs
index 43e3e16..92a61f4 100644
--- a/scripts/loader/uiLoader/LevelGraphEditorLoader.cs
+++ b/scripts/loader/uiLoader/LevelGraphEditorLoader.cs
@@ -27,6 +27,12 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
///
private int _roomIndex = 1;
+ ///
+ /// Is there a start node?
+ /// 是否有开始节点了?
+ ///
+ private bool _hasStartNode;
+
private PackedScene? _roomNodeScene;
private readonly List _selectedNodes = new List();
@@ -235,6 +241,7 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
}
var nodes = _selectedNodes.ToArray();
+ _roomIndex -= _selectedNodes.Count;
foreach (var node in nodes)
{
if (node is not RoomNode roomNode)
@@ -242,10 +249,18 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
continue;
}
+ if (roomNode.RoomNodeData != null && roomNode.RoomNodeData.HasTag(Config.RoomDataTag.StartingRoom))
+ {
+ //The node with the start room label was deleted.
+ //删除了带有起始房间标签的节点。
+ _hasStartNode = false;
+ }
+
_nodeBinding.GraphEdit.RemoveChild(node);
roomNode.QueueFree();
_selectedNodes.Remove(node);
}
+
};
}
@@ -268,6 +283,23 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
_nodeBinding.RoomNameLineEdit.Text = string.Format(_defaultRoomName, _roomIndex);
}
+ if (_nodeBinding.RoomDescriptionLineEdit != null)
+ {
+ _nodeBinding.RoomDescriptionLineEdit.Text = string.Empty;
+ }
+
+ if (_nodeBinding.TagLineEdit != null)
+ {
+ if (_hasStartNode)
+ {
+ _nodeBinding.TagLineEdit.Text = string.Empty;
+ }
+ else
+ {
+ _nodeBinding.TagLineEdit.Text = Config.RoomDataTag.StartingRoom;
+ }
+ }
+
if (_nodeBinding.HBoxContainer != null)
{
_nodeBinding.HBoxContainer.Visible = false;
@@ -293,7 +325,7 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
_nodeBinding.CreateRoomButton.Pressed += () =>
{
if (_nodeBinding.RoomNameLineEdit == null || _nodeBinding.RoomDescriptionLineEdit == null ||
- _nodeBinding.RoomTemplateCollectionTextEdit == null)
+ _nodeBinding.RoomTemplateCollectionTextEdit == null || _nodeBinding.TagLineEdit == null)
{
return;
}
@@ -310,13 +342,27 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
return;
}
+ string[]? tagArray = null;
+ var tagData = _nodeBinding.TagLineEdit.Text;
+ if (!string.IsNullOrEmpty(tagData))
+ {
+ tagArray = tagData.Split(',');
+ }
+
+
var roomNodeData = new RoomNodeData
{
Id = GuidUtils.GetGuid(),
Title = _nodeBinding.RoomNameLineEdit.Text,
Description = _nodeBinding.RoomDescriptionLineEdit.Text,
- RoomTemplateSet = roomTemplateArray
+ RoomTemplateSet = roomTemplateArray,
+ Tags = tagArray
};
+ if (!_hasStartNode && roomNodeData.HasTag(Config.RoomDataTag.StartingRoom))
+ {
+ _hasStartNode = true;
+ }
+
var roomNode = CreateRoomNode(roomNodeData);
if (roomNode != null)
{
@@ -587,6 +633,7 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
//不要调用DeleteAllChildAsync方法,这会引发“ERROR: Caller thread can't call this function in this node”。
NodeUtils.DeleteAllChild(_nodeBinding.GraphEdit);
_roomIndex = 1;
+ _hasStartNode = false;
var roomNodeDataList = levelGraphEditorSaveData.RoomNodeDataList;
if (roomNodeDataList != null)
{
@@ -597,6 +644,11 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
continue;
}
+ if (!_hasStartNode && roomNodeData.HasTag(Config.RoomDataTag.StartingRoom))
+ {
+ _hasStartNode = true;
+ }
+
//Instantiate the room node.
//实例化房间节点。
var roomNode = CreateRoomNode(roomNodeData);
diff --git a/scripts/nodeBinding/LevelGraphEditorBinding.cs b/scripts/nodeBinding/LevelGraphEditorBinding.cs
index 2af207b..a481728 100644
--- a/scripts/nodeBinding/LevelGraphEditorBinding.cs
+++ b/scripts/nodeBinding/LevelGraphEditorBinding.cs
@@ -30,6 +30,7 @@ public class LevelGraphEditorBinding : INodeBinding
public LineEdit? FileNameLineEdit;
public Button? ShowLoadPanelButton;
public Button? DeleteSelectedNodeButton;
+ public LineEdit? TagLineEdit;
public void Binding(Node root)
{
RoomTemplateTipsLabel = root.GetNode