初始化 monorepo: Go后端(7微服务) + Unity客户端(9模块) + 启动器 HTML5原型: Three.js 3D体素世界, Perlin噪声地形, 原版材质, 22种方块 Minecraft创造模式背包: 双栏布局, 拖拽移动物品, 方向性元件引脚 AI助搭策划文档 + 客户端/服务端骨架 + Docker Compose + CI
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using PCL.Core.App.Localization;
|
||||
|
||||
namespace PCL.Core.UI;
|
||||
|
||||
public record MsgBoxButtonInfo(
|
||||
string Context,
|
||||
int Value = 0,
|
||||
Action? OnClick = null
|
||||
);
|
||||
|
||||
public enum MsgBoxTheme
|
||||
{
|
||||
Info,
|
||||
Warning,
|
||||
Error
|
||||
}
|
||||
|
||||
public delegate void MsgBoxHandler(
|
||||
string message,
|
||||
string caption,
|
||||
ICollection<MsgBoxButtonInfo> buttons,
|
||||
MsgBoxTheme theme,
|
||||
bool block,
|
||||
ref int result
|
||||
);
|
||||
|
||||
public static class MsgBoxWrapper
|
||||
{
|
||||
public static event MsgBoxHandler? OnShow;
|
||||
|
||||
public static int ShowWithCustomButtons(
|
||||
string message,
|
||||
string? caption,
|
||||
MsgBoxTheme theme,
|
||||
bool block,
|
||||
ICollection<MsgBoxButtonInfo> buttonCollection)
|
||||
{
|
||||
var result = 0;
|
||||
if (buttonCollection.Count == 0)
|
||||
buttonCollection = [new MsgBoxButtonInfo(Lang.Text("Common.Action.Confirm"))];
|
||||
OnShow?.Invoke(message, _ResolveCaption(caption, theme), buttonCollection, theme, block, ref result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int ShowWithCustomButtons(
|
||||
string message,
|
||||
string? caption = null,
|
||||
MsgBoxTheme theme = MsgBoxTheme.Info,
|
||||
bool block = true,
|
||||
params MsgBoxButtonInfo[] buttons)
|
||||
{
|
||||
return ShowWithCustomButtons(message, caption, theme, block, buttonCollection: buttons);
|
||||
}
|
||||
|
||||
public static int Show(
|
||||
string message,
|
||||
string? caption = null,
|
||||
MsgBoxTheme theme = MsgBoxTheme.Info,
|
||||
bool block = true,
|
||||
params string[] buttons)
|
||||
{
|
||||
var index = 0;
|
||||
var list = buttons.Select(button => new MsgBoxButtonInfo(button, ++index)).ToList();
|
||||
return ShowWithCustomButtons(message, caption, theme, block, list);
|
||||
}
|
||||
|
||||
private static string _ResolveCaption(string? caption, MsgBoxTheme theme)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(caption)) return caption;
|
||||
|
||||
return theme switch
|
||||
{
|
||||
MsgBoxTheme.Warning => Lang.Text("Common.Dialog.Warning"),
|
||||
MsgBoxTheme.Error => Lang.Text("SystemDialog.Error.Title"),
|
||||
_ => Lang.Text("Common.Dialog.Title")
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user