Another Dialog Fail: detecting selection

Dan

The New Helper.Net gives me great Anxiety... o.O;;
Reaction score
159
Interesting find:

Code:
TechMenu: Detect ListBox Selection
    Events
        Dialog - (Used dialog item) is Changed Selection by Player Any Player
    Local Variables
    Conditions
    Actions
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                [COLOR="Red"][B]ListBoxSelection != 1[/B][/COLOR]
                (Selected list item of TechTypesDropdown for (Triggering player)) == 1
            Then
                [COLOR="red"][B]Variable - Set ListBoxSelection = 1[/B][/COLOR]
                TechMenu: Generate Tech List((Player group(Triggering Player)), 1)
            Else

in this you will notice that I am having to use a global variable "ListBoxSelection" of type integer in order to fix a problem that occurs when running the event type "Dialog - (Used dialog item) is Changed Selection by Player Any Player".

what happens without the global variable condition added is that the current list selection is continually counted as an event (periodically) instead of only firing after a change in selection (which is preferred). The problem I was facing without the global was that my action "generate tech list" was repeatedly being re-run for the current list selection.
 

SerraAvenger

Cuz I can
Reaction score
234
Hmm, very interesting. Thanks for pointing this out.

So you're saving the currently selected item in the variable?


May I suggest this change:
EDIT, optimized:

Code:
    Local Variables
        newSelected =  (Selected list item of TechTypesDropdown for (Triggering player)) <int>
    Conditions
        ListBoxSelection != newSelected
    Actions
        Variable - Set ListBoxSelection = newSelected
 

Dan

The New Helper.Net gives me great Anxiety... o.O;;
Reaction score
159
Hmm. since last night I changed several of my "if-then" statements to "switches" because they are much more tidy and allow me to check for different used dialog items. It seems as though this problem isn't happening anymore.

actually i think the problem lies in the conditional: "(Selected list item of TechTypesDropdown for (Triggering player)) == 1"

since my new code has a new layer added that checks "used dialog"

here is how my gui looks now:

Code:
TechMenu: Detect Dialog Selections
    Events
        Dialog - (Used dialog item) is Changed Selection by Player Any Player
    Local Variables
        Triggering Player = (Empty player group) <Player Group>
        tempInt = 0 <Integer>
    Conditions
    Actions
        Variable - Set Triggering Player = (Player group((Triggering player)))
        [COLOR="Red"]General - Switch (Actions) depending on (Used dialog item)[/COLOR]
            Cases
                [COLOR="Green"]General - If (TechTypesDropdown)[/COLOR]
                    Actions
                        General - For each integer tempInt from 1 to 5 with increment 1, do (Actions)
                            Actions
                                General - If (Conditions) then do (Actions) else do (Actions)
                                    If
                                        (Selected list item of TechTypesDropdown for (Triggering player)) == tempInt
                                    Then
                                        Variable - Set DropdownSelection = tempInt
                                        TechMenu: Generate Tech List(Triggering Player, tempInt)
                                        General - Break
                                    Else
                [COLOR="green"]General - If (ListBox)[/COLOR]
                    Actions
                        General - For each integer tempInt from 1 to 50 with increment 1, do (Actions)
                            Actions
                                General - If (Conditions) then do (Actions) else do (Actions)
                                    If
                                        (Selected list item of ListBox for (Triggering player)) == tempInt
                                    Then
                                        Dialog - Set InfoBox text to (Text(Tech Item[DropdownSelection][tempInt].info)) for Triggering Player
                                        General - Break
                                    Else
                                        Dialog - Set InfoBox text to "Choose a technology piece in the li..." for Triggering Player
            Default

the green parts are my dropdown and my list which are dialog items of type "used dialog" because they are the actual structure. the internal list pieces are considered "dialog items" too; however, do not respond to "used dialog" because they are not the overal structure parts. with this new layer, i no longer need to check to see if the list selected was the list previously selected.

@Serra: I'm trying to wrap my brain around your optimization. how much of a change does that make and how? what you mean is just that you don't have to look up the value of the list piece every cycle right? just once at the beginning? if so gotcha.
 

SerraAvenger

Cuz I can
Reaction score
234
Hmm. since last night I changed several of my "if-then" statements to "switches" because they are much more tidy and allow me to check for different used dialog items. It seems as though this problem isn't happening anymore.
A good change to make = )
here is how my gui looks now:

Code:
TechMenu: Detect Dialog Selections
    Events
        Dialog - (Used dialog item) is Changed Selection by Player Any Player
    Local Variables
        Triggering Player = (Empty player group) <Player Group>
        tempInt = 0 <Integer>
    Conditions
    Actions
        Variable - Set Triggering Player = (Player group((Triggering player)))
        [COLOR="Red"]General - Switch (Actions) depending on (Used dialog item)[/COLOR]
            Cases
                [COLOR="Green"]General - If (TechTypesDropdown)[/COLOR]
                    Actions
                        General - For each integer tempInt from 1 to 5 with increment 1, do (Actions)
                            Actions
                                General - If (Conditions) then do (Actions) else do (Actions)
                                    If
                                        (Selected list item of TechTypesDropdown for (Triggering player)) == tempInt
                                    Then
                                        Variable - Set DropdownSelection = tempInt
                                        TechMenu: Generate Tech List(Triggering Player, tempInt)
                                        General - Break
                                    Else
                [COLOR="green"]General - If (ListBox)[/COLOR]
                    Actions
                        General - For each integer tempInt from 1 to 50 with increment 1, do (Actions)
                            Actions
                                General - If (Conditions) then do (Actions) else do (Actions)
                                    If
                                        (Selected list item of ListBox for (Triggering player)) == tempInt
                                    Then
                                        Dialog - Set InfoBox text to (Text(Tech Item[DropdownSelection][tempInt].info)) for Triggering Player
                                        General - Break
                                    Else
                                        Dialog - Set InfoBox text to "Choose a technology piece in the li..." for Triggering Player
            Default


@Serra: I'm trying to wrap my brain around your optimization. how much of a change does that make and how? what you mean is just that you don't have to look up the value of the list piece every cycle right? just once at the beginning? if so gotcha.

Well from your code before it was that you wouldn't need to do the "ListBoxSelection != 1" check for every single list item, but only once per dialog. (Once every cycle though)

The optimization that I wrote about was actually an optimization within my own code, where I reduced the number of function calls by one and used conditions instead of an if clause.


Anyhow, you can take out the loops completely.
Code:
                        General - For each integer tempInt from 1 to 50 with increment 1, do (Actions)
                            Actions
                                General - If (Conditions) then do (Actions) else do (Actions)
                                    If
                                        (Selected list item of ListBox for (Triggering player)) == tempInt
                                    Then
                                        Dialog - Set InfoBox text to (Text(Tech Item[DropdownSelection][tempInt].info)) for Triggering Player
                                        General - Break
                                    Else
                                        Dialog - Set InfoBox text to "Choose a technology piece in the li..." for Triggering Player
->
Code:
If
    [An item is selected] // I don't know the correct GUI script and I don't have SC2 on this system
Then
    Dialog - Set InfoBox text to (Text(Tech Item[DropdownSelection][newSelected].info)) for Triggering Player
Else
    Dialog - Set InfoBox text to "Choose a technology piece in the li..." for Triggering Player


actually i think the problem lies in the conditional: "(Selected list item of TechTypesDropdown for (Triggering player)) == 1"

since my new code has a new layer added that checks "used dialog"
Btw, are you sure your function still fires at all? And if it does, did you check if it really runs only once with the help of some debug messages?
 

Dan

The New Helper.Net gives me great Anxiety... o.O;;
Reaction score
159
Mmmhmm it works perfectly as is. once per selection and all. error messages confirmed that before I posted last.

[EDIT] i'll remove the loops. ^^ Guess I started getting a bit off track at some point.
 

Dan

The New Helper.Net gives me great Anxiety... o.O;;
Reaction score
159
works without the loops wonderfully as well.


Dialog - (Used dialog item) is Changed Selection by Player Any Player

reconfirmed not to fire unless a change in selection is made with error text... so i'm going to plug my old code in once more with error text this time to see if it fires more than once... what was happening before is that my list just kept being regenerated which was evident by trying to click any list item (and then it being deselected). There was no tricky parts, my code was exactly as stated in the first post so very interesting... it really seems as though the switch instead of the if-then made a huge enough difference because of the "used dialog" layer added.

Let me reconfirm what i'm thinking and we will talk again... I'm telling you, dialogs have ridiculous GUI in this editor. I feel like dialoging could use some lovin' from what we have now...
 

Dan

The New Helper.Net gives me great Anxiety... o.O;;
Reaction score
159
Ok I'm putting this to rest because I kind of figured it out but am pretty tired of this.

Code:
TechMenu: Detect Dialog Selections 3
    Events
        Dialog - (Used dialog item) is Changed Selection by Player Any Player
    Local Variables
    Conditions
    Actions
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                (Selected list item of TechTypesDropdown for (Triggering player)) == 1
            Then
                UI - Display "WTF!?!?" for (All players) to Subtitle area
                TechMenu: Generate Tech List((Player group((Triggering player))), 1)
            Else

"WTF!?!?" fires twice at a time when hitting a list (sometimes... at least) just some kind of confusion over what a "used item" and "selected item" is i suppose. interestingly enough a list item is a dialog item and the list itself is a dialog item as well... so i think that's the problem. redundancy.

final code:

Code:
TechMenu: Detect Dialog Selections 2
    Events
        Dialog - (Used dialog item) is Changed Selection by Player Any Player
    Local Variables
        TTD_Selection = (Selected list item of TechTypesDropdown for (Triggering player)) <Integer>
        LB_Selection = (Selected list item of ListBox for (Triggering player)) <Integer>
        Triggering Player = (Empty player group) <Player Group>
    Conditions
    Actions
        Variable - Set Triggering Player = (Player group((Triggering player)))
        General - Switch (Actions) depending on (Used dialog item)
            Cases
                General - If (TechTypesDropdown)
                    Actions
                        TechMenu: Generate Tech List(Triggering Player, TTD_Selection)
                General - If (ListBox)
                    Actions
                        General - If (Conditions) then do (Actions) else do (Actions)
                            If
                                (Selected list item of ListBox for (Triggering player)) != 0
                            Then
                                Dialog - Set InfoBox text to "" for Triggering Player
                                Dialog - Set InfoBox text to (Text(Tech Item[TTD_Selection][LB_Selection].info)) for Triggering Player
                            Else
                                Dialog - Set InfoBox text to "" for Triggering Player
                                Dialog - Set InfoBox text to "Choose a technology piece in the li..." for Triggering Player
            Default

seems to be working fine. I'm going to go pray to Blizzard to fix their dialog issues and then go to bed. may this thread help someone...
 

SerraAvenger

Cuz I can
Reaction score
234
interestingly enough a list item is a dialog item and the list itself is a dialog item as well... so i think that's the problem. redundancy.

That's exactly why I wondered if your code actually works. I thought they were distinct.

Meh, Blizzard is doing weird stuff again.

If I'm back on Windows, I'll think about a new GUI dialogs library...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top