From 15e2d5012e5444d897ede8bca33305d4df5451b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Fri, 24 Mar 2017 16:51:32 +0800 Subject: [PATCH] Moved fnAskParam from 0Main to 1Dialog, to move all UI to 1Dialog and keep only algorithm in 0Main. --- PokemonGoIV/0Main.vb | 79 ------------------------------- PokemonGoIV/1Dialog.vb | 92 +++++++++++++++++++++++++++++++++++-- oxt/PokemonGoIV/0Main.xba | 79 ------------------------------- oxt/PokemonGoIV/1Dialog.xba | 92 +++++++++++++++++++++++++++++++++++-- 4 files changed, 178 insertions(+), 164 deletions(-) diff --git a/PokemonGoIV/0Main.vb b/PokemonGoIV/0Main.vb index 83dbe9c..f7fc9be 100644 --- a/PokemonGoIV/0Main.vb +++ b/PokemonGoIV/0Main.vb @@ -80,85 +80,6 @@ Sub subMain End If End Sub -' fnAskParam: Asks the users for the parameters for the Pokémon. -Function fnAskParam As aFindIVParam - Dim oDialog As Object - Dim oList As Object, mPokemons () As String, nI As Integer - Dim bIsBestAttack As Boolean, bIsBestDefense As Boolean - Dim bIsBestHP As Boolean - Dim aQuery As New aFindIVParam, nSelected As Integer - - oDialog = fnLoadParamDialog - If oDialog.execute = 0 Then - aQuery.bIsCancelled = True - fnAskParam = aQuery - Exit Function - End If - - subReadBaseStats - nSelected = oDialog.getControl ("lstPokemon").getSelectedItemPos - With aQuery - .sPokemonId = maBaseStats (nSelected).sPokemonId - .sPokemonName = 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) - .nTotal = oDialog.getControl ("lstTotal").getSelectedItemPos + 1 - .nMax = oDialog.getControl ("lstMax").getSelectedItemPos + 1 - .bIsCancelled = False - End With - If oDialog.getControl ("cbxIsNew").getState = 1 Then - aQuery.bIsNew = True - Else - aQuery.bIsNew = False - End If - - ' The best stats - bIsBestAttack = False - bIsBestDefense = False - bIsBestHP = False - If oDialog.getControl ("lstBest").getSelectedItemPos = 0 Then - bIsBestAttack = True - If oDialog.getControl ("cbxBest2").getState = 1 Then - bIsBestDefense = True - End If - If oDialog.getControl ("cbxBest3").getState = 1 Then - bIsBestHP = True - End If - End If - If oDialog.getControl ("lstBest").getSelectedItemPos = 1 Then - bIsBestDefense = True - If oDialog.getControl ("cbxBest2").getState = 1 Then - bIsBestAttack = True - End If - If oDialog.getControl ("cbxBest3").getState = 1 Then - bIsBestHP = True - End If - End If - If oDialog.getControl ("lstBest").getSelectedItemPos = 2 Then - bIsBestHP = True - If oDialog.getControl ("cbxBest2").getState = 1 Then - bIsBestAttack = True - End If - If oDialog.getControl ("cbxBest3").getState = 1 Then - bIsBestDefense = True - End If - End If - aQuery.sBest = "" - If bIsBestAttack Then - aQuery.sBest = aQuery.sBest & "Atk " - End If - If bIsBestDefense Then - aQuery.sBest = aQuery.sBest & "Def " - End If - If bIsBestHP Then - aQuery.sBest = aQuery.sBest & "Sta " - End If - - fnAskParam = aQuery -End Function - ' fnFindIV: Finds the possible individual values of the Pokémon Function fnFindIV ( _ aBaseStats As aStats, aQuery As aFindIVParam) As Variant diff --git a/PokemonGoIV/1Dialog.vb b/PokemonGoIV/1Dialog.vb index ef7e1d3..475d377 100644 --- a/PokemonGoIV/1Dialog.vb +++ b/PokemonGoIV/1Dialog.vb @@ -17,9 +17,28 @@ Option Explicit -' fnLoadParamDialog: Loads the parameter dialog. -Function fnLoadParamDialog As Object +' The parameters to find the individual values. +Type aFindIVParam + sPokemonId As String + sPokemonName As String + nCP As Integer + nHP As Integer + nStardust As Integer + nPlayerLevel As Integer + bIsNew As Boolean + nTotal As Integer + sBest As String + nMax 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 + Dim oList As Object, mPokemons () As String, nI As Integer + Dim bIsBestAttack As Boolean, bIsBestDefense As Boolean + Dim bIsBestHP As Boolean + Dim aQuery As New aFindIVParam, nSelected As Integer DialogLibraries.loadLibrary "PokemonGoIV" oDialog = CreateUnoDialog (DialogLibraries.PokemonGoIV.DlgMain) @@ -36,7 +55,74 @@ Function fnLoadParamDialog As Object oDialog.getControl ("imgTeamLogo").getModel.setPropertyValue ( _ "ImageURL", fnGetImageUrl ("Unknown")) - fnLoadParamDialog = oDialog + If oDialog.execute = 0 Then + aQuery.bIsCancelled = True + fnAskParam = aQuery + Exit Function + End If + + subReadBaseStats + nSelected = oDialog.getControl ("lstPokemon").getSelectedItemPos + With aQuery + .sPokemonId = maBaseStats (nSelected).sPokemonId + .sPokemonName = 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) + .nTotal = oDialog.getControl ("lstTotal").getSelectedItemPos + 1 + .nMax = oDialog.getControl ("lstMax").getSelectedItemPos + 1 + .bIsCancelled = False + End With + If oDialog.getControl ("cbxIsNew").getState = 1 Then + aQuery.bIsNew = True + Else + aQuery.bIsNew = False + End If + + ' The best stats + bIsBestAttack = False + bIsBestDefense = False + bIsBestHP = False + If oDialog.getControl ("lstBest").getSelectedItemPos = 0 Then + bIsBestAttack = True + If oDialog.getControl ("cbxBest2").getState = 1 Then + bIsBestDefense = True + End If + If oDialog.getControl ("cbxBest3").getState = 1 Then + bIsBestHP = True + End If + End If + If oDialog.getControl ("lstBest").getSelectedItemPos = 1 Then + bIsBestDefense = True + If oDialog.getControl ("cbxBest2").getState = 1 Then + bIsBestAttack = True + End If + If oDialog.getControl ("cbxBest3").getState = 1 Then + bIsBestHP = True + End If + End If + If oDialog.getControl ("lstBest").getSelectedItemPos = 2 Then + bIsBestHP = True + If oDialog.getControl ("cbxBest2").getState = 1 Then + bIsBestAttack = True + End If + If oDialog.getControl ("cbxBest3").getState = 1 Then + bIsBestDefense = True + End If + End If + aQuery.sBest = "" + If bIsBestAttack Then + aQuery.sBest = aQuery.sBest & "Atk " + End If + If bIsBestDefense Then + aQuery.sBest = aQuery.sBest & "Def " + End If + If bIsBestHP Then + aQuery.sBest = aQuery.sBest & "Sta " + End If + + fnAskParam = aQuery End Function ' subBtnOKCheck: Checks whether the required columns are filled. diff --git a/oxt/PokemonGoIV/0Main.xba b/oxt/PokemonGoIV/0Main.xba index 887a0bb..8cf2aae 100644 --- a/oxt/PokemonGoIV/0Main.xba +++ b/oxt/PokemonGoIV/0Main.xba @@ -82,85 +82,6 @@ Sub subMain End If End Sub -' fnAskParam: Asks the users for the parameters for the Pokémon. -Function fnAskParam As aFindIVParam - Dim oDialog As Object - Dim oList As Object, mPokemons () As String, nI As Integer - Dim bIsBestAttack As Boolean, bIsBestDefense As Boolean - Dim bIsBestHP As Boolean - Dim aQuery As New aFindIVParam, nSelected As Integer - - oDialog = fnLoadParamDialog - If oDialog.execute = 0 Then - aQuery.bIsCancelled = True - fnAskParam = aQuery - Exit Function - End If - - subReadBaseStats - nSelected = oDialog.getControl ("lstPokemon").getSelectedItemPos - With aQuery - .sPokemonId = maBaseStats (nSelected).sPokemonId - .sPokemonName = 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) - .nTotal = oDialog.getControl ("lstTotal").getSelectedItemPos + 1 - .nMax = oDialog.getControl ("lstMax").getSelectedItemPos + 1 - .bIsCancelled = False - End With - If oDialog.getControl ("cbxIsNew").getState = 1 Then - aQuery.bIsNew = True - Else - aQuery.bIsNew = False - End If - - ' The best stats - bIsBestAttack = False - bIsBestDefense = False - bIsBestHP = False - If oDialog.getControl ("lstBest").getSelectedItemPos = 0 Then - bIsBestAttack = True - If oDialog.getControl ("cbxBest2").getState = 1 Then - bIsBestDefense = True - End If - If oDialog.getControl ("cbxBest3").getState = 1 Then - bIsBestHP = True - End If - End If - If oDialog.getControl ("lstBest").getSelectedItemPos = 1 Then - bIsBestDefense = True - If oDialog.getControl ("cbxBest2").getState = 1 Then - bIsBestAttack = True - End If - If oDialog.getControl ("cbxBest3").getState = 1 Then - bIsBestHP = True - End If - End If - If oDialog.getControl ("lstBest").getSelectedItemPos = 2 Then - bIsBestHP = True - If oDialog.getControl ("cbxBest2").getState = 1 Then - bIsBestAttack = True - End If - If oDialog.getControl ("cbxBest3").getState = 1 Then - bIsBestDefense = True - End If - End If - aQuery.sBest = "" - If bIsBestAttack Then - aQuery.sBest = aQuery.sBest & "Atk " - End If - If bIsBestDefense Then - aQuery.sBest = aQuery.sBest & "Def " - End If - If bIsBestHP Then - aQuery.sBest = aQuery.sBest & "Sta " - End If - - fnAskParam = aQuery -End Function - ' fnFindIV: Finds the possible individual values of the Pokémon Function fnFindIV ( _ aBaseStats As aStats, aQuery As aFindIVParam) As Variant diff --git a/oxt/PokemonGoIV/1Dialog.xba b/oxt/PokemonGoIV/1Dialog.xba index 5985c4e..31a433d 100644 --- a/oxt/PokemonGoIV/1Dialog.xba +++ b/oxt/PokemonGoIV/1Dialog.xba @@ -19,9 +19,28 @@ Option Explicit -' fnLoadParamDialog: Loads the parameter dialog. -Function fnLoadParamDialog As Object +' The parameters to find the individual values. +Type aFindIVParam + sPokemonId As String + sPokemonName As String + nCP As Integer + nHP As Integer + nStardust As Integer + nPlayerLevel As Integer + bIsNew As Boolean + nTotal As Integer + sBest As String + nMax 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 + Dim oList As Object, mPokemons () As String, nI As Integer + Dim bIsBestAttack As Boolean, bIsBestDefense As Boolean + Dim bIsBestHP As Boolean + Dim aQuery As New aFindIVParam, nSelected As Integer DialogLibraries.loadLibrary "PokemonGoIV" oDialog = CreateUnoDialog (DialogLibraries.PokemonGoIV.DlgMain) @@ -38,7 +57,74 @@ Function fnLoadParamDialog As Object oDialog.getControl ("imgTeamLogo").getModel.setPropertyValue ( _ "ImageURL", fnGetImageUrl ("Unknown")) - fnLoadParamDialog = oDialog + If oDialog.execute = 0 Then + aQuery.bIsCancelled = True + fnAskParam = aQuery + Exit Function + End If + + subReadBaseStats + nSelected = oDialog.getControl ("lstPokemon").getSelectedItemPos + With aQuery + .sPokemonId = maBaseStats (nSelected).sPokemonId + .sPokemonName = 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) + .nTotal = oDialog.getControl ("lstTotal").getSelectedItemPos + 1 + .nMax = oDialog.getControl ("lstMax").getSelectedItemPos + 1 + .bIsCancelled = False + End With + If oDialog.getControl ("cbxIsNew").getState = 1 Then + aQuery.bIsNew = True + Else + aQuery.bIsNew = False + End If + + ' The best stats + bIsBestAttack = False + bIsBestDefense = False + bIsBestHP = False + If oDialog.getControl ("lstBest").getSelectedItemPos = 0 Then + bIsBestAttack = True + If oDialog.getControl ("cbxBest2").getState = 1 Then + bIsBestDefense = True + End If + If oDialog.getControl ("cbxBest3").getState = 1 Then + bIsBestHP = True + End If + End If + If oDialog.getControl ("lstBest").getSelectedItemPos = 1 Then + bIsBestDefense = True + If oDialog.getControl ("cbxBest2").getState = 1 Then + bIsBestAttack = True + End If + If oDialog.getControl ("cbxBest3").getState = 1 Then + bIsBestHP = True + End If + End If + If oDialog.getControl ("lstBest").getSelectedItemPos = 2 Then + bIsBestHP = True + If oDialog.getControl ("cbxBest2").getState = 1 Then + bIsBestAttack = True + End If + If oDialog.getControl ("cbxBest3").getState = 1 Then + bIsBestDefense = True + End If + End If + aQuery.sBest = "" + If bIsBestAttack Then + aQuery.sBest = aQuery.sBest & "Atk " + End If + If bIsBestDefense Then + aQuery.sBest = aQuery.sBest & "Def " + End If + If bIsBestHP Then + aQuery.sBest = aQuery.sBest & "Sta " + End If + + fnAskParam = aQuery End Function ' subBtnOKCheck: Checks whether the required columns are filled.