Rename Manifest.Mod -> Metadata.
This commit is contained in:
@@ -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<string, string> 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);
|
||||
|
||||
|
||||
@@ -31,12 +31,21 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
public class ModMetadata
|
||||
{
|
||||
public string Title;
|
||||
public string Description;
|
||||
public string Version;
|
||||
public string Author;
|
||||
public bool Hidden;
|
||||
}
|
||||
|
||||
/// <summary> Describes what is to be loaded in order to run a mod. </summary>
|
||||
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<ModMetadata>(yaml["Metadata"]);
|
||||
Metadata = FieldLoader.Load<ModMetadata>(yaml["Metadata"]);
|
||||
|
||||
// TODO: Use fieldloader
|
||||
MapFolders = YamlDictionary(yaml, "MapFolders");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
|
||||
@@ -204,7 +204,6 @@
|
||||
<Compile Include="Traits\Player\FixedColorPalette.cs" />
|
||||
<Compile Include="Primitives\ReadOnlyDictionary.cs" />
|
||||
<Compile Include="Primitives\ReadOnlyList.cs" />
|
||||
<Compile Include="ModMetadata.cs" />
|
||||
<Compile Include="GameRules\Ruleset.cs" />
|
||||
<Compile Include="Support\MersenneTwister.cs" />
|
||||
<Compile Include="GameInformation.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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
var maps = new List<Map>();
|
||||
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);
|
||||
|
||||
@@ -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), " +
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (mpe != null)
|
||||
mpe.Fade(mpe.Info.MenuEffect);
|
||||
|
||||
menu.Get<LabelWidget>("VERSION_LABEL").Text = modData.Manifest.Mod.Version;
|
||||
menu.Get<LabelWidget>("VERSION_LABEL").Text = modData.Manifest.Metadata.Version;
|
||||
|
||||
var hideMenu = false;
|
||||
menu.Get("MENU_BUTTONS").IsVisible = () => !hideMenu;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public MainMenuLogic(Widget widget, World world, ModData modData)
|
||||
{
|
||||
rootMenu = widget;
|
||||
rootMenu.Get<LabelWidget>("VERSION_LABEL").Text = modData.Manifest.Mod.Version;
|
||||
rootMenu.Get<LabelWidget>("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)
|
||||
|
||||
@@ -69,9 +69,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
modTemplate = modList.Get<ButtonWidget>("MOD_TEMPLATE");
|
||||
|
||||
modChooserPanel.Get<LabelWidget>("MOD_DESC").GetText = () => selectedDescription;
|
||||
modChooserPanel.Get<LabelWidget>("MOD_TITLE").GetText = () => selectedMod.Mod.Title;
|
||||
modChooserPanel.Get<LabelWidget>("MOD_TITLE").GetText = () => selectedMod.Metadata.Title;
|
||||
modChooserPanel.Get<LabelWidget>("MOD_AUTHOR").GetText = () => selectedAuthor;
|
||||
modChooserPanel.Get<LabelWidget>("MOD_VERSION").GetText = () => selectedMod.Mod.Version;
|
||||
modChooserPanel.Get<LabelWidget>("MOD_VERSION").GetText = () => selectedMod.Metadata.Version;
|
||||
|
||||
var prevMod = modChooserPanel.Get<ButtonWidget>("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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var template = panel.Get<ScrollItemWidget>("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));
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user