Fixed so that the "OK" butten is only enabled when all the Pokémon, CP, HP, star dust are filled.

This commit is contained in:
依瑪貓 2016-12-06 16:58:24 +08:00
parent 12e4cd3052
commit c3e70ddff9
4 changed files with 111 additions and 16 deletions

View File

@ -437,6 +437,7 @@ Function fnAskParam0 As aFindIVParam
oButtonModel.setPropertyValue ("PushButtonType", _
com.sun.star.awt.PushButtonType.OK)
oButtonModel.setPropertyValue ("DefaultButton", True)
oButtonModel.setPropertyValue ("Enabled", False)
oDialogModel.insertByName ("btnOK", oButtonModel)
' Adds the cancel button.
@ -455,6 +456,18 @@ Function fnAskParam0 As aFindIVParam
oDialog.setModel (oDialogModel)
oDialog.setVisible (True)
oDialog.getControl ("lstPokemon").setFocus
oListener = CreateUnoListener ("subBtnOKCheck_", _
"com.sun.star.awt.XItemListener")
oDialog.getControl ("lstPokemon").addItemListener (oListener)
oListener = CreateUnoListener ("subBtnOKCheck_", _
"com.sun.star.awt.XTextListener")
oDialog.getControl ("numCP").addTextListener (oListener)
oListener = CreateUnoListener ("subBtnOKCheck_", _
"com.sun.star.awt.XTextListener")
oDialog.getControl ("numHP").addTextListener (oListener)
oListener = CreateUnoListener ("subBtnOKCheck_", _
"com.sun.star.awt.XItemListener")
oDialog.getControl ("lstStarDust").addItemListener (oListener)
oListener = CreateUnoListener ("subRdoTeamRedItemChanged_", _
"com.sun.star.awt.XItemListener")
oDialog.getControl ("rdoTeamRed").addItemListener (oListener)
@ -541,6 +554,38 @@ Function fnAskParam0 As aFindIVParam
fnAskParam0 = aQuery
End Function
' subBtnOKCheck_disposing: Dummy for the listener.
Sub subBtnOKCheck_disposing (oEvent As object)
End Sub
' subBtnOKCheck_itemStateChanged: When the Pokémon or star dust is selected.
Sub subBtnOKCheck_itemStateChanged (oEvent As object)
Dim oDialog As Object
Dim oPokemon As Object, oCP As Object
Dim oHP As Object, oStarDust As Object, oOK As Object
oDialog = oEvent.Source.getContext
oPokemon = oDialog.getControl ("lstPokemon")
oCP = oDialog.getControl ("numCP")
oHP = oDialog.getControl ("numHP")
oStarDust = oDialog.getControl ("lstStarDust")
oOK = oDialog.getControl ("btnOK")
If oPokemon.getSelectedItemPos <> -1 _
And oCP.getText <> "" _
And oHP.getText <> "" _
And oStarDust.getSelectedItemPos <> -1 Then
oOK.setEnable (True)
Else
oOK.setEnable (False)
End If
End Sub
' subBtnOKCheck_textChanged: When the CP or HP is filled
Sub subBtnOKCheck_textChanged (oEvent As object)
subBtnOKCheck_itemStateChanged (oEvent)
End Sub
' subRdoTeamRedItemChanged_disposing: Dummy for the listener.
Sub subRdoTeamRedItemChanged_disposing (oEvent As object)
End Sub
@ -550,12 +595,13 @@ Sub subRdoTeamRedItemChanged_itemStateChanged (oEvent As object)
Dim oDialog As Object, oList As Object, oText As Object
Dim mItems () As String
oDialog = oEvent.Source.getContext
mItems = Array ( _
"Overall, your [Pokémon] simply amazes me. It can accomplish anything!", _
"Overall, your [Pokémon] is a strong Pokémon. You should be proud!", _
"Overall, your [Pokémon] is a decent Pokémon.", _
"Overall, your [Pokémon] may not be great in battle, but I still like it!")
oDialog = oEvent.Source.getContext
oList = oDialog.getControl ("lstApprasal1")
oList.removeItems (0, oList.getItemCount())
oList.addItems (mItems, 0)
@ -592,7 +638,6 @@ Sub subRdoTeamRedItemChanged_itemStateChanged (oEvent As object)
"It's got excellent stats! How exciting!", _
"Its stats indicate that in battle, it'll get the job done.", _
"Its stats don't point to greatness in battle.")
oDialog = oEvent.Source.getContext
oList = oDialog.getControl ("lstApprasal2")
oList.removeItems (0, oList.getItemCount())
oList.addItems (mItems, 0)
@ -608,12 +653,13 @@ Sub subRdoTeamBlueItemChanged_itemStateChanged (oEvent As object)
Dim oDialog As Object, oList As Object, oText As Object
Dim mItems () As String
oDialog = oEvent.Source.getContext
mItems = Array ( _
"Overall, your [Pokémon] is a wonder! What a breathtaking Pokémon!", _
"Overall, your [Pokémon] has certainly caught my attention.", _
"Overall, your [Pokémon] is above average.", _
"Overall, your [Pokémon] is not likely to make much headway in battle.")
oDialog = oEvent.Source.getContext
oList = oDialog.getControl ("lstApprasal1")
oList.removeItems (0, oList.getItemCount())
oList.addItems (mItems, 0)
@ -650,7 +696,6 @@ Sub subRdoTeamBlueItemChanged_itemStateChanged (oEvent As object)
"I am certainly impressed by its stats, I must say.", _
"Its stats are noticeably trending to the positive.", _
"Its stats are not out of the norm, in my opinion.")
oDialog = oEvent.Source.getContext
oList = oDialog.getControl ("lstApprasal2")
oList.removeItems (0, oList.getItemCount())
oList.addItems (mItems, 0)
@ -666,12 +711,13 @@ Sub subRdoTeamYellowItemChanged_itemStateChanged (oEvent As object)
Dim oDialog As Object, oList As Object, oText As Object
Dim mItems () As String
oDialog = oEvent.Source.getContext
mItems = Array ( _
"Overall, your [Pokémon] looks like it can really battle with the best of them!", _
"Overall, your [Pokémon] is really strong!", _
"Overall, your [Pokémon] is pretty decent!", _
"Overall, your [Pokémon] has room for improvement as far as battling goes.")
oDialog = oEvent.Source.getContext
oList = oDialog.getControl ("lstApprasal1")
oList.removeItems (0, oList.getItemCount())
oList.addItems (mItems, 0)
@ -708,7 +754,6 @@ Sub subRdoTeamYellowItemChanged_itemStateChanged (oEvent As object)
"Its stats are really strong! Impressive.", _
"It's definitely got some good stats. Definitely!", _
"Its stats are all right, but kinda basic, as far as I can see.")
oDialog = oEvent.Source.getContext
oList = oDialog.getControl ("lstApprasal2")
oList.removeItems (0, oList.getItemCount())
oList.addItems (mItems, 0)

View File

@ -439,6 +439,7 @@ Function fnAskParam0 As aFindIVParam
oButtonModel.setPropertyValue (&quot;PushButtonType&quot;, _
com.sun.star.awt.PushButtonType.OK)
oButtonModel.setPropertyValue (&quot;DefaultButton&quot;, True)
oButtonModel.setPropertyValue (&quot;Enabled&quot;, False)
oDialogModel.insertByName (&quot;btnOK&quot;, oButtonModel)
&apos; Adds the cancel button.
@ -457,6 +458,18 @@ Function fnAskParam0 As aFindIVParam
oDialog.setModel (oDialogModel)
oDialog.setVisible (True)
oDialog.getControl (&quot;lstPokemon&quot;).setFocus
oListener = CreateUnoListener (&quot;subBtnOKCheck_&quot;, _
&quot;com.sun.star.awt.XItemListener&quot;)
oDialog.getControl (&quot;lstPokemon&quot;).addItemListener (oListener)
oListener = CreateUnoListener (&quot;subBtnOKCheck_&quot;, _
&quot;com.sun.star.awt.XTextListener&quot;)
oDialog.getControl (&quot;numCP&quot;).addTextListener (oListener)
oListener = CreateUnoListener (&quot;subBtnOKCheck_&quot;, _
&quot;com.sun.star.awt.XTextListener&quot;)
oDialog.getControl (&quot;numHP&quot;).addTextListener (oListener)
oListener = CreateUnoListener (&quot;subBtnOKCheck_&quot;, _
&quot;com.sun.star.awt.XItemListener&quot;)
oDialog.getControl (&quot;lstStarDust&quot;).addItemListener (oListener)
oListener = CreateUnoListener (&quot;subRdoTeamRedItemChanged_&quot;, _
&quot;com.sun.star.awt.XItemListener&quot;)
oDialog.getControl (&quot;rdoTeamRed&quot;).addItemListener (oListener)
@ -543,6 +556,38 @@ Function fnAskParam0 As aFindIVParam
fnAskParam0 = aQuery
End Function
&apos; subBtnOKCheck_disposing: Dummy for the listener.
Sub subBtnOKCheck_disposing (oEvent As object)
End Sub
&apos; subBtnOKCheck_itemStateChanged: When the Pokémon or star dust is selected.
Sub subBtnOKCheck_itemStateChanged (oEvent As object)
Dim oDialog As Object
Dim oPokemon As Object, oCP As Object
Dim oHP As Object, oStarDust As Object, oOK As Object
oDialog = oEvent.Source.getContext
oPokemon = oDialog.getControl (&quot;lstPokemon&quot;)
oCP = oDialog.getControl (&quot;numCP&quot;)
oHP = oDialog.getControl (&quot;numHP&quot;)
oStarDust = oDialog.getControl (&quot;lstStarDust&quot;)
oOK = oDialog.getControl (&quot;btnOK&quot;)
If oPokemon.getSelectedItemPos &lt;&gt; -1 _
And oCP.getText &lt;&gt; &quot;&quot; _
And oHP.getText &lt;&gt; &quot;&quot; _
And oStarDust.getSelectedItemPos &lt;&gt; -1 Then
oOK.setEnable (True)
Else
oOK.setEnable (False)
End If
End Sub
&apos; subBtnOKCheck_textChanged: When the CP or HP is filled
Sub subBtnOKCheck_textChanged (oEvent As object)
subBtnOKCheck_itemStateChanged (oEvent)
End Sub
&apos; subRdoTeamRedItemChanged_disposing: Dummy for the listener.
Sub subRdoTeamRedItemChanged_disposing (oEvent As object)
End Sub
@ -552,12 +597,13 @@ Sub subRdoTeamRedItemChanged_itemStateChanged (oEvent As object)
Dim oDialog As Object, oList As Object, oText As Object
Dim mItems () As String
oDialog = oEvent.Source.getContext
mItems = Array ( _
&quot;Overall, your [Pokémon] simply amazes me. It can accomplish anything!&quot;, _
&quot;Overall, your [Pokémon] is a strong Pokémon. You should be proud!&quot;, _
&quot;Overall, your [Pokémon] is a decent Pokémon.&quot;, _
&quot;Overall, your [Pokémon] may not be great in battle, but I still like it!&quot;)
oDialog = oEvent.Source.getContext
oList = oDialog.getControl (&quot;lstApprasal1&quot;)
oList.removeItems (0, oList.getItemCount())
oList.addItems (mItems, 0)
@ -594,7 +640,6 @@ Sub subRdoTeamRedItemChanged_itemStateChanged (oEvent As object)
&quot;It&apos;s got excellent stats! How exciting!&quot;, _
&quot;Its stats indicate that in battle, it&apos;ll get the job done.&quot;, _
&quot;Its stats don&apos;t point to greatness in battle.&quot;)
oDialog = oEvent.Source.getContext
oList = oDialog.getControl (&quot;lstApprasal2&quot;)
oList.removeItems (0, oList.getItemCount())
oList.addItems (mItems, 0)
@ -610,12 +655,13 @@ Sub subRdoTeamBlueItemChanged_itemStateChanged (oEvent As object)
Dim oDialog As Object, oList As Object, oText As Object
Dim mItems () As String
oDialog = oEvent.Source.getContext
mItems = Array ( _
&quot;Overall, your [Pokémon] is a wonder! What a breathtaking Pokémon!&quot;, _
&quot;Overall, your [Pokémon] has certainly caught my attention.&quot;, _
&quot;Overall, your [Pokémon] is above average.&quot;, _
&quot;Overall, your [Pokémon] is not likely to make much headway in battle.&quot;)
oDialog = oEvent.Source.getContext
oList = oDialog.getControl (&quot;lstApprasal1&quot;)
oList.removeItems (0, oList.getItemCount())
oList.addItems (mItems, 0)
@ -652,7 +698,6 @@ Sub subRdoTeamBlueItemChanged_itemStateChanged (oEvent As object)
&quot;I am certainly impressed by its stats, I must say.&quot;, _
&quot;Its stats are noticeably trending to the positive.&quot;, _
&quot;Its stats are not out of the norm, in my opinion.&quot;)
oDialog = oEvent.Source.getContext
oList = oDialog.getControl (&quot;lstApprasal2&quot;)
oList.removeItems (0, oList.getItemCount())
oList.addItems (mItems, 0)
@ -668,12 +713,13 @@ Sub subRdoTeamYellowItemChanged_itemStateChanged (oEvent As object)
Dim oDialog As Object, oList As Object, oText As Object
Dim mItems () As String
oDialog = oEvent.Source.getContext
mItems = Array ( _
&quot;Overall, your [Pokémon] looks like it can really battle with the best of them!&quot;, _
&quot;Overall, your [Pokémon] is really strong!&quot;, _
&quot;Overall, your [Pokémon] is pretty decent!&quot;, _
&quot;Overall, your [Pokémon] has room for improvement as far as battling goes.&quot;)
oDialog = oEvent.Source.getContext
oList = oDialog.getControl (&quot;lstApprasal1&quot;)
oList.removeItems (0, oList.getItemCount())
oList.addItems (mItems, 0)
@ -710,7 +756,6 @@ Sub subRdoTeamYellowItemChanged_itemStateChanged (oEvent As object)
&quot;Its stats are really strong! Impressive.&quot;, _
&quot;It&apos;s definitely got some good stats. Definitely!&quot;, _
&quot;Its stats are all right, but kinda basic, as far as I can see.&quot;)
oDialog = oEvent.Source.getContext
oList = oDialog.getControl (&quot;lstApprasal2&quot;)
oList.removeItems (0, oList.getItemCount())
oList.addItems (mItems, 0)

View File

@ -163,11 +163,16 @@
<dlg:menuitem dlg:value="Mewtwo"/>
<dlg:menuitem dlg:value="Mew"/>
</dlg:menupopup>
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.script:PokemonGoIV.0Main.subBtnOKCheck_itemStateChanged?language=Basic&amp;location=application" script:language="Script"/>
</dlg:menulist>
<dlg:text dlg:id="txtCP" dlg:tab-index="17" dlg:left="5" dlg:top="21" dlg:width="15" dlg:height="8" dlg:help-text="&amp;26.DlgMain.txtCP.HelpText" dlg:value="&amp;27.DlgMain.txtCP.Label"/>
<dlg:numericfield dlg:id="numCP" dlg:tab-index="1" dlg:left="20" dlg:top="19" dlg:width="20" dlg:height="12" dlg:help-text="&amp;28.DlgMain.numCP.HelpText" dlg:decimal-accuracy="0" dlg:value-min="10" dlg:value-max="5000"/>
<dlg:numericfield dlg:id="numCP" dlg:tab-index="1" dlg:left="20" dlg:top="19" dlg:width="20" dlg:height="12" dlg:help-text="&amp;28.DlgMain.numCP.HelpText" dlg:decimal-accuracy="0" dlg:value-min="10" dlg:value-max="5000">
<script:event script:event-name="on-textchange" script:macro-name="vnd.sun.star.script:PokemonGoIV.0Main.subBtnOKCheck_textChanged?language=Basic&amp;location=application" script:language="Script"/>
</dlg:numericfield>
<dlg:text dlg:id="txtHP" dlg:tab-index="18" dlg:left="50" dlg:top="21" dlg:width="15" dlg:height="8" dlg:help-text="&amp;29.DlgMain.txtHP.HelpText" dlg:value="&amp;30.DlgMain.txtHP.Label"/>
<dlg:numericfield dlg:id="numHP" dlg:tab-index="2" dlg:left="65" dlg:top="19" dlg:width="15" dlg:height="12" dlg:help-text="&amp;31.DlgMain.numHP.HelpText" dlg:decimal-accuracy="0" dlg:value-min="0" dlg:value-max="200"/>
<dlg:numericfield dlg:id="numHP" dlg:tab-index="2" dlg:left="65" dlg:top="19" dlg:width="15" dlg:height="12" dlg:help-text="&amp;31.DlgMain.numHP.HelpText" dlg:decimal-accuracy="0" dlg:value-min="0" dlg:value-max="200">
<script:event script:event-name="on-textchange" script:macro-name="vnd.sun.star.script:PokemonGoIV.0Main.subBtnOKCheck_textChanged?language=Basic&amp;location=application" script:language="Script"/>
</dlg:numericfield>
<dlg:text dlg:id="txtStarDust" dlg:tab-index="19" dlg:left="90" dlg:top="21" dlg:width="30" dlg:height="8" dlg:help-text="&amp;32.DlgMain.txtStarDust.HelpText" dlg:value="&amp;33.DlgMain.txtStarDust.Label"/>
<dlg:menulist dlg:id="lstStarDust" dlg:tab-index="3" dlg:left="120" dlg:top="19" dlg:width="30" dlg:height="12" dlg:help-text="&amp;162.DlgMain.lstStarDust.HelpText" dlg:spin="true">
<dlg:menupopup>
@ -192,6 +197,7 @@
<dlg:menuitem dlg:value="9000"/>
<dlg:menuitem dlg:value="10000"/>
</dlg:menupopup>
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.script:PokemonGoIV.0Main.subBtnOKCheck_itemStateChanged?language=Basic&amp;location=application" script:language="Script"/>
</dlg:menulist>
<dlg:text dlg:id="txtPlayerLevel" dlg:tab-index="20" dlg:left="160" dlg:top="21" dlg:width="35" dlg:height="8" dlg:help-text="&amp;40.DlgMain.txtPlayerLevel.HelpText" dlg:value="&amp;41.DlgMain.txtPlayerLevel.Label"/>
<dlg:menulist dlg:id="lstPlayerLevel" dlg:tab-index="4" dlg:left="195" dlg:top="19" dlg:width="20" dlg:height="12" dlg:help-text="&amp;163.DlgMain.lstPlayerLevel.HelpText" dlg:spin="true">
@ -263,7 +269,7 @@
<dlg:checkbox dlg:id="cbxBest2" dlg:tab-index="11" dlg:left="10" dlg:top="111" dlg:width="200" dlg:height="8" dlg:help-text="&amp;201.DlgMain.cbxBest2.HelpText" dlg:checked="false"/>
<dlg:checkbox dlg:id="cbxBest3" dlg:tab-index="12" dlg:left="10" dlg:top="126" dlg:width="200" dlg:height="8" dlg:help-text="&amp;203.DlgMain.cbxBest3.HelpText" dlg:checked="false"/>
<dlg:menulist dlg:id="lstApprasal2" dlg:tab-index="13" dlg:left="10" dlg:top="139" dlg:width="200" dlg:height="12" dlg:help-text="&amp;165.DlgMain.lstApprasal2.HelpText" dlg:spin="true"/>
<dlg:button dlg:id="btnOK" dlg:tab-index="14" dlg:left="35" dlg:top="165" dlg:width="60" dlg:height="15" dlg:help-text="&amp;85.DlgMain.btnOK.HelpText" dlg:default="true" dlg:button-type="ok"/>
<dlg:button dlg:id="btnOK" dlg:tab-index="14" dlg:disabled="true" dlg:left="35" dlg:top="165" dlg:width="60" dlg:height="15" dlg:help-text="&amp;85.DlgMain.btnOK.HelpText" dlg:default="true" dlg:button-type="ok"/>
<dlg:button dlg:id="btnCancel" dlg:tab-index="15" dlg:left="125" dlg:top="165" dlg:width="60" dlg:height="15" dlg:help-text="&amp;87.DlgMain.btnCancel.HelpText" dlg:button-type="cancel"/>
</dlg:bulletinboard>
</dlg:window>

View File

@ -4,5 +4,4 @@
<library:element library:name="0Main"/>
<library:element library:name="1Data"/>
<library:element library:name="9Load"/>
<library:element library:name="2Data"/>
</library:library>