public static void Draw(Rect rect)
        {
            if (currentProfilerInformation == null || GUIController.CurrentProfiler != null && currentProfilerInformation.Value.method != GUIController.CurrentProfiler.meth)
            {
                GetGeneralSidePanelInformation();
            }

            var statbox = rect;

            statbox.width = Panel_Tabs.width - 10;


            var pRect = rect;

            pRect.x      = statbox.xMax + 10;
            pRect.width -= statbox.xMax;
            pRect.AdjustVerticallyBy(tabRect.height);

            Widgets.DrawMenuSection(statbox);

            Panel_Stats.DrawStats(statbox, currentProfilerInformation);

            Widgets.DrawMenuSection(pRect);

            Text.Font   = GameFont.Tiny;
            Text.Anchor = TextAnchor.MiddleCenter;

            tabRect.width = Mathf.Min(100f, pRect.width / 3f);

            tabRect.x = pRect.x;
            tabRect.y = pRect.y - tabRect.height;
            Drawtab(tabRect, ProfileInfoMode.Graph, "Graph");
            tabRect.x = tabRect.xMax;
            Drawtab(tabRect, ProfileInfoMode.Patches, "Patches");
            tabRect.x = tabRect.xMax;
            Drawtab(tabRect, ProfileInfoMode.StackTrace, "Stacktrace");
            tabRect.x = tabRect.xMax;

            DubGUI.ResetFont();

            switch (ProfileInfoTab)
            {
            case ProfileInfoMode.Graph: graph.Draw(pRect.ContractedBy(1)); break;

            case ProfileInfoMode.Stats: Panel_Stats.DrawStats(pRect, currentProfilerInformation); break;

            case ProfileInfoMode.Patches: Panel_Patches.Draw(pRect, currentProfilerInformation); break;

            case ProfileInfoMode.StackTrace: Panel_StackTraces.Draw(pRect, currentProfilerInformation); break;
            }
        }
Esempio n. 2
0
        public static void Draw(Rect rect, Rect bigRect)
        {
            if (currentProfilerInformation == null || (GUIController.CurrentProfiler != null && currentProfilerInformation.Value.method != GUIController.CurrentProfiler.meth))
            {
                GetGeneralSidePanelInformation();
            }


            var buttonColumn = rect.LeftPartPixels(" + ".GetWidthCached());

            rect.AdjustHorizonallyBy(" + ".GetWidthCached());

            DrawButtonColumn(buttonColumn, rect.width);

            panels[panels.Count - 1].width =
                (panels.Count <= 1) ?
                rect.width :
                rect.width - (panels[panels.Count - 2].xStart + panels[panels.Count - 2].width) - 18;

            for (int i = panels.Count - 1; i >= 0; i--)
            {
                var panel = panels[i];

                var panelRect = new Rect(rect.x + panel.xStart, rect.y, panel.width, rect.height);

                if (i != 0) // Drag Rct
                {
                    var r = new Rect(rect.x + (panel.xStart - Window_Analyzer.DRAGGABLE_RECT_DIM), rect.y, Window_Analyzer.DRAGGABLE_RECT_DIM, rect.height);

                    Widgets.DrawHighlightIfMouseover(r);

                    if (Input.GetMouseButtonDown(0) && Mouse.IsOver(r) && !panel.dragging)
                    {
                        panel.dragging = true;
                    }

                    if (panel.dragging)
                    {
                        var newPos = Event.current.mousePosition.x - (rect.x - Window_Analyzer.DRAGGABLE_RECT_DIM / 2.0f);
                        var delta  = panel.xStart - newPos;
                        panel.xStart         = newPos;
                        panel.width         += delta;
                        panels[i - 1].width -= delta;
                    }

                    if (Input.GetMouseButtonUp(0))
                    {
                        panel.dragging = false;
                    }
                }

                Widgets.DrawMenuSection(panelRect);
                {
                    var topRect = panelRect.TopPartPixels(Text.LineHeight);
                    panelRect.AdjustVerticallyBy(Text.LineHeight);
                    Widgets.DrawLineHorizontal(panelRect.x, panelRect.y, panelRect.width);

                    panelRect = panelRect.ContractedBy(2f);

                    var label = "  " + panel.type.ToString();

                    var leftPartRect = topRect.LeftPartPixels(label.GetWidthCached());
                    Widgets.Label(leftPartRect, label);

                    if (Widgets.ButtonImage(topRect.RightPartPixels(Text.LineHeight), ResourceCache.GUI.Menu))
                    {
                        var enums = typeof(RowName).GetEnumValues();
                        var list  = (from object e in enums select new FloatMenuOption(((RowName)e).ToString(), () =>
                        {
                            panel.type = (RowName)e;
                            panel.graph = panel.type == RowName.Graph ? new Panel_Graph() : null;
                        })).ToList();
                        Find.WindowStack.Add(new FloatMenu(list));
                    }
                }

                panelRect.AdjustVerticallyBy(2f);

                // ALL OF THESE FUNCTIONS MUST HANDLE THE CASE WHERE CURRENTPROFILERINFORMATION IS NULL.

                switch (panel.type)
                {
                case RowName.Graph: panel.graph.Draw(panelRect); break;

                case RowName.Stats: Panel_Stats.DrawStats(panelRect, currentProfilerInformation); break;

                case RowName.Patches: Panel_Patches.Draw(panelRect, currentProfilerInformation); break;

                case RowName.StackTrace: Panel_StackTraces.Draw(panelRect, currentProfilerInformation); break;
                }
            }
        }