修复BUG和事件改进

This commit is contained in:
Mili 2023-03-06 21:34:26 +08:00
parent 14c4cdb48f
commit 618f9c93c9
8 changed files with 26 additions and 15 deletions

View File

@ -9,7 +9,7 @@ namespace Milimoe.FunGame.Desktop.Controller
{
public static bool LoginAccount(params object[]? objs)
{
RunTime.Login?.OnBeforeLoginEvent(new GeneralEventArgs());
if (RunTime.Login?.OnBeforeLoginEvent(new GeneralEventArgs()) == Core.Library.Constant.EventResult.Fail) return false;
bool result = LoginModel.LoginAccount(objs);
if (!result)
{

View File

@ -46,7 +46,7 @@ namespace Milimoe.FunGame.Desktop.Controller
break;
case MainInvokeType.Disconnect:
Main.OnBeforeDisconnectEvent(new GeneralEventArgs());
if (Main.OnBeforeDisconnectEvent(new GeneralEventArgs()) == EventResult.Fail) return (T)result;
MainModel.Disconnect();
break;
@ -72,7 +72,7 @@ namespace Milimoe.FunGame.Desktop.Controller
break;
case MainInvokeType.LogOut:
Main.OnBeforeLogoutEvent(new GeneralEventArgs());
if (Main.OnBeforeLogoutEvent(new GeneralEventArgs()) == EventResult.Fail) return (T)result;
result = MainModel.LogOut();
break;
@ -81,12 +81,12 @@ namespace Milimoe.FunGame.Desktop.Controller
break;
case MainInvokeType.IntoRoom:
Main.OnBeforeIntoRoomEvent(new GeneralEventArgs());
if (Main.OnBeforeIntoRoomEvent(new GeneralEventArgs()) == EventResult.Fail) return (T)result;
result = MainModel.IntoRoom();
break;
case MainInvokeType.Chat:
Main.OnBeforeSendTalkEvent(new GeneralEventArgs());
if (Main.OnBeforeSendTalkEvent(new GeneralEventArgs()) == EventResult.Fail) return (T)result;
if (args != null && args.Length > 0)
result = MainModel.Chat((string)args[0]);
break;

View File

@ -3,10 +3,11 @@ using Milimoe.FunGame.Desktop.Library;
using Milimoe.FunGame.Desktop.Model;
using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Desktop.UI;
using Milimoe.FunGame.Desktop.Library.Interface;
namespace Milimoe.FunGame.Desktop.Controller
{
public class RegisterController
public class RegisterController : ISocketCallBack
{
private readonly Register Register;
private readonly RegisterModel RegModel;
@ -24,7 +25,7 @@ namespace Milimoe.FunGame.Desktop.Controller
public bool Reg(params object[]? objs)
{
Register.OnBeforeRegEvent(Register.EventArgs);
if (Register.OnBeforeRegEvent(Register.EventArgs) == EventResult.Fail) return false;
bool result = RegModel.Reg(objs);
if (!result)
{

View File

@ -0,0 +1,9 @@
using Milimoe.FunGame.Core.Library.Constant;
namespace Milimoe.FunGame.Desktop.Library.Interface
{
public interface ISocketCallBack
{
public void SocketHandler(SocketMessageType type, params object[]? objs);
}
}

View File

@ -105,7 +105,7 @@ namespace Milimoe.FunGame.Desktop.Model
public ConnectResult Connect()
{
Main.OnBeforeConnectEvent(new GeneralEventArgs());
if (Main.OnBeforeConnectEvent(new GeneralEventArgs()) == EventResult.Fail) return ConnectResult.ConnectFailed;
if (Constant.Server_Address == "" || Constant.Server_Port <= 0)
{
ShowMessage.ErrorMessage("查找可用的服务器失败!");

View File

@ -3,11 +3,12 @@ using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Core.Library.Exception;
using Milimoe.FunGame.Desktop.Library;
using Milimoe.FunGame.Desktop.Library.Component;
using Milimoe.FunGame.Desktop.Library.Interface;
using Milimoe.FunGame.Desktop.UI;
namespace Milimoe.FunGame.Desktop.Model
{
public class RegisterModel
public class RegisterModel : ISocketCallBack
{
private readonly Register Register;
@ -78,7 +79,7 @@ namespace Milimoe.FunGame.Desktop.Model
}
catch (Exception e)
{
e.GetErrorInfo();
RunTime.WritelnSystemInfo(e.GetErrorInfo());
}
return false;
}
@ -107,7 +108,7 @@ namespace Milimoe.FunGame.Desktop.Model
}
catch (Exception e)
{
e.GetErrorInfo();
RunTime.WritelnSystemInfo(e.GetErrorInfo());
}
return false;
}

View File

@ -93,7 +93,7 @@ namespace Milimoe.FunGame.Desktop.UI
private EventResult BeforeLoginEvent(object sender, GeneralEventArgs e)
{
RunTime.Main?.OnBeforeLoginEvent(e);
if (RunTime.Main?.OnBeforeLoginEvent(e) == EventResult.Fail) return EventResult.Fail;
return EventResult.Success;
}

View File

@ -6,11 +6,11 @@ using Milimoe.FunGame.Desktop.Controller;
using Milimoe.FunGame.Desktop.Library;
using Milimoe.FunGame.Desktop.Library.Base;
using Milimoe.FunGame.Desktop.Library.Component;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
using Milimoe.FunGame.Desktop.Library.Interface;
namespace Milimoe.FunGame.Desktop.UI
{
public partial class Register : BaseReg
public partial class Register : BaseReg, ISocketCallBack
{
public bool CheckReg { get; set; } = false;
public RegisterEventArgs EventArgs { get; set; } = new RegisterEventArgs();
@ -59,7 +59,7 @@ namespace Milimoe.FunGame.Desktop.UI
if (password != "")
{
int length = password.Length;
if (length >= 6 && length <= 15) // 字节范围 3~12
if (length < 6 || length > 15) // 字节范围 3~12
{
ShowMessage.ErrorMessage("密码长度不符合要求6~15个字符数");
PasswordText.Focus();