Dialogs

Status
Not open for further replies.
Level 4
Joined
Aug 8, 2011
Messages
84
So I've been using global variables for Dialogs / Dialog buttons for a long time, but I wanted to move away from this and simply use a struct housing the needed elements for simplicity.

My struct:

JASS:
struct dialogdat
    dialog Diag = DialogCreate()
    button array Buttons[12]
endstruct

I have the struct saved to a player ID in a hashtable, shortly after game initialization, and am trying to recall the struct from the ID of the player after they click a button on the dialog. This way I can do:

JASS:
    loop
        exitwhen(clicked == D.Buttons[i])
        set i = i + 1
    endloop

To easily figure out what was pressed. The problem, however, is that the function attached to the dialog isn't running, regardless of which button is pressed.

JASS:
function blah takes nothing returns nothing
    local player p = GetTriggerPlayer()
    local integer pID = GetConvertedPlayerId(p)
    local button clicked = GetClickedButton()
    local integer i = 0
    local trigger allocate = CreateTrigger()
    local dialogdat D = LoadInteger(udg_Hash, StringHashBJ("diag"), GetHandleId(p))
    local playerdat S = LoadInteger(udg_Hash, StringHashBJ("heroinfo"), GetHandleId(p))
        
        call DialogClear(D.Diag)
        call DialogSetMessage(D.Diag, "yo:")
        
        loop
            exitwhen(i > S.NumMemSkills - 1) 
            set D.Buttons[i] = DialogAddButton(D.Diag, GetObjectName(S.MemSkillID[i]), i)
            set i = i + 1
        endloop
        
        call DialogDisplay(p, D.Diag, true)
        
        call TriggerAddAction(allocate, function blah2)
        call TriggerRegisterDialogEvent(allocate, D.Diag)
endfunction

S is a different struct type, whose data members function just fine, and yet is loaded in the same manner, so I am confused as to why just the dialog doesn't work.

EDIT: I have solved my problem, thank you.
 
Last edited:
Status
Not open for further replies.
Top