public override void OnEnable(NGConsoleWindow editor, int id) { base.OnEnable(editor, id); // In case the data is corrupted, restart the instance. if (this.folders == null || this.folders.Count == 0) { this.folders = new List <Folder>(); this.folders.Add(new UnexportableFolder() { name = "Common" }); } for (int i = 0; i < this.folders.Count; i++) { this.InitFolder(this.folders[i]); } RowsDrawer.GlobalLogContextMenu += this.ArchiveFromContextMenu; if (this.perWindowVars == null) { this.perWindowVars = new PerWindowVars <Vars>(); } else { // It is possible to modify a variable from file, therefore we need to guarantee safety. foreach (Vars vars in this.perWindowVars.Each()) { vars.workingFolder = Mathf.Clamp(vars.workingFolder, 0, this.folders.Count - 1); } } }
public ArchiveModule() { this.name = "Archive"; this.folders = new List <Folder>(); this.folders.Add(new UnexportableFolder() { name = "Common" }); this.perWindowVars = new PerWindowVars <Vars>(); }
public MainModule() { this.name = "Main"; this.streams = new List <StreamLog>(); this.streams.Add(new CompilerStream()); this.streams.Add(new MainStream()); this.perWindowVars = new PerWindowVars <Vars>(); MainModuleSettings mainSettings = HQ.Settings.Get <MainModuleSettings>(); foreach (ILogFilter filter in mainSettings.GenerateFilters()) { this.streams[1].groupFilters.filters.Add(filter); } }
public override void OnEnable(NGConsoleWindow console, int id) { base.OnEnable(console, id); // Prevents corrupted console settings. if (this.streams.Count < 2 || this.compilerStream == null || this.mainStream == null) { this.streams.Clear(); this.streams.Add(new CompilerStream()); this.streams.Add(new MainStream()); MainModuleSettings mainSettings = HQ.Settings.Get <MainModuleSettings>(); foreach (ILogFilter filter in mainSettings.GenerateFilters()) { this.streams[1].groupFilters.filters.Add(filter); } } foreach (StreamLog stream in this.streams) { stream.Init(this.console, this); stream.FilterAltered += this.console.SaveModules; stream.OptionAltered += this.console.SaveModules; } this.console.CheckNewLogConsume += this.CreateStreamForCategory; this.console.OptionAltered += this.UpdateFilteredRows; this.console.ConsoleCleared += this.Clear; this.console.wantsMouseMove = true; // Populates with default commands if missing. ConsoleSettings settings = HQ.Settings.Get <ConsoleSettings>(); settings.inputsManager.AddCommand("Navigation", ConsoleConstants.SwitchNextStreamCommand, KeyCode.Tab, true); settings.inputsManager.AddCommand("Navigation", ConsoleConstants.SwitchPreviousStreamCommand, KeyCode.Tab, true, true); if (this.perWindowVars == null) { this.perWindowVars = new PerWindowVars <Vars>(); } }
public override void OnEnable(NGConsoleWindow console, int id) { base.OnEnable(console, id); foreach (var stream in this.streams) { stream.Init(this.console, this); } this.console.ConsoleCleared += this.Clear; this.console.wantsMouseMove = true; // Populate with default commands if missing. HQ.Settings.Get <ConsoleSettings>().inputsManager.AddCommand("Navigation", ConsoleConstants.SwitchNextStreamCommand, KeyCode.Tab, true); HQ.Settings.Get <ConsoleSettings>().inputsManager.AddCommand("Navigation", ConsoleConstants.SwitchPreviousStreamCommand, KeyCode.Tab, true, true); if (this.perWindowVars == null) { this.perWindowVars = new PerWindowVars <Vars>(); } }
protected virtual void OnEnable() { Utility.RegisterWindow(this); PerWindowVars.InitWindow(this, "Module"); if (this.console == null) { NGConsoleWindow[] consoles = Resources.FindObjectsOfTypeAll <NGConsoleWindow>(); if (consoles.Length > 0) { this.console = consoles[0]; } else { return; } } if (this.console.IsReady == false) { EditorApplication.delayCall += this.OnEnable; return; } this.module = this.console.GetModule(this.moduleID); if (this.module == null) { EditorApplication.delayCall += this.OnEnable; } else { this.r = new Rect(0F, 0F, this.position.width, this.position.height); this.wantsMouseMove = true; Utility.RegisterIntervalCallback(this.Repaint, ModuleWindow.ForceRepaintRefreshTick); } }
public RecorderModule() { this.name = "Recorder"; this.streams = new List <SampleStream>(); this.perWindowVars = new PerWindowVars <Vars>(); }
protected virtual void OnEnable() { Utility.RegisterWindow(this); Utility.RestoreIcon(this, NGConsoleWindow.TitleColor); Metrics.UseTool(2); // NGConsole if (this.initialized == true || HQ.Settings == null) { return; } NGChangeLogWindow.CheckLatestVersion(NGTools.NGConsole.NGAssemblyInfo.Name); try { //Debug.Log("StartEnable"); int i = 0; PerWindowVars.InitWindow(this, "NGConsole"); this.syncLogs = new SyncLogs(this); this.syncLogs.EndNewLog += this.RepaintWithModules; this.syncLogs.UpdateLog += this.UpdateLog; this.syncLogs.NewLog += this.ConvertNewLog; this.syncLogs.ResetLog += this.LocalResetLogs; this.syncLogs.ClearLog += this.Clear; this.syncLogs.OptionAltered += this.UpdateConsoleFlags; this.rows = new List <Row>(ConsoleConstants.PreAllocatedArray); this.r = new Rect(); List <RowType> rowDrawerTypes = new List <RowType>(); foreach (Type c in Utility.EachNGTSubClassesOf(typeof(Row))) { object[] attributes = c.GetCustomAttributes(typeof(RowLogHandlerAttribute), false); if (attributes.Length == 0) { continue; } MethodInfo handler = c.GetMethod(RowLogHandlerAttribute.StaticVerifierMethodName, BindingFlags.Static | BindingFlags.NonPublic); if (handler == null) { InternalNGDebug.LogWarning("The class \"" + c + "\" inherits from \"" + typeof(Row) + "\" and has the attribute \"" + typeof(RowLogHandlerAttribute) + "\" must implement: private static bool " + RowLogHandlerAttribute.StaticVerifierMethodName + "(UnityLogEntry log)."); continue; } RowType rdt = new RowType() { type = c, attribute = attributes[0] as RowLogHandlerAttribute }; rdt.attribute.handler = (Func <UnityLogEntry, bool>)Delegate.CreateDelegate(typeof(Func <UnityLogEntry, bool>), handler); rowDrawerTypes.Add(rdt); } rowDrawerTypes.Sort((r1, r2) => r2.attribute.priority - r1.attribute.priority); NGConsoleWindow.rowDrawers = rowDrawerTypes.ToArray(); List <Module> filteredModules = new List <Module>(); if (HQ.Settings.Get <ConsoleSettings>().serializedModules.Count > 0) { this.modules = HQ.Settings.Get <ConsoleSettings>().serializedModules.Deserialize <Module>(); } if (this.modules == null) { foreach (Type t in Utility.EachNGTSubClassesOf(typeof(Module))) { filteredModules.Add((Module)Activator.CreateInstance(t)); } } else { filteredModules.AddRange(this.modules); // Detect new Module. foreach (Type t in Utility.EachNGTSubClassesOf(typeof(Module), c => filteredModules.Exists(m => m.GetType() == c) == false)) { InternalNGDebug.VerboseLogFormat("Module \"{0}\" generated.", t); filteredModules.Add((Module)Activator.CreateInstance(t)); } } this.modules = filteredModules.ToArray(); this.visibleModules = this.GetVisibleModules(filteredModules); // Initialize modules int id = NGConsoleWindow.StartModuleID; for (i = 0; i < this.modules.Length; i++) { if (this.visibleModules.Contains(this.modules[i]) == true) { this.modules[i].OnEnable(this, id++); } else { this.modules[i].OnEnable(this, -1); } } // Do not overflow if there is removed modules. if (this.visibleModules.Length > 0) { if (this.workingModuleId == -1) { this.workingModuleId = this.visibleModules[0].Id; } else { this.workingModuleId = Mathf.Clamp(this.workingModuleId, NGConsoleWindow.StartModuleID, this.visibleModules.Length); } Module module = this.GetModule(this.workingModuleId); if (module != null) { module.OnEnter(); } } else { this.workingModuleId = -1; } GUI.FocusControl(null); Object[] nativeConsoleInstances = Resources.FindObjectsOfTypeAll(NGConsoleWindow.nativeConsoleType); if (nativeConsoleInstances.Length > 0) { NGConsoleWindow.nativeConsoleWindowField.SetValue(null, nativeConsoleInstances[nativeConsoleInstances.Length - 1]); } this.settings = HQ.Settings; HQ.SettingsChanged += this.OnSettingsChanged; Undo.undoRedoPerformed += this.Repaint; EditorApplication.delayCall += () => GUICallbackWindow.Open(this.VerifySettingsStyles); this.initialized = true; } catch (Exception ex) { InternalNGDebug.LogException(ex); } }