/// <summary> /// Handle win32 window message proc. /// </summary> private IntPtr HandleMessages(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { // WM_HOTKEY (we relay this to HotkeyManager) if (msg == WM_HOTKEY) { // hotkey id, supplied upon registration //var id = (int) wParam; // convert lParam to int, and split into high+low var lpInt = (int) lParam; var low = lpInt & 0xFFFF; var high = lpInt >> 16; // get virtual key code from high var key = KeyInterop.KeyFromVirtualKey(high); // get modifier from low var modifier = (Modifier) (low); // relay to hotkey manager var combo = new KeyCombo(modifier, key); _hotkeyManager.HandleKeyCombo(combo); } if (msg == WM_CLOSE) { _app.Shutdown(); } return IntPtr.Zero; }
public HotkeyEditor() { InitializeComponent(); MyKeyCombo = new KeyCombo(); }
public static KeyCombo ActionScriptKeyCodeToVK(string code) { if (string.IsNullOrEmpty(code)) return null; var codeElems = code.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); KeyCombo kc = new KeyCombo(); foreach(var el in codeElems) { var c = el.ToIntNullable(); if (!c.HasValue) continue; if (ActionScriptKeyCodeToVkLookup.ContainsKey(c.Value)) { var k = ActionScriptKeyCodeToVkLookup[c.Value]; kc.AddKey(k); } else { // MainWindow.LogStatic("WARNING!"); } } //return Key.None; return kc; }
public bool Equals(KeyCombo other) { return(other == this); }
private void AddMovesGPDXD(KeyManager manager) { Player player = GetObj().GetComponent <Player>(); KeyHistoryId leftX = manager.AddKeyHistory(new AxisHistory(new KeyStroke(new GPDXDKeyHandler(GPDXDKeyType.LeftJoyX)), 0f, -1f, 1f)); KeyHistoryId leftY = manager.AddKeyHistory(new AxisHistory(new KeyStroke(new GPDXDKeyHandler(GPDXDKeyType.LeftJoyY)), 0f, -1f, 1f)); { KeyCombo combo = new KeyCombo(manager); PlayerAction action = PlayerAction.MakePlayerWalkAction(1f, 1f); combo.RegisterKeyHistory(leftX); combo.RegisterKeyHistory(leftY); Move <PlayerAction> move = new Move <PlayerAction>(combo, action, PriorityConstants.PRIORITY_WALK); player.AddMove(move); } //KeyHistoryId leftLeft = manager.AddKeyHistory(new AxisHistory(new KeyStroke(new GPDXDKeyHandler(GPDXDKeyType.LeftJoyX)), 0f, -1f, -0.1f)); //KeyHistoryId leftRight = manager.AddKeyHistory(new AxisHistory(new KeyStroke(new GPDXDKeyHandler(GPDXDKeyType.LeftJoyX)), 0f, 0.1f, 1f)); //KeyHistoryId leftUp = manager.AddKeyHistory(new AxisHistory(new KeyStroke(new GPDXDKeyHandler(GPDXDKeyType.LeftJoyY)), 0f, 0.1f, 1f)); //KeyHistoryId leftDown = manager.AddKeyHistory(new AxisHistory(new KeyStroke(new GPDXDKeyHandler(GPDXDKeyType.LeftJoyY)), 0f, -1f, -0.1f)); //{ // KeyCombo combo = new KeyCombo(manager); // PlayerAction action = PlayerAction.MakePlayerWalkAction(1f, 1f); // combo.RegisterKeyHistory(leftLeft); // Move<PlayerAction> move = new Move<PlayerAction>(combo, action, PriorityConstants.PRIORITY_WALK_LEFT); // player.AddMove(move); //} //{ // KeyCombo combo = new KeyCombo(manager); // PlayerAction action = PlayerAction.MakePlayerWalkAction(1f, 1f); // combo.RegisterKeyHistory(leftRight); // Move<PlayerAction> move = new Move<PlayerAction>(combo, action, PriorityConstants.PRIORITY_WALK_RIGHT); // player.AddMove(move); //} //{ // KeyCombo combo = new KeyCombo(manager); // PlayerAction action = PlayerAction.MakePlayerWalkAction(1f, 1f); // combo.RegisterKeyHistory(leftUp); // Move<PlayerAction> move = new Move<PlayerAction>(combo, action, PriorityConstants.PRIORITY_WALK_UP); // player.AddMove(move); //} //{ // KeyCombo combo = new KeyCombo(manager); // PlayerAction action = PlayerAction.MakePlayerWalkAction(1f, 1f); // combo.RegisterKeyHistory(leftDown); // Move<PlayerAction> move = new Move<PlayerAction>(combo, action, PriorityConstants.PRIORITY_WALK_DOWN); // player.AddMove(move); //} }
public Keybind(UserAction action, KeyCombo keyCombo) { this.action = action; this.keyCombo = keyCombo; }
/// <summary> /// Initializes a new instance of the <see cref="NuGenHotKeyPopup"/> class. /// </summary> /// <param name="serviceProvider">Requires:<para/> /// <para><see cref="INuGenButtonStateTracker"/></para> /// <para><see cref="INuGenControlStateTracker"/></para> /// <para><see cref="INuGenButtonLayoutManager"/></para> /// <para><see cref="INuGenButtonRenderer"/></para> /// <para><see cref="INuGenCheckBoxLayoutManager"/></para> /// <para><see cref="INuGenCheckBoxRenderer"/></para> /// <para><see cref="INuGenComboBoxRenderer"/></para> /// <para><see cref="INuGenLabelLayoutManager"/></para> /// <para><see cref="INuGenLabelRenderer"/></para> /// <para><see cref="INuGenPanelRenderer"/></para> /// <para><see cref="INuGenControlImageManager"/></para> /// </param> /// <exception cref="ArgumentNullException"><paramref name="serviceProvider"/> is <see langword="null"/>.</exception> public NuGenHotKeyPopup(INuGenServiceProvider serviceProvider) : base(serviceProvider) { _modifiersLabel = new Label(serviceProvider); _modifiersLabel.Text = Resources.Text_HotKeysPopup_Modifiers; _keyLabel = new Label(serviceProvider); _keyLabel.Text = Resources.Text_HotKeysPopup_Key; _ctrlCheckBox = new NuGenCheckBox(serviceProvider); _ctrlCheckBox.Text = Resources.Text_HotKey_ctrlCheckBox; _shiftCheckBox = new NuGenCheckBox(serviceProvider); _shiftCheckBox.Text = Resources.Text_HotKey_shiftCheckBox; _altCheckBox = new NuGenCheckBox(serviceProvider); _altCheckBox.Text = Resources.Text_HotKey_altCheckBox; _modifiersLayoutPanel = new FlowLayoutPanel(); _modifiersLayoutPanel.Dock = DockStyle.Fill; _modifiersLayoutPanel.Controls.AddRange( new Control[] { _ctrlCheckBox , _shiftCheckBox , _altCheckBox } ); _modifiersLayoutPanel.Margin = _offsetMargin; _keyCombo = new KeyCombo(serviceProvider); _keyCombo.Width = 80; _resetButton = new NuGenButton(serviceProvider); _resetButton.Click += _resetButton_Click; _resetButton.Text = Resources.Text_HotKeysPopup_Reset; _keyLayoutPanel = new FlowLayoutPanel(); _keyLayoutPanel.Dock = DockStyle.Fill; _keyLayoutPanel.Controls.AddRange( new Control[] { _keyCombo , _resetButton } ); _keyLayoutPanel.Margin = _offsetMargin; _tableLayoutPanel = new TableLayoutPanel(); _tableLayoutPanel.Dock = DockStyle.Fill; _tableLayoutPanel.Parent = this; _tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); _tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 22)); _tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 24)); _tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 22)); _tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 24)); _tableLayoutPanel.Controls.Add(_modifiersLabel, 0, 0); _tableLayoutPanel.Controls.Add(_modifiersLayoutPanel, 0, 1); _tableLayoutPanel.Controls.Add(_keyLabel, 0, 2); _tableLayoutPanel.Controls.Add(_keyLayoutPanel, 0, 3); }
// Update is called once per frame void Update() { if (Input.GetButtonDown("B1")) { PlaySound(0, false); } else if(Input.GetButtonDown("B2")) { PlaySound(1, false); } else if (Input.GetButtonDown("B3")) { PlaySound(2, false); } Waiter(); GenerateCombos(); //se terminou de gerar os combos if (GenerateComboStrings() && !isComboCreated) { CAgua = new KeyCombo(SAgua); CFogo = new KeyCombo(SFogo); CTerra = new KeyCombo(STerra); CAr = new KeyCombo(SAr); isComboCreated = true; Debug.Log("Created Random Combos!"); combosGUI[0].text = "Agua: "+ comboAgua[0] + " " + comboAgua[1] + " " + comboAgua[2] + " " + comboAgua[3]; combosGUI[1].text = "Fogo: "+comboFogo[0] + " " + comboFogo[1] + " " + comboFogo[2] + " " + comboFogo[3]; combosGUI[2].text = "Terra: "+comboTerra[0] + " " + comboTerra[1] + " " + comboTerra[2] + " " + comboTerra[3]; combosGUI[3].text = "Ar: "+comboAr[0] + " " + comboAr[1] + " " + comboAr[2] + " " + comboAr[3]; } if (isComboCreated && CAgua.Check() && !wait) { Debug.Log("AGUA BREAKER"); GameObject.FindGameObjectWithTag("DestroyArea").SendMessage("destroyBlocks", 1); GameObject.FindGameObjectWithTag("GameManager").SendMessage("OKombo",1); wait = true; } else if (isComboCreated && CFogo.Check() && !wait) { Debug.Log("And everything changed when the fire nation attacked."); GameObject.FindGameObjectWithTag("DestroyArea").SendMessage("destroyBlocks", 2); GameObject.FindGameObjectWithTag("GameManager").SendMessage("OKombo",2); wait = true; } else if(isComboCreated && CTerra.Check() && !wait) { Debug.Log("TERRA BREAKER"); GameObject.FindGameObjectWithTag("DestroyArea").SendMessage("destroyBlocks", 3); GameObject.FindGameObjectWithTag("GameManager").SendMessage("OKombo",3); wait = true; } else if(isComboCreated && CAr.Check() && !wait) { Debug.Log("AVATAR"); GameObject.FindGameObjectWithTag("DestroyArea").SendMessage("destroyBlocks", 4); GameObject.FindGameObjectWithTag("GameManager").SendMessage("OKombo",4); wait = true; } }
// Update is called once per frame void Update() { if (keypressToRelease != null) { KeyboardInput.Up(keypressToRelease); keypressToRelease = null; } if (DataLoader.Settings.Lasermode != lastLaserMode) { UpdateLaserMode(); } if (!Device.IsValid) { OwnOverlay.enabled = false; HandOverlay.enabled = false; ButtonOverlay.enabled = false; return; } OwnOverlay.enabled = ActivityMonitor.Active && !DataLoader.Profile.hidePointer; HandOverlay.enabled = true; OwnOverlay.Alpha = (float)DataLoader.Profile.pointerAlpha; HandOverlay.Alpha = (float)DataLoader.Profile.controllerAlpha; if (DataLoader.Settings.Lasermode) { transform.position = Hand.transform.position; Quaternion laserRot = Quaternion.Euler(new Vector3(LaserAngle, 0, 0)); Vector3 rotAxis = laserRot * Vector3.up; transform.localRotation = laserRot; Vector3 localHeadLaser = Hand.transform.InverseTransformPoint(Head.transform.position); localHeadLaser = Quaternion.Inverse(laserRot) * localHeadLaser; float angleLaser = Mathf.Atan2(localHeadLaser.y, localHeadLaser.x) * 180 / Mathf.PI - 90; laserRot = Quaternion.AngleAxis(angleLaser, rotAxis) * laserRot; transform.localRotation = laserRot; } else { transform.position = Hand.transform.position; transform.LookAt(Head.transform.position); Quaternion look = transform.rotation; transform.rotation = Quaternion.Inverse(Hand.transform.rotation); transform.rotation = transform.rotation * look * Quaternion.AngleAxis(180, Vector3.up); } Vector3 localHead = Hand.transform.InverseTransformPoint(Head.transform.position); float angle = Mathf.Atan2(localHead.y, localHead.x) * 180 / Mathf.PI - 90; //HandOverlayObject.transform.position = Hand.transform.position; Vector3 euler = HandOverlayObject.transform.localRotation.eulerAngles; euler.y = angle; HandOverlayObject.transform.localRotation = Quaternion.Euler(euler); if (ActivityMonitor.Active) { UpdateDraggingOverlay(); UpdateOverlays(); } }
public Move(KeyCombo newCombo, T newAction, int newPriority) { combo = newCombo; action = newAction; priority = newPriority; }
private void UserControl_PreviewKeyDown(object sender, KeyEventArgs e) { Key key = e.Key; e.Handled = true; // If the System tried to capture the key and handle it, find out // what the key originally was... if (key == Key.System) { key = e.SystemKey; } if (IsKeyRequiredForNavigation(key)) { e.Handled = false; return; } if (e.IsRepeat || !e.IsDown) { return; } #if (DEBUG) System.Diagnostics.Debug.WriteLine("PreviewKeyDown: " + e.Key.ToString() + ", " + e.SystemKey.ToString() + ", " + e.KeyStates.ToString()); #endif MessageTextBlock.Text = ""; if (_workingKeyCombo == null) { _workingKeyCombo = new KeyCombo(); } if (KeyCombo.IsCtrlKey(key)) { _workingKeyCombo.Ctrl = true; SetKeyComboText(); } else if (KeyCombo.IsAltKey(key)) { _workingKeyCombo.Alt = true; SetKeyComboText(); } else if (KeyCombo.IsShiftKey(key)) { _workingKeyCombo.Shift = true; SetKeyComboText(); } else if (KeyCombo.IsWindowsKey(key)) { } else if (key == Key.Delete && !_workingKeyCombo.Shift && !_workingKeyCombo.Alt && !_workingKeyCombo.Ctrl) { // Allow Delete (by itself) to clear the existing combo KeyCombo = null; return; } else { // Try to set it and see if it works! _workingKeyCombo.Key = key; } HandleAfterKeyPressed(); }
private void ClearButton_MouseDown(object sender, MouseButtonEventArgs e) { KeyCombo = null; _workingKeyCombo = null; SetKeyComboText(); }
private void UserControl_LostFocus(object sender, RoutedEventArgs e) { MessageTextBlock.Text = ""; _workingKeyCombo = null; SetKeyComboText(); }
private void UserControl_PreviewKeyUp(object sender, KeyEventArgs e) { var key = e.Key; e.Handled = true; // If the System tried to capture the key and handle it, find out // what the key originally was... if (key == Key.System) { key = e.SystemKey; } if (IsKeyRequiredForNavigation(key)) { return; } if (e.IsRepeat) { return; } #if (DEBUG) System.Diagnostics.Debug.WriteLine("PreviewKeyUp: " + e.Key.ToString() + ", " + e.SystemKey.ToString()); #endif MessageTextBlock.Text = ""; if (_workingKeyCombo == null) { if (key == Key.PrintScreen) { // The Print Key is special. We need to watch // KeyUp instead of just KeyDown _workingKeyCombo = new KeyCombo(); } else { return; } } if (KeyCombo.IsCtrlKey(key)) { _workingKeyCombo.Ctrl = false; SetKeyComboText(); } else if (KeyCombo.IsAltKey(key)) { _workingKeyCombo.Alt = false; SetKeyComboText(); } else if (KeyCombo.IsShiftKey(key)) { _workingKeyCombo.Shift = false; SetKeyComboText(); } else if (key == Key.PrintScreen) { // The KeyDown for PrintScreen seems to be consumed by // Windows and we don't see it. Therefore, we need to // treat PrintScreen as a special key that we handle on // KeyUp. _workingKeyCombo.Key = key; HandleAfterKeyPressed(); } else if (_workingKeyCombo.Key == key) { _workingKeyCombo.Key = Key.None; SetKeyComboText(); } }
public NewKeyComboEventArgs(KeyCombo keyCombo) { KeyCombo = keyCombo; }
private static void UpdateRow(Table table, KeyCombo keys, IDictionary<string, object> data) { table.MergeRow(keys.PartitionKey, keys.RowKey, data); }
void UpdateOverlays() { if (PressedDown(SteamVR_Controller.ButtonMask.ApplicationMenu)) { DataLoader.StartSelectingProfile(DataLoader.Settings.Lasermode ? Hand.transform.position + 0.2f * LaserDirection() : BallPosition(), Head.transform.position); } if (PressedUp(SteamVR_Controller.ButtonMask.ApplicationMenu) && DataLoader.SelectingProfile) { DataLoader.StopSelectingProfile(profileIndex); } bool profileSet = false; if (CurrentButton != null) { isLeftRight = CurrentButton.isLeftRight; } Vector2 touchPos = TouchpadPos(); bool touchModeTouchpadActive = Mathf.Abs(isLeftRight ? touchPos.x : touchPos.y) >= 0.5; bool touchModeTouchpadPressed = touchModeTouchpadActive && !this.TouchModeTouchpadWasActive; bool touchModeTouchpadReleased = !touchModeTouchpadActive && this.TouchModeTouchpadWasActive; this.TouchModeTouchpadWasActive = touchModeTouchpadActive; if (CurrentButton == null) { bool showOverlay = false; OverlayLoader closestOverlay = null; Vector3 closestPos = new Vector3(0, 0, 1000); float closestDist = 1000; List <OverlayLoader> overlays = DataLoader.SelectingProfile ? DataLoader.ProfileOverlayList : DataLoader.Overlays; foreach (OverlayLoader overlay in overlays) { float dist; Vector3 relPos = overlay.RelativePosition(DataLoader.Settings.Lasermode ? Hand.transform.position : BallPosition(), DataLoader.Settings.Lasermode ? LaserDirection() : Vector3.zero, out dist); if (overlay.PositionInRange(relPos, 0.1f) && dist < closestDist) { closestOverlay = overlay; closestPos = relPos; closestDist = dist; } } if (closestOverlay != null) { if (DataLoader.Settings.Lasermode) { SetLaserLength(closestDist); } GridButton button = closestOverlay.PointedButton(closestPos); if (button != null) { showOverlay = true; ButtonOverlay.OverlayTexture = OverlayTextureForButton(button); closestOverlay.ShowButtonOverlay(button, ButtonOverlay); if (!DataLoader.SelectingProfile) { if (PressedDown(SteamVR_Controller.ButtonMask.Trigger)) { CurrentButton = button; CurrentKeypress = button.keypress; if (button.buttonType == ButtonType.Normal || button.buttonType == ButtonType.ThreeWaySwitch) { KeyboardInput.Down(button.keypress); } else { RotaryDirection = PointingDirection(); RotaryOriginalUp = PointingUpDirection(); } ButtonOverlay.OverlayTexture = OverlayTexturePressed; } else if ((!DataLoader.Settings.OculusTouchMode && PressedDown(SteamVR_Controller.ButtonMask.Touchpad)) || (DataLoader.Settings.OculusTouchMode && touchModeTouchpadPressed)) { if (button.buttonType == ButtonType.ThreeWaySwitch) { CurrentButton = button; ButtonOverlay.OverlayTexture = OverlayTexturePressed; CurrentKeypress = (CurrentButton.isLeftRight ? touchPos.x : touchPos.y) >= 0 ? button.cwKeypress : button.ccwKeypress; KeyboardInput.Down(CurrentKeypress); } else if (button.buttonType == ButtonType.MultiPositionSwitch) { CurrentButton = button; ButtonOverlay.OverlayTexture = OverlayTexturePressed; int sign = (CurrentButton.isLeftRight ? touchPos.x : touchPos.y) >= 0 ? 1 : -1; int nextPosition = CurrentButton.currentKeypress + (int)sign; if (nextPosition >= 0 && nextPosition < CurrentButton.multiKeypresses.Count) { CurrentButton.currentKeypress = nextPosition; KeyCombo keypress = CurrentButton.multiKeypresses[nextPosition]; KeyboardInput.Down(keypress); KeyboardInput.Up(keypress); } } } } else { profileIndex = closestOverlay.ButtonGrid.buttons.IndexOf(button); profileSet = true; } } if (!DataLoader.SelectingProfile && !closestOverlay.ButtonGrid.locked && PressedDown(SteamVR_Controller.ButtonMask.Grip)) { MovingOverlay = closestOverlay; MovingOriginalPosition = BallPosition(); MovingOriginalRotation = Hand.transform.rotation; MovingOriginalOverlayPosition = closestOverlay.transform.position; MovingOriginalOverlayRotation = closestOverlay.transform.rotation; } } else if (DataLoader.Settings.Lasermode) { SetLaserLength(0.2f); } if (!showOverlay) { ButtonOverlay.enabled = false; } } else { if (PressedUp(SteamVR_Controller.ButtonMask.Trigger) || (((!DataLoader.Settings.OculusTouchMode && PressedUp(SteamVR_Controller.ButtonMask.Touchpad)) || (DataLoader.Settings.OculusTouchMode && touchModeTouchpadReleased)) && (CurrentButton.buttonType == ButtonType.ThreeWaySwitch || CurrentButton.buttonType == ButtonType.MultiPositionSwitch))) { if (CurrentButton.buttonType == ButtonType.Normal || CurrentButton.buttonType == ButtonType.ThreeWaySwitch || CurrentButton.buttonType == ButtonType.MultiPositionSwitch) { KeyboardInput.Up(CurrentKeypress); } ButtonOverlay.OverlayTexture = OverlayTexture; CurrentButton = null; CurrentKeypress = null; } else if (CurrentButton.buttonType == ButtonType.TwoDirectionRotary || CurrentButton.buttonType == ButtonType.MultiPositionRotary) { float angle = AngleBetween(this.RotaryOriginalUp, PointingUpDirection(), this.RotaryDirection); if (Mathf.Abs(angle) >= CurrentButton.rotaryAngle) { float sign = Mathf.Sign(angle); this.RotaryOriginalUp = Quaternion.AngleAxis((float)CurrentButton.rotaryAngle * (-sign), this.RotaryDirection) * this.RotaryOriginalUp; if (CurrentButton.buttonType == ButtonType.TwoDirectionRotary) { KeyCombo keypress = sign > 0 ? CurrentButton.cwKeypress : CurrentButton.ccwKeypress; KeyboardInput.Down(keypress); keypressToRelease = keypress; } else if (CurrentButton.buttonType == ButtonType.MultiPositionRotary) { int nextPosition = CurrentButton.currentKeypress + (int)sign; if (nextPosition >= 0 && nextPosition < CurrentButton.multiKeypresses.Count) { CurrentButton.currentKeypress = nextPosition; KeyCombo keypress = CurrentButton.multiKeypresses[nextPosition]; KeyboardInput.Down(keypress); keypressToRelease = keypress; } } } } } if (!profileSet && DataLoader.SelectingProfile) { profileIndex = -1; } }
/// <summary> /// Changes the keybind for an action. Must be run as a coroutine! /// </summary> /// <param name="selectedAction">The action to change the keybinding of</param> /// <param name="isPrimary">Is this a primary or a secondary keybinding?</param> public IEnumerator ChangeKeybind(KeyAction selectedAction, bool isPrimary) { KeyValuePair <KeyAction, DualKeyCombo> conflictingKVP; KeyCombo capturedKeyCombo = KeyCombo.None; bool isConflictPrimary = true; // Wait for the keycombo to be captured KeyCapturePanel.SetActive(true); UIManager.IsInputFocus = true; while (capturedKeyCombo == KeyCombo.None) { capturedKeyCombo = keybindManager.CaptureKeyCombo(); yield return(null); } KeyCapturePanel.SetActive(false); // If null stop the function (null is returned if Escape was captured) if (capturedKeyCombo == null) { Logger.Log("Captured Escape key, cancelling change", Category.Keybindings); UIManager.IsInputFocus = false; yield break; } Logger.Log("Captured key combo: " + capturedKeyCombo.ToString(), Category.Keybindings); conflictingKVP = tempKeybinds.CheckConflict(capturedKeyCombo, ref isConflictPrimary); KeyAction conflictingAction = conflictingKVP.Key; if (conflictingAction == KeyAction.None) { // No conflicts found so set the new keybind and refresh the view tempKeybinds.Set(selectedAction, capturedKeyCombo, isPrimary); keybindManager.SaveKeybinds(tempKeybinds); // Make sure the player can move around again UIManager.IsInputFocus = false; PopulateKeybindScrollView(); } // Check that the conflict isn't with itself, if it is just ignore it else if (conflictingAction != selectedAction) { // Get the metadata for the keybind KeybindMetadata conflictingKeybindMetadata = keybindManager.keyActionMetadata[conflictingAction]; // Check if the user wants to change the keybind modalPanelManager.Confirm( "Warning!\n\nThis combination is already being used by:\n" + conflictingKeybindMetadata.Name + "\nAre you sure you want to override it?", () => { // User confirms they want to change the keybind tempKeybinds.Set(selectedAction, capturedKeyCombo, isPrimary); tempKeybinds.Remove(conflictingAction, isConflictPrimary); keybindManager.SaveKeybinds(tempKeybinds); UIManager.IsInputFocus = false; PopulateKeybindScrollView(); }, "Yes", () => { UIManager.IsInputFocus = false; } ); } }
/// <summary> /// Initializes a new instance of the <see cref="NuGenHotKeyPopup"/> class. /// </summary> /// <param name="serviceProvider">Requires:<para/> /// <para><see cref="INuGenButtonStateTracker"/></para> /// <para><see cref="INuGenControlStateTracker"/></para> /// <para><see cref="INuGenButtonLayoutManager"/></para> /// <para><see cref="INuGenButtonRenderer"/></para> /// <para><see cref="INuGenCheckBoxLayoutManager"/></para> /// <para><see cref="INuGenCheckBoxRenderer"/></para> /// <para><see cref="INuGenComboBoxRenderer"/></para> /// <para><see cref="INuGenLabelLayoutManager"/></para> /// <para><see cref="INuGenLabelRenderer"/></para> /// <para><see cref="INuGenPanelRenderer"/></para> /// <para><see cref="INuGenControlImageManager"/></para> /// </param> /// <exception cref="ArgumentNullException"><paramref name="serviceProvider"/> is <see langword="null"/>.</exception> public NuGenHotKeyPopup(INuGenServiceProvider serviceProvider) : base(serviceProvider) { _modifiersLabel = new Label(serviceProvider); _modifiersLabel.Text = Resources.Text_HotKeysPopup_Modifiers; _keyLabel = new Label(serviceProvider); _keyLabel.Text = Resources.Text_HotKeysPopup_Key; _ctrlCheckBox = new NuGenCheckBox(serviceProvider); _ctrlCheckBox.Text = Resources.Text_HotKey_ctrlCheckBox; _shiftCheckBox = new NuGenCheckBox(serviceProvider); _shiftCheckBox.Text = Resources.Text_HotKey_shiftCheckBox; _altCheckBox = new NuGenCheckBox(serviceProvider); _altCheckBox.Text = Resources.Text_HotKey_altCheckBox; _modifiersLayoutPanel = new FlowLayoutPanel(); _modifiersLayoutPanel.Dock = DockStyle.Fill; _modifiersLayoutPanel.Controls.AddRange( new Control[] { _ctrlCheckBox , _shiftCheckBox , _altCheckBox } ); _modifiersLayoutPanel.Margin = _offsetMargin; _keyCombo = new KeyCombo(serviceProvider); _keyCombo.Width = 80; _resetButton = new NuGenButton(serviceProvider); _resetButton.Click += _resetButton_Click; _resetButton.Text = Resources.Text_HotKeysPopup_Reset; _keyLayoutPanel = new FlowLayoutPanel(); _keyLayoutPanel.Dock = DockStyle.Fill; _keyLayoutPanel.Controls.AddRange( new Control[] { _keyCombo , _resetButton } ); _keyLayoutPanel.Margin = _offsetMargin; _tableLayoutPanel = new TableLayoutPanel(); _tableLayoutPanel.Dock = DockStyle.Fill; _tableLayoutPanel.Parent = this; _tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); _tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 22)); _tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 24)); _tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 22)); _tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 24)); _tableLayoutPanel.Controls.Add(_modifiersLabel, 0, 0); _tableLayoutPanel.Controls.Add(_modifiersLayoutPanel, 0, 1); _tableLayoutPanel.Controls.Add(_keyLabel, 0, 2); _tableLayoutPanel.Controls.Add(_keyLayoutPanel, 0, 3); }
public KeyConfig(KeyPressAction action, KeyCombo combo) { Action = action; Param1 = combo?.KeyCode ?? 0; Param2 = (byte)(combo?.Modifier ?? 0); }
/// <summary> /// Retrieves the KeyCombo for the name. If the named key combination has not been defined /// then this returns null. Named key combinations are defined using /// DefineKeyCombo(string, KeyCode[]), e.g., DefineKey ("Reset", new {KeyCode.CONTROL, KeyCode.R}) /// </summary> /// <returns><c>true</c>, if screen point over an object, <c>false</c> otherwise.</returns> /// <param name="name">The Name of the key combination.</param> /// <param name="hitInfo">The requested KeyCombo object (if it was found).</param> public static bool RetrieveKeyCombo(string name, out KeyCombo keyCombo) { return(KeyComboDict.TryGetValue(name, out keyCombo)); }
public Keybind(UserAction action, KeyCombo keyCombo, KeyCombo keyComboAlt) : this(action, keyCombo) { this.keyComboAlt = keyComboAlt; }
/// <summary> /// Returns true if the all the keys of the key combination are down. /// </summary> /// <returns><c>true</c>, if all the requisite keys are down, /// AND trigger key of the combination was just released, /// <c>false</c> otherwise.</returns> public static bool Hold(this KeyCombo keyCombo) { return(AllKeysDown(keyCombo.secondaryKeys) && keyCombo.triggerKey.Hold()); }
public KeyBindingSource(KeyCombo keyCombo) { Control = keyCombo; }
public KeyBindingSource(params Key[] keys) { Control = new KeyCombo(keys); }
public DualKeyCombo(KeyCombo primaryCombo = null, KeyCombo secondaryCombo = null) { PrimaryCombo = primaryCombo ?? KeyCombo.None; SecondaryCombo = secondaryCombo ?? KeyCombo.None; }
/** * Get a simulated keypress combo */ public static IKeyPress Key(KeyCombo keyCombo) { return(Key(keyCombo.key, keyCombo.modifiers)); }