• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Help for changing dialog button

Status
Not open for further replies.
Level 4
Joined
Dec 10, 2015
Messages
85
Hello,
so here's the deal, I want to create a dialog with two button.
The lower one is the Confirm! Button and will close the dialog
The upper one is the one causing me trouble
I'm trying to figure out how to change the title of the button when the player click on it.
The button is used to choose between three lane Top Middle Bottom.
So when you click on it, the button name will change from Top to Middle, or from Middle to Bottom, or from Bottom to Top.

But I can't find a way to change the button name without closing the dialog at all. I can't find a way to destroy a single button to create a new one.

If anyone can help me, or send me a script, it would be appreciated

thanks
 
I checked the Dialog natives:

JASS:
//============================================================================

// Dialog API

native DialogCreate                 takes nothing returns dialog

native DialogDestroy                takes dialog whichDialog returns nothing

native DialogClear                  takes dialog whichDialog returns nothing

native DialogSetMessage             takes dialog whichDialog, string messageText returns nothing

native DialogAddButton              takes dialog whichDialog, string buttonText, integer hotkey returns button

native DialogAddQuitButton          takes dialog whichDialog, boolean doScoreScreen, string buttonText, integer hotkey returns button

native DialogDisplay                takes player whichPlayer, dialog whichDialog, boolean flag returns nothing

The only way for you to do that is to create another dialog.
 
Level 11
Joined
Oct 9, 2015
Messages
721
I think there's also the option of changing the dialog's title, you can use the first button and change it to something like "Change Lane" and when it's clicked you can change the dialog's title to "Upper", "Middle" or "Bottom". Then you set an integer variable to 1 (meaning upper), 2 (meaning middle) or 3(meaning bottom) to check for condition if you need so.
 
I think there's also the option of changing the dialog's title, you can use the first button and change it to something like "Change Lane" and when it's clicked you can change the dialog's title to "Upper", "Middle" or "Bottom". Then you set an integer variable to 1 (meaning upper), 2 (meaning middle) or 3(meaning bottom) to check for condition if you need so.

He doesn't want that. What he wants is to change the button title not the dialog title
 
Level 4
Joined
Dec 10, 2015
Messages
85
I checked the Dialog natives:

JASS:
//============================================================================

// Dialog API

native DialogCreate                 takes nothing returns dialog

native DialogDestroy                takes dialog whichDialog returns nothing

native DialogClear                  takes dialog whichDialog returns nothing

native DialogSetMessage             takes dialog whichDialog, string messageText returns nothing

native DialogAddButton              takes dialog whichDialog, string buttonText, integer hotkey returns button

native DialogAddQuitButton          takes dialog whichDialog, boolean doScoreScreen, string buttonText, integer hotkey returns button

native DialogDisplay                takes player whichPlayer, dialog whichDialog, boolean flag returns nothing

The only way for you to do that is to create another dialog.
okay, well according to a tutorial I though it was possible, maybe they do as you say, they clear the dialog and create a new one...
I think I'll go with the alternate solution and change the Dialog title...
thanks
 
Level 4
Joined
Dec 10, 2015
Messages
85
So, I'm trying to change the title of the dialog, but it doesn't work at all
here's the trigger
  • P3Focus Menu
    • Events
      • Dialog - A dialog button is clicked for P3FocMenu
    • Conditions
      • (Clicked dialog button) Equal to P3_FocButton
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • P3_Focus Equal to 0
        • Then - Actions
          • Dialog - Change the title of P3FocMenu to Lane Focus : Top La...
          • Set P3_Focus = 1
          • Dialog - Show P3FocMenu for Player 3 (Teal)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • P3_Focus Equal to 1
        • Then - Actions
          • Dialog - Change the title of P3FocMenu to Lane Focus : Middle...
          • Set P3_Focus = 2
          • Dialog - Show P3FocMenu for Player 3 (Teal)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • P3_Focus Equal to 2
        • Then - Actions
          • Dialog - Change the title of P3FocMenu to Lane Focus : Bottom...
          • Set P3_Focus = 3
          • Dialog - Show P3FocMenu for Player 3 (Teal)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • P3_Focus Equal to 3
        • Then - Actions
          • Dialog - Change the title of P3FocMenu to Lane Focus : None
          • Set P3_Focus = 0
          • Dialog - Show P3FocMenu for Player 3 (Teal)
        • Else - Actions
When I try it in game, the title stay to the same, the original one, the one I used when it was created at the beginning of the game.
 
Level 6
Joined
May 20, 2014
Messages
228
Can I ask what are these P3_Focus variables and what are they for? Also I believe you have to clear the dialog before showing them, and the new dialogs you're creating after the old dialog doesn't seem to have the buttons so I assume that may be why they're not showing up.
 
Level 4
Joined
Dec 10, 2015
Messages
85
errr... okay so firstly first :
P3_Focus is an interger that I use so the games know what lane the player is focusing on.
P3FocMenu is the dialog for P3
P3_FocButton is the button in the dialog that is supposed to make the variable changing its value and the title of the dialog to change too.

Also, I didn't said the dialog is not showing up, I said that the title doesn'T change
 
Level 6
Joined
May 20, 2014
Messages
228
I'm a bit confused with how you're trying to do with the variables, why not just declare the variable after some user clicked on what exact button in if conditions, unless there's some information I'm missing.

Also my bad, I misunderstood, you have to use the action "Dialog - Clear <dialog>" before each dialog so it's fully reusable I believe.

edit: I think this tutorial will help.
 
Level 6
Joined
May 20, 2014
Messages
228
If it was possible to do that without clearing then would it not work?

I made two triggers, one that shows a button + the title of the dialog, and then the other trigger showing the same dialog but changing the title also works and it works normally just fine (the lowercase dialog is a Dialog variable, and the button is a Dialog button variable):

  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Dialog - Clear dialog
      • Dialog - Change the title of dialog to What do you want the game to say
      • Dialog - Create a dialog button for dialog labelled Hello World
      • Set button = (Last created dialog Button)
      • Dialog - Show dialog for Player 1 (Red)

  • Untitled Trigger 002
    • Events
      • Dialog - A dialog button is clicked for dialog
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to button
        • Then - Actions
          • Dialog - Clear dialog
          • Dialog - Change the title of dialog to Confirm?
          • Dialog - Create a dialog button for dialog labelled Yes
          • Dialog - Create a dialog button for dialog labelled No
          • Dialog - Show dialog for Player 1 (Red)
        • Else - Actions
So what you want to do is to clear the dialog before creating it, then create the buttons before the dialog, and show the dialog. The tutorial I've linked in my post earlier is really great at explaining how they work and why you should use them...

The real reason why I was initially confused by your conditions because you are not having the triggers do anything for each individual button that was clicked... that's why I asked about the variables, etc.
 
Level 4
Joined
Dec 10, 2015
Messages
85
Well, just tryed this, and still doesn't work, can you tellme what is wrong in it?
  • P3Focus Menu
    • Events
      • Dialog - A dialog button is clicked for P3FocMenu
    • Conditions
      • (Clicked dialog button) Equal to P3_FocButton
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • P3_Focus Equal to 0
        • Then - Actions
          • Set P3_Focus = 1
          • Dialog - Clear P3FocMenu
          • Dialog - Change the title of P3FocMenu to Lane Focus : Top
          • Dialog - Create a dialog button for P3FocMenu labelled Change Focus
          • Set P3_FocButton = (Last created dialog Button)
          • Dialog - Create a dialog button for P3FocMenu labelled Confirm!
          • Set P3_conf = (Last created dialog Button)
          • Dialog - Show P3FocMenu for Player 3 (Teal)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • P3_Focus Equal to 1
        • Then - Actions
          • Set P3_Focus = 2
          • Dialog - Clear P3FocMenu
          • Dialog - Change the title of P3FocMenu to Lane Focus : Middle
          • Dialog - Create a dialog button for P3FocMenu labelled Change Focus
          • Set P3_FocButton = (Last created dialog Button)
          • Dialog - Create a dialog button for P3FocMenu labelled Confirm!
          • Set P3_conf = (Last created dialog Button)
          • Dialog - Show P3FocMenu for Player 3 (Teal)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • P3_Focus Equal to 2
        • Then - Actions
          • Set P3_Focus = 3
          • Dialog - Clear P3FocMenu
          • Dialog - Change the title of P3FocMenu to Lane Focus : Bottom
          • Dialog - Create a dialog button for P3FocMenu labelled Change Focus
          • Set P3_FocButton = (Last created dialog Button)
          • Dialog - Create a dialog button for P3FocMenu labelled Confirm!
          • Set P3_conf = (Last created dialog Button)
          • Dialog - Show P3FocMenu for Player 3 (Teal)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • P3_Focus Equal to 3
        • Then - Actions
          • Set P3_Focus = 0
          • Dialog - Clear P3FocMenu
          • Dialog - Change the title of P3FocMenu to Lane Focus : None
          • Dialog - Create a dialog button for P3FocMenu labelled Change Focus
          • Set P3_FocButton = (Last created dialog Button)
          • Dialog - Create a dialog button for P3FocMenu labelled Confirm!
          • Set P3_conf = (Last created dialog Button)
          • Dialog - Show P3FocMenu for Player 3 (Teal)
        • Else - Actions
 
Level 6
Joined
May 20, 2014
Messages
228
And that's where the problem lies in with your conditions, but I can't say as I have no idea how they work since you never specified exactly (which was my original question). But it looks more cleaner/clear now.
 
Level 4
Joined
Dec 10, 2015
Messages
85
I want the dialog title to change once a specified dialog button is pressed (P3_FocButton)
If it's about the P3_Focus variable, well, the original value IS 0, so I don't see the problem
 
Level 6
Joined
May 20, 2014
Messages
228
Can you try and post the map here so I can see the real issue and try and find a solution?

My perspective is that the trigger is supposed to work but it only assumes if the conditions are true, which I assume is not true (unless you predefined the variable to be equal to 0 originally, but that can't work because then the rest of the trigger wouldn't make sense as it's designed to only run once).
 
Level 4
Joined
Dec 10, 2015
Messages
85
Can you try and post the map here so I can see the real issue and try and find a solution?

My perspective is that the trigger is supposed to work but it only assumes if the conditions are true, which I assume is not true (unless you predefined the variable to be equal to 0 originally, but that can't work because then the rest of the trigger wouldn't make sense as it's designed to only run once).

P3_Focus is originally set to 0, indeed... weird...
 

Attachments

  • Castle Wars Revolution.w3x
    336.7 KB · Views: 36
Level 6
Joined
May 20, 2014
Messages
228
Apparently the real issue was not nesting if/then/else conditions in together, which wasn't causing it to run properly.

I fixed the problem, I also made new triggers (and disabled your ones) in the new folder at the bottom and removed some bloating. It should do what you exactly were looking for, unless I got something wrong but shouldn't be hard to change it to something you were looking for. I also still made some stuff precautionary (like initializing P3Focus = 0, etc.).
 

Attachments

  • CWRupdate.w3x
    337.3 KB · Views: 27
Level 4
Joined
Dec 10, 2015
Messages
85
I though it already was initialized to 0
In the variable menu, there's a "Initial value" option, and I set it to 0. it doesn't work like that?
 
Level 6
Joined
May 20, 2014
Messages
228
No idea, but for sake of consistency I'd rather initialize it to some number, although if you remove it and works just fine then go crazy about it. Experiment, I guess, stuff whatever.
 
Status
Not open for further replies.
Top