示例#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);
            }
示例#2
0
 public static void TipRegion(Rect rect, TipSignal tip)
 {
     if (Event.current.type != EventType.Repaint)
     {
         return;
     }
     if (tip.textGetter == null && tip.text.NullOrEmpty())
     {
         return;
     }
     if (!Mouse.IsOver(rect))
     {
         return;
     }
     if (DebugViewSettings.drawTooltipEdges)
     {
         Widgets.DrawBox(rect, 1);
     }
     if (!TooltipHandler.activeTips.ContainsKey(tip.uniqueId))
     {
         ActiveTip value = new ActiveTip(tip);
         TooltipHandler.activeTips.Add(tip.uniqueId, value);
         TooltipHandler.activeTips[tip.uniqueId].firstTriggerTime = (double)Time.realtimeSinceStartup;
     }
     TooltipHandler.activeTips[tip.uniqueId].lastTriggerFrame  = TooltipHandler.frame;
     TooltipHandler.activeTips[tip.uniqueId].signal.text       = tip.text;
     TooltipHandler.activeTips[tip.uniqueId].signal.textGetter = tip.textGetter;
 }
示例#3
0
 public TipSignal(TipSignal cloneSource)
 {
     this.text       = cloneSource.text;
     this.textGetter = null;
     this.priority   = cloneSource.priority;
     this.uniqueId   = cloneSource.uniqueId;
 }
示例#4
0
        public override TipSignal GetTooltip()
        {
            TipSignal tip = base.GetTooltip();

            tip.text += "\n" + StoredEnergyText(this);
            return(tip);
        }
 public void DispenseAllThingTooltips()
 {
     if (Event.current.type == EventType.Repaint && Find.WindowStack.FloatMenu == null)
     {
         CellRect currentViewRect = Find.CameraDriver.CurrentViewRect;
         float    cellSizePixels  = Find.CameraDriver.CellSizePixels;
         Vector2  vector          = new Vector2(cellSizePixels, cellSizePixels);
         Rect     rect            = new Rect(0f, 0f, vector.x, vector.y);
         int      num             = 0;
         for (int i = 0; i < this.givers.Count; i++)
         {
             Thing thing = this.givers[i];
             if (currentViewRect.Contains(thing.Position) && !thing.Position.Fogged(thing.Map))
             {
                 Vector2 vector2 = thing.DrawPos.MapToUIPosition();
                 rect.x = (float)(vector2.x - vector.x / 2.0);
                 rect.y = (float)(vector2.y - vector.y / 2.0);
                 if (rect.Contains(Event.current.mousePosition))
                 {
                     string text = (!this.ShouldShowShotReport(thing)) ? null : TooltipUtility.ShotCalculationTipString(thing);
                     if (thing.def.hasTooltip || !text.NullOrEmpty())
                     {
                         TipSignal tooltip = thing.GetTooltip();
                         if (!text.NullOrEmpty())
                         {
                             tooltip.text = tooltip.text + "\n\n" + text;
                         }
                         TooltipHandler.TipRegion(rect, tooltip);
                     }
                 }
                 num++;
             }
         }
     }
 }
示例#6
0
 public TipSignal(TipSignal cloneSource)
 {
     text       = cloneSource.text;
     textGetter = null;
     priority   = cloneSource.priority;
     uniqueId   = cloneSource.uniqueId;
     delay      = 0.45f;
 }
示例#7
0
 public static void TipRegion(Rect rect, TipSignal tip)
 {
     if (Event.current.type == EventType.Repaint && (tip.textGetter != null || !tip.text.NullOrEmpty()) && (Mouse.IsOver(rect) || DebugViewSettings.drawTooltipEdges))
     {
         if (DebugViewSettings.drawTooltipEdges)
         {
             Widgets.DrawBox(rect);
         }
         if (!activeTips.ContainsKey(tip.uniqueId))
         {
             ActiveTip value = new ActiveTip(tip);
             activeTips.Add(tip.uniqueId, value);
             activeTips[tip.uniqueId].firstTriggerTime = Time.realtimeSinceStartup;
         }
         activeTips[tip.uniqueId].lastTriggerFrame  = frame;
         activeTips[tip.uniqueId].signal.text       = tip.text;
         activeTips[tip.uniqueId].signal.textGetter = tip.textGetter;
     }
 }
示例#8
0
        public bool RadioButton_NewTemp(string label, bool active, float tabIn = 0f, string tooltip = null, float?tooltipDelay = null)
        {
            float lineHeight = Text.LineHeight;
            Rect  rect       = GetRect(lineHeight);

            rect.xMin += tabIn;
            if (!tooltip.NullOrEmpty())
            {
                if (Mouse.IsOver(rect))
                {
                    Widgets.DrawHighlight(rect);
                }
                TipSignal tip = tooltipDelay.HasValue ? new TipSignal(tooltip, tooltipDelay.Value) : new TipSignal(tooltip);
                TooltipHandler.TipRegion(rect, tip);
            }
            bool result = Widgets.RadioButtonLabeled(rect, label, active);

            Gap(verticalSpacing);
            return(result);
        }
示例#9
0
        public void DispenseAllThingTooltips()
        {
            if (Event.current.type != EventType.Repaint || Find.WindowStack.FloatMenu != null)
            {
                return;
            }
            CellRect currentViewRect = Find.CameraDriver.CurrentViewRect;
            float    cellSizePixels  = Find.CameraDriver.CellSizePixels;
            Vector2  vector          = new Vector2(cellSizePixels, cellSizePixels);
            Rect     rect            = new Rect(0f, 0f, vector.x, vector.y);
            int      num             = 0;

            for (int i = 0; i < givers.Count; i++)
            {
                Thing thing = givers[i];
                if (!currentViewRect.Contains(thing.Position) || thing.Position.Fogged(thing.Map))
                {
                    continue;
                }
                Vector2 vector2 = thing.DrawPos.MapToUIPosition();
                rect.x = vector2.x - vector.x / 2f;
                rect.y = vector2.y - vector.y / 2f;
                if (rect.Contains(Event.current.mousePosition))
                {
                    string text = ShouldShowShotReport(thing) ? TooltipUtility.ShotCalculationTipString(thing) : null;
                    if (thing.def.hasTooltip || !text.NullOrEmpty())
                    {
                        TipSignal tooltip = thing.GetTooltip();
                        if (!text.NullOrEmpty())
                        {
                            ref string text2 = ref tooltip.text;
                            text2 = text2 + "\n\n" + text;
                        }
                        TooltipHandler.TipRegion(rect, tooltip);
                    }
                }
                num++;
            }
示例#10
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));
            }
        }
示例#11
0
 public ActiveTip(ActiveTip cloneSource)
 {
     this.signal           = cloneSource.signal;
     this.firstTriggerTime = cloneSource.firstTriggerTime;
     this.lastTriggerFrame = cloneSource.lastTriggerFrame;
 }
示例#12
0
 public ActiveTip(TipSignal signal)
 {
     this.signal = signal;
 }
示例#13
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);
            }
示例#14
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));
        }