diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 6ef06af877..d5e0eb6be8 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -306,7 +306,7 @@ namespace OpenRA Mods = new InstalledMods(); Console.WriteLine("Available mods:"); foreach (var mod in Mods) - Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Mod.Title, mod.Value.Mod.Version); + Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Metadata.Title, mod.Value.Metadata.Version); InitializeMod(Settings.Game.Mod, args); } @@ -319,7 +319,7 @@ namespace OpenRA public static bool IsModInstalled(KeyValuePair mod) { return Mods.ContainsKey(mod.Key) - && Mods[mod.Key].Mod.Version == mod.Value + && Mods[mod.Key].Metadata.Version == mod.Value && IsModInstalled(mod.Key); } @@ -471,7 +471,7 @@ namespace OpenRA ThreadPool.QueueUserWorkItem(_ => { - var mod = ModData.Manifest.Mod; + var mod = ModData.Manifest.Metadata; var directory = Platform.ResolvePath("^", "Screenshots", ModData.Manifest.Id, mod.Version); Directory.CreateDirectory(directory); diff --git a/OpenRA.Game/Manifest.cs b/OpenRA.Game/Manifest.cs index 6bcc24d924..a2ef3c7c81 100644 --- a/OpenRA.Game/Manifest.cs +++ b/OpenRA.Game/Manifest.cs @@ -31,12 +31,21 @@ namespace OpenRA } } + public class ModMetadata + { + public string Title; + public string Description; + public string Version; + public string Author; + public bool Hidden; + } + /// Describes what is to be loaded in order to run a mod. public class Manifest { public readonly string Id; public readonly IReadOnlyPackage Package; - public readonly ModMetadata Mod; + public readonly ModMetadata Metadata; public readonly string[] Rules, ServerTraits, Sequences, VoxelSequences, Cursors, Chrome, Assemblies, ChromeLayout, @@ -70,7 +79,7 @@ namespace OpenRA Package = package; yaml = new MiniYaml(null, MiniYaml.FromStream(package.GetStream("mod.yaml"), "mod.yaml")).ToDictionary(); - Mod = FieldLoader.Load(yaml["Metadata"]); + Metadata = FieldLoader.Load(yaml["Metadata"]); // TODO: Use fieldloader MapFolders = YamlDictionary(yaml, "MapFolders"); diff --git a/OpenRA.Game/ModMetadata.cs b/OpenRA.Game/ModMetadata.cs deleted file mode 100644 index f8e039f79a..0000000000 --- a/OpenRA.Game/ModMetadata.cs +++ /dev/null @@ -1,22 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2016 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. For more - * information, see COPYING. - */ -#endregion - -namespace OpenRA -{ - public class ModMetadata - { - public string Title; - public string Description; - public string Version; - public string Author; - public bool Hidden; - } -} diff --git a/OpenRA.Game/Network/GameServer.cs b/OpenRA.Game/Network/GameServer.cs index 5110aecd52..5060309d31 100644 --- a/OpenRA.Game/Network/GameServer.cs +++ b/OpenRA.Game/Network/GameServer.cs @@ -44,8 +44,8 @@ namespace OpenRA.Network { ModId = modVersion[0]; ModVersion = modVersion[1]; - ModLabel = "{0} ({1})".F(mod.Mod.Title, modVersion[1]); - IsCompatible = Game.Settings.Debug.IgnoreVersionMismatch || ModVersion == mod.Mod.Version; + ModLabel = "{0} ({1})".F(mod.Metadata.Title, modVersion[1]); + IsCompatible = Game.Settings.Debug.IgnoreVersionMismatch || ModVersion == mod.Metadata.Version; } else ModLabel = "Unknown mod: {0}".F(Mods); diff --git a/OpenRA.Game/Network/ReplayRecorder.cs b/OpenRA.Game/Network/ReplayRecorder.cs index cf694694cc..f2c33c7da0 100644 --- a/OpenRA.Game/Network/ReplayRecorder.cs +++ b/OpenRA.Game/Network/ReplayRecorder.cs @@ -45,7 +45,7 @@ namespace OpenRA.Network { var filename = chooseFilename(); var mod = Game.ModData.Manifest; - var dir = Platform.ResolvePath("^", "Replays", mod.Id, mod.Mod.Version); + var dir = Platform.ResolvePath("^", "Replays", mod.Id, mod.Metadata.Version); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); diff --git a/OpenRA.Game/Network/SyncReport.cs b/OpenRA.Game/Network/SyncReport.cs index 4dc3ce1ec8..1e405b7c8e 100644 --- a/OpenRA.Game/Network/SyncReport.cs +++ b/OpenRA.Game/Network/SyncReport.cs @@ -96,7 +96,7 @@ namespace OpenRA.Network { if (r.Frame == frame) { - var mod = Game.ModData.Manifest.Mod; + var mod = Game.ModData.Manifest.Metadata; Log.Write("sync", "Player: {0} ({1} {2} {3})", Game.Settings.Player.Name, Platform.CurrentPlatform, Environment.OSVersion, Platform.RuntimeVersion); Log.Write("sync", "Game ID: {0} (Mod: {1} at Version {2})", orderManager.LobbyInfo.GlobalSettings.GameUid, mod.Title, mod.Version); Log.Write("sync", "Sync for net frame {0} -------------", r.Frame); diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index 5301d9ec61..c4461f0e44 100644 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -138,7 +138,7 @@ namespace OpenRA.Network Manifest serverMod; if (request.Mod != mod.Id && Game.Mods.TryGetValue(request.Mod, out serverMod) && - serverMod.Mod.Version == request.Version) + serverMod.Metadata.Version == request.Version) { var replay = orderManager.Connection as ReplayConnection; var launchCommand = replay != null ? @@ -170,7 +170,7 @@ namespace OpenRA.Network { Client = info, Mod = mod.Id, - Version = mod.Mod.Version, + Version = mod.Metadata.Version, Password = orderManager.Password }; diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 399078bb9e..031793d901 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -204,7 +204,6 @@ - diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 479c7421a8..f01b7718b7 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -263,7 +263,7 @@ namespace OpenRA.Server var request = new HandshakeRequest { Mod = ModData.Manifest.Id, - Version = ModData.Manifest.Mod.Version, + Version = ModData.Manifest.Metadata.Version, Map = LobbyInfo.GlobalSettings.Map }; @@ -337,7 +337,7 @@ namespace OpenRA.Server return; } - if (ModData.Manifest.Mod.Version != handshake.Version && !LobbyInfo.GlobalSettings.AllowVersionMismatch) + if (ModData.Manifest.Metadata.Version != handshake.Version && !LobbyInfo.GlobalSettings.AllowVersionMismatch) { Log.Write("server", "Rejected connection from {0}; Not running the same version.", newConn.Socket.RemoteEndPoint); diff --git a/OpenRA.Game/Support/Program.cs b/OpenRA.Game/Support/Program.cs index 193790bdfe..b359d6da50 100644 --- a/OpenRA.Game/Support/Program.cs +++ b/OpenRA.Game/Support/Program.cs @@ -52,7 +52,7 @@ namespace OpenRA if (Game.ModData != null) { - var mod = Game.ModData.Manifest.Mod; + var mod = Game.ModData.Manifest.Metadata; Log.Write("exception", "{0} Mod at Version {1}", mod.Title, mod.Version); } diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index d0967b0d7d..e83c9d4027 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -177,7 +177,7 @@ namespace OpenRA gameInfo = new GameInformation { Mod = Game.ModData.Manifest.Id, - Version = Game.ModData.Manifest.Mod.Version, + Version = Game.ModData.Manifest.Metadata.Version, MapUid = Map.Uid, MapTitle = Map.Title diff --git a/OpenRA.Mods.Cnc/CncLoadScreen.cs b/OpenRA.Mods.Cnc/CncLoadScreen.cs index 39df630e11..7b7b6f50ba 100644 --- a/OpenRA.Mods.Cnc/CncLoadScreen.cs +++ b/OpenRA.Mods.Cnc/CncLoadScreen.cs @@ -68,7 +68,7 @@ namespace OpenRA.Mods.Cnc brightBlock = new Sprite(sheet, new Rectangle(320, 0, 16, 35), TextureChannel.Alpha); dimBlock = new Sprite(sheet, new Rectangle(336, 0, 16, 35), TextureChannel.Alpha); - versionText = modData.Manifest.Mod.Version; + versionText = modData.Manifest.Metadata.Version; } bool setup; diff --git a/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs b/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs index 2e555b9151..f55ee18d98 100644 --- a/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs +++ b/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs @@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Server (int)server.State, numPlayers, numBots, - "{0}@{1}".F(mod.Id, mod.Mod.Version), + "{0}@{1}".F(mod.Id, mod.Metadata.Version), server.LobbyInfo.GlobalSettings.Map, numSlots, numSpectators, diff --git a/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs index a4ff23234a..087946283c 100644 --- a/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs +++ b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var maps = new List(); if (args.Length < 2) { - Console.WriteLine("Testing mod: {0}".F(modData.Manifest.Mod.Title)); + Console.WriteLine("Testing mod: {0}".F(modData.Manifest.Metadata.Title)); // Run all rule checks on the default mod rules. CheckRules(modData, modData.DefaultRules); diff --git a/OpenRA.Mods.Common/UtilityCommands/ExtractLuaDocsCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ExtractLuaDocsCommand.cs index febdd5fc01..b5b69321a7 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ExtractLuaDocsCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ExtractLuaDocsCommand.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.UtilityCommands // HACK: The engine code assumes that Game.modData is set. Game.ModData = utility.ModData; - Console.WriteLine("This is an automatically generated listing of the new Lua map scripting API, generated for {0} of OpenRA.", Game.ModData.Manifest.Mod.Version); + Console.WriteLine("This is an automatically generated listing of the new Lua map scripting API, generated for {0} of OpenRA.", Game.ModData.Manifest.Metadata.Version); Console.WriteLine(); Console.WriteLine("OpenRA allows custom maps and missions to be scripted using Lua 5.1.\n" + "These scripts run in a sandbox that prevents access to unsafe functions (e.g. OS or file access), " + diff --git a/OpenRA.Mods.Common/UtilityCommands/ExtractSettingsDocsCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ExtractSettingsDocsCommand.cs index 92a480513a..f62e26c3d4 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ExtractSettingsDocsCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ExtractSettingsDocsCommand.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.UtilityCommands Console.WriteLine( "This documentation is aimed at server administrators. It displays all settings with default values and description. " + "Please do not edit it directly, but add new `[Desc(\"String\")]` tags to the source code. This file has been " + - "automatically generated for version {0} of OpenRA.", utility.ModData.Manifest.Mod.Version); + "automatically generated for version {0} of OpenRA.", utility.ModData.Manifest.Metadata.Version); Console.WriteLine(); Console.WriteLine("All settings can be changed by starting the game via a command-line parameter like `Game.Mod=ra`."); Console.WriteLine(); diff --git a/OpenRA.Mods.Common/UtilityCommands/ExtractTraitDocsCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ExtractTraitDocsCommand.cs index ae64508d60..b0f6bda5af 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ExtractTraitDocsCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ExtractTraitDocsCommand.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.UtilityCommands Console.WriteLine( "This documentation is aimed at modders. It displays all traits with default values and developer commentary. " + "Please do not edit it directly, but add new `[Desc(\"String\")]` tags to the source code. This file has been " + - "automatically generated for version {0} of OpenRA.", utility.ModData.Manifest.Mod.Version); + "automatically generated for version {0} of OpenRA.", utility.ModData.Manifest.Metadata.Version); Console.WriteLine(); var toc = new StringBuilder(); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs index c30fa9b229..32c152ce12 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (mpe != null) mpe.Fade(mpe.Info.MenuEffect); - menu.Get("VERSION_LABEL").Text = modData.Manifest.Mod.Version; + menu.Get("VERSION_LABEL").Text = modData.Manifest.Metadata.Version; var hideMenu = false; menu.Get("MENU_BUTTONS").IsVisible = () => !hideMenu; diff --git a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs index 71960401ae..9c62478ecf 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs @@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic public MainMenuLogic(Widget widget, World world, ModData modData) { rootMenu = widget; - rootMenu.Get("VERSION_LABEL").Text = modData.Manifest.Mod.Version; + rootMenu.Get("VERSION_LABEL").Text = modData.Manifest.Metadata.Version; // Menu buttons var mainMenu = widget.Get("MAIN_MENU"); @@ -283,9 +283,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic { // Send the mod and engine version to support version-filtered news (update prompts) var newsURL = Game.Settings.Game.NewsUrl + "?version={0}&mod={1}&modversion={2}".F( - Uri.EscapeUriString(Game.Mods["modchooser"].Mod.Version), + Uri.EscapeUriString(Game.Mods["modchooser"].Metadata.Version), Uri.EscapeUriString(Game.ModData.Manifest.Id), - Uri.EscapeUriString(Game.ModData.Manifest.Mod.Version)); + Uri.EscapeUriString(Game.ModData.Manifest.Metadata.Version)); // Append system profile data if the player has opted in if (Game.Settings.Debug.SendSystemInformation) diff --git a/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs index 024c1f8224..4ff00d3252 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs @@ -69,9 +69,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic modTemplate = modList.Get("MOD_TEMPLATE"); modChooserPanel.Get("MOD_DESC").GetText = () => selectedDescription; - modChooserPanel.Get("MOD_TITLE").GetText = () => selectedMod.Mod.Title; + modChooserPanel.Get("MOD_TITLE").GetText = () => selectedMod.Metadata.Title; modChooserPanel.Get("MOD_AUTHOR").GetText = () => selectedAuthor; - modChooserPanel.Get("MOD_VERSION").GetText = () => selectedMod.Mod.Version; + modChooserPanel.Get("MOD_VERSION").GetText = () => selectedMod.Metadata.Version; var prevMod = modChooserPanel.Get("PREV_MOD"); prevMod.OnClick = () => { modOffset -= 1; RebuildModList(); }; @@ -89,8 +89,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic }; sheetBuilder = new SheetBuilder(SheetType.BGRA); - allMods = Game.Mods.Values.Where(m => !m.Mod.Hidden) - .OrderBy(m => m.Mod.Title) + allMods = Game.Mods.Values.Where(m => !m.Metadata.Hidden) + .OrderBy(m => m.Metadata.Title) .ToArray(); // Load preview images, and eat any errors @@ -153,7 +153,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic SelectMod(mod); }; - item.TooltipText = mod.Mod.Title; + item.TooltipText = mod.Metadata.Title; if (j < 9) item.Key = new Hotkey((Keycode)((int)Keycode.NUMBER_1 + j), Modifiers.None); @@ -170,8 +170,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic void SelectMod(Manifest mod) { selectedMod = mod; - selectedAuthor = "By " + (mod.Mod.Author ?? "unknown author"); - selectedDescription = (mod.Mod.Description ?? "").Replace("\\n", "\n"); + selectedAuthor = "By " + (mod.Metadata.Author ?? "unknown author"); + selectedDescription = (mod.Metadata.Description ?? "").Replace("\\n", "\n"); var selectedIndex = Array.IndexOf(allMods, mod); if (selectedIndex - modOffset > 4) modOffset = selectedIndex - 4; diff --git a/OpenRA.Mods.Common/Widgets/Logic/MultiplayerLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MultiplayerLogic.cs index 1150d526e0..da706eb8fd 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MultiplayerLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MultiplayerLogic.cs @@ -316,9 +316,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic }; var queryURL = Game.Settings.Server.MasterServer + "games?version={0}&mod={1}&modversion={2}".F( - Uri.EscapeUriString(Game.Mods["modchooser"].Mod.Version), + Uri.EscapeUriString(Game.Mods["modchooser"].Metadata.Version), Uri.EscapeUriString(Game.ModData.Manifest.Id), - Uri.EscapeUriString(Game.ModData.Manifest.Mod.Version)); + Uri.EscapeUriString(Game.ModData.Manifest.Metadata.Version)); currentQuery = new Download(queryURL, _ => { }, onComplete); } diff --git a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs index 2c114d0551..291697159d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs @@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var template = panel.Get("REPLAY_TEMPLATE"); var mod = modData.Manifest; - var dir = Platform.ResolvePath("^", "Replays", mod.Id, mod.Mod.Version); + var dir = Platform.ResolvePath("^", "Replays", mod.Id, mod.Metadata.Version); if (Directory.Exists(dir)) ThreadPool.QueueUserWorkItem(_ => LoadReplays(dir, template)); diff --git a/OpenRA.Mods.Common/Widgets/Logic/ReplayUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/ReplayUtils.cs index ed7f0b0588..7df19548ef 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ReplayUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ReplayUtils.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (!Game.Mods.ContainsKey(mod)) return IncompatibleReplayDialog("unavailable mod", mod, onCancel); - if (Game.Mods[mod].Mod.Version != version) + if (Game.Mods[mod].Metadata.Version != version) return IncompatibleReplayDialog("incompatible version", version, onCancel); if (replayMeta.GameInfo.MapPreview.Status != MapStatus.Available)