Exemplo n.º 1
0
        public static IEnumerable <LocalTargetInfo> TargetsAt(Vector3 clickPos, TargetingParameters clickParams, bool thingsOnly = false)
        {
            List <Thing> clickableList = GenUI.ThingsUnderMouse(clickPos, 0.8f, clickParams);

            for (int i = 0; i < clickableList.Count; i++)
            {
                yield return(clickableList[i]);
            }
            if (!thingsOnly)
            {
                IntVec3 cellTarg = UI.MouseCell();
                if (cellTarg.InBounds(Find.VisibleMap) && clickParams.CanTarget(new TargetInfo(cellTarg, Find.VisibleMap, false)))
                {
                    yield return(cellTarg);
                }
            }
        }
Exemplo n.º 2
0
        private static Vector2 CalculateInitialTipPosition(List <ActiveTip> drawingTips)
        {
            float num  = 0f;
            float num2 = 0f;

            for (int i = 0; i < drawingTips.Count; i++)
            {
                Rect tipRect = drawingTips[i].TipRect;
                num += tipRect.height;
                num2 = Mathf.Max(num2, tipRect.width);
                if (i != drawingTips.Count - 1)
                {
                    num += 2f;
                }
            }
            return(GenUI.GetMouseAttachedWindowPos(num2, num));
        }
Exemplo n.º 3
0
 private void UpdateBaseColor()
 {
     this.baseColor = Color.white;
     if (this.vanishIfMouseDistant)
     {
         Rect r = new Rect(0f, 0f, this.TotalWidth, this.TotalWindowHeight).ContractedBy(-5f);
         if (!r.Contains(Event.current.mousePosition))
         {
             float num = GenUI.DistFromRect(r, Event.current.mousePosition);
             this.baseColor = new Color(1f, 1f, 1f, 1f - num / 95f);
             if (num > 95f)
             {
                 this.Close(false);
                 this.Cancel();
             }
         }
     }
 }
Exemplo n.º 4
0
 public static void Save()
 {
     try
     {
         XDocument xdocument = new XDocument();
         XElement  content   = DirectXmlSaver.XElementFromObject(Prefs.data, typeof(PrefsData));
         xdocument.Add(content);
         xdocument.Save(GenFilePaths.PrefsFilePath);
     }
     catch (Exception ex)
     {
         GenUI.ErrorDialog("ProblemSavingFile".Translate(new object[]
         {
             GenFilePaths.PrefsFilePath,
             ex.ToString()
         }));
         Log.Error("Exception saving prefs: " + ex, false);
     }
 }
Exemplo n.º 5
0
        private void UpdateBaseColor()
        {
            baseColor = Color.white;
            if (!vanishIfMouseDistant)
            {
                return;
            }
            Rect r = new Rect(0f, 0f, TotalWidth, TotalWindowHeight).ContractedBy(-5f);

            if (!r.Contains(Event.current.mousePosition))
            {
                float num = GenUI.DistFromRect(r, Event.current.mousePosition);
                baseColor = new Color(1f, 1f, 1f, 1f - num / 95f);
                if (num > 95f)
                {
                    Close(doCloseSound: false);
                    Cancel();
                }
            }
        }
Exemplo n.º 6
0
 public static void SaveDataObject(object obj, string filePath)
 {
     try
     {
         XDocument xDocument = new XDocument();
         XElement  content   = DirectXmlSaver.XElementFromObject(obj, obj.GetType());
         xDocument.Add(content);
         xDocument.Save(filePath);
     }
     catch (Exception ex)
     {
         Log.Error(string.Concat(new object[]
         {
             "Exception saving data object ",
             obj.ToStringSafe <object>(),
             ": ",
             ex
         }), false);
         GenUI.ErrorDialog("ProblemSavingFile".Translate(filePath, ex.ToString()));
     }
 }
Exemplo n.º 7
0
        public void MouseoverReadoutOnGUI()
        {
            if (Event.current.type != EventType.Repaint || Find.MainTabsRoot.OpenTab != null)
            {
                return;
            }
            GenUI.DrawTextWinterShadow(new Rect(256f, UI.screenHeight - 256, -256f, 256f));
            Text.Font = GameFont.Small;
            GUI.color = new Color(1f, 1f, 1f, 0.8f);
            IntVec3 c = UI.MouseCell();

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

            if (c.Fogged(Find.CurrentMap))
            {
                Widgets.Label(new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f), "Undiscovered".Translate());
                GUI.color = Color.white;
                return;
            }
            Rect rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
            int  num2 = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c) * 100f);

            Widgets.Label(rect, glowStrings[num2]);
            num += 19f;
            Rect       rect2   = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
            TerrainDef terrain = c.GetTerrain(Find.CurrentMap);

            if (terrain != cachedTerrain)
            {
                string t = ((double)terrain.fertility > 0.0001) ? (" " + "FertShort".TranslateSimple() + " " + terrain.fertility.ToStringPercent()) : "";
                cachedTerrainString = terrain.LabelCap + ((terrain.passability != Traversability.Impassable) ? (" (" + "WalkSpeed".Translate(SpeedPercentString(terrain.pathCost)) + t + ")") : ((TaggedString)null));
                cachedTerrain       = terrain;
            }
            Widgets.Label(rect2, cachedTerrainString);
            num += 19f;
            Zone zone = c.GetZone(Find.CurrentMap);

            if (zone != null)
            {
                Rect   rect3 = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                string label = zone.label;
                Widgets.Label(rect3, label);
                num += 19f;
            }
            float depth = Find.CurrentMap.snowGrid.GetDepth(c);

            if (depth > 0.03f)
            {
                Rect         rect4        = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth);
                string       label2       = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(SpeedPercentString(SnowUtility.MovementTicksAddOn(snowCategory))) + ")";
                Widgets.Label(rect4, 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   rect5          = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                    string labelMouseover = thing.LabelMouseover;
                    Widgets.Label(rect5, labelMouseover);
                    num += 19f;
                }
            }
            RoofDef roof = c.GetRoof(Find.CurrentMap);

            if (roof != null)
            {
                Widgets.Label(new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f), roof.LabelCap);
                num += 19f;
            }
            GUI.color = Color.white;
        }
Exemplo n.º 8
0
        public virtual void OnGUI(LocalTargetInfo target)
        {
            Texture2D icon = (!target.IsValid) ? TexCommand.CannotShoot : ((!(UIIcon != BaseContent.BadTex)) ? TexCommand.Attack : UIIcon);

            GenUI.DrawMouseAttachment(icon);
        }
Exemplo n.º 9
0
        public virtual void DrawButtonAt(float topY)
        {
            float num   = (float)UI.screenWidth - 38f - 12f;
            Rect  rect  = new Rect(num, topY, 38f, 30f);
            Rect  rect2 = new Rect(rect);
            float num2  = Time.time - arrivalTime;
            Color color = def.color;

            if (num2 < 1f)
            {
                rect2.y -= (1f - num2) * 200f;
                color.a  = num2 / 1f;
            }
            if (!Mouse.IsOver(rect) && def.bounce && num2 > 15f && num2 % 5f < 1f)
            {
                float num3 = (float)UI.screenWidth * 0.06f;
                float num4 = 2f * (num2 % 1f) - 1f;
                float num5 = num3 * (1f - num4 * num4);
                rect2.x -= num5;
            }
            if (Event.current.type == EventType.Repaint)
            {
                if (def.flashInterval > 0f)
                {
                    float num6 = Time.time - (arrivalTime + 1f);
                    if (num6 > 0f && num6 % def.flashInterval < 1f)
                    {
                        GenUI.DrawFlash(num, topY, (float)UI.screenWidth * 0.6f, Pulser.PulseBrightness(1f, 1f, num6) * 0.55f, def.flashColor);
                    }
                }
                GUI.color = color;
                Widgets.DrawShadowAround(rect2);
                GUI.DrawTexture(rect2, def.Icon);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperRight;
                string  text    = PostProcessedLabel();
                Vector2 vector  = Text.CalcSize(text);
                float   x       = vector.x;
                float   y       = vector.y;
                Vector2 vector2 = new Vector2(rect2.x + rect2.width / 2f, rect2.center.y - y / 2f + 4f);
                float   num7    = vector2.x + x / 2f - (float)(UI.screenWidth - 2);
                if (num7 > 0f)
                {
                    vector2.x -= num7;
                }
                GUI.DrawTexture(new Rect(vector2.x - x / 2f - 6f - 1f, vector2.y, x + 12f, 16f), TexUI.GrayTextBG);
                GUI.color = new Color(1f, 1f, 1f, 0.75f);
                Widgets.Label(new Rect(vector2.x - x / 2f, vector2.y - 3f, x, 999f), text);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperLeft;
            }
            if (CanDismissWithRightClick && Event.current.type == EventType.MouseDown && Event.current.button == 1 && Mouse.IsOver(rect))
            {
                SoundDefOf.Click.PlayOneShotOnCamera();
                Find.LetterStack.RemoveLetter(this);
                Event.current.Use();
            }
            if (Widgets.ButtonInvisible(rect2))
            {
                OpenLetter();
                Event.current.Use();
            }
        }
Exemplo n.º 10
0
 public static void Save(string path, string documentElementName, Action saveAction)
 {
     try
     {
         SafeSaver.CleanSafeSaverFiles(path);
         if (!File.Exists(SafeSaver.GetFileFullPath(path)))
         {
             SafeSaver.DoSave(SafeSaver.GetFileFullPath(path), documentElementName, saveAction);
         }
         else
         {
             SafeSaver.DoSave(SafeSaver.GetNewFileFullPath(path), documentElementName, saveAction);
             try
             {
                 SafeSaver.SafeMove(SafeSaver.GetFileFullPath(path), SafeSaver.GetOldFileFullPath(path));
             }
             catch (Exception ex)
             {
                 Log.Warning(string.Concat(new object[]
                 {
                     "Could not move file from \"",
                     SafeSaver.GetFileFullPath(path),
                     "\" to \"",
                     SafeSaver.GetOldFileFullPath(path),
                     "\": ",
                     ex
                 }));
                 throw;
             }
             try
             {
                 SafeSaver.SafeMove(SafeSaver.GetNewFileFullPath(path), SafeSaver.GetFileFullPath(path));
             }
             catch (Exception ex2)
             {
                 Log.Warning(string.Concat(new object[]
                 {
                     "Could not move file from \"",
                     SafeSaver.GetNewFileFullPath(path),
                     "\" to \"",
                     SafeSaver.GetFileFullPath(path),
                     "\": ",
                     ex2
                 }));
                 SafeSaver.RemoveFileIfExists(SafeSaver.GetFileFullPath(path), false);
                 SafeSaver.RemoveFileIfExists(SafeSaver.GetNewFileFullPath(path), false);
                 try
                 {
                     SafeSaver.SafeMove(SafeSaver.GetOldFileFullPath(path), SafeSaver.GetFileFullPath(path));
                 }
                 catch (Exception ex3)
                 {
                     Log.Warning(string.Concat(new object[]
                     {
                         "Could not move file from \"",
                         SafeSaver.GetOldFileFullPath(path),
                         "\" back to \"",
                         SafeSaver.GetFileFullPath(path),
                         "\": ",
                         ex3
                     }));
                 }
                 throw;
             }
             SafeSaver.RemoveFileIfExists(SafeSaver.GetOldFileFullPath(path), true);
         }
     }
     catch (Exception ex4)
     {
         GenUI.ErrorDialog("ProblemSavingFile".Translate(new object[]
         {
             SafeSaver.GetFileFullPath(path),
             ex4.ToString()
         }));
         throw;
     }
 }
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Room room = Room;

            if (room == null)
            {
                return(new GizmoResult(GizmoState.Clear));
            }
            Rect rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f);

            Widgets.DrawWindowBackground(rect);
            Text.WordWrap = false;
            GUI.BeginGroup(rect);
            Rect rect2 = rect.AtZero().ContractedBy(10f);

            Text.Font = GameFont.Small;
            Rect  rect3 = new Rect(rect2.x, rect2.y - 2f, rect2.width, 100f);
            float stat  = room.GetStat(RoomStatDefOf.Impressiveness);
            RoomStatScoreStage scoreStage = RoomStatDefOf.Impressiveness.GetScoreStage(stat);
            TaggedString       str        = room.Role.LabelCap + ", " + scoreStage.label + " (" + RoomStatDefOf.Impressiveness.ScoreToString(stat) + ")";

            Widgets.Label(rect3, str.Truncate(rect3.width));
            float num = rect2.y + Text.LineHeight + Text.SpaceBetweenLines + 7f;

            GUI.color = RoomStatsColor;
            Text.Font = GameFont.Tiny;
            List <RoomStatDef> allDefsListForReading = DefDatabase <RoomStatDef> .AllDefsListForReading;
            int num2 = 0;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                if (!allDefsListForReading[i].isHidden && allDefsListForReading[i] != RoomStatDefOf.Impressiveness)
                {
                    float stat2 = room.GetStat(allDefsListForReading[i]);
                    RoomStatScoreStage scoreStage2 = allDefsListForReading[i].GetScoreStage(stat2);
                    Rect   rect4 = ((num2 % 2 == 0) ? new Rect(rect2.x, num, rect2.width / 2f, 100f) : new Rect(rect2.x + rect2.width / 2f, num, rect2.width / 2f, 100f));
                    string str2  = scoreStage2.label.CapitalizeFirst() + " (" + allDefsListForReading[i].ScoreToString(stat2) + ")";
                    Widgets.Label(rect4, str2.Truncate(rect4.width));
                    if (num2 % 2 == 1)
                    {
                        num += Text.LineHeight + Text.SpaceBetweenLines;
                    }
                    num2++;
                }
            }
            GUI.color = Color.white;
            Text.Font = GameFont.Small;
            GUI.EndGroup();
            Text.WordWrap = true;
            GenUI.AbsorbClicksInRect(rect);
            if (Mouse.IsOver(rect))
            {
                Rect windowRect = EnvironmentStatsDrawer.GetWindowRect(shouldShowBeauty: false, shouldShowRoomStats: true);
                Find.WindowStack.ImmediateWindow(74975, windowRect, WindowLayer.Super, delegate
                {
                    float curY = 12f;
                    EnvironmentStatsDrawer.DoRoomInfo(room, ref curY, windowRect);
                });
                return(new GizmoResult(GizmoState.Mouseover));
            }
            return(new GizmoResult(GizmoState.Clear));
        }
Exemplo n.º 12
0
        public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo)
        {
            tmpAllGizmos.Clear();
            tmpAllGizmos.AddRange(gizmos);
            tmpAllGizmos.SortStable((Gizmo lhs, Gizmo rhs) => lhs.order.CompareTo(rhs.order));
            gizmoGroups.Clear();
            for (int i = 0; i < tmpAllGizmos.Count; i++)
            {
                Gizmo gizmo = tmpAllGizmos[i];
                bool  flag  = false;
                for (int j = 0; j < gizmoGroups.Count; j++)
                {
                    if (gizmoGroups[j][0].GroupsWith(gizmo))
                    {
                        flag = true;
                        gizmoGroups[j].Add(gizmo);
                        gizmoGroups[j][0].MergeWith(gizmo);
                        break;
                    }
                }
                if (!flag)
                {
                    List <Gizmo> list = new List <Gizmo>();
                    list.Add(gizmo);
                    gizmoGroups.Add(list);
                }
            }
            firstGizmos.Clear();
            for (int k = 0; k < gizmoGroups.Count; k++)
            {
                List <Gizmo> list2  = gizmoGroups[k];
                Gizmo        gizmo2 = null;
                for (int l = 0; l < list2.Count; l++)
                {
                    if (!list2[l].disabled)
                    {
                        gizmo2 = list2[l];
                        break;
                    }
                }
                if (gizmo2 == null)
                {
                    gizmo2 = list2.FirstOrDefault();
                }
                if (gizmo2 != null)
                {
                    firstGizmos.Add(gizmo2);
                }
            }
            drawnHotKeys.Clear();
            float num      = (float)(UI.screenWidth - 147);
            float maxWidth = num - startX;

            Text.Font = GameFont.Tiny;
            float   num2         = (float)(UI.screenHeight - 35);
            Vector2 gizmoSpacing = GizmoSpacing;
            Vector2 topLeft      = new Vector2(startX, num2 - gizmoSpacing.y - 75f);

            mouseoverGizmo = null;
            Gizmo interactedGiz = null;
            Event ev            = null;
            Gizmo floatMenuGiz  = null;

            for (int m = 0; m < firstGizmos.Count; m++)
            {
                Gizmo gizmo3 = firstGizmos[m];
                if (gizmo3.Visible)
                {
                    if (topLeft.x + gizmo3.GetWidth(maxWidth) > num)
                    {
                        topLeft.x = startX;
                        float   y             = topLeft.y;
                        Vector2 gizmoSpacing2 = GizmoSpacing;
                        topLeft.y = y - (75f + gizmoSpacing2.x);
                    }
                    heightDrawnFrame = Time.frameCount;
                    heightDrawn      = (float)UI.screenHeight - topLeft.y;
                    GizmoResult gizmoResult = gizmo3.GizmoOnGUI(topLeft, maxWidth);
                    if (gizmoResult.State == GizmoState.Interacted)
                    {
                        ev            = gizmoResult.InteractEvent;
                        interactedGiz = gizmo3;
                    }
                    else if (gizmoResult.State == GizmoState.OpenedFloatMenu)
                    {
                        floatMenuGiz = gizmo3;
                    }
                    if ((int)gizmoResult.State >= 1)
                    {
                        mouseoverGizmo = gizmo3;
                    }
                    float   x2            = topLeft.x;
                    float   y2            = topLeft.y;
                    float   width         = gizmo3.GetWidth(maxWidth);
                    Vector2 gizmoSpacing3 = GizmoSpacing;
                    Rect    rect          = new Rect(x2, y2, width, 75f + gizmoSpacing3.y);
                    rect = rect.ContractedBy(-12f);
                    GenUI.AbsorbClicksInRect(rect);
                    float   x3            = topLeft.x;
                    float   width2        = gizmo3.GetWidth(maxWidth);
                    Vector2 gizmoSpacing4 = GizmoSpacing;
                    topLeft.x = x3 + (width2 + gizmoSpacing4.x);
                }
            }
            if (interactedGiz != null)
            {
                List <Gizmo> list3 = gizmoGroups.First((List <Gizmo> group) => group.Contains(interactedGiz));
                for (int n = 0; n < list3.Count; n++)
                {
                    Gizmo gizmo4 = list3[n];
                    if (gizmo4 != interactedGiz && !gizmo4.disabled && interactedGiz.InheritInteractionsFrom(gizmo4))
                    {
                        gizmo4.ProcessInput(ev);
                    }
                }
                interactedGiz.ProcessInput(ev);
                Event.current.Use();
            }
            else if (floatMenuGiz != null)
            {
                List <FloatMenuOption> list4 = new List <FloatMenuOption>();
                foreach (FloatMenuOption rightClickFloatMenuOption in floatMenuGiz.RightClickFloatMenuOptions)
                {
                    list4.Add(rightClickFloatMenuOption);
                }
                List <Gizmo> list5 = gizmoGroups.First((List <Gizmo> group) => group.Contains(floatMenuGiz));
                Action       prevAction;
                Action       localOptionAction;
                for (int num3 = 0; num3 < list5.Count; num3++)
                {
                    Gizmo gizmo5 = list5[num3];
                    if (gizmo5 != floatMenuGiz && !gizmo5.disabled && floatMenuGiz.InheritFloatMenuInteractionsFrom(gizmo5))
                    {
                        foreach (FloatMenuOption rightClickFloatMenuOption2 in gizmo5.RightClickFloatMenuOptions)
                        {
                            FloatMenuOption floatMenuOption = list4.Find((FloatMenuOption x) => x.Label == rightClickFloatMenuOption2.Label);
                            if (floatMenuOption == null)
                            {
                                list4.Add(rightClickFloatMenuOption2);
                            }
                            else if (!rightClickFloatMenuOption2.Disabled)
                            {
                                if (!floatMenuOption.Disabled)
                                {
                                    prevAction             = floatMenuOption.action;
                                    localOptionAction      = rightClickFloatMenuOption2.action;
                                    floatMenuOption.action = delegate
                                    {
                                        prevAction();
                                        localOptionAction();
                                    };
                                }
                                else if (floatMenuOption.Disabled)
                                {
                                    list4[list4.IndexOf(floatMenuOption)] = rightClickFloatMenuOption2;
                                }
                            }
                        }
                    }
                }
                Event.current.Use();
                if (list4.Any())
                {
                    Find.WindowStack.Add(new FloatMenu(list4));
                }
            }
            gizmoGroups.Clear();
            firstGizmos.Clear();
            tmpAllGizmos.Clear();
        }
Exemplo n.º 13
0
        public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo)
        {
            GizmoGridDrawer.gizmoGroups.Clear();
            foreach (Gizmo gizmo4 in gizmos)
            {
                bool flag = false;
                int  num  = 0;
                while (num < GizmoGridDrawer.gizmoGroups.Count)
                {
                    if (!GizmoGridDrawer.gizmoGroups[num][0].GroupsWith(gizmo4))
                    {
                        num++;
                        continue;
                    }
                    flag = true;
                    GizmoGridDrawer.gizmoGroups[num].Add(gizmo4);
                    break;
                }
                if (!flag)
                {
                    List <Gizmo> list = new List <Gizmo>();
                    list.Add(gizmo4);
                    GizmoGridDrawer.gizmoGroups.Add(list);
                }
            }
            GizmoGridDrawer.firstGizmos.Clear();
            for (int i = 0; i < GizmoGridDrawer.gizmoGroups.Count; i++)
            {
                List <Gizmo> source = GizmoGridDrawer.gizmoGroups[i];
                Gizmo        gizmo  = source.FirstOrDefault((Gizmo opt) => !opt.disabled);
                if (gizmo == null)
                {
                    gizmo = source.FirstOrDefault();
                }
                GizmoGridDrawer.firstGizmos.Add(gizmo);
            }
            GizmoGridDrawer.drawnHotKeys.Clear();
            float num2 = (float)(UI.screenWidth - 140);

            Text.Font = GameFont.Tiny;
            float   num3         = (float)(UI.screenHeight - 35);
            Vector2 gizmoSpacing = GizmoGridDrawer.GizmoSpacing;
            Vector2 topLeft      = new Vector2(startX, (float)(num3 - gizmoSpacing.y - 75.0));

            mouseoverGizmo = null;
            Gizmo interactedGiz = null;
            Event ev            = null;

            for (int j = 0; j < GizmoGridDrawer.firstGizmos.Count; j++)
            {
                Gizmo gizmo2 = GizmoGridDrawer.firstGizmos[j];
                if (gizmo2.Visible)
                {
                    float   num4          = topLeft.x + gizmo2.Width;
                    Vector2 gizmoSpacing2 = GizmoGridDrawer.GizmoSpacing;
                    if (num4 + gizmoSpacing2.x > num2)
                    {
                        topLeft.x = startX;
                        float   y             = topLeft.y;
                        Vector2 gizmoSpacing3 = GizmoGridDrawer.GizmoSpacing;
                        topLeft.y = (float)(y - (75.0 + gizmoSpacing3.x));
                    }
                    GizmoGridDrawer.heightDrawnFrame = Time.frameCount;
                    GizmoGridDrawer.heightDrawn      = (float)UI.screenHeight - topLeft.y;
                    GizmoResult gizmoResult = gizmo2.GizmoOnGUI(topLeft);
                    if (gizmoResult.State == GizmoState.Interacted)
                    {
                        ev            = gizmoResult.InteractEvent;
                        interactedGiz = gizmo2;
                    }
                    if ((int)gizmoResult.State >= 1)
                    {
                        mouseoverGizmo = gizmo2;
                    }
                    float   x             = topLeft.x;
                    float   y2            = topLeft.y;
                    float   width         = gizmo2.Width;
                    Vector2 gizmoSpacing4 = GizmoGridDrawer.GizmoSpacing;
                    Rect    rect          = new Rect(x, y2, width, (float)(75.0 + gizmoSpacing4.y));
                    rect = rect.ContractedBy(-12f);
                    GenUI.AbsorbClicksInRect(rect);
                    float   x2            = topLeft.x;
                    float   width2        = gizmo2.Width;
                    Vector2 gizmoSpacing5 = GizmoGridDrawer.GizmoSpacing;
                    topLeft.x = x2 + (width2 + gizmoSpacing5.x);
                }
            }
            if (interactedGiz != null)
            {
                List <Gizmo> list2 = GizmoGridDrawer.gizmoGroups.First((List <Gizmo> group) => group.Contains(interactedGiz));
                for (int k = 0; k < list2.Count; k++)
                {
                    Gizmo gizmo3 = list2[k];
                    if (gizmo3 != interactedGiz && !gizmo3.disabled && interactedGiz.InheritInteractionsFrom(gizmo3))
                    {
                        gizmo3.ProcessInput(ev);
                    }
                }
                interactedGiz.ProcessInput(ev);
                Event.current.Use();
            }
        }
Exemplo n.º 14
0
 public void MouseoverReadoutOnGUI()
 {
     if (Event.current.type == EventType.Repaint)
     {
         if (Find.MainTabsRoot.OpenTab == null)
         {
             GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f));
             Text.Font = GameFont.Small;
             GUI.color = new Color(1f, 1f, 1f, 0.8f);
             IntVec3 c = UI.MouseCell();
             if (c.InBounds(Find.CurrentMap))
             {
                 float num = 0f;
                 Profiler.BeginSample("fog");
                 if (c.Fogged(Find.CurrentMap))
                 {
                     Rect rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                     Widgets.Label(rect, "Undiscovered".Translate());
                     GUI.color = Color.white;
                     Profiler.EndSample();
                 }
                 else
                 {
                     Profiler.EndSample();
                     Profiler.BeginSample("light");
                     Rect rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                     int  num2 = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c, false) * 100f);
                     Widgets.Label(rect, this.glowStrings[num2]);
                     num += 19f;
                     Profiler.EndSample();
                     Profiler.BeginSample("terrain");
                     rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                     TerrainDef terrain = c.GetTerrain(Find.CurrentMap);
                     if (terrain != this.cachedTerrain)
                     {
                         string str = ((double)terrain.fertility <= 0.0001) ? "" : (" " + "FertShort".Translate() + " " + terrain.fertility.ToStringPercent());
                         this.cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable) ? null : (" (" + "WalkSpeed".Translate(new object[]
                         {
                             this.SpeedPercentString((float)terrain.pathCost)
                         }) + str + ")"));
                         this.cachedTerrain = terrain;
                     }
                     Widgets.Label(rect, this.cachedTerrainString);
                     num += 19f;
                     Profiler.EndSample();
                     Profiler.BeginSample("zone");
                     Zone zone = c.GetZone(Find.CurrentMap);
                     if (zone != null)
                     {
                         rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                         string label = zone.label;
                         Widgets.Label(rect, label);
                         num += 19f;
                     }
                     Profiler.EndSample();
                     float depth = Find.CurrentMap.snowGrid.GetDepth(c);
                     if (depth > 0.03f)
                     {
                         rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - 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;
                     }
                     Profiler.BeginSample("things");
                     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(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                             string labelMouseover = thing.LabelMouseover;
                             Widgets.Label(rect, labelMouseover);
                             num += 19f;
                         }
                     }
                     Profiler.EndSample();
                     Profiler.BeginSample("roof");
                     RoofDef roof = c.GetRoof(Find.CurrentMap);
                     if (roof != null)
                     {
                         rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                         Widgets.Label(rect, roof.LabelCap);
                         num += 19f;
                     }
                     Profiler.EndSample();
                     GUI.color = Color.white;
                 }
             }
         }
     }
 }
Exemplo n.º 15
0
        protected virtual GizmoResult GizmoOnGUIInt(Rect butRect, bool shrunk = false)
        {
            Text.Font = GameFont.Tiny;
            bool flag = false;

            if (Mouse.IsOver(butRect))
            {
                flag = true;
                if (!disabled)
                {
                    GUI.color = GenUI.MouseoverColor;
                }
            }
            MouseoverSounds.DoRegion(butRect, SoundDefOf.Mouseover_Command);
            Material material = (disabled ? TexUI.GrayscaleGUI : null);

            GenUI.DrawTextureWithMaterial(butRect, shrunk ? BGTextureShrunk : BGTexture, material);
            DrawIcon(butRect, material);
            bool    flag2   = false;
            KeyCode keyCode = ((hotKey != null) ? hotKey.MainKey : KeyCode.None);

            if (keyCode != 0 && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Vector2 vector = (shrunk ? new Vector2(3f, 0f) : new Vector2(5f, 3f));
                Widgets.Label(new Rect(butRect.x + vector.x, butRect.y + vector.y, butRect.width - 10f, 18f), keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(butRect))
            {
                flag2 = true;
            }
            if (!shrunk)
            {
                string topRightLabel = TopRightLabel;
                if (!topRightLabel.NullOrEmpty())
                {
                    Vector2 vector2 = Text.CalcSize(topRightLabel);
                    Rect    position;
                    Rect    rect = (position = new Rect(butRect.xMax - vector2.x - 2f, butRect.y + 3f, vector2.x, vector2.y));
                    position.x     -= 2f;
                    position.width += 3f;
                    GUI.color       = Color.white;
                    Text.Anchor     = TextAnchor.UpperRight;
                    GUI.DrawTexture(position, TexUI.GrayTextBG);
                    Widgets.Label(rect, topRightLabel);
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                string labelCap = LabelCap;
                if (!labelCap.NullOrEmpty())
                {
                    float num   = Text.CalcHeight(labelCap, butRect.width);
                    Rect  rect2 = new Rect(butRect.x, butRect.yMax - num + 12f, butRect.width, num);
                    GUI.DrawTexture(rect2, TexUI.GrayTextBG);
                    GUI.color   = Color.white;
                    Text.Anchor = TextAnchor.UpperCenter;
                    Widgets.Label(rect2, labelCap);
                    Text.Anchor = TextAnchor.UpperLeft;
                    GUI.color   = Color.white;
                }
                GUI.color = Color.white;
            }
            if (Mouse.IsOver(butRect) && DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    ref string text = ref tip.text;
                    text += "\n\n" + "DisabledCommand".Translate() + ": " + disabledReason;
                }
                TooltipHandler.TipRegion(butRect, tip);
            }
Exemplo n.º 16
0
 public void MouseoverReadoutOnGUI()
 {
     if (Event.current.type == EventType.Repaint && Find.MainTabsRoot.OpenTab == null)
     {
         GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f));
         Text.Font = GameFont.Small;
         GUI.color = new Color(1f, 1f, 1f, 0.8f);
         IntVec3 c = UI.MouseCell();
         if (c.InBounds(Find.CurrentMap))
         {
             float num  = 0f;
             Rect  rect = default(Rect);
             if (c.Fogged(Find.CurrentMap))
             {
                 Vector2 botLeft  = BotLeft;
                 float   x        = botLeft.x;
                 float   num2     = (float)UI.screenHeight;
                 Vector2 botLeft2 = BotLeft;
                 rect = new Rect(x, num2 - botLeft2.y - num, 999f, 999f);
                 Widgets.Label(rect, "Undiscovered".Translate());
                 GUI.color = Color.white;
             }
             else
             {
                 Vector2 botLeft3 = BotLeft;
                 float   x2       = botLeft3.x;
                 float   num3     = (float)UI.screenHeight;
                 Vector2 botLeft4 = BotLeft;
                 rect = new Rect(x2, num3 - botLeft4.y - num, 999f, 999f);
                 int num4 = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c) * 100f);
                 Widgets.Label(rect, glowStrings[num4]);
                 num += 19f;
                 Vector2 botLeft5 = BotLeft;
                 float   x3       = botLeft5.x;
                 float   num5     = (float)UI.screenHeight;
                 Vector2 botLeft6 = BotLeft;
                 rect = new Rect(x3, num5 - botLeft6.y - num, 999f, 999f);
                 TerrainDef terrain = c.GetTerrain(Find.CurrentMap);
                 if (terrain != cachedTerrain)
                 {
                     string str = (!((double)terrain.fertility > 0.0001)) ? string.Empty : (" " + "FertShort".Translate() + " " + terrain.fertility.ToStringPercent());
                     cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable) ? null : (" (" + "WalkSpeed".Translate(SpeedPercentString((float)terrain.pathCost)) + str + ")"));
                     cachedTerrain       = terrain;
                 }
                 Widgets.Label(rect, cachedTerrainString);
                 num += 19f;
                 Zone zone = c.GetZone(Find.CurrentMap);
                 if (zone != null)
                 {
                     Vector2 botLeft7 = BotLeft;
                     float   x4       = botLeft7.x;
                     float   num6     = (float)UI.screenHeight;
                     Vector2 botLeft8 = BotLeft;
                     rect = new Rect(x4, num6 - botLeft8.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)
                 {
                     Vector2 botLeft9  = BotLeft;
                     float   x5        = botLeft9.x;
                     float   num7      = (float)UI.screenHeight;
                     Vector2 botLeft10 = BotLeft;
                     rect = new Rect(x5, num7 - botLeft10.y - num, 999f, 999f);
                     SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth);
                     string       label2       = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(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)
                     {
                         Vector2 botLeft11 = BotLeft;
                         float   x6        = botLeft11.x;
                         float   num8      = (float)UI.screenHeight;
                         Vector2 botLeft12 = BotLeft;
                         rect = new Rect(x6, num8 - botLeft12.y - num, 999f, 999f);
                         string labelMouseover = thing.LabelMouseover;
                         Widgets.Label(rect, labelMouseover);
                         num += 19f;
                     }
                 }
                 RoofDef roof = c.GetRoof(Find.CurrentMap);
                 if (roof != null)
                 {
                     Vector2 botLeft13 = BotLeft;
                     float   x7        = botLeft13.x;
                     float   num9      = (float)UI.screenHeight;
                     Vector2 botLeft14 = BotLeft;
                     rect = new Rect(x7, num9 - botLeft14.y - num, 999f, 999f);
                     Widgets.Label(rect, roof.LabelCap);
                     num += 19f;
                 }
                 GUI.color = Color.white;
             }
         }
     }
 }
Exemplo n.º 17
0
        public virtual void DrawButtonAt(float topY)
        {
            float num   = (float)((float)UI.screenWidth - 38.0 - 12.0);
            Rect  rect  = new Rect(num, topY, 38f, 30f);
            Rect  rect2 = new Rect(rect);
            float num2  = Time.time - this.arrivalTime;
            Color color = this.def.color;

            if (num2 < 1.0)
            {
                rect2.y -= (float)((1.0 - num2) * 200.0);
                color.a  = (float)(num2 / 1.0);
            }
            if (!Mouse.IsOver(rect) && this.def.bounce && num2 > 15.0 && num2 % 5.0 < 1.0)
            {
                float num3 = (float)((float)UI.screenWidth * 0.059999998658895493);
                float num4 = (float)(2.0 * (num2 % 1.0) - 1.0);
                float num5 = (float)(num3 * (1.0 - num4 * num4));
                rect2.x -= num5;
            }
            if (this.def.flashInterval > 0.0)
            {
                float num6 = (float)(Time.time - (this.arrivalTime + 1.0));
                if (num6 > 0.0 && num6 % this.def.flashInterval < 1.0)
                {
                    GenUI.DrawFlash(num, topY, (float)((float)UI.screenWidth * 0.60000002384185791), (float)(Pulser.PulseBrightness(1f, 1f, num6) * 0.550000011920929), this.def.flashColor);
                }
            }
            GUI.color = color;
            Widgets.DrawShadowAround(rect2);
            GUI.DrawTexture(rect2, this.def.Icon);
            GUI.color   = Color.white;
            Text.Font   = GameFont.Tiny;
            Text.Anchor = TextAnchor.UpperRight;
            string  text    = this.PostProcessedLabel();
            Vector2 vector  = Text.CalcSize(text);
            float   x       = vector.x;
            float   y       = vector.y;
            double  x2      = rect2.x + rect2.width / 2.0;
            Vector2 center  = rect2.center;
            Vector2 vector2 = new Vector2((float)x2, (float)(center.y - y / 4.0));
            float   num7    = (float)(vector2.x + x / 2.0 - (float)(UI.screenWidth - 2));

            if (num7 > 0.0)
            {
                vector2.x -= num7;
            }
            Rect position = new Rect((float)(vector2.x - x / 2.0 - 4.0 - 1.0), vector2.y, (float)(x + 8.0), 12f);

            GUI.DrawTexture(position, TexUI.GrayTextBG);
            GUI.color = new Color(1f, 1f, 1f, 0.75f);
            Rect rect3 = new Rect((float)(vector2.x - x / 2.0), (float)(vector2.y - 3.0), x, 999f);

            Widgets.Label(rect3, text);
            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Small;
            if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && Mouse.IsOver(rect))
            {
                SoundDefOf.Click.PlayOneShotOnCamera(null);
                Find.LetterStack.RemoveLetter(this);
                Event.current.Use();
            }
            if (Widgets.ButtonInvisible(rect2, false))
            {
                this.OpenLetter();
                Event.current.Use();
            }
        }
        public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo)
        {
            GizmoGridDrawer.tmpAllGizmos.Clear();
            GizmoGridDrawer.tmpAllGizmos.AddRange(gizmos);
            GizmoGridDrawer.tmpAllGizmos.SortStable((Gizmo lhs, Gizmo rhs) => lhs.order.CompareTo(rhs.order));
            GizmoGridDrawer.gizmoGroups.Clear();
            for (int i = 0; i < GizmoGridDrawer.tmpAllGizmos.Count; i++)
            {
                Gizmo gizmo = GizmoGridDrawer.tmpAllGizmos[i];
                bool  flag  = false;
                for (int j = 0; j < GizmoGridDrawer.gizmoGroups.Count; j++)
                {
                    if (GizmoGridDrawer.gizmoGroups[j][0].GroupsWith(gizmo))
                    {
                        flag = true;
                        GizmoGridDrawer.gizmoGroups[j].Add(gizmo);
                        GizmoGridDrawer.gizmoGroups[j][0].MergeWith(gizmo);
                        break;
                    }
                }
                if (!flag)
                {
                    List <Gizmo> list = new List <Gizmo>();
                    list.Add(gizmo);
                    GizmoGridDrawer.gizmoGroups.Add(list);
                }
            }
            GizmoGridDrawer.firstGizmos.Clear();
            for (int k = 0; k < GizmoGridDrawer.gizmoGroups.Count; k++)
            {
                List <Gizmo> list2  = GizmoGridDrawer.gizmoGroups[k];
                Gizmo        gizmo2 = null;
                for (int l = 0; l < list2.Count; l++)
                {
                    if (!list2[l].disabled)
                    {
                        gizmo2 = list2[l];
                        break;
                    }
                }
                if (gizmo2 == null)
                {
                    gizmo2 = list2.FirstOrDefault <Gizmo>();
                }
                if (gizmo2 != null)
                {
                    GizmoGridDrawer.firstGizmos.Add(gizmo2);
                }
            }
            GizmoGridDrawer.drawnHotKeys.Clear();
            float num      = (float)(UI.screenWidth - 147);
            float maxWidth = num - startX;

            Text.Font = GameFont.Tiny;
            Vector2 topLeft = new Vector2(startX, (float)(UI.screenHeight - 35) - GizmoGridDrawer.GizmoSpacing.y - 75f);

            mouseoverGizmo = null;
            Gizmo interactedGiz = null;
            Event ev            = null;
            Gizmo floatMenuGiz  = null;

            for (int m = 0; m < GizmoGridDrawer.firstGizmos.Count; m++)
            {
                Gizmo gizmo3 = GizmoGridDrawer.firstGizmos[m];
                if (gizmo3.Visible)
                {
                    if (topLeft.x + gizmo3.GetWidth(maxWidth) > num)
                    {
                        topLeft.x  = startX;
                        topLeft.y -= 75f + GizmoGridDrawer.GizmoSpacing.x;
                    }
                    GizmoGridDrawer.heightDrawnFrame = Time.frameCount;
                    GizmoGridDrawer.heightDrawn      = (float)UI.screenHeight - topLeft.y;
                    GizmoResult gizmoResult = gizmo3.GizmoOnGUI(topLeft, maxWidth);
                    if (gizmoResult.State == GizmoState.Interacted)
                    {
                        ev            = gizmoResult.InteractEvent;
                        interactedGiz = gizmo3;
                    }
                    else if (gizmoResult.State == GizmoState.OpenedFloatMenu)
                    {
                        floatMenuGiz = gizmo3;
                    }
                    if (gizmoResult.State >= GizmoState.Mouseover)
                    {
                        mouseoverGizmo = gizmo3;
                    }
                    Rect rect = new Rect(topLeft.x, topLeft.y, gizmo3.GetWidth(maxWidth), 75f + GizmoGridDrawer.GizmoSpacing.y);
                    rect = rect.ContractedBy(-12f);
                    GenUI.AbsorbClicksInRect(rect);
                    topLeft.x += gizmo3.GetWidth(maxWidth) + GizmoGridDrawer.GizmoSpacing.x;
                }
            }
            if (interactedGiz != null)
            {
                List <Gizmo> list3 = GizmoGridDrawer.gizmoGroups.First((List <Gizmo> group) => group.Contains(interactedGiz));
                for (int n = 0; n < list3.Count; n++)
                {
                    Gizmo gizmo4 = list3[n];
                    if (gizmo4 != interactedGiz && !gizmo4.disabled && interactedGiz.InheritInteractionsFrom(gizmo4))
                    {
                        gizmo4.ProcessInput(ev);
                    }
                }
                interactedGiz.ProcessInput(ev);
                Event.current.Use();
            }
            else if (floatMenuGiz != null)
            {
                List <FloatMenuOption> list4 = new List <FloatMenuOption>();
                foreach (FloatMenuOption item in floatMenuGiz.RightClickFloatMenuOptions)
                {
                    list4.Add(item);
                }
                List <Gizmo> list5 = GizmoGridDrawer.gizmoGroups.First((List <Gizmo> group) => group.Contains(floatMenuGiz));
                for (int num2 = 0; num2 < list5.Count; num2++)
                {
                    Gizmo gizmo5 = list5[num2];
                    if (gizmo5 != floatMenuGiz && !gizmo5.disabled && floatMenuGiz.InheritFloatMenuInteractionsFrom(gizmo5))
                    {
                        using (IEnumerator <FloatMenuOption> enumerator2 = gizmo5.RightClickFloatMenuOptions.GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                FloatMenuOption option          = enumerator2.Current;
                                FloatMenuOption floatMenuOption = list4.Find((FloatMenuOption x) => x.Label == option.Label);
                                if (floatMenuOption == null)
                                {
                                    list4.Add(option);
                                }
                                else if (!option.Disabled)
                                {
                                    if (!floatMenuOption.Disabled)
                                    {
                                        Action prevAction        = floatMenuOption.action;
                                        Action localOptionAction = option.action;
                                        floatMenuOption.action = delegate()
                                        {
                                            prevAction();
                                            localOptionAction();
                                        };
                                    }
                                    else if (floatMenuOption.Disabled)
                                    {
                                        list4[list4.IndexOf(floatMenuOption)] = option;
                                    }
                                }
                            }
                        }
                    }
                }
                Event.current.Use();
                if (list4.Any <FloatMenuOption>())
                {
                    Find.WindowStack.Add(new FloatMenu(list4));
                }
            }
            GizmoGridDrawer.gizmoGroups.Clear();
            GizmoGridDrawer.firstGizmos.Clear();
            GizmoGridDrawer.tmpAllGizmos.Clear();
        }
Exemplo n.º 19
0
        public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo)
        {
            tmpAllGizmos.Clear();
            tmpAllGizmos.AddRange(gizmos);
            tmpAllGizmos.SortStable(SortByOrder);
            gizmoGroups.Clear();
            for (int i = 0; i < tmpAllGizmos.Count; i++)
            {
                Gizmo gizmo = tmpAllGizmos[i];
                bool  flag  = false;
                for (int j = 0; j < gizmoGroups.Count; j++)
                {
                    if (gizmoGroups[j][0].GroupsWith(gizmo))
                    {
                        flag = true;
                        gizmoGroups[j].Add(gizmo);
                        gizmoGroups[j][0].MergeWith(gizmo);
                        break;
                    }
                }
                if (!flag)
                {
                    List <Gizmo> list = SimplePool <List <Gizmo> > .Get();

                    list.Add(gizmo);
                    gizmoGroups.Add(list);
                }
            }
            firstGizmos.Clear();
            for (int k = 0; k < gizmoGroups.Count; k++)
            {
                List <Gizmo> list2  = gizmoGroups[k];
                Gizmo        gizmo2 = null;
                for (int l = 0; l < list2.Count; l++)
                {
                    if (!list2[l].disabled)
                    {
                        gizmo2 = list2[l];
                        break;
                    }
                }
                if (gizmo2 == null)
                {
                    gizmo2 = list2.FirstOrDefault();
                }
                else
                {
                    Command_Toggle command_Toggle = gizmo2 as Command_Toggle;
                    if (command_Toggle != null)
                    {
                        if (!command_Toggle.activateIfAmbiguous && !command_Toggle.isActive())
                        {
                            for (int m = 0; m < list2.Count; m++)
                            {
                                Command_Toggle command_Toggle2 = list2[m] as Command_Toggle;
                                if (command_Toggle2 != null && !command_Toggle2.disabled && command_Toggle2.isActive())
                                {
                                    gizmo2 = list2[m];
                                    break;
                                }
                            }
                        }
                        if (command_Toggle.activateIfAmbiguous && command_Toggle.isActive())
                        {
                            for (int n = 0; n < list2.Count; n++)
                            {
                                Command_Toggle command_Toggle3 = list2[n] as Command_Toggle;
                                if (command_Toggle3 != null && !command_Toggle3.disabled && !command_Toggle3.isActive())
                                {
                                    gizmo2 = list2[n];
                                    break;
                                }
                            }
                        }
                    }
                }
                if (gizmo2 != null)
                {
                    firstGizmos.Add(gizmo2);
                }
            }
            drawnHotKeys.Clear();
            float num      = UI.screenWidth - 147;
            float maxWidth = num - startX;

            Text.Font = GameFont.Tiny;
            Vector2 topLeft = new Vector2(startX, (float)(UI.screenHeight - 35) - GizmoSpacing.y - 75f);

            mouseoverGizmo = null;
            Gizmo gizmo3 = null;
            Event ev     = null;
            Gizmo gizmo4 = null;

            for (int num2 = 0; num2 < firstGizmos.Count; num2++)
            {
                Gizmo gizmo5 = firstGizmos[num2];
                if (gizmo5.Visible)
                {
                    if (topLeft.x + gizmo5.GetWidth(maxWidth) > num)
                    {
                        topLeft.x  = startX;
                        topLeft.y -= 75f + GizmoSpacing.x;
                    }
                    heightDrawnFrame = Time.frameCount;
                    heightDrawn      = (float)UI.screenHeight - topLeft.y;
                    GizmoResult gizmoResult = gizmo5.GizmoOnGUI(topLeft, maxWidth);
                    if (gizmoResult.State == GizmoState.Interacted || (gizmoResult.State == GizmoState.OpenedFloatMenu && gizmo5.RightClickFloatMenuOptions.FirstOrDefault() == null))
                    {
                        ev     = gizmoResult.InteractEvent;
                        gizmo3 = gizmo5;
                    }
                    else if (gizmoResult.State == GizmoState.OpenedFloatMenu)
                    {
                        gizmo4 = gizmo5;
                    }
                    if ((int)gizmoResult.State >= 1)
                    {
                        mouseoverGizmo = gizmo5;
                    }
                    GenUI.AbsorbClicksInRect(new Rect(topLeft.x, topLeft.y, gizmo5.GetWidth(maxWidth), 75f + GizmoSpacing.y).ContractedBy(-12f));
                    topLeft.x += gizmo5.GetWidth(maxWidth) + GizmoSpacing.x;
                }
            }
            if (gizmo3 != null)
            {
                List <Gizmo> list3 = FindMatchingGroup(gizmo3);
                for (int num3 = 0; num3 < list3.Count; num3++)
                {
                    Gizmo gizmo6 = list3[num3];
                    if (gizmo6 != gizmo3 && !gizmo6.disabled && gizmo3.InheritInteractionsFrom(gizmo6))
                    {
                        gizmo6.ProcessInput(ev);
                    }
                }
                gizmo3.ProcessInput(ev);
                Event.current.Use();
            }
            else if (gizmo4 != null)
            {
                List <FloatMenuOption> list4 = new List <FloatMenuOption>();
                foreach (FloatMenuOption rightClickFloatMenuOption in gizmo4.RightClickFloatMenuOptions)
                {
                    list4.Add(rightClickFloatMenuOption);
                }
                List <Gizmo> list5 = FindMatchingGroup(gizmo4);
                Action       prevAction;
                Action       localOptionAction;
                for (int num4 = 0; num4 < list5.Count; num4++)
                {
                    Gizmo gizmo7 = list5[num4];
                    if (gizmo7 != gizmo4 && !gizmo7.disabled && gizmo4.InheritFloatMenuInteractionsFrom(gizmo7))
                    {
                        foreach (FloatMenuOption rightClickFloatMenuOption2 in gizmo7.RightClickFloatMenuOptions)
                        {
                            FloatMenuOption floatMenuOption = null;
                            for (int num5 = 0; num5 < list4.Count; num5++)
                            {
                                if (list4[num5].Label == rightClickFloatMenuOption2.Label)
                                {
                                    floatMenuOption = list4[num5];
                                    break;
                                }
                            }
                            if (floatMenuOption == null)
                            {
                                list4.Add(rightClickFloatMenuOption2);
                            }
                            else if (!rightClickFloatMenuOption2.Disabled)
                            {
                                if (!floatMenuOption.Disabled)
                                {
                                    prevAction             = floatMenuOption.action;
                                    localOptionAction      = rightClickFloatMenuOption2.action;
                                    floatMenuOption.action = delegate
                                    {
                                        prevAction();
                                        localOptionAction();
                                    };
                                }
                                else if (floatMenuOption.Disabled)
                                {
                                    list4[list4.IndexOf(floatMenuOption)] = rightClickFloatMenuOption2;
                                }
                            }
                        }
                    }
                }
                Event.current.Use();
                if (list4.Any())
                {
                    Find.WindowStack.Add(new FloatMenu(list4));
                }
            }
            for (int num6 = 0; num6 < gizmoGroups.Count; num6++)
            {
                gizmoGroups[num6].Clear();
                SimplePool <List <Gizmo> > .Return(gizmoGroups[num6]);
            }
            gizmoGroups.Clear();
            firstGizmos.Clear();
            tmpAllGizmos.Clear();
            List <Gizmo> FindMatchingGroup(Gizmo toMatch)
            {
                for (int num7 = 0; num7 < gizmoGroups.Count; num7++)
                {
                    if (gizmoGroups[num7].Contains(toMatch))
                    {
                        return(gizmoGroups[num7]);
                    }
                }
                return(null);
            }
        }
Exemplo n.º 20
0
 public static IEnumerable <LocalTargetInfo> TargetsAtMouse(TargetingParameters clickParams, bool thingsOnly = false)
 {
     return(GenUI.TargetsAt(UI.MouseMapPosition(), clickParams, thingsOnly));
 }
        private static void DrawContents(Rect rect)
        {
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            float num  = 0f;
            float num2 = 17f;
            float itemListInnerMargin = 8f;
            float num3  = num2 + 4f;
            Rect  rect2 = new Rect(rect.x + num2, rect.y, rect.width - num2 * 2f, 0f);
            Rect  rect3 = rect;

            rect3.x += num3;
            rect3.y += 10f;
            Widgets.Label(rect3, "OfficialContent".Translate());
            num += 10f + Text.LineHeight + 4f;
            Rect rect4 = rect2;

            rect4.y     += num;
            rect4.height = 94f;
            Widgets.DrawBoxSolid(rect4, ModInfoListBackground);
            num += 104f;
            List <GenUI.AnonymousStackElement> list = new List <GenUI.AnonymousStackElement>();

            Text.Anchor = TextAnchor.MiddleLeft;
            for (int i = 0; i < ModLister.AllExpansions.Count; i++)
            {
                ExpansionDef exp = ModLister.AllExpansions[i];
                list.Add(new GenUI.AnonymousStackElement
                {
                    drawer = delegate(Rect r)
                    {
                        bool flag = exp.Status == ExpansionStatus.Active;
                        Widgets.DrawBoxSolid(r, flag ? ModInfoListItemBackground : ModInfoListItemBackgroundDisabled);
                        Widgets.DrawHighlightIfMouseover(r);
                        if (!exp.isCore && !exp.StoreURL.NullOrEmpty() && Widgets.ButtonInvisible(r))
                        {
                            SteamUtility.OpenUrl(exp.StoreURL);
                        }
                        GUI.color         = (flag ? Color.white : DisabledIconTint);
                        Material material = (flag ? null : TexUI.GrayscaleGUI);
                        Rect rect9        = new Rect(r.x + itemListInnerMargin, r.y + 2f, 32f, 32f);
                        float num4        = 42f;
                        GenUI.DrawTextureWithMaterial(rect9, exp.Icon, material);
                        GUI.color   = (flag ? Color.white : Color.grey);
                        Rect rect10 = new Rect(r.x + itemListInnerMargin + num4, r.y, r.width - num4, r.height);
                        if (exp.Status != 0)
                        {
                            TaggedString t = ((exp.Status == ExpansionStatus.Installed) ? "DisabledLower" : "ContentNotInstalled").Translate().ToLower();
                            Widgets.Label(rect10, exp.label + " (" + t + ")");
                        }
                        else
                        {
                            Widgets.Label(rect10, exp.label);
                        }
                        GUI.color = Color.white;
                        if (Mouse.IsOver(r))
                        {
                            string description2 = exp.label + "\n" + exp.StatusDescription + "\n\n" + exp.description.StripTags();
                            TooltipHandler.TipRegion(tip: new TipSignal(() => description2, exp.GetHashCode() * 37), rect: r);
                        }
                    }
                });
            }
            GenUI.DrawElementStackVertical(new Rect(rect4.x + itemListInnerMargin, rect4.y + itemListInnerMargin, rect4.width - itemListInnerMargin * 2f, 94f), ListElementSize.y, list, delegate(Rect r, GenUI.AnonymousStackElement obj)
            {
                obj.drawer(r);
            }, (GenUI.AnonymousStackElement obj) => ListElementSize.x, 6f);
            list.Clear();
            Rect rect5 = rect;

            rect5.x    += num3;
            rect5.y    += num;
            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.Label(rect5, "Mods".Translate());
            num += Text.LineHeight + 4f;
            Rect rect6 = rect2;

            rect6.y     += num;
            rect6.height = (AnyMods ? 224f : 40f);
            Widgets.DrawBoxSolid(rect6, ModInfoListBackground);
            if (AnyMods)
            {
                Text.Anchor = TextAnchor.MiddleLeft;
                foreach (ModMetaData mod in ModLister.AllInstalledMods.Where((ModMetaData m) => !m.Official && m.Active))
                {
                    list.Add(new GenUI.AnonymousStackElement
                    {
                        drawer = delegate(Rect r)
                        {
                            Widgets.DrawBoxSolid(r, mod.VersionCompatible ? ModInfoListItemBackground : ModInfoListItemBackgroundIncompatible);
                            Widgets.DrawHighlightIfMouseover(r);
                            if (mod.OnSteamWorkshop && mod.GetPublishedFileId() != PublishedFileId_t.Invalid && Widgets.ButtonInvisible(r))
                            {
                                SteamUtility.OpenWorkshopPage(mod.GetPublishedFileId());
                            }
                            Rect rect8   = new Rect(r.x + itemListInnerMargin, r.y, r.width, r.height);
                            string label = mod.Name.Truncate(rect8.width - itemListInnerMargin - 4f);
                            Widgets.Label(rect8, label);
                            if (Mouse.IsOver(r))
                            {
                                string description = mod.Name + "\n\n" + mod.Description.StripTags();
                                if (!mod.VersionCompatible)
                                {
                                    description = description + "\n\n" + "ModNotMadeForThisVersionShort".Translate().RawText.Colorize(Color.yellow);
                                }
                                TooltipHandler.TipRegion(tip: new TipSignal(() => description, mod.GetHashCode() * 37), rect: r);
                            }
                            GUI.color = Color.white;
                        }
                    });
                }
                Widgets.BeginScrollView(rect6, ref modListScrollPos, new Rect(0f, 0f, rect6.width - 16f, modListLastHeight + itemListInnerMargin * 2f));
                modListLastHeight = GenUI.DrawElementStack(new Rect(itemListInnerMargin, itemListInnerMargin, rect6.width - itemListInnerMargin * 2f, 99999f), ListElementSize.y, list, delegate(Rect r, GenUI.AnonymousStackElement obj)
                {
                    obj.drawer(r);
                }, (GenUI.AnonymousStackElement obj) => ListElementSize.x, 6f).height;
                Widgets.EndScrollView();
            }
            else
            {
                Text.Anchor = TextAnchor.UpperLeft;
                Rect rect7 = rect6;
                rect7.x  += itemListInnerMargin;
                rect7.y  += itemListInnerMargin;
                GUI.color = Color.gray;
                Widgets.Label(rect7, "None".Translate());
                GUI.color = Color.white;
            }
            Text.Anchor = TextAnchor.UpperLeft;
        }
Exemplo n.º 22
0
        public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo)
        {
            GizmoGridDrawer.gizmoGroups.Clear();
            foreach (Gizmo current in gizmos)
            {
                bool flag = false;
                for (int i = 0; i < GizmoGridDrawer.gizmoGroups.Count; i++)
                {
                    if (GizmoGridDrawer.gizmoGroups[i][0].GroupsWith(current))
                    {
                        flag = true;
                        GizmoGridDrawer.gizmoGroups[i].Add(current);
                        break;
                    }
                }
                if (!flag)
                {
                    List <Gizmo> list = new List <Gizmo>();
                    list.Add(current);
                    GizmoGridDrawer.gizmoGroups.Add(list);
                }
            }
            GizmoGridDrawer.firstGizmos.Clear();
            for (int j = 0; j < GizmoGridDrawer.gizmoGroups.Count; j++)
            {
                List <Gizmo> source = GizmoGridDrawer.gizmoGroups[j];
                Gizmo        gizmo  = source.FirstOrDefault((Gizmo opt) => !opt.disabled);
                if (gizmo == null)
                {
                    gizmo = source.FirstOrDefault <Gizmo>();
                }
                GizmoGridDrawer.firstGizmos.Add(gizmo);
            }
            GizmoGridDrawer.drawnHotKeys.Clear();
            float num = (float)(UI.screenWidth - 140);

            Text.Font = GameFont.Tiny;
            Vector2 topLeft = new Vector2(startX, (float)(UI.screenHeight - 35) - GizmoGridDrawer.GizmoSpacing.y - 75f);

            mouseoverGizmo = null;
            Gizmo interactedGiz = null;
            Event ev            = null;

            for (int k = 0; k < GizmoGridDrawer.firstGizmos.Count; k++)
            {
                Gizmo gizmo2 = GizmoGridDrawer.firstGizmos[k];
                if (gizmo2.Visible)
                {
                    if (topLeft.x + gizmo2.Width + GizmoGridDrawer.GizmoSpacing.x > num)
                    {
                        topLeft.x  = startX;
                        topLeft.y -= 75f + GizmoGridDrawer.GizmoSpacing.x;
                    }
                    GizmoGridDrawer.heightDrawnFrame = Time.frameCount;
                    GizmoGridDrawer.heightDrawn      = (float)UI.screenHeight - topLeft.y;
                    GizmoResult gizmoResult = gizmo2.GizmoOnGUI(topLeft);
                    if (gizmoResult.State == GizmoState.Interacted)
                    {
                        ev            = gizmoResult.InteractEvent;
                        interactedGiz = gizmo2;
                    }
                    if (gizmoResult.State >= GizmoState.Mouseover)
                    {
                        mouseoverGizmo = gizmo2;
                    }
                    Rect rect = new Rect(topLeft.x, topLeft.y, gizmo2.Width, 75f + GizmoGridDrawer.GizmoSpacing.y);
                    rect = rect.ContractedBy(-12f);
                    GenUI.AbsorbClicksInRect(rect);
                    topLeft.x += gizmo2.Width + GizmoGridDrawer.GizmoSpacing.x;
                }
            }
            if (interactedGiz != null)
            {
                List <Gizmo> list2 = GizmoGridDrawer.gizmoGroups.First((List <Gizmo> group) => group.Contains(interactedGiz));
                for (int l = 0; l < list2.Count; l++)
                {
                    Gizmo gizmo3 = list2[l];
                    if (gizmo3 != interactedGiz && !gizmo3.disabled && interactedGiz.InheritInteractionsFrom(gizmo3))
                    {
                        gizmo3.ProcessInput(ev);
                    }
                }
                interactedGiz.ProcessInput(ev);
                Event.current.Use();
            }
        }
Exemplo n.º 23
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));
            }
        }
        public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo)
        {
            if (Event.current.type == EventType.Layout)
            {
                mouseoverGizmo = null;
                return;
            }
            tmpAllGizmos.Clear();
            tmpAllGizmos.AddRange(gizmos);
            tmpAllGizmos.SortStable(SortByOrder);
            gizmoGroups.Clear();
            for (int i = 0; i < tmpAllGizmos.Count; i++)
            {
                Gizmo gizmo = tmpAllGizmos[i];
                bool  flag  = false;
                for (int j = 0; j < gizmoGroups.Count; j++)
                {
                    if (gizmoGroups[j][0].GroupsWith(gizmo))
                    {
                        flag = true;
                        gizmoGroups[j].Add(gizmo);
                        gizmoGroups[j][0].MergeWith(gizmo);
                        break;
                    }
                }
                if (!flag)
                {
                    List <Gizmo> list = SimplePool <List <Gizmo> > .Get();

                    list.Add(gizmo);
                    gizmoGroups.Add(list);
                }
            }
            firstGizmos.Clear();
            shrinkableCommands.Clear();
            float   num      = UI.screenWidth - 147;
            Vector2 vector   = new Vector2(startX, (float)(UI.screenHeight - 35) - GizmoSpacing.y - 75f);
            float   maxWidth = num - startX;
            int     num2     = 0;

            for (int k = 0; k < gizmoGroups.Count; k++)
            {
                List <Gizmo> list2  = gizmoGroups[k];
                Gizmo        gizmo2 = null;
                for (int l = 0; l < list2.Count; l++)
                {
                    if (!list2[l].disabled)
                    {
                        gizmo2 = list2[l];
                        break;
                    }
                }
                if (gizmo2 == null)
                {
                    gizmo2 = list2.FirstOrDefault();
                }
                else
                {
                    Command_Toggle command_Toggle = gizmo2 as Command_Toggle;
                    if (command_Toggle != null)
                    {
                        if (!command_Toggle.activateIfAmbiguous && !command_Toggle.isActive())
                        {
                            for (int m = 0; m < list2.Count; m++)
                            {
                                Command_Toggle command_Toggle2 = list2[m] as Command_Toggle;
                                if (command_Toggle2 != null && !command_Toggle2.disabled && command_Toggle2.isActive())
                                {
                                    gizmo2 = list2[m];
                                    break;
                                }
                            }
                        }
                        if (command_Toggle.activateIfAmbiguous && command_Toggle.isActive())
                        {
                            for (int n = 0; n < list2.Count; n++)
                            {
                                Command_Toggle command_Toggle3 = list2[n] as Command_Toggle;
                                if (command_Toggle3 != null && !command_Toggle3.disabled && !command_Toggle3.isActive())
                                {
                                    gizmo2 = list2[n];
                                    break;
                                }
                            }
                        }
                    }
                }
                if (gizmo2 != null)
                {
                    Command command;
                    if ((command = gizmo2 as Command) != null && command.shrinkable && command.Visible)
                    {
                        shrinkableCommands.Add(command);
                    }
                    if (vector.x + gizmo2.GetWidth(maxWidth) > num)
                    {
                        vector.x  = startX;
                        vector.y -= 75f + GizmoSpacing.x;
                        num2++;
                    }
                    vector.x += gizmo2.GetWidth(maxWidth) + GizmoSpacing.x;
                    firstGizmos.Add(gizmo2);
                }
            }
            if (num2 > 1 && shrinkableCommands.Count > 1)
            {
                for (int num3 = 0; num3 < shrinkableCommands.Count; num3++)
                {
                    firstGizmos.Remove(shrinkableCommands[num3]);
                }
            }
            else
            {
                shrinkableCommands.Clear();
            }
            drawnHotKeys.Clear();
            Text.Font = GameFont.Tiny;
            Vector2 vector2 = new Vector2(startX, (float)(UI.screenHeight - 35) - GizmoSpacing.y - 75f);

            mouseoverGizmo = null;
            Gizmo interactedGiz   = null;
            Event interactedEvent = null;
            Gizmo floatMenuGiz    = null;

            for (int num4 = 0; num4 < firstGizmos.Count; num4++)
            {
                Gizmo gizmo3 = firstGizmos[num4];
                if (gizmo3.Visible)
                {
                    if (vector2.x + gizmo3.GetWidth(maxWidth) > num)
                    {
                        vector2.x  = startX;
                        vector2.y -= 75f + GizmoSpacing.x;
                    }
                    heightDrawnFrame = Time.frameCount;
                    heightDrawn      = (float)UI.screenHeight - vector2.y;
                    GizmoResult result2 = gizmo3.GizmoOnGUI(vector2, maxWidth);
                    ProcessGizmoState(gizmo3, result2, ref mouseoverGizmo);
                    GenUI.AbsorbClicksInRect(new Rect(vector2.x, vector2.y, gizmo3.GetWidth(maxWidth), 75f + GizmoSpacing.y).ContractedBy(-12f));
                    vector2.x += gizmo3.GetWidth(maxWidth) + GizmoSpacing.x;
                }
            }
            float x    = vector2.x;
            int   num5 = 0;

            for (int num6 = 0; num6 < shrinkableCommands.Count; num6++)
            {
                Command command2      = shrinkableCommands[num6];
                float   getShrunkSize = command2.GetShrunkSize;
                if (vector2.x + getShrunkSize > num)
                {
                    num5++;
                    if (num5 > 1)
                    {
                        x = startX;
                    }
                    vector2.x  = x;
                    vector2.y -= getShrunkSize + 3f;
                }
                Vector2 topLeft = vector2;
                topLeft.y       += getShrunkSize + 3f;
                heightDrawnFrame = Time.frameCount;
                heightDrawn      = Mathf.Min(heightDrawn, (float)UI.screenHeight - topLeft.y);
                GizmoResult result3 = command2.GizmoOnGUIShrunk(topLeft, getShrunkSize);
                ProcessGizmoState(command2, result3, ref mouseoverGizmo);
                GenUI.AbsorbClicksInRect(new Rect(topLeft.x, topLeft.y, getShrunkSize, getShrunkSize + 3f).ExpandedBy(3f));
                vector2.x += getShrunkSize + 3f;
            }
            if (interactedGiz != null)
            {
                List <Gizmo> list3 = FindMatchingGroup(interactedGiz);
                for (int num7 = 0; num7 < list3.Count; num7++)
                {
                    Gizmo gizmo4 = list3[num7];
                    if (gizmo4 != interactedGiz && !gizmo4.disabled && interactedGiz.InheritInteractionsFrom(gizmo4))
                    {
                        gizmo4.ProcessInput(interactedEvent);
                    }
                }
                interactedGiz.ProcessInput(interactedEvent);
                Event.current.Use();
            }
            else if (floatMenuGiz != null)
            {
                List <FloatMenuOption> list4 = new List <FloatMenuOption>();
                foreach (FloatMenuOption rightClickFloatMenuOption in floatMenuGiz.RightClickFloatMenuOptions)
                {
                    list4.Add(rightClickFloatMenuOption);
                }
                List <Gizmo> list5 = FindMatchingGroup(floatMenuGiz);
                for (int num8 = 0; num8 < list5.Count; num8++)
                {
                    Gizmo gizmo5 = list5[num8];
                    if (gizmo5 == floatMenuGiz || gizmo5.disabled || !floatMenuGiz.InheritFloatMenuInteractionsFrom(gizmo5))
                    {
                        continue;
                    }
                    foreach (FloatMenuOption rightClickFloatMenuOption2 in gizmo5.RightClickFloatMenuOptions)
                    {
                        FloatMenuOption floatMenuOption = null;
                        for (int num9 = 0; num9 < list4.Count; num9++)
                        {
                            if (list4[num9].Label == rightClickFloatMenuOption2.Label)
                            {
                                floatMenuOption = list4[num9];
                                break;
                            }
                        }
                        if (floatMenuOption == null)
                        {
                            list4.Add(rightClickFloatMenuOption2);
                        }
                        else
                        {
                            if (rightClickFloatMenuOption2.Disabled)
                            {
                                continue;
                            }
                            if (!floatMenuOption.Disabled)
                            {
                                Action prevAction        = floatMenuOption.action;
                                Action localOptionAction = rightClickFloatMenuOption2.action;
                                floatMenuOption.action = delegate
                                {
                                    prevAction();
                                    localOptionAction();
                                };
                            }
                            else if (floatMenuOption.Disabled)
                            {
                                list4[list4.IndexOf(floatMenuOption)] = rightClickFloatMenuOption2;
                            }
                        }
                    }
                }
                Event.current.Use();
                if (list4.Any())
                {
                    Find.WindowStack.Add(new FloatMenu(list4));
                }
            }
            for (int num10 = 0; num10 < gizmoGroups.Count; num10++)
            {
                gizmoGroups[num10].Clear();
                SimplePool <List <Gizmo> > .Return(gizmoGroups[num10]);
            }
            gizmoGroups.Clear();
            firstGizmos.Clear();
            tmpAllGizmos.Clear();