protected override void OnInitialize() { var chatPanel = GameObjectUtilities.FindGameObject("Voice/VoicePanelContainer").gameObject; _talkButton = GameObjectUtilities.FindGameObject("Voice/PressToTalkButtonContainer").GetComponent <PressedState>(); base.OnInitialize(); }
public MouseEventArgsExtended(MouseButtons button, PressedState state, bool doubleClick, double x, double y, double wheel) /*: base(args.MouseDevice, args.Timestamp, args.StylusDevice)*/ { Button = button; State = state; DoubleClick = doubleClick; X = x; Y = y; Wheel = wheel; }
/* * Basically all of the logic for the button is done in here so that the things that rely on it will be able to gather the results that * they need from it when they have their Update() called. */ public void HandleInput() { /* * All of these only happen on one frame, so we'll set them to false right at the start. */ JustClicked = false; JustHovered = false; JustReleased = false; JustUnhovered = false; if (state != PressedState.Disabled) { MouseState mouse = Mouse.GetState(); /* * The collision box may not perfectly line up with the texture's top left corner, so we've got to add a bunch of things together in * order to properly check whether or not the mouse is within the box. */ if (mouse.X > collision.X + position.X && mouse.X < collision.X + collision.Width + position.X && mouse.Y > collision.Y + position.Y && mouse.Y < collision.Y + collision.Height + position.Y) { if (state == PressedState.Idle) { JustHovered = true; } if (mouse.LeftButton == ButtonState.Pressed) { if (state != PressedState.Pressed) { JustClicked = true; } state = PressedState.Pressed; } else { if (state == PressedState.Pressed) { JustReleased = true; } state = PressedState.Hovered; } } else { if (state != PressedState.Idle) { if (state == PressedState.Pressed) { JustReleased = true; } JustUnhovered = true; state = PressedState.Idle; } } } }
/* * A button can: * -Be pressed * -Be disabled * -Handle input * -Be drawn * -Only if there is a texture * -If sample areas were provided, choose one based on the state */ public Button(Rectangle collisionBox, Texture2D texture = null, Rectangle[] samples = null, Vector2 position = new Vector2(), bool disabled = false) { this.texture = texture; sampleAreas = samples; collision = collisionBox; this.position = position; if (disabled) { state = PressedState.Disabled; } else { state = PressedState.Idle; } }
protected static PressedState CheckPressedState(ButtonState a_currentState, PressedState a_lastState) { if (a_currentState == ButtonState.Pressed) { if (a_lastState == PressedState.Pressed || a_lastState == PressedState.Held) { return PressedState.Held; } return PressedState.Pressed; } if (a_lastState != PressedState.Released && a_lastState != PressedState.Idle) { return PressedState.Released; } return PressedState.Idle; }
protected override GUIFSM <Button> CreateFSM() { var iState = new ButtonState(); iState.AddTransition(GUIEventID.MouseEnter, 1); iState.AddTransition(GUIEventID.FocusGained, 2); var hState = new ButtonState(); hState.AddTransition(GUIEventID.MouseExit, 0); hState.AddTransition(GUIEventID.FocusGained, 3); var fState = new FocusedState(); fState.AddTransition(GUIEventID.FocusLost, 0); fState.AddTransition(GUIEventID.MouseEnter, 3); var fhState = new FocusedState(); fhState.AddTransition(GUIEventID.FocusLost, 1); fhState.AddTransition(GUIEventID.MouseExit, 2); fhState.AddTransition(GUIEventID.LeftMouseDown, 4); var phState = new PressedState(); phState.AddTransition(GUIEventID.LeftMouseUp, 3); phState.AddTransition(GUIEventID.MouseExit, 5); phState.AddTransition(GUIEventID.FocusLost, 1); var pState = new FocusedState(); pState.AddTransition(GUIEventID.MouseEnter, 4); pState.AddTransition(GUIEventID.LeftMouseUp, 2); pState.AddTransition(GUIEventID.FocusLost, 0); return(new GUIFSM <Button>(this, new GUIState <Button>[] { iState, hState, fState, fhState, phState, pState })); }
public abstract bool Run(double elapsed, PressedState pressedState, ref Xim.Input input, ref Xim.Input startState);
public override bool Run(double elapsed, PressedState pressedState, ref Xim.Input input, ref Xim.Input startState) { m_stillPressed = m_stillPressed && pressedState.xinputState.IsButtonDown(this.button); return base.Run(elapsed, m_stillPressed, ref input, ref startState); }
public override bool Run(double elapsed, PressedState pressedState, ref Xim.Input input, ref Xim.Input startState) { int analogVal = 0; float controllerValue = 0; switch (button) { case Xim.Analog.LeftStickX: controllerValue = pressedState.xinputState.ThumbSticks.Left.X; break; case Xim.Analog.LeftStickY: controllerValue = pressedState.xinputState.ThumbSticks.Left.Y; break; case Xim.Analog.LeftTrigger: controllerValue = pressedState.xinputState.Triggers.Left; break; case Xim.Analog.RightStickX: controllerValue = pressedState.xinputState.ThumbSticks.Right.X; break; case Xim.Analog.RightStickY: controllerValue = pressedState.xinputState.ThumbSticks.Right.Y; break; case Xim.Analog.RightTrigger: controllerValue = pressedState.xinputState.Triggers.Right; break; default: return false; } analogVal = (int)(controllerValue * (int)Xim.Stick.Max + (int)Xim.Stick.Max); inputEvent.Run(false, elapsed, analogVal, ref input, ref startState); return true; }
public override bool Run(double elapsed, PressedState pressedState, ref Xim.Input input, ref Xim.Input startState) { m_stillPressed = m_stillPressed && pressedState.mouseButtons.Contains(m_button); return base.Run(elapsed, m_stillPressed, ref input, ref startState); }
public override bool Run(double elapsed, PressedState pressedState, ref Xim.Input input, ref Xim.Input startState) { m_stillPressed = m_stillPressed && Xim.GetButtonState(button, ref input) == Xim.ButtonState.Pressed; return base.Run(elapsed, m_stillPressed, ref input, ref startState); }
public override bool Run(double elapsed, PressedState pressedState, ref Xim.Input input, ref Xim.Input startState) { int analogVal = 0; switch (button) { case Joystick.Analog.JoyRx: analogVal = pressedState.joyState.Rx; break; case Joystick.Analog.JoyRy: analogVal = pressedState.joyState.Ry; break; case Joystick.Analog.JoyRz: analogVal = pressedState.joyState.Rz; break; case Joystick.Analog.JoyX: analogVal = pressedState.joyState.X; break; case Joystick.Analog.JoyY: analogVal = pressedState.joyState.Y; break; case Joystick.Analog.JoyZ: analogVal = pressedState.joyState.Z; break; case Joystick.Analog.JoySlider0: { int[] sliders = pressedState.joyState.GetSlider(); if (sliders != null && sliders.Length != 0) { analogVal = pressedState.joyState.GetSlider()[0]; } else { InfoTextManager.Instance.WriteLine("There is an active bind for Slider0 but no sliders are available on this controller. This is usually caused by using joy binds when 360 binds should be used."); return false; } } break; case Joystick.Analog.JoySlider1: { int[] sliders = pressedState.joyState.GetSlider(); if (sliders != null && sliders.Length != 0) { analogVal = pressedState.joyState.GetSlider()[1]; } else { InfoTextManager.Instance.WriteLine("There is an active bind for Slider1 but no sliders are available on this controller. This is usually caused by using joy binds when 360 binds should be used."); return false; } } break; default: return false; } inputEvent.Run(false, elapsed, analogVal, ref input, ref startState); return true; }
public KeyTrigger(Keys key) { Key = key; CurrentState = PressedState.None; }