示例#1
0
        public static void ResolveCoreShouldLoadFirst(ModButton core)
        {
            var options = NewOptions;

            options.Add(new FloatMenuOption(I18n.MoveCoreToFirst, () => ModButtonManager.Insert(core, 0)));
            FloatMenu(options);
        }
示例#2
0
        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);
        }
示例#3
0
 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)));
 }