Example #1
0
        public void MenuUpdate(MainMenu menu)
        {
            GamePad.Update();
            if (!isReady)
            {
                if (!hasPickedName)
                {
                    if (isInNameSelect)
                    {
                        if (GamePad.LeftStick().Y == -1 && GamePad.DeltaLeftStick().Y < 0)
                        {
                            currentHighlight++;
                            if (currentHighlight > Settings.PrvNames.Count)
                            {
                                currentHighlight--;
                            }
                        }
                        else if (GamePad.LeftStick().Y == 1 && GamePad.DeltaLeftStick().Y > 0)
                        {
                            currentHighlight--;
                            if (currentHighlight < 0)
                            {
                                currentHighlight = 0;
                            }
                        }
                        if (GamePad.IsButtonDown(ControllerButton.A))
                        {
                            if (currentHighlight < Settings.PrvNames.Count)
                            {
                                isSpellingName   = false;
                                isInNameSelect   = false;
                                hasPickedName    = true;
                                base.Name        = Settings.PrvNames[currentHighlight];
                                currentHighlight = 0;
                            }
                            else
                            {
                                isSpellingName   = true;
                                isInNameSelect   = false;
                                currentHighlight = 0;
                            }
                        }
                    }
                    else if (isSpellingName)
                    {
                        if (GamePad.DeltaLeftStick().X >= .5f && GamePad.BasePrevious().LeftStick.X >= 0)
                        {
                            currentHighlight++;
                        }
                        if (GamePad.DeltaLeftStick().X <= -.5f && GamePad.BasePrevious().LeftStick.X <= 0)
                        {
                            currentHighlight += 25;
                        }
                        if (GamePad.DeltaLeftStick().Y >= .5f && GamePad.BasePrevious().LeftStick.Y >= 0)
                        {
                            currentHighlight += 26 - COL_NAME;
                        }
                        if (GamePad.DeltaLeftStick().Y <= -.5f && GamePad.BasePrevious().LeftStick.Y <= 0)
                        {
                            currentHighlight += COL_NAME;
                        }
                        if (GamePad.IsButtonPressed(ControllerButton.A))
                        {
                            if (Name.Length < Settings.NAMELEN)
                            {
                                Name += (char)('A' + currentHighlight);
                            }
                        }
                        if (GamePad.IsButtonPressed(ControllerButton.B))
                        {
                            if (Name.Length != 0)
                            {
                                Name = Name.Substring(0, Name.Length - 1);
                            }
                        }
                        if (GamePad.IsButtonPressed(ControllerButton.Start))
                        {
                            if (Name.Length != 0)
                            {
                                isSpellingName = false;
                                hasPickedName  = true;
                                Settings.PrvNames.Add(Name);
                            }
                        }
                        currentHighlight %= 26;
                    }
                }
                else
                {
                    /// THEY HAVE PICKED A NAME
                    if (GamePad.LeftStick().Y == -1 && GamePad.DeltaLeftStick().Y < 0)
                    {
                        currentHighlight++;
                        if (currentHighlight > 1)
                        {
                            currentHighlight = 0;
                        }
                    }
                    else if (GamePad.LeftStick().Y == 1 && GamePad.DeltaLeftStick().Y > 0)
                    {
                        currentHighlight--;
                        if (currentHighlight < 0)
                        {
                            currentHighlight = 1;
                        }
                    }

                    if (currentHighlight == 0)
                    {
                        // Picking Color
                        if (GamePad.LeftStick().X == 1 && GamePad.DeltaLeftStick().X > 0)
                        {
                            PlayerColor = menu.NextColor(PlayerColor);
                        }
                        if (GamePad.LeftStick().X == -1 && GamePad.DeltaLeftStick().X < 0)
                        {
                            PlayerColor = menu.PreviousColor(PlayerColor);
                        }
                    }
                    else
                    {
                        if (GamePad.IsButtonPressed(ControllerButton.A))
                        {
                            isReady = true;
                        }
                    }
                }
            }
        }