diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/NodeMonitor.cs b/DungeonShooting_Godot/addons/dungeonShooting_plugin/NodeMonitor.cs
index 2a62912..cc95225 100644
--- a/DungeonShooting_Godot/addons/dungeonShooting_plugin/NodeMonitor.cs
+++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/NodeMonitor.cs
@@ -95,7 +95,7 @@
catch (Exception e)
{
//检查节点存在报错, 直接跳过该节点的检查
- Debug.Log(e.Message);
+ GD.Print(e.Message);
}
}
@@ -131,7 +131,7 @@
catch (Exception e)
{
//检查节点存在报错, 直接跳过该节点的检查
- Debug.Log(e.Message);
+ GD.Print(e.Message);
_targetNode = null;
}
_checkTreeTimer = 0;
diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/ResourcePathGenerator.cs b/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/ResourcePathGenerator.cs
index c8f4479..c824d0f 100644
--- a/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/ResourcePathGenerator.cs
+++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/ResourcePathGenerator.cs
@@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
+using Godot;
namespace Generator;
@@ -65,18 +66,18 @@
"public class ResourcePath\n" +
"{\n";
- Debug.Log("更新 ResourcePath...");
+ GD.Print("更新 ResourcePath...");
var directoryInfo = new DirectoryInfo(System.Environment.CurrentDirectory);
EachDir(directoryInfo);
resultStr += "}";
File.WriteAllText(savePath, resultStr);
- Debug.Log("ResourcePath.cs 写出完成!");
+ GD.Print("ResourcePath.cs 写出完成!");
}
catch (Exception e)
{
- Debug.LogError(e.ToString());
+ GD.PrintErr(e.ToString());
return false;
}
@@ -91,7 +92,7 @@
path = path.Replace('\\', '/');
if (exclude.Contains(path))
{
- Debug.Log("扫描排除路径: " + path);
+ GD.Print("扫描排除路径: " + path);
return;
}
}
diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/UiGenerator.cs b/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/UiGenerator.cs
index 3a84f2a..849d21d 100644
--- a/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/UiGenerator.cs
+++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/UiGenerator.cs
@@ -86,7 +86,7 @@
}
catch (Exception e)
{
- Debug.LogError(e.ToString());
+ GD.PrintErr(e.ToString());
return false;
}
@@ -117,7 +117,7 @@
var uiName = control.Name.ToString();
var path = GameConfig.UiCodeDir + uiName.FirstToLower() + "/" + uiName + ".cs";
- Debug.Log("重新生成ui代码: " + path);
+ GD.Print("重新生成ui代码: " + path);
var uiNode = EachNodeFromEditor(control.Name, control);
var code = GenerateClassCode(uiNode);
@@ -126,7 +126,7 @@
{
if (pair.Value > 1)
{
- Debug.Log($"检测到同名节点: '{pair.Key}', 使用该名称的节点将无法生成唯一节点属性!");
+ GD.Print($"检测到同名节点: '{pair.Key}', 使用该名称的节点将无法生成唯一节点属性!");
}
}
@@ -134,7 +134,7 @@
}
catch (Exception e)
{
- Debug.LogError(e.ToString());
+ GD.PrintErr(e.ToString());
return false;
}
@@ -177,25 +177,23 @@
{
str += retraction + $" _ = {node};\n";
}
- else
+
+ if (uiNodeInfo.Children != null)
{
- if (uiNodeInfo.Children != null)
+ for (var i = 0; i < uiNodeInfo.Children.Count; i++)
{
- for (var i = 0; i < uiNodeInfo.Children.Count; i++)
+ var item = uiNodeInfo.Children[i];
+ if (uiNodeInfo.OriginName == uiNodeInfo.UiRootName)
{
- var item = uiNodeInfo.Children[i];
- if (uiNodeInfo.OriginName == uiNodeInfo.UiRootName)
- {
- str += GenerateUiScriptCode("", item, retraction);
- }
- else
- {
- str += GenerateUiScriptCode(node, item, retraction);
- }
+ str += GenerateUiScriptCode("", item, retraction);
+ }
+ else
+ {
+ str += GenerateUiScriptCode(node, item, retraction);
}
}
}
-
+
return str;
}
@@ -400,12 +398,12 @@
bool isNodeScript;
if (match.Success) //存在命名空间
{
- isNodeScript = IsNodeScript(match.Value + "." + fileName);
+ isNodeScript = CheckNodeScript(match.Value + "." + fileName);
uiNode = new UiNodeInfo(uiRootName, fieldName, originName, className, match.Value + "." + fileName, isNodeScript);
}
else //不存在命名空间
{
- isNodeScript = IsNodeScript(fileName);
+ isNodeScript = CheckNodeScript(fileName);
uiNode = new UiNodeInfo(uiRootName, fieldName, originName, className, fileName, isNodeScript);
}
//检测是否是引用Ui
@@ -447,7 +445,7 @@
return uiNode;
}
- private static bool IsNodeScript(string typeName)
+ private static bool CheckNodeScript(string typeName)
{
var type = typeof(UiGenerator).Assembly.GetType(typeName);
if (type == null)
@@ -501,6 +499,10 @@
ClassName = className;
NodeTypeName = nodeTypeName;
IsNodeScript = isNodeScript;
+ if (isNodeScript)
+ {
+ GD.Print("发现 IUiNodeScript 节点: " + originName);
+ }
}
}
diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/UiManagerMethodsGenerator.cs b/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/UiManagerMethodsGenerator.cs
index d005c2b..8aae0cd 100644
--- a/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/UiManagerMethodsGenerator.cs
+++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/generator/UiManagerMethodsGenerator.cs
@@ -2,6 +2,7 @@
using System;
using System.IO;
+using Godot;
namespace Generator;
@@ -104,7 +105,7 @@
}
catch (Exception e)
{
- Debug.LogError(e.ToString());
+ GD.PrintErr(e.ToString());
return false;
}
diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditorCombination.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditorCombination.tscn
index 819b1fa..393a3c2 100644
--- a/DungeonShooting_Godot/prefab/ui/TileSetEditorCombination.tscn
+++ b/DungeonShooting_Godot/prefab/ui/TileSetEditorCombination.tscn
@@ -1,8 +1,7 @@
-[gd_scene load_steps=14 format=3 uid="uid://daias2tkvj20c"]
+[gd_scene load_steps=11 format=3 uid="uid://daias2tkvj20c"]
[ext_resource type="Script" path="res://src/game/ui/tileSetEditorCombination/TileSetEditorCombinationPanel.cs" id="1_to1lc"]
[ext_resource type="Script" path="res://src/game/ui/tileSetEditorCombination/leftBottom/TileEditArea.cs" id="2_h43yx"]
-[ext_resource type="Shader" path="res://resource/material/Grid.gdshader" id="2_t1p2n"]
[ext_resource type="Script" path="res://src/game/ui/tileSetEditorCombination/leftTop/RectBrush.cs" id="3_avikb"]
[ext_resource type="Script" path="res://src/game/ui/tileSetEditorCombination/leftBottom/MaskBrush.cs" id="4_ytys0"]
[ext_resource type="Texture2D" uid="uid://fkg21rtph51d" path="res://resource/sprite/ui/commonIcon/Delete2.png" id="5_6jqro"]
@@ -12,24 +11,6 @@
[ext_resource type="Script" path="res://src/game/ui/tileSetEditorCombination/right/TileSelected.cs" id="6_gql80"]
[ext_resource type="Texture2D" uid="uid://d2wslibovwv7w" path="res://resource/sprite/ui/commonIcon/CenterTool.png" id="7_mbnpy"]
-[sub_resource type="ShaderMaterial" id="ShaderMaterial_df7va"]
-resource_local_to_scene = true
-shader = ExtResource("2_t1p2n")
-shader_parameter/color = Color(0.529412, 0.529412, 0.529412, 0.0431373)
-shader_parameter/size = Vector2(1334, 1076)
-shader_parameter/line_width = 2
-shader_parameter/offset = Vector2(0, 0)
-shader_parameter/grid_size = 16.0
-
-[sub_resource type="ShaderMaterial" id="ShaderMaterial_llwpd"]
-resource_local_to_scene = true
-shader = ExtResource("2_t1p2n")
-shader_parameter/color = Color(0.529412, 0.529412, 0.529412, 0.0431373)
-shader_parameter/size = Vector2(1334, 1076)
-shader_parameter/line_width = 2
-shader_parameter/offset = Vector2(0, 0)
-shader_parameter/grid_size = 16.0
-
[node name="TileSetEditorCombination" type="Control"]
layout_mode = 3
anchors_preset = 15
@@ -100,7 +81,6 @@
script = ExtResource("3_avikb")
[node name="Grid" type="ColorRect" parent="HSplitContainer/VSplitContainer/LeftTop/MarginContainer/LeftTopBg"]
-material = SubResource("ShaderMaterial_df7va")
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
@@ -108,6 +88,7 @@
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
+color = Color(1, 1, 1, 0)
[node name="FocusBtn" type="TextureButton" parent="HSplitContainer/VSplitContainer/LeftTop/MarginContainer/LeftTopBg"]
layout_mode = 1
@@ -219,7 +200,6 @@
script = ExtResource("4_ytys0")
[node name="Grid" type="ColorRect" parent="HSplitContainer/VSplitContainer/LeftBottom/MarginContainer/LeftBottomBg"]
-material = SubResource("ShaderMaterial_llwpd")
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
@@ -227,6 +207,7 @@
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
+color = Color(1, 1, 1, 0)
[node name="FocusBtn" type="TextureButton" parent="HSplitContainer/VSplitContainer/LeftBottom/MarginContainer/LeftBottomBg"]
layout_mode = 1
diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn
index 1d83eb1..684b926 100644
--- a/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn
+++ b/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn
@@ -1,10 +1,143 @@
-[gd_scene load_steps=2 format=3 uid="uid://dfqb73y4br8yd"]
+[gd_scene load_steps=4 format=3 uid="uid://dfqb73y4br8yd"]
[ext_resource type="Script" path="res://src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs" id="1_6jjk7"]
+[ext_resource type="Script" path="res://src/game/ui/tileSetEditorTerrain/left/TileEditArea.cs" id="2_ynf0r"]
+[ext_resource type="Texture2D" uid="uid://d2wslibovwv7w" path="res://resource/sprite/ui/commonIcon/CenterTool.png" id="5_08bc4"]
[node name="TileSetEditorTerrain" 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_6jjk7")
+Layer = null
+
+[node name="HSplitContainer" type="HSplitContainer" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="LeftBottom" type="Panel" parent="HSplitContainer"]
+layout_mode = 2
+size_flags_horizontal = 3
+size_flags_vertical = 3
+size_flags_stretch_ratio = 50.0
+
+[node name="MarginContainer" type="MarginContainer" parent="HSplitContainer/LeftBottom"]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+theme_override_constants/margin_left = 2
+theme_override_constants/margin_top = 2
+theme_override_constants/margin_right = 2
+theme_override_constants/margin_bottom = 2
+
+[node name="LeftBg" type="ColorRect" parent="HSplitContainer/LeftBottom/MarginContainer"]
+clip_children = 2
+z_index = 1
+layout_mode = 2
+color = Color(0.203922, 0.203922, 0.203922, 1)
+script = ExtResource("2_ynf0r")
+
+[node name="TileTexture" type="TextureRect" parent="HSplitContainer/LeftBottom/MarginContainer/LeftBg"]
+layout_mode = 1
+anchors_preset = 8
+anchor_left = 0.5
+anchor_top = 0.5
+anchor_right = 0.5
+anchor_bottom = 0.5
+grow_horizontal = 2
+grow_vertical = 2
+scale = Vector2(2, 2)
+mouse_filter = 2
+
+[node name="MaskBrush" type="Control" parent="HSplitContainer/LeftBottom/MarginContainer/LeftBg/TileTexture"]
+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="Grid" type="ColorRect" parent="HSplitContainer/LeftBottom/MarginContainer/LeftBg"]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+mouse_filter = 2
+color = Color(1, 1, 1, 0)
+
+[node name="FocusBtn" type="TextureButton" parent="HSplitContainer/LeftBottom/MarginContainer/LeftBg"]
+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("5_08bc4")
+ignore_texture_size = true
+stretch_mode = 5
+
+[node name="LeftBottom2" type="Panel" parent="HSplitContainer"]
+layout_mode = 2
+size_flags_horizontal = 3
+size_flags_vertical = 3
+size_flags_stretch_ratio = 50.0
+
+[node name="MarginContainer" type="MarginContainer" parent="HSplitContainer/LeftBottom2"]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+theme_override_constants/margin_left = 2
+theme_override_constants/margin_top = 2
+theme_override_constants/margin_right = 2
+theme_override_constants/margin_bottom = 2
+
+[node name="LeftBottomBg" type="ColorRect" parent="HSplitContainer/LeftBottom2/MarginContainer"]
+clip_children = 2
+z_index = 1
+layout_mode = 2
+color = Color(0.203922, 0.203922, 0.203922, 1)
+
+[node name="Grid" type="ColorRect" parent="HSplitContainer/LeftBottom2/MarginContainer/LeftBottomBg"]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+mouse_filter = 2
+color = Color(1, 1, 1, 0)
+
+[node name="FocusBtn" type="TextureButton" parent="HSplitContainer/LeftBottom2/MarginContainer/LeftBottomBg"]
+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("5_08bc4")
+ignore_texture_size = true
+stretch_mode = 5
diff --git a/DungeonShooting_Godot/resource/material/Grid.tres b/DungeonShooting_Godot/resource/material/Grid.tres
new file mode 100644
index 0000000..eaf95e9
--- /dev/null
+++ b/DungeonShooting_Godot/resource/material/Grid.tres
@@ -0,0 +1,12 @@
+[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://chcpnatun8hlf"]
+
+[ext_resource type="Shader" path="res://resource/material/Grid.gdshader" id="1_xhgfe"]
+
+[resource]
+resource_local_to_scene = true
+shader = ExtResource("1_xhgfe")
+shader_parameter/color = Color(0.529412, 0.529412, 0.529412, 0.0431373)
+shader_parameter/size = Vector2(1280, 720)
+shader_parameter/line_width = 2
+shader_parameter/offset = Vector2(0, 0)
+shader_parameter/grid_size = 16.0
diff --git a/DungeonShooting_Godot/src/framework/common/GridBg.cs b/DungeonShooting_Godot/src/framework/common/GridBg.cs
new file mode 100644
index 0000000..c89664e
--- /dev/null
+++ b/DungeonShooting_Godot/src/framework/common/GridBg.cs
@@ -0,0 +1,108 @@
+using Godot;
+
+///
+/// 通用Ui网格背景组件, 包含可拖拽的容器根节点
+///
+public abstract partial class GridBg : ColorRect, IUiNodeScript where T : IUiNode
+{
+ ///
+ /// 可拖拽容器根节点
+ ///
+ public Control ContainerRoot { get; private set; }
+ ///
+ /// 显示网格的节点
+ ///
+ public ColorRect Grid { get; private set; }
+ ///
+ /// 当前对象绑定的Ui节点
+ ///
+ public T UiNode { get; private set; }
+
+ private ShaderMaterial _gridMaterial;
+
+ ///
+ /// 初始化节点数据
+ ///
+ /// 可拖拽容器根节点
+ /// 当前对象绑定的Ui节点
+ public void InitNode(Control containerRoot, ColorRect grid)
+ {
+ ContainerRoot = containerRoot;
+ Grid = grid;
+ grid.MouseFilter = MouseFilterEnum.Ignore;
+ _gridMaterial = ResourceManager.Load(ResourcePath.resource_material_Grid_tres, false);
+ grid.Material = _gridMaterial;
+ }
+
+ public virtual void SetUiNode(IUiNode uiNode)
+ {
+ UiNode = (T)uiNode;
+ this.AddDragListener(DragButtonEnum.Middle, OnDrag);
+ Resized += RefreshGridTrans;
+ }
+
+ public virtual void OnDestroy()
+ {
+
+ }
+
+ ///
+ /// 当前Ui被显示出来时调用
+ ///
+ public void OnShow()
+ {
+ RefreshGridTrans();
+ }
+
+ public override void _GuiInput(InputEvent @event)
+ {
+ if (@event is InputEventMouseButton mouseButton)
+ {
+ AcceptEvent();
+ if (mouseButton.ButtonIndex == MouseButton.WheelDown)
+ {
+ //缩小
+ if (Utils.DoShrinkByMousePosition(ContainerRoot, 0.4f))
+ {
+ SetGridTransform(ContainerRoot.Position, ContainerRoot.Scale.X);
+ }
+ }
+ else if (mouseButton.ButtonIndex == MouseButton.WheelUp)
+ {
+ //放大
+ if (Utils.DoMagnifyByMousePosition(ContainerRoot, 20))
+ {
+ SetGridTransform(ContainerRoot.Position, ContainerRoot.Scale.X);
+ }
+ }
+ }
+ }
+
+ //拖拽回调
+ private void OnDrag(DragState state, Vector2 pos)
+ {
+ if (state == DragState.DragMove)
+ {
+ ContainerRoot.Position += pos;
+ RefreshGridTrans();
+ }
+ }
+
+
+ ///
+ /// 刷新背景网格位置和缩放
+ ///
+ public void RefreshGridTrans()
+ {
+ _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);
+ }
+
+}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs
index c507d27..c4349c5 100644
--- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs
+++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs
@@ -6,6 +6,14 @@
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 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_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";
public const string prefab_bullet_explode_Explode0001_tscn = "res://prefab/bullet/explode/Explode0001.tscn";
public const string prefab_bullet_laser_Laser0001_tscn = "res://prefab/bullet/laser/Laser0001.tscn";
@@ -115,6 +123,7 @@
public const string resource_material_Blend_gdshader = "res://resource/material/Blend.gdshader";
public const string resource_material_Blend_tres = "res://resource/material/Blend.tres";
public const string resource_material_Grid_gdshader = "res://resource/material/Grid.gdshader";
+ public const string resource_material_Grid_tres = "res://resource/material/Grid.tres";
public const string resource_material_Mask_gdshader = "res://resource/material/Mask.gdshader";
public const string resource_material_OffsetVertex_gdshader = "res://resource/material/OffsetVertex.gdshader";
public const string resource_material_Outline_gdshader = "res://resource/material/Outline.gdshader";
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/GridBg.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/GridBg.cs
deleted file mode 100644
index 2f6c1bd..0000000
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/GridBg.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using Godot;
-
-namespace UI.TileSetEditorCombination;
-
-public abstract partial class GridBg : ColorRect, IUiNodeScript where T : IUiNode
-{
- public ColorRect Grid { get; protected set; }
- public Control ContainerRoot { get; protected set; }
- public T UiNode { get; private set; }
-
- public virtual void SetUiNode(IUiNode uiNode)
- {
- UiNode = (T)uiNode;
- this.AddDragListener(DragButtonEnum.Middle, OnDrag);
- Resized += RefreshGridTrans;
- }
-
- public virtual void OnDestroy()
- {
-
- }
-
- ///
- /// 当前Ui被显示出来时调用
- ///
- public void OnShow()
- {
- RefreshGridTrans();
- }
-
- public override void _GuiInput(InputEvent @event)
- {
- if (@event is InputEventMouseButton mouseButton)
- {
- AcceptEvent();
- if (mouseButton.ButtonIndex == MouseButton.WheelDown)
- {
- //缩小
- if (Utils.DoShrinkByMousePosition(ContainerRoot, 0.4f))
- {
- SetGridTransform(ContainerRoot.Position, ContainerRoot.Scale.X);
- }
- }
- else if (mouseButton.ButtonIndex == MouseButton.WheelUp)
- {
- //放大
- if (Utils.DoMagnifyByMousePosition(ContainerRoot, 20))
- {
- SetGridTransform(ContainerRoot.Position, ContainerRoot.Scale.X);
- }
- }
- }
- }
-
- //拖拽回调
- private void OnDrag(DragState state, Vector2 pos)
- {
- if (state == DragState.DragMove)
- {
- ContainerRoot.Position += pos;
- RefreshGridTrans();
- }
- }
-
-
- ///
- /// 刷新背景网格位置和缩放
- ///
- public void RefreshGridTrans()
- {
- Grid.Material.SetShaderMaterialParameter(ShaderParamNames.Size, Size);
- SetGridTransform(ContainerRoot.Position, ContainerRoot.Scale.X);
- }
-
- //设置网格位置和缩放
- private void SetGridTransform(Vector2 pos, float scale)
- {
- Grid.Material.SetShaderMaterialParameter(ShaderParamNames.GridSize, GameConfig.TileCellSize * scale);
- Grid.Material.SetShaderMaterialParameter(ShaderParamNames.Offset, -pos);
- }
-
-}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/TileSetEditorCombination.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/TileSetEditorCombination.cs
index 63379d9..520e585 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/TileSetEditorCombination.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/TileSetEditorCombination.cs
@@ -27,6 +27,7 @@
{
_ = L_HSplitContainer.L_VSplitContainer.L_LeftTop.L_MarginContainer.L_LeftTopBg;
_ = L_HSplitContainer.L_VSplitContainer.L_LeftBottom.L_MarginContainer.L_LeftBottomBg;
+ _ = L_HSplitContainer.L_VSplitContainer.L_LeftBottom.L_MarginContainer.L_LeftBottomBg.L_TileTexture.L_MaskBrush;
_ = L_HSplitContainer.L_Right.L_MarginContainer.L_RightBg;
}
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftBottom/MaskBrush.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftBottom/MaskBrush.cs
index 94c0cdb..d7c7f11 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftBottom/MaskBrush.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftBottom/MaskBrush.cs
@@ -2,18 +2,19 @@
namespace UI.TileSetEditorCombination;
-public partial class MaskBrush : Control
+public partial class MaskBrush : Control, IUiNodeScript
{
///
/// 绑定的地图纹理节点
///
- public TextureRect TileTexture { get; set; }
+ public TextureRect TileTexture { get; private set; }
///
/// 绑定的TileSet编辑区域节点
///
- public TileEditArea TileEditArea { get; set; }
-
+ public TileEditArea TileEditArea { get; private set; }
+
+ private TileSetEditorCombination.MaskBrush _maskBrush;
public override void _Process(double delta)
{
QueueRedraw();
@@ -42,4 +43,16 @@
);
}
}
+
+ public void SetUiNode(IUiNode uiNode)
+ {
+ _maskBrush = (TileSetEditorCombination.MaskBrush)uiNode;
+ TileTexture = _maskBrush.UiPanel.S_TileTexture.Instance;
+ TileEditArea = _maskBrush.UiPanel.S_LeftBottomBg.Instance;
+ }
+
+ public void OnDestroy()
+ {
+
+ }
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftBottom/TileEditArea.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftBottom/TileEditArea.cs
index 3fc22ab..1ed6f44 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftBottom/TileEditArea.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftBottom/TileEditArea.cs
@@ -11,13 +11,8 @@
public override void SetUiNode(IUiNode uiNode)
{
base.SetUiNode(uiNode);
- Grid = UiNode.L_Grid.Instance;
- ContainerRoot = UiNode.L_TileTexture.Instance;
+ InitNode(UiNode.L_TileTexture.Instance, UiNode.L_Grid.Instance);
UiNode.L_TileTexture.Instance.Texture = UiNode.UiPanel.EditorPanel.Texture;
-
- var maskBrush = UiNode.L_TileTexture.L_MaskBrush.Instance;
- maskBrush.TileTexture = UiNode.L_TileTexture.Instance;
- maskBrush.TileEditArea = this;
_maskGrid = new UiGrid(UiNode.L_TileTexture.L_MaskRoot.L_MaskRect, typeof(MaskRectCell));
_maskGrid.SetCellOffset(Vector2I.Zero);
@@ -66,15 +61,7 @@
private void OnFocusClick()
{
var texture = UiNode.L_TileTexture.Instance.Texture;
- if (texture != null)
- {
- Utils.DoFocusNode(ContainerRoot, Size, texture.GetSize());
- }
- else
- {
- Utils.DoFocusNode(ContainerRoot, Size, Vector2.Zero);
- }
-
+ Utils.DoFocusNode(ContainerRoot, Size, texture != null ? texture.GetSize() : Vector2.Zero);
RefreshGridTrans();
}
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftTop/TileEditCombination.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftTop/TileEditCombination.cs
index b50a9e2..80ca5c6 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftTop/TileEditCombination.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftTop/TileEditCombination.cs
@@ -34,8 +34,7 @@
{
base.SetUiNode(uiNode);
UiNode.L_CombinationRoot.L_RectBrush.Instance.Root = UiNode.L_CombinationRoot.Instance;
- Grid = UiNode.L_Grid.Instance;
- ContainerRoot = UiNode.L_CombinationRoot.Instance;
+ InitNode(UiNode.L_CombinationRoot.Instance, UiNode.L_Grid.Instance);
UiNode.UiPanel.AddEventListener(EventEnum.OnSelectCombinationCell, OnSelectCombinationCell);
UiNode.UiPanel.AddEventListener(EventEnum.OnRemoveCombinationCell, OnRemoveCombinationCell);
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs
index d6a0e26..1d34d9e 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs
@@ -5,6 +5,19 @@
///
public abstract partial class TileSetEditorTerrain : UiBase
{
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer
+ ///
+ public HSplitContainer L_HSplitContainer
+ {
+ get
+ {
+ if (_L_HSplitContainer == null) _L_HSplitContainer = new HSplitContainer((TileSetEditorTerrainPanel)this, GetNode("HSplitContainer"));
+ return _L_HSplitContainer;
+ }
+ }
+ private HSplitContainer _L_HSplitContainer;
+
public TileSetEditorTerrain() : base(nameof(TileSetEditorTerrain))
{
@@ -12,8 +25,317 @@
public sealed override void OnInitNestedUi()
{
+ _ = L_HSplitContainer.L_LeftBottom.L_MarginContainer.L_LeftBg;
}
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer.LeftBg.TileTexture.MaskBrush
+ ///
+ public class MaskBrush : UiNode
+ {
+ public MaskBrush(TileSetEditorTerrainPanel uiPanel, Godot.Control node) : base(uiPanel, node) { }
+ public override MaskBrush Clone() => new (UiPanel, (Godot.Control)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer.LeftBg.TileTexture
+ ///
+ public class TileTexture : UiNode
+ {
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer.LeftBg.MaskBrush
+ ///
+ public MaskBrush L_MaskBrush
+ {
+ get
+ {
+ if (_L_MaskBrush == null) _L_MaskBrush = new MaskBrush(UiPanel, Instance.GetNode("MaskBrush"));
+ return _L_MaskBrush;
+ }
+ }
+ private MaskBrush _L_MaskBrush;
+
+ public TileTexture(TileSetEditorTerrainPanel uiPanel, Godot.TextureRect node) : base(uiPanel, node) { }
+ public override TileTexture Clone() => new (UiPanel, (Godot.TextureRect)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer.LeftBg.Grid
+ ///
+ public class Grid : UiNode
+ {
+ public Grid(TileSetEditorTerrainPanel uiPanel, Godot.ColorRect node) : base(uiPanel, node) { }
+ public override Grid Clone() => new (UiPanel, (Godot.ColorRect)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer.LeftBg.FocusBtn
+ ///
+ public class FocusBtn : UiNode
+ {
+ public FocusBtn(TileSetEditorTerrainPanel uiPanel, Godot.TextureButton node) : base(uiPanel, node) { }
+ public override FocusBtn Clone() => new (UiPanel, (Godot.TextureButton)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer.LeftBg
+ ///
+ public class LeftBg : UiNode
+ {
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer.TileTexture
+ ///
+ public TileTexture L_TileTexture
+ {
+ get
+ {
+ if (_L_TileTexture == null) _L_TileTexture = new TileTexture(UiPanel, Instance.GetNode("TileTexture"));
+ return _L_TileTexture;
+ }
+ }
+ private TileTexture _L_TileTexture;
+
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer.Grid
+ ///
+ public Grid L_Grid
+ {
+ get
+ {
+ if (_L_Grid == null) _L_Grid = new Grid(UiPanel, Instance.GetNode("Grid"));
+ return _L_Grid;
+ }
+ }
+ private Grid _L_Grid;
+
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer.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 LeftBg(TileSetEditorTerrainPanel uiPanel, UI.TileSetEditorTerrain.TileEditArea node) : base(uiPanel, node) { }
+ public override LeftBg Clone() => new (UiPanel, (UI.TileSetEditorTerrain.TileEditArea)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer
+ ///
+ public class MarginContainer : UiNode
+ {
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.LeftBg
+ ///
+ public LeftBg L_LeftBg
+ {
+ get
+ {
+ if (_L_LeftBg == null) _L_LeftBg = new LeftBg(UiPanel, Instance.GetNode("LeftBg"));
+ return _L_LeftBg;
+ }
+ }
+ private LeftBg _L_LeftBg;
+
+ public MarginContainer(TileSetEditorTerrainPanel uiPanel, Godot.MarginContainer node) : base(uiPanel, node) { }
+ public override MarginContainer Clone() => new (UiPanel, (Godot.MarginContainer)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer.LeftBottom
+ ///
+ public class LeftBottom : UiNode
+ {
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.MarginContainer
+ ///
+ public MarginContainer L_MarginContainer
+ {
+ get
+ {
+ if (_L_MarginContainer == null) _L_MarginContainer = new MarginContainer(UiPanel, Instance.GetNode("MarginContainer"));
+ return _L_MarginContainer;
+ }
+ }
+ private MarginContainer _L_MarginContainer;
+
+ public LeftBottom(TileSetEditorTerrainPanel uiPanel, Godot.Panel node) : base(uiPanel, node) { }
+ public override LeftBottom Clone() => new (UiPanel, (Godot.Panel)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer.LeftBottom2.MarginContainer.LeftBottomBg.Grid
+ ///
+ public class Grid_1 : UiNode
+ {
+ public Grid_1(TileSetEditorTerrainPanel uiPanel, Godot.ColorRect node) : base(uiPanel, node) { }
+ public override Grid_1 Clone() => new (UiPanel, (Godot.ColorRect)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer.LeftBottom2.MarginContainer.LeftBottomBg.FocusBtn
+ ///
+ public class FocusBtn_1 : UiNode
+ {
+ public FocusBtn_1(TileSetEditorTerrainPanel uiPanel, Godot.TextureButton node) : base(uiPanel, node) { }
+ public override FocusBtn_1 Clone() => new (UiPanel, (Godot.TextureButton)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer.LeftBottom2.MarginContainer.LeftBottomBg
+ ///
+ public class LeftBottomBg : UiNode
+ {
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom2.MarginContainer.Grid
+ ///
+ public Grid_1 L_Grid
+ {
+ get
+ {
+ if (_L_Grid == null) _L_Grid = new Grid_1(UiPanel, Instance.GetNode("Grid"));
+ return _L_Grid;
+ }
+ }
+ private Grid_1 _L_Grid;
+
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom2.MarginContainer.FocusBtn
+ ///
+ public FocusBtn_1 L_FocusBtn
+ {
+ get
+ {
+ if (_L_FocusBtn == null) _L_FocusBtn = new FocusBtn_1(UiPanel, Instance.GetNode("FocusBtn"));
+ return _L_FocusBtn;
+ }
+ }
+ private FocusBtn_1 _L_FocusBtn;
+
+ public LeftBottomBg(TileSetEditorTerrainPanel uiPanel, Godot.ColorRect node) : base(uiPanel, node) { }
+ public override LeftBottomBg Clone() => new (UiPanel, (Godot.ColorRect)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer.LeftBottom2.MarginContainer
+ ///
+ public class MarginContainer_1 : UiNode
+ {
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom2.LeftBottomBg
+ ///
+ public LeftBottomBg L_LeftBottomBg
+ {
+ get
+ {
+ if (_L_LeftBottomBg == null) _L_LeftBottomBg = new LeftBottomBg(UiPanel, Instance.GetNode("LeftBottomBg"));
+ return _L_LeftBottomBg;
+ }
+ }
+ private LeftBottomBg _L_LeftBottomBg;
+
+ public MarginContainer_1(TileSetEditorTerrainPanel uiPanel, Godot.MarginContainer node) : base(uiPanel, node) { }
+ public override MarginContainer_1 Clone() => new (UiPanel, (Godot.MarginContainer)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer.LeftBottom2
+ ///
+ public class LeftBottom2 : UiNode
+ {
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.MarginContainer
+ ///
+ public MarginContainer_1 L_MarginContainer
+ {
+ get
+ {
+ if (_L_MarginContainer == null) _L_MarginContainer = new MarginContainer_1(UiPanel, Instance.GetNode("MarginContainer"));
+ return _L_MarginContainer;
+ }
+ }
+ private MarginContainer_1 _L_MarginContainer;
+
+ public LeftBottom2(TileSetEditorTerrainPanel uiPanel, Godot.Panel node) : base(uiPanel, node) { }
+ public override LeftBottom2 Clone() => new (UiPanel, (Godot.Panel)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditorTerrain.HSplitContainer
+ ///
+ public class HSplitContainer : UiNode
+ {
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.LeftBottom
+ ///
+ public LeftBottom L_LeftBottom
+ {
+ get
+ {
+ if (_L_LeftBottom == null) _L_LeftBottom = new LeftBottom(UiPanel, Instance.GetNode("LeftBottom"));
+ return _L_LeftBottom;
+ }
+ }
+ private LeftBottom _L_LeftBottom;
+
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.LeftBottom2
+ ///
+ public LeftBottom2 L_LeftBottom2
+ {
+ get
+ {
+ if (_L_LeftBottom2 == null) _L_LeftBottom2 = new LeftBottom2(UiPanel, Instance.GetNode("LeftBottom2"));
+ return _L_LeftBottom2;
+ }
+ }
+ private LeftBottom2 _L_LeftBottom2;
+
+ public HSplitContainer(TileSetEditorTerrainPanel uiPanel, Godot.HSplitContainer node) : base(uiPanel, node) { }
+ public override HSplitContainer Clone() => new (UiPanel, (Godot.HSplitContainer)Instance.Duplicate());
+ }
+
+
+ ///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer.LeftBg.TileTexture.MaskBrush
+ ///
+ public MaskBrush S_MaskBrush => L_HSplitContainer.L_LeftBottom.L_MarginContainer.L_LeftBg.L_TileTexture.L_MaskBrush;
+
+ ///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer.LeftBg.TileTexture
+ ///
+ public TileTexture S_TileTexture => L_HSplitContainer.L_LeftBottom.L_MarginContainer.L_LeftBg.L_TileTexture;
+
+ ///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom.MarginContainer.LeftBg
+ ///
+ public LeftBg S_LeftBg => L_HSplitContainer.L_LeftBottom.L_MarginContainer.L_LeftBg;
+
+ ///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom
+ ///
+ public LeftBottom S_LeftBottom => L_HSplitContainer.L_LeftBottom;
+
+ ///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom2.MarginContainer.LeftBottomBg
+ ///
+ public LeftBottomBg S_LeftBottomBg => L_HSplitContainer.L_LeftBottom2.L_MarginContainer.L_LeftBottomBg;
+
+ ///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer.LeftBottom2
+ ///
+ public LeftBottom2 S_LeftBottom2 => L_HSplitContainer.L_LeftBottom2;
+
+ ///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.HSplitContainer
+ ///
+ public HSplitContainer S_HSplitContainer => L_HSplitContainer;
}
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs
index e7fcf6a..f90a0bf 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs
@@ -1,13 +1,21 @@
using Godot;
+using UI.TileSetEditor;
namespace UI.TileSetEditorTerrain;
public partial class TileSetEditorTerrainPanel : TileSetEditorTerrain
{
-
+ ///
+ /// 父Ui
+ ///
+ public TileSetEditorPanel EditorPanel;
+
public override void OnCreateUi()
{
+ EditorPanel = (TileSetEditorPanel)ParentUi;
+ //改变纹理事件
+ AddEventListener(EventEnum.OnSetTileTexture, OnSetTileTexture);
}
public override void OnDestroyUi()
@@ -15,4 +23,14 @@
}
+ public override void OnShowUi()
+ {
+ S_LeftBg.Instance.OnShow();
+ }
+
+ //改变TileSet纹理
+ private void OnSetTileTexture(object arg)
+ {
+ S_LeftBg.Instance.OnChangeTileSetTexture();
+ }
}
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/left/TileEditArea.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/left/TileEditArea.cs
new file mode 100644
index 0000000..40ead48
--- /dev/null
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/left/TileEditArea.cs
@@ -0,0 +1,35 @@
+using Godot;
+
+namespace UI.TileSetEditorTerrain;
+
+public partial class TileEditArea : GridBg
+{
+ public override void SetUiNode(IUiNode uiNode)
+ {
+ base.SetUiNode(uiNode);
+ InitNode(UiNode.L_TileTexture.Instance, UiNode.L_Grid.Instance);
+ UiNode.L_TileTexture.Instance.Texture = UiNode.UiPanel.EditorPanel.Texture;
+
+ //聚焦按钮点击
+ UiNode.L_FocusBtn.Instance.Pressed += OnFocusClick;
+ }
+
+ ///
+ /// 改变TileSet纹理
+ ///
+ public void OnChangeTileSetTexture()
+ {
+ // var width = UiNode.UiPanel.EditorPanel.CellHorizontal;
+ // var height = UiNode.UiPanel.EditorPanel.CellVertical;
+ UiNode.L_TileTexture.Instance.Size = UiNode.L_TileTexture.Instance.Texture.GetSize();
+ OnFocusClick();
+ }
+
+ //聚焦按钮点击
+ private void OnFocusClick()
+ {
+ var texture = UiNode.L_TileTexture.Instance.Texture;
+ Utils.DoFocusNode(ContainerRoot, Size, texture != null ? texture.GetSize() : Vector2.Zero);
+ RefreshGridTrans();
+ }
+}
\ No newline at end of file