public GameOverScreen(Bindings activeBindings) : base(activeBindings) { TransitionOutEnabled = false; switch (activeBindings.PlayerIndex) { case PlayerIndex.One: activePlayerFolder = Player.One; break; case PlayerIndex.Two: activePlayerFolder = Player.Two; break; } gameOverOptions = new MenuOptions("Game Over", new Dictionary<string, Action<MenuOptionAction>>() { {"Retry", delegate { DisplayConfirmationDialog("Retry?", delegate{ RetroGame.PopScreen(); SaveGame loadedGame = RetroGame.Load(Saves.LastSaveFilename); if (loadedGame != null) { Type[] powerupTypes = new Type[loadedGame.storePowerupTypeNames.Length]; for (int i = 0; i < powerupTypes.Length; i++) powerupTypes[i] = Type.GetType(loadedGame.storePowerupTypeNames[i]); RetroGame.AddScreen(new StoreScreen(powerupTypes), true); } }); }}, {"Settings", delegate { settingsMode = SettingsMode.Menu; SetMenuOptions(GetSettingsOptions()); }}, {"Quit to title", delegate { RetroGame.Reset(); RetroGame.PopScreen(true); RetroGame.AddScreen(new StartScreen(activeBindings), true); }}, } , (Action<MenuOptionAction>)null); SetMenuOptions(gameOverOptions); }
public PauseScreen(Bindings activeBindings) : base(activeBindings) { switch (activeBindings.PlayerIndex) { case PlayerIndex.One: activePlayerFolder = Player.One; break; case PlayerIndex.Two: activePlayerFolder = Player.Two; break; } Action onStoreTransition = delegate { RetroGame.storeChargeTime = 0; RetroGame.StoreCharge = 0; options["Go to Store"] = null; RetroGame.AddScreen(new StoreScreen(null), true); Highscores.Save(); RetroGame.Save(); }; Action<MenuOptionAction> storeAction = delegate { SoundManager.SetMusicVolumeSmooth(0); RetroGame.AddScreen(new StaticTransitionScreen(TransitionMode.ToStatic, STATIC_TRANSITION_TIME, onStoreTransition, true)); }; pauseOptions = new MenuOptions("Paused", new Dictionary<string, Action<MenuOptionAction>>() { {"Resume", delegate{ mode = MenuScreenMode.TransitioningOut; }}, {"Go to Store", (RetroGame.StoreCharge >= 1) ? storeAction : null}, {"Inventory", delegate{ RetroGame.AddScreen(new InventoryScreen(bindings)); }}, {"Settings", delegate { settingsMode = SettingsMode.Menu; SetMenuOptions(GetSettingsOptions()); }}, {"Restart", delegate { DisplayConfirmationDialog("Restart?", delegate{ RetroGame.PopScreen(); SaveGame loadedGame = RetroGame.Load(Saves.LastSaveFilename); if (loadedGame != null) { Type[] powerupTypes = new Type[loadedGame.storePowerupTypeNames.Length]; for (int i = 0; i < powerupTypes.Length; i++) powerupTypes[i] = Type.GetType(loadedGame.storePowerupTypeNames[i]); RetroGame.AddScreen(new StoreScreen(powerupTypes), true); } }); }}, {"Quit Game", delegate { DisplayConfirmationDialog("Quit?", delegate { RetroGame.Reset(); RetroGame.PopScreen(); RetroGame.AddScreen(new StartScreen(RetroGame.getHeroes()[0].bindings), true); ((StartScreen)RetroGame.TopScreen).folderPositionRelative = StartScreen.FOLDER_SCREEN_POSITION_RELATIVE_SHOWN; }); }}, } , 0); SetMenuOptions(pauseOptions); }
public MenuOptions GetSettingsOptions() { preSettingsOptionsOptions = options; settingsOptions["Back"] = delegate { settingsMode = SettingsMode.None; SetMenuOptions(preSettingsOptionsOptions); }; return settingsOptions; }
public void SetMenuOptions(MenuOptions options) { if(options == null) throw new ArgumentNullException("options"); this.options = options; currentMenuIndex = 0; }
public void DisplayConfirmationDialog(string title, string positiveOption, string negativeOption, Action<MenuOptionAction> onConfirmAction) { preConfirmationDialogOptions = options; SetMenuOptions(new MenuOptions(title, new Dictionary<string, Action<MenuOptionAction>>() { {negativeOption, delegate { SetMenuOptions(preConfirmationDialogOptions); }}, {positiveOption, onConfirmAction}, }, negativeOption)); }
public void bindingsMenuOptionDelegate(MenuOptionAction action) { switch (action) { case MenuOptionAction.Click: settingsMode = SettingsMode.Bindings; bool p1 = options[0].Key == "<P1 Bindings>"; bindingsMenuInstructions = "Select an action to modify\nbindings for that action"; usesCustomBindings = Bindings.USE_CUSTOM_BINDINGS[p1 ? PlayerIndex.One : PlayerIndex.Two]; customBindingsToModify = Bindings.CUSTOM_BINDINGS[p1 ? PlayerIndex.One : PlayerIndex.Two]; currentPlayerBindingsMenu = p1 ? PlayerIndex.One : PlayerIndex.Two; MenuOptions bindingsMenu = new MenuOptions(p1 ? "P1 Bindings" : "P2 Bindings", new Dictionary<string, Action<MenuOptionAction>>() { { usesCustomBindings ? "<Custom>" : "<Default>", delegate(MenuOptionAction action2) { switch (action2) { case MenuOptionAction.Click: case MenuOptionAction.Left: case MenuOptionAction.Right: if(usesCustomBindings) { options[0] = new KeyValuePair<string, Action<MenuOptionAction>>("<Default>", options[0].Value); options.SetEnabled(false, 1, 9); usesCustomBindings = false; } else { options[0] = new KeyValuePair<string, Action<MenuOptionAction>>("<Custom>", options[0].Value); options.SetEnabled(true, 1, 9); usesCustomBindings = true; } break; } } }, {" Up", getSetBindingDelegate(InputAction.Up)}, {" Down", getSetBindingDelegate(InputAction.Down)}, {" Left", getSetBindingDelegate(InputAction.Left)}, {" Right", getSetBindingDelegate(InputAction.Right)}, {" Action1", getSetBindingDelegate(InputAction.Action1)}, {" Action2", getSetBindingDelegate(InputAction.Action2)}, {" Action3", getSetBindingDelegate(InputAction.Action3)}, {" Action4", getSetBindingDelegate(InputAction.Action4)}, {" Start", getSetBindingDelegate(InputAction.Start)}, {"Apply", delegate { Bindings.USE_CUSTOM_BINDINGS[p1 ? PlayerIndex.One : PlayerIndex.Two] = usesCustomBindings; Bindings.CUSTOM_BINDINGS[p1? PlayerIndex.One : PlayerIndex.Two] = customBindingsToModify; if (p1 && RetroGame.getHeroes().Length > 0) { if (usesCustomBindings) RetroGame.getHeroes()[0].bindings.setToCustom(); else RetroGame.getHeroes()[0].bindings.setToDefault(); } else if (RetroGame.getHeroes().Length > 1) { if (usesCustomBindings) RetroGame.getHeroes()[1].bindings.setToCustom(); else RetroGame.getHeroes()[1].bindings.setToDefault(); } RetroGame.SaveConfig(); settingsMode = SettingsMode.Menu; SetMenuOptions(settingsOptions); } }, {"Cancel", delegate { customBindingsToModify = null; settingsMode = SettingsMode.Menu; SetMenuOptions(settingsOptions); } }, }, "Cancel"); SetMenuOptions(bindingsMenu); options.SetEnabled(usesCustomBindings, 1, 9); break; case MenuOptionAction.Left: case MenuOptionAction.Right: if (options[0].Key == "<P1 Bindings>") options[0] = new KeyValuePair<string, Action<MenuOptionAction>>("<P2 Bindings>", options[0].Value); else options[0] = new KeyValuePair<string, Action<MenuOptionAction>>("<P1 Bindings>", options[0].Value); break; } }
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); }
public void InitializeSetupOptions(int numPlayers) { for(int i = 0; i < RetroGame.MAX_PLAYERS; i++) { Hero.NEW_HERO_IDS[i] = Prisoner.getRandomPrisonerID(); Hero.NEW_HERO_NAMES[i] = Names.getRandomName(); Hero.NEW_HERO_COLORS[i] = Hero.NEW_HERO_COLORS[i].Randomize(COLOR_MIN, 255); } setupTypingName = false; setupTypedName = ""; Action soloTransitionAction = delegate { RetroGame.PopScreen(true); RetroGame.NUM_PLAYERS = 1; RetroGame.Load(Saves.NEW_GAME); RetroGame.AddScreen(new StaticTransitionScreen(TransitionMode.FromStatic, STATIC_TRANSITION_TIME, null), true); }; Action coopTransitionAction = delegate { RetroGame.PopScreen(true); RetroGame.NUM_PLAYERS = 2; RetroGame.Load(Saves.NEW_GAME); RetroGame.AddScreen(new StaticTransitionScreen(TransitionMode.FromStatic, STATIC_TRANSITION_TIME, null), true); }; currentSetupIndex = Player.One; KeyValuePair<string, Action<MenuOptionAction>> startOption = new KeyValuePair<string, Action<MenuOptionAction>> ("Start", (numPlayers == 1) ? new Action<MenuOptionAction>(delegate { RetroGame.AddScreen(new StaticTransitionScreen(TransitionMode.ToStatic, STATIC_TRANSITION_TIME, soloTransitionAction), true); }) : new Action<MenuOptionAction>(delegate { RetroGame.AddScreen(new StaticTransitionScreen(TransitionMode.ToStatic, STATIC_TRANSITION_TIME, coopTransitionAction), true); })); KeyValuePair<string, Action<MenuOptionAction>> nextOption = new KeyValuePair<string, Action<MenuOptionAction>> ("Next", delegate { currentSetupIndex++; setupOptions.Title = "Setup P" + (currentSetupIndex + 1); setupOptions[6] = startOption; }); bool useStartOption = numPlayers == 1; setupOptions = new MenuOptions("Setup P1", new Dictionary<string, Action<MenuOptionAction>>() { {"Randomize", delegate { Hero.NEW_HERO_IDS[currentSetupIndex] = Prisoner.getRandomPrisonerID(); Hero.NEW_HERO_NAMES[currentSetupIndex] = Names.getRandomName(); Hero.NEW_HERO_COLORS[currentSetupIndex] = Hero.NEW_HERO_COLORS[currentSetupIndex].Randomize(COLOR_MIN, 255); }}, {"ID", delegate { Hero.NEW_HERO_IDS[currentSetupIndex] = Prisoner.getRandomPrisonerID(); }}, {"Name", setNameDelegate}, {"<R>", delegate(MenuOptionAction action) { switch (action) { case MenuOptionAction.Click: Hero.NEW_HERO_COLORS[currentSetupIndex].R = (byte)(RetroGame.rand.Next(255 - COLOR_MIN) + COLOR_MIN); break; case MenuOptionAction.Left: Hero.NEW_HERO_COLORS[currentSetupIndex].R = (byte)MathHelper.Clamp(Hero.NEW_HERO_COLORS[currentSetupIndex].R - COLOR_STEP, COLOR_MIN, 255); break; case MenuOptionAction.Right: Hero.NEW_HERO_COLORS[currentSetupIndex].R = (byte)MathHelper.Clamp(Hero.NEW_HERO_COLORS[currentSetupIndex].R + COLOR_STEP, COLOR_MIN, 255); break; } }}, {"<G>", delegate(MenuOptionAction action) { switch (action) { case MenuOptionAction.Click: Hero.NEW_HERO_COLORS[currentSetupIndex].G = (byte)(RetroGame.rand.Next(255 - COLOR_MIN) + COLOR_MIN); break; case MenuOptionAction.Left: Hero.NEW_HERO_COLORS[currentSetupIndex].G = (byte)MathHelper.Clamp(Hero.NEW_HERO_COLORS[currentSetupIndex].G - COLOR_STEP, COLOR_MIN, 255); break; case MenuOptionAction.Right: Hero.NEW_HERO_COLORS[currentSetupIndex].G = (byte)MathHelper.Clamp(Hero.NEW_HERO_COLORS[currentSetupIndex].G + COLOR_STEP, COLOR_MIN, 255); break; } }}, {"<B>", delegate(MenuOptionAction action) { switch (action) { case MenuOptionAction.Click: Hero.NEW_HERO_COLORS[currentSetupIndex].B = (byte)(RetroGame.rand.Next(255 - COLOR_MIN) + COLOR_MIN); break; case MenuOptionAction.Left: Hero.NEW_HERO_COLORS[currentSetupIndex].B = (byte)MathHelper.Clamp(Hero.NEW_HERO_COLORS[currentSetupIndex].B - COLOR_STEP, COLOR_MIN, 255); break; case MenuOptionAction.Right: Hero.NEW_HERO_COLORS[currentSetupIndex].B = (byte)MathHelper.Clamp(Hero.NEW_HERO_COLORS[currentSetupIndex].B + COLOR_STEP, COLOR_MIN, 255); break; } }}, {useStartOption ? startOption.Key : nextOption.Key, useStartOption ? startOption.Value : nextOption.Value}, {"Back", delegate { if (currentSetupIndex == 0) DisplayConfirmationDialog("Back?", delegate { settingsMode = SettingsMode.None; SetMenuOptions(startOptions); }); else { currentSetupIndex--; setupOptions.Title = "Setup P" + (currentSetupIndex + 1); setupOptions[6] = nextOption; } }}, } , "Back"); }
public StartScreen(Bindings activeBindings) : base(activeBindings) { TransitionOutEnabled = false; switch (activeBindings.PlayerIndex) { case PlayerIndex.One: activePlayerFolder = Player.One; break; case PlayerIndex.Two: activePlayerFolder = Player.Two; break; } startOptions = new MenuOptions("Start", new Dictionary<string, Action<MenuOptionAction>>() { {"Solo escape", delegate { settingsMode = SettingsMode.Setup; InitializeSetupOptions(1); SetMenuOptions(setupOptions); }}, {"Co-op escape", delegate { settingsMode = SettingsMode.Setup; InitializeSetupOptions(2); SetMenuOptions(setupOptions); }}, {"Continue", delegate { settingsMode = SettingsMode.Continue; continueSortMode = ContinueSortMode.DateDesc; SetMenuOptions(continueOptions); continueSaveSelectedIndex = 0; updateContinueMenuOptions(); }}, {"Settings", delegate { settingsMode = SettingsMode.Menu; SetMenuOptions(GetSettingsOptions()); }}, {"Credits", delegate { settingsMode = SettingsMode.Credits; SetMenuOptions(creditsOptions); }}, {"Exit game", delegate { DisplayConfirmationDialog("Exit?", delegate { RetroGame.game.Exit(); }); }}, } , (Action<MenuOptionAction>)null); Action<MenuOptionAction> loadDeleteAction = null; loadDeleteAction = delegate(MenuOptionAction action) { switch (action) { case MenuOptionAction.Click: if (options[LOADDELETE].Key == "<Load>") { RetroGame.AddScreen(new StaticTransitionScreen(TransitionMode.ToStatic, STATIC_TRANSITION_TIME, delegate { RetroGame.PopScreen(true); RetroGame.NUM_PLAYERS = continueSaves[continueSaveSelectedIndex].numPlayers; SaveGame loadedGame = RetroGame.Load(continueSaves[continueSaveSelectedIndex].filename); if (loadedGame != null) { Type[] powerupTypes = new Type[loadedGame.storePowerupTypeNames.Length]; for (int i = 0; i < powerupTypes.Length; i++) powerupTypes[i] = Type.GetType(loadedGame.storePowerupTypeNames[i]); RetroGame.AddScreen(new StoreScreen(powerupTypes), true); } })); } else if (options[LOADDELETE].Key == "<Delete>") { DisplayConfirmationDialog("Delete?", delegate { Saves.DeleteSave(continueSaves[continueSaveSelectedIndex].filename); SetMenuOptions(continueOptions); updateContinueMenuOptions(); if (continueSaveSelectedIndex > (continueSaves.Count - 1)) continueSaveSelectedIndex = continueSaves.Count - 1; }); } break; case MenuOptionAction.Left: case MenuOptionAction.Right: if (options[LOADDELETE].Key == "<Load>") options[LOADDELETE] = new KeyValuePair<string, Action<MenuOptionAction>>("<Delete>", loadDeleteAction); else if (options[LOADDELETE].Key == "<Delete>") options[LOADDELETE] = new KeyValuePair<string, Action<MenuOptionAction>>("<Load>", loadDeleteAction); break; } }; continueOptions = new MenuOptions("Continue ", new Dictionary<string, Action<MenuOptionAction>>() { {"<Sort:" + CONTINUE_SORT_TO_STRING[ContinueSortMode.DateDesc] + ">", delegate (MenuOptionAction action) { int sortIndex = (int)continueSortMode; switch (action) { case MenuOptionAction.Click: case MenuOptionAction.Right: if(sortIndex < (Enum.GetValues(typeof(ContinueSortMode)).Length - 1)) sortIndex++; else sortIndex = 0; break; case MenuOptionAction.Left: if (sortIndex > 0) sortIndex--; else sortIndex = Enum.GetValues(typeof(ContinueSortMode)).Length - 1; break; } continueSortMode = (ContinueSortMode)Enum.GetValues(typeof(ContinueSortMode)).GetValue(sortIndex); options[0] = new KeyValuePair<string, Action<MenuOptionAction>>("<Sort:" + CONTINUE_SORT_TO_STRING[continueSortMode] + ">", options[0].Value); sortSaves(); }}, {@"/\/\/\", delegate { continueSaveSelectedIndex = 0; }}, {@" /\ ", delegate { if(continueSaveSelectedIndex > 0) continueSaveSelectedIndex--; }}, {@" \/ ", delegate { if(continueSaveSelectedIndex < (continueSaves.Count - 1)) continueSaveSelectedIndex++; }}, {@"\/\/\/", delegate { continueSaveSelectedIndex = continueSaves.Count - 1; }}, {"<Load>", loadDeleteAction}, {"Back", delegate{ settingsMode = SettingsMode.None; SetMenuOptions(startOptions); }}, } , "Back"); creditsOptions = new MenuOptions("Credits", new Dictionary<string, Action<MenuOptionAction>>() { {"Developers", null }, {"Extra", null }, {"Back", delegate { settingsMode = SettingsMode.None; SetMenuOptions(startOptions); }}, } , "Back"); SetMenuOptions(startOptions); }