Esempio n. 1
0
        private static void     OnGUIInputs()
        {
            ConsoleSettings settings = HQ.Settings.Get <ConsoleSettings>();

            for (int n = 0, i = 0; i < settings.inputsManager.groups.Count; ++i, ++n)
            {
                if (GUILayout.Toggle(i == ConsoleSettingsEditor.selectedInputsGroup, LC.G("InputGroup_" + settings.inputsManager.groups[i].name), ConsoleSettingsEditor.menuButtonStyle) == true)
                {
                    ConsoleSettingsEditor.selectedInputsGroup = i;
                }
            }

            if (ConsoleSettingsEditor.selectedInputsGroup < settings.inputsManager.groups.Count)
            {
                ConsoleSettingsEditor.inputScrollPosition = EditorGUILayout.BeginScrollView(ConsoleSettingsEditor.inputScrollPosition);
                {
                    for (int n = 0, j = 0; j < settings.inputsManager.groups[ConsoleSettingsEditor.selectedInputsGroup].commands.Count; ++j, ++n)
                    {
                        while (n >= ConsoleSettingsEditor.testInputAnimationFeedback.Count)
                        {
                            var af = new AnimFloat(0F, EditorWindow.focusedWindow.Repaint);
                            af.speed  = 1F;
                            af.target = 0F;
                            ConsoleSettingsEditor.testInputAnimationFeedback.Add(new GUITimer(EditorWindow.focusedWindow.Repaint, Constants.CheckFadeoutCooldown, 0F));
                        }

                        if (settings.inputsManager.groups[ConsoleSettingsEditor.selectedInputsGroup].commands[j].Check() == true)
                        {
                            ConsoleSettingsEditor.testInputAnimationFeedback[n].Start();
                            ConsoleSettingsEditor.testInputAnimationFeedback[n].af.valueChanged.RemoveAllListeners();
                            ConsoleSettingsEditor.testInputAnimationFeedback[n].af.valueChanged.AddListener(EditorWindow.focusedWindow.Repaint);
                        }

                        if (ConsoleSettingsEditor.testInputAnimationFeedback[n].Value > 0F)
                        {
                            using (ColorContentRestorer.Get(Color.Lerp(GUI.contentColor, ConsoleSettingsEditor.HighlightInput, ConsoleSettingsEditor.testInputAnimationFeedback[n].Value)))
                                ConsoleSettingsEditor.DrawInputCommand(settings.inputsManager.groups[ConsoleSettingsEditor.selectedInputsGroup].commands[j]);
                        }
                        else
                        {
                            ConsoleSettingsEditor.DrawInputCommand(settings.inputsManager.groups[ConsoleSettingsEditor.selectedInputsGroup].commands[j]);
                        }
                    }

                    GUILayout.Space(10F);
                }
                EditorGUILayout.EndScrollView();
            }
        }
Esempio n. 2
0
        private object  HandleKeyboard(object data)
        {
            RowsDrawer rowsDrawer = data as RowsDrawer;

            if (Event.current.type == EventType.KeyDown)
            {
                ConsoleSettings general = HQ.Settings.Get <ConsoleSettings>();

                if (general.inputsManager.Check("Navigation", ConsoleConstants.CloseLogCommand) == true)
                {
                    if (this.isOpened == true)
                    {
                        this.isOpened = false;
                        rowsDrawer.InvalidateViewHeight();
                        RowUtility.drawingWindow.Repaint();
                        RowUtility.ClearPreview();
                    }
                }
                else if (general.inputsManager.Check("Navigation", ConsoleConstants.OpenLogCommand) == true)
                {
                    if (this.isOpened == false)
                    {
                        this.isOpened = true;
                        rowsDrawer.InvalidateViewHeight();
                        RowUtility.drawingWindow.Repaint();
                        RowUtility.ClearPreview();
                    }
                }
                else if (general.inputsManager.Check("Navigation", ConsoleConstants.GoToLineCommand) == true &&
                         rowsDrawer.currentVars.CountSelection == 1 &&
                         this.Frames.Length > 0)
                {
                    string fileName = this.Frames[0].fileName;
                    int    line     = this.Frames[0].line;
                    bool   focus    = (Event.current.modifiers & HQ.Settings.Get <LogSettings>().forceFocusOnModifier) != 0;

                    RowUtility.GoToFileLine(fileName, line, focus);
                    RowUtility.drawingWindow.Repaint();
                    Event.current.Use();
                }
            }

            return(null);
        }
Esempio n. 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>();
            }
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 6
0
        private Rect    DrawFolderTabs(Rect r)
        {
            ConsoleSettings settings = HQ.Settings.Get <ConsoleSettings>();
            GeneralSettings general  = HQ.Settings.Get <GeneralSettings>();
            float           height   = r.height;

            r.height = ConsoleConstants.DefaultSingleLineHeight;

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

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

                Event.current.Use();
            }

            GUILayout.BeginArea(r);
            {
                GUILayout.BeginHorizontal();
                {
                    for (int i = 0; i < this.folders.Count; i++)
                    {
                        EditorGUI.BeginChangeCheck();
                        GUILayout.Toggle(i == this.currentVars.workingFolder, this.folders[i].name + " (" + this.folders[i].rowsDrawer.Count + ")", general.MenuButtonStyle);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            if (Event.current.button == 0)
                            {
                                this.currentVars.workingFolder = i;
                                this.console.SaveModules();
                            }
                            // Forbid to alter the main folder.
                            else if (i > 0 || Conf.DebugMode != Conf.DebugState.None)
                            {
                                // Show context menu on right click.
                                if (Event.current.button == 1)
                                {
                                    GenericMenu menu = new GenericMenu();
                                    menu.AddItem(new GUIContent(LC.G("ArchiveModule_ChangeName")), false, this.ChangeStreamName, i);
                                    if (i > 0)
                                    {
                                        menu.AddItem(new GUIContent(LC.G("Delete")), false, this.DeleteFolder, i);
                                    }
                                    if (Conf.DebugMode != Conf.DebugState.None)
                                    {
                                        menu.AddItem(new GUIContent("Clear"), false, this.ClearFolder, i);
                                    }
                                    menu.DropDown(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0));
                                }
                                else if (Event.current.button == 2)
                                {
                                    if (i > 0 || Conf.DebugMode != Conf.DebugState.None)
                                    {
                                        this.DeleteFolder(i);
                                    }
                                }
                            }
                        }

                        if ((Event.current.type == EventType.DragPerform ||
                             Event.current.type == EventType.DragUpdated ||
                             Event.current.type == EventType.DragExited ||
                             Event.current.type == EventType.MouseUp) &&
                            DragAndDrop.GetGenericData("n") != null)
                        {
                            Rect toggleRect = GUILayoutUtility.GetLastRect();

                            // Check drop Row.
                            if (toggleRect.Contains(Event.current.mousePosition))
                            {
                                if (Event.current.type == EventType.DragUpdated)
                                {
                                    LogNote note = DragAndDrop.GetGenericData("n") as LogNote;

                                    if (this.folders[i].notes.Contains(note) == false)
                                    {
                                        DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                                    }
                                    else
                                    {
                                        DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                                    }

                                    Event.current.Use();
                                }
                                else if (Event.current.type == EventType.DragPerform)
                                {
                                    DragAndDrop.AcceptDrag();

                                    LogNote note = DragAndDrop.GetGenericData("n") as LogNote;
                                    Folder  f    = this.folders[i];

                                    EditorApplication.delayCall += () =>
                                    {
                                        this.DeleteNote(note);
                                        f.notes.Add(note);
                                        f.rowsDrawer.Add(f.notes.Count - 1);
                                        this.UpdateName();
                                        this.console.SaveModules();
                                        this.console.Repaint();
                                    };

                                    Event.current.Use();
                                }

                                RowUtility.drawingWindow.Repaint();
                            }

                            if (Event.current.type == EventType.DragExited ||
                                Event.current.type == EventType.MouseUp)
                            {
                                DragAndDrop.PrepareStartDrag();
                            }
                        }
                    }

                    if (GUILayout.Button("+", general.MenuButtonStyle) == true)
                    {
                        Folder folder = new Folder()
                        {
                            name = "Folder " + this.folders.Count
                        };

                        this.InitFolder(folder);

                        this.folders.Add(folder);
                        this.console.SaveModules();

                        if (this.folders.Count == 1)
                        {
                            this.currentVars.workingFolder = 0;
                        }
                    }

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

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

            r.height = height - r.height - 2F;

            return(r);
        }