public static bool Prefix(IEnumerable <object> selectedObjects, ref Gizmo mouseoverGizmo, ref Profiler __state)
        {
            if (Active && DetourMode)
            {
                Detour(selectedObjects, ref mouseoverGizmo);
                return(false);
            }


            if (!Active && !Analyzer.Settings.OptimizeDrawInspectGizmoGrid)
            {
                return(true);
            }

            if (Active)
            {
                __state = Analyzer.Start(str);
            }

            if (Analyzer.Settings.OptimizeDrawInspectGizmoGrid)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    return(true);
                }

                if (Event.current.type != EventType.Layout)
                {
                    GizmoGridDrawer.DrawGizmoGrid(cach, InspectPaneUtility.PaneWidthFor(Find.WindowStack.WindowOfType <IInspectPane>()) + 20f, out mouseoverGizmo);
                }

                return(false);
            }
            return(true);
        }
        public static Vector2 CardSize(CompToggleDef compToggleDef)
        {
            var width    = InspectPaneUtility.PaneWidthFor((MainTabWindow_Inspect)MainButtonDefOf.Inspect.TabWindow);
            var rowCount = Math.Min(compToggleDef.Props.toggleDefs.Count, MaxRows);

            return(new Vector2(width, TotalRowHeight(rowCount) + CardPadding * 2 + ExtraTopPadding));
        }
Exemple #3
0
        public static bool Prefix(ref Gizmo mouseoverGizmo)
        {
            if (!Active && !Analyzer.Settings.OptimizeDrawInspectGizmoGrid)
            {
                return(true);
            }

            if (Active)
            {
                Analyzer.Start(str);
            }

            if (Analyzer.Settings.OptimizeDrawInspectGizmoGrid)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    return(true);
                }

                if (Event.current.type != EventType.Layout)
                {
                    GizmoGridDrawer.DrawGizmoGrid(cach, InspectPaneUtility.PaneWidthFor(Find.WindowStack.WindowOfType <IInspectPane>()) + 20f, out mouseoverGizmo);
                }

                return(false);
            }
            return(true);
        }
Exemple #4
0
        private static bool Prefix(ref Vector2 __result, IInspectPane pane)
        {
            if (!State.AltInspectPane || !State.PawnSelected)
            {
                return(true);
            }

            __result = new Vector2(InspectPaneUtility.PaneWidthFor(pane), Theme.InspectPaneHeight.Value - 35f);
            return(false);
        }
        public static bool DrawTabs(IInspectPane pane)
        {
            try
            {
                var y = pane.PaneTopY - 30f;
                var x = InspectPaneUtility.PaneWidthFor(pane) - Theme.InspectPaneTabWidth.Value;

                var width      = 0f;
                var isSelected = false;

                foreach (var curTab in pane.CurTabs)
                {
                    if (!curTab.IsVisible)
                    {
                        continue;
                    }

                    var rect = new Rect(x, y, Theme.InspectPaneTabWidth.Value, 30f);
                    width = x;

                    Text.Font = GameFont.Small;

                    if (Widgets.ButtonText(rect, curTab.labelKey.Translate()))
                    {
                        InterfaceToggleTab(curTab, pane);
                    }

                    var isOpenTab = curTab.GetType() == pane.OpenTabType;
                    if (!isOpenTab && !curTab.TutorHighlightTagClosed.NullOrEmpty())
                    {
                        UIHighlighter.HighlightOpportunity(rect, curTab.TutorHighlightTagClosed);
                    }

                    if (isOpenTab)
                    {
                        curTab.DoTabGUI();
                        pane.RecentHeight = 700f;
                        isSelected        = true;
                    }

                    x -= Theme.InspectPaneTabWidth.Value;
                }
                if (!isSelected)
                {
                    return(false);
                }

                GUI.DrawTexture(new Rect(0.0f, y, width, 30f), Textures.InspectTabButtonFillTex);
            }
            catch (Exception ex) { Log.ErrorOnce(ex.ToString(), 742783); }

            return(false);
        }
        public static void Detour(IEnumerable <object> selectedObjects, ref Gizmo mouseoverGizmo)
        {
            var DoRebuild = !(Analyzer.Settings.OptimizeDrawInspectGizmoGrid && Event.current.type != EventType.Repaint);

            Profiler prof = null;

            if (DoRebuild)
            {
                mouseoverGizmo = null;
                try
                {
                    InspectGizmoGrid.objList.Clear();
                    InspectGizmoGrid.objList.AddRange(selectedObjects);
                    InspectGizmoGrid.gizmoList.Clear();
                    var slam = InspectGizmoGrid.objList.Count;
                    for (var i = 0; i < slam; i++)
                    {
                        if (InspectGizmoGrid.objList[i] is ISelectable selectable)
                        {
                            if (Active)
                            {
                                var me = string.Intern($"{selectable.GetType()} Gizmos");
                                prof = Analyzer.Start(me);
                                InspectGizmoGrid.gizmoList.AddRange(selectable.GetGizmos());
                                prof.Stop();
                            }
                            else
                            {
                                InspectGizmoGrid.gizmoList.AddRange(selectable.GetGizmos());
                            }
                        }
                    }
                    for (var j = 0; j < InspectGizmoGrid.objList.Count; j++)
                    {
                        if (InspectGizmoGrid.objList[j] is Thing t)
                        {
                            var allDesignators = Find.ReverseDesignatorDatabase.AllDesignators;
                            var coo            = allDesignators.Count;
                            for (var k = 0; k < coo; k++)
                            {
                                Designator des = allDesignators[k];
                                if (des.CanDesignateThing(t).Accepted)
                                {
                                    var command_Action = new Command_Action
                                    {
                                        defaultLabel = des.LabelCapReverseDesignating(t),
                                        icon         = des.IconReverseDesignating(t, out var iconAngle, out var iconOffset),
                                        iconAngle    = iconAngle,
                                        iconOffset   = iconOffset,
                                        defaultDesc  = des.DescReverseDesignating(t),
                                        order        = (!(des is Designator_Uninstall) ? -20f : -11f),
                                        action       = delegate
                                        {
                                            if (!TutorSystem.AllowAction(des.TutorTagDesignate))
                                            {
                                                return;
                                            }

                                            des.DesignateThing(t);
                                            des.Finalize(true);
                                        },
                                        hotKey   = des.hotKey,
                                        groupKey = des.groupKey
                                    };
                                    InspectGizmoGrid.gizmoList.Add(command_Action);
                                }
                            }
                        }
                    }
                    InspectGizmoGrid.objList.Clear();
                }
                catch (Exception ex)
                {
                    Log.ErrorOnce(ex.ToString(), 3427734);
                }
            }

            if (Active)
            {
                prof = Analyzer.Start(str);
            }
            GizmoGridDrawer.DrawGizmoGrid(InspectGizmoGrid.gizmoList, InspectPaneUtility.PaneWidthFor(Find.WindowStack.WindowOfType <IInspectPane>()) + 20f, out mouseoverGizmo);
            if (Active)
            {
                prof.Stop();
            }
        }
Exemple #7
0
 public static void Prefix(MainTabWindow_Inspect __instance, ref Rect rect)
 {
     rect.width = InspectPaneUtility.PaneWidthFor(__instance) - 72f;
 }
 public void DrawInspectGizmos()
 {
     GizmoGridDrawer.DrawGizmoGrid(resolvedDesignatorTypes.Cast <Gizmo>(), InspectPaneUtility.PaneWidthFor(this) + 20f, out mouseoverGizmo);
 }
Exemple #9
0
        public static bool DrawTabs(IInspectPane pane)
        {
            if (pane.CurTabs == null)
            {
                Log.Warning("NO CURTABS");
                return(false);
            }

            try
            {
                var y = pane.PaneTopY - 30f;
                var x = InspectPaneUtility.PaneWidthFor(pane) - Theme.InspectPaneTabWidth.Value;

                var width      = 0f;
                var isSelected = false;

                foreach (var tab in pane.CurTabs)
                {
                    if (!tab.IsVisible)
                    {
                        continue;
                    }

                    int buttonWidth;
                    if (TabButtonWidths.ContainsKey(tab))
                    {
                        buttonWidth = TabButtonWidths[tab];
                    }
                    else
                    {
                        buttonWidth = Traverse.Create(tab).Field <int>("tabButtonWidth")?.Value ?? 0;
                        if (buttonWidth <= 0)
                        {
                            buttonWidth = Theme.InspectPaneTabWidth.Value;
                        }
                        TabButtonWidths[tab] = buttonWidth;
                    }

                    var rect = new Rect(x, y, buttonWidth, 30f);
                    width = x;

                    Text.Font = GameFont.Small;

                    if (Widgets.ButtonText(rect, tab.labelKey.Translate()))
                    {
                        InterfaceToggleTab(tab, pane);
                    }

                    var isOpenTab = tab.GetType() == pane.OpenTabType;
                    if (!isOpenTab && !tab.TutorHighlightTagClosed.NullOrEmpty())
                    {
                        UIHighlighter.HighlightOpportunity(rect, tab.TutorHighlightTagClosed);
                    }

                    if (isOpenTab)
                    {
                        tab.DoTabGUI();
                        pane.RecentHeight = 700f;
                        isSelected        = true;
                    }

                    x -= Theme.InspectPaneTabWidth.Value;
                }
                if (!isSelected)
                {
                    return(false);
                }

                GUI.DrawTexture(new Rect(0f, y, width, 30f), Textures.InspectTabButtonFill);
            }
            catch (Exception exception) { Mod.HandleError(exception); }
            return(false);
        }
Exemple #10
0
        /// <summary>
        ///     This is a rip of the DoCustomBottomButtons() function in RimWorld.Page_SelectLandingSite with a new button.
        /// </summary>
        private void DoCustomBottomButtons()
        {
            // HACK : changed the number of buttons from '5 : 4' to '6 : 5' as we add a button
            var num = (!TutorSystem.TutorialMode) ? 6 : 5;
            int num2;

            if (num >= 4 && UI.screenWidth < 1340f)
            {
                num2 = 2;
            }
            else
            {
                num2 = 1;
            }
            var num3             = Mathf.CeilToInt(num / (float)num2);
            var num4             = BottomButSize.x * num3 + 10f * (num3 + 1);
            var num5             = num2 * BottomButSize.y + 10f * (num2 + 1);
            var rect             = new Rect((UI.screenWidth - num4) / 2f, UI.screenHeight - num5 - 4f, num4, num5);
            var worldInspectPane = Find.WindowStack.WindowOfType <WorldInspectPane>();

            if (worldInspectPane != null && rect.x < InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f)
            {
                rect.x = InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f;
            }
            Widgets.DrawWindowBackground(rect);
            var num6 = rect.xMin + 10f;
            var num7 = rect.yMin + 10f;

            Text.Font = GameFont.Small;
            if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Back".Translate()))
            {
                if (CanDoBack())
                {
                    /* ADDED CODE */

                    #region INSERTED_CODE

                    // make sure the prepare landing window (or its minimized window) is closed when we go back
                    if (Find.WindowStack.IsOpen <MainWindow>() || Find.WindowStack.IsOpen <MinimizedWindow>())
                    {
                        if (PrepareLanding.Instance.MainWindow != null)
                        {
                            PrepareLanding.Instance.MainWindow.ForceClose();
                        }
                    }

                    #endregion

                    /* END ADDED CODE*/

                    DoBack();
                }
            }
            num6 += BottomButSize.x + 10f;
            if (!TutorSystem.TutorialMode)
            {
                if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Advanced".Translate()))
                {
                    Find.WindowStack.Add(new Dialog_AdvancedGameConfig(Find.WorldInterface.SelectedTile));
                }
                num6 += BottomButSize.x + 10f;
            }
            if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "SelectRandomSite".Translate()))
            {
                SoundDefOf.Click.PlayOneShotOnCamera();
                Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile();
                Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
            }
            num6 += BottomButSize.x + 10f;
            if (num2 == 2)
            {
                num6  = rect.xMin + 10f;
                num7 += BottomButSize.y + 10f;
            }
            if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "WorldFactionsTab".Translate()))
            {
                Find.WindowStack.Add(new Dialog_FactionDuringLanding());
            }
            num6 += BottomButSize.x + 10f;

            #region INSERTED_CODE

            if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Prepare Landing"))
            {
                Log.Message("[PrepareLanding] Page button pressed!");

                // don't add a new window if the window is already there
                if (PrepareLanding.Instance.MainWindow == null)
                {
                    PrepareLanding.Instance.MainWindow = new MainWindow(PrepareLanding.Instance.GameData);
                }

                PrepareLanding.Instance.MainWindow.Show();
            }
            num6 += BottomButSize.x + 10f;

            #endregion INSERTED_CODE

            /* end of inserted code */


            if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Next".Translate()))
            {
                if (CanDoNext())
                {
                    /* ADDED CODE */
                    #region INSERTED_CODE

                    // make sure the prepare landing window (or its minimized window) is closed when we go to the next window / game stage
                    if (Find.WindowStack.IsOpen <MainWindow>() || Find.WindowStack.IsOpen <MinimizedWindow>())
                    {
                        if (PrepareLanding.Instance.MainWindow != null)
                        {
                            PrepareLanding.Instance.MainWindow.ForceClose();
                        }
                    }

                    #endregion
                    /* END ADDED CODE*/

                    DoNext();
                }
            }
            //num6 += BottomButSize.x + 10f;
            GenUI.AbsorbClicksInRect(rect);
        }
        private void DoCustomBottomButtons()
        {
            int              num              = (!TutorSystem.TutorialMode) ? 5 : 4;
            int              num2             = (num < 4 || !((float)UI.screenWidth < 1340f)) ? 1 : 2;
            int              num3             = Mathf.CeilToInt((float)num / (float)num2);
            Vector2          bottomButSize    = Page.BottomButSize;
            float            num4             = bottomButSize.x * (float)num3 + 10f * (float)(num3 + 1);
            float            num5             = num2;
            Vector2          bottomButSize2   = Page.BottomButSize;
            float            num6             = num5 * bottomButSize2.y + 10f * (float)(num2 + 1);
            Rect             rect             = new Rect(((float)UI.screenWidth - num4) / 2f, (float)UI.screenHeight - num6 - 4f, num4, num6);
            WorldInspectPane worldInspectPane = Find.WindowStack.WindowOfType <WorldInspectPane>();

            if (worldInspectPane != null && rect.x < InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f)
            {
                rect.x = InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f;
            }
            Widgets.DrawWindowBackground(rect);
            float num7 = rect.xMin + 10f;
            float num8 = rect.yMin + 10f;

            Text.Font = GameFont.Small;
            float   x = num7;
            float   y = num8;
            Vector2 bottomButSize3 = Page.BottomButSize;
            float   x2             = bottomButSize3.x;
            Vector2 bottomButSize4 = Page.BottomButSize;
            float   num9           = num7;
            Vector2 bottomButSize5 = Page.BottomButSize;

            num7 = num9 + (bottomButSize5.x + 10f);
            if (!TutorSystem.TutorialMode)
            {
                float   x3             = num7;
                float   y2             = num8;
                Vector2 bottomButSize6 = Page.BottomButSize;
                float   x4             = bottomButSize6.x;
                Vector2 bottomButSize7 = Page.BottomButSize;
                if (Widgets.ButtonText(new Rect(x3, y2, x4, bottomButSize7.y), "Advanced".Translate()))
                {
                    Find.WindowStack.Add(new Dialog_AdvancedGameConfig(Find.WorldInterface.SelectedTile));
                }
                float   num10          = num7;
                Vector2 bottomButSize8 = Page.BottomButSize;
                num7 = num10 + (bottomButSize8.x + 10f);
            }
            float   x5              = num7;
            float   y3              = num8;
            Vector2 bottomButSize9  = Page.BottomButSize;
            float   x6              = bottomButSize9.x;
            Vector2 bottomButSize10 = Page.BottomButSize;

            if (Widgets.ButtonText(new Rect(x5, y3, x6, bottomButSize10.y), "SelectRandomSite".Translate()))
            {
                SoundDefOf.Click.PlayOneShotOnCamera();
                Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile();
                Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
            }
            float   num11           = num7;
            Vector2 bottomButSize11 = Page.BottomButSize;

            num7 = num11 + (bottomButSize11.x + 10f);
            if (num2 == 2)
            {
                num7 = rect.xMin + 10f;
                float   num12           = num8;
                Vector2 bottomButSize12 = Page.BottomButSize;
                num8 = num12 + (bottomButSize12.y + 10f);
            }
            float   x7 = num7;
            float   y4 = num8;
            Vector2 bottomButSize13 = Page.BottomButSize;
            float   x8 = bottomButSize13.x;
            Vector2 bottomButSize14 = Page.BottomButSize;

            if (Widgets.ButtonText(new Rect(x7, y4, x8, bottomButSize14.y), "WorldFactionsTab".Translate()))
            {
                Find.WindowStack.Add(new Dialog_FactionDuringLanding());
            }
            float   num13           = num7;
            Vector2 bottomButSize15 = Page.BottomButSize;

            num7 = num13 + (bottomButSize15.x + 10f);
            float   x9 = num7;
            float   y5 = num8;
            Vector2 bottomButSize16 = Page.BottomButSize;
            float   x10             = bottomButSize16.x;
            Vector2 bottomButSize17 = Page.BottomButSize;

            if (Widgets.ButtonText(new Rect(x9, y5, x10, bottomButSize17.y), "Next".Translate()))
            {
                if (Find.WorldSelector.selectedTile < 0)
                {
                    return;
                }

                StartGame(Find.WorldSelector.selectedTile);
            }
            float   num14           = num7;
            Vector2 bottomButSize18 = Page.BottomButSize;

            num7 = num14 + (bottomButSize18.x + 10f);
            GenUI.AbsorbClicksInRect(rect);
        }