Esempio n. 1
0
        public override bool KeyDown(GameTime gameTime, KeyboardKeyEventArgs e)
        {
            if (!Editing)
            {
                if (e.Key == Keys.T)
                {
                    Editing = true;
                    return true;
                }
                return false;
            }
            if (e.Key == Keys.Back)
                Text = Text.Length > 0 ? Text.Substring(0, Text.Length - 1) : Text;
            else if (e.Key == Keys.Escape)
            {
                Editing = false;
                Text = string.Empty;
            }
            else if (e.Key == Keys.Enter)
            {
                Game.Client.SendMessage(Text);
                Editing = false;
                Text = string.Empty;
            }
            else
            {
                var shift = (Keyboard.GetState().IsKeyDown(Keys.LeftShift) || Keyboard.GetState().IsKeyDown(Keys.RightShift));
                var value = default(char);

                if (TryParseKey(e.Key, shift, out value))
                    Text += value;
            }
            return true;
        }
Esempio n. 2
0
 public override bool KeyDown(GameTime gameTime, KeyboardKeyEventArgs e)
 {
     switch (e.Key)
     {
         case Keys.F3:
             return true;
     }
     return false;
 }
Esempio n. 3
0
 public override bool KeyUp(GameTime gameTime, KeyboardKeyEventArgs e)
 {
     switch (e.Key)
     {
         case Keys.F3:
             Enabled = !Enabled;
             return true;
     }
     return false;
 }
Esempio n. 4
0
        /// <summary>
        /// Processes a change between two states.
        /// </summary>
        /// <param name="newState">The new state.</param>
        /// <param name="oldState">The old state.</param>
        private void Process(KeyboardState newState, KeyboardState oldState)
        {
            var currentKeys = newState.GetPressedKeys();
            var lastKeys = oldState.GetPressedKeys();

            // LINQ was a saviour here.
            var pressed = currentKeys.Except(lastKeys);
            var unpressed = lastKeys.Except(currentKeys);

            foreach (var key in pressed)
            {
                var args = new KeyboardKeyEventArgs(key, true);
                if (KeyDown != null)
                    KeyDown(this, args);
            }

            foreach (var key in unpressed)
            {
                var args = new KeyboardKeyEventArgs(key, false);
                if (KeyUp != null)
                    KeyUp(this, args);
            }
        }
 private void Game_KeyDown(object sender, KeyboardKeyEventArgs e)
 {
     activeInterface.Game_KeyDown(sender, e);
 }
Esempio n. 6
0
 private void Parent_KeyDown(KeyboardKeyEventArgs obj)
 => input.ProcessKeyDown(obj);
Esempio n. 7
0
 private static void Window_KeyDown(object sender, KeyboardKeyEventArgs e)
 {
     keysDown.Add(e.Key);
 }
Esempio n. 8
0
        public override void onKeyDown(object sender, KeyboardKeyEventArgs e)
        {
            //base.onKeyDown (sender, e);

            Key key = e.Key;

            if (e.Control)
            {
                switch (key)
                {
                case Key.S:
                    projFile.Save();
                    break;

                case Key.W:
                    editorMutex.EnterWriteLock();
                    if (e.Shift)
                    {
                        projFile.Redo(null);
                    }
                    else
                    {
                        projFile.Undo(null);
                    }
                    editorMutex.ExitWriteLock();
                    break;

                default:
                    Console.WriteLine("");
                    break;
                }
            }

            switch (key)
            {
            case Key.Back:
                buffer.Delete();
                break;

            case Key.Clear:
                break;

            case Key.Delete:
                if (buffer.SelectionIsEmpty)
                {
                    buffer.MoveRight();
                }
//				else if (e.Shift)
//					IFace.Clipboard = buffer.SelectedText;
                buffer.Delete();
                break;

            case Key.Enter:
            case Key.KeypadEnter:
                if (!buffer.SelectionIsEmpty)
                {
                    buffer.Delete();
                }
                buffer.InsertLineBreak();
                break;

            case Key.Escape:
                buffer.ResetSelection();
                break;

            case Key.Home:
                if (e.Shift)
                {
                    if (buffer.SelectionIsEmpty)
                    {
                        buffer.SetSelStartPos();
                    }
                    if (e.Control)
                    {
                        buffer.CurrentLine = 0;
                    }
                    buffer.CurrentColumn = 0;
                    buffer.SetSelEndPos();
                    break;
                }
                buffer.ResetSelection();
                if (e.Control)
                {
                    buffer.CurrentLine = 0;
                }
                buffer.CurrentColumn = 0;
                break;

            case Key.End:
                if (e.Shift)
                {
                    if (buffer.SelectionIsEmpty)
                    {
                        buffer.SetSelStartPos();
                    }
                    if (e.Control)
                    {
                        buffer.CurrentLine = int.MaxValue;
                    }
                    buffer.CurrentColumn = int.MaxValue;
                    buffer.SetSelEndPos();
                    break;
                }
                buffer.ResetSelection();
                if (e.Control)
                {
                    buffer.CurrentLine = int.MaxValue;
                }
                buffer.CurrentColumn = int.MaxValue;
                break;

            case Key.Insert:
                if (e.Shift)
                {
                    buffer.InsertAt(IFace.Clipboard);
                }
                else if (e.Control && !buffer.SelectionIsEmpty)
                {
                    IFace.Clipboard = buffer.SelectedText;
                }
                break;

            case Key.Left:
                if (e.Shift)
                {
                    if (buffer.SelectionIsEmpty)
                    {
                        buffer.SetSelStartPos();
                    }
                    if (e.Control)
                    {
                        buffer.GotoWordStart();
                    }
                    else
                    {
                        buffer.MoveLeft();
                    }
                    buffer.SetSelEndPos();
                    break;
                }
                buffer.ResetSelection();
                if (e.Control)
                {
                    buffer.GotoWordStart();
                }
                else
                {
                    buffer.MoveLeft();
                }
                break;

            case Key.Right:
                if (e.Shift)
                {
                    if (buffer.SelectionIsEmpty)
                    {
                        buffer.SetSelStartPos();
                    }
                    if (e.Control)
                    {
                        buffer.GotoWordEnd();
                    }
                    else
                    {
                        buffer.MoveRight();
                    }
                    buffer.SetSelEndPos();
                    break;
                }
                buffer.ResetSelection();
                if (e.Control)
                {
                    buffer.GotoWordEnd();
                }
                else
                {
                    buffer.MoveRight();
                }
                break;

            case Key.Up:
                if (e.Shift)
                {
                    if (buffer.SelectionIsEmpty)
                    {
                        buffer.SetSelStartPos();
                    }
                    CurrentLine--;
                    buffer.SetSelEndPos();
                    break;
                }
                buffer.ResetSelection();
                CurrentLine--;
                break;

            case Key.Down:
                if (e.Shift)
                {
                    if (buffer.SelectionIsEmpty)
                    {
                        buffer.SetSelStartPos();
                    }
                    CurrentLine++;
                    buffer.SetSelEndPos();
                    break;
                }
                buffer.ResetSelection();
                CurrentLine++;
                break;

            case Key.Menu:
                break;

            case Key.NumLock:
                break;

            case Key.PageDown:
                if (e.Shift)
                {
                    if (buffer.SelectionIsEmpty)
                    {
                        buffer.SetSelStartPos();
                    }
                    CurrentLine += visibleLines;
                    buffer.SetSelEndPos();
                    break;
                }
                buffer.ResetSelection();
                CurrentLine += visibleLines;
                break;

            case Key.PageUp:
                if (e.Shift)
                {
                    if (buffer.SelectionIsEmpty)
                    {
                        buffer.SetSelStartPos();
                    }
                    CurrentLine -= visibleLines;
                    buffer.SetSelEndPos();
                    break;
                }
                buffer.ResetSelection();
                CurrentLine -= visibleLines;
                break;

            case Key.RWin:
                break;

            case Key.Tab:
                buffer.InsertAt("\t");
                break;

            default:
                break;
            }
            RegisterForGraphicUpdate();
        }
Esempio n. 9
0
 protected override void OnKeyDown(KeyboardKeyEventArgs e)
 {
     base.OnKeyDown(e);
 }
Esempio n. 10
0
        void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
        {
            // This method is handling the "You are dead, enter name" keyboard input.
            // It is a very, very primitive implementation, but it should work.
            if (Player.Instance == null && (this.highscore.Count() < 10 || Player.Score > this.highscore.Min(entry => entry.Score)))
            {
                DualityApp.Keyboard.KeyRepeat = true;
                if (this.gameOverEnterName == null)
                {
                    this.gameOverEnterName = "";
                }

                if (e.Key == Key.Enter || e.Key == Key.KeypadEnter)
                {
                    // Write to highscore - back to main menu happens because the GameSceneController reacts to it anyway.
                    this.highscore.Insert(0, new HighscoreEntry(this.gameOverEnterName, Player.Score));
                    this.highscore.StableSort((entry1, entry2) => entry2.Score - entry1.Score);
                    if (this.highscore.Count > 10)
                    {
                        this.highscore.RemoveAt(10);
                    }

                    DualityApp.Keyboard.KeyRepeat = false;
                }
                else if (e.Key == Key.Escape)
                {
                    // Don't save score, but reset key repeat
                    DualityApp.Keyboard.KeyRepeat = false;
                }
                else if (e.Key == Key.BackSpace)
                {
                    this.gameOverEnterName = this.gameOverEnterName.Substring(0, MathF.Max(0, this.gameOverEnterName.Length - 1));
                }
                else if (e.Key == Key.Delete)
                {
                    this.gameOverEnterName = "";
                }
                else if (this.gameOverEnterName.Length < 10)
                {
                    string enumName = e.Key.ToString();
                    if (enumName.Length == 1)
                    {
                        this.gameOverEnterName += (DualityApp.Keyboard[Key.ShiftLeft] || DualityApp.Keyboard[Key.ShiftRight]) ? enumName[0] : char.ToLower(enumName[0]);
                    }
                    else
                    {
                        switch (e.Key)
                        {
                        case Key.Space:         { this.gameOverEnterName += ' '; break; }

                        case Key.Number0:       { this.gameOverEnterName += '0'; break; }

                        case Key.Number1:       { this.gameOverEnterName += '1'; break; }

                        case Key.Number2:       { this.gameOverEnterName += '2'; break; }

                        case Key.Number3:       { this.gameOverEnterName += '3'; break; }

                        case Key.Number4:       { this.gameOverEnterName += '4'; break; }

                        case Key.Number5:       { this.gameOverEnterName += '5'; break; }

                        case Key.Number6:       { this.gameOverEnterName += '6'; break; }

                        case Key.Number7:       { this.gameOverEnterName += '7'; break; }

                        case Key.Number8:       { this.gameOverEnterName += '8'; break; }

                        case Key.Number9:       { this.gameOverEnterName += '9'; break; }
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        public override bool KeyDown(GameTime gameTime, KeyboardKeyEventArgs e)
        {
            switch (e.Key)
            {
                // Exit game
                case Keys.Escape:
                    Process.GetCurrentProcess().Kill();
                    return true;

                // Take a screenshot.
                case Keys.F2:
                    Game.TakeScreenshot();
                    return true;

                // Move to the left.
                case Keys.A:
                case Keys.Left:
                    Delta += XVector3.Left;
                    return true;

                // Move to the right.
                case Keys.D:
                case Keys.Right:
                    Delta += XVector3.Right;
                    return true;

                // Move forwards.
                case Keys.W:
                case Keys.Up:
                    Delta += XVector3.Forward;
                    return true;

                // Move backwards.
                case Keys.S:
                case Keys.Down:
                    Delta += XVector3.Backward;
                    return true;

                case Keys.I:
                    Game.Client.Position = Game.Client.Position.Floor();
                    return true;

                case Keys.Tab:
                    Capture = !Capture;
                    return true;

                case Keys.E:
                    Game.Client.CurrentWindow = Game.Client.Inventory;
                    return true;

                case Keys.Space:
                    if (Math.Floor(Game.Client.Position.Y) == Game.Client.Position.Y)
                        Game.Client.Velocity += TrueCraft.API.Vector3.Up * 0.3;
                    return true;

                case Keys.D1:
                case Keys.NumPad1:
                    Game.Client.HotbarSelection = 0;
                    return true;

                case Keys.D2:
                case Keys.NumPad2:
                    Game.Client.HotbarSelection = 1;
                    return true;

                case Keys.D3:
                case Keys.NumPad3:
                    Game.Client.HotbarSelection = 2;
                    return true;

                case Keys.D4:
                case Keys.NumPad4:
                    Game.Client.HotbarSelection = 3;
                    return true;

                case Keys.D5:
                case Keys.NumPad5:
                    Game.Client.HotbarSelection = 4;
                    return true;

                case Keys.D6:
                case Keys.NumPad6:
                    Game.Client.HotbarSelection = 5;
                    return true;

                case Keys.D7:
                case Keys.NumPad7:
                    Game.Client.HotbarSelection = 6;
                    return true;

                case Keys.D8:
                case Keys.NumPad8:
                    Game.Client.HotbarSelection = 7;
                    return true;

                case Keys.D9:
                case Keys.NumPad9:
                    Game.Client.HotbarSelection = 8;
                    return true;
            }
            return false;
        }
Esempio n. 12
0
 private void OnKeyUp(object sender, KeyboardKeyEventArgs e)
 {
     _uiKeyboardState[new Ui.Framework.Input.Key(e.Key.ToString())] = false;
 }
Esempio n. 13
0
 protected void OnKeyUp(object sender, KeyboardKeyEventArgs e)
 {
     KeyboardInput.KeyUp(sender, e);
 }
Esempio n. 14
0
        void OnKeyDown(object sender, KeyboardKeyEventArgs e)
        {
//            e.Key
        }
Esempio n. 15
0
 void Keyboard_KeyUp(object sender, KeyboardKeyEventArgs e)
 {
     _input.ProcessKeyUp(e);
 }
Esempio n. 16
0
 private void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
 {
     sceneManager.ChangeScene(0);
 }
 public void OnKeyUp(KeyboardKeyEventArgs args)
 {
     keyStates[args.Key] = false;
 }
Esempio n. 18
0
        // process events
        internal static void KeyDown(object sender, KeyboardKeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.LShift:
            case Key.RShift:
                ShiftPressed = true;
                break;

            case Key.F5:
                // reset
                RefreshObjects();
                break;

            case Key.F7:
            {
                OpenFileDialog Dialog = new OpenFileDialog
                {
                    CheckFileExists = true,
                    Multiselect     = true,
                    Filter          = @"All supported object files|*.csv;*.b3d;*.x;*.animated;extensions.cfg;*.l3dobj;*.l3dgrp;*.obj;*.s|openBVE Objects|*.csv;*.b3d;*.x;*.animated;extensions.cfg|LokSim 3D Objects|*.l3dobj;*.l3dgrp|Wavefront Objects|*.obj|Microsoft Train Simulator Objects|*.s|All files|*"
                };
                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                    Application.DoEvents();
                    string[] f = Dialog.FileNames;
                    for (int i = 0; i < f.Length; i++)
                    {
                        string currentTrainFolder = string.Empty;
                        if (f[i].EndsWith(".dat", StringComparison.InvariantCultureIgnoreCase) || f[i].EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase) || f[i].EndsWith(".cfg", StringComparison.InvariantCultureIgnoreCase))
                        {
                            // only check to see if it's a train if this is a specified filetype, else we'll start loading the full train from an object in it's folder
                            currentTrainFolder = System.IO.Path.GetDirectoryName(f[i]);
                        }
                        for (int j = 0; j < Program.CurrentHost.Plugins.Length; j++)
                        {
                            if (Program.CurrentHost.Plugins[j].Route != null && Program.CurrentHost.Plugins[j].Route.CanLoadRoute(f[i]))
                            {
                                // oops, that's actually a routefile- Let's show Route Viewer
                                string File = System.IO.Path.Combine(Application.StartupPath, "RouteViewer.exe");
                                if (System.IO.File.Exists(File))
                                {
                                    System.Diagnostics.Process.Start(File, "\"" + f[i] + "\"");
                                }
                            }

                            if (Program.CurrentHost.Plugins[j].Object != null && Program.CurrentHost.Plugins[j].Object.CanLoadObject(f[i]))
                            {
                                Files.Add(f[i]);
                            }
                            if (!string.IsNullOrEmpty(currentTrainFolder) && Program.CurrentHost.Plugins[j].Train != null && Program.CurrentHost.Plugins[j].Train.CanLoadTrain(currentTrainFolder))
                            {
                                Files.Add(f[i]);
                            }
                        }
                    }
                }
                else
                {
                    if (Program.CurrentHost.MonoRuntime)
                    {
                        //HACK: Dialog doesn't close properly when pressing the ESC key under Mono
                        //Avoid calling Application.DoEvents() unless absolutely necessary though!
                        Application.DoEvents();
                    }
                }
                Dialog.Dispose();
                RefreshObjects();
            }
            break;

            case Key.F9:
                if (Interface.LogMessages.Count != 0)
                {
                    formMessages.ShowMessages();
                    Application.DoEvents();
                }
                break;

            case Key.Delete:
                LightingRelative = -1.0;
                Game.Reset();
                Files = new List <string>();
                NearestTrain.UpdateSpecs();
                Renderer.ApplyBackgroundColor();
                break;

            case Key.Left:
                RotateX = -1;
                break;

            case Key.Right:
                RotateX = 1;
                break;

            case Key.Up:
                RotateY = -1;
                break;

            case Key.Down:
                RotateY = 1;
                break;

            case Key.A:
            case Key.Keypad4:
                MoveX = -1;
                break;

            case Key.D:
            case Key.Keypad6:
                MoveX = 1;
                break;

            case Key.Keypad8:
                MoveY = 1;
                break;

            case Key.Keypad2:
                MoveY = -1;
                break;

            case Key.W:
            case Key.Keypad9:
                MoveZ = 1;
                break;

            case Key.S:
            case Key.Keypad3:
                MoveZ = -1;
                break;

            case Key.Keypad5:
                Renderer.Camera.Reset(new Vector3(-5.0, 2.5, -25.0));
                break;

            case Key.F:
            case Key.F1:
                Renderer.OptionWireFrame = !Renderer.OptionWireFrame;
                break;

            case Key.N:
            case Key.F2:
                Renderer.OptionNormals = !Renderer.OptionNormals;
                break;

            case Key.L:
            case Key.F3:
                LightingTarget = 1 - LightingTarget;
                break;

            case Key.I:
            case Key.F4:
                Renderer.OptionInterface = !Renderer.OptionInterface;
                break;

            case Key.F8:
                formOptions.ShowOptions();
                Application.DoEvents();
                break;

            case Key.F10:
                formTrain.ShowTrainSettings();
                break;

            case Key.G:
            case Key.C:
                Renderer.OptionCoordinateSystem = !Renderer.OptionCoordinateSystem;
                break;

            case Key.B:
                if (ShiftPressed)
                {
                    using (ColorDialog dialog = new ColorDialog {
                        FullOpen = true
                    })
                    {
                        if (dialog.ShowDialog() == DialogResult.OK)
                        {
                            Renderer.BackgroundColor = -1;
                            Renderer.ApplyBackgroundColor(dialog.Color.R, dialog.Color.G, dialog.Color.B);
                        }
                    }
                }
                else
                {
                    Renderer.BackgroundColor++;
                    if (Renderer.BackgroundColor >= NewRenderer.MaxBackgroundColor)
                    {
                        Renderer.BackgroundColor = 0;
                    }
                    Renderer.ApplyBackgroundColor();
                }
                break;

            case Key.R:
                Renderer.SwitchOpenGLVersion();
                break;

            case Key.F11:
                Renderer.RenderStatsOverlay = !Renderer.RenderStatsOverlay;
                break;
            }
        }
Esempio n. 19
0
 private void Keyboard_KeyUp(object sender, KeyboardKeyEventArgs e)
 {
   Microsoft.Xna.Framework.Input.Keys keys = KeyboardUtil.ToXna(e.Key);
   if (!this.keys.Contains(keys))
     return;
   this.keys.Remove(keys);
 }
Esempio n. 20
0
 void dev_KeyDown(object sender, KeyboardKeyEventArgs e)
 {
     keys[(int)e.Key] = true;
     Root.Instance.ClientOnKeyDown(e.Key);
 }
Esempio n. 21
0
 private void OnKeyDown(object sender, KeyboardKeyEventArgs e)
 {
     ImGui.GetIO().KeysDown[(int)e.Key] = true;
     UpdateModifiers(e);
 }
Esempio n. 22
0
 private void OnKeyUp(object sender, KeyboardKeyEventArgs keyboardKeyEventArgs)
 {
 }
Esempio n. 23
0
        internal static void keyDownEvent(object sender, KeyboardKeyEventArgs e)
        {
            double speedModified = (ShiftPressed ? 2.0 : 1.0) * (ControlPressed ? 4.0 : 1.0) * (AltPressed ? 8.0 : 1.0);

            switch (e.Key)
            {
            case Key.ShiftLeft:
            case Key.ShiftRight:
                ShiftPressed = true;
                break;

            case Key.ControlLeft:
            case Key.ControlRight:
                ControlPressed = true;
                break;

            case Key.LAlt:
            case Key.RAlt:
                AltPressed = true;
                break;

            case Key.F5:
                if (CurrentRoute != null && CurrentlyLoading == false)
                {
                    Bitmap bitmap = null;
                    CurrentlyLoading         = true;
                    Renderer.OptionInterface = false;
                    if (!Interface.CurrentOptions.LoadingBackground)
                    {
                        Renderer.RenderScene(0.0);
                        currentGameWindow.SwapBuffers();
                        bitmap = new Bitmap(Renderer.ScreenWidth, Renderer.ScreenHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                        BitmapData bData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, bitmap.PixelFormat);
                        GL.ReadPixels(0, 0, Renderer.ScreenWidth, Renderer.ScreenHeight, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bData.Scan0);
                        bitmap.UnlockBits(bData);
                        bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
                        Renderer.TextureLoadingBkg = Textures.RegisterTexture(bitmap, new TextureParameters(null, null));
                    }
                    World.CameraAlignment a = World.CameraCurrentAlignment;
                    if (LoadRoute())
                    {
                        World.CameraCurrentAlignment = a;
                        TrackManager.UpdateTrackFollower(ref World.CameraTrackFollower, -1.0, true, false);
                        TrackManager.UpdateTrackFollower(ref World.CameraTrackFollower, a.TrackPosition, true, false);
                        World.CameraAlignmentDirection = new World.CameraAlignment();
                        World.CameraAlignmentSpeed     = new World.CameraAlignment();
                        ObjectManager.UpdateVisibility(a.TrackPosition, true);
                        ObjectManager.UpdateAnimatedWorldObjects(0.0, true);
                    }

                    CurrentlyLoading         = false;
                    Renderer.OptionInterface = true;
                    Textures.UnloadTexture(Renderer.TextureLoadingBkg);
                    if (bitmap != null)
                    {
                        bitmap.Dispose();
                    }
                }
                break;

            case Key.F7:
                if (CurrentlyLoading == true)
                {
                    break;
                }
                OpenFileDialog Dialog = new OpenFileDialog();
                Dialog.CheckFileExists = true;
                Dialog.Filter          = @"CSV/RW files|*.csv;*.rw|All files|*";
                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                    Application.DoEvents();
                    CurrentlyLoading = true;
                    CurrentRoute     = Dialog.FileName;
                    LoadRoute();
                    ObjectManager.UpdateAnimatedWorldObjects(0.0, true);
                    CurrentlyLoading = false;
                    UpdateCaption();
                }
                else
                {
                    if (Program.CurrentlyRunOnMono)
                    {
                        //HACK: Dialog doesn't close properly when pressing the ESC key under Mono
                        //Avoid calling Application.DoEvents() unless absolutely necessary though!
                        Application.DoEvents();
                    }
                }
                Dialog.Dispose();
                break;

            case Key.F8:
                if (Program.CurrentlyLoading == true)
                {
                    //Don't allow the user to update the settings during loading, bad idea....
                    break;
                }
                if (formOptions.ShowOptions() == DialogResult.OK)
                {
                    UpdateGraphicsSettings();
                }
                Application.DoEvents();
                break;

            case Key.F9:
                if (Interface.MessageCount != 0)
                {
                    formMessages.ShowMessages();
                    Application.DoEvents();
                }
                break;

            case Key.F10:
                Renderer.RenderStatsOverlay = !Renderer.RenderStatsOverlay;
                break;

            case Key.A:
            case Key.Keypad4:
                World.CameraAlignmentDirection.Position.X = -World.CameraExteriorTopSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.D:
            case Key.Keypad6:
                World.CameraAlignmentDirection.Position.X = World.CameraExteriorTopSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.Keypad2:
                World.CameraAlignmentDirection.Position.Y = -World.CameraExteriorTopSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.Keypad8:
                World.CameraAlignmentDirection.Position.Y = World.CameraExteriorTopSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.W:
            case Key.Keypad9:
                World.CameraAlignmentDirection.TrackPosition = World.CameraExteriorTopSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.S:
            case Key.Keypad3:
                World.CameraAlignmentDirection.TrackPosition = -World.CameraExteriorTopSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.Left:
                World.CameraAlignmentDirection.Yaw = -World.CameraExteriorTopAngularSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.Right:
                World.CameraAlignmentDirection.Yaw = World.CameraExteriorTopAngularSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.Up:
                World.CameraAlignmentDirection.Pitch = World.CameraExteriorTopAngularSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.Down:
                World.CameraAlignmentDirection.Pitch = -World.CameraExteriorTopAngularSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.KeypadDivide:
                World.CameraAlignmentDirection.Roll = -World.CameraExteriorTopAngularSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.KeypadMultiply:
                World.CameraAlignmentDirection.Roll = World.CameraExteriorTopAngularSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.Keypad0:
                World.CameraAlignmentDirection.Zoom = World.CameraZoomTopSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.KeypadPeriod:
                World.CameraAlignmentDirection.Zoom = -World.CameraZoomTopSpeed * speedModified;
                CpuReducedMode = false;
                break;

            case Key.Keypad1:
                Game.ApplyPointOfInterest(-1, true);
                CpuReducedMode = false;
                break;

            case Key.Keypad7:
                Game.ApplyPointOfInterest(1, true);
                CpuReducedMode = false;
                break;

            case Key.PageUp:
                JumpToStation(1);
                CpuReducedMode = false;
                break;

            case Key.PageDown:
                JumpToStation(-1);
                CpuReducedMode = false;
                break;

            case Key.Keypad5:
                World.CameraCurrentAlignment.Yaw      = 0.0;
                World.CameraCurrentAlignment.Pitch    = 0.0;
                World.CameraCurrentAlignment.Roll     = 0.0;
                World.CameraCurrentAlignment.Position = new Vector3(0.0, 2.5, 0.0);
                World.CameraCurrentAlignment.Zoom     = 0.0;
                World.CameraAlignmentDirection        = new World.CameraAlignment();
                World.CameraAlignmentSpeed            = new World.CameraAlignment();
                World.VerticalViewingAngle            = World.OriginalVerticalViewingAngle;
                UpdateViewport();
                World.UpdateAbsoluteCamera(0.0);
                World.UpdateViewingDistances();
                CpuReducedMode = false;
                break;

            case Key.F:
                Renderer.OptionWireframe = !Renderer.OptionWireframe;
                CpuReducedMode           = false;
                if (Renderer.OptionWireframe)
                {
                    GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
                }
                else
                {
                    GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
                }
                break;

            case Key.N:
                Renderer.OptionNormals = !Renderer.OptionNormals;
                CpuReducedMode         = false;
                break;

            case Key.E:
                Renderer.OptionEvents = !Renderer.OptionEvents;
                CpuReducedMode        = false;
                break;

            case Key.C:
                CpuAutomaticMode = !CpuAutomaticMode;
                CpuReducedMode   = false;
                break;

            case Key.I:
                Renderer.OptionInterface = !Renderer.OptionInterface;
                CpuReducedMode           = false;
                break;

            case Key.M:
                //SoundManager.Mute = !SoundManager.Mute;
                break;

            case Key.Plus:
            case Key.KeypadPlus:
                if (!JumpToPositionEnabled)
                {
                    JumpToPositionEnabled = true;
                    JumpToPositionValue   = "+";
                    CpuReducedMode        = false;
                }
                break;

            case Key.Minus:
            case Key.KeypadMinus:
                if (!JumpToPositionEnabled)
                {
                    JumpToPositionEnabled = true;
                    JumpToPositionValue   = "-";
                    CpuReducedMode        = false;
                }
                break;

            case Key.Number0:
            case Key.Number1:
            case Key.Number2:
            case Key.Number3:
            case Key.Number4:
            case Key.Number5:
            case Key.Number6:
            case Key.Number7:
            case Key.Number8:
            case Key.Number9:
                if (!JumpToPositionEnabled)
                {
                    JumpToPositionEnabled = true;
                    JumpToPositionValue   = string.Empty;
                }
                JumpToPositionValue += char.ConvertFromUtf32(48 + e.Key - Key.Number0);
                CpuReducedMode       = false;
                break;

            case Key.Period:
                if (!JumpToPositionEnabled)
                {
                    JumpToPositionEnabled = true;
                    JumpToPositionValue   = "0.";
                }
                else if (JumpToPositionValue.IndexOf('.') == -1)
                {
                    JumpToPositionValue += ".";
                }
                CpuReducedMode = false;
                break;

            case Key.BackSpace:
                if (JumpToPositionEnabled && JumpToPositionValue.Length != 0)
                {
                    JumpToPositionValue = JumpToPositionValue.Substring(0, JumpToPositionValue.Length - 1);
                    CpuReducedMode      = false;
                }
                break;

            case Key.Enter:
                if (JumpToPositionEnabled)
                {
                    if (JumpToPositionValue.Length != 0)
                    {
                        int direction;
                        if (JumpToPositionValue[0] == '-')
                        {
                            JumpToPositionValue = JumpToPositionValue.Substring(1);
                            direction           = -1;
                        }
                        else if (JumpToPositionValue[0] == '+')
                        {
                            JumpToPositionValue = JumpToPositionValue.Substring(1);
                            direction           = 1;
                        }
                        else
                        {
                            direction = 0;
                        }
                        double value;
                        if (double.TryParse(JumpToPositionValue, NumberStyles.Float, CultureInfo.InvariantCulture,
                                            out value))
                        {
                            if (value < TrackManager.CurrentTrack.Elements[TrackManager.CurrentTrack.Elements.Length - 1].StartingTrackPosition + 100 && value > MinimumJumpToPositionValue - 100)
                            {
                                if (direction != 0)
                                {
                                    value = World.CameraTrackFollower.TrackPosition + (double)direction * value;
                                }
                                TrackManager.UpdateTrackFollower(ref World.CameraTrackFollower, value, true, false);
                                World.CameraCurrentAlignment.TrackPosition = value;
                                World.UpdateAbsoluteCamera(0.0);
                                World.UpdateViewingDistances();
                            }
                        }
                    }
                }
                JumpToPositionEnabled = false;
                CpuReducedMode        = false;
                break;

            case Key.Escape:
                JumpToPositionEnabled = false;
                CpuReducedMode        = false;
                break;
            }
        }
Esempio n. 24
0
 public override bool KeyUp(GameTime gameTime, KeyboardKeyEventArgs e)
 {
     return Editing;
 }
Esempio n. 25
0
 public virtual bool KeyDown(GameTime gameTime, KeyboardKeyEventArgs e)
 {
     return(false);
 }
Esempio n. 26
0
 public KeyboardKeyEvent(KeyboardKeyEventArgs e)
 {
     this.keyboardKeyEvent = e;
 }
Esempio n. 27
0
 void KeyUpHandler(object sender, KeyboardKeyEventArgs e)
 {
     modifiers = e.Modifiers;
 }
Esempio n. 28
0
        private void HandleKeyDown(object sender, KeyboardKeyEventArgs keyEventArgs)
        {
            int texmax = GL.GetInteger(GetPName.MaxTextureSize);

            switch (keyEventArgs.Key)
            {
            case Key.Escape:
                Exit();
                break;

            case Key.Space:
            case Key.Right:
                currentDemoPage++;
                break;

            case Key.BackSpace:
            case Key.Left:
                currentDemoPage--;
                break;

            case Key.Enter:
            {
                if (currentDemoPage == 4)
                {
                    boundsAnimationCnt = 0f;
                }
                break;
            }

            case Key.Up:
            {
                if (currentDemoPage == 4)
                {
                    if (cycleAlignment == QFontAlignment.Justify)
                    {
                        cycleAlignment = QFontAlignment.Left;
                    }
                    else
                    {
                        cycleAlignment++;
                    }
                }
                break;
            }

            case Key.Down:
            {
                if (currentDemoPage == 4)
                {
                    if (cycleAlignment == QFontAlignment.Left)
                    {
                        cycleAlignment = QFontAlignment.Justify;
                    }
                    else
                    {
                        cycleAlignment--;
                    }
                }
                break;
            }

            case Key.F9:
                break;
            }

            if (currentDemoPage > lastPage)
            {
                currentDemoPage = lastPage;
            }
            if (currentDemoPage < 0)
            {
                currentDemoPage = 0;
            }
        }
Esempio n. 29
0
 protected override void OnKeyDown(KeyboardKeyEventArgs e)
 {
     base.OnKeyDown(e);
     //camera.Update();
 }
Esempio n. 30
0
 private void KeyDown(object sender, KeyboardKeyEventArgs e)
 {
     Handle(ScaleMode.KeyPress, e.Keyboard, 1);
 }
Esempio n. 31
0
 public override bool KeyUp(GameTime gameTime, KeyboardKeyEventArgs e)
 {
     return(Editing);
 }
Esempio n. 32
0
 public override bool OnKey(KeyboardKeyEventArgs E, bool Pressed)
 {
     return(StateMgr.OnKey(E, Pressed));
 }
Esempio n. 33
0
 private unsafe void OnKeyUp(object sender, KeyboardKeyEventArgs e)
 {
     ImGui.GetIO().KeysDown[(int)e.Key] = false;
     UpdateModifiers(e);
 }
Esempio n. 34
0
 void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
 {
     InputHandler.ProcessKeyDown(e);
 }
Esempio n. 35
0
 protected override void OnKeyDown(KeyboardKeyEventArgs e)
 {
     Keyboard = e.Keyboard;
 }
Esempio n. 36
0
 public override bool KeyDown(GameTime gameTime, KeyboardKeyEventArgs e)
 {
     if (Game.Client.CurrentWindow != null)
     {
         if (e.Key == Keys.Escape)
         {
             if (Game.Client.CurrentWindow.Type != -1)
                 Game.Client.QueuePacket(new CloseWindowPacket(Game.Client.CurrentWindow.ID));
             Game.Client.CurrentWindow = null;
             Mouse.SetPosition(Game.GraphicsDevice.Viewport.Width / 2, Game.GraphicsDevice.Viewport.Height / 2);
         }
         return true;
     }
     return base.KeyDown(gameTime, e);
 }
Esempio n. 37
0
 private void OnKeyboardKeyUp(object sender, KeyboardKeyEventArgs e)
 {
     foreach (var module in InputModules)
     {
         var input = module as IInputModule;
         if (input != null)
         {
             if (input.KeyUp(GameTime, e))
                 break;
         }
     }
 }
Esempio n. 38
0
 void dev_KeyUp(object sender, KeyboardKeyEventArgs e)
 {
     keys[(int)e.Key] = false;
 }
Esempio n. 39
0
        private void OnKeyboardKeyUp(object sender, KeyboardKeyEventArgs e)
        {
            switch (e.Key)
            {
                // Stop moving to the left.
                case Keys.A:
                case Keys.Left:
                    if (ChatInterface.HasFocus) break;
                    Delta -= Microsoft.Xna.Framework.Vector3.Left;
                    break;

                // Stop moving to the right.
                case Keys.D:
                case Keys.Right:
                    if (ChatInterface.HasFocus) break;
                    Delta -= Microsoft.Xna.Framework.Vector3.Right;
                    break;

                // Stop moving forwards.
                case Keys.W:
                case Keys.Up:
                    if (ChatInterface.HasFocus) break;
                    Delta -= Microsoft.Xna.Framework.Vector3.Forward;
                    break;

                // Stop moving backwards.
                case Keys.S:
                case Keys.Down:
                    if (ChatInterface.HasFocus) break;
                    Delta -= Microsoft.Xna.Framework.Vector3.Backward;
                    break;
            }
        }
Esempio n. 40
0
        public override bool KeyUp(GameTime gameTime, KeyboardKeyEventArgs e)
        {
            switch (e.Key)
            {
                // Stop moving to the left.
                case Keys.A:
                case Keys.Left:
                    Delta -= XVector3.Left;
                    return true;

                // Stop moving to the right.
                case Keys.D:
                case Keys.Right:
                    Delta -= XVector3.Right;
                    return true;

                // Stop moving forwards.
                case Keys.W:
                case Keys.Up:
                    Delta -= XVector3.Forward;
                    return true;

                // Stop moving backwards.
                case Keys.S:
                case Keys.Down:
                    Delta -= XVector3.Backward;
                    return true;
            }
            return false;
        }
Esempio n. 41
0
 private void Keyboard_KeyUp(object sender, KeyboardKeyEventArgs e)
 {
   Keys keys = KeyboardUtil.ToXna(e.Key);
   if (!this.keys.Contains(keys))
     return;
   this.keys.Remove(keys);
 }
Esempio n. 42
0
 protected override void OnKeyUp(KeyboardKeyEventArgs e)
 {
     base.OnKeyUp(e);
     eventHandler.OnKeyUp(e);
 }
Esempio n. 43
0
		void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
		{			
			if (_focusedWidget == null)
				return;
			_focusedWidget.onKeyDown (sender, e);
		}
Esempio n. 44
0
        private void OnKeyboardKeyDown(object sender, KeyboardKeyEventArgs e)
        {
            // TODO: Rebindable keys
            // TODO: Horizontal terrain collisions

            switch (e.Key)
            {
                // Close game (or chat).
                case Keys.Escape:
                    if (ChatInterface.HasFocus)
                        ChatInterface.HasFocus = false;
                    else
                        Exit();
                    break;

                // Open chat window.
                case Keys.T:
                    if (!ChatInterface.HasFocus && ChatInterface.IsVisible)
                        ChatInterface.HasFocus = true;
                    break;

                // Open chat window.
                case Keys.OemQuestion:
                    if (!ChatInterface.HasFocus && ChatInterface.IsVisible)
                        ChatInterface.HasFocus = true;
                    break;

                // Close chat window.
                case Keys.Enter:
                    if (ChatInterface.HasFocus)
                        ChatInterface.HasFocus = false;
                    break;

                // Take a screenshot.
                case Keys.F2:
                    TakeScreenshot();
                    break;

                // Toggle debug view.
                case Keys.F3:
                    DebugInterface.IsVisible = !DebugInterface.IsVisible;
                    break;

                // Change interface scale.
                case Keys.F4:
                    foreach (var item in Interfaces)
                    {
                        item.Scale = (InterfaceScale)(item.Scale + 1);
                        if ((int)item.Scale > 2) item.Scale = InterfaceScale.Small;
                    }
                    break;

                // Move to the left.
                case Keys.A:
                case Keys.Left:
                    if (ChatInterface.HasFocus) break;
                    Delta += Microsoft.Xna.Framework.Vector3.Left;
                    break;

                // Move to the right.
                case Keys.D:
                case Keys.Right:
                    if (ChatInterface.HasFocus) break;
                    Delta += Microsoft.Xna.Framework.Vector3.Right;
                    break;

                // Move forwards.
                case Keys.W:
                case Keys.Up:
                    if (ChatInterface.HasFocus) break;
                    Delta += Microsoft.Xna.Framework.Vector3.Forward;
                    break;

                // Move backwards.
                case Keys.S:
                case Keys.Down:
                    if (ChatInterface.HasFocus) break;
                    Delta += Microsoft.Xna.Framework.Vector3.Backward;
                    break;

                // Toggle mouse capture.
                case Keys.Tab:
                    MouseCaptured = !MouseCaptured;
                    break;
            }
        }
Esempio n. 45
0
 public void OnKeyUp(object sender, KeyboardKeyEventArgs e)
 {
 }
Esempio n. 46
0
        private void OnKeyDown(object sender, KeyboardKeyEventArgs e)
        {
            if (HasFocus)
            {
                if (e.Key == Keys.Back)
                    Input = Input.Length > 0 ? Input.Substring(0, Input.Length - 1) : Input;
                else
                {
                    var shift = (Keyboard.State.IsKeyDown(Keys.LeftShift) || Keyboard.State.IsKeyDown(Keys.RightShift));
                    var value = default(char);

                    if (TryParseKey(e.Key, shift, out value))
                        Input += new string(new char[] { value });
                }
            }
            else
            {
                if (Input != string.Empty)
                {
                    Client.SendMessage(Input);
                    Input = string.Empty;
                }
            }
        }
Esempio n. 47
0
 protected override void OnKeyUp(KeyboardKeyEventArgs e)
 {
     _keyboard = e.Keyboard;
 }
Esempio n. 48
0
 private void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
 {
   if (e.Key == Key.F4 && this.keys.Contains(Keys.LeftAlt))
   {
     this.window.Close();
   }
   else
   {
     Keys keys = KeyboardUtil.ToXna(e.Key);
     if (this.keys.Contains(keys))
       return;
     this.keys.Add(keys);
   }
 }
Esempio n. 49
0
 protected virtual void OnKeyPress(KeyboardKeyEventArgs evArgs)
 {
     for (int i = 0; i < Children.Count; ++i)
     {
         Children[i].CallEvent(GUIObject.EventType.KeyDown, Children[i].Location, evArgs.Key);
     }
 }