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

View File

@ -68,6 +68,9 @@ Sub subMain
Dim aBaseStats As New aStats, maIVs As Variant, nI As Integer
Dim aQuery As New aFindIVParam
' TODO: To be removed.
BasicLibraries.loadLibrary "XrayTool"
aQuery = fnAskParam
If aQuery.bIsCancelled Then
Exit Sub
@ -83,13 +86,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)
@ -108,6 +124,7 @@ Function fnAskParam As aFindIVParam
fnAskParam = aQuery
Exit Function
End If
Xray oDialog.getControl ("lstPokemon")
With aQuery
.sPokemon = oDialog.getControl ("lstPokemon").getSelectedItem
@ -1035,6 +1052,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

@ -15,7 +15,7 @@
' limitations under the License.
' 1Data: The Pokémon GO data for IV calculation
' by imacat <imacat@mail.imacat.idv.tw>, 2017-01-03
' by imacat <imacat@mail.imacat.idv.tw>, 2017-02-14
' Generated with 9Load.subReadDataSheets ()
Option Explicit
@ -51,10 +51,10 @@ Function fnGetBaseStatsData As Variant
Array ("Raichu", "026", 120, 193, 165, Array ()), _
Array ("Sandshrew", "027", 100, 126, 145, Array ("Sandslash")), _
Array ("Sandslash", "028", 150, 182, 202, Array ()), _
Array ("Nidoran", "029", 110, 86, 94, Array ("Nidorina", "Nidoqueen")), _
Array ("NidoranFemale", "029", 110, 86, 94, Array ("Nidorina", "Nidoqueen")), _
Array ("Nidorina", "030", 140, 117, 126, Array ("Nidoqueen")), _
Array ("Nidoqueen", "031", 180, 180, 174, Array ()), _
Array ("Nidoran", "032", 92, 105, 76, Array ("Nidorino", "Nidoking")), _
Array ("NidoranMale", "032", 92, 105, 76, Array ("Nidorino", "Nidoking")), _
Array ("Nidorino", "033", 122, 137, 112, Array ("Nidoking")), _
Array ("Nidoking", "034", 162, 204, 157, Array ()), _
Array ("Clefairy", "035", 140, 107, 116, Array ("Clefable")), _
@ -105,7 +105,7 @@ Function fnGetBaseStatsData As Variant
Array ("Slowbro", "080", 190, 177, 194, Array ()), _
Array ("Magnemite", "081", 50, 165, 128, Array ("Magneton")), _
Array ("Magneton", "082", 100, 223, 182, Array ()), _
Array ("Farfetch'd", "083", 104, 124, 118, Array ()), _
Array ("Farfetchd", "083", 104, 124, 118, Array ()), _
Array ("Doduo", "084", 70, 158, 88, Array ("Dodrio")), _
Array ("Dodrio", "085", 120, 218, 145, Array ()), _
Array ("Seel", "086", 130, 85, 128, Array ("Dewgong")), _
@ -144,7 +144,7 @@ Function fnGetBaseStatsData As Variant
Array ("Seaking", "119", 160, 175, 154, Array ()), _
Array ("Staryu", "120", 60, 137, 112, Array ("Starmie")), _
Array ("Starmie", "121", 120, 210, 184, Array ()), _
Array ("Mr. Mime", "122", 80, 192, 233, Array ()), _
Array ("MrMime", "122", 80, 192, 233, Array ()), _
Array ("Scyther", "123", 140, 218, 170, Array ()), _
Array ("Jynx", "124", 130, 223, 182, Array ()), _
Array ("Electabuzz", "125", 130, 198, 173, Array ()), _

View File

@ -113,7 +113,8 @@ Function fnReadBaseStatsSheet As String
For nI = 1 To UBound (mData) - 1
sEvolveForms = fnFindEvolveForms (mData (nI))
sOutput = sOutput _
& Chr (9) & Chr (9) & "Array (""" & mData (nI) (0) _
& Chr (9) & Chr (9) & "Array (""" _
& fnMapPokemonNameToId (mData (nI) (0)) _
& """, """ & mData (nI) (1) _
& """, " & mData (nI) (3) _
& ", " & mData (nI) (4) _
@ -123,7 +124,8 @@ Function fnReadBaseStatsSheet As String
nI = UBound (mData)
sEvolveForms = fnFindEvolveForms (mData (nI))
sOutput = sOutput _
& Chr (9) & Chr (9) & "Array (""" & mData (nI) (0) _
& Chr (9) & Chr (9) & "Array (""" _
& fnMapPokemonNameToId (mData (nI) (0)) _
& """, """ & mData (nI) (1) _
& """, " & mData (nI) (3) _
& ", " & mData (nI) (4) _
@ -133,6 +135,7 @@ Function fnReadBaseStatsSheet As String
fnReadBaseStatsSheet = sOutput
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
Dim sEvolveForms As String
@ -164,10 +167,12 @@ Function fnFindEvolveForms (mData () As Variant) As String
If nEnd = nStart - 1 Then
sEvolveForms = "Array ()"
Else
sEvolveForms = """" & mData (nStart) & """"
sEvolveForms = """" _
& fnMapPokemonNameToId (mData (nStart)) & """"
For nJ = nStart + 1 To nEnd
sEvolveForms = sEvolveForms _
& ", """ & mData (nJ) & """"
& ", """ _
& fnMapPokemonNameToId (mData (nJ)) & """"
Next nJ
sEvolveForms = "Array (" & sEvolveForms & ")"
End If

View File

@ -10,167 +10,6 @@
<dlg:bulletinboard>
<dlg:text dlg:id="txtPokemon" dlg:tab-index="16" dlg:left="5" dlg:top="26" dlg:width="30" dlg:height="8" dlg:value="&amp;23.DlgMain.txtPokemon.Label"/>
<dlg:menulist dlg:id="lstPokemon" dlg:tab-index="0" dlg:left="35" dlg:top="24" dlg:width="55" dlg:height="12" dlg:spin="true">
<dlg:menupopup>
<dlg:menuitem dlg:value="Bulbasaur"/>
<dlg:menuitem dlg:value="Ivysaur"/>
<dlg:menuitem dlg:value="Venusaur"/>
<dlg:menuitem dlg:value="Charmander"/>
<dlg:menuitem dlg:value="Charmeleon"/>
<dlg:menuitem dlg:value="Charizard"/>
<dlg:menuitem dlg:value="Squirtle"/>
<dlg:menuitem dlg:value="Wartortle"/>
<dlg:menuitem dlg:value="Blastoise"/>
<dlg:menuitem dlg:value="Caterpie"/>
<dlg:menuitem dlg:value="Metapod"/>
<dlg:menuitem dlg:value="Butterfree"/>
<dlg:menuitem dlg:value="Weedle"/>
<dlg:menuitem dlg:value="Kakuna"/>
<dlg:menuitem dlg:value="Beedrill"/>
<dlg:menuitem dlg:value="Pidgey"/>
<dlg:menuitem dlg:value="Pidgeotto"/>
<dlg:menuitem dlg:value="Pidgeot"/>
<dlg:menuitem dlg:value="Rattata"/>
<dlg:menuitem dlg:value="Raticate"/>
<dlg:menuitem dlg:value="Spearow"/>
<dlg:menuitem dlg:value="Fearow"/>
<dlg:menuitem dlg:value="Ekans"/>
<dlg:menuitem dlg:value="Arbok"/>
<dlg:menuitem dlg:value="Pikachu"/>
<dlg:menuitem dlg:value="Raichu"/>
<dlg:menuitem dlg:value="Sandshrew"/>
<dlg:menuitem dlg:value="Sandslash"/>
<dlg:menuitem dlg:value="Nidoran♀"/>
<dlg:menuitem dlg:value="Nidorina"/>
<dlg:menuitem dlg:value="Nidoqueen"/>
<dlg:menuitem dlg:value="Nidoran♂"/>
<dlg:menuitem dlg:value="Nidorino"/>
<dlg:menuitem dlg:value="Nidoking"/>
<dlg:menuitem dlg:value="Clefairy"/>
<dlg:menuitem dlg:value="Clefable"/>
<dlg:menuitem dlg:value="Vulpix"/>
<dlg:menuitem dlg:value="Ninetales"/>
<dlg:menuitem dlg:value="Jigglypuff"/>
<dlg:menuitem dlg:value="Wigglytuff"/>
<dlg:menuitem dlg:value="Zubat"/>
<dlg:menuitem dlg:value="Golbat"/>
<dlg:menuitem dlg:value="Oddish"/>
<dlg:menuitem dlg:value="Gloom"/>
<dlg:menuitem dlg:value="Vileplume"/>
<dlg:menuitem dlg:value="Paras"/>
<dlg:menuitem dlg:value="Parasect"/>
<dlg:menuitem dlg:value="Venonat"/>
<dlg:menuitem dlg:value="Venomoth"/>
<dlg:menuitem dlg:value="Diglett"/>
<dlg:menuitem dlg:value="Dugtrio"/>
<dlg:menuitem dlg:value="Meowth"/>
<dlg:menuitem dlg:value="Persian"/>
<dlg:menuitem dlg:value="Psyduck"/>
<dlg:menuitem dlg:value="Golduck"/>
<dlg:menuitem dlg:value="Mankey"/>
<dlg:menuitem dlg:value="Primeape"/>
<dlg:menuitem dlg:value="Growlithe"/>
<dlg:menuitem dlg:value="Arcanine"/>
<dlg:menuitem dlg:value="Poliwag"/>
<dlg:menuitem dlg:value="Poliwhirl"/>
<dlg:menuitem dlg:value="Poliwrath"/>
<dlg:menuitem dlg:value="Abra"/>
<dlg:menuitem dlg:value="Kadabra"/>
<dlg:menuitem dlg:value="Alakazam"/>
<dlg:menuitem dlg:value="Machop"/>
<dlg:menuitem dlg:value="Machoke"/>
<dlg:menuitem dlg:value="Machamp"/>
<dlg:menuitem dlg:value="Bellsprout"/>
<dlg:menuitem dlg:value="Weepinbell"/>
<dlg:menuitem dlg:value="Victreebel"/>
<dlg:menuitem dlg:value="Tentacool"/>
<dlg:menuitem dlg:value="Tentacruel"/>
<dlg:menuitem dlg:value="Geodude"/>
<dlg:menuitem dlg:value="Graveler"/>
<dlg:menuitem dlg:value="Golem"/>
<dlg:menuitem dlg:value="Ponyta"/>
<dlg:menuitem dlg:value="Rapidash"/>
<dlg:menuitem dlg:value="Slowpoke"/>
<dlg:menuitem dlg:value="Slowbro"/>
<dlg:menuitem dlg:value="Magnemite"/>
<dlg:menuitem dlg:value="Magneton"/>
<dlg:menuitem dlg:value="Farfetch&apos;d"/>
<dlg:menuitem dlg:value="Doduo"/>
<dlg:menuitem dlg:value="Dodrio"/>
<dlg:menuitem dlg:value="Seel"/>
<dlg:menuitem dlg:value="Dewgong"/>
<dlg:menuitem dlg:value="Grimer"/>
<dlg:menuitem dlg:value="Muk"/>
<dlg:menuitem dlg:value="Shellder"/>
<dlg:menuitem dlg:value="Cloyster"/>
<dlg:menuitem dlg:value="Gastly"/>
<dlg:menuitem dlg:value="Haunter"/>
<dlg:menuitem dlg:value="Gengar"/>
<dlg:menuitem dlg:value="Onix"/>
<dlg:menuitem dlg:value="Drowzee"/>
<dlg:menuitem dlg:value="Hypno"/>
<dlg:menuitem dlg:value="Krabby"/>
<dlg:menuitem dlg:value="Kingler"/>
<dlg:menuitem dlg:value="Voltorb"/>
<dlg:menuitem dlg:value="Electrode"/>
<dlg:menuitem dlg:value="Exeggcute"/>
<dlg:menuitem dlg:value="Exeggutor"/>
<dlg:menuitem dlg:value="Cubone"/>
<dlg:menuitem dlg:value="Marowak"/>
<dlg:menuitem dlg:value="Hitmonlee"/>
<dlg:menuitem dlg:value="Hitmonchan"/>
<dlg:menuitem dlg:value="Lickitung"/>
<dlg:menuitem dlg:value="Koffing"/>
<dlg:menuitem dlg:value="Weezing"/>
<dlg:menuitem dlg:value="Rhyhorn"/>
<dlg:menuitem dlg:value="Rhydon"/>
<dlg:menuitem dlg:value="Chansey"/>
<dlg:menuitem dlg:value="Tangela"/>
<dlg:menuitem dlg:value="Kangaskhan"/>
<dlg:menuitem dlg:value="Horsea"/>
<dlg:menuitem dlg:value="Seadra"/>
<dlg:menuitem dlg:value="Goldeen"/>
<dlg:menuitem dlg:value="Seaking"/>
<dlg:menuitem dlg:value="Staryu"/>
<dlg:menuitem dlg:value="Starmie"/>
<dlg:menuitem dlg:value="Mr. Mime"/>
<dlg:menuitem dlg:value="Scyther"/>
<dlg:menuitem dlg:value="Jynx"/>
<dlg:menuitem dlg:value="Electabuzz"/>
<dlg:menuitem dlg:value="Magmar"/>
<dlg:menuitem dlg:value="Pinsir"/>
<dlg:menuitem dlg:value="Tauros"/>
<dlg:menuitem dlg:value="Magikarp"/>
<dlg:menuitem dlg:value="Gyarados"/>
<dlg:menuitem dlg:value="Lapras"/>
<dlg:menuitem dlg:value="Ditto"/>
<dlg:menuitem dlg:value="Eevee"/>
<dlg:menuitem dlg:value="Vaporeon"/>
<dlg:menuitem dlg:value="Jolteon"/>
<dlg:menuitem dlg:value="Flareon"/>
<dlg:menuitem dlg:value="Porygon"/>
<dlg:menuitem dlg:value="Omanyte"/>
<dlg:menuitem dlg:value="Omastar"/>
<dlg:menuitem dlg:value="Kabuto"/>
<dlg:menuitem dlg:value="Kabutops"/>
<dlg:menuitem dlg:value="Aerodactyl"/>
<dlg:menuitem dlg:value="Snorlax"/>
<dlg:menuitem dlg:value="Articuno"/>
<dlg:menuitem dlg:value="Zapdos"/>
<dlg:menuitem dlg:value="Moltres"/>
<dlg:menuitem dlg:value="Dratini"/>
<dlg:menuitem dlg:value="Dragonair"/>
<dlg:menuitem dlg:value="Dragonite"/>
<dlg:menuitem dlg:value="Mewtwo"/>
<dlg:menuitem dlg:value="Mew"/>
<dlg:menuitem dlg:value="Pichu"/>
<dlg:menuitem dlg:value="Cleffa"/>
<dlg:menuitem dlg:value="Igglybuff"/>
<dlg:menuitem dlg:value="Togepi"/>
<dlg:menuitem dlg:value="Togetic"/>
<dlg:menuitem dlg:value="Smoochum"/>
<dlg:menuitem dlg:value="Elekid"/>
<dlg:menuitem dlg:value="Magby"/>
</dlg:menupopup>
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.script:PokemonGoIV.0Main.subLstPokemonSelected?language=Basic&amp;location=application" script:language="Script"/>
</dlg:menulist>
<dlg:img dlg:style-id="0" dlg:id="imgPokemon" dlg:tab-index="26" dlg:left="95" dlg:top="5" dlg:width="30" dlg:height="30"/>