public static void MakeAndSwitchTab(string tabName) { Type myType = null; if (types.Contains(tabName)) { myType = AccessTools.TypeByName(tabName); } else { myType = DynamicTypeBuilder.CreateType(tabName, null); types.Add(tabName); } foreach (var profileTab in SideTabCategories) { if (profileTab.UpdateMode == UpdateMode.Update) { ProfileMode mode = ProfileMode.Create(myType.Name, UpdateMode.Update, null, false, myType, true); mode.IsPatched = true; profileTab.Modes.Add(mode, null); break; } } SwapTab(tabName, UpdateMode.Update); }
public static void SwapTab(KeyValuePair <ProfileMode, Type> mode, UpdateMode updateMode) { if (State == CurrentState.Uninitialised) { Dialog_Analyzer.Reboot(); } if (!(CurrentSideTabCategory == UpdateToSideTab(updateMode))) { CurrentSideTabCategory = UpdateToSideTab(updateMode); Analyzer.Settings.Write(); } if (CurrentTab != null) { CurrentTab.SetActive(false); } mode.Key.SetActive(CurrentlyRunning); CurrentTab = mode.Key; CurrentProfileKey = "Overview"; ResetState(); if (!mode.Key.IsPatched) { mode.Key.ProfilePatch(); } }
public Analyzer(ModContentPack content) : base(content) { Settings = GetSettings <PerfAnalSettings>(); if (Settings.UnlockFramerate && Application.platform != RuntimePlatform.OSXPlayer) { QualitySettings.vSyncCount = 0; Application.targetFrameRate = 999; } foreach (var mod in LoadedModManager.RunningMods) { if (mod.Name == this.Content.Name) { continue; } foreach (var ass in mod.assemblies.loadedAssemblies) { try { AnalyzerCache.AssemblyToModname.Add(ass.FullName, mod.Name); } catch (Exception) { // we do this so if there are duplicated assemblies, we don't have duplicated keys(unnecessary complexity) } } } foreach (var dir in ModLister.AllActiveModDirs) { var count = dir.GetFiles("Analyzer.xml")?.Count(); if (count != 0) { var thing = dir.GetFiles("Analyzer.xml").First(); XmlDocument doc = new XmlDocument(); doc.Load(thing.OpenRead()); XmlParser.Parse(doc, ref methods); } } if (methods.Count != 0) { foreach (var m in methods) { Type myType = DynamicTypeBuilder.CreateType(m.Key, m.Value); foreach (var profileTab in AnalyzerState.SideTabCategories) { if (profileTab.UpdateMode == UpdateMode.ModderAdded) { ProfileMode mode = ProfileMode.Create(myType.Name, UpdateMode.ModderAdded, null, false, myType); profileTab.Modes.Add(mode, null); break; } } } } }
public static ProfileMode Create(string name, UpdateMode mode, string tip = null, bool basics = false, Type profilerClass = null, bool closable = false) { var getit = instances.FirstOrDefault(x => x.name == name && x.mode == mode); if (getit != null) { return(getit); } getit = new ProfileMode(name, mode, tip, basics); getit.typeRef = profilerClass; getit.Closable = closable; instances.Add(getit); return(getit); }
public static void RemoveTab(KeyValuePair <ProfileMode, Type> tab) { foreach (var profileTab in SideTabCategories) { var deletedTab = profileTab.Modes.Where(t => t.Key == tab.Key); if (deletedTab == null || deletedTab.Count() == 0 || deletedTab.First().Key == null) { continue; } profileTab.Modes.Remove(deletedTab.First().Key); if (deletedTab == CurrentTab) { CurrentTab = profileTab.Modes.First().Key; } return; } }