public override void OnInputAction(InputAction action, bool pressedThisFrame) { if (mode == MenuScreenMode.Active) { if (pressedThisFrame) { switch (action) { case InputAction.Action1: if (options.IsEnabled(currentMenuIndex)) { arrowVelocityModifier = 1; arrowDistance = ARROW_DISTANCE_MIN; SoundManager.PlaySoundOnce("ButtonForward"); options[currentMenuIndex].Value(MenuOptionAction.Click); } else { SoundManager.PlaySoundOnce("ButtonFailure"); } break; case InputAction.Left: if (options.IsEnabled(currentMenuIndex) && MenuOptions.IsLeftRightAction(options[currentMenuIndex])) { arrowVelocityModifier = 1; arrowDistance = ARROW_DISTANCE_MIN; SoundManager.PlaySoundOnce("ButtonForward"); options[currentMenuIndex].Value(MenuOptionAction.Left); } break; case InputAction.Right: if (options.IsEnabled(currentMenuIndex) && MenuOptions.IsLeftRightAction(options[currentMenuIndex])) { arrowVelocityModifier = 1; arrowDistance = ARROW_DISTANCE_MIN; SoundManager.PlaySoundOnce("ButtonForward"); options[currentMenuIndex].Value(MenuOptionAction.Right); } break; case InputAction.Action2: if (options.BackAction != null) { SoundManager.PlaySoundOnce("ButtonBack"); options.BackAction(MenuOptionAction.Click); } break; case InputAction.Start: case InputAction.Escape: if (TransitionOutEnabled) { SoundManager.PlaySoundOnce("ButtonBack"); mode = MenuScreenMode.TransitioningOut; } break; case InputAction.Up: arrowVelocityModifier = 1; arrowDistance = ARROW_DISTANCE_MIN; currentMenuIndex--; if (currentMenuIndex < 0) currentMenuIndex = options.Count - 1; break; case InputAction.Down: arrowVelocityModifier = 1; arrowDistance = ARROW_DISTANCE_MIN; currentMenuIndex = (currentMenuIndex + 1) % options.Count; break; } } } else { if (pressedThisFrame && (action == InputAction.Start || action == InputAction.Escape)) { if (mode == MenuScreenMode.TransitioningIn) { SoundManager.PlaySoundOnce("ButtonBack"); mode = MenuScreenMode.TransitioningOut; } else if (mode == MenuScreenMode.TransitioningOut) { SoundManager.PlaySoundOnce("ButtonForward"); mode = MenuScreenMode.TransitioningIn; } } } }
public MenuScreen(Bindings activeBindings) { DrawPreviousScreen = true; mode = MenuScreenMode.TransitioningIn; TransitionOutEnabled = true; bindings = activeBindings; settingsOptions = new MenuOptions("Settings", new Dictionary<string, Action<MenuOptionAction>>() { {"<P1 Bindings>", bindingsMenuOptionDelegate}, {"Sound", delegate{ settingsMode = SettingsMode.Sound; SetMenuOptions(soundOptions); }}, {"Screen Size", delegate { settingsMode = SettingsMode.ScreenSize; SetMenuOptions(screenSizeOptions); }}, {"Reset Scores", delegate{ DisplayConfirmationDialog("Reset Scores?", delegate { RetroGame.ResetScores(); SetMenuOptions(settingsOptions); }); } }, {"Back", null }, //set dynamically } , "Back"); soundOptions = new MenuOptions("Sound", new Dictionary<string, Action<MenuOptionAction>>() { {"<Master>", delegate(MenuOptionAction action) { switch (action) { case MenuOptionAction.Click: if(SoundManager.MasterVolume != 0) { previousMasterVolume = SoundManager.MasterVolume; SoundManager.SetMasterVolume(0); } else SoundManager.SetMasterVolume(previousMasterVolume); break; case MenuOptionAction.Left: SoundManager.SetMasterVolume(SoundManager.MasterVolume - VOLUME_SETTINGS_STEP); break; case MenuOptionAction.Right: SoundManager.SetMasterVolume(SoundManager.MasterVolume + VOLUME_SETTINGS_STEP); break; } RetroGame.SaveConfig(); }}, {"<Music>", delegate(MenuOptionAction action) { switch (action) { case MenuOptionAction.Click: if (SoundManager.MusicMasterVolume != 0) { previousMusicVolume = SoundManager.MusicMasterVolume; SoundManager.SetMusicMasterVolume(0); } else SoundManager.SetMusicMasterVolume(previousMusicVolume); break; case MenuOptionAction.Left: SoundManager.SetMusicMasterVolume(SoundManager.MusicMasterVolume - VOLUME_SETTINGS_STEP); break; case MenuOptionAction.Right: SoundManager.SetMusicMasterVolume(SoundManager.MusicMasterVolume + VOLUME_SETTINGS_STEP); break; } RetroGame.SaveConfig(); }}, {"<Sounds>", delegate(MenuOptionAction action) { switch (action) { case MenuOptionAction.Click: if (SoundManager.SoundMasterVolume != 0) { previousSoundVolume = SoundManager.SoundMasterVolume; SoundManager.SetSoundMasterVolume(0); } else SoundManager.SetSoundMasterVolume(previousSoundVolume); break; case MenuOptionAction.Left: SoundManager.SetSoundMasterVolume(SoundManager.SoundMasterVolume - VOLUME_SETTINGS_STEP); break; case MenuOptionAction.Right: SoundManager.SetSoundMasterVolume(SoundManager.SoundMasterVolume + VOLUME_SETTINGS_STEP); break; } RetroGame.SaveConfig(); }}, {"Back", delegate{ settingsMode = SettingsMode.Menu; SetMenuOptions(settingsOptions); }}, } , "Back"); screenSizeOptions = new MenuOptions("Screen Size", new Dictionary<string, Action<MenuOptionAction>>() { {"Small", delegate{ RetroGame.SetScreenSize(ScreenSize.Small); RetroGame.SaveConfig(); }}, {"Medium", delegate{ RetroGame.SetScreenSize(ScreenSize.Medium); RetroGame.SaveConfig(); }}, {"Large", delegate{ RetroGame.SetScreenSize(ScreenSize.Large); RetroGame.SaveConfig(); }}, {"Huge", delegate{ RetroGame.SetScreenSize(ScreenSize.Huge); RetroGame.SaveConfig(); }}, {"Back", delegate{ settingsMode = SettingsMode.Menu; SetMenuOptions(settingsOptions); }}, } , 4); }