All these years of Jass usage went into past and never did I need to use any dialogue...
Now, I do. And I am very surprised, that the following code did not exactly work as I supposed it to do:
What I see:
All messages appear once the function is called. But never something that I would call a dialogue (in fact, nothing else happens), so, well... what indubitablely simple and mortifying mistake did I make?
And is a "Dialog" indeed the dialogue that I am in need of? A window with selectable buttons, whose activation I can catch with a trigger event?
Oh, if it is of use, here is the whole script with the "real" variable names.
It is still unfinished as I see no sense in continuing without all existing code working properly.
Now, I do. And I am very surprised, that the following code did not exactly work as I supposed it to do:
JASS:
function Trig_Initialisierung_Actions takes nothing returns nothing
local dialog charGen = DialogCreate()
<various other variable declarations>
call DisplayTextToPlayer(gk_Spieler, 0, 0, "Variables initialised.")
[...]
call DialogSetMessage(charGen, "Choose your language:")
set g_CharGenKnopf[0] = DialogAddButton(charGen, "Deutsch", 'D')
set g_CharGenKnopf[1] = DialogAddButton(charGen, "English", 'E')
[...]
if charGen != null then
call DisplayTextToPlayer(gk_Spieler, 0, 0, "charGen exists.")
endif
if g_CharGenKnopf[0] != null then
call DisplayTextToPlayer(gk_Spieler, 0, 0, "CharGenKnopf[0] exists.")
endif
if g_CharGenKnopf[1] != null then
call DisplayTextToPlayer(gk_Spieler, 0, 0, "CharGenKnopf[1] exists.")
endif
call DialogDisplay(gk_Spieler, charGen, true)
call DisplayTextToPlayer(gk_Spieler, 0, 0, "Dialogue is shown.")
[...]
endfunction
What I see:
All messages appear once the function is called. But never something that I would call a dialogue (in fact, nothing else happens), so, well... what indubitablely simple and mortifying mistake did I make?
And is a "Dialog" indeed the dialogue that I am in need of? A window with selectable buttons, whose activation I can catch with a trigger event?
Oh, if it is of use, here is the whole script with the "real" variable names.
It is still unfinished as I see no sense in continuing without all existing code working properly.
JASS:
globals
constant player gk_Spieler = Player(0)
boolean g_Weiter = false
button array g_CharGenKnopf
integer g_Sprache = -1
unit g_DracheneiGruen
unit g_DracheneiRot
unit g_DracheneiSchwarz
endglobals
JASS:
function Ausl_Signal_BefehleA takes nothing returns nothing
if GetClickedButton() == g_CharGenKnopf[1] then
set g_Sprache = 1
else
set g_Sprache = 0
endif
set g_Weiter = true
endfunction
JASS:
function Ausl_Signal_BefehleB takes nothing returns nothing
local string naechsterSatz
local unit wahl = GetTriggerUnit()
if wahl == g_DracheneiGruen then
if g_Sprache == 1 then
set naechsterSatz = "blaE1"
else
set naechsterSatz = "blaD1"
endif
elseif wahl == g_DracheneiRot then
if g_Sprache == 1 then
set naechsterSatz = "blaE2"
else
set naechsterSatz = "blaD2"
endif
elseif wahl == g_DracheneiSchwarz then
if g_Sprache == 1 then
set naechsterSatz = "blaE3"
else
set naechsterSatz = "blaD3"
endif
else
set naechsterSatz = null
set wahl = null
return null
endif
call DisplayTextToPlayer(gk_Spieler, 0, 0, naechsterSatz)
set naechsterSatz = null
set wahl = null
endfunction
JASS:
function Ausl_Initialisierung_Befehle takes nothing returns nothing
local dialog charGen = DialogCreate()
local rect umgebungGruen = Rect(-660, -680, -140, -230)
local rect umgebungRot = Rect(300, -655, 850, -40)
local rect umgebungSchwarz = Rect(-435, 245, 205, 760)
local string naechsterSatz
local trigger signal = CreateTrigger()
local weathereffect gruen = AddWeatherEffect(umgebungGruen, 'RAlr')
local weathereffect rot = AddWeatherEffect(umgebungRot, 'FDrh')
local weathereffect schwarz = AddWeatherEffect(umgebungSchwarz, 'LRma')
set g_DracheneiGruen = CreateUnit(gk_Spieler, 'o002', -440, -425, 0)
set g_DracheneiRot = CreateUnit(gk_Spieler, 'o000', 540, -275, 0)
set g_DracheneiSchwarz = CreateUnit(gk_Spieler, 'o001', -70, 520, 0)
call DisplayTextToPlayer(gk_Spieler, 0, 0, "Variablen initialisiert.")
call EnableWeatherEffect(gruen, true)
call EnableWeatherEffect(rot, true)
call EnableWeatherEffect(schwarz, true)
call DialogSetMessage(charGen, "Wähle die Spielsprache:")
set g_CharGenKnopf[0] = DialogAddButton(charGen, "Deutsch", 'D')
set g_CharGenKnopf[1] = DialogAddButton(charGen, "English", 'E')
call TriggerAddAction(signal, function Ausl_Signal_BefehleA)
call TriggerRegisterDialogButtonEvent(signal, g_CharGenKnopf[0])
call TriggerRegisterDialogButtonEvent(signal, g_CharGenKnopf[1])
if charGen != null then
call DisplayTextToPlayer(gk_Spieler, 0, 0, "charGen existiert.")
endif
if g_CharGenKnopf[0] != null then
call DisplayTextToPlayer(gk_Spieler, 0, 0, "CharGenKnopf[0] existiert.")
endif
if g_CharGenKnopf[1] != null then
call DisplayTextToPlayer(gk_Spieler, 0, 0, "CharGenKnopf[1] existiert.")
endif
call DialogDisplay(gk_Spieler, charGen, true)
call DisplayTextToPlayer(gk_Spieler, 0, 0, "Sprachdialog angezeigt.")
loop
call TriggerSleepAction(1)
exitwhen g_Weiter
endloop
set g_Weiter = false
call DisplayTextToPlayer(gk_Spieler, 0, 0, "Sprache gewählt.")
call DialogDisplay(gk_Spieler, charGen, true)
call DialogClear(charGen)
call TriggerClearActions(signal)
call DestroyTrigger(signal)
set signal = CreateTrigger()
call TriggerAddAction(signal, function Ausl_Signal_BefehleB)
call TriggerRegisterPlayerUnitEvent(signal, gk_Spieler, EVENT_PLAYER_UNIT_SELECTED, null)
if g_Sprache == 1 then
set naechsterSatz = "Select one of the eggs to gain information about the dragon inside."
else
set naechsterSatz = "Wähle eines der Eier um Informationen über den enthaltenen Drachen zu bekommen."
endif
call DisplayTextToPlayer(gk_Spieler, 0, 0, naechsterSatz)
set signal = CreateTrigger()
call TriggerAddAction(signal, function Ausl_Signal_BefehleB)
call TriggerRegisterPlayerUnitEvent(signal, gk_Spieler, EVENT_PLAYER_UNIT_SELECTED, null)
loop
call TriggerSleepAction(1)
exitwhen g_Weiter
endloop
set g_Weiter = false
endfunction