private void HandleTouchInput(TouchContact touch, Vector2 hit) { if (hitBox.Touched(touch, hit)) { Deactivate(); } // Check for hover and adjust text color to match. Color newColor; newColor = hitBox.Contains(hit) ? hoverTextColor : lightTextColor; if (newColor != labelATargetColor) { labelATargetColor = newColor; Vector3 curColor = new Vector3(labelAColor.R / 255.0f, labelAColor.G / 255.0f, labelAColor.B / 255.0f); Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f); TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param) { labelAColor.R = (byte)(value.X * 255.0f + 0.5f); labelAColor.G = (byte)(value.Y * 255.0f + 0.5f); labelAColor.B = (byte)(value.Z * 255.0f + 0.5f); }; TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut); } } // end of HandleTouchInput()
} // end of Update() private void HandleTouchInput(TouchContact touch, Vector2 hit) { if (hitBox.Touched(touch, hit)) { Boku.Common.Gesture.TouchGestureManager.Get().TapGesture.ClearWasTapped(); AuthUI.ShowSignOutDialog(); } }
} // 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 Update() private void HandleTouchInput(TouchContact touch, Vector2 hit) { if (checkBoxBox.Touched(touch, hit)) { Boku.Common.Gesture.TouchGestureManager.Get().TapGesture.ClearWasTapped(); keepSignedInChecked = !keepSignedInChecked; } // Buttons if (signOutButton.Box.Touched(touch, hit)) { Boku.Common.Gesture.TouchGestureManager.Get().TapGesture.ClearWasTapped(); OnAccept(); } if (cancelButton.Box.Touched(touch, hit)) { Boku.Common.Gesture.TouchGestureManager.Get().TapGesture.ClearWasTapped(); OnCancel(); } } // end of HandleTouchInput()
} // end of Update() private void HandleTouchInput(TouchContact touch, Vector2 hit) { if (helpBox.Touched(touch, hit)) { Boku.Common.Gesture.TouchGestureManager.Get().TapGesture.ClearWasTapped(); OnHelp(); } if (creatorBox.Touched(touch, hit)) { Boku.Common.Gesture.TouchGestureManager.Get().TapGesture.ClearWasTapped(); EditingCreator = true; } if (pinBox.Touched(touch, hit)) { Boku.Common.Gesture.TouchGestureManager.Get().TapGesture.ClearWasTapped(); EditingPin = true; } if (checkBoxBox.Touched(touch, hit)) { Boku.Common.Gesture.TouchGestureManager.Get().TapGesture.ClearWasTapped(); keepSignedInChecked = !keepSignedInChecked; EditingCreator = false; EditingPin = false; } // Buttons if (okButton.Box.Touched(touch, hit)) { Boku.Common.Gesture.TouchGestureManager.Get().TapGesture.ClearWasTapped(); OnAccept(); } if (cancelButton.Box.Touched(touch, hit)) { Boku.Common.Gesture.TouchGestureManager.Get().TapGesture.ClearWasTapped(); OnCancel(); } } // end of HandleTouchInput()
private void HandleTouchInput(TouchContact touch, Vector2 hit) { if (hitBoxA.Touched(touch, hit)) { // Disable this hint for this session. if (curHint.ShowOnce) { curHint.Disabled = true; } Deactivate(); } else if (hitBoxB.Touched(touch, hit)) { // Disable this hint until reset by user. XmlOptionsData.SetHintAsDisabled(curHint.ID); // Disable this hint for this session. if (curHint.ShowOnce) { curHint.Disabled = true; } Deactivate(); } else if (upBox.Touched(touch, hit)) { ScrollDown(); } else if (downBox.Touched(touch, hit)) { ScrollUp(); } else { // Touch is active, but none of the buttons were hit so assume user is trying to scroll text. if (touch.phase == TouchPhase.Began) { prevTouchY = touch.position.Y; } if (touch.phase == TouchPhase.Moved) { // Note we calc the delta ourselves since the TouchInput code // may return the TouchContact for multiple frames. float delta = touch.position.Y - prevTouchY; // Adjust for screen / rt ratio. Vector2 ratio = TouchInput.GetWinRTRatio(camera); delta /= ratio.Y; accumulatedTouchInput += delta; prevTouchY = touch.position.Y; if (accumulatedTouchInput > blob.TotalSpacing / 2) { accumulatedTouchInput -= blob.TotalSpacing; ScrollDown(); } else if (accumulatedTouchInput < -blob.TotalSpacing / 2) { accumulatedTouchInput += blob.TotalSpacing; ScrollUp(); } } } // Check for hover and adjust text color to match. Color newColor; newColor = hitBoxA.Contains(hit) ? hoverTextColor : lightTextColor; if (newColor != labelATargetColor) { labelATargetColor = newColor; Vector3 curColor = new Vector3(labelAColor.R / 255.0f, labelAColor.G / 255.0f, labelAColor.B / 255.0f); Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f); TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param) { labelAColor.R = (byte)(value.X * 255.0f + 0.5f); labelAColor.G = (byte)(value.Y * 255.0f + 0.5f); labelAColor.B = (byte)(value.Z * 255.0f + 0.5f); }; TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut); } newColor = hitBoxB.Contains(hit) ? hoverTextColor : lightTextColor; if (newColor != labelBTargetColor) { labelBTargetColor = newColor; Vector3 curColor = new Vector3(labelBColor.R / 255.0f, labelBColor.G / 255.0f, labelBColor.B / 255.0f); Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f); TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param) { labelBColor.R = (byte)(value.X * 255.0f + 0.5f); labelBColor.G = (byte)(value.Y * 255.0f + 0.5f); labelBColor.B = (byte)(value.Z * 255.0f + 0.5f); }; TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut); } } // end of HandleTouchInput()
public static void Update() { // Should only happens during device reset. if (dirty) { RefreshTexture(); } // If we've changed modes, refresh the texture. if (GamePadInput.ActiveMode != prevMode) { RefreshTexture(); prevMode = GamePadInput.ActiveMode; } if (wasRenderingAsThumbnail && !InGame.inGame.RenderWorldAsThumbnail) { RefreshTexture(); wasRenderingAsThumbnail = false; } if (InGame.inGame.RenderWorldAsThumbnail) { wasRenderingAsThumbnail = true; } if (Active && GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse) { camera.Resolution = new Point(1280, 720); // Match the render target we're using. Vector2 mouseHit = MouseInput.GetAspectRatioAdjustedPosition(camera, false); if (homeHitBox.LeftPressed(mouseHit)) { InGame.inGame.SwitchToMiniHub(); } if (editHitBox.LeftPressed(mouseHit)) { InGame.inGame.CurrentUpdateMode = InGame.UpdateMode.EditObject; } if (restartHitBox.LeftPressed(mouseHit)) { InGame.inGame.ResetSim(preserveScores: false, removeCreatablesFromScene: true, keepPersistentScores: false); } } else if (Active && GamePadInput.ActiveMode == GamePadInput.InputMode.Touch) { camera.Resolution = new Point(1280, 720); // Match the render target we're using. for (int i = 0; i < TouchInput.TouchCount; i++) { TouchContact touch = TouchInput.GetTouchContactByIndex(i); // Touch input on grid. // Hit the in-focus tile, then open popup. // Hit another tile, then bring that one to focus. Note because of overlap of // the tiles we should do this center-out. Vector2 touchHit = TouchInput.GetAspectRatioAdjustedPosition( touch.position, camera, false ); if (homeHitBox.Touched(touch, touchHit)) { InGame.inGame.SwitchToMiniHub(); } if (editHitBox.Touched(touch, touchHit)) { InGame.inGame.CurrentUpdateMode = InGame.UpdateMode.EditObject; } if (restartHitBox.Touched(touch, touchHit)) { InGame.inGame.ResetSim(preserveScores: false, removeCreatablesFromScene: true, keepPersistentScores: false); } } } } // end of Update()
private void HandleTouchInput(Camera camera) { if (GamePadInput.ActiveMode != GamePadInput.InputMode.Touch) { return; } // Touch input // If the touch is over the menu, move the selection index to the item under the mouse. // On touch down, make the item (if any) under the touch the ClickedOnItem. // On tap, if the touch is still over the ClickedOnItem, activate it. If not, just clear ClickedOnItem. TouchContact touch = TouchInput.GetOldestTouch(); if (touch != null) { Vector2 hitUV = TouchInput.GetHitUV(touch.position, camera, ref invWorldMatrix, width, height, useRtCoords: useRtCoords); // See if we're over anything. If so, set that item to being selected but only if we've moved the mouse. // This prevents the menu from feeling 'broken' if the mouse is over it and the user tries to use // the gamepad or keyboard. int touchItem = -1; for (int i = 0; i < itemList.Count; i++) { if (itemList[i].UVBoundingBox != null && itemList[i].UVBoundingBox.Contains(hitUV)) { // Only update the current in-focus element when the mouse moves. if (true) // touch.position != touch.previousPosition) { CurIndex = i; } touchItem = i; } } //if ( TouchInput.TapGesture.WasTapped() ) if (TouchInput.IsTouched) { if (touchItem != -1) { touch.TouchedObject = itemList[touchItem]; } } if (TouchGestureManager.Get().TapGesture.WasTapped()) { // Make sure we're still over the ClickedOnItem. if (touchItem != -1 && touch.TouchedObject == itemList[touchItem]) { ToggleState(); } } Vector2 hit = touch.position; if (useRtCoords) { hit = ScreenWarp.ScreenToRT(hit); } if (changeBox.Touched(touch, hit)) { ToggleState(); } if (backBox.Touched(touch, hit)) { Deactivate(); Foley.PlayBack(); } // Allow Swipeto cycle through elements. // Allow scroll wheel to cycle through elements. SwipeGestureRecognizer swipeGesture = TouchGestureManager.Get().SwipeGesture; if (swipeGesture.WasSwiped()) { if (swipeGesture.SwipeDirection == Boku.Programming.Directions.South) { curIndex -= 6; if (curIndex < 0) { curIndex = itemList.Count - 1; } Foley.PlayShuffle(); } else if (swipeGesture.SwipeDirection == Boku.Programming.Directions.North) { curIndex += 6; if (curIndex > (itemList.Count - 1)) { curIndex = 0; } Foley.PlayShuffle(); } } // If we click outside of the list, close it treating it as if select was chosen. //if (TouchInput.TapGesture.WasTapped() && touch.touchedObject == null) if (TouchInput.WasTouched && touch.TouchedObject == null) { Deactivate(); } } }
} // end of Update() private void HandleTouchInput(TouchContact touch, Vector2 hit) { if (hitBoxA.Touched(touch, hit)) { // Disable this hint for this session. if (curHint.ShowOnce) { curHint.Disabled = true; } Deactivate(); } else if (hitBoxB.Touched(touch, hit)) { // Disable this hint until reset by user. XmlOptionsData.SetHintAsDisabled(curHint.ID); // Disable this hint for this session. if (curHint.ShowOnce) { curHint.Disabled = true; } Deactivate(); } // Check for hover and adjust text color to match. Color newColor; newColor = hitBoxA.Contains(hit) ? hoverTextColor : lightTextColor; if (newColor != labelATargetColor) { labelATargetColor = newColor; Vector3 curColor = new Vector3(labelAColor.R / 255.0f, labelAColor.G / 255.0f, labelAColor.B / 255.0f); Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f); TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param) { labelAColor.R = (byte)(value.X * 255.0f + 0.5f); labelAColor.G = (byte)(value.Y * 255.0f + 0.5f); labelAColor.B = (byte)(value.Z * 255.0f + 0.5f); }; TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut); } newColor = hitBoxB.Contains(hit) ? hoverTextColor : lightTextColor; if (newColor != labelBTargetColor) { labelBTargetColor = newColor; Vector3 curColor = new Vector3(labelBColor.R / 255.0f, labelBColor.G / 255.0f, labelBColor.B / 255.0f); Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f); TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param) { labelBColor.R = (byte)(value.X * 255.0f + 0.5f); labelBColor.G = (byte)(value.Y * 255.0f + 0.5f); labelBColor.B = (byte)(value.Z * 255.0f + 0.5f); }; TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut); } } // end of HandleTouchInput()