public void Open(string value, string comboName, IModInputCombinationMenu combinationMenu = null, IModInputCombinationElement element = null) { _combinationMenu = combinationMenu; _element = element; _comboName = comboName; _inputMenu.OnPopupConfirm += OnPopupConfirm; _inputMenu.OnPopupCancel += OnPopupCancel; _inputMenu.OnPopupValidate += OnPopupValidate; const string message = "Press your combination"; _inputMenu.EnableMenu(true, value); var okCommand = InputLibrary.confirm; var okPrompt = new ScreenPrompt(okCommand, "OK"); if (_cancelCommand == null) { _cancelCommand = new SingleAxisCommand(); var cancelBindingGamepad = new InputBinding(JoystickButton.Select); var cancelBindingKeyboard = new InputBinding(KeyCode.Escape); _cancelCommand.SetInputs(cancelBindingGamepad, cancelBindingKeyboard); var commandObject = new GameObject(); var commandComponent = commandObject.AddComponent <ModCommandUpdater>(); commandComponent.Initialize(_cancelCommand); } var cancelPrompt = new ScreenPrompt(_cancelCommand, "Cancel"); var resetPrompt = new ScreenPrompt("Reset"); _inputMenu.SetUpPopup(message, okCommand, _cancelCommand, null, okPrompt, cancelPrompt, resetPrompt); _inputMenu.GetValue <Text>("_labelText").text = message; }
private static void PostSetPopupCommands(SingleAxisCommand okCommand, ref SingleAxisCommand ____okCommand) { if (okCommand == InputLibrary.select) { ____okCommand = InputLibrary.confirm; } }
public void RemoveFromListener(SingleAxisCommand command) { if (_commands.Contains(command) && !_toRemove.Contains(command)) { _toRemove.Add(command); } }
public void SetUpPopup(string message, SingleAxisCommand okCommand, SingleAxisCommand cancelCommand, SingleAxisCommand resetCommand, ScreenPrompt okPrompt, ScreenPrompt cancelPrompt, ScreenPrompt resetPrompt, bool closeMenuOnOk = true, bool setCancelButtonActive = true) { SetUpPopupCommandsShort(resetCommand, resetPrompt); base.SetUpPopup(message, okCommand, cancelCommand, okPrompt, cancelPrompt, closeMenuOnOk, setCancelButtonActive); }
protected virtual void OnOpenCommand(SingleAxisCommand command) { if (IsSelected && _openCommands.Contains(command)) { command.ConsumeInput(); command.BlockNextRelease(); Open(); } }
public void AddToListener(SingleAxisCommand command) { if (_commands.Contains(command)) { return; } _commands.Add(command); _wasPressed.Add(command, false); _isPressed.Add(command, false); }
public void Init(SingleAxisCommand inputCommand) { _button = GetComponent <Button>(); _inputCommand = inputCommand; var imageElement = GetComponent <ButtonWithHotkeyImageElement>(); if (imageElement == null) { return; } var textId = GetComponentInChildren <LocalizedText>().GetValue <UITextType>("_textID"); var title = UITextLibrary.GetString(textId); imageElement.SetPrompt(new ScreenPrompt(inputCommand, title)); }
private static bool SingleAxisUpdate( SingleAxisCommand __instance, InputBinding ____gamepadBinding, ref float ____value, ref bool ____newlyPressedThisFrame, ref float ____lastValue, ref float ____lastPressedDuration, ref float ____pressedDuration, ref float ____realtimeSinceLastUpdate ) { if (!IsInputEnabled) { return(false); } var positive = ____gamepadBinding.gamepadButtonPos; var negative = ____gamepadBinding.gamepadButtonNeg; ____newlyPressedThisFrame = false; ____lastValue = ____value; ____value = 0f; if (_buttons.ContainsKey(positive)) { ____value += _buttons[positive]; } if (_buttons.ContainsKey(negative)) { ____value -= _buttons[negative]; } var axis = InputTranslator.GetAxisName(____gamepadBinding.axisID); if (_axes.ContainsKey(axis)) { ____value += DeadzonedValue(_axes[axis] * ____gamepadBinding.axisDirection); } ____lastPressedDuration = ____pressedDuration; ____pressedDuration = ((!__instance.IsPressed()) ? 0f : (____pressedDuration + (Time.realtimeSinceStartup - ____realtimeSinceLastUpdate))); ____realtimeSinceLastUpdate = Time.realtimeSinceStartup; return(false); }
protected virtual void OnButton(SingleAxisCommand command) { command.ConsumeInput(); if ((command == InputLibrary.confirm && (OWInput.IsGamepadEnabled() || !InputLibrary.enter.GetValue <bool>("_blockNextRelease"))) || command == InputLibrary.enter2) { OnSave(); } if (command == InputLibrary.cancel || command == InputLibrary.escape) { OnExit(); } if (command == InputLibrary.setDefaults) { OnReset(); } }
public static void SingleAxisUpdatePost( SingleAxisCommand __instance, ref float ____value, List <KeyCode> ____posKeyCodes, List <KeyCode> ____negKeyCodes ) { foreach (var key in ____posKeyCodes) { if (ModInputHandler.Instance.IsPressedAndIgnored(key)) { ____value = 0f; } } foreach (var key in ____negKeyCodes) { if (ModInputHandler.Instance.IsPressedAndIgnored(key)) { ____value = 0f; } } }
static bool SingleAxisUpdate( SingleAxisCommand __instance, XboxButton ____xboxButtonPositive, XboxButton ____xboxButtonNegative, ref float ____value, ref bool ____newlyPressedThisFrame, ref float ____lastValue, ref float ____lastPressedDuration, ref float ____pressedDuration, ref float ____realtimeSinceLastUpdate ) { if (____xboxButtonPositive == XboxButton.None && ____xboxButtonNegative == XboxButton.None) { return(true); } ____newlyPressedThisFrame = false; ____lastValue = ____value; ____value = 0f; if (_buttons.ContainsKey(____xboxButtonPositive)) { ____value += _buttons[____xboxButtonPositive]; } if (_buttons.ContainsKey(____xboxButtonNegative)) { ____value -= _buttons[____xboxButtonNegative]; } ____lastPressedDuration = ____pressedDuration; ____pressedDuration = ((!__instance.IsPressed()) ? 0f : (____pressedDuration + (Time.realtimeSinceStartup - ____realtimeSinceLastUpdate))); ____realtimeSinceLastUpdate = Time.realtimeSinceStartup; return(false); }
private static void SetCommandButton(SingleAxisCommand command, JoystickButton buttonPositive, JoystickButton buttonNegative) { SetGamepadBinding(command, new InputBinding(buttonPositive, buttonNegative)); }
private static void SetGamepadBinding(SingleAxisCommand command, InputBinding binding) { command.SetValue("_gamepadBinding", binding); }
public virtual void SetUpPopupCommands(SingleAxisCommand okCommand, SingleAxisCommand cancelCommand, SingleAxisCommand resetCommand, ScreenPrompt okPrompt, ScreenPrompt cancelPrompt, ScreenPrompt resetPrompt) { SetUpPopupCommandsShort(resetCommand, resetPrompt); base.SetUpPopupCommands(okCommand, cancelCommand, okPrompt, cancelPrompt); }
private void SetUpPopupCommandsShort(SingleAxisCommand resetCommand, ScreenPrompt resetPrompt) { _resetCommand = resetCommand; _resetButton.SetPrompt(resetPrompt); }