适配最新版本的模组系统 (#27)

This commit is contained in:
milimoe 2024-08-22 00:39:59 +08:00 committed by GitHub
parent 3bb069ca5a
commit 1e5ee1fc2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 86 additions and 85 deletions

View File

@ -216,14 +216,14 @@ namespace Milimoe.FunGame.Desktop.Controller
} }
} }
public async Task<Room> CreateRoomAsync(RoomType RoomType, string GameMode, string GameMap, bool IsRank, string Password = "") public async Task<Room> CreateRoomAsync(RoomType RoomType, string GameModule, string GameMap, bool IsRank, string Password = "")
{ {
Room room = General.HallInstance; Room room = General.HallInstance;
try try
{ {
CreateRoomRequest.AddRequestData("roomtype", RoomType); CreateRoomRequest.AddRequestData("roomtype", RoomType);
CreateRoomRequest.AddRequestData("gamemode", GameMode); CreateRoomRequest.AddRequestData("gamemodule", GameModule);
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);

View File

@ -32,8 +32,8 @@ namespace Milimoe.FunGame.Desktop.Controller
Hashtable delegates = []; Hashtable delegates = [];
delegates.Add("WriteLine", new Action<string>(WritelnSystemInfo)); delegates.Add("WriteLine", new Action<string>(WritelnSystemInfo));
delegates.Add("Error", new Action<Exception>(Error)); delegates.Add("Error", new Action<Exception>(Error));
delegates.Add("NewDataRequest", new Func<DataRequestType, DataRequest>(NewDataRequest)); delegates.Add("NewDataRequest", new Func<DataRequestType, DataRequest>(NewDataRequestForAddon));
delegates.Add("NewLongRunningDataRequest", new Func<DataRequestType, DataRequest>(NewLongRunningDataRequest)); delegates.Add("NewLongRunningDataRequest", new Func<DataRequestType, DataRequest>(NewLongRunningDataRequestForAddon));
RunTime.PluginLoader = PluginLoader.LoadPlugins( delegates, RunTime.Session, RunTime.Config); RunTime.PluginLoader = PluginLoader.LoadPlugins( delegates, RunTime.Session, RunTime.Config);
foreach (string name in RunTime.PluginLoader.Plugins.Keys) foreach (string name in RunTime.PluginLoader.Plugins.Keys)
{ {
@ -46,7 +46,7 @@ namespace Milimoe.FunGame.Desktop.Controller
} }
} }
public void LoadGameModes() public void LoadGameModules()
{ {
try try
{ {
@ -54,12 +54,12 @@ namespace Milimoe.FunGame.Desktop.Controller
Hashtable delegates = []; Hashtable delegates = [];
delegates.Add("WriteLine", new Action<string>(WritelnSystemInfo)); delegates.Add("WriteLine", new Action<string>(WritelnSystemInfo));
delegates.Add("Error", new Action<Exception>(Error)); delegates.Add("Error", new Action<Exception>(Error));
delegates.Add("NewDataRequest", new Func<DataRequestType, DataRequest>(NewDataRequest)); delegates.Add("NewGamingRequest", new Func<GamingType, DataRequest>(NewDataRequestForAddon));
delegates.Add("NewLongRunningDataRequest", new Func<DataRequestType, DataRequest>(NewLongRunningDataRequest)); delegates.Add("NewLongRunningGamingRequest", new Func<GamingType, DataRequest>(NewLongRunningDataRequestForAddon));
RunTime.GameModeLoader = GameModeLoader.LoadGameModes(Constant.FunGameType, delegates, RunTime.Session, RunTime.Config); RunTime.GameModuleLoader = GameModuleLoader.LoadGameModules(Constant.FunGameType, delegates, RunTime.Session, RunTime.Config);
foreach (string name in RunTime.GameModeLoader.Modes.Keys) foreach (string name in RunTime.GameModuleLoader.Modules.Keys)
{ {
Main.GetMessage("[ GameMode ] Loaded: " + name); Main.GetMessage("[ GameModule ] Loaded: " + name);
} }
} }
catch (Exception e) catch (Exception e)
@ -89,12 +89,12 @@ namespace Milimoe.FunGame.Desktop.Controller
Main.GetMessage("正在连接服务器,请耐心等待。"); Main.GetMessage("正在连接服务器,请耐心等待。");
return false; return false;
} }
string[] gamemodes = []; string[] gamemodules = [];
if (RunTime.GameModeLoader != null) if (RunTime.GameModuleLoader != null)
{ {
gamemodes = [.. RunTime.GameModeLoader.Modes.Keys]; gamemodules = [.. RunTime.GameModuleLoader.Modules.Keys];
} }
ConnectArgs.Add(gamemodes); // 服务器检查是否拥有需要的模组 ConnectArgs.Add(gamemodules); // 服务器检查是否拥有需要的模组
ConnectArgs.Add(FunGameInfo.FunGame_DebugMode); // 是否开启了debug模式 ConnectArgs.Add(FunGameInfo.FunGame_DebugMode); // 是否开启了debug模式
if (!Config.FunGame_isConnected) if (!Config.FunGame_isConnected)
{ {

View File

@ -80,27 +80,28 @@ namespace Milimoe.FunGame.Desktop.Library
public static readonly object[] AllComboItem = ["全部"]; public static readonly object[] AllComboItem = ["全部"];
public static object[] SupportedRoomType() public static object[] SupportedRoomType()
{ {
List<string> objs = []; List<string> objs = [
objs.Add(RoomSet.GetTypeString(RoomType.All)); RoomSet.GetTypeString(RoomType.All),
objs.Add(RoomSet.GetTypeString(RoomType.Mix)); RoomSet.GetTypeString(RoomType.Mix),
objs.Add(RoomSet.GetTypeString(RoomType.Team)); RoomSet.GetTypeString(RoomType.Team),
objs.Add(RoomSet.GetTypeString(RoomType.Solo)); RoomSet.GetTypeString(RoomType.Solo),
objs.Add(RoomSet.GetTypeString(RoomType.FastAuto)); RoomSet.GetTypeString(RoomType.FastAuto),
objs.Add(RoomSet.GetTypeString(RoomType.Custom)); RoomSet.GetTypeString(RoomType.Custom)
return objs.ToArray(); ];
return [.. objs];
} }
public static object[] SupportedGameMode(RoomType type) public static object[] SupportedGameModule(RoomType type)
{ {
if (RunTime.GameModeLoader != null) if (RunTime.GameModuleLoader != null)
{ {
IEnumerable<object> list; IEnumerable<object> list;
if (type == RoomType.All) if (type == RoomType.All)
{ {
list = RunTime.GameModeLoader.Modes.Values.Select(mod => mod.Name).Distinct(); list = RunTime.GameModuleLoader.Modules.Values.Select(mod => mod.Name).Distinct();
} }
else else
{ {
list = RunTime.GameModeLoader.Modes.Values.Where(mod => mod.RoomType == type).Select(mod => mod.Name).Distinct(); list = RunTime.GameModuleLoader.Modules.Values.Where(mod => mod.RoomType == type).Select(mod => mod.Name).Distinct();
} }
if (list.Any()) return AllComboItem.Union(list).ToArray(); if (list.Any()) return AllComboItem.Union(list).ToArray();
} }
@ -109,19 +110,19 @@ namespace Milimoe.FunGame.Desktop.Library
public static object[] SupportedGameMap() public static object[] SupportedGameMap()
{ {
List<string> list = []; List<string> list = [];
if (RunTime.GameModeLoader != null) if (RunTime.GameModuleLoader != null)
{ {
foreach (GameMode mod in RunTime.GameModeLoader.Modes.Values) foreach (GameModule module in RunTime.GameModuleLoader.Modules.Values)
{ {
list.AddRange(mod.Maps.Distinct()); list.AddRange(module.GameModuleDepend.Maps.Select(m => m.Name).Distinct());
} }
} }
if (list.Count != 0) return AllComboItem.Union(list).ToArray(); if (list.Count != 0) return AllComboItem.Union(list).ToArray();
return ["- 缺少地图 -"]; return ["- 缺少地图 -"];
} }
public static object[] SupportedGameMap(GameMode mod) public static object[] SupportedGameMap(GameModule module)
{ {
IEnumerable<object> list = mod.Maps.Where(map => mod.Maps.Contains(map)).Distinct(); IEnumerable<object> list = module.GameModuleDepend.Maps.Where(map => module.GameModuleDepend.Maps.Contains(map)).Distinct();
if (list.Any()) return AllComboItem.Union(list).ToArray(); if (list.Any()) return AllComboItem.Union(list).ToArray();
return ["- 缺少地图 -"]; return ["- 缺少地图 -"];
} }

View File

@ -13,7 +13,7 @@ namespace Milimoe.FunGame.Desktop.Model
public static Core.Model.FunGameConfig Config { get; } = new(); public static Core.Model.FunGameConfig Config { get; } = new();
public static Core.Model.Gaming? Gaming { get; set; } = null; public static Core.Model.Gaming? Gaming { get; set; } = null;
public static Core.Api.Utility.PluginLoader? PluginLoader { get; set; } = null; public static Core.Api.Utility.PluginLoader? PluginLoader { get; set; } = null;
public static Core.Api.Utility.GameModeLoader? GameModeLoader { get; set; } = null; public static Core.Api.Utility.GameModuleLoader? GameModuleLoader { get; set; } = null;
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;

View File

@ -69,7 +69,7 @@ namespace Milimoe.FunGame.Desktop.UI
StopMatch = new Button(); StopMatch = new Button();
CheckIsRank = new CheckBox(); CheckIsRank = new CheckBox();
ComboRoomType = new ComboBox(); ComboRoomType = new ComboBox();
ComboGameMode = new ComboBox(); ComboGameModule = new ComboBox();
ComboGameMap = new ComboBox(); ComboGameMap = new ComboBox();
RoomBox.SuspendLayout(); RoomBox.SuspendLayout();
Notice.SuspendLayout(); Notice.SuspendLayout();
@ -514,7 +514,7 @@ namespace Milimoe.FunGame.Desktop.UI
Copyright.Size = new Size(186, 23); Copyright.Size = new Size(186, 23);
Copyright.TabIndex = 97; Copyright.TabIndex = 97;
Copyright.TabStop = true; Copyright.TabStop = true;
Copyright.Text = "©2023 Milimoe. 米粒的糖果屋"; Copyright.Text = "©2024 Milimoe. 米粒的糖果屋";
Copyright.TextAlign = ContentAlignment.MiddleLeft; Copyright.TextAlign = ContentAlignment.MiddleLeft;
Copyright.UseCompatibleTextRendering = true; Copyright.UseCompatibleTextRendering = true;
Copyright.LinkClicked += Copyright_LinkClicked; Copyright.LinkClicked += Copyright_LinkClicked;
@ -559,18 +559,18 @@ namespace Milimoe.FunGame.Desktop.UI
ComboRoomType.TabIndex = 99; ComboRoomType.TabIndex = 99;
ComboRoomType.SelectionChangeCommitted += ComboRoomType_SelectionChangeCommitted; ComboRoomType.SelectionChangeCommitted += ComboRoomType_SelectionChangeCommitted;
// //
// ComboGameMode // ComboGameModule
// //
ComboGameMode.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; ComboGameModule.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
ComboGameMode.DropDownStyle = ComboBoxStyle.DropDownList; ComboGameModule.DropDownStyle = ComboBoxStyle.DropDownList;
ComboGameMode.Font = new Font("LanaPixel", 11.25F); ComboGameModule.Font = new Font("LanaPixel", 11.25F);
ComboGameMode.FormattingEnabled = true; ComboGameModule.FormattingEnabled = true;
ComboGameMode.Items.AddRange(new object[] { "- 请选择类型 -" }); ComboGameModule.Items.AddRange(new object[] { "- 请选择类型 -" });
ComboGameMode.Location = new Point(665, 122); ComboGameModule.Location = new Point(665, 122);
ComboGameMode.Name = "ComboGameMode"; ComboGameModule.Name = "ComboGameModule";
ComboGameMode.Size = new Size(130, 26); ComboGameModule.Size = new Size(130, 26);
ComboGameMode.TabIndex = 100; ComboGameModule.TabIndex = 100;
ComboGameMode.SelectionChangeCommitted += ComboGameMode_SelectionChangeCommitted; ComboGameModule.SelectionChangeCommitted += ComboGameModule_SelectionChangeCommitted;
// //
// ComboGameMap // ComboGameMap
// //
@ -591,7 +591,7 @@ namespace Milimoe.FunGame.Desktop.UI
BackgroundImage = Properties.Resources.back; BackgroundImage = Properties.Resources.back;
ClientSize = new Size(800, 450); ClientSize = new Size(800, 450);
Controls.Add(ComboGameMap); Controls.Add(ComboGameMap);
Controls.Add(ComboGameMode); Controls.Add(ComboGameModule);
Controls.Add(ComboRoomType); Controls.Add(ComboRoomType);
Controls.Add(CheckIsRank); Controls.Add(CheckIsRank);
Controls.Add(RefreshRoomList); Controls.Add(RefreshRoomList);
@ -653,7 +653,7 @@ namespace Milimoe.FunGame.Desktop.UI
Controls.SetChildIndex(RefreshRoomList, 0); Controls.SetChildIndex(RefreshRoomList, 0);
Controls.SetChildIndex(CheckIsRank, 0); Controls.SetChildIndex(CheckIsRank, 0);
Controls.SetChildIndex(ComboRoomType, 0); Controls.SetChildIndex(ComboRoomType, 0);
Controls.SetChildIndex(ComboGameMode, 0); Controls.SetChildIndex(ComboGameModule, 0);
Controls.SetChildIndex(ComboGameMap, 0); Controls.SetChildIndex(ComboGameMap, 0);
RoomBox.ResumeLayout(false); RoomBox.ResumeLayout(false);
RoomBox.PerformLayout(); RoomBox.PerformLayout();
@ -702,7 +702,7 @@ namespace Milimoe.FunGame.Desktop.UI
private Button RefreshRoomList; private Button RefreshRoomList;
private CheckBox CheckIsRank; private CheckBox CheckIsRank;
private ComboBox ComboGameMap; private ComboBox ComboGameMap;
private ComboBox ComboGameMode; private ComboBox ComboGameModule;
private ComboBox ComboRoomType; private ComboBox ComboRoomType;
} }
} }

View File

@ -62,7 +62,7 @@ namespace Milimoe.FunGame.Desktop.UI
} }
} }
// 加载模组 // 加载模组
RunTime.Controller.LoadGameModes(); RunTime.Controller.LoadGameModules();
// 加载插件 // 加载插件
RunTime.Controller.LoadPlugins(); RunTime.Controller.LoadPlugins();
// 设置预设 // 设置预设
@ -71,9 +71,9 @@ namespace Milimoe.FunGame.Desktop.UI
ComboRoomType.Items.Clear(); ComboRoomType.Items.Clear();
ComboRoomType.Items.AddRange(Constant.SupportedRoomType()); ComboRoomType.Items.AddRange(Constant.SupportedRoomType());
ComboRoomType.SelectedIndex = 0; ComboRoomType.SelectedIndex = 0;
ComboGameMode.Items.Clear(); ComboGameModule.Items.Clear();
ComboGameMode.Items.AddRange(Constant.SupportedGameMode(RoomType.All)); ComboGameModule.Items.AddRange(Constant.SupportedGameModule(RoomType.All));
ComboGameMode.SelectedIndex = 0; ComboGameModule.SelectedIndex = 0;
ComboGameMap.Items.Clear(); ComboGameMap.Items.Clear();
ComboGameMap.Items.AddRange(Constant.SupportedGameMap()); ComboGameMap.Items.AddRange(Constant.SupportedGameMap());
ComboGameMap.SelectedIndex = 0; ComboGameMap.SelectedIndex = 0;
@ -496,14 +496,14 @@ namespace Milimoe.FunGame.Desktop.UI
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.GameModeLoader?.Modes.ContainsKey(room.GameMode) ?? false) if (RunTime.GameModuleLoader?.Modules.ContainsKey(room.GameModule) ?? false)
{ {
RunTime.Gaming = Core.Model.Gaming.StartGame(RunTime.GameModeLoader[room.GameMode], room, users); RunTime.Gaming = Core.Model.Gaming.StartGame(RunTime.GameModuleLoader[room.GameModule], room, RunTime.Session.LoginUser, users, RunTime.GameModuleLoader);
Visible = false; // 隐藏主界面 Visible = false; // 隐藏主界面
} }
else else
{ {
WritelnGameInfo("缺少房间所需模组 [ " + room.GameMode + " ] 无法开始游戏,请检查模组是否正确安装。"); WritelnGameInfo("缺少房间所需模组 [ " + room.GameModule + " ] 无法开始游戏,请检查模组是否正确安装。");
} }
}); });
SetButtonEnabled(false, ClientState.InRoom); SetButtonEnabled(false, ClientState.InRoom);
@ -557,7 +557,7 @@ namespace Milimoe.FunGame.Desktop.UI
RoomBox.Enabled = isEnabled; RoomBox.Enabled = isEnabled;
RefreshRoomList.Enabled = isEnabled; RefreshRoomList.Enabled = isEnabled;
ComboRoomType.Enabled = isEnabled; ComboRoomType.Enabled = isEnabled;
ComboGameMode.Enabled = isEnabled; ComboGameModule.Enabled = isEnabled;
ComboGameMap.Enabled = isEnabled; ComboGameMap.Enabled = isEnabled;
CheckIsRank.Enabled = isEnabled; CheckIsRank.Enabled = isEnabled;
CheckHasPass.Enabled = isEnabled; CheckHasPass.Enabled = isEnabled;
@ -600,7 +600,7 @@ namespace Milimoe.FunGame.Desktop.UI
CreateRoom.Enabled = isEnabled; CreateRoom.Enabled = isEnabled;
RefreshRoomList.Enabled = isEnabled; RefreshRoomList.Enabled = isEnabled;
ComboRoomType.Enabled = isEnabled; ComboRoomType.Enabled = isEnabled;
ComboGameMode.Enabled = isEnabled; ComboGameModule.Enabled = isEnabled;
ComboGameMap.Enabled = isEnabled; ComboGameMap.Enabled = isEnabled;
CheckIsRank.Enabled = isEnabled; CheckIsRank.Enabled = isEnabled;
CheckHasPass.Enabled = isEnabled; CheckHasPass.Enabled = isEnabled;
@ -762,7 +762,7 @@ namespace Milimoe.FunGame.Desktop.UI
bool isEnabled = false; bool isEnabled = false;
if (objs != null) isEnabled = (bool)objs[0]; if (objs != null) isEnabled = (bool)objs[0];
ComboRoomType.Enabled = isEnabled; ComboRoomType.Enabled = isEnabled;
ComboGameMode.Enabled = isEnabled; ComboGameModule.Enabled = isEnabled;
ComboGameMap.Enabled = isEnabled; ComboGameMap.Enabled = isEnabled;
CheckHasPass.Enabled = isEnabled; CheckHasPass.Enabled = isEnabled;
CreateRoom.Enabled = isEnabled; CreateRoom.Enabled = isEnabled;
@ -893,20 +893,20 @@ namespace Milimoe.FunGame.Desktop.UI
/// <param name="RoomType"></param> /// <param name="RoomType"></param>
/// <param name="Password"></param> /// <param name="Password"></param>
/// <returns></returns> /// <returns></returns>
private async Task CreateRoom_Handler(RoomType RoomType, string GameMode, 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;
} }
GameMode? mode = RunTime.GameModeLoader?.Modes.Values.FirstOrDefault() ?? default; GameModule? mode = RunTime.GameModuleLoader?.Modules.Values.FirstOrDefault() ?? default;
if (mode is null) if (mode is null)
{ {
ShowMessage(ShowMessageType.Error, ">> 缺少" + Config.FunGame_RoomType + "所需的模组,无法创建房间。"); ShowMessage(ShowMessageType.Error, ">> 缺少" + Config.FunGame_RoomType + "所需的模组,无法创建房间。");
return; return;
} }
Room room = await InvokeController_CreateRoom(RoomType, GameMode, GameMap, IsRank, Password); Room room = await InvokeController_CreateRoom(RoomType, GameModule, GameMap, IsRank, Password);
if (MainController is not null && room.Roomid != "-1") if (MainController is not null && room.Roomid != "-1")
{ {
await MainController.UpdateRoomAsync(); await MainController.UpdateRoomAsync();
@ -1056,7 +1056,7 @@ namespace Milimoe.FunGame.Desktop.UI
/// <param name="e"></param> /// <param name="e"></param>
private void StartMatch_Click(object sender, EventArgs e) private void StartMatch_Click(object sender, EventArgs e)
{ {
if (ComboRoomType.SelectedIndex < 0 || ComboGameMode.SelectedIndex < 0 || ComboGameMap.SelectedIndex < 0) if (ComboRoomType.SelectedIndex < 0 || ComboGameModule.SelectedIndex < 0 || ComboGameMap.SelectedIndex < 0)
{ {
ShowMessage(ShowMessageType.Warning, "未正确选择房间类型/游戏模组/游戏地图,请检查!"); ShowMessage(ShowMessageType.Warning, "未正确选择房间类型/游戏模组/游戏地图,请检查!");
return; return;
@ -1067,14 +1067,14 @@ namespace Milimoe.FunGame.Desktop.UI
return; return;
} }
string all = Constant.AllComboItem[0].ToString() ?? "全部"; string all = Constant.AllComboItem[0].ToString() ?? "全部";
string modname = ComboGameMode.SelectedItem?.ToString() ?? all; string modname = ComboGameModule.SelectedItem?.ToString() ?? all;
string modmap = ComboGameMap.SelectedItem?.ToString() ?? all; string modmap = ComboGameMap.SelectedItem?.ToString() ?? all;
if (RunTime.GameModeLoader is null || (modname != all && !RunTime.GameModeLoader.Modes.ContainsKey(modname))) if (RunTime.GameModuleLoader is null || (modname != all && !RunTime.GameModuleLoader.Modules.ContainsKey(modname)))
{ {
ShowMessage(ShowMessageType.Error, ">> 模组未正确加载,无法创建房间。"); ShowMessage(ShowMessageType.Error, ">> 模组未正确加载,无法创建房间。");
return; return;
} }
if (RunTime.GameModeLoader is null || (modmap != all && !RunTime.GameModeLoader.Maps.ContainsKey(modmap))) if (RunTime.GameModuleLoader is null || (modmap != all && !RunTime.GameModuleLoader.Maps.ContainsKey(modmap)))
{ {
ShowMessage(ShowMessageType.Error, ">> 地图未正确加载,无法创建房间。"); ShowMessage(ShowMessageType.Error, ">> 地图未正确加载,无法创建房间。");
return; return;
@ -1103,7 +1103,7 @@ namespace Milimoe.FunGame.Desktop.UI
private void CreateRoom_Click(object sender, EventArgs e) private void CreateRoom_Click(object sender, EventArgs e)
{ {
string password = ""; string password = "";
if (Config.FunGame_RoomType == RoomType.All || ComboRoomType.SelectedIndex <= 0 || ComboGameMode.SelectedIndex <= 0 || ComboGameMap.SelectedIndex <= 0) if (Config.FunGame_RoomType == RoomType.All || ComboRoomType.SelectedIndex <= 0 || ComboGameModule.SelectedIndex <= 0 || ComboGameMap.SelectedIndex <= 0)
{ {
ShowMessage(ShowMessageType.Warning, "创建房间时不允许将房间类型/游戏模组/游戏地图的选项设置为[ 全部 ]。"); ShowMessage(ShowMessageType.Warning, "创建房间时不允许将房间类型/游戏模组/游戏地图的选项设置为[ 全部 ]。");
return; return;
@ -1114,19 +1114,19 @@ namespace Milimoe.FunGame.Desktop.UI
return; return;
} }
string all = Constant.AllComboItem[0].ToString() ?? "全部"; string all = Constant.AllComboItem[0].ToString() ?? "全部";
string modname = ComboGameMode.SelectedItem?.ToString() ?? all; string modname = ComboGameModule.SelectedItem?.ToString() ?? all;
string modmap = ComboGameMap.SelectedItem?.ToString() ?? all; string modmap = ComboGameMap.SelectedItem?.ToString() ?? all;
if (modname == all || modmap == all) if (modname == all || modmap == all)
{ {
ShowMessage(ShowMessageType.Warning, "创建房间时不允许将房间类型/游戏模组/游戏地图的选项设置为[ 全部 ]。"); ShowMessage(ShowMessageType.Warning, "创建房间时不允许将房间类型/游戏模组/游戏地图的选项设置为[ 全部 ]。");
return; return;
} }
if (RunTime.GameModeLoader is null || (modname != all && !RunTime.GameModeLoader.Modes.ContainsKey(modname))) if (RunTime.GameModuleLoader is null || (modname != all && !RunTime.GameModuleLoader.Modules.ContainsKey(modname)))
{ {
ShowMessage(ShowMessageType.Error, ">> 模组未正确加载,无法创建房间。"); ShowMessage(ShowMessageType.Error, ">> 模组未正确加载,无法创建房间。");
return; return;
} }
if (RunTime.GameModeLoader is null || (modmap != all && !RunTime.GameModeLoader.Maps.ContainsKey(modmap))) if (RunTime.GameModuleLoader is null || (modmap != all && !RunTime.GameModuleLoader.Maps.ContainsKey(modmap)))
{ {
ShowMessage(ShowMessageType.Error, ">> 地图未正确加载,无法创建房间。"); ShowMessage(ShowMessageType.Error, ">> 地图未正确加载,无法创建房间。");
return; return;
@ -1250,9 +1250,9 @@ namespace Milimoe.FunGame.Desktop.UI
if (ComboRoomType.SelectedIndex >= 0) if (ComboRoomType.SelectedIndex >= 0)
{ {
SetRoomTypeString(); SetRoomTypeString();
ComboGameMode.Items.Clear(); ComboGameModule.Items.Clear();
ComboGameMode.Items.AddRange(Constant.SupportedGameMode(Config.FunGame_RoomType)); ComboGameModule.Items.AddRange(Constant.SupportedGameModule(Config.FunGame_RoomType));
ComboGameMode.SelectedIndex = 0; ComboGameModule.SelectedIndex = 0;
ComboGameMap.Items.Clear(); ComboGameMap.Items.Clear();
ComboGameMap.Items.Add("全部"); ComboGameMap.Items.Add("全部");
ComboGameMap.SelectedIndex = 0; ComboGameMap.SelectedIndex = 0;
@ -1260,18 +1260,18 @@ namespace Milimoe.FunGame.Desktop.UI
} }
/// <summary> /// <summary>
/// 切换GameMode时设置GameMap选项 /// 切换GameModule时设置GameMap选项
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void ComboGameMode_SelectionChangeCommitted(object sender, EventArgs e) private void ComboGameModule_SelectionChangeCommitted(object sender, EventArgs e)
{ {
if (ComboGameMode.SelectedIndex > 0) if (ComboGameModule.SelectedIndex > 0)
{ {
string modname = ComboGameMode.SelectedItem?.ToString() ?? ""; string modname = ComboGameModule.SelectedItem?.ToString() ?? "";
if (modname != "- 缺少模组 -" && RunTime.GameModeLoader != null && RunTime.GameModeLoader.Modes.ContainsKey(modname)) if (modname != "- 缺少模组 -" && RunTime.GameModuleLoader != null && RunTime.GameModuleLoader.Modules.ContainsKey(modname))
{ {
GameMode mod = RunTime.GameModeLoader[modname]; GameModule mod = RunTime.GameModuleLoader[modname];
ComboRoomType.SelectedItem = RoomSet.GetTypeString(mod.RoomType); ComboRoomType.SelectedItem = RoomSet.GetTypeString(mod.RoomType);
SetRoomTypeString(); SetRoomTypeString();
ComboGameMap.Items.Clear(); ComboGameMap.Items.Clear();
@ -1603,8 +1603,8 @@ namespace Milimoe.FunGame.Desktop.UI
case Constant.FunGame_CreateMix: case Constant.FunGame_CreateMix:
if (Usercfg.InRoom.Roomid == "-1") if (Usercfg.InRoom.Roomid == "-1")
{ {
GameMode? mode = RunTime.GameModeLoader?.Modes.Values.FirstOrDefault() ?? default; GameModule? module = RunTime.GameModuleLoader?.Modules.Values.FirstOrDefault() ?? default;
if (mode != null) TaskUtility.NewTask(() => CreateRoom_Handler(RoomType.Mix, mode.Name, mode.DefaultMap, false)); if (module != null) TaskUtility.NewTask(() => CreateRoom_Handler(RoomType.Mix, module.Name, module.DefaultMap, false));
else WritelnGameInfo(">> 缺少" + RoomSet.GetTypeString(RoomType.Mix) + "所需的模组,无法创建房间。此命令使用默认模组创建。"); else WritelnGameInfo(">> 缺少" + RoomSet.GetTypeString(RoomType.Mix) + "所需的模组,无法创建房间。此命令使用默认模组创建。");
} }
else WritelnGameInfo(">> 先退出当前房间才可以创建房间。"); else WritelnGameInfo(">> 先退出当前房间才可以创建房间。");
@ -1612,8 +1612,8 @@ namespace Milimoe.FunGame.Desktop.UI
case Constant.FunGame_CreateTeam: case Constant.FunGame_CreateTeam:
if (Usercfg.InRoom.Roomid == "-1") if (Usercfg.InRoom.Roomid == "-1")
{ {
GameMode? mode = RunTime.GameModeLoader?.Modes.Values.FirstOrDefault() ?? default; GameModule? module = RunTime.GameModuleLoader?.Modules.Values.FirstOrDefault() ?? default;
if (mode != null) TaskUtility.NewTask(() => CreateRoom_Handler(RoomType.Team, mode.Name, mode.DefaultMap, false)); if (module != null) TaskUtility.NewTask(() => CreateRoom_Handler(RoomType.Team, module.Name, module.DefaultMap, false));
else WritelnGameInfo(">> 缺少" + RoomSet.GetTypeString(RoomType.Team) + "所需的模组,无法创建房间。此命令使用默认模组创建。"); else WritelnGameInfo(">> 缺少" + RoomSet.GetTypeString(RoomType.Team) + "所需的模组,无法创建房间。此命令使用默认模组创建。");
} }
else WritelnGameInfo(">> 先退出当前房间才可以创建房间。"); else WritelnGameInfo(">> 先退出当前房间才可以创建房间。");
@ -1967,7 +1967,7 @@ 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 GameMode, string GameMap, bool IsRank, 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; Room room = General.HallInstance;
@ -1978,7 +1978,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, GameMode, GameMap, IsRank, Password); room = MainController is null ? room : await MainController.CreateRoomAsync(RoomType, GameModule, GameMap, IsRank, Password);
if (room.Roomid != "-1") if (room.Roomid != "-1")
{ {

View File

@ -1,7 +1,7 @@
GNU AFFERO GENERAL PUBLIC LICENSE GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007 Version 3, 19 November 2007
Copyright (C) 2022-2024 milimoe & project-redbud. Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.