Hello
I have a pulldown list displaying the factions that the user can select, once the user has selected the faction from the dropdown they then confirm the selection by pressing the ok button which makes the dialog disappear. The problem is, how do I retrieve the selected list dialog item so I can display it as a text tag or use it to manipulate events in the game.
My code so far
This is the Creation of the race select dialog
The dialog creation step is fine
Create a Modal dialog of size (500, 400) at (0, 0) relative to Center of screen
Variable - Set Race selection dialog = (Last created dialog)
Dialog - Create a Pulldown for dialog Race selection dialog
Variable - Set Race Select List = (Last created dialog item)
Dialog - Move Race Select List to (50, 50) relative to Top Right of dialog for (All players)
Dialog - Add list item "Team A" to Race Select List for (All players)
Dialog - Add list item "Team B" to Race Select List for (All players)
Dialog - Create a button for dialog Race selection dialog with the dimensions (200, 50) anchored to Bottom Right with an offset of (50, 50) setting the tooltip to "" with button text "Ok" and the hover image set to ""
Variable - Set Race Confirm Button = (Last created dialog item)
Dialog - Show Race selection dialog for (All players)
Varibles
Race selection dialog = No Dialog <Dialog>
Race Select List = No Dialog Item <Dialog Item="">
Race Confirm Button = No Dialog Item <Dialog Item="">
Here is the event that closes the faction select screen and I want it to output the selected list item or store it somehow.
Untitled Trigger 001
Events
Dialog - Any Dialog Item is used by Player Any Player with event type Clicked
Local Variables
Conditions
(Used dialog item) == Race Confirm Button
Actions
Dialog - Hide Race selection dialog for (All players)
Dialog - Destroy Race selection dialog
Text Tag - Create a text tag with the text (Text of Race Select List for 1) for (All players), using a font size of 24, at (Current camera target of player 1) and height offset 1.0, initially Visible, and fog of war enforcement set to False
Text Tag - Show (Last created text tag) for (All players)
Your list items have indexes and with the function "Selected List Item" you can retrieve the index of the selected list item. You need an integer array to store the race for all players. Now you have to create a new trigger that runs when the selection of your list box is changed and then you set the race variable for the triggering player to "Selected List Item". The first race you add to the list will have the index 0 so when the race variable of the player is 0 you create the according units for the player. The second race is defined by the value 1 and the third race by the value 2, ... etc.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
My code so far
This is the Creation of the race select dialog
The dialog creation step is fine
Create a Modal dialog of size (500, 400) at (0, 0) relative to Center of screen
Variable - Set Race selection dialog = (Last created dialog)
Dialog - Create a Pulldown for dialog Race selection dialog
Variable - Set Race Select List = (Last created dialog item)
Dialog - Move Race Select List to (50, 50) relative to Top Right of dialog for (All players)
Dialog - Add list item "Team A" to Race Select List for (All players)
Dialog - Add list item "Team B" to Race Select List for (All players)
Dialog - Create a button for dialog Race selection dialog with the dimensions (200, 50) anchored to Bottom Right with an offset of (50, 50) setting the tooltip to "" with button text "Ok" and the hover image set to ""
Variable - Set Race Confirm Button = (Last created dialog item)
Dialog - Show Race selection dialog for (All players)
Varibles
Race selection dialog = No Dialog <Dialog>
Race Select List = No Dialog Item <Dialog Item="">
Race Confirm Button = No Dialog Item <Dialog Item="">
Here is the event that closes the faction select screen and I want it to output the selected list item or store it somehow.
Untitled Trigger 001
Events
Dialog - Any Dialog Item is used by Player Any Player with event type Clicked
Local Variables
Conditions
(Used dialog item) == Race Confirm Button
Actions
Dialog - Hide Race selection dialog for (All players)
Dialog - Destroy Race selection dialog
Text Tag - Create a text tag with the text (Text of Race Select List for 1) for (All players), using a font size of 24, at (Current camera target of player 1) and height offset 1.0, initially Visible, and fog of war enforcement set to False
Text Tag - Show (Last created text tag) for (All players)
Your list items have indexes and with the function "Selected List Item" you can retrieve the index of the selected list item. You need an integer array to store the race for all players. Now you have to create a new trigger that runs when the selection of your list box is changed and then you set the race variable for the triggering player to "Selected List Item". The first race you add to the list will have the index 0 so when the race variable of the player is 0 you create the according units for the player. The second race is defined by the value 1 and the third race by the value 2, ... etc.