public override void Update(GameTime gameTime) { bool inGame = Globals.gameInstance.gameState == GameState.inGame; if (selected) { if (GlobalControls.MenuLeftPressed()) { value -= valueIncrement; if (value < 0) { value = 0.0f; } if (soundEffectOnSliderChange) { Globals.soundEffectsManager.PlaySoundEffect(SoundEffects.MenuSlider, false, SoundEffectsManager.zeroPanVectorLocation); } } if (GlobalControls.MenuRightPressed()) { value += valueIncrement; if (value > 1) { value = 1.0f; } if (soundEffectOnSliderChange) { Globals.soundEffectsManager.PlaySoundEffect(SoundEffects.MenuSlider, false, SoundEffectsManager.zeroPanVectorLocation); } } if (PlayerControls.MouseLeftPressed() && BoundingRect().Contains(PlayerControls.MousePosition())) { mouseChangingValue = true; } if (mouseChangingValue && PlayerControls.MouseLeftDown()) { value = (PlayerControls.MousePosition().X - position.X) / size.X; if (value < 0) { value = 0; } else if (value > 1) { value = 1; } } else { if (mouseChangingValue && soundEffectOnSliderChange) { Globals.soundEffectsManager.PlaySoundEffect(SoundEffects.MenuSlider, false, SoundEffectsManager.zeroPanVectorLocation); } mouseChangingValue = false; } } }
public override void Update(GameTime gameTime) { if (selected && menuScreen != null && enabled && inScrollView && ((PlayerControls.MouseLeftPressed() && BoundingRect().Contains(PlayerControls.MousePosition())) || GlobalControls.ConfirmPressed() || PlayerControls.ConfirmPressed(ControlsConfig.keyboardControllerIndex))) { SelectionClicked(); menuScreen.ButtonClicked(this); Globals.soundEffectsManager.PlaySoundEffect(SoundEffects.MenuConfirm, false, SoundEffectsManager.zeroPanVectorLocation); } }
public void Update(GameTime gameTime) { gameUI.Update(gameTime); if (gameScreenStatus == GameScreenStatus.inPause) { pauseMenu.Update(gameTime); } else if (gameScreenStatus == GameScreenStatus.inGame) { if (GlobalControls.PausePressed() || PlayerControls.PausePressed(ControlsConfig.keyboardControllerIndex)) { PauseGame(); } } }
public override void Update(GameTime gameTime) { if (selected && menuScreen != null && enabled && inScrollView) { if (((PlayerControls.MouseLeftPressed() && RightArrowBoundingRect().Contains(PlayerControls.MousePosition())) || GlobalControls.MenuRightPressed() || PlayerControls.MenuRightPressed(ControlsConfig.keyboardControllerIndex))) { RightArrowPressed(); } if (((PlayerControls.MouseLeftPressed() && LeftArrowBoundingRect().Contains(PlayerControls.MousePosition())) || GlobalControls.MenuLeftPressed() || PlayerControls.MenuLeftPressed(ControlsConfig.keyboardControllerIndex))) { LeftArrowPressed(); } } }
public override void Update(GameTime gameTime) { if (!waitingForKeyPress) { base.Update(gameTime); if (GlobalControls.MenuLeftPressed() || (PlayerControls.MouseLeftPressed() && LeftArrowBoundingRect().Contains(PlayerControls.MousePosition()))) { selectionArrowColor = -3; DefaultControls.DecrementGamepadPreset(playerNumber); CheckToEnableButtons(); UpdateNewControlsPreset(); } else if (GlobalControls.MenuRightPressed() || (PlayerControls.MouseLeftPressed() && RightArrowBoundingRect().Contains(PlayerControls.MousePosition()))) { selectionArrowColor = 3; DefaultControls.IncrementGamepadPreset(playerNumber); CheckToEnableButtons(); UpdateNewControlsPreset(); } } else { if (!waitingForAllKeysToBeUnpressed) { if (GamepadInputPressed()) { ((GamepadControlsMenuButton)buttonList[buttonIndexPressed]).SetNewInput(ButtonPressed()); waitingForKeyPress = false; } } else if (!GamepadInputPressed()) { waitingForAllKeysToBeUnpressed = false; } } }
public virtual void Update(GameTime gameTime) { if (GlobalControls.PausePressed()) { BackPressed(); Globals.soundEffectsManager.PlaySoundEffect(SoundEffects.MenuBack, false, SoundEffectsManager.zeroPanVectorLocation); } if (currentSubMenuScreenIndex >= 0) { subMenues[currentSubMenuScreenIndex].Update(gameTime); } else { if (GlobalControls.DeclinePressed()) { BackPressed(); Globals.soundEffectsManager.PlaySoundEffect(SoundEffects.MenuBack, false, SoundEffectsManager.zeroPanVectorLocation); } if (buttonList.Count > 0) { if (GlobalControls.MenuDownPressed()) { currentlySelectedButtonIndex++; if (currentlySelectedButtonIndex >= buttonList.Count) { if (cycleOptions) { currentlySelectedButtonIndex = 0; } else { currentlySelectedButtonIndex = buttonList.Count - 1; } } while (!buttonList[currentlySelectedButtonIndex].selectable) { currentlySelectedButtonIndex++; if (currentlySelectedButtonIndex >= buttonList.Count) { if (cycleOptions) { currentlySelectedButtonIndex = 0; } else { currentlySelectedButtonIndex = LastSelectableButtonIndex(); } } } Globals.soundEffectsManager.PlaySoundEffect(SoundEffects.MenuDown, false, SoundEffectsManager.zeroPanVectorLocation); } if (GlobalControls.MenuUpPressed()) { currentlySelectedButtonIndex--; if (currentlySelectedButtonIndex < 0) { if (cycleOptions) { currentlySelectedButtonIndex = buttonList.Count - 1; } else { currentlySelectedButtonIndex = 0; } } while (!buttonList[currentlySelectedButtonIndex].selectable) { currentlySelectedButtonIndex--; if (currentlySelectedButtonIndex < 0) { if (cycleOptions) { currentlySelectedButtonIndex = buttonList.Count - 1; } else { currentlySelectedButtonIndex = FirstSelectableButtonIndex(); } } } Globals.soundEffectsManager.PlaySoundEffect(SoundEffects.MenuUp, false, SoundEffectsManager.zeroPanVectorLocation); } if (PlayerControls.MousePositionMoved()) { for (int i = 0; i < buttonList.Count; i++) { if (buttonList[i].BoundingRect().Contains(PlayerControls.MousePosition()) && buttonList[i].selectable && buttonList[i].inScrollView) { currentlySelectedButtonIndex = i; } } } for (int i = 0; i < buttonList.Count; i++) { buttonList[i].selected = false; } if (currentlySelectedButtonIndex < buttonList.Count) { buttonList[currentlySelectedButtonIndex].selected = true; } for (int i = 0; i < buttonList.Count; i++) { buttonList[i].Update(gameTime); } } } }