public Modbase(ModContentPack content) : base(content) { Settings = GetSettings <Settings>(); ThreadSafeLogger.Message($"[Analyzer] Loaded version {analyzerVersion.Major}.{analyzerVersion.Minor}.{analyzerVersion.Build} rev {analyzerVersion.Revision}"); { // Profiling ModInfoCache.PopulateCache(Content.Name); GUIController.InitialiseTabs(); // GUI needs to be initialised before xml (the tabs need to exist for entries to be inserted into them) XmlParser.CollectXmlData(); } { // Always Running StaticHarmony.Patch(AccessTools.Method(typeof(GlobalControlsUtility), nameof(GlobalControlsUtility.DoTimespeedControls)), prefix: new HarmonyMethod(typeof(GUIElement_TPS), nameof(GUIElement_TPS.Prefix))); } { // Performance Patches PerformancePatches.InitialisePatches(); } #if DEBUG ThreadSafeLogger.Warning("=========================================================================="); ThreadSafeLogger.Warning(" Analyzer Running In Debug Mode "); ThreadSafeLogger.Warning("=========================================================================="); #endif }
// Performance Settings are held in the type which implements the optimisation public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref GraphSettings.lineAliasing, "lineAliasing", 7.5f); Scribe_Values.Look(ref GraphSettings.showMax, "showMax"); Scribe_Values.Look(ref GraphSettings.showAxis, "showAxis", true); Scribe_Values.Look(ref GraphSettings.showGrid, "showGrid", true); Scribe_Values.Look(ref timeColour, "timeColour", new Color32(79, 147, 191, 255)); Scribe_Values.Look(ref callsColour, "callsColour", new Color32(10, 10, 255, 255)); Scribe_Values.Look(ref GraphCol, "GraphCol", new Color32(17, 17, 17, 255)); Scribe_Values.Look(ref PathToDnspy, "dnspyPath"); Scribe_Values.Look(ref updatesPerSecond, "updatesPerSecond", 2); Scribe_Values.Look(ref verboseLogging, "verboseLogging"); Scribe_Values.Look(ref disableCleanup, "disableCleanup"); Scribe_Values.Look(ref disableTPSCounter, "disableTPSCounter"); Scribe_Collections.Look(ref SavedPatches_Update, "SavedPatches_Update"); Scribe_Collections.Look(ref SavedPatches_Tick, "SavedPatches_Tick"); // We save/load all performance-related settings here. PerformancePatches.ExposeData(); }
// Performance Settings are held in the type which implements the optimisation public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref GraphSettings.showMax, "showMax"); Scribe_Values.Look(ref GraphSettings.showAxis, "showAxis", true); Scribe_Values.Look(ref GraphSettings.showGrid, "showGrid", true); Scribe_Collections.Look(ref Panel_Logs.columns, "columnSettings"); Scribe_Values.Look(ref timeColour, "timeColour", new Color32(79, 147, 191, 255)); Scribe_Values.Look(ref callsColour, "callsColour", new Color32(10, 10, 255, 255)); Scribe_Values.Look(ref GraphCol, "GraphCol", new Color32(17, 17, 17, 255)); Scribe_Values.Look(ref PathToDnspy, "dnspyPath"); Scribe_Values.Look(ref updatesPerSecond, "updatesPerSecond", 2); Scribe_Values.Look(ref verboseLogging, "verboseLogging"); Scribe_Values.Look(ref disableCleanup, "disableCleanup"); Scribe_Values.Look(ref disableTPSCounter, "disableTPSCounter"); Scribe_Values.Look(ref enableLog, "enableDebugLog", false); Scribe_Values.Look(ref showIcon, "showMainTabIcon", true); Scribe_Values.Look(ref longFormNames, "longFormNames", false); Scribe_Collections.Look(ref SavedPatches_Update, "SavedPatches_Update"); Scribe_Collections.Look(ref SavedPatches_Tick, "SavedPatches_Tick"); // We save/load all performance-related settings here. PerformancePatches.ExposeData(); }
public GameComponent_Analyzer(Game game) { this.game = game; // On game load, initialise the currently active performance patches PerformancePatches.ActivateEnabledPatches(); FixPatches.OnGameInit(game); }
public static void Draw(Rect rect, bool settingsPage = false) { if (settingsPage) { currentTab = 0; } else { rect.y += 35; List <TabRecord> 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, 500f); } Rect view = rect.AtZero(); view.height = rect.height; Widgets.BeginScrollView(rect, ref scrollPos, view, false); GUI.BeginGroup(view); view.height = 9999; listing.Begin(view.ContractedBy(10f)); // Draw the github and discord textures / Icons Rect rec = listing.GetRect(24f); Rect lrec = rec.LeftHalf(); rec = rec.RightHalf(); Widgets.DrawTextureFitted(lrec.LeftPartPixels(40f), ResourceCache.GUI.Support, 1f); lrec.x += 40; if (Widgets.ButtonText(lrec.LeftPartPixels(ResourceCache.Strings.settings_wiki.GetWidthCached()), ResourceCache.Strings.settings_wiki, false, true)) { Application.OpenURL("https://github.com/Dubwise56/Dubs-Performance-Analyzer/wiki"); } Widgets.DrawTextureFitted(rec.RightPartPixels(40f), ResourceCache.GUI.disco, 1f); rec.width -= 40; if (Widgets.ButtonText(rec.RightPartPixels(ResourceCache.Strings.settings_discord.GetWidthCached()), ResourceCache.Strings.settings_discord, false, true)) { Application.OpenURL("https://discord.gg/Az5CnDW"); } listing.GapLine(6f); switch (currentTab) { case 0: PerformancePatches.Draw(ref listing); FixPatches.Draw(listing); break; case 1: DrawDevOptions(rect.height); break; } listing.End(); GUI.EndGroup(); Widgets.EndScrollView(); }
public override void WriteSettings() { base.WriteSettings(); // Any patches we had pending closing are now going to get closed PerformancePatches.ClosePatches(); }
public Modbase(ModContentPack content) : base(content) { try { Settings = GetSettings <Settings>(); ThreadSafeLogger.Message($"[Analyzer] Loaded version {analyzerVersion.Major}.{analyzerVersion.Minor}.{analyzerVersion.Build} rev {analyzerVersion.Revision}"); staticHarmony = new Harmony("Dubwise.PerformanceAnalyzer"); harmony = new Harmony("Dubwise.DubsProfiler");; if (ModLister.HasActiveModWithName("Visual Exceptions")) { var type = AccessTools.TypeByName("VisualExceptions.ExceptionState"); var field = AccessTools.Field(type, "configuration"); type = AccessTools.TypeByName("VisualExceptions.Configuration"); var property = AccessTools.PropertyGetter(type, "Debugging"); visualExceptionIntegration = (bool)property.Invoke(field.GetValue(null), null); var str = "Detected Visual Exceptions - " + (visualExceptionIntegration ? "Integrating" : "Is disabled, relying on inbuilt functionality"); ThreadSafeLogger.Message(str); } if (visualExceptionIntegration is false) { // For registering harmony patches StaticHarmony.Patch(AccessTools.Constructor(typeof(Harmony), new[] { typeof(string) }), new HarmonyMethod(typeof(RememberHarmonyIDs), nameof(RememberHarmonyIDs.Prefix))); if (ModLister.HasActiveModWithName("HugsLib")) { StaticHarmony.Patch(AccessTools.Method("HugsLib.ModBase:ApplyHarmonyPatches"), transpiler: new HarmonyMethod(typeof(RememberHarmonyIDs), nameof(RememberHarmonyIDs.Transpiler))); } } { // Profiling ModInfoCache.PopulateCache(Content.Name); GUIController.InitialiseTabs(); // GUI needs to be initialised before xml (the tabs need to exist for entries to be inserted into them) XmlParser.CollectXmlData(); StackTraceUtility.Initialise(); } { // Always Running StaticHarmony.Patch( AccessTools.Method(typeof(GlobalControlsUtility), nameof(GlobalControlsUtility.DoTimespeedControls)), prefix: new HarmonyMethod(typeof(GUIElement_TPS), nameof(GUIElement_TPS.Prefix))); var logError = AccessTools.Method(typeof(Log), nameof(Log.Error), new Type[] { typeof(string) }); StaticHarmony.Patch(logError, prefix: new HarmonyMethod(typeof(DebugLogenabler), nameof(DebugLogenabler.ErrorPrefix)), new HarmonyMethod(typeof(DebugLogenabler), nameof(DebugLogenabler.ErrorPostfix))); StaticHarmony.Patch(AccessTools.Method(typeof(Prefs), "get_DevMode"), prefix: new HarmonyMethod(typeof(DebugLogenabler), nameof(DebugLogenabler.DevModePrefix))); StaticHarmony.Patch(AccessTools.Method(typeof(DebugWindowsOpener), "DevToolStarterOnGUI"), prefix: new HarmonyMethod(typeof(DebugLogenabler), nameof(DebugLogenabler.DebugKeysPatch))); } { // Performance Patches PerformancePatches.InitialisePatches(); } #if DEBUG ThreadSafeLogger.Warning("=========================================================================="); ThreadSafeLogger.Warning(" Analyzer Running In Debug Mode "); ThreadSafeLogger.Warning("=========================================================================="); #endif } catch (Exception e) { ThreadSafeLogger.ReportException(e, "Failed to initialise analyzer, dumping messages to debug log"); } finally { ThreadSafeLogger.DisplayLogs(); } }
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(); }