//public override bool GroupsWith(Gizmo other)
        //{
        //    if (other is Command_PawnAbility p && p.pawnAbility.Def.abilityClass == this.pawnAbility.Def.abilityClass)
        //        return true;
        //    return false;
        //}

        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            var rect        = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            var isMouseOver = false;

            if (Mouse.IsOver(rect))
            {
                isMouseOver = true;
                GUI.color   = GenUI.MouseoverColor;
            }
            var badTex = icon;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }

            GUI.DrawTexture(rect, BGTex);
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            GUI.color = IconDrawColor;
            Widgets.DrawTextureFitted(new Rect(rect), badTex, iconDrawScale * 0.85f, iconProportions, iconTexCoords);
            GUI.color = Color.white;
            var isUsed = false;
            //Rect rectFil = new Rect(topLeft.x, topLeft.y, this.Width, this.Width);

            var keyCode = hotKey != null ? hotKey.MainKey : KeyCode.None;

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

            if (!labelCap.NullOrEmpty())
            {
                var num = Text.CalcHeight(labelCap, rect.width);
                num -= 2f;
                var 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 (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    tip.text = tip.text + "\n" + StringsToTranslate.AU_DISABLED + ": " + disabledReason;
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (pawnAbility.CooldownTicksLeft != -1 && pawnAbility.CooldownTicksLeft < pawnAbility.MaxCastingTicks)
            {
                var math = curTicks / (float)pawnAbility.MaxCastingTicks;
                Widgets.FillableBar(rect, math, AbilityButtons.FullTex, AbilityButtons.EmptyTex, false);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null ||
                                                !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, HighlightTag);
            }
            if (isUsed)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(disabledReason, MessageTypeDefOf.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                var result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(TutorTagSelect);
                return(result);
            }
            if (isMouseOver)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }
            return(new GizmoResult(GizmoState.Clear, null));
        }
Exemple #2
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag      = true;
                GUI.color = GenUI.MouseoverColor;
            }
            Texture2D badTex = LockUtility.GetData(parent).WantedState.locked ? lockTexture : unlockTexture;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }
            GUI.DrawTexture(rect, BGTex);
            GUI.DrawTexture(rect, badTex);
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            bool    flag2   = false;
            KeyCode keyCode = (this.hotKey != null) ? 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 (hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                flag2 = true;
            }
            string labelCap = 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 (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        disabledReason
                    });
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, HighlightTag);
            }
            if (flag2)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(disabledReason, MessageTypeDefOf.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                GizmoResult result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(TutorTagSelect);
                return(result);
            }
            else
            {
                if (flag)
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                return(new GizmoResult(GizmoState.Clear, null));
            }
        }
        //public override bool GroupsWith(Gizmo other)
        //{
        //    return other is Command_PawnAbility p && p.pawnAbility.Def.abilityClass == pawnAbility.Def.abilityClass;
        //}

        protected override GizmoResult GizmoOnGUIInt(Rect butRect, GizmoRenderParms parms)
        {
            // TODO: This is based off Command.GizmoOnGUI at version ~A17, so it's very outdated. Actually use parms and other modern features.
            var isMouseOver = false;

            if (Mouse.IsOver(butRect))
            {
                isMouseOver = true;
                GUI.color   = GenUI.MouseoverColor;
            }
            var badTex = icon ?? BaseContent.BadTex;

            GUI.DrawTexture(butRect, BGTex);
            MouseoverSounds.DoRegion(butRect, SoundDefOf.Mouseover_Command);
            GUI.color = IconDrawColor;
            Widgets.DrawTextureFitted(new Rect(butRect), badTex, iconDrawScale * 0.85f, iconProportions, iconTexCoords);
            GUI.color = Color.white;
            var isUsed = false;

            var keyCode = hotKey != null ? hotKey.MainKey : KeyCode.None;

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

            if (!labelCap.NullOrEmpty())
            {
                var labelHeight = Text.CalcHeight(labelCap, butRect.width) - 2f;
                var labelRect   = new Rect(butRect.x, butRect.yMax - labelHeight + 12f, butRect.width, labelHeight);
                GUI.DrawTexture(labelRect, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(labelRect, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    tip.text += "\n" + StringsToTranslate.AU_DISABLED + ": " + disabledReason;
                }
                TooltipHandler.TipRegion(butRect, tip);
            }
            if (pawnAbility.CooldownTicksLeft != -1 && pawnAbility.CooldownTicksLeft < pawnAbility.MaxCastingTicks)
            {
                var math = curTicks / (float)pawnAbility.MaxCastingTicks;
                Widgets.FillableBar(butRect, math, AbilityButtons.FullTex, AbilityButtons.EmptyTex, false);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null ||
                                                !Find.WindowStack.FloatMenu.windowRect.Overlaps(butRect)))
            {
                UIHighlighter.HighlightOpportunity(butRect, HighlightTag);
            }
            if (isUsed)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(disabledReason, MessageTypeDefOf.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                var result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(TutorTagSelect);
                return(result);
            }
            return(new GizmoResult(isMouseOver ? GizmoState.Mouseover : GizmoState.Clear, null));
        }
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Text.Font = GameFont.Tiny;
            Rect rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), GizmoSize);
            bool flag = false;

            Rect      gizmoRect = new Rect(rect.x + 3.5f, rect.y, rect.width / 2, rect.height).ContractedBy(7);
            Texture2D badTex    = icon;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }
            var gizmoColor  = GUI.color;
            var ammoColor   = GUI.color;
            var reloadColor = GUI.color;


            Material material = (!disabled) ? null : TexUI.GrayscaleGUI;

            GenUI.DrawTextureWithMaterial(rect, AmmoBG, material, default);
            Rect ammoRect   = new Rect(gizmoRect.x + gizmoRect.width + 7, gizmoRect.y, gizmoRect.width, (gizmoRect.height / 2) - 3.5f);
            Rect reloadRect = new Rect(gizmoRect.x + gizmoRect.width + 7, ammoRect.y + ammoRect.height + 7, gizmoRect.width, (gizmoRect.height / 2) - 3.5f);

            MouseoverSounds.DoRegion(gizmoRect, SoundDefOf.Mouseover_Command);
            MouseoverSounds.DoRegion(ammoRect, SoundDefOf.Mouseover_Command);
            MouseoverSounds.DoRegion(reloadRect, SoundDefOf.Mouseover_Command);

            if (Mouse.IsOver(gizmoRect))
            {
                flag = true;
                if (!disabled)
                {
                    GUI.color = GenUI.MouseoverColor;
                }
            }
            GenUI.DrawTextureWithMaterial(gizmoRect, BGTex, material, default);
            GUI.color = gizmoColor;
            if (cannon.cannonDef.ammoAllowed?.Any() ?? false)
            {
                if (Mouse.IsOver(ammoRect))
                {
                    flag = true;
                    if (!disabled)
                    {
                        GUI.color = GenUI.MouseoverColor;
                    }
                }
                GenUI.DrawTextureWithMaterial(ammoRect, BGTex, material, default);
                GUI.color = ammoColor;
                if (Mouse.IsOver(reloadRect))
                {
                    flag = true;
                    if (!disabled)
                    {
                        GUI.color = GenUI.MouseoverColor;
                    }
                }
                GenUI.DrawTextureWithMaterial(reloadRect, BGTex, material, default);
                GUI.color = reloadColor;
                Rect reloadLabel = new Rect(reloadRect.x + 10, reloadRect.y + reloadRect.height / 4, reloadRect.width - 10, reloadRect.height / 1.5f);
                Widgets.Label(reloadLabel, "Extract".Translate());
            }
            GUI.color = IconDrawColor;
            Widgets.DrawTextureFitted(gizmoRect, badTex, iconDrawScale * 0.85f, iconProportions, iconTexCoords, iconAngle, material);
            GUI.color = Color.white;
            bool    flag2   = false;
            bool    flag3   = false;
            bool    flag4   = false;
            KeyCode keyCode = (hotKey != null) ? 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 (hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(gizmoRect, false))
            {
                flag2 = true;
            }
            if (Widgets.ButtonInvisible(ammoRect, false))
            {
                flag3 = true;
            }
            if (Widgets.ButtonInvisible(reloadRect, false))
            {
                flag4 = false;
            }
            string labelCap = 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 (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        disabledReason
                    });
                }
                TooltipHandler.TipRegion(gizmoRect, tip);
            }
            if (cannon.cooldownTicks > 0)
            {
                float percent = cannon.cooldownTicks / (float)cannon.MaxTicks;
                SPExtra.VerticalFillableBar(gizmoRect, percent, FillableBar, ClearBar);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(gizmoRect)))
            {
                UIHighlighter.HighlightOpportunity(gizmoRect, HighlightTag);
            }
            Text.Font = GameFont.Small;
            if (flag2)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(disabledReason, MessageTypeDefOf.RejectInput, false);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                var result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(TutorTagSelect);
                return(result);
            }
            if (flag3)
            {
                //Change later
                cannon.ReloadCannon(cannon.pawn.inventory.innerContainer.FirstOrDefault(x => cannon.cannonDef.ammoAllowed.Contains(x.def)).def);
            }
            if (flag4)
            {
                cannon.TryRemoveShell();
            }
            if (flag)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }
            return(new GizmoResult(GizmoState.Clear, null));
        }
Exemple #5
0
        // same as base.GizmoOnGUI(), but in specified rect size
        public GizmoResult DrawDesignator(Rect rect)
        {
            bool mouseOver = false;

            if (Mouse.IsOver(rect))
            {
                mouseOver = true;
                GUI.color = GenUI.MouseoverColor;
            }
            GUI.DrawTexture(rect, BGTex);
            MouseoverSounds.DoRegion(rect, SoundDefOf.MouseoverCommand);

            // draw thing's texture
            Widgets.ThingIcon(rect, SlotsBackpackComp.parent);

            bool    gizmoActivated = false;
            KeyCode keyCode        = hotKey?.MainKey ?? KeyCode.None;

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

            if (!labelCap.NullOrEmpty())
            {
                float num = Text.CalcHeight(labelCap, rect.width);
                num -= 2f;
                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 (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    tip.text = tip.text + "\n\nDISABLED: " + disabledReason;
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!HighlightTag.NullOrEmpty() &&
                (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, HighlightTag);
            }
            if (gizmoActivated)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(disabledReason, MessageSound.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                return(new GizmoResult(GizmoState.Interacted, Event.current));
            }
            if (mouseOver)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }
            return(new GizmoResult(GizmoState.Clear, null));
        }
Exemple #6
0
        // copy paste from Command.GizmoOnGUI
        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;
                }
            }

            Material material = (!disabled) ? null : TexUI.GrayscaleGUI;

            GenUI.DrawTextureWithMaterial(rect, BGTex, material);
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            // BEGIN EDIT
            GUI.color = IconDrawColor;
            DrawToolbarIcon(rect);
            // END EDIT
            GUI.color = UnityEngine.Color.white;
            bool    flag2   = false;
            KeyCode keyCode = (hotKey != null) ? hotKey.MainKey : KeyCode.None;

            if (keyCode != 0 && !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 (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  rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = UnityEngine.Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = UnityEngine.Color.white;
            }
            GUI.color = UnityEngine.Color.white;
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = text + "\n\n" + "DisabledCommand".Translate() + ": " + disabledReason;
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, HighlightTag);
            }
            Text.Font = GameFont.Small;
            if (flag2)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(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(TutorTagSelect))
                    {
                        return(new GizmoResult(GizmoState.Mouseover, null));
                    }
                    result = new GizmoResult(GizmoState.Interacted, Event.current);
                    TutorSystem.Notify_Event(TutorTagSelect);
                }
                return(result);
            }
            if (flag)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }
            return(new GizmoResult(GizmoState.Clear, null));
        }
Exemple #7
0
        // copy paste from Command.GizmoOnGUI
        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;
                }
            }
            Texture2D badTex = icon;

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

            GenUI.DrawTextureWithMaterial(rect, BGTex, material);
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            Rect    outerRect = rect;
            Vector2 position  = outerRect.position;
            float   x         = iconOffset.x;
            Vector2 size      = outerRect.size;
            float   x2        = x * size.x;
            float   y         = iconOffset.y;
            Vector2 size2     = outerRect.size;

            outerRect.position = position + new Vector2(x2, y * size2.y);
            GUI.color          = IconDrawColor;
            // BEGIN EDIT
            //Widgets.DrawTextureFitted(outerRect, badTex, iconDrawScale * 0.85f, iconProportions, iconTexCoords, iconAngle, material);
            {
                Rect  positionColor = new Rect(0f, 0f, iconProportions.x, iconProportions.y);
                float num;
                if (positionColor.width / positionColor.height < rect.width / rect.height)
                {
                    num = rect.height / positionColor.height;
                }
                else
                {
                    num = rect.width / positionColor.width;
                }
                num *= iconDrawScale * 0.85f;
                positionColor.width  *= num;
                positionColor.height *= num;
                positionColor.x       = rect.x + rect.width / 2f - positionColor.width / 2f;
                positionColor.y       = rect.y + rect.height / 2f - positionColor.height / 2f;

                Widgets.DrawBoxSolid(positionColor, PlanColorManager.PlanColor[Color]);

                Widgets.DrawTextureFitted(outerRect,
                                          MorePlanningMod.Instance.SelectedColor == Color
                        ? Resources.ToolBoxColorSelected
                        : Resources.ToolBoxColor, iconDrawScale * 0.85f, iconProportions, iconTexCoords);
            }
            // END EDIT
            GUI.color = UnityEngine.Color.white;
            bool    flag2   = false;
            KeyCode keyCode = (hotKey != null) ? hotKey.MainKey : KeyCode.None;

            if (keyCode != 0 && !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 (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  rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = UnityEngine.Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = UnityEngine.Color.white;
            }
            GUI.color = UnityEngine.Color.white;
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = text + "\n\n" + "DisabledCommand".Translate() + ": " + disabledReason;
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, HighlightTag);
            }
            Text.Font = GameFont.Small;
            if (flag2)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(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(TutorTagSelect))
                    {
                        return(new GizmoResult(GizmoState.Mouseover, null));
                    }
                    result = new GizmoResult(GizmoState.Interacted, Event.current);
                    TutorSystem.Notify_Event(TutorTagSelect);
                }
                return(result);
            }
            if (flag)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }
            return(new GizmoResult(GizmoState.Clear, null));
        }