Esempio n. 1
0
        public ModCore(ModContentPack mcp) : base(mcp)
        {
            Instance = this;

            Log.Message("Loaded What's That Mod.");
            LongEventHandler.QueueLongEvent(Run, "WTM_LoadingMsg", false, null);
        }
Esempio n. 2
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();
        }