Example #1
0
        private static void     AutoReplaceNativeConsole()
        {
            if (HQ.Settings == null || HQ.Settings.Get <GeneralSettings>().autoReplaceUnityConsole == false)
            {
                return;
            }

            object value = NGConsoleWindow.nativeConsoleWindowField.GetValue(null);

            if (value != null && value != NGConsoleWindow.lastUnityConsoleInstance)
            {
                NGConsoleWindow[] consoles = Resources.FindObjectsOfTypeAll <NGConsoleWindow>();

                if (consoles.Length == 0)
                {
                    EditorWindow[] nativeConsoles = Resources.FindObjectsOfTypeAll(NGConsoleWindow.nativeConsoleType) as EditorWindow[];

                    if (nativeConsoles.Length > 0)
                    {
                        NGConsoleWindow window = EditorWindow.GetWindow <NGConsoleWindow>(NGConsoleWindow.Title, true, nativeConsoleType);
                        window.titleContent.text = NGConsoleWindow.Title.Substring(3);
                        Utility.RestoreIcon(window, NGConsoleWindow.TitleColor);
                        nativeConsoles[0].Close();
                    }
                }
            }

            NGConsoleWindow.lastUnityConsoleInstance = value;
        }
Example #2
0
        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);
                }
            }
        }
Example #3
0
        public virtual void     Init(NGConsoleWindow console, IStreams container)
        {
            this.console   = console;
            this.container = container;

            this.console.CheckNewLogConsume += this.ConsumeLog;
            this.console.PropagateNewLog    += this.AddLog;

            this.rowsDrawer.Init(this.console, this.console);
            this.rowsDrawer.RowDeleted     += this.DecrementCounts;
            this.rowsDrawer.LogContextMenu += this.FillContextMenu;
            this.rowsDrawer.Clear();

            this.groupFilters.FilterAltered += this.RefreshFilteredRows;

            this.totalCount     = 0;
            this.logCount       = 0;
            this.warningCount   = 0;
            this.errorCount     = 0;
            this.exceptionCount = 0;

            this.logContent       = new GUIContent(UtilityResources.InfoIcon, "Log");
            this.warningContent   = new GUIContent(UtilityResources.WarningIcon, "Warning");
            this.errorContent     = new GUIContent(UtilityResources.ErrorIcon, "Error");
            this.exceptionContent = new GUIContent(this.errorContent.image, "Exception");
            this.tabLabel         = new GUIContent();

            Texture2D pacman = new Texture2D(0, 0, TextureFormat.RGBA32, false);

            pacman.LoadImage(Convert.FromBase64String(StreamLog.PacMan));
            this.consumeLogContent = new GUIContent(pacman);
        }
Example #4
0
 public void     Init(NGConsoleWindow console, Module module)
 {
     this.console           = console;
     this.module            = module;
     this.moduleID          = this.module.Id;
     this.titleContent.text = module.name;
 }
Example #5
0
        public virtual void     Init(NGConsoleWindow editor, LogEntry log)
        {
            this.editor = editor;
            this.log    = log;

            this.commands = new Dictionary <string, Func <object, object> >();
        }
Example #6
0
        public override void    Init(NGConsoleWindow editor, LogEntry log)
        {
            base.Init(editor, log);

            this.logParser = new LogConditionParser(log);

            this.commands.Add(RowsDrawer.ShortCopyCommand, this.ShortCopy);
            this.commands.Add(RowsDrawer.FullCopyCommand, this.FullCopy);
            this.commands.Add(RowsDrawer.HandleKeyboardCommand, this.HandleKeyboard);
        }
Example #7
0
        public override void    OnEnable(NGConsoleWindow editor, int id)
        {
            base.OnEnable(editor, id);

            Conf.DebugModeChanged += this.OnDebugModeChanged;

            if (Conf.DebugMode != Conf.DebugState.None)
            {
                this.console.PostOnGUIHeader += DrawDebugBar;
            }
        }
Example #8
0
        public static void      OpenModuleInWindow(NGConsoleWindow console, Module module, bool focus = false)
        {
            ModuleWindow moduleWindow = EditorWindow.CreateInstance <ModuleWindow>();

            moduleWindow.Init(console, module);

            if (ConsoleUtility.windows != null && ConsoleUtility.mainView != null && ConsoleUtility.allChildren != null && ConsoleUtility.m_Panes != null && ConsoleUtility.AddTab != null)
            {
                Array array = ConsoleUtility.windows.GetValue(null, null) as Array;

                foreach (object w in array)
                {
                    Array children = ConsoleUtility.allChildren.GetValue(ConsoleUtility.mainView.GetValue(w, null), null) as Array;

                    foreach (object c in children)
                    {
                        try
                        {
                            List <EditorWindow> panesCasted = ConsoleUtility.m_Panes.GetValue(c) as List <EditorWindow>;

                            if (panesCasted.Exists((EditorWindow pane) => pane.GetType() == console.GetType()))
                            {
                                try
                                {
                                    ConsoleUtility.AddTab.Invoke(c, new object[] { moduleWindow });
                                }
                                catch
                                {
                                    // Changed since Unity 2018.3.
                                    ConsoleUtility.AddTab.Invoke(c, new object[] { moduleWindow, true });
                                }

                                moduleWindow.Show();
                                if (focus == false)
                                {
                                    console.Focus();
                                }
                                return;
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }

            moduleWindow.Show();
            if (focus == false)
            {
                console.Focus();
            }
        }
Example #9
0
        public override void    Init(NGConsoleWindow console, IStreams container)
        {
            base.Init(console, container);

#if !UNITY_2017_2_OR_NEWER
            EditorApplication.playmodeStateChanged += this.StartListening;
#else
            EditorApplication.playModeStateChanged += this.StartListening;
#endif

            this.RefreshFilteredRows();
        }
Example #10
0
            public void     Init(NGConsoleWindow console)
            {
                this.console = console;
                this.rowsDrawer.Init(console, this);
                this.rowsDrawer.RowHovered     += this.ShowNote;
                this.rowsDrawer.RowClicked     += this.StartDrag;
                this.rowsDrawer.LogContextMenu += this.LogContextMenu;

                for (int i = 0; i < this.notes.Count; i++)
                {
                    this.notes[i].row.Init(console, this.notes[i].row.log);
                    this.rowsDrawer.Add(i);
                }
            }
Example #11
0
        /// <summary>
        /// A special Init. Requires container to be a MainModule and an IStreams.
        /// </summary>
        /// <param name="console"></param>
        /// <param name="container">An instance of both MainModule and IStreams.</param>
        public override void    Init(NGConsoleWindow console, IStreams container)
        {
            base.Init(console, container);

            this.console.syncLogs.EndNewLog += this.UpdateAwareness;

            this.compileRows = new List <CompileRow>();
            this.rowsDrawer.SetRowGetter(this);
            this.restorer = new BgColorContentRestorer();

            this.console.UpdateTick += this.DetectCompile;

            this.OptionAltered += this.UpdateUnityConsoleOptions;
        }
Example #12
0
        public override void    Init(NGConsoleWindow editor, LogEntry log)
        {
            base.Init(editor, log);

            this.logParser = new LogConditionParser(this.log);

            this.commands.Add(RowsDrawer.ShortCopyCommand, this.ShortCopy);
            this.commands.Add(RowsDrawer.FullCopyCommand, this.FullCopy);
            this.commands.Add(RowsDrawer.CopyStackTraceCommand, this.CopyStackTrace);
            this.commands.Add(RowsDrawer.HandleKeyboardCommand, this.HandleKeyboard);
            this.commands.Add(JSONRow.CopyActualExplodedJSONCommand, this.CopyActualExplodedJSON);
            this.commands.Add(JSONRow.CopyFullExplodedJSONCommand, this.FullCopy);

            this.isParsed = false;
        }
Example #13
0
        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>();
            }
        }
Example #14
0
        public override void    OnEnable(NGConsoleWindow console, int id)
        {
            base.OnEnable(console, id);

            this.coloredRows = new List <ColoredRow>();

            MainModule main = this.console.GetModule("Main") as MainModule;

            main.StreamAdded   += this.OnMainStreamAdded;
            main.StreamDeleted += this.OnMainStreamDeleted;

            for (int i = 0; i < main.Streams.Count; i++)
            {
                main.Streams[i].RowAdded += this.OnRowAdded;
            }

            RowsDrawer.GlobalBeforeFoldout        += this.RowsDrawer_GlobalBeforeFoldout;
            RowsDrawer.GlobalLogContextMenu       += this.AppendColorsMenuItem;
            this.console.BeforeGUIHeaderRightMenu += this.HeaderButton;
        }
Example #15
0
        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>();
            }
        }
Example #16
0
        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);
            }
        }
Example #17
0
 /// <summary>Called during OnEnable of NGConsole. Prepares the Module.</summary>
 /// <param name="editor">An instance of NGConsole to work on.</param>
 /// <param name="id">The ID of the current module. Is only available for visible module.</param>
 public virtual void     OnEnable(NGConsoleWindow editor, int id)
 {
     this.console = editor;
     this.id      = id;
 }
Example #18
0
        public override void    OnEnable(NGConsoleWindow editor, int id)
        {
            base.OnEnable(editor, id);

            this.console.wantsMouseMove = true;
        }
Example #19
0
 public SyncLogs(NGConsoleWindow editor)
 {
     this.console   = editor;
     this.lastFlags = EditorPrefs.GetInt(SyncLogs.LastFlagsPrefKey);
 }
Example #20
0
        public override void    Init(NGConsoleWindow console, IStreams container)
        {
            base.Init(console, container);

            this.OptionAltered += this.UpdateUnityConsoleOptions;
        }
Example #21
0
        public override void    Init(NGConsoleWindow editor, LogEntry log)
        {
            base.Init(editor, log);

            this.ParseLog();
        }