}   // end of RunSimUpdateObj OrbitAndTrackCamera()

            private void MoveCameraEditMode(bool inputFocus, bool ignoreRotation)
            {
                if (inputFocus)
                {
                    if (!ignoreRotation)
                    {
                        OrbitAndTrackCamera();
                    }

                    GamePadInput pad = GamePadInput.GetGamePad0();

                    // Left stick to control cursor position.  Cursor movement is relative to view heading.
                    Vector2 position = new Vector2(shared.CursorPosition.X, shared.CursorPosition.Y);
                    Vector2 forward  = new Vector2((float)Math.Cos(parent.Camera.Rotation), (float)Math.Sin(parent.Camera.Rotation));
                    Vector2 right    = new Vector2(forward.Y, -forward.X);
                    position += forward * pad.LeftStick.Y * Time.WallClockFrameSeconds * kCursorSpeed;
                    position += right * pad.LeftStick.X * Time.WallClockFrameSeconds * kCursorSpeed;
                    // Numpad controls cursor position. NumLock must be on!
                    float y = KeyboardInput.IsPressed(Keys.NumPad7) || KeyboardInput.IsPressed(Keys.NumPad8) || KeyboardInput.IsPressed(Keys.NumPad9) ? 1.0f : 0.0f;
                    y += KeyboardInput.IsPressed(Keys.NumPad1) || KeyboardInput.IsPressed(Keys.NumPad2) || KeyboardInput.IsPressed(Keys.NumPad3) ? -1.0f : 0.0f;
                    float x = KeyboardInput.IsPressed(Keys.NumPad3) || KeyboardInput.IsPressed(Keys.NumPad6) || KeyboardInput.IsPressed(Keys.NumPad9) ? 1.0f : 0.0f;
                    x        += KeyboardInput.IsPressed(Keys.NumPad1) || KeyboardInput.IsPressed(Keys.NumPad4) || KeyboardInput.IsPressed(Keys.NumPad7) ? -1.0f : 0.0f;
                    position += forward * y * Time.WallClockFrameSeconds * kCursorSpeed;
                    position += right * x * Time.WallClockFrameSeconds * kCursorSpeed;

                    // If the user has programmed the left mouse button,
                    // don't also use it for moving the camera.
                    // Is this what we really want?  The normal left mouse input only
                    // effects the camera when dragged.  Note that ProgramUsesLeftMouse has changed behaviour.
                    // Now it is only true if the mouse left is used in a way that would conflict with normal
                    // camera movement.  If there is no conflict then we left it go through.
                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse && !InGame.inGame.ProgramUsesLeftMouse)
                    {
                        position = parent.MouseEdit.DoCursor(parent.Camera, position);
                    }

                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                    {
                        position = new Vector2(parent.Camera.DesiredAt.X, parent.Camera.DesiredAt.Y);
                        position = parent.TouchEdit.DoCursor(parent.Camera, position);
                    }

                    shared.CursorPosition = new Vector3(position, shared.CursorPosition.Z);

                    // Ensure that the 3D cursor is active.
                    if (parent.cursorClone == null)
                    {
                        parent.CreateCursorClone();
                    }
                    parent.cursor3D.Activate();
                    parent.cursor3D.DiffuseColor = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);

                    // Assign the new position to the 3d cursor and then read it back since
                    // it will modify the height to accommodate the terrain.
                    parent.cursor3D.Position = shared.CursorPosition;
                    shared.CursorPosition    = parent.cursor3D.Position;
                }

                shared.camera.DesiredAt = shared.CursorPosition;
            }   // end of RunSimUpdateObj MoveCameraEditMode()
        private void TestStorage()
        {
            GamePadInput pad = GamePadInput.GetGamePad0();

            if (pad.ButtonY.WasPressed)
            {
                doTest = 0;
            }
            if (doTest >= 0)
            {
                string fileName = "Test0.dat";
                if (!Storage4.FileExists(fileName))
                {
                    doTest = 0;
                }

                Stream writeStream = Storage4.OpenWrite(fileName);
                if (writeStream == null)
                {
                    doTest = 0;
                }
                byte[] writeBytes = new byte[10000];
                writeStream.Write(writeBytes, 0, writeBytes.Length);
                Storage4.Close(writeStream);

                if (!Storage4.FileExists(fileName))
                {
                    doTest = 0;
                }

                ++testsDone;
            }
        }
        public override void Update(ref Matrix parentMatrix)
        {
            // Check for input but only if selected.
            if (selected)
            {
                GamePadInput pad = GamePadInput.GetGamePad0();

                // Handle input changes here.
                if (pad.DPadLeft.WasPressed ||
                    pad.DPadLeft.WasRepeatPressed ||
                    pad.LeftStickLeft.WasPressed ||
                    pad.LeftStickLeft.WasRepeatPressed)
                {
                    if (DecrementCurrentValue())
                    {
                        Foley.PlayClick();
                    }
                }
                if (pad.DPadRight.WasPressed ||
                    pad.DPadRight.WasRepeatPressed ||
                    pad.LeftStickRight.WasPressed ||
                    pad.LeftStickRight.WasRepeatPressed)
                {
                    if (IncrementCurrentValue())
                    {
                        Foley.PlayClick();
                    }
                }
            }

            RefreshTexture();

            base.Update(ref parentMatrix);
        }   // end of UIGridBaseSliderElement Update()
        }   // end of NoiseTool GetInstance()

        public override void Update()
        {
            if (Active)
            {
                CheckSelectCursor(false);

                if (!PickerXInUse && !PickerYInUse)
                {
                    if (DebouncePending)
                    {
                        return;
                    }

                    GamePadInput pad = GamePadInput.GetGamePad0();
                    if (RightRate < kSmallRate)
                    {
                        /// Reseed everytime they switch modes.
                        Terrain.Reseed();
                    }

                    UpdateRates();

                    ProcessTriggers(
                        Terrain.EditMode.Hill,
                        Terrain.EditMode.Smooth,
                        Terrain.EditMode.Roughen);

                    SelectOverlay();
                }
            }

            base.Update();
        }   // end of NoiseTool Update()
        }   // end of HandleMouseInput()

        private void HandleGamepadInput()
        {
            GamePadInput pad = GamePadInput.GetGamePad0();

            // Select a level.
            if (pad.ButtonA.WasPressed)
            {
                OnSelect();
            }

            // Cancel.
            if (pad.Back.WasPressed)
            {
                OnCancel();
            }

            // Cycle through worlds.
            if (Actions.ComboRight.WasPressedOrRepeat)
            {
                focusLevelIndex = (focusLevelIndex + 1) % levels.Count;
            }
            if (Actions.ComboLeft.WasPressedOrRepeat)
            {
                focusLevelIndex = (focusLevelIndex + levels.Count - 1) % levels.Count;
            }
        }   // end of HandleGamepadInput()
            /// <summary>
            /// Hierarchical cull check, with result cached. This is just
            /// so we don't have to recheck for each face pass.
            /// </summary>
            /// <param name="camera"></param>
            /// <param name="nodes"></param>
            /// <returns></returns>
            public Frustum.CullResult PreCull(Camera camera, List <Node> nodes)
            {
#if MF_HOLDFRUSTUM
                GamePadInput pad = GamePadInput.GetGamePad0();
                if (pad.ButtonY.IsPressed)
                {
                    _holdFrustum = camera.Frustum.Clone();
                }
                else if (pad.ButtonX.IsPressed)
                {
                    _holdFrustum = null;
                }
                Frustum frustum = _holdFrustum == null ? camera.Frustum : _holdFrustum;
#else // MF_HOLDFRUSTUM
                Frustum frustum = camera.Frustum;
#endif // MF_HOLDFRUSTUM

                Cull = frustum.CullTest(Min, Max);

                if (Cull == Frustum.CullResult.PartiallyInside)
                {
                    if (Left >= 0)
                    {
                        Debug.Assert(Right >= 0);
                        nodes[Left].PreCull(camera, nodes);
                        nodes[Right].PreCull(camera, nodes);
                    }
                }
                return(Cull);
            }
        public override void Update(ref Matrix parentMatrix)
        {
            // Check for input but only if selected.
            if (selected)
            {
                GamePadInput pad = GamePadInput.GetGamePad0();

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

                    if (onAButton != null)
                    {
                        onAButton();
                        Foley.PlayPressA();
                    }
                }

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

                    if (onXButton != null)
                    {
                        onXButton();
                        Foley.PlayCut();
                    }
                }
            }

            RefreshTexture();

            base.Update(ref parentMatrix);
        }   // end of UIGridModularButtonElement Update()
            }   // end of EditObjectParametersUpdateObj c'tor

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

                if (AuthUI.IsModalActive)
                {
                    return;
                }

                // No need to check for input focus or anything.  If
                // we're active then the EditObjectParameters object has focus.

                GamePadInput pad = GamePadInput.GetGamePad0();

                // Jump straight to Tool Menu.
                if (pad.Back.WasPressed)
                {
                    parent.CurrentUpdateMode = UpdateMode.ToolMenu;
                    return;
                }

                shared.editObjectParameters.Update();

                // If the Object param editor is no longer active we're done.
                if (!shared.editObjectParameters.Active)
                {
                    return;
                }

                // TODO (****) Needed?
                // Do the common bits of the Update().
                UpdateCamera();
                UpdateWorld();
            }   // end of EditObjectParametersUpdateObj Update()
Exemple #9
0
        private void HandleGamepadInput()
        {
            if (GamePadInput.ActiveMode != GamePadInput.InputMode.GamePad)
            {
                return;
            }

            GamePadInput pad = GamePadInput.GetGamePad0();

            if ((Actions.Raise.WasPressedOrRepeat) || (Actions.Up.WasPressedOrRepeat))
            {
                if (newsScroller.Count > 0)
                {
                    newsScroller.FocusPrev();
                }
            }
            else if ((Actions.Lower.WasPressedOrRepeat) || (Actions.Down.WasPressedOrRepeat))
            {
                if (newsScroller.Count > 0)
                {
                    newsScroller.FocusNext();
                }
            }
            else if (Actions.ComboRight.WasPressed)
            {
                Deactivate();
            }
            else if (Actions.Select.WasPressed)
            {
                if (newsScroller.Count > 0)
                {
                    newsScroller.PressFocus();
                }
            }
        }
        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()
Exemple #11
0
        public override void Update(ref Matrix parentMatrix)
        {
            // Check for input but only if selected.
            if (selected)
            {
                GamePadInput pad = GamePadInput.GetGamePad0();

                if (pad.ButtonA.WasPressed)
                {
                    check = !check;
                    if (check && onCheck != null)
                    {
                        onCheck();
                    }
                    else if (!check && onClear != null)
                    {
                        onClear();
                    }

                    pad.ButtonA.ClearAllWasPressedState();
                    Foley.PlayClick();
                    dirty = true;
                }
            }

            RefreshTexture();

            base.Update(ref parentMatrix);
        }   // end of UIGrid2DCheckboxElement Update()
        private void TestXml2()
        {
            GamePadInput pad = GamePadInput.GetGamePad0();

            if (pad.ButtonY.WasPressed)
            {
                doTest = 0;
            }
            if (doTest >= 0)
            {
                if (!Storage4.FileExists(BokuGame.Settings.MediaPath + @"Xml\OptionsData.Xml"))
                {
                    doTest = 0; /// This breakpoint isn't ever hit, OptionsData.xml exists here
                }
                Stream hoseStream = Storage4.OpenWrite(@"Xml\Hoser.xml");

                XmlHose hoser = new XmlHose();
                hoser.hoser = true;

                XmlSerializer serializer = new XmlSerializer(typeof(XmlHose));
                serializer.Serialize(hoseStream, hoser);

                Storage4.Close(hoseStream);
                if (!Storage4.FileExists(BokuGame.Settings.MediaPath + @"Xml\OptionsData.Xml"))
                {
                    doTest = 0; /// THis breakpoint is hit on failure, after the flush
                                /// OptionsData.xml is not longer there.
                }
                ++testsDone;
            }
        }
            }   // end of TextDialog UpdateObj c'tor

            public override void Update()
            {
                // Check if we have input focus.
                if (CommandStack.Peek() == commandMap)
                {
                    GamePadInput pad = GamePadInput.GetGamePad0();

                    if (pad.ButtonA.WasPressed && (0 != (parent.Buttons & TextDialogButtons.Accept)))
                    {
                        Accept();
                    }

                    if (pad.ButtonB.WasPressed && (0 != (parent.Buttons & TextDialogButtons.Cancel)))
                    {
                        Cancel();
                    }

                    if (pad.ButtonX.WasPressed && (0 != (parent.Buttons & TextDialogButtons.Discard)))
                    {
                        Discard();
                    }

                    if (pad.ButtonY.WasPressed)
                    {
                        shared.IncrementString();
                    }
                }

                parent.renderObj.RefreshTexture();
            }   // end of UpdateObj Update()
        /// <summary>
        /// Common update code, expected to be overriden but base Update called as well.
        /// </summary>
        public virtual void Update()
        {
            // Only update if active and the toolbox isn't changing.
            if (Active)
            {
                NotifyTerrainActivity();

                CheckStretchMode();

                GamePadInput pad = GamePadInput.GetGamePad0();

                // Switch to Mini-Hub?
                if (!PickerXInUse && !PickerYInUse && (pad.Start.WasPressed || pad.ButtonB.WasPressed))
                {
                    /// The InGameEditBase will handle backing us out. Just don't do anything.
                    return;
                }

                // Use X and Y to bring up associated pickers.  If another is already
                // being used, accept the current state and switch to the new one.
                if ((Actions.PickerX.WasPressed) && pickerX != null)
                {
                    Actions.PickerX.ClearAllWasPressedState();

                    // First check if the other picker is already in use.
                    if (PickerYInUse)
                    {
                        PickerY.SelectCurrentChoice();
                        PickerY.Hidden = true;
                    }

                    PickerX.Hidden = false;
                }
                if ((Actions.PickerY.WasPressed) && pickerY != null && pickerY.Hidden)
                {
                    Actions.PickerY.ClearAllWasPressedState();

                    // First check if the other picker is already in use.
                    if (PickerXInUse)
                    {
                        PickerX.SelectCurrentChoice();
                        PickerX.Hidden = true;
                    }

                    PickerY.Hidden = false;
                }
            }

            if (Active)
            {
                if (shared.ToolBox.PickersActive)
                {
                    //inGame.Terrain.EndSelection();
                }
            }
            shared.editBrushSizeActive = !shared.ToolBox.PickersActive;
        }   // end of BaseTool Update()
Exemple #15
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();
        }
        }   // end of SetXButton()

        public override void Update(ref Matrix parentMatrix)
        {
            // Check for input but only if selected.
            if (selected)
            {
                GamePadInput pad = GamePadInput.GetGamePad0();

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

                    onSetNextLevel();
                }

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

                    NextLevel = null;
                    if (onClear != null)
                    {
                        onClear();
                    }
                }
            }

            //load thumbnail if it hasn't loaded yet
            if (nextLevel != null && !nextLevel.Thumbnail.IsLoaded)
            {
                if (nextLevel.ThumbnailBytes == null)
                {
                    string texFilename = BokuGame.Settings.MediaPath + Utils.FolderNameFromFlags(nextLevel.Genres) + nextLevel.WorldId.ToString();
                    Stream texStream   = Storage4.TextureFileOpenRead(texFilename);
                    if (texStream != null)
                    {
                        nextLevel.Thumbnail.Texture = Storage4.TextureLoad(texStream);
                        Storage4.Close(texStream);
                    }
                }
                else
                {
                    MemoryStream stream = new MemoryStream(nextLevel.ThumbnailBytes);
                    nextLevel.Thumbnail.Texture = Storage4.TextureLoad(stream);
                    nextLevel.ThumbnailBytes    = null;
                }
            }

            //refresh the render target
            RefreshTexture();

            base.Update(ref parentMatrix);
        }   // end of UIGridModularCheckboxElement Update()
            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()
        }   // end of SetXButton()

        public override void Update(ref Matrix parentMatrix)
        {
            // Check for input but only if selected.
            if (selected)
            {
                GamePadInput pad = GamePadInput.GetGamePad0();

                bool changed = false;

                // Handle input changes here.
                if (pad.DPadLeft.WasPressed ||
                    pad.DPadLeft.WasRepeatPressed ||
                    pad.LeftStickLeft.WasPressed ||
                    pad.LeftStickLeft.WasRepeatPressed)
                {
                    curIndex = (curIndex + pictures.Count - 1) % pictures.Count;
                    Foley.PlayClickDown();
                    changed = true;
                }
                if (pad.DPadRight.WasPressed ||
                    pad.DPadRight.WasRepeatPressed ||
                    pad.LeftStickRight.WasPressed ||
                    pad.LeftStickRight.WasRepeatPressed)
                {
                    curIndex = (curIndex + 1) % pictures.Count;
                    Foley.PlayClickUp();
                    changed = true;
                }

                if (pad.ButtonX.WasPressed)
                {
                    if (onXButton != null)
                    {
                        onXButton(curIndex);
                    }
                }

                if (changed || curIndex == -1)
                {
                    RecalcPositions();
                    if (onChange != null)
                    {
                        onChange(curIndex);
                    }
                }
            }

            RefreshTexture();

            base.Update(ref parentMatrix);
        }   // end of UIGridPictureListElement Update()
Exemple #20
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();
                }
            }
            }   // end of ToolMenuUpdateObj c'tor

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

                // No need to check for input focus or anything.  If
                // we're active then the ToolMenu object has focus.

                shared.ToolMenu.Update();

                // If the ToolMenu is no longer active we're done.
                if (!shared.ToolMenu.Active)
                {
                    return;
                }

                // Do the common bits of the Update().  If our child is active we
                // can temporarily push/pop our commandMap to grab input focus.
                if (shared.ToolMenu.Active)
                {
                    CommandStack.Push(commandMap);
                }
                UpdateCamera(false);
                if (shared.ToolMenu.Active)
                {
                    CommandStack.Pop(commandMap);
                }
                UpdateWorld();
                // TODO (****) Should this only be called for tools that use the edit brush?
                // TODO (****) How do we turn off the edit brush rendering if we don't need it?
                UpdateEditBrush();

                GamePadInput pad = GamePadInput.GetGamePad0();

                // Run!
                if (pad.Back.WasPressed)
                {
                    // TODO (****) Transition to RunSim.
                    // Or is this already done in the base class???
                }

                // MiniHub!
                if (pad.Start.WasPressed)
                {
                    // TODO (****) Transition to MinHub.
                    // Or is this already done in the base class???
                }

                ToolTipManager.Update();
                ThoughtBalloonManager.Update(shared.camera);
            }   // end of ToolMenuUpdateObj Update()
        public override bool MatchAction(Reflex reflex, out object param)
        {
            GamePadSensor.PlayerId playerIdSensor = (GamePadSensor.PlayerId)reflex.targetSet.Param;

            if (this.playerId != playerIdSensor)
            {
                this.playerId = playerIdSensor;
            }

            GamePadInput pad = null;

            // Get the correct game pad.
            switch (playerId)
            {
            case GamePadSensor.PlayerId.All:
                pad = GamePadInput.GetGamePad0();
                break;

            case GamePadSensor.PlayerId.One:
                pad = GamePadInput.GetGamePad1();
                break;

            case GamePadSensor.PlayerId.Two:
                pad = GamePadInput.GetGamePad2();
                break;

            case GamePadSensor.PlayerId.Three:
                pad = GamePadInput.GetGamePad3();
                break;

            case GamePadSensor.PlayerId.Four:
                pad = GamePadInput.GetGamePad4();
                break;
            }

            if (trigger == GamePadTrigger.LeftTrigger)
            {
                triggerValue = pad.LeftTrigger;
            }
            else if (trigger == GamePadTrigger.RightTrigger)
            {
                triggerValue = pad.RightTrigger;
            }

            // Return as a parameter a vector that can be used for input to the movement system, so
            // that players can drive and turn bots using gamepad triggers.
            param = new Vector2(0, triggerValue);

            return(triggerValue > 0); // only if pressed
        }
Exemple #23
0
        private void HandleGamepadInput()
        {
            GamePadInput pad = GamePadInput.GetGamePad0();

            UIGridElement e = grid.SelectionElement;

            UpdateInvertAxis();
            string helpID   = e.HelpID;
            string helpText = TweakScreenHelp.GetHelp(helpID);

            if (helpText != null && Actions.Help.WasPressed)
            {
                ShowHelp(helpText);
            }
        }
        }               // end of Update()

        private void HandleGamepadInput()
        {
            // Our children have input focus but we can still steal away the buttons we care about.
            GamePadInput pad = GamePadInput.GetGamePad0();

            if (pad.ButtonA.WasPressed)
            {
                pad.ButtonA.ClearAllWasPressedState();
                Accept();
            }
            else if (pad.ButtonB.WasPressed)
            {
                pad.ButtonB.ClearAllWasPressedState();
                Cancel();
            }
        }
        }   // end of UIGridModularRadioBoxElement AddText()

        public override void Update(ref Matrix parentMatrix)
        {
            // Check for input but only if selected.
            if (selected && list.Count > 1)
            {
                GamePadInput pad = GamePadInput.GetGamePad0();

                bool changed = false;

                // Handle input changes here.
                if (Actions.Select.WasPressedOrRepeat)
                {
                    Actions.Select.ClearAllWasPressedState();

                    ++curIndex;
                    if (curIndex >= list.Count)
                    {
                        curIndex = 0;
                    }

                    Foley.PlayPressA();
                    changed = true;
                }

                if (changed)
                {
                    if (null != onSelection)
                    {
                        onSelection(list[curIndex]);
                    }

                    if (null != onChange)
                    {
                        onChange(list[curIndex]);
                    }

                    dirty = true;
                    //RecalcPositions();
                }
            }

            RefreshTexture();

            base.Update(ref parentMatrix);
        }   // end of UIGridModularRadioBoxElement Update()
Exemple #26
0
        protected virtual void ProcessBButton()
        {
            float distSq = Vector2.DistanceSquared(shared.editBrushStart, shared.editBrushPosition);

            GamePadInput pad = GamePadInput.GetGamePad0();

            if (Actions.Cancel.IsPressed)
            {
                StretchPhase = Phase.Open;
                Actions.Cancel.IgnoreUntilReleased();
            }
            if (MouseInput.Left.WasPressed &&
                !MouseInput.Middle.IsPressed &&
                !MouseInput.Right.IsPressed)
            {
                StretchPhase = Phase.Open;
            }
        }
Exemple #27
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);
                    }
                }
            }
        }   // end of Refresh()

        public override void Update(ref Matrix parentMatrix)
        {
            int  focus    = SelectionIndex.X;
            bool wasDirty = dirty;

            GamePadInput pad = GamePadInput.GetGamePad0();

            base.Update(ref parentMatrix);

            // Did something change?  If so, update the transforms for the tiles.
            if (wasDirty || focus != SelectionIndex.X)
            {
                float   twitchTime = Time.FrameRate > 20.0f ? 0.2f : 0.0f;
                Vector3 negativeX  = new Vector3(-1.0f, 1.0f, 1.0f);
                Vector3 rotation   = new Vector3(kTipBackAngle, 0.0f, 0.0f);

                for (int i = 0; i < ActualDimensions.X; i++)
                {
                    UIGridElement e = grid[i, 0];
                    e.Rotation = rotation;

                    int index = focusIndex.X - i;
                    if (index >= 0)
                    {
                        //e.Position = positions[index];
                        e.TwitchPosition(positions[index], twitchTime, TwitchCurve.Shape.OvershootOut);
                    }
                    else
                    {
                        Vector3 position = positions[-index];
                        position.X = -position.X;
                        //e.Position = position;
                        e.TwitchPosition(position, twitchTime, TwitchCurve.Shape.OvershootOut);
                    }
                }
            }

            var brushElement = (UIGrid2DBrushElement)SelectionElement;
            var overlay      = (string)(brushElement.Tag);

            HelpOverlay.ReplaceTop(overlay);
        }   // end of Update();
Exemple #29
0
        private void CheckResizeSelection()
        {
            GamePadInput pad            = GamePadInput.GetGamePad0();
            const float  kMinResizeTime = 0.25f;

            if (sizeTimer >= kMinResizeTime)
            {
                if (Actions.BrushLarger.WasPressedOrRepeat)
                {
                    inGame.Terrain.ExpandSelection();
                    sizeTimer = 0.0f;
                }

                if (Actions.BrushSmaller.WasPressedOrRepeat)
                {
                    inGame.Terrain.ShrinkSelection();
                    sizeTimer = 0.0f;
                }
            }
        }
        }   // end of SetXButton()

        public override void Update(ref Matrix parentMatrix)
        {
            // Check for input but only if selected.
            if (selected)
            {
                GamePadInput pad = GamePadInput.GetGamePad0();

                if (Actions.ComboRight.WasPressedOrRepeat)
                {
                    Actions.ComboRight.ClearAllWasPressedState();

                    curIndex = (curIndex + 1) % 3;
                    Foley.PlayClickUp();
                    dirty = true;
                }

                if (Actions.ComboLeft.WasPressedOrRepeat)
                {
                    Actions.ComboLeft.ClearAllWasPressedState();

                    curIndex = (curIndex + 3 - 1) % 3;
                    Foley.PlayClickDown();
                    dirty = true;
                }

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

                    if (onXButton != null)
                    {
                        onXButton(curIndex);
                    }
                }
            }

            RefreshTexture();

            base.Update(ref parentMatrix);
        }   // end of UIGridModularCameraModeElement Update()