Пример #1
0
        public override void PreOpen()
        {
            if (Analyzer.CurrentlyCleaningUp)
            {
                Find.WindowStack.TryRemove(this);
                ThreadSafeLogger.Error("[Analyzer] Analyzer is currently in the process of cleaning up - This is unlikely to happen, and shouldn't take long. please attempt to re-open the window in a couple seconds");
                return;
            }

            base.PreOpen();

            if (firstOpen)             // If we have not been opened yet, load all our entries
            {
                LoadEntries();
                firstOpen = false;
            }

            Analyzer.BeginProfiling();

            if (Modbase.isPatched)
            {
                return;
            }


            Modbase.Harmony.Patch(AccessTools.Method(typeof(Root_Play), nameof(Root_Play.Update)),
                                  prefix: new HarmonyMethod(typeof(H_RootUpdate), nameof(H_RootUpdate.Prefix)),
                                  postfix: new HarmonyMethod(typeof(H_RootUpdate), nameof(H_RootUpdate.Postfix)));

            Modbase.Harmony.Patch(AccessTools.Method(typeof(TickManager), nameof(TickManager.DoSingleTick)),
#if DEBUG
                                  prefix: new HarmonyMethod(typeof(H_DoSingleTickUpdate), nameof(H_DoSingleTickUpdate.Prefix)),
#endif
                                  postfix: new HarmonyMethod(typeof(H_DoSingleTickUpdate), nameof(H_DoSingleTickUpdate.Postfix)));

            Modbase.isPatched = true;

            if (Settings.SavedPatches_Tick == null)
            {
                Settings.SavedPatches_Tick   = new HashSet <string>();
                Settings.SavedPatches_Update = new HashSet <string>();
            }
            foreach (var patch in Settings.SavedPatches_Tick)
            {
                Panel_DevOptions.ExecutePatch(CurrentInput.Method, patch, Category.Tick);
            }
            foreach (var patch in Settings.SavedPatches_Update)
            {
                Panel_DevOptions.ExecutePatch(CurrentInput.Method, patch, Category.Update);
            }
        }
Пример #2
0
        /* For Dev Tools */

        public static void DrawDevOptions(float height)
        {
            DubGUI.InputField(listing.GetRect(Text.LineHeight), ResourceCache.Strings.settings_dnspy, ref Settings.PathToDnspy, ShowName: true);
            DubGUI.LabeledSliderFloat(listing, ResourceCache.Strings.settings_updates_per_second, ref Settings.updatesPerSecond, 1.0f, 20.0f);
            DubGUI.Checkbox(ResourceCache.Strings.settings_logging, listing, ref Settings.verboseLogging);
            DubGUI.Checkbox(ResourceCache.Strings.settings_disable_tps_counter, listing, ref Settings.disableTPSCounter);

            var s    = ResourceCache.Strings.settings_disable_cleanup;
            var size = Mathf.CeilToInt(s.GetWidthCached() / listing.ColumnWidth) * Text.LineHeight;
            var rect = listing.GetRect(size);

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

            listing.GapLine();

            Panel_DevOptions.Draw(listing, height);
        }
        public static void Draw(Rect rect, bool settingsPage = false)
        {
            rect         = rect.Rounded();
            rect.height -= 32;
            rect.y      += 32;
            Widgets.DrawMenuSection(rect);

            var list = new List <TabRecord>();

            list.Add(new TabRecord("settings.performance".Translate(), delegate
            {
                currentTab = 0;
                Modbase.Settings.Write();
            }, currentTab == 0));
            list.Add(new TabRecord("settings.developer".Translate(), delegate
            {
                currentTab = 1;
                Modbase.Settings.Write();
            }, currentTab == 1));

            TabDrawer.DrawTabs(rect, list);

            rect = rect.ContractedBy(10);

            listing.maxOneColumn = true;
            var innyrek = new Rect(0, 0, rect.width - 16f, listheight);

            if (innyrek.width < 400)
            {
                innyrek.width = 400;
            }
            Widgets.BeginScrollView(rect, ref scrollPos, innyrek);

            listing.Begin(innyrek);

            var rec  = listing.GetRect(24f);
            var lrec = rec.LeftHalf();

            rec = rec.RightHalf();
            Widgets.DrawTextureFitted(lrec.LeftPartPixels(40f), Textures.Support, 1f);
            lrec.x += 40;
            if (Widgets.ButtonText(lrec.LeftPartPixels(Strings.settings_wiki.GetWidthCached()),
                                   Strings.settings_wiki, false))
            {
                Application.OpenURL("https://github.com/simplyWiri/Dubs-Performance-Analyzer/blob/master/README.md");
            }

            Widgets.DrawTextureFitted(rec.RightPartPixels(40f), Textures.disco, 1f);
            rec.width -= 40;
            if (Widgets.ButtonText(rec.RightPartPixels(Strings.settings_discord.GetWidthCached()),
                                   Strings.settings_discord, false))
            {
                Application.OpenURL("https://discord.gg/Az5CnDW");
            }

            listing.GapLine();

            if (currentTab == 0)
            {
                PerformancePatches.Draw(listing);
            }
            else
            {
                Panel_DevOptions.Draw(listing, rect, settingsPage);
            }

            listheight = listing.curY;
            listing.End();
            Widgets.EndScrollView();
        }