I am completly lost
Maybe the problem lies in fact that its midnight already here, but still, when I create dialog and I want to display it, it wont display for my life, it will fade the background, and when I press enter, the
However, the GUI trigger attached below will work 100% of time
(Notice the 0.1 seconds delay, I tried it inside the onInit method, I tried it with 0.0 seconds callback, nothing worked)
here is the GUI shit that works flawlessly:
Maybe the problem lies in fact that its midnight already here, but still, when I create dialog and I want to display it, it wont display for my life, it will fade the background, and when I press enter, the
function handler
and when I printed debug messages, the button4 was pressed every time.However, the GUI trigger attached below will work 100% of time
JASS:
library DifficultyChooser
globals
private constant boolean WANT_SHOW = true
private integer PlayerCount = 6
endglobals
static if WANT_SHOW then
globals
integer GAMEMODE = 0
endglobals
function GetGameMode takes nothing returns integer
return GAMEMODE
endfunction
globals
private dialog dialogC = null
private button button1 = null
private button button2 = null
private button button3 = null
private button button4 = null
private integer array votes
private integer voted = 0
private trigger t = null
private string array messages
endglobals
private function handler takes nothing returns boolean
local button b = GetClickedButton()
local integer i = 2
local integer index = 0
local integer max = 0
if b == button1 then
set votes[0] = votes[0] + 1
set voted = voted + 1
elseif b == button2 then
set votes[1] = votes[1] + 1
set voted = voted + 1
elseif b == button3 then
set votes[2] = votes[2] + 1
set voted = voted + 1
else
set votes[3] = votes[3] + 1
set voted = voted + 1
endif
if voted == PlayerCount then
set max = votes[3]
loop
if votes[i] >= max then
set index = i
set max = votes[i]
endif
exitwhen i == 0
set i = i - 1
endloop
set GAMEMODE = index
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 10, messages[GAMEMODE])
// call DialogClear(dialogC)
// call DialogDestroy(dialogC)
// set dialogC = null
call DestroyTrigger(t)
set t = null
endif
return false
endfunction
private module m
static method onLoad takes nothing returns nothing
local integer i = 0
loop
call DialogDisplay(Player(i), dialogC, true)
exitwhen i == PlayerCount
set i = i + 1
endloop
call DestroyTimer(GetExpiredTimer())
endmethod
static method onInit takes nothing returns nothing
set t = CreateTrigger()
set dialogC = DialogCreate()
set button1 = DialogAddButton(dialogC, "E|cffffcc00asy Mode|r", 'e')
set button2 = DialogAddButton(dialogC, "N|cffffcc00ormal Mode|r", 'n')
set button3 = DialogAddButton(dialogC, "H|cffffcc00ard Mode|r", 'h')
set button4 = DialogAddButton(dialogC, "|cffffcc00H|ra|cffffcc00rdcore|r", 'a')
call TriggerRegisterDialogButtonEvent(t, button1)
call TriggerRegisterDialogButtonEvent(t, button2)
call TriggerRegisterDialogButtonEvent(t, button3)
call TriggerRegisterDialogButtonEvent(t, button4)
set messages[0] = "Game mode Chosen: Easy Mode!"
set messages[1] = "Game mode Chosen: Normal Mode!"
set messages[2] = "Game mode Chosen: Hard Mode!"
set messages[3] = "Game mode Chosen: Hardcore!"
call DialogSetMessage(dialogC, "Select difficulty")
call TimerStart(CreateTimer(), 0.1, false, function thistype.onLoad)
call TriggerAddCondition(t, Filter(function handler))
endmethod
endmodule
private struct s extends array
implement m
endstruct
function RunModeVote takes nothing returns nothing
call s.onInit()
endfunction
endif
endlibrary
here is the GUI shit that works flawlessly:
-
Untitled Trigger 001
-
Events
- Time - Elapsed game time is 0.00 seconds
- Conditions
-
Actions
- Dialog - Create a dialog button for dial labelled Button
- Set but1 = (Last created dialog Button)
- Dialog - Change the title of dial to Title
- Dialog - Show dial for Player 1 (Red)
-
Events