mirror of
https://github.com/project-redbud/FunGame-Desktop.git
synced 2025-04-20 03:59:34 +08:00
适配最新版本的模组系统 (#27)
This commit is contained in:
parent
3bb069ca5a
commit
1e5ee1fc2e
@ -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;
|
||||
|
||||
try
|
||||
{
|
||||
CreateRoomRequest.AddRequestData("roomtype", RoomType);
|
||||
CreateRoomRequest.AddRequestData("gamemode", GameMode);
|
||||
CreateRoomRequest.AddRequestData("gamemodule", GameModule);
|
||||
CreateRoomRequest.AddRequestData("gamemap", GameMap);
|
||||
CreateRoomRequest.AddRequestData("master", Usercfg.LoginUser);
|
||||
CreateRoomRequest.AddRequestData("password", Password);
|
||||
|
@ -32,8 +32,8 @@ namespace Milimoe.FunGame.Desktop.Controller
|
||||
Hashtable delegates = [];
|
||||
delegates.Add("WriteLine", new Action<string>(WritelnSystemInfo));
|
||||
delegates.Add("Error", new Action<Exception>(Error));
|
||||
delegates.Add("NewDataRequest", new Func<DataRequestType, DataRequest>(NewDataRequest));
|
||||
delegates.Add("NewLongRunningDataRequest", new Func<DataRequestType, DataRequest>(NewLongRunningDataRequest));
|
||||
delegates.Add("NewDataRequest", new Func<DataRequestType, DataRequest>(NewDataRequestForAddon));
|
||||
delegates.Add("NewLongRunningDataRequest", new Func<DataRequestType, DataRequest>(NewLongRunningDataRequestForAddon));
|
||||
RunTime.PluginLoader = PluginLoader.LoadPlugins( delegates, RunTime.Session, RunTime.Config);
|
||||
foreach (string name in RunTime.PluginLoader.Plugins.Keys)
|
||||
{
|
||||
@ -46,7 +46,7 @@ namespace Milimoe.FunGame.Desktop.Controller
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadGameModes()
|
||||
public void LoadGameModules()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -54,12 +54,12 @@ namespace Milimoe.FunGame.Desktop.Controller
|
||||
Hashtable delegates = [];
|
||||
delegates.Add("WriteLine", new Action<string>(WritelnSystemInfo));
|
||||
delegates.Add("Error", new Action<Exception>(Error));
|
||||
delegates.Add("NewDataRequest", new Func<DataRequestType, DataRequest>(NewDataRequest));
|
||||
delegates.Add("NewLongRunningDataRequest", new Func<DataRequestType, DataRequest>(NewLongRunningDataRequest));
|
||||
RunTime.GameModeLoader = GameModeLoader.LoadGameModes(Constant.FunGameType, delegates, RunTime.Session, RunTime.Config);
|
||||
foreach (string name in RunTime.GameModeLoader.Modes.Keys)
|
||||
delegates.Add("NewGamingRequest", new Func<GamingType, DataRequest>(NewDataRequestForAddon));
|
||||
delegates.Add("NewLongRunningGamingRequest", new Func<GamingType, DataRequest>(NewLongRunningDataRequestForAddon));
|
||||
RunTime.GameModuleLoader = GameModuleLoader.LoadGameModules(Constant.FunGameType, delegates, RunTime.Session, RunTime.Config);
|
||||
foreach (string name in RunTime.GameModuleLoader.Modules.Keys)
|
||||
{
|
||||
Main.GetMessage("[ GameMode ] Loaded: " + name);
|
||||
Main.GetMessage("[ GameModule ] Loaded: " + name);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -89,12 +89,12 @@ namespace Milimoe.FunGame.Desktop.Controller
|
||||
Main.GetMessage("正在连接服务器,请耐心等待。");
|
||||
return false;
|
||||
}
|
||||
string[] gamemodes = [];
|
||||
if (RunTime.GameModeLoader != null)
|
||||
string[] gamemodules = [];
|
||||
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模式
|
||||
if (!Config.FunGame_isConnected)
|
||||
{
|
||||
|
@ -80,27 +80,28 @@ namespace Milimoe.FunGame.Desktop.Library
|
||||
public static readonly object[] AllComboItem = ["全部"];
|
||||
public static object[] SupportedRoomType()
|
||||
{
|
||||
List<string> objs = [];
|
||||
objs.Add(RoomSet.GetTypeString(RoomType.All));
|
||||
objs.Add(RoomSet.GetTypeString(RoomType.Mix));
|
||||
objs.Add(RoomSet.GetTypeString(RoomType.Team));
|
||||
objs.Add(RoomSet.GetTypeString(RoomType.Solo));
|
||||
objs.Add(RoomSet.GetTypeString(RoomType.FastAuto));
|
||||
objs.Add(RoomSet.GetTypeString(RoomType.Custom));
|
||||
return objs.ToArray();
|
||||
List<string> objs = [
|
||||
RoomSet.GetTypeString(RoomType.All),
|
||||
RoomSet.GetTypeString(RoomType.Mix),
|
||||
RoomSet.GetTypeString(RoomType.Team),
|
||||
RoomSet.GetTypeString(RoomType.Solo),
|
||||
RoomSet.GetTypeString(RoomType.FastAuto),
|
||||
RoomSet.GetTypeString(RoomType.Custom)
|
||||
];
|
||||
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;
|
||||
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
|
||||
{
|
||||
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();
|
||||
}
|
||||
@ -109,19 +110,19 @@ namespace Milimoe.FunGame.Desktop.Library
|
||||
public static object[] SupportedGameMap()
|
||||
{
|
||||
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();
|
||||
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();
|
||||
return ["- 缺少地图 -"];
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace Milimoe.FunGame.Desktop.Model
|
||||
public static Core.Model.FunGameConfig Config { get; } = new();
|
||||
public static Core.Model.Gaming? Gaming { 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 Controller.RunTimeController? Controller { get; set; } = null;
|
||||
public static UI.Main? Main { get; set; } = null;
|
||||
|
32
FunGame.Desktop/UI/Main/Main.Designer.cs
generated
32
FunGame.Desktop/UI/Main/Main.Designer.cs
generated
@ -69,7 +69,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
StopMatch = new Button();
|
||||
CheckIsRank = new CheckBox();
|
||||
ComboRoomType = new ComboBox();
|
||||
ComboGameMode = new ComboBox();
|
||||
ComboGameModule = new ComboBox();
|
||||
ComboGameMap = new ComboBox();
|
||||
RoomBox.SuspendLayout();
|
||||
Notice.SuspendLayout();
|
||||
@ -514,7 +514,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
Copyright.Size = new Size(186, 23);
|
||||
Copyright.TabIndex = 97;
|
||||
Copyright.TabStop = true;
|
||||
Copyright.Text = "©2023 Milimoe. 米粒的糖果屋";
|
||||
Copyright.Text = "©2024 Milimoe. 米粒的糖果屋";
|
||||
Copyright.TextAlign = ContentAlignment.MiddleLeft;
|
||||
Copyright.UseCompatibleTextRendering = true;
|
||||
Copyright.LinkClicked += Copyright_LinkClicked;
|
||||
@ -559,18 +559,18 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
ComboRoomType.TabIndex = 99;
|
||||
ComboRoomType.SelectionChangeCommitted += ComboRoomType_SelectionChangeCommitted;
|
||||
//
|
||||
// ComboGameMode
|
||||
// ComboGameModule
|
||||
//
|
||||
ComboGameMode.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
ComboGameMode.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
ComboGameMode.Font = new Font("LanaPixel", 11.25F);
|
||||
ComboGameMode.FormattingEnabled = true;
|
||||
ComboGameMode.Items.AddRange(new object[] { "- 请选择类型 -" });
|
||||
ComboGameMode.Location = new Point(665, 122);
|
||||
ComboGameMode.Name = "ComboGameMode";
|
||||
ComboGameMode.Size = new Size(130, 26);
|
||||
ComboGameMode.TabIndex = 100;
|
||||
ComboGameMode.SelectionChangeCommitted += ComboGameMode_SelectionChangeCommitted;
|
||||
ComboGameModule.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
ComboGameModule.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
ComboGameModule.Font = new Font("LanaPixel", 11.25F);
|
||||
ComboGameModule.FormattingEnabled = true;
|
||||
ComboGameModule.Items.AddRange(new object[] { "- 请选择类型 -" });
|
||||
ComboGameModule.Location = new Point(665, 122);
|
||||
ComboGameModule.Name = "ComboGameModule";
|
||||
ComboGameModule.Size = new Size(130, 26);
|
||||
ComboGameModule.TabIndex = 100;
|
||||
ComboGameModule.SelectionChangeCommitted += ComboGameModule_SelectionChangeCommitted;
|
||||
//
|
||||
// ComboGameMap
|
||||
//
|
||||
@ -591,7 +591,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
BackgroundImage = Properties.Resources.back;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(ComboGameMap);
|
||||
Controls.Add(ComboGameMode);
|
||||
Controls.Add(ComboGameModule);
|
||||
Controls.Add(ComboRoomType);
|
||||
Controls.Add(CheckIsRank);
|
||||
Controls.Add(RefreshRoomList);
|
||||
@ -653,7 +653,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
Controls.SetChildIndex(RefreshRoomList, 0);
|
||||
Controls.SetChildIndex(CheckIsRank, 0);
|
||||
Controls.SetChildIndex(ComboRoomType, 0);
|
||||
Controls.SetChildIndex(ComboGameMode, 0);
|
||||
Controls.SetChildIndex(ComboGameModule, 0);
|
||||
Controls.SetChildIndex(ComboGameMap, 0);
|
||||
RoomBox.ResumeLayout(false);
|
||||
RoomBox.PerformLayout();
|
||||
@ -702,7 +702,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
private Button RefreshRoomList;
|
||||
private CheckBox CheckIsRank;
|
||||
private ComboBox ComboGameMap;
|
||||
private ComboBox ComboGameMode;
|
||||
private ComboBox ComboGameModule;
|
||||
private ComboBox ComboRoomType;
|
||||
}
|
||||
}
|
@ -62,7 +62,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
}
|
||||
}
|
||||
// 加载模组
|
||||
RunTime.Controller.LoadGameModes();
|
||||
RunTime.Controller.LoadGameModules();
|
||||
// 加载插件
|
||||
RunTime.Controller.LoadPlugins();
|
||||
// 设置预设
|
||||
@ -71,9 +71,9 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
ComboRoomType.Items.Clear();
|
||||
ComboRoomType.Items.AddRange(Constant.SupportedRoomType());
|
||||
ComboRoomType.SelectedIndex = 0;
|
||||
ComboGameMode.Items.Clear();
|
||||
ComboGameMode.Items.AddRange(Constant.SupportedGameMode(RoomType.All));
|
||||
ComboGameMode.SelectedIndex = 0;
|
||||
ComboGameModule.Items.Clear();
|
||||
ComboGameModule.Items.AddRange(Constant.SupportedGameModule(RoomType.All));
|
||||
ComboGameModule.SelectedIndex = 0;
|
||||
ComboGameMap.Items.Clear();
|
||||
ComboGameMap.Items.AddRange(Constant.SupportedGameMap());
|
||||
ComboGameMap.SelectedIndex = 0;
|
||||
@ -496,14 +496,14 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
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; // 隐藏主界面
|
||||
}
|
||||
else
|
||||
{
|
||||
WritelnGameInfo("缺少房间所需模组 [ " + room.GameMode + " ] 无法开始游戏,请检查模组是否正确安装。");
|
||||
WritelnGameInfo("缺少房间所需模组 [ " + room.GameModule + " ] 无法开始游戏,请检查模组是否正确安装。");
|
||||
}
|
||||
});
|
||||
SetButtonEnabled(false, ClientState.InRoom);
|
||||
@ -557,7 +557,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
RoomBox.Enabled = isEnabled;
|
||||
RefreshRoomList.Enabled = isEnabled;
|
||||
ComboRoomType.Enabled = isEnabled;
|
||||
ComboGameMode.Enabled = isEnabled;
|
||||
ComboGameModule.Enabled = isEnabled;
|
||||
ComboGameMap.Enabled = isEnabled;
|
||||
CheckIsRank.Enabled = isEnabled;
|
||||
CheckHasPass.Enabled = isEnabled;
|
||||
@ -600,7 +600,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
CreateRoom.Enabled = isEnabled;
|
||||
RefreshRoomList.Enabled = isEnabled;
|
||||
ComboRoomType.Enabled = isEnabled;
|
||||
ComboGameMode.Enabled = isEnabled;
|
||||
ComboGameModule.Enabled = isEnabled;
|
||||
ComboGameMap.Enabled = isEnabled;
|
||||
CheckIsRank.Enabled = isEnabled;
|
||||
CheckHasPass.Enabled = isEnabled;
|
||||
@ -762,7 +762,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
bool isEnabled = false;
|
||||
if (objs != null) isEnabled = (bool)objs[0];
|
||||
ComboRoomType.Enabled = isEnabled;
|
||||
ComboGameMode.Enabled = isEnabled;
|
||||
ComboGameModule.Enabled = isEnabled;
|
||||
ComboGameMap.Enabled = isEnabled;
|
||||
CheckHasPass.Enabled = isEnabled;
|
||||
CreateRoom.Enabled = isEnabled;
|
||||
@ -893,20 +893,20 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// <param name="RoomType"></param>
|
||||
/// <param name="Password"></param>
|
||||
/// <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")
|
||||
{
|
||||
ShowMessage(ShowMessageType.Warning, "已在房间中,无法创建房间。");
|
||||
return;
|
||||
}
|
||||
GameMode? mode = RunTime.GameModeLoader?.Modes.Values.FirstOrDefault() ?? default;
|
||||
GameModule? mode = RunTime.GameModuleLoader?.Modules.Values.FirstOrDefault() ?? default;
|
||||
if (mode is null)
|
||||
{
|
||||
ShowMessage(ShowMessageType.Error, ">> 缺少" + Config.FunGame_RoomType + "所需的模组,无法创建房间。");
|
||||
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")
|
||||
{
|
||||
await MainController.UpdateRoomAsync();
|
||||
@ -1056,7 +1056,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// <param name="e"></param>
|
||||
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, "未正确选择房间类型/游戏模组/游戏地图,请检查!");
|
||||
return;
|
||||
@ -1067,14 +1067,14 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
return;
|
||||
}
|
||||
string all = Constant.AllComboItem[0].ToString() ?? "全部";
|
||||
string modname = ComboGameMode.SelectedItem?.ToString() ?? all;
|
||||
string modname = ComboGameModule.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, ">> 模组未正确加载,无法创建房间。");
|
||||
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, ">> 地图未正确加载,无法创建房间。");
|
||||
return;
|
||||
@ -1103,7 +1103,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
private void CreateRoom_Click(object sender, EventArgs e)
|
||||
{
|
||||
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, "创建房间时不允许将房间类型/游戏模组/游戏地图的选项设置为[ 全部 ]。");
|
||||
return;
|
||||
@ -1114,19 +1114,19 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
return;
|
||||
}
|
||||
string all = Constant.AllComboItem[0].ToString() ?? "全部";
|
||||
string modname = ComboGameMode.SelectedItem?.ToString() ?? all;
|
||||
string modname = ComboGameModule.SelectedItem?.ToString() ?? all;
|
||||
string modmap = ComboGameMap.SelectedItem?.ToString() ?? all;
|
||||
if (modname == all || modmap == all)
|
||||
{
|
||||
ShowMessage(ShowMessageType.Warning, "创建房间时不允许将房间类型/游戏模组/游戏地图的选项设置为[ 全部 ]。");
|
||||
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, ">> 模组未正确加载,无法创建房间。");
|
||||
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, ">> 地图未正确加载,无法创建房间。");
|
||||
return;
|
||||
@ -1250,9 +1250,9 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
if (ComboRoomType.SelectedIndex >= 0)
|
||||
{
|
||||
SetRoomTypeString();
|
||||
ComboGameMode.Items.Clear();
|
||||
ComboGameMode.Items.AddRange(Constant.SupportedGameMode(Config.FunGame_RoomType));
|
||||
ComboGameMode.SelectedIndex = 0;
|
||||
ComboGameModule.Items.Clear();
|
||||
ComboGameModule.Items.AddRange(Constant.SupportedGameModule(Config.FunGame_RoomType));
|
||||
ComboGameModule.SelectedIndex = 0;
|
||||
ComboGameMap.Items.Clear();
|
||||
ComboGameMap.Items.Add("全部");
|
||||
ComboGameMap.SelectedIndex = 0;
|
||||
@ -1260,18 +1260,18 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换GameMode时,设置GameMap选项
|
||||
/// 切换GameModule时,设置GameMap选项
|
||||
/// </summary>
|
||||
/// <param name="sender"></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() ?? "";
|
||||
if (modname != "- 缺少模组 -" && RunTime.GameModeLoader != null && RunTime.GameModeLoader.Modes.ContainsKey(modname))
|
||||
string modname = ComboGameModule.SelectedItem?.ToString() ?? "";
|
||||
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);
|
||||
SetRoomTypeString();
|
||||
ComboGameMap.Items.Clear();
|
||||
@ -1603,8 +1603,8 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
case Constant.FunGame_CreateMix:
|
||||
if (Usercfg.InRoom.Roomid == "-1")
|
||||
{
|
||||
GameMode? mode = RunTime.GameModeLoader?.Modes.Values.FirstOrDefault() ?? default;
|
||||
if (mode != null) TaskUtility.NewTask(() => CreateRoom_Handler(RoomType.Mix, mode.Name, mode.DefaultMap, false));
|
||||
GameModule? module = RunTime.GameModuleLoader?.Modules.Values.FirstOrDefault() ?? default;
|
||||
if (module != null) TaskUtility.NewTask(() => CreateRoom_Handler(RoomType.Mix, module.Name, module.DefaultMap, false));
|
||||
else WritelnGameInfo(">> 缺少" + RoomSet.GetTypeString(RoomType.Mix) + "所需的模组,无法创建房间。此命令使用默认模组创建。");
|
||||
}
|
||||
else WritelnGameInfo(">> 先退出当前房间才可以创建房间。");
|
||||
@ -1612,8 +1612,8 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
case Constant.FunGame_CreateTeam:
|
||||
if (Usercfg.InRoom.Roomid == "-1")
|
||||
{
|
||||
GameMode? mode = RunTime.GameModeLoader?.Modes.Values.FirstOrDefault() ?? default;
|
||||
if (mode != null) TaskUtility.NewTask(() => CreateRoom_Handler(RoomType.Team, mode.Name, mode.DefaultMap, false));
|
||||
GameModule? module = RunTime.GameModuleLoader?.Modules.Values.FirstOrDefault() ?? default;
|
||||
if (module != null) TaskUtility.NewTask(() => CreateRoom_Handler(RoomType.Team, module.Name, module.DefaultMap, false));
|
||||
else WritelnGameInfo(">> 缺少" + RoomSet.GetTypeString(RoomType.Team) + "所需的模组,无法创建房间。此命令使用默认模组创建。");
|
||||
}
|
||||
else WritelnGameInfo(">> 先退出当前房间才可以创建房间。");
|
||||
@ -1967,7 +1967,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <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);
|
||||
Room room = General.HallInstance;
|
||||
@ -1978,7 +1978,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
RunTime.PluginLoader?.OnBeforeCreateRoomEvent(this, EventArgs);
|
||||
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")
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
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
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user