Пример #1
0
        /// <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()
Пример #2
0
        /// <summary>
        /// Common update code, expected to be overridden but base Update called as well.
        /// </summary>
        public virtual void Update(Camera camera)
        {
            // Only update if active and the toolbox isn't changing.
            if (Active)
            {
                NotifyTerrainActivity();

                CheckStretchMode();

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

                // When a picker is being used currentTouchAction gets set to the invalid state NUMBER_OF_Buttons but
                // when the picker stops being used currentTouchAction doesn't get restored to its previous value.  The
                // result is that the user must tap the paint button again before any input works.  So, this hack tries
                // to keep track of the good state in previousGoodTouchAction and restores that if the pickers are both
                // closed and the state is bad.
                // If neither picker is in use, either restore currentTouchAction to a useful state or save its current state.
                if ((pickerX == null || pickerX.Hidden) && (pickerY == null || pickerY.Hidden))
                {
                    // Do we have an invalid state?
                    if (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.NUMBER_OF_Buttons)
                    {
                        // Invalid state, restore previous good state.
                        shared.currentTouchAction = shared.previousGoodTouchAction;
                    }
                    else
                    {
                        // Valid state, save it to restore later.
                        shared.previousGoodTouchAction = shared.currentTouchAction;
                    }
                }

                // 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 = !inGame.mouseEditUpdateObj.ToolBox.PickersActive;
        }   // end of BaseMouseEditTool Update()