mirror of
https://github.com/project-redbud/FunGame-Desktop.git
synced 2025-04-20 12:09:34 +08:00
parent
e313288c9f
commit
e09da145b9
@ -29,8 +29,8 @@ namespace Milimoe.FunGame.Desktop.Controller
|
||||
try
|
||||
{
|
||||
// 构建AddonController
|
||||
Hashtable delegates = [];
|
||||
delegates.Add("WriteLine", new Action<string>(WritelnSystemInfo));
|
||||
Dictionary<string, object> delegates = [];
|
||||
delegates.Add("WriteLine", new Action<string, LogLevel, bool>(WritelnSystemInfo));
|
||||
delegates.Add("Error", new Action<Exception>(Error));
|
||||
delegates.Add("NewDataRequest", new Func<DataRequestType, DataRequest>(NewDataRequestForAddon));
|
||||
delegates.Add("NewLongRunningDataRequest", new Func<DataRequestType, DataRequest>(NewLongRunningDataRequestForAddon));
|
||||
@ -51,8 +51,8 @@ namespace Milimoe.FunGame.Desktop.Controller
|
||||
try
|
||||
{
|
||||
// 构建AddonController
|
||||
Hashtable delegates = [];
|
||||
delegates.Add("WriteLine", new Action<string>(WritelnSystemInfo));
|
||||
Dictionary<string, object> delegates = [];
|
||||
delegates.Add("WriteLine", new Action<string, string, LogLevel, bool>(WritelnSystemInfo));
|
||||
delegates.Add("Error", new Action<Exception>(Error));
|
||||
delegates.Add("NewGamingRequest", new Func<GamingType, DataRequest>(NewDataRequestForAddon));
|
||||
delegates.Add("NewLongRunningGamingRequest", new Func<GamingType, DataRequest>(NewLongRunningDataRequestForAddon));
|
||||
@ -68,7 +68,12 @@ namespace Milimoe.FunGame.Desktop.Controller
|
||||
}
|
||||
}
|
||||
|
||||
public override void WritelnSystemInfo(string msg)
|
||||
public override void WritelnSystemInfo(string msg, LogLevel level = LogLevel.Info, bool useLevel = true)
|
||||
{
|
||||
Main.GetMessage(msg);
|
||||
}
|
||||
|
||||
public void WritelnSystemInfo(string name, string msg, LogLevel level = LogLevel.Info, bool useLevel = true)
|
||||
{
|
||||
Main.GetMessage(msg);
|
||||
}
|
||||
@ -79,7 +84,7 @@ namespace Milimoe.FunGame.Desktop.Controller
|
||||
Main.UpdateUI(MainInvokeType.Disconnected);
|
||||
ConnectEventArgs args = new(RunTime.Session.Server_Address, RunTime.Session.Server_Port, ConnectResult.ConnectFailed);
|
||||
Main.OnFailedConnectEvent(Main, args);
|
||||
Close();
|
||||
Close_Socket();
|
||||
}
|
||||
|
||||
public override bool BeforeConnect(ref string ip, ref int port, ArrayList ConnectArgs)
|
||||
@ -162,7 +167,7 @@ namespace Milimoe.FunGame.Desktop.Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
Core.Api.Utility.TaskUtility.NewTask(async () => await LoginController.LoginAccountAsync(Username, Password, AutoKey));
|
||||
TaskUtility.NewTask(async () => await LoginController.LoginAccountAsync(Username, Password, AutoKey));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -177,7 +182,7 @@ namespace Milimoe.FunGame.Desktop.Controller
|
||||
if (ServerMessage.Parameters.Length > 0) msg = ServerMessage.GetParam<string>(0) ?? "";
|
||||
Main.GetMessage(msg);
|
||||
Main.UpdateUI(MainInvokeType.Disconnect);
|
||||
Close();
|
||||
Close_Socket();
|
||||
}
|
||||
|
||||
protected override void SocketHandler_System(SocketObject ServerMessage)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net9.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="FunGame.Core">
|
||||
<HintPath>..\..\FunGame.Core\bin\Debug\net8.0\FunGame.Core.dll</HintPath>
|
||||
<HintPath>..\..\FunGame.Core\bin\Debug\net9.0\FunGame.Core.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -4,6 +4,7 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
||||
{
|
||||
public partial class ExitButton : Button
|
||||
{
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
public GeneralForm? RelativeForm { get; set; }
|
||||
|
||||
public ExitButton()
|
||||
|
@ -4,6 +4,7 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
||||
{
|
||||
public partial class MinButton : Button
|
||||
{
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
public GeneralForm? RelativeForm { get; set; }
|
||||
|
||||
public MinButton()
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Milimoe.FunGame.Desktop.Library.Component
|
||||
{
|
||||
@ -24,31 +25,37 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
||||
SetStyle(ControlStyles.Opaque, false);
|
||||
UpdateStyles();
|
||||
}
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
public new Color BackColor
|
||||
{
|
||||
get { return _backColor; }
|
||||
set { _backColor = value; Invalidate(); }
|
||||
}
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
public ShapeBorderStyles ShapeBorderStyle
|
||||
{
|
||||
get { return _borderStyle; }
|
||||
set { _borderStyle = value; this.Invalidate(); }
|
||||
}
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
public Color BorderColor
|
||||
{
|
||||
get { return _borderColor; }
|
||||
set { _borderColor = value; Invalidate(); }
|
||||
}
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
public int Opacity
|
||||
{
|
||||
get { return _opacity; }
|
||||
set { _opacity = value; this.Invalidate(); }
|
||||
}
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
public int Radius
|
||||
{
|
||||
get { return _radius; }
|
||||
set { _radius = value; this.Invalidate(); }
|
||||
}
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
public override Color ForeColor
|
||||
{
|
||||
get { return base.ForeColor; }
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
using Milimoe.FunGame.Core.Library.Exception;
|
||||
using Milimoe.FunGame.Desktop.Controller;
|
||||
using Milimoe.FunGame.Desktop.Model;
|
||||
@ -8,116 +7,29 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
{
|
||||
public partial class ForgetPassword
|
||||
{
|
||||
private readonly LoginController LoginController;
|
||||
|
||||
public ForgetPassword()
|
||||
{
|
||||
InitializeComponent();
|
||||
LoginController = new(this);
|
||||
}
|
||||
|
||||
private void FindPassword_Click(object sender, EventArgs e)
|
||||
private async void FindPassword_Click(object sender, EventArgs e)
|
||||
{
|
||||
TaskUtility.NewTask(async () =>
|
||||
{
|
||||
if (RunTime.Socket != null)
|
||||
{
|
||||
string username = "";
|
||||
string email = "";
|
||||
InvokeUpdateUI(() =>
|
||||
{
|
||||
username = UsernameText.Text.Trim();
|
||||
email = EmailText.Text.Trim();
|
||||
});
|
||||
if (username == "" || email == "")
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "账号或邮箱不能为空!");
|
||||
InvokeUpdateUI(() => UsernameText.Focus());
|
||||
return;
|
||||
}
|
||||
if (RunTime.Socket == null) return;
|
||||
|
||||
string msg;
|
||||
bool success = false;
|
||||
string username = UsernameText.Text.Trim();
|
||||
string email = EmailText.Text.Trim();
|
||||
|
||||
if (!ValidateInput(username, email)) return;
|
||||
|
||||
try
|
||||
{
|
||||
// 发送找回密码请求
|
||||
msg = await LoginController.ForgetPassword_CheckVerifyCodeAsync(username, email, "");
|
||||
if (!await RequestVerificationCodeAsync(username, email)) return;
|
||||
|
||||
if (msg.Trim() != "")
|
||||
string newPassword = await GetNewPasswordAsync(username, email);
|
||||
|
||||
if (!string.IsNullOrEmpty(newPassword) && await UpdatePasswordAsync(username, newPassword))
|
||||
{
|
||||
// 如果返回一个信息,则停止找回密码
|
||||
ShowMessage(ShowMessageType.Error, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (!success)
|
||||
{
|
||||
string verifycode = ShowInputMessageCancel("请输入找回密码邮件中的6位数字验证码", "注册验证码", out MessageResult result);
|
||||
if (result != MessageResult.Cancel)
|
||||
{
|
||||
if (verifycode.Trim() != "")
|
||||
{
|
||||
msg = await LoginController.ForgetPassword_CheckVerifyCodeAsync(username, email, verifycode);
|
||||
if (msg.Trim() != "")
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage(ShowMessageType.Warning, "不能输入空值!");
|
||||
}
|
||||
}
|
||||
else break;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
string newpass = ShowInputMessageCancel("请输入新密码", "设置新密码", out MessageResult result);
|
||||
if (result != MessageResult.Cancel)
|
||||
{
|
||||
if (newpass.Trim() != "")
|
||||
{
|
||||
if (newpass.Length < 6 || newpass.Length > 15) // 字节范围 3~12
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "密码长度不符合要求:6~15个字符数");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = await LoginController.ForgetPassword_UpdatePasswordAsync(username, newpass);
|
||||
if (msg.Trim() != "")
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage(ShowMessageType.General, "密码更新成功!请您牢记新的密码。", "找回密码");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ShowMessage(ShowMessageType.OKCancel, "确定放弃设置新密码吗?", "找回密码") == MessageResult.OK)
|
||||
{
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
InvokeUpdateUI(Dispose);
|
||||
}
|
||||
Close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -125,7 +37,104 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
RunTime.WritelnSystemInfo(ex.GetErrorInfo());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private bool ValidateInput(string username, string email)
|
||||
{
|
||||
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(email))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "账号或邮箱不能为空!");
|
||||
InvokeUpdateUI(() => UsernameText.Focus());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task<bool> RequestVerificationCodeAsync(string username, string email)
|
||||
{
|
||||
string msg = await LoginController.ForgetPassword_CheckVerifyCodeAsync(username, email, "");
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, msg);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task<string> GetNewPasswordAsync(string username, string email)
|
||||
{
|
||||
bool success = false;
|
||||
do
|
||||
{
|
||||
string verifycode = ShowInputMessageCancel("请输入找回密码邮件中的6位数字验证码", "注册验证码", out MessageResult result);
|
||||
if (result == MessageResult.Cancel)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(verifycode))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Warning, "不能输入空值!");
|
||||
continue;
|
||||
}
|
||||
|
||||
string msg = await LoginController.ForgetPassword_CheckVerifyCodeAsync(username, email, verifycode);
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
} while (!success);
|
||||
|
||||
if (!success) return "";
|
||||
|
||||
string newPassword;
|
||||
success = false;
|
||||
do
|
||||
{
|
||||
newPassword = ShowInputMessageCancel("请输入新密码", "设置新密码", out MessageResult result);
|
||||
if (result == MessageResult.Cancel)
|
||||
{
|
||||
if (ShowMessage(ShowMessageType.OKCancel, "确定放弃设置新密码吗?", "找回密码") == MessageResult.OK)
|
||||
{
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(newPassword))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (newPassword.Length < 6 || newPassword.Length > 15)
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "密码长度不符合要求:6~15个字符数");
|
||||
continue;
|
||||
}
|
||||
success = true;
|
||||
} while (!success);
|
||||
|
||||
if (!success) return "";
|
||||
|
||||
return newPassword;
|
||||
}
|
||||
|
||||
private async Task<bool> UpdatePasswordAsync(string username, string newPassword)
|
||||
{
|
||||
string msg = await LoginController.ForgetPassword_UpdatePasswordAsync(username, newPassword);
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage(ShowMessageType.General, "密码更新成功!请您牢记新的密码。", "找回密码");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
using Milimoe.FunGame.Core.Library.Exception;
|
||||
using Milimoe.FunGame.Desktop.Controller;
|
||||
@ -28,18 +27,10 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
SucceedLogin += SucceedLoginEvent;
|
||||
}
|
||||
|
||||
private async Task<bool> Login_Handler()
|
||||
private async Task<bool> Login_HandlerAsync(string username, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
string username = UsernameText.Text.Trim();
|
||||
string password = PasswordText.Text.Trim();
|
||||
if (username == "" || password == "")
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "账号或密码不能为空!");
|
||||
UsernameText.Focus();
|
||||
return false;
|
||||
}
|
||||
return await LoginController.LoginAccountAsync(username, password);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -49,11 +40,6 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开注册界面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void RegButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenForm.SingleForm(FormType.Register, OpenFormType.Dialog);
|
||||
@ -64,19 +50,29 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
ShowMessage(ShowMessageType.Tip, "与No.16对话即可获得快速登录秘钥,快去试试吧!");
|
||||
}
|
||||
|
||||
private void GoToLogin_Click(object sender, EventArgs e)
|
||||
private async void GoToLogin_Click(object sender, EventArgs e)
|
||||
{
|
||||
GoToLogin.Enabled = false;
|
||||
bool result = false;
|
||||
TaskUtility.NewTask(async () =>
|
||||
string username = UsernameText.Text.Trim();
|
||||
string password = PasswordText.Text.Trim();
|
||||
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
result = await Login_Handler();
|
||||
}).OnCompleted(() =>
|
||||
{
|
||||
if (result) InvokeUpdateUI(Dispose);
|
||||
else GoToLogin.Enabled = true;
|
||||
});
|
||||
ShowMessage(ShowMessageType.Error, "账号或密码不能为空!");
|
||||
UsernameText.Focus();
|
||||
GoToLogin.Enabled = true;
|
||||
return;
|
||||
}
|
||||
bool result = await Login_HandlerAsync(username, password);
|
||||
if (result)
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
GoToLogin.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ForgetPassword_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -84,13 +80,21 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
UsernameText.Focus();
|
||||
}
|
||||
|
||||
public void FailedLoginEvent(object sender, LoginEventArgs e)
|
||||
private void FailedLoginEvent(object sender, LoginEventArgs e)
|
||||
{
|
||||
GoToLogin.Enabled = true;
|
||||
UpdateFailedLoginUI();
|
||||
RunTime.Main?.OnFailedLoginEvent(sender, e);
|
||||
RunTime.PluginLoader?.OnFailedLoginEvent(sender, e);
|
||||
}
|
||||
|
||||
private void UpdateFailedLoginUI()
|
||||
{
|
||||
InvokeUpdateUI(() =>
|
||||
{
|
||||
GoToLogin.Enabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
private void SucceedLoginEvent(object sender, LoginEventArgs e)
|
||||
{
|
||||
RunTime.Main?.OnSucceedLoginEvent(sender, e);
|
||||
|
2
FunGame.Desktop/UI/Main/Main.Designer.cs
generated
2
FunGame.Desktop/UI/Main/Main.Designer.cs
generated
@ -514,7 +514,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
Copyright.Size = new Size(186, 23);
|
||||
Copyright.TabIndex = 97;
|
||||
Copyright.TabStop = true;
|
||||
Copyright.Text = "©2024 Milimoe. 米粒的糖果屋";
|
||||
Copyright.Text = "©2022 Milimoe. 米粒的糖果屋";
|
||||
Copyright.TextAlign = ContentAlignment.MiddleLeft;
|
||||
Copyright.UseCompatibleTextRendering = true;
|
||||
Copyright.LinkClicked += Copyright_LinkClicked;
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
@ -22,6 +23,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
* 属性
|
||||
*/
|
||||
public int MaxRetryTimes { get; } = SocketSet.MaxRetryTimes; // 最大重试连接次数
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
public int CurrentRetryTimes { get; set; } = -1; // 当前重试连接次数
|
||||
|
||||
/**
|
||||
@ -44,6 +46,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// </summary>
|
||||
public void Init()
|
||||
{
|
||||
Copyright.Text = FunGameInfo.FunGame_CopyRight;
|
||||
RunTime.Main = this;
|
||||
SetButtonEnabled(false, ClientState.WaitConnect);
|
||||
SetRoomid(Usercfg.InRoom); // 房间号初始化
|
||||
@ -403,7 +406,9 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// </summary>
|
||||
private void WritelnGameInfo()
|
||||
{
|
||||
WritelnGameInfo("\r\n");
|
||||
GameInfo.AppendText("\n");
|
||||
GameInfo.SelectionStart = GameInfo.Text.Length - 1;
|
||||
GameInfo.ScrollToCaret();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -414,7 +419,9 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
{
|
||||
if (msg.Trim() != "")
|
||||
{
|
||||
WriteGameInfo(msg + "\r\n");
|
||||
GameInfo.AppendText(msg + "\n");
|
||||
GameInfo.SelectionStart = GameInfo.Text.Length - 1;
|
||||
GameInfo.ScrollToCaret();
|
||||
}
|
||||
}
|
||||
|
||||
@ -425,13 +432,10 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
private void WriteGameInfo(string msg)
|
||||
{
|
||||
if (msg.Trim() != "")
|
||||
{
|
||||
InvokeUpdateUI(() =>
|
||||
{
|
||||
GameInfo.AppendText(msg);
|
||||
GameInfo.SelectionStart = GameInfo.Text.Length - 1;
|
||||
GameInfo.ScrollToCaret();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -489,16 +493,16 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
TaskUtility.NewTask(async () =>
|
||||
{
|
||||
int PlayerCount = users.Count;
|
||||
for (int i = 5; i > 0; i--)
|
||||
for (int i = 10; i > 0; i--)
|
||||
{
|
||||
WritelnGameInfo("房间 [ " + room.Roomid + " (" + PlayerCount + "人" + RoomSet.GetTypeString(room.RoomType) + ") ] 的游戏将在" + i + "秒后开始...");
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
WritelnGameInfo("房间 [ " + room.Roomid + " (" + PlayerCount + "人" + RoomSet.GetTypeString(room.RoomType) + ") ] 的游戏正式开始!");
|
||||
if (RunTime.GameModuleLoader?.Modules.TryGetValue(room.GameModule, out GameModule? module) ?? false && module != null)
|
||||
if (RunTime.GameModuleLoader?.Modules.ContainsKey(room.GameModule) ?? false)
|
||||
{
|
||||
RunTime.Gaming = Core.Model.Gaming.StartGame(module, room, RunTime.Session.LoginUser, users, RunTime.GameModuleLoader);
|
||||
Visible = !module.HideMain; // 隐藏主界面
|
||||
RunTime.Gaming = Core.Model.Gaming.StartGame(RunTime.GameModuleLoader[room.GameModule], room, RunTime.Session.LoginUser, users, RunTime.GameModuleLoader);
|
||||
Visible = false; // 隐藏主界面
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -525,8 +529,8 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
{
|
||||
// 恢复界面
|
||||
Visible = true;
|
||||
SetButtonEnabled(true, ClientState.InRoom);
|
||||
_InGame = false;
|
||||
SetButtonEnabled(true, ClientState.InRoom);
|
||||
OnSucceedEndGameEvent(this, e);
|
||||
RunTime.PluginLoader?.OnSucceedEndGameEvent(this, e);
|
||||
}
|
||||
@ -629,12 +633,12 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// <summary>
|
||||
/// 通过双击房间列表的房间号加入房间
|
||||
/// </summary>
|
||||
/// <param name="selectedIndex"></param>
|
||||
private async Task<bool> JoinRoom(int selectedIndex)
|
||||
/// <param name="selectedindex"></param>
|
||||
private async Task<bool> JoinRoom(int selectedindex)
|
||||
{
|
||||
if (selectedIndex != -1 && RunTime.RoomList.Count > selectedIndex)
|
||||
if (selectedindex != -1 && RunTime.RoomList.Count > selectedindex)
|
||||
{
|
||||
string roomid = RunTime.RoomList.ListRoom[selectedIndex]?.Roomid ?? "";
|
||||
string roomid = RunTime.RoomList.ListRoom[selectedindex]?.Roomid ?? "";
|
||||
return await JoinRoom_Handler(roomid);
|
||||
}
|
||||
return false;
|
||||
@ -654,14 +658,27 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
{
|
||||
if (Usercfg.InRoom.Roomid == "-1")
|
||||
{
|
||||
GameModule? gameModule = RunTime.GameModuleLoader?[RunTime.RoomList[roomid].GameModule];
|
||||
if (await MainController.GetRoomPlayerCountAsync(roomid) < gameModule?.MaxUsers)
|
||||
if (await MainController.GetRoomPlayerCountAsync(roomid) < 8)
|
||||
{
|
||||
if (ShowMessage(ShowMessageType.YesNo, "已找到房间 -> [ " + roomid + " ]\n是否加入?", "已找到房间") == MessageResult.Yes)
|
||||
{
|
||||
Room r = GetRoom(roomid);
|
||||
bool result = true;
|
||||
if (r.Password.Trim() != "")
|
||||
{
|
||||
// 验证密码
|
||||
string inputPassword = ShowInputMessageCancel("请输入房间密码", "房间需要密码", out MessageResult messageResult);
|
||||
if (messageResult == MessageResult.Cancel || inputPassword != r.Password)
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "密码验证失败,拒绝加入!");
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
return await InvokeController_IntoRoom(r);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@ -890,27 +907,23 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// <summary>
|
||||
/// 创建房间的处理方法
|
||||
/// </summary>
|
||||
/// <param name="roomType"></param>
|
||||
/// <param name="gameModule"></param>
|
||||
/// <param name="gameMap"></param>
|
||||
/// <param name="isRank"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="RoomType"></param>
|
||||
/// <param name="Password"></param>
|
||||
/// <returns></returns>
|
||||
private async Task CreateRoom_Handler(RoomType roomType, string gameModule, string gameMap, bool isRank, string password = "")
|
||||
private async Task CreateRoom_Handler(RoomType RoomType, string GameModule, string GameMap, bool IsRank, string Password = "")
|
||||
{
|
||||
if (Usercfg.InRoom.Roomid != "-1")
|
||||
{
|
||||
ShowMessage(ShowMessageType.Warning, "已在房间中,无法创建房间。");
|
||||
return;
|
||||
}
|
||||
GameModule? module = RunTime.GameModuleLoader?[gameModule];
|
||||
if (module is null)
|
||||
GameModule? mode = RunTime.GameModuleLoader?.Modules.Values.FirstOrDefault() ?? default;
|
||||
if (mode is null)
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, ">> 缺少" + Config.FunGame_RoomType + "所需的模组,无法创建房间。");
|
||||
return;
|
||||
}
|
||||
string gameModuleServer = module.AssociatedServerModuleName;
|
||||
Room room = await InvokeController_CreateRoom(roomType, gameModuleServer, gameMap, isRank, module.MaxUsers, password);
|
||||
Room room = await InvokeController_CreateRoom(RoomType, GameModule, GameMap, IsRank, Password);
|
||||
if (MainController is not null && room.Roomid != "-1")
|
||||
{
|
||||
await MainController.UpdateRoomAsync();
|
||||
@ -1075,12 +1088,12 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
string modmap = ComboGameMap.SelectedItem?.ToString() ?? all;
|
||||
if (RunTime.GameModuleLoader is null || (modname != all && !RunTime.GameModuleLoader.Modules.ContainsKey(modname)))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "模组未正确加载,无法创建房间。");
|
||||
ShowMessage(ShowMessageType.Error, ">> 模组未正确加载,无法创建房间。");
|
||||
return;
|
||||
}
|
||||
if (RunTime.GameModuleLoader is null || (modmap != all && !RunTime.GameModuleLoader.Maps.ContainsKey(modmap)))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "地图未正确加载,无法创建房间。");
|
||||
ShowMessage(ShowMessageType.Error, ">> 地图未正确加载,无法创建房间。");
|
||||
return;
|
||||
}
|
||||
// 开始匹配
|
||||
@ -1127,12 +1140,12 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
}
|
||||
if (RunTime.GameModuleLoader is null || (modname != all && !RunTime.GameModuleLoader.Modules.ContainsKey(modname)))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "模组未正确加载,无法创建房间。");
|
||||
ShowMessage(ShowMessageType.Error, ">> 模组未正确加载,无法创建房间。");
|
||||
return;
|
||||
}
|
||||
if (RunTime.GameModuleLoader is null || (modmap != all && !RunTime.GameModuleLoader.Maps.ContainsKey(modmap)))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "地图未正确加载,无法创建房间。");
|
||||
ShowMessage(ShowMessageType.Error, ">> 地图未正确加载,无法创建房间。");
|
||||
return;
|
||||
}
|
||||
if (CheckHasPass.Checked)
|
||||
@ -1152,25 +1165,21 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void QuitRoom_Click(object sender, EventArgs e)
|
||||
private async void QuitRoom_Click(object sender, EventArgs e)
|
||||
{
|
||||
string roomid = Usercfg.InRoom.Roomid;
|
||||
bool isMaster = Usercfg.InRoom.RoomMaster?.Id == Usercfg.LoginUser.Id;
|
||||
bool result = false;
|
||||
TaskUtility.NewTask(async () =>
|
||||
{
|
||||
if (await InvokeController_QuitRoom(Usercfg.InRoom, isMaster))
|
||||
{
|
||||
WritelnGameInfo(DateTimeUtility.GetNowShortTime() + " 离开房间");
|
||||
WritelnGameInfo("[ " + Usercfg.LoginUserName + " ] 已离开房间 -> [ " + roomid + " ]");
|
||||
InvokeUpdateUI(InMain);
|
||||
InMain();
|
||||
_ = MainController?.UpdateRoomAsync();
|
||||
result = true;
|
||||
}
|
||||
}).OnCompleted(() =>
|
||||
else
|
||||
{
|
||||
if (!result) ShowMessage(ShowMessageType.Error, "无法退出房间!", "退出房间");
|
||||
});
|
||||
ShowMessage(ShowMessageType.Error, "无法退出房间!", "退出房间");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1199,9 +1208,9 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void QueryRoom_Click(object sender, EventArgs e)
|
||||
private async void QueryRoom_Click(object sender, EventArgs e)
|
||||
{
|
||||
TaskUtility.NewTask(async () => await JoinRoom(RoomText.Text));
|
||||
await JoinRoom(RoomText.Text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1280,7 +1289,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
SetRoomTypeString();
|
||||
ComboGameMap.Items.Clear();
|
||||
ComboGameMap.Items.AddRange(Constant.SupportedGameMap(mod));
|
||||
ComboGameMap.SelectedItem = mod.DefaultMap;
|
||||
ComboGameMap.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1299,8 +1308,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
{
|
||||
if (RoomList.SelectedItem != null)
|
||||
{
|
||||
int selected = RoomList.SelectedIndex;
|
||||
TaskUtility.NewTask(async () => await JoinRoom(selected));
|
||||
TaskUtility.NewTask(async () => await JoinRoom(RoomList.SelectedIndex));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1347,13 +1355,13 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void RoomText_KeyUp(object sender, KeyEventArgs e)
|
||||
private async void RoomText_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
RoomText.ForeColor = Color.Black;
|
||||
if (e.KeyCode.Equals(Keys.Enter))
|
||||
{
|
||||
// 按下回车加入房间
|
||||
TaskUtility.NewTask(async () => await JoinRoom(RoomText.Text));
|
||||
await JoinRoom(RoomText.Text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1403,7 +1411,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// <param name="e"></param>
|
||||
private void Copyright_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
// Copyright 2023 milimoe
|
||||
// Copyright 2022-Present milimoe
|
||||
Process.Start(new ProcessStartInfo("https://github.com/milimoe") { UseShellExecute = true });
|
||||
}
|
||||
|
||||
@ -1561,10 +1569,13 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SucceedCreateRoomEvent(object sender, RoomEventArgs e)
|
||||
{
|
||||
InvokeUpdateUI(() =>
|
||||
{
|
||||
WritelnGameInfo(DateTimeUtility.GetNowShortTime() + " 创建" + e.RoomTypeString + "房间");
|
||||
WritelnGameInfo(">> 创建" + e.RoomTypeString + "房间成功!房间号: " + e.RoomID);
|
||||
ShowMessage(ShowMessageType.General, "创建" + e.RoomTypeString + "房间成功!\n房间号是 -> [ " + e.RoomID + " ]", "创建成功");
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -1632,12 +1643,6 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
if (MainController != null)
|
||||
{
|
||||
if (Usercfg.InRoom.Roomid != "-1")
|
||||
{
|
||||
if (Usercfg.LoginUser.Id == Usercfg.InRoom.RoomMaster.Id)
|
||||
{
|
||||
WritelnGameInfo(">> 房主无法使用此命令。");
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskUtility.NewTask(async () =>
|
||||
{
|
||||
@ -1647,7 +1652,6 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else WritelnGameInfo(">> 不在房间中无法使用此命令。");
|
||||
}
|
||||
break;
|
||||
@ -1658,12 +1662,6 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
if (MainController != null)
|
||||
{
|
||||
if (Usercfg.InRoom.Roomid != "-1")
|
||||
{
|
||||
if (Usercfg.LoginUser.Id == Usercfg.InRoom.RoomMaster.Id)
|
||||
{
|
||||
WritelnGameInfo(">> 房主无法使用此命令。");
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskUtility.NewTask(async () =>
|
||||
{
|
||||
@ -1673,7 +1671,6 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else WritelnGameInfo(">> 不在房间中无法使用此命令。");
|
||||
}
|
||||
break;
|
||||
@ -1821,7 +1818,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
OnBeforeConnectEvent(this, EventArgs);
|
||||
RunTime.PluginLoader?.OnBeforeConnectEvent(this, EventArgs);
|
||||
if (EventArgs.Cancel) return;
|
||||
result = RunTime.Controller?.Connect(RunTime.Session.Server_Address, RunTime.Session.Server_Port) ?? result;
|
||||
result = RunTime.Controller?.Connect(TransmittalType.Socket, RunTime.Session.Server_Address, RunTime.Session.Server_Port) ?? result;
|
||||
EventArgs.ConnectResult = result;
|
||||
}).OnCompleted(() =>
|
||||
{
|
||||
@ -1989,9 +1986,9 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Room> InvokeController_CreateRoom(RoomType roomType, string gameModuleServer, string gameMap, bool isRank, int maxUsers,string password = "")
|
||||
public async Task<Room> InvokeController_CreateRoom(RoomType RoomType, string GameModule, string GameMap, bool IsRank, string Password = "")
|
||||
{
|
||||
RoomEventArgs EventArgs = new(roomType, password);
|
||||
RoomEventArgs EventArgs = new(RoomType, Password);
|
||||
Room room = General.HallInstance;
|
||||
|
||||
try
|
||||
@ -2000,7 +1997,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
RunTime.PluginLoader?.OnBeforeCreateRoomEvent(this, EventArgs);
|
||||
if (EventArgs.Cancel) return room;
|
||||
|
||||
room = MainController is null ? room : await MainController.CreateRoomAsync(roomType, gameModuleServer, gameMap, isRank, maxUsers, password);
|
||||
room = MainController is null ? room : await MainController.CreateRoomAsync(RoomType, GameModule, GameMap, IsRank, 8, Password);
|
||||
|
||||
if (room.Roomid != "-1")
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using System.ComponentModel;
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
using Milimoe.FunGame.Core.Library.Exception;
|
||||
@ -10,6 +11,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
{
|
||||
public partial class Register : BaseReg
|
||||
{
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
public bool CheckReg { get; set; } = false;
|
||||
|
||||
private readonly RegisterController RegController;
|
||||
@ -28,77 +30,10 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
SucceedReg += SucceedRegEvent;
|
||||
}
|
||||
|
||||
private async Task<bool> Reg_Handler()
|
||||
private async Task<bool> Reg_HandlerAsync(string username, string password, string email)
|
||||
{
|
||||
try
|
||||
{
|
||||
string username = "";
|
||||
string password = "";
|
||||
string checkpassword = "";
|
||||
string email = "";
|
||||
InvokeUpdateUI(() =>
|
||||
{
|
||||
username = UsernameText.Text.Trim();
|
||||
password = PasswordText.Text.Trim();
|
||||
checkpassword = CheckPasswordText.Text.Trim();
|
||||
email = EmailText.Text.Trim();
|
||||
});
|
||||
if (username != "")
|
||||
{
|
||||
if (NetworkUtility.IsUserName(username))
|
||||
{
|
||||
int length = NetworkUtility.GetUserNameLength(username);
|
||||
if (length >= 3 && length <= 12) // 字节范围 3~12
|
||||
{
|
||||
if (password != checkpassword)
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "两个密码不相同,请重新输入!");
|
||||
InvokeUpdateUI(() => CheckPasswordText.Focus());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "账号名长度不符合要求:3~12个字符数(一个中文2个字符)");
|
||||
InvokeUpdateUI(() => UsernameText.Focus());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "账号名不符合要求:不能包含特殊字符");
|
||||
InvokeUpdateUI(() => UsernameText.Focus());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (password != "")
|
||||
{
|
||||
int length = password.Length;
|
||||
if (length < 6 || length > 15) // 字节范围 6~15
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "密码长度不符合要求:6~15个字符数");
|
||||
InvokeUpdateUI(() => PasswordText.Focus());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (username == "" || password == "" || checkpassword == "")
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "请将账号和密码填写完整!");
|
||||
InvokeUpdateUI(() => UsernameText.Focus());
|
||||
return false;
|
||||
}
|
||||
if (email == "")
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "邮箱不能为空!");
|
||||
InvokeUpdateUI(() => EmailText.Focus());
|
||||
return false;
|
||||
}
|
||||
if (!NetworkUtility.IsEmail(email))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "这不是一个邮箱地址!");
|
||||
InvokeUpdateUI(() => EmailText.Focus());
|
||||
return false;
|
||||
}
|
||||
return await RegController.RegAsync(username, password, email);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -108,35 +43,98 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ExitButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
private void SucceedRegEvent(object sender, GeneralEventArgs e)
|
||||
private async void SucceedRegEvent(object sender, GeneralEventArgs e)
|
||||
{
|
||||
string username = ((RegisterEventArgs)e).Username;
|
||||
string password = ((RegisterEventArgs)e).Password;
|
||||
TaskUtility.NewTask(async () => await LoginController.LoginAccountAsync(username, password, encrypt: false));
|
||||
if (RunTime.Login != null)
|
||||
await LoginController.LoginAccountAsync(username, password, encrypt: false);
|
||||
RunTime.Login?.Dispose();
|
||||
}
|
||||
|
||||
private async void RegButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
RunTime.Login.InvokeUpdateUI(RunTime.Login.Close);
|
||||
RegButton.Enabled = false;
|
||||
|
||||
string username = UsernameText.Text.Trim();
|
||||
string password = PasswordText.Text.Trim();
|
||||
string checkpassword = CheckPasswordText.Text.Trim();
|
||||
string email = EmailText.Text.Trim();
|
||||
|
||||
if (!ValidateInput(username, password, checkpassword, email))
|
||||
{
|
||||
RegButton.Enabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
bool result = await Reg_HandlerAsync(username, password, email);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
RegButton.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void RegButton_Click(object sender, EventArgs e)
|
||||
private bool ValidateInput(string username, string password, string checkpassword, string email)
|
||||
{
|
||||
RegButton.Enabled = false;
|
||||
TaskUtility.NewTask(async () =>
|
||||
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(checkpassword))
|
||||
{
|
||||
if (!await Reg_Handler()) InvokeUpdateUI(() => RegButton.Enabled = true);
|
||||
else InvokeUpdateUI(Close);
|
||||
});
|
||||
ShowMessage(ShowMessageType.Error, "请将账号和密码填写完整!");
|
||||
UsernameText.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(email))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "邮箱不能为空!");
|
||||
EmailText.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!NetworkUtility.IsUserName(username))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "账号名不符合要求:不能包含特殊字符");
|
||||
UsernameText.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
int usernameLength = NetworkUtility.GetUserNameLength(username);
|
||||
if (usernameLength < 3 || usernameLength > 12)
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "账号名长度不符合要求:3~12个字符数(一个中文2个字符)");
|
||||
UsernameText.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (password != checkpassword)
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "两个密码不相同,请重新输入!");
|
||||
CheckPasswordText.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (password.Length < 6 || password.Length > 15)
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "密码长度不符合要求:6~15个字符数");
|
||||
PasswordText.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!NetworkUtility.IsEmail(email))
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, "这不是一个邮箱地址!");
|
||||
EmailText.Focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GoToLogin_Click(object sender, EventArgs e)
|
||||
|
@ -8,7 +8,7 @@ namespace Milimoe.FunGame.Desktop.Utility
|
||||
{
|
||||
public class OpenForm
|
||||
{
|
||||
public static List<Form> Forms { get; } = new();
|
||||
public static List<Form> Forms { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@ -86,8 +86,9 @@ namespace Milimoe.FunGame.Desktop.Utility
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Singleton.Add(form))
|
||||
if (!Singleton.IsExist(form))
|
||||
{
|
||||
Singleton.AddOrUpdate(form);
|
||||
if (opentype == OpenFormType.Dialog) form.ShowDialog();
|
||||
else form.Show();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Company>Milimoe</Company>
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="FunGame.Core">
|
||||
<HintPath>..\..\FunGame.Core\bin\Debug\net8.0\FunGame.Core.dll</HintPath>
|
||||
<HintPath>..\..\FunGame.Core\bin\Debug\net9.0\FunGame.Core.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user