Пример #1
0
        public static ModMetaData GetInstalledMod(string id)
        {
            if (ModsConfig.IsActive(id + ModMetaData.SteamModPostfix))
            {
                id += ModMetaData.SteamModPostfix;
            }

            return(ModLister.GetModWithIdentifier(id));
        }
Пример #2
0
        private static string GetUniquePackageId(ModMetaData mod)
        {
            var baseId = mod.PackageIdPlayerFacing + LocalCopyPostfix;
            var id     = baseId;
            var i      = 1;

            while (ModLister.GetModWithIdentifier(id) != null)
            {
                id = baseId + "_" + i++;
            }
            return(id);
        }
 internal static void ResetRootDir()
 {
     RootDir = ModLister.GetModWithIdentifier(AchievementHarmony.modIdentifier)?.RootDir.ToString();
     if (string.IsNullOrEmpty(RootDir))
     {
         Verse.Log.Message($"{AchievementPointManager.AchievementTag} Disabling DebugWriter. Vanilla Achievements Expanded mod not found in mod list.");
         writerDisabled = true;
         return;
     }
     Clear();
     messageLogs.Clear();
     Log(new string[] { "Vanilla Achievements Expanded", "This log is for logging Tracker information and Event triggers only.\n" });
 }
Пример #4
0
        public override IEnumerable <string> ConfigErrors()
        {
            foreach (string item in base.ConfigErrors())
            {
                yield return(item);
            }
            ModMetaData modWithIdentifier = ModLister.GetModWithIdentifier(linkedMod);

            if (modWithIdentifier != null && !modWithIdentifier.Official)
            {
                yield return(modWithIdentifier.Name + " - ExpansionDefs are used for official content. For mods, you should define ModMetaData in About.xml.");
            }
        }
Пример #5
0
        public static void Reset(bool addDefaultMods = true)
        {
            foreach (var button in new List <ModButton>(ActiveButtons))
            {
                button.Active = false;
            }

            if (addDefaultMods)
            {
                CoreMod.Active = true;

                if (ModManager.Settings.AddExpansionsToNewModLists)
                {
                    foreach (var expansion in Expansions)
                    {
                        expansion.Active = true;
                    }
                }

                if (ModManager.Settings.AddHugsLibToNewModLists)
                {
                    var hugslib = ModLister.GetModWithIdentifier("unlimitedhugs.hugslib");
                    if (hugslib != null)
                    {
                        var hugslibButton = ModButton_Installed.For(hugslib);
                        hugslibButton.Active = true;
                    }
                }

                if (ModManager.Settings.AddModManagerToNewModLists && ModManagerMod != null)
                {
                    ModManagerMod.Active = true;
                }

                if (ModManager.Settings.AddHugsLibToNewModLists || ModManager.Settings.AddModManagerToNewModLists)
                {
                    // also try to activate harmony
                    var harmony = ModLister.GetModWithIdentifier("brrainz.harmony");
                    if (harmony != null)
                    {
                        var harmonyButton = ModButton_Installed.For(harmony);
                        harmonyButton.Active = true;
                        Insert(harmonyButton, 0);
                    }
                }
            }

            Notify_ModListChanged();
        }
Пример #6
0
 public bool TryResolve()
 {
     Mod = ModLister.GetModWithIdentifier(_identifier);
     return(Mod != null);
 }
Пример #7
0
        public void DrawWindow(Rect rect)
        {
            // Draw all settings.
            Listing_Standard listing = new Listing_Standard();

            listing.Begin(new Rect(rect.x, rect.y, Mathf.Min(rect.width, 320), rect.height));

            listing.Label("<color=yellow>" + "WTM_RequireRestart".Translate() + "</color>");
            listing.GapLine();

            listing.CheckboxLabeled("WTM_FlagVanilla".Translate(), ref FlagVanilla, "WTM_FlagVanilla_Desc".Translate(VanillaName.Trim()));
            VanillaName = listing.TextEntryLabeled("WTM_VanillaName".Translate(), VanillaName);
            listing.Gap();

            listing.Label("<b>" + "WTM_VisualOptions".Translate() + "</b>");

            listing.Label("WTM_Format".Translate(), tooltip: "WTM_Format_Desc".Translate());
            Format = listing.TextEntry(Format);
            if (!Format.Contains("{0}"))
            {
                listing.Label("<color=red>" + "WTM_Format_MissingTag".Translate() + "</color>");
            }
            try
            {
                _ = string.Format(Format.Replace('[', '(').Replace(']', ')'), "ExampleModName");
            }
            catch (Exception e)
            {
                _ = e;
                listing.Label("<color=red>" + "WTM_Format_FormatError".Translate() + "</color>");
            }

            listing.CheckboxLabeled("WTM_Italics".Translate(), ref Italics, "WTM_Italics_Desc".Translate());
            listing.CheckboxLabeled("WTM_Bold".Translate(), ref Bold, "WTM_Bold_Desc".Translate());

            listing.Label("WTM_CustomSize".Translate(CustomSize), tooltip: "WTM_CustomSize_Desc".Translate());
            listing.IntEntry(ref CustomSize, ref fontSizeBuffer);
            CustomSize     = Mathf.Clamp(CustomSize, 0, 64);
            fontSizeBuffer = CustomSize.ToString();

            listing.Label("WTM_BlankLines".Translate(BlankLines), tooltip: "WTM_BlankLines_Desc".Translate());
            listing.IntEntry(ref BlankLines, ref blankLinesBuffer);
            BlankLines       = Mathf.Clamp(BlankLines, 0, 12);
            blankLinesBuffer = BlankLines.ToString();

            listing.Label("WTM_SelectFontColor".Translate(), tooltip: "WTM_SelectFontColor_Desc".Translate());
            bool openColorPicker = listing.ButtonImage(GetCurrentColorTexture(), 100, 32);

            if (openColorPicker)
            {
                OpenColorPicker();
            }

            // Do preview box.
            float y          = listing.CurHeight + rect.y - 30;
            Rect  previewBox = new Rect(rect.x, y, 310, 170);

            Widgets.DrawBox(previewBox);
            previewBox = previewBox.ExpandedBy(-5);
            string rawText  = "WTM_ExampleDescription".Translate();
            string template = ModCore.MakeTemplate(this);
            string text     = ModCore.MakeNewDescription(rawText, "Example Mod", template, false);

            Widgets.Label(previewBox, text);

            listing.End();

            listing = new Listing_Standard();
            listing.Begin(new Rect(rect.x + 350, rect.y, 320, rect.height));
            if (listing.ButtonText($"{(showAdvanced ? "WTM_Hide".Translate() : "WTM_Show".Translate())} {"WTM_AdvancedSettings".Translate()}"))
            {
                showAdvanced = !showAdvanced;
            }

            if (showAdvanced)
            {
                // Draw advanced settings.
                listing.GapLine();

                listing.CheckboxLabeled("WTM_CECompat".Translate(), ref CECompat, "WTM_CECompat_Desc".Translate());
                listing.CheckboxLabeled("WTM_DetectPatched".Translate(), ref DetectPatched, "WTM_DetectPatched_Desc".Translate());

                if (!DetectPatched)
                {
                    GUI.enabled = false;
                }
                listing.CheckboxLabeled("WTM_UltraDeepMode".Translate(), ref UltraDeepMode, "WTM_UltraDeepMode_Desc".Translate());
                GUI.enabled = true;

                listing.CheckboxLabeled("WTM_ZooLabel".Translate(), ref ZooModeEnabled, "WTM_ZooDesc".Translate());
                if (ZooModeEnabled)
                {
                    listing.CheckboxLabeled("WTM_ZooMultiLabel".Translate(), ref ZooModeMultithread, "WTM_ZooMultiDesc".Translate());
                }

                listing.Label("WTM_ExcludedMods".Translate(), tooltip: "WTM_ExcludedMods_Desc".Translate());
                bool addNew      = listing.ButtonText("WTM_AddNew".Translate());
                bool removeBlank = listing.ButtonText("WTM_RemoveBlank".Translate());
                listing.Gap();

                if (addNew)
                {
                    ExcludedMods.Add("");
                }
                if (removeBlank)
                {
                    for (int i = 0; i < ExcludedMods.Count; i++)
                    {
                        string txt = ExcludedMods[i];
                        if (string.IsNullOrWhiteSpace(txt))
                        {
                            ExcludedMods.RemoveAt(i);
                            i--;
                        }
                    }
                }
                for (int i = 0; i < ExcludedMods.Count; i++)
                {
                    var mod = ExcludedMods[i];
                    mod             = listing.TextEntry(mod);
                    ExcludedMods[i] = mod;

                    string final = mod.Trim();
                    var    meta  = ModLister.GetModWithIdentifier(final, true);
                    string msg   = meta == null ? "WTM_ModNotFound".Translate() : "WTM_ModFound".Translate(meta.Name);
                    string color = meta == null ? "red" : "green";
                    listing.Label($"<color={color}>{msg}</color>");
                    listing.GapLine();
                }
            }

            listing.End();
        }