Exemplo n.º 1
0
            internal void <> m__0()
            {
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect  rect  = this.rect.AtZero();
                float alpha = this.$this.Alpha;

                GUI.color = new Color(1f, 1f, 1f, alpha);
                if (Message.ShouldDrawBackground)
                {
                    GUI.color = new Color(0.15f, 0.15f, 0.15f, 0.8f * alpha);
                    GUI.DrawTexture(rect, BaseContent.WhiteTex);
                    GUI.color = new Color(1f, 1f, 1f, alpha);
                }
                if (CameraJumper.CanJump(this.$this.lookTargets.TryGetPrimaryTarget()))
                {
                    UIHighlighter.HighlightOpportunity(rect, "Messages");
                    Widgets.DrawHighlightIfMouseover(rect);
                }
                Rect rect2 = new Rect(2f, 0f, rect.width - 2f, rect.height);

                Widgets.Label(rect2, this.$this.text);
                if (Current.ProgramState == ProgramState.Playing && CameraJumper.CanJump(this.$this.lookTargets.TryGetPrimaryTarget()) && Widgets.ButtonInvisible(rect, false))
                {
                    CameraJumper.TryJumpAndSelect(this.$this.lookTargets.TryGetPrimaryTarget());
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.ClickingMessages, KnowledgeAmount.Total);
                }
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
                if (Mouse.IsOver(rect))
                {
                    Messages.Notify_Mouseover(this.$this);
                }
            }
Exemplo n.º 2
0
        public bool ButtonText(string label, string highlightTag = null)
        {
            Rect rect   = base.GetRect(30f);
            bool result = Widgets.ButtonText(rect, label, true, false, true);

            if (highlightTag != null)
            {
                UIHighlighter.HighlightOpportunity(rect, highlightTag);
            }
            base.Gap(this.verticalSpacing);
            return(result);
        }
Exemplo n.º 3
0
        public bool ButtonText(string label, string highlightTag = null)
        {
            Rect rect   = GetRect(30f);
            bool result = Widgets.ButtonText(rect, label);

            if (highlightTag != null)
            {
                UIHighlighter.HighlightOpportunity(rect, highlightTag);
            }
            Gap(verticalSpacing);
            return(result);
        }
Exemplo n.º 4
0
        public void Draw(int xOffset, int yOffset)
        {
            Rect rect = CalculateRect(xOffset, yOffset);

            Find.WindowStack.ImmediateWindow(Gen.HashCombineInt(ID, 45574281), rect, WindowLayer.Super, delegate
            {
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect rect2  = rect.AtZero();
                float alpha = Alpha;
                GUI.color   = new Color(1f, 1f, 1f, alpha);
                if (ShouldDrawBackground)
                {
                    GUI.color = new Color(0.15f, 0.15f, 0.15f, 0.8f * alpha);
                    GUI.DrawTexture(rect2, BaseContent.WhiteTex);
                    GUI.color = new Color(1f, 1f, 1f, alpha);
                }
                if (CameraJumper.CanJump(lookTargets.TryGetPrimaryTarget()) || quest != null)
                {
                    UIHighlighter.HighlightOpportunity(rect2, "Messages");
                    Widgets.DrawHighlightIfMouseover(rect2);
                }
                Widgets.Label(new Rect(2f, 0f, rect2.width - 2f, rect2.height), text);
                if (Current.ProgramState == ProgramState.Playing && Widgets.ButtonInvisible(rect2))
                {
                    if (CameraJumper.CanJump(lookTargets.TryGetPrimaryTarget()))
                    {
                        CameraJumper.TryJumpAndSelect(lookTargets.TryGetPrimaryTarget());
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.ClickingMessages, KnowledgeAmount.Total);
                    }
                    else if (quest != null)
                    {
                        if (Find.MainTabsRoot.OpenTab == MainButtonDefOf.Quests)
                        {
                            SoundDefOf.Click.PlayOneShotOnCamera();
                        }
                        else
                        {
                            Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Quests);
                        }
                        ((MainTabWindow_Quests)MainButtonDefOf.Quests.TabWindow).Select(quest);
                    }
                }
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
                if (Mouse.IsOver(rect2))
                {
                    Messages.Notify_Mouseover(this);
                }
            }, doBackground: false, absorbInputAroundWindow: false, 0f);
        }
Exemplo n.º 5
0
        public virtual float DrawOption(Vector2 pos, float width)
        {
            float b    = Text.CalcHeight(label, width);
            float num  = Mathf.Max(minHeight, b);
            Rect  rect = new Rect(pos.x, pos.y, width, num);

            if (Widgets.ButtonText(rect, label))
            {
                action();
            }
            if (uiHighlightTag != null)
            {
                UIHighlighter.HighlightOpportunity(rect, uiHighlightTag);
            }
            return(num);
        }
Exemplo n.º 6
0
        public void Draw(int xOffset, int yOffset)
        {
            Rect rect = this.CalculateRect((float)xOffset, (float)yOffset);

            Find.WindowStack.ImmediateWindow(Gen.HashCombineInt(this.ID, 45574281), rect, WindowLayer.Super, delegate
            {
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect rect   = rect.AtZero();
                float alpha = this.Alpha;
                GUI.color   = new Color(1f, 1f, 1f, alpha);
                if (Message.ShouldDrawBackground)
                {
                    GUI.color = new Color(0.15f, 0.15f, 0.15f, 0.8f * alpha);
                    GUI.DrawTexture(rect, BaseContent.WhiteTex);
                    GUI.color = new Color(1f, 1f, 1f, alpha);
                }
                if (CameraJumper.CanJump(this.lookTargets.TryGetPrimaryTarget()))
                {
                    UIHighlighter.HighlightOpportunity(rect, "Messages");
                    Widgets.DrawHighlightIfMouseover(rect);
                }
                Rect rect2 = new Rect(2f, 0f, rect.width - 2f, rect.height);
                Widgets.Label(rect2, this.text);
                if (Current.ProgramState == ProgramState.Playing && CameraJumper.CanJump(this.lookTargets.TryGetPrimaryTarget()))
                {
                    if (Widgets.ButtonInvisible(rect, false))
                    {
                        CameraJumper.TryJumpAndSelect(this.lookTargets.TryGetPrimaryTarget());
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.ClickingMessages, KnowledgeAmount.Total);
                    }
                }
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
                if (Mouse.IsOver(rect))
                {
                    Messages.Notify_Mouseover(this);
                }
            }, false, false, 0f);
        }
Exemplo n.º 7
0
        public void ToggleableIcon(ref bool toggleable, Texture2D tex, string tooltip, SoundDef mouseoverSound = null, string tutorTag = null)
        {
            IncrementYIfWillExceedMaxWidth(24f);
            Rect rect = new Rect(LeftX(24f), curY, 24f, 24f);
            bool num  = Widgets.ButtonImage(rect, tex);

            IncrementPosition(24f + gap);
            if (!tooltip.NullOrEmpty())
            {
                TooltipHandler.TipRegion(rect, tooltip);
            }
            Rect      position = new Rect(rect.x + rect.width / 2f, rect.y, rect.height / 2f, rect.height / 2f);
            Texture2D image    = toggleable ? Widgets.CheckboxOnTex : Widgets.CheckboxOffTex;

            GUI.DrawTexture(position, image);
            if (mouseoverSound != null)
            {
                MouseoverSounds.DoRegion(rect, mouseoverSound);
            }
            if (num)
            {
                toggleable = !toggleable;
                if (toggleable)
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                }
                else
                {
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                }
            }
            if (tutorTag != null)
            {
                UIHighlighter.HighlightOpportunity(rect, tutorTag);
            }
        }
Exemplo n.º 8
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));
            }
        }
        public virtual bool DoGUI(Rect rect, bool colonistOrdering, FloatMenu floatMenu)
        {
            Rect rect2 = rect;

            rect2.height--;
            bool flag  = !Disabled && Mouse.IsOver(rect2);
            bool flag2 = false;

            Text.Font = CurrentFont;
            Rect rect3 = rect;

            rect3.xMin += 4f;
            rect3.xMax  = rect.x + 27f;
            rect3.yMin += 4f;
            rect3.yMax  = rect.y + 27f;
            if (flag)
            {
                rect3.x += 4f;
            }
            Rect rect4 = rect;

            rect4.xMin += HorizontalMargin;
            rect4.xMax -= HorizontalMargin;
            rect4.xMax -= 4f;
            rect4.xMax -= extraPartWidth + IconOffset;
            rect4.x    += IconOffset;
            if (flag)
            {
                rect4.x += 4f;
            }
            Rect rect5 = default(Rect);

            if (extraPartWidth != 0f)
            {
                float num = Mathf.Min(Text.CalcSize(Label).x, rect4.width - 4f);
                rect5 = new Rect(rect4.xMin + num, rect4.yMin, extraPartWidth, 30f);
                flag2 = Mouse.IsOver(rect5);
            }
            if (!Disabled)
            {
                MouseoverSounds.DoRegion(rect2);
            }
            Color color = GUI.color;

            if (Disabled)
            {
                GUI.color = ColorBGDisabled * color;
            }
            else if (flag && !flag2)
            {
                GUI.color = ColorBGActiveMouseover * color;
            }
            else
            {
                GUI.color = ColorBGActive * color;
            }
            GUI.DrawTexture(rect, BaseContent.WhiteTex);
            GUI.color = ((!Disabled) ? ColorTextActive : ColorTextDisabled) * color;
            if (sizeMode == FloatMenuSizeMode.Tiny)
            {
                rect4.y += 1f;
            }
            Widgets.DrawAtlas(rect, TexUI.FloatMenuOptionBG);
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(rect4, Label);
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = iconColor;
            if (shownItem != null || drawPlaceHolderIcon)
            {
                Widgets.DefIcon(rect3, shownItem, null, 1f, drawPlaceHolderIcon);
            }
            else if ((bool)itemIcon)
            {
                GUI.DrawTexture(rect3, itemIcon);
            }
            GUI.color = color;
            if (extraPartOnGUI != null)
            {
                bool num2 = extraPartOnGUI(rect5);
                GUI.color = color;
                if (num2)
                {
                    return(true);
                }
            }
            if (flag && mouseoverGuiAction != null)
            {
                mouseoverGuiAction();
            }
            if (tutorTag != null)
            {
                UIHighlighter.HighlightOpportunity(rect, tutorTag);
            }
            if (Widgets.ButtonInvisible(rect2))
            {
                if (tutorTag != null && !TutorSystem.AllowAction(tutorTag))
                {
                    return(false);
                }
                Chosen(colonistOrdering, floatMenu);
                if (tutorTag != null)
                {
                    TutorSystem.Notify_Event(tutorTag);
                }
                return(true);
            }
            return(false);
        }
        public virtual bool DoGUI(Rect rect, bool colonistOrdering, FloatMenu floatMenu)
        {
            Rect rect2 = rect;

            rect2.height -= 1f;
            bool flag  = !this.Disabled && Mouse.IsOver(rect2);
            bool flag2 = false;

            Text.Font = this.CurrentFont;
            Rect rect3 = rect;

            rect3.xMin += this.HorizontalMargin;
            rect3.xMax -= this.HorizontalMargin;
            rect3.xMax -= 4f;
            rect3.xMax -= this.extraPartWidth;
            if (flag)
            {
                rect3.x += 4f;
            }
            Rect rect4 = default(Rect);

            if (this.extraPartWidth != 0f)
            {
                float num = Mathf.Min(Text.CalcSize(this.Label).x, rect3.width - 4f);
                rect4 = new Rect(rect3.xMin + num, rect3.yMin, this.extraPartWidth, 30f);
                flag2 = Mouse.IsOver(rect4);
            }
            if (!this.Disabled)
            {
                MouseoverSounds.DoRegion(rect2);
            }
            Color color = GUI.color;

            if (this.Disabled)
            {
                GUI.color = FloatMenuOption.ColorBGDisabled * color;
            }
            else if (flag && !flag2)
            {
                GUI.color = FloatMenuOption.ColorBGActiveMouseover * color;
            }
            else
            {
                GUI.color = FloatMenuOption.ColorBGActive * color;
            }
            GUI.DrawTexture(rect, BaseContent.WhiteTex);
            GUI.color = (this.Disabled ? FloatMenuOption.ColorTextDisabled : FloatMenuOption.ColorTextActive) * color;
            if (this.sizeMode == FloatMenuSizeMode.Tiny)
            {
                rect3.y += 1f;
            }
            Widgets.DrawAtlas(rect, TexUI.FloatMenuOptionBG);
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(rect3, this.Label);
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = color;
            if (this.extraPartOnGUI != null)
            {
                bool flag3 = this.extraPartOnGUI(rect4);
                GUI.color = color;
                if (flag3)
                {
                    return(true);
                }
            }
            if (flag && this.mouseoverGuiAction != null)
            {
                this.mouseoverGuiAction();
            }
            if (this.tutorTag != null)
            {
                UIHighlighter.HighlightOpportunity(rect, this.tutorTag);
            }
            if (!Widgets.ButtonInvisible(rect2, false))
            {
                return(false);
            }
            if (this.tutorTag != null && !TutorSystem.AllowAction(this.tutorTag))
            {
                return(false);
            }
            this.Chosen(colonistOrdering, floatMenu);
            if (this.tutorTag != null)
            {
                TutorSystem.Notify_Event(this.tutorTag);
            }
            return(true);
        }
Exemplo n.º 11
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft)
        {
            Rect rect = new Rect(topLeft.x, topLeft.y, this.Width, 75f);
            bool flag = false;

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

            if ((Object)badTex == (Object)null)
            {
                badTex = BaseContent.BadTex;
            }
            GUI.DrawTexture(rect, Command.BGTex);
            MouseoverSounds.DoRegion(rect, SoundDefOf.MouseoverCommand);
            GUI.color = this.IconDrawColor;
            Widgets.DrawTextureFitted(rect, badTex, (float)(this.iconDrawScale * 0.85000002384185791), this.iconProportions, this.iconTexCoords, this.iconAngle);
            GUI.color = Color.white;
            bool    flag2   = false;
            KeyCode keyCode = (this.hotKey != null) ? this.hotKey.MainKey : KeyCode.None;

            if (keyCode != 0 && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Rect rect2 = new Rect((float)(rect.x + 5.0), (float)(rect.y + 5.0), (float)(rect.width - 10.0), 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, (float)(rect.yMax - num + 12.0), 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 (base.disabled && !base.disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = text + "\n\n" + "DisabledCommand".Translate() + ": " + base.disabledReason;
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!this.HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, this.HighlightTag);
            }
            if (flag2)
            {
                if (base.disabled)
                {
                    if (!base.disabledReason.NullOrEmpty())
                    {
                        Messages.Message(base.disabledReason, MessageTypeDefOf.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(this.TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                GizmoResult result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(this.TutorTagSelect);
                return(result);
            }
            if (flag)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }
            return(new GizmoResult(GizmoState.Clear, null));
        }