void UpdateButtonPressed() { if (focusedButton == null) { return; } int commandType = 0; string command = null; if (InputManager.JustPressed(GameCommand.MenuConfirm) && focusedButton.PressCommand != null) { commandType = 1; command = focusedButton.PressCommand; } if (InputManager.JustPressed(GameCommand.MenuLeft) && focusedButton.LeftCommand != null) { commandType = 2; command = focusedButton.LeftCommand; } if (InputManager.JustPressed(GameCommand.MenuRight) && focusedButton.RightCommand != null) { commandType = 3; command = focusedButton.RightCommand; } if (commandType == 0) { return; } //SoundManager.PlaySound("tap2"); GameStateComponent gameState = sys.GetGameState(); if (scene.Name == "menu") { switch (command) { case "start": gameState.Request("danmaku"); break; case "options": gameState.Request("options"); break; case "quit": gameState.Request("quit"); break; } } else if (scene.Name == "options") { switch (command) { case "m-dn": SoundManager.MusicVolume = Math.Max(SoundManager.MusicVolume -= 0.1f, 0); break; case "m-up": SoundManager.MusicVolume = Math.Min(SoundManager.MusicVolume += 0.1f, 1); break; case "s-dn": SoundManager.SoundVolume = Math.Max(SoundManager.SoundVolume -= 0.1f, 0); break; case "s-up": SoundManager.SoundVolume = Math.Min(SoundManager.SoundVolume += 0.1f, 1); break; case "fs": InputManager.StickMouse(); if (gs.DisplayManager.Fullscreen) { gs.DisplayManager.SetFullscreen(false); } else { gs.DisplayManager.SetFullscreen(true); } break; case "zoom-up": InputManager.StickMouse(); if (Config.Zoom < Config.GameScales.Count - 1) { Config.Zoom++; } else { Config.Zoom = 0; } gs.DisplayManager.SetZoom(Config.GameScales[Config.Zoom]); break; case "zoom-dn": InputManager.StickMouse(); if (Config.Zoom > 0) { Config.Zoom--; } else { Config.Zoom = Config.GameScales.Count - 1; } gs.DisplayManager.SetZoom(Config.GameScales[Config.Zoom]); break; case "controls": gameState.Request("controls"); break; case "controls-r": InputManager.Default(); InputManager.AskSetControls = false; InputManager.SaveConfig(); InputManager.UpdateAliases(); break; case "return": Config.SaveConfig(); gameState.Request("return"); break; } UpdateText(); } InputManager.Reset(GameCommand.Action1); }
void UpdateInput(GameTime gameTime) { GameStateComponent gameState = sys.GetGameState(); if (conflictTimer > 0) { conflictTimer -= gameTime.ElapsedGameTime.TotalSeconds; } if (InputManager.JustPressed(GameCommand.SafeBack)) { //SoundManager.PlaySound("Throw2"); currentKey--; if (currentKey < 0) { scene.Disable(); gameState.Request("return"); } return; } if (InputManager.Held(GameCommand.SafeBack)) { return; } Keys[] pressedKeys = InputManager.GetKeyboardInput(); List <MouseInput> pressedMouseKeys = InputManager.GetMouseInput(); List <Buttons> pressedGamepadKeys = InputManager.GetGamepadInput(); if (pressedKeys.Length == 0 && pressedMouseKeys.Count == 0 && pressedGamepadKeys.Count == 0) { keysHeld = false; return; } if (!keysHeld) { // Bind keyboard input. if (pressedKeys.Length > 0) { keysHeld = true; Keys key = pressedKeys[0]; if (key != Keys.LeftAlt && key != Keys.RightAlt) { SetBinding(key, UniversalInputType.Keyboard); } } // Bind mouse input. else if (pressedMouseKeys.Count > 0) { keysHeld = true; MouseInput key = pressedMouseKeys[0]; SetBinding(key, UniversalInputType.Mouse); } // Bind gamepad input. else if (pressedGamepadKeys.Count > 0) { keysHeld = true; GamepadInput key = (GamepadInput)pressedGamepadKeys[0]; SetBinding(key, UniversalInputType.Gamepad); } } // If all customizable bindings are set, then leave this scene. if (currentKey >= (int)GameCommand.MenuUp) { success = true; // TODO: I don't think this is needed anymore. FinalizeKeybinds(); scene.Disable(); gameState.Request("return"); } }