diff --git a/P3D/Screens/Pokedex/PokedexScreen.vb b/P3D/Screens/Pokedex/PokedexScreen.vb index adf7860cd..9c3731ed4 100644 --- a/P3D/Screens/Pokedex/PokedexScreen.vb +++ b/P3D/Screens/Pokedex/PokedexScreen.vb @@ -316,977 +316,986 @@ Public Class PokedexScreen Public Shared TileOffset As Integer = 0 - Public Enum OrderType - Numeric - Weigth - Height - Alphabetically - End Enum - - Public Enum FilterType - Type1 - Type2 - Name - End Enum - - Structure Filter - Public FilterType As FilterType - Public FilterValue As String - End Structure - - Dim texture As Texture2D - - Public ReverseOrder As Boolean = False - Public Order As OrderType = OrderType.Numeric - - Public Filters As New List(Of Filter) - Public Profile As PokedexSelectScreen.PokedexProfile - Public CHabitat As Habitat = Nothing - - Dim Scroll As Integer = 0 - Dim Cursor As New Vector2(0) - - Shared TempPokemonStorage As New Dictionary(Of Integer, Pokemon) - Shared TempPokemonDexType As New Dictionary(Of Integer, Integer) - - Dim PokemonList As New List(Of Pokemon) - Dim menu As SelectMenu - - Public Sub New(ByVal currentScreen As Screen, ByVal Profile As PokedexSelectScreen.PokedexProfile, ByVal Habitat As Habitat) - Me.Identification = Identifications.PokedexScreen - Me.PreScreen = currentScreen - - Me.texture = TextureManager.GetTexture("GUI\Menus\General") - Me.Profile = Profile - Me.CHabitat = Habitat - - Me.MouseVisible = True - Me.CanMuteAudio = True - Me.CanBePaused = True - - TempPokemonStorage.Clear() - TempPokemonDexType.Clear() - - SetList() - - Me.menu = New SelectMenu({""}.ToList(), 0, Nothing, 0) - Me.menu.Visible = False - End Sub - - Private Sub SetList() - PokemonList.Clear() - TempPokemonStorage.Clear() - TempPokemonDexType.Clear() - - Dim neededEntryType As Integer = 0 - Select Case Me.Order - Case OrderType.Alphabetically - neededEntryType = 1 - Case OrderType.Height, OrderType.Weigth - neededEntryType = 2 - End Select - - For Each f As Filter In Me.Filters - Dim thisType As Integer = 0 - If f.FilterType = FilterType.Name Then - thisType = 1 - Else - thisType = 2 - End If - If thisType > neededEntryType Then - neededEntryType = thisType - End If - Next - - Dim pokeSearchList As New List(Of String) - - If CHabitat Is Nothing Then - ' Add any external Pokémon if specified to do so: - If Profile.Pokedex.IncludeExternalPokemon = True Then - If Pokedex.PokemonMaxCount > 0 Then - For i = 1 To Pokedex.PokemonMaxCount - If Me.Profile.Pokedex.HasPokemon(i.ToString, False) = False Then - If Pokedex.GetEntryType(Core.Player.PokedexData, i.ToString) > 0 Then - Profile.Pokedex.PokemonList.Add(Profile.Pokedex.PokemonList.Count + 1, i.ToString) - End If - End If - Next - End If - End If - For Each i As String In Profile.Pokedex.PokemonList.Values - pokeSearchList.Add(i) - Next + Public Enum OrderType + Numeric + Weigth + Height + Alphabetically + End Enum + + Public Enum FilterType + Type1 + Type2 + Name + End Enum + + Structure Filter + Public FilterType As FilterType + Public FilterValue As String + End Structure + + Dim texture As Texture2D + + Public ReverseOrder As Boolean = False + Public Order As OrderType = OrderType.Numeric + + Public Filters As New List(Of Filter) + Public Profile As PokedexSelectScreen.PokedexProfile + Public CHabitat As Habitat = Nothing + + Dim Scroll As Integer = 0 + Dim Cursor As New Vector2(0) + + Public Shared TempPokemonStorage As New Dictionary(Of Integer, Pokemon) + Shared TempPokemonDexType As New Dictionary(Of Integer, Integer) + + Dim PokemonList As New List(Of Pokemon) + Dim menu As SelectMenu + + Public Sub New(ByVal currentScreen As Screen, ByVal Profile As PokedexSelectScreen.PokedexProfile, ByVal Habitat As Habitat) + Me.Identification = Identifications.PokedexScreen + Me.PreScreen = currentScreen + + Me.texture = TextureManager.GetTexture("GUI\Menus\General") + Me.Profile = Profile + Me.CHabitat = Habitat + + Me.MouseVisible = True + Me.CanMuteAudio = True + Me.CanBePaused = True + + TempPokemonStorage.Clear() + TempPokemonDexType.Clear() + + SetList() + + Me.menu = New SelectMenu({""}.ToList(), 0, Nothing, 0) + Me.menu.Visible = False + End Sub + + Private Sub SetList() + PokemonList.Clear() + TempPokemonStorage.Clear() + TempPokemonDexType.Clear() + + Dim neededEntryType As Integer = 0 + Select Case Me.Order + Case OrderType.Alphabetically + neededEntryType = 1 + Case OrderType.Height, OrderType.Weigth + neededEntryType = 2 + End Select + + For Each f As Filter In Me.Filters + Dim thisType As Integer = 0 + If f.FilterType = FilterType.Name Then + thisType = 1 Else - For Each i As String In CHabitat.PokemonList - pokeSearchList.Add(i) - Next + thisType = 2 End If - - For i = 0 To pokeSearchList.Count - 1 - If Pokemon.PokemonDataExists(pokeSearchList(i).GetSplit(0, "_")) = True OrElse Pokemon.PokemonDataExists(pokeSearchList(i).GetSplit(0, ";")) = True Then - - Dim pID As Integer - Dim pAD As String = "" - - If pokeSearchList(i).Contains(";") Then - pID = CInt(pokeSearchList(i).GetSplit(0, ";")) - pAD = pokeSearchList(i).GetSplit(1, ";") - ElseIf pokeSearchList(i).Contains("_") Then - Dim additionalValue As String = PokemonForms.GetAdditionalValueFromDataFile(pokeSearchList(i)) - pID = CInt(pokeSearchList(i).GetSplit(0, "_")) - If additionalValue <> "" Then - pAD = additionalValue + If thisType > neededEntryType Then + neededEntryType = thisType + End If + Next + + Dim pokeSearchList As New List(Of String) + + If CHabitat Is Nothing Then + ' Add any external Pokémon if specified to do so: + If Profile.Pokedex.IncludeExternalPokemon = True Then + If Pokedex.PokemonMaxCount > 0 Then + For i = 1 To Pokedex.PokemonMaxCount + If Me.Profile.Pokedex.HasPokemon(i.ToString, False) = False Then + If Pokedex.GetEntryType(Core.Player.PokedexData, i.ToString) > 0 Then + Profile.Pokedex.PokemonList.Add(Profile.Pokedex.PokemonList.Count + 1, i.ToString) + End If End If - Else - pID = CInt(pokeSearchList(i)) + Next + End If + End If + For Each i As String In Profile.Pokedex.PokemonList.Values + pokeSearchList.Add(i) + Next + Else + For Each i As String In CHabitat.PokemonList + pokeSearchList.Add(i) + Next + End If + + For i = 0 To pokeSearchList.Count - 1 + If Pokemon.PokemonDataExists(pokeSearchList(i).GetSplit(0, "_")) = True OrElse Pokemon.PokemonDataExists(pokeSearchList(i).GetSplit(0, ";")) = True Then + + Dim pID As Integer + Dim pAD As String = "" + + If pokeSearchList(i).Contains(";") Then + pID = CInt(pokeSearchList(i).GetSplit(0, ";")) + pAD = pokeSearchList(i).GetSplit(1, ";") + ElseIf pokeSearchList(i).Contains("_") Then + Dim additionalValue As String = PokemonForms.GetAdditionalValueFromDataFile(pokeSearchList(i)) + pID = CInt(pokeSearchList(i).GetSplit(0, "_")) + If additionalValue <> "" Then + pAD = additionalValue End If - - Dim p As Pokemon - If pAD <> "" Then - p = Pokemon.GetPokemonByID(pID, pAD) - Else - p = Pokemon.GetPokemonByID(pID, pAD, True) - End If - - - If Pokedex.GetEntryType(Core.Player.PokedexData, pokeSearchList(i)) >= neededEntryType Then - - Dim valid As Boolean = True - For Each F As Filter In Me.Filters - Select Case F.FilterType - Case FilterType.Name - If p.GetName().ToUpper().StartsWith(F.FilterValue.ToUpper()) = False Then - valid = False - Exit For - End If - Case FilterType.Type1 - If p.Type1.Type <> New Element(F.FilterValue).Type Then - valid = False - Exit For - End If - Case FilterType.Type2 - If p.Type2.Type <> New Element(F.FilterValue).Type Then - valid = False - Exit For - End If - End Select - Next - - If valid = True Then - + Else + pID = CInt(pokeSearchList(i)) + End If + + Dim p As Pokemon + If pAD <> "" Then + p = Pokemon.GetPokemonByID(pID, pAD) + Else + p = Pokemon.GetPokemonByID(pID, pAD, True) + End If + + + If Pokedex.GetEntryType(Core.Player.PokedexData, pokeSearchList(i)) >= neededEntryType Then + + Dim valid As Boolean = True + For Each F As Filter In Me.Filters + Select Case F.FilterType + Case FilterType.Name + If p.GetName().ToUpper().StartsWith(F.FilterValue.ToUpper()) = False Then + valid = False + Exit For + End If + Case FilterType.Type1 + If p.Type1.Type <> New Element(F.FilterValue).Type Then + valid = False + Exit For + End If + Case FilterType.Type2 + If p.Type2.Type <> New Element(F.FilterValue).Type Then + valid = False + Exit For + End If + End Select + Next + + If valid = True Then + If Profile.Pokedex IsNot Nothing Then If Profile.Pokedex.GetPlace(pokeSearchList(i)) <> -1 Then Me.PokemonList.Add(p) End If - End If - End If - End If - Next - - Select Case Me.Order - Case OrderType.Numeric - If CHabitat Is Nothing Then - If Me.ReverseOrder = True Then - Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By Profile.Pokedex.GetPlace(PokemonForms.GetPokemonDataFileName(p.Number, p.AdditionalData, True)) Descending).ToList() Else - Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By Profile.Pokedex.GetPlace(PokemonForms.GetPokemonDataFileName(p.Number, p.AdditionalData, True)) Ascending).ToList() + Me.PokemonList.Add(p) End If + End If + End If + End If + Next + + Select Case Me.Order + Case OrderType.Numeric + If CHabitat Is Nothing Then + If Me.ReverseOrder = True Then + Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By Profile.Pokedex.GetPlace(PokemonForms.GetPokemonDataFileName(p.Number, p.AdditionalData, True)) Descending).ToList() Else - If Me.ReverseOrder = True Then - Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By PokemonForms.GetPokemonDataFileName(p.Number, p.AdditionalData, True) Descending).ToList() + Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By Profile.Pokedex.GetPlace(PokemonForms.GetPokemonDataFileName(p.Number, p.AdditionalData, True)) Ascending).ToList() + End If + Else + If Me.ReverseOrder = True Then + Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By PokemonForms.GetPokemonDataFileName(p.Number, p.AdditionalData, True) Descending).ToList() + Else + Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By PokemonForms.GetPokemonDataFileName(p.Number, p.AdditionalData, True) Ascending).ToList() + End If + End If + Case OrderType.Alphabetically + If Me.ReverseOrder = True Then + Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By p.GetName() Descending).ToList() + Else + Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By p.GetName() Ascending).ToList() + End If + Case OrderType.Weigth + If Me.ReverseOrder = True Then + Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By p.PokedexEntry.Weight Descending).ToList() + Else + Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By p.PokedexEntry.Weight Ascending).ToList() + End If + Case OrderType.Height + If Me.ReverseOrder = True Then + Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By p.PokedexEntry.Height Descending).ToList() + Else + Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By p.PokedexEntry.Height Ascending).ToList() + End If + End Select + + Me.ClampCursor() + End Sub + + Public Overrides Sub Draw() + Canvas.DrawRectangle(Core.windowSize, New Color(84, 198, 216)) + + For y = -64 To Core.windowSize.Height Step 64 + Core.SpriteBatch.Draw(Me.texture, New Rectangle(Core.windowSize.Width - 128, y + TileOffset, 128, 64), New Rectangle(48, 0, 16, 16), Color.White) + Next + + Canvas.DrawGradient(New Rectangle(0, 0, CInt(Core.windowSize.Width), 200), New Color(42, 167, 198), New Color(42, 167, 198, 0), False, -1) + Canvas.DrawGradient(New Rectangle(0, CInt(Core.windowSize.Height - 200), CInt(Core.windowSize.Width), 200), New Color(42, 167, 198, 0), New Color(42, 167, 198), False, -1) + + Canvas.DrawRectangle(New Rectangle(50, 30, 564, 90), New Color(42, 167, 198, 150)) + + If CHabitat Is Nothing Then + Core.SpriteBatch.DrawString(FontManager.MainFont, Profile.Pokedex.Name, New Vector2(60, 55), Color.White, 0.0F, Vector2.Zero, 1.5F, SpriteEffects.None, 0.0F) + Core.SpriteBatch.DrawString(FontManager.MainFont, "Seen: " & Environment.NewLine & Environment.NewLine & "Obtained: ", New Vector2(420, 45), Color.White) + Core.SpriteBatch.DrawString(FontManager.MainFont, Profile.Seen + Profile.Obtained & Environment.NewLine & Environment.NewLine & Profile.Obtained, New Vector2(540, 45), Color.Black) + Else + Core.SpriteBatch.DrawString(FontManager.MainFont, CHabitat.Name, New Vector2(60, 80), Color.White, 0.0F, Vector2.Zero, 1.5F, SpriteEffects.None, 0.0F) + Core.SpriteBatch.Draw(CHabitat.Texture, New Rectangle(60, 32, 64, 48), Color.White) + Core.SpriteBatch.DrawString(FontManager.MainFont, "Available: " & Environment.NewLine & Environment.NewLine & "Obtained: ", New Vector2(420, 45), Color.White) + Core.SpriteBatch.DrawString(FontManager.MainFont, CHabitat.PokemonList.Count & Environment.NewLine & Environment.NewLine & CHabitat.PokemonCaught, New Vector2(540, 45), Color.Black) + + Dim progressTexture As Texture2D = Me.CHabitat.ProgressTexture + If Not progressTexture Is Nothing Then + Core.SpriteBatch.Draw(progressTexture, New Rectangle(134, 46, 20, 20), Color.White) + End If + End If + + If PokemonList.Count > 0 Then + For x = 0 To 5 + For y = 0 To 4 + Dim id As Integer = (y + Scroll) * 6 + x + + If id <= Me.PokemonList.Count - 1 Then + Dim dexID As String = PokemonForms.GetPokemonDataFileName(Me.PokemonList(id).Number, Me.PokemonList(id).AdditionalData) + If dexID.Contains("_") = False Then + If PokemonForms.GetAdditionalDataForms(Me.PokemonList(id).Number) IsNot Nothing AndAlso PokemonForms.GetAdditionalDataForms(Me.PokemonList(id).Number).Contains(Me.PokemonList(id).AdditionalData) Then + dexID = Me.PokemonList(id).Number & ";" & Me.PokemonList(id).AdditionalData + Else + dexID = Me.PokemonList(id).Number.ToString + End If + End If + + If Not CHabitat Is Nothing OrElse Me.Profile.Pokedex.OriginalCount >= Profile.Pokedex.GetPlace(dexID) Then + Canvas.DrawRectangle(New Rectangle(50 + x * 100, 140 + y * 100, 64, 92), New Color(42, 167, 198, 150)) Else - Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By PokemonForms.GetPokemonDataFileName(p.Number, p.AdditionalData, True) Ascending).ToList() + Canvas.DrawBorder(3, New Rectangle(50 + x * 100, 140 + y * 100, 64, 92), New Color(42, 167, 198, 150)) End If - End If - Case OrderType.Alphabetically - If Me.ReverseOrder = True Then - Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By p.GetName() Descending).ToList() - Else - Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By p.GetName() Ascending).ToList() - End If - Case OrderType.Weigth - If Me.ReverseOrder = True Then - Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By p.PokedexEntry.Weight Descending).ToList() - Else - Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By p.PokedexEntry.Weight Ascending).ToList() - End If - Case OrderType.Height - If Me.ReverseOrder = True Then - Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By p.PokedexEntry.Height Descending).ToList() - Else - Me.PokemonList = (From p As Pokemon In Me.PokemonList Order By p.PokedexEntry.Height Ascending).ToList() - End If - End Select - - Me.ClampCursor() - End Sub - - Public Overrides Sub Draw() - Canvas.DrawRectangle(Core.windowSize, New Color(84, 198, 216)) - - For y = -64 To Core.windowSize.Height Step 64 - Core.SpriteBatch.Draw(Me.texture, New Rectangle(Core.windowSize.Width - 128, y + TileOffset, 128, 64), New Rectangle(48, 0, 16, 16), Color.White) - Next - - Canvas.DrawGradient(New Rectangle(0, 0, CInt(Core.windowSize.Width), 200), New Color(42, 167, 198), New Color(42, 167, 198, 0), False, -1) - Canvas.DrawGradient(New Rectangle(0, CInt(Core.windowSize.Height - 200), CInt(Core.windowSize.Width), 200), New Color(42, 167, 198, 0), New Color(42, 167, 198), False, -1) - - Canvas.DrawRectangle(New Rectangle(50, 30, 564, 90), New Color(42, 167, 198, 150)) - - If CHabitat Is Nothing Then - Core.SpriteBatch.DrawString(FontManager.MainFont, Profile.Pokedex.Name, New Vector2(60, 55), Color.White, 0.0F, Vector2.Zero, 1.5F, SpriteEffects.None, 0.0F) - Core.SpriteBatch.DrawString(FontManager.MainFont, "Seen: " & Environment.NewLine & Environment.NewLine & "Obtained: ", New Vector2(420, 45), Color.White) - Core.SpriteBatch.DrawString(FontManager.MainFont, Profile.Seen + Profile.Obtained & Environment.NewLine & Environment.NewLine & Profile.Obtained, New Vector2(540, 45), Color.Black) - Else - Core.SpriteBatch.DrawString(FontManager.MainFont, CHabitat.Name, New Vector2(60, 80), Color.White, 0.0F, Vector2.Zero, 1.5F, SpriteEffects.None, 0.0F) - Core.SpriteBatch.Draw(CHabitat.Texture, New Rectangle(60, 32, 64, 48), Color.White) - Core.SpriteBatch.DrawString(FontManager.MainFont, "Available: " & Environment.NewLine & Environment.NewLine & "Obtained: ", New Vector2(420, 45), Color.White) - Core.SpriteBatch.DrawString(FontManager.MainFont, CHabitat.PokemonList.Count & Environment.NewLine & Environment.NewLine & CHabitat.PokemonCaught, New Vector2(540, 45), Color.Black) - - Dim progressTexture As Texture2D = Me.CHabitat.ProgressTexture - If Not progressTexture Is Nothing Then - Core.SpriteBatch.Draw(progressTexture, New Rectangle(134, 46, 20, 20), Color.White) - End If - End If - - If PokemonList.Count > 0 Then - For x = 0 To 5 - For y = 0 To 4 - Dim id As Integer = (y + Scroll) * 6 + x - - If id <= Me.PokemonList.Count - 1 Then - Dim dexID As String = PokemonForms.GetPokemonDataFileName(Me.PokemonList(id).Number, Me.PokemonList(id).AdditionalData) - If dexID.Contains("_") = False Then - If PokemonForms.GetAdditionalDataForms(Me.PokemonList(id).Number) IsNot Nothing AndAlso PokemonForms.GetAdditionalDataForms(Me.PokemonList(id).Number).Contains(Me.PokemonList(id).AdditionalData) Then - dexID = Me.PokemonList(id).Number & ";" & Me.PokemonList(id).AdditionalData - Else - dexID = Me.PokemonList(id).Number.ToString - End If - End If - - If Not CHabitat Is Nothing OrElse Me.Profile.Pokedex.OriginalCount >= Profile.Pokedex.GetPlace(dexID) Then - Canvas.DrawRectangle(New Rectangle(50 + x * 100, 140 + y * 100, 64, 92), New Color(42, 167, 198, 150)) - Else - Canvas.DrawBorder(3, New Rectangle(50 + x * 100, 140 + y * 100, 64, 92), New Color(42, 167, 198, 150)) - End If - - Dim p As Pokemon = Nothing - Dim entryType As Integer = 0 - - If TempPokemonStorage.ContainsKey(id + 1) = False Then - TempPokemonStorage.Add(id + 1, Me.PokemonList(id)) - TempPokemonDexType.Add(id + 1, Pokedex.GetEntryType(Core.Player.PokedexData, dexID)) - End If - p = TempPokemonStorage(id + 1) - entryType = TempPokemonDexType(id + 1) - - If Cursor = New Vector2(x, y) Then - DrawPokemonPreview(p) - End If - - Dim c As Color = Color.Gray - If entryType > 0 Then - If entryType > 1 Then - c = Color.White - End If - Dim pokeTexture = p.GetMenuTexture() - Dim pokeTextureScale As Vector2 = New Vector2(CSng(32 / pokeTexture.Width * 2), CSng(32 / pokeTexture.Height * 2)) - Core.SpriteBatch.Draw(pokeTexture, New Rectangle(50 + x * 100, 140 + y * 100, CInt(pokeTexture.Width * pokeTextureScale.X), CInt(pokeTexture.Height * pokeTextureScale.Y)), c) - End If - - Dim no As String = "000" - - If CHabitat Is Nothing Then - no = Profile.Pokedex.GetPlace(dexID).ToString() - Else - no = p.Number.ToString() - End If - While no.Length < 3 - no = "0" & no - End While - Core.SpriteBatch.DrawString(FontManager.MainFont, no, New Vector2(50 + x * 100 + CInt(32 - FontManager.MainFont.MeasureString(no).X / 2), 206 + y * 100), Color.White) + + Dim p As Pokemon = Nothing + Dim entryType As Integer = 0 + + If TempPokemonStorage.ContainsKey(id + 1) = False Then + TempPokemonStorage.Add(id + 1, Me.PokemonList(id)) + TempPokemonDexType.Add(id + 1, Pokedex.GetEntryType(Core.Player.PokedexData, dexID)) End If - Next - Next - Else - Canvas.DrawGradient(New Rectangle(50, 300, 80, 90), New Color(84, 198, 216), New Color(42, 167, 198, 150), True, -1) - Canvas.DrawRectangle(New Rectangle(130, 300, 404, 90), New Color(42, 167, 198, 150)) - Canvas.DrawGradient(New Rectangle(534, 300, 80, 90), New Color(42, 167, 198, 150), New Color(84, 198, 216), True, -1) - - Core.SpriteBatch.DrawString(FontManager.MainFont, "No search results.", New Vector2(50 + CInt(564 / 2) - CInt(FontManager.MainFont.MeasureString("No search results.").X / 2), 330), Color.White) - End If - - Canvas.DrawRectangle(New Rectangle(670, 30, 480, 90), New Color(42, 167, 198, 150)) - Dim orderText As String = "Numeric" - Select Case Me.Order - Case OrderType.Alphabetically - orderText = "A-Z" - Case OrderType.Height - orderText = "Height" - Case OrderType.Weigth - orderText = "Weight" - End Select - Dim filterText As String = "None" - If Filters.Count > 0 Then - filterText = "" - For Each f As Filter In Me.Filters - If filterText <> "" Then - filterText &= ", " - End If - Select Case f.FilterType - Case FilterType.Name - filterText &= "Name" - Case FilterType.Type1 - filterText &= "Type 1" - Case FilterType.Type2 - filterText &= "Type 2" - End Select - Next - End If - Core.SpriteBatch.DrawString(FontManager.MainFont, "Order:" & Environment.NewLine & "Filter:" & Environment.NewLine & "Press " & KeyBindings.SpecialKey.ToString & " on the keyboard to search.", New Vector2(685, 45), Color.White) - Core.SpriteBatch.DrawString(FontManager.MainFont, orderText & Environment.NewLine & filterText, New Vector2(790, 45), Color.Black) - - If menu.Visible = True Then - menu.Draw() - Else - If PokemonList.Count > 0 Then - DrawCursor() - End If - End If - End Sub - - Private Function GetPlace(ByVal PokemonNumber As Integer) As Integer - For i = 0 To PokemonList.Count - 1 - If PokemonList(i).Number = PokemonNumber Then - Return i + 1 - End If - Next - - Return -1 - End Function - - Private Sub DrawPokemonPreview(ByVal p As Pokemon) - Dim dexID As String = PokemonForms.GetPokemonDataFileName(p.Number, p.AdditionalData) - If dexID.Contains("_") = False Then - If PokemonForms.GetAdditionalDataForms(p.Number) IsNot Nothing AndAlso PokemonForms.GetAdditionalDataForms(p.Number).Contains(p.AdditionalData) Then - dexID = p.Number & ";" & p.AdditionalData - Else - dexID = p.Number.ToString - End If - End If - - Dim entryType As Integer = Pokedex.GetEntryType(Core.Player.PokedexData, dexID) - - For i = 0 To 4 - Canvas.DrawGradient(New Rectangle(650, 300 + i * 40, 50, 2), New Color(255, 255, 255, 10), New Color(255, 255, 255, 255), True, -1) - Canvas.DrawRectangle(New Rectangle(700, 300 + i * 40, 350, 2), Color.White) - Canvas.DrawGradient(New Rectangle(1050, 300 + i * 40, 50, 2), New Color(255, 255, 255, 255), New Color(255, 255, 255, 10), True, -1) - Next - - Dim no As String = "000" - If CHabitat Is Nothing Then - no = Profile.Pokedex.GetPlace(dexID).ToString() - Else - no = p.Number.ToString() - End If - While no.Length < 3 - no = "0" & no - End While - - If entryType = 0 Then - Core.SpriteBatch.DrawString(FontManager.MainFont, "???" & Environment.NewLine & Environment.NewLine & "No. " & no, New Vector2(864, 200), Color.White) - Else - Core.SpriteBatch.DrawString(FontManager.MainFont, p.GetName() & Environment.NewLine & Environment.NewLine & "No. " & no, New Vector2(864, 200), Color.White) - Core.SpriteBatch.Draw(p.GetTexture(True), New Rectangle(CInt(680 - p.GetTexture(True).Width / 4), CInt(140 - p.GetTexture(True).Height / 4), MathHelper.Min(CInt(p.GetTexture(True).Width * 2), 256), MathHelper.Min(CInt(p.GetTexture(True).Height * 2), 256)), Color.White) - - Core.SpriteBatch.DrawString(FontManager.MainFont, "SPECIES", New Vector2(680, 310), Color.Black) - Core.SpriteBatch.DrawString(FontManager.MainFont, "TYPE", New Vector2(680, 350), Color.Black) - Core.SpriteBatch.DrawString(FontManager.MainFont, "HEIGHT", New Vector2(680, 390), Color.Black) - Core.SpriteBatch.DrawString(FontManager.MainFont, "WEIGHT", New Vector2(680, 430), Color.Black) - - Canvas.DrawRectangle(New Rectangle(670, 480, 480, 152), New Color(42, 167, 198, 150)) - - If Not CHabitat Is Nothing Then - Dim encounterTypes As New List(Of Integer) - For Each ec As PokedexScreen.Habitat.EncounterPokemon In CHabitat.ObtainTypeList - If ec.PokemonID = PokemonForms.GetPokemonDataFileName(p.Number, p.AdditionalData) Then - If encounterTypes.Contains(ec.EncounterType) = False Then - encounterTypes.Add(ec.EncounterType) - End If + p = TempPokemonStorage(id + 1) + entryType = TempPokemonDexType(id + 1) + + If Cursor = New Vector2(x, y) Then + DrawPokemonPreview(p) End If - Next - For i = 0 To encounterTypes.Count - 1 - Dim encounterType As Integer = encounterTypes(i) - Core.SpriteBatch.Draw(PokedexScreen.Habitat.GetEncounterTypeImage(encounterType), New Rectangle(824 + i * 32, 266, 32, 32), Color.White) - Next - End If - - If entryType > 1 Then - Core.SpriteBatch.DrawString(FontManager.MainFont, p.PokedexEntry.Species, New Vector2(850, 310), Color.Black) - Core.SpriteBatch.DrawString(FontManager.MainFont, "", New Vector2(850, 350), Color.Black) - Core.SpriteBatch.DrawString(FontManager.MainFont, p.PokedexEntry.Height & " m", New Vector2(850, 390), Color.Black) - Core.SpriteBatch.DrawString(FontManager.MainFont, p.PokedexEntry.Weight & " kg", New Vector2(850, 430), Color.Black) - - Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\Types"), New Rectangle(850, 356, 48, 16), p.Type1.GetElementImage(), Color.White) - If p.Type2.Type <> Element.Types.Blank Then - Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\Types"), New Rectangle(900, 356, 48, 16), p.Type2.GetElementImage(), Color.White) - End If - - Core.SpriteBatch.DrawString(FontManager.MainFont, p.PokedexEntry.Text.CropStringToWidth(FontManager.MainFont, 448), New Vector2(688, 490), Color.Black) - - Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\pokedexhabitat", New Rectangle(160, 160, 10, 10), ""), New Rectangle(992, 242, 20, 20), Color.White) - Else - Core.SpriteBatch.DrawString(FontManager.MainFont, "??? Pokémon", New Vector2(850, 310), Color.Black) - Core.SpriteBatch.DrawString(FontManager.MainFont, "???", New Vector2(850, 350), Color.Black) - Core.SpriteBatch.DrawString(FontManager.MainFont, "??? m", New Vector2(850, 390), Color.Black) - Core.SpriteBatch.DrawString(FontManager.MainFont, "??? kg", New Vector2(850, 430), Color.Black) - - Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\pokedexhabitat", New Rectangle(160, 170, 10, 10), ""), New Rectangle(992, 242, 20, 20), Color.White) - End If - End If - End Sub - - Private Sub DrawCursor() - Dim cPosition As Vector2 = New Vector2(50 + Me.Cursor.X * 100 + 42, 140 + Me.Cursor.Y * 100 - 42) - - 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 - - Public Overrides Sub Update() - If menu.Visible = True Then - menu.Update() - Else - If Controls.Left(True, True, False, True, True, True) = True Then - Me.Cursor.X -= 1 - End If - If Controls.Right(True, True, False, True, True, True) = True Then - Me.Cursor.X += 1 - End If - If Controls.Up(True, True, True, True, True, True) = True Then - Me.Cursor.Y -= 1 - If Controls.ShiftDown() = True Then - Me.Cursor.Y -= 4 - End If - End If - If Controls.Down(True, True, True, True, True, True) = True Then - Me.Cursor.Y += 1 - If Controls.ShiftDown() = True Then - Me.Cursor.Y += 4 - End If - End If - - If Cursor.X > 5 Then - Cursor.X = 0 - Cursor.Y += 1 - End If - If Cursor.X < 0 Then - Cursor.X = 5 - Cursor.Y -= 1 - End If - - While Cursor.Y < 0 - Me.Cursor.Y += 1 - Me.Scroll -= 1 - End While - While Cursor.Y > 4 - Me.Cursor.Y -= 1 - Me.Scroll += 1 - End While - - If Controls.Accept(True, False, False) = True Then - For i = 0 To 29 - Dim x As Integer = i - Dim y As Integer = 0 - While x > 5 - x -= 6 - y += 1 + + Dim c As Color = Color.Gray + If entryType > 0 Then + If entryType > 1 Then + c = Color.White + End If + Dim pokeTexture = p.GetMenuTexture() + Dim pokeTextureScale As Vector2 = New Vector2(CSng(32 / pokeTexture.Width * 2), CSng(32 / pokeTexture.Height * 2)) + Core.SpriteBatch.Draw(pokeTexture, New Rectangle(50 + x * 100, 140 + y * 100, CInt(pokeTexture.Width * pokeTextureScale.X), CInt(pokeTexture.Height * pokeTextureScale.Y)), c) + End If + + Dim no As String = "000" + + If CHabitat Is Nothing Then + no = Profile.Pokedex.GetPlace(dexID).ToString() + Else + no = p.Number.ToString() + End If + While no.Length < 3 + no = "0" & no End While - - If New Rectangle(50 + x * 100, 140 + y * 100, 64, 92).Contains(MouseHandler.MousePosition) = True Then - If Cursor.X + Cursor.Y * 6 = i Then - If TempPokemonDexType(CInt((Cursor.Y + Scroll) * 6 + Cursor.X + 1)) > 0 Then - SoundManager.PlaySound("select") - Core.SetScreen(New PokedexViewScreen(Me, TempPokemonStorage(CInt((Cursor.Y + Scroll) * 6 + Cursor.X + 1)), False)) - End If - Else - Cursor.X = x - Cursor.Y = y - End If - End If - Next - End If - - ClampCursor() - - If Controls.Accept(False, True, True) = True Then - If TempPokemonDexType(CInt((Cursor.Y + Scroll) * 6 + Cursor.X + 1)) > 0 Then - SoundManager.PlaySound("select") - Core.SetScreen(New PokedexViewScreen(Me, TempPokemonStorage(CInt((Cursor.Y + Scroll) * 6 + Cursor.X + 1)), False)) - End If - End If - - If KeyBoardHandler.KeyPressed(KeyBindings.SpecialKey) = True Or ControllerHandler.ButtonPressed(Buttons.Y) = True Then - Me.menu = New SelectMenu({"Order", "Filter", "Reset", "Back"}.ToList(), 0, AddressOf SelectMenu1, 3) - End If - - If Controls.Dismiss(True, True, True) = True Then - If Me.Filters.Count > 0 Or Me.Order <> OrderType.Numeric Or Me.ReverseOrder = True Then - SoundManager.PlaySound("select") - Me.Filters.Clear() - Me.ReverseOrder = False - Me.Order = OrderType.Numeric - Me.SetList() - Else - SoundManager.PlaySound("select") - Core.SetScreen(Me.PreScreen) + Core.SpriteBatch.DrawString(FontManager.MainFont, no, New Vector2(50 + x * 100 + CInt(32 - FontManager.MainFont.MeasureString(no).X / 2), 206 + y * 100), Color.White) End If + Next + Next + Else + Canvas.DrawGradient(New Rectangle(50, 300, 80, 90), New Color(84, 198, 216), New Color(42, 167, 198, 150), True, -1) + Canvas.DrawRectangle(New Rectangle(130, 300, 404, 90), New Color(42, 167, 198, 150)) + Canvas.DrawGradient(New Rectangle(534, 300, 80, 90), New Color(42, 167, 198, 150), New Color(84, 198, 216), True, -1) + + Core.SpriteBatch.DrawString(FontManager.MainFont, "No search results.", New Vector2(50 + CInt(564 / 2) - CInt(FontManager.MainFont.MeasureString("No search results.").X / 2), 330), Color.White) + End If + + Canvas.DrawRectangle(New Rectangle(670, 30, 480, 90), New Color(42, 167, 198, 150)) + Dim orderText As String = "Numeric" + Select Case Me.Order + Case OrderType.Alphabetically + orderText = "A-Z" + Case OrderType.Height + orderText = "Height" + Case OrderType.Weigth + orderText = "Weight" + End Select + Dim filterText As String = "None" + If Filters.Count > 0 Then + filterText = "" + For Each f As Filter In Me.Filters + If filterText <> "" Then + filterText &= ", " End If + Select Case f.FilterType + Case FilterType.Name + filterText &= "Name" + Case FilterType.Type1 + filterText &= "Type 1" + Case FilterType.Type2 + filterText &= "Type 2" + End Select + Next + End If + Core.SpriteBatch.DrawString(FontManager.MainFont, "Order:" & Environment.NewLine & "Filter:" & Environment.NewLine & "Press " & KeyBindings.SpecialKey.ToString & " on the keyboard to search.", New Vector2(685, 45), Color.White) + Core.SpriteBatch.DrawString(FontManager.MainFont, orderText & Environment.NewLine & filterText, New Vector2(790, 45), Color.Black) + + If menu.Visible = True Then + menu.Draw() + Else + If PokemonList.Count > 0 Then + DrawCursor() End If - - TileOffset += 1 - If TileOffset >= 64 Then - TileOffset = 0 + End If + End Sub + + Private Function GetPlace(ByVal PokemonNumber As Integer) As Integer + For i = 0 To PokemonList.Count - 1 + If PokemonList(i).Number = PokemonNumber Then + Return i + 1 End If - End Sub - - Private Sub ClampCursor() - Dim linesCount As Integer = CInt(Math.Ceiling(Me.PokemonList.Count / 6)) - - If linesCount < 6 Then - Me.Scroll = 0 + Next + + Return -1 + End Function + + Private Sub DrawPokemonPreview(ByVal p As Pokemon) + Dim dexID As String = PokemonForms.GetPokemonDataFileName(p.Number, p.AdditionalData) + If dexID.Contains("_") = False Then + If PokemonForms.GetAdditionalDataForms(p.Number) IsNot Nothing AndAlso PokemonForms.GetAdditionalDataForms(p.Number).Contains(p.AdditionalData) Then + dexID = p.Number & ";" & p.AdditionalData Else - Me.Scroll = Me.Scroll.Clamp(0, linesCount - 5) + dexID = p.Number.ToString End If - - Dim maxY As Integer = linesCount - Scroll - 1 - Me.Cursor.Y = Me.Cursor.Y.Clamp(0, maxY) - - If Me.Cursor.Y = maxY Then - Dim maxX As Integer = Me.PokemonList.Count - While maxX > 6 - maxX -= 6 - End While - Me.Cursor.X = Me.Cursor.X.Clamp(0, maxX - 1) + End If + + Dim entryType As Integer = Pokedex.GetEntryType(Core.Player.PokedexData, dexID) + + For i = 0 To 4 + Canvas.DrawGradient(New Rectangle(650, 300 + i * 40, 50, 2), New Color(255, 255, 255, 10), New Color(255, 255, 255, 255), True, -1) + Canvas.DrawRectangle(New Rectangle(700, 300 + i * 40, 350, 2), Color.White) + Canvas.DrawGradient(New Rectangle(1050, 300 + i * 40, 50, 2), New Color(255, 255, 255, 255), New Color(255, 255, 255, 10), True, -1) + Next + + Dim no As String = "000" + If CHabitat Is Nothing Then + no = Profile.Pokedex.GetPlace(dexID).ToString() + Else + no = p.Number.ToString() + End If + While no.Length < 3 + no = "0" & no + End While + + If entryType = 0 Then + Core.SpriteBatch.DrawString(FontManager.MainFont, "???" & Environment.NewLine & Environment.NewLine & "No. " & no, New Vector2(864, 200), Color.White) + Else + Core.SpriteBatch.DrawString(FontManager.MainFont, p.GetName() & Environment.NewLine & Environment.NewLine & "No. " & no, New Vector2(864, 200), Color.White) + Core.SpriteBatch.Draw(p.GetTexture(True), New Rectangle(CInt(680 - p.GetTexture(True).Width / 4), CInt(140 - p.GetTexture(True).Height / 4), MathHelper.Min(CInt(p.GetTexture(True).Width * 2), 256), MathHelper.Min(CInt(p.GetTexture(True).Height * 2), 256)), Color.White) + + Core.SpriteBatch.DrawString(FontManager.MainFont, "SPECIES", New Vector2(680, 310), Color.Black) + Core.SpriteBatch.DrawString(FontManager.MainFont, "TYPE", New Vector2(680, 350), Color.Black) + Core.SpriteBatch.DrawString(FontManager.MainFont, "HEIGHT", New Vector2(680, 390), Color.Black) + Core.SpriteBatch.DrawString(FontManager.MainFont, "WEIGHT", New Vector2(680, 430), Color.Black) + + Canvas.DrawRectangle(New Rectangle(670, 480, 480, 152), New Color(42, 167, 198, 150)) + + If Not CHabitat Is Nothing Then + Dim encounterTypes As New List(Of Integer) + For Each ec As PokedexScreen.Habitat.EncounterPokemon In CHabitat.ObtainTypeList + If ec.PokemonID = PokemonForms.GetPokemonDataFileName(p.Number, p.AdditionalData) Then + If encounterTypes.Contains(ec.EncounterType) = False Then + encounterTypes.Add(ec.EncounterType) + End If + End If + Next + For i = 0 To encounterTypes.Count - 1 + Dim encounterType As Integer = encounterTypes(i) + Core.SpriteBatch.Draw(PokedexScreen.Habitat.GetEncounterTypeImage(encounterType), New Rectangle(824 + i * 32, 266, 32, 32), Color.White) + Next End If - End Sub - - Public Overrides Sub ChangeTo() - TempPokemonDexType.Clear() - TempPokemonStorage.Clear() - End Sub - - #Region "Menus" - - Private Sub SelectMenu1(ByVal s As SelectMenu) - Select Case s.SelectedItem.ToLower() - Case "order" - Me.menu = New SelectMenu({"Type", "Reverse: " & Me.ReverseOrder.ToString(), "Back"}.ToList(), 0, AddressOf SelectMenuOrder, 2) - Case "filter" - Me.menu = New SelectMenu({"Name", "Type1", "Type2", "Clear", "Back"}.ToList(), 0, AddressOf SelectMenuFilter, 4) - Case "reset" + + If entryType > 1 Then + Core.SpriteBatch.DrawString(FontManager.MainFont, p.PokedexEntry.Species, New Vector2(850, 310), Color.Black) + Core.SpriteBatch.DrawString(FontManager.MainFont, "", New Vector2(850, 350), Color.Black) + Core.SpriteBatch.DrawString(FontManager.MainFont, p.PokedexEntry.Height & " m", New Vector2(850, 390), Color.Black) + Core.SpriteBatch.DrawString(FontManager.MainFont, p.PokedexEntry.Weight & " kg", New Vector2(850, 430), Color.Black) + + Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\Types"), New Rectangle(850, 356, 48, 16), p.Type1.GetElementImage(), Color.White) + If p.Type2.Type <> Element.Types.Blank Then + Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\Types"), New Rectangle(900, 356, 48, 16), p.Type2.GetElementImage(), Color.White) + End If + + Core.SpriteBatch.DrawString(FontManager.MainFont, p.PokedexEntry.Text.CropStringToWidth(FontManager.MainFont, 448), New Vector2(688, 490), Color.Black) + + Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\pokedexhabitat", New Rectangle(160, 160, 10, 10), ""), New Rectangle(992, 242, 20, 20), Color.White) + Else + Core.SpriteBatch.DrawString(FontManager.MainFont, "??? Pokémon", New Vector2(850, 310), Color.Black) + Core.SpriteBatch.DrawString(FontManager.MainFont, "???", New Vector2(850, 350), Color.Black) + Core.SpriteBatch.DrawString(FontManager.MainFont, "??? m", New Vector2(850, 390), Color.Black) + Core.SpriteBatch.DrawString(FontManager.MainFont, "??? kg", New Vector2(850, 430), Color.Black) + + Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\pokedexhabitat", New Rectangle(160, 170, 10, 10), ""), New Rectangle(992, 242, 20, 20), Color.White) + End If + End If + End Sub + + Private Sub DrawCursor() + Dim cPosition As Vector2 = New Vector2(50 + Me.Cursor.X * 100 + 42, 140 + Me.Cursor.Y * 100 - 42) + + 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 + + Public Overrides Sub Update() + If menu.Visible = True Then + menu.Update() + Else + If Controls.Left(True, True, False, True, True, True) = True Then + Me.Cursor.X -= 1 + End If + If Controls.Right(True, True, False, True, True, True) = True Then + Me.Cursor.X += 1 + End If + If Controls.Up(True, True, True, True, True, True) = True Then + Me.Cursor.Y -= 1 + If Controls.ShiftDown() = True Then + Me.Cursor.Y -= 4 + End If + End If + If Controls.Down(True, True, True, True, True, True) = True Then + Me.Cursor.Y += 1 + If Controls.ShiftDown() = True Then + Me.Cursor.Y += 4 + End If + End If + + If Cursor.X > 5 Then + Cursor.X = 0 + Cursor.Y += 1 + End If + If Cursor.X < 0 Then + Cursor.X = 5 + Cursor.Y -= 1 + End If + + While Cursor.Y < 0 + Me.Cursor.Y += 1 + Me.Scroll -= 1 + End While + While Cursor.Y > 4 + Me.Cursor.Y -= 1 + Me.Scroll += 1 + End While + + If Controls.Accept(True, False, False) = True Then + For i = 0 To 29 + Dim x As Integer = i + Dim y As Integer = 0 + While x > 5 + x -= 6 + y += 1 + End While + + If New Rectangle(50 + x * 100, 140 + y * 100, 64, 92).Contains(MouseHandler.MousePosition) = True Then + If Cursor.X + Cursor.Y * 6 = i Then + Dim dexIndex As Integer = CInt((Cursor.Y + Scroll) * 6 + Cursor.X + 1) + If TempPokemonDexType(dexIndex) > 0 Then + SoundManager.PlaySound("select") + + Core.SetScreen(New PokedexViewScreen(Me, TempPokemonStorage(dexIndex), False, dexIndex)) + End If + Else + Cursor.X = x + Cursor.Y = y + End If + End If + Next + End If + + ClampCursor() + + If Controls.Accept(False, True, True) = True Then + Dim dexIndex As Integer = CInt((Cursor.Y + Scroll) * 6 + Cursor.X + 1) + If TempPokemonDexType(dexIndex) > 0 Then + SoundManager.PlaySound("select") + Core.SetScreen(New PokedexViewScreen(Me, TempPokemonStorage(dexIndex), False, dexIndex)) + End If + End If + + If KeyBoardHandler.KeyPressed(KeyBindings.SpecialKey) = True Or ControllerHandler.ButtonPressed(Buttons.Y) = True Then + Me.menu = New SelectMenu({"Order", "Filter", "Reset", "Back"}.ToList(), 0, AddressOf SelectMenu1, 3) + End If + + If Controls.Dismiss(True, True, True) = True Then + If Me.Filters.Count > 0 Or Me.Order <> OrderType.Numeric Or Me.ReverseOrder = True Then + SoundManager.PlaySound("select") Me.Filters.Clear() Me.ReverseOrder = False Me.Order = OrderType.Numeric Me.SetList() - End Select + Else + SoundManager.PlaySound("select") + Core.SetScreen(Me.PreScreen) + End If + End If + End If + + TileOffset += 1 + If TileOffset >= 64 Then + TileOffset = 0 + End If + End Sub + + Private Sub ClampCursor() + Dim linesCount As Integer = CInt(Math.Ceiling(Me.PokemonList.Count / 6)) + + If linesCount < 6 Then + Me.Scroll = 0 + Else + Me.Scroll = Me.Scroll.Clamp(0, linesCount - 5) + End If + + Dim maxY As Integer = linesCount - Scroll - 1 + Me.Cursor.Y = Me.Cursor.Y.Clamp(0, maxY) + + If Me.Cursor.Y = maxY Then + Dim maxX As Integer = Me.PokemonList.Count + While maxX > 6 + maxX -= 6 + End While + Me.Cursor.X = Me.Cursor.X.Clamp(0, maxX - 1) + End If + End Sub + + Public Overrides Sub ChangeTo() + TempPokemonDexType.Clear() + TempPokemonStorage.Clear() + End Sub + +#Region "Menus" + + Private Sub SelectMenu1(ByVal s As SelectMenu) + Select Case s.SelectedItem.ToLower() + Case "order" + Me.menu = New SelectMenu({"Type", "Reverse: " & Me.ReverseOrder.ToString(), "Back"}.ToList(), 0, AddressOf SelectMenuOrder, 2) + Case "filter" + Me.menu = New SelectMenu({"Name", "Type1", "Type2", "Clear", "Back"}.ToList(), 0, AddressOf SelectMenuFilter, 4) + Case "reset" + Me.Filters.Clear() + Me.ReverseOrder = False + Me.Order = OrderType.Numeric + Me.SetList() + End Select + End Sub + + Private Sub SelectMenuFilter(ByVal s As SelectMenu) + Select Case s.SelectedItem.ToLower() + Case "name" + Me.menu = New SelectMenu({"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Back"}.ToList(), 0, AddressOf SelectMenuNameFilter, -1) + Case "type1" + Me.menu = New SelectMenu({"Normal", "Fire", "Fighting", "Water", "Flying", "Grass", "Poison", "Electric", "Ground", "Psychic", "Rock", "Ice", "Bug", "Dragon", "Ghost", "Dark", "Steel", "Fairy", "Blank", "Back"}.ToList(), 0, AddressOf SelectMenuType1Filter, -1) + Case "type2" + Me.menu = New SelectMenu({"Normal", "Fire", "Fighting", "Water", "Flying", "Grass", "Poison", "Electric", "Ground", "Psychic", "Rock", "Ice", "Bug", "Dragon", "Ghost", "Dark", "Steel", "Fairy", "Blank", "Back"}.ToList(), 0, AddressOf SelectMenuType2Filter, -1) + Case "clear" + Me.Filters.Clear() + Me.SetList() + Case "back" + Me.menu = New SelectMenu({"Order", "Filter", "Reset", "Back"}.ToList(), 0, AddressOf SelectMenu1, 3) + End Select + End Sub + + Private Sub SelectMenuType1Filter(ByVal s As SelectMenu) + If s.SelectedItem <> "Back" Then + For i = 0 To Filters.Count - 1 + If Filters(i).FilterType = FilterType.Type1 Then + Filters.RemoveAt(i) + Exit For + End If + Next + + Filters.Add(New Filter With {.FilterType = FilterType.Type1, .FilterValue = s.SelectedItem}) + SetList() + Else + Me.menu = New SelectMenu({"Name", "Type1", "Type2", "Clear", "Back"}.ToList(), 0, AddressOf SelectMenuFilter, 4) + End If + End Sub + + Private Sub SelectMenuType2Filter(ByVal s As SelectMenu) + If s.SelectedItem <> "Back" Then + For i = 0 To Filters.Count - 1 + If Filters(i).FilterType = FilterType.Type2 Then + Filters.RemoveAt(i) + Exit For + End If + Next + + Filters.Add(New Filter With {.FilterType = FilterType.Type2, .FilterValue = s.SelectedItem}) + SetList() + Else + Me.menu = New SelectMenu({"Name", "Type1", "Type2", "Clear", "Back"}.ToList(), 0, AddressOf SelectMenuFilter, 4) + End If + End Sub + + Private Sub SelectMenuNameFilter(ByVal s As SelectMenu) + If s.SelectedItem <> "Back" Then + For i = 0 To Filters.Count - 1 + If Filters(i).FilterType = FilterType.Name Then + Filters.RemoveAt(i) + Exit For + End If + Next + + Filters.Add(New Filter With {.FilterType = FilterType.Name, .FilterValue = s.SelectedItem}) + SetList() + Else + Me.menu = New SelectMenu({"Name", "Type1", "Type2", "Clear", "Back"}.ToList(), 0, AddressOf SelectMenuFilter, 4) + End If + End Sub + + Private Sub SelectMenuOrder(ByVal s As SelectMenu) + Select Case s.SelectedItem.ToLower() + Case "type" + Me.menu = New SelectMenu({"Numeric", "A-Z", "Weight", "Height", "Back"}.ToList(), 0, AddressOf SelectMenuOrderType, 4) + Case "reverse: " & Me.ReverseOrder.ToString().ToLower() + Me.ReverseOrder = Not Me.ReverseOrder + Me.menu = New SelectMenu({"Type", "Reverse: " & Me.ReverseOrder.ToString(), "Back"}.ToList(), 0, AddressOf SelectMenuOrder, 2) + Me.SetList() + Case "back" + Me.menu = New SelectMenu({"Order", "Filter", "Reset", "Back"}.ToList(), 0, AddressOf SelectMenu1, 3) + End Select + End Sub + + Private Sub SelectMenuOrderType(ByVal s As SelectMenu) + Select Case s.SelectedItem.ToLower() + Case "numeric" + Me.Order = OrderType.Numeric + Me.SetList() + Case "a-z" + Me.Order = OrderType.Alphabetically + Me.SetList() + Case "weight" + Me.Order = OrderType.Weigth + Me.SetList() + Case "height" + Me.Order = OrderType.Height + Me.SetList() + Case "back" + Me.menu = New SelectMenu({"Type", "Reverse: " & Me.ReverseOrder.ToString(), "Back"}.ToList(), 0, AddressOf SelectMenuOrder, 2) + End Select + End Sub + +#End Region + + Private Class SelectMenu + + Dim Items As New List(Of String) + Dim Index As Integer = 0 + Public Delegate Sub ClickEvent(ByVal s As SelectMenu) + 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 + + 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), "") End Sub - - Private Sub SelectMenuFilter(ByVal s As SelectMenu) - Select Case s.SelectedItem.ToLower() - Case "name" - Me.menu = New SelectMenu({"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Back"}.ToList(), 0, AddressOf SelectMenuNameFilter, -1) - Case "type1" - Me.menu = New SelectMenu({"Normal", "Fire", "Fighting", "Water", "Flying", "Grass", "Poison", "Electric", "Ground", "Psychic", "Rock", "Ice", "Bug", "Dragon", "Ghost", "Dark", "Steel", "Fairy", "Blank", "Back"}.ToList(), 0, AddressOf SelectMenuType1Filter, -1) - Case "type2" - Me.menu = New SelectMenu({"Normal", "Fire", "Fighting", "Water", "Flying", "Grass", "Poison", "Electric", "Ground", "Psychic", "Rock", "Ice", "Bug", "Dragon", "Ghost", "Dark", "Steel", "Fairy", "Blank", "Back"}.ToList(), 0, AddressOf SelectMenuType2Filter, -1) - Case "clear" - Me.Filters.Clear() - Me.SetList() - Case "back" - Me.menu = New SelectMenu({"Order", "Filter", "Reset", "Back"}.ToList(), 0, AddressOf SelectMenu1, 3) - End Select - End Sub - - Private Sub SelectMenuType1Filter(ByVal s As SelectMenu) - If s.SelectedItem <> "Back" Then - For i = 0 To Filters.Count - 1 - If Filters(i).FilterType = FilterType.Type1 Then - Filters.RemoveAt(i) - Exit For + + Public Sub Update() + If Visible = True Then + If Controls.Up(True, True, True, True, True, True) = True Then + Me.Index -= 1 + End If + If Controls.Down(True, True, True, True, True, True) = True Then + Me.Index += 1 + End If + Me.Index = Me.Index.Clamp(0, Me.Items.Count - 1) + + 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, 66 * ((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 + + If Not ClickHandler Is Nothing Then + ClickHandler(Me) + SoundManager.PlaySound("select") + End If + Me.Visible = False + End If + If Controls.Dismiss(True, True, True) = True Then + Me.Index = Me.BackIndex + If Not ClickHandler Is Nothing Then + ClickHandler(Me) + SoundManager.PlaySound("select") + End If + Me.Visible = False + End If + If New Rectangle(Core.windowSize.Width - 270, 66 * ((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 - - Filters.Add(New Filter With {.FilterType = FilterType.Type1, .FilterValue = s.SelectedItem}) - SetList() - Else - Me.menu = New SelectMenu({"Name", "Type1", "Type2", "Clear", "Back"}.ToList(), 0, AddressOf SelectMenuFilter, 4) + + If Index - Scroll > 8 Then + Scroll = Index - 8 + End If + If Index - Scroll < 0 Then + Scroll = Index + End If End If End Sub - - Private Sub SelectMenuType2Filter(ByVal s As SelectMenu) - If s.SelectedItem <> "Back" Then - For i = 0 To Filters.Count - 1 - If Filters(i).FilterType = FilterType.Type2 Then - Filters.RemoveAt(i) - Exit For + + 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) + + Dim startPos As New Vector2(Core.windowSize.Width - 270, 66 * ((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) + + Core.SpriteBatch.DrawString(FontManager.MainFont, Text, New Vector2(startPos.X + 128 - (FontManager.MainFont.MeasureString(Text).X * 1.4F) / 2, startPos.Y + 15), Color.Black, 0.0F, Vector2.Zero, 1.4F, SpriteEffects.None, 0.0F) + + If Me.Index = i Then + Dim cPosition As Vector2 = New Vector2(startPos.X + 128, startPos.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 If End If Next - - Filters.Add(New Filter With {.FilterType = FilterType.Type2, .FilterValue = s.SelectedItem}) - SetList() - Else - Me.menu = New SelectMenu({"Name", "Type1", "Type2", "Clear", "Back"}.ToList(), 0, AddressOf SelectMenuFilter, 4) End If End Sub - - Private Sub SelectMenuNameFilter(ByVal s As SelectMenu) - If s.SelectedItem <> "Back" Then - For i = 0 To Filters.Count - 1 - If Filters(i).FilterType = FilterType.Name Then - Filters.RemoveAt(i) - Exit For - End If - Next - - Filters.Add(New Filter With {.FilterType = FilterType.Name, .FilterValue = s.SelectedItem}) - SetList() - Else - Me.menu = New SelectMenu({"Name", "Type1", "Type2", "Clear", "Back"}.ToList(), 0, AddressOf SelectMenuFilter, 4) - End If - End Sub - - Private Sub SelectMenuOrder(ByVal s As SelectMenu) - Select Case s.SelectedItem.ToLower() - Case "type" - Me.menu = New SelectMenu({"Numeric", "A-Z", "Weight", "Height", "Back"}.ToList(), 0, AddressOf SelectMenuOrderType, 4) - Case "reverse: " & Me.ReverseOrder.ToString().ToLower() - Me.ReverseOrder = Not Me.ReverseOrder - Me.menu = New SelectMenu({"Type", "Reverse: " & Me.ReverseOrder.ToString(), "Back"}.ToList(), 0, AddressOf SelectMenuOrder, 2) - Me.SetList() - Case "back" - Me.menu = New SelectMenu({"Order", "Filter", "Reset", "Back"}.ToList(), 0, AddressOf SelectMenu1, 3) - End Select - End Sub - - Private Sub SelectMenuOrderType(ByVal s As SelectMenu) - Select Case s.SelectedItem.ToLower() - Case "numeric" - Me.Order = OrderType.Numeric - Me.SetList() - Case "a-z" - Me.Order = OrderType.Alphabetically - Me.SetList() - Case "weight" - Me.Order = OrderType.Weigth - Me.SetList() - Case "height" - Me.Order = OrderType.Height - Me.SetList() - Case "back" - Me.menu = New SelectMenu({"Type", "Reverse: " & Me.ReverseOrder.ToString(), "Back"}.ToList(), 0, AddressOf SelectMenuOrder, 2) - End Select - End Sub - - #End Region - - Private Class SelectMenu - - Dim Items As New List(Of String) - Dim Index As Integer = 0 - Public Delegate Sub ClickEvent(ByVal s As SelectMenu) - 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 - - 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), "") - End Sub - - Public Sub Update() - If Visible = True Then - If Controls.Up(True, True, True, True, True, True) = True Then - Me.Index -= 1 - End If - If Controls.Down(True, True, True, True, True, True) = True Then - Me.Index += 1 - End If - Me.Index = Me.Index.Clamp(0, Me.Items.Count - 1) - - 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, 66 * ((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 - - If Not ClickHandler Is Nothing Then - ClickHandler(Me) - SoundManager.PlaySound("select") - End If - Me.Visible = False - End If - If Controls.Dismiss(True, True, True) = True Then - Me.Index = Me.BackIndex - If Not ClickHandler Is Nothing Then - ClickHandler(Me) - SoundManager.PlaySound("select") - End If - Me.Visible = False - End If - If New Rectangle(Core.windowSize.Width - 270, 66 * ((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 - - If Index - Scroll > 8 Then - Scroll = Index - 8 - End If - If Index - Scroll < 0 Then - Scroll = Index - End If - End If - End Sub - - 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) - - Dim startPos As New Vector2(Core.windowSize.Width - 270, 66 * ((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) - - Core.SpriteBatch.DrawString(FontManager.MainFont, Text, New Vector2(startPos.X + 128 - (FontManager.MainFont.MeasureString(Text).X * 1.4F) / 2, startPos.Y + 15), Color.Black, 0.0F, Vector2.Zero, 1.4F, SpriteEffects.None, 0.0F) - - If Me.Index = i Then - Dim cPosition As Vector2 = New Vector2(startPos.X + 128, startPos.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 If - End If - Next - End If - End Sub - - Public ReadOnly Property SelectedItem() As String - Get - Return Items(Me.Index) - End Get - End Property - - End Class - - Public Class Habitat - - Public Enum HabitatTypes As Integer - Grassland = 0 - Forest = 1 - WatersEdge = 2 - Sea = 3 - Cave = 4 - Mountain = 5 - RoughTerrain = 6 - City = 7 - End Enum - - Public Structure EncounterPokemon - Public PokemonID As String - Public EncounterType As Integer - Public Daytimes() As Integer - End Structure - - Dim MergeData() As String = {} ' Temporary data storage if needs to merge. - - Public File As String = "" - Public Name As String = "" - Public HabitatType As HabitatTypes = HabitatTypes.Grassland - - Public PokemonList As New List(Of String) - Public ObtainTypeList As New List(Of EncounterPokemon) - - Public PokemonCaught As Integer = 0 - Public PokemonSeen As Integer = 0 - - Public Sub New(ByVal file As String) - Security.FileValidation.CheckFileValid(file, False, "PokedexScreen.vb") - Dim data() As String = System.IO.File.ReadAllLines(file) - Me.MergeData = data - Me.File = file - - For Each line As String In data - If line.ToLower().StartsWith("name=") = True Then - Me.Name = line.Remove(0, 5) - ElseIf line.ToLower().StartsWith("type=") = True Then - Dim arg As String = line.Remove(0, 5) - Select Case arg.ToLower() - Case "grassland" - Me.HabitatType = HabitatTypes.Grassland - Case "forest" - Me.HabitatType = HabitatTypes.Forest - Case "watersedge" - Me.HabitatType = HabitatTypes.WatersEdge - Case "sea" - Me.HabitatType = HabitatTypes.Sea - Case "cave" - Me.HabitatType = HabitatTypes.Cave - Case "mountain" - Me.HabitatType = HabitatTypes.Mountain - Case "roughterrain" - Me.HabitatType = HabitatTypes.RoughTerrain - Case "city" - Me.HabitatType = HabitatTypes.City - End Select - ElseIf line.StartsWith("{") = True And line.EndsWith("}") = True Then - Dim pokemonData() As String = line.Remove(line.Length - 1, 1).Remove(0, 1).Split(CChar("|")) - - If Me.PokemonList.Contains(pokemonData(1)) = False Then - Me.PokemonList.Add(pokemonData(1)) - - Dim entryType As Integer = Pokedex.GetEntryType(Core.Player.PokedexData, pokemonData(1)) - - If entryType > 0 Then - Me.PokemonSeen += 1 - End If - If entryType > 1 Then - Me.PokemonCaught += 1 - End If - End If - - Dim daytimesData As List(Of String) = pokemonData(3).Split(CChar(",")).ToList() - Dim dayTimes As New List(Of Integer) - - For Each s As String In daytimesData - If StringHelper.IsNumeric(s) = True Then - Dim i As Integer = CInt(s) - If i > 0 Then - dayTimes.Add(i) - Else - dayTimes.Clear() - Exit For - End If - End If - Next - - Me.ObtainTypeList.Add(New EncounterPokemon With {.PokemonID = pokemonData(1), .EncounterType = CInt(pokemonData(0)), .Daytimes = dayTimes.ToArray()}) - End If - Next - - If Me.Name = "" Then - Me.Name = System.IO.Path.GetFileNameWithoutExtension(file) - Me.Name = Me.Name(0).ToString().ToUpper() & Me.Name.Remove(0, 1) - End If - End Sub - - Public ReadOnly Property Texture() As Texture2D - Get - Dim x As Integer = CInt(Me.HabitatType) - Dim y As Integer = 0 - While x > 1 - x -= 2 - y += 1 - End While - Return TextureManager.GetTexture("GUI\Menus\pokedexhabitat", New Rectangle(x * 64, y * 48, 64, 48), "") - End Get - End Property - - Public Shared Function GetEncounterTypeImage(ByVal encounterType As Integer) As Texture2D - Dim x As Integer = 0 - Dim y As Integer = 4 - - Select Case encounterType - Case 0 - x = 0 - y = 3 - Case 1 - x = 0 - y = 4 - Case 2 - x = 1 - y = 0 - Case 3 - x = 0 - y = 0 - Case 31 - x = 0 - y = 1 - Case 32 - x = 0 - y = 2 - End Select - - Return TextureManager.GetTexture("GUI\Menus\pokedexhabitat", New Rectangle(128 + x * 32, y * 32, 32, 32), "") - End Function - - Public ReadOnly Property ProgressTexture() As Texture2D - Get - If Me.PokemonCaught >= Me.PokemonList.Count Then - Return TextureManager.GetTexture("GUI\Menus\pokedexhabitat", New Rectangle(160, 160, 10, 10), "") - Else - If Me.PokemonSeen >= Me.PokemonList.Count Then - Return TextureManager.GetTexture("GUI\Menus\pokedexhabitat", New Rectangle(160, 170, 10, 10), "") - End If - End If - Return Nothing - End Get - End Property - - Public Sub Merge(ByVal h As Habitat) - Dim data() As String = h.MergeData - - For Each line As String In data - If line.StartsWith("{") = True And line.EndsWith("}") = True Then - Dim pokemonData() As String = line.Remove(line.Length - 1, 1).Remove(0, 1).Split(CChar("|")) - - If Me.PokemonList.Contains(pokemonData(1)) = False Then - Me.PokemonList.Add(pokemonData(1)) - - Dim entryType As Integer = Pokedex.GetEntryType(Core.Player.PokedexData, pokemonData(1)) - - If entryType > 0 Then - Me.PokemonSeen += 1 - End If - If entryType > 1 Then - Me.PokemonCaught += 1 - End If - End If - - Me.ObtainTypeList.Add(New EncounterPokemon With {.PokemonID = pokemonData(1), .EncounterType = CInt(pokemonData(0))}) - End If - Next - End Sub - - Public Function HasPokemon(ByVal pokemonNumber As String) As Boolean - Return Me.PokemonList.Contains(pokemonNumber) - End Function - - End Class - + + Public ReadOnly Property SelectedItem() As String + Get + Return Items(Me.Index) + End Get + End Property + End Class + Public Class Habitat + + Public Enum HabitatTypes As Integer + Grassland = 0 + Forest = 1 + WatersEdge = 2 + Sea = 3 + Cave = 4 + Mountain = 5 + RoughTerrain = 6 + City = 7 + End Enum + + Public Structure EncounterPokemon + Public PokemonID As String + Public EncounterType As Integer + Public Daytimes() As Integer + End Structure + + Dim MergeData() As String = {} ' Temporary data storage if needs to merge. + + Public File As String = "" + Public Name As String = "" + Public HabitatType As HabitatTypes = HabitatTypes.Grassland + + Public PokemonList As New List(Of String) + Public ObtainTypeList As New List(Of EncounterPokemon) + + Public PokemonCaught As Integer = 0 + Public PokemonSeen As Integer = 0 + + Public Sub New(ByVal file As String) + Security.FileValidation.CheckFileValid(file, False, "PokedexScreen.vb") + Dim data() As String = System.IO.File.ReadAllLines(file) + Me.MergeData = data + Me.File = file + + For Each line As String In data + If line.ToLower().StartsWith("name=") = True Then + Me.Name = line.Remove(0, 5) + ElseIf line.ToLower().StartsWith("type=") = True Then + Dim arg As String = line.Remove(0, 5) + Select Case arg.ToLower() + Case "grassland" + Me.HabitatType = HabitatTypes.Grassland + Case "forest" + Me.HabitatType = HabitatTypes.Forest + Case "watersedge" + Me.HabitatType = HabitatTypes.WatersEdge + Case "sea" + Me.HabitatType = HabitatTypes.Sea + Case "cave" + Me.HabitatType = HabitatTypes.Cave + Case "mountain" + Me.HabitatType = HabitatTypes.Mountain + Case "roughterrain" + Me.HabitatType = HabitatTypes.RoughTerrain + Case "city" + Me.HabitatType = HabitatTypes.City + End Select + ElseIf line.StartsWith("{") = True And line.EndsWith("}") = True Then + Dim pokemonData() As String = line.Remove(line.Length - 1, 1).Remove(0, 1).Split(CChar("|")) + + If Me.PokemonList.Contains(pokemonData(1)) = False Then + Me.PokemonList.Add(pokemonData(1)) + + Dim entryType As Integer = Pokedex.GetEntryType(Core.Player.PokedexData, pokemonData(1)) + + If entryType > 0 Then + Me.PokemonSeen += 1 + End If + If entryType > 1 Then + Me.PokemonCaught += 1 + End If + End If + + Dim daytimesData As List(Of String) = pokemonData(3).Split(CChar(",")).ToList() + Dim dayTimes As New List(Of Integer) + + For Each s As String In daytimesData + If StringHelper.IsNumeric(s) = True Then + Dim i As Integer = CInt(s) + If i > 0 Then + dayTimes.Add(i) + Else + dayTimes.Clear() + Exit For + End If + End If + Next + + Me.ObtainTypeList.Add(New EncounterPokemon With {.PokemonID = pokemonData(1), .EncounterType = CInt(pokemonData(0)), .Daytimes = dayTimes.ToArray()}) + End If + Next + + If Me.Name = "" Then + Me.Name = System.IO.Path.GetFileNameWithoutExtension(file) + Me.Name = Me.Name(0).ToString().ToUpper() & Me.Name.Remove(0, 1) + End If + End Sub + + Public ReadOnly Property Texture() As Texture2D + Get + Dim x As Integer = CInt(Me.HabitatType) + Dim y As Integer = 0 + While x > 1 + x -= 2 + y += 1 + End While + Return TextureManager.GetTexture("GUI\Menus\pokedexhabitat", New Rectangle(x * 64, y * 48, 64, 48), "") + End Get + End Property + + Public Shared Function GetEncounterTypeImage(ByVal encounterType As Integer) As Texture2D + Dim x As Integer = 0 + Dim y As Integer = 4 + + Select Case encounterType + Case 0 + x = 0 + y = 3 + Case 1 + x = 0 + y = 4 + Case 2 + x = 1 + y = 0 + Case 3 + x = 0 + y = 0 + Case 31 + x = 0 + y = 1 + Case 32 + x = 0 + y = 2 + End Select + + Return TextureManager.GetTexture("GUI\Menus\pokedexhabitat", New Rectangle(128 + x * 32, y * 32, 32, 32), "") + End Function + + Public ReadOnly Property ProgressTexture() As Texture2D + Get + If Me.PokemonCaught >= Me.PokemonList.Count Then + Return TextureManager.GetTexture("GUI\Menus\pokedexhabitat", New Rectangle(160, 160, 10, 10), "") + Else + If Me.PokemonSeen >= Me.PokemonList.Count Then + Return TextureManager.GetTexture("GUI\Menus\pokedexhabitat", New Rectangle(160, 170, 10, 10), "") + End If + End If + Return Nothing + End Get + End Property + + Public Sub Merge(ByVal h As Habitat) + Dim data() As String = h.MergeData + + For Each line As String In data + If line.StartsWith("{") = True And line.EndsWith("}") = True Then + Dim pokemonData() As String = line.Remove(line.Length - 1, 1).Remove(0, 1).Split(CChar("|")) + + If Me.PokemonList.Contains(pokemonData(1)) = False Then + Me.PokemonList.Add(pokemonData(1)) + + Dim entryType As Integer = Pokedex.GetEntryType(Core.Player.PokedexData, pokemonData(1)) + + If entryType > 0 Then + Me.PokemonSeen += 1 + End If + If entryType > 1 Then + Me.PokemonCaught += 1 + End If + End If + + Me.ObtainTypeList.Add(New EncounterPokemon With {.PokemonID = pokemonData(1), .EncounterType = CInt(pokemonData(0))}) + End If + Next + End Sub + + Public Function HasPokemon(ByVal pokemonNumber As String) As Boolean + Return Me.PokemonList.Contains(pokemonNumber) + End Function + + End Class + +End Class + Public Class PokedexViewScreen Inherits Screen + Dim DexIndex As Integer = -1 Dim Pokemon As Pokemon Dim texture As Texture2D Dim Page As Integer = 0 + Dim Forms As New List(Of String) + Dim FormIndex As Integer = 0 Dim EntryType As Integer = 0 Dim _transitionOut As Boolean = False @@ -1336,7 +1345,7 @@ Public Class PokedexViewScreen ''' The screen that is currently active. ''' The Pokémon to display. ''' If the screen should fade out when closed. - Public Sub New(ByVal currentScreen As Screen, ByVal Pokemon As Pokemon, ByVal transitionOut As Boolean) + Public Sub New(ByVal currentScreen As Screen, ByVal Pokemon As Pokemon, ByVal transitionOut As Boolean, Optional DexIndex As Integer = -1) Me.PreScreen = currentScreen Me.Identification = Identifications.PokedexViewScreen Me.texture = TextureManager.GetTexture("GUI\Menus\General") @@ -1346,7 +1355,29 @@ Public Class PokedexViewScreen Me.CanBePaused = True Me._transitionOut = transitionOut - Me.Pokemon = Pokemon + If Me.Forms.Count > 0 Then + Me.Forms.Clear() + Me.Forms.Add(Me.Pokemon.Number.ToString) + Me.FormIndex = 0 + End If + + LoadPokemonData(DexIndex, Pokemon) + + End Sub + + Private Sub LoadPokemonData(ByVal newDexIndex As Integer, Optional ByVal newPokemon As Pokemon = Nothing, Optional playCry As Boolean = False) + If newPokemon IsNot Nothing Then + EvolutionLineConnections.Clear() + Me.Pokemon = newPokemon + End If + If newDexIndex <> -1 AndAlso newDexIndex <> Me.DexIndex Then + Me.Pokemon = PokedexScreen.TempPokemonStorage(newDexIndex) + Me.DexIndex = newDexIndex + Me.Forms.Clear() + Me.Forms.Add(Me.Pokemon.Number.ToString) + Me.FormIndex = 0 + End If + Dim dexID As String = PokemonForms.GetPokemonDataFileName(Me.Pokemon.Number, Me.Pokemon.AdditionalData) If dexID.Contains("_") = False Then @@ -1360,8 +1391,14 @@ Public Class PokedexViewScreen Me.EntryType = Pokedex.GetEntryType(Core.Player.PokedexData, dexID) Me.GetYOffset() - Me.FillEvolutionGrid() Me.FillHabitats() + Me.FillEvolutionGrid() + + If playCry = True Then + Dim crySuffix As String = PokemonForms.GetCrySuffix(Me.Pokemon) + SoundManager.PlayPokemonCry(Pokemon.Number, crySuffix) + End If + End Sub Private Sub FillEvolutionGrid() @@ -1395,6 +1432,14 @@ Public Class PokedexViewScreen Next Dim evoline As New PokemonEvolutionLine(GridPositions, PokemonIDs) EvolutionLineConnections.Add(evoline) + + For Each f As String In PokemonIDs + If CInt(f.GetSplit(0, "_").GetSplit(0, ";")) = Me.Pokemon.Number Then + If Me.Forms.Contains(f) = False Then + Me.Forms.Add(f) + End If + End If + Next Next Else Dim GridPositions As New List(Of Vector2) @@ -1509,7 +1554,8 @@ Public Class PokedexViewScreen For i = 0 To Me.HabitatList.Count - 1 If i <= Me.HabitatList.Count - 1 Then - If Me.HabitatList(i).HasPokemon(PokemonForms.GetPokemonDataFileName(Me.Pokemon.Number, Me.Pokemon.AdditionalData)) = False Then + Dim dexID As String = PokemonForms.GetPokemonDataFileName(Me.Pokemon.Number, Me.Pokemon.AdditionalData) + If Me.HabitatList(i).HasPokemon(dexID) = False Then Me.HabitatList.RemoveAt(i) i -= 1 End If @@ -1630,6 +1676,9 @@ Public Class PokedexViewScreen Else Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\Types"), New Rectangle(CInt(mV.X - 350), CInt(mV.Y + 123), 96, 32), Pokemon.Type1.GetElementImage(), Color.White) End If + + Core.SpriteBatch.DrawString(FontManager.MainFont, Pokemon.PokedexEntry.Text.CropStringToWidth(FontManager.MainFont, 720), New Vector2(mV.X - FontManager.MainFont.MeasureString(Pokemon.PokedexEntry.Text.CropStringToWidth(FontManager.MainFont, 720)).X / 2, windowSize.Height - 128), Color.Black) + Else Core.SpriteBatch.DrawString(FontManager.MainFont, "??? m", New Vector2(mV.X + 250, mV.Y - 152), Color.Black) Core.SpriteBatch.DrawString(FontManager.MainFont, "??? kg", New Vector2(mV.X + 250, mV.Y + 128), Color.Black) @@ -1782,6 +1831,52 @@ Public Class PokedexViewScreen End If End If + If DexIndex > -1 Then + If Me.DexIndex > PokedexScreen.TempPokemonStorage.Keys(0) Then + If Controls.Up(True, True, False, True, True, True) = True Then + vLineLength = 1 + mLineLength = 1 + fadeMainImage = 0 + LoadPokemonData(Me.DexIndex - 1, Nothing, True) + End If + End If + + If Me.DexIndex < PokedexScreen.TempPokemonStorage.Keys(PokedexScreen.TempPokemonStorage.Count - 1) Then + If Controls.Down(True, True, False, True, True, True) = True Then + vLineLength = 1 + mLineLength = 1 + fadeMainImage = 0 + LoadPokemonData(Me.DexIndex + 1, Nothing, True) + End If + End If + End If + + If Controls.ShiftPressed = True Then + Me.FormIndex += 1 + If Me.FormIndex > Me.Forms.Count - 1 Then + Me.FormIndex = 0 + End If + If Me.Forms(Me.FormIndex) IsNot "" Then + Dim PokeID As Integer = CInt(Me.Forms(Me.FormIndex).GetSplit(0, "_").GetSplit(0, ";")) + Dim PokeAD As String = "" + + If Me.Forms(Me.FormIndex).Contains("_") Then + PokeAD = PokemonForms.GetAdditionalValueFromDataFile(Me.Forms(Me.FormIndex)) + ElseIf Me.Forms(Me.FormIndex).Contains(";") Then + PokeAD = Me.Forms(Me.FormIndex).GetSplit(1, ";") + End If + + Dim newPokemon As Pokemon = Pokemon.GetPokemonByID(PokeID, PokeAD, True) + + Dim playCry As Boolean = False + If Page = 0 Then + playCry = True + End If + LoadPokemonData(-1, newPokemon, playCry) + + End If + End If + UpdateIntro() If mLineLength = 100 Then @@ -1832,7 +1927,8 @@ Public Class PokedexViewScreen fadeMainImage = 255 If playedCry = False Then playedCry = True - SoundManager.PlayPokemonCry(Pokemon.Number) + Dim crySuffix As String = PokemonForms.GetCrySuffix(Me.Pokemon) + SoundManager.PlayPokemonCry(Pokemon.Number, crySuffix) End If End If Else