diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditorProject.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditorProject.tscn index 2ea3a6d..1e4f076 100644 --- a/DungeonShooting_Godot/prefab/ui/TileSetEditorProject.tscn +++ b/DungeonShooting_Godot/prefab/ui/TileSetEditorProject.tscn @@ -1,10 +1,13 @@ -[gd_scene load_steps=6 format=3 uid="uid://bxrpxwsvveq8i"] +[gd_scene load_steps=9 format=3 uid="uid://bxrpxwsvveq8i"] [ext_resource type="Script" path="res://src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs" id="1_rklha"] [ext_resource type="Texture2D" uid="uid://cajcnlimvoxk" path="res://resource/sprite/ui/commonIcon/Back.png" id="2_4prd2"] [ext_resource type="Texture2D" uid="uid://blfvsup876agh" path="res://resource/sprite/ui/commonIcon/Search.png" id="3_htmoo"] [ext_resource type="Texture2D" uid="uid://n4atvj5fkcpg" path="res://resource/sprite/ui/commonIcon/Add.png" id="4_6incc"] +[ext_resource type="Texture2D" uid="uid://dggb6p4sdmfry" path="res://resource/sprite/ui/commonIcon/Edit.png" id="5_0y7kc"] +[ext_resource type="Texture2D" uid="uid://do3q1nsagxayh" path="res://resource/sprite/ui/commonIcon/Success_mini.png" id="5_d0rev"] [ext_resource type="Texture2D" uid="uid://bn47bmilcw4x0" path="res://resource/sprite/ui/commonIcon/Select2.png" id="5_l4lwx"] +[ext_resource type="Texture2D" uid="uid://c5778ntk2rdon" path="res://resource/sprite/ui/commonIcon/Delete.png" id="6_jwxdd"] [node name="TileSetEditorProject" type="Control"] layout_mode = 3 @@ -83,65 +86,77 @@ theme_override_constants/margin_right = 12 theme_override_constants/margin_bottom = 12 -[node name="VBoxContainer" type="VBoxContainer" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer"] +[node name="HBoxContainer2" type="HBoxContainer" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2"] +custom_minimum_size = Vector2(0, 45) +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 7.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/VBoxContainer"] custom_minimum_size = Vector2(0, 45) layout_mode = 2 -[node name="HBoxContainer" type="HBoxContainer" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/VBoxContainer"] -custom_minimum_size = Vector2(0, 45) -layout_mode = 2 - -[node name="TileSearchInput" type="LineEdit" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/VBoxContainer/HBoxContainer"] +[node name="TileSearchInput" type="LineEdit" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/VBoxContainer/HBoxContainer"] custom_minimum_size = Vector2(400, 0) layout_mode = 2 placeholder_text = "搜索" -[node name="TileSearchButton" type="Button" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/VBoxContainer/HBoxContainer"] +[node name="TileSearchButton" type="Button" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/VBoxContainer/HBoxContainer"] layout_mode = 2 icon = ExtResource("3_htmoo") -[node name="TileAddButton" type="Button" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/VBoxContainer/HBoxContainer"] +[node name="TileAddButton" type="Button" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/VBoxContainer/HBoxContainer"] layout_mode = 2 icon = ExtResource("4_6incc") -[node name="ScrollContainer" type="ScrollContainer" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/VBoxContainer"] +[node name="TileEditButton" type="Button" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/VBoxContainer/HBoxContainer"] layout_mode = 2 +icon = ExtResource("5_0y7kc") + +[node name="TileDeleteButton" type="Button" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/VBoxContainer/HBoxContainer"] +layout_mode = 2 +icon = ExtResource("6_jwxdd") + +[node name="ScrollContainer" type="ScrollContainer" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 size_flags_vertical = 3 +size_flags_stretch_ratio = 7.0 -[node name="TileButton" type="Button" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/VBoxContainer/ScrollContainer"] -custom_minimum_size = Vector2(200, 239) +[node name="TileButton" type="Button" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/VBoxContainer/ScrollContainer"] +custom_minimum_size = Vector2(200, 60) layout_mode = 2 +size_flags_horizontal = 3 -[node name="PreviewImage" type="TextureRect" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/VBoxContainer/ScrollContainer/TileButton"] +[node name="Icon" type="TextureRect" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/VBoxContainer/ScrollContainer/TileButton"] +layout_mode = 1 +anchors_preset = 9 +anchor_bottom = 1.0 +offset_left = 6.0 +offset_top = 6.0 +offset_right = 54.0 +offset_bottom = -6.0 +grow_vertical = 2 +texture = ExtResource("5_d0rev") + +[node name="TileName" type="Label" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/VBoxContainer/ScrollContainer/TileButton"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = 2.0 -offset_top = 2.0 -offset_right = -2.0 -offset_bottom = -41.0 +offset_left = 59.0 grow_horizontal = 2 grow_vertical = 2 -mouse_filter = 2 -stretch_mode = 5 - -[node name="TileName" type="Label" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/VBoxContainer/ScrollContainer/TileButton"] -layout_mode = 1 -anchors_preset = 12 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_top = -46.0 -offset_bottom = -3.0 -grow_horizontal = 2 -grow_vertical = 0 text = "Name" -horizontal_alignment = 1 +vertical_alignment = 1 clip_text = true text_overrun_behavior = 3 -[node name="SelectTexture" type="NinePatchRect" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/VBoxContainer/ScrollContainer/TileButton"] +[node name="SelectTexture" type="NinePatchRect" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/VBoxContainer/ScrollContainer/TileButton"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -154,3 +169,51 @@ patch_margin_top = 3 patch_margin_right = 3 patch_margin_bottom = 3 + +[node name="Panel" type="Panel" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 3.0 + +[node name="ScrollContainer" type="ScrollContainer" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/Panel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 2.0 +offset_top = 2.0 +offset_right = -2.0 +offset_bottom = -2.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 3.0 + +[node name="Preview" type="Panel" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/Panel/ScrollContainer"] +custom_minimum_size = Vector2(0, 450) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Name" type="Label" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/Panel/ScrollContainer/Preview"] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_bottom = 40.0 +grow_horizontal = 2 +text = "Name" +horizontal_alignment = 1 +vertical_alignment = 1 +clip_text = true +text_overrun_behavior = 3 + +[node name="PreviewImage" type="TextureRect" parent="Bg/VBoxContainer/HBoxContainer/Panel/MarginContainer/HBoxContainer2/Panel/ScrollContainer/Preview"] +custom_minimum_size = Vector2(0, 410) +layout_mode = 1 +anchors_preset = 12 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 0 +expand_mode = 2 +stretch_mode = 5 diff --git a/DungeonShooting_Godot/resource/map/tileSet/TileSetConfig.json b/DungeonShooting_Godot/resource/map/tileSet/TileSetConfig.json new file mode 100644 index 0000000..04a100a --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileSet/TileSetConfig.json @@ -0,0 +1,6 @@ +{ + "测试数据": { + "ErrorType": 0, + "Path": "resource/map/tileSet/测试数据" + } +} \ No newline at end of file diff --git "a/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/Test3.png" "b/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/Test3.png" new file mode 100644 index 0000000..d74eba2 --- /dev/null +++ "b/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/Test3.png" Binary files differ diff --git "a/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/Test3.png.import" "b/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/Test3.png.import" new file mode 100644 index 0000000..bf2ed3c --- /dev/null +++ "b/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/Test3.png.import" @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bcfp6gaqj0yl8" +path="res://.godot/imported/Test3.png-cf3c536c55fcfc7190831a6b6b80331f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/map/tileSet/测试数据/Test3.png" +dest_files=["res://.godot/imported/Test3.png-cf3c536c55fcfc7190831a6b6b80331f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git "a/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/TileSet.json" "b/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/TileSet.json" index 666373a..6e89016 100644 --- "a/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/TileSet.json" +++ "b/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/TileSet.json" @@ -791,6 +791,124 @@ ] } ] + }, + { + "Name": "Test3", + "SourcePath": "resource/map/tileSet/\u6D4B\u8BD5\u6570\u636E/Test3.png", + "Terrain": { + "_f": null, + "_vl": null, + "_vc": null, + "_vr": null, + "_vs": null, + "_000_010_010": null, + "_010_010_010": null, + "_010_010_000": null, + "_000_010_000": null, + "_000_011_010": null, + "_010_011_010": null, + "_010_011_000": null, + "_000_011_000": null, + "_000_111_010": null, + "_010_111_010": null, + "_010_111_000": null, + "_000_111_000": null, + "_000_110_010": null, + "_010_110_010": null, + "_010_110_000": null, + "_000_110_000": null, + "_110_111_010": null, + "_010_011_011": null, + "_011_011_010": null, + "_010_111_110": null, + "_000_111_011": null, + "_011_111_111": null, + "_111_111_011": null, + "_011_111_000": null, + "_000_111_110": null, + "_110_111_111": null, + "_111_111_110": null, + "_110_111_000": null, + "_011_111_010": null, + "_010_110_110": null, + "_110_110_010": null, + "_010_111_011": null, + "_000_011_011": null, + "_011_011_011": null, + "_011_111_011": null, + "_011_011_000": null, + "_010_111_111": null, + "_110_111_011": null, + "_111_111_111": null, + "_111_111_000": null, + "_000_111_111": null, + "_011_111_110": null, + "_111_111_010": null, + "_000_110_110": null, + "_110_111_110": null, + "_110_110_110": null, + "_110_110_000": null + }, + "Combination": [] + }, + { + "Name": "Test4", + "SourcePath": null, + "Terrain": { + "_f": null, + "_vl": null, + "_vc": null, + "_vr": null, + "_vs": null, + "_000_010_010": null, + "_010_010_010": null, + "_010_010_000": null, + "_000_010_000": null, + "_000_011_010": null, + "_010_011_010": null, + "_010_011_000": null, + "_000_011_000": null, + "_000_111_010": null, + "_010_111_010": null, + "_010_111_000": null, + "_000_111_000": null, + "_000_110_010": null, + "_010_110_010": null, + "_010_110_000": null, + "_000_110_000": null, + "_110_111_010": null, + "_010_011_011": null, + "_011_011_010": null, + "_010_111_110": null, + "_000_111_011": null, + "_011_111_111": null, + "_111_111_011": null, + "_011_111_000": null, + "_000_111_110": null, + "_110_111_111": null, + "_111_111_110": null, + "_110_111_000": null, + "_011_111_010": null, + "_010_110_110": null, + "_110_110_010": null, + "_010_111_011": null, + "_000_011_011": null, + "_011_011_011": null, + "_011_111_011": null, + "_011_011_000": null, + "_010_111_111": null, + "_110_111_011": null, + "_111_111_111": null, + "_111_111_000": null, + "_000_111_111": null, + "_011_111_110": null, + "_111_111_010": null, + "_000_110_110": null, + "_110_111_110": null, + "_110_110_110": null, + "_110_110_000": null + }, + "Combination": [] } ] } \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/sprite/ui/commonIcon/Success_mini.png b/DungeonShooting_Godot/resource/sprite/ui/commonIcon/Success_mini.png new file mode 100644 index 0000000..f0ee233 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/ui/commonIcon/Success_mini.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/ui/commonIcon/Success_mini.png.import b/DungeonShooting_Godot/resource/sprite/ui/commonIcon/Success_mini.png.import new file mode 100644 index 0000000..6de5da5 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/ui/commonIcon/Success_mini.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://do3q1nsagxayh" +path="res://.godot/imported/Success_mini.png-d6b53004d1673ea1eec0224fa98c69b6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/ui/commonIcon/Success_mini.png" +dest_files=["res://.godot/imported/Success_mini.png-d6b53004d1673ea1eec0224fa98c69b6.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSplit.cs b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSplit.cs new file mode 100644 index 0000000..942f1e2 --- /dev/null +++ b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSplit.cs @@ -0,0 +1,66 @@ + +using System.Text.Json; +using System.Text.Json.Serialization; + +public class TileSetSplit +{ + /// + /// 错误类型 + /// + [JsonInclude] + public int ErrorType; + + /// + /// 路径 + /// + [JsonInclude] + public string Path; + + /// + /// 备注 + /// + [JsonInclude] + public string Remark; + + /// + /// 图块集路径 + /// + [JsonIgnore] + public string TileSetPath => Path + "/TileSet.json"; + + /// + /// 图块集信息 + /// + [JsonIgnore] + public TileSetInfo TileSetInfo + { + get + { + if (_tileSetInfo == null && TileSetPath != null) + { + ReloadTileSetInfo(); + } + + return _tileSetInfo; + } + } + + private TileSetInfo _tileSetInfo; + + /// + /// 设置图块集信息 + /// + public void SetTileSetInfo(TileSetInfo info) + { + _tileSetInfo = info; + } + + /// + /// 重新加载图块集信息 + /// + public void ReloadTileSetInfo() + { + var asText = ResourceManager.LoadText("res://" + TileSetPath); + _tileSetInfo = JsonSerializer.Deserialize(asText); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index 9eda44b..e748120 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -57,6 +57,11 @@ /// public Dictionary RoomConfig { get; private set; } + /// + /// TileSet配置 + /// + public Dictionary TileSetConfig { get; private set; } + // /// // /// 房间配置数据, key: 模板房间资源路径 // /// @@ -91,6 +96,8 @@ ExcelConfig.Init(); //初始化房间配置数据 InitRoomConfig(); + //初始化TileSet配置数据 + InitTileSetConfig(); //初始化武器数据 Weapon.InitWeaponAttribute(); //初始化敌人数据 @@ -262,6 +269,20 @@ } } + //初始化TileSet配置 + private void InitTileSetConfig() + { + //加载房间配置信息 + var asText = ResourceManager.LoadText("res://" + GameConfig.RoomTileSetDir + GameConfig.TileSetConfigFile); + TileSetConfig = JsonSerializer.Deserialize>(asText); + + //加载所有数据 + foreach (var tileSetSplit in TileSetConfig) + { + tileSetSplit.Value.ReloadTileSetInfo(); + } + } + //窗体大小改变 private void OnWindowSizeChanged() { diff --git a/DungeonShooting_Godot/src/game/GameConfig.cs b/DungeonShooting_Godot/src/game/GameConfig.cs index 552a45d..696f91b 100644 --- a/DungeonShooting_Godot/src/game/GameConfig.cs +++ b/DungeonShooting_Godot/src/game/GameConfig.cs @@ -47,6 +47,10 @@ /// public const string RoomGroupConfigFile = "GroupConfig.json"; /// + /// TileSet配置文件 + /// + public const string TileSetConfigFile = "TileSetConfig.json"; + /// /// ui预制体路径 /// public const string UiPrefabDir = "prefab/ui/"; diff --git a/DungeonShooting_Godot/src/game/event/EventEnum.cs b/DungeonShooting_Godot/src/game/event/EventEnum.cs index fa848a4..af3581a 100644 --- a/DungeonShooting_Godot/src/game/event/EventEnum.cs +++ b/DungeonShooting_Godot/src/game/event/EventEnum.cs @@ -149,7 +149,7 @@ OnSetMarkVisible, /// - /// 保存TileSet, 参数为 + /// 保存TileSet, 参数为 /// OnTileSetSave, /// diff --git a/DungeonShooting_Godot/src/game/manager/EditorTileSetManager.cs b/DungeonShooting_Godot/src/game/manager/EditorTileSetManager.cs index b03a3d9..0d02792 100644 --- a/DungeonShooting_Godot/src/game/manager/EditorTileSetManager.cs +++ b/DungeonShooting_Godot/src/game/manager/EditorTileSetManager.cs @@ -211,11 +211,23 @@ return null; } + /// + /// 保存TileSetConfig数据 + /// + public static void SaveTileSetConfig() + { + var options = new JsonSerializerOptions(); + options.WriteIndented = true; + var jsonText = JsonSerializer.Serialize(GameApplication.Instance.TileSetConfig, options); + File.WriteAllText(GameConfig.RoomTileSetDir + GameConfig.TileSetConfigFile, jsonText); + } + //保存图块集 private static void OnTileSetSave(object o) { - if (o is TileSetInfo tileSetInfo) + if (o is TileSetSplit tileSetSplit) { + var tileSetInfo = tileSetSplit.TileSetInfo; var dir = CustomMapPath + tileSetInfo.Name; if (Directory.Exists(dir)) { @@ -259,7 +271,10 @@ if (sourceInfo.IsOverWriteImage()) { var image = sourceInfo.GetSourceImage(); - image.SavePng(dir + "/" + sourceInfo.Name + ".png"); + if (image != null) + { + image.SavePng(dir + "/" + sourceInfo.Name + ".png"); + } } } } diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs index 9bf03c5..1bb91ac 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs @@ -9,15 +9,16 @@ /// 数据是否脏了 /// public bool IsDirty { get; private set; } - + + /// + /// 编辑使用的 tileSetSplit 数据 + /// + public TileSetSplit TileSetSplit { get; private set; } + /// /// 编辑使用的 tileSetInfo 数据 /// public TileSetInfo TileSetInfo { get; private set; } - /// - /// 原始 tileSetInfo 数据 - /// - public TileSetInfo OriginTileSetInfo { get; private set; } /// /// 当前正在使用的 TileSetSourceInfo 数据 @@ -116,11 +117,12 @@ /// /// 初始化数据 /// - public void InitData(TileSetInfo tileSetInfo) + public void InitData(TileSetSplit tileSetSplit) { IsDirty = false; - OriginTileSetInfo = tileSetInfo; - TileSetInfo = tileSetInfo.Clone(); + tileSetSplit.ReloadTileSetInfo(); + TileSetSplit = tileSetSplit; + TileSetInfo = tileSetSplit.TileSetInfo.Clone(); RefreshTitle(); //初始化下拉框 @@ -321,7 +323,9 @@ //保存 private void OnSaveClick() { - EventManager.EmitEvent(EventEnum.OnTileSetSave, TileSetInfo); + TileSetSplit.TileSetInfo.Dispose(); + TileSetSplit.SetTileSetInfo(TileSetInfo.Clone()); + EventManager.EmitEvent(EventEnum.OnTileSetSave, TileSetSplit); IsDirty = false; RefreshTitle(); } diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/PreviewCell.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/PreviewCell.cs new file mode 100644 index 0000000..348fa94 --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/PreviewCell.cs @@ -0,0 +1,35 @@ +using Godot; + +namespace UI.TileSetEditorProject; + +public class PreviewCell : UiCell +{ + private ImageTexture _imageTexture; + + public override void OnInit() + { + _imageTexture = new ImageTexture(); + CellNode.L_PreviewImage.Instance.Texture = _imageTexture; + } + + public override void OnSetData(TileSetSourceInfo data) + { + CellNode.L_Name.Instance.Text = data.Name; + var sourceImage = data.GetSourceImage(); + if (sourceImage == null) + { + CellNode.L_PreviewImage.Instance.Visible = false; + } + else + { + CellNode.L_PreviewImage.Instance.Visible = true; + _imageTexture.SetImage(sourceImage); + } + } + + public override void OnDestroy() + { + _imageTexture.Dispose(); + _imageTexture = null; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileButtonCell.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileButtonCell.cs index 56aba1d..dc5d128 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileButtonCell.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileButtonCell.cs @@ -1,13 +1,19 @@  +using Godot; using UI.TileSetEditor; namespace UI.TileSetEditorProject; -public class TileButtonCell : UiCell +public class TileButtonCell : UiCell { - public override void OnSetData(TileSetInfo data) + public override void OnInit() { - CellNode.L_TileName.Instance.Text = data.Name; + CellNode.L_SelectTexture.Instance.Visible = false; + } + + public override void OnSetData(TileSetSplit data) + { + CellNode.L_TileName.Instance.Text = data.TileSetInfo.Name; } public override void OnDoubleClick() @@ -16,4 +22,16 @@ var tileSetEditorPanel = CellNode.UiPanel.OpenNextUi(UiManager.UiNames.TileSetEditor); tileSetEditorPanel.InitData(Data); } + + public override void OnSelect() + { + CellNode.L_SelectTexture.Instance.Visible = true; + var previewGrid = CellNode.UiPanel.PreviewGrid; + previewGrid.SetDataList(Data.TileSetInfo.Sources.ToArray()); + } + + public override void OnUnSelect() + { + CellNode.L_SelectTexture.Instance.Visible = false; + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProject.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProject.cs index 75da239..01bd478 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProject.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProject.cs @@ -82,7 +82,7 @@ } /// - /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.HBoxContainer.TileSearchInput + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.HBoxContainer.TileSearchInput /// public class TileSearchInput : UiNode { @@ -91,7 +91,7 @@ } /// - /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.HBoxContainer.TileSearchButton + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.HBoxContainer.TileSearchButton /// public class TileSearchButton : UiNode { @@ -100,7 +100,7 @@ } /// - /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.HBoxContainer.TileAddButton + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.HBoxContainer.TileAddButton /// public class TileAddButton : UiNode { @@ -109,12 +109,30 @@ } /// - /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.HBoxContainer + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.HBoxContainer.TileEditButton + /// + public class TileEditButton : UiNode + { + public TileEditButton(TileSetEditorProjectPanel uiPanel, Godot.Button node) : base(uiPanel, node) { } + public override TileEditButton Clone() => new (UiPanel, (Godot.Button)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.HBoxContainer.TileDeleteButton + /// + public class TileDeleteButton : UiNode + { + public TileDeleteButton(TileSetEditorProjectPanel uiPanel, Godot.Button node) : base(uiPanel, node) { } + public override TileDeleteButton Clone() => new (UiPanel, (Godot.Button)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.HBoxContainer /// public class HBoxContainer_1 : UiNode { /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.TileSearchInput + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.TileSearchInput /// public TileSearchInput L_TileSearchInput { @@ -127,7 +145,7 @@ private TileSearchInput _L_TileSearchInput; /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.TileSearchButton + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.TileSearchButton /// public TileSearchButton L_TileSearchButton { @@ -140,7 +158,7 @@ private TileSearchButton _L_TileSearchButton; /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.TileAddButton + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.TileAddButton /// public TileAddButton L_TileAddButton { @@ -152,21 +170,47 @@ } private TileAddButton _L_TileAddButton; + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.TileEditButton + /// + public TileEditButton L_TileEditButton + { + get + { + if (_L_TileEditButton == null) _L_TileEditButton = new TileEditButton(UiPanel, Instance.GetNode("TileEditButton")); + return _L_TileEditButton; + } + } + private TileEditButton _L_TileEditButton; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.TileDeleteButton + /// + public TileDeleteButton L_TileDeleteButton + { + get + { + if (_L_TileDeleteButton == null) _L_TileDeleteButton = new TileDeleteButton(UiPanel, Instance.GetNode("TileDeleteButton")); + return _L_TileDeleteButton; + } + } + private TileDeleteButton _L_TileDeleteButton; + public HBoxContainer_1(TileSetEditorProjectPanel uiPanel, Godot.HBoxContainer node) : base(uiPanel, node) { } public override HBoxContainer_1 Clone() => new (UiPanel, (Godot.HBoxContainer)Instance.Duplicate()); } /// - /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.TileButton.PreviewImage + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.ScrollContainer.TileButton.Icon /// - public class PreviewImage : UiNode + public class Icon : UiNode { - public PreviewImage(TileSetEditorProjectPanel uiPanel, Godot.TextureRect node) : base(uiPanel, node) { } - public override PreviewImage Clone() => new (UiPanel, (Godot.TextureRect)Instance.Duplicate()); + public Icon(TileSetEditorProjectPanel uiPanel, Godot.TextureRect node) : base(uiPanel, node) { } + public override Icon Clone() => new (UiPanel, (Godot.TextureRect)Instance.Duplicate()); } /// - /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.TileButton.TileName + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.ScrollContainer.TileButton.TileName /// public class TileName : UiNode { @@ -175,7 +219,7 @@ } /// - /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.TileButton.SelectTexture + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.ScrollContainer.TileButton.SelectTexture /// public class SelectTexture : UiNode { @@ -184,25 +228,25 @@ } /// - /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.TileButton + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.ScrollContainer.TileButton /// public class TileButton : UiNode { /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.PreviewImage + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.ScrollContainer.Icon /// - public PreviewImage L_PreviewImage + public Icon L_Icon { get { - if (_L_PreviewImage == null) _L_PreviewImage = new PreviewImage(UiPanel, Instance.GetNode("PreviewImage")); - return _L_PreviewImage; + if (_L_Icon == null) _L_Icon = new Icon(UiPanel, Instance.GetNode("Icon")); + return _L_Icon; } } - private PreviewImage _L_PreviewImage; + private Icon _L_Icon; /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.TileName + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.ScrollContainer.TileName /// public TileName L_TileName { @@ -215,7 +259,7 @@ private TileName _L_TileName; /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.SelectTexture + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.ScrollContainer.SelectTexture /// public SelectTexture L_SelectTexture { @@ -232,12 +276,12 @@ } /// - /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.ScrollContainer /// public class ScrollContainer : UiNode { /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.TileButton + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.TileButton /// public TileButton L_TileButton { @@ -254,12 +298,12 @@ } /// - /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer /// public class VBoxContainer_1 : UiNode { /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.HBoxContainer /// public HBoxContainer_1 L_HBoxContainer { @@ -272,7 +316,7 @@ private HBoxContainer_1 _L_HBoxContainer; /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.ScrollContainer + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.ScrollContainer /// public ScrollContainer L_ScrollContainer { @@ -289,12 +333,109 @@ } /// - /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.Panel.ScrollContainer.Preview.Name /// - public class MarginContainer : UiNode + public class Name : UiNode + { + public Name(TileSetEditorProjectPanel uiPanel, Godot.Label node) : base(uiPanel, node) { } + public override Name Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.Panel.ScrollContainer.Preview.PreviewImage + /// + public class PreviewImage : UiNode + { + public PreviewImage(TileSetEditorProjectPanel uiPanel, Godot.TextureRect node) : base(uiPanel, node) { } + public override PreviewImage Clone() => new (UiPanel, (Godot.TextureRect)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.Panel.ScrollContainer.Preview + /// + public class Preview : UiNode { /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.VBoxContainer + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.Panel.ScrollContainer.Name + /// + public Name L_Name + { + get + { + if (_L_Name == null) _L_Name = new Name(UiPanel, Instance.GetNode("Name")); + return _L_Name; + } + } + private Name _L_Name; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.Panel.ScrollContainer.PreviewImage + /// + public PreviewImage L_PreviewImage + { + get + { + if (_L_PreviewImage == null) _L_PreviewImage = new PreviewImage(UiPanel, Instance.GetNode("PreviewImage")); + return _L_PreviewImage; + } + } + private PreviewImage _L_PreviewImage; + + public Preview(TileSetEditorProjectPanel uiPanel, Godot.Panel node) : base(uiPanel, node) { } + public override Preview Clone() => new (UiPanel, (Godot.Panel)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.Panel.ScrollContainer + /// + public class ScrollContainer_1 : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.Panel.Preview + /// + public Preview L_Preview + { + get + { + if (_L_Preview == null) _L_Preview = new Preview(UiPanel, Instance.GetNode("Preview")); + return _L_Preview; + } + } + private Preview _L_Preview; + + public ScrollContainer_1(TileSetEditorProjectPanel uiPanel, Godot.ScrollContainer node) : base(uiPanel, node) { } + public override ScrollContainer_1 Clone() => new (UiPanel, (Godot.ScrollContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.Panel + /// + public class Panel_1 : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.ScrollContainer + /// + public ScrollContainer_1 L_ScrollContainer + { + get + { + if (_L_ScrollContainer == null) _L_ScrollContainer = new ScrollContainer_1(UiPanel, Instance.GetNode("ScrollContainer")); + return _L_ScrollContainer; + } + } + private ScrollContainer_1 _L_ScrollContainer; + + public Panel_1(TileSetEditorProjectPanel uiPanel, Godot.Panel node) : base(uiPanel, node) { } + public override Panel_1 Clone() => new (UiPanel, (Godot.Panel)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2 + /// + public class HBoxContainer2 : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer /// public VBoxContainer_1 L_VBoxContainer { @@ -306,6 +447,41 @@ } private VBoxContainer_1 _L_VBoxContainer; + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.Panel + /// + public Panel_1 L_Panel + { + get + { + if (_L_Panel == null) _L_Panel = new Panel_1(UiPanel, Instance.GetNode("Panel")); + return _L_Panel; + } + } + private Panel_1 _L_Panel; + + public HBoxContainer2(TileSetEditorProjectPanel uiPanel, Godot.HBoxContainer node) : base(uiPanel, node) { } + public override HBoxContainer2 Clone() => new (UiPanel, (Godot.HBoxContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer + /// + public class MarginContainer : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.HBoxContainer2 + /// + public HBoxContainer2 L_HBoxContainer2 + { + get + { + if (_L_HBoxContainer2 == null) _L_HBoxContainer2 = new HBoxContainer2(UiPanel, Instance.GetNode("HBoxContainer2")); + return _L_HBoxContainer2; + } + } + private HBoxContainer2 _L_HBoxContainer2; + public MarginContainer(TileSetEditorProjectPanel uiPanel, Godot.MarginContainer node) : base(uiPanel, node) { } public override MarginContainer Clone() => new (UiPanel, (Godot.MarginContainer)Instance.Duplicate()); } @@ -428,44 +604,69 @@ public Head S_Head => L_Bg.L_VBoxContainer.L_Head; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.HBoxContainer.TileSearchInput + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.HBoxContainer.TileSearchInput /// - public TileSearchInput S_TileSearchInput => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_VBoxContainer.L_HBoxContainer.L_TileSearchInput; + public TileSearchInput S_TileSearchInput => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2.L_VBoxContainer.L_HBoxContainer.L_TileSearchInput; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.HBoxContainer.TileSearchButton + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.HBoxContainer.TileSearchButton /// - public TileSearchButton S_TileSearchButton => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_VBoxContainer.L_HBoxContainer.L_TileSearchButton; + public TileSearchButton S_TileSearchButton => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2.L_VBoxContainer.L_HBoxContainer.L_TileSearchButton; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.HBoxContainer.TileAddButton + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.HBoxContainer.TileAddButton /// - public TileAddButton S_TileAddButton => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_VBoxContainer.L_HBoxContainer.L_TileAddButton; + public TileAddButton S_TileAddButton => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2.L_VBoxContainer.L_HBoxContainer.L_TileAddButton; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.TileButton.PreviewImage + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.HBoxContainer.TileEditButton /// - public PreviewImage S_PreviewImage => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_VBoxContainer.L_ScrollContainer.L_TileButton.L_PreviewImage; + public TileEditButton S_TileEditButton => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2.L_VBoxContainer.L_HBoxContainer.L_TileEditButton; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.TileButton.TileName + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.HBoxContainer.TileDeleteButton /// - public TileName S_TileName => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_VBoxContainer.L_ScrollContainer.L_TileButton.L_TileName; + public TileDeleteButton S_TileDeleteButton => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2.L_VBoxContainer.L_HBoxContainer.L_TileDeleteButton; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.TileButton.SelectTexture + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.ScrollContainer.TileButton.Icon /// - public SelectTexture S_SelectTexture => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_VBoxContainer.L_ScrollContainer.L_TileButton.L_SelectTexture; + public Icon S_Icon => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2.L_VBoxContainer.L_ScrollContainer.L_TileButton.L_Icon; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.TileButton + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.ScrollContainer.TileButton.TileName /// - public TileButton S_TileButton => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_VBoxContainer.L_ScrollContainer.L_TileButton; + public TileName S_TileName => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2.L_VBoxContainer.L_ScrollContainer.L_TileButton.L_TileName; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.ScrollContainer.TileButton.SelectTexture /// - public ScrollContainer S_ScrollContainer => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_VBoxContainer.L_ScrollContainer; + public SelectTexture S_SelectTexture => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2.L_VBoxContainer.L_ScrollContainer.L_TileButton.L_SelectTexture; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.VBoxContainer.ScrollContainer.TileButton + /// + public TileButton S_TileButton => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2.L_VBoxContainer.L_ScrollContainer.L_TileButton; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.Panel.ScrollContainer.Preview.Name + /// + public Name S_Name => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2.L_Panel.L_ScrollContainer.L_Preview.L_Name; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.Panel.ScrollContainer.Preview.PreviewImage + /// + public PreviewImage S_PreviewImage => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2.L_Panel.L_ScrollContainer.L_Preview.L_PreviewImage; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2.Panel.ScrollContainer.Preview + /// + public Preview S_Preview => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2.L_Panel.L_ScrollContainer.L_Preview; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer.HBoxContainer2 + /// + public HBoxContainer2 S_HBoxContainer2 => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer.L_HBoxContainer2; /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel.MarginContainer @@ -473,11 +674,6 @@ public MarginContainer S_MarginContainer => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel.L_MarginContainer; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg.VBoxContainer.HBoxContainer.Panel - /// - public Panel S_Panel => L_Bg.L_VBoxContainer.L_HBoxContainer.L_Panel; - - /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorProject.Bg /// public Bg S_Bg => L_Bg; diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs index 07ae992..c447b3a 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs @@ -6,8 +6,15 @@ public partial class TileSetEditorProjectPanel : TileSetEditorProject { - - private UiGrid _grid; + /// + /// TileSet列表 + /// + public UiGrid Grid { get; private set; } + + /// + /// TileSet Source 预览列表 + /// + public UiGrid PreviewGrid { get; private set; } public override void OnCreateUi() { @@ -17,19 +24,46 @@ OpenPrevUi(); }; - _grid = new UiGrid(S_TileButton, typeof(TileButtonCell)); - _grid.SetAutoColumns(true); - _grid.SetCellOffset(new Vector2I(10, 10)); - _grid.SetHorizontalExpand(true); + S_TileSearchButton.Instance.Pressed += OnSearchClick; - var jsonData = File.ReadAllText("resource/map/tileSet/测试数据/TileSet.json"); - var tileSetInfo = JsonSerializer.Deserialize(jsonData); - _grid.Add(tileSetInfo); + Grid = CreateUiGrid(S_TileButton); + Grid.SetColumns(1); + Grid.SetCellOffset(new Vector2I(0, 5)); + Grid.SetHorizontalExpand(true); + + PreviewGrid = CreateUiGrid(S_Preview); + PreviewGrid.SetColumns(1); + PreviewGrid.SetCellOffset(new Vector2I(0, 15)); + PreviewGrid.SetHorizontalExpand(true); + + //初始化数据 + OnSearchClick(); } - public override void OnDestroyUi() + public override void OnShowUi() { - _grid.Destroy(); + OnSearchClick(); } + /// + /// 刷新数据 + /// + public void SearchData(string text) + { + Grid.RemoveAll(); + PreviewGrid.RemoveAll(); + text = text.ToLower(); + foreach (var tileSetSplit in GameApplication.Instance.TileSetConfig) + { + if (text.Length == 0 || tileSetSplit.Value.TileSetInfo.Name.ToLower().Contains(text)) + { + Grid.Add(tileSetSplit.Value); + } + } + } + + private void OnSearchClick() + { + SearchData(S_TileSearchInput.Instance.Text); + } }