protected override void Init() { var mods = new List <IModInfo>(); mods.AddRange(ModEntry.GetInstance().Helper.ModRegistry.GetAll()); mods.Sort((m1, m2) => FontUtils.GetWidth(m2.Manifest.Name) - FontUtils.GetWidth(m1.Manifest.Name)); _slot = new Slot <ModInfoSlot>("", "", 10, 50, FontUtils.GetWidth(mods[0].Manifest.Name), (Game1.viewport.Height - 100) / 80 * 80, 80); foreach (var variable in ModEntry.GetInstance().Helper.ModRegistry.GetAll()) { ModMenuEntity modMenuEntity = null; var manifestExtraFields = variable.Manifest.ExtraFields; if (manifestExtraFields != null && manifestExtraFields.ContainsKey("Custom")) { var custom = JsonConvert.DeserializeObject <CustomEntity>(manifestExtraFields["Custom"].ToString()); if (custom != null) { modMenuEntity = custom.ModMenu; } } _slot.AddEntry(new ModInfoSlot(variable, modMenuEntity)); } _slot.SelectedEntry = _slot.Entries[0]; _homePageButton = new Button(GetTranslation("button.homePage"), "", Game1.viewport.Width - _slot.X - 220, _slot.Height - 80, 200, 80); _issuesButton = new Button(GetTranslation("button.issues"), "", Game1.viewport.Width - _slot.X - 440, _slot.Height - 80, 200, 80); _updateButton = new Button(GetTranslation("button.update"), "", Game1.viewport.Width - _slot.X - 440, 80, 200, 80); _settingButton = new Button(GetTranslation("button.setting"), "", Game1.viewport.Width - _slot.X - 220, 80, 200, 80); AddComponentRange(_homePageButton, _issuesButton, _updateButton, _settingButton, _slot); base.Init(); }
public ModInfoSlot(IModInfo modInfo, ModMenuEntity modMenu) { ModInfo = modInfo; ModMenu = modMenu; }