Moved the UI to the main module so that we do not need to duplicate the type.

This commit is contained in:
依瑪貓 2016-11-29 15:02:15 +08:00
parent 9fc4dab9a7
commit 16c621171f
9 changed files with 612 additions and 668 deletions

View File

@ -75,6 +75,306 @@ Sub subMain
End If End If
End Sub 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 oTextModel As Object, oListModel As Object
Dim oNumericModel As Object, oCheckBoxModel As Object
Dim oGroupModel As Object, oButtonModel As Object
Dim mListItems () As String, sTemp As String
Dim nI As Integer, nCount As Integer
Dim aQuery As New aFindIVParam
' Creates a dialog
oDialogModel = CreateUnoService ( _
"com.sun.star.awt.UnoControlDialogModel")
oDialogModel.setPropertyValue ("PositionX", 100)
oDialogModel.setPropertyValue ("PositionY", 100)
oDialogModel.setPropertyValue ("Height", 140)
oDialogModel.setPropertyValue ("Width", 220)
oDialogModel.setPropertyValue ("Title", "Pokémon Go IV Calculator")
' Adds a text label for the Pokémon list.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 5)
oTextModel.setPropertyValue ("PositionY", 5)
oTextModel.setPropertyValue ("Height", 12)
oTextModel.setPropertyValue ("Width", 30)
oTextModel.setPropertyValue ("Label", "~Pokémon:")
oDialogModel.insertByName ("txtPokemon", oTextModel)
' Adds the Pokémon list.
subReadBaseStats
ReDim mListItems (UBound (maBaseStats)) As String
For nI = 0 To UBound (maBaseStats)
mListItems (nI) = maBaseStats (nI).sPokemon
Next nI
oListModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlListBoxModel")
oListModel.setPropertyValue ("PositionX", 35)
oListModel.setPropertyValue ("PositionY", 4)
oListModel.setPropertyValue ("Height", 12)
oListModel.setPropertyValue ("Width", 50)
oListModel.setPropertyValue ("TabIndex", 0)
oListModel.setPropertyValue ("Dropdown", True)
oListModel.setPropertyValue ("StringItemList", mListItems)
oDialogModel.insertByName ("lstPokemon", oListModel)
' Adds a text label for the CP field.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 5)
oTextModel.setPropertyValue ("PositionY", 20)
oTextModel.setPropertyValue ("Height", 12)
oTextModel.setPropertyValue ("Width", 15)
oTextModel.setPropertyValue ("Label", "~CP:")
oDialogModel.insertByName ("txtCP", oTextModel)
' Adds the CP field.
oNumericModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlNumericFieldModel")
oNumericModel.setPropertyValue ("PositionX", 20)
oNumericModel.setPropertyValue ("PositionY", 19)
oNumericModel.setPropertyValue ("Height", 12)
oNumericModel.setPropertyValue ("Width", 20)
oNumericModel.setPropertyValue ("DecimalAccuracy", 0)
oDialogModel.insertByName ("numCP", oNumericModel)
' Adds a text label for the HP field.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 50)
oTextModel.setPropertyValue ("PositionY", 20)
oTextModel.setPropertyValue ("Height", 12)
oTextModel.setPropertyValue ("Width", 15)
oTextModel.setPropertyValue ("Label", "~HP:")
oDialogModel.insertByName ("txtHP", oTextModel)
' Adds the HP field.
oNumericModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlNumericFieldModel")
oNumericModel.setPropertyValue ("PositionX", 65)
oNumericModel.setPropertyValue ("PositionY", 19)
oNumericModel.setPropertyValue ("Height", 12)
oNumericModel.setPropertyValue ("Width", 15)
oNumericModel.setPropertyValue ("DecimalAccuracy", 0)
oDialogModel.insertByName ("numHP", oNumericModel)
' Adds a text label for the star dust field.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 90)
oTextModel.setPropertyValue ("PositionY", 20)
oTextModel.setPropertyValue ("Height", 12)
oTextModel.setPropertyValue ("Width", 30)
oTextModel.setPropertyValue ("Label", "S~tar dust:")
oDialogModel.insertByName ("txtStarDust", oTextModel)
' Adds the star dust field.
subReadStarDust
sTemp = " "
ReDim mListItems () As String
nCount = -1
For nI = 1 To UBound (mStarDust)
If InStr (sTemp, " " & CStr (mStarDust (nI)) & " ") = 0 Then
nCount = nCount + 1
ReDim Preserve mListItems (nCount) As String
mListItems (nCount) = CStr (mStarDust (nI))
sTemp = sTemp & CStr (mStarDust (nI)) & " "
End If
Next nI
oListModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlListBoxModel")
oListModel.setPropertyValue ("PositionX", 120)
oListModel.setPropertyValue ("PositionY", 19)
oListModel.setPropertyValue ("Height", 12)
oListModel.setPropertyValue ("Width", 30)
oListModel.setPropertyValue ("Dropdown", True)
oListModel.setPropertyValue ("StringItemList", mListItems)
oDialogModel.insertByName ("lstStarDust", oListModel)
' Adds a text label for the player level field.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 160)
oTextModel.setPropertyValue ("PositionY", 20)
oTextModel.setPropertyValue ("Height", 12)
oTextModel.setPropertyValue ("Width", 35)
oTextModel.setPropertyValue ("Label", "Player ~level:")
oDialogModel.insertByName ("txtPlayerLevel", oTextModel)
' Adds the player level field.
ReDim mListItems (39) As String
For nI = 0 To UBound (mListItems)
mListItems (nI) = CStr (nI + 1)
Next nI
oListModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlListBoxModel")
oListModel.setPropertyValue ("PositionX", 195)
oListModel.setPropertyValue ("PositionY", 19)
oListModel.setPropertyValue ("Height", 12)
oListModel.setPropertyValue ("Width", 20)
oListModel.setPropertyValue ("Dropdown", True)
oListModel.setPropertyValue ("StringItemList", mListItems)
oDialogModel.insertByName ("lstPlayerLevel", oListModel)
' Adds the whether powered-up check box.
oCheckBoxModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlCheckBoxModel")
oCheckBoxModel.setPropertyValue ("PositionX", 5)
oCheckBoxModel.setPropertyValue ("PositionY", 35)
oCheckBoxModel.setPropertyValue ("Height", 12)
oCheckBoxModel.setPropertyValue ("Width", 210)
oCheckBoxModel.setPropertyValue ("Label", _
"This Pokémon is ~newly-caught and was not powered-up yet.")
oCheckBoxModel.setPropertyValue ("State", 1)
oDialogModel.insertByName ("cbxIsNew", oCheckBoxModel)
' Adds a group for the appraisals
oGroupModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlGroupBoxModel")
oGroupModel.setPropertyValue ("PositionX", 5)
oGroupModel.setPropertyValue ("PositionY", 50)
oGroupModel.setPropertyValue ("Height", 65)
oGroupModel.setPropertyValue ("Width", 210)
oGroupModel.setPropertyValue ("Label", "Apprasals")
oDialogModel.insertByName ("grpApprasals", oGroupModel)
' Adds the first appraisal list.
mListItems = Array ( _
"1. Amazed me/wonder/best", _
"2. Strong/caught my attention", _
"3. Decent/above average", _
"4. Not great/not make headway/has room")
oListModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlListBoxModel")
oListModel.setPropertyValue ("PositionX", 10)
oListModel.setPropertyValue ("PositionY", 64)
oListModel.setPropertyValue ("Height", 12)
oListModel.setPropertyValue ("Width", 200)
oListModel.setPropertyValue ("Dropdown", True)
oListModel.setPropertyValue ("StringItemList", mListItems)
oDialogModel.insertByName ("lstApprasal1", oListModel)
' Adds a text label for the HP field.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 10)
oTextModel.setPropertyValue ("PositionY", 80)
oTextModel.setPropertyValue ("Height", 12)
oTextModel.setPropertyValue ("Width", 15)
oTextModel.setPropertyValue ("Label", "Best:")
oDialogModel.insertByName ("txtBest", oTextModel)
' Adds the attack is best check box
oCheckBoxModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlCheckBoxModel")
oCheckBoxModel.setPropertyValue ("PositionX", 25)
oCheckBoxModel.setPropertyValue ("PositionY", 80)
oCheckBoxModel.setPropertyValue ("Height", 12)
oCheckBoxModel.setPropertyValue ("Width", 30)
oCheckBoxModel.setPropertyValue ("Label", "~Attack")
oDialogModel.insertByName ("cbxAttackBest", oCheckBoxModel)
' Adds the defense is best check box
oCheckBoxModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlCheckBoxModel")
oCheckBoxModel.setPropertyValue ("PositionX", 55)
oCheckBoxModel.setPropertyValue ("PositionY", 80)
oCheckBoxModel.setPropertyValue ("Height", 12)
oCheckBoxModel.setPropertyValue ("Width", 35)
oCheckBoxModel.setPropertyValue ("Label", "~Defense")
oDialogModel.insertByName ("cbxDefenseBest", oCheckBoxModel)
' Adds the defense is best check box
oCheckBoxModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlCheckBoxModel")
oCheckBoxModel.setPropertyValue ("PositionX", 90)
oCheckBoxModel.setPropertyValue ("PositionY", 80)
oCheckBoxModel.setPropertyValue ("Height", 12)
oCheckBoxModel.setPropertyValue ("Width", 45)
oCheckBoxModel.setPropertyValue ("Label", "HP (~Stamina)")
oDialogModel.insertByName ("cbxHPBest", oCheckBoxModel)
' Adds the second appraisal list.
mListItems = Array ( _
"1. WOW/incredible/stats are best", _
"2. Excellent/impressed/impressive", _
"3. Get the job done/noticeable/some good stats", _
"4. No greatness/not out of the norm/kinda basic")
oListModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlListBoxModel")
oListModel.setPropertyValue ("PositionX", 10)
oListModel.setPropertyValue ("PositionY", 95)
oListModel.setPropertyValue ("Height", 12)
oListModel.setPropertyValue ("Width", 200)
oListModel.setPropertyValue ("Dropdown", True)
oListModel.setPropertyValue ("StringItemList", mListItems)
oDialogModel.insertByName ("lstApprasal2", oListModel)
' Adds the OK button.
oButtonModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlButtonModel")
oButtonModel.setPropertyValue ("PositionX", 35)
oButtonModel.setPropertyValue ("PositionY", 120)
oButtonModel.setPropertyValue ("Height", 15)
oButtonModel.setPropertyValue ("Width", 60)
oButtonModel.setPropertyValue ("PushButtonType", _
com.sun.star.awt.PushButtonType.OK)
oButtonModel.setPropertyValue ("DefaultButton", True)
oDialogModel.insertByName ("btnOK", oButtonModel)
' Adds the cancel button.
oButtonModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlButtonModel")
oButtonModel.setPropertyValue ("PositionX", 125)
oButtonModel.setPropertyValue ("PositionY", 120)
oButtonModel.setPropertyValue ("Height", 15)
oButtonModel.setPropertyValue ("Width", 60)
oButtonModel.setPropertyValue ("PushButtonType", _
com.sun.star.awt.PushButtonType.CANCEL)
oDialogModel.insertByName ("btnCancel", oButtonModel)
' Adds the dialog model to the control and runs it.
oDialog = CreateUnoService ("com.sun.star.awt.UnoControlDialog")
oDialog.setModel (oDialogModel)
oDialog.setVisible (True)
oDialog.getControl ("lstPokemon").setFocus
If oDialog.execute = 0 Then
aQuery.bIsCancelled = True
fnAskParam = aQuery
Exit Function
End If
With aQuery
.sPokemon = oDialog.getControl ("lstPokemon").getSelectedItem
.nCP = oDialog.getControl ("numCP").getValue
.nHP = oDialog.getControl ("numHP").getValue
.nStarDust = CInt (oDialog.getControl ("lstStarDust").getSelectedItem)
.nPlayerLevel = CInt (oDialog.getControl ("lstPlayerLevel").getSelectedItem)
.nAppraisal1 = oDialog.getControl ("lstApprasal1").getSelectedItemPos + 1
.nAppraisal2 = oDialog.getControl ("lstApprasal2").getSelectedItemPos + 1
.bIsCancelled = False
End With
If oDialog.getControl ("cbxIsNew").getState = 1 Then
aQuery.bIsNew = True
Else
aQuery.bIsNew = False
End If
aQuery.sBest = ""
If oDialog.getControl ("cbxAttackBest").getState = 1 Then
aQuery.sBest = aQuery.sBest & "Atk "
End If
If oDialog.getControl ("cbxDefenseBest").getState = 1 Then
aQuery.sBest = aQuery.sBest & "Def "
End If
If oDialog.getControl ("cbxHPBest").getState = 1 Then
aQuery.sBest = aQuery.sBest & "Sta "
End If
fnAskParam = aQuery
End Function
' fnFindIV: Finds the possible individual values of the Pokémon ' fnFindIV: Finds the possible individual values of the Pokémon
Function fnFindIV (aQuery As aFindIVParam) As Variant Function fnFindIV (aQuery As aFindIVParam) As Variant
Dim aBaseStats As New aStats, maIV () As New aStats Dim aBaseStats As New aStats, maIV () As New aStats

View File

@ -1,6 +1,6 @@
' 2Data: The Pokémon Go data for IV calculation ' 1Data: The Pokémon Go data for IV calculation
' by imacat <imacat@mail.imacat.idv.tw>, 2016-11-28 ' by imacat <imacat@mail.imacat.idv.tw>, 2016-11-28
' Generated with _3Load.subReadDataSheets () ' Generated with 9Load.subReadDataSheets ()
Option Explicit Option Explicit

View File

@ -1,326 +0,0 @@
' 1Dialog: The UI of the Pokémon IV calculator
' by imacat <imacat@mail.imacat.idv.tw>, 2016-11-27
Option Explicit
' The parameters to find the individual values.
Type aFindIVParam
sPokemon As String
nCP As Integer
nHP As Integer
nStarDust As Integer
nPlayerLevel As Integer
bIsNew As Boolean
nAppraisal1 As Integer
sBest As String
nAppraisal2 As Integer
bIsCancelled As Boolean
End Type
' fnAskParam: Asks the users for the parameters for the Pokémon.
Function fnAskParam As aFindIVParam
Dim oDialog As Object, oDialogModel As Object
Dim oTextModel As Object, oListModel As Object
Dim oNumericModel As Object, oCheckBoxModel As Object
Dim oGroupModel As Object, oButtonModel As Object
Dim mListItems () As String, sTemp As String
Dim nI As Integer, nCount As Integer
Dim aQuery As New aFindIVParam
' Creates a dialog
oDialogModel = CreateUnoService ( _
"com.sun.star.awt.UnoControlDialogModel")
oDialogModel.setPropertyValue ("PositionX", 100)
oDialogModel.setPropertyValue ("PositionY", 100)
oDialogModel.setPropertyValue ("Height", 140)
oDialogModel.setPropertyValue ("Width", 220)
oDialogModel.setPropertyValue ("Title", "Pokémon Go IV Calculator")
' Adds a text label for the Pokémon list.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 5)
oTextModel.setPropertyValue ("PositionY", 5)
oTextModel.setPropertyValue ("Height", 12)
oTextModel.setPropertyValue ("Width", 30)
oTextModel.setPropertyValue ("Label", "~Pokémon:")
oDialogModel.insertByName ("txtPokemon", oTextModel)
' Adds the Pokémon list.
subReadBaseStats
ReDim mListItems (UBound (maBaseStats)) As String
For nI = 0 To UBound (maBaseStats)
mListItems (nI) = maBaseStats (nI).sPokemon
Next nI
oListModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlListBoxModel")
oListModel.setPropertyValue ("PositionX", 35)
oListModel.setPropertyValue ("PositionY", 4)
oListModel.setPropertyValue ("Height", 12)
oListModel.setPropertyValue ("Width", 50)
oListModel.setPropertyValue ("TabIndex", 0)
oListModel.setPropertyValue ("Dropdown", True)
oListModel.setPropertyValue ("StringItemList", mListItems)
oDialogModel.insertByName ("lstPokemon", oListModel)
' Adds a text label for the CP field.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 5)
oTextModel.setPropertyValue ("PositionY", 20)
oTextModel.setPropertyValue ("Height", 12)
oTextModel.setPropertyValue ("Width", 15)
oTextModel.setPropertyValue ("Label", "~CP:")
oDialogModel.insertByName ("txtCP", oTextModel)
' Adds the CP field.
oNumericModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlNumericFieldModel")
oNumericModel.setPropertyValue ("PositionX", 20)
oNumericModel.setPropertyValue ("PositionY", 19)
oNumericModel.setPropertyValue ("Height", 12)
oNumericModel.setPropertyValue ("Width", 20)
oNumericModel.setPropertyValue ("DecimalAccuracy", 0)
oDialogModel.insertByName ("numCP", oNumericModel)
' Adds a text label for the HP field.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 50)
oTextModel.setPropertyValue ("PositionY", 20)
oTextModel.setPropertyValue ("Height", 12)
oTextModel.setPropertyValue ("Width", 15)
oTextModel.setPropertyValue ("Label", "~HP:")
oDialogModel.insertByName ("txtHP", oTextModel)
' Adds the HP field.
oNumericModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlNumericFieldModel")
oNumericModel.setPropertyValue ("PositionX", 65)
oNumericModel.setPropertyValue ("PositionY", 19)
oNumericModel.setPropertyValue ("Height", 12)
oNumericModel.setPropertyValue ("Width", 15)
oNumericModel.setPropertyValue ("DecimalAccuracy", 0)
oDialogModel.insertByName ("numHP", oNumericModel)
' Adds a text label for the star dust field.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 90)
oTextModel.setPropertyValue ("PositionY", 20)
oTextModel.setPropertyValue ("Height", 12)
oTextModel.setPropertyValue ("Width", 30)
oTextModel.setPropertyValue ("Label", "S~tar dust:")
oDialogModel.insertByName ("txtStarDust", oTextModel)
' Adds the star dust field.
subReadStarDust
sTemp = " "
ReDim mListItems () As String
nCount = -1
For nI = 1 To UBound (mStarDust)
If InStr (sTemp, " " & CStr (mStarDust (nI)) & " ") = 0 Then
nCount = nCount + 1
ReDim Preserve mListItems (nCount) As String
mListItems (nCount) = CStr (mStarDust (nI))
sTemp = sTemp & CStr (mStarDust (nI)) & " "
End If
Next nI
oListModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlListBoxModel")
oListModel.setPropertyValue ("PositionX", 120)
oListModel.setPropertyValue ("PositionY", 19)
oListModel.setPropertyValue ("Height", 12)
oListModel.setPropertyValue ("Width", 30)
oListModel.setPropertyValue ("Dropdown", True)
oListModel.setPropertyValue ("StringItemList", mListItems)
oDialogModel.insertByName ("lstStarDust", oListModel)
' Adds a text label for the player level field.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 160)
oTextModel.setPropertyValue ("PositionY", 20)
oTextModel.setPropertyValue ("Height", 12)
oTextModel.setPropertyValue ("Width", 35)
oTextModel.setPropertyValue ("Label", "Player ~level:")
oDialogModel.insertByName ("txtPlayerLevel", oTextModel)
' Adds the player level field.
ReDim mListItems (39) As String
For nI = 0 To UBound (mListItems)
mListItems (nI) = CStr (nI + 1)
Next nI
oListModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlListBoxModel")
oListModel.setPropertyValue ("PositionX", 195)
oListModel.setPropertyValue ("PositionY", 19)
oListModel.setPropertyValue ("Height", 12)
oListModel.setPropertyValue ("Width", 20)
oListModel.setPropertyValue ("Dropdown", True)
oListModel.setPropertyValue ("StringItemList", mListItems)
oDialogModel.insertByName ("lstPlayerLevel", oListModel)
' Adds the whether powered-up check box.
oCheckBoxModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlCheckBoxModel")
oCheckBoxModel.setPropertyValue ("PositionX", 5)
oCheckBoxModel.setPropertyValue ("PositionY", 35)
oCheckBoxModel.setPropertyValue ("Height", 12)
oCheckBoxModel.setPropertyValue ("Width", 210)
oCheckBoxModel.setPropertyValue ("Label", _
"This Pokémon is ~newly-caught and was not powered-up yet.")
oCheckBoxModel.setPropertyValue ("State", 1)
oDialogModel.insertByName ("cbxIsNew", oCheckBoxModel)
' Adds a group for the appraisals
oGroupModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlGroupBoxModel")
oGroupModel.setPropertyValue ("PositionX", 5)
oGroupModel.setPropertyValue ("PositionY", 50)
oGroupModel.setPropertyValue ("Height", 65)
oGroupModel.setPropertyValue ("Width", 210)
oGroupModel.setPropertyValue ("Label", "Apprasals")
oDialogModel.insertByName ("grpApprasals", oGroupModel)
' Adds the first appraisal list.
mListItems = Array ( _
"1. Amazed me/wonder/best", _
"2. Strong/caught my attention", _
"3. Decent/above average", _
"4. Not great/not make headway/has room")
oListModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlListBoxModel")
oListModel.setPropertyValue ("PositionX", 10)
oListModel.setPropertyValue ("PositionY", 64)
oListModel.setPropertyValue ("Height", 12)
oListModel.setPropertyValue ("Width", 200)
oListModel.setPropertyValue ("Dropdown", True)
oListModel.setPropertyValue ("StringItemList", mListItems)
oDialogModel.insertByName ("lstApprasal1", oListModel)
' Adds a text label for the HP field.
oTextModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlFixedTextModel")
oTextModel.setPropertyValue ("PositionX", 10)
oTextModel.setPropertyValue ("PositionY", 80)
oTextModel.setPropertyValue ("Height", 12)
oTextModel.setPropertyValue ("Width", 15)
oTextModel.setPropertyValue ("Label", "Best:")
oDialogModel.insertByName ("txtBest", oTextModel)
' Adds the attack is best check box
oCheckBoxModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlCheckBoxModel")
oCheckBoxModel.setPropertyValue ("PositionX", 25)
oCheckBoxModel.setPropertyValue ("PositionY", 80)
oCheckBoxModel.setPropertyValue ("Height", 12)
oCheckBoxModel.setPropertyValue ("Width", 30)
oCheckBoxModel.setPropertyValue ("Label", "~Attack")
oDialogModel.insertByName ("cbxAttackBest", oCheckBoxModel)
' Adds the defense is best check box
oCheckBoxModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlCheckBoxModel")
oCheckBoxModel.setPropertyValue ("PositionX", 55)
oCheckBoxModel.setPropertyValue ("PositionY", 80)
oCheckBoxModel.setPropertyValue ("Height", 12)
oCheckBoxModel.setPropertyValue ("Width", 35)
oCheckBoxModel.setPropertyValue ("Label", "~Defense")
oDialogModel.insertByName ("cbxDefenseBest", oCheckBoxModel)
' Adds the defense is best check box
oCheckBoxModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlCheckBoxModel")
oCheckBoxModel.setPropertyValue ("PositionX", 90)
oCheckBoxModel.setPropertyValue ("PositionY", 80)
oCheckBoxModel.setPropertyValue ("Height", 12)
oCheckBoxModel.setPropertyValue ("Width", 45)
oCheckBoxModel.setPropertyValue ("Label", "HP (~Stamina)")
oDialogModel.insertByName ("cbxHPBest", oCheckBoxModel)
' Adds the second appraisal list.
mListItems = Array ( _
"1. WOW/incredible/stats are best", _
"2. Excellent/impressed/impressive", _
"3. Get the job done/noticeable/some good stats", _
"4. No greatness/not out of the norm/kinda basic")
oListModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlListBoxModel")
oListModel.setPropertyValue ("PositionX", 10)
oListModel.setPropertyValue ("PositionY", 95)
oListModel.setPropertyValue ("Height", 12)
oListModel.setPropertyValue ("Width", 200)
oListModel.setPropertyValue ("Dropdown", True)
oListModel.setPropertyValue ("StringItemList", mListItems)
oDialogModel.insertByName ("lstApprasal2", oListModel)
' Adds the OK button.
oButtonModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlButtonModel")
oButtonModel.setPropertyValue ("PositionX", 35)
oButtonModel.setPropertyValue ("PositionY", 120)
oButtonModel.setPropertyValue ("Height", 15)
oButtonModel.setPropertyValue ("Width", 60)
oButtonModel.setPropertyValue ("PushButtonType", _
com.sun.star.awt.PushButtonType.OK)
oButtonModel.setPropertyValue ("DefaultButton", True)
oDialogModel.insertByName ("btnOK", oButtonModel)
' Adds the cancel button.
oButtonModel = oDialogModel.createInstance ( _
"com.sun.star.awt.UnoControlButtonModel")
oButtonModel.setPropertyValue ("PositionX", 125)
oButtonModel.setPropertyValue ("PositionY", 120)
oButtonModel.setPropertyValue ("Height", 15)
oButtonModel.setPropertyValue ("Width", 60)
oButtonModel.setPropertyValue ("PushButtonType", _
com.sun.star.awt.PushButtonType.CANCEL)
oDialogModel.insertByName ("btnCancel", oButtonModel)
' Adds the dialog model to the control and runs it.
oDialog = CreateUnoService ("com.sun.star.awt.UnoControlDialog")
oDialog.setModel (oDialogModel)
oDialog.setVisible (True)
oDialog.getControl ("lstPokemon").setFocus
If oDialog.execute = 0 Then
aQuery.bIsCancelled = True
fnAskParam = aQuery
Exit Function
End If
With aQuery
.sPokemon = oDialog.getControl ("lstPokemon").getSelectedItem
.nCP = oDialog.getControl ("numCP").getValue
.nHP = oDialog.getControl ("numHP").getValue
.nStarDust = CInt (oDialog.getControl ("lstStarDust").getSelectedItem)
.nPlayerLevel = CInt (oDialog.getControl ("lstPlayerLevel").getSelectedItem)
.nAppraisal1 = oDialog.getControl ("lstApprasal1").getSelectedItemPos + 1
.nAppraisal2 = oDialog.getControl ("lstApprasal2").getSelectedItemPos + 1
.bIsCancelled = False
End With
If oDialog.getControl ("cbxIsNew").getState = 1 Then
aQuery.bIsNew = True
Else
aQuery.bIsNew = False
End If
aQuery.sBest = ""
If oDialog.getControl ("cbxAttackBest").getState = 1 Then
aQuery.sBest = aQuery.sBest & "Atk "
End If
If oDialog.getControl ("cbxDefenseBest").getState = 1 Then
aQuery.sBest = aQuery.sBest & "Def "
End If
If oDialog.getControl ("cbxHPBest").getState = 1 Then
aQuery.sBest = aQuery.sBest & "Sta "
End If
fnAskParam = aQuery
End Function
sub subBtnOK_actionPerformed
MsgBox "OK"
End Sub
sub subBtnOK_disposing
MsgBox "OK"
End Sub

View File

@ -1,4 +1,4 @@
' 3Load: The Pokémon Go IV data ' 9Load: The Pokémon Go data sheets loader
' by imacat <imacat@mail.imacat.idv.tw>, 2016-11-28 ' by imacat <imacat@mail.imacat.idv.tw>, 2016-11-28
Option Explicit Option Explicit
@ -9,9 +9,9 @@ Sub subReadDataSheets
Dim sOutput as String, mData As Variant Dim sOutput as String, mData As Variant
sOutput = "" _ sOutput = "" _
& "' 2Data: The Pokémon Go data for IV calculation" & Chr (10) _ & "' 1Data: The Pokémon Go data for IV calculation" & Chr (10) _
& "' by imacat <imacat@mail.imacat.idv.tw>, " & Format (Date (), "yyyy-mm-dd") & Chr (10) _ & "' by imacat <imacat@mail.imacat.idv.tw>, " & Format (Date (), "yyyy-mm-dd") & Chr (10) _
& "' Generated with _3Load.subReadDataSheets ()" & Chr (10) _ & "' Generated with 9Load.subReadDataSheets ()" & Chr (10) _
& Chr (10) _ & Chr (10) _
& "Option Explicit" & "Option Explicit"
sOutput = sOutput & Chr (10) & Chr (10) & fnReadBaseStatsSheet sOutput = sOutput & Chr (10) & Chr (10) & fnReadBaseStatsSheet

View File

@ -77,6 +77,306 @@ Sub subMain
End If End If
End Sub End Sub
&apos; fnAskParam: Asks the users for the parameters for the Pokémon.
Function fnAskParam As aFindIVParam
Dim oDialog As Object, oDialogModel As Object
Dim oTextModel As Object, oListModel As Object
Dim oNumericModel As Object, oCheckBoxModel As Object
Dim oGroupModel As Object, oButtonModel As Object
Dim mListItems () As String, sTemp As String
Dim nI As Integer, nCount As Integer
Dim aQuery As New aFindIVParam
&apos; Creates a dialog
oDialogModel = CreateUnoService ( _
&quot;com.sun.star.awt.UnoControlDialogModel&quot;)
oDialogModel.setPropertyValue (&quot;PositionX&quot;, 100)
oDialogModel.setPropertyValue (&quot;PositionY&quot;, 100)
oDialogModel.setPropertyValue (&quot;Height&quot;, 140)
oDialogModel.setPropertyValue (&quot;Width&quot;, 220)
oDialogModel.setPropertyValue (&quot;Title&quot;, &quot;Pokémon Go IV Calculator&quot;)
&apos; Adds a text label for the Pokémon list.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 5)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 5)
oTextModel.setPropertyValue (&quot;Height&quot;, 12)
oTextModel.setPropertyValue (&quot;Width&quot;, 30)
oTextModel.setPropertyValue (&quot;Label&quot;, &quot;~Pokémon:&quot;)
oDialogModel.insertByName (&quot;txtPokemon&quot;, oTextModel)
&apos; Adds the Pokémon list.
subReadBaseStats
ReDim mListItems (UBound (maBaseStats)) As String
For nI = 0 To UBound (maBaseStats)
mListItems (nI) = maBaseStats (nI).sPokemon
Next nI
oListModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlListBoxModel&quot;)
oListModel.setPropertyValue (&quot;PositionX&quot;, 35)
oListModel.setPropertyValue (&quot;PositionY&quot;, 4)
oListModel.setPropertyValue (&quot;Height&quot;, 12)
oListModel.setPropertyValue (&quot;Width&quot;, 50)
oListModel.setPropertyValue (&quot;TabIndex&quot;, 0)
oListModel.setPropertyValue (&quot;Dropdown&quot;, True)
oListModel.setPropertyValue (&quot;StringItemList&quot;, mListItems)
oDialogModel.insertByName (&quot;lstPokemon&quot;, oListModel)
&apos; Adds a text label for the CP field.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 5)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 20)
oTextModel.setPropertyValue (&quot;Height&quot;, 12)
oTextModel.setPropertyValue (&quot;Width&quot;, 15)
oTextModel.setPropertyValue (&quot;Label&quot;, &quot;~CP:&quot;)
oDialogModel.insertByName (&quot;txtCP&quot;, oTextModel)
&apos; Adds the CP field.
oNumericModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlNumericFieldModel&quot;)
oNumericModel.setPropertyValue (&quot;PositionX&quot;, 20)
oNumericModel.setPropertyValue (&quot;PositionY&quot;, 19)
oNumericModel.setPropertyValue (&quot;Height&quot;, 12)
oNumericModel.setPropertyValue (&quot;Width&quot;, 20)
oNumericModel.setPropertyValue (&quot;DecimalAccuracy&quot;, 0)
oDialogModel.insertByName (&quot;numCP&quot;, oNumericModel)
&apos; Adds a text label for the HP field.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 50)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 20)
oTextModel.setPropertyValue (&quot;Height&quot;, 12)
oTextModel.setPropertyValue (&quot;Width&quot;, 15)
oTextModel.setPropertyValue (&quot;Label&quot;, &quot;~HP:&quot;)
oDialogModel.insertByName (&quot;txtHP&quot;, oTextModel)
&apos; Adds the HP field.
oNumericModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlNumericFieldModel&quot;)
oNumericModel.setPropertyValue (&quot;PositionX&quot;, 65)
oNumericModel.setPropertyValue (&quot;PositionY&quot;, 19)
oNumericModel.setPropertyValue (&quot;Height&quot;, 12)
oNumericModel.setPropertyValue (&quot;Width&quot;, 15)
oNumericModel.setPropertyValue (&quot;DecimalAccuracy&quot;, 0)
oDialogModel.insertByName (&quot;numHP&quot;, oNumericModel)
&apos; Adds a text label for the star dust field.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 90)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 20)
oTextModel.setPropertyValue (&quot;Height&quot;, 12)
oTextModel.setPropertyValue (&quot;Width&quot;, 30)
oTextModel.setPropertyValue (&quot;Label&quot;, &quot;S~tar dust:&quot;)
oDialogModel.insertByName (&quot;txtStarDust&quot;, oTextModel)
&apos; Adds the star dust field.
subReadStarDust
sTemp = &quot; &quot;
ReDim mListItems () As String
nCount = -1
For nI = 1 To UBound (mStarDust)
If InStr (sTemp, &quot; &quot; &amp; CStr (mStarDust (nI)) &amp; &quot; &quot;) = 0 Then
nCount = nCount + 1
ReDim Preserve mListItems (nCount) As String
mListItems (nCount) = CStr (mStarDust (nI))
sTemp = sTemp &amp; CStr (mStarDust (nI)) &amp; &quot; &quot;
End If
Next nI
oListModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlListBoxModel&quot;)
oListModel.setPropertyValue (&quot;PositionX&quot;, 120)
oListModel.setPropertyValue (&quot;PositionY&quot;, 19)
oListModel.setPropertyValue (&quot;Height&quot;, 12)
oListModel.setPropertyValue (&quot;Width&quot;, 30)
oListModel.setPropertyValue (&quot;Dropdown&quot;, True)
oListModel.setPropertyValue (&quot;StringItemList&quot;, mListItems)
oDialogModel.insertByName (&quot;lstStarDust&quot;, oListModel)
&apos; Adds a text label for the player level field.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 160)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 20)
oTextModel.setPropertyValue (&quot;Height&quot;, 12)
oTextModel.setPropertyValue (&quot;Width&quot;, 35)
oTextModel.setPropertyValue (&quot;Label&quot;, &quot;Player ~level:&quot;)
oDialogModel.insertByName (&quot;txtPlayerLevel&quot;, oTextModel)
&apos; Adds the player level field.
ReDim mListItems (39) As String
For nI = 0 To UBound (mListItems)
mListItems (nI) = CStr (nI + 1)
Next nI
oListModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlListBoxModel&quot;)
oListModel.setPropertyValue (&quot;PositionX&quot;, 195)
oListModel.setPropertyValue (&quot;PositionY&quot;, 19)
oListModel.setPropertyValue (&quot;Height&quot;, 12)
oListModel.setPropertyValue (&quot;Width&quot;, 20)
oListModel.setPropertyValue (&quot;Dropdown&quot;, True)
oListModel.setPropertyValue (&quot;StringItemList&quot;, mListItems)
oDialogModel.insertByName (&quot;lstPlayerLevel&quot;, oListModel)
&apos; Adds the whether powered-up check box.
oCheckBoxModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlCheckBoxModel&quot;)
oCheckBoxModel.setPropertyValue (&quot;PositionX&quot;, 5)
oCheckBoxModel.setPropertyValue (&quot;PositionY&quot;, 35)
oCheckBoxModel.setPropertyValue (&quot;Height&quot;, 12)
oCheckBoxModel.setPropertyValue (&quot;Width&quot;, 210)
oCheckBoxModel.setPropertyValue (&quot;Label&quot;, _
&quot;This Pokémon is ~newly-caught and was not powered-up yet.&quot;)
oCheckBoxModel.setPropertyValue (&quot;State&quot;, 1)
oDialogModel.insertByName (&quot;cbxIsNew&quot;, oCheckBoxModel)
&apos; Adds a group for the appraisals
oGroupModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlGroupBoxModel&quot;)
oGroupModel.setPropertyValue (&quot;PositionX&quot;, 5)
oGroupModel.setPropertyValue (&quot;PositionY&quot;, 50)
oGroupModel.setPropertyValue (&quot;Height&quot;, 65)
oGroupModel.setPropertyValue (&quot;Width&quot;, 210)
oGroupModel.setPropertyValue (&quot;Label&quot;, &quot;Apprasals&quot;)
oDialogModel.insertByName (&quot;grpApprasals&quot;, oGroupModel)
&apos; Adds the first appraisal list.
mListItems = Array ( _
&quot;1. Amazed me/wonder/best&quot;, _
&quot;2. Strong/caught my attention&quot;, _
&quot;3. Decent/above average&quot;, _
&quot;4. Not great/not make headway/has room&quot;)
oListModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlListBoxModel&quot;)
oListModel.setPropertyValue (&quot;PositionX&quot;, 10)
oListModel.setPropertyValue (&quot;PositionY&quot;, 64)
oListModel.setPropertyValue (&quot;Height&quot;, 12)
oListModel.setPropertyValue (&quot;Width&quot;, 200)
oListModel.setPropertyValue (&quot;Dropdown&quot;, True)
oListModel.setPropertyValue (&quot;StringItemList&quot;, mListItems)
oDialogModel.insertByName (&quot;lstApprasal1&quot;, oListModel)
&apos; Adds a text label for the HP field.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 10)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 80)
oTextModel.setPropertyValue (&quot;Height&quot;, 12)
oTextModel.setPropertyValue (&quot;Width&quot;, 15)
oTextModel.setPropertyValue (&quot;Label&quot;, &quot;Best:&quot;)
oDialogModel.insertByName (&quot;txtBest&quot;, oTextModel)
&apos; Adds the attack is best check box
oCheckBoxModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlCheckBoxModel&quot;)
oCheckBoxModel.setPropertyValue (&quot;PositionX&quot;, 25)
oCheckBoxModel.setPropertyValue (&quot;PositionY&quot;, 80)
oCheckBoxModel.setPropertyValue (&quot;Height&quot;, 12)
oCheckBoxModel.setPropertyValue (&quot;Width&quot;, 30)
oCheckBoxModel.setPropertyValue (&quot;Label&quot;, &quot;~Attack&quot;)
oDialogModel.insertByName (&quot;cbxAttackBest&quot;, oCheckBoxModel)
&apos; Adds the defense is best check box
oCheckBoxModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlCheckBoxModel&quot;)
oCheckBoxModel.setPropertyValue (&quot;PositionX&quot;, 55)
oCheckBoxModel.setPropertyValue (&quot;PositionY&quot;, 80)
oCheckBoxModel.setPropertyValue (&quot;Height&quot;, 12)
oCheckBoxModel.setPropertyValue (&quot;Width&quot;, 35)
oCheckBoxModel.setPropertyValue (&quot;Label&quot;, &quot;~Defense&quot;)
oDialogModel.insertByName (&quot;cbxDefenseBest&quot;, oCheckBoxModel)
&apos; Adds the defense is best check box
oCheckBoxModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlCheckBoxModel&quot;)
oCheckBoxModel.setPropertyValue (&quot;PositionX&quot;, 90)
oCheckBoxModel.setPropertyValue (&quot;PositionY&quot;, 80)
oCheckBoxModel.setPropertyValue (&quot;Height&quot;, 12)
oCheckBoxModel.setPropertyValue (&quot;Width&quot;, 45)
oCheckBoxModel.setPropertyValue (&quot;Label&quot;, &quot;HP (~Stamina)&quot;)
oDialogModel.insertByName (&quot;cbxHPBest&quot;, oCheckBoxModel)
&apos; Adds the second appraisal list.
mListItems = Array ( _
&quot;1. WOW/incredible/stats are best&quot;, _
&quot;2. Excellent/impressed/impressive&quot;, _
&quot;3. Get the job done/noticeable/some good stats&quot;, _
&quot;4. No greatness/not out of the norm/kinda basic&quot;)
oListModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlListBoxModel&quot;)
oListModel.setPropertyValue (&quot;PositionX&quot;, 10)
oListModel.setPropertyValue (&quot;PositionY&quot;, 95)
oListModel.setPropertyValue (&quot;Height&quot;, 12)
oListModel.setPropertyValue (&quot;Width&quot;, 200)
oListModel.setPropertyValue (&quot;Dropdown&quot;, True)
oListModel.setPropertyValue (&quot;StringItemList&quot;, mListItems)
oDialogModel.insertByName (&quot;lstApprasal2&quot;, oListModel)
&apos; Adds the OK button.
oButtonModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlButtonModel&quot;)
oButtonModel.setPropertyValue (&quot;PositionX&quot;, 35)
oButtonModel.setPropertyValue (&quot;PositionY&quot;, 120)
oButtonModel.setPropertyValue (&quot;Height&quot;, 15)
oButtonModel.setPropertyValue (&quot;Width&quot;, 60)
oButtonModel.setPropertyValue (&quot;PushButtonType&quot;, _
com.sun.star.awt.PushButtonType.OK)
oButtonModel.setPropertyValue (&quot;DefaultButton&quot;, True)
oDialogModel.insertByName (&quot;btnOK&quot;, oButtonModel)
&apos; Adds the cancel button.
oButtonModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlButtonModel&quot;)
oButtonModel.setPropertyValue (&quot;PositionX&quot;, 125)
oButtonModel.setPropertyValue (&quot;PositionY&quot;, 120)
oButtonModel.setPropertyValue (&quot;Height&quot;, 15)
oButtonModel.setPropertyValue (&quot;Width&quot;, 60)
oButtonModel.setPropertyValue (&quot;PushButtonType&quot;, _
com.sun.star.awt.PushButtonType.CANCEL)
oDialogModel.insertByName (&quot;btnCancel&quot;, oButtonModel)
&apos; Adds the dialog model to the control and runs it.
oDialog = CreateUnoService (&quot;com.sun.star.awt.UnoControlDialog&quot;)
oDialog.setModel (oDialogModel)
oDialog.setVisible (True)
oDialog.getControl (&quot;lstPokemon&quot;).setFocus
If oDialog.execute = 0 Then
aQuery.bIsCancelled = True
fnAskParam = aQuery
Exit Function
End If
With aQuery
.sPokemon = oDialog.getControl (&quot;lstPokemon&quot;).getSelectedItem
.nCP = oDialog.getControl (&quot;numCP&quot;).getValue
.nHP = oDialog.getControl (&quot;numHP&quot;).getValue
.nStarDust = CInt (oDialog.getControl (&quot;lstStarDust&quot;).getSelectedItem)
.nPlayerLevel = CInt (oDialog.getControl (&quot;lstPlayerLevel&quot;).getSelectedItem)
.nAppraisal1 = oDialog.getControl (&quot;lstApprasal1&quot;).getSelectedItemPos + 1
.nAppraisal2 = oDialog.getControl (&quot;lstApprasal2&quot;).getSelectedItemPos + 1
.bIsCancelled = False
End With
If oDialog.getControl (&quot;cbxIsNew&quot;).getState = 1 Then
aQuery.bIsNew = True
Else
aQuery.bIsNew = False
End If
aQuery.sBest = &quot;&quot;
If oDialog.getControl (&quot;cbxAttackBest&quot;).getState = 1 Then
aQuery.sBest = aQuery.sBest &amp; &quot;Atk &quot;
End If
If oDialog.getControl (&quot;cbxDefenseBest&quot;).getState = 1 Then
aQuery.sBest = aQuery.sBest &amp; &quot;Def &quot;
End If
If oDialog.getControl (&quot;cbxHPBest&quot;).getState = 1 Then
aQuery.sBest = aQuery.sBest &amp; &quot;Sta &quot;
End If
fnAskParam = aQuery
End Function
&apos; fnFindIV: Finds the possible individual values of the Pokémon &apos; fnFindIV: Finds the possible individual values of the Pokémon
Function fnFindIV (aQuery As aFindIVParam) As Variant Function fnFindIV (aQuery As aFindIVParam) As Variant
Dim aBaseStats As New aStats, maIV () As New aStats Dim aBaseStats As New aStats, maIV () As New aStats

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="2Data" script:language="StarBasic">&apos; 2Data: The Pokémon Go data for IV calculation <script:module xmlns:script="http://openoffice.org/2000/script" script:name="1Data" script:language="StarBasic">&apos; 1Data: The Pokémon Go data for IV calculation
&apos; by imacat &lt;imacat@mail.imacat.idv.tw&gt;, 2016-11-28 &apos; by imacat &lt;imacat@mail.imacat.idv.tw&gt;, 2016-11-28
&apos; Generated with _3Load.subReadDataSheets () &apos; Generated with 9Load.subReadDataSheets ()
Option Explicit Option Explicit

View File

@ -1,329 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="1Dialog" script:language="StarBasic">&apos; 1Dialog: The UI of the Pokémon IV calculator
&apos; by imacat &lt;imacat@mail.imacat.idv.tw&gt;, 2016-11-27
Option Explicit
&apos; The parameters to find the individual values.
Type aFindIVParam
sPokemon As String
nCP As Integer
nHP As Integer
nStarDust As Integer
nPlayerLevel As Integer
bIsNew As Boolean
nAppraisal1 As Integer
sBest As String
nAppraisal2 As Integer
bIsCancelled As Boolean
End Type
&apos; fnAskParam: Asks the users for the parameters for the Pokémon.
Function fnAskParam As aFindIVParam
Dim oDialog As Object, oDialogModel As Object
Dim oTextModel As Object, oListModel As Object
Dim oNumericModel As Object, oCheckBoxModel As Object
Dim oGroupModel As Object, oButtonModel As Object
Dim mListItems () As String, sTemp As String
Dim nI As Integer, nCount As Integer
Dim aQuery As New aFindIVParam
&apos; Creates a dialog
oDialogModel = CreateUnoService ( _
&quot;com.sun.star.awt.UnoControlDialogModel&quot;)
oDialogModel.setPropertyValue (&quot;PositionX&quot;, 100)
oDialogModel.setPropertyValue (&quot;PositionY&quot;, 100)
oDialogModel.setPropertyValue (&quot;Height&quot;, 140)
oDialogModel.setPropertyValue (&quot;Width&quot;, 220)
oDialogModel.setPropertyValue (&quot;Title&quot;, &quot;Pokémon Go IV Calculator&quot;)
&apos; Adds a text label for the Pokémon list.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 5)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 5)
oTextModel.setPropertyValue (&quot;Height&quot;, 12)
oTextModel.setPropertyValue (&quot;Width&quot;, 30)
oTextModel.setPropertyValue (&quot;Label&quot;, &quot;~Pokémon:&quot;)
oDialogModel.insertByName (&quot;txtPokemon&quot;, oTextModel)
&apos; Adds the Pokémon list.
subReadBaseStats
ReDim mListItems (UBound (maBaseStats)) As String
For nI = 0 To UBound (maBaseStats)
mListItems (nI) = maBaseStats (nI).sPokemon
Next nI
oListModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlListBoxModel&quot;)
oListModel.setPropertyValue (&quot;PositionX&quot;, 35)
oListModel.setPropertyValue (&quot;PositionY&quot;, 4)
oListModel.setPropertyValue (&quot;Height&quot;, 12)
oListModel.setPropertyValue (&quot;Width&quot;, 50)
oListModel.setPropertyValue (&quot;TabIndex&quot;, 0)
oListModel.setPropertyValue (&quot;Dropdown&quot;, True)
oListModel.setPropertyValue (&quot;StringItemList&quot;, mListItems)
oDialogModel.insertByName (&quot;lstPokemon&quot;, oListModel)
&apos; Adds a text label for the CP field.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 5)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 20)
oTextModel.setPropertyValue (&quot;Height&quot;, 12)
oTextModel.setPropertyValue (&quot;Width&quot;, 15)
oTextModel.setPropertyValue (&quot;Label&quot;, &quot;~CP:&quot;)
oDialogModel.insertByName (&quot;txtCP&quot;, oTextModel)
&apos; Adds the CP field.
oNumericModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlNumericFieldModel&quot;)
oNumericModel.setPropertyValue (&quot;PositionX&quot;, 20)
oNumericModel.setPropertyValue (&quot;PositionY&quot;, 19)
oNumericModel.setPropertyValue (&quot;Height&quot;, 12)
oNumericModel.setPropertyValue (&quot;Width&quot;, 20)
oNumericModel.setPropertyValue (&quot;DecimalAccuracy&quot;, 0)
oDialogModel.insertByName (&quot;numCP&quot;, oNumericModel)
&apos; Adds a text label for the HP field.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 50)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 20)
oTextModel.setPropertyValue (&quot;Height&quot;, 12)
oTextModel.setPropertyValue (&quot;Width&quot;, 15)
oTextModel.setPropertyValue (&quot;Label&quot;, &quot;~HP:&quot;)
oDialogModel.insertByName (&quot;txtHP&quot;, oTextModel)
&apos; Adds the HP field.
oNumericModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlNumericFieldModel&quot;)
oNumericModel.setPropertyValue (&quot;PositionX&quot;, 65)
oNumericModel.setPropertyValue (&quot;PositionY&quot;, 19)
oNumericModel.setPropertyValue (&quot;Height&quot;, 12)
oNumericModel.setPropertyValue (&quot;Width&quot;, 15)
oNumericModel.setPropertyValue (&quot;DecimalAccuracy&quot;, 0)
oDialogModel.insertByName (&quot;numHP&quot;, oNumericModel)
&apos; Adds a text label for the star dust field.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 90)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 20)
oTextModel.setPropertyValue (&quot;Height&quot;, 12)
oTextModel.setPropertyValue (&quot;Width&quot;, 30)
oTextModel.setPropertyValue (&quot;Label&quot;, &quot;S~tar dust:&quot;)
oDialogModel.insertByName (&quot;txtStarDust&quot;, oTextModel)
&apos; Adds the star dust field.
subReadStarDust
sTemp = &quot; &quot;
ReDim mListItems () As String
nCount = -1
For nI = 1 To UBound (mStarDust)
If InStr (sTemp, &quot; &quot; &amp; CStr (mStarDust (nI)) &amp; &quot; &quot;) = 0 Then
nCount = nCount + 1
ReDim Preserve mListItems (nCount) As String
mListItems (nCount) = CStr (mStarDust (nI))
sTemp = sTemp &amp; CStr (mStarDust (nI)) &amp; &quot; &quot;
End If
Next nI
oListModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlListBoxModel&quot;)
oListModel.setPropertyValue (&quot;PositionX&quot;, 120)
oListModel.setPropertyValue (&quot;PositionY&quot;, 19)
oListModel.setPropertyValue (&quot;Height&quot;, 12)
oListModel.setPropertyValue (&quot;Width&quot;, 30)
oListModel.setPropertyValue (&quot;Dropdown&quot;, True)
oListModel.setPropertyValue (&quot;StringItemList&quot;, mListItems)
oDialogModel.insertByName (&quot;lstStarDust&quot;, oListModel)
&apos; Adds a text label for the player level field.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 160)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 20)
oTextModel.setPropertyValue (&quot;Height&quot;, 12)
oTextModel.setPropertyValue (&quot;Width&quot;, 35)
oTextModel.setPropertyValue (&quot;Label&quot;, &quot;Player ~level:&quot;)
oDialogModel.insertByName (&quot;txtPlayerLevel&quot;, oTextModel)
&apos; Adds the player level field.
ReDim mListItems (39) As String
For nI = 0 To UBound (mListItems)
mListItems (nI) = CStr (nI + 1)
Next nI
oListModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlListBoxModel&quot;)
oListModel.setPropertyValue (&quot;PositionX&quot;, 195)
oListModel.setPropertyValue (&quot;PositionY&quot;, 19)
oListModel.setPropertyValue (&quot;Height&quot;, 12)
oListModel.setPropertyValue (&quot;Width&quot;, 20)
oListModel.setPropertyValue (&quot;Dropdown&quot;, True)
oListModel.setPropertyValue (&quot;StringItemList&quot;, mListItems)
oDialogModel.insertByName (&quot;lstPlayerLevel&quot;, oListModel)
&apos; Adds the whether powered-up check box.
oCheckBoxModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlCheckBoxModel&quot;)
oCheckBoxModel.setPropertyValue (&quot;PositionX&quot;, 5)
oCheckBoxModel.setPropertyValue (&quot;PositionY&quot;, 35)
oCheckBoxModel.setPropertyValue (&quot;Height&quot;, 12)
oCheckBoxModel.setPropertyValue (&quot;Width&quot;, 210)
oCheckBoxModel.setPropertyValue (&quot;Label&quot;, _
&quot;This Pokémon is ~newly-caught and was not powered-up yet.&quot;)
oCheckBoxModel.setPropertyValue (&quot;State&quot;, 1)
oDialogModel.insertByName (&quot;cbxIsNew&quot;, oCheckBoxModel)
&apos; Adds a group for the appraisals
oGroupModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlGroupBoxModel&quot;)
oGroupModel.setPropertyValue (&quot;PositionX&quot;, 5)
oGroupModel.setPropertyValue (&quot;PositionY&quot;, 50)
oGroupModel.setPropertyValue (&quot;Height&quot;, 65)
oGroupModel.setPropertyValue (&quot;Width&quot;, 210)
oGroupModel.setPropertyValue (&quot;Label&quot;, &quot;Apprasals&quot;)
oDialogModel.insertByName (&quot;grpApprasals&quot;, oGroupModel)
&apos; Adds the first appraisal list.
mListItems = Array ( _
&quot;1. Amazed me/wonder/best&quot;, _
&quot;2. Strong/caught my attention&quot;, _
&quot;3. Decent/above average&quot;, _
&quot;4. Not great/not make headway/has room&quot;)
oListModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlListBoxModel&quot;)
oListModel.setPropertyValue (&quot;PositionX&quot;, 10)
oListModel.setPropertyValue (&quot;PositionY&quot;, 64)
oListModel.setPropertyValue (&quot;Height&quot;, 12)
oListModel.setPropertyValue (&quot;Width&quot;, 200)
oListModel.setPropertyValue (&quot;Dropdown&quot;, True)
oListModel.setPropertyValue (&quot;StringItemList&quot;, mListItems)
oDialogModel.insertByName (&quot;lstApprasal1&quot;, oListModel)
&apos; Adds a text label for the HP field.
oTextModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlFixedTextModel&quot;)
oTextModel.setPropertyValue (&quot;PositionX&quot;, 10)
oTextModel.setPropertyValue (&quot;PositionY&quot;, 80)
oTextModel.setPropertyValue (&quot;Height&quot;, 12)
oTextModel.setPropertyValue (&quot;Width&quot;, 15)
oTextModel.setPropertyValue (&quot;Label&quot;, &quot;Best:&quot;)
oDialogModel.insertByName (&quot;txtBest&quot;, oTextModel)
&apos; Adds the attack is best check box
oCheckBoxModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlCheckBoxModel&quot;)
oCheckBoxModel.setPropertyValue (&quot;PositionX&quot;, 25)
oCheckBoxModel.setPropertyValue (&quot;PositionY&quot;, 80)
oCheckBoxModel.setPropertyValue (&quot;Height&quot;, 12)
oCheckBoxModel.setPropertyValue (&quot;Width&quot;, 30)
oCheckBoxModel.setPropertyValue (&quot;Label&quot;, &quot;~Attack&quot;)
oDialogModel.insertByName (&quot;cbxAttackBest&quot;, oCheckBoxModel)
&apos; Adds the defense is best check box
oCheckBoxModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlCheckBoxModel&quot;)
oCheckBoxModel.setPropertyValue (&quot;PositionX&quot;, 55)
oCheckBoxModel.setPropertyValue (&quot;PositionY&quot;, 80)
oCheckBoxModel.setPropertyValue (&quot;Height&quot;, 12)
oCheckBoxModel.setPropertyValue (&quot;Width&quot;, 35)
oCheckBoxModel.setPropertyValue (&quot;Label&quot;, &quot;~Defense&quot;)
oDialogModel.insertByName (&quot;cbxDefenseBest&quot;, oCheckBoxModel)
&apos; Adds the defense is best check box
oCheckBoxModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlCheckBoxModel&quot;)
oCheckBoxModel.setPropertyValue (&quot;PositionX&quot;, 90)
oCheckBoxModel.setPropertyValue (&quot;PositionY&quot;, 80)
oCheckBoxModel.setPropertyValue (&quot;Height&quot;, 12)
oCheckBoxModel.setPropertyValue (&quot;Width&quot;, 45)
oCheckBoxModel.setPropertyValue (&quot;Label&quot;, &quot;HP (~Stamina)&quot;)
oDialogModel.insertByName (&quot;cbxHPBest&quot;, oCheckBoxModel)
&apos; Adds the second appraisal list.
mListItems = Array ( _
&quot;1. WOW/incredible/stats are best&quot;, _
&quot;2. Excellent/impressed/impressive&quot;, _
&quot;3. Get the job done/noticeable/some good stats&quot;, _
&quot;4. No greatness/not out of the norm/kinda basic&quot;)
oListModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlListBoxModel&quot;)
oListModel.setPropertyValue (&quot;PositionX&quot;, 10)
oListModel.setPropertyValue (&quot;PositionY&quot;, 95)
oListModel.setPropertyValue (&quot;Height&quot;, 12)
oListModel.setPropertyValue (&quot;Width&quot;, 200)
oListModel.setPropertyValue (&quot;Dropdown&quot;, True)
oListModel.setPropertyValue (&quot;StringItemList&quot;, mListItems)
oDialogModel.insertByName (&quot;lstApprasal2&quot;, oListModel)
&apos; Adds the OK button.
oButtonModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlButtonModel&quot;)
oButtonModel.setPropertyValue (&quot;PositionX&quot;, 35)
oButtonModel.setPropertyValue (&quot;PositionY&quot;, 120)
oButtonModel.setPropertyValue (&quot;Height&quot;, 15)
oButtonModel.setPropertyValue (&quot;Width&quot;, 60)
oButtonModel.setPropertyValue (&quot;PushButtonType&quot;, _
com.sun.star.awt.PushButtonType.OK)
oButtonModel.setPropertyValue (&quot;DefaultButton&quot;, True)
oDialogModel.insertByName (&quot;btnOK&quot;, oButtonModel)
&apos; Adds the cancel button.
oButtonModel = oDialogModel.createInstance ( _
&quot;com.sun.star.awt.UnoControlButtonModel&quot;)
oButtonModel.setPropertyValue (&quot;PositionX&quot;, 125)
oButtonModel.setPropertyValue (&quot;PositionY&quot;, 120)
oButtonModel.setPropertyValue (&quot;Height&quot;, 15)
oButtonModel.setPropertyValue (&quot;Width&quot;, 60)
oButtonModel.setPropertyValue (&quot;PushButtonType&quot;, _
com.sun.star.awt.PushButtonType.CANCEL)
oDialogModel.insertByName (&quot;btnCancel&quot;, oButtonModel)
&apos; Adds the dialog model to the control and runs it.
oDialog = CreateUnoService (&quot;com.sun.star.awt.UnoControlDialog&quot;)
oDialog.setModel (oDialogModel)
oDialog.setVisible (True)
oDialog.getControl (&quot;lstPokemon&quot;).setFocus
If oDialog.execute = 0 Then
aQuery.bIsCancelled = True
fnAskParam = aQuery
Exit Function
End If
With aQuery
.sPokemon = oDialog.getControl (&quot;lstPokemon&quot;).getSelectedItem
.nCP = oDialog.getControl (&quot;numCP&quot;).getValue
.nHP = oDialog.getControl (&quot;numHP&quot;).getValue
.nStarDust = CInt (oDialog.getControl (&quot;lstStarDust&quot;).getSelectedItem)
.nPlayerLevel = CInt (oDialog.getControl (&quot;lstPlayerLevel&quot;).getSelectedItem)
.nAppraisal1 = oDialog.getControl (&quot;lstApprasal1&quot;).getSelectedItemPos + 1
.nAppraisal2 = oDialog.getControl (&quot;lstApprasal2&quot;).getSelectedItemPos + 1
.bIsCancelled = False
End With
If oDialog.getControl (&quot;cbxIsNew&quot;).getState = 1 Then
aQuery.bIsNew = True
Else
aQuery.bIsNew = False
End If
aQuery.sBest = &quot;&quot;
If oDialog.getControl (&quot;cbxAttackBest&quot;).getState = 1 Then
aQuery.sBest = aQuery.sBest &amp; &quot;Atk &quot;
End If
If oDialog.getControl (&quot;cbxDefenseBest&quot;).getState = 1 Then
aQuery.sBest = aQuery.sBest &amp; &quot;Def &quot;
End If
If oDialog.getControl (&quot;cbxHPBest&quot;).getState = 1 Then
aQuery.sBest = aQuery.sBest &amp; &quot;Sta &quot;
End If
fnAskParam = aQuery
End Function
sub subBtnOK_actionPerformed
MsgBox &quot;OK&quot;
End Sub
sub subBtnOK_disposing
MsgBox &quot;OK&quot;
End Sub
</script:module>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="3Load" script:language="StarBasic">&apos; 3Load: The Pokémon Go IV data <script:module xmlns:script="http://openoffice.org/2000/script" script:name="9Load" script:language="StarBasic">&apos; 9Load: The Pokémon Go data sheets loader
&apos; by imacat &lt;imacat@mail.imacat.idv.tw&gt;, 2016-11-28 &apos; by imacat &lt;imacat@mail.imacat.idv.tw&gt;, 2016-11-28
Option Explicit Option Explicit
@ -11,9 +11,9 @@ Sub subReadDataSheets
Dim sOutput as String, mData As Variant Dim sOutput as String, mData As Variant
sOutput = &quot;&quot; _ sOutput = &quot;&quot; _
&amp; &quot;&apos; 2Data: The Pokémon Go data for IV calculation&quot; &amp; Chr (10) _ &amp; &quot;&apos; 1Data: The Pokémon Go data for IV calculation&quot; &amp; Chr (10) _
&amp; &quot;&apos; by imacat &lt;imacat@mail.imacat.idv.tw&gt;, &quot; &amp; Format (Date (), &quot;yyyy-mm-dd&quot;) &amp; Chr (10) _ &amp; &quot;&apos; by imacat &lt;imacat@mail.imacat.idv.tw&gt;, &quot; &amp; Format (Date (), &quot;yyyy-mm-dd&quot;) &amp; Chr (10) _
&amp; &quot;&apos; Generated with _3Load.subReadDataSheets ()&quot; &amp; Chr (10) _ &amp; &quot;&apos; Generated with 9Load.subReadDataSheets ()&quot; &amp; Chr (10) _
&amp; Chr (10) _ &amp; Chr (10) _
&amp; &quot;Option Explicit&quot; &amp; &quot;Option Explicit&quot;
sOutput = sOutput &amp; Chr (10) &amp; Chr (10) &amp; fnReadBaseStatsSheet sOutput = sOutput &amp; Chr (10) &amp; Chr (10) &amp; fnReadBaseStatsSheet

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> <!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="PokemonGoIV" library:readonly="false" library:passwordprotected="false"> <library:library xmlns:library="http://openoffice.org/2000/library" library:name="PokemonGoIV" library:readonly="false" library:passwordprotected="false">
<library:element library:name="3Load"/> <library:element library:name="9Load"/>
<library:element library:name="0Main"/> <library:element library:name="0Main"/>
<library:element library:name="1Dialog"/> <library:element library:name="1Data"/>
<library:element library:name="2Data"/>
</library:library> </library:library>