public override void Update(ref Matrix parentMatrix) { // Check for input but only if selected. if (selected) { GamePadInput pad = GamePadInput.GetGamePad0(); if (Actions.Select.WasPressed) { Actions.Select.ClearAllWasPressedState(); if (onAButton != null) { onAButton(); Foley.PlayPressA(); } } if (Actions.X.WasPressed) { Actions.X.ClearAllWasPressedState(); if (onXButton != null) { onXButton(); Foley.PlayCut(); } } } RefreshTexture(); base.Update(ref parentMatrix); } // end of UIGridModularButtonElement Update()
} // end of HandleMouseInput() public override void HandleTouchInput(TouchContact touch, Vector2 hitUV) { if (onXButton != null) { if (xButtonBox.Touched(touch, hitUV)) { onXButton(); Foley.PlayCut(); } } if (onAButton != null) { if (aButtonBox.Touched(touch, hitUV)) { onAButton(); Foley.PlayPressA(); } } } // end of HandleTouchInput()
} // end of UIGridModularButtonElement Update() /// <summary> /// Test mouse input against buttons. hitUV is in /// local UV coords for button. Full range is 0..1 /// in either coordinate. /// </summary> /// <param name="hitUV"></param> public override void HandleMouseInput(Vector2 hitUV) { if (onXButton != null) { if (xButtonBox.LeftPressed(hitUV)) { onXButton(); Foley.PlayCut(); } } if (onAButton != null) { if (aButtonBox.LeftPressed(hitUV)) { onAButton(); Foley.PlayPressA(); } } } // end of HandleMouseInput()
public void HandleMouseInput() { if (GamePadInput.ActiveMode != GamePadInput.InputMode.KeyboardMouse) { return; } // In eyedropper mode, show the pointy cursor. if (KeyboardInput.AltIsPressed) { inGame.Cursor3D.Rep = Cursor3D.Visual.Pointy; inGame.Cursor3D.Hidden = false; } else { inGame.Cursor3D.Hidden = true; } if (KeyboardInput.AltIsPressed) { // Sample the current terrain. if (MouseEdit.TriggerSample()) { MouseInput.Left.IgnoreUntilReleased = true; // Prevent terrain from being painted when Alt is being used to select material. editMode = Terrain.EditMode.Noop; Vector3 p = MouseEdit.HitInfo.TerrainPosition; Vector2 pos = new Vector2(p.X, p.Y); ushort matIdx = Terrain.GetMaterialType(pos); if (TerrainMaterial.IsValid(matIdx, false, false)) { Terrain.CurrentMaterialIndex = matIdx; Foley.PlayCut(); } } } else if (!PickerXInUse && !PickerYInUse) { if (DebouncePending) { return; } if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse) { // Set the mode based on whether or not // option keys are pressed. if (MouseInput.Left.WasPressed) { editMode = Terrain.EditMode.PaintAndAddMaterial; if (KeyboardInput.ShiftIsPressed) { editMode = Terrain.EditMode.PaintMaterial; } else if (KeyboardInput.CtrlIsPressed) { editMode = Terrain.EditMode.AddAtCenter; } } } } }
} // end of BasePicker RestorePreviousChoice() public virtual void Update(PerspectiveUICamera camera) { if (active) { if (hidden) { // Note, even though we're hidden we may still be rendering our fade out. double elapsedTime = Time.WallClockTotalSeconds - startFadeTime; if (elapsedTime >= fadeTime) { Alpha = 0.0f; } else { Alpha = 1.0f - (float)(elapsedTime / fadeTime); } } else { // Not hidden, so respond to user input. int scroll = MouseInput.ScrollWheel - MouseInput.PrevScrollWheel; if (Actions.PickerRight.WasPressedOrRepeat || scroll > 0) { Actions.PickerRight.ClearAllWasPressedState(); DecrementFocus(); } if (Actions.PickerLeft.WasPressedOrRepeat || scroll < 0) { Actions.PickerLeft.ClearAllWasPressedState(); IncrementFocus(); } if (Actions.Select.WasPressed) { Actions.Select.ClearAllWasPressedState(); SelectCurrentChoice(); Foley.PlayPressA(); } if (Actions.Cancel.WasPressedOrRepeat) { Actions.Cancel.ClearAllWasPressedState(); RestorePreviousChoice(); Foley.PlayBack(); } bool handled = false; if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch) { handled = HandleTouchInput(camera); } else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse) { handled = HandleMouseInput(camera); } if (!handled) { // If the user clicked but didn't hit any of the picker elements, close the picker. // If alt is pressed, they must be in eyedropper mode. if ((MouseInput.Left.WasPressed && !KeyboardInput.AltIsPressed) || (TouchGestureManager.Get().TapGesture.WasRecognized)) { SelectCurrentChoice(); Foley.PlayPressA(); } else if (Actions.Sample.WasPressed || MouseEdit.TriggerSample() || TouchEdit.TriggerSample()) { Actions.Sample.ClearAllWasPressedState(); int t = OnSampleType(); if (t >= 0) { OnSetType(t); Point selection = grid.SelectionIndex; selection.X = t; grid.SelectionIndex = selection; Foley.PlayCut(); } else { Foley.PlayNoBudget(); } } } grid.Update(ref worldMatrix); } } // end if active } // end of BasePicker Update()