diff --git a/DungeonShooting_Godot/export_presets.cfg b/DungeonShooting_Godot/export_presets.cfg
index 009af33..dec7e9c 100644
--- a/DungeonShooting_Godot/export_presets.cfg
+++ b/DungeonShooting_Godot/export_presets.cfg
@@ -22,7 +22,7 @@
gradle_build/export_format=0
gradle_build/min_sdk=""
gradle_build/target_sdk=""
-architectures/armeabi-v7a=true
+architectures/armeabi-v7a=false
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
diff --git a/DungeonShooting_Godot/prefab/ui/EditorColorPicker.tscn b/DungeonShooting_Godot/prefab/ui/EditorColorPicker.tscn
new file mode 100644
index 0000000..6d0e4a3
--- /dev/null
+++ b/DungeonShooting_Godot/prefab/ui/EditorColorPicker.tscn
@@ -0,0 +1,19 @@
+[gd_scene load_steps=2 format=3 uid="uid://ceinixdnf00ta"]
+
+[ext_resource type="Script" path="res://src/game/ui/editorColorPicker/EditorColorPickerPanel.cs" id="1_yaxtp"]
+
+[node name="EditorColorPicker" 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_yaxtp")
+
+[node name="ColorPicker" type="ColorPicker" parent="."]
+layout_mode = 1
+anchors_preset = 10
+anchor_right = 1.0
+offset_bottom = 648.0
+grow_horizontal = 2
diff --git a/DungeonShooting_Godot/prefab/ui/EditorWindow.tscn b/DungeonShooting_Godot/prefab/ui/EditorWindow.tscn
index 1a8f5bb..17a2e37 100644
--- a/DungeonShooting_Godot/prefab/ui/EditorWindow.tscn
+++ b/DungeonShooting_Godot/prefab/ui/EditorWindow.tscn
@@ -28,7 +28,7 @@
size = Vector2i(500, 350)
visible = false
transient = true
-min_size = Vector2i(500, 350)
+min_size = Vector2i(100, 100)
theme_override_constants/title_height = 33
[node name="Panel" type="Panel" parent="Window"]
diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditor.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditor.tscn
index fc7a0b4..644e9cf 100644
--- a/DungeonShooting_Godot/prefab/ui/TileSetEditor.tscn
+++ b/DungeonShooting_Godot/prefab/ui/TileSetEditor.tscn
@@ -96,7 +96,7 @@
[node name="ImportTab" type="Button" parent="Bg/VBoxContainer/HBoxContainer/LeftRoot/MarginContainer/GridContainer/VBoxContainer"]
custom_minimum_size = Vector2(0, 60)
layout_mode = 2
-text = "导入纹理"
+text = "纹理"
[node name="TileCellTab" type="Button" parent="Bg/VBoxContainer/HBoxContainer/LeftRoot/MarginContainer/GridContainer/VBoxContainer"]
custom_minimum_size = Vector2(0, 60)
@@ -177,6 +177,16 @@
mouse_filter = 2
texture = ExtResource("6_4ra02")
+[node name="ImportPreviewBg" type="ColorRect" parent="Bg/VBoxContainer/HBoxContainer/RightRoot/ImportRoot"]
+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(0.278431, 0.278431, 0.278431, 1)
+
[node name="Control" type="Control" parent="Bg/VBoxContainer/HBoxContainer/RightRoot/ImportRoot"]
layout_mode = 1
anchors_preset = 8
@@ -192,3 +202,27 @@
grow_vertical = 2
[node name="ImportPreview" type="Sprite2D" parent="Bg/VBoxContainer/HBoxContainer/RightRoot/ImportRoot/Control"]
+
+[node name="ImportColorPicker" type="Button" parent="Bg/VBoxContainer/HBoxContainer/RightRoot/ImportRoot"]
+layout_mode = 1
+anchors_preset = 1
+anchor_left = 1.0
+anchor_right = 1.0
+offset_left = -238.0
+offset_top = 25.0
+offset_right = -34.0
+offset_bottom = 82.0
+grow_horizontal = 0
+text = "背景颜色"
+
+[node name="ReimportButton" type="Button" parent="Bg/VBoxContainer/HBoxContainer/RightRoot/ImportRoot"]
+layout_mode = 1
+anchors_preset = 1
+anchor_left = 1.0
+anchor_right = 1.0
+offset_left = -238.0
+offset_top = 106.0
+offset_right = -34.0
+offset_bottom = 163.0
+grow_horizontal = 0
+text = "重新导入"
diff --git a/DungeonShooting_Godot/src/game/manager/EditorWindowManager.cs b/DungeonShooting_Godot/src/game/manager/EditorWindowManager.cs
index a87a109..2d9ed4e 100644
--- a/DungeonShooting_Godot/src/game/manager/EditorWindowManager.cs
+++ b/DungeonShooting_Godot/src/game/manager/EditorWindowManager.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using Config;
using Godot;
+using UI.EditorColorPicker;
using UI.EditorTips;
using UI.EditorWindow;
using UI.MapEditorCreateGroup;
@@ -11,9 +12,67 @@
using UI.MapEditorCreateRoom;
using UI.MapEditorSelectObject;
+///
+/// 通用弹窗管理类
+///
public static class EditorWindowManager
{
///
+ /// 打开颜色选择器弹窗
+ ///
+ /// 位置
+ /// 当前选中的颜色
+ /// 颜色改变时回调
+ /// 关闭时回调
+ public static void ShowColorPicker(Vector2 position, Color color, ColorPicker.ColorChangedEventHandler onChangeColor, Action onClose = null)
+ {
+ var window = CreateWindowInstance();
+ var colorPickerPanel = window.OpenBody(UiManager.UiNames.EditorColorPicker);
+ window.SetWindowTitle("颜色选择器");
+ window.SetWindowSize(new Vector2I(298, 720));
+ window.S_Window.Instance.Position = new Vector2I((int)(position.X - 298f * 0.5f), (int)(position.Y + 80));
+ colorPickerPanel.S_ColorPicker.Instance.Color = color;
+ colorPickerPanel.S_ColorPicker.Instance.ColorChanged += onChangeColor;
+ if (onClose != null)
+ {
+ window.CloseEvent += onClose;
+ }
+ }
+
+ ///
+ /// 显示打开文件窗口
+ ///
+ /// 过滤文件后缀
+ /// 关闭回调, 回调参数为选择的文件路径, 如果选择文件, 则回调参数为null
+ public static void ShowOpenFileDialog(string[] filters, Action onClose)
+ {
+ //UiManager.Open_EditorFileDialog();
+ var fileDialog = new FileDialog();
+ fileDialog.UseNativeDialog = true;
+ fileDialog.ModeOverridesTitle = false;
+ fileDialog.FileMode = FileDialog.FileModeEnum.OpenFile;
+ fileDialog.Access = FileDialog.AccessEnum.Filesystem;
+ fileDialog.Filters = filters;
+ fileDialog.FileSelected += (path) =>
+ {
+ onClose(path);
+ fileDialog.QueueFree();
+ };
+ fileDialog.Canceled += () =>
+ {
+ onClose(null);
+ fileDialog.QueueFree();
+ };
+ fileDialog.Confirmed += () =>
+ {
+ onClose(null);
+ fileDialog.QueueFree();
+ };
+ UiManager.GetUiLayer(UiLayer.Pop).AddChild(fileDialog);
+ fileDialog.Popup();
+ }
+
+ ///
/// 弹出通用提示面板
///
/// 标题
@@ -367,7 +426,7 @@
};
}
- private static EditorWindowPanel CreateWindowInstance(UiBase parentUi)
+ private static EditorWindowPanel CreateWindowInstance(UiBase parentUi = null)
{
if (parentUi != null)
{
diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs
index 2004942..43d6178 100644
--- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs
+++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs
@@ -63,6 +63,8 @@
public const string prefab_test_MoveComponent_tscn = "res://prefab/test/MoveComponent.tscn";
public const string prefab_ui_BottomTips_tscn = "res://prefab/ui/BottomTips.tscn";
public const string prefab_ui_Debugger_tscn = "res://prefab/ui/Debugger.tscn";
+ public const string prefab_ui_EditorColorPicker_tscn = "res://prefab/ui/EditorColorPicker.tscn";
+ public const string prefab_ui_EditorFileDialog_tscn = "res://prefab/ui/EditorFileDialog.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";
@@ -293,6 +295,7 @@
public const string resource_sprite_ui_commonIcon_Edit_png = "res://resource/sprite/ui/commonIcon/Edit.png";
public const string resource_sprite_ui_commonIcon_Error_mini_png = "res://resource/sprite/ui/commonIcon/Error_mini.png";
public const string resource_sprite_ui_commonIcon_Hide_png = "res://resource/sprite/ui/commonIcon/Hide.png";
+ public const string resource_sprite_ui_commonIcon_Import_png = "res://resource/sprite/ui/commonIcon/Import.png";
public const string resource_sprite_ui_commonIcon_Lock_png = "res://resource/sprite/ui/commonIcon/Lock.png";
public const string resource_sprite_ui_commonIcon_Mark_png = "res://resource/sprite/ui/commonIcon/Mark.png";
public const string resource_sprite_ui_commonIcon_MarkCell_png = "res://resource/sprite/ui/commonIcon/MarkCell.png";
diff --git a/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs b/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs
index 62fcb65..77558f6 100644
--- a/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs
+++ b/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs
@@ -7,6 +7,7 @@
{
public const string BottomTips = "BottomTips";
public const string Debugger = "Debugger";
+ public const string EditorColorPicker = "EditorColorPicker";
public const string EditorTips = "EditorTips";
public const string EditorTools = "EditorTools";
public const string EditorWindow = "EditorWindow";
@@ -128,6 +129,54 @@
}
///
+ /// 创建 EditorColorPicker, 并返回UI实例, 该函数不会打开 Ui
+ ///
+ public static UI.EditorColorPicker.EditorColorPickerPanel Create_EditorColorPicker()
+ {
+ return CreateUi(UiNames.EditorColorPicker);
+ }
+
+ ///
+ /// 打开 EditorColorPicker, 并返回UI实例
+ ///
+ public static UI.EditorColorPicker.EditorColorPickerPanel Open_EditorColorPicker()
+ {
+ return OpenUi(UiNames.EditorColorPicker);
+ }
+
+ ///
+ /// 隐藏 EditorColorPicker 的所有实例
+ ///
+ public static void Hide_EditorColorPicker()
+ {
+ var uiInstance = Get_EditorColorPicker_Instance();
+ foreach (var uiPanel in uiInstance)
+ {
+ uiPanel.HideUi();
+ }
+ }
+
+ ///
+ /// 销毁 EditorColorPicker 的所有实例
+ ///
+ public static void Destroy_EditorColorPicker()
+ {
+ var uiInstance = Get_EditorColorPicker_Instance();
+ foreach (var uiPanel in uiInstance)
+ {
+ uiPanel.Destroy();
+ }
+ }
+
+ ///
+ /// 获取所有 EditorColorPicker 的实例, 如果没有实例, 则返回一个空数组
+ ///
+ public static UI.EditorColorPicker.EditorColorPickerPanel[] Get_EditorColorPicker_Instance()
+ {
+ return GetUiInstance(nameof(UI.EditorColorPicker.EditorColorPicker));
+ }
+
+ ///
/// 创建 EditorTips, 并返回UI实例, 该函数不会打开 Ui
///
public static UI.EditorTips.EditorTipsPanel Create_EditorTips()
diff --git a/DungeonShooting_Godot/src/game/ui/editorColorPicker/EditorColorPicker.cs b/DungeonShooting_Godot/src/game/ui/editorColorPicker/EditorColorPicker.cs
new file mode 100644
index 0000000..f882f90
--- /dev/null
+++ b/DungeonShooting_Godot/src/game/ui/editorColorPicker/EditorColorPicker.cs
@@ -0,0 +1,46 @@
+namespace UI.EditorColorPicker;
+
+///
+/// Ui代码, 该类是根据ui场景自动生成的, 请不要手动编辑该类, 以免造成代码丢失
+///
+public abstract partial class EditorColorPicker : UiBase
+{
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorColorPicker.ColorPicker
+ ///
+ public ColorPicker L_ColorPicker
+ {
+ get
+ {
+ if (_L_ColorPicker == null) _L_ColorPicker = new ColorPicker((EditorColorPickerPanel)this, GetNode("ColorPicker"));
+ return _L_ColorPicker;
+ }
+ }
+ private ColorPicker _L_ColorPicker;
+
+
+ public EditorColorPicker() : base(nameof(EditorColorPicker))
+ {
+ }
+
+ public sealed override void OnInitNestedUi()
+ {
+
+ }
+
+ ///
+ /// 类型: , 路径: EditorColorPicker.ColorPicker
+ ///
+ public class ColorPicker : UiNode
+ {
+ public ColorPicker(EditorColorPickerPanel uiPanel, Godot.ColorPicker node) : base(uiPanel, node) { }
+ public override ColorPicker Clone() => new (UiPanel, (Godot.ColorPicker)Instance.Duplicate());
+ }
+
+
+ ///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorColorPicker.ColorPicker
+ ///
+ public ColorPicker S_ColorPicker => L_ColorPicker;
+
+}
diff --git a/DungeonShooting_Godot/src/game/ui/editorColorPicker/EditorColorPickerPanel.cs b/DungeonShooting_Godot/src/game/ui/editorColorPicker/EditorColorPickerPanel.cs
new file mode 100644
index 0000000..2d8e4dc
--- /dev/null
+++ b/DungeonShooting_Godot/src/game/ui/editorColorPicker/EditorColorPickerPanel.cs
@@ -0,0 +1,18 @@
+using Godot;
+
+namespace UI.EditorColorPicker;
+
+public partial class EditorColorPickerPanel : EditorColorPicker
+{
+
+ public override void OnCreateUi()
+ {
+
+ }
+
+ public override void OnDestroyUi()
+ {
+
+ }
+
+}
diff --git a/DungeonShooting_Godot/src/game/ui/editorWindow/EditorWindowPanel.cs b/DungeonShooting_Godot/src/game/ui/editorWindow/EditorWindowPanel.cs
index 6e1761b..6d20e02 100644
--- a/DungeonShooting_Godot/src/game/ui/editorWindow/EditorWindowPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/editorWindow/EditorWindowPanel.cs
@@ -102,6 +102,10 @@
/// 是否派发关闭窗口的事件
public void CloseWindow(bool triggerEvent = true)
{
+ if (IsDestroyed)
+ {
+ return;
+ }
if (triggerEvent && CloseEvent != null)
{
CloseEvent();
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditor.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditor.cs
index 16a368b..2fad5b9 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditor.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditor.cs
@@ -339,6 +339,15 @@
}
///
+ /// 类型: , 路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ImportRoot.ImportPreviewBg
+ ///
+ public class ImportPreviewBg : UiNode
+ {
+ public ImportPreviewBg(TileSetEditorPanel uiPanel, Godot.ColorRect node) : base(uiPanel, node) { }
+ public override ImportPreviewBg Clone() => new (UiPanel, (Godot.ColorRect)Instance.Duplicate());
+ }
+
+ ///
/// 类型: , 路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ImportRoot.Control.ImportPreview
///
public class ImportPreview : UiNode
@@ -370,6 +379,24 @@
}
///
+ /// 类型: , 路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ImportRoot.ImportColorPicker
+ ///
+ public class ImportColorPicker : UiNode
+ {
+ public ImportColorPicker(TileSetEditorPanel uiPanel, Godot.Button node) : base(uiPanel, node) { }
+ public override ImportColorPicker Clone() => new (UiPanel, (Godot.Button)Instance.Duplicate());
+ }
+
+ ///
+ /// 类型: , 路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ImportRoot.ReimportButton
+ ///
+ public class ReimportButton : UiNode
+ {
+ public ReimportButton(TileSetEditorPanel uiPanel, Godot.Button node) : base(uiPanel, node) { }
+ public override ReimportButton Clone() => new (UiPanel, (Godot.Button)Instance.Duplicate());
+ }
+
+ ///
/// 类型: , 路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ImportRoot
///
public class ImportRoot : UiNode
@@ -414,6 +441,19 @@
private ImportIcon _L_ImportIcon;
///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ImportPreviewBg
+ ///
+ public ImportPreviewBg L_ImportPreviewBg
+ {
+ get
+ {
+ if (_L_ImportPreviewBg == null) _L_ImportPreviewBg = new ImportPreviewBg(UiPanel, Instance.GetNode("ImportPreviewBg"));
+ return _L_ImportPreviewBg;
+ }
+ }
+ private ImportPreviewBg _L_ImportPreviewBg;
+
+ ///
/// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.Control
///
public Control L_Control
@@ -426,6 +466,32 @@
}
private Control _L_Control;
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ImportColorPicker
+ ///
+ public ImportColorPicker L_ImportColorPicker
+ {
+ get
+ {
+ if (_L_ImportColorPicker == null) _L_ImportColorPicker = new ImportColorPicker(UiPanel, Instance.GetNode("ImportColorPicker"));
+ return _L_ImportColorPicker;
+ }
+ }
+ private ImportColorPicker _L_ImportColorPicker;
+
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ReimportButton
+ ///
+ public ReimportButton L_ReimportButton
+ {
+ get
+ {
+ if (_L_ReimportButton == null) _L_ReimportButton = new ReimportButton(UiPanel, Instance.GetNode("ReimportButton"));
+ return _L_ReimportButton;
+ }
+ }
+ private ReimportButton _L_ReimportButton;
+
public ImportRoot(TileSetEditorPanel uiPanel, UI.TileSetEditor.TileSetEditorImportRoot node) : base(uiPanel, node) { }
public override ImportRoot Clone() => new (UiPanel, (UI.TileSetEditor.TileSetEditorImportRoot)Instance.Duplicate());
}
@@ -626,6 +692,11 @@
public ImportIcon S_ImportIcon => L_Bg.L_VBoxContainer.L_HBoxContainer.L_RightRoot.L_ImportRoot.L_ImportIcon;
///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ImportRoot.ImportPreviewBg
+ ///
+ public ImportPreviewBg S_ImportPreviewBg => L_Bg.L_VBoxContainer.L_HBoxContainer.L_RightRoot.L_ImportRoot.L_ImportPreviewBg;
+
+ ///
/// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ImportRoot.Control.ImportPreview
///
public ImportPreview S_ImportPreview => L_Bg.L_VBoxContainer.L_HBoxContainer.L_RightRoot.L_ImportRoot.L_Control.L_ImportPreview;
@@ -636,6 +707,16 @@
public Control S_Control => L_Bg.L_VBoxContainer.L_HBoxContainer.L_RightRoot.L_ImportRoot.L_Control;
///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ImportRoot.ImportColorPicker
+ ///
+ public ImportColorPicker S_ImportColorPicker => L_Bg.L_VBoxContainer.L_HBoxContainer.L_RightRoot.L_ImportRoot.L_ImportColorPicker;
+
+ ///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ImportRoot.ReimportButton
+ ///
+ public ReimportButton S_ReimportButton => L_Bg.L_VBoxContainer.L_HBoxContainer.L_RightRoot.L_ImportRoot.L_ReimportButton;
+
+ ///
/// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.RightRoot.ImportRoot
///
public ImportRoot S_ImportRoot => L_Bg.L_VBoxContainer.L_HBoxContainer.L_RightRoot.L_ImportRoot;
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorImportRoot.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorImportRoot.cs
index 0251cbd..0489b97 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorImportRoot.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorImportRoot.cs
@@ -7,17 +7,20 @@
{
private TileSetEditor.ImportRoot _importRoot;
private DragBinder _dragBinder;
+ //是否打开了颜色选择器
+ private bool _isOpenColorPicker;
public void SetUiNode(IUiNode uiNode)
{
_importRoot = (TileSetEditor.ImportRoot)uiNode;
- GetTree().Root.FilesDropped += OnFilesDropped;
-
- _importRoot.L_ImportButton.Instance.Pressed += () =>
- {
- Debug.Log("点击了...");
- };
_dragBinder = DragUiManager.BindDrag(_importRoot.L_ImportButton.Instance, OnDragCallback);
+ GetTree().Root.FilesDropped += OnFilesDropped;
+ _importRoot.L_ImportButton.Instance.Pressed += OnImportButtonClick;
+ _importRoot.L_ReimportButton.Instance.Pressed += OnReimportButtonClick;
+ _importRoot.L_ImportColorPicker.Instance.Pressed += OnColorPickerClick;
+
+ _importRoot.L_ImportPreviewBg.Instance.Visible = false;
+ _importRoot.L_ReimportButton.Instance.Visible = false;
}
public void OnDestroy()
@@ -51,10 +54,49 @@
}
}
+ //点击导入按钮
+ private void OnImportButtonClick()
+ {
+ if (_importRoot.UiPanel.Texture != null)
+ {
+ return;
+ }
+
+ OnReimportButtonClick();
+ }
+
+ //重新导入
+ private void OnReimportButtonClick()
+ {
+ EditorWindowManager.ShowOpenFileDialog(["*.png"], (path) =>
+ {
+ if (path != null)
+ {
+ SetImportTexture(path);
+ }
+ });
+ }
+
+ //点击调整背景颜色
+ private void OnColorPickerClick()
+ {
+ if (!_isOpenColorPicker)
+ {
+ _isOpenColorPicker = true;
+ EditorWindowManager.ShowColorPicker(
+ _importRoot.L_ImportColorPicker.Instance.GlobalPosition,
+ _importRoot.L_ImportPreviewBg.Instance.Color,
+ //设置颜色
+ color => { _importRoot.L_ImportPreviewBg.Instance.Color = color; },
+ //关闭窗口
+ () => { _isOpenColorPicker = false; }
+ );
+ }
+ }
+
//拖拽区域回调
private void OnDragCallback(DragState state, Vector2 position)
{
- Debug.Log("state: ", state);
var sprite2D = _importRoot.L_Control.L_ImportPreview.Instance;
if (state == DragState.DragMove && sprite2D.Visible)
{
@@ -73,26 +115,40 @@
if (flag)
{
var file = files[0];
- Debug.Log("导入文件: " + file);
if (Path.GetExtension(file) != ".png")
{
EditorWindowManager.ShowTips("警告", "只能导入'.png'格式的文件!");
return;
}
- var imageTexture = ImageTexture.CreateFromImage(Image.LoadFromFile(file));
- var textureRect = _importRoot.L_Control.L_ImportPreview.Instance;
- if (textureRect.Texture != null)
- {
- textureRect.Texture.Dispose();
- }
-
- textureRect.Texture = imageTexture;
-
- //隐藏导入文本和icon
- _importRoot.L_ImportLabel.Instance.Visible = false;
- _importRoot.L_ImportIcon.Instance.Visible = false;
+ SetImportTexture(file);
}
}
+
+ ///
+ /// 导入纹理
+ ///
+ /// 纹理路径
+ private void SetImportTexture(string file)
+ {
+ Debug.Log("导入文件: " + file);
+ var imageTexture = ImageTexture.CreateFromImage(Image.LoadFromFile(file));
+ _importRoot.UiPanel.TexturePath = file;
+ _importRoot.UiPanel.Texture = imageTexture;
+
+ var textureRect = _importRoot.L_Control.L_ImportPreview.Instance;
+ if (textureRect.Texture != null)
+ {
+ textureRect.Texture.Dispose();
+ }
+
+ textureRect.Texture = imageTexture;
+ _importRoot.L_ImportPreviewBg.Instance.Visible = true;
+ _importRoot.L_ReimportButton.Instance.Visible = true;
+
+ //隐藏导入文本和icon
+ _importRoot.L_ImportLabel.Instance.Visible = false;
+ _importRoot.L_ImportIcon.Instance.Visible = false;
+ }
}
\ 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 8d484eb..330bf7c 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs
@@ -4,6 +4,16 @@
public partial class TileSetEditorPanel : TileSetEditor
{
+ ///
+ /// 纹理路径
+ ///
+ public string TexturePath;
+
+ ///
+ /// 纹理
+ ///
+ public Texture Texture;
+
public override void OnCreateUi()
{
S_Back.Instance.Visible = PrevUi != null;