public CncModBrowserLogic([ObjectCreator.Param] Widget widget, [ObjectCreator.Param] Action onSwitch, [ObjectCreator.Param] Action onExit) { var panel = widget.GetWidget("MODS_PANEL"); var modList = panel.GetWidget<ScrollPanelWidget>("MOD_LIST"); var loadButton = panel.GetWidget<ButtonWidget>("LOAD_BUTTON"); loadButton.OnClick = () => LoadMod(currentMod.Id, onSwitch); loadButton.IsDisabled = () => currentMod.Id == Game.CurrentMods.Keys.First(); panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); }; currentMod = Mod.AllMods[Game.modData.Manifest.Mods[0]]; // Mod list var modTemplate = modList.GetWidget<ScrollItemWidget>("MOD_TEMPLATE"); foreach (var m in Mod.AllMods) { var mod = m.Value; var item = ScrollItemWidget.Setup(modTemplate, () => currentMod == mod, () => currentMod = mod); item.GetWidget<LabelWidget>("TITLE").GetText = () => mod.Title; item.GetWidget<LabelWidget>("VERSION").GetText = () => mod.Version; item.GetWidget<LabelWidget>("AUTHOR").GetText = () => mod.Author; modList.AddChild(item); } }
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(); }