mirror of
https://github.com/project-redbud/FunGame-Desktop.git
synced 2025-04-22 04:59:34 +08:00
parent
c1bfd1e106
commit
09b2029955
@ -1,4 +1,5 @@
|
|||||||
using Milimoe.FunGame.Core.Library.Common.Event;
|
using Milimoe.FunGame.Core.Api.Transmittal;
|
||||||
|
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;
|
||||||
@ -20,30 +21,13 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
RunTimeModel = new RunTimeModel(Main);
|
RunTimeModel = new RunTimeModel(Main);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<bool> GetServerConnection()
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
RunTimeModel.GetServerConnection();
|
|
||||||
result = await Connect() == ConnectResult.Success;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Main.GetMessage(e.GetErrorInfo(), TimeType.None);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task<ConnectResult> Connect()
|
public override async Task<ConnectResult> Connect()
|
||||||
{
|
{
|
||||||
ConnectResult result = ConnectResult.ConnectFailed;
|
ConnectResult result = ConnectResult.ConnectFailed;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ConnectEventArgs EventArgs = new(Constant.Server_IP, Constant.Server_Port);
|
ConnectEventArgs EventArgs = new(RunTime.Session.Server_IP, RunTime.Session.Server_Port);
|
||||||
if (Main.OnBeforeConnectEvent(EventArgs) == EventResult.Fail) return ConnectResult.ConnectFailed;
|
if (Main.OnBeforeConnectEvent(EventArgs) == EventResult.Fail) return ConnectResult.ConnectFailed;
|
||||||
|
|
||||||
result = await RunTimeModel.Connect();
|
result = await RunTimeModel.Connect();
|
||||||
@ -121,5 +105,11 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
{
|
{
|
||||||
Main?.GetMessage(msg);
|
Main?.GetMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override DataRequest NewDataRequest(DataRequestType RequestType)
|
||||||
|
{
|
||||||
|
DataRequest? request = RunTimeModel?.NewDataRequest(RequestType);
|
||||||
|
return request is null ? throw new ConnectFailedException() : request;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,19 +2,112 @@
|
|||||||
{
|
{
|
||||||
public class Config
|
public class Config
|
||||||
{
|
{
|
||||||
public static bool FunGame_isAutoConnect { get; set; } = true; // 是否自动连接服务器
|
/// <summary>
|
||||||
public static bool FunGame_isAutoLogin { get; set; } = false; // 是否自动登录
|
/// 是否自动连接服务器
|
||||||
public static bool FunGame_isMatching { get; set; } = false; // 是否在匹配中
|
/// </summary>
|
||||||
public static bool FunGame_isConnected { get; set; } = false; // 是否连接上服务器
|
public static bool FunGame_isAutoConnect
|
||||||
public static bool FunGame_isRetrying { get; set; } = false; // 是否正在重连
|
{
|
||||||
public static bool FunGame_isAutoRetry { get; set; } = true; // 是否自动重连
|
get => RunTime.Config.FunGame_isAutoConnect;
|
||||||
public static bool Match_Mix { get; set; } = false; // 混战模式选项
|
set => RunTime.Config.FunGame_isAutoConnect = value;
|
||||||
public static bool Match_Team { get; set; } = false; // 团队模式选项
|
}
|
||||||
public static bool Match_HasPass { get; set; } = false; // 密码房间选项
|
|
||||||
public static string FunGame_ServerName { get; set; } = ""; // 服务器名称
|
/// <summary>
|
||||||
public static string FunGame_Notice { get; set; } = ""; // 公告
|
/// 是否自动登录
|
||||||
public static string FunGame_AutoLoginUser { get; set; } = ""; // 自动登录的账号
|
/// </summary>
|
||||||
public static string FunGame_AutoLoginPassword { get; set; } = ""; // 自动登录的密码
|
public static bool FunGame_isAutoLogin
|
||||||
public static string FunGame_AutoLoginKey { get; set; } = ""; // 自动登录的秘钥
|
{
|
||||||
|
get => RunTime.Config.FunGame_isAutoLogin;
|
||||||
|
set => RunTime.Config.FunGame_isAutoLogin = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否在匹配中
|
||||||
|
/// </summary>
|
||||||
|
public static bool FunGame_isMatching
|
||||||
|
{
|
||||||
|
get => RunTime.Config.FunGame_isMatching;
|
||||||
|
set => RunTime.Config.FunGame_isMatching = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否连接上服务器
|
||||||
|
/// </summary>
|
||||||
|
public static bool FunGame_isConnected
|
||||||
|
{
|
||||||
|
get => RunTime.Config.FunGame_isConnected;
|
||||||
|
set => RunTime.Config.FunGame_isConnected = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否正在重连
|
||||||
|
/// </summary>
|
||||||
|
public static bool FunGame_isRetrying
|
||||||
|
{
|
||||||
|
get => RunTime.Config.FunGame_isRetrying;
|
||||||
|
set => RunTime.Config.FunGame_isRetrying = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否自动重连
|
||||||
|
/// </summary>
|
||||||
|
public static bool FunGame_isAutoRetry
|
||||||
|
{
|
||||||
|
get => RunTime.Config.FunGame_isAutoRetry;
|
||||||
|
set => RunTime.Config.FunGame_isAutoRetry = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前游戏模式
|
||||||
|
/// </summary>
|
||||||
|
public static string FunGame_GameMode
|
||||||
|
{
|
||||||
|
get => RunTime.Config.FunGame_GameMode;
|
||||||
|
set => RunTime.Config.FunGame_GameMode = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务器名称
|
||||||
|
/// </summary>
|
||||||
|
public static string FunGame_ServerName
|
||||||
|
{
|
||||||
|
get => RunTime.Config.FunGame_ServerName;
|
||||||
|
set => RunTime.Config.FunGame_ServerName = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 公告
|
||||||
|
/// </summary>
|
||||||
|
public static string FunGame_Notice
|
||||||
|
{
|
||||||
|
get => RunTime.Config.FunGame_Notice;
|
||||||
|
set => RunTime.Config.FunGame_Notice = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自动登录的账号
|
||||||
|
/// </summary>
|
||||||
|
public static string FunGame_AutoLoginUser
|
||||||
|
{
|
||||||
|
get => RunTime.Config.FunGame_AutoLoginUser;
|
||||||
|
set => RunTime.Config.FunGame_AutoLoginUser = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自动登录的密码
|
||||||
|
/// </summary>
|
||||||
|
public static string FunGame_AutoLoginPassword
|
||||||
|
{
|
||||||
|
get => RunTime.Config.FunGame_AutoLoginPassword;
|
||||||
|
set => RunTime.Config.FunGame_AutoLoginPassword = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自动登录的秘钥
|
||||||
|
/// </summary>
|
||||||
|
public static string FunGame_AutoLoginKey
|
||||||
|
{
|
||||||
|
get => RunTime.Config.FunGame_AutoLoginKey;
|
||||||
|
set => RunTime.Config.FunGame_AutoLoginKey = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,6 @@ namespace Milimoe.FunGame.Desktop.Library
|
|||||||
*/
|
*/
|
||||||
public static int FunGameType { get; } = (int)FunGameInfo.FunGame.FunGame_Desktop;
|
public static int FunGameType { get; } = (int)FunGameInfo.FunGame.FunGame_Desktop;
|
||||||
|
|
||||||
/**
|
|
||||||
* Socket Configs
|
|
||||||
*/
|
|
||||||
public static string Server_IP { get; set; } = ""; // 服务器IP地址
|
|
||||||
public static int Server_Port { get; set; } = 0; // 服务器端口号
|
|
||||||
public static Encoding Default_Encoding { get; } = General.DefaultEncoding;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FunGame Configs
|
* FunGame Configs
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Milimoe.FunGame.Core.Api.Transmittal;
|
using Milimoe.FunGame.Core.Api.Transmittal;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
using Milimoe.FunGame.Desktop.Model;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Desktop.Library
|
namespace Milimoe.FunGame.Desktop.Library
|
||||||
{
|
{
|
||||||
@ -11,6 +12,7 @@ namespace Milimoe.FunGame.Desktop.Library
|
|||||||
{
|
{
|
||||||
public static Core.Model.RoomList RoomList { get; } = new();
|
public static Core.Model.RoomList RoomList { get; } = new();
|
||||||
public static Core.Model.Session Session { get; } = new();
|
public static Core.Model.Session Session { get; } = new();
|
||||||
|
public static Core.Model.FunGameConfig Config { get; } = new();
|
||||||
public static Core.Library.Common.Network.Socket? Socket { get; set; } = null;
|
public static Core.Library.Common.Network.Socket? Socket { get; set; } = null;
|
||||||
public static Controller.RunTimeController? Controller { get; set; } = null;
|
public static Controller.RunTimeController? Controller { get; set; } = null;
|
||||||
public static UI.Main? Main { get; set; } = null;
|
public static UI.Main? Main { get; set; } = null;
|
||||||
@ -28,12 +30,8 @@ namespace Milimoe.FunGame.Desktop.Library
|
|||||||
|
|
||||||
public static DataRequest NewDataRequest(DataRequestType RequestType)
|
public static DataRequest NewDataRequest(DataRequestType RequestType)
|
||||||
{
|
{
|
||||||
if (Socket != null)
|
DataRequest? request = Controller?.NewDataRequest(RequestType);
|
||||||
{
|
return request is null ? throw new ConnectFailedException() : request;
|
||||||
DataRequest request = new(Socket, RequestType);
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
throw new ConnectFailedException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.Common.Network;
|
using Milimoe.FunGame.Core.Library.Common.Network;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Core.Library.Exception;
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
@ -14,8 +13,6 @@ namespace Milimoe.FunGame.Desktop.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RunTimeModel : Core.Model.RunTime
|
public class RunTimeModel : Core.Model.RunTime
|
||||||
{
|
{
|
||||||
public override Socket? Socket => _Socket;
|
|
||||||
|
|
||||||
private readonly Main Main;
|
private readonly Main Main;
|
||||||
private readonly Core.Model.Session Usercfg = RunTime.Session;
|
private readonly Core.Model.Session Usercfg = RunTime.Session;
|
||||||
|
|
||||||
@ -26,11 +23,15 @@ namespace Milimoe.FunGame.Desktop.Model
|
|||||||
|
|
||||||
public override async Task<ConnectResult> Connect()
|
public override async Task<ConnectResult> Connect()
|
||||||
{
|
{
|
||||||
if (Constant.Server_IP == "" || Constant.Server_Port <= 0)
|
if (RunTime.Session.Server_IP == "" || RunTime.Session.Server_Port <= 0)
|
||||||
|
{
|
||||||
|
(RunTime.Session.Server_IP, RunTime.Session.Server_Port) = GetServerAddress();
|
||||||
|
if (RunTime.Session.Server_IP == "" || RunTime.Session.Server_Port <= 0)
|
||||||
{
|
{
|
||||||
ShowMessage.ErrorMessage("查找可用的服务器失败!");
|
ShowMessage.ErrorMessage("查找可用的服务器失败!");
|
||||||
return ConnectResult.FindServerFailed;
|
return ConnectResult.FindServerFailed;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Config.FunGame_isRetrying)
|
if (Config.FunGame_isRetrying)
|
||||||
@ -52,7 +53,7 @@ namespace Milimoe.FunGame.Desktop.Model
|
|||||||
// 与服务器建立连接
|
// 与服务器建立连接
|
||||||
Socket?.Close();
|
Socket?.Close();
|
||||||
Config.FunGame_isRetrying = true;
|
Config.FunGame_isRetrying = true;
|
||||||
_Socket = Socket.Connect(Constant.Server_IP, Constant.Server_Port);
|
_Socket = Socket.Connect(RunTime.Session.Server_IP, RunTime.Session.Server_Port);
|
||||||
if (Socket != null && Socket.Connected)
|
if (Socket != null && Socket.Connected)
|
||||||
{
|
{
|
||||||
// 设置可复用Socket
|
// 设置可复用Socket
|
||||||
@ -106,38 +107,10 @@ namespace Milimoe.FunGame.Desktop.Model
|
|||||||
{
|
{
|
||||||
Main.GetMessage(e.GetErrorInfo(), TimeType.None);
|
Main.GetMessage(e.GetErrorInfo(), TimeType.None);
|
||||||
Main.UpdateUI(MainInvokeType.Disconnected);
|
Main.UpdateUI(MainInvokeType.Disconnected);
|
||||||
Main.OnFailedConnectEvent(new ConnectEventArgs(Constant.Server_IP, Constant.Server_Port));
|
Main.OnFailedConnectEvent(new ConnectEventArgs(RunTime.Session.Server_IP, RunTime.Session.Server_Port));
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void GetServerConnection()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// 获取服务器IP
|
|
||||||
string? ipaddress = (string?)Implement.GetFunGameImplValue(InterfaceType.IClient, InterfaceMethod.RemoteServerIP);
|
|
||||||
if (ipaddress != null)
|
|
||||||
{
|
|
||||||
string[] s = ipaddress.Split(':');
|
|
||||||
if (s != null && s.Length > 1)
|
|
||||||
{
|
|
||||||
Constant.Server_IP = s[0];
|
|
||||||
Constant.Server_Port = Convert.ToInt32(s[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ShowMessage.ErrorMessage("查找可用的服务器失败!");
|
|
||||||
Config.FunGame_isRetrying = false;
|
|
||||||
throw new FindServerFailedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Main.GetMessage(e.GetErrorInfo(), TimeType.None);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool SocketHandler_Connect(SocketObject ServerMessage)
|
protected override bool SocketHandler_Connect(SocketObject ServerMessage)
|
||||||
{
|
{
|
||||||
string msg = "";
|
string msg = "";
|
||||||
|
6
FunGame.Desktop/UI/Main/Main.Designer.cs
generated
6
FunGame.Desktop/UI/Main/Main.Designer.cs
generated
@ -204,7 +204,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
CheckMix.Text = "混战模式房间";
|
CheckMix.Text = "混战模式房间";
|
||||||
CheckMix.TextAlign = ContentAlignment.BottomLeft;
|
CheckMix.TextAlign = ContentAlignment.BottomLeft;
|
||||||
CheckMix.UseVisualStyleBackColor = false;
|
CheckMix.UseVisualStyleBackColor = false;
|
||||||
CheckMix.CheckedChanged += CheckMix_CheckedChanged;
|
CheckMix.CheckedChanged += CheckGameMode_CheckedChanged;
|
||||||
//
|
//
|
||||||
// CheckTeam
|
// CheckTeam
|
||||||
//
|
//
|
||||||
@ -217,7 +217,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
CheckTeam.Text = "团队模式房间";
|
CheckTeam.Text = "团队模式房间";
|
||||||
CheckTeam.TextAlign = ContentAlignment.BottomLeft;
|
CheckTeam.TextAlign = ContentAlignment.BottomLeft;
|
||||||
CheckTeam.UseVisualStyleBackColor = false;
|
CheckTeam.UseVisualStyleBackColor = false;
|
||||||
CheckTeam.CheckedChanged += CheckTeam_CheckedChanged;
|
CheckTeam.CheckedChanged += CheckGameMode_CheckedChanged;
|
||||||
//
|
//
|
||||||
// RoomSetting
|
// RoomSetting
|
||||||
//
|
//
|
||||||
@ -491,7 +491,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
CheckHasPass.Text = "带密码的房间";
|
CheckHasPass.Text = "带密码的房间";
|
||||||
CheckHasPass.TextAlign = ContentAlignment.BottomLeft;
|
CheckHasPass.TextAlign = ContentAlignment.BottomLeft;
|
||||||
CheckHasPass.UseVisualStyleBackColor = false;
|
CheckHasPass.UseVisualStyleBackColor = false;
|
||||||
CheckHasPass.CheckedChanged += CheckHasPass_CheckedChanged;
|
CheckHasPass.CheckedChanged += CheckGameMode_CheckedChanged;
|
||||||
//
|
//
|
||||||
// Stock
|
// Stock
|
||||||
//
|
//
|
||||||
|
@ -64,7 +64,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Config.FunGame_isAutoConnect) RunTime.Controller?.GetServerConnection();
|
if (Config.FunGame_isAutoConnect) RunTime.Controller?.Connect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
|
|
||||||
case MainInvokeType.SetGreenAndPing:
|
case MainInvokeType.SetGreenAndPing:
|
||||||
Config.FunGame_isRetrying = false;
|
Config.FunGame_isRetrying = false;
|
||||||
SetServerStatusLight((int)LightType.Green, ping: NetworkUtility.GetServerPing(Constant.Server_IP));
|
SetServerStatusLight((int)LightType.Green, ping: NetworkUtility.GetServerPing(RunTime.Session.Server_IP));
|
||||||
SetButtonEnableIfLogon(true, ClientState.Online);
|
SetButtonEnableIfLogon(true, ClientState.Online);
|
||||||
Config.FunGame_isConnected = true;
|
Config.FunGame_isConnected = true;
|
||||||
CurrentRetryTimes = 0;
|
CurrentRetryTimes = 0;
|
||||||
@ -900,13 +900,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
WritelnGameInfo(DateTimeUtility.GetNowShortTime() + " 开始匹配");
|
WritelnGameInfo(DateTimeUtility.GetNowShortTime() + " 开始匹配");
|
||||||
WritelnGameInfo("[ " + Usercfg.LoginUserName + " ] 开始匹配");
|
WritelnGameInfo("[ " + Usercfg.LoginUserName + " ] 开始匹配");
|
||||||
WriteGameInfo(">> 匹配参数:");
|
WriteGameInfo(">> 匹配参数:");
|
||||||
if (!Config.Match_Mix && !Config.Match_Team && !Config.Match_HasPass)
|
WritelnGameInfo(Config.FunGame_GameMode);
|
||||||
WritelnGameInfo("无");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WriteGameInfo((Config.Match_Mix ? " 混战房间 " : "") + (Config.Match_Team ? " 团队房间 " : "") + (Config.Match_HasPass ? " 密码房间 " : ""));
|
|
||||||
WritelnGameInfo();
|
|
||||||
}
|
|
||||||
// 显示停止匹配按钮
|
// 显示停止匹配按钮
|
||||||
StartMatch.Visible = false;
|
StartMatch.Visible = false;
|
||||||
StopMatch.Visible = true;
|
StopMatch.Visible = true;
|
||||||
@ -939,30 +933,13 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private async void CreateRoom_Click(object sender, EventArgs e)
|
private async void CreateRoom_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string roomtype = "";
|
|
||||||
string password = "";
|
string password = "";
|
||||||
if (Config.Match_Mix && Config.Match_Team)
|
if (CheckMix.Checked && CheckTeam.Checked)
|
||||||
{
|
{
|
||||||
ShowMessage.WarningMessage("创建房间不允许同时勾选混战和团队!");
|
ShowMessage.WarningMessage("创建房间不允许同时勾选混战和团队!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (Config.Match_Mix && !Config.Match_Team && !Config.Match_HasPass)
|
if (CheckHasPass.Checked)
|
||||||
{
|
|
||||||
roomtype = GameMode.GameMode_Mix;
|
|
||||||
}
|
|
||||||
else if (!Config.Match_Mix && Config.Match_Team && !Config.Match_HasPass)
|
|
||||||
{
|
|
||||||
roomtype = GameMode.GameMode_Team;
|
|
||||||
}
|
|
||||||
else if (Config.Match_Mix && !Config.Match_Team && Config.Match_HasPass)
|
|
||||||
{
|
|
||||||
roomtype = GameMode.GameMode_MixHasPass;
|
|
||||||
}
|
|
||||||
else if (!Config.Match_Mix && Config.Match_Team && Config.Match_HasPass)
|
|
||||||
{
|
|
||||||
roomtype = GameMode.GameMode_TeamHasPass;
|
|
||||||
}
|
|
||||||
if (Config.Match_HasPass)
|
|
||||||
{
|
{
|
||||||
password = ShowMessage.InputMessage("请输入该房间的密码:", "创建密码房间").Trim();
|
password = ShowMessage.InputMessage("请输入该房间的密码:", "创建密码房间").Trim();
|
||||||
if (password == "" || password.Length > 10)
|
if (password == "" || password.Length > 10)
|
||||||
@ -971,12 +948,12 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (roomtype.Equals(""))
|
if (Config.FunGame_GameMode.Equals(""))
|
||||||
{
|
{
|
||||||
ShowMessage.WarningMessage("请勾选你要创建的房间类型!");
|
ShowMessage.WarningMessage("请勾选你要创建的房间类型!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await CreateRoom_Handler(roomtype, password);
|
await CreateRoom_Handler(Config.FunGame_GameMode, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1094,36 +1071,22 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 勾选混战选项
|
/// 勾选任意模式选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void CheckMix_CheckedChanged(object sender, EventArgs e)
|
private void CheckGameMode_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (CheckMix.Checked) Config.Match_Mix = true;
|
bool IsMix = CheckMix.Checked;
|
||||||
else Config.Match_Mix = false;
|
bool IsTeam = CheckTeam.Checked;
|
||||||
}
|
bool IsHasPass = CheckHasPass.Checked;
|
||||||
|
if (IsMix && IsTeam && !IsHasPass) Config.FunGame_GameMode = GameMode.GameMode_All;
|
||||||
/// <summary>
|
else if (IsMix && IsTeam && IsHasPass) Config.FunGame_GameMode = GameMode.GameMode_AllHasPass;
|
||||||
/// 勾选团队选项
|
else if (IsMix && !IsTeam && !IsHasPass) Config.FunGame_GameMode = GameMode.GameMode_Mix;
|
||||||
/// </summary>
|
else if (IsMix && !IsTeam && IsHasPass) Config.FunGame_GameMode = GameMode.GameMode_MixHasPass;
|
||||||
/// <param name="sender"></param>
|
else if (!IsMix && IsTeam && !IsHasPass) Config.FunGame_GameMode = GameMode.GameMode_Team;
|
||||||
/// <param name="e"></param>
|
else if (!IsMix && IsTeam && IsHasPass) Config.FunGame_GameMode = GameMode.GameMode_TeamHasPass;
|
||||||
private void CheckTeam_CheckedChanged(object sender, EventArgs e)
|
else Config.FunGame_GameMode = GameMode.GameMode_All;
|
||||||
{
|
|
||||||
if (CheckTeam.Checked) Config.Match_Team = true;
|
|
||||||
else Config.Match_Team = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 勾选密码选项
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void CheckHasPass_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (CheckHasPass.Checked) Config.Match_HasPass = true;
|
|
||||||
else Config.Match_HasPass = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1370,7 +1333,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
CurrentRetryTimes = -1;
|
CurrentRetryTimes = -1;
|
||||||
Config.FunGame_isAutoRetry = true;
|
Config.FunGame_isAutoRetry = true;
|
||||||
RunTime.Controller?.GetServerConnection();
|
RunTime.Controller?.Connect();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Constant.FunGame_Disconnect:
|
case Constant.FunGame_Disconnect:
|
||||||
@ -1410,8 +1373,8 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
ErrorType ErrorType = NetworkUtility.IsServerAddress(ip, port);
|
ErrorType ErrorType = NetworkUtility.IsServerAddress(ip, port);
|
||||||
if (ErrorType == Core.Library.Constant.ErrorType.None)
|
if (ErrorType == Core.Library.Constant.ErrorType.None)
|
||||||
{
|
{
|
||||||
Constant.Server_IP = ip;
|
RunTime.Session.Server_IP = ip;
|
||||||
Constant.Server_Port = port;
|
RunTime.Session.Server_Port = port;
|
||||||
CurrentRetryTimes = -1;
|
CurrentRetryTimes = -1;
|
||||||
Config.FunGame_isAutoRetry = true;
|
Config.FunGame_isAutoRetry = true;
|
||||||
RunTime.Controller?.Connect();
|
RunTime.Controller?.Connect();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user