Beispiel #1
0
        /// <summary>
        /// Create a new WhiskeyConsole with default values
        /// </summary>
        public WhiskeyConsole()
        {
            this.textBox                 = new TextBox();
            this.textBox.Position        = new Vector2(2, 2);
            this.textBox.Size            = new Vector2(GameManager.Instance.WindowScreenWidth - 4, 200);
            this.textBox.TextSize        = .8f;
            this.textBox.BackGroundColor = new Color(80, 20, 40, 70);

            this.inputBox                 = new TextBox();
            this.inputBox.Position        = new Vector2(2, 210);
            this.inputBox.Size            = new Vector2(GameManager.Instance.WindowScreenWidth - 4, 40);
            this.inputBox.TextSize        = .8f;
            this.inputBox.BackGroundColor = new Color(80, 20, 40, 70);
            keyBoard    = new RealKeyBoard();
            oldKeys     = keyBoard.AllDownKeys;
            currentKeys = oldKeys;
            keyTimes    = new Dictionary <Keys, int>();
            foreach (Keys k in currentKeys.Keys)
            {
                keyTimes.Add(k, 0);
            }

            commandTable = new Dictionary <string, ConsoleCommand>();

            //default commands
            addCommand(new ExitCommand());
            addCommand(new HelpCommand());
            addCommand(new ReplayCommand());
            addCommand(new ResetCommand());
            addCommand(new DebugCommand());
            addCommand(new ReadValueCommand());
            addCommand(new GameObjectCounterCommand());
        }
Beispiel #2
0
        /// <summary>
        /// initialize the HUD
        /// </summary>
        public void init()
        {
            textLines = new List <TextLine>();
            boxes     = new List <Box>();

            DebugLevel = LogLevel.DEBUG;

            debugWindow                 = new TextBox();
            debugWindow.Position        = new Vector2(2, GameManager.Instance.WindowScreenHeight - 100);
            debugWindow.Size            = new Vector2(GameManager.Instance.WindowScreenWidth - 4, 98);
            debugWindow.BackGroundColor = Color.Transparent;
            debugWindow.BorderColor     = Color.Transparent;
            debugWindow.TextColor       = Color.White;
            debugWindow.TextSize        = .8f;

            keyboard    = new RealKeyBoard();
            console     = new WhiskeyConsole();
            ConsoleMode = false;
        }
Beispiel #3
0
        /// <summary>
        /// updates the console
        /// </summary>
        public void update()
        {
            oldKeys     = currentKeys;
            currentKeys = keyBoard.AllDownKeys;

            Keys[] allkeys = (Keys[])Enum.GetValues(typeof(Keys));
            bool   isShift = currentKeys.Where(x => x.Key == Keys.LeftShift && x.Value).Count() == 1;

            foreach (Keys k in allkeys)
            {
                if (isNewKey(k))
                {
                    inputBox.append(RealKeyBoard.keyToString(k, isShift));
                }
                if (currentKeys[k])
                {
                    keyTimes[k]++;
                }
                else
                {
                    keyTimes[k] = 0;
                }
            }


            if (isNewKey(Keys.Enter))
            {
                submitCommand(inputBox.Text);
                inputBox.clearText();
            }

            if (isNewKey(Keys.Back))
            {
                if (inputBox.Text.Length > 0)
                {
                    inputBox.removeFromEnd();
                }
            }
        }
Beispiel #4
0
 public DefaultInputSourceManager()
 {
     keyboardSource = new RealKeyBoard();
     activeSource   = keyboardSource;
     defaultSource  = keyboardSource;
 }