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 void setNameDelegate(MenuOptionAction menuOptionAction) { SoundManager.PlaySoundOnce("ButtonForward"); setupTypingName = true; setupTypedName = ""; Action<Keys?, Buttons?> nameTypingDelegate = null; nameTypingDelegate = delegate(Keys? pressedKey, Buttons? pressedButton) { if (pressedKey != null) { if (pressedKey.Value == Keys.Escape || pressedKey.Value == Keys.Enter) { setupTypingName = false; if (pressedKey.Value != Keys.Escape) { if (setupTypedName.Length > 0) { Hero.NEW_HERO_NAMES[currentSetupIndex] = setupTypedName; SoundManager.PlaySoundOnce("ButtonForward"); } else SoundManager.PlaySoundOnce("ButtonFailure"); } else SoundManager.PlaySoundOnce("ButtonBack"); return; } if (NAME_ALPHABET.Contains(pressedKey.Value.ToString())) setupTypedName += (setupTypedName.Length == 0) ? pressedKey.Value.ToString().ToUpper() : pressedKey.Value.ToString().ToLower(); if (setupTypedName.Length >= Names.CHAR_LIMIT) { setupTypingName = false; if (setupTypedName.Length > 0) { Hero.NEW_HERO_NAMES[currentSetupIndex] = setupTypedName; SoundManager.PlaySoundOnce("ButtonForward"); } else SoundManager.PlaySoundOnce("ButtonFailure"); return; } if (setupTypedName.Length > 0 && (pressedKey.Value == Keys.Back || pressedKey.Value == Keys.Delete)) { setupTypedName = setupTypedName.Substring(0, setupTypedName.Length - 1); } } currentBindings.onNextInputAction = nameTypingDelegate; //keep capturing input }; currentBindings.onNextInputAction = nameTypingDelegate; }