P3D-Legacy/P3D/Input/UI/SelectMenu.vb

162 lines
7.3 KiB
VB.net
Raw Normal View History

Namespace UI
''' <summary>
''' A menu that displays multiple selectable options to the player.
''' </summary>
Public Class SelectMenu
''' <summary>
''' The event that gets fired upon selection.
''' </summary>
''' <param name="s">The menu that the item got selected on.</param>
Public Delegate Sub ClickEvent(ByVal s As SelectMenu)
Dim Items As New List(Of String)
Dim Index As Integer = 0
Dim ClickHandler As ClickEvent = Nothing
Dim BackIndex As Integer = 0
Public Visible As Boolean = True
Public Scroll As Integer = 0
Dim t1 As Texture2D
Dim t2 As Texture2D
''' <summary>
''' Creates a new instance of a select menu.
''' </summary>
''' <param name="Items">The items in the menu.</param>
''' <param name="Index">The selected index.</param>
''' <param name="ClickHandle">The method to call when the player selects an item.</param>
''' <param name="BackIndex">The index of the item to select when back is pressed.</param>
Public Sub New(ByVal Items As List(Of String), ByVal Index As Integer, ByVal ClickHandle As ClickEvent, ByVal BackIndex As Integer)
Me.Items = Items
Me.Index = Index
Me.ClickHandler = ClickHandle
Me.BackIndex = BackIndex
If Me.BackIndex < 0 Then
Me.BackIndex = Me.Items.Count + Me.BackIndex
End If
Me.Visible = True
t1 = TextureManager.GetTexture("GUI\Menus\General", New Rectangle(16, 16, 16, 16), "")
t2 = TextureManager.GetTexture("GUI\Menus\General", New Rectangle(32, 16, 16, 16), "")
SetCursorDest()
cursorPos = cursorDest
End Sub
Public Sub Update()
If Visible = True Then
Battle fixes and improvements * Fixed camera angle not changing to the Pokémon when status effects are doing something * Fixed softlock when opponent trainer switches Pokémon * (Hopefully) fixed initial positioning errors with spawned BattleAnimation entities related to BattleFlip functionality * Removed the now unneccessary BattleFlip checks in the move animation of Growl * Improved Ember move animation (fireball speed & flame delay) * Improved Poison Sting move animation by making the stinger smaller, increasing the speed of the stinger and making it use a flipped version of the texture when the opponent uses the move * Improved Poisoned status effect animation by making it 1 bubble for regular poison and 3 bubbles for toxic * Repositioned the flame of the Burned status effect animation * Trainers now display a message when sending out their Pokémon (I removed that before) * Fixed Party Screen not appearing immediately after the player's Pokémon fainted and also made the player unable to exit the Party Screen when that happens. * Fixed the incorrectly scaled font sizes and text alignment in the selection menu that appears when selecting a Pokémon in the Party screen * Replaced minifont in the Pokémon level up stats box with InGameFont and fixed the offsets * Fixed the error I made in the ceiling map code of Violet City's gym * Removed the file MoveAnimationQueryObject.vb because AnimationQueryObject.vb also includes Move Animations * Fixed the textbox in battles where an empty rectangle would appear before the animation finished. * When a trainer spots the player and an exclamation mark bubble pops up above their head, a sound is played (Emote_Exclamation) * In trainer battles, the player's Pokémon now also plays their cry.
2022-01-16 17:22:36 +01:00
cursorPos.Y = CInt(MathHelper.Lerp(cursorDest.Y, cursorPos.Y, 0.6F))
If Controls.Up(True, True, True, True, True, True) = True Then
Me.Index -= 1
If Me.Index < 0 Then
Me.Index = Me.Items.Count - 1
End If
End If
If Controls.Down(True, True, True, True, True, True) = True Then
Me.Index += 1
If Index > Items.Count - 1 Then
Index = 0
End If
End If
Dim PlaySelectSound As Boolean = False
If CurrentScreen.MouseVisible = True Then
For i = Scroll To Me.Scroll + 8
If i <= Me.Items.Count - 1 Then
If Controls.Accept(True, False, False) = True And i = Me.Index And New Rectangle(Core.windowSize.Width - 270, 72 * ((i + 1) - Scroll), 256, 64).Contains(MouseHandler.MousePosition) = True Or
Controls.Accept(False, True, True) = True And i = Me.Index Or Controls.Dismiss(True, True, True) = True And Me.BackIndex = Me.Index Then
PlaySelectSound = True
If Not ClickHandler Is Nothing Then
ClickHandler(Me)
End If
Me.Visible = False
End If
If Controls.Dismiss(True, True, True) = True Then
Me.Index = Me.BackIndex
PlaySelectSound = True
If Not ClickHandler Is Nothing Then
ClickHandler(Me)
End If
Me.Visible = False
End If
If New Rectangle(Core.windowSize.Width - 270, 72 * ((i + 1) - Scroll), 256, 64).Contains(MouseHandler.MousePosition) = True And Controls.Accept(True, False, False) = True Then
Me.Index = i
End If
End If
Next
Else
For i = Scroll To Me.Scroll + 8
If Controls.Accept(True, True, True) = True And i = Me.Index Then
PlaySelectSound = True
If Not ClickHandler Is Nothing Then
ClickHandler(Me)
End If
Me.Visible = False
Exit For
End If
If Controls.Dismiss(True, True, True) = True Then
Me.Index = Me.BackIndex
PlaySelectSound = True
If Not ClickHandler Is Nothing Then
ClickHandler(Me)
End If
Me.Visible = False
Exit For
End If
Next
End If
If PlaySelectSound = True Then
SoundManager.PlaySound("select")
PlaySelectSound = False
End If
End If
If Index - Scroll > 8 Then
Scroll = Index - 8
End If
If Index - Scroll < 0 Then
Scroll = Index
End If
SetCursorDest()
End Sub
Private cursorPos As Vector2
Private cursorDest As Vector2
Public Sub Draw()
If Visible = True Then
For i = Scroll To Me.Scroll + 8
If i <= Me.Items.Count - 1 Then
Dim Text As String = Items(i)
Battle fixes and improvements * Fixed camera angle not changing to the Pokémon when status effects are doing something * Fixed softlock when opponent trainer switches Pokémon * (Hopefully) fixed initial positioning errors with spawned BattleAnimation entities related to BattleFlip functionality * Removed the now unneccessary BattleFlip checks in the move animation of Growl * Improved Ember move animation (fireball speed & flame delay) * Improved Poison Sting move animation by making the stinger smaller, increasing the speed of the stinger and making it use a flipped version of the texture when the opponent uses the move * Improved Poisoned status effect animation by making it 1 bubble for regular poison and 3 bubbles for toxic * Repositioned the flame of the Burned status effect animation * Trainers now display a message when sending out their Pokémon (I removed that before) * Fixed Party Screen not appearing immediately after the player's Pokémon fainted and also made the player unable to exit the Party Screen when that happens. * Fixed the incorrectly scaled font sizes and text alignment in the selection menu that appears when selecting a Pokémon in the Party screen * Replaced minifont in the Pokémon level up stats box with InGameFont and fixed the offsets * Fixed the error I made in the ceiling map code of Violet City's gym * Removed the file MoveAnimationQueryObject.vb because AnimationQueryObject.vb also includes Move Animations * Fixed the textbox in battles where an empty rectangle would appear before the animation finished. * When a trainer spots the player and an exclamation mark bubble pops up above their head, a sound is played (Emote_Exclamation) * In trainer battles, the player's Pokémon now also plays their cry.
2022-01-16 17:22:36 +01:00
Dim startPos As New Vector2(Core.windowSize.Width - 270, 72 * ((i + 1) - Scroll))
Core.SpriteBatch.Draw(t1, New Rectangle(CInt(startPos.X), CInt(startPos.Y), 64, 64), Color.White)
Core.SpriteBatch.Draw(t2, New Rectangle(CInt(startPos.X + 64), CInt(startPos.Y), 64, 64), Color.White)
Core.SpriteBatch.Draw(t2, New Rectangle(CInt(startPos.X + 128), CInt(startPos.Y), 64, 64), Color.White)
Core.SpriteBatch.Draw(t1, New Rectangle(CInt(startPos.X + 192), CInt(startPos.Y), 64, 64), Nothing, Color.White, 0.0F, New Vector2(0), SpriteEffects.FlipHorizontally, 0.0F)
Battle fixes and improvements * Fixed camera angle not changing to the Pokémon when status effects are doing something * Fixed softlock when opponent trainer switches Pokémon * (Hopefully) fixed initial positioning errors with spawned BattleAnimation entities related to BattleFlip functionality * Removed the now unneccessary BattleFlip checks in the move animation of Growl * Improved Ember move animation (fireball speed & flame delay) * Improved Poison Sting move animation by making the stinger smaller, increasing the speed of the stinger and making it use a flipped version of the texture when the opponent uses the move * Improved Poisoned status effect animation by making it 1 bubble for regular poison and 3 bubbles for toxic * Repositioned the flame of the Burned status effect animation * Trainers now display a message when sending out their Pokémon (I removed that before) * Fixed Party Screen not appearing immediately after the player's Pokémon fainted and also made the player unable to exit the Party Screen when that happens. * Fixed the incorrectly scaled font sizes and text alignment in the selection menu that appears when selecting a Pokémon in the Party screen * Replaced minifont in the Pokémon level up stats box with InGameFont and fixed the offsets * Fixed the error I made in the ceiling map code of Violet City's gym * Removed the file MoveAnimationQueryObject.vb because AnimationQueryObject.vb also includes Move Animations * Fixed the textbox in battles where an empty rectangle would appear before the animation finished. * When a trainer spots the player and an exclamation mark bubble pops up above their head, a sound is played (Emote_Exclamation) * In trainer battles, the player's Pokémon now also plays their cry.
2022-01-16 17:22:36 +01:00
Core.SpriteBatch.DrawString(FontManager.MainFont, Text, New Vector2(CInt(startPos.X + 20), CInt(startPos.Y + 32 - FontManager.MainFont.MeasureString(Text).Y / 2)), Color.Black, 0.0F, Vector2.Zero, 1.0F, SpriteEffects.None, 0.0F)
End If
Next
End If
Battle fixes and improvements * Fixed camera angle not changing to the Pokémon when status effects are doing something * Fixed softlock when opponent trainer switches Pokémon * (Hopefully) fixed initial positioning errors with spawned BattleAnimation entities related to BattleFlip functionality * Removed the now unneccessary BattleFlip checks in the move animation of Growl * Improved Ember move animation (fireball speed & flame delay) * Improved Poison Sting move animation by making the stinger smaller, increasing the speed of the stinger and making it use a flipped version of the texture when the opponent uses the move * Improved Poisoned status effect animation by making it 1 bubble for regular poison and 3 bubbles for toxic * Repositioned the flame of the Burned status effect animation * Trainers now display a message when sending out their Pokémon (I removed that before) * Fixed Party Screen not appearing immediately after the player's Pokémon fainted and also made the player unable to exit the Party Screen when that happens. * Fixed the incorrectly scaled font sizes and text alignment in the selection menu that appears when selecting a Pokémon in the Party screen * Replaced minifont in the Pokémon level up stats box with InGameFont and fixed the offsets * Fixed the error I made in the ceiling map code of Violet City's gym * Removed the file MoveAnimationQueryObject.vb because AnimationQueryObject.vb also includes Move Animations * Fixed the textbox in battles where an empty rectangle would appear before the animation finished. * When a trainer spots the player and an exclamation mark bubble pops up above their head, a sound is played (Emote_Exclamation) * In trainer battles, the player's Pokémon now also plays their cry.
2022-01-16 17:22:36 +01:00
Dim cPosition As Vector2 = New Vector2(CInt(cursorPos.X + 128), CInt(cursorPos.Y - 40))
Dim t As Texture2D = TextureManager.GetTexture("GUI\Menus\General", New Rectangle(0, 0, 16, 16), "")
Core.SpriteBatch.Draw(t, New Rectangle(CInt(cPosition.X), CInt(cPosition.Y), 64, 64), Color.White)
End Sub
Private Sub SetCursorDest()
Battle fixes and improvements * Fixed camera angle not changing to the Pokémon when status effects are doing something * Fixed softlock when opponent trainer switches Pokémon * (Hopefully) fixed initial positioning errors with spawned BattleAnimation entities related to BattleFlip functionality * Removed the now unneccessary BattleFlip checks in the move animation of Growl * Improved Ember move animation (fireball speed & flame delay) * Improved Poison Sting move animation by making the stinger smaller, increasing the speed of the stinger and making it use a flipped version of the texture when the opponent uses the move * Improved Poisoned status effect animation by making it 1 bubble for regular poison and 3 bubbles for toxic * Repositioned the flame of the Burned status effect animation * Trainers now display a message when sending out their Pokémon (I removed that before) * Fixed Party Screen not appearing immediately after the player's Pokémon fainted and also made the player unable to exit the Party Screen when that happens. * Fixed the incorrectly scaled font sizes and text alignment in the selection menu that appears when selecting a Pokémon in the Party screen * Replaced minifont in the Pokémon level up stats box with InGameFont and fixed the offsets * Fixed the error I made in the ceiling map code of Violet City's gym * Removed the file MoveAnimationQueryObject.vb because AnimationQueryObject.vb also includes Move Animations * Fixed the textbox in battles where an empty rectangle would appear before the animation finished. * When a trainer spots the player and an exclamation mark bubble pops up above their head, a sound is played (Emote_Exclamation) * In trainer battles, the player's Pokémon now also plays their cry.
2022-01-16 17:22:36 +01:00
cursorDest = New Vector2(CInt(Core.windowSize.Width - 270), CInt(72 * (Index + 1 - Scroll)))
End Sub
Public ReadOnly Property SelectedItem() As String
Get
Return Items(Me.Index)
End Get
End Property
End Class
End Namespace