Dialog Buttons :)

DonMushroom

Member
Reaction score
4
Hi :)

I see button on maps all the time. I would like to add one but do not know how :p

I'm aiming for when the button is clicked it opens a dialog window. If the button is clicked again it closes the dialog it just opened.


Does anybody know how this is done? :)
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
I recommend you start by reading this tutorial.

What kind of button do you want to have the opens the dialog window? A normal button on the command card or a custom button somewhere on the screen?

For the first option, create an ability and have a trigger that shows the dialog window when the ability is cast.

For the second option, create a new dialog with the button and then use the "Show/Hide Dialog Background" action to hide the rest of the dialog. Have a trigger that runs on the event "Dialog item is used" with a condition that checks that it is your button that is clicked. Make it show the other dialog that you want shown.

Tell me if that didn't make sense :)
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
So you went with the second option? You already got the button looking like you want it to, and now you want it to open the dialog?

First of all, you need a dialog variable to save the dialog with your button in.(Let's call it OpenDialogX) You also need a dialog variable to save the dialog you want to show. (Let's call it DialogX).

(Sorry for the lack of proper syntax, I don't have access to the editor right now)
Event:
Any dialog item is used
Conditions:
(Used Dialog Item) == OpenDialogX
Local Variables
Actions:
Show DialogX
 

DonMushroom

Member
Reaction score
4
So your saying the process is create a button, create a dialog you want to show, then link them together with the post above this? I don't talk in editor yet :( so really need a exact thing to look at, Figure out what you have done, how you go there and then i will hopefully have this button section down :)


Do i need 3 triggers? 1 for button, 1 for dialog, 1 for telling the button what to do?

I need the process of what im meant to be doing. :(
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Okay. First of all I need to know what kind of button you want to have to show the dialog.

Is it one like this:
k2cqpc.jpg
(The three buttons above the minimap. Although you might only want one and without the border)

Or is it one like this:
ozs06.jpg

For this, I'm assuming the dialog you want to open is some kind of score dialog that shows the score of stuff. This doesn't matter though, I just assumed it for the purpose of naming stuff.

First alternative

Read this tutorial until you understand how to create a dialog with a button.

Create a dialog approximately where you want your button that opens the other dialog to be. In my case(the first picture), I created my dialog right above the minimap. I created the dialog attached to bottom left with the offset (0,450) (or something similar to that). Next up, create the button on your last created dialog where you want it to be. Save this button in a dialog item variable.

Optional: Hide the background of the dialog you just created. This will make everything but the button, invisible. You wont see the border nor the background.

Also make the dialog that you want to show when the user presses the button.

Here's a trigger that does that:
Trigger:
  • Map initialization
    • Events
      • Game - Map initialization
    • Local Variables
    • Conditions
    • Actions
      • ------- Button that opens the score
      • Dialog - Create a Modal dialog of size (200, 200) at (0, 450) relative to Bottom Left of screen
      • Dialog - Show (Last created dialog) for (All players)
      • Dialog - Create a button for dialog (Last created dialog) with the dimensions (100, 100) anchored to Top Left with an offset of (50, 50) setting the tooltip to "" with button text "" and the hover image set to ""
      • Variable - Set OpenScoreButton = (Last created dialog item)
      • Dialog - Hide the background image of (Last created dialog)
      • ------- The score dialog
      • Dialog - Create a Modal dialog of size (500, 500) at (0, 0) relative to Center of screen
      • Variable - Set ScoreDialog = (Last created dialog)


It requires one dialog variable called "ScoreDialog" and one dialog item variable called "OpenScoreButton".

Make a trigger like this, which will handle the opening of the other dialog:
Trigger:
  • Open Score 1
    • Events
      • Dialog - Any Dialog Item is used by Player Any Player with event type Clicked
    • Local Variables
    • Conditions
      • (Used dialog item) == OpenScoreButton
    • Actions
      • Dialog - Show ScoreDialog for (Player group((Triggering player)))


Second alternative

In case you want an ability to open the dialog, do it this way.

First of all, you can use part of the first trigger from the first part. You just need to create the dialog that you want to show and save it in the ScoreDialog variable.

Next up, create a button and an effect - instant ability and give it to the unit you want to have it on.

Create a trigger like this for the opening of the dialog:
Trigger:
  • Open Score 2
    • Events
      • Unit - Any Unit uses Open score at Generic6 - Complete stage (Ignore shared abilities)
    • Local Variables
    • Conditions
    • Actions
      • Dialog - Show ScoreDialog for (Player group((Triggering player)))


Here's what the triggers would look like if you want it to be toggleable(So you can show and hide it with the same button):
Trigger:
  • Open Score 1 toggle
    • Events
      • Dialog - Any Dialog Item is used by Player Any Player with event type Clicked
    • Local Variables
    • Conditions
      • (Used dialog item) == OpenScoreButton
    • Actions
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • (ScoreDialog is visible for (Triggering player)) == True
        • Then
          • Dialog - Hide ScoreDialog for (Player group((Triggering player)))
        • Else
          • Dialog - Show ScoreDialog for (Player group((Triggering player)))

Trigger:
  • Open Score 2 toggle
    • Events
      • Unit - Any Unit uses Open score at Generic6 - Complete stage (Ignore shared abilities)
    • Local Variables
    • Conditions
    • Actions
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • (ScoreDialog is visible for (Triggering player)) == True
        • Then
          • Dialog - Hide ScoreDialog for (Player group((Triggering player)))
        • Else
          • Dialog - Show ScoreDialog for (Player group((Triggering player)))

Here's a test map I made. You can look it through to see how it works. View attachment opendialog.SC2Map
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top