Example #1
0
        // Token: 0x06000030 RID: 48 RVA: 0x00003AA4 File Offset: 0x00001CA4
        public static Rect LineRectSpilter(this Listing_Standard listing_Standard, out Rect leftHalf, float leftPartPct = 0.5f, float?height = null)
        {
            Rect rect = listing_Standard.GetRect(height);

            leftHalf = GenUI.Rounded(GenUI.LeftPart(rect, leftPartPct));
            return(rect);
        }
Example #2
0
        // Token: 0x06000029 RID: 41 RVA: 0x00003844 File Offset: 0x00001A44
        public static void FloatRange(this Listing_Standard ls, string label, ref FloatRange range, float min = 0f, float max = 1f, string tooltip = null, ToStringStyle valueStyle = ToStringStyle.FloatTwo)
        {
            Rect rect  = ls.GetRect(Text.LineHeight);
            Rect rect2 = GenUI.Rounded(GenUI.LeftPart(rect, 0.7f));
            Rect rect3 = GenUI.Rounded(GenUI.LeftPart(GenUI.Rounded(GenUI.RightPart(rect, 0.3f)), 0.9f));

            rect3.yMin -= 5f;
            TextAnchor anchor = Text.Anchor;

            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(rect2, label);
            Text.Anchor = TextAnchor.MiddleRight;
            int hashCode = ls.CurHeight.GetHashCode();

            Widgets.FloatRange(rect3, hashCode, ref range, min, max, null, valueStyle);
            if (!GenText.NullOrEmpty(tooltip))
            {
                TooltipHandler.TipRegion(rect, tooltip);
            }
            Text.Anchor = anchor;
            ls.Gap(ls.verticalSpacing);
        }
Example #3
0
        // Token: 0x06000028 RID: 40 RVA: 0x0000377C File Offset: 0x0000197C
        public static void SliderLabeled(this Listing_Standard ls, string label, ref float val, string format, float min = 0f, float max = 1f, string tooltip = null)
        {
            Rect       rect   = ls.GetRect(Text.LineHeight);
            Rect       rect2  = GenUI.Rounded(GenUI.LeftPart(rect, 0.7f));
            Rect       rect3  = GenUI.Rounded(GenUI.LeftPart(GenUI.Rounded(GenUI.RightPart(rect, 0.3f)), 0.67f));
            Rect       rect4  = GenUI.Rounded(GenUI.RightPart(rect, 0.1f));
            TextAnchor anchor = Text.Anchor;

            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(rect2, label);
            float num = Widgets.HorizontalSlider(rect3, val, min, max, true, null, null, null, -1f);

            val         = num;
            Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(rect4, string.Format(format, val));
            if (!GenText.NullOrEmpty(tooltip))
            {
                TooltipHandler.TipRegion(rect, tooltip);
            }
            Text.Anchor = anchor;
            ls.Gap(ls.verticalSpacing);
        }
Example #4
0
        //=====================================================================================================\\

        public override void DoSettingsWindowContents(Rect rect)
        {
            Color headerColor = new Color(
                r: 1.0f,
                g: 0.9725490f,
                b: 0.239215686f,
                a: 1.0f
                );
            GUIStyleState headerState = new GUIStyleState()
            {
                textColor = headerColor
            };
            GUIStyle headerStyle = new GUIStyle(Text.CurFontStyle);

            headerStyle.fontStyle = FontStyle.Bold;
            headerStyle.normal    = headerState;

            GUIStyle hdStyle = new GUIStyle(Text.CurFontStyle);

            hdStyle.alignment = TextAnchor.MiddleLeft;
            hdStyle.fontSize  = 11;
            hdStyle.fontStyle = FontStyle.Bold;
            hdStyle.normal    = new GUIStyleState()
            {
                textColor = new Color(
                    r: 1.0f,
                    g: 0.74117647f,
                    b: 0.2392156862f,
                    a: 1.0f
                    )
            };
            hdStyle.padding = new RectOffset(4, 0, 0, 0);

            Listing_Standard listing        = new Listing_Standard(GameFont.Small);
            Listing_Standard listingPresets = new Listing_Standard(GameFont.Small);
            List <KeyValuePair <string, int> > overrides = new IndividualOverrides().ViewInternalOverrides();

            // 3 headers
            // 2 table headers
            // 2 spacers
            // 23 ish listing.regulars
            // individualoverrides.count
            float height
                = (3 * (Verse.Text.LineHeight + 2))                 // include 2 for bottom border
                  + (2 * (hdStyle.lineHeight))                      // table headers
                  + (2 * 15)                                        // spacer hight 15
                  + (23 * (Verse.Text.LineHeight + 7))              // divider line is 7 in regular listing entries
                  + (overrides.Count * (Verse.Text.LineHeight + 3)) // divider line is 3 in overrides
                  + 40;                                             // for fudge making

            Rect mainRect = new Rect(
                x: 0,
                y: 0,
                width: rect.width - 25,                 //25 for scrollbar
                height: height
                );

            Widgets.BeginScrollView(rect, ref this.settings.ScrollPosition, mainRect, true);

            Rect mainLeft  = mainRect.LeftPart(0.78f);
            Rect mainRight = mainRect.RightPart(0.20f);


            // PRESETS
            listingPresets.ColumnWidth = mainRight.width;
            listingPresets.Begin(mainRight);
            Rect       section = listingPresets.GetRect(Verse.Text.LineHeight + 2);
            TextAnchor anchor  = Text.Anchor;

            Text.Anchor = TextAnchor.UpperLeft;
            GUI.Box(section, Translator.Translate("OgreStack.SectionHeader.Presets"), headerStyle);
            Text.Anchor = anchor;

            Color color = GUI.color;

            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 1, section.width);
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 2, section.width);
            GUI.color = color;

            // Ogre
            section = listingPresets.GetRect(hdStyle.lineHeight);
            GUI.Box(section, Translator.Translate("OgreStack.Presets.Section.Ogre"), hdStyle);

            section   = listingPresets.GetRect(7);
            color     = GUI.color;
            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(section.x, section.y + 3, section.width);
            GUI.color = color;

            foreach (Preset p in Presets.GetOgrePresets())
            {
                section = listingPresets.GetRect(Verse.Text.LineHeight);
                GUI.SetNextControlName(p.NameKey);
                if (Widgets.ButtonText(section, Translator.Translate(p.NameKey)))
                {
                    p.Modify(this.settings);
                }

                section = listingPresets.GetRect(1);
            }

            listingPresets.GetRect(7);

            // Scalar
            section = listingPresets.GetRect(hdStyle.lineHeight);
            GUI.Box(section, Translator.Translate("OgreStack.Presets.Section.Scalar"), hdStyle);

            section   = listingPresets.GetRect(7);
            color     = GUI.color;
            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(section.x, section.y + 3, section.width);
            GUI.color = color;

            foreach (Preset p in Presets.GetScalarPresets())
            {
                section = listingPresets.GetRect(Verse.Text.LineHeight);
                GUI.SetNextControlName(p.NameKey);
                if (Widgets.ButtonText(section, Translator.Translate(p.NameKey)))
                {
                    p.Modify(this.settings);
                }

                section = listingPresets.GetRect(1);
            }

            listingPresets.End();


            // SETTINGS
            listing.ColumnWidth = mainLeft.width;
            listing.Begin(mainLeft);

            section     = listing.GetRect(Verse.Text.LineHeight + 2);
            anchor      = Text.Anchor;
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.Box(section, Translator.Translate("OgreStack.SectionHeader.Settings"), headerStyle);
            Text.Anchor = anchor;

            color     = GUI.color;
            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 1, section.width);
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 2, section.width);
            GUI.color = color;

            Rect header = listing.GetRect(hdStyle.lineHeight);

            GUI.Box(GenUI.LeftPart(header, 0.6f), Translator.Translate("OgreStack.Settings.Category"), hdStyle);
            Rect headerInputs = GenUI.RightPart(header, 0.4f);
            Rect boxModeHd    = GenUI.LeftHalf(headerInputs);

            GUI.Box(boxModeHd, Translator.Translate("OgreStack.Settings.Mode"), hdStyle);
            GUI.Box(GenUI.RightHalf(headerInputs), Translator.Translate("OgreStack.Settings.Value"), hdStyle);

            TooltipHandler.TipRegion(boxModeHd, Translator.Translate("OgreStack.Settings.Mode.Desc"));

            List <Category> allCats = new List <Category>(OgreStackMod._PROCESSING_ORDER);

            allCats.Add(Category.Other);

            foreach (Category c in allCats)
            {
                // separator line
                Rect divider = listing.GetRect(7);
                color     = GUI.color;
                GUI.color = Color.grey;
                Widgets.DrawLineHorizontal(divider.x, divider.y + 3, divider.width);
                GUI.color = color;


                // Container for row
                Rect container = listing.GetRect(Verse.Text.LineHeight);
                Widgets.DrawHighlightIfMouseover(container);

                // Category
                Rect boxCategory = GenUI.LeftPart(container, 0.6f);
                anchor      = Text.Anchor;
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(boxCategory, Translator.Translate("OgreStack.Settings." + c.ToString() + ".Title"));
                Text.Anchor = anchor;

                TooltipHandler.TipRegion(boxCategory, Translator.Translate("OgreStack.Settings." + c.ToString() + ".Desc"));


                // MODE
                Rect boxInputs = GenUI.RightPart(container, 0.4f);
                //Rect boxMode = GenUI.LeftHalf(boxInputs);
                Rect boxMode  = GenUI.LeftPart(boxInputs, 0.49f);
                Rect boxValue = GenUI.Rounded(GenUI.RightHalf(boxInputs));

                Widgets.Dropdown <MultiplierMode, MultiplierMode>(
                    rect: boxMode,

                    // no idea what target
                    // and getPayload are for/do
                    target: MultiplierMode.Fixed,
                    getPayload: (s) => {
                    return(s);
                },

                    // This appears to update automatically
                    buttonLabel: Translator.Translate("OgreStack.Settings.Mode." + this.settings.Values[c].Mode.ToString()),
                    menuGenerator: (s) => {
                    List <Widgets.DropdownMenuElement <MultiplierMode> > rv = new List <Widgets.DropdownMenuElement <MultiplierMode> >();
                    rv.Add(new Widgets.DropdownMenuElement <MultiplierMode>()
                    {
                        option = new FloatMenuOption(Translator.Translate("OgreStack.Settings.Mode.Scalar"), () => {
                            this.settings.Values[c].Mode = MultiplierMode.Scalar;
                        }),
                        payload = MultiplierMode.Scalar
                    });

                    rv.Add(new Widgets.DropdownMenuElement <MultiplierMode>()
                    {
                        option = new FloatMenuOption(Translator.Translate("OgreStack.Settings.Mode.Fixed"), () => {
                            this.settings.Values[c].Mode = MultiplierMode.Fixed;
                        }),
                        payload = MultiplierMode.Fixed
                    });
                    return(rv);
                }
                    );

                // VALUE
                this.settings.Values[c].Buffer = Widgets.TextField(boxValue, this.settings.Values[c].Buffer);

                if (!this.settings.Values[c].ParseBuffer())
                {
                    color     = GUI.color;
                    GUI.color = new Color(0.662745f, 0f, 0f);
                    Widgets.DrawBox(GenUI.Rounded(boxValue), 2);
                    GUI.color = color;
                }
            }

            Rect space = listing.GetRect(15);

            section     = listing.GetRect(Verse.Text.LineHeight + 2);
            anchor      = Text.Anchor;
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.Box(section, Translator.Translate("OgreStack.SectionHeader.SingleThingDefTargeting"), headerStyle);
            Text.Anchor = anchor;

            color     = GUI.color;
            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 1, section.width);
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 2, section.width);
            GUI.color = color;

            anchor      = Text.Anchor;
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(listing.GetRect(Verse.Text.LineHeight * 3), Translator.Translate("OgreStack.Settings.SingleThingDefTargeting.Desc", DataUtil.GenerateFilePath(DataUtil._OVERRIDES_FILE_NAME).Replace("/", "\\")));
            Text.Anchor = anchor;

            header      = listing.GetRect(hdStyle.lineHeight);
            anchor      = Text.Anchor;
            Text.Anchor = TextAnchor.MiddleLeft;

            GUI.Box(GenUI.LeftPart(header, 0.35f), Translator.Translate("OgreStack.Settings.DefName"), hdStyle);
            GUI.Box(GenUI.RightPart(header, 0.65f), Translator.Translate("OgreStack.Settings.StackLimit"), hdStyle);
            Text.Anchor = anchor;


            foreach (KeyValuePair <string, int> kvp in overrides)
            {
                string defName    = kvp.Key;
                int    stackLimit = kvp.Value;

                // separator line
                Rect divider = listing.GetRect(3);
                color     = GUI.color;
                GUI.color = Color.grey;
                Widgets.DrawLineHorizontal(divider.x, divider.y + 1, divider.width);
                GUI.color = color;

                // Container for row
                Rect container = listing.GetRect(Verse.Text.LineHeight);
                Widgets.DrawHighlightIfMouseover(container);

                // DefName
                Rect boxDefName = GenUI.LeftPart(container, 0.35f);
                anchor      = Text.Anchor;
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(boxDefName, defName);
                Text.Anchor = anchor;

                // StackLimit
                Rect boxStackLimit = GenUI.RightPart(container, 0.65f);
                anchor      = Text.Anchor;
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(boxStackLimit, stackLimit.ToString());
                Text.Anchor = anchor;

                // Show The Rule
                // * ends up text wrapping, so its not really
                // * very helpful IMO
                TooltipHandler.TipRegion(container, "From Rule:\n<item defName=\"" + defName + "\" stackLimit=\"" + stackLimit.ToString() + "\" />");
            }



            // DEBUG
            space       = listing.GetRect(15);
            section     = listing.GetRect(Verse.Text.LineHeight + 2);
            anchor      = Text.Anchor;
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.Box(section, Translator.Translate("OgreStack.SectionHeader.Debug"), headerStyle);
            Text.Anchor = anchor;

            color     = GUI.color;
            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 1, section.width);
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 2, section.width);
            GUI.color = color;

            Rect oContainer = listing.GetRect(Verse.Text.LineHeight);

            Widgets.DrawHighlightIfMouseover(oContainer);
            Rect oLeft = GenUI.LeftPart(oContainer, 0.8f);

            anchor      = Text.Anchor;
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(oLeft, Translator.Translate("OgreStack.Settings.CSV.Title"));
            Text.Anchor = anchor;

            TooltipHandler.TipRegion(oLeft, Translator.Translate("OgreStack.Settings.CSV.Desc", DataUtil.GenerateFilePath("OgreStack_DefsList.csv").Replace("/", "\\")));

            Rect oRight = GenUI.RightPart(oContainer, 0.2f);

            Widgets.Checkbox(oRight.x + oRight.width - 26, oRight.y, ref this.settings.IsDebug);

            //oContainer = listing.GetRect(Verse.Text.LineHeight);
            //GUI.SetNextControlName("preset_test");
            //if (Widgets.ButtonText(oContainer, "Test"))
            //{
            //	this.settings.Values[Category.SmallVolumeResource].Buffer = "999";
            //	if (this.settings.Values[Category.SmallVolumeResource].Mode == MultiplierMode.Fixed)
            //	{
            //		this.settings.Values[Category.SmallVolumeResource].Mode = MultiplierMode.Scalar;
            //	}
            //	else
            //	{
            //		this.settings.Values[Category.SmallVolumeResource].Mode = MultiplierMode.Fixed;
            //	}
            //}

            //TooltipHandler.TipRegion(oContainer, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed porttitor rhoncus lacus, sed condimentum odio pretium sed. Pellentesque luctus velit id magna efficitur interdum. Duis nec dictum ante. Morbi urna nibh, ullamcorper id blandit viverra, molestie et risus. In hac habitasse platea dictumst. Suspendisse ut dictum velit, in vestibulum erat. Proin vel ultrices ante, eget tristique lorem. Donec scelerisque rutrum fermentum. Vivamus pulvinar nec augue a convallis. Donec ut tellus lorem. Maecenas at pharetra libero, a iaculis risus. Sed dui tellus, euismod sit amet egestas vitae, convallis at eros. Quisque sed placerat quam, vel luctus erat. Suspendisse leo tellus, porta in laoreet in, feugiat quis mi. Suspendisse fermentum aliquam metus id sollicitudin. Curabitur consectetur lacus ac dolor scelerisque vestibulum.");
            listing.End();
            Widgets.EndScrollView();
        }