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 Draw(GameTime gameTime) { _preScreen.Draw(gameTime); _batch.Begin(samplerState: SamplerState.PointClamp); var(unit, startX, width, height) = Border.GetDefaultScreenValues(); Border.DrawCenter(_batch, startX, 0, Border.SCREEN_WIDTH, Border.SCREEN_HEIGHT, Border.SCALE); // draw border // vertical for (var i = 0; i < Border.SCREEN_HEIGHT; i++) { _batch.Draw(_border, new Rectangle(startX, unit * i, unit, unit), Color.White); _batch.Draw(_border, new Rectangle(startX + unit * 19, unit * i, unit, unit), Color.White); } var verticalOffset = (5 - ActiveCharset.Length / CHARS_PER_LINE) * 2; // horizontal var horizontalBars = new[] { 0, 5 + verticalOffset, 15, 17 }; for (var i = 1; i < Border.SCREEN_WIDTH - 1; i++) { foreach (var y in horizontalBars) { _batch.Draw(_border, new Rectangle(startX + i * unit, unit * y, unit, unit), Color.White); } } // title _fontRenderer.DrawText(_batch, _title, new Vector2(startX + unit * 5, unit * 2), Color.Black, Border.SCALE); // icon if (_icon != null) { _batch.Draw(_icon, new Rectangle( startX + 2 * unit, (int)(unit * 1.5), (int)(Border.SCALE * _iconFrameSize), (int)(Border.SCALE * _iconFrameSize)), new Rectangle(_iconFrame * _iconFrameSize, 0, _iconFrameSize, _iconFrameSize), Color.White); } // name _fontRenderer.DrawText(_batch, _name, new Vector2(startX + unit * 5, unit * (4 + verticalOffset)), Color.Black, Border.SCALE); var nameLength = PokemonFontRenderer.PrintableCharAmount(_name); for (var i = nameLength; i < _maxLength; i++) { var textureOffset = i > nameLength ? 1 : 0; _batch.Draw(_placeholders, new Rectangle( startX + unit * 5 + unit * i, unit * (4 + verticalOffset), (int)(_placeholders.Height * Border.SCALE), (int)(_placeholders.Height * Border.SCALE)), new Rectangle(textureOffset * 8, 0, 8, 8), Color.White); } // char list var charListText = ""; for (var i = 0; i < ActiveCharset.Length; i++) { charListText += ActiveCharset[i]; if ((i + 1) % CHARS_PER_LINE == 0) { charListText += NewLine; } else { charListText += " "; } } _fontRenderer.DrawText(_batch, charListText, new Vector2(startX + unit * 2, unit * (6 + verticalOffset)), Color.Black, Border.SCALE); // menu var menuText = ""; if (_isLower) { menuText += "UPPER"; } else { menuText += "lower"; } menuText += " DEL END"; _fontRenderer.DrawText(_batch, menuText, new Vector2(startX + unit * 2, unit * 16), Color.Black, Border.SCALE); // selector if (_selectorVisible) { if (_menuActive) { _batch.Draw(_selectorMenu, new Rectangle( startX + unit * 2 + unit * _menuIndex * 6, (int)(unit * 16 - Border.SCALE), (int)(_selectorMenu.Width * Border.SCALE), (int)(_selectorMenu.Height * Border.SCALE)), Color.White); } else { _batch.Draw(_selector, new Rectangle( (int)(startX + unit * _charX * 2 + unit * 2 - Border.SCALE), (int)(unit * _charY * 2 + unit * (6 + verticalOffset) - Border.SCALE), (int)(_selector.Width * Border.SCALE), (int)(_selector.Height * Border.SCALE)), Color.White); } } _batch.End(); }
internal override void Draw(GameTime gameTime) { _preScreen.Draw(gameTime); _batch.Begin(samplerState: SamplerState.PointClamp); var(unit, startX, width, height) = Border.GetDefaultScreenValues(); Border.DrawCenter(_batch, startX, 0, Border.SCREEN_WIDTH, Border.SCREEN_HEIGHT, Border.SCALE); // borders for (var x = 0; x < Border.SCREEN_WIDTH; x++) { for (var y = 0; y < 6; y++) { if (y == 0 || x == 0 || x == Border.SCREEN_WIDTH - 1 || y == 5) { _batch.Draw(_border, new Rectangle(startX + x * unit, y * unit, unit, unit), Color.White); } } } // compose icon _batch.Draw(_icon, new Rectangle( startX, 0, (int)(Border.SCALE * _icon.Height), (int)(Border.SCALE * _icon.Height)), new Rectangle(_iconFrame * 16, 0, 16, 16), Color.White); // message var lines = Mail.GetLinesFromMessage(_message); _fontRenderer.DrawText(_batch, lines[0], new Vector2(startX + unit * 2, unit * 2), Color.Black, Border.SCALE); if (lines[1] != null) { _fontRenderer.DrawText(_batch, lines[1], new Vector2(startX + unit * 2, unit * 4), Color.Black, Border.SCALE); } // placeholders var messageLength = PokemonFontRenderer.PrintableCharAmount(_message); for (var i = messageLength; i < Mail.MESSAGE_MAX_LENGTH; i++) { var y = 0; var x = i; if (x >= Mail.MESSAGE_CHARS_PER_LINE) { y++; x -= Mail.MESSAGE_CHARS_PER_LINE; } var textureOffset = i > messageLength ? 1 : 0; _batch.Draw(_placeholders, new Rectangle( startX + unit * 2 + unit * x, unit * 2 + y * unit * 2, (int)(_placeholders.Height * Border.SCALE), (int)(_placeholders.Height * Border.SCALE)), new Rectangle(textureOffset * 8, 0, 8, 8), Color.White); } // char list var charListText = ""; for (var i = 0; i < ActiveCharset.Length; i++) { charListText += ActiveCharset[i]; if ((i + 1) % CHARS_PER_LINE == 0) { charListText += Environment.NewLine; } else { charListText += " "; } } _fontRenderer.DrawText(_batch, charListText, new Vector2(startX + unit, unit * 7), Color.Black, Border.SCALE); // menu var menuText = ""; if (_isLower) { menuText += "UPPER"; } else { menuText += "lower"; } menuText += " DEL END"; _fontRenderer.DrawText(_batch, menuText, new Vector2(startX + unit, unit * 17), Color.Black, Border.SCALE); // selector if (_selectorVisible) { if (_menuActive) { _batch.Draw(_selectorMenu, new Rectangle( startX + unit + unit * _menuIndex * 6, (int)(unit * 17 - Border.SCALE), (int)(_selectorMenu.Width * Border.SCALE), (int)(_selectorMenu.Height * Border.SCALE)), Color.White); } else { _batch.Draw(_selector, new Rectangle( (int)(startX + unit * _charX * 2 + unit - Border.SCALE), (int)(unit * _charY * 2 + unit * 7 - Border.SCALE), (int)(_selector.Width * Border.SCALE), (int)(_selector.Height * Border.SCALE)), Color.White); } } _batch.End(); }