Rename ModInformation to ModMetadata
This commit is contained in:
@@ -29,7 +29,7 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
currentMod = args.FirstOrDefault() ?? "ra";
|
currentMod = args.FirstOrDefault() ?? "ra";
|
||||||
|
|
||||||
toolStripComboBox1.Items.AddRange(ModInformation.AllMods.Keys.ToArray());
|
toolStripComboBox1.Items.AddRange(ModMetadata.AllMods.Keys.ToArray());
|
||||||
|
|
||||||
toolStripComboBox1.SelectedIndexChanged += (_, e) =>
|
toolStripComboBox1.SelectedIndexChanged += (_, e) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Available mods:");
|
Console.WriteLine("Available mods:");
|
||||||
foreach (var mod in ModInformation.AllMods)
|
foreach (var mod in ModMetadata.AllMods)
|
||||||
Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version);
|
Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version);
|
||||||
|
|
||||||
InitializeWithMod(Settings.Game.Mod, args.GetValue("Launch.Replay", null));
|
InitializeWithMod(Settings.Game.Mod, args.GetValue("Launch.Replay", null));
|
||||||
@@ -385,7 +385,7 @@ namespace OpenRA
|
|||||||
orderManager.Dispose();
|
orderManager.Dispose();
|
||||||
|
|
||||||
// Fall back to default if the mod doesn't exist
|
// Fall back to default if the mod doesn't exist
|
||||||
if (!ModInformation.AllMods.ContainsKey(mod))
|
if (!ModMetadata.AllMods.ContainsKey(mod))
|
||||||
mod = new GameSettings().Mod;
|
mod = new GameSettings().Mod;
|
||||||
|
|
||||||
Console.WriteLine("Loading mod: {0}", mod);
|
Console.WriteLine("Loading mod: {0}", mod);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenRA
|
|||||||
// Describes what is to be loaded in order to run a mod
|
// Describes what is to be loaded in order to run a mod
|
||||||
public class Manifest
|
public class Manifest
|
||||||
{
|
{
|
||||||
public readonly ModInformation Mod;
|
public readonly ModMetadata Mod;
|
||||||
public readonly string[]
|
public readonly string[]
|
||||||
Folders, MapFolders, Rules, ServerTraits,
|
Folders, MapFolders, Rules, ServerTraits,
|
||||||
Sequences, VoxelSequences, Cursors, Chrome, Assemblies, ChromeLayout,
|
Sequences, VoxelSequences, Cursors, Chrome, Assemblies, ChromeLayout,
|
||||||
@@ -38,7 +38,7 @@ namespace OpenRA
|
|||||||
var path = new[] { "mods", mod, "mod.yaml" }.Aggregate(Path.Combine);
|
var path = new[] { "mods", mod, "mod.yaml" }.Aggregate(Path.Combine);
|
||||||
var yaml = new MiniYaml(null, MiniYaml.FromFile(path)).NodesDict;
|
var yaml = new MiniYaml(null, MiniYaml.FromFile(path)).NodesDict;
|
||||||
|
|
||||||
Mod = FieldLoader.Load<ModInformation>(yaml["Metadata"]);
|
Mod = FieldLoader.Load<ModMetadata>(yaml["Metadata"]);
|
||||||
Mod.Id = mod;
|
Mod.Id = mod;
|
||||||
|
|
||||||
// TODO: Use fieldloader
|
// TODO: Use fieldloader
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
public class ModInformation
|
public class ModMetadata
|
||||||
{
|
{
|
||||||
public static readonly Dictionary<string, ModInformation> AllMods = ValidateMods(Directory.GetDirectories("mods").Select(x => x.Substring(5)).ToArray());
|
public static readonly Dictionary<string, ModMetadata> AllMods = ValidateMods(Directory.GetDirectories("mods").Select(x => x.Substring(5)).ToArray());
|
||||||
|
|
||||||
public string Id;
|
public string Id;
|
||||||
public string Title;
|
public string Title;
|
||||||
@@ -24,9 +24,9 @@ namespace OpenRA
|
|||||||
public string Version;
|
public string Version;
|
||||||
public string Author;
|
public string Author;
|
||||||
|
|
||||||
public static Dictionary<string, ModInformation> ValidateMods(string[] mods)
|
public static Dictionary<string, ModMetadata> ValidateMods(string[] mods)
|
||||||
{
|
{
|
||||||
var ret = new Dictionary<string, ModInformation>();
|
var ret = new Dictionary<string, ModMetadata>();
|
||||||
foreach (var m in mods)
|
foreach (var m in mods)
|
||||||
{
|
{
|
||||||
var yamlPath = new[] { "mods", m, "mod.yaml" }.Aggregate(Path.Combine);
|
var yamlPath = new[] { "mods", m, "mod.yaml" }.Aggregate(Path.Combine);
|
||||||
@@ -37,7 +37,7 @@ namespace OpenRA
|
|||||||
if (!yaml.NodesDict.ContainsKey("Metadata"))
|
if (!yaml.NodesDict.ContainsKey("Metadata"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var mod = FieldLoader.Load<ModInformation>(yaml.NodesDict["Metadata"]);
|
var mod = FieldLoader.Load<ModMetadata>(yaml.NodesDict["Metadata"]);
|
||||||
mod.Id = m;
|
mod.Id = m;
|
||||||
|
|
||||||
ret.Add(m, mod);
|
ret.Add(m, mod);
|
||||||
@@ -244,7 +244,7 @@
|
|||||||
<Compile Include="Scripting\ScriptPlayerInterface.cs" />
|
<Compile Include="Scripting\ScriptPlayerInterface.cs" />
|
||||||
<Compile Include="Traits\Player\FixedColorPalette.cs" />
|
<Compile Include="Traits\Player\FixedColorPalette.cs" />
|
||||||
<Compile Include="Primitives\ReadOnlyDictionary.cs" />
|
<Compile Include="Primitives\ReadOnlyDictionary.cs" />
|
||||||
<Compile Include="ModInformation.cs" />
|
<Compile Include="ModMetadata.cs" />
|
||||||
<Compile Include="GameRules\Ruleset.cs" />
|
<Compile Include="GameRules\Ruleset.cs" />
|
||||||
<Compile Include="GameRules\RulesetCache.cs" />
|
<Compile Include="GameRules\RulesetCache.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
Widget modList;
|
Widget modList;
|
||||||
ButtonWidget modTemplate;
|
ButtonWidget modTemplate;
|
||||||
ModInformation[] allMods;
|
ModMetadata[] allMods;
|
||||||
ModInformation selectedMod;
|
ModMetadata selectedMod;
|
||||||
string selectedAuthor;
|
string selectedAuthor;
|
||||||
string selectedDescription;
|
string selectedDescription;
|
||||||
int modOffset = 0;
|
int modOffset = 0;
|
||||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var sheetBuilder = new SheetBuilder(SheetType.BGRA);
|
var sheetBuilder = new SheetBuilder(SheetType.BGRA);
|
||||||
previews = new Dictionary<string, Sprite>();
|
previews = new Dictionary<string, Sprite>();
|
||||||
logos = new Dictionary<string, Sprite>();
|
logos = new Dictionary<string, Sprite>();
|
||||||
allMods = ModInformation.AllMods.Values.Where(m => m.Id != "modchooser")
|
allMods = ModMetadata.AllMods.Values.Where(m => m.Id != "modchooser")
|
||||||
.OrderBy(m => m.Title)
|
.OrderBy(m => m.Title)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
@@ -96,9 +96,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ModInformation initialMod = null;
|
ModMetadata initialMod = null;
|
||||||
ModInformation.AllMods.TryGetValue(Game.Settings.Game.PreviousMod, out initialMod);
|
ModMetadata.AllMods.TryGetValue(Game.Settings.Game.PreviousMod, out initialMod);
|
||||||
SelectMod(initialMod ?? ModInformation.AllMods["ra"]);
|
SelectMod(initialMod ?? ModMetadata.AllMods["ra"]);
|
||||||
|
|
||||||
RebuildModList();
|
RebuildModList();
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectMod(ModInformation mod)
|
void SelectMod(ModMetadata mod)
|
||||||
{
|
{
|
||||||
selectedMod = mod;
|
selectedMod = mod;
|
||||||
selectedAuthor = "By " + mod.Author ?? "unknown author";
|
selectedAuthor = "By " + mod.Author ?? "unknown author";
|
||||||
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
modOffset = selectedIndex - 4;
|
modOffset = selectedIndex - 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadMod(ModInformation mod)
|
void LoadMod(ModMetadata mod)
|
||||||
{
|
{
|
||||||
Game.RunAfterTick(() =>
|
Game.RunAfterTick(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -315,10 +315,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
public static string GenerateModLabel(GameServer s)
|
public static string GenerateModLabel(GameServer s)
|
||||||
{
|
{
|
||||||
ModInformation mod;
|
ModMetadata mod;
|
||||||
var modVersion = s.Mods.Split('@');
|
var modVersion = s.Mods.Split('@');
|
||||||
|
|
||||||
if (modVersion.Length == 2 && ModInformation.AllMods.TryGetValue(modVersion[0], out mod))
|
if (modVersion.Length == 2 && ModMetadata.AllMods.TryGetValue(modVersion[0], out mod))
|
||||||
return "{0} ({1})".F(mod.Title, modVersion[1]);
|
return "{0} ({1})".F(mod.Title, modVersion[1]);
|
||||||
|
|
||||||
return "Unknown mod: {0}".F(s.Mods);
|
return "Unknown mod: {0}".F(s.Mods);
|
||||||
|
|||||||
Reference in New Issue
Block a user