diff --git a/DungeonShooting_Godot/prefab/ui/EditorTileImage.tscn b/DungeonShooting_Godot/prefab/ui/EditorTileImage.tscn new file mode 100644 index 0000000..991d05e --- /dev/null +++ b/DungeonShooting_Godot/prefab/ui/EditorTileImage.tscn @@ -0,0 +1,148 @@ +[gd_scene load_steps=4 format=3 uid="uid://c506mkdjqua2r"] + +[ext_resource type="Script" path="res://src/game/ui/editorTileImage/EditorTileImagePanel.cs" id="1_y1hns"] +[ext_resource type="Texture2D" uid="uid://d2wslibovwv7w" path="res://resource/sprite/ui/commonIcon/CenterTool.png" id="2_ntsra"] +[ext_resource type="Script" path="res://src/game/ui/editorTileImage/ImageBg.cs" id="2_qkj2u"] + +[node name="EditorTileImage" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_y1hns") + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/separation = 0 + +[node name="Left" type="Panel" parent="HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Bg" type="ColorRect" parent="HBoxContainer/Left"] +clip_children = 2 +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 +color = Color(0.145098, 0.145098, 0.145098, 1) +script = ExtResource("2_qkj2u") + +[node name="TextureRoot" type="Control" parent="HBoxContainer/Left/Bg"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -0.5 +offset_top = -0.5 +offset_right = 0.5 +offset_bottom = 0.5 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 + +[node name="TileSprite" type="Sprite2D" parent="HBoxContainer/Left/Bg/TextureRoot"] +centered = false + +[node name="Brush" type="Control" parent="HBoxContainer/Left/Bg/TextureRoot"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 + +[node name="FocusBtn" type="TextureButton" parent="HBoxContainer/Left/Bg"] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -79.0 +offset_top = 14.0 +offset_right = -15.0 +offset_bottom = 78.0 +grow_horizontal = 0 +tooltip_text = "聚焦" +texture_normal = ExtResource("2_ntsra") +ignore_texture_size = true +stretch_mode = 5 + +[node name="Right" type="Panel" parent="HBoxContainer"] +custom_minimum_size = Vector2(400, 0) +layout_mode = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/Right"] +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 + +[node name="HBoxContainer" type="HBoxContainer" parent="HBoxContainer/Right/VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="HBoxContainer/Right/VBoxContainer/HBoxContainer"] +custom_minimum_size = Vector2(160, 0) +layout_mode = 2 +text = "起始X:" + +[node name="SpinBox" type="SpinBox" parent="HBoxContainer/Right/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="HBoxContainer2" type="HBoxContainer" parent="HBoxContainer/Right/VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="HBoxContainer/Right/VBoxContainer/HBoxContainer2"] +custom_minimum_size = Vector2(160, 0) +layout_mode = 2 +text = "起始Y:" + +[node name="SpinBox" type="SpinBox" parent="HBoxContainer/Right/VBoxContainer/HBoxContainer2"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="HBoxContainer3" type="HBoxContainer" parent="HBoxContainer/Right/VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="HBoxContainer/Right/VBoxContainer/HBoxContainer3"] +custom_minimum_size = Vector2(160, 0) +layout_mode = 2 +text = "间距Y:" + +[node name="SpinBox" type="SpinBox" parent="HBoxContainer/Right/VBoxContainer/HBoxContainer3"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="HBoxContainer4" type="HBoxContainer" parent="HBoxContainer/Right/VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="HBoxContainer/Right/VBoxContainer/HBoxContainer4"] +custom_minimum_size = Vector2(160, 0) +layout_mode = 2 +text = "间距Y:" + +[node name="SpinBox" type="SpinBox" parent="HBoxContainer/Right/VBoxContainer/HBoxContainer4"] +layout_mode = 2 +size_flags_horizontal = 3 diff --git a/DungeonShooting_Godot/prefab/ui/MapEditorMapTile.tscn b/DungeonShooting_Godot/prefab/ui/MapEditorMapTile.tscn index 49c7fd0..64027e4 100644 --- a/DungeonShooting_Godot/prefab/ui/MapEditorMapTile.tscn +++ b/DungeonShooting_Godot/prefab/ui/MapEditorMapTile.tscn @@ -16,6 +16,7 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_gtth6") +Layer = null [node name="VBoxContainer" type="VBoxContainer" parent="."] layout_mode = 1 diff --git a/DungeonShooting_Godot/resource/material/Grid.tres b/DungeonShooting_Godot/resource/material/Grid.tres index eaf95e9..2b824d9 100644 --- a/DungeonShooting_Godot/resource/material/Grid.tres +++ b/DungeonShooting_Godot/resource/material/Grid.tres @@ -5,7 +5,7 @@ [resource] resource_local_to_scene = true shader = ExtResource("1_xhgfe") -shader_parameter/color = Color(0.529412, 0.529412, 0.529412, 0.0431373) +shader_parameter/color = Color(0.529412, 0.529412, 0.529412, 0.0784314) shader_parameter/size = Vector2(1280, 720) shader_parameter/line_width = 2 shader_parameter/offset = Vector2(0, 0) diff --git a/DungeonShooting_Godot/scene/Main.tscn b/DungeonShooting_Godot/scene/Main.tscn index 346e221..698f3f2 100644 --- a/DungeonShooting_Godot/scene/Main.tscn +++ b/DungeonShooting_Godot/scene/Main.tscn @@ -39,5 +39,6 @@ process_callback = 0 editor_draw_drag_margin = true script = ExtResource("2_2j367") +RecoveryCoefficient = null [node name="GlobalNodeRoot" type="Node2D" parent="."] diff --git a/DungeonShooting_Godot/src/game/common/ui/EditorGridBg.cs b/DungeonShooting_Godot/src/game/common/ui/EditorGridBg.cs index 44dbb5c..2bb7f0e 100644 --- a/DungeonShooting_Godot/src/game/common/ui/EditorGridBg.cs +++ b/DungeonShooting_Godot/src/game/common/ui/EditorGridBg.cs @@ -26,13 +26,16 @@ /// /// 可拖拽容器根节点 /// 当前对象绑定的Ui节点 - public void InitNode(Control containerRoot, ColorRect grid) + public void InitNode(Control containerRoot, ColorRect grid = null) { ContainerRoot = containerRoot; - Grid = grid; - grid.MouseFilter = MouseFilterEnum.Ignore; - _gridMaterial = ResourceManager.Load(ResourcePath.resource_material_Grid_tres, false); - grid.Material = _gridMaterial; + if (grid != null) + { + Grid = grid; + grid.MouseFilter = MouseFilterEnum.Ignore; + _gridMaterial = ResourceManager.Load(ResourcePath.resource_material_Grid_tres, false); + grid.Material = _gridMaterial; + } } public virtual void SetUiNode(IUiNode uiNode) @@ -103,15 +106,32 @@ /// public void RefreshGridTrans() { - _gridMaterial.SetShaderMaterialParameter(ShaderParamNames.Size, Size); - SetGridTransform(ContainerRoot.Position, ContainerRoot.Scale.X); + if (_gridMaterial != null) + { + _gridMaterial.SetShaderMaterialParameter(ShaderParamNames.Size, Size); + SetGridTransform(ContainerRoot.Position, ContainerRoot.Scale.X); + } } //设置网格位置和缩放 private void SetGridTransform(Vector2 pos, float scale) { - _gridMaterial.SetShaderMaterialParameter(ShaderParamNames.GridSize, GameConfig.TileCellSize * scale); - _gridMaterial.SetShaderMaterialParameter(ShaderParamNames.Offset, -pos); + if (_gridMaterial != null) + { + _gridMaterial.SetShaderMaterialParameter(ShaderParamNames.GridSize, GameConfig.TileCellSize * scale); + _gridMaterial.SetShaderMaterialParameter(ShaderParamNames.Offset, -pos); + } + } + + /// + /// 设置网格颜色 + /// + public void SetLineColor(Color color) + { + if (_gridMaterial != null) + { + _gridMaterial.SetShaderMaterialParameter(ShaderParamNames.Color, color); + } } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/data/property/ShaderParamNames.cs b/DungeonShooting_Godot/src/game/data/property/ShaderParamNames.cs index 9c00cc1..e6e924c 100644 --- a/DungeonShooting_Godot/src/game/data/property/ShaderParamNames.cs +++ b/DungeonShooting_Godot/src/game/data/property/ShaderParamNames.cs @@ -34,6 +34,10 @@ /// 网格大小 /// public static readonly StringName GridSize = "grid_size"; + /// + /// 颜色 + /// + public static readonly StringName Color = "color"; /// /// 快速设置一个材质的 shader 材质参数 diff --git a/DungeonShooting_Godot/src/game/manager/EditorWindowManager.cs b/DungeonShooting_Godot/src/game/manager/EditorWindowManager.cs index 4abfe28..19638b2 100644 --- a/DungeonShooting_Godot/src/game/manager/EditorWindowManager.cs +++ b/DungeonShooting_Godot/src/game/manager/EditorWindowManager.cs @@ -10,6 +10,7 @@ using UI.EditorImportCombination; using UI.EditorInfo; using UI.EditorInput; +using UI.EditorTileImage; using UI.EditorTips; using UI.EditorWindow; using UI.MapEditorCreateMark; @@ -753,6 +754,25 @@ }) ); } + + public static void ShowImportTileImage(Image image, UiBase parentUi = null) + { + var window = CreateWindowInstance(parentUi); + window.SetWindowTitle("导入纹理"); + window.SetWindowSize(new Vector2I(1400, 800)); + var body = window.OpenBody(UiManager.UiNames.EditorTileImage); + body.InitData(image); + window.SetButtonList( + new EditorWindowPanel.ButtonData("确定", () => + { + window.CloseWindow(); + }), + new EditorWindowPanel.ButtonData("取消", () => + { + window.CloseWindow(); + }) + ); + } private static EditorWindowPanel CreateWindowInstance(UiBase parentUi = null) { diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs index 821cfaf..eb06752 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -6,12 +6,21 @@ public const string default_bus_layout_tres = "res://default_bus_layout.tres"; public const string default_env_tres = "res://default_env.tres"; public const string icon_png = "res://icon.png"; + public const string _VSCodeCounter_20240109_204848_diff_txt = "res://.VSCodeCounter/2024-01-09_20-48-48/diff.txt"; + public const string _VSCodeCounter_20240109_204848_results_json = "res://.VSCodeCounter/2024-01-09_20-48-48/results.json"; + public const string _VSCodeCounter_20240109_204848_results_txt = "res://.VSCodeCounter/2024-01-09_20-48-48/results.txt"; + public const string _VSCodeCounter_20240112_214732_diff_txt = "res://.VSCodeCounter/2024-01-12_21-47-32/diff.txt"; + public const string _VSCodeCounter_20240112_214732_results_json = "res://.VSCodeCounter/2024-01-12_21-47-32/results.json"; + public const string _VSCodeCounter_20240112_214732_results_txt = "res://.VSCodeCounter/2024-01-12_21-47-32/results.txt"; + public const string _VSCodeCounter_20240117_161913_diff_txt = "res://.VSCodeCounter/2024-01-17_16-19-13/diff.txt"; + public const string _VSCodeCounter_20240117_161913_results_json = "res://.VSCodeCounter/2024-01-17_16-19-13/results.json"; + public const string _VSCodeCounter_20240117_161913_results_txt = "res://.VSCodeCounter/2024-01-17_16-19-13/results.txt"; public const string excelTool_bin_Release_net8_0_winx64_ExcelTool_deps_json = "res://excelTool/bin/Release/net8.0/win-x64/ExcelTool.deps.json"; public const string excelTool_bin_Release_net8_0_winx64_ExcelTool_runtimeconfig_json = "res://excelTool/bin/Release/net8.0/win-x64/ExcelTool.runtimeconfig.json"; public const string excelTool_obj_ExcelTool_csproj_nuget_dgspec_json = "res://excelTool/obj/ExcelTool.csproj.nuget.dgspec.json"; public const string excelTool_obj_project_assets_json = "res://excelTool/obj/project.assets.json"; public const string excelTool_obj_Release_net8_0_winx64_ExcelTool_csproj_FileListAbsolute_txt = "res://excelTool/obj/Release/net8.0/win-x64/ExcelTool.csproj.FileListAbsolute.txt"; - public const string excelTool_obj_Release_net8_0_winx64_PublishOutputs_a0fcfe3642_txt = "res://excelTool/obj/Release/net8.0/win-x64/PublishOutputs.a0fcfe3642.txt"; + public const string excelTool_obj_Release_net8_0_winx64_PublishOutputs_77891b5d25_txt = "res://excelTool/obj/Release/net8.0/win-x64/PublishOutputs.77891b5d25.txt"; public const string excelTool_publish_winx64_ExcelTool_deps_json = "res://excelTool/publish/win-x64/ExcelTool.deps.json"; public const string excelTool_publish_winx64_ExcelTool_runtimeconfig_json = "res://excelTool/publish/win-x64/ExcelTool.runtimeconfig.json"; public const string prefab_Cursor_tscn = "res://prefab/Cursor.tscn"; @@ -75,6 +84,7 @@ public const string prefab_ui_EditorInfo_tscn = "res://prefab/ui/EditorInfo.tscn"; public const string prefab_ui_EditorInput_tscn = "res://prefab/ui/EditorInput.tscn"; public const string prefab_ui_EditorManager_tscn = "res://prefab/ui/EditorManager.tscn"; + public const string prefab_ui_EditorTileImage_tscn = "res://prefab/ui/EditorTileImage.tscn"; public const string prefab_ui_EditorTips_tscn = "res://prefab/ui/EditorTips.tscn"; public const string prefab_ui_EditorTools_tscn = "res://prefab/ui/EditorTools.tscn"; public const string prefab_ui_EditorWindow_tscn = "res://prefab/ui/EditorWindow.tscn"; @@ -127,6 +137,8 @@ public const string resource_map_tileSet_TileSetConfig_json = "res://resource/map/tileSet/TileSetConfig.json"; public const string resource_map_tileSet_TileSet1_Main_png = "res://resource/map/tileSet/TileSet1/Main.png"; public const string resource_map_tileSet_TileSet1_Test1_png = "res://resource/map/tileSet/TileSet1/Test1.png"; + public const string resource_map_tileSet_TileSet1_Test2_png = "res://resource/map/tileSet/TileSet1/Test2.png"; + public const string resource_map_tileSet_TileSet1_Test3_png = "res://resource/map/tileSet/TileSet1/Test3.png"; public const string resource_map_tileSet_TileSet1_TileSet_json = "res://resource/map/tileSet/TileSet1/TileSet.json"; public const string resource_map_tileSet_TileSet2_Main_png = "res://resource/map/tileSet/TileSet2/Main.png"; public const string resource_map_tileSet_TileSet2_Test2_png = "res://resource/map/tileSet/TileSet2/Test2.png"; diff --git a/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs b/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs index 95de4d9..1b8dbe2 100644 --- a/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs +++ b/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs @@ -13,6 +13,7 @@ public const string EditorInfo = "EditorInfo"; public const string EditorInput = "EditorInput"; public const string EditorManager = "EditorManager"; + public const string EditorTileImage = "EditorTileImage"; public const string EditorTips = "EditorTips"; public const string EditorTools = "EditorTools"; public const string EditorWindow = "EditorWindow"; @@ -425,6 +426,54 @@ } /// + /// 创建 EditorTileImage, 并返回UI实例, 该函数不会打开 Ui + /// + public static UI.EditorTileImage.EditorTileImagePanel Create_EditorTileImage() + { + return CreateUi(UiNames.EditorTileImage); + } + + /// + /// 打开 EditorTileImage, 并返回UI实例 + /// + public static UI.EditorTileImage.EditorTileImagePanel Open_EditorTileImage() + { + return OpenUi(UiNames.EditorTileImage); + } + + /// + /// 隐藏 EditorTileImage 的所有实例 + /// + public static void Hide_EditorTileImage() + { + var uiInstance = Get_EditorTileImage_Instance(); + foreach (var uiPanel in uiInstance) + { + uiPanel.HideUi(); + } + } + + /// + /// 销毁 EditorTileImage 的所有实例 + /// + public static void Destroy_EditorTileImage() + { + var uiInstance = Get_EditorTileImage_Instance(); + foreach (var uiPanel in uiInstance) + { + uiPanel.Destroy(); + } + } + + /// + /// 获取所有 EditorTileImage 的实例, 如果没有实例, 则返回一个空数组 + /// + public static UI.EditorTileImage.EditorTileImagePanel[] Get_EditorTileImage_Instance() + { + return GetUiInstance(nameof(UI.EditorTileImage.EditorTileImage)); + } + + /// /// 创建 EditorTips, 并返回UI实例, 该函数不会打开 Ui /// public static UI.EditorTips.EditorTipsPanel Create_EditorTips() diff --git a/DungeonShooting_Godot/src/game/ui/editorTileImage/EditorTileImage.cs b/DungeonShooting_Godot/src/game/ui/editorTileImage/EditorTileImage.cs new file mode 100644 index 0000000..b6152a5 --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/editorTileImage/EditorTileImage.cs @@ -0,0 +1,537 @@ +namespace UI.EditorTileImage; + +/// +/// Ui代码, 该类是根据ui场景自动生成的, 请不要手动编辑该类, 以免造成代码丢失 +/// +public abstract partial class EditorTileImage : UiBase +{ + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer + /// + public HBoxContainer L_HBoxContainer + { + get + { + if (_L_HBoxContainer == null) _L_HBoxContainer = new HBoxContainer((EditorTileImagePanel)this, GetNode("HBoxContainer")); + return _L_HBoxContainer; + } + } + private HBoxContainer _L_HBoxContainer; + + + public EditorTileImage() : base(nameof(EditorTileImage)) + { + } + + public sealed override void OnInitNestedUi() + { + _ = L_HBoxContainer.L_Left.L_Bg; + + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Left.Bg.TextureRoot.TileSprite + /// + public class TileSprite : UiNode + { + public TileSprite(EditorTileImagePanel uiPanel, Godot.Sprite2D node) : base(uiPanel, node) { } + public override TileSprite Clone() => new (UiPanel, (Godot.Sprite2D)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Left.Bg.TextureRoot.Brush + /// + public class Brush : UiNode + { + public Brush(EditorTileImagePanel uiPanel, Godot.Control node) : base(uiPanel, node) { } + public override Brush Clone() => new (UiPanel, (Godot.Control)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Left.Bg.TextureRoot + /// + public class TextureRoot : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Left.Bg.TileSprite + /// + public TileSprite L_TileSprite + { + get + { + if (_L_TileSprite == null) _L_TileSprite = new TileSprite(UiPanel, Instance.GetNode("TileSprite")); + return _L_TileSprite; + } + } + private TileSprite _L_TileSprite; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Left.Bg.Brush + /// + public Brush L_Brush + { + get + { + if (_L_Brush == null) _L_Brush = new Brush(UiPanel, Instance.GetNode("Brush")); + return _L_Brush; + } + } + private Brush _L_Brush; + + public TextureRoot(EditorTileImagePanel uiPanel, Godot.Control node) : base(uiPanel, node) { } + public override TextureRoot Clone() => new (UiPanel, (Godot.Control)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Left.Bg.FocusBtn + /// + public class FocusBtn : UiNode + { + public FocusBtn(EditorTileImagePanel uiPanel, Godot.TextureButton node) : base(uiPanel, node) { } + public override FocusBtn Clone() => new (UiPanel, (Godot.TextureButton)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Left.Bg + /// + public class Bg : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Left.TextureRoot + /// + public TextureRoot L_TextureRoot + { + get + { + if (_L_TextureRoot == null) _L_TextureRoot = new TextureRoot(UiPanel, Instance.GetNode("TextureRoot")); + return _L_TextureRoot; + } + } + private TextureRoot _L_TextureRoot; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Left.FocusBtn + /// + public FocusBtn L_FocusBtn + { + get + { + if (_L_FocusBtn == null) _L_FocusBtn = new FocusBtn(UiPanel, Instance.GetNode("FocusBtn")); + return _L_FocusBtn; + } + } + private FocusBtn _L_FocusBtn; + + public Bg(EditorTileImagePanel uiPanel, UI.EditorTileImage.ImageBg node) : base(uiPanel, node) { } + public override Bg Clone() => new (UiPanel, (UI.EditorTileImage.ImageBg)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Left + /// + public class Left : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Bg + /// + public Bg L_Bg + { + get + { + if (_L_Bg == null) _L_Bg = new Bg(UiPanel, Instance.GetNode("Bg")); + return _L_Bg; + } + } + private Bg _L_Bg; + + public Left(EditorTileImagePanel uiPanel, Godot.Panel node) : base(uiPanel, node) { } + public override Left Clone() => new (UiPanel, (Godot.Panel)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer.Label + /// + public class Label : UiNode + { + public Label(EditorTileImagePanel uiPanel, Godot.Label node) : base(uiPanel, node) { } + public override Label Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer.SpinBox + /// + public class SpinBox : UiNode + { + public SpinBox(EditorTileImagePanel uiPanel, Godot.SpinBox node) : base(uiPanel, node) { } + public override SpinBox Clone() => new (UiPanel, (Godot.SpinBox)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer + /// + public class HBoxContainer_1 : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.Label + /// + public Label L_Label + { + get + { + if (_L_Label == null) _L_Label = new Label(UiPanel, Instance.GetNode("Label")); + return _L_Label; + } + } + private Label _L_Label; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.SpinBox + /// + public SpinBox L_SpinBox + { + get + { + if (_L_SpinBox == null) _L_SpinBox = new SpinBox(UiPanel, Instance.GetNode("SpinBox")); + return _L_SpinBox; + } + } + private SpinBox _L_SpinBox; + + public HBoxContainer_1(EditorTileImagePanel uiPanel, Godot.HBoxContainer node) : base(uiPanel, node) { } + public override HBoxContainer_1 Clone() => new (UiPanel, (Godot.HBoxContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer2.Label + /// + public class Label_1 : UiNode + { + public Label_1(EditorTileImagePanel uiPanel, Godot.Label node) : base(uiPanel, node) { } + public override Label_1 Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer2.SpinBox + /// + public class SpinBox_1 : UiNode + { + public SpinBox_1(EditorTileImagePanel uiPanel, Godot.SpinBox node) : base(uiPanel, node) { } + public override SpinBox_1 Clone() => new (UiPanel, (Godot.SpinBox)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer2 + /// + public class HBoxContainer2 : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.Label + /// + public Label_1 L_Label + { + get + { + if (_L_Label == null) _L_Label = new Label_1(UiPanel, Instance.GetNode("Label")); + return _L_Label; + } + } + private Label_1 _L_Label; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.SpinBox + /// + public SpinBox_1 L_SpinBox + { + get + { + if (_L_SpinBox == null) _L_SpinBox = new SpinBox_1(UiPanel, Instance.GetNode("SpinBox")); + return _L_SpinBox; + } + } + private SpinBox_1 _L_SpinBox; + + public HBoxContainer2(EditorTileImagePanel uiPanel, Godot.HBoxContainer node) : base(uiPanel, node) { } + public override HBoxContainer2 Clone() => new (UiPanel, (Godot.HBoxContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer3.Label + /// + public class Label_2 : UiNode + { + public Label_2(EditorTileImagePanel uiPanel, Godot.Label node) : base(uiPanel, node) { } + public override Label_2 Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer3.SpinBox + /// + public class SpinBox_2 : UiNode + { + public SpinBox_2(EditorTileImagePanel uiPanel, Godot.SpinBox node) : base(uiPanel, node) { } + public override SpinBox_2 Clone() => new (UiPanel, (Godot.SpinBox)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer3 + /// + public class HBoxContainer3 : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.Label + /// + public Label_2 L_Label + { + get + { + if (_L_Label == null) _L_Label = new Label_2(UiPanel, Instance.GetNode("Label")); + return _L_Label; + } + } + private Label_2 _L_Label; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.SpinBox + /// + public SpinBox_2 L_SpinBox + { + get + { + if (_L_SpinBox == null) _L_SpinBox = new SpinBox_2(UiPanel, Instance.GetNode("SpinBox")); + return _L_SpinBox; + } + } + private SpinBox_2 _L_SpinBox; + + public HBoxContainer3(EditorTileImagePanel uiPanel, Godot.HBoxContainer node) : base(uiPanel, node) { } + public override HBoxContainer3 Clone() => new (UiPanel, (Godot.HBoxContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer4.Label + /// + public class Label_3 : UiNode + { + public Label_3(EditorTileImagePanel uiPanel, Godot.Label node) : base(uiPanel, node) { } + public override Label_3 Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer4.SpinBox + /// + public class SpinBox_3 : UiNode + { + public SpinBox_3(EditorTileImagePanel uiPanel, Godot.SpinBox node) : base(uiPanel, node) { } + public override SpinBox_3 Clone() => new (UiPanel, (Godot.SpinBox)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer4 + /// + public class HBoxContainer4 : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.Label + /// + public Label_3 L_Label + { + get + { + if (_L_Label == null) _L_Label = new Label_3(UiPanel, Instance.GetNode("Label")); + return _L_Label; + } + } + private Label_3 _L_Label; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.SpinBox + /// + public SpinBox_3 L_SpinBox + { + get + { + if (_L_SpinBox == null) _L_SpinBox = new SpinBox_3(UiPanel, Instance.GetNode("SpinBox")); + return _L_SpinBox; + } + } + private SpinBox_3 _L_SpinBox; + + public HBoxContainer4(EditorTileImagePanel uiPanel, Godot.HBoxContainer node) : base(uiPanel, node) { } + public override HBoxContainer4 Clone() => new (UiPanel, (Godot.HBoxContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right.VBoxContainer + /// + public class VBoxContainer : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.HBoxContainer + /// + public HBoxContainer_1 L_HBoxContainer + { + get + { + if (_L_HBoxContainer == null) _L_HBoxContainer = new HBoxContainer_1(UiPanel, Instance.GetNode("HBoxContainer")); + return _L_HBoxContainer; + } + } + private HBoxContainer_1 _L_HBoxContainer; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.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; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.HBoxContainer3 + /// + public HBoxContainer3 L_HBoxContainer3 + { + get + { + if (_L_HBoxContainer3 == null) _L_HBoxContainer3 = new HBoxContainer3(UiPanel, Instance.GetNode("HBoxContainer3")); + return _L_HBoxContainer3; + } + } + private HBoxContainer3 _L_HBoxContainer3; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.HBoxContainer4 + /// + public HBoxContainer4 L_HBoxContainer4 + { + get + { + if (_L_HBoxContainer4 == null) _L_HBoxContainer4 = new HBoxContainer4(UiPanel, Instance.GetNode("HBoxContainer4")); + return _L_HBoxContainer4; + } + } + private HBoxContainer4 _L_HBoxContainer4; + + public VBoxContainer(EditorTileImagePanel uiPanel, Godot.VBoxContainer node) : base(uiPanel, node) { } + public override VBoxContainer Clone() => new (UiPanel, (Godot.VBoxContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer.Right + /// + public class Right : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.VBoxContainer + /// + public VBoxContainer L_VBoxContainer + { + get + { + if (_L_VBoxContainer == null) _L_VBoxContainer = new VBoxContainer(UiPanel, Instance.GetNode("VBoxContainer")); + return _L_VBoxContainer; + } + } + private VBoxContainer _L_VBoxContainer; + + public Right(EditorTileImagePanel uiPanel, Godot.Panel node) : base(uiPanel, node) { } + public override Right Clone() => new (UiPanel, (Godot.Panel)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorTileImage.HBoxContainer + /// + public class HBoxContainer : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.Left + /// + public Left L_Left + { + get + { + if (_L_Left == null) _L_Left = new Left(UiPanel, Instance.GetNode("Left")); + return _L_Left; + } + } + private Left _L_Left; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorTileImage.Right + /// + public Right L_Right + { + get + { + if (_L_Right == null) _L_Right = new Right(UiPanel, Instance.GetNode("Right")); + return _L_Right; + } + } + private Right _L_Right; + + public HBoxContainer(EditorTileImagePanel uiPanel, Godot.HBoxContainer node) : base(uiPanel, node) { } + public override HBoxContainer Clone() => new (UiPanel, (Godot.HBoxContainer)Instance.Duplicate()); + } + + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Left.Bg.TextureRoot.TileSprite + /// + public TileSprite S_TileSprite => L_HBoxContainer.L_Left.L_Bg.L_TextureRoot.L_TileSprite; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Left.Bg.TextureRoot.Brush + /// + public Brush S_Brush => L_HBoxContainer.L_Left.L_Bg.L_TextureRoot.L_Brush; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Left.Bg.TextureRoot + /// + public TextureRoot S_TextureRoot => L_HBoxContainer.L_Left.L_Bg.L_TextureRoot; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Left.Bg.FocusBtn + /// + public FocusBtn S_FocusBtn => L_HBoxContainer.L_Left.L_Bg.L_FocusBtn; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Left.Bg + /// + public Bg S_Bg => L_HBoxContainer.L_Left.L_Bg; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Left + /// + public Left S_Left => L_HBoxContainer.L_Left; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer2 + /// + public HBoxContainer2 S_HBoxContainer2 => L_HBoxContainer.L_Right.L_VBoxContainer.L_HBoxContainer2; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer3 + /// + public HBoxContainer3 S_HBoxContainer3 => L_HBoxContainer.L_Right.L_VBoxContainer.L_HBoxContainer3; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.VBoxContainer.HBoxContainer4 + /// + public HBoxContainer4 S_HBoxContainer4 => L_HBoxContainer.L_Right.L_VBoxContainer.L_HBoxContainer4; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right.VBoxContainer + /// + public VBoxContainer S_VBoxContainer => L_HBoxContainer.L_Right.L_VBoxContainer; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorTileImage.HBoxContainer.Right + /// + public Right S_Right => L_HBoxContainer.L_Right; + +} diff --git a/DungeonShooting_Godot/src/game/ui/editorTileImage/EditorTileImagePanel.cs b/DungeonShooting_Godot/src/game/ui/editorTileImage/EditorTileImagePanel.cs new file mode 100644 index 0000000..cf59d89 --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/editorTileImage/EditorTileImagePanel.cs @@ -0,0 +1,41 @@ +using Godot; + +namespace UI.EditorTileImage; + +public partial class EditorTileImagePanel : EditorTileImage +{ + private Image _image; + private ImageTexture _texture; + + public override void OnCreateUi() + { + + } + + public override void OnDestroyUi() + { + if (_image != null) + { + _image.Dispose(); + _image = null; + } + + if (_texture != null) + { + _texture.Dispose(); + _texture = null; + } + } + + /// + /// 初始化Ui数据 + /// + public void InitData(Image image) + { + _image = image; + _texture = ImageTexture.CreateFromImage(image); + S_TileSprite.Instance.Texture = _texture; + S_Bg.Instance.DoFocus(); + } + +} diff --git a/DungeonShooting_Godot/src/game/ui/editorTileImage/ImageBg.cs b/DungeonShooting_Godot/src/game/ui/editorTileImage/ImageBg.cs new file mode 100644 index 0000000..55bd620 --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/editorTileImage/ImageBg.cs @@ -0,0 +1,29 @@ +using Godot; + +namespace UI.EditorTileImage; + +public partial class ImageBg : EditorGridBg +{ + public override void SetUiNode(IUiNode uiNode) + { + base.SetUiNode(uiNode); + InitNode(UiNode.L_TextureRoot.Instance); + var arr = UiManager.Get_TileSetEditor_Instance(); + if (arr.Length > 0) + { + UiNode.Instance.Color = arr[0].BgColor; + } + //聚焦按钮点击 + UiNode.L_FocusBtn.Instance.Pressed += DoFocus; + } + + /// + /// 聚焦 + /// + public void DoFocus() + { + var texture = UiNode.L_TextureRoot.L_TileSprite.Instance.Texture; + Utils.DoFocusNode(ContainerRoot, Size, texture != null ? texture.GetSize() : Vector2.Zero); + RefreshGridTrans(); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs index 7e9077d..2665850 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs @@ -48,7 +48,7 @@ /// /// 背景颜色 /// - public Color BgColor { get; private set; } + public Color BgColor { get; private set; } = new Color(0.14f, 0.14f, 0.14f, 1); /// /// Cell 横轴数量 diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/TileSetEditorCombinationPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/TileSetEditorCombinationPanel.cs index 80f450e..38ff3c8 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/TileSetEditorCombinationPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/TileSetEditorCombinationPanel.cs @@ -20,6 +20,7 @@ AddEventListener(EventEnum.OnSetTileTexture, OnSetTileTexture); //改变背景颜色事件 AddEventListener(EventEnum.OnSetTileSetBgColor, OnSetTileSetBgColor); + OnSetTileSetBgColor(EditorPanel.BgColor); } public override void OnShowUi() diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs index 6cda361..2130246 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs @@ -13,7 +13,7 @@ public override void OnCreateUi() { _tileSetEditor = (TileSetEditor.TileSetEditorPanel)ParentUi; - _tileSetEditor.SetBgColor(S_ImportPreviewBg.Instance.Color); + S_ImportPreviewBg.Instance.Color = _tileSetEditor.BgColor; S_ImportPreview.Instance.Texture = _tileSetEditor.Texture; GetTree().Root.FilesDropped += OnFilesDropped; @@ -181,9 +181,10 @@ Debug.Log("导入文件: " + file); var image = Image.LoadFromFile(file); - tileSetSourceInfo.SourcePath = GameConfig.RoomTileSetDir + _tileSetEditor.TileSetInfo.Name + "/" + tileSetSourceInfo.Name + ".png"; - tileSetSourceInfo.SetSourceImage(image); - _tileSetEditor.SetTextureData(image); - EventManager.EmitEvent(EventEnum.OnTileSetDirty); + EditorWindowManager.ShowImportTileImage(image, null); + // tileSetSourceInfo.SourcePath = GameConfig.RoomTileSetDir + _tileSetEditor.TileSetInfo.Name + "/" + tileSetSourceInfo.Name + ".png"; + // tileSetSourceInfo.SetSourceImage(image); + // _tileSetEditor.SetTextureData(image); + // EventManager.EmitEvent(EventEnum.OnTileSetDirty); } }