Exemple #1
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.IsCurrentPrimary(weapon.def.defName))
            {
                drawPocket = TextureResources.drawPocketPrimary;
            }
            else
            {
                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;

            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;

            if (Widgets.ButtonInvisible(iconRect, true))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
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);
            }
        }
        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.Mouseover_Command);

            Texture2D drawPocket = TextureResources.drawPocketTemp;

            if (pawnMemory != null && pawnMemory.IsCurrentPrimary(weapon.def.defName))
            {
                drawPocket = TextureResources.drawPocketPrimary;
            }
            else
            {
                if (pawnMemory != null)
                {
                    foreach (string weaponName in pawnMemory.weapons)
                    {
                        if (weaponName.Equals(weapon.def.defName))
                        {
                            drawPocket = TextureResources.drawPocket;
                            break;
                        }
                    }
                }
            }

            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);
            }
        }
Exemple #4
0
        private static bool DrawIconForWeaponMemory(GoldfishModule pawnMemory, ThingDef weapon, Rect contentRect, Vector2 iconOffset)
        {
            //Log.Message("drawing memory of " + weapon.defName);

            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);

            //if (!contentRect.Contains(iconRect))
            //    return false;

            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))
            {
                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;

            //Log.Message("done");

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