public static void ResolveCoreShouldLoadFirst(ModButton core) { var options = NewOptions; options.Add(new FloatMenuOption(I18n.MoveCoreToFirst, () => ModButtonManager.Insert(core, 0))); FloatMenu(options); }
public static bool Prefix(PublishedFileId_t pfid) { // TODO: display some sort of in-progress indicator Debug.Log("Notify_Subscribed"); // check if item was already present. var item = WorkshopItem.MakeFrom(pfid); if (item is WorkshopItem_Mod item_installed) { // register item in WorkshopItems workshopitems.Add(item_installed); // register item in ModLister var mod = new ModMetaData(item_installed); modlister.Add(mod); // show a message Messages.Message(I18n.ModInstalled(mod.Name), MessageTypeDefOf.PositiveEvent, false); // notify button manager that we done stuff. ModButtonManager.Notify_DownloadCompleted(mod); } else { // add dowloading item to MBM var button = new ModButton_Downloading(pfid); ModButtonManager.TryAdd(button); Page_BetterModConfig.Instance.Selected = button; } // do whatever needs doing for ScenarioLister. ScenarioLister.MarkDirty(); return(false); }
public static void ResolveFindMod( string identifier, ModButton requester = null, Version desired = null, Dependency.EqualityOperator op = Dependency.EqualityOperator.GreaterEqual, Version current = null, bool replace = false) { // find identifier in available var mods = ModButtonManager.AvailableMods .Where(m => m.MatchesIdentifier(identifier)) .Where(m => m.VersionCompatible) .Where(m => desired == null || Dependency.MatchesVersion(m, op, desired, true)) .Where(m => current == null || Manifest.For(m)?.Version > current) .OrderByDescending(m => Manifest.For(m)?.Version); var options = NewOptions; if (mods.Any()) { var insertIndex = requester != null ? ModButtonManager.ActiveButtons.IndexOf(requester) : ModButtonManager.ActiveButtons.Count; foreach (var mod in mods) { options.Add(new FloatMenuOption(I18n.ActivateMod(mod), () => { var button = ModButton_Installed.For(mod); button.Selected = mod; ModButtonManager.Insert(button, insertIndex); if (replace && requester != null && requester != button) { requester.Active = false; } })); } } else { if (desired != null) { options.Add(new FloatMenuOption(I18n.NoMatchingModInstalled(identifier, desired, op), null)); } else { options.Add(new FloatMenuOption(I18n.NoMatchingModInstalled(identifier), null)); } } if (requester is ModButton_Missing missing && missing.Identifier.IsSteamWorkshopIdentifier()) { options.Add(SubscribeOption(missing.Name, missing.Identifier)); } options.Add(WorkshopSearchOption(requester?.TrimmedName ?? identifier)); options.Add(ForumSearchOption(requester?.TrimmedName ?? identifier)); FloatMenu(options); }
public static bool Prefix(PublishedFileId_t pfid) { Debug.Log("Notify_Unsubscribed"); // deregister item in WorkshopItems var item = workshopitems.FirstOrDefault(i => i.PublishedFileId == pfid); workshopitems.TryRemove(item); // deregister item in ModLister var mod = modlister.FirstOrDefault(m => m.Source == ContentSource.SteamWorkshop && m.Identifier == pfid.ToString()); modlister.TryRemove(mod); // remove button ModButtonManager.Notify_Unsubscribed(pfid.ToString()); ScenarioLister.MarkDirty(); return(false); }
public static bool Prefix(PublishedFileId_t pfid) { Debug.Log("Notify_Installed"); // register item in WorkshopItems var item = WorkshopItem.MakeFrom(pfid); workshopitems.Add(item); // register item in ModLister var mod = new ModMetaData(item); modlister.Add(mod); // show a message Messages.Message(I18n.ModInstalled(mod.Name), MessageTypeDefOf.PositiveEvent, false); // notify button manager that we done stuff. ModButtonManager.Notify_DownloadCompleted(mod); ScenarioLister.MarkDirty(); return(false); }
private static FloatMenuOption MoveAfterOption(ModButton_Installed from, ModButton_Installed to) { return(new FloatMenuOption(I18n.MoveAfter(from, to), () => ModButtonManager.Insert(from, ModButtonManager.ActiveButtons.IndexOf(to) + 1))); }