/// <summary>
        /// Pops the command map from the stack exposing the next one as the active one
        /// This is only needed to be done when the object is no longer activated or
        /// within the running stack of objects
        /// </summary>
        /// <param name="commandMap"></param>
        public static void Pop(CommandMap commandMap)
        {
            if (commandMaps.Count > 0)
            {
                // Currently not needed.  Useful to uncomment for debugging.
                //CommandMap activeMap = commandMaps[commandMaps.Count - 1];

                //commandMaps.Remove(commandMap);
                // We can't just do a Remove here.  If a command map is in
                // the stack more than once the Remove will take out the
                // wrong one.  The whole reason we're in this mess is because
                // the command "stack" doesn't always act like a stack.  Hence
                // having to pass in the element that we want to pop.  This
                // should be cleaned up.
                int index = commandMaps.LastIndexOf(commandMap);

                // I have no idea why the programming UI is popping command
                // that aren't on the stack...
                if (index >= 0)
                {
                    commandMaps.RemoveAt(index);
                }

                SyncTop(commandMap);

                GamePadInput.ClearAllWasPressedState();
#if DEBUG_SPEW
                Debug.Print("pop " + commandMap.name);
                PrintStack();
#endif
            }
        }
Exemplo n.º 2
0
        }   // end of Activate()

        public void Deactivate()
        {
            if (Active)
            {
                if (prevLanguage != XmlOptionsData.Language)
                {
                    changeLanguageMessage.Activate(useRtCoords: true);
                    grid.Active = true; // Keep grid active.
                    return;
                }

                grid.Active = false;
                HelpOverlay.Pop();      // Pop off the help overlay for the current options element.

                CommandStack.Pop(commandMap);
                HelpOverlay.Pop();      // Pop off the help for the options menu.

                // Prevent the button pressed from leaking into runtime.
                GamePadInput.IgnoreUntilReleased(Buttons.B);

                active = false;

                touched = (PlayerIndex)(-1);

                GamePadInput.ClearAllWasPressedState();

                MainMenu.Instance.LiveFeedDirty = true;
            }
        }   // end of Deactivate()
Exemplo n.º 3
0
        public void ClearAllWasPressedState(int numFrames)
        {
            if (b0 != 0)
            {
                GamePadInput        pad = GamePadInput.GetGamePad0();
                GamePadInput.Button b   = pad.GetButton(b0);
                b.ClearAllWasPressedState();
                b.IgnoreUntilReleased = true;
                if (b1 != 0)
                {
                    b = pad.GetButton(b0);
                    b.ClearAllWasPressedState();
                    b.IgnoreUntilReleased = true;
                }
                if (numFrames > 0)
                {
                    GamePadInput.ClearAllWasPressedState(numFrames);
                }
            }

            for (int i = 0; i < keys.Count; i++)
            {
                KeyboardInput.ClearAllWasPressedState(keys[i]);
            }
        }   // end of ClearAllWasPressedState()
Exemplo n.º 4
0
            }   // end of EditWorldParametersUpdateObj c'tor

            /// <summary>
            /// EditWorldParametersUpdateObj Update()
            /// </summary>
            /// <param name="camera"></param>
            public override void Update()
            {
                base.Update();

                if (AuthUI.IsModalActive)
                {
                    return;
                }

                //Because the text editor can show above the edit world parameter we need to update it first so it can steal inputs.
                if (shared.textEditor.Active)
                {
                    shared.textEditor.Update();
                }
                else if (shared.textLineDialog.Active)
                {
                    shared.textLineDialog.Update();
                }
                else
                {
                    // Jump straight to ToolMenu (unless load level menu was up - in which case, let it handle the escape)
                    if (Actions.ToolMenu.WasPressed && !BokuGame.bokuGame.loadLevelMenu.Active && !shared.editWorldParameters.IsInProgrammingTileMode())
                    {
                        Actions.ToolMenu.ClearAllWasPressedState();

                        Deactivate();
                        parent.CurrentUpdateMode = UpdateMode.ToolMenu;
                        return;
                    }

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

                        Deactivate();
                        parent.SwitchToMiniHub();

                        return;
                    }

                    shared.editWorldParameters.Update();

                    // Has the user exited?
                    if (shared.editWorldParameters.Active == false)
                    {
                        GamePadInput.ClearAllWasPressedState();
                        Deactivate();

                        return;
                    }
                }

                // Do the common bits of the Update().
                UpdateCamera();
                UpdateWorld();
            }   // end of EditWorldParametersUpdateObj Update()
Exemplo n.º 5
0
        }   // end of Deactivate()

        /// <summary>
        /// Called once per frame by the
        /// </summary>
        public void Update()
        {
            if (Active)
            {
                /// Don't let anyone else grab focus, if anyone has, grab it back.
                if (CommandStack.Peek() != commandMap)
                {
                    CommandStack.Pop(commandMap);
                    CommandStack.Push(commandMap);
                }
                // Check if we have input focus.
                if (CommandStack.Peek() == commandMap)
                {
                    GamePadInput pad = GamePadInput.GetGamePad0();

                    if (handlerA != null && (pad.ButtonA.WasPressed || KeyboardInput.WasPressed(Keys.A)))
                    {
                        GamePadInput.ClearAllWasPressedState();
                        GamePadInput.IgnoreUntilReleased(Buttons.A);
                        handlerA(this);
                    }

                    if (handlerB != null && (pad.ButtonB.WasPressed || KeyboardInput.WasPressed(Keys.B)))
                    {
                        GamePadInput.ClearAllWasPressedState();
                        GamePadInput.IgnoreUntilReleased(Buttons.B);
                        handlerB(this);
                    }

                    if (handlerX != null && (pad.ButtonX.WasPressed || KeyboardInput.WasPressed(Keys.X)))
                    {
                        GamePadInput.ClearAllWasPressedState();
                        GamePadInput.IgnoreUntilReleased(Buttons.X);
                        handlerX(this);
                    }

                    if (handlerY != null && (pad.ButtonY.WasPressed || KeyboardInput.WasPressed(Keys.Y)))
                    {
                        GamePadInput.ClearAllWasPressedState();
                        GamePadInput.IgnoreUntilReleased(Buttons.Y);
                        handlerY(this);
                    }
                }   // end if we have input focus.

                if (dirty)
                {
                    // Calc max width for text string.
                    maxWidth = (int)(width - 2.0f * margin);

                    RefreshTexture();
                }
            }
        }   // end of Update()
        private void HandleGamePadInput(Camera camera)
        {
            if (GamePadInput.ActiveMode != GamePadInput.InputMode.GamePad)
            {
                return;
            }

            GamePadInput pad = GamePadInput.GetGamePad0();

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

                ToggleState();
            }

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

                // Shut down.
                Deactivate();
                Foley.PlayBack();

                return;
            }

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

                Foley.PlayShuffle();
            }

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

                Foley.PlayShuffle();
            }

            // Don't let anyone else steal input while we're active.
            GamePadInput.ClearAllWasPressedState();
        }
Exemplo n.º 7
0
            public override void Update()
            {
                GamePadInput pad = GamePadInput.GetGamePad0();

                if ((pad.ButtonB.IsPressed && !pad.ButtonB.WasPressed) || (pad.Back.IsPressed && !pad.Back.WasPressed) || KeyboardInput.WasPressed(Keys.Back) || KeyboardInput.WasPressed(Keys.Escape))
                {
                    parent.Deactivate();

                    GamePadInput.ClearAllWasPressedState(3);
                }

                shared.backdrop.Update();
            }   // end of Update()
Exemplo n.º 8
0
            public override void Update()
            {
                if (OwnsFocus())
                {
                    GamePadInput pad = GamePadInput.GetGamePad0();

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

                        // TODO (****) Get rid of the args...
                        parent.OnCancel(null, null);

                        Deactivate();
                    }

                    /// Note that we've already handled B-Cancel above, so the
                    /// picker never will get it.
                    if (parent.TypePicker != null)
                    {
                        parent.TypePicker.Update(InGame.inGame.shared.ToolBox.Camera);
                    }

                    // Check if the currently selected item has help available.
                    // If it doesn't, suppress the help overlay text saying that
                    // help is available.  Note this also makes for a nice place
                    // to set a breakpoint to find all those things we still
                    // need to create help for.
                    Editor editor = InGame.inGame.Editor;
                    //bool helpAvailable = false;
                    //HelpOverlay.SuppressYButton = !helpAvailable;

                    if (pad.ButtonY.WasPressed)
                    {
                        pad.ButtonY.ClearAllWasPressedState();
                    }

                    // Handle stick movement, since that's kind of the point.
                    //parent.UpdateSelection(null, new StickEventArgs(pad.LeftStick));

                    // Clear out any other button presses.  This normally shouldn't be needed
                    // but if we're in the programming UI the reflex may think can still safely
                    // steal input.
                    GamePadInput.ClearAllWasPressedState();
                }

                if (parent.WhileHighlit != null)
                {
                    parent.WhileHighlit();
                }
            }
Exemplo n.º 9
0
            public override void Update()
            {
                if (CommandStack.Peek() == commandMap)
                {
                    GamePadInput pad = GamePadInput.GetGamePad0();

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

                        parent.PlaceReflex(null, null);
                    }

                    if (Actions.ComboUp.WasPressedOrRepeat)
                    {
                        Actions.ComboUp.ClearAllWasPressedState();
                        GamePadInput.ClearAllWasPressedState(3);

                        parent.MoveUp(null, null);
                    }

                    if (Actions.ComboDown.WasPressedOrRepeat)
                    {
                        Actions.ComboDown.ClearAllWasPressedState();
                        GamePadInput.ClearAllWasPressedState(3);

                        parent.MoveDown(null, null);
                    }

                    if (Actions.ComboRight.WasPressed)
                    {
                        // Indent the current block.
                        reflexBlock.Indent(true);
                    }

                    if (Actions.ComboLeft.WasPressed)
                    {
                        // Unindent the current block.
                        reflexBlock.Unindent(true);
                    }
                }
            }
Exemplo n.º 10
0
        }   // end of HelpScreens Activate()

        override public void Deactivate()
        {
            if (state != States.Inactive)
            {
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Pop(commandMap);

                pendingState             = States.Inactive;
                BokuGame.objectListDirty = true;

                GamePadInput.ClearAllWasPressedState();

                Foley.StopMenuLoop();

                // Exiting, restart the main menu.
                BokuGame.bokuGame.mainMenu.Activate();
            }
        }   // end of HelpScreens Deactivate()
Exemplo n.º 11
0
        }   // end of c'tor

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

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

                    // Disable this hint for this session.
                    if (curHint.ShowOnce)
                    {
                        curHint.Disabled = true;
                    }

                    Deactivate();
                }
                if (Actions.X.WasPressed)
                {
                    Actions.X.ClearAllWasPressedState();

                    // Disable this hint until reset by user.
                    XmlOptionsData.SetHintAsDisabled(curHint.ID);

                    // Disable this hint for this session.
                    if (curHint.ShowOnce)
                    {
                        curHint.Disabled = true;
                    }

                    Deactivate();
                }

                // We need to be able to slip out to the mini-hub here since
                // continuous, repeated calls to ScrollableModalHint 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 ScrollableModalHint can lock the
                // user out of control.
                if (Actions.ToolMenu.WasPressed)
                {
                    Actions.ToolMenu.ClearAllWasPressedState();

                    Deactivate();
                    if (InGame.inGame.State == InGame.States.Active)
                    {
                        InGame.inGame.CurrentUpdateMode = InGame.UpdateMode.ToolMenu;
                    }
                }

                // Scroll text???
                if (blob.NumLines != 0)
                {
                    int scroll = MouseInput.ScrollWheel - MouseInput.PrevScrollWheel;

                    if (Actions.Up.WasPressedOrRepeat || scroll > 0)
                    {
                        ScrollDown();
                    }

                    if (Actions.Down.WasPressedOrRepeat || scroll < 0)
                    {
                        ScrollUp();
                    }

                    // If we're not shutting down...
                    if (Active)
                    {
                    }   // end if not shutting down.
                }

                // We should be on top and owning all input
                // focus so don't let anthing trickle down.
                GamePadInput.ClearAllWasPressedState();

                // Disable the help overlay's tool icon because in some situations
                // it can overlap the text making it unreadable.
                HelpOverlay.ToolIcon = null;

                // If active we need to pre-render the text to the 1k rendertarget since
                // changing render targets on the Xbox forces a resolve.
                PreRender();

                // 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);

                        Vector2 touchHit = touch.position;

                        // Adjust for position and scaling of final rendering.
                        touchHit -= renderPosition;
                        touchHit /= renderScale;

                        if (useRtCoords)
                        {
                            touchHit = ScreenWarp.ScreenToRT(touch.position);
                        }
                        HandleTouchInput(touch, touchHit);
                    }
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    Vector2 hit = MouseInput.PositionVec;

                    // Adjust for position and scaling of final rendering.
                    hit -= renderPosition;
                    hit /= renderScale;

                    if (useRtCoords)
                    {
                        hit = MouseInput.GetMouseInRtCoords();
                    }
                    HandleMouseInput(hit);
                }
            } // end if active.
        }     // end of Update()
Exemplo n.º 12
0
        }   // end of c'tor

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

#if !NETFX_CORE
                // For games using micro:bit, allow buttons to dismiss ingame dialogs.
                if (InGame.inGame.CurrentUpdateMode == InGame.UpdateMode.RunSim)
                {
                    Microbit bit = MicrobitExtras.GetMicrobitOrNull(GamePadSensor.PlayerId.All);
                    if (bit != null)
                    {
                        // Allow either button to dismiss display.
                        if (bit.State.ButtonA.IsPressed() || bit.State.ButtonB.IsPressed())
                        {
                            Deactivate();
                        }
                    }
                }
#endif

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

                    Deactivate();
                }

                if (!string.IsNullOrEmpty(textB))
                {
                    if (Actions.B.WasPressed)
                    {
                        Actions.B.ClearAllWasPressedState();

                        userHitA = false;
                        Deactivate();
                    }
                }

                // We need to be able to slip out to the mini-hub here since
                // continuous, repeated calls to TextDisplay 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 TextDisplay can lock the
                // user out of control.
                if (Actions.ToolMenu.WasPressed)
                {
                    Actions.ToolMenu.ClearAllWasPressedState();

                    Deactivate();
                    if (InGame.inGame.State == InGame.States.Active)
                    {
                        InGame.inGame.CurrentUpdateMode = InGame.UpdateMode.ToolMenu;
                    }
                }

                // Scroll text???
                if (blob.NumLines != 0)
                {
                    int scroll = MouseInput.ScrollWheel - MouseInput.PrevScrollWheel;

                    if (Actions.Up.WasPressedOrRepeat || scroll > 0)
                    {
                        ScrollDown();
                    }

                    if (Actions.Down.WasPressedOrRepeat || scroll < 0)
                    {
                        ScrollUp();
                    }

                    // If we're not shutting down...
                    if (Active)
                    {
                    }   // end if not shutting down.
                }

                // We should be on top and owning all input
                // focus so don't let anthing trickle down.
                GamePadInput.ClearAllWasPressedState();

                // Disable the help overlay's tool icon because in some situations
                // it can overlap the text making it unreadable.
                HelpOverlay.ToolIcon = null;

                // If active we need to pre-render the text to the 1k rendertarget since
                // changing render targets on the Xbox forces a resolve.
                if (dirty)
                {
                    PreRender();
                    dirty = false;
                }

                // 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);

                        Vector2 touchHit = touch.position;

                        // Adjust for position and scaling of final rendering.
                        touchHit -= renderPosition;
                        touchHit /= renderScale;

                        if (useRtCoords)
                        {
                            touchHit = ScreenWarp.ScreenToRT(touch.position);
                        }
                        HandleTouchInput(touch, touchHit);
                    }
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    Vector2 hit = MouseInput.PositionVec;

                    // Adjust for position and scaling of final rendering.
                    hit -= renderPosition;
                    hit /= renderScale;

                    if (useRtCoords)
                    {
                        //hit = MouseInput.GetMouseInRtCoords();
                    }
                    HandleMouseInput(hit);
                }
            } // end if active.
        }     // end of Update()
Exemplo n.º 13
0
        }   // end of c'tor

        public void Update()
        {
            if (Active)
            {
                // Due to command stack funkiness, need to bring the command map to top.
                if (CommandStack.Peek() != commandMap)
                {
                    CommandStack.Pop(commandMap);
                    CommandStack.Push(commandMap);
                }

                GamePadInput pad = GamePadInput.GetGamePad0();

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

                    if (OnContinue != null)
                    {
                        OnContinue();
                    }
                    Deactivate();
                    return;
                }

                /*
                 * if (Actions.Cancel.WasPressed)
                 * {
                 *  Actions.Cancel.ClearAllWasPressedState();
                 *
                 *  if (OnBack != null)
                 *  {
                 *      OnBack();
                 *  }
                 *  Deactivate();
                 *  return;
                 * }
                 */

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

                    if (OnExitTutorial != null)
                    {
                        OnExitTutorial();
                    }
                    Deactivate();
                    return;
                }

                // Change text?
                switch (GamePadInput.ActiveMode)
                {
                case GamePadInput.InputMode.KeyboardMouse:
                    if (blob.RawText != mouseText)
                    {
                        blob.RawText = mouseText;
                    }
                    break;

                case GamePadInput.InputMode.GamePad:
                    if (blob.RawText != gamepadText)
                    {
                        blob.RawText = gamepadText;
                    }
                    break;

                case GamePadInput.InputMode.Touch:
                    if (blob.RawText != touchText)
                    {
                        blob.RawText = touchText;
                    }
                    break;
                }

                // Scroll text???
                if (blob.NumLines != 0)
                {
                    int scroll = MouseInput.ScrollWheel - MouseInput.PrevScrollWheel;

                    if (Actions.Up.WasPressedOrRepeat || scroll > 0)
                    {
                        ScrollDown();
                    }

                    if (Actions.Down.WasPressedOrRepeat || scroll < 0)
                    {
                        ScrollUp();
                    }

                    // If we're not shutting down...
                    if (Active)
                    {
                    }   // end if not shutting down.
                }

                // We should be on top and owning all input
                // focus so don't let anthing trickle down.
                GamePadInput.ClearAllWasPressedState();

                // Disable the help overlay's tool icon because in some situations
                // it can overlap the text making it unreadable.
                HelpOverlay.ToolIcon = null;

                // If active we need to pre-render the text to the 1k rendertarget since
                // changing render targets on the Xbox forces a resolve.
                PreRender();

                Vector2 hit;
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    TouchContact touch = TouchInput.GetOldestTouch();
                    if (touch != null)
                    {
                        Vector2 touchHit = touch.position;

                        // Adjust for position and scaling of final rendering.
                        touchHit -= renderPosition;
                        touchHit /= renderScale;

                        HandleTouchInput(touch, touchHit);
                    }
                    else
                    {
                        continueButton.ClearState();
                        backButton.ClearState();
                        exitTutorialButton.ClearState();
                    }
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    // Consider adjusting modal dialog size to take overscan into account BUT NOT tutorial mode.
                    hit = MouseInput.PositionVec;

                    // Adjust for position and scaling of final rendering.
                    hit -= renderPosition;
                    hit /= renderScale;

                    HandleMouseInput(hit);
                }
            } // end if active.
        }     // end of Update()
Exemplo n.º 14
0
        }   // end of c'tor

        public void Update()
        {
            changeLanguageMessage.Update(camera);

            if (active && CommandStack.Peek() == grid.CommandMap)
            {
                UIGridElement prevE = grid.SelectionElement;

                HandleTouchInput();
                HandleMouseInput();
                HandleGamepadInput();

                // Update the grid.
                grid.Update(ref worldGrid);

                // If the Update deactived us, bail.
                if (!active)
                {
                    return;
                }

                // Update help square's positioning to line up with current selection.
                Vector3 selectionElementOffset = grid.SelectionElement.Position - grid.ScrollOffset;
                helpSquare.Position = new Vector2(helpSquare.Position.X, selectionElementOffset.Y);

                // For each element in the grid, calc it's screen space Y position
                // and give it a slight twist around the Y axis based on this.
                // Note this assumes that this grid is 1d vertical.
                for (int j = 0; j < grid.ActualDimensions.Y; j++)
                {
                    UIGridElement e               = grid.Get(0, j);
                    Vector3       pos             = Vector3.Transform(e.Position, grid.WorldMatrix);
                    Vector3       rot             = Vector3.Zero;
                    float         rotationScaling = 0.2f;
                    rot.Y      = -rotationScaling * pos.Y;
                    e.Rotation = rot;
                }

                if (prevE != grid.SelectionElement)
                {
                    if (grid.SelectionElement.ShowHelpButton)
                    {
                        helpSquare.Show();
                    }
                    else
                    {
                        helpSquare.Hide();
                    }
                }
                helpSquare.Update();

                GamePadInput.ClearAllWasPressedState();
            }   // end of if active and have input focus.

            // Update the text displays.  Internally they check if they're active before doing anything.
            if (active)
            {
                InGame.inGame.shared.smallTextDisplay.Update(camera);
                InGame.inGame.shared.scrollableTextDisplay.Update(camera);
            }
        }   // end of Update()
            /// <summary>
            /// TopLevelPaletteUpdateObj Update()
            /// </summary>
            /// <param name="camera"></param>
            public override void Update()
            {
                float secs = Time.WallClockFrameSeconds;

                // Check if we have input focus.  Don't do any input
                // related update if we don't.
                if (CommandStack.Peek() == commandMap)
                {
                    // Grab the current state of the gamepad.
                    GamePadInput pad = GamePadInput.GetGamePad1();

                    // Switch to Mini-Hub?
                    if (pad.Back.WasPressed)
                    {
                        GamePadInput.ClearAllWasPressedState();
                        parent.ResetSim(CurrentLevelFilename());

                        // Needed to make sure that deactivated objects are actually removed from
                        // the list otherwise they may get saved along with the newly activated ones.
                        parent.Refresh(BokuGame.gameListManager.updateList, BokuGame.gameListManager.renderList);

                        parent.SwitchToMiniHub();
                        return;
                    }

                    // The start button should always return to run mode.
                    if (pad.Start.WasPressed)
                    {
                        BokuGame.Audio.GetCue("programming add").Play();
                        parent.CurrentUpdateMode = UpdateMode.RunSim;
                        HelpOverlay.Pop();
                        return;
                    }

                    // Return to previous mode
                    if (pad.ButtonB.WasPressed)
                    {
                        parent.CurrentUpdateMode = UpdateMode.RunSim;
                        HelpOverlay.Pop();
                        return;
                    }

                    // Select current mode.
                    if (pad.ButtonA.WasPressed)
                    {
                        BokuGame.Audio.GetCue("programming add").Play();
                        parent.CurrentUpdateMode = curMode;
                        HelpOverlay.Pop();  // Remove whichever help overlay is active.
                    }

                    // Change selected mode.
                    if (pad.LeftTriggerButton.WasPressed || pad.DPadLeft.WasPressed)
                    {
                        BokuGame.Audio.GetCue("programming click").Play();
                        MoveToPreviousMode();
                        SetHelpOverlay();
                    }
                    if (pad.RightTriggerButton.WasPressed || pad.DPadRight.WasPressed)
                    {
                        BokuGame.Audio.GetCue("programming click").Play();
                        MoveToNextMode();
                        SetHelpOverlay();
                    }
                }   // end if we have input focus.

                UpdateCamera();
                UpdateWorld();
                UpdateEditBrush();
            }   // end of TopLevelPaletteUpdateObj Update()