Update() protected method

protected Update ( ) : void
return void
示例#1
0
            internal void RefreshGrid()
            {
                Point currSelection = grid.SelectionIndex;

                GetSortedGridElements(refreshGrid_scratch);

                for (int i = 0; i < grid.ActualDimensions.Y; ++i)
                {
                    UIGridShareHubElement elem = grid.Get(0, i) as UIGridShareHubElement;

                    elem.Selected = false;

                    if (!refreshGrid_scratch.Contains(elem))
                    {
                        BokuGame.Unload(elem);
                    }
                }

                grid.Clear();

                for (int i = 0; i < refreshGrid_scratch.Count; ++i)
                {
                    grid.Add(refreshGrid_scratch[i], 0, grid.ActualDimensions.Y);
                    BokuGame.Load(refreshGrid_scratch[i]);
                }

                grid.Dirty = true;

                // Try to preserve selection index.
                // We might want to try to relocate the selected element if it moved instead.
                if (grid.ActualDimensions.Y > currSelection.Y)
                {
                    grid.SelectionIndex = new Point(0, currSelection.Y);
                }
                else if (grid.ActualDimensions.Y > 0)
                {
                    grid.SelectionIndex = new Point(0, grid.ActualDimensions.Y - 1);
                }

                Matrix parentMatrix = Matrix.Identity;

                grid.Update(ref parentMatrix);
            }
示例#2
0
        }   // end of BasePicker RestorePreviousChoice()

        public virtual void Update(PerspectiveUICamera camera)
        {
            if (active)
            {
                if (hidden)
                {
                    // Note, even though we're hidden we may still be rendering our fade out.
                    double elapsedTime = Time.WallClockTotalSeconds - startFadeTime;
                    if (elapsedTime >= fadeTime)
                    {
                        Alpha = 0.0f;
                    }
                    else
                    {
                        Alpha = 1.0f - (float)(elapsedTime / fadeTime);
                    }
                }
                else
                {
                    // Not hidden, so respond to user input.

                    int scroll = MouseInput.ScrollWheel - MouseInput.PrevScrollWheel;

                    if (Actions.PickerRight.WasPressedOrRepeat || scroll > 0)
                    {
                        Actions.PickerRight.ClearAllWasPressedState();
                        DecrementFocus();
                    }
                    if (Actions.PickerLeft.WasPressedOrRepeat || scroll < 0)
                    {
                        Actions.PickerLeft.ClearAllWasPressedState();
                        IncrementFocus();
                    }

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

                        SelectCurrentChoice();
                        Foley.PlayPressA();
                    }

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

                        RestorePreviousChoice();
                        Foley.PlayBack();
                    }
                    bool handled = false;
                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                    {
                        handled = HandleTouchInput(camera);
                    }
                    else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                    {
                        handled = HandleMouseInput(camera);
                    }

                    if (!handled)
                    {
                        // If the user clicked but didn't hit any of the picker elements, close the picker.
                        // If alt is pressed, they must be in eyedropper mode.
                        if ((MouseInput.Left.WasPressed && !KeyboardInput.AltIsPressed) ||
                            (TouchGestureManager.Get().TapGesture.WasRecognized))
                        {
                            SelectCurrentChoice();
                            Foley.PlayPressA();
                        }
                        else if (Actions.Sample.WasPressed ||
                                 MouseEdit.TriggerSample() || TouchEdit.TriggerSample())
                        {
                            Actions.Sample.ClearAllWasPressedState();

                            int t = OnSampleType();
                            if (t >= 0)
                            {
                                OnSetType(t);
                                Point selection = grid.SelectionIndex;
                                selection.X         = t;
                                grid.SelectionIndex = selection;
                                Foley.PlayCut();
                            }
                            else
                            {
                                Foley.PlayNoBudget();
                            }
                        }
                    }

                    grid.Update(ref worldMatrix);
                }
            } // end if active
        }     // end of BasePicker Update()
示例#3
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()
示例#4
0
        }   // end of TexturePicker InitFileList()

        public void Update()
        {
            if (active)
            {
                GamePadInput pad = GamePadInput.GetGamePad1();

                // Switch active grid?
                bool changed = false;
                if (pad.LeftStickLeft.WasPressed || pad.DPadLeft.WasPressed)
                {
                    activeGrid = (activeGrid + 3) % 4;
                    changed    = true;
                    Foley.PlayProgrammingClick();
                }
                if (pad.LeftStickRight.WasPressed || pad.DPadRight.WasPressed)
                {
                    activeGrid = (activeGrid + 1) % 4;
                    changed    = true;
                    Foley.PlayProgrammingClick();
                }

                if (changed)
                {
                    Vector3 newPosition                = new Vector3(-2.25f + 1.5f * activeGrid, 0.0f, 0.0f);
                    TwitchManager.GetVector3    get    = delegate(Object param) { return(selectionPlate.Position); };
                    TwitchManager.SetVector3    set    = delegate(Vector3 value, Object param) { selectionPlate.Position = value; };
                    TwitchManager.Vector3Twitch twitch = new TwitchManager.Vector3Twitch(get, set, newPosition, 0.25f, TwitchCurve.Shape.OvershootOut);
                    twitch.Start();

                    grid0.Active = false;
                    grid1.Active = false;
                    grid2.Active = false;
                    grid3.Active = false;

                    switch (activeGrid)
                    {
                    case 0: grid0.Active = true; break;

                    case 1: grid1.Active = true; break;

                    case 2: grid2.Active = true; break;

                    case 3: grid3.Active = true; break;
                    }

                    changed = false;
                }

                backPlate.Update();
                selectionPlate.Update();
                grid0.Update(ref worldGrid);
                grid1.Update(ref worldGrid);
                grid2.Update(ref worldGrid);
                grid3.Update(ref worldGrid);

                // See if any of the grids have changed which texture is in focus.
                // If so, change what the terrain sees.
                if (grid0.SelectionIndex.Y != curFocusIndex0)
                {
                    curFocusIndex0 = grid0.SelectionIndex.Y;
                    InGame.inGame.Terrain.ChangeTerrainTexture(0, files[curFocusIndex0]);
                    InGame.inGame.IsLevelDirty = true;
                }
                if (grid1.SelectionIndex.Y != curFocusIndex1)
                {
                    curFocusIndex1 = grid1.SelectionIndex.Y;
                    InGame.inGame.Terrain.ChangeTerrainTexture(1, files[curFocusIndex1]);
                    InGame.inGame.IsLevelDirty = true;
                }
                if (grid2.SelectionIndex.Y != curFocusIndex2)
                {
                    curFocusIndex2 = grid2.SelectionIndex.Y;
                    InGame.inGame.Terrain.ChangeTerrainTexture(2, files[curFocusIndex2]);
                    InGame.inGame.IsLevelDirty = true;
                }
                if (grid3.SelectionIndex.Y != curFocusIndex3)
                {
                    curFocusIndex3 = grid3.SelectionIndex.Y;
                    InGame.inGame.Terrain.ChangeTerrainTexture(3, files[curFocusIndex3]);
                    InGame.inGame.IsLevelDirty = true;
                }

                float outerRowAlpha = 0.3f;
                float innerRowAlpha = 0.7f;

                // Update the alpha values of the visible tiles.
                for (int i = 0; i < grid0.ActualDimensions.Y; i++)
                {
                    UIGrid2DTextureElement e = null;

                    e = grid0.Get(0, i) as UIGrid2DTextureElement;
                    if (e != null)
                    {
                        int delta = Math.Abs(i - grid0.SelectionIndex.Y);
                        if (delta < 2)
                        {
                            e.Alpha = 1.0f;
                        }
                        else if (delta < 3)
                        {
                            e.Alpha = innerRowAlpha;
                        }
                        else
                        {
                            e.Alpha = outerRowAlpha;
                        }
                    }

                    e = grid1.Get(0, i) as UIGrid2DTextureElement;
                    if (e != null)
                    {
                        int delta = Math.Abs(i - grid1.SelectionIndex.Y);
                        if (delta < 2)
                        {
                            e.Alpha = 1.0f;
                        }
                        else if (delta < 3)
                        {
                            e.Alpha = innerRowAlpha;
                        }
                        else
                        {
                            e.Alpha = outerRowAlpha;
                        }
                    }
                    e = grid2.Get(0, i) as UIGrid2DTextureElement;
                    if (e != null)
                    {
                        int delta = Math.Abs(i - grid2.SelectionIndex.Y);
                        if (delta < 2)
                        {
                            e.Alpha = 1.0f;
                        }
                        else if (delta < 3)
                        {
                            e.Alpha = innerRowAlpha;
                        }
                        else
                        {
                            e.Alpha = outerRowAlpha;
                        }
                    }
                    e = grid3.Get(0, i) as UIGrid2DTextureElement;
                    if (e != null)
                    {
                        int delta = Math.Abs(i - grid3.SelectionIndex.Y);
                        if (delta < 2)
                        {
                            e.Alpha = 1.0f;
                        }
                        else if (delta < 3)
                        {
                            e.Alpha = innerRowAlpha;
                        }
                        else
                        {
                            e.Alpha = outerRowAlpha;
                        }
                    }
                }
            }
        }   // end of TexturePicker Update()