private static void ThreadStart(Dictionary <string, Profiler> Profiles) { Thread.CurrentThread.IsBackground = true; var newLogs = new List <ProfileLog>(); foreach (var key in Profiles.Keys) { var value = Profiles[key]; var av = value.History.GetAverageTime(AveragingTime); newLogs.Add(new ProfileLog(value.label, string.Empty, av, null, key, string.Empty, 0, value.type)); } var dd = newLogs.Sum(x => x.Average); for (var index = 0; index < newLogs.Count; index++) { var k = newLogs[index]; var pc = (float)(k.Average / dd); var Log = new ProfileLog(k.Label, pc.ToStringPercent(), pc, k.Def, k.Key, k.Mod, pc, k.Type); newLogs[index] = Log; } newLogs.SortByDescending(x => x.Average); lock (sync) { Logs = newLogs; } }
public static void Clicked(Profiler prof, ProfileLog log) { if (Input.GetKey(KeyCode.LeftControl)) { if (log.Meth == null) { Messages.Message("Null method", MessageTypeDefOf.NegativeEvent, false); return; } var patches = Harmony.GetAllPatchedMethods().ToList(); // Patches patchInfo = Harmony.GetPatchInfo(log.Meth); foreach (var methodBase in patches) { var infos = Harmony.GetPatchInfo(methodBase); foreach (var infosPrefix in infos.Prefixes) { if (infosPrefix.PatchMethod == log.Meth) { Analyzer.harmony.Unpatch(methodBase, HarmonyPatchType.All, "*"); Messages.Message("Unpatched prefixes", MessageTypeDefOf.TaskCompletion, false); } } foreach (var infosPostfixesx in infos.Postfixes) { if (infosPostfixesx.PatchMethod == log.Meth) { Analyzer.harmony.Unpatch(methodBase, HarmonyPatchType.All, "*"); Messages.Message("Unpatched postfixes", MessageTypeDefOf.TaskCompletion, false); } } } } }
private static void ThreadStart(Dictionary <string, Profiler> Profiles) { var newLogs = new List <ProfileLog>(); foreach (var key in Profiles.Keys) { var value = Profiles[key]; var av = value.History.GetAverageTime(AveragingTime); newLogs.Add(new ProfileLog(value.label, string.Empty, av, (float)value.History.times.Max(), null, key, string.Empty, 0, value.type, value.meth)); } var total = newLogs.Sum(x => x.Average); for (var index = 0; index < newLogs.Count; index++) { var k = newLogs[index]; var pc = (float)(k.Average / total); var Log = new ProfileLog(k.Label, pc.ToStringPercent(), pc, k.Max, k.Def, k.Key, k.Mod, pc, k.Type, k.Meth); newLogs[index] = Log; } newLogs.SortByDescending(x => x.Average); lock (sync) { AnalyzerState.Logs = newLogs; } }
public static void Checkbox(Profiler prof, ProfileLog log) { if (log.Type != null) { if (!Analyzer.Settings.AlertFilter.ContainsKey(log.Type)) { Analyzer.Settings.AlertFilter.Add(log.Type, true); } else { var bam = Analyzer.Settings.AlertFilter[log.Type]; Analyzer.Settings.AlertFilter[log.Type] = !bam; } } }
public static void Clicked(Profiler prof, ProfileLog log) { if (Input.GetKey(KeyCode.LeftControl)) { if (log.Meth != null) { Analyzer.harmony.Unpatch(log.Meth, HarmonyPatchType.Transpiler, "*"); Messages.Message("Unpatched", MessageTypeDefOf.TaskCompletion, false); } else { Messages.Message("Null method", MessageTypeDefOf.NegativeEvent, false); } } }
public static bool Selected(Profiler prof, ProfileLog log) { if (log.Type == null) { return(false); } if (Analyzer.Settings.AlertFilter.ContainsKey(log.Type)) { var bam = Analyzer.Settings.AlertFilter[log.Type]; if (bam) { return(false); } } return(true); }
public static void MouseOver(Rect r, Profiler prof, ProfileLog log) { if (LogCache != log.Label) { LogCache = log.Label; TipCache = string.Empty; // var patches = Harmony.GetAllPatchedMethods().ToList(); // foreach (var methodBase in patches) // { var infos = Harmony.GetPatchInfo(log.Meth); //foreach (var infosPrefix in infos.Prefixes) //{ // if (infosPrefix.PatchMethod == log.Meth) // { // TipCache += $"{infosPrefix.owner} {infosPrefix.PatchMethod}\n"; // } //} //foreach (var infosPostfixesx in infos.Postfixes) //{ // if (infosPostfixesx.PatchMethod == log.Meth) // { // TipCache += $"{infosPostfixesx.owner} {infosPostfixesx.PatchMethod}\n"; // } //} foreach (var infosPostfixesx in infos.Transpilers) { // if (infosPostfixesx.PatchMethod == log.Meth) // { TipCache += $"{infosPostfixesx.owner} - {infosPostfixesx.PatchMethod.Name}\n\n"; // } } // } } TooltipHandler.TipRegion(r, TipCache); }
public static void Clicked(Profiler prof, ProfileLog log) { }