コード例 #1
0
        }   // end of c'tor

        public void Update(Camera camera)
        {
            if (Active)
            {
                GamePadInput pad = GamePadInput.GetGamePad0();

                if (InGame.inGame.State == InGame.States.Active && InGame.inGame.CurrentUpdateMode == InGame.UpdateMode.RunSim)
                {
                    // We need to be able to slip out to the mini-hub here since
                    // continuous, repeated calls to LiveFeedDisplay can lock the
                    // user out of control.
                    if (Actions.MiniHub.WasPressed)
                    {
                        Actions.MiniHub.ClearAllWasPressedState();

                        Deactivate();
                        InGame.inGame.SwitchToMiniHub();
                    }

/*
 *                  // We need to be able to slip out to the tool menu here since
 *                  // continuous, repeated calls to LiveFeedDisplay can lock the
 *                  // user out of control.
 *                  if (Actions.ToolMenu.WasPressed)
 *                  {
 *                      Actions.ToolMenu.ClearAllWasPressedState();
 *
 *                      Deactivate();
 *                      InGame.inGame.CurrentUpdateMode = InGame.UpdateMode.ToolMenu;
 *                  }
 */
                }

                if (Actions.Select.WasPressed)
                {
                    Actions.Select.ClearAllWasPressedState();

                    Deactivate();
                }

                // If we're rendering this into a 1280x720 rt we need a matching camera to calc mouse hits.
                if (useBackgroundThumbnail)
                {
                    camera            = new PerspectiveUICamera();
                    camera.Resolution = new Point(1280, 720);
                }

                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    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,
                            useOverscanForHitTesting
                            );
                        HandleTouchInput(touch, touchHit);
                    }
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    Vector2 hit = MouseInput.GetAspectRatioAdjustedPosition(camera, useOverscanForHitTesting);
                    HandleMouseInput(hit);
                }
            } // end if active.
        }     // end of Update()
コード例 #2
0
        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()
コード例 #3
0
        }   // end of ClearAllItems()

        public void Update(Camera camera, ref Matrix parentMatrix)
        {
            CommandMap map = CommandStack.Peek();

            if (map != commandMap)
            {
                return;
            }

            // Check for input.
            if (active && itemList.Count > 0)
            {
                GamePadInput pad = GamePadInput.GetGamePad0();

                bool mouseDown   = false;
                bool mouseUp     = false;
                bool mouseSelect = false;
                bool touchSelect = false;
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                // MouseInput
                {
                    // Did user double click?  If so, treat as a shortcut to play.
                    if (MouseInput.Left.WasDoubleClicked)
                    {
                        // This works because we _know_ Play is the first one in the list.
                        // Not exactly a great solution.
                        curIndex    = 0;
                        mouseSelect = true;
                    }

                    Vector2 hit = MouseInput.GetMouseInRtCoords();
                    if (!mouseSelect)
                    {
                        if (itemList[CurIndex].hitBox.LeftPressed(hit))
                        {
                            mouseSelect = true;
                        }
                    }

                    // If mouse is over menu and moving, choose item under mouse as selection.
                    if (!mouseSelect && MouseInput.Position != MouseInput.PrevPosition)
                    {
                        for (int i = 0; i < itemList.Count; i++)
                        {
                            if (itemList[i].hitBox.Contains(hit))
                            {
                                CurIndex = i;
                                break;
                            }
                        }
                    }

                    int scroll = MouseInput.ScrollWheel - MouseInput.PrevScrollWheel;
                    if (scroll > 0)
                    {
                        mouseUp = true;
                    }
                    else if (scroll < 0)
                    {
                        mouseDown = true;
                    }

                    // If user clicks off of the popup, treat as Back.
                    if (MouseInput.Left.WasPressed && MouseInput.ClickedOnObject == null)
                    {
                        Active = false;
                        return;
                    }
                }   // end of mouse input.
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                // TouchInput
                {
                    TouchContact touch = TouchInput.GetOldestTouch();
                    if (touch != null)
                    {
                        Vector2 hit          = TouchInput.GetAspectRatioAdjustedPosition(touch.position, camera, true);
                        bool    hitSomething = false;

                        // Check for a hit on any of the items.
                        for (int i = 0; i < itemList.Count; i++)
                        {
                            if (itemList[i].hitBox.Contains(hit))
                            {
                                CurIndex     = i;
                                hitSomething = true;
                            }
                        }

                        if (touch.phase == TouchPhase.Ended)
                        {
                            if (hitSomething)
                            {
                                // We've touched off on an item so choose it.
                                touchSelect = true;
                            }
                            else
                            {
                                // We touched off and didn't hit anything.
                                if (touch.TouchedObject == this)
                                {
                                    touch.TouchedObject = null;
                                }
                                else
                                {
                                    Active = false;
                                }
                            }
                        }
                    }
                }   // end of Touch input.


                if (Actions.Select.WasPressed || mouseSelect || touchSelect)
                {
                    Actions.Select.ClearAllWasPressedState();

                    if (itemList[curIndex].OnSelect != null)
                    {
                        itemList[curIndex].OnSelect();
                    }
                    Foley.PlayPressA();

                    return;
                }

                if (Actions.Cancel.WasPressed)
                {
                    Actions.Cancel.ClearAllWasPressedState();

                    Active = false;
                    Foley.PlayBack();

                    return;
                }

                int prevIndex = curIndex;

                // Handle input changes here.
                if (Actions.ComboDown.WasPressedOrRepeat || mouseDown)
                {
                    ++curIndex;
                    if (curIndex >= itemList.Count)
                    {
                        curIndex = 0;
                    }

                    Foley.PlayShuffle();
                }

                if (Actions.ComboUp.WasPressedOrRepeat || mouseUp)
                {
                    --curIndex;
                    if (curIndex < 0)
                    {
                        curIndex = itemList.Count - 1;
                    }

                    Foley.PlayShuffle();
                }

                // Ensure that the selected state of all items is correct.
                for (int i = 0; i < itemList.Count; i++)
                {
                    itemList[i].Selected = i == CurIndex;
                }
            }
        }   // end of LoadLevelPopup Update()