private void UpdateInfoPage()
 {
     if (GameboyInputs.APressed() ||
         GameboyInputs.BPressed() ||
         GameboyInputs.SelectPressed() ||
         GameboyInputs.StartPressed())
     {
         Close();
     }
     else
     {
         UpdateChangePage();
     }
 }
Exemple #2
0
        internal override void Update(GameTime gameTime)
        {
            _selectorDelay--;
            if (_selectorDelay == 0)
            {
                _selectorDelay   = SELECTOR_FLICKER_DELAY;
                _selectorVisible = !_selectorVisible;
            }

            if (_iconFrames > 1)
            {
                _iconFrameDelay--;
                if (_iconFrameDelay == 0)
                {
                    _iconFrameDelay = ICON_ANIMATION_DELAY;
                    _iconFrame++;
                    if (_iconFrame == _iconFrames)
                    {
                        _iconFrame = 0;
                    }
                }
            }

            if (GameboyInputs.RightPressed())
            {
                if (_menuActive)
                {
                    _menuIndex++;
                    // wrap around to the beginning of the line
                    if (_menuIndex == MENU_OPTIONS_COUNT)
                    {
                        _menuIndex = 0;
                    }
                }
                else
                {
                    _charX++;
                    // wrap around to the beginning of the line
                    if (_charX == CHARS_PER_LINE)
                    {
                        _charX = 0;
                    }
                }
            }
            else if (GameboyInputs.LeftPressed())
            {
                if (_menuActive)
                {
                    _menuIndex--;
                    // wrap around to the end of the line
                    if (_menuIndex == -1)
                    {
                        _menuIndex = MENU_OPTIONS_COUNT - 1;
                    }
                }
                else
                {
                    _charX--;
                    // wrap around to the end of the line
                    if (_charX == -1)
                    {
                        _charX = CHARS_PER_LINE - 1;
                    }
                }
            }
            else if (GameboyInputs.DownPressed())
            {
                if (_menuActive)
                {
                    _charY = 0;
                    if (MenuColumn != _menuIndex)
                    {
                        _charX = _menuIndex * 3;
                    }
                    _menuActive = false;
                }
                else
                {
                    _charY++;
                    if (_charY == ActiveCharset.Length / CHARS_PER_LINE)
                    {
                        _menuActive = true;
                        _menuIndex  = MenuColumn;
                    }
                }
            }
            else if (GameboyInputs.UpPressed())
            {
                if (_menuActive)
                {
                    _charY = ActiveCharset.Length / CHARS_PER_LINE - 1;
                    if (MenuColumn != _menuIndex)
                    {
                        _charX = _menuIndex * 3;
                    }
                    _menuActive = false;
                }
                else
                {
                    _charY--;
                    if (_charY == -1)
                    {
                        _menuActive = true;
                        _menuIndex  = MenuColumn;
                    }
                }
            }

            if (GameboyInputs.BPressed())
            {
                BackspaceName();
            }
            else if (GameboyInputs.APressed())
            {
                if (_menuActive)
                {
                    switch (_menuIndex)
                    {
                    case 0:     // upper/lower switch
                        _isLower = !_isLower;
                        break;

                    case 1:     // DEL
                        BackspaceName();
                        break;

                    case 2:     // END
                        Close();
                        break;
                    }
                }
                else
                {
                    var nameLength = PokemonFontRenderer.PrintableCharAmount(_name);
                    if (nameLength < _maxLength)
                    {
                        var activeChar = ActiveCharset[_charX + _charY * CHARS_PER_LINE];
                        _name     += activeChar;
                        nameLength = PokemonFontRenderer.PrintableCharAmount(_name);
                        if (nameLength == _maxLength)
                        {
                            // select END button
                            _menuActive = true;
                            _menuIndex  = 2;
                        }
                    }
                }
            }
            else if (GameboyInputs.StartPressed())
            {
                // select END button
                _menuActive = true;
                _menuIndex  = 2;
            }
            else if (GameboyInputs.SelectPressed())
            {
                // switch upper/lower
                _isLower = !_isLower;
            }
        }
        internal override void Update(GameTime gameTime)
        {
            if (GameboyInputs.DownPressed())
            {
                if (_index + _scrollIndex + 1 < _entries.Length)
                {
                    if (_index < VisibleEntries - 1)
                    {
                        _index++;
                    }
                    else
                    {
                        _scrollIndex++;
                    }
                }
            }
            else if (GameboyInputs.UpPressed())
            {
                if (_index > 0)
                {
                    _index--;
                }
                else if (_scrollIndex > 0)
                {
                    _scrollIndex--;
                }
            }
            else if (GameboyInputs.LeftPressed())
            {
                _scrollIndex -= 7;
                if (_scrollIndex < 0)
                {
                    _scrollIndex = 0;
                }
            }
            else if (GameboyInputs.RightPressed())
            {
                _scrollIndex += 7;
                if (_scrollIndex + VisibleEntries > _entries.Length)
                {
                    _scrollIndex = _entries.Length - VisibleEntries;
                }
            }

            var stackEntryIsComplete = false;

            for (var i = 0; i < _entryStack.Count; i++)
            {
                _spriteAnimationStack[i] += 0.2;
                if (_spriteAnimationStack[i] >= 1.0)
                {
                    if (stackEntryIsComplete)
                    {
                        _spriteAnimationStack.RemoveAt(i);
                        _entryStack.RemoveAt(i);
                        i--;
                    }
                    else
                    {
                        stackEntryIsComplete     = true;
                        _spriteAnimationStack[i] = 1.0;
                    }
                }
            }

            if (GameboyInputs.APressed())
            {
                var selectedEntry = _entries[_scrollIndex + _index];
                if (selectedEntry.IsKnown)
                {
                    // open details screen
                    var screenManager = GetComponent <ScreenManager>();
                    var detailsScreen = new PokedexDetailsScreen(this, selectedEntry, GetNextEntry, GetPreviousEntry);
                    detailsScreen.LoadContent();
                    screenManager.SetScreen(detailsScreen);
                }
            }
            else if (GameboyInputs.BPressed())
            {
                Close();
            }
            else if (GameboyInputs.SelectPressed())
            {
                // open options screen
                var screenManager = GetComponent <ScreenManager>();
                var optionsScreen = new PokedexOptionScreen(_preScreen, this);
                optionsScreen.LoadContent();
                screenManager.SetScreen(optionsScreen);
            }
            else if (GameboyInputs.StartPressed())
            {
                // open search screen
                var screenManager = GetComponent <ScreenManager>();
                var searchScreen  = new PokedexSearchScreen(_preScreen, this, ListMode);
                searchScreen.LoadContent();
                screenManager.SetScreen(searchScreen);
            }
        }