public static Dictionary <string, Mod> ValidateMods(string[] mods) { var ret = new Dictionary <string, Mod>(); foreach (var m in mods) { var yamlPath = new[] { "mods", m, "mod.yaml" }.Aggregate(Path.Combine); if (!File.Exists(yamlPath)) { continue; } var yaml = new MiniYaml(null, MiniYaml.FromFile(yamlPath)); if (!yaml.NodesDict.ContainsKey("Metadata")) { continue; } var mod = FieldLoader.Load <Mod>(yaml.NodesDict["Metadata"]); mod.Id = m; ret.Add(m, mod); } return(ret); }
public Manifest(string[] mods) { Mods = mods; var yaml = new MiniYaml(null, mods .Select(m => MiniYaml.FromFile("mods/" + m + "/mod.yaml")) .Aggregate(MiniYaml.MergeLiberal)).NodesDict; // Todo: Use fieldloader Folders = YamlList(yaml, "Folders"); Packages = YamlList(yaml, "Packages"); Rules = YamlList(yaml, "Rules"); ServerTraits = YamlList(yaml, "ServerTraits"); Sequences = YamlList(yaml, "Sequences"); Cursors = YamlList(yaml, "Cursors"); Chrome = YamlList(yaml, "Chrome"); Assemblies = YamlList(yaml, "Assemblies"); ChromeLayout = YamlList(yaml, "ChromeLayout"); Weapons = YamlList(yaml, "Weapons"); Voices = YamlList(yaml, "Voices"); Notifications = YamlList(yaml, "Notifications"); Music = YamlList(yaml, "Music"); Movies = YamlList(yaml, "Movies"); TileSets = YamlList(yaml, "TileSets"); ChromeMetrics = YamlList(yaml, "ChromeMetrics"); LoadScreen = yaml["LoadScreen"]; Fonts = yaml["Fonts"].NodesDict.ToDictionary(x => x.Key, x => Pair.New(x.Value.NodesDict["Font"].Value, int.Parse(x.Value.NodesDict["Size"].Value))); if (yaml.ContainsKey("TileSize")) { TileSize = int.Parse(yaml["TileSize"].Value); } }
public Manifest(string mod) { var path = new[] { "mods", mod, "mod.yaml" }.Aggregate(Path.Combine); var yaml = new MiniYaml(null, MiniYaml.FromFile(path)).NodesDict; Mod = FieldLoader.Load <Mod>(yaml["Metadata"]); Mod.Id = mod; // TODO: Use fieldloader Folders = YamlList(yaml, "Folders"); MapFolders = YamlList(yaml, "MapFolders"); Packages = yaml["Packages"].NodesDict.ToDictionary(x => x.Key, x => x.Value.Value); Rules = YamlList(yaml, "Rules"); ServerTraits = YamlList(yaml, "ServerTraits"); Sequences = YamlList(yaml, "Sequences"); VoxelSequences = YamlList(yaml, "VoxelSequences"); Cursors = YamlList(yaml, "Cursors"); Chrome = YamlList(yaml, "Chrome"); Assemblies = YamlList(yaml, "Assemblies"); ChromeLayout = YamlList(yaml, "ChromeLayout"); Weapons = YamlList(yaml, "Weapons"); Voices = YamlList(yaml, "Voices"); Notifications = YamlList(yaml, "Notifications"); Music = YamlList(yaml, "Music"); Movies = YamlList(yaml, "Movies"); Translations = YamlList(yaml, "Translations"); TileSets = YamlList(yaml, "TileSets"); ChromeMetrics = YamlList(yaml, "ChromeMetrics"); PackageContents = YamlList(yaml, "PackageContents"); LuaScripts = YamlList(yaml, "LuaScripts"); LoadScreen = yaml["LoadScreen"]; LobbyDefaults = yaml["LobbyDefaults"]; Fonts = yaml["Fonts"].NodesDict.ToDictionary(x => x.Key, x => Pair.New(x.Value.NodesDict["Font"].Value, int.Parse(x.Value.NodesDict["Size"].Value))); if (yaml.ContainsKey("TileSize")) { TileSize = int.Parse(yaml["TileSize"].Value); } // Allow inherited mods to import parent maps. var compat = new List <string>(); compat.Add(mod); if (yaml.ContainsKey("SupportsMapsFrom")) { foreach (var c in yaml["SupportsMapsFrom"].Value.Split(',')) { compat.Add(c.Trim()); } } MapCompatibility = compat.ToArray(); }