public override void DoHeader(Rect rect, PawnTable table)
        {
            base.DoHeader(rect, table);
            Text.Font = GameFont.Small;
            if (cachedWorkLabelSize == default(Vector2))
            {
                cachedWorkLabelSize = Text.CalcSize(def.workType.labelShort);
            }
            Rect labelRect = GetLabelRect(rect);

            MouseoverSounds.DoRegion(labelRect);
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(labelRect, def.workType.labelShort);
            GUI.color = new Color(1f, 1f, 1f, 0.3f);
            Widgets.DrawLineVertical(labelRect.center.x, labelRect.yMax - 3f, rect.y + 50f - labelRect.yMax + 3f);
            Widgets.DrawLineVertical(labelRect.center.x + 1f, labelRect.yMax - 3f, rect.y + 50f - labelRect.yMax + 3f);
            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
        }
        private static void DoAreaSelector(Rect rect, Pawn p, Area area)
        {
            MouseoverSounds.DoRegion(rect);
            rect = rect.ContractedBy(1f);
            GUI.DrawTexture(rect, (area != null) ? area.ColorTexture : BaseContent.GreyTex);
            Text.Anchor = TextAnchor.MiddleLeft;
            string text  = AreaUtility.AreaAllowedLabel_Area(area);
            Rect   rect2 = rect;

            rect2.xMin += 3f;
            rect2.yMin += 2f;
            Widgets.Label(rect2, text);
            if (p.playerSettings.AreaRestriction == area)
            {
                Widgets.DrawBox(rect, 2);
            }
            if (Event.current.rawType == EventType.MouseUp && Event.current.button == 0)
            {
                dragging = false;
            }
            if (!Input.GetMouseButton(0) && Event.current.type != 0)
            {
                dragging = false;
            }
            if (Mouse.IsOver(rect))
            {
                area?.MarkForDraw();
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
                {
                    dragging = true;
                }
                if (dragging && p.playerSettings.AreaRestriction != area)
                {
                    p.playerSettings.AreaRestriction = area;
                    SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera();
                }
            }
            Text.Anchor = TextAnchor.UpperLeft;
            TooltipHandler.TipRegion(rect, text);
        }
Ejemplo n.º 3
0
        private bool DrawLocklock(SwapControlsHandler handler, Rect rect)
        {
            Texture2D lockTex;

            if (handler.autoLockOnManualSwap)
            {
                lockTex = TextureResources.autolockOn;
                TooltipHandler.TipRegion(rect, "WeaponSwitchAutolockOn".Translate());
            }
            else
            {
                lockTex = TextureResources.autolockOff;
                TooltipHandler.TipRegion(rect, "WeaponSwitchAutolockOff".Translate());
            }
            MouseoverSounds.DoRegion(rect, SoundDefOf.MouseoverCommand);

            if (Mouse.IsOver(rect))
            {
                LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SimpleSidearmsAdvanced, OpportunityType.GoodToKnow);
                GUI.color = iconMouseOverColor;
            }
            else
            {
                GUI.color = iconBaseColor;
            }

            GUI.DrawTexture(rect, lockTex);
            GUI.color = Color.white;

            if (Widgets.ButtonInvisible(rect, true))
            {
                handler.autoLockOnManualSwap = !handler.autoLockOnManualSwap;
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsAdvanced, KnowledgeAmount.SpecificInteraction);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public static void Checkbox(float x, float y, ref bool checkOn, float size = 24f, bool disabled = false, Texture2D texChecked = null, Texture2D texUnchecked = null, Texture2D texDisabled = null)
        {
            Rect rect = new Rect(x, y, size, size);

            WhoreCheckbox.CheckboxDraw(x, y, checkOn, disabled, size, texChecked, texUnchecked, texDisabled);
            if (!disabled)
            {
                MouseoverSounds.DoRegion(rect);
                bool flag = false;
                Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(rect, false);
                if (draggableResult == Widgets.DraggableResult.Pressed)
                {
                    checkOn = !checkOn;
                    flag    = true;
                }
                else if (draggableResult == Widgets.DraggableResult.Dragged)
                {
                    checkOn = !checkOn;
                    flag    = true;
                    WhoreCheckbox.checkboxPainting      = true;
                    WhoreCheckbox.checkboxPaintingState = checkOn;
                }
                if (Mouse.IsOver(rect) && WhoreCheckbox.checkboxPainting && Input.GetMouseButton(0) && checkOn != WhoreCheckbox.checkboxPaintingState)
                {
                    checkOn = WhoreCheckbox.checkboxPaintingState;
                    flag    = true;
                }
                if (flag)
                {
                    if (checkOn)
                    {
                        SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null);
                    }
                    else
                    {
                        SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private bool DrawIconForUnarmed(Pawn pawn, Rect contentRect, Vector2 iconOffset)
        {
            var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize);

            //var iconColor = iconBaseColor;

            TooltipHandler.TipRegion(iconRect, "DrawSidearm_gizmoTooltipUnarmed".Translate());
            MouseoverSounds.DoRegion(iconRect, SoundDefOf.MouseoverCommand);

            Texture2D drawPocket = TextureResources.drawPocket;

            if (Mouse.IsOver(iconRect))
            {
                GUI.color = iconMouseOverColor;
                GUI.DrawTexture(iconRect, drawPocket);
                //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconMouseOverColor);
            }
            else
            {
                GUI.color = iconBaseColor;
                GUI.DrawTexture(iconRect, drawPocket);
                //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconBaseColor);
            }

            Texture resolvedIcon = TextureResources.unarmedIcon;

            GUI.color = Color.white;
            GUI.DrawTexture(iconRect, resolvedIcon);
            GUI.color = Color.white;

            if (Widgets.ButtonInvisible(iconRect, true))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        private void DoScenarioListEntry(Rect rect, ChallengeDef challenge)
        {
            bool isSelected = this.selectedChallenge == challenge;
            bool canPick    = challenge.CanStartNow;

            Widgets.DrawOptionBackground(rect, isSelected);
            Rect rect2 = rect.ContractedBy(4f);

            if (!canPick)
            {
                GUI.color = new Color(1f, 1f, 1f, 0.5f);
            }
            else
            {
                MouseoverSounds.DoRegion(rect);
            }
            Text.Font = GameFont.Small;
            Rect rect3 = rect2;

            rect3.height = Text.CalcHeight(challenge.LabelCap, rect3.width);
            Widgets.Label(rect3, challenge.LabelCap);
            Text.Font = GameFont.Tiny;
            Rect rect4 = rect2;

            rect4.yMin = rect3.yMax;
            Widgets.Label(rect4, challenge.description);

            GUI.color = Color.white;


            if (canPick)
            {
                if (!isSelected && Widgets.ButtonInvisible(rect, false))
                {
                    this.selectedChallenge = challenge;
                    SoundDefOf.Click.PlayOneShotOnCamera(null);
                }
            }
        }
Ejemplo n.º 7
0
		public static bool TextButton(Rect rect, string label, bool drawBackground, bool doMouseoverSound, bool enabled)
		{
			TextAnchor anchor = Text.Anchor;
			Color color = GUI.color;
			GUI.color = ((!enabled) ? Button.InactiveButtonColor : Color.white);
			if (drawBackground)
			{
				Texture2D atlas = Button.ButtonBGAtlas;
				if (enabled && rect.Contains(Event.current.mousePosition))
				{
					atlas = Button.ButtonBGAtlasMouseover;
					if (Input.GetMouseButton(0))
					{
						atlas = Button.ButtonBGAtlasClick;
					}
				}
				Widgets.DrawAtlas(rect, atlas);
			}
			if (doMouseoverSound)
			{
				MouseoverSounds.DoRegion(rect);
			}
			if (!drawBackground && enabled && rect.Contains(Event.current.mousePosition))
			{
				GUI.color = Button.MouseoverOptionColor;
			}
			if (drawBackground)
			{
				Text.Anchor = TextAnchor.MiddleCenter;
			}
			else
			{
				Text.Anchor = TextAnchor.MiddleLeft;
			}
			Widgets.Label(rect, label);
			Text.Anchor = anchor;
			GUI.color = color;
			return enabled && Widgets.InvisibleButton(rect);
		}
Ejemplo n.º 8
0
        private bool DrawLock(SwapControlsHandler handler, Rect rect)
        {
            Texture2D lockTex;

            if (handler.currentWeaponLocked)
            {
                lockTex = TextureResources.lockClosed;
                TooltipHandler.TipRegion(rect, "LockedWeaponSwitch".Translate());
            }
            else
            {
                lockTex = TextureResources.lockOpen;
                TooltipHandler.TipRegion(rect, "UnlockedWeaponSwitch".Translate());
            }
            MouseoverSounds.DoRegion(rect, SoundDefOf.MouseoverCommand);

            if (Mouse.IsOver(rect))
            {
                GUI.color = iconMouseOverColor;
            }
            else
            {
                GUI.color = iconBaseColor;
            }

            GUI.DrawTexture(rect, lockTex);
            GUI.color = Color.white;

            if (Widgets.ButtonInvisible(rect, true))
            {
                handler.currentWeaponLocked = !handler.currentWeaponLocked;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 9
0
        private bool DrawLocklock(SwapControlsHandler handler, Rect rect)
        {
            Texture2D lockTex;

            if (handler.autoLockOnManualSwap)
            {
                lockTex = TextureResources.autolockOn;
                TooltipHandler.TipRegion(rect, "WeaponSwitchAutolockOn".Translate());
            }
            else
            {
                lockTex = TextureResources.autolockOff;
                TooltipHandler.TipRegion(rect, "WeaponSwitchAutolockOff".Translate());
            }
            MouseoverSounds.DoRegion(rect, SoundDefOf.MouseoverCommand);

            if (Mouse.IsOver(rect))
            {
                GUI.color = iconMouseOverColor;
            }
            else
            {
                GUI.color = iconBaseColor;
            }

            GUI.DrawTexture(rect, lockTex);
            GUI.color = Color.white;

            if (Widgets.ButtonInvisible(rect, true))
            {
                handler.autoLockOnManualSwap = !handler.autoLockOnManualSwap;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 10
0
        public static void DoCopyPasteButtons(Rect rect, Action copyAction, Action pasteAction)
        {
            MouseoverSounds.DoRegion(rect);
            Rect rect2 = new Rect(rect.x, rect.y + (rect.height / 2f - 12f), 18f, 24f);

            if (Widgets.ButtonImage(rect2, TexButton.Copy))
            {
                copyAction();
                SoundDefOf.Tick_High.PlayOneShotOnCamera();
            }
            TooltipHandler.TipRegionByKey(rect2, "Copy");
            if (pasteAction != null)
            {
                Rect rect3 = rect2;
                rect3.x = rect2.xMax;
                if (Widgets.ButtonImage(rect3, TexButton.Paste))
                {
                    pasteAction();
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                }
                TooltipHandler.TipRegionByKey(rect3, "Paste");
            }
        }
Ejemplo n.º 11
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);
            }
        }
Ejemplo n.º 12
0
        public void DrawPreferenceSelector(Pawn pawn, CompSidearmMemory pawnMemory, Rect contentRect)
        {
            var rangedIconRect = new Rect(contentRect.x, contentRect.y, PreferenceIconWidth, PreferenceIconHeight);
            var skillIconRect  = new Rect(contentRect.x, contentRect.y + PreferenceIconHeight + IconGap, PreferenceIconWidth, PreferenceIconHeight);
            var meleeIconRect  = new Rect(contentRect.x, contentRect.y + (PreferenceIconHeight + IconGap) * 2, PreferenceIconWidth, PreferenceIconHeight);

            var skillPref = pawn.getSkillWeaponPreference();

            if (Mouse.IsOver(contentRect))
            {
                LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SimpleSidearmsBasic, OpportunityType.Important);
                LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SimpleSidearmsPreference, OpportunityType.Important);
            }

            if (Mouse.IsOver(rangedIconRect))
            {
                if (pawnMemory.primaryWeaponMode == PrimaryWeaponMode.Ranged)
                {
                    GUI.color = preferenceHighlightSet;
                }
                else
                {
                    GUI.color = preferenceHighlight;
                }
                GUI.DrawTexture(rangedIconRect, TextureResources.preferRanged);
                TooltipHandler.TipRegion(rangedIconRect, string.Format("SidearmPreference_Ranged".Translate()));
                MouseoverSounds.DoRegion(rangedIconRect, SoundDefOf.Mouseover_Command);
            }
            else
            {
                if (pawnMemory.primaryWeaponMode == PrimaryWeaponMode.Ranged)
                {
                    GUI.color = preferenceSet;
                }
                else if (pawnMemory.primaryWeaponMode == PrimaryWeaponMode.BySkill && skillPref == PrimaryWeaponMode.Ranged)
                {
                    GUI.color = preferenceOfSkill;
                }
                else
                {
                    GUI.color = preferenceBase;
                }
                GUI.DrawTexture(rangedIconRect, TextureResources.preferRanged);
            }

            if (Mouse.IsOver(skillIconRect))
            {
                if (pawnMemory.primaryWeaponMode == PrimaryWeaponMode.BySkill)
                {
                    GUI.color = preferenceHighlightSet;
                }
                else
                {
                    GUI.color = preferenceHighlight;
                }
                GUI.DrawTexture(skillIconRect, TextureResources.preferSkilled);
                TooltipHandler.TipRegion(skillIconRect, string.Format("SidearmPreference_Skill".Translate()));
                MouseoverSounds.DoRegion(skillIconRect, SoundDefOf.Mouseover_Command);
            }
            else
            {
                if (pawn.skills != null)
                {
                    if (pawnMemory.primaryWeaponMode == PrimaryWeaponMode.BySkill)
                    {
                        GUI.color = preferenceSet;
                    }
                    else
                    {
                        GUI.color = preferenceBase;
                    }
                    GUI.DrawTexture(skillIconRect, TextureResources.preferSkilled);
                }
            }

            if (Mouse.IsOver(meleeIconRect))
            {
                if (pawnMemory.primaryWeaponMode == PrimaryWeaponMode.Melee)
                {
                    GUI.color = preferenceHighlightSet;
                }
                else
                {
                    GUI.color = preferenceHighlight;
                }
                GUI.DrawTexture(meleeIconRect, TextureResources.preferMelee);
                TooltipHandler.TipRegion(meleeIconRect, string.Format("SidearmPreference_Melee".Translate()));
                MouseoverSounds.DoRegion(meleeIconRect, SoundDefOf.Mouseover_Command);
            }
            else
            {
                if (pawnMemory.primaryWeaponMode == PrimaryWeaponMode.Melee)
                {
                    GUI.color = preferenceSet;
                }
                else if (pawnMemory.primaryWeaponMode == PrimaryWeaponMode.BySkill && skillPref == PrimaryWeaponMode.Melee)
                {
                    GUI.color = preferenceOfSkill;
                }
                else
                {
                    GUI.color = preferenceBase;
                }
                GUI.DrawTexture(meleeIconRect, TextureResources.preferMelee);
            }

            UIHighlighter.HighlightOpportunity(rangedIconRect, "SidearmPreferenceButton");
            UIHighlighter.HighlightOpportunity(skillIconRect, "SidearmPreferenceButton");
            UIHighlighter.HighlightOpportunity(meleeIconRect, "SidearmPreferenceButton");

            if (Widgets.ButtonInvisible(rangedIconRect, true))
            {
                interactedWith = SidearmsListInteraction.SelectorRanged;
            }
            if (Widgets.ButtonInvisible(skillIconRect, true))
            {
                interactedWith = SidearmsListInteraction.SelectorSkill;
            }
            if (Widgets.ButtonInvisible(meleeIconRect, true))
            {
                interactedWith = SidearmsListInteraction.SelectorMelee;
            }
        }
Ejemplo n.º 13
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));
            }
        }
Ejemplo n.º 14
0
        public override void DrawExtraGui(Rect rect)
        {
            if (this.colonistGroup.isColonyGroup || this.colonistGroup.isTaskForce)
            {
                Rect treasureButtonRect = new Rect(rect.x + Textures.TreasuryButton.width, rect.height - 113, Textures.TreasuryButton.width, Textures.TreasuryButton.height);
                GUI.DrawTexture(treasureButtonRect, Textures.TreasuryButton);
                if (Mouse.IsOver(treasureButtonRect))
                {
                    GUI.DrawTexture(treasureButtonRect, Textures.RescueTendHover);
                    if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                    {
                        Find.MainTabsRoot.ToggleTab(DefDatabase <MainButtonDef> .GetNamed("History"));
                    }
                }
                Rect treasureLabelRect = new Rect(treasureButtonRect.x + treasureButtonRect.width + 10f, treasureButtonRect.y, 100f, 26f);
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(treasureLabelRect, this.colonistGroup.Map.wealthWatcher.WealthTotal.ToStringDecimalIfSmall());
                Text.Anchor = TextAnchor.UpperLeft;
            }
            else if (this.colonistGroup is PawnGroup pawnGroup)
            {
                Rect disbandRect = new Rect((rect.width - Textures.DisbandMenu.width) / 2f, rect.height * 0.66f, Textures.DisbandMenu.width, Textures.DisbandMenu.height);
                GUI.DrawTexture(disbandRect, Textures.DisbandMenu);

                Text.Anchor = TextAnchor.UpperCenter;
                var disbandLabelRect = new Rect(disbandRect.x, disbandRect.y + 25f, disbandRect.width, disbandRect.height - 10f);
                Widgets.Label(disbandLabelRect, Strings.Disband);

                var toggleAbleAutoDisbandRect = new Rect(disbandRect.x + (disbandRect.width / 2f) - (Textures.WorkSelectEmpty.width / 2), disbandRect.yMax + 5, Textures.WorkSelectEmpty.width, Textures.WorkSelectEmpty.height);
                if (pawnGroup.autoDisbandWithoutPawns)
                {
                    GUI.DrawTexture(toggleAbleAutoDisbandRect, Textures.WorkSelectEmpty);
                }
                else
                {
                    GUI.DrawTexture(toggleAbleAutoDisbandRect, Textures.WorkSelectBlue);
                }
                if (Mouse.IsOver(toggleAbleAutoDisbandRect))
                {
                    TooltipHandler.TipRegion(toggleAbleAutoDisbandRect, Strings.AutoDisbandTooltip);
                    if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                    {
                        pawnGroup.autoDisbandWithoutPawns = !pawnGroup.autoDisbandWithoutPawns;
                    }
                }

                var disbandPawn = new Rect((disbandRect.x / 2f) + 5f, (disbandRect.y + disbandRect.height) - (Textures.DisbandPawn.height / 2f), Textures.DisbandPawn.width, Textures.DisbandPawn.height);
                MouseoverSounds.DoRegion(disbandPawn);
                if (Mouse.IsOver(disbandPawn))
                {
                    GUI.DrawTexture(disbandPawn, Textures.DisbandPawnHover);
                    if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                    {
                        TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                        foreach (var pawn in Find.Selector.SelectedPawns)
                        {
                            this.colonistGroup.Disband(pawn);
                        }
                        Event.current.Use();
                        if (!this.colonistGroup.pawns.Any())
                        {
                            this.CloseAllWindows();
                        }
                    }
                }
                else
                {
                    GUI.DrawTexture(disbandPawn, Textures.DisbandPawn);
                }

                var disbandPawnLabelRect = new Rect(disbandPawn.x, disbandPawn.y + disbandPawn.height + 1f, disbandPawn.width, disbandPawn.height - 10f);
                Widgets.Label(disbandPawnLabelRect, Strings.DisbandPawn);

                var disbandGroup = new Rect((disbandRect.x + disbandRect.width) - (Textures.DisbandGroup.width / 2f), (disbandRect.y + disbandRect.height) - (Textures.DisbandGroup.height / 2f), Textures.DisbandGroup.width, Textures.DisbandGroup.height);
                MouseoverSounds.DoRegion(disbandGroup);
                if (Mouse.IsOver(disbandGroup))
                {
                    GUI.DrawTexture(disbandGroup, Textures.DisbandGroupHover);
                    if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                    {
                        this.CloseAllWindows();
                        TacticDefOf.TG_DisbandGroupSFX.PlayOneShotOnCamera();
                        Event.current.Use();
                        if (Find.CurrentMap != null && this.colonistGroup.pawns != null)
                        {
                            for (int num = this.colonistGroup.pawns.Count - 1; num >= 0; num--)
                            {
                                if (this.colonistGroup.pawns[num].Map == Find.CurrentMap)
                                {
                                    this.colonistGroup.Disband(this.colonistGroup.pawns[num]);
                                }
                            }
                        }
                        this.colonistGroup.Disband();
                    }
                }
                else
                {
                    GUI.DrawTexture(disbandGroup, Textures.DisbandGroup);
                }
                var disbandGroupLabelRect = new Rect(disbandGroup.x, disbandGroup.y + disbandGroup.height + 1f, disbandGroup.width, disbandGroup.height - 10f);
                Widgets.Label(disbandGroupLabelRect, Strings.DisbandGroup);
                Text.Anchor = TextAnchor.UpperLeft;
            }
        }
        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);
        }
Ejemplo n.º 16
0
        private void DrawPawnList(Rect rect)
        {
            Rect rect2 = rect;

            rect2.height = 60f;
            rect2        = rect2.ContractedBy(4f);
            int groupID = ReorderableWidget.NewGroup(delegate(int from, int to)
            {
                if (TutorSystem.AllowAction("ReorderPawn"))
                {
                    Pawn item = Find.GameInitData.startingPawns[from];
                    Find.GameInitData.startingPawns.RemoveAt(from);
                    Find.GameInitData.startingPawns.Insert(to, item);
                    TutorSystem.Notify_Event("ReorderPawn");
                }
            });

            rect2.y += 15f;
            this.DrawPawnListLabelAbove(rect2, "StartingPawnsSelected".Translate());
            for (int i = 0; i < Find.GameInitData.startingPawns.Count; i++)
            {
                if (i == Find.GameInitData.startingPawnCount)
                {
                    rect2.y += 30f;
                    this.DrawPawnListLabelAbove(rect2, "StartingPawnsLeftBehind".Translate());
                }
                Pawn pawn = Find.GameInitData.startingPawns[i];
                GUI.BeginGroup(rect2);
                Rect rect3 = new Rect(Vector2.zero, rect2.size);
                Widgets.DrawOptionBackground(rect3, this.curPawn == pawn);
                MouseoverSounds.DoRegion(rect3);
                GUI.color = new Color(1f, 1f, 1f, 0.2f);
                Vector2 pawnSelectorPortraitSize = Page_ConfigureStartingPawns.PawnSelectorPortraitSize;
                double  x = 110.0 - pawnSelectorPortraitSize.x / 2.0;
                Vector2 pawnSelectorPortraitSize2 = Page_ConfigureStartingPawns.PawnSelectorPortraitSize;
                double  y = 40.0 - pawnSelectorPortraitSize2.y / 2.0;
                Vector2 pawnSelectorPortraitSize3 = Page_ConfigureStartingPawns.PawnSelectorPortraitSize;
                float   x2 = pawnSelectorPortraitSize3.x;
                Vector2 pawnSelectorPortraitSize4 = Page_ConfigureStartingPawns.PawnSelectorPortraitSize;
                GUI.DrawTexture(new Rect((float)x, (float)y, x2, pawnSelectorPortraitSize4.y), PortraitsCache.Get(pawn, Page_ConfigureStartingPawns.PawnSelectorPortraitSize, default(Vector3), 1f));
                GUI.color = Color.white;
                Rect       rect4      = rect3.ContractedBy(4f).Rounded();
                NameTriple nameTriple = pawn.Name as NameTriple;
                string     label      = (nameTriple == null) ? pawn.LabelShort : ((!string.IsNullOrEmpty(nameTriple.Nick)) ? nameTriple.Nick : nameTriple.First);
                Widgets.Label(rect4.TopPart(0.5f).Rounded(), label);
                Vector2 vector = Text.CalcSize(pawn.story.Title);
                if (vector.x > rect4.width)
                {
                    Widgets.Label(rect4.BottomPart(0.5f).Rounded(), pawn.story.TitleShort);
                }
                else
                {
                    Widgets.Label(rect4.BottomPart(0.5f).Rounded(), pawn.story.Title);
                }
                if (Event.current.type == EventType.MouseDown && Mouse.IsOver(rect3))
                {
                    this.curPawn = pawn;
                    SoundDefOf.TickTiny.PlayOneShotOnCamera(null);
                }
                GUI.EndGroup();
                if (ReorderableWidget.Reorderable(groupID, rect2.ExpandedBy(4f)))
                {
                    Widgets.DrawRectFast(rect2, Widgets.WindowBGFillColor * new Color(1f, 1f, 1f, 0.5f), null);
                }
                TooltipHandler.TipRegion(rect2, new TipSignal("DragToReorder".Translate(), pawn.GetHashCode() * 3499));
                rect2.y += 60f;
            }
        }
Ejemplo n.º 17
0
        public void DrawIconForUnarmed(Pawn pawn, CompSidearmMemory pawnMemory, Rect contentRect, Vector2 iconOffset)
        {
            var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize);
            //var iconColor = iconBaseColor;

            string hoverText;

            if (pawn.Drafted)
            {
                if (pawnMemory.ForcedUnarmedWhileDrafted)
                {
                    hoverText = "DrawSidearm_gizmoTooltipUnarmedForcedWhileDrafted";
                }
                else
                {
                    hoverText = "DrawSidearm_gizmoTooltipUnarmedWhileDrafted";
                }
            }
            else
            {
                if (pawnMemory.ForcedUnarmed)
                {
                    hoverText = "DrawSidearm_gizmoTooltipUnarmedForced";
                }
                else if (pawnMemory.PreferredUnarmed)
                {
                    hoverText = "DrawSidearm_gizmoTooltipUnarmedPreferred";
                }
                else
                {
                    hoverText = "DrawSidearm_gizmoTooltipUnarmed";
                }
            }

            TooltipHandler.TipRegion(iconRect, hoverText.Translate());
            MouseoverSounds.DoRegion(iconRect, SoundDefOf.Mouseover_Command);

            Texture2D drawPocket = TextureResources.drawPocket;

            if (Mouse.IsOver(iconRect))
            {
                GUI.color = iconMouseOverColor;
                GUI.DrawTexture(iconRect, drawPocket);
                //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconMouseOverColor);
            }
            else
            {
                GUI.color = iconBaseColor;
                GUI.DrawTexture(iconRect, drawPocket);
                //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconBaseColor);
            }

            Texture resolvedIcon = TexCommand.AttackMelee;

            GUI.color = Color.white;
            GUI.DrawTexture(iconRect, resolvedIcon);
            GUI.color = Color.white;

            GUI.color = Color.white;

            if (pawnMemory.ForcedUnarmedWhileDrafted)
            {
                GUI.DrawTexture(iconRect, TextureResources.forcedDrafted);
            }

            if (pawnMemory.ForcedUnarmed)
            {
                GUI.DrawTexture(iconRect, TextureResources.forcedAlways);
            }

            if (pawnMemory.PreferredUnarmed)
            {
                GUI.DrawTexture(iconRect, TextureResources.preferredMelee);
            }
            else
            {
                GUI.color = Color.white;
            }

            if (Widgets.ButtonInvisible(iconRect, true))
            {
                interactedWith = SidearmsListInteraction.Unarmed;
            }
        }
Ejemplo n.º 18
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft)
        {
            // start GUI.color is the transparency set by our floatmenu parent
            // store it, so we can apply it to all subsequent colours
            Color transparency = GUI.color;

            // below is 99% copypasta from Designator_Build, with minor naming changes and taking account of transparency.
            var buttonRect = new Rect(topLeft.x, topLeft.y, Width, 75f);
            var mouseover  = false;

            if (Mouse.IsOver(buttonRect))
            {
                mouseover = true;
                GUI.color = GenUI.MouseoverColor * transparency;
            }
            Texture2D tex = icon;

            if (tex == null)
            {
                tex = BaseContent.BadTex;
            }
            GUI.DrawTexture(buttonRect, BGTex);
            MouseoverSounds.DoRegion(buttonRect, SoundDefOf.MouseoverCommand);
            GUI.color = IconDrawColor * transparency;
            Widgets.DrawTextureFitted(new Rect(buttonRect), tex, iconDrawScale * 0.85f, iconProportions,
                                      iconTexCoords);
            GUI.color = Color.white * transparency;
            var     clicked = false;
            KeyCode keyCode = hotKey != null ? hotKey.MainKey : KeyCode.None;

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

            if (!labelCap.NullOrEmpty())
            {
                float height = Text.CalcHeight(labelCap, buttonRect.width) - 2f;
                var   rect2  = new Rect(buttonRect.x, (float)(buttonRect.yMax - (double)height + 12.0),
                                        buttonRect.width, height);
                GUI.DrawTexture(rect2, TexUI.GrayTextBG);
                GUI.color   = Color.white * transparency;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect2, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
            }
            GUI.color = Color.white;
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    TipSignal local = tip;
                    local.text += "\n\nDISABLED: " + disabledReason;
                }
                TooltipHandler.TipRegion(buttonRect, tip);
            }
            // TODO: Reimplement tutor.
            //if( !tutorHighlightTag.NullOrEmpty() )
            //    TutorUIHighlighter.HighlightOpportunity( tutorHighlightTag, buttonRect );

            if (clicked)
            {
                if (!disabled)
                {
                    return(new GizmoResult(GizmoState.Interacted, Event.current));
                }
                if (!disabledReason.NullOrEmpty())
                {
                    Messages.Message(disabledReason, MessageTypeDefOf.RejectInput);
                }
                return(new GizmoResult(GizmoState.Mouseover, null));
            }

            if (mouseover)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }

            return(new GizmoResult(GizmoState.Clear, null));
        }
Ejemplo n.º 19
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));
            }
        }
Ejemplo n.º 20
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 (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }

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

            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);
                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 (this.DoTooltip)
            {
                TipSignal tip = this.Desc;
                if (this.disabled && !this.disabledReason.NullOrEmpty())
                {
                    tip.text = tip.text + "\n\nDISABLED: " + 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);
            }
            float x    = compPsyker.TicksToCast;
            float y    = compPsyker.TicksToCastMax;
            float fill = x / y;

            Widgets.FillableBar(rect, fill, FullTex, EmptyTex, false);
            if (flag2)
            {
                if (this.disabled)
                {
                    if (!this.disabledReason.NullOrEmpty())
                    {
                        Messages.Message(this.disabledReason, MessageSound.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);
            }
            else
            {
                if (flag)
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                return(new GizmoResult(GizmoState.Clear, null));
            }
        }
        //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));
        }
        private void DrawPawnList(Rect rect)
        {
            Rect rect2 = rect;

            rect2.height = 60f;
            rect2        = rect2.ContractedBy(4f);
            int groupID = ReorderableWidget.NewGroup(delegate(int from, int to)
            {
                if (TutorSystem.AllowAction("ReorderPawn"))
                {
                    Pawn item = Find.GameInitData.startingAndOptionalPawns[from];
                    Find.GameInitData.startingAndOptionalPawns.Insert(to, item);
                    Find.GameInitData.startingAndOptionalPawns.RemoveAt((from < to) ? from : (from + 1));
                    TutorSystem.Notify_Event("ReorderPawn");
                    if (to < Find.GameInitData.startingPawnCount && from >= Find.GameInitData.startingPawnCount)
                    {
                        TutorSystem.Notify_Event("ReorderPawnOptionalToStarting");
                    }
                }
            }, ReorderableDirection.Vertical);

            rect2.y += 15f;
            DrawPawnListLabelAbove(rect2, "StartingPawnsSelected".Translate());
            for (int i = 0; i < Find.GameInitData.startingAndOptionalPawns.Count; i++)
            {
                if (i == Find.GameInitData.startingPawnCount)
                {
                    rect2.y += 30f;
                    DrawPawnListLabelAbove(rect2, "StartingPawnsLeftBehind".Translate());
                }
                Pawn pawn = Find.GameInitData.startingAndOptionalPawns[i];
                GUI.BeginGroup(rect2);
                Rect rect3 = new Rect(Vector2.zero, rect2.size);
                Widgets.DrawOptionBackground(rect3, curPawn == pawn);
                MouseoverSounds.DoRegion(rect3);
                GUI.color = new Color(1f, 1f, 1f, 0.2f);
                GUI.DrawTexture(new Rect(110f - PawnSelectorPortraitSize.x / 2f, 40f - PawnSelectorPortraitSize.y / 2f, PawnSelectorPortraitSize.x, PawnSelectorPortraitSize.y), PortraitsCache.Get(pawn, PawnSelectorPortraitSize));
                GUI.color = Color.white;
                Rect       rect4      = rect3.ContractedBy(4f).Rounded();
                NameTriple nameTriple = pawn.Name as NameTriple;
                Widgets.Label(label: (nameTriple == null) ? pawn.LabelShort : (string.IsNullOrEmpty(nameTriple.Nick) ? nameTriple.First : nameTriple.Nick), rect: rect4.TopPart(0.5f).Rounded());
                if (Text.CalcSize(pawn.story.TitleCap).x > rect4.width)
                {
                    Widgets.Label(rect4.BottomPart(0.5f).Rounded(), pawn.story.TitleShortCap);
                }
                else
                {
                    Widgets.Label(rect4.BottomPart(0.5f).Rounded(), pawn.story.TitleCap);
                }
                if (Event.current.type == EventType.MouseDown && Mouse.IsOver(rect3))
                {
                    curPawn = pawn;
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                }
                GUI.EndGroup();
                if (ReorderableWidget.Reorderable(groupID, rect2.ExpandedBy(4f)))
                {
                    Widgets.DrawRectFast(rect2, Widgets.WindowBGFillColor * new Color(1f, 1f, 1f, 0.5f));
                }
                if (Mouse.IsOver(rect2))
                {
                    TooltipHandler.TipRegion(rect2, new TipSignal("DragToReorder".Translate(), pawn.GetHashCode() * 3499));
                }
                rect2.y += 60f;
            }
        }
Ejemplo n.º 23
0
        public void DrawIconForWeaponMemory(Pawn pawn, CompSidearmMemory pawnMemory, ThingDefStuffDefPair weaponType, int stackCount, bool isDuplicate, Rect contentRect, Vector2 iconOffset)
        {
            Graphic g = weaponType.thing.graphicData.Graphic;

            var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize);

            Texture2D drawPocket;

            drawPocket = TextureResources.drawPocketMemory;

            if (pawn.Drafted)
            {
                TooltipHandler.TipRegion(iconRect, string.Format("DrawSidearm_gizmoTooltipMemoryWhileDrafted".Translate(), weaponType.getLabel()));
            }
            else
            {
                TooltipHandler.TipRegion(iconRect, string.Format("DrawSidearm_gizmoTooltipMemory".Translate(), weaponType.getLabel()));
            }
            MouseoverSounds.DoRegion(iconRect, SoundDefOf.Mouseover_Command);
            if (Mouse.IsOver(iconRect))
            {
                LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SidearmsMissing, OpportunityType.GoodToKnow);

                GUI.color = iconMouseOverColor;
                GUI.DrawTexture(iconRect, drawPocket);
            }
            else
            {
                GUI.color = iconBaseColor;
                GUI.DrawTexture(iconRect, drawPocket);
            }

            Graphic outerGraphic = weaponType.thing.graphic;

            if (outerGraphic is Graphic_StackCount)
            {
                outerGraphic = (outerGraphic as Graphic_StackCount).SubGraphicForStackCount(stackCount, weaponType.thing);
            }

            Material material     = outerGraphic.ExtractInnerGraphicFor(null).MatAt(weaponType.thing.defaultPlacingRot, null);
            Texture  resolvedIcon = (Texture2D)material.mainTexture;

            GUI.color = weaponType.getDrawColor();
            GUI.DrawTexture(iconRect, resolvedIcon);
            GUI.color = Color.white;

            if (stackCount > 1)
            {
                var store = Text.Anchor;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(iconRect, stackCount.ToString());
                Text.Anchor = store;
            }

            if (!isDuplicate)
            {
                GUI.color = Color.white;

                if (pawnMemory.ForcedWeapon == weaponType)
                {
                    GUI.DrawTexture(iconRect, TextureResources.forcedAlways);
                }

                if (weaponType.thing.IsRangedWeapon & pawnMemory.DefaultRangedWeapon == weaponType)
                {
                    GUI.DrawTexture(iconRect, TextureResources.defaultRanged);
                }
                else if (pawnMemory.PreferredMeleeWeapon == weaponType)
                {
                    GUI.DrawTexture(iconRect, TextureResources.preferredMelee);
                }

                GUI.color = Color.white;
            }

            UIHighlighter.HighlightOpportunity(iconRect, "SidearmMissing");

            if (Widgets.ButtonInvisible(iconRect, true))
            {
                interactedWith               = SidearmsListInteraction.WeaponMemory;
                interactionWeaponType        = weaponType;
                interactionWeaponIsDuplicate = isDuplicate;
            }
        }
Ejemplo n.º 24
0
        public void DrawIconForWeaponMemory(Pawn pawn, GoldfishModule pawnMemory, ThingStuffPair weaponType, bool isDuplicate, Rect contentRect, Vector2 iconOffset)
        {
            Graphic g = weaponType.thing.graphicData.Graphic;

            var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize);

            Texture2D drawPocket;

            drawPocket = TextureResources.drawPocketMemory;

            if (pawn.Drafted)
            {
                TooltipHandler.TipRegion(iconRect, string.Format("DrawSidearm_gizmoTooltipMemoryWhileDrafted".Translate(), weaponType.getLabel()));
            }
            else
            {
                TooltipHandler.TipRegion(iconRect, string.Format("DrawSidearm_gizmoTooltipMemory".Translate(), weaponType.getLabel()));
            }
            MouseoverSounds.DoRegion(iconRect, SoundDefOf.Mouseover_Command);
            if (Mouse.IsOver(iconRect))
            {
                LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SidearmsMissing, OpportunityType.GoodToKnow);

                GUI.color = iconMouseOverColor;
                GUI.DrawTexture(iconRect, drawPocket);
            }
            else
            {
                GUI.color = iconBaseColor;
                GUI.DrawTexture(iconRect, drawPocket);
            }

            Texture resolvedIcon = weaponType.thing.uiIcon;

            GUI.color = weaponType.getDrawColor();
            GUI.DrawTexture(iconRect, resolvedIcon);
            GUI.color = Color.white;

            if (!isDuplicate)
            {
                GUI.color = Color.white;

                if (pawnMemory.ForcedWeapon == weaponType)
                {
                    GUI.DrawTexture(iconRect, TextureResources.forcedAlways);
                }

                if (weaponType.thing.IsRangedWeapon & pawnMemory.DefaultRangedWeapon == weaponType)
                {
                    GUI.DrawTexture(iconRect, TextureResources.defaultRanged);
                }
                else if (pawnMemory.PreferredMeleeWeapon == weaponType)
                {
                    GUI.DrawTexture(iconRect, TextureResources.preferredMelee);
                }

                GUI.color = Color.white;
            }

            UIHighlighter.HighlightOpportunity(iconRect, "SidearmMissing");

            if (Widgets.ButtonInvisible(iconRect, true))
            {
                interactedWith               = SidearmsListInteraction.WeaponMemory;
                interactionWeaponType        = weaponType;
                interactionWeaponIsDuplicate = isDuplicate;
            }
        }
Ejemplo n.º 25
0
        public void DrawIconForWeapon(Pawn pawn, CompSidearmMemory pawnMemory, ThingWithComps weapon, bool isDuplicate, Rect contentRect, Vector2 iconOffset)
        {
            if (weapon is null || weapon.def is null || weapon.def.uiIcon is null)
            {
                return;
            }

            ThingDefStuffDefPair weaponType = weapon.toThingDefStuffDefPair();

            var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize);
            //var iconColor = iconBaseColor;

            string hoverText;

            if (pawn.Drafted)
            {
                if (pawnMemory.ForcedWeaponWhileDrafted == weapon.toThingDefStuffDefPair())
                {
                    hoverText = "DrawSidearm_gizmoTooltipForcedWhileDrafted";
                }
                else
                {
                    hoverText = "DrawSidearm_gizmoTooltipWhileDrafted";
                }
            }
            else
            {
                if (pawnMemory.ForcedWeapon == weapon.toThingDefStuffDefPair())
                {
                    hoverText = "DrawSidearm_gizmoTooltipForced";
                }
                else
                {
                    if (weapon.def.IsRangedWeapon)
                    {
                        if (pawnMemory.DefaultRangedWeapon == weaponType)
                        {
                            hoverText = "DrawSidearm_gizmoTooltipRangedDefault";
                        }
                        else
                        {
                            hoverText = "DrawSidearm_gizmoTooltipRanged";
                        }
                    }
                    else
                    {
                        if (pawnMemory.PreferredMeleeWeapon == weaponType)
                        {
                            hoverText = "DrawSidearm_gizmoTooltipMeleePreferred";
                        }
                        else
                        {
                            hoverText = "DrawSidearm_gizmoTooltipMelee";
                        }
                    }
                }
            }

            TooltipHandler.TipRegion(iconRect, string.Format(hoverText.Translate(), weapon.toThingDefStuffDefPair().getLabel()));
            MouseoverSounds.DoRegion(iconRect, SoundDefOf.Mouseover_Command);

            Texture2D drawPocket;

            if (pawnMemory.RememberedWeapons.Contains(weapon.toThingDefStuffDefPair()))
            {
                drawPocket = TextureResources.drawPocket;
            }
            else
            {
                drawPocket = TextureResources.drawPocketTemp;
            }

            if (Mouse.IsOver(iconRect))
            {
                LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SidearmsDropping, OpportunityType.GoodToKnow);

                if (pawn.Drafted)
                {
                    LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SimpleSidearmsAdvancedDrafted, OpportunityType.GoodToKnow);
                }
                else
                {
                    if (weapon.def.IsRangedWeapon)
                    {
                        LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SimpleSidearmsAdvancedRanged, OpportunityType.GoodToKnow);
                    }
                    else
                    {
                        LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SimpleSidearmsAdvancedMelee, OpportunityType.GoodToKnow);
                    }
                }

                GUI.color = iconMouseOverColor;
                GUI.DrawTexture(iconRect, drawPocket);
                //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconMouseOverColor);
            }
            else
            {
                GUI.color = iconBaseColor;
                GUI.DrawTexture(iconRect, drawPocket);
                //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconBaseColor);
            }

            Graphic outerGraphic = weaponType.thing.graphic;

            if (outerGraphic is Graphic_StackCount)
            {
                outerGraphic = (outerGraphic as Graphic_StackCount).SubGraphicForStackCount(weapon.stackCount, weaponType.thing);
            }

            Material material     = outerGraphic.ExtractInnerGraphicFor(null).MatAt(weaponType.thing.defaultPlacingRot, null);
            Texture  resolvedIcon = (Texture2D)material.mainTexture;

            GUI.color = weapon.DrawColor;
            GUI.DrawTexture(iconRect, resolvedIcon);
            GUI.color = Color.white;

            if (weapon.stackCount > 1)
            {
                var store = Text.Anchor;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(iconRect, weapon.stackCount.ToString());
                Text.Anchor = store;
            }

            if (!isDuplicate)
            {
                GUI.color = Color.white;


                if (pawnMemory.ForcedWeaponWhileDrafted == weaponType)
                {
                    GUI.DrawTexture(iconRect, TextureResources.forcedDrafted);
                }

                if (pawnMemory.ForcedWeapon == weaponType)
                {
                    GUI.DrawTexture(iconRect, TextureResources.forcedAlways);
                }

                if (weaponType.thing.IsRangedWeapon & pawnMemory.DefaultRangedWeapon == weaponType)
                {
                    GUI.DrawTexture(iconRect, TextureResources.defaultRanged);
                }
                else if (pawnMemory.PreferredMeleeWeapon == weaponType)
                {
                    GUI.DrawTexture(iconRect, TextureResources.preferredMelee);
                }

                GUI.color = Color.white;
            }

            UIHighlighter.HighlightOpportunity(iconRect, "SidearmInInventory");
            if (weapon.def.IsRangedWeapon)
            {
                UIHighlighter.HighlightOpportunity(iconRect, "SidearmInInventoryRanged");
            }
            else
            {
                UIHighlighter.HighlightOpportunity(iconRect, "SidearmInInventoryMelee");
            }

            if (Widgets.ButtonInvisible(iconRect, true))
            {
                interactedWith               = SidearmsListInteraction.Weapon;
                interactionWeapon            = weapon;
                interactionWeaponIsDuplicate = isDuplicate;
            }
        }
Ejemplo n.º 26
0
        public static TabRecord DrawTabs(Rect baseRect, List <TabRecord> tabs, float maxTabWidth = 200f)
        {
            TabRecord tabRecord  = null;
            TabRecord tabRecord2 = tabs.Find((TabRecord t) => t.Selected);
            float     num        = baseRect.width + (float)(tabs.Count - 1) * 10f;
            float     tabWidth   = num / (float)tabs.Count;

            if (tabWidth > maxTabWidth)
            {
                tabWidth = maxTabWidth;
            }
            Rect position = new Rect(baseRect);

            position.y     -= 32f;
            position.height = 9999f;
            GUI.BeginGroup(position);
            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Small;
            Func <TabRecord, Rect> func = (TabRecord tab) => new Rect((float)tabs.IndexOf(tab) * (tabWidth - 10f), 1f, tabWidth, 32f);
            List <TabRecord>       list = tabs.ListFullCopy();

            if (tabRecord2 != null)
            {
                list.Remove(tabRecord2);
                list.Add(tabRecord2);
            }
            TabRecord        tabRecord3 = null;
            List <TabRecord> list2      = list.ListFullCopy();

            list2.Reverse();
            for (int i = 0; i < list2.Count; i++)
            {
                TabRecord tabRecord4 = list2[i];
                Rect      rect       = func(tabRecord4);
                if (tabRecord3 == null && Mouse.IsOver(rect))
                {
                    tabRecord3 = tabRecord4;
                }
                MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Tab);
                if (Widgets.ButtonInvisible(rect))
                {
                    tabRecord = tabRecord4;
                }
            }
            foreach (TabRecord item in list)
            {
                Rect rect2 = func(item);
                item.Draw(rect2);
            }
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
            if (tabRecord != null && tabRecord != tabRecord2)
            {
                SoundDefOf.RowTabSelect.PlayOneShotOnCamera();
                if (tabRecord.clickedAction != null)
                {
                    tabRecord.clickedAction();
                }
            }
            return(tabRecord);
        }
Ejemplo n.º 27
0
        private static bool DrawIconForWeaponMemory(GoldfishModule pawnMemory, ThingDef weapon, Rect contentRect, Vector2 iconOffset)
        {
            var     iconTex  = weapon.uiIcon;
            Graphic g        = weapon.graphicData.Graphic;
            Color   color    = getColor(weapon);
            Color   colorTwo = getColor(weapon);
            Graphic g2       = weapon.graphicData.Graphic.GetColoredVersion(g.Shader, color, colorTwo);

            var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize);

            string label = weapon.label;

            Texture2D drawPocket;

            if (pawnMemory.IsCurrentPrimary(weapon.defName))
            {
                drawPocket = TextureResources.drawPocketMemoryPrimary;
            }
            else
            {
                drawPocket = TextureResources.drawPocketMemory;
            }

            TooltipHandler.TipRegion(iconRect, string.Format("DrawSidearm_gizmoTooltipMemory".Translate(), weapon.label));
            MouseoverSounds.DoRegion(iconRect, SoundDefOf.MouseoverCommand);
            if (Mouse.IsOver(iconRect))
            {
                LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SidearmsMissing, OpportunityType.GoodToKnow);
                if (pawnMemory.IsCurrentPrimary(weapon.defName))
                {
                    LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SidearmsPrimary, OpportunityType.GoodToKnow);
                }
                GUI.color = iconMouseOverColor;
                GUI.DrawTexture(iconRect, drawPocket);
            }
            else
            {
                GUI.color = iconBaseColor;
                GUI.DrawTexture(iconRect, drawPocket);
            }

            Texture resolvedIcon;

            if (!weapon.uiIconPath.NullOrEmpty())
            {
                resolvedIcon = weapon.uiIcon;
            }
            else
            {
                resolvedIcon = g2.MatSingle.mainTexture;
            }
            GUI.color = color;
            GUI.DrawTexture(iconRect, resolvedIcon);
            GUI.color = Color.white;

            UIHighlighter.HighlightOpportunity(iconRect, "SidearmMissing");
            if (pawnMemory.IsCurrentPrimary(weapon.defName))
            {
                UIHighlighter.HighlightOpportunity(iconRect, "SidearmPrimary");
            }

            if (Widgets.ButtonInvisible(iconRect, true))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 28
0
 public override void DoHeader(Rect rect, PawnTable table)
 {
     base.DoHeader(rect, table);
     MouseoverSounds.DoRegion(rect);
 }
Ejemplo n.º 29
0
        private void DoScenarioListEntry(Rect rect, Scenario scen)
        {
            bool flag = curScen == scen;

            Widgets.DrawOptionBackground(rect, flag);
            MouseoverSounds.DoRegion(rect);
            Rect rect2 = rect.ContractedBy(4f);

            Text.Font = GameFont.Small;
            Rect rect3 = rect2;

            rect3.height = Text.CalcHeight(scen.name, rect3.width);
            Widgets.Label(rect3, scen.name);
            Text.Font = GameFont.Tiny;
            Rect rect4 = rect2;

            rect4.yMin = rect3.yMax;
            Widgets.Label(rect4, scen.GetSummary());
            if (!scen.enabled)
            {
                return;
            }
            WidgetRow widgetRow = new WidgetRow(rect.xMax, rect.y, UIDirection.LeftThenDown);

            if (scen.Category == ScenarioCategory.CustomLocal && widgetRow.ButtonIcon(TexButton.DeleteX, "Delete".Translate(), GenUI.SubtleMouseoverColor))
            {
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDelete".Translate(scen.File.Name), delegate
                {
                    scen.File.Delete();
                    ScenarioLister.MarkDirty();
                }, destructive: true));
            }
            if (scen.Category == ScenarioCategory.SteamWorkshop && widgetRow.ButtonIcon(TexButton.DeleteX, "Unsubscribe".Translate(), GenUI.SubtleMouseoverColor))
            {
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(scen.File.Name), delegate
                {
                    scen.enabled = false;
                    if (curScen == scen)
                    {
                        curScen = null;
                        EnsureValidSelection();
                    }
                    Workshop.Unsubscribe(scen);
                }, destructive: true));
            }
            if (scen.GetPublishedFileId() != PublishedFileId_t.Invalid)
            {
                if (widgetRow.ButtonIcon(ContentSource.SteamWorkshop.GetIcon(), "WorkshopPage".Translate()))
                {
                    SteamUtility.OpenWorkshopPage(scen.GetPublishedFileId());
                }
                if (scen.CanToUploadToWorkshop())
                {
                    widgetRow.Icon(CanUploadIcon, "CanBeUpdatedOnWorkshop".Translate());
                }
            }
            if (!flag && Widgets.ButtonInvisible(rect))
            {
                curScen = scen;
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
        }
Ejemplo n.º 30
0
        private bool DrawIconForWeapon(GoldfishModule pawnMemory, Thing weapon, Rect contentRect, Vector2 iconOffset)
        {
            var   iconTex = weapon.def.uiIcon;
            Color color   = weapon.DrawColor;

            var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize);

            //var iconColor = iconBaseColor;

            TooltipHandler.TipRegion(iconRect, string.Format("DrawSidearm_gizmoTooltip".Translate(), weapon.LabelShort));
            MouseoverSounds.DoRegion(iconRect, SoundDefOf.MouseoverCommand);

            Texture2D drawPocket;

            if (pawnMemory != null && pawnMemory.IsCurrentPrimary(weapon.def.defName))
            {
                drawPocket = TextureResources.drawPocketPrimary;
            }
            else
            {
                drawPocket = TextureResources.drawPocket;
            }

            if (Mouse.IsOver(iconRect))
            {
                LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SidearmsInInventory, OpportunityType.GoodToKnow);
                if (pawnMemory != null && pawnMemory.IsCurrentPrimary(weapon.def.defName))
                {
                    LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SidearmsPrimary, OpportunityType.GoodToKnow);
                }
                GUI.color = iconMouseOverColor;
                GUI.DrawTexture(iconRect, drawPocket);
                //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconMouseOverColor);
            }
            else
            {
                GUI.color = iconBaseColor;
                GUI.DrawTexture(iconRect, drawPocket);
                //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconBaseColor);
            }

            Texture resolvedIcon;

            if (!weapon.def.uiIconPath.NullOrEmpty())
            {
                resolvedIcon = weapon.def.uiIcon;
            }
            else
            {
                resolvedIcon = weapon.Graphic.ExtractInnerGraphicFor(weapon).MatSingle.mainTexture;
            }
            GUI.color = weapon.DrawColor;
            GUI.DrawTexture(iconRect, resolvedIcon);
            GUI.color = Color.white;

            UIHighlighter.HighlightOpportunity(iconRect, "SidearmInInventory");
            if (pawnMemory != null && pawnMemory.IsCurrentPrimary(weapon.def.defName))
            {
                UIHighlighter.HighlightOpportunity(iconRect, "SidearmPrimary");
            }

            if (Widgets.ButtonInvisible(iconRect, true))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }