Add mod metadata, and filter valid mods on startup.
This commit is contained in:
@@ -267,7 +267,14 @@ namespace OpenRA
|
|||||||
Renderer.SheetSize = Settings.Game.SheetSize;
|
Renderer.SheetSize = Settings.Game.SheetSize;
|
||||||
Renderer = new Renderer();
|
Renderer = new Renderer();
|
||||||
|
|
||||||
LobbyInfo.GlobalSettings.Mods = Settings.Game.Mods;
|
Console.WriteLine("Available mods:");
|
||||||
|
foreach(var mod in ModData.AllMods)
|
||||||
|
Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version);
|
||||||
|
|
||||||
|
// Discard any invalid mods
|
||||||
|
LobbyInfo.GlobalSettings.Mods = Settings.Game.Mods.Where(m => ModData.AllMods.ContainsKey(m)).ToArray();
|
||||||
|
Console.WriteLine("Loading mods: {0}",string.Join(",",LobbyInfo.GlobalSettings.Mods));
|
||||||
|
|
||||||
modData = new ModData( LobbyInfo.GlobalSettings.Mods );
|
modData = new ModData( LobbyInfo.GlobalSettings.Mods );
|
||||||
|
|
||||||
Sound.Initialize();
|
Sound.Initialize();
|
||||||
|
|||||||
@@ -19,6 +19,35 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
public class ModData
|
public class ModData
|
||||||
{
|
{
|
||||||
|
public static readonly Dictionary<string,Mod> AllMods = ValidateMods(Directory.GetDirectories("mods").Select(x => x.Substring(5)).ToArray());
|
||||||
|
|
||||||
|
public static Dictionary<string,Mod> ValidateMods(string[] mods)
|
||||||
|
{
|
||||||
|
var ret = new Dictionary<string,Mod>();
|
||||||
|
foreach (var m in mods)
|
||||||
|
{
|
||||||
|
if (!File.Exists("mods" + Path.DirectorySeparatorChar + m + Path.DirectorySeparatorChar + "mod.yaml"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var yaml = new MiniYaml( null, MiniYaml.FromFile("mods" + Path.DirectorySeparatorChar + m + Path.DirectorySeparatorChar + "mod.yaml"));
|
||||||
|
if (!yaml.NodesDict.ContainsKey("Metadata"))
|
||||||
|
{
|
||||||
|
System.Console.WriteLine("Invalid mod: "+m);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.Add(m,FieldLoader.Load<Mod>(yaml.NodesDict["Metadata"]));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Mod
|
||||||
|
{
|
||||||
|
public string Title;
|
||||||
|
public string Description;
|
||||||
|
public string Version;
|
||||||
|
}
|
||||||
|
|
||||||
public readonly Manifest Manifest;
|
public readonly Manifest Manifest;
|
||||||
public readonly ObjectCreator ObjectCreator;
|
public readonly ObjectCreator ObjectCreator;
|
||||||
public readonly SheetBuilder SheetBuilder;
|
public readonly SheetBuilder SheetBuilder;
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
# Classic Command and Conquer -- Package Manifest
|
Metadata:
|
||||||
|
Title: Command & Conquer
|
||||||
|
Description: OpenRA Reimagining of the classic game
|
||||||
|
Version: a0001
|
||||||
|
|
||||||
Folders:
|
Folders:
|
||||||
.
|
.
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
# Default Game Mod
|
Metadata:
|
||||||
|
Title: Default Mod Template
|
||||||
|
Description: Minimal template for creating a base mod
|
||||||
|
Version: a0001
|
||||||
|
|
||||||
Folders:
|
Folders:
|
||||||
.
|
.
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
# Classic Red Alert Mod -- Package Manifest
|
Metadata:
|
||||||
|
Title: Red Alert
|
||||||
|
Description: OpenRA Reimagining of the classic game
|
||||||
|
Version: a0001
|
||||||
|
|
||||||
Folders:
|
Folders:
|
||||||
.
|
.
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
# RA Performance Tests -- Package Manifest
|
Metadata:
|
||||||
|
Title: RA Perf
|
||||||
|
Description: Performance Test map pack
|
||||||
|
Version: a0001
|
||||||
|
|
||||||
Folders:
|
Folders:
|
||||||
./mods/ra_perf
|
./mods/ra_perf
|
||||||
|
|||||||
Reference in New Issue
Block a user