refactor: CycleUiHelper 重命名为 FairyUiHelper

对齐 FairyView 宿主命名。环线/充电/按钮/门进程的 Stop 改为 override,避免隐藏基类;Kiva.ForceStop 改为 override。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
黄兆尉
2026-08-26 22:49:07 +08:00
co-authored by Cursor
parent 7c925985eb
commit e075bc0d7d
23 changed files with 143 additions and 116 deletions
@@ -1,24 +1,44 @@
using FairyView;
using Simple3;
namespace StandardScene.Utils
{
/// <summary>
/// CycleGUI 通用 UI 小工具:统一委托 SafeUI 居中弹窗,避免自建 Panel 缺 Docking.None 跑到左上角
/// FairyView 通用 UI 小工具:浮动居中弹窗,不依赖宿主 SafeUI
/// </summary>
public static class CycleUiHelper
public static class FairyUiHelper
{
/// <summary>
/// 非阻塞二次确认:用户点「确认」后在当前线程执行 <paramref name="onConfirm"/>。
/// 耗时逻辑请自行 <c>Task.Run</c>。
/// </summary>
public static void ConfirmThen(string message, System.Action onConfirm) =>
SafeUI.ConfirmThen(message, onConfirm);
public static void ConfirmThen(string message, System.Action onConfirm)
{
var dlg = CenteredDialog(GUI.DeclarePanel().ShowTitle("确认"), 380, 150);
dlg.Define(pb =>
{
if (pb.Closing())
{
dlg.Exit();
return;
}
pb.Label(message);
pb.Separator();
if (pb.Button("确认", distinct: "fairyui-confirm-ok"))
{
dlg.Exit();
onConfirm?.Invoke();
}
pb.SameLine(8);
if (pb.Button("取消", distinct: "fairyui-confirm-cancel"))
dlg.Exit();
});
}
/// <summary>非阻塞文件选择对话框。</summary>
public static void PickOpenFile(string label, string filter, System.Action<string> onPicked)
{
var dlg = SafeUI.ApplyCenteredFloating(GUI.DeclarePanel().ShowTitle("选择文件"), 420, 120);
var dlg = CenteredDialog(GUI.DeclarePanel().ShowTitle("选择文件"), 420, 120);
dlg.Define(pb =>
{
if (pb.Closing())
@@ -38,7 +58,7 @@ namespace StandardScene.Utils
/// <summary>非阻塞提示对话框。</summary>
public static void Alert(string title, string message)
{
var dlg = SafeUI.ApplyCenteredFloating(GUI.DeclarePanel().ShowTitle(title), 380, 150);
var dlg = CenteredDialog(GUI.DeclarePanel().ShowTitle(title), 380, 150);
dlg.Define(pb =>
{
if (pb.Closing())
@@ -49,7 +69,7 @@ namespace StandardScene.Utils
pb.Label(message);
pb.Separator();
if (pb.Button("确定", distinct: "cycleui-alert-ok"))
if (pb.Button("确定", distinct: "fairyui-alert-ok"))
dlg.Exit();
});
}
@@ -59,5 +79,12 @@ namespace StandardScene.Utils
/// </summary>
public static int TableHeightPx(int visibleRows) =>
visibleRows <= 0 ? 0 : visibleRows * 32;
static Panel CenteredDialog(Panel panel, int width, int height) =>
panel
.TopMost(true)
.ForceFloat()
.InitSize(width, height)
.InitPos(true, 0, 0, 0.5f, 0.5f, 0.5f, 0.5f);
}
}