Files
MRCC/launcher/PCL-CE/Plain Craft Launcher 2/Pages/PageLaunch/PageLoginOffline.xaml.cs
T
xyou f70b061d1a
CI / Go Backend (push) Canceled after 0s
feat: 项目初始化 + 3D方块世界原型 + AI助搭系统
初始化 monorepo: Go后端(7微服务) + Unity客户端(9模块) + 启动器

HTML5原型: Three.js 3D体素世界, Perlin噪声地形, 原版材质, 22种方块

Minecraft创造模式背包: 双栏布局, 拖拽移动物品, 方向性元件引脚

AI助搭策划文档 + 客户端/服务端骨架 + Docker Compose + CI
2026-08-08 14:07:56 +08:00

89 lines
3.0 KiB
C#

using System.Windows;
using PCL.Core.Utils.Validate;
using PCL.Core.App.Localization;
namespace PCL;
public partial class PageLoginOffline
{
public PageLoginOffline()
{
// Handles
InitializeComponent();
BtnBack.Click += BtnBack_Click;
RadioUuidCustom.Check += RadioUuid_Checked;
RadioUuidStandard.Check += RadioUuid_Checked;
RadioUuidLegacy.Check += RadioUuid_Checked;
BtnLogin.Click += BtnLogin_Click;
}
private void BtnBack_Click(object sender, EventArgs e)
{
ModBase.RunInUi(() => ModMain.frmLaunchLeft.RefreshPage(true));
}
private void RadioUuid_Checked(object sender, ModBase.RouteEventArgs e)
{
if (RadioUuidCustom.Checked)
{
TextUuidTitle.Visibility = Visibility.Visible;
TextUuid.Visibility = Visibility.Visible;
}
else
{
TextUuidTitle.Visibility = Visibility.Collapsed;
TextUuid.Visibility = Visibility.Collapsed;
}
}
private void BtnLogin_Click(object sender, EventArgs e)
{
// 玩家 ID 输入检查
var username = TextName.Text;
var usernameValidateResult = new RegexValidator("^[A-z0-9_]{3,16}$").Validate(username);
if (!usernameValidateResult.IsValid)
if (ModMain.MyMsgBox(
Lang.Text("Launch.Account.Offline.InvalidPlayerId.Message"),
Lang.Text("Launch.Account.Offline.InvalidPlayerId.Title"), Lang.Text("Common.Action.Continue"), Lang.Text("Common.Action.Cancel"), isWarn: true, forceWait: true) == 2)
return;
// UUID
string userUuid = null;
if (RadioUuidCustom.Checked)
{
// 自定义输入检查
var uuidInput = TextUuid.Text.Replace("-", "");
var uuidValidateResult = new RegexValidator("^[a-fA-F0-9]{32}$").Validate(uuidInput);
if (RadioUuidCustom.Checked && !uuidValidateResult.IsValid)
{
HintService.Hint(Lang.Text("Launch.Account.Offline.InvalidUuid", uuidValidateResult), HintType.Error);
return;
}
userUuid = uuidInput;
}
else if (RadioUuidLegacy.Checked)
{
userUuid = ModProfile.GetOfflineUuid(username, isLegacy: true);
}
else
{
userUuid = ModProfile.GetOfflineUuid(username);
}
// 创建档案
var newProfile = new ModProfile.McProfile
{
Type = ModLaunch.McLoginType.Legacy,
Uuid = userUuid,
Username = username,
Desc = ""
};
ModProfile.profileList.Add(newProfile);
ModProfile.SaveProfile();
ModProfile.selectedProfile = newProfile;
ModProfile.isCreatingProfile = false;
HintService.Hint(Lang.Text("Launch.Account.Profile.Created"), HintType.Success);
ModBase.RunInUi(() => ModMain.frmLaunchLeft.RefreshPage(true));
}
}