Esempio n. 1
0
        }   // end of HandleTouchInput()

        private void HandleMouseInput(Vector2 hit)
        {
            if (hitBox.LeftPressed(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 HandleMouseInput()
 private void HandleMouseInput(Vector2 hit)
 {
     if (hitBox.LeftPressed(hit))
     {
         AuthUI.ShowSignOutDialog();
     }
 }
Esempio n. 3
0
        }   // end of HandleTouchInput()

        private void HandleMouseInput(Vector2 hit)
        {
            // Hovering?
            continueButton.SetHoverState(hit);
            backButton.SetHoverState(hit);
            exitTutorialButton.SetHoverState(hit);

            if (continueButton.Box.LeftPressed(hit))
            {
                if (OnContinue != null)
                {
                    OnContinue();
                }
                Deactivate();
            }

            /*
             * else if (backButton.Box.LeftPressed(hit))
             * {
             *  if (OnBack != null)
             *  {
             *      OnBack();
             *  }
             *  Deactivate();
             * }
             */
            else if (exitTutorialButton.Box.LeftPressed(hit))
            {
                if (OnExitTutorial != null)
                {
                    OnExitTutorial();
                }
                Deactivate();
            }
            else if (upBox.LeftPressed(hit))
            {
                ScrollDown();
            }
            else if (downBox.LeftPressed(hit))
            {
                ScrollUp();
            }
        }   // end of HandleMouseInput()
        }   // 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()
Esempio n. 5
0
        }   // end of HandleTouchInput()

        private void HandleMouseInput(Vector2 hit)
        {
            if (checkBoxBox.LeftPressed(hit))
            {
                keepSignedInChecked = !keepSignedInChecked;
            }

            // Buttons
            if (signOutButton.Box.LeftPressed(hit))
            {
                // Save results.
                OnAccept();
            }
            if (cancelButton.Box.LeftPressed(hit))
            {
                OnCancel();
            }

            // Update hover state.
            signOutButton.SetHoverState(hit);
            cancelButton.SetHoverState(hit);
        }   // end of HandleMouseInput()
        }   // end of HandleTouchInput()

        private void HandleMouseInput(Vector2 hit)
        {
            if (helpBox.LeftPressed(hit))
            {
                OnHelp();
            }
            if (creatorBox.LeftPressed(hit))
            {
                EditingCreator = true;
            }
            if (pinBox.LeftPressed(hit))
            {
                EditingPin = true;
            }
            if (checkBoxBox.LeftPressed(hit))
            {
                keepSignedInChecked = !keepSignedInChecked;
                EditingCreator      = false;
                EditingPin          = false;
            }

            // Buttons
            if (okButton.Box.LeftPressed(hit))
            {
                // Save results.
                OnAccept();
            }
            if (cancelButton.Box.LeftPressed(hit))
            {
                OnCancel();
            }

            // Update hover state.
            okButton.SetHoverState(hit);
            cancelButton.SetHoverState(hit);
        }   // end of HandleMouseInput()
Esempio n. 7
0
        }   // end of HandleTouchInput()

        private void HandleMouseInput(Vector2 hit)
        {
            if (hitBoxA.LeftPressed(hit))
            {
                // Disable this hint for this session.
                if (curHint.ShowOnce)
                {
                    curHint.Disabled = true;
                }

                Deactivate();
            }
            else if (hitBoxB.LeftPressed(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.LeftPressed(hit))
            {
                ScrollDown();
            }
            else if (downBox.LeftPressed(hit))
            {
                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 HandleMouseInput()
        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()
        }   // end of DeleteText()

        private void HandleMouseInput(Camera camera)
        {
            if (GamePadInput.ActiveMode != GamePadInput.InputMode.KeyboardMouse)
            {
                return;
            }

            // If the mouse is over the menu, move the selection index to the item under the mouse.
            // On mouse down, make the item (if any) under the mouse the ClickedOnItem.
            // On mouse up, if the mouse is still over the ClickedOnItem, activate it.  If not, just clear ClickedOnItem.
            Vector2 hitUV = MouseInput.GetHitUV(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 mouseOverItem = -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 (MouseInput.Position != MouseInput.PrevPosition)
                    {
                        CurIndex = i;
                    }
                    mouseOverItem = i;
                }
            }

            if (MouseInput.Left.WasPressed)
            {
                if (mouseOverItem != -1)
                {
                    MouseInput.ClickedOnObject = itemList[mouseOverItem];
                }
            }
            if (MouseInput.Left.WasReleased)
            {
                // Make sure we're still over the ClickedOnItem.
                if (mouseOverItem != -1 && MouseInput.ClickedOnObject == itemList[mouseOverItem])
                {
                    ToggleState();
                }
            }

            Vector2 hit = MouseInput.PositionVec;

            if (useRtCoords)
            {
                hit = ScreenWarp.ScreenToRT(hit);
            }
            if (changeBox.LeftPressed(hit))
            {
                ToggleState();
            }
            if (backBox.LeftPressed(hit))
            {
                Deactivate();
                Foley.PlayBack();
            }

            // Allow scroll wheel to cycle through elements.
            int wheel = MouseInput.ScrollWheel - MouseInput.PrevScrollWheel;

            if (wheel > 0)
            {
                --curIndex;
                if (curIndex < 0)
                {
                    curIndex = itemList.Count - 1;
                }

                Foley.PlayShuffle();
            }
            else if (wheel < 0)
            {
                ++curIndex;
                if (curIndex >= itemList.Count)
                {
                    curIndex = 0;
                }

                Foley.PlayShuffle();
            }

            // If we click outside of the list, close it treating it as if select was chosen.
            if (MouseInput.Left.WasPressed && MouseInput.ClickedOnObject == null)
            {
                Deactivate();
            }
        }