public static void Checkbox(ref Rect rect, ProfileLog log, Profiler profile, ref bool active)
        {
            var checkboxRect = new Rect(rect.x, rect.y, 25f, rect.height);

            rect.x += 25f;
            if (DubGUI.Checkbox(checkboxRect, "", ref active))
            {
                GUIController.CurrentEntry.checkBox.Invoke(null, new object[] { log });
                Modbase.Settings.Write();
            }
        }
        private static float DrawCheckbox(ref Rect rect, MethodInfo meth)
        {
            var checkBoxWidth = 30.0f + $"Enable for {meth.Name}".GetWidthCached();
            var checkBox      = rect.LeftPartPixels(checkBoxWidth);

            if (DubGUI.Checkbox(checkBox, $"Enable for {meth.Name}", ref currentlyTracking))
            {
                if (currentlyTracking)
                {
                    Modbase.Harmony.Patch(meth, postfix: new HarmonyMethod(postfix));
                    StackTraceRegex.Reset();
                    currentTrace = "";
                    currentTrackedStacktraces = 0;
                }
                else
                {
                    Modbase.Harmony.CreateProcessor(meth).Unpatch(postfix);
                }
            }

            return(checkBoxWidth);
        }
示例#3
0
        private static void DrawSettings(Panel_Graph instance, ref Rect position)
        {
            // [ - Calls ] [ - Times ] [ Lines ] [ Entries ------ ] [ - Bg Col ]

            var width         = position.width;
            var currentHeight = 32;
            var currentSlice  = position.TopPartPixels(currentHeight);

            position.AdjustVerticallyBy(currentHeight);

            Text.Anchor = TextAnchor.MiddleCenter;

            // [ - Times ]
            var str          = " Times ";
            var contentWidth = 20 + str.GetWidthCached();
            var rect         = currentSlice.LeftPartPixels(contentWidth);

            currentSlice.AdjustHorizonallyBy(contentWidth);

            DrawButton(instance, rect, " Times ", 0);

            // [ - Calls ]
            str          = " Calls ";
            contentWidth = 20 + str.GetWidthCached();
            rect         = currentSlice.LeftPartPixels(contentWidth);
            currentSlice.AdjustHorizonallyBy(contentWidth);

            DrawButton(instance, rect, " Calls ", 1);

            // [ - Background ]
            str          = " Background ";
            contentWidth = 20 + str.GetWidthCached();
            rect         = currentSlice.LeftPartPixels(contentWidth);
            currentSlice.AdjustHorizonallyBy(contentWidth);

            DrawButton(instance, rect, " Background ", 2);

            Text.Anchor = TextAnchor.UpperLeft;

            // [ - Entries ]
            contentWidth = 150;
            if (currentSlice.width < contentWidth)
            {
                currentSlice = position.TopPartPixels(currentHeight);
                position.AdjustVerticallyBy(currentHeight);
            }

            rect = currentSlice.LeftPartPixels(contentWidth);
            instance.entryCount = (int)Widgets.HorizontalSlider(rect.BottomPartPixels(30f), instance.entryCount, 10, 2000, true, string.Intern($"{instance.entryCount} Entries  "));

            currentSlice.AdjustHorizonallyBy(contentWidth);


            Text.Anchor = TextAnchor.MiddleCenter;

            // [ - Show Axis ]
            str          = " Axis";
            contentWidth = str.GetWidthCached() + 30;
            if (currentSlice.width < contentWidth)
            {
                currentSlice = position.TopPartPixels(currentHeight);
                position.AdjustVerticallyBy(currentHeight);
            }

            rect = currentSlice.LeftPartPixels(contentWidth);
            DubGUI.Checkbox(rect, str, ref GraphSettings.showAxis);
            currentSlice.AdjustHorizonallyBy(contentWidth);

            // [ - Show Grid ]
            str          = " Grid " + 30;
            contentWidth = str.GetWidthCached();
            if (currentSlice.width < contentWidth)
            {
                currentSlice = position.TopPartPixels(currentHeight);
                position.AdjustVerticallyBy(currentHeight);
            }

            rect = currentSlice.LeftPartPixels(contentWidth);
            DubGUI.Checkbox(rect, str, ref GraphSettings.showGrid);
            currentSlice.AdjustHorizonallyBy(contentWidth);

            // [ - Show Max ]
            str          = " Max ";
            contentWidth = str.GetWidthCached() + 30;
            if (currentSlice.width < contentWidth)
            {
                currentSlice = position.TopPartPixels(currentHeight);
                position.AdjustVerticallyBy(currentHeight);
            }

            rect = currentSlice.LeftPartPixels(contentWidth);
            DubGUI.Checkbox(rect, str, ref GraphSettings.showMax);
            currentSlice.AdjustHorizonallyBy(contentWidth);

            // [ - Aliasing ]
            str          = " Aliasing: " + (GraphSettings.lineAliasing == 0 ? "none" : GraphSettings.lineAliasing.ToString()) + " ";
            contentWidth = str.GetWidthCached();
            if (currentSlice.width < contentWidth)
            {
                currentSlice = position.TopPartPixels(currentHeight);
                position.AdjustVerticallyBy(currentHeight);
            }

            rect = currentSlice.LeftPartPixels(contentWidth);
            if (Widgets.ButtonText(rect, str, false))
            {
                GraphSettings.lineAliasing = GraphSettings.lineAliasing switch
                {
                    7.5f => 12.5f,
                    12.5f => 0.0f,
                    0.0f => 5.0f,
                    5.0f => 7.5f,
                    _ => 0.0f
                };
            }

            currentSlice.AdjustHorizonallyBy(contentWidth);

            Text.Anchor = TextAnchor.UpperLeft;
        }
示例#4
0
        private static void DrawEntry(ref Rect row, KeyValuePair <Entry, Type> entry)
        {
            row = listing.GetRect(30f);
            Widgets.DrawHighlightIfMouseover(row);

            if (GUIController.CurrentEntry == entry.Key)
            {
                Widgets.DrawOptionSelected(row);
            }

            row.x   += 20f;
            yOffset += 30f;

            Widgets.Label(row, entry.Key.name);

            if (Widgets.ButtonInvisible(row))
            {
                GUIController.SwapToEntry(entry.Key.name);
            }

            if (entry.Key.isClosable)
            {
                if (Input.GetMouseButtonDown(1) && row.Contains(Event.current.mousePosition))
                {
                    List <FloatMenuOption> options = new List <FloatMenuOption>()
                    {
                        new FloatMenuOption("Close", () => GUIController.RemoveEntry(entry.Key.name))
                    };
                    Find.WindowStack.Add(new FloatMenu(options));
                }
            }

            TooltipHandler.TipRegion(row, entry.Key.tip);

            if (GUIController.CurrentEntry == entry.Key)
            {
                bool firstEntry = true;
                foreach (KeyValuePair <FieldInfo, Setting> keySetting in entry.Key.Settings)
                {
                    if (keySetting.Key.FieldType == typeof(bool))
                    {
                        row       = listing.GetRect(30f);
                        row.x    += 20f;
                        GUI.color = Widgets.OptionSelectedBGBorderColor;
                        Widgets.DrawLineVertical(row.x, row.y, 15f);

                        if (!firstEntry)
                        {
                            Widgets.DrawLineVertical(row.x, row.y - 15f, 15f);
                        }

                        row.x += 10f;
                        Widgets.DrawLineHorizontal(row.x - 10f, row.y + 15f, 10f);
                        GUI.color = Color.white;
                        yOffset  += 30f;

                        bool cur = (bool)keySetting.Key.GetValue(null);

                        if (DubGUI.Checkbox(row, keySetting.Value.name, ref cur))
                        {
                            keySetting.Key.SetValue(null, cur);

                            GUIController.ResetProfilers();
                        }
                    }

                    if (keySetting.Value.tip != null)
                    {
                        TooltipHandler.TipRegion(row, keySetting.Value.tip);
                    }

                    firstEntry = false;
                }
            }
        }
示例#5
0
        public static void Draw(Listing_Standard listing, Rect win)
        {
            listing.Label(Strings.settings_dnspy);
            Settings.PathToDnspy = listing.TextEntry(Settings.PathToDnspy);
            listing.Gap();
            DubGUI.LabeledSliderFloat(listing, Strings.settings_updates_per_second, ref Settings.updatesPerSecond, 1.0f, 20.0f);
            DubGUI.Checkbox(Strings.settings_logging, listing, ref Settings.verboseLogging);
            DubGUI.Checkbox(Strings.settings_disable_tps_counter, listing, ref Settings.disableTPSCounter);
            DubGUI.Checkbox("settings.debuglog".Tr(), listing, ref Settings.enableLog);

            var s    = Strings.settings_disable_cleanup;
            var rect = listing.GetRect(Text.LineHeight);

            DubGUI.Checkbox(rect, s, ref Settings.disableCleanup);
            TooltipHandler.TipRegion(rect, Strings.settings_disable_cleanup_desc);

            listing.GapLine();

            DubGUI.CenterText(() => listing.Label("devoptions.heading".Tr()));
            listing.GapLine();

            var tabs = listing.GetRect(tabRect.height);

            tabs.width = tabRect.width;

            Drawtab(tabs, 0, "Patch Tools");
            tabs.x = tabs.xMax;
            Drawtab(tabs, 1, $"Saved Patches ({Settings.SavedPatches_Tick.Count + Settings.SavedPatches_Update.Count})");
            listing.Gap(4);
            if (PatchTab == 0)
            {
                if (listing.ButtonTextLabeled("Logging cycle", patchType.ToString()))
                {
                    if (patchType == Category.Tick)
                    {
                        patchType = Category.Update;
                    }
                    else
                    {
                        patchType = Category.Tick;
                    }
                    //For if onGui gets added
                    //var list = new List<FloatMenuOption>
                    //{
                    //    new FloatMenuOption("devoptions.patchtype.tick".Tr(), () => patchType = Category.Tick),
                    //    new FloatMenuOption("devoptions.patchtype.update".Tr(), () => patchType = Category.Update)
                    //    new FloatMenuOption("devoptions.patchtype.ongui".Tr(), () => patchType = Category.OnGui)
                    //};
                    //Find.WindowStack.Add(new FloatMenu(list));
                }

                if (showSearchbox)
                {
                    Window_SearchBar.Control();
                }
                var inputR = DisplayInputField(listing);

                Window_SearchBar.SetCurrentInput(input);
                Window_SearchBar.UpdateSearchString(currentInput);

                var searchRect = listing.GetRect(Mathf.Min(listing.curY, win.height - listing.curY));

                lock (Window_SearchBar.sync)
                {
                    if (showSearchbox && !Mouse.IsOver(searchRect) && Event.current.type != EventType.MouseDown)
                    {
                        showSearchbox = false;
                    }
                    if (GUI.GetNameOfFocusedControl() == "profileinput")
                    {
                        showSearchbox = true;
                    }
                    else
                    if (Mouse.IsOver(inputR))
                    {
                        showSearchbox = true;
                    }
                }

                if (showSearchbox)
                {
                    Window_SearchBar.DoWindowContents(searchRect);
                }
            }
            else
            {
                foreach (var patch in Settings.SavedPatches_Tick.ToList())
                {
                    var row = listing.GetRect(Text.LineHeight);
                    if (Widgets.CloseButtonFor(row.LeftPartPixels(30f)))
                    {
                        Settings.SavedPatches_Tick.Remove(patch);
                    }
                    Widgets.Label(row.RightPartPixels(row.width - 30f), patch + " Tick");
                    listing.GapLine();
                }
                foreach (var patch in Settings.SavedPatches_Update.ToList())
                {
                    var row = listing.GetRect(Text.LineHeight);
                    if (Widgets.CloseButtonFor(row.LeftPartPixels(30f)))
                    {
                        Settings.SavedPatches_Update.Remove(patch);
                    }
                    Widgets.Label(row.RightPartPixels(row.width - 30f), patch + " Update");
                    listing.GapLine();
                }
            }
        }