Exemple #1
0
        private void    CreateStreamForCategory(int consoleIndex, Row row)
        {
            // StreamLog does not receive output from compiler.
            if ((row.log.mode & (Mode.ScriptCompileError | Mode.ScriptCompileWarning)) != 0)
            {
                return;
            }

            // Category has a priority over all rules.
            string category;
            int    hash = row.log.condition.GetHashCode();

            if (MainModule.methodsCategories.TryGetValue(hash, out category) == false)
            {
                ILogContentGetter log = row as ILogContentGetter;

                if (log != null)
                {
                    category = log.Category;
                }
                else
                {
                    category = null;
                }

                MainModule.methodsCategories.Add(hash, category);
            }

            if (category != null)
            {
                for (int j = 0; j < this.streams.Count; j++)
                {
                    if (this.streams[j].onlyCategory == true && this.streams[j].name == category)
                    {
                        return;
                    }
                }

                MainModuleSettings mainSettings = HQ.Settings.Get <MainModuleSettings>();
                StreamLog          stream       = new StreamLog();
                stream.onlyCategory = true;
                stream.name         = category;
                stream.Init(this.console, this);

                foreach (ILogFilter filter in mainSettings.GenerateFilters())
                {
                    stream.groupFilters.filters.Add(filter);
                }

                this.streams.Add(stream);

                if (this.StreamAdded != null)
                {
                    this.StreamAdded(stream);
                }
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
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>();
            }
        }
Exemple #4
0
        private Rect    DrawSampleTabs(Rect r)
        {
            ConsoleSettings settings = HQ.Settings.Get <ConsoleSettings>();

            r.height = Constants.SingleLineHeight;

            // Switch stream
            if (settings.inputsManager.Check("Navigation", ConsoleConstants.SwitchNextStreamCommand) == true)
            {
                this.currentVars.workingStream += 1;
                if (this.currentVars.workingStream >= this.streams.Count)
                {
                    this.currentVars.workingStream = 0;
                }

                Event.current.Use();
            }
            if (settings.inputsManager.Check("Navigation", ConsoleConstants.SwitchPreviousStreamCommand) == true)
            {
                this.currentVars.workingStream -= 1;
                if (this.currentVars.workingStream < 0)
                {
                    this.currentVars.workingStream = this.streams.Count - 1;
                }

                Event.current.Use();
            }

            GUILayout.BeginArea(r);
            {
                GUILayout.BeginHorizontal();
                {
                    for (int i = 0; i < this.streams.Count; i++)
                    {
                        r = this.streams[i].OnTabGUI(r, i);
                    }

                    if (GUILayout.Button("+", HQ.Settings.Get <GeneralSettings>().MenuButtonStyle) == true)
                    {
                        MainModuleSettings mainSettings = HQ.Settings.Get <MainModuleSettings>();
                        SampleStream       stream       = new SampleStream();

                        stream.Init(this.console, this);

                        foreach (ILogFilter filter in mainSettings.GenerateFilters())
                        {
                            stream.groupFilters.filters.Add(filter);
                        }

                        this.streams.Add(stream);

                        if (this.streams.Count == 1)
                        {
                            this.currentVars.workingStream = 0;
                        }

                        if (this.StreamAdded != null)
                        {
                            this.StreamAdded(stream);
                        }

                        stream.RefreshFilteredRows();
                    }

                    GUILayout.FlexibleSpace();
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndArea();

            r.y += r.height + 2F;

            return(r);
        }
Exemple #5
0
        private Rect    DrawStreamTabs(Rect r)
        {
            float maxWidth = r.width;

            r.y     += 2F;
            r.height = Constants.SingleLineHeight;

            MainModuleSettings mainSettings = HQ.Settings.Get <MainModuleSettings>();
            ConsoleSettings    settings     = HQ.Settings.Get <ConsoleSettings>();
            Vars vars = this.perWindowVars.Get(RowUtility.drawingWindow);

            // Switch stream
            if (settings.inputsManager.Check("Navigation", ConsoleConstants.SwitchNextStreamCommand) == true)
            {
                vars.workingStream += 1;
                if (vars.workingStream >= this.streams.Count)
                {
                    vars.workingStream = 0;
                }

                Event.current.Use();
            }
            else if (settings.inputsManager.Check("Navigation", ConsoleConstants.SwitchPreviousStreamCommand) == true)
            {
                vars.workingStream -= 1;
                // Handle CompilerStream.
                if (vars.workingStream == 0 && this.compilerStream.totalCount == 0)
                {
                    vars.workingStream = this.streams.Count - 1;
                }
                if (vars.workingStream < 0)
                {
                    vars.workingStream = this.streams.Count - 1;
                }

                Event.current.Use();
            }

            for (int i = 0; i < this.streams.Count; i++)
            {
                r = this.streams[i].OnTabGUI(r, i);
            }

            r.width = 16F;

            if (GUI.Button(r, "+", HQ.Settings.Get <GeneralSettings>().MenuButtonStyle) == true)
            {
                if (this.CheckMaxStreams(this.streams.Count - 2) == true)
                {
                    StreamLog stream = new StreamLog();
                    stream.Init(this.console, this);
                    stream.FilterAltered += this.console.SaveModules;
                    stream.OptionAltered += this.console.SaveModules;

                    foreach (ILogFilter filter in mainSettings.GenerateFilters())
                    {
                        stream.groupFilters.filters.Add(filter);
                    }

                    this.streams.Add(stream);

                    this.console.SaveModules();

                    if (this.streams.Count == 1)
                    {
                        vars.workingStream = 0;
                    }

                    if (this.StreamAdded != null)
                    {
                        this.StreamAdded(stream);
                    }

                    stream.RefreshFilteredRows();
                }
            }

            r.x    += r.width;
            r.width = maxWidth - r.x;

            return(r);
        }
Exemple #6
0
        protected virtual void  OnGUI()
        {
            if (HQ.Settings == null)
            {
                GUILayout.Label(string.Format(LC.G("RequiringConfigurationFile"), ColorMarkersWizard.Title));
                if (GUILayout.Button(LC.G("ShowPreferencesWindow")) == true)
                {
                    Utility.ShowPreferencesWindowAt(Constants.PreferenceTitle);
                }
                return;
            }

            ColorMarkersModuleSettings settings = HQ.Settings.Get <ColorMarkersModuleSettings>();

            this.r.x      = 0F;
            this.r.y      = 0F;
            this.r.width  = this.position.width;
            this.r.height = Constants.SingleLineHeight;

            if (GUI.Button(r, LC.G("AddMarker")) == true)
            {
                if (this.CheckMaxColorMarkers(settings.colorMarkers.Count) == true)
                {
                    Undo.RecordObject(settings, "Add color marker");

                    ColorMarker        marker       = new ColorMarker();
                    MainModuleSettings mainSettings = HQ.Settings.Get <MainModuleSettings>();

                    foreach (ILogFilter filter in mainSettings.GenerateFilters())
                    {
                        marker.groupFilters.filters.Add(filter);
                    }

                    settings.colorMarkers.Add(marker);

                    this.RefreshAllStreams();
                }
            }

            this.r.y += this.r.height + ColorMarkersWizard.MarkerSpacing;

            float totalHeight = 0f;

            for (int i = 0; i < settings.colorMarkers.Count; i++)
            {
                while (this.folds.Count < settings.colorMarkers.Count)
                {
                    this.folds.Add(true);
                }

                totalHeight += this.r.height + ColorMarkersWizard.Spacing + ColorMarkersWizard.MarkerSpacing;
                if (this.folds[i] == true)
                {
                    totalHeight += this.r.height + ColorMarkersWizard.Spacing;

                    for (int j = 0; j < settings.colorMarkers[i].groupFilters.filters.Count; j++)
                    {
                        if (settings.colorMarkers[i].groupFilters.filters[j].Enabled == true)
                        {
                            totalHeight += this.r.height + 2F;
                        }
                    }
                }
            }

            totalHeight         -= ColorMarkersWizard.MarkerSpacing;
            this.viewRect.height = totalHeight;

            Rect body = this.r;

            body.height = this.position.height - this.r.y;

            this.scrollPosition = GUI.BeginScrollView(body, this.scrollPosition, this.viewRect);
            {
                float width = body.width;

                if (totalHeight > body.height)
                {
                    width -= 16F;
                }

                this.r.y = 0F;
                for (int i = 0; i < settings.colorMarkers.Count; i++)
                {
                    this.r.x     = 0F;
                    this.r.width = width;

                    GUI.Box(r, GUIContent.none, GeneralStyles.Toolbar);

                    this.r.width  = width - 325F;
                    this.folds[i] = EditorGUI.Foldout(this.r, this.folds[i], LC.G("Marker") + " #" + (i + 1));
                    this.r.x     += this.r.width;

                    this.r.width = 200F;

                    EditorGUI.BeginChangeCheck();
                    Color color = EditorGUI.ColorField(r, settings.colorMarkers[i].backgroundColor);
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        this.alteredColorMarker = settings.colorMarkers[i];
                        this.newColor           = color;

                        settings.colorMarkers[i].backgroundColor = color;
                        Utility.RepaintEditorWindow(typeof(NGConsoleWindow));
                        Utility.RegisterIntervalCallback(this.DelayedSetBackgroundcolor, 100, 1);
                    }
                    this.r.x += this.r.width;

                    this.r.width = 65F;
                    EditorGUI.DrawRect(this.r, settings.colorMarkers[i].backgroundColor);
                    EditorGUI.LabelField(this.r, "# # # # #");
                    this.r.x += this.r.width;

                    this.r.width = 20F;

                    EditorGUI.BeginDisabledGroup(i == 0);
                    {
                        if (GUI.Button(r, "↑", GeneralStyles.ToolbarButton) == true)
                        {
                            Undo.RecordObject(settings, "Reorder color marker");
                            settings.colorMarkers.Reverse(i - 1, 2);
                            this.RefreshAllStreams();
                            break;
                        }
                        this.r.x += this.r.width;

                        GUI.enabled = i < settings.colorMarkers.Count - 1;
                        if (GUI.Button(r, "↓", GeneralStyles.ToolbarButton) == true)
                        {
                            Undo.RecordObject(settings, "Reorder color marker");
                            settings.colorMarkers.Reverse(i, 2);
                            this.RefreshAllStreams();
                            break;
                        }
                        this.r.x += this.r.width;

                        GUI.enabled = true;
                        if (GUI.Button(r, "X", GeneralStyles.ToolbarCloseButton) == true)
                        {
                            Undo.RecordObject(settings, "Delete color marker");
                            settings.colorMarkers.RemoveAt(i);
                            this.RefreshAllStreams();
                            break;
                        }
                    }
                    EditorGUI.EndDisabledGroup();

                    this.r.y += this.r.height + ColorMarkersWizard.Spacing;

                    if (this.folds[i] == true)
                    {
                        this.r.x = 0F;

                        EditorGUI.BeginChangeCheck();
                        {
                            settings.colorMarkers[i].groupFilters.OnGUI(r);

                            this.r.y += this.r.height + ColorMarkersWizard.Spacing;

                            for (int j = 0; j < settings.colorMarkers[i].groupFilters.filters.Count; j++)
                            {
                                if (settings.colorMarkers[i].groupFilters.filters[j].Enabled == true)
                                {
                                    this.r.x     = 0F;
                                    this.r.width = width;
                                    this.r       = settings.colorMarkers[i].groupFilters.filters[j].OnGUI(this.r, false);
                                }
                            }
                        }
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            this.RefreshAllStreams();
                        }
                    }

                    this.r.y += ColorMarkersWizard.MarkerSpacing;
                }
            }
            GUI.EndScrollView();
        }