mirror of
https://github.com/project-redbud/FunGame-Desktop.git
synced 2025-04-20 20:19:34 +08:00
修改部分用法 (#29)
* 修改游戏相关 * 添加禁止房主使用准备和取消准备 * 因底层改动,使用了NewTask的地方都要Invoke。(所以当初一直await不好吗。。)
This commit is contained in:
parent
1e5ee1fc2e
commit
f442d71c41
@ -216,18 +216,19 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Room> CreateRoomAsync(RoomType RoomType, string GameModule, string GameMap, bool IsRank, string Password = "")
|
public async Task<Room> CreateRoomAsync(RoomType roomType, string gameModuleServer, string gameMap, bool isRank, int maxUsers, string password = "")
|
||||||
{
|
{
|
||||||
Room room = General.HallInstance;
|
Room room = General.HallInstance;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateRoomRequest.AddRequestData("roomtype", RoomType);
|
CreateRoomRequest.AddRequestData("roomtype", roomType);
|
||||||
CreateRoomRequest.AddRequestData("gamemodule", GameModule);
|
CreateRoomRequest.AddRequestData("gamemoduleserver", gameModuleServer);
|
||||||
CreateRoomRequest.AddRequestData("gamemap", GameMap);
|
CreateRoomRequest.AddRequestData("gamemap", gameMap);
|
||||||
CreateRoomRequest.AddRequestData("master", Usercfg.LoginUser);
|
CreateRoomRequest.AddRequestData("master", Usercfg.LoginUser);
|
||||||
CreateRoomRequest.AddRequestData("password", Password);
|
CreateRoomRequest.AddRequestData("password", password);
|
||||||
CreateRoomRequest.AddRequestData("isrank", IsRank);
|
CreateRoomRequest.AddRequestData("isrank", isRank);
|
||||||
|
CreateRoomRequest.AddRequestData("maxusers", maxUsers);
|
||||||
await CreateRoomRequest.SendRequestAsync();
|
await CreateRoomRequest.SendRequestAsync();
|
||||||
if (CreateRoomRequest.Result == RequestResult.Success)
|
if (CreateRoomRequest.Result == RequestResult.Success)
|
||||||
{
|
{
|
||||||
@ -242,13 +243,13 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
return room;
|
return room;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> MatchRoomAsync(RoomType RoomType, bool isCancel = false)
|
public async Task<bool> MatchRoomAsync(RoomType roomType, bool isCancel = false)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MatchRoomRequest.AddRequestData("roomtype", RoomType);
|
MatchRoomRequest.AddRequestData("roomtype", roomType);
|
||||||
MatchRoomRequest.AddRequestData("matcher", Usercfg.LoginUser);
|
MatchRoomRequest.AddRequestData("matcher", Usercfg.LoginUser);
|
||||||
MatchRoomRequest.AddRequestData("iscancel", isCancel);
|
MatchRoomRequest.AddRequestData("iscancel", isCancel);
|
||||||
await MatchRoomRequest.SendRequestAsync();
|
await MatchRoomRequest.SendRequestAsync();
|
||||||
|
@ -276,9 +276,9 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
protected override void SocketHandler_Gaming(SocketObject ServerMessage)
|
protected override void SocketHandler_Gaming(SocketObject ServerMessage)
|
||||||
{
|
{
|
||||||
GamingType gamingtype = GamingType.None;
|
GamingType gamingtype = GamingType.None;
|
||||||
Hashtable data = [];
|
Dictionary<string, object> data = [];
|
||||||
if (ServerMessage.Length > 0) gamingtype = ServerMessage.GetParam<GamingType>(0);
|
if (ServerMessage.Length > 0) gamingtype = ServerMessage.GetParam<GamingType>(0);
|
||||||
if (ServerMessage.Length > 1) data = ServerMessage.GetParam<Hashtable>(1) ?? data;
|
if (ServerMessage.Length > 1) data = ServerMessage.GetParam<Dictionary<string, object>>(1) ?? data;
|
||||||
RunTime.Gaming?.GamingHandler(gamingtype, data);
|
RunTime.Gaming?.GamingHandler(gamingtype, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,16 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 委托更新UI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action"></param>
|
||||||
|
public virtual void InvokeUpdateUI(Action action)
|
||||||
|
{
|
||||||
|
if (InvokeRequired) Invoke(action);
|
||||||
|
else action();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 绑定事件,子类需要重写
|
/// 绑定事件,子类需要重写
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -197,16 +207,5 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
|||||||
{
|
{
|
||||||
BindEvent();
|
BindEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 委托更新UI
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="action"></param>
|
|
||||||
protected virtual void InvokeUpdateUI(Action action)
|
|
||||||
{
|
|
||||||
if (InvokeRequired) Invoke(action);
|
|
||||||
else action();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
|||||||
ChangeSecond(msg, autoclose);
|
ChangeSecond(msg, autoclose);
|
||||||
}
|
}
|
||||||
MessageResult = AutoResult;
|
MessageResult = AutoResult;
|
||||||
Close();
|
InvokeUpdateUI(Dispose);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
|||||||
/// <param name="s"></param>
|
/// <param name="s"></param>
|
||||||
private void ChangeSecond(string msg, int s)
|
private void ChangeSecond(string msg, int s)
|
||||||
{
|
{
|
||||||
MsgText.Text = msg + "\n[ " + s + " 秒后自动关闭 ]";
|
InvokeUpdateUI(() => MsgText.Text = msg + "\n[ " + s + " 秒后自动关闭 ]");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LeftButton_Click(object sender, EventArgs e)
|
private void LeftButton_Click(object sender, EventArgs e)
|
||||||
|
@ -122,7 +122,7 @@ namespace Milimoe.FunGame.Desktop.Library
|
|||||||
}
|
}
|
||||||
public static object[] SupportedGameMap(GameModule module)
|
public static object[] SupportedGameMap(GameModule module)
|
||||||
{
|
{
|
||||||
IEnumerable<object> list = module.GameModuleDepend.Maps.Where(map => module.GameModuleDepend.Maps.Contains(map)).Distinct();
|
IEnumerable<object> list = module.GameModuleDepend.Maps.Where(module.GameModuleDepend.Maps.Contains).Select(m => m.Name).Distinct();
|
||||||
if (list.Any()) return AllComboItem.Union(list).ToArray();
|
if (list.Any()) return AllComboItem.Union(list).ToArray();
|
||||||
return ["- 缺少地图 -"];
|
return ["- 缺少地图 -"];
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,17 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
if (RunTime.Socket != null)
|
if (RunTime.Socket != null)
|
||||||
{
|
{
|
||||||
string username = UsernameText.Text.Trim();
|
string username = "";
|
||||||
string email = EmailText.Text.Trim();
|
string email = "";
|
||||||
|
InvokeUpdateUI(() =>
|
||||||
|
{
|
||||||
|
username = UsernameText.Text.Trim();
|
||||||
|
email = EmailText.Text.Trim();
|
||||||
|
});
|
||||||
if (username == "" || email == "")
|
if (username == "" || email == "")
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, "账号或邮箱不能为空!");
|
ShowMessage(ShowMessageType.Error, "账号或邮箱不能为空!");
|
||||||
UsernameText.Focus();
|
InvokeUpdateUI(() => UsernameText.Focus());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +116,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
}
|
}
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
Dispose();
|
InvokeUpdateUI(Dispose);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
result = await Login_Handler();
|
result = await Login_Handler();
|
||||||
}).OnCompleted(() =>
|
}).OnCompleted(() =>
|
||||||
{
|
{
|
||||||
if (result) Dispose();
|
if (result) InvokeUpdateUI(Dispose);
|
||||||
else GoToLogin.Enabled = true;
|
else GoToLogin.Enabled = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -403,9 +403,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void WritelnGameInfo()
|
private void WritelnGameInfo()
|
||||||
{
|
{
|
||||||
GameInfo.AppendText("\n");
|
WritelnGameInfo("\r\n");
|
||||||
GameInfo.SelectionStart = GameInfo.Text.Length - 1;
|
|
||||||
GameInfo.ScrollToCaret();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -416,9 +414,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
if (msg.Trim() != "")
|
if (msg.Trim() != "")
|
||||||
{
|
{
|
||||||
GameInfo.AppendText(msg + "\n");
|
WriteGameInfo(msg + "\r\n");
|
||||||
GameInfo.SelectionStart = GameInfo.Text.Length - 1;
|
|
||||||
GameInfo.ScrollToCaret();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,9 +426,12 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
if (msg.Trim() != "")
|
if (msg.Trim() != "")
|
||||||
{
|
{
|
||||||
GameInfo.AppendText(msg);
|
InvokeUpdateUI(() =>
|
||||||
GameInfo.SelectionStart = GameInfo.Text.Length - 1;
|
{
|
||||||
GameInfo.ScrollToCaret();
|
GameInfo.AppendText(msg);
|
||||||
|
GameInfo.SelectionStart = GameInfo.Text.Length - 1;
|
||||||
|
GameInfo.ScrollToCaret();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,16 +489,16 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
TaskUtility.NewTask(async () =>
|
TaskUtility.NewTask(async () =>
|
||||||
{
|
{
|
||||||
int PlayerCount = users.Count;
|
int PlayerCount = users.Count;
|
||||||
for (int i = 10; i > 0; i--)
|
for (int i = 5; i > 0; i--)
|
||||||
{
|
{
|
||||||
WritelnGameInfo("房间 [ " + room.Roomid + " (" + PlayerCount + "人" + RoomSet.GetTypeString(room.RoomType) + ") ] 的游戏将在" + i + "秒后开始...");
|
WritelnGameInfo("房间 [ " + room.Roomid + " (" + PlayerCount + "人" + RoomSet.GetTypeString(room.RoomType) + ") ] 的游戏将在" + i + "秒后开始...");
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
}
|
}
|
||||||
WritelnGameInfo("房间 [ " + room.Roomid + " (" + PlayerCount + "人" + RoomSet.GetTypeString(room.RoomType) + ") ] 的游戏正式开始!");
|
WritelnGameInfo("房间 [ " + room.Roomid + " (" + PlayerCount + "人" + RoomSet.GetTypeString(room.RoomType) + ") ] 的游戏正式开始!");
|
||||||
if (RunTime.GameModuleLoader?.Modules.ContainsKey(room.GameModule) ?? false)
|
if (RunTime.GameModuleLoader?.Modules.TryGetValue(room.GameModule, out GameModule? module) ?? false && module != null)
|
||||||
{
|
{
|
||||||
RunTime.Gaming = Core.Model.Gaming.StartGame(RunTime.GameModuleLoader[room.GameModule], room, RunTime.Session.LoginUser, users, RunTime.GameModuleLoader);
|
RunTime.Gaming = Core.Model.Gaming.StartGame(module, room, RunTime.Session.LoginUser, users, RunTime.GameModuleLoader);
|
||||||
Visible = false; // 隐藏主界面
|
Visible = !module.HideMain; // 隐藏主界面
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -526,8 +525,8 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
// 恢复界面
|
// 恢复界面
|
||||||
Visible = true;
|
Visible = true;
|
||||||
_InGame = false;
|
|
||||||
SetButtonEnabled(true, ClientState.InRoom);
|
SetButtonEnabled(true, ClientState.InRoom);
|
||||||
|
_InGame = false;
|
||||||
OnSucceedEndGameEvent(this, e);
|
OnSucceedEndGameEvent(this, e);
|
||||||
RunTime.PluginLoader?.OnSucceedEndGameEvent(this, e);
|
RunTime.PluginLoader?.OnSucceedEndGameEvent(this, e);
|
||||||
}
|
}
|
||||||
@ -630,12 +629,12 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过双击房间列表的房间号加入房间
|
/// 通过双击房间列表的房间号加入房间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="selectedindex"></param>
|
/// <param name="selectedIndex"></param>
|
||||||
private async Task<bool> JoinRoom(int selectedindex)
|
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 await JoinRoom_Handler(roomid);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -655,7 +654,8 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
if (Usercfg.InRoom.Roomid == "-1")
|
if (Usercfg.InRoom.Roomid == "-1")
|
||||||
{
|
{
|
||||||
if (await MainController.GetRoomPlayerCountAsync(roomid) < 8)
|
GameModule? gameModule = RunTime.GameModuleLoader?[RunTime.RoomList[roomid].GameModule];
|
||||||
|
if (await MainController.GetRoomPlayerCountAsync(roomid) < gameModule?.MaxUsers)
|
||||||
{
|
{
|
||||||
if (ShowMessage(ShowMessageType.YesNo, "已找到房间 -> [ " + roomid + " ]\n是否加入?", "已找到房间") == MessageResult.Yes)
|
if (ShowMessage(ShowMessageType.YesNo, "已找到房间 -> [ " + roomid + " ]\n是否加入?", "已找到房间") == MessageResult.Yes)
|
||||||
{
|
{
|
||||||
@ -890,23 +890,27 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建房间的处理方法
|
/// 创建房间的处理方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="RoomType"></param>
|
/// <param name="roomType"></param>
|
||||||
/// <param name="Password"></param>
|
/// <param name="gameModule"></param>
|
||||||
|
/// <param name="gameMap"></param>
|
||||||
|
/// <param name="isRank"></param>
|
||||||
|
/// <param name="password"></param>
|
||||||
/// <returns></returns>
|
/// <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")
|
if (Usercfg.InRoom.Roomid != "-1")
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Warning, "已在房间中,无法创建房间。");
|
ShowMessage(ShowMessageType.Warning, "已在房间中,无法创建房间。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GameModule? mode = RunTime.GameModuleLoader?.Modules.Values.FirstOrDefault() ?? default;
|
GameModule? module = RunTime.GameModuleLoader?[gameModule];
|
||||||
if (mode is null)
|
if (module is null)
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, ">> 缺少" + Config.FunGame_RoomType + "所需的模组,无法创建房间。");
|
ShowMessage(ShowMessageType.Error, ">> 缺少" + Config.FunGame_RoomType + "所需的模组,无法创建房间。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Room room = await InvokeController_CreateRoom(RoomType, GameModule, GameMap, IsRank, Password);
|
string gameModuleServer = module.AssociatedServerModuleName;
|
||||||
|
Room room = await InvokeController_CreateRoom(roomType, gameModuleServer, gameMap, isRank, module.MaxUsers, password);
|
||||||
if (MainController is not null && room.Roomid != "-1")
|
if (MainController is not null && room.Roomid != "-1")
|
||||||
{
|
{
|
||||||
await MainController.UpdateRoomAsync();
|
await MainController.UpdateRoomAsync();
|
||||||
@ -1071,12 +1075,12 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
string modmap = ComboGameMap.SelectedItem?.ToString() ?? all;
|
string modmap = ComboGameMap.SelectedItem?.ToString() ?? all;
|
||||||
if (RunTime.GameModuleLoader is null || (modname != all && !RunTime.GameModuleLoader.Modules.ContainsKey(modname)))
|
if (RunTime.GameModuleLoader is null || (modname != all && !RunTime.GameModuleLoader.Modules.ContainsKey(modname)))
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, ">> 模组未正确加载,无法创建房间。");
|
ShowMessage(ShowMessageType.Error, "模组未正确加载,无法创建房间。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (RunTime.GameModuleLoader is null || (modmap != all && !RunTime.GameModuleLoader.Maps.ContainsKey(modmap)))
|
if (RunTime.GameModuleLoader is null || (modmap != all && !RunTime.GameModuleLoader.Maps.ContainsKey(modmap)))
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, ">> 地图未正确加载,无法创建房间。");
|
ShowMessage(ShowMessageType.Error, "地图未正确加载,无法创建房间。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 开始匹配
|
// 开始匹配
|
||||||
@ -1123,12 +1127,12 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
}
|
}
|
||||||
if (RunTime.GameModuleLoader is null || (modname != all && !RunTime.GameModuleLoader.Modules.ContainsKey(modname)))
|
if (RunTime.GameModuleLoader is null || (modname != all && !RunTime.GameModuleLoader.Modules.ContainsKey(modname)))
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, ">> 模组未正确加载,无法创建房间。");
|
ShowMessage(ShowMessageType.Error, "模组未正确加载,无法创建房间。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (RunTime.GameModuleLoader is null || (modmap != all && !RunTime.GameModuleLoader.Maps.ContainsKey(modmap)))
|
if (RunTime.GameModuleLoader is null || (modmap != all && !RunTime.GameModuleLoader.Maps.ContainsKey(modmap)))
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, ">> 地图未正确加载,无法创建房间。");
|
ShowMessage(ShowMessageType.Error, "地图未正确加载,无法创建房间。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (CheckHasPass.Checked)
|
if (CheckHasPass.Checked)
|
||||||
@ -1159,7 +1163,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
WritelnGameInfo(DateTimeUtility.GetNowShortTime() + " 离开房间");
|
WritelnGameInfo(DateTimeUtility.GetNowShortTime() + " 离开房间");
|
||||||
WritelnGameInfo("[ " + Usercfg.LoginUserName + " ] 已离开房间 -> [ " + roomid + " ]");
|
WritelnGameInfo("[ " + Usercfg.LoginUserName + " ] 已离开房间 -> [ " + roomid + " ]");
|
||||||
InMain();
|
InvokeUpdateUI(InMain);
|
||||||
_ = MainController?.UpdateRoomAsync();
|
_ = MainController?.UpdateRoomAsync();
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
@ -1276,7 +1280,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
SetRoomTypeString();
|
SetRoomTypeString();
|
||||||
ComboGameMap.Items.Clear();
|
ComboGameMap.Items.Clear();
|
||||||
ComboGameMap.Items.AddRange(Constant.SupportedGameMap(mod));
|
ComboGameMap.Items.AddRange(Constant.SupportedGameMap(mod));
|
||||||
ComboGameMap.SelectedIndex = 0;
|
ComboGameMap.SelectedItem = mod.DefaultMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1295,7 +1299,8 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
if (RoomList.SelectedItem != null)
|
if (RoomList.SelectedItem != null)
|
||||||
{
|
{
|
||||||
TaskUtility.NewTask(async () => await JoinRoom(RoomList.SelectedIndex));
|
int selected = RoomList.SelectedIndex;
|
||||||
|
TaskUtility.NewTask(async () => await JoinRoom(selected));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1533,8 +1538,11 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void SucceedIntoRoomEvent(object sender, RoomEventArgs e)
|
private void SucceedIntoRoomEvent(object sender, RoomEventArgs e)
|
||||||
{
|
{
|
||||||
SetRoomid(e.Room);
|
InvokeUpdateUI(() =>
|
||||||
InRoom();
|
{
|
||||||
|
SetRoomid(e.Room);
|
||||||
|
InRoom();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1625,13 +1633,20 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
if (Usercfg.InRoom.Roomid != "-1")
|
if (Usercfg.InRoom.Roomid != "-1")
|
||||||
{
|
{
|
||||||
TaskUtility.NewTask(async () =>
|
if (Usercfg.LoginUser.Id == Usercfg.InRoom.RoomMaster.Id)
|
||||||
{
|
{
|
||||||
if (await MainController.SetReadyAsync(Usercfg.InRoom.Roomid))
|
WritelnGameInfo(">> 房主无法使用此命令。");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TaskUtility.NewTask(async () =>
|
||||||
{
|
{
|
||||||
await InvokeController_SendTalk(" [ " + Usercfg.LoginUser.Username + " ] 已准备。");
|
if (await MainController.SetReadyAsync(Usercfg.InRoom.Roomid))
|
||||||
}
|
{
|
||||||
});
|
await InvokeController_SendTalk(" [ " + Usercfg.LoginUser.Username + " ] 已准备。");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else WritelnGameInfo(">> 不在房间中无法使用此命令。");
|
else WritelnGameInfo(">> 不在房间中无法使用此命令。");
|
||||||
}
|
}
|
||||||
@ -1644,13 +1659,20 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
if (Usercfg.InRoom.Roomid != "-1")
|
if (Usercfg.InRoom.Roomid != "-1")
|
||||||
{
|
{
|
||||||
TaskUtility.NewTask(async () =>
|
if (Usercfg.LoginUser.Id == Usercfg.InRoom.RoomMaster.Id)
|
||||||
{
|
{
|
||||||
if (await MainController.CancelReadyAsync(Usercfg.InRoom.Roomid))
|
WritelnGameInfo(">> 房主无法使用此命令。");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TaskUtility.NewTask(async () =>
|
||||||
{
|
{
|
||||||
await InvokeController_SendTalk(" [ " + Usercfg.LoginUser.Username + " ] 已取消准备。");
|
if (await MainController.CancelReadyAsync(Usercfg.InRoom.Roomid))
|
||||||
}
|
{
|
||||||
});
|
await InvokeController_SendTalk(" [ " + Usercfg.LoginUser.Username + " ] 已取消准备。");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else WritelnGameInfo(">> 不在房间中无法使用此命令。");
|
else WritelnGameInfo(">> 不在房间中无法使用此命令。");
|
||||||
}
|
}
|
||||||
@ -1967,9 +1989,9 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="room"></param>
|
/// <param name="room"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<Room> InvokeController_CreateRoom(RoomType RoomType, string GameModule, string GameMap, bool IsRank, string Password = "")
|
public async Task<Room> InvokeController_CreateRoom(RoomType roomType, string gameModuleServer, string gameMap, bool isRank, int maxUsers,string password = "")
|
||||||
{
|
{
|
||||||
RoomEventArgs EventArgs = new(RoomType, Password);
|
RoomEventArgs EventArgs = new(roomType, password);
|
||||||
Room room = General.HallInstance;
|
Room room = General.HallInstance;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -1978,7 +2000,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
RunTime.PluginLoader?.OnBeforeCreateRoomEvent(this, EventArgs);
|
RunTime.PluginLoader?.OnBeforeCreateRoomEvent(this, EventArgs);
|
||||||
if (EventArgs.Cancel) return room;
|
if (EventArgs.Cancel) return room;
|
||||||
|
|
||||||
room = MainController is null ? room : await MainController.CreateRoomAsync(RoomType, GameModule, GameMap, IsRank, Password);
|
room = MainController is null ? room : await MainController.CreateRoomAsync(roomType, gameModuleServer, gameMap, isRank, maxUsers, password);
|
||||||
|
|
||||||
if (room.Roomid != "-1")
|
if (room.Roomid != "-1")
|
||||||
{
|
{
|
||||||
@ -2029,7 +2051,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
OnSucceedQuitRoomEvent(this, EventArgs);
|
OnSucceedQuitRoomEvent(this, EventArgs);
|
||||||
RunTime.PluginLoader?.OnSucceedQuitRoomEvent(this, EventArgs);
|
RunTime.PluginLoader?.OnSucceedQuitRoomEvent(this, EventArgs);
|
||||||
// 禁用和激活按钮,并切换预设快捷消息
|
// 禁用和激活按钮,并切换预设快捷消息
|
||||||
SetButtonEnabled(true, ClientState.Online);
|
InvokeUpdateUI(() => SetButtonEnabled(true, ClientState.Online));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2047,7 +2069,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
OnAfterQuitRoomEvent(this, EventArgs);
|
OnAfterQuitRoomEvent(this, EventArgs);
|
||||||
RunTime.PluginLoader?.OnAfterQuitRoomEvent(this, EventArgs);
|
RunTime.PluginLoader?.OnAfterQuitRoomEvent(this, EventArgs);
|
||||||
// 禁用和激活按钮,并切换预设快捷消息
|
// 禁用和激活按钮,并切换预设快捷消息
|
||||||
SetButtonEnabled(true, ClientState.Online);
|
InvokeUpdateUI(() => SetButtonEnabled(true, ClientState.Online));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -32,10 +32,17 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string username = UsernameText.Text.Trim();
|
string username = "";
|
||||||
string password = PasswordText.Text.Trim();
|
string password = "";
|
||||||
string checkpassword = CheckPasswordText.Text.Trim();
|
string checkpassword = "";
|
||||||
string email = EmailText.Text.Trim();
|
string email = "";
|
||||||
|
InvokeUpdateUI(() =>
|
||||||
|
{
|
||||||
|
username = UsernameText.Text.Trim();
|
||||||
|
password = PasswordText.Text.Trim();
|
||||||
|
checkpassword = CheckPasswordText.Text.Trim();
|
||||||
|
email = EmailText.Text.Trim();
|
||||||
|
});
|
||||||
if (username != "")
|
if (username != "")
|
||||||
{
|
{
|
||||||
if (NetworkUtility.IsUserName(username))
|
if (NetworkUtility.IsUserName(username))
|
||||||
@ -46,21 +53,21 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
if (password != checkpassword)
|
if (password != checkpassword)
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, "两个密码不相同,请重新输入!");
|
ShowMessage(ShowMessageType.Error, "两个密码不相同,请重新输入!");
|
||||||
CheckPasswordText.Focus();
|
InvokeUpdateUI(() => CheckPasswordText.Focus());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, "账号名长度不符合要求:3~12个字符数(一个中文2个字符)");
|
ShowMessage(ShowMessageType.Error, "账号名长度不符合要求:3~12个字符数(一个中文2个字符)");
|
||||||
UsernameText.Focus();
|
InvokeUpdateUI(() => UsernameText.Focus());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, "账号名不符合要求:不能包含特殊字符");
|
ShowMessage(ShowMessageType.Error, "账号名不符合要求:不能包含特殊字符");
|
||||||
UsernameText.Focus();
|
InvokeUpdateUI(() => UsernameText.Focus());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,26 +77,26 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
if (length < 6 || length > 15) // 字节范围 6~15
|
if (length < 6 || length > 15) // 字节范围 6~15
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, "密码长度不符合要求:6~15个字符数");
|
ShowMessage(ShowMessageType.Error, "密码长度不符合要求:6~15个字符数");
|
||||||
PasswordText.Focus();
|
InvokeUpdateUI(() => PasswordText.Focus());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (username == "" || password == "" || checkpassword == "")
|
if (username == "" || password == "" || checkpassword == "")
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, "请将账号和密码填写完整!");
|
ShowMessage(ShowMessageType.Error, "请将账号和密码填写完整!");
|
||||||
UsernameText.Focus();
|
InvokeUpdateUI(() => UsernameText.Focus());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (email == "")
|
if (email == "")
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, "邮箱不能为空!");
|
ShowMessage(ShowMessageType.Error, "邮箱不能为空!");
|
||||||
EmailText.Focus();
|
InvokeUpdateUI(() => EmailText.Focus());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!NetworkUtility.IsEmail(email))
|
if (!NetworkUtility.IsEmail(email))
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, "这不是一个邮箱地址!");
|
ShowMessage(ShowMessageType.Error, "这不是一个邮箱地址!");
|
||||||
EmailText.Focus();
|
InvokeUpdateUI(() => EmailText.Focus());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return await RegController.RegAsync(username, password, email);
|
return await RegController.RegAsync(username, password, email);
|
||||||
@ -116,7 +123,10 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
string username = ((RegisterEventArgs)e).Username;
|
string username = ((RegisterEventArgs)e).Username;
|
||||||
string password = ((RegisterEventArgs)e).Password;
|
string password = ((RegisterEventArgs)e).Password;
|
||||||
TaskUtility.NewTask(async () => await LoginController.LoginAccountAsync(username, password, encrypt: false));
|
TaskUtility.NewTask(async () => await LoginController.LoginAccountAsync(username, password, encrypt: false));
|
||||||
RunTime.Login?.Close();
|
if (RunTime.Login != null)
|
||||||
|
{
|
||||||
|
RunTime.Login.InvokeUpdateUI(RunTime.Login.Close);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RegButton_Click(object sender, EventArgs e)
|
private void RegButton_Click(object sender, EventArgs e)
|
||||||
@ -124,8 +134,8 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
RegButton.Enabled = false;
|
RegButton.Enabled = false;
|
||||||
TaskUtility.NewTask(async () =>
|
TaskUtility.NewTask(async () =>
|
||||||
{
|
{
|
||||||
if (!await Reg_Handler()) RegButton.Enabled = true;
|
if (!await Reg_Handler()) InvokeUpdateUI(() => RegButton.Enabled = true);
|
||||||
else Close();
|
else InvokeUpdateUI(Close);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user