diff --git a/DungeonShooting_Godot/prefab/ui/EditorInput.tscn b/DungeonShooting_Godot/prefab/ui/EditorInput.tscn
index 50dda1e..27cf072 100644
--- a/DungeonShooting_Godot/prefab/ui/EditorInput.tscn
+++ b/DungeonShooting_Godot/prefab/ui/EditorInput.tscn
@@ -7,6 +7,8 @@
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
script = ExtResource("1_n62mt")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
diff --git a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSourceInfo.cs b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSourceInfo.cs
index 20d7c7d..2fbd026 100644
--- a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSourceInfo.cs
+++ b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSourceInfo.cs
@@ -12,6 +12,13 @@
[JsonInclude]
public string Name;
+ ///
+ /// 初始化默认数据
+ ///
+ public void InitData()
+ {
+ }
+
public TileSetSourceInfo Clone()
{
var tileSetSourceInfo = new TileSetSourceInfo();
diff --git a/DungeonShooting_Godot/src/game/event/EventEnum.cs b/DungeonShooting_Godot/src/game/event/EventEnum.cs
index f9824af..3b51809 100644
--- a/DungeonShooting_Godot/src/game/event/EventEnum.cs
+++ b/DungeonShooting_Godot/src/game/event/EventEnum.cs
@@ -153,7 +153,7 @@
///
OnCreateTileSetSource,
///
- /// 选中TileSet资源, 参数为
+ /// 选中TileSet资源, 参数为, 参数为 null 表示取消选中
///
OnSelectTileSetSource,
///
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs
index 130ed17..5e2a4c2 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs
@@ -1,3 +1,4 @@
+using System.Linq;
using Godot;
namespace UI.TileSetEditor;
@@ -155,16 +156,28 @@
OpenPrevUi();
}
+ //删除资源
private void OnDeleteSourceClick()
{
var optionButton = S_OptionButton.Instance;
- if (optionButton.Selected >= 0)
+ var selectIndex = optionButton.Selected;
+ if (selectIndex >= 0)
{
EditorWindowManager.ShowConfirm("提示", "是否需要删除该资源!", v =>
{
if (v)
{
- Debug.Log("删除资源: ");
+ var name = optionButton.GetItemText(selectIndex);
+ var findIndex = TileSetInfo.Sources.FindIndex(info => info.Name == name);
+ if (findIndex >= 0)
+ {
+ TileSetInfo.Sources.RemoveAt(findIndex);
+ }
+
+ var index = optionButton.ItemCount - 2;
+ optionButton.RemoveItem(selectIndex);
+ optionButton.Selected = index;
+ OnOptionChange(index);
}
});
}
@@ -174,20 +187,49 @@
}
}
+ //创建资源
private void OnAddSourceClick()
{
- EditorWindowManager.ShowInput("创建资源", "资源名称:", null, (value, isClose) =>
+ EditorWindowManager.ShowInput("创建资源", "资源名称:", null, (value, isSubmit) =>
{
- EventManager.EmitEvent(EventEnum.OnCreateTileSetSource);
- var optionButton = S_OptionButton.Instance;
- optionButton.AddItem(value);
- optionButton.Selected = optionButton.ItemCount - 1;
+ if (isSubmit)
+ {
+ if (TileSetInfo.Sources.FindIndex(info => info.Name == value) >= 0)
+ {
+ EditorWindowManager.ShowTips("错误", "该资源名称已存在!");
+ return false;
+ }
+
+ var source = new TileSetSourceInfo();
+ source.InitData();
+ source.Name = value;
+ TileSetInfo.Sources.Add(source);
+
+ EventManager.EmitEvent(EventEnum.OnCreateTileSetSource, source);
+ var optionButton = S_OptionButton.Instance;
+ optionButton.AddItem(value);
+ var selectIndex = optionButton.ItemCount - 1;
+ optionButton.Selected = selectIndex;
+ OnOptionChange(selectIndex);
+ }
+
return true;
});
}
+ //选中资源
private void OnOptionChange(long index)
{
+ if (index >= 0)
+ {
+ TabGrid.Visible = true;
+ TabGrid.SelectIndex = 0;
+ }
+ else
+ {
+ TabGrid.Visible = false;
+ TabGrid.SelectIndex = -1;
+ }
EventManager.EmitEvent(EventEnum.OnSelectTileSetSource);
}
}