Updates the dialog so that the Pokémon list is created at run time, for the localization of Pokémon names.

This commit is contained in:
2017-02-14 22:00:46 +08:00
parent 8b80db44fc
commit 403885d6cb
6 changed files with 109 additions and 199 deletions

View File

@ -81,13 +81,26 @@ End Sub
' fnAskParam: Asks the users for the parameters for the Pokémon.
Function fnAskParam As aFindIVParam
Dim oDialog As Object, oDialogModel As Object
Dim oDialog As Object
Dim oListPokemons As Object, mPokemons () As String, nI As Integer
Dim bIsBestAttack As Boolean, bIsBestDefense As Boolean
Dim bIsBestHP As Boolean
Dim aQuery As New aFindIVParam
DialogLibraries.loadLibrary "PokemonGoIV"
oDialog = CreateUnoDialog (DialogLibraries.PokemonGoIV.DlgMain)
' Sets the Pokémons list
oListPokemons = oDialog.getControl ("lstPokemon")
oListPokemons.removeItems (0, oListPokemons.getItemCount)
subReadBaseStats
ReDim mPokemons (UBound (maBaseStats)) As String
For nI = 0 To UBound (maBaseStats)
mPokemons (nI) = _
fnMapPokemonIdToName (maBaseStats (nI).sPokemon)
Next nI
oListPokemons.addItems (mPokemons, 0)
oDialog.getControl ("lstTotal").setVisible (False)
oDialog.getControl ("txtBestBefore").setVisible (False)
oDialog.getControl ("lstBest").setVisible (False)
@ -106,6 +119,7 @@ Function fnAskParam As aFindIVParam
fnAskParam = aQuery
Exit Function
End If
Xray oDialog.getControl ("lstPokemon")
With aQuery
.sPokemon = oDialog.getControl ("lstPokemon").getSelectedItem
@ -1033,6 +1047,34 @@ Function fnFloor (fNumber As Double) As Integer
fnFloor = CInt (fNumber - 0.5)
End Function
' fnMapPokemonNameToId: Maps the English Pokémon names to their IDs.
Function fnMapPokemonNameToId (sName As String) As String
Dim sId As String
sId = ""
If sName = "Farfetch'd" Then
sId = "Farfetchd"
End If
If sName = "Nidoran♀" Then
sId = "NidoranFemale"
End If
If sName = "Nidoran♂" Then
sId = "NidoranMale"
End If
If sName = "Mr. Mime" Then
sId = "MrMime"
End If
If sId = "" Then
sId = sName
End If
fnMapPokemonNameToId = sId
End Function
' fnMapPokemonIdToName: Maps the Pokémon IDs to their localized names.
Function fnMapPokemonIdToName (sId As String) As String
fnMapPokemonIdToName = fnGetResString ("Pokemon" & sId)
End Function
' subReadBaseStats: Reads the base stats table.
Sub subReadBaseStats
Dim mData As Variant, nI As Integer, nJ As Integer

View File

@ -112,7 +112,7 @@ Function fnReadBaseStatsSheet As String
sEvolveForms = fnFindEvolveForms (mData (nI))
sOutput = sOutput _
& Chr (9) & Chr (9) & "Array (""" _
& fnMapNameToId (mData (nI) (0)) _
& fnMapPokemonNameToId (mData (nI) (0)) _
& """, """ & mData (nI) (1) _
& """, " & mData (nI) (3) _
& ", " & mData (nI) (4) _
@ -123,7 +123,7 @@ Function fnReadBaseStatsSheet As String
sEvolveForms = fnFindEvolveForms (mData (nI))
sOutput = sOutput _
& Chr (9) & Chr (9) & "Array (""" _
& fnMapNameToId (mData (nI) (0)) _
& fnMapPokemonNameToId (mData (nI) (0)) _
& """, """ & mData (nI) (1) _
& """, " & mData (nI) (3) _
& ", " & mData (nI) (4) _
@ -133,29 +133,6 @@ Function fnReadBaseStatsSheet As String
fnReadBaseStatsSheet = sOutput
End Function
' fnMapNameToId: Maps the English Pokémon names to their IDs.
Function fnMapNameToId (sName As String) As String
Dim sId As String
sId = ""
If sName = "Farfetch'd" Then
sId = "Farfetchd"
End If
If sName = "Nidoran♀" Then
sId = "NidoranFemale"
End If
If sName = "Nidoran♂" Then
sId = "NidoranMale"
End If
If sName = "Mr. Mime" Then
sId = "MrMime"
End If
If sId = "" Then
sId = sName
End If
fnMapNameToId = sId
End Function
' fnFindEvolveForms: Finds the evolved forms of the Pokémons.
Function fnFindEvolveForms (mData () As Variant) As String
Dim nJ As Integer, nStart As Integer, nEnd As Integer
@ -188,10 +165,12 @@ Function fnFindEvolveForms (mData () As Variant) As String
If nEnd = nStart - 1 Then
sEvolveForms = "Array ()"
Else
sEvolveForms = """" & fnMapNameToId (mData (nStart)) & """"
sEvolveForms = """" _
& fnMapPokemonNameToId (mData (nStart)) & """"
For nJ = nStart + 1 To nEnd
sEvolveForms = sEvolveForms _
& ", """ & fnMapNameToId (mData (nJ)) & """"
& ", """ _
& fnMapPokemonNameToId (mData (nJ)) & """"
Next nJ
sEvolveForms = "Array (" & sEvolveForms & ")"
End If