Exemple #1
0
        public bool HandlerKeyboard(IConsole console, KeyboardInfo info)
        {
            //TODO: This is dependent on how fast update is working... Make independent
            bool handled = false;

            if (console.CanUseKeyboard && CanMoveWithKeyboard)
            {
                var view = console.TextSurface.RenderArea;

                if (info.IsKeyDown(MoveLeftKey))
                {
                    view.X -= 1;
                    handled = true;
                }
                else if (info.IsKeyDown(MoveRightKey))
                {
                    view.X += 1;
                    handled = true;
                }
                if (info.IsKeyDown(MoveUpKey))
                {
                    view.Y -= 1;
                    handled = true;
                }
                else if (info.IsKeyDown(MoveDownKey))
                {
                    view.Y += 1;
                    handled = true;
                }

                console.TextSurface.RenderArea = view;
            }
            return(handled);
        }
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            if (info.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.Space))
                animation.Restart();

            return base.ProcessKeyboard(info);
        }
        public bool HandleKeyboard(IConsole console, KeyboardInfo info)
        {
            // Check each key pressed.
            foreach (var key in info.KeysPressed)
            {
                // If the character associated with the key pressed is a printable character, print it
                if (key.Character != '\0')
                    console.VirtualCursor.Print(key.Character.ToString());

                // Special character - BACKSPACE
                else if (key.XnaKey == Keys.Back)
                {
                    // Get the prompt that the console has.
                    string prompt = ((CustomConsoles.DOSConsole)console).Prompt;

                    // If the console has scrolled since the user started typing, adjust the starting row of the virtual cursor by that much.
                    if (console.CellData.TimesShiftedUp != 0)
                    {
                        VirtualCursorLastY -= console.CellData.TimesShiftedUp;
                        console.CellData.TimesShiftedUp = 0;
                    }

                    // Do not let them backspace into the prompt
                    if (console.VirtualCursor.Position.Y != VirtualCursorLastY || console.VirtualCursor.Position.X > prompt.Length)
                        console.VirtualCursor.LeftWrap(1).Print(" ").LeftWrap(1);
                }

                // Special character - ENTER
                else if (key.XnaKey == Keys.Enter)
                {
                    // If the console has scrolled since the user started typing, adjust the starting row of the virtual cursor by that much.
                    if (console.CellData.TimesShiftedUp != 0)
                    {
                        VirtualCursorLastY -= console.CellData.TimesShiftedUp;
                        console.CellData.TimesShiftedUp = 0;
                    }

                    // Get the prompt to exclude it in determining the total length of the string the user has typed.
                    string prompt = ((CustomConsoles.DOSConsole)console).Prompt;
                    int startingIndex = console.CellData.GetIndexFromPoint(new Point(prompt.Length, VirtualCursorLastY));
                    string data = console.CellData.GetString(startingIndex, console.CellData.GetIndexFromPoint(console.VirtualCursor.Position) - startingIndex);

                    // Move the cursor to the next line before we send the string data to the processor
                    console.VirtualCursor.CarriageReturn().LineFeed();

                    // Send the string data
                    EnterPressedAction(data);

                    // After they have processed the string, we will create a new line and display the prompt.
                    console.VirtualCursor.CarriageReturn().LineFeed();
                    console.VirtualCursor.Print(((CustomConsoles.DOSConsole)console).Prompt);
                    VirtualCursorLastY = console.VirtualCursor.Position.Y;

                    // Preparing the next lines could have scrolled the console, reset the counter
                    console.CellData.TimesShiftedUp = 0;
                }
            }

            return true;
        }
Exemple #4
0
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            // If the space key is pressed, run the fade
            if (info.IsKeyReleased(Keys.Space))
                startFade = true;

            // Do not pass the keyboard input to the child consoles, eat it.
            return true;
        }
Exemple #5
0
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            if (info.IsKeyReleased(Keys.Space))
            {
                Renderer = _renderer == oldRenderer ? cachedRenderer : oldRenderer;
                TextSurface.Tint = _renderer == oldRenderer ? Color.Transparent : new Color(255, 255, 255, 70);
            }

            return false;
        }
Exemple #6
0
 public override bool ProcessKeyboard(KeyboardInfo info)
 {
     return base.ProcessKeyboard(info);
 }
Exemple #7
0
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            bool keyHit = false;

            var newPosition = player.Position;

            if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Up)))
            {
                newPosition.Y -= 1;
                keyHit = true;
            }
            else if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Down)))
            {
                newPosition.Y += 1;
                keyHit = true;
            }

            if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Left)))
            {
                newPosition.X -= 1;
                keyHit = true;
            }
            else if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Right)))
            {
                newPosition.X += 1;
                keyHit = true;
            }

            // Test location
            if (map.IsWalkable(newPosition.X, newPosition.Y))
            {
                player.Position = newPosition;

                UpdatePlayerView();

            }

            return keyHit || base.ProcessKeyboard(info);
        }
Exemple #8
0
 public bool ProcessKeyboard(KeyboardInfo info, ITextSurface surface)
 {
     return false;
 }
 public override bool ProcessKeyboard(KeyboardInfo info)
 {
     return EditorConsoleManager.ProcessKeyboard(info);
 }
        public static bool ProcessKeyboard(KeyboardInfo info)
        {
            bool movekeyPressed = false;
            var position = new Point(borderConsole.Position.X + 1, borderConsole.Position.Y + 1);
            //var result = base.ProcessKeyboard(info);
            if (AllowKeyboardToMoveConsole && ActiveEditor != null && ActiveEditor.RenderedConsole != null)
            {
                bool shifted = info.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift) || info.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightShift);
                var oldRenderArea = ActiveEditor.RenderedConsole.TextSurface.RenderArea;

                if (!shifted && info.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left))
                    ActiveEditor.RenderedConsole.TextSurface.RenderArea = new Rectangle(ActiveEditor.RenderedConsole.TextSurface.RenderArea.Left - 1, ActiveEditor.RenderedConsole.TextSurface.RenderArea.Top, InnerEmptyBounds.Width, InnerEmptyBounds.Height);

                else if (!shifted && info.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right))
                    ActiveEditor.RenderedConsole.TextSurface.RenderArea = new Rectangle(ActiveEditor.RenderedConsole.TextSurface.RenderArea.Left + 1, ActiveEditor.RenderedConsole.TextSurface.RenderArea.Top, InnerEmptyBounds.Width, InnerEmptyBounds.Height);

                if (!shifted && info.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up))
                    ActiveEditor.RenderedConsole.TextSurface.RenderArea = new Rectangle(ActiveEditor.RenderedConsole.TextSurface.RenderArea.Left, ActiveEditor.RenderedConsole.TextSurface.RenderArea.Top - 1, InnerEmptyBounds.Width, InnerEmptyBounds.Height);

                else if (!shifted && info.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down))
                    ActiveEditor.RenderedConsole.TextSurface.RenderArea = new Rectangle(ActiveEditor.RenderedConsole.TextSurface.RenderArea.Left, ActiveEditor.RenderedConsole.TextSurface.RenderArea.Top + 1, InnerEmptyBounds.Width, InnerEmptyBounds.Height);

                movekeyPressed = oldRenderArea != ActiveEditor.RenderedConsole.TextSurface.RenderArea;
            }

            if (movekeyPressed)
            {
                ActiveEditor.Move(ActiveEditor.Position.X, ActiveEditor.Position.Y);
            }
            else
            {
                //if (info.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.Subtract))
                //{
                //	SelectedEditor.Surface.ResizeCells(SelectedEditor.Surface.CellSize.X / 2, SelectedEditor.Surface.CellSize.Y / 2);
                //}
                //else if (info.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.Add))
                //{
                //	SelectedEditor.Surface.ResizeCells(SelectedEditor.Surface.CellSize.X * 2, SelectedEditor.Surface.CellSize.Y * 2);
                //}
                //else
                {
                    // Look for tool hotkeys
                    if (ToolsPane.ProcessKeyboard(info))
                    {
                        return true;
                    }
                    // Look for quick select F* keys
                    else if (QuickSelectPane.ProcessKeyboard(info))
                    {
                        return true;
                    }
                    else if (ActiveEditor != null)
                    {
                        return ActiveEditor.ProcessKeyboard(info);
                    }
                }
            }

            return false;
        }
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            foreach (var tool in ToolsPanel.ToolsListBox.Items.Cast<ITool>())
            {
                foreach (var key in info.KeysPressed)
                {
                    if (key.Character == tool.Hotkey)
                    {
                        ToolsPanel.ToolsListBox.SelectedItem = tool;
                        return true;
                    }
                }
            }

            return false;
        }
Exemple #12
0
        public bool ProcessKeyboard(KeyboardInfo info, ITextSurface surface)
        {
            if (writing)
            {
                if (info.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape))
                {
                    writing = false;
                    Brush.IsVisible = false;
                    EditorConsoleManager.AllowKeyboardToMoveConsole = true;
                }
                else
                {
                    //tempConsole.TextSurface = (ITextSurfaceRendered)surface;
                    tempConsole.VirtualCursor.PrintAppearance = new CellAppearance(CharacterPickPanel.SharedInstance.SettingForeground, CharacterPickPanel.SharedInstance.SettingBackground);
                    tempConsole.ProcessKeyboard(info);
                    Brush.Position = tempConsole.VirtualCursor.Position;
                }

                return true;
            }

            return false;
        }
        public bool ProcessKeyboard(KeyboardInfo info)
        {
            bool toolHandled = toolsPanel.SelectedTool.ProcessKeyboard(info, textSurface);

            if (!toolHandled)
            {
                if (info.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.OemOpenBrackets))
                {
                    framesPanel.TryPreviousFrame();
                    return true;
                }

                else if (info.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.OemCloseBrackets))
                {
                    framesPanel.TryNextFrame();
                    return true;
                }
                else
                {
                    var keys = info.KeysReleased.Select(k => k.Character).ToList();

                    foreach (var item in tools.Values)
                    {
                        if (keys.Contains(item.Hotkey))
                        {
                            SelectedTool = item;
                            return true;
                        }
                    }
                }
            }

            return false;
        }
Exemple #14
0
        /// <summary>
        /// Called by the engine to process the keyboard. If the <see cref="KeyboardHandler"/> has been set, that will be called instead of this method.
        /// </summary>
        /// <param name="info">Keyboard information.</param>
        /// <returns>True when the keyboard had data and this console did something with it.</returns>
        public virtual bool ProcessKeyboard(KeyboardInfo info)
        {
            var handlerResult = KeyboardHandler == null ? false : KeyboardHandler(this, info);

            if (!handlerResult && this.CanUseKeyboard)
            {
                bool didSomething = false;
                foreach (var key in info.KeysPressed)
                {
                    if (key.Character == '\0')
                    {
                        switch (key.XnaKey)
                        {
                            case Keys.Space:
                                this._virtualCursor.Print(key.Character.ToString());
                                didSomething = true;
                                break;
                            case Keys.Enter:
                                this._virtualCursor.CarriageReturn().LineFeed();
                                didSomething = true;
                                break;
#if !SILVERLIGHT
                            case Keys.LeftShift:
                            case Keys.RightShift:
                            case Keys.LeftAlt:
                            case Keys.RightAlt:
                            case Keys.LeftControl:
                            case Keys.RightControl:
                            case Keys.LeftWindows:
                            case Keys.RightWindows:
                            case Keys.F1:case Keys.F2:case Keys.F3:case Keys.F4:case Keys.F5:case Keys.F6:case Keys.F7:case Keys.F8:case Keys.F9:case Keys.F10:
                            case Keys.F11:case Keys.F12:case Keys.F13:case Keys.F14:case Keys.F15:case Keys.F16:case Keys.F17:case Keys.F18:case Keys.F19:case Keys.F20:
                            case Keys.F21:case Keys.F22:case Keys.F23:case Keys.F24:
                            case Keys.Pause:
                            case Keys.Escape:
#else
							case Keys.Shift:
							case Keys.Alt:
							case Keys.Ctrl:
#endif
                                //this._virtualCursor.Print(key.Character.ToString());
                                break;
                            case Keys.Up:
                                this._virtualCursor.Up(1);
                                didSomething = true;
                                break;
                            case Keys.Left:
                                this._virtualCursor.Left(1);
                                didSomething = true;
                                break;
                            case Keys.Right:
                                this._virtualCursor.Right(1);
                                didSomething = true;
                                break;
                            case Keys.Down:
                                this._virtualCursor.Down(1);
                                didSomething = true;
                                break;
                            case Keys.None:
                                break;
                            case Keys.Back:
                                this._virtualCursor.Left(1).Print(" ").Left(1);
                                didSomething = true;
                                break;
                            default:
                                this._virtualCursor.Print(key.Character.ToString());
                                didSomething = true;
                                break;
                        }
                    }
                    else
                    {
                        this._virtualCursor.Print(key.Character.ToString());
                        didSomething = true;
                    }
                }

                return didSomething;
            }

            return handlerResult;
        }
 public override bool ProcessKeyboard(KeyboardInfo info)
 {
     return true;
 }
Exemple #16
0
 public override bool ProcessKeyboard(KeyboardInfo info)
 {
     return subView.ProcessKeyboard(info);
 }
Exemple #17
0
        /// <summary>
        /// Called when the control should process keyboard information.
        /// </summary>
        /// <param name="info">The keyboard information.</param>
        /// <returns>True if the keyboard was handled by this control.</returns>
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            if (info.KeysPressed.Count != 0)
            {
                if (DisableKeyboard)
                {
                    for (int i = 0; i < info.KeysPressed.Count; i++)
                    {
                        if (info.KeysPressed[i].XnaKey == Keys.Enter)
                        {
                            this.IsDirty = true;
                            DisableKeyboard = false;
                            Text = _editingText;
                        }
                    }
                    return true;
                }
                else
                {
                    System.Text.StringBuilder newText = new System.Text.StringBuilder(_editingText, this.Width - 1);

                    this.IsDirty = true;

					for (int i = 0; i < info.KeysPressed.Count; i++)
					{
						if (_isNumeric)
						{
							if (info.KeysPressed[i].XnaKey == Keys.Back && newText.Length != 0)
								newText.Remove(newText.Length - 1, 1);

							else if (info.KeysPressed[i].XnaKey == Keys.Enter)
							{
								DisableKeyboard = true;

								Text = _editingText;

								return true;
							}
							else if (info.KeysPressed[i].XnaKey == Keys.Escape)
							{
								DisableKeyboard = true;
								return true;
							}

							else if (char.IsDigit(info.KeysPressed[i].Character) || (_allowDecimalPoint && info.KeysPressed[i].Character == '.'))
							{
								newText.Append(info.KeysPressed[i].Character);
							}

							PositionCursor();
						}

						else
						{
							if (info.KeysPressed[i].XnaKey == Keys.Back && newText.Length != 0 && _carrotPos != 0)
							{
								if (_carrotPos == newText.Length)
									newText.Remove(newText.Length - 1, 1);
								else
									newText.Remove(_carrotPos - 1, 1);

								_carrotPos -= 1;

								if (_carrotPos == -1)
									_carrotPos = 0;
							}
							else if (info.KeysPressed[i].XnaKey == Keys.Space && (MaxLength == 0 || (MaxLength != 0 && newText.Length < MaxLength)))
							{
								newText.Insert(_carrotPos, ' ');
								_carrotPos++;

								if (_carrotPos > newText.Length)
									_carrotPos = newText.Length;
							}

							else if (info.KeysPressed[i].XnaKey == Keys.Delete && _carrotPos != newText.Length)
							{
								newText.Remove(_carrotPos, 1);

								if (_carrotPos > newText.Length)
									_carrotPos = newText.Length;
							}

							else if (info.KeysPressed[i].XnaKey == Keys.Enter)
							{
								Text = _editingText;
								DisableKeyboard = true;
								return true;
							}
							else if (info.KeysPressed[i].XnaKey == Keys.Escape)
							{
								DisableKeyboard = true;
								return true;
							}
							else if (info.KeysPressed[i].XnaKey == Keys.Left)
							{
								_carrotPos -= 1;

								if (_carrotPos == -1)
									_carrotPos = 0;
							}
							else if (info.KeysPressed[i].XnaKey == Keys.Right)
							{
								_carrotPos += 1;

								if (_carrotPos > newText.Length)
									_carrotPos = newText.Length;
							}

							else if (info.KeysPressed[i].XnaKey == Keys.Home)
							{
								_carrotPos = 0;
							}

							else if (info.KeysPressed[i].XnaKey == Keys.End)
							{
									_carrotPos = newText.Length;
							}

							else if (info.KeysPressed[i].Character != 0 && (MaxLength == 0 || (MaxLength != 0 && newText.Length < MaxLength)))
							{
								newText.Insert(_carrotPos, info.KeysPressed[i].Character);
								_carrotPos++;

								if (_carrotPos > newText.Length)
									_carrotPos = newText.Length;
							}

							// Test to see if carrot is off edge of box
							if (_carrotPos >= _width)
							{
								_leftDrawOffset = newText.Length - _width + 1;

								if (_leftDrawOffset < 0)
									_leftDrawOffset = 0;
							}
							else
							{
								_leftDrawOffset = 0;
							}
						}

					}

                    string newString = newText.ToString();
                    if (newString != _editingText)
                        _editingText = newString;

                    ValidateEdit();
                }

                return true;
            }

            return false;
        }
        public bool HandlerKeyboard(IConsole console, KeyboardInfo info)
        {
            //TODO: This is dependent on how fast update is working... Make independent
            bool handled = false;
            if (console.CanUseKeyboard && CanMoveWithKeyboard)
            {
                var view = console.TextSurface.RenderArea;

                if (info.IsKeyDown(MoveLeftKey))
                {
                    view.X -= 1;
                    handled = true;
                }
                else if (info.IsKeyDown(MoveRightKey))
                {
                    view.X += 1;
                    handled = true;
                }
                if (info.IsKeyDown(MoveUpKey))
                {
                    view.Y -= 1;
                    handled = true;
                }
                else if (info.IsKeyDown(MoveDownKey))
                {
                    view.Y += 1;
                    handled = true;
                }

                console.TextSurface.RenderArea = view;
            }
            return handled;
        }
Exemple #19
0
 public bool ProcessKeyboard(KeyboardInfo info)
 {
     return ((IConsole)baseConsole).ProcessKeyboard(info);
 }
Exemple #20
0
 /// <summary>
 /// Called when the keyboard is used on this control.
 /// </summary>
 /// <param name="info">The state of the keyboard.</param>
 public virtual bool ProcessKeyboard(KeyboardInfo info)
 {
     return false;
 }
Exemple #21
0
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            if (info.IsKeyReleased(Keys.C))
            {
                backIndex++;

                if (backIndex == backgroundcycle.Length)
                    backIndex = 0;

                var theme = Theme;
                theme.FillStyle.Background = backgroundcycle[backIndex];
                Theme = theme;

            }

            return base.ProcessKeyboard(info);
        }
        public bool ProcessKeyboard(KeyboardInfo info)
        {
            if (!toolsPanel.SelectedTool.ProcessKeyboard(info, textSurface))
            {
                var keys = info.KeysReleased.Select(k => k.Character).ToList();

                foreach (var item in tools.Values)
                {
                    if (keys.Contains(item.Hotkey))
                    {
                        SelectedTool = item;
                        return true;
                    }
                }

                return false;
            }

            return true;
        }
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            bool shifted = info.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift) || info.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightShift);

            if (shifted && info.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.Down))
            {
                currentCharSet++;

                if (currentCharSet >= CharacterSets.Length)
                    currentCharSet = 0;

                Characters = CharacterSets[currentCharSet];
                Redraw();
                return true;
            }
            else if (shifted && info.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.Up))
            {
                currentCharSet--;

                if (currentCharSet < 0)
                    currentCharSet = CharacterSets.Length - 1;

                Characters = CharacterSets[currentCharSet];
                Redraw();
                return true;
            }

            foreach (var key in info.KeysPressed)
            {
                for (int i = 0; i < keys.Length; i++)
                {
                    if (key == keys[i])
                    {
                        Panels.CharacterPickPanel.SharedInstance.SettingCharacter = Characters[i];
                        return true;
                    }
                }
            }

            return false;
        }
 public void ProcessKeyboard(KeyboardInfo info)
 {
     EditorConsoleManager.Instance.ToolPane.SelectedTool.ProcessKeyboard(info, _consoleLayers.ActiveLayer);
 }
Exemple #25
0
        /// <summary>
        /// Called when the control should process keyboard information.
        /// </summary>
        /// <param name="info">The keyboard information.</param>
        /// <returns>True if the keyboard was handled by this control.</returns>
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            if (info.KeysPressed.Count != 0)
            {
                if (DisableKeyboard)
                {
                    for (int i = 0; i < info.KeysPressed.Count; i++)
                    {
                        if (info.KeysPressed[i].XnaKey == Keys.Enter)
                        {
                            this.IsDirty = true;
                            DisableKeyboard = false;
                        }
                    }
                    return true;
                }
                else
                {
                    System.Text.StringBuilder newText = new System.Text.StringBuilder(_text, this.Width - 1);

                    this.IsDirty = true;

                    for (int i = 0; i < info.KeysPressed.Count; i++)
                    {
                        if (_isNumeric)
                        {
                            if (info.KeysPressed[i].XnaKey == Keys.Back && newText.Length != 0)
                                newText.Remove(newText.Length - 1, 1);

                            else if (info.KeysPressed[i].XnaKey == Keys.Enter || info.KeysPressed[i].XnaKey == Keys.Escape)
                            {
                                DisableKeyboard = true;

                                Validate();
                                Text = _text;

                                return true;
                            }

                            else if (char.IsDigit(info.KeysPressed[i].Character) || (_allowDecimalPoint && info.KeysPressed[i].Character == '.'))
                            {
                                newText.Append(info.KeysPressed[i].Character);
                            }
                        }

                        else
                        {
                            if (info.KeysPressed[i].XnaKey == Keys.Back && newText.Length != 0)
                                newText.Remove(newText.Length - 1, 1);
                            else if (info.KeysPressed[i].XnaKey == Keys.Space)
                                newText.Append(' ');
                            else if (info.KeysPressed[i].Character != 0)
                                newText.Append(info.KeysPressed[i].Character);
                            else if (info.KeysPressed[i].XnaKey == Keys.Enter || info.KeysPressed[i].XnaKey == Keys.Escape)
                                DisableKeyboard = true;
                        }

                    }

                    string newString = newText.ToString();
                    if (newString != _text)
                        _text = newString;

                    PositionCursor();
                }

                return true;
            }

            return false;
        }