Exemplo n.º 1
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Text.Font = GameFont.Tiny;
            Rect rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag = true;
                if (!disabled)
                {
                    GUI.color = GenUI.MouseoverColor;
                }
            }
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            Material material = disabled ? TexUI.GrayscaleGUI : null;

            GenUI.DrawTextureWithMaterial(rect, BGTexture, material);
            DrawIcon(rect, material);
            bool    flag2   = false;
            KeyCode keyCode = (hotKey != null) ? hotKey.MainKey : KeyCode.None;

            if (keyCode != 0 && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Widgets.Label(new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f), keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect))
            {
                flag2 = true;
            }
            string labelCap = LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float num   = Text.CalcHeight(labelCap, rect.width);
                Rect  rect2 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect2, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect2, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (Mouse.IsOver(rect) && DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    ref string text = ref tip.text;
                    text += "\n\n" + "DisabledCommand".Translate() + ": " + disabledReason;
                }
                TooltipHandler.TipRegion(rect, tip);
            }
Exemplo n.º 2
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Text.Font = GameFont.Tiny;
            Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag = true;
                if (!this.disabled)
                {
                    GUI.color = GenUI.MouseoverColor;
                }
            }
            Texture2D badTex = this.icon;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }
            Material material = (!this.disabled) ? null : TexUI.GrayscaleGUI;

            GenUI.DrawTextureWithMaterial(rect, Command.BGTex, material, default(Rect));
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            Rect outerRect = rect;

            outerRect.position += new Vector2(this.iconOffset.x * outerRect.size.x, this.iconOffset.y * outerRect.size.y);
            GUI.color           = this.IconDrawColor;
            Widgets.DrawTextureFitted(outerRect, badTex, this.iconDrawScale * 0.85f, this.iconProportions, this.iconTexCoords, this.iconAngle, material);
            GUI.color = Color.white;
            bool    flag2   = false;
            KeyCode keyCode = (this.hotKey != null) ? this.hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Rect rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
                Widgets.Label(rect2, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (this.hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                flag2 = true;
            }
            string labelCap = this.LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float num   = Text.CalcHeight(labelCap, rect.width);
                Rect  rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (this.DoTooltip)
            {
                TipSignal tip = this.Desc;
                if (this.disabled && !this.disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        this.disabledReason
                    });
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!this.HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, this.HighlightTag);
            }
            Text.Font = GameFont.Small;
            if (flag2)
            {
                if (this.disabled)
                {
                    if (!this.disabledReason.NullOrEmpty())
                    {
                        Messages.Message(this.disabledReason, MessageTypeDefOf.RejectInput, false);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                GizmoResult result;
                if (Event.current.button == 1)
                {
                    result = new GizmoResult(GizmoState.OpenedFloatMenu, Event.current);
                }
                else
                {
                    if (!TutorSystem.AllowAction(this.TutorTagSelect))
                    {
                        return(new GizmoResult(GizmoState.Mouseover, null));
                    }
                    result = new GizmoResult(GizmoState.Interacted, Event.current);
                    TutorSystem.Notify_Event(this.TutorTagSelect);
                }
                return(result);
            }
            else
            {
                if (flag)
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                return(new GizmoResult(GizmoState.Clear, null));
            }
        }
Exemplo n.º 3
0
        protected virtual GizmoResult GizmoOnGUIInt(Rect butRect, bool shrunk = false)
        {
            Text.Font = GameFont.Tiny;
            bool flag = false;

            if (Mouse.IsOver(butRect))
            {
                flag = true;
                if (!disabled)
                {
                    GUI.color = GenUI.MouseoverColor;
                }
            }
            MouseoverSounds.DoRegion(butRect, SoundDefOf.Mouseover_Command);
            Material material = (disabled ? TexUI.GrayscaleGUI : null);

            GenUI.DrawTextureWithMaterial(butRect, shrunk ? BGTextureShrunk : BGTexture, material);
            DrawIcon(butRect, material);
            bool    flag2   = false;
            KeyCode keyCode = ((hotKey != null) ? hotKey.MainKey : KeyCode.None);

            if (keyCode != 0 && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Vector2 vector = (shrunk ? new Vector2(3f, 0f) : new Vector2(5f, 3f));
                Widgets.Label(new Rect(butRect.x + vector.x, butRect.y + vector.y, butRect.width - 10f, 18f), keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(butRect))
            {
                flag2 = true;
            }
            if (!shrunk)
            {
                string topRightLabel = TopRightLabel;
                if (!topRightLabel.NullOrEmpty())
                {
                    Vector2 vector2 = Text.CalcSize(topRightLabel);
                    Rect    position;
                    Rect    rect = (position = new Rect(butRect.xMax - vector2.x - 2f, butRect.y + 3f, vector2.x, vector2.y));
                    position.x     -= 2f;
                    position.width += 3f;
                    GUI.color       = Color.white;
                    Text.Anchor     = TextAnchor.UpperRight;
                    GUI.DrawTexture(position, TexUI.GrayTextBG);
                    Widgets.Label(rect, topRightLabel);
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                string labelCap = LabelCap;
                if (!labelCap.NullOrEmpty())
                {
                    float num   = Text.CalcHeight(labelCap, butRect.width);
                    Rect  rect2 = new Rect(butRect.x, butRect.yMax - num + 12f, butRect.width, num);
                    GUI.DrawTexture(rect2, TexUI.GrayTextBG);
                    GUI.color   = Color.white;
                    Text.Anchor = TextAnchor.UpperCenter;
                    Widgets.Label(rect2, labelCap);
                    Text.Anchor = TextAnchor.UpperLeft;
                    GUI.color   = Color.white;
                }
                GUI.color = Color.white;
            }
            if (Mouse.IsOver(butRect) && DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    ref string text = ref tip.text;
                    text += "\n\n" + "DisabledCommand".Translate() + ": " + disabledReason;
                }
                TooltipHandler.TipRegion(butRect, tip);
            }
        private static void DrawContents(Rect rect)
        {
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            float num  = 0f;
            float num2 = 17f;
            float itemListInnerMargin = 8f;
            float num3  = num2 + 4f;
            Rect  rect2 = new Rect(rect.x + num2, rect.y, rect.width - num2 * 2f, 0f);
            Rect  rect3 = rect;

            rect3.x += num3;
            rect3.y += 10f;
            Widgets.Label(rect3, "OfficialContent".Translate());
            num += 10f + Text.LineHeight + 4f;
            Rect rect4 = rect2;

            rect4.y     += num;
            rect4.height = 94f;
            Widgets.DrawBoxSolid(rect4, ModInfoListBackground);
            num += 104f;
            List <GenUI.AnonymousStackElement> list = new List <GenUI.AnonymousStackElement>();

            Text.Anchor = TextAnchor.MiddleLeft;
            for (int i = 0; i < ModLister.AllExpansions.Count; i++)
            {
                ExpansionDef exp = ModLister.AllExpansions[i];
                list.Add(new GenUI.AnonymousStackElement
                {
                    drawer = delegate(Rect r)
                    {
                        bool flag = exp.Status == ExpansionStatus.Active;
                        Widgets.DrawBoxSolid(r, flag ? ModInfoListItemBackground : ModInfoListItemBackgroundDisabled);
                        Widgets.DrawHighlightIfMouseover(r);
                        if (!exp.isCore && !exp.StoreURL.NullOrEmpty() && Widgets.ButtonInvisible(r))
                        {
                            SteamUtility.OpenUrl(exp.StoreURL);
                        }
                        GUI.color         = (flag ? Color.white : DisabledIconTint);
                        Material material = (flag ? null : TexUI.GrayscaleGUI);
                        Rect rect9        = new Rect(r.x + itemListInnerMargin, r.y + 2f, 32f, 32f);
                        float num4        = 42f;
                        GenUI.DrawTextureWithMaterial(rect9, exp.Icon, material);
                        GUI.color   = (flag ? Color.white : Color.grey);
                        Rect rect10 = new Rect(r.x + itemListInnerMargin + num4, r.y, r.width - num4, r.height);
                        if (exp.Status != 0)
                        {
                            TaggedString t = ((exp.Status == ExpansionStatus.Installed) ? "DisabledLower" : "ContentNotInstalled").Translate().ToLower();
                            Widgets.Label(rect10, exp.label + " (" + t + ")");
                        }
                        else
                        {
                            Widgets.Label(rect10, exp.label);
                        }
                        GUI.color = Color.white;
                        if (Mouse.IsOver(r))
                        {
                            string description2 = exp.label + "\n" + exp.StatusDescription + "\n\n" + exp.description.StripTags();
                            TooltipHandler.TipRegion(tip: new TipSignal(() => description2, exp.GetHashCode() * 37), rect: r);
                        }
                    }
                });
            }
            GenUI.DrawElementStackVertical(new Rect(rect4.x + itemListInnerMargin, rect4.y + itemListInnerMargin, rect4.width - itemListInnerMargin * 2f, 94f), ListElementSize.y, list, delegate(Rect r, GenUI.AnonymousStackElement obj)
            {
                obj.drawer(r);
            }, (GenUI.AnonymousStackElement obj) => ListElementSize.x, 6f);
            list.Clear();
            Rect rect5 = rect;

            rect5.x    += num3;
            rect5.y    += num;
            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.Label(rect5, "Mods".Translate());
            num += Text.LineHeight + 4f;
            Rect rect6 = rect2;

            rect6.y     += num;
            rect6.height = (AnyMods ? 224f : 40f);
            Widgets.DrawBoxSolid(rect6, ModInfoListBackground);
            if (AnyMods)
            {
                Text.Anchor = TextAnchor.MiddleLeft;
                foreach (ModMetaData mod in ModLister.AllInstalledMods.Where((ModMetaData m) => !m.Official && m.Active))
                {
                    list.Add(new GenUI.AnonymousStackElement
                    {
                        drawer = delegate(Rect r)
                        {
                            Widgets.DrawBoxSolid(r, mod.VersionCompatible ? ModInfoListItemBackground : ModInfoListItemBackgroundIncompatible);
                            Widgets.DrawHighlightIfMouseover(r);
                            if (mod.OnSteamWorkshop && mod.GetPublishedFileId() != PublishedFileId_t.Invalid && Widgets.ButtonInvisible(r))
                            {
                                SteamUtility.OpenWorkshopPage(mod.GetPublishedFileId());
                            }
                            Rect rect8   = new Rect(r.x + itemListInnerMargin, r.y, r.width, r.height);
                            string label = mod.Name.Truncate(rect8.width - itemListInnerMargin - 4f);
                            Widgets.Label(rect8, label);
                            if (Mouse.IsOver(r))
                            {
                                string description = mod.Name + "\n\n" + mod.Description.StripTags();
                                if (!mod.VersionCompatible)
                                {
                                    description = description + "\n\n" + "ModNotMadeForThisVersionShort".Translate().RawText.Colorize(Color.yellow);
                                }
                                TooltipHandler.TipRegion(tip: new TipSignal(() => description, mod.GetHashCode() * 37), rect: r);
                            }
                            GUI.color = Color.white;
                        }
                    });
                }
                Widgets.BeginScrollView(rect6, ref modListScrollPos, new Rect(0f, 0f, rect6.width - 16f, modListLastHeight + itemListInnerMargin * 2f));
                modListLastHeight = GenUI.DrawElementStack(new Rect(itemListInnerMargin, itemListInnerMargin, rect6.width - itemListInnerMargin * 2f, 99999f), ListElementSize.y, list, delegate(Rect r, GenUI.AnonymousStackElement obj)
                {
                    obj.drawer(r);
                }, (GenUI.AnonymousStackElement obj) => ListElementSize.x, 6f).height;
                Widgets.EndScrollView();
            }
            else
            {
                Text.Anchor = TextAnchor.UpperLeft;
                Rect rect7 = rect6;
                rect7.x  += itemListInnerMargin;
                rect7.y  += itemListInnerMargin;
                GUI.color = Color.gray;
                Widgets.Label(rect7, "None".Translate());
                GUI.color = Color.white;
            }
            Text.Anchor = TextAnchor.UpperLeft;
        }