Hello fine gents. I'm trying to understand dialogs to the best of my ability but I'm struggling with buttons.
I want to do something very simple.
Have a dialog box that displays text (already done), with a button (already done) and when you click that button, the windows hides.
I know I have to set up some variables and stuff but I have no idea how to do it. It's no help that the event for dialog is really limited.
I usually have an initialization action for the window and a record object type for the window components I want to track. The code below isn't perfect, I think you can actually call a trigger to see if a dialog is showing or not so the bool showing probably not needed. Please let me know if this helps or not. Here's an example window of mine:
initScoreboardOptions:ActionReturnType:(None)ParametersplayerIndex<Integer>GrammarText:initScoreboard(playerIndex)HintText:(None)CustomScriptCodeLocalVariablesi=0<Integer>Actions-------CreateUI-maindialogDialog-CreateaModaldialogofsize(348,220)at(0,150)relativetoTopLeftofscreenVariable-Setg_userData[playerIndex].scoreBoard.dialog = (Last created dialog)
------- Create UI - scoreboard header
Dialog - Create a Label for dialog (Last created dialog)
Dialog - Set (Last created dialog item) text to (Text "Player" with color (100%, 100%, 100%)) for (All players)
Dialog - Set (Last created dialog item) size to (120, 20) for (All players)
Dialog - Move (Last created dialog item) to (SCOREBOARD_ENTRY_NAME_X_OFF, (scoreboardEntryYOffset(0))) relative to Top Left of dialog for (All players)
Dialog - Create a Label for dialog (Last created dialog)
Dialog - Set (Last created dialog item) text to (Text "Power Level" with color (100%, 100%, 100%)) for (All players)
Dialog - Set (Last created dialog item) size to (120, 20) for (All players)
Dialog - Move (Last created dialog item) to (SCOREBOARD_ENTRY_SCORE_X_OFF, (scoreboardEntryYOffset(0))) relative to Top Left of dialog for (All players)
------- Create UI - scoreboard entries
TOGGLE SCOREBOARD SHOWING / HIDING
toggleScoreboardOptions:ActionReturnType:(None)ParametersplayerIndex<Integer>GrammarText:toggleScoreboard(playerIndex)HintText:(None)CustomScriptCodeLocalVariablesplayer=(Playergroup(playerIndex))<PlayerGroup>ActionsGeneral-Switch(Actions)dependingong_userData[playerIndex].scoreBoard.showing
Cases
General - If (false)
Actions
Dialog - Show g_userData[playerIndex].scoreBoard.dialog for player
Dialog - Show g_userData[playerIndex].scoreBoard.collapseIcon for player
Dialog - Hide g_userData[playerIndex].scoreBoard.expandIcon for player
Dialog - Set g_userData[playerIndex].scoreBoard.toggleBtn tooltip to "Collapse Ranking" for (All players)
General - If (true)
Actions
Dialog - Hide g_userData[playerIndex].scoreBoard.dialog for player
Dialog - Hide g_userData[playerIndex].scoreBoard.collapseIcon for player
Dialog - Show g_userData[playerIndex].scoreBoard.expandIcon for player
Dialog - Set g_userData[playerIndex].scoreBoard.toggleBtn tooltip to "Expand Ranking" for (All players)
Default
Variable - Set g_userData[playerIndex].scoreBoard.showing = (Not (g_userData[playerIndex].scoreBoard.showing))
event
Any dialog item is pressed
condition
*you could add condition like dialog == closedialogbutton
action
Show/Hide [last created dialog or ur variable for the dialog] for player [triggering player]
Thinking of asking here to avoid making other thread, for its a simple question. Dialog related.
How do you go about adding images to the dialog? I know how to actually do it (Just did it using some of the asset textures), but can you currently import images you create to put them in the dialogs? If so, what format should it be?
Edit: Oh and something else, how do I block control of the player when a dialog(clicking, moving, etc) when a dialog box is shown?
Yes you can put them inside, just use import manager (one of the buttons on top). I know that .TGA and .DDS (maybe some more but dunno) formats are supported for images, after importing you must save map and you should be able to select them from the list of images.
Ok, so I have another question. I managed to close dialogs like a pro, but I can't manage to get the check boxes to work. I want to show a series of dialogs, but if they check a box once, they don't get more dialogs.
I don't know how to make the trigger recognize that it has been checked.
When creating check box set is as variable Dialog Item just like button.
In your case i'd make global variable of type Player Group (when map starts/before first dialog shows) and set it to = (Active Players). Whenever you show those dialogs, if you're showing them to all players at the same time just call the player group variable, else check if player is in this player group before showing it.
Then you need trigger that will fire when dialog item is used by - checked (in conditions add used dialog item == dialog item variable you set for this checkbox). In actions make an IF THEN ELSE:
If (Used Dialog Item) is checked for (Triggering Player) == true
then Player Group - Remove (Triggering Player) from (PlayerGroupVariablehere)
else add him to this group, if you want that functionality
Ok, so its a SP map so I don't really need to address that, but I'm still unable to make it work. This is what I have so far
A global variable called TutorialEnabled (boolean) which starts out as true
A global variably called TutorialCheck(dialog item) which starts out empty
Now in every dialog I have this: I set the checkbox to TutorialCheck
Dialog - Create a check box for dialog (Last created dialog) with the dimensions (200, 50) anchored to Bottom Right with an offset of (69, 50) setting the tooltip to "Check this to hide tutorials." and default to Unchecked
Variable - Set TutorialCheck = (Last created dialog item)
Then in every dialog, I have a condition
TutorialEnabled == true
Finally, I have a trigger called TutorialEnable
TutorialEnable
Events
Local Variables
Conditions
(Used dialog item) == TutorialCheck
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(TutorialCheck is checked for 1) == true
Then
Variable - Set TutorialEnabled = false
Else
But... it's not working, and I don't know what I'm doing wrong (or right lol)
No event - it doesn't know when to run. You always need an event, unless the trigger is only supposed to be used by the "Run trigger" action (if you dont know what it does, you put it in a trigger, and that trigger will force another specified trigger to... well... trigger? Anyway, it runs another trigger but skips the events part, and possibly also conditions. Not needed in any simple trigger work though.)
Hello fine gents. I'm trying to understand dialogs to the best of my ability but I'm struggling with buttons.
I want to do something very simple.
Have a dialog box that displays text (already done), with a button (already done) and when you click that button, the windows hides.
I know I have to set up some variables and stuff but I have no idea how to do it. It's no help that the event for dialog is really limited.
Anyone care to teach this poor noobie?
@Kitadol: Go
I usually have an initialization action for the window and a record object type for the window components I want to track. The code below isn't perfect, I think you can actually call a trigger to see if a dialog is showing or not so the bool showing probably not needed. Please let me know if this helps or not. Here's an example window of mine:
TRIGGER FOR HANDLING TOGGLE SHOW / HIDE BUTTON:
DIALOG RECORD
INIT SCOREBOARD RECORD
TOGGLE SCOREBOARD SHOWING / HIDING
Yo dawg, thanks for the help but I have no idea what you talking about, I just want to hide the dialog when I click a button :(
event
Any dialog item is pressed
condition
*you could add condition like dialog == closedialogbutton
action
Show/Hide [last created dialog or ur variable for the dialog] for player [triggering player]
You need 2 global variables of type Dialog and Dialog item. In trigger you create your dialog and button add those:
Set variable = (Last Created Dialog) and Set variable = (Last created Dialog Item) right below them.
Then you need a trigger with event: Any dialog item is used (clicked) by player any (or specify)
Conditions: Used dialog item == DialogItem variable you made
Then actions: Hide (Dialog variable you made) for player (triggering player)
YAY!!!!!!!!!! It worked
Thanks a lot guys. Your post was awfully informative uiasdnmb. I'm still not very familiar with how variable and conditions work
Thinking of asking here to avoid making other thread, for its a simple question. Dialog related.
How do you go about adding images to the dialog? I know how to actually do it (Just did it using some of the asset textures), but can you currently import images you create to put them in the dialogs? If so, what format should it be?
Edit: Oh and something else, how do I block control of the player when a dialog(clicking, moving, etc) when a dialog box is shown?
Yes you can put them inside, just use import manager (one of the buttons on top). I know that .TGA and .DDS (maybe some more but dunno) formats are supported for images, after importing you must save map and you should be able to select them from the list of images.
Thanks for replying uiasdnmb :). What program do I need to create those kind of files?
Nvm, I found a converter and it worked great, thanks!
How does it work, exactly? Is the image now attached to my map, so if I share it, the images will transfer?
Map files are practically MPQ archieves, and your image is saved inside it, so yes it will go anywhere where the map does.
It's simple, just do something like
Dialog - Button is clicked
Dialog - Hide Dialog ()
It's something like that, I'm not at the right comp right now but, its something like that.
@WraithChaser: Go
I C u r reading the thread b4 posting. D=
Ok, so I have another question. I managed to close dialogs like a pro, but I can't manage to get the check boxes to work. I want to show a series of dialogs, but if they check a box once, they don't get more dialogs.
I don't know how to make the trigger recognize that it has been checked.
When creating check box set is as variable Dialog Item just like button.
Ok, so its a SP map so I don't really need to address that, but I'm still unable to make it work. This is what I have so far
A global variable called TutorialEnabled (boolean) which starts out as true
A global variably called TutorialCheck(dialog item) which starts out empty
Now in every dialog I have this: I set the checkbox to TutorialCheck
Dialog - Create a check box for dialog (Last created dialog) with the dimensions (200, 50) anchored to Bottom Right with an offset of (69, 50) setting the tooltip to "Check this to hide tutorials." and default to Unchecked
Variable - Set TutorialCheck = (Last created dialog item)
Then in every dialog, I have a condition
TutorialEnabled == true
Finally, I have a trigger called TutorialEnable
TutorialEnable
Events
Local Variables
Conditions
(Used dialog item) == TutorialCheck
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(TutorialCheck is checked for 1) == true
Then
Variable - Set TutorialEnabled = false
Else
But... it's not working, and I don't know what I'm doing wrong (or right lol)
You copied this trigger here? Coz you're doin everything good... but i dont see event for your pasted trigger.
For TutorialEnable? I guess it should have an event, no?
No event - it doesn't know when to run. You always need an event, unless the trigger is only supposed to be used by the "Run trigger" action (if you dont know what it does, you put it in a trigger, and that trigger will force another specified trigger to... well... trigger? Anyway, it runs another trigger but skips the events part, and possibly also conditions. Not needed in any simple trigger work though.)
The event you need is "Any dialog item is used"
dayum
thanks masters, you masters are my masters of triggers mastery