Пример #1
0
        public static void Draw(Rect rect)
        {
            var row = rect.LeftPartPixels(25f);

            if (Widgets.ButtonImage(row, TexButton.SpeedButtonTextures[Analyzer.CurrentlyPaused ? 1 : 0]))
            {
                Analyzer.CurrentlyPaused = !Analyzer.CurrentlyPaused;
                GUIController.CurrentEntry.SetActive(!Analyzer.CurrentlyPaused);
            }

            TooltipHandler.TipRegion(row, Strings.top_pause_analyzer);
            rect.AdjustHorizonallyBy(25f);

            row = rect.LeftPartPixels(25);
            if (Widgets.ButtonImage(row, Textures.refresh))
            {
                GUIController.ResetProfilers();
            }

            TooltipHandler.TipRegion(row, Strings.top_refresh);

            var searchbox = rect.LeftPartPixels(rect.width - 300f);

            searchbox.x += 25f;

            DubGUI.InputField(searchbox, Strings.top_search, ref TimesFilter, DubGUI.MintSearch);

            rect.AdjustHorizonallyBy(rect.width - 250f);

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

            var cat = GUIController.CurrentCategory == Category.Tick ? "tick" : "update";
            var str = $"{ProfileController.updateAverage:F3}ms/{cat}";

            var strLen = str.GetWidthCached();

            var periodLen = rect.LeftPartPixels(130);

            rect.AdjustHorizonallyBy(130);

            Widgets.Label(periodLen, str);


            var tpsFpsRect = rect;

            tpsFpsRect.width = 50f;
            Widgets.Label(tpsFpsRect, $"FPS: {GUIElement_TPS.FPS}");
            TooltipHandler.TipRegion(tpsFpsRect, Strings.top_fps_tip);
            tpsFpsRect.x     = tpsFpsRect.xMax + 5;
            tpsFpsRect.width = 90f;
            Widgets.Label(tpsFpsRect, $"TPS: {GUIElement_TPS.TPS}({GUIElement_TPS.TPSTarget})");
            TooltipHandler.TipRegion(tpsFpsRect, Strings.top_tps_tip);
            tpsFpsRect.x     = tpsFpsRect.xMax + 5;
            tpsFpsRect.width = 30f;
            Text.Font        = GameFont.Medium;
        }
Пример #2
0
        public void Draw(Rect rect, GeneralInformation?info)
        {
            if (info == null || info.Value.method == null)
            {
                return;
            }
            currentMethod = info.Value.method as MethodInfo;

            var panelWidth    = Mathf.Clamp(rect.width / 4, 0, 65);
            var leftHandPanel = rect.LeftPartPixels(panelWidth);

            rect.AdjustHorizonallyBy(panelWidth + 4f);
            DrawLeftColumn(leftHandPanel, currentMethod);

            var statusBox = rect.TopPartPixels(30f);

            rect.AdjustVerticallyBy(30f);
            DrawCurrentStatus(statusBox, currentMethod);

            if (currentTrace == 0)
            {
                if (StackTraceUtility.traces.Count > 0)
                {
                    currentTrace = StackTraceUtility.traces.MaxBy(t => t.Value.Count).Key;
                }
            }
            else
            {
                DrawStackTrace(rect, StackTraceUtility.traces[currentTrace]);
            }
        }
        public static void Draw(Rect rect)
        {
            var row = rect.LeftPartPixels(25f);

            if (Widgets.ButtonImage(row, TexButton.SpeedButtonTextures[Analyzer.CurrentlyPaused ? 1 : 0]))
            {
                Analyzer.CurrentlyPaused = !Analyzer.CurrentlyPaused;
                GUIController.CurrentEntry.SetActive(!Analyzer.CurrentlyPaused);
            }

            TooltipHandler.TipRegion(row, Strings.top_pause_analyzer);
            rect.AdjustHorizonallyBy(25f);

            row = rect.LeftPartPixels(25);
            if (Widgets.ButtonImage(row, Textures.refresh))
            {
                GUIController.ResetProfilers();
            }

            TooltipHandler.TipRegion(row, Strings.top_refresh);

            var searchbox = rect.LeftPartPixels(rect.width - 220f);

            searchbox.x += 25f;

            DubGUI.InputField(searchbox, Strings.top_search, ref TimesFilter, DubGUI.MintSearch);
            //    searchbox.x = searchbox.xMax;
            //    searchbox.width = 150;
            //   GUI.color = Color.grey;
            //   Widgets.Label(searchbox, MatchType);
            //   GUI.color = Color.white;


            // bit shitty and distracting, replace with a mini graph and or an entire page dedicated to garbage if it even matters realistically now which it probably doesn't so why bother aye just keep it clean
            //row.x = searchbox.xMax + 5;
            // row.width = 130f;
            //Text.Anchor = TextAnchor.MiddleCenter;
            //Widgets.FillableBar(row, Mathf.Clamp01(Mathf.InverseLerp(H_RootUpdate.LastMinGC, H_RootUpdate.LastMaxGC, H_RootUpdate.totalBytesOfMemoryUsed)), Textures.darkgrey);
            //Widgets.Label(row, H_RootUpdate.GarbageCollectionInfo);
            //TooltipHandler.TipRegion(row, Strings.top_gc_tip);

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

            row.width = 50f;
            row.x     = searchbox.xMax + 10;
            Widgets.Label(row, $"FPS: {GUIElement_TPS.FPS}");
            TooltipHandler.TipRegion(row, Strings.top_fps_tip);
            row.x     = row.xMax + 5;
            row.width = 90f;
            Widgets.Label(row, $"TPS: {GUIElement_TPS.TPS}({GUIElement_TPS.TPSTarget})");
            TooltipHandler.TipRegion(row, Strings.top_tps_tip);
            row.x     = row.xMax + 5;
            row.width = 30f;
            Text.Font = GameFont.Medium;
        }
Пример #4
0
        private static void DrawColumnHeader(ref Rect inRect, string name, string desc, SortBy value, float width)
        {
            if (!columns[(int)value]) // If our column is currently collapsed
            {
                if (value != SortBy.Name)
                {
                    width = ARBITRARY_CLOSED_OFFSET;
                }
                name = "";
            }

            var rect = inRect.LeftPartPixels(width);

            Widgets.Label(rect, name);

            if (Analyzer.SortBy == value)
            {
                Widgets.DrawHighlight(rect);
            }

            if (Widgets.ButtonInvisible(rect))
            {                                  // sort by 'max'
                if (Event.current.button == 0) // left click, change sort by
                {
                    if (Analyzer.SortBy == value)
                    {
                        Analyzer.SortBy = DEFAULT_SORTBY;
                    }
                    else
                    {
                        Analyzer.SortBy = value;
                    }
                }
                else // middle / right, close the tab
                {
                    columns[(int)value] = !columns[(int)value];
                }
            }
            TooltipHandler.TipRegion(rect, desc);

            if (value != SortBy.Name)
            {
                inRect.AdjustHorizonallyBy(width);

                Widgets.DrawLineVertical(inRect.x, rect.y, rect.height);
            }
        }
Пример #5
0
        public static void Draw(Rect rect)
        {
            Rect row = rect.LeftPartPixels(25f);

            if (Widgets.ButtonImage(row, TexButton.SpeedButtonTextures[Analyzer.CurrentlyPaused ? 1 : 0]))
            {
                Analyzer.CurrentlyPaused = !Analyzer.CurrentlyPaused;
                GUIController.CurrentEntry.SetActive(!Analyzer.CurrentlyPaused);
            }

            TooltipHandler.TipRegion(row, ResourceCache.Strings.top_pause_analyzer);
            rect.AdjustHorizonallyBy(25f);

            row = rect.LeftPartPixels(25);
            if (Widgets.ButtonImage(row, ResourceCache.GUI.refresh))
            {
                GUIController.ResetProfilers();
            }

            TooltipHandler.TipRegion(row, ResourceCache.Strings.top_refresh);

            Rect searchbox = rect.LeftPartPixels(rect.width - 350f);

            searchbox.x += 25f;
            DubGUI.InputField(searchbox, ResourceCache.Strings.top_search, ref TimesFilter, DubGUI.MintSearch);
            row.x       = searchbox.xMax + 5;
            row.width   = 130f;
            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Tiny;
            Widgets.FillableBar(row, Mathf.Clamp01(Mathf.InverseLerp(H_RootUpdate.LastMinGC, H_RootUpdate.LastMaxGC, H_RootUpdate.totalBytesOfMemoryUsed)), ResourceCache.GUI.darkgrey);
            Widgets.Label(row, H_RootUpdate.GarbageCollectionInfo);
            Text.Anchor = TextAnchor.UpperLeft;
            TooltipHandler.TipRegion(row, ResourceCache.Strings.top_gc_tip);

            row.x     = row.xMax + 5;
            row.width = 50f;
            Widgets.Label(row, "FPS: " + GUIElement_TPS.FPS.ToString());
            TooltipHandler.TipRegion(row, ResourceCache.Strings.top_fps_tip);
            row.x     = row.xMax + 5;
            row.width = 90f;
            Widgets.Label(row, "TPS: " + GUIElement_TPS.TPS.ToString() + "(" + GUIElement_TPS.TPSTarget.ToString() + ")");
            TooltipHandler.TipRegion(row, ResourceCache.Strings.top_tps_tip);
            row.x     = row.xMax + 5;
            row.width = 30f;
            Text.Font = GameFont.Medium;
        }
        private static bool ToggleColCombo(Rect rect, string str, bool enabled, Color setcol, Action ac)
        {
            rect.y += 4;
            rect.height -= 8;

            GUI.color = Color.grey * 0.7f;
            Widgets.DrawBox(rect);
            GUI.color = Color.white;

            var iconRect = rect.LeftPartPixels(20f);
            iconRect.height = 10;
            iconRect.x += 5;
            iconRect.width -= 10;
            iconRect.y += rect.height / 2.0f - 5f;
            rect.AdjustHorizonallyBy(20f);
            DisplayColorPicker(iconRect, setcol, ac);
            return DrawButton(rect, str, enabled, false);
        }
Пример #7
0
        private static void DrawButton(Panel_Graph instance, Rect rect, string str, int idx)
        {
            var iconRect = rect.LeftPartPixels(20f);

            iconRect.height = 10;
            iconRect.x     += 5;
            iconRect.width -= 10;
            iconRect.y     += (rect.height / 2.0f) - 5f;
            rect.AdjustHorizonallyBy(20f);

            DisplayColorPicker(iconRect, idx);

            if (idx == 0 && !instance.times.visible)
            {
                GUI.color = Color.grey;
            }
            else if (idx == 1 && !instance.calls.visible)
            {
                GUI.color = Color.grey;
            }

            Widgets.Label(rect, str);

            GUI.color = Color.white;

            if (idx == 2)
            {
                return;
            }

            if (Widgets.ButtonInvisible(rect))
            {
                if (idx == 0)
                {
                    instance.times.visible = !instance.times.visible;
                }
                else
                {
                    instance.calls.visible = !instance.calls.visible;
                }
            }

            Widgets.DrawHighlightIfMouseover(rect);
        }
        private static void DrawColumnHeader(ref Rect inRect, Column c)
        {
            Widgets.DrawOptionBackground(inRect, false);

            var rect = inRect.LeftPartPixels(NUMERIC_WIDTH);

            if (c.total != 0)
            {
                Widgets.Label(rect.TopHalf(), c.Name);
                Widgets.Label(rect.BottomHalf(), $"{c.total:0.000}ms");
            }
            else
            {
                Widgets.Label(rect, (c.sortBy == SortBy.Name ? "    " : "") + c.Name);
            }

            if (Analyzer.SortBy == c.sortBy)
            {
                Widgets.DrawHighlight(rect);
            }

            if (Widgets.ButtonInvisible(rect))
            {
                if (Event.current.button == 0) // left click, change sort by
                {
                    Analyzer.SortBy = Analyzer.SortBy == c.sortBy ? DEFAULT_SORTBY : c.sortBy;
                }
            }

            TooltipHandler.TipRegion(rect, c.Desc);

            if (c.sortBy != SortBy.Name)
            {
                inRect.AdjustHorizonallyBy(NUMERIC_WIDTH);

                GUI.color = Color.grey;
                Widgets.DrawLineVertical(inRect.x, rect.y, rect.height);
                GUI.color = Color.white;
            }
        }
Пример #9
0
        // Vertical strip along the top of the UI informing the user of the current
        // status of the patching
        private void DrawCurrentStatus(Rect statusBox, MethodInfo method)
        {
            const string activeTemplate          = "Tracing; {0:#,##0.##} traces collected";
            const string idleTemplate            = "Idle";
            const string inactiveTemplate        = "Finished; {0:#,##0.##} traces collected";
            const string traceInformationTempate = "Calls: {0:#,##0.##} ({1:P}), Mods Involved {2}  ";

            var status = "";

            if (currentlyTracking)
            {
                status = string.Format(activeTemplate, currentTrackedStacktraces);
            }
            else
            {
                status = currentTrackedStacktraces != 0
                    ? string.Format(inactiveTemplate, currentTrackedStacktraces)
                    : string.Format(idleTemplate);
            }

            var statusWidth       = status.GetWidthCached();
            var tracingStatusRect = statusBox.LeftPartPixels(statusWidth);

            statusBox.AdjustHorizonallyBy(statusWidth);
            Widgets.Label(tracingStatusRect, status);

            var ct = CurrentTrace;

            if (ct == null)
            {
                return;
            }

            var modsInvolved = CurrentTrace.Methods.Sum(st => st.Patches);

            status = string.Format(traceInformationTempate, ct.Count, ct.Count / (float)currentTrackedStacktraces, modsInvolved);
            Widgets.Label(statusBox.RightPartPixels(status.GetWidthCached()), status);
        }
Пример #10
0
        private static void DrawColumnHeader(ref Rect inRect, string name, string desc, SortBy value, float width, string totalReadout = "")
        {
            bool closed = false;

            if (!columns[(int)value]) // If our column is currently collapsed
            {
                if (value != SortBy.Name)
                {
                    width = ARBITRARY_CLOSED_OFFSET;
                }
                closed = true;
            }

            Widgets.DrawOptionBackground(inRect, false);

            var rect = inRect.LeftPartPixels(width);

            if (closed is false)
            {
                //  Text.Font = GameFont.Small;
                Widgets.Label(rect.TopHalf(), name);
                if (totalReadout != string.Empty)
                {
                    // Text.Font = GameFont.Tiny;
                    Widgets.Label(rect.BottomHalf(), totalReadout);
                }
            }

            if (Analyzer.SortBy == value)
            {
                Widgets.DrawHighlight(rect);
            }

            if (Widgets.ButtonInvisible(rect))
            {                                  // sort by 'max'
                if (Event.current.button == 0) // left click, change sort by
                {
                    if (Analyzer.SortBy == value)
                    {
                        Analyzer.SortBy = DEFAULT_SORTBY;
                    }
                    else
                    {
                        Analyzer.SortBy = value;
                    }
                }
                else // middle / right, close the tab
                {
                    columns[(int)value] = !columns[(int)value];
                }
            }
            TooltipHandler.TipRegion(rect, desc);

            if (value != SortBy.Name)
            {
                inRect.AdjustHorizonallyBy(width);

                GUI.color = Color.grey;
                Widgets.DrawLineVertical(inRect.x, rect.y, rect.height);
                GUI.color = Color.white;
            }
        }
Пример #11
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;
                }
            }
        }