/* For Dev Tools */

        public void DrawDevOptions()
        {
            listing.Label("settings.developer.heading".Translate());
            DubGUI.Checkbox("SidePanel".Translate(), listing, ref SidePanel);
            DubGUI.Checkbox("TickPawnTog".Translate(), listing, ref H_PawnTick.TickPawns);
            DubGUI.Checkbox("DevMode".Translate(), listing, ref DevMode);
            if (DevMode)
            {
                DubGUI.InputField(listing.GetRect(Text.LineHeight), "Path to Dnspy.exe (including the exe)", ref PathToDnspy, ShowName: true);
            }

            listing.GapLine();

            Dialog_DeveloperSettings.DrawOptions(listing);
        }
Exemple #2
0
            public static void DisplayUnPatchInputField(Listing_Standard listing)
            {
                string FieldDescription = null;

                switch (unPatchType)
                {
                case UnPatchType.Method: FieldDescription = "Type:Method"; break;

                case UnPatchType.MethodsOnMethod: FieldDescription = "Type:Method"; break;

                case UnPatchType.Type: FieldDescription = "Type"; break;

                case UnPatchType.InternalMethod: FieldDescription = "Type:Method"; break;

                case UnPatchType.All: FieldDescription = "N/A"; break;
                }

                Rect inputBox = listing.GetRect(Text.LineHeight);

                DubGUI.InputField(inputBox, FieldDescription, ref currentUnPatch, ShowName: true);
            }
Exemple #3
0
            public static void DisplayInputField(Listing_Standard listing)
            {
                string FieldDescription = null;

                switch (input)
                {
                case CurrentInput.Method: FieldDescription = "Type:Method"; break;

                case CurrentInput.Type: FieldDescription = "Type"; break;

                case CurrentInput.MethodHarmony: FieldDescription = "Type:Method"; break;

                case CurrentInput.TypeHarmony: FieldDescription = "Type"; break;

                case CurrentInput.InternalMethod: FieldDescription = "Type:Method"; break;

                case CurrentInput.Assembly: FieldDescription = "Mod or PackageId"; break;
                }

                Rect inputBox = listing.GetRect(Text.LineHeight);

                DubGUI.InputField(inputBox, FieldDescription, ref currentInput, ShowName: true);
                //SearchBar.PopulateSearch(inputBox, currentInput, input);
            }
Exemple #4
0
        private void DoThingTab(Rect rect)
        {
            if (!Analyzer.SelectedMode.IsPatched)
            {
                Text.Font   = GameFont.Medium;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(rect, $"Loading{GenText.MarchingEllipsis(0f)}");
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.UpperLeft;
                return;
            }

            var  topslot = rect.TopPartPixels(20f);
            Rect rowby   = topslot.LeftPartPixels(25f);

            if (Widgets.ButtonImage(rowby, TexButton.SpeedButtonTextures[Analyzer.running ? 0 : 1]))
            {
                Analyzer.running = !Analyzer.running;
            }

            TooltipHandler.TipRegion(rowby, "Start and stop logging");
            bool save = false;

            if (Analyzer.Settings.AdvancedMode)
            {
                Rect searchbox = topslot.LeftPartPixels(topslot.width - 300f);
                searchbox.x += 25f;
                DubGUI.InputField(searchbox, "Search", ref TimesFilter, DubGUI.MintSearch);
                rowby.x     = searchbox.xMax;
                rowby.width = 175f;
                if (Widgets.ButtonTextSubtle(rowby, stlank, Mathf.Clamp01(Mathf.InverseLerp(H_RootUpdate.LastMinGC, H_RootUpdate.LastMaxGC, totalBytesOfMemoryUsed)), 5))
                {
                    totalBytesOfMemoryUsed = GC.GetTotalMemory(true);
                }
                TooltipHandler.TipRegion(rowby, "Approximation of total bytes currently allocated in managed memory + rate of new allocation\n\nClick to force GC");

                rowby.x     = rowby.xMax;
                rowby.width = 100f;
                save        = Widgets.ButtonTextSubtle(rowby, "Save .CSV");
                TooltipHandler.TipRegion(rowby, $"Save the current list of times to a csv file in {GenFilePaths.FolderUnderSaveData("Profiling")}");
            }
            else
            {
                Rect searchbox = topslot.RightPartPixels(topslot.width - 25f);
                DubGUI.InputField(searchbox, "Search", ref TimesFilter, DubGUI.MintSearch);
            }

            rowby.x     = rowby.xMax;
            rowby.width = 25f;


            rect.y      += 25f;
            rect.height -= 25f;

            var innyrek = rect.AtZero();

            innyrek.width -= 16f;
            innyrek.height = groaner;

            GizmoListRect    = rect.AtZero();
            GizmoListRect.y += scrolpos.y;
            Widgets.BeginScrollView(rect, ref scrolpos, innyrek);

            GUI.BeginGroup(innyrek);

            listing.Begin(innyrek);

            float goat = 0;

            //List<ProfileLog> logs = null;

            //if (Analyzer.SortBy == "First")
            //{
            //    logs = Analyzer.Logs.ToList();
            //}
            //else if (Analyzer.SortBy == "A-Z")
            //{
            //    logs = Analyzer.Logs.ToList().OrderBy(x => x.Key).ToList();
            //}
            //else if (Analyzer.SortBy == "Usage")
            //{
            //    logs = Analyzer.Logs.ToList().OrderByDescending(x => x.Average).ToList();
            //}

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

            lock (Analyzer.sync)
            {
                foreach (var log in Analyzer.Logs)
                {
                    if (!log.Label.Has(TimesFilter))
                    {
                        continue;
                    }

                    var r = listing.GetRect(40f);

                    if (r.Overlaps(GizmoListRect))
                    {
                        var profile = Analyzer.Profiles[log.Key];

                        if (Input.GetKey(KeyCode.LeftControl))
                        {
                            if (Widgets.ButtonInvisible(r))
                            {
                                Analyzer.SelectedMode.Clicked?.Invoke(null, new object[] { profile, log });
                                Analyzer.Settings.Write();
                            }
                        }

                        bool on = true;

                        if (Analyzer.SelectedMode.Selected != null)
                        {
                            on = (bool)Analyzer.SelectedMode.Selected.Invoke(null, new object[] { profile, log });
                        }

                        if (Analyzer.SelectedMode.Checkbox != null)
                        {
                            var r2 = new Rect(r.x, r.y, 25f, r.height);
                            r.x += 25f;
                            if (DubGUI.Checkbox(r2, "", ref on))
                            {
                                Analyzer.SelectedMode.Checkbox?.Invoke(null, new object[] { profile, log });
                                Analyzer.Settings.Write();
                            }
                        }

                        Widgets.DrawHighlightIfMouseover(r);

                        if (Widgets.ButtonInvisible(r))
                        {
                            Dialog_Graph.RunKey(log.Key);
                        }

                        if (Dialog_Graph.key == log.Key)
                        {
                            Widgets.DrawHighlightSelected(r);
                        }


                        var col = grey;
                        if (log.Percent > 0.25f)
                        {
                            col = blue;
                        }

                        if (log.Percent > 0.75f)
                        {
                            col = red;
                        }


                        Widgets.FillableBar(r.BottomPartPixels(8f), log.Percent, col, clear, false);

                        r = r.LeftPartPixels(50);

                        if (!on)
                        {
                            GUI.color = Color.grey;
                        }

                        Widgets.Label(r, log.Average_s);

                        if (Analyzer.Settings.AdvancedMode)
                        {
                            r.x = r.xMax;

                            Widgets.Label(r, profile.memRiseStr);
                        }

                        r.x     = r.xMax;
                        r.width = 2000;
                        Widgets.Label(r, log.Label);

                        GUI.color = Color.white;

                        if (save)
                        {
                            csv.Append($"{log.Label},{log.Average},{profile.BytesUsed}");
                            foreach (var historyTime in profile.History.times)
                            {
                                csv.Append($",{historyTime}");
                            }
                            csv.AppendLine();
                        }
                    }
                    listing.GapLine(0f);
                    goat += 4f;
                    goat += r.height;
                }
            }

            if (save)
            {
                var path = GenFilePaths.FolderUnderSaveData("Profiling") + $"/{Analyzer.SelectedMode.name}_{DateTime.Now.ToFileTime()}.csv";
                File.WriteAllText(path, csv.ToString());
                csv.Clear();
                Messages.Message($"Saved to {path}", MessageTypeDefOf.TaskCompletion, false);
            }

            listing.End();
            groaner = goat;
            GUI.EndGroup();

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.EndScrollView();
        }
        public void DoSettings(Rect canvas)
        {
            listing.Begin(canvas.ContractedBy(10f));

            var rec = listing.GetRect(24f);

            Widgets.DrawTextureFitted(rec.LeftPartPixels(40f), Gfx.Support, 1f);
            if (Widgets.ButtonText(rec.RightPartPixels(rec.width - 40), "Performance Analyzer Wiki", false, true))
            {
                Application.OpenURL("https://github.com/Dubwise56/Dubs-Performance-Analyzer/wiki");
            }

            rec = listing.GetRect(24f);
            Widgets.DrawTextureFitted(rec.LeftPartPixels(40f), Gfx.disco, 1f);
            if (Widgets.ButtonText(rec.RightPartPixels(rec.width - 40), "Dubs Mods Discord", false, true))
            {
                Application.OpenURL("https://discord.gg/Az5CnDW");
            }

            listing.GapLine();
            listing.Label("Optimizations and fixes");
            DubGUI.Checkbox("Speed up temperature stats (Fixes lots of stutters)", listing,
                            ref Analyzer.Settings.FixGame);
            //   DubGUI.Checkbox("Fix memory leak on beds and room stats", listing, ref Analyzer.Settings.FixBedMemLeak);
            DubGUI.Checkbox("Optimize build roof job scanner", listing, ref Analyzer.Settings.OverrideBuildRoof);
            DubGUI.Checkbox("Override alerts (ctrl click analyzed alerts to kill them)", listing,
                            ref Analyzer.Settings.OverrideAlerts);
            DubGUI.Checkbox("Optimize DrawInspectGizmoGrid (Buttons when selecting things)", listing,
                            ref Analyzer.Settings.OptimizeDrawInspectGizmoGrid);
            var jam = Analyzer.Settings.MeshOnlyBuildings;

            DubGUI.Checkbox("Disable realtime drawing on walls and conduit", listing,
                            ref Analyzer.Settings.MeshOnlyBuildings);
            if (jam != Analyzer.Settings.MeshOnlyBuildings)
            {
                H_FixWallsNConduits.Swapclasses();
            }
            // dirk("Never check jobs on take damage", ref Analyzer.Settings.NeverCheckJobsOnDamage);

            DubGUI.Checkbox("Disable music manager", listing, ref Analyzer.Settings.KillMusicMan);
            //  dirk("Replace bill ingredient finder (Testing only)", ref Analyzer.Settings.ReplaceIngredientFinder);
            //var dan = Analyzer.Settings.HumanoidOnlyWarden;
            //dirk("Replace warden jobs to only scan Humanoids (Testing only)", ref Analyzer.Settings.HumanoidOnlyWarden);
            //if (dan != Analyzer.Settings.HumanoidOnlyWarden)
            //{
            //    H_WardenRequest.Swapclasses();
            //}
            listing.GapLine();
            DubGUI.Checkbox("Show analyzer button on main tabs", listing, ref Analyzer.Settings.ShowOnMainTab);
            //   DubGUI.Checkbox("Mute GC messages", listing, ref Analyzer.Settings.MuteGC);
            DubGUI.Checkbox("Advanced mode (More data)", listing, ref Analyzer.Settings.AdvancedMode);
            DubGUI.Checkbox("Tick Pawns", listing, ref H_PawnTick.TickPawns);
            listing.GapLine();
            if (Analyzer.Settings.AdvancedMode)
            {
                listing.Label("Profile a method e.g. ResourceReadout:ResourceReadoutOnGUI");
                var r = listing.GetRect(25f);
                DubGUI.InputField(r, "Type:Method", ref methToPatch, ShowName: true);
                r = listing.GetRect(25f).LeftPartPixels(150);
                if (Widgets.RadioButtonLabeled(r, "Custom Tick", customPatchMode == UpdateMode.Tick))
                {
                    customPatchMode = UpdateMode.Tick;
                }
                r = listing.GetRect(25f).LeftPartPixels(150);
                if (Widgets.RadioButtonLabeled(r, "Custom Update", customPatchMode == UpdateMode.Update))
                {
                    customPatchMode = UpdateMode.Update;
                }
                var b = listing.GetRect(25);
                if (Widgets.ButtonText(b.LeftPartPixels(100), "Try patch"))
                {
                    if (customPatchMode == UpdateMode.Tick)
                    {
                        CustomProfilersTick.PatchMeth(methToPatch);
                    }
                    else
                    {
                        CustomProfilersUpdate.PatchMeth(methToPatch);
                    }
                }
            }


            listing.End();
        }