Support to delete the selected node, the room template edit box for anti-shake processing.
支持删除选中的节点了,对房间模板编辑框进行防抖处理。
This commit is contained in:
parent
4d583b6650
commit
250bd53392
|
@ -19,11 +19,12 @@ name,名称,Name,めいしょう
|
|||
describe,描述,Describe,ないよう
|
||||
creation,创建,Creation,創建
|
||||
default_room_name,房间{0},Room{0},部屋{0}です
|
||||
room_template_collection_prompt,房间模板集(每一行被认为是一条房间模板地址。),Room template set (Each row is considered to be one room template address.),お部屋テンプレートセット(各行がお部屋テンプレートアドレスとされています。)
|
||||
error_specifying_room_template_line,位于{0}错误,文件不存在。,"Located at {0} error, file does not exist.",{0}エラーに位置し、ファイルは存在しません。
|
||||
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 or folder does not exist.",{0}エラーに位置し、ファイルやフォルダが存在しません。
|
||||
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,エクスポートディレクトリを開きます
|
||||
save,保存,Save,保留
|
||||
filename,文件名,File name,ファイル名
|
||||
cancel,取消,Cancel,キャンセル
|
||||
load,加载,Load,ろーど
|
||||
delete_selected_node,删除选中的节点,Delete selected node,選択されたノードを削除します
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -147,7 +147,6 @@ hotbar_previous={
|
|||
[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/test="jp"
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ offset_bottom = 32.0
|
|||
text = "level_graph_editor"
|
||||
|
||||
[node name="CreateOrEditorPanel" type="Panel" parent="."]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
@ -152,6 +151,10 @@ offset_right = -15.0
|
|||
offset_bottom = 47.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"]
|
||||
layout_mode = 2
|
||||
text = "open_the_export_directory"
|
||||
|
|
|
@ -80,6 +80,12 @@ public static class Config
|
|||
/// </summary>
|
||||
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>
|
||||
/// <para>Operation prompts, function key text color</para>
|
||||
/// <para>操作提示内,功能键文本颜色</para>
|
||||
|
|
|
@ -5,4 +5,6 @@ public class RoomNodeData
|
|||
public string? Id { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
public string[]? RoomTemplateSet { get; set; }
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using ColdMint.scripts.debug;
|
||||
using ColdMint.scripts.levelGraphEditor;
|
||||
using ColdMint.scripts.serialization;
|
||||
using ColdMint.scripts.utils;
|
||||
|
@ -49,6 +51,14 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
private Label? _saveOrLoadPanelTitleLabel;
|
||||
private LineEdit? _fileNameLineEdit;
|
||||
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>
|
||||
/// <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");
|
||||
_roomTemplateCollectionTextEdit = GetNode<TextEdit>("CreateOrEditorPanel/RoomTemplateCollectionTextEdit");
|
||||
_graphEdit = GetNode<GraphEdit>("GraphEdit");
|
||||
_deleteSelectedNodeButton = GetNode<Button>("HBoxContainer/DeleteSelectedNodeButton");
|
||||
_showCreateRoomPanelButton = GetNode<Button>("HBoxContainer/ShowCreateRoomPanelButton");
|
||||
_returnButton = GetNode<Button>("HBoxContainer/ReturnButton");
|
||||
_createOrEditorPanel = GetNode<Panel>("CreateOrEditorPanel");
|
||||
|
@ -143,6 +154,77 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
return roomNode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Displays input suggestions for room templates</para>
|
||||
/// <para>显示房间模板的输入建议</para>
|
||||
/// </summary>
|
||||
private void DisplayInputPrompt()
|
||||
{
|
||||
if (_roomTemplateTipsLabel == null || _roomTemplateCollectionTextEdit == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var text = _roomTemplateCollectionTextEdit.Text;
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
_roomTemplateTipsLabel.Text = string.Empty;
|
||||
return;
|
||||
}
|
||||
|
||||
var lastLine = StrUtils.GetLastLine(text);
|
||||
if (string.IsNullOrEmpty(lastLine))
|
||||
{
|
||||
_roomTemplateTipsLabel.Text = string.Empty;
|
||||
return;
|
||||
}
|
||||
|
||||
//Parse the last line
|
||||
//解析最后一行
|
||||
if (lastLine.Length > 0)
|
||||
{
|
||||
if (!lastLine.StartsWith("res://"))
|
||||
{
|
||||
var lineError = TranslationServer.Translate("line_errors_must_start_with_res");
|
||||
if (lineError == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_roomTemplateTipsLabel.Text = string.Format(lineError, lastLine);
|
||||
return;
|
||||
}
|
||||
|
||||
var fileExists = FileAccess.FileExists(lastLine);
|
||||
var dirExists = DirAccess.DirExistsAbsolute(lastLine);
|
||||
if (!fileExists && !dirExists)
|
||||
{
|
||||
var lineError = TranslationServer.Translate("error_specifying_room_template_line");
|
||||
if (lineError == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_roomTemplateTipsLabel.Text = string.Format(lineError, lastLine);
|
||||
return;
|
||||
}
|
||||
|
||||
_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();
|
||||
|
@ -150,61 +232,18 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
{
|
||||
_roomTemplateCollectionTextEdit.TextChanged += () =>
|
||||
{
|
||||
if (_roomTemplateTipsLabel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var text = _roomTemplateCollectionTextEdit.Text;
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
_roomTemplateTipsLabel.Text = string.Empty;
|
||||
return;
|
||||
}
|
||||
|
||||
var lastLine = StrUtils.GetLastLine(text);
|
||||
if (string.IsNullOrEmpty(lastLine))
|
||||
{
|
||||
_roomTemplateTipsLabel.Text = string.Empty;
|
||||
return;
|
||||
}
|
||||
|
||||
//Parse the last line
|
||||
//解析最后一行
|
||||
if (lastLine.Length > 0)
|
||||
{
|
||||
if (!lastLine.StartsWith("res://"))
|
||||
{
|
||||
var lineError = TranslationServer.Translate("line_errors_must_start_with_res");
|
||||
if (lineError == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_roomTemplateTipsLabel.Text = string.Format(lineError, lastLine);
|
||||
return;
|
||||
}
|
||||
|
||||
var exists = FileAccess.FileExists(lastLine);
|
||||
if (!exists)
|
||||
{
|
||||
var lineError = TranslationServer.Translate("error_specifying_room_template_line");
|
||||
if (lineError == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_roomTemplateTipsLabel.Text = string.Format(lineError, lastLine);
|
||||
return;
|
||||
}
|
||||
|
||||
_roomTemplateTipsLabel.Text = string.Empty;
|
||||
}
|
||||
//Add anti-shake treatment.
|
||||
//添加防抖处理。
|
||||
//Higher frequency events are executed last time.
|
||||
//频率较高的事件中,执行最后一次。
|
||||
_displaysTheSuggestedInputTime = DateTime.Now.Add(TimeSpan.FromMilliseconds(Config.TextChangesBuffetingDuration));
|
||||
};
|
||||
}
|
||||
|
||||
if (_graphEdit != null)
|
||||
{
|
||||
_graphEdit.NodeSelected += node => { _selectedNodes.Add(node); };
|
||||
_graphEdit.NodeDeselected += node => { _selectedNodes.Remove(node); };
|
||||
_graphEdit.ConnectionRequest += (fromNode, fromPort, toNode, 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)
|
||||
{
|
||||
_showCreateRoomPanelButton.Pressed += () =>
|
||||
|
@ -246,8 +314,6 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
{
|
||||
_hBoxContainer.Visible = false;
|
||||
}
|
||||
|
||||
_showCreateRoomPanelButton.Visible = false;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -268,7 +334,20 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
{
|
||||
_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;
|
||||
}
|
||||
|
@ -277,7 +356,8 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
{
|
||||
Id = GuidUtils.GetGuid(),
|
||||
Title = _roomNameLineEdit.Text,
|
||||
Description = _roomDescriptionLineEdit.Text
|
||||
Description = _roomDescriptionLineEdit.Text,
|
||||
RoomTemplateSet = roomTemplateArray
|
||||
};
|
||||
var roomNode = CreateRoomNode(roomNodeData);
|
||||
if (roomNode != null)
|
||||
|
@ -638,10 +718,5 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
{
|
||||
_hBoxContainer.Visible = true;
|
||||
}
|
||||
|
||||
if (_showCreateRoomPanelButton != null)
|
||||
{
|
||||
_showCreateRoomPanelButton.Visible = true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user