Support to delete the selected node, the room template edit box for anti-shake processing.

支持删除选中的节点了,对房间模板编辑框进行防抖处理。
This commit is contained in:
Cold-Mint 2024-05-17 22:08:19 +08:00
parent 4d583b6650
commit 250bd53392
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
9 changed files with 151 additions and 65 deletions

View File

@ -19,11 +19,12 @@ name,名称,Name,めいしょう
describe,描述,Describe,ないよう describe,描述,Describe,ないよう
creation,创建,Creation,創建 creation,创建,Creation,創建
default_room_name,房间{0},Room{0},部屋{0}です default_room_name,房间{0},Room{0},部屋{0}です
room_template_collection_prompt,房间模板集(每一行被认为是一条房间模板地址。),Room template set (Each row is considered to be one room template address.),お部屋テンプレートセット(各行がお部屋テンプレートアドレスとされています。) room_template_collection_prompt,房间模板集(传入路径为文件夹,将选择文件夹内的所有子文件),"Room template set (incoming path is folder, all subfiles in folder will be selected)",部屋テンプレートセット(着信経路をフォルダにして、フォルダ内のすべてのサブファイルを選択します。)
error_specifying_room_template_line,位于{0}错误,文件不存在。,"Located at {0} error, file does not exist.",{0}エラーに位置し、ファイル存在しません。 error_specifying_room_template_line,位于{0}错误,文件或文件夹不存在。,"Located at {0} error, file or folder does not exist.",{0}エラーに位置し、ファイルやフォルダが存在しません。
line_errors_must_start_with_res,位于{0}错误必须以res://开头。,"Located at {0} error, must start with res://.",{0}エラーに位置し、res://で始めなければなりません。 line_errors_must_start_with_res,位于{0}错误必须以res://开头。,"Located at {0} error, must start with res://.",{0}エラーに位置し、res://で始めなければなりません。
open_the_export_directory,打开导出目录,Open the export directory,エクスポートディレクトリを開きます open_the_export_directory,打开导出目录,Open the export directory,エクスポートディレクトリを開きます
save,保存,Save,保留 save,保存,Save,保留
filename,文件名,File name,ファイル名 filename,文件名,File name,ファイル名
cancel,取消,Cancel,キャンセル cancel,取消,Cancel,キャンセル
load,加载,Load,ろーど load,加载,Load,ろーど
delete_selected_node,删除选中的节点,Delete selected node,選択されたノードを削除します
1 id zh en jp
19 describe 描述 Describe ないよう
20 creation 创建 Creation 創建
21 default_room_name 房间{0} Room{0} 部屋{0}です
22 room_template_collection_prompt 房间模板集(每一行被认为是一条房间模板地址。) 房间模板集(传入路径为文件夹,将选择文件夹内的所有子文件) Room template set (Each row is considered to be one room template address.) Room template set (incoming path is folder, all subfiles in folder will be selected) お部屋テンプレートセット(各行がお部屋テンプレートアドレスとされています。) 部屋テンプレートセット(着信経路をフォルダにして、フォルダ内のすべてのサブファイルを選択します。)
23 error_specifying_room_template_line 位于{0}错误,文件不存在。 位于{0}错误,文件或文件夹不存在。 Located at {0} error, file does not exist. Located at {0} error, file or folder does not exist. {0}エラーに位置し、ファイルは存在しません。 {0}エラーに位置し、ファイルやフォルダが存在しません。
24 line_errors_must_start_with_res 位于{0}错误,必须以res://开头。 Located at {0} error, must start with res://. {0}エラーに位置し、res://で始めなければなりません。
25 open_the_export_directory 打开导出目录 Open the export directory エクスポートディレクトリを開きます
26 save 保存 Save 保留
27 filename 文件名 File name ファイル名
28 cancel 取消 Cancel キャンセル
29 load 加载 Load ろーど
30 delete_selected_node 删除选中的节点 Delete selected node 選択されたノードを削除します

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -147,7 +147,6 @@ hotbar_previous={
[internationalization] [internationalization]
locale/translations=PackedStringArray("res://locals/UI.en.translation", "res://locals/UI.zh.translation", "res://locals/Error.zh.translation", "res://locals/Error.en.translation", "res://locals/slogan.en.translation", "res://locals/slogan.zh.translation", "res://locals/Log.en.translation", "res://locals/Log.zh.translation", "res://locals/Weapon.en.translation", "res://locals/Weapon.zh.translation", "res://locals/InputMapping.en.translation", "res://locals/InputMapping.zh.translation", "res://locals/Error.jp.translation", "res://locals/InputMapping.jp.translation", "res://locals/Log.jp.translation", "res://locals/slogan.jp.translation", "res://locals/UI.jp.translation", "res://locals/Weapon.jp.translation") locale/translations=PackedStringArray("res://locals/UI.en.translation", "res://locals/UI.zh.translation", "res://locals/Error.zh.translation", "res://locals/Error.en.translation", "res://locals/slogan.en.translation", "res://locals/slogan.zh.translation", "res://locals/Log.en.translation", "res://locals/Log.zh.translation", "res://locals/Weapon.en.translation", "res://locals/Weapon.zh.translation", "res://locals/InputMapping.en.translation", "res://locals/InputMapping.zh.translation", "res://locals/Error.jp.translation", "res://locals/InputMapping.jp.translation", "res://locals/Log.jp.translation", "res://locals/slogan.jp.translation", "res://locals/UI.jp.translation", "res://locals/Weapon.jp.translation")
locale/test="jp"
[layer_names] [layer_names]

View File

@ -35,7 +35,6 @@ offset_bottom = 32.0
text = "level_graph_editor" text = "level_graph_editor"
[node name="CreateOrEditorPanel" type="Panel" parent="."] [node name="CreateOrEditorPanel" type="Panel" parent="."]
visible = false
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@ -152,6 +151,10 @@ offset_right = -15.0
offset_bottom = 47.0 offset_bottom = 47.0
grow_horizontal = 0 grow_horizontal = 0
[node name="DeleteSelectedNodeButton" type="Button" parent="HBoxContainer"]
layout_mode = 2
text = "delete_selected_node"
[node name="OpenExportFolderButton" type="Button" parent="HBoxContainer"] [node name="OpenExportFolderButton" type="Button" parent="HBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "open_the_export_directory" text = "open_the_export_directory"

View File

@ -80,6 +80,12 @@ public static class Config
/// </summary> /// </summary>
public const int MaxStackQuantity = 99; public const int MaxStackQuantity = 99;
/// <summary>
/// <para>Text change buffering Time How long does it take to execute the actual event after an event with a text change listener is triggered? (Anti-shake processing time), unit: milliseconds</para>
/// <para>当添加了文本改变监听器的事件被触发后,多长时间后执行实际事件?(防抖处理时长),单位:毫秒</para>
/// </summary>
public const long TextChangesBuffetingDuration = 300;
/// <summary> /// <summary>
/// <para>Operation prompts, function key text color</para> /// <para>Operation prompts, function key text color</para>
/// <para>操作提示内,功能键文本颜色</para> /// <para>操作提示内,功能键文本颜色</para>

View File

@ -5,4 +5,6 @@ public class RoomNodeData
public string? Id { get; set; } public string? Id { get; set; }
public string? Title { get; set; } public string? Title { get; set; }
public string? Description { get; set; } public string? Description { get; set; }
public string[]? RoomTemplateSet { get; set; }
} }

View File

@ -1,5 +1,7 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using ColdMint.scripts.debug;
using ColdMint.scripts.levelGraphEditor; using ColdMint.scripts.levelGraphEditor;
using ColdMint.scripts.serialization; using ColdMint.scripts.serialization;
using ColdMint.scripts.utils; using ColdMint.scripts.utils;
@ -49,6 +51,14 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
private Label? _saveOrLoadPanelTitleLabel; private Label? _saveOrLoadPanelTitleLabel;
private LineEdit? _fileNameLineEdit; private LineEdit? _fileNameLineEdit;
private Button? _showLoadPanelButton; private Button? _showLoadPanelButton;
private Button? _deleteSelectedNodeButton;
private readonly List<Node> _selectedNodes = new List<Node>();
/// <summary>
/// <para>Displays the time to enter the suggestion</para>
/// <para>显示输入建议的时刻</para>
/// </summary>
private DateTime? _displaysTheSuggestedInputTime;
/// <summary> /// <summary>
/// <para>Offset to append when a new node is created.</para> /// <para>Offset to append when a new node is created.</para>
@ -103,6 +113,7 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
_showSavePanelButton = GetNode<Button>("HBoxContainer/ShowSavePanelButton"); _showSavePanelButton = GetNode<Button>("HBoxContainer/ShowSavePanelButton");
_roomTemplateCollectionTextEdit = GetNode<TextEdit>("CreateOrEditorPanel/RoomTemplateCollectionTextEdit"); _roomTemplateCollectionTextEdit = GetNode<TextEdit>("CreateOrEditorPanel/RoomTemplateCollectionTextEdit");
_graphEdit = GetNode<GraphEdit>("GraphEdit"); _graphEdit = GetNode<GraphEdit>("GraphEdit");
_deleteSelectedNodeButton = GetNode<Button>("HBoxContainer/DeleteSelectedNodeButton");
_showCreateRoomPanelButton = GetNode<Button>("HBoxContainer/ShowCreateRoomPanelButton"); _showCreateRoomPanelButton = GetNode<Button>("HBoxContainer/ShowCreateRoomPanelButton");
_returnButton = GetNode<Button>("HBoxContainer/ReturnButton"); _returnButton = GetNode<Button>("HBoxContainer/ReturnButton");
_createOrEditorPanel = GetNode<Panel>("CreateOrEditorPanel"); _createOrEditorPanel = GetNode<Panel>("CreateOrEditorPanel");
@ -143,14 +154,13 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
return roomNode; return roomNode;
} }
public override void LoadUiActions() /// <summary>
/// <para>Displays input suggestions for room templates</para>
/// <para>显示房间模板的输入建议</para>
/// </summary>
private void DisplayInputPrompt()
{ {
base.LoadUiActions(); if (_roomTemplateTipsLabel == null || _roomTemplateCollectionTextEdit == null)
if (_roomTemplateCollectionTextEdit != null)
{
_roomTemplateCollectionTextEdit.TextChanged += () =>
{
if (_roomTemplateTipsLabel == null)
{ {
return; return;
} }
@ -185,8 +195,9 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
return; return;
} }
var exists = FileAccess.FileExists(lastLine); var fileExists = FileAccess.FileExists(lastLine);
if (!exists) var dirExists = DirAccess.DirExistsAbsolute(lastLine);
if (!fileExists && !dirExists)
{ {
var lineError = TranslationServer.Translate("error_specifying_room_template_line"); var lineError = TranslationServer.Translate("error_specifying_room_template_line");
if (lineError == null) if (lineError == null)
@ -200,11 +211,39 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
_roomTemplateTipsLabel.Text = string.Empty; _roomTemplateTipsLabel.Text = string.Empty;
} }
}
public override void _Process(double delta)
{
base._Process(delta);
if (_displaysTheSuggestedInputTime != null && DateTime.Now > _displaysTheSuggestedInputTime)
{
//Performs the actual input field text change event.
//执行实际的输入框文本改变事件。
DisplayInputPrompt();
_displaysTheSuggestedInputTime = null;
}
}
public override void LoadUiActions()
{
base.LoadUiActions();
if (_roomTemplateCollectionTextEdit != null)
{
_roomTemplateCollectionTextEdit.TextChanged += () =>
{
//Add anti-shake treatment.
//添加防抖处理。
//Higher frequency events are executed last time.
//频率较高的事件中,执行最后一次。
_displaysTheSuggestedInputTime = DateTime.Now.Add(TimeSpan.FromMilliseconds(Config.TextChangesBuffetingDuration));
}; };
} }
if (_graphEdit != null) if (_graphEdit != null)
{ {
_graphEdit.NodeSelected += node => { _selectedNodes.Add(node); };
_graphEdit.NodeDeselected += node => { _selectedNodes.Remove(node); };
_graphEdit.ConnectionRequest += (fromNode, fromPort, toNode, toPort) => _graphEdit.ConnectionRequest += (fromNode, fromPort, toNode, toPort) =>
{ {
_graphEdit.ConnectNode(fromNode, (int)fromPort, toNode, (int)toPort); _graphEdit.ConnectNode(fromNode, (int)fromPort, toNode, (int)toPort);
@ -223,6 +262,35 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
}; };
} }
if (_deleteSelectedNodeButton != null)
{
_deleteSelectedNodeButton.Pressed += () =>
{
if (_graphEdit == null)
{
return;
}
if (_selectedNodes.Count == 0)
{
return;
}
var nodes = _selectedNodes.ToArray();
foreach (var node in nodes)
{
if (node is not RoomNode roomNode)
{
continue;
}
_graphEdit.RemoveChild(node);
roomNode.QueueFree();
_selectedNodes.Remove(node);
}
};
}
if (_showCreateRoomPanelButton != null) if (_showCreateRoomPanelButton != null)
{ {
_showCreateRoomPanelButton.Pressed += () => _showCreateRoomPanelButton.Pressed += () =>
@ -246,8 +314,6 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
{ {
_hBoxContainer.Visible = false; _hBoxContainer.Visible = false;
} }
_showCreateRoomPanelButton.Visible = false;
}; };
} }
@ -268,7 +334,20 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
{ {
_createRoomButton.Pressed += () => _createRoomButton.Pressed += () =>
{ {
if (_roomNameLineEdit == null || _roomDescriptionLineEdit == null) if (_roomNameLineEdit == null || _roomDescriptionLineEdit == null ||
_roomTemplateCollectionTextEdit == null)
{
return;
}
var roomTemplateData = _roomTemplateCollectionTextEdit.Text;
if (string.IsNullOrEmpty(roomTemplateData))
{
return;
}
var roomTemplateArray = roomTemplateData.Split('\n');
if (roomTemplateArray.Length == 0)
{ {
return; return;
} }
@ -277,7 +356,8 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
{ {
Id = GuidUtils.GetGuid(), Id = GuidUtils.GetGuid(),
Title = _roomNameLineEdit.Text, Title = _roomNameLineEdit.Text,
Description = _roomDescriptionLineEdit.Text Description = _roomDescriptionLineEdit.Text,
RoomTemplateSet = roomTemplateArray
}; };
var roomNode = CreateRoomNode(roomNodeData); var roomNode = CreateRoomNode(roomNodeData);
if (roomNode != null) if (roomNode != null)
@ -638,10 +718,5 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
{ {
_hBoxContainer.Visible = true; _hBoxContainer.Visible = true;
} }
if (_showCreateRoomPanelButton != null)
{
_showCreateRoomPanelButton.Visible = true;
}
} }
} }