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()
            public override void Update()
            {
                // Did we switch modes?
                if (inputMode != GamePadInput.ActiveMode)
                {
                    inputMode    = GamePadInput.ActiveMode;
                    shared.dirty = true;
                }

                if (AuthUI.IsModalActive)
                {
                    return;
                }

                // Input focus and not pushing?
                if (parent.Active && CommandStack.Peek() == parent.commandMap && shared.pushOffset == 0.0f)
                {
                    GamePadInput pad = GamePadInput.GetGamePad0();

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

                        parent.Deactivate();
                        Foley.PlayShuffle();
                        shared.dirty = true;
                    }

                    bool moveLeft  = false;
                    bool moveRight = false;

                    // left
                    if (Actions.ComboLeft.WasPressedOrRepeat)
                    {
                        moveLeft = true;
                    }

                    // right
                    if (Actions.ComboRight.WasPressedOrRepeat)
                    {
                        moveRight = true;
                    }

                    //touch?
                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                    {
                        TouchContact touch    = TouchInput.GetOldestTouch();
                        Vector2      touchHit = Vector2.Zero;

                        SwipeGestureRecognizer swipeGesture = TouchGestureManager.Get().SwipeGesture;
                        if (swipeGesture.WasSwiped() &&
                            swipeGesture.SwipeDirection == Boku.Programming.Directions.East)
                        {
                            moveLeft = true;
                        }
                        else if (swipeGesture.WasSwiped() &&
                                 swipeGesture.SwipeDirection == Boku.Programming.Directions.West)
                        {
                            moveRight = true;
                        }
                        else if (touch != null)
                        {
                            touchHit = touch.position;

                            if (shared.leftArrowBox.Touched(touch, touchHit))
                            {
                                moveLeft = true;
                            }

                            if (shared.rightArrowBox.Touched(touch, touchHit))
                            {
                                moveRight = true;
                            }

                            if (shared.backBox.Touched(touch, touchHit))
                            {
                                Actions.Cancel.ClearAllWasPressedState();

                                parent.Deactivate();
                                Foley.PlayShuffle();
                                shared.dirty = true;
                            }
                        }
                    }

                    // Mouse hit?
                    else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                    {
                        Vector2 mouseHit = new Vector2(MouseInput.Position.X, MouseInput.Position.Y);

                        if (shared.leftArrowBox.LeftPressed(mouseHit))
                        {
                            moveLeft = true;
                        }

                        if (shared.rightArrowBox.LeftPressed(mouseHit))
                        {
                            moveRight = true;
                        }

                        if (shared.backBox.LeftPressed(mouseHit))
                        {
                            Actions.Cancel.ClearAllWasPressedState();

                            parent.Deactivate();
                            Foley.PlayShuffle();
                            shared.dirty = true;
                        }
                    }

                    if (moveLeft)
                    {
                        --shared.curScreen;
                        if (shared.curScreen < 0)
                        {
                            parent.Deactivate();
                        }
                        Foley.PlayShuffle();
                        shared.dirty = true;

                        shared.pushOffset = -BokuGame.ScreenSize.X;
                    }

                    if (moveRight)
                    {
                        ++shared.curScreen;
                        if (shared.curScreen >= shared.screenList.Count)
                        {
                            parent.Deactivate();
                        }
                        Foley.PlayShuffle();
                        shared.dirty = true;

                        shared.pushOffset = BokuGame.ScreenSize.X;
                    }
                }

                if (shared.dirty && shared.curScreen >= 0 && shared.curScreen < shared.screenList.Count)
                {
                    shared.prevTexture = shared.curTexture;

                    // Get the correct overlay image to use depending on input mode.
                    string name = GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad ? shared.screenList[shared.curScreen].name : shared.screenList[shared.curScreen].mouseName;
                    shared.curTexture = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\HelpScreens\" + name);
                    shared.dirty      = false;

                    // Create a twitch to do the push.
                    TwitchManager.Set <float> set = delegate(float val, Object param) { shared.pushOffset = val; };
                    TwitchManager.CreateTwitch <float>(shared.pushOffset, 0.0f, set, 0.3f, TwitchCurve.Shape.EaseOut);
                }
            }   // end of Update()