示例#1
0
        public static void UpdateTabs(IInspectPane pane)
        {
            bool tabUpdated = false;

            if (pane.CurTabs != null)
            {
                IList list = pane.CurTabs as IList;
                if (list != null)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        Update((InspectTabBase)list[i]);
                    }
                }
                else
                {
                    foreach (InspectTabBase curTab in pane.CurTabs)
                    {
                        Update(curTab);
                    }
                }
            }
            if (!tabUpdated)
            {
                pane.CloseOpenTab();
            }
            void Update(InspectTabBase tab)
            {
                if (tab.IsVisible && tab.GetType() == pane.OpenTabType)
                {
                    tab.TabUpdate();
                    tabUpdated = true;
                }
            }
        }
示例#2
0
        // Resizes the tabs if more than 6 visible
        public static bool DoTabs_Prefix(IInspectPane pane)
        {
            try
            {
                int count = pane.CurTabs.Count(x => x.IsVisible);
                if (count > 6)
                {
                    tabWidth = PaneWidth / count;
                }
                else
                {
                    tabWidth = 72f;
                }

                float y     = pane.PaneTopY - TabHeight;
                float num   = PaneWidth - tabWidth;
                float width = 0f;
                bool  flag  = false;

                foreach (InspectTabBase current in pane.CurTabs)
                {
                    if (current.IsVisible)
                    {
                        Rect rect = new Rect(num, y, tabWidth, TabHeight);
                        width     = num;
                        Text.Font = GameFont.Small;
                        if (Widgets.ButtonText(rect, current.labelKey.Translate()))
                        {
                            InterfaceToggleTab(current, pane);
                        }

                        bool flag2 = current.GetType() == pane.OpenTabType;
                        if (!flag2 && !current.TutorHighlightTagClosed.NullOrEmpty())
                        {
                            UIHighlighter.HighlightOpportunity(rect, current.TutorHighlightTagClosed);
                        }

                        if (flag2)
                        {
                            current.DoTabGUI();
                            pane.RecentHeight = 700f;
                            flag = true;
                        }

                        num -= tabWidth;
                    }
                }

                if (flag)
                {
                    GUI.DrawTexture(new Rect(0f, y, width, TabHeight), InspectTabButtonFillTex);
                }
            }
            catch (Exception ex)
            {
                Log.ErrorOnce(ex.ToString(), 742783);
            }

            return(false);
        }
 private static void InterfaceToggleTab(InspectTabBase tab, IInspectPane pane)
 {
     if (!TutorSystem.TutorialMode || InspectPaneUtility.IsOpen(tab, pane) || TutorSystem.AllowAction("ITab-" + tab.tutorTag + "-Open"))
     {
         InspectPaneUtility.ToggleTab(tab, pane);
     }
 }
示例#4
0
 private static bool Prefix(IInspectPane pane)
 {
     if (!State.AltInspectPane || !State.PawnSelected)
     {
         return(true);
     }
     return(InspectPanePlus.DrawTabs(pane));
 }
示例#5
0
        //private static void DoTabs(IInspectPane pane)
        private static void Postfix(IInspectPane pane)
        {
            float TAB_WIDTH = TABLIST_WIDTH / Math.Max(pane.CurTabs.Count(arg => arg.IsVisible), 6);

            try
            {
                float y     = pane.PaneTopY - 30f;
                float num   = TABLIST_WIDTH - TAB_WIDTH;               // mod
                float width = 0f;
                bool  flag  = false;
                foreach (InspectTabBase current in pane.CurTabs)
                {
                    if (current.IsVisible)
                    {
                        Rect rect = new Rect(num, y, TAB_WIDTH, 30f);
                        width = num;

                        var labelsize = Text.CalcSize(current.labelKey.Translate());

                        if (labelsize.x > TAB_WIDTH)
                        {
                            Text.Font = GameFont.Tiny;
                        }
                        else
                        {
                            Text.Font = GameFont.Small;
                        }

                        if (Widgets.ButtonText(rect, current.labelKey.Translate(), true, false, true))
                        {
                            InspectPaneUtility.DoTabs.InterfaceToggleTab(current, pane);
                        }
                        bool flag2 = current.GetType() == pane.OpenTabType;
                        if (!flag2 && !current.TutorHighlightTagClosed.NullOrEmpty())
                        {
                            UIHighlighter.HighlightOpportunity(rect, current.TutorHighlightTagClosed);
                        }
                        if (flag2)
                        {
                            current.DoTabGUI();
                            pane.RecentHeight = 700f;
                            flag = true;
                        }
                        num -= TAB_WIDTH;
                    }
                }
                if (flag)
                {
                    GUI.DrawTexture(new Rect(0f, y, width, 30f), InspectPaneUtility.DoTabs.InspectTabButtonFillTex);
                }
            }
            catch (Exception ex)
            {
                Verse.Log.ErrorOnce(ex.ToString(), 742783);
            }
        }
        private static bool Prefix(Rect inRect, IInspectPane pane)
        {
            if (!State.ModifyPane)
            {
                return(true);
            }

            InspectPanePlus.OnGUI(inRect, pane);
            return(false);
        }
示例#7
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);
        }
示例#8
0
        private static void InterfaceToggleTab(InspectTabBase tab, IInspectPane pane)
        {
            if (TutorSystem.TutorialMode && !IsOpen(tab, pane) &&
                !TutorSystem.AllowAction("ITab-" + tab.tutorTag + "-Open"))
            {
                return;
            }

            ToggleTab(tab, pane);
        }
        private static bool Prefix(Rect inRect, IInspectPane pane)
        {
            if (!State.AltInspectPane || !State.PawnSelected)
            {
                return(true);
            }

            InspectPanePlus.OnGUI(inRect, pane);
            return(false);
        }
        private static bool Prefix(ref float __result, IInspectPane pane)
        {
            if (!State.ModifyPane)
            {
                return(true);
            }

            var count = pane.CurTabs.Count(tab => tab.IsVisible);

            __result = Theme.InspectPaneTabWidth.Value * (float)Mathf.Max(Theme.InspectPaneMinTabs.Value, count);
            return(false);
        }
示例#11
0
        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);
        }
示例#12
0
 public static void ExtraOnGUI(IInspectPane pane)
 {
     if (pane.AnythingSelected)
     {
         if (KeyBindingDefOf.SelectNextInCell.KeyDownEvent)
         {
             pane.SelectNextInCell();
         }
         pane.DrawInspectGizmos();
         InspectPaneUtility.DoTabs(pane);
     }
 }
示例#13
0
 private static void ToggleTab(InspectTabBase tab, IInspectPane pane)
 {
     if (InspectPaneUtility.IsOpen(tab, pane) || (tab == null && pane.OpenTabType == null))
     {
         pane.OpenTabType = null;
         SoundDefOf.TabClose.PlayOneShotOnCamera(null);
     }
     else
     {
         tab.OnOpen();
         pane.OpenTabType = tab.GetType();
         SoundDefOf.TabOpen.PlayOneShotOnCamera(null);
     }
 }
 public static void InspectPaneOnGUI(Rect inRect, IInspectPane pane)
 {
     pane.RecentHeight = 165f;
     if (pane.AnythingSelected)
     {
         try
         {
             Rect rect = inRect.ContractedBy(12f);
             rect.yMin -= 4f;
             rect.yMax += 6f;
             GUI.BeginGroup(rect);
             float num = 0f;
             if (pane.ShouldShowSelectNextInCellButton)
             {
                 Rect rect2 = new Rect(rect.width - 24f, 0f, 24f, 24f);
                 if (Widgets.ButtonImage(rect2, TexButton.SelectOverlappingNext))
                 {
                     pane.SelectNextInCell();
                 }
                 num += 24f;
                 TooltipHandler.TipRegion(rect2, "SelectNextInSquareTip".Translate(new object[]
                 {
                     KeyBindingDefOf.SelectNextInCell.MainKeyLabel
                 }));
             }
             pane.DoInspectPaneButtons(rect, ref num);
             Rect   rect3 = new Rect(0f, 0f, rect.width - num, 50f);
             string label = pane.GetLabel(rect3);
             rect3.width += 300f;
             Text.Font    = GameFont.Medium;
             Text.Anchor  = TextAnchor.UpperLeft;
             Widgets.Label(rect3, label);
             if (pane.ShouldShowPaneContents)
             {
                 Rect rect4 = rect.AtZero();
                 rect4.yMin += 26f;
                 pane.DoPaneContents(rect4);
             }
         }
         catch (Exception ex)
         {
             Log.Error("Exception doing inspect pane: " + ex.ToString(), false);
         }
         finally
         {
             GUI.EndGroup();
         }
     }
 }
 public static void ExtraOnGUI(IInspectPane pane)
 {
     if (pane.AnythingSelected)
     {
         if (KeyBindingDefOf.SelectNextInCell.KeyDownEvent)
         {
             pane.SelectNextInCell();
         }
         if (Current.ProgramState == ProgramState.Playing)
         {
             pane.DrawInspectGizmos();
         }
         InspectPaneUtility.DoTabs(pane);
     }
 }
示例#16
0
        public static void UpdateTabs(IInspectPane pane)
        {
            bool flag = false;

            foreach (InspectTabBase curTab in pane.CurTabs)
            {
                if (curTab.IsVisible && curTab.GetType() == pane.OpenTabType)
                {
                    curTab.TabUpdate();
                    flag = true;
                }
            }
            if (!flag)
            {
                pane.CloseOpenTab();
            }
        }
示例#17
0
        public static float PaneWidthFor(IInspectPane pane)
        {
            if (pane == null)
            {
                return(432f);
            }
            int num = 0;

            foreach (InspectTabBase curTab in pane.CurTabs)
            {
                if (curTab.IsVisible)
                {
                    num++;
                }
            }
            return((float)(72.0 * (float)Mathf.Max(6, num)));
        }
示例#18
0
        private static bool Prefix(ref float __result, IInspectPane pane)
        {
            if (!State.AltInspectPane || !State.PawnSelected)
            {
                return(true);
            }

            if (pane == null)
            {
                __result = 432f;
                return(false);
            }

            var count = pane.CurTabs.Count(tab => tab.IsVisible);

            __result = Theme.InspectPaneTabWidth.Value * (float)Mathf.Max(Theme.InspectPaneMinTabs.Value, count);
            return(false);
        }
示例#19
0
 private static void DoTabs(IInspectPane pane)
 {
     try
     {
         float y     = (float)(pane.PaneTopY - 30.0);
         float num   = (float)(InspectPaneUtility.PaneWidthFor(pane) - 72.0);
         float width = 0f;
         bool  flag  = false;
         foreach (InspectTabBase curTab in pane.CurTabs)
         {
             if (curTab.IsVisible)
             {
                 Rect rect = new Rect(num, y, 72f, 30f);
                 width     = num;
                 Text.Font = GameFont.Small;
                 if (Widgets.ButtonText(rect, curTab.labelKey.Translate(), true, false, true))
                 {
                     InspectPaneUtility.InterfaceToggleTab(curTab, pane);
                 }
                 bool flag2 = curTab.GetType() == pane.OpenTabType;
                 if (!flag2 && !curTab.TutorHighlightTagClosed.NullOrEmpty())
                 {
                     UIHighlighter.HighlightOpportunity(rect, curTab.TutorHighlightTagClosed);
                 }
                 if (flag2)
                 {
                     curTab.DoTabGUI();
                     pane.RecentHeight = 700f;
                     flag = true;
                 }
                 num = (float)(num - 72.0);
             }
         }
         if (flag)
         {
             GUI.DrawTexture(new Rect(0f, y, width, 30f), InspectPaneUtility.InspectTabButtonFillTex);
         }
     }
     catch (Exception ex)
     {
         Log.ErrorOnce(ex.ToString(), 742783);
     }
 }
        public static float PaneWidthFor(IInspectPane pane)
        {
            float result;

            if (pane == null)
            {
                result = 432f;
            }
            else
            {
                int num = 0;
                foreach (InspectTabBase inspectTabBase in pane.CurTabs)
                {
                    if (inspectTabBase.IsVisible)
                    {
                        num++;
                    }
                }
                result = 72f * (float)Mathf.Max(6, num);
            }
            return(result);
        }
示例#21
0
        public static float PaneWidthFor(IInspectPane pane)
        {
            if (pane == null)
            {
                return(432f);
            }
            int visible = 0;

            if (pane.CurTabs != null)
            {
                IList list = pane.CurTabs as IList;
                if (list != null)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        Process((InspectTabBase)list[i]);
                    }
                }
                else
                {
                    foreach (InspectTabBase curTab in pane.CurTabs)
                    {
                        Process(curTab);
                    }
                }
            }
            return(72f * (float)Mathf.Max(6, visible));

            void Process(InspectTabBase tab)
            {
                if (tab.IsVisible)
                {
                    visible++;
                }
            }
        }
示例#22
0
        public static void OnGUI(Rect inRect, IInspectPane pane)
        {
            Theme.CheckFontChange();

            var model = PawnModel.Selected;

            pane.RecentHeight = Theme.InspectPaneHeight.Value - 35f;

            if (model == null)
            {
                return;
            }
            if (!pane.AnythingSelected)
            {
                return;
            }

            var rect = inRect.ContractedBy(12f);

            rect.yMin -= 4f;
            rect.yMax += 6f;

            try
            {
                GUI.BeginGroup(rect.ExpandedBy(1f));

                var lineEndWidth = 0f;

                if (pane.ShouldShowSelectNextInCellButton)
                {
                    var selectOverlappingNextRect = new Rect(rect.width - ButtonSize, 0f, ButtonSize, ButtonSize);
                    if (Widgets.ButtonImage(selectOverlappingNextRect, Textures.SelectOverlappingNext))
                    {
                        pane.SelectNextInCell();
                    }
                    lineEndWidth += ButtonSize;
                    TooltipHandler.TipRegion(selectOverlappingNextRect, "SelectNextInSquareTip".Translate(KeyBindingDefOf.SelectNextInCell.MainKeyLabel));
                }

                DrawButtons(rect, ref lineEndWidth);

                var previousAnchor = Text.Anchor;
                Text.Anchor = TextAnchor.UpperLeft;
                GUIPlus.SetFont(GameFont.Medium);
                GUIPlus.SetColor(model.FactionRelationColor);

                var labelRect = new Rect(0f, 0f, rect.width - lineEndWidth, Text.LineHeight);
                var label     = model.Name;

                Widgets.Label(labelRect, label);
                if (Widgets.ButtonInvisible(labelRect))
                {
                    ToggleSocialTab();
                }

                GUIPlus.ResetFont();
                GUIPlus.ResetColor();
                Text.Anchor = previousAnchor;
                GUIPlus.DrawTooltip(labelRect, model.BioTooltip, false);

                if (!pane.ShouldShowPaneContents)
                {
                    return;
                }

                var contentRect = rect.AtZero();
                contentRect.yMin += 26f;
                DrawContent(contentRect, model, null);
            }
            catch (Exception exception) { Mod.HandleError(exception); }
            finally { GUI.EndGroup(); }
        }
示例#23
0
 private static void InterfaceToggleTab(InspectTabBase tab, IInspectPane pane) => Access.Method_RimWorld_InspectPaneUtility_InterfaceToggleTab.Invoke(null, new object[] { tab, pane });
示例#24
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);
        }
 static void InterfaceToggleTab(InspectTabBase current, IInspectPane pane)
 {
     typeof(RimWorld.InspectPaneUtility).GetMethod("InterfaceToggleTab", Helpers.AllBindingFlags).Invoke(null, new object[] { current, pane });
 }
示例#26
0
 public static Vector2 PaneSizeFor(IInspectPane pane)
 {
     return(new Vector2(InspectPaneUtility.PaneWidthFor(pane), 165f));
 }
示例#27
0
 private static bool Prefix(IInspectPane pane) => !State.ModifyPane || InspectPanePlus.DrawTabs(pane);
示例#28
0
 private static void DoTabs(IInspectPane pane)
 {
     try
     {
         float tabsTopY = pane.PaneTopY - 30f;
         float curTabX  = PaneWidthFor(pane) - 72f;
         float leftEdge = 0f;
         bool  drewOpen = false;
         if (pane.CurTabs != null)
         {
             IList list = pane.CurTabs as IList;
             if (list != null)
             {
                 for (int i = 0; i < list.Count; i++)
                 {
                     Do((InspectTabBase)list[i]);
                 }
             }
             else
             {
                 foreach (InspectTabBase curTab in pane.CurTabs)
                 {
                     Do(curTab);
                 }
             }
         }
         if (drewOpen)
         {
             GUI.DrawTexture(new Rect(0f, tabsTopY, leftEdge, 30f), InspectTabButtonFillTex);
         }
         void Do(InspectTabBase tab)
         {
             if (tab.IsVisible)
             {
                 Rect rect = new Rect(curTabX, tabsTopY, 72f, 30f);
                 leftEdge  = curTabX;
                 Text.Font = GameFont.Small;
                 if (Widgets.ButtonText(rect, tab.labelKey.Translate()))
                 {
                     InterfaceToggleTab(tab, pane);
                 }
                 bool num = tab.GetType() == pane.OpenTabType;
                 if (!num && !tab.TutorHighlightTagClosed.NullOrEmpty())
                 {
                     UIHighlighter.HighlightOpportunity(rect, tab.TutorHighlightTagClosed);
                 }
                 if (num)
                 {
                     tab.DoTabGUI();
                     pane.RecentHeight = 700f;
                     drewOpen          = true;
                 }
                 curTabX -= 72f;
             }
         }
     }
     catch (Exception ex)
     {
         Log.ErrorOnce(ex.ToString(), 742783);
     }
 }
示例#29
0
 static void InterfaceToggleTab(InspectTabBase current, IInspectPane pane)
 {
     typeof(RimWorld.InspectPaneUtility).GetMethod("InterfaceToggleTab", AccessTools.all).Invoke(null, new object[] { current, pane });
 }
示例#30
0
 private static bool IsOpen(InspectTabBase tab, IInspectPane pane)
 {
     return(tab.GetType() == pane.OpenTabType);
 }