Esempio n. 1
0
    void GetInput()
    {
        if (focus == "console" && subFocus == "input")
        {
            if (Input.GetKeyDown(KeyCode.Return))
            {
                rawInput = console_InputField.text;
                console_InputField.text = "";

                if (rawInput != "")
                {
                    LogText(rawInput);

                    //if (!commandFeedback.valid)
                    //{
                    //    LogText(commandFeedback.feedback);
                    //}

                    ////TEST CASES:
                    if (rawInput.Contains("open"))
                    {
                        //hard coded: must begin with "open "
                        string temp = rawInput.Remove(0, 5);
                        //Capitalize first letter
                        temp = temp.First().ToString().ToUpper() + temp.Substring(1);

                        Debug.Log(temp);

                        xml.MoveDown(temp);
                    }

                    if (rawInput.Contains("move up"))
                    {
                        xml.MoveUp();
                    }

                    //if (rawInput.Contains("fullscreen"))
                    //{
                    //    StartCoroutine(gameObject.GetComponent<SizeManager>().EnterFullscreenCam());
                    //}

                    //if (rawInput.Contains("resize to (0.2, 0.2)"))
                    //{
                    //    StartCoroutine(gameObject.GetComponent<SizeManager>().ResizeWindows(new Vector2(0.2F, 0.2F)));
                    //}
                }

                console_InputField.ActivateInputField();
            }

            if (Input.GetKeyUp(KeyCode.UpArrow))
            {
                SetFocus("log");

                ScrollText(true, true);
            }
        }
        else if (focus == "console" && subFocus == "log")
        {
            if (Input.GetKeyDown(KeyCode.Return))
            {
                SetFocus("input");

                //Copy the selected text to input
                console_InputField.text = consoleLog[currentLogIndex];
                //Set the caret to the end of the line
                console_InputField.caretPosition = console_InputField.text.Length;
                //Remove the "> " from the selected slot
                log_TextFields[selectedSlotIndex].text = log_TextFields[selectedSlotIndex].text.Remove(0, 2);
            }

            if (Input.GetKeyUp(KeyCode.UpArrow))
            {
                ScrollText(true);
            }

            if (Input.GetKeyUp(KeyCode.DownArrow) && currentLogIndex == 0)
            {
                ScrollText(false, true);
                SetFocus("input");
            }
            else if (Input.GetKeyUp(KeyCode.DownArrow))
            {
                ScrollText(false);
            }
        }
    }