public override void ProcessKeyboard(SadConsole.Console consoleObject, SadConsole.Input.Keyboard info, out bool handled)
        {
            // Upcast this because we know we're only using it with a Console type.
            var console = (ScrollingConsole)consoleObject;

            if (info.IsKeyDown(Keys.Left))
            {
                console.ViewPort = new Rectangle(console.ViewPort.Left - 1, console.ViewPort.Top, 80, 23);
            }

            if (info.IsKeyDown(Keys.Right))
            {
                console.ViewPort = new Rectangle(console.ViewPort.Left + 1, console.ViewPort.Top, 80, 23);
            }

            if (info.IsKeyDown(Keys.Up))
            {
                console.ViewPort = new Rectangle(console.ViewPort.Left, console.ViewPort.Top - 1, 80, 23);
            }

            if (info.IsKeyDown(Keys.Down))
            {
                console.ViewPort = new Rectangle(console.ViewPort.Left, console.ViewPort.Top + 1, 80, 23);
            }


            handled = true;
        }
        public override void ProcessKeyboard(IScreenObject consoleObject, SadConsole.Input.Keyboard info, out bool handled)
        {
            // Upcast this because we know we're only using it with a Console type.
            var console = (Console)consoleObject;

            if (info.IsKeyDown(Keys.Left))
            {
                console.ViewPosition = console.ViewPosition.Translate((-1, 0));
            }

            if (info.IsKeyDown(Keys.Right))
            {
                console.ViewPosition = console.ViewPosition.Translate((1, 0));
            }

            if (info.IsKeyDown(Keys.Up))
            {
                console.ViewPosition = console.ViewPosition.Translate((0, -1));
            }

            if (info.IsKeyDown(Keys.Down))
            {
                console.ViewPosition = console.ViewPosition.Translate((0, +1));
            }

            handled = true;
        }
示例#3
0
        public override bool ProcessKeyboard(SadConsole.Input.Keyboard info)
        {
            if (info.IsKeyDown(Keys.Left))
            {
                ViewPort = new Rectangle(ViewPort.Left - 1, ViewPort.Top, 80, 23);
            }

            if (info.IsKeyDown(Keys.Right))
            {
                ViewPort = new Rectangle(ViewPort.Left + 1, ViewPort.Top, 80, 23);
            }

            if (info.IsKeyDown(Keys.Up))
            {
                ViewPort = new Rectangle(ViewPort.Left, ViewPort.Top - 1, 80, 23);
            }

            if (info.IsKeyDown(Keys.Down))
            {
                ViewPort = new Rectangle(ViewPort.Left, ViewPort.Top + 1, 80, 23);
            }

            if (info.IsKeyReleased(Keys.Space))
            {
                NextAnsi();
                LoadAnsi();
            }

            if (info.IsKeyReleased(Keys.L))
            {
                if (writer == null || lineCounter == lines.Length)
                {
                    NextAnsi();
                    lineCounter = 0;
                    Clear();
                    lines  = doc.AnsiString.Split('\n');
                    writer = new SadConsole.Ansi.AnsiWriter(doc, this);
                }

                writer.AnsiReadLine(lines[lineCounter], true);

                lineCounter++;

                if (lineCounter > lines.Length)
                {
                    writer = null;
                }
            }

            return(true);
        }
示例#4
0
        /// <summary>
        /// Processes the keyboard for the console.
        /// </summary>
        /// <param name="info">Keyboard information sent by the engine.</param>
        public override bool ProcessKeyboard(Input.Keyboard info)
        {
            if (!UseGlobalKeyboardInput)
            {
                KeyboardState.Update(Global.GameTimeUpdate);
                info = KeyboardState;
            }

            var handlerResult = KeyboardHandler == null ? false : KeyboardHandler(this, info);

            if (!handlerResult && this.UseKeyboard)
            {
                bool canTab = true;

                if (FocusedControl != null)
                {
                    canTab = FocusedControl.TabStop;
                }

                if (canTab)
                {
                    if (
                        ((info.IsKeyDown(Keys.LeftShift) ||
                          info.IsKeyDown(Keys.RightShift)) ||

                         info.IsKeyReleased(Keys.LeftShift) ||
                         info.IsKeyReleased(Keys.RightShift))

                        &&
                        info.IsKeyReleased(Keys.Tab))
                    {
                        // TODO: Handle tab by changing focused control unless existing control doesn't support tab
                        TabPreviousControl();
                        return(true);
                    }
                    else if (info.IsKeyReleased(Keys.Tab))
                    {
                        // TODO: Handle tab by changing focused control unless existing control doesn't support tab
                        TabNextControl();
                        return(false);
                    }
                }

                if (FocusedControl != null && FocusedControl.IsEnabled && FocusedControl.UseKeyboard)
                {
                    return(FocusedControl.ProcessKeyboard(info));
                }
            }

            return(false);
        }
示例#5
0
        public override bool ProcessKeyboard(SadConsole.Input.Keyboard info)
        {
            if (info.IsKeyDown(Keys.Left))
            {
                View = View.WithPosition(new Point(View.Position.X - 1, View.Position.Y));
            }

            if (info.IsKeyDown(Keys.Right))
            {
                View = View.WithPosition(new Point(View.Position.X + 1, View.Position.Y));
            }

            if (info.IsKeyDown(Keys.Up))
            {
                View = View.WithPosition(new Point(View.Position.X, View.Position.Y - 1));
            }

            if (info.IsKeyDown(Keys.Down))
            {
                View = View.WithPosition(new Point(View.Position.X, View.Position.Y + 1));
            }

            if (info.IsKeyReleased(Keys.Space))
            {
                NextAnsi();
                LoadAnsi();
            }

            if (info.IsKeyReleased(Keys.L))
            {
                if (writer == null || lineCounter == lines.Length)
                {
                    NextAnsi();
                    lineCounter = 0;
                    this.Clear();
                    lines  = doc.AnsiString.Split('\n');
                    writer = new SadConsole.Ansi.AnsiWriter(doc, this);
                }

                writer.AnsiReadLine(lines[lineCounter], true);

                lineCounter++;

                if (lineCounter > lines.Length)
                {
                    writer = null;
                }
            }

            return(true);
        }
示例#6
0
        public override bool ProcessKeyboard(SadInput.Keyboard info)
        {
            // TODO use some StateMachine instead.

            if (info.IsKeyDown(Keys.Right))
            {
                Animation = Animations["WalkRight"];
            }
            else if (info.IsKeyDown(Keys.Left))
            {
                Animation = Animations["WalkLeft"];
            }
            else
            {
                Animation = Animations["Idle"];
            }

            Animation.Start();

            return(base.ProcessKeyboard(info));
        }
示例#7
0
    public override void ProcessKeyboard(SadConsole.Console console, Keyboard info, out bool handled)
    {
        handled = true;
        bool shift = info.IsKeyDown(Keys.LeftShift) || info.IsKeyDown(Keys.RightShift);         // could move this to line 36 if (info.IsKeyPressed(Keys.X)){ if this is an issue

        if (Program.world != null)
        {
            // movement keys can use else ifs since they are contradictory
            if (info.IsKeyPressed(Keys.Left))
            {
                Program.world.MoveCursor(-1, 0);
            }
            else if (info.IsKeyPressed(Keys.Right))
            {
                Program.world.MoveCursor(1, 0);
            }
            if (info.IsKeyPressed(Keys.Up))
            {
                Program.world.MoveCursor(0, -1);
            }
            else if (info.IsKeyPressed(Keys.Down))
            {
                Program.world.MoveCursor(0, 1);
            }
            // when released, update the map
            if (info.IsKeyReleased(Keys.Left) ||
                info.IsKeyReleased(Keys.Right) ||
                info.IsKeyReleased(Keys.Up) ||
                info.IsKeyReleased(Keys.Down)
                )
            {
                new Task(() => { Program.world.RedrawTooltip(); }).Start();
            }
            // ditto for zoom keys
            if (info.IsKeyPressed(Keys.OemPlus))
            {
                Program.world.Zoom(1);
            }
            else if (info.IsKeyPressed(Keys.OemMinus))
            {
                Program.world.Zoom(-1);
            }
            // other keys can be pressed simultaneously
            if (info.IsKeyPressed(Keys.E))
            {
                Program.world.selection.Embark();
                Program.Log("Embarked! (Not yet implemented...)");
            }
            if (info.IsKeyPressed(Keys.R))             // debug
            {
                Program.Log(People.NamingSystem.systems
                            [Program.rng.Next(0, People.NamingSystem.systems.Count)]
                            .RandomFromGender(MochaRandom.Bool()));
            }
            if (info.IsKeyPressed(Keys.S))             // save map
            {
                new Task(() => { Export.Celestia.ExportBitmap(); }).Start();
            }
            if (info.IsKeyPressed(Keys.X))
            {
                Mapping.CycleChar(shift ? -1 : 1);
                Program.world.Print();
            }
            if (info.IsKeyPressed(Keys.Z))
            {
                Mapping.CycleColor(shift ? -1 : 1);
                Program.world.Print();
            }
        }
        if (info.IsKeyPressed(Keys.Escape))
        {
            Program.Exit();
        }
    }
示例#8
0
    public override bool ProcessKeyboard(SadConsole.Input.Keyboard info)
    {
        int delta = 1;    //Distance moved by camera

        if (info.IsKeyDown(Keys.RightControl))
        {
            delta *= 8;
        }

        /*
         * if (info.IsKeyDown(Keys.RightControl)) {
         *  examineMenu.ListControls(info);
         * } else
         */
        if (info.IsKeyPressed(Keys.Up))
        {
            if (info.IsKeyDown(Keys.RightShift))
            {
                world.camera += new XYZ(0, 0, delta);
            }
            else
            {
                world.camera += new XYZ(0, delta);
            }
            UpdateExamine();
        }
        else if (info.IsKeyPressed(Keys.Down))
        {
            if (info.IsKeyDown(Keys.RightShift))
            {
                world.camera += new XYZ(0, 0, -delta);
            }
            else
            {
                world.camera += new XYZ(0, -delta);
            }
            UpdateExamine();
        }
        else if (info.IsKeyPressed(Keys.Left))
        {
            world.camera += new XYZ(-delta, 0);
            UpdateExamine();
        }
        else if (info.IsKeyPressed(Keys.Right))
        {
            world.camera += new XYZ(delta, 0);
            UpdateExamine();
        }
        else if (info.IsKeyPressed(Keys.Escape))
        {
            world.camera = world.player.Position;

            Parent.IsFocused = true;
            Parent.Children.Remove(this);
        }
        else if (info.IsKeyPressed(Keys.Enter))
        {
            selectAt(world.camera);
        }
        else
        {
            examineMenu.ListControls(info);
        }
        return(true);
    }