mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 08:09:02 +00:00
CheckLogin
This commit is contained in:
parent
5a516d7242
commit
b1cf47cdcb
@ -11,8 +11,8 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
|||||||
*/
|
*/
|
||||||
[LibraryImport("kernel32", StringMarshalling = StringMarshalling.Utf16)]
|
[LibraryImport("kernel32", StringMarshalling = StringMarshalling.Utf16)]
|
||||||
private static partial long WritePrivateProfileString(string section, string key, string val, string filePath);
|
private static partial long WritePrivateProfileString(string section, string key, string val, string filePath);
|
||||||
[LibraryImport("kernel32", StringMarshalling = StringMarshalling.Utf16)]
|
[LibraryImport("Kernel32.dll", EntryPoint = "GetPrivateProfileStringW", StringMarshalling = StringMarshalling.Utf16)]
|
||||||
private static partial int GetPrivateProfileString(string section, string key, string def, byte[] val, int size, string filePath);
|
private static partial int GetPrivateProfileString(string section, string key, string def, char[] val, int size, string filePath);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 写入ini文件
|
/// 写入ini文件
|
||||||
@ -35,10 +35,10 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
|||||||
/// <returns>读取到的值</returns>
|
/// <returns>读取到的值</returns>
|
||||||
public static string ReadINI(string Section, string Key, string FileName = @"FunGame.ini")
|
public static string ReadINI(string Section, string Key, string FileName = @"FunGame.ini")
|
||||||
{
|
{
|
||||||
byte[] val = new byte[1024];
|
char[] val = new char[2048];
|
||||||
_ = GetPrivateProfileString(Section, Key, "", val, 1024, Environment.CurrentDirectory.ToString() + @"\" + FileName);
|
_ = GetPrivateProfileString(Section, Key, "", val, 2048, Environment.CurrentDirectory.ToString() + @"\" + FileName);
|
||||||
string? read = val.ToString();
|
string? read = new(val);
|
||||||
return read ?? "";
|
return read != null ? read.Trim('\0') : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -7,7 +7,7 @@ namespace Milimoe.FunGame.Core.Library.Constant
|
|||||||
{
|
{
|
||||||
// Static Variable
|
// Static Variable
|
||||||
public static Empty EntityInstance { get; } = new();
|
public static Empty EntityInstance { get; } = new();
|
||||||
public static Encoding DefaultEncoding { get; } = Encoding.UTF8;
|
public static Encoding DefaultEncoding { get; } = Encoding.Unicode;
|
||||||
|
|
||||||
// Const
|
// Const
|
||||||
public const int MaxRetryTimes = 20;
|
public const int MaxRetryTimes = 20;
|
||||||
|
|||||||
@ -1,21 +1,11 @@
|
|||||||
using Milimoe.FunGame.Core.Library.Common.Event;
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
using Milimoe.FunGame.Desktop.Library;
|
using Milimoe.FunGame.Desktop.Library;
|
||||||
using Milimoe.FunGame.Desktop.Library.Interface;
|
|
||||||
using Milimoe.FunGame.Desktop.Model;
|
using Milimoe.FunGame.Desktop.Model;
|
||||||
using Milimoe.FunGame.Desktop.UI;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Desktop.Controller
|
namespace Milimoe.FunGame.Desktop.Controller
|
||||||
{
|
{
|
||||||
public class LoginController : ILogin
|
public class LoginController
|
||||||
{
|
{
|
||||||
private Login Login { get; }
|
|
||||||
|
|
||||||
public LoginController(Login Login)
|
|
||||||
{
|
|
||||||
this.Login = Login;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool LoginAccount(params object[]? objs)
|
public static bool LoginAccount(params object[]? objs)
|
||||||
{
|
{
|
||||||
RunTime.Login?.OnBeforeLoginEvent(new GeneralEventArgs());
|
RunTime.Login?.OnBeforeLoginEvent(new GeneralEventArgs());
|
||||||
@ -28,11 +18,6 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool LoginAccount(string username, string password)
|
|
||||||
{
|
|
||||||
return LoginController.LoginAccount(username, password);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool CheckLogin(params object[]? objs)
|
public static bool CheckLogin(params object[]? objs)
|
||||||
{
|
{
|
||||||
bool result = LoginModel.CheckLogin(objs);
|
bool result = LoginModel.CheckLogin(objs);
|
||||||
@ -46,10 +31,5 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CheckLogin(Guid key)
|
|
||||||
{
|
|
||||||
return LoginController.CheckLogin(key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
namespace Milimoe.FunGame.Desktop.Library.Interface
|
|
||||||
{
|
|
||||||
public interface ILogin
|
|
||||||
{
|
|
||||||
public bool LoginAccount(string username, string password);
|
|
||||||
public bool CheckLogin(Guid key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +1,6 @@
|
|||||||
using Milimoe.FunGame.Core.Library.Common.Event;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
|
||||||
using Milimoe.FunGame.Core.Library.Exception;
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
using Milimoe.FunGame.Desktop.Library;
|
using Milimoe.FunGame.Desktop.Library;
|
||||||
using Milimoe.FunGame.Desktop.Library.Interface;
|
|
||||||
using Milimoe.FunGame.Desktop.UI;
|
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Desktop.Model
|
namespace Milimoe.FunGame.Desktop.Model
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
using Milimoe.FunGame.Core.Library.Exception;
|
|
||||||
using Milimoe.FunGame.Desktop.Controller;
|
using Milimoe.FunGame.Desktop.Controller;
|
||||||
using Milimoe.FunGame.Desktop.Library;
|
using Milimoe.FunGame.Desktop.Library;
|
||||||
using Milimoe.FunGame.Desktop.Library.Base;
|
using Milimoe.FunGame.Desktop.Library.Base;
|
||||||
@ -10,12 +9,9 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
public partial class Login : BaseLogin
|
public partial class Login : BaseLogin
|
||||||
{
|
{
|
||||||
private LoginController LoginController;
|
|
||||||
|
|
||||||
public Login()
|
public Login()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
LoginController = new LoginController(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Login_Handler()
|
private void Login_Handler()
|
||||||
|
|||||||
@ -195,7 +195,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MainSet.SetUser:
|
case MainSet.SetUser:
|
||||||
if (objs != null && objs.Length > 1)
|
if (objs != null && objs.Length > 0)
|
||||||
{
|
{
|
||||||
SetLoginUser(objs);
|
SetLoginUser(objs);
|
||||||
}
|
}
|
||||||
@ -285,15 +285,12 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
|
|
||||||
if (strUserName != null && strUserName.Trim() != "")
|
if (strUserName != null && strUserName.Trim() != "")
|
||||||
Config.FunGame_AutoLoginUser = strUserName.Trim();
|
Config.FunGame_AutoLoginUser = strUserName.Trim();
|
||||||
else throw new ReadConfigException();
|
|
||||||
|
|
||||||
if (strPassword != null && strPassword.Trim() != "")
|
if (strPassword != null && strPassword.Trim() != "")
|
||||||
Config.FunGame_AutoLoginPassword = strPassword.Trim();
|
Config.FunGame_AutoLoginPassword = strPassword.Trim();
|
||||||
else throw new ReadConfigException();
|
|
||||||
|
|
||||||
if (strAutoKey != null && strAutoKey.Trim() != "")
|
if (strAutoKey != null && strAutoKey.Trim() != "")
|
||||||
Config.FunGame_AutoLoginKey = strAutoKey.Trim();
|
Config.FunGame_AutoLoginKey = strAutoKey.Trim();
|
||||||
else throw new ReadConfigException();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user