Example #1
0
        public static bool MouseoverReadoutOnGUI_Prefix(MouseoverReadout __instance)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return(true);
            }
            if (Find.MainTabsRoot.OpenTab != null)
            {
                return(true);
            }
            IntVec3 c = UI.MouseCell();

            if (!c.InBounds(Find.VisibleMap))
            {
                return(true);
            }

            MapComponentSeenFog seenFog = Find.VisibleMap.getMapComponentSeenFog();

            if (!c.Fogged(Find.VisibleMap) && (seenFog != null && !seenFog.knownCells[Find.VisibleMap.cellIndices.CellToIndex(c)]))
            {
                GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f));
                Text.Font = GameFont.Small;
                GUI.color = new Color(1f, 1f, 1f, 0.8f);

                Rect rect = new Rect(_MouseoverReadout.BotLeft.x, (float)UI.screenHeight - _MouseoverReadout.BotLeft.y, 999f, 999f);
                Widgets.Label(rect, "NotVisible".Translate());
                GUI.color = Color.white;
                return(false);
            }

            return(true);
        }
            static void ResourceGoalReadout(ResourceReadout __instance)
            {
                if (Event.current.type == EventType.layout)
                {
                    return;
                }
                if (Current.ProgramState != ProgramState.Playing)
                {
                    return;
                }
                if (Find.MainTabsRoot.OpenTab == MainButtonDefOf.Menu)
                {
                    return;
                }
                if (curGoal.resourceAmounts == null)
                {
                    return;
                }

                GenUI.DrawTextWinterShadow(new Rect(256f, 512f, -256f, -512f)); // copied from ResourceReadout, not sure exactly
                Text.Font = GameFont.Small;

                var readoutRect = new Rect(120f + 7f, 48f + 7f, 110f, UI.screenHeight - 7 - 200f);
                var viewRect    = new Rect(0f, 0f, readoutRect.width, lastDrawnHeight);
                var needScroll  = viewRect.height > readoutRect.height;

                if (needScroll)
                {
                    Widgets.BeginScrollView(readoutRect, ref scrollPosition, viewRect, false);
                }
                else
                {
                    scrollPosition = Vector2.zero;
                    GUI.BeginGroup(readoutRect);
                }

                GUI.BeginGroup(viewRect);
                Text.Anchor = TextAnchor.MiddleLeft;
                var labelRect = new Rect(0f, 0f, 999f, 24f);

                Widgets.Label(labelRect, "Goal Tracker");
                if (Event.current.type == EventType.MouseUp && Event.current.button == 1 && Mouse.IsOver(labelRect))
                {
                    Event.current.Use();
                    Find.WindowStack.Add(Goal.FloatMenu(null));
                }
                DrawResource(__instance, readoutRect, out lastDrawnHeight);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.EndGroup();

                if (needScroll)
                {
                    Widgets.EndScrollView();
                }
                else
                {
                    GUI.EndGroup();
                }
            }
Example #3
0
 public static void DrawTextWinterShadowTR(Rect badRect)
 {
     if (Settings.Get().mouseoverInfoTopRight)
     {
         GenUI.DrawTextWinterShadow(new Rect(UI.screenWidth - 256f, 256f, 256f, -256f));
     }
     else
     {
         GenUI.DrawTextWinterShadow(badRect);
     }
 }
Example #4
0
        public void GlobalControlsOnGUI()
        {
            float num  = (float)Screen.width - 134f;
            float num2 = (float)Screen.height;

            num2 -= 35f;
            GenUI.DrawTextWinterShadow(new Rect((float)(Screen.width - 270), (float)(Screen.height - 450), 270f, 450f));
            num2 -= 4f;
            float y = num2 - TimeControls.TimeButSize.y;

            this.rowVisibility.Init((float)Screen.width, y, UIDirection.LeftThenUp, 141f, 29f);
            Find.PlaySettings.DoPlaySettingsGlobalControls(this.rowVisibility);
            num2  = this.rowVisibility.FinalY;
            num2 -= 4f;
            float y2        = TimeControls.TimeButSize.y;
            Rect  timerRect = new Rect(num, num2 - y2, 134f, y2);

            TimeControls.DoTimeControlsGUI(timerRect);
            num2 -= timerRect.height;
            num2 -= 4f;
            if (this.preferenceEnableAlternateTimeDisplay == null || !this.preferenceEnableAlternateTimeDisplay.Value)
            {
                Rect dateRect = new Rect(num, num2 - 22f, 134f, 22f);
                DateReadout.DateOnGUI(dateRect);
                num2 -= dateRect.height;
            }
            else
            {
                Rect dateRect2 = new Rect(num - 48f, num2 - 22f, 182f, 22f);
                DateReadout.AlternateDateOnGUI(dateRect2, this.preferenceAmPm.Value, this.preferenceMinuteInterval.Value);
                num2 -= dateRect2.height;
            }
            Rect rect = new Rect(num - 30f, num2 - 26f, 164f, 26f);

            Find.WeatherManager.DoWeatherGUI(rect);
            num2 -= rect.height;
            Rect rect2 = new Rect(num - 100f, num2 - 26f, 227f, 26f);

            Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(rect2, GlobalControls.TemperatureString());
            Text.Anchor = TextAnchor.UpperLeft;
            num2       -= 26f;
            float num3  = 164f;
            float num4  = Find.MapConditionManager.TotalHeightAt(num3 - 15f);
            Rect  rect3 = new Rect(num - 30f, num2 - num4, num3, num4);

            Find.MapConditionManager.DoConditionsUI(rect3);
            num2 -= rect3.height;
            num2 -= 10f;
            Find.LetterStack.LettersOnGUI(num2);
        }
Example #5
0
        public void GlobalControlsOnGUI()
        {
            if (Event.current.type == EventType.Layout)
            {
                return;
            }
            float num  = (float)UI.screenWidth - 200f;
            float num2 = (float)UI.screenHeight;

            num2 -= 35f;
            GenUI.DrawTextWinterShadow(new Rect((float)(UI.screenWidth - 270), (float)(UI.screenHeight - 450), 270f, 450f));
            num2 -= 4f;
            GlobalControlsUtility.DoPlaySettings(this.rowVisibility, false, ref num2);
            num2 -= 4f;
            GlobalControlsUtility.DoTimespeedControls(num, 200f, ref num2);
            num2 -= 4f;
            GlobalControlsUtility.DoDate(num, 200f, ref num2);
            Rect rect = new Rect(num - 30f, num2 - 26f, 230f, 26f);

            Find.CurrentMap.weatherManager.DoWeatherGUI(rect);
            num2 -= rect.height;
            Rect rect2 = new Rect(num - 100f, num2 - 26f, 293f, 26f);

            Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(rect2, GlobalControls.TemperatureString());
            Text.Anchor = TextAnchor.UpperLeft;
            num2       -= 26f;
            float num3  = 230f;
            float num4  = Find.CurrentMap.gameConditionManager.TotalHeightAt(num3 - 15f);
            Rect  rect3 = new Rect(num - 30f, num2 - num4, num3, num4);

            Find.CurrentMap.gameConditionManager.DoConditionsUI(rect3);
            num2 -= rect3.height;
            if (Prefs.ShowRealtimeClock)
            {
                GlobalControlsUtility.DoRealtimeClock(num, 200f, ref num2);
            }
            TimedForcedExit component = Find.CurrentMap.Parent.GetComponent <TimedForcedExit>();

            if (component != null && component.ForceExitAndRemoveMapCountdownActive)
            {
                Rect rect4 = new Rect(num, num2 - 26f, 193f, 26f);
                Text.Anchor = TextAnchor.MiddleRight;
                GlobalControls.DoCountdownTimer(rect4, component);
                Text.Anchor = TextAnchor.UpperLeft;
                num2       -= 26f;
            }
            num2 -= 10f;
            Find.LetterStack.LettersOnGUI(num2);
        }
Example #6
0
        public void ResourceReadoutOnGUI()
        {
            if (Event.current.type == EventType.Layout)
            {
                return;
            }
            if (Current.ProgramState != ProgramState.Playing)
            {
                return;
            }
            if (Find.MainTabsRoot.OpenTab == MainButtonDefOf.Menu)
            {
                return;
            }
            GenUI.DrawTextWinterShadow(new Rect(256f, 512f, -256f, -512f));
            Text.Font = GameFont.Small;
            Rect rect  = (!Prefs.ResourceReadoutCategorized) ? new Rect(7f, 7f, 110f, (float)(UI.screenHeight - 7) - 200f) : new Rect(2f, 7f, 124f, (float)(UI.screenHeight - 7) - 200f);
            Rect rect2 = new Rect(0f, 0f, rect.width, this.lastDrawnHeight);
            bool flag  = rect2.height > rect.height;

            if (flag)
            {
                Widgets.BeginScrollView(rect, ref this.scrollPosition, rect2, false);
            }
            else
            {
                this.scrollPosition = Vector2.zero;
                GUI.BeginGroup(rect);
            }
            if (!Prefs.ResourceReadoutCategorized)
            {
                this.DoReadoutSimple(rect2, rect.height);
            }
            else
            {
                this.DoReadoutCategorized(rect2);
            }
            if (flag)
            {
                Widgets.EndScrollView();
            }
            else
            {
                GUI.EndGroup();
            }
        }
Example #7
0
 public void GlobalControlsOnGUI()
 {
     if (Event.current.type != EventType.Layout)
     {
         float num  = (float)UI.screenWidth - 200f;
         float num2 = UI.screenHeight;
         num2 -= 35f;
         GenUI.DrawTextWinterShadow(new Rect(UI.screenWidth - 270, UI.screenHeight - 450, 270f, 450f));
         num2 -= 4f;
         GlobalControlsUtility.DoPlaySettings(rowVisibility, worldView: false, ref num2);
         num2 -= 4f;
         GlobalControlsUtility.DoTimespeedControls(num, 200f, ref num2);
         num2 -= 4f;
         GlobalControlsUtility.DoDate(num, 200f, ref num2);
         Rect rect = new Rect(num - 22f, num2 - 26f, 230f, 26f);
         Find.CurrentMap.weatherManager.DoWeatherGUI(rect);
         num2 -= rect.height;
         Rect rect2 = new Rect(num - 100f, num2 - 26f, 293f, 26f);
         Text.Anchor = TextAnchor.MiddleRight;
         Widgets.Label(rect2, TemperatureString());
         Text.Anchor = TextAnchor.UpperLeft;
         num2       -= 26f;
         float num3  = 154f;
         float num4  = Find.CurrentMap.gameConditionManager.TotalHeightAt(num3);
         Rect  rect3 = new Rect((float)UI.screenWidth - num3, num2 - num4, num3, num4);
         Find.CurrentMap.gameConditionManager.DoConditionsUI(rect3);
         num2 -= rect3.height;
         if (Prefs.ShowRealtimeClock)
         {
             GlobalControlsUtility.DoRealtimeClock(num, 200f, ref num2);
         }
         TimedDetectionRaids component = Find.CurrentMap.Parent.GetComponent <TimedDetectionRaids>();
         if (component != null && component.NextRaidCountdownActiveAndVisible)
         {
             Rect rect4 = new Rect(num, num2 - 26f, 193f, 26f);
             Text.Anchor = TextAnchor.MiddleRight;
             DoCountdownTimer(rect4, component);
             Text.Anchor = TextAnchor.UpperLeft;
             num2       -= 26f;
         }
         num2 -= 10f;
         Find.LetterStack.LettersOnGUI(num2);
     }
 }
 public void ResourceReadoutOnGUI()
 {
     if (Event.current.type != EventType.Layout && Current.ProgramState == ProgramState.Playing && Find.MainTabsRoot.OpenTab != MainButtonDefOf.Menu)
     {
         GenUI.DrawTextWinterShadow(new Rect(256f, 512f, -256f, -512f));
         Text.Font = GameFont.Small;
         Rect rect  = (Prefs.ResourceReadoutCategorized ? new Rect(2f, 7f, 124f, (float)(UI.screenHeight - 7) - 200f) : new Rect(7f, 7f, 110f, (float)(UI.screenHeight - 7) - 200f));
         Rect rect2 = new Rect(0f, 0f, rect.width, lastDrawnHeight);
         bool num   = rect2.height > rect.height;
         if (num)
         {
             Widgets.BeginScrollView(rect, ref scrollPosition, rect2, showScrollbars: false);
         }
         else
         {
             scrollPosition = Vector2.zero;
             GUI.BeginGroup(rect);
         }
         if (!Prefs.ResourceReadoutCategorized)
         {
             DoReadoutSimple(rect2, rect.height);
         }
         else
         {
             DoReadoutCategorized(rect2);
         }
         if (num)
         {
             Widgets.EndScrollView();
         }
         else
         {
             GUI.EndGroup();
         }
     }
 }
Example #9
0
        public void MouseoverReadoutOnGUI()
        {
            if (Find.MainTabsRoot.OpenTab != null)
            {
                return;
            }
            GenUI.DrawTextWinterShadow(new Rect(256f, (float)(Screen.height - 256), -256f, 256f));
            Text.Font = GameFont.Small;
            GUI.color = new Color(1f, 1f, 1f, 0.8f);
            IntVec3 c = Gen.MouseCell();

            if (!c.InBounds())
            {
                return;
            }
            float num = 0f;
            Rect  rect;

            if (c.Fogged())
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                Widgets.Label(rect, "Undiscovered".Translate());
                GUI.color = Color.white;
                return;
            }
            rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
            Widgets.Label(rect, Find.GlowGrid.PsychGlowAt(c).GetLabel() + " (" + Find.GlowGrid.GameGlowAt(c).ToStringPercent() + ")");
            num += 19f;
            rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
            TerrainDef terrain = c.GetTerrain();

            if (terrain != this.cachedTerrain)
            {
                this.cachedTerrainString = terrain.LabelCap + ((terrain.passability != Traversability.Impassable) ? (" (" + "WalkSpeed".Translate(new object[]
                {
                    this.SpeedPercentString((float)terrain.pathCost)
                }) + ")") : null);
                this.cachedTerrain = terrain;
            }
            Widgets.Label(rect, this.cachedTerrainString);
            num += 19f;
            Zone zone = c.GetZone();

            if (zone != null)
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                string label = zone.label;
                Widgets.Label(rect, label);
                num += 19f;
            }
            float depth = Find.SnowGrid.GetDepth(c);

            if ((double)depth > 0.03)
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth);
                string       label2       = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(new object[]
                {
                    this.SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory))
                }) + ")";
                Widgets.Label(rect, label2);
                num += 19f;
            }
            List <Thing> list = Find.ThingGrid.ThingsListAt(c);

            for (int i = 0; i < list.Count; i++)
            {
                Thing thing = list[i];
                if (thing.def.category != ThingCategory.Mote)
                {
                    rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                    string labelMouseover = thing.LabelMouseover;
                    Widgets.Label(rect, labelMouseover);
                    num += 19f;
                }
            }
            RoofDef roof = c.GetRoof();

            if (roof != null)
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                Widgets.Label(rect, roof.LabelCap);
                num += 19f;
            }
            GUI.color = Color.white;
        }
        public static bool MouseoverReadoutOnGUI(MouseoverReadout __instance)
        {
            IntVec3 c = UI.MouseCell();

            if (!c.InBounds(Find.CurrentMap) ||
                Event.current.type != EventType.Repaint ||
                Find.MainTabsRoot.OpenTab != null)
            {
                return(false);
            }

            if (Find.CurrentMap.GetComponent <MapComponent_FertilityMods>().Get is MapComponent_FertilityMods fert &&
                fert.ActiveCells.Contains(c))
            {
                //Original Variables
                Vector2 BotLeft = new Vector2(15f, 65f);

                GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f));
                Text.Font = GameFont.Small;
                GUI.color = new Color(1f, 1f, 1f, 0.8f);

                float num = 0f;
                Rect  rect;
                if (c.Fogged(Find.CurrentMap))
                {
                    rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                    Widgets.Label(rect, "Undiscovered".Translate());
                    GUI.color = Color.white;
                    return(false);
                }
                rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                int      num2        = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c) * 100f);
                string[] glowStrings = Traverse.Create(__instance).Field("glowStrings").GetValue <string[]>();
                Widgets.Label(rect, glowStrings[num2]);
                num += 19f;
                rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                TerrainDef terrain = c.GetTerrain(Find.CurrentMap);
                //string SpeedPercentString = Traverse.Create(__instance).Method("SpeedPercentString", (float)terrain.pathCost).GetValue<string>();
                //TerrainDef cachedTerrain = Traverse.Create(__instance).Field("cachedTerrain").GetValue<TerrainDef>();
                string cachedTerrainString =
                    Traverse.Create(__instance).Field("cachedTerrainString").GetValue <string>();

                //if (terrain != cachedTerrain)
                //{
                float  fertNum = Find.CurrentMap.fertilityGrid.FertilityAt(c);
                string str     = ((double)fertNum <= 0.0001)
                    ? string.Empty
                    : (" " + "FertShort".Translate() + " " + fertNum.ToStringPercent());
                cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable)
                                          ? null
                                          : (" (" + "WalkSpeed".Translate(new object[]
                {
                    SpeedPercentString((float)terrain.pathCost)
                }) + str + ")"));
                //cachedTerrain = terrain;
                //}
                Widgets.Label(rect, cachedTerrainString);
                num += 19f;
                Zone zone = c.GetZone(Find.CurrentMap);
                if (zone != null)
                {
                    rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                    string label = zone.label;
                    Widgets.Label(rect, label);
                    num += 19f;
                }
                float depth = Find.CurrentMap.snowGrid.GetDepth(c);
                if (depth > 0.03f)
                {
                    rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                    SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth);
                    string       label2       = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(new object[]
                    {
                        SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory))
                    }) + ")";
                    Widgets.Label(rect, label2);
                    num += 19f;
                }
                List <Thing> thingList = c.GetThingList(Find.CurrentMap);
                for (int i = 0; i < thingList.Count; i++)
                {
                    Thing thing = thingList[i];
                    if (thing.def.category != ThingCategory.Mote)
                    {
                        rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                        string labelMouseover = thing.LabelMouseover;
                        Widgets.Label(rect, labelMouseover);
                        num += 19f;
                    }
                }
                RoofDef roof = c.GetRoof(Find.CurrentMap);
                if (roof != null)
                {
                    rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                    Widgets.Label(rect, roof.LabelCap);
                    num += 19f;
                }
                GUI.color = Color.white;
                return(false);
            }
            return(true);
        }