Ejemplo n.º 1
0
        private static void DrawMenuDisplay()
        {
            //& Draws the menu display
            // Draws the buttons from the system
            GUILayout.BeginVertical(GUI.skin.textArea, GUILayout.ExpandHeight(true));
            GUILayout.Label(SYSTEM_CMD_MENU, GUI.skin.GetStyle("centerLabel"), GUILayout.ExpandWidth(true), GUILayout.Height(20));
            systemCmdScroll = GUILayout.BeginScrollView(systemCmdScroll, GUILayout.Height(DebugHandler.devWindow.Rect.height * 0.3f));

            foreach (ConsoleButton button in GuuConsole.buttons.Values)
            {
                if (GUILayout.Button(button.Text))
                {
                    GuuConsole.ExecuteCommand(button.Command, true);
                }
            }

            GUILayout.EndScrollView();
            GUILayout.EndVertical();

            // Draws the buttons from the users
            GUILayout.BeginVertical(GUI.skin.textArea, GUILayout.ExpandHeight(true));
            GUILayout.Label(USER_CMD_MENU, GUI.skin.GetStyle("centerLabel"), GUILayout.ExpandWidth(true), GUILayout.Height(20));
            usedCmdScroll = GUILayout.BeginScrollView(usedCmdScroll, GUILayout.ExpandHeight(true));

            foreach (ConsoleButton button in GuuConsole.customButtons.Values)
            {
                if (GUILayout.Button(button.Text))
                {
                    GuuConsole.ExecuteCommand(button.Command, true);
                }
            }

            GUILayout.EndScrollView();
            GUILayout.EndVertical();
        }
Ejemplo n.º 2
0
        //+ INPUT CONTROL
        internal override bool OnProcessInput(EventModifiers mods)
        {
            if (Event.current == null)
            {
                return(false);
            }

            switch (Event.current.keyCode)
            {
            // Closes auto complete if open and ESC is pressed
            case KeyCode.Escape when autoComplete:
                autoComplete = false;

                return(true);

            // Submits the input of the console if ENTER/RETURN is pressed
            case KeyCode.Return:
            case KeyCode.KeypadEnter:
                GuuConsole.ExecuteCommand(input.TrimEnd(' '));
                input = string.Empty;

                currHistory   = -1;
                completeIndex = 0;
                autoComplete  = false;

                return(true);

            // Toggles the auto complete if CTRL+Space is pressed (CMD for mac)
            case KeyCode.Space when mods == EventModifiers.Control || mods == EventModifiers.Command:
                CheckChanges();

                removeLastSpace = true;
                if (acCache.Count == 0)
                {
                    return(true);
                }

                autoComplete = true;
                return(true);

            // Executes auto complete when TAB is pressed without modifiers
            case KeyCode.Tab when mods == EventModifiers.None && autoComplete:
                input      = input.Substring(0, input.Length - acSelection.Length) + acCache[completeIndex];
                moveCursor = true;
                return(true);

            // Changes the history if the UP ARROW was pressed
            case KeyCode.UpArrow when !autoComplete && GuuConsole.history.Count > 0:
                currHistory = currHistory == -1 ? GuuConsole.history.Count - 1 : currHistory > 0 ? currHistory - 1 : currHistory;
                input       = GuuConsole.history[currHistory];

                moveCursor = true;
                return(true);

            // Changes the history if the DOWN ARROW was pressed
            case KeyCode.DownArrow when !autoComplete && GuuConsole.history.Count > 0:
                if (currHistory == -1)
                {
                    return(true);
                }

                currHistory = currHistory < GuuConsole.history.Count - 1 ? currHistory + 1 : -1;
                input       = currHistory == -1 ? string.Empty : GuuConsole.history[currHistory];

                moveCursor = true;
                return(true);

            // Changes the auto complete selection if UP ARROW was pressed
            case KeyCode.UpArrow when autoComplete:
                completeIndex = completeIndex == 0 ? acCache.Count - 1 : completeIndex - 1;
                acScroll.y    = 25 * completeIndex;

                return(true);

            // Changes the auto complete selection if DOWN ARROW was pressed
            case KeyCode.DownArrow when autoComplete:
                completeIndex = completeIndex == acCache.Count - 1 ? 0 : completeIndex + 1;
                acScroll.y    = 25 * completeIndex;

                return(true);

            // Anything else
            default:
                return(false);
            }
        }
Ejemplo n.º 3
0
 //+ INTERACTIONS
 internal void Execute()
 {
     GuuConsole.ExecuteCommand(Command, true);
 }