EQ2Interface (https://www.eq2interface.com/forums/index.php)
-   XML Modification Help & Info (https://www.eq2interface.com/forums/forumdisplay.php?f=22)
-   -   Dropdowns In a Nutshell (https://www.eq2interface.com/forums/showthread.php?t=2483)

Zonx 04-08-2005 07:47 PM

Dropdowns In a Nutshell
I wont bother with all the usual properties, only what's needed to make dropdowns function.

Dropdowns are essentialy a mechanism for sellecting a row of data properties (aka fields or cells) from a database table.

The database for a dropdown is the DataSource object (not a DataSourceContainer).

Nested within the DataSource are Data Items. Data Items are essentially the rows of your database. They have only 1 default property "Name", which is used for internal referencing.

Data Items can be given any additional properties you desire. Each property used is esentially a field (or cell) in the database table. The name you give each property doesn't really mater. What matters is that you use the same property names on each Data Item. Corisponding property names form a column in your database table. The values assigned to those properties are the cells of the table.

Dropdowns also require a RowTemplate that includes at least 1 property used in the DataSource. The RowTemplate defines what's displayed in each row of the dropdown menu. The typical RowTemplate is /Templates.dropdowntemplate which uses a "text" property for display.

You'll also need to give the dropdown a style that defines its normal background and highlight background. The standard style is /dropdownlist.dropdown_default

So at a minimum, you have a dropdown object:


<Dropdownbox DataSource="MiscMapsDS" Name="MiscDropdown" RowTemplate="/Templates.dropdowntemplate" Size="51,16" Style="/dropdownlist.dropdown_default"/>
Which pulls data from the "MiscMapsDS" DataSource.


<DataSource Name="MiscMapsDS">
<Data Name="Misc" text="Misc"/>
<Data Name="World" text="World"/>
<Data Name="The Isle of Refuge" text="The Isle of Refuge"/>

Each of the "text" values will be used in the menu.

Ok so we've got a menu, but it doesn't actually make anything happen. Here's where the magic happens!

Dropdowns have an OnSelect event handler that can be used to drive scripts when a selection is made. You can also pull the value of any property for the selected row using SelectedItem.propertyname. Combineing these 2 functions allows data to be pulled from the DataSource and passed to other objects.



This passes the value of the selected item's text property to TextWidget.

Ok maybe that's not so exciting. Lets try something more advanced. First lets add a property to each Data Item for associated commands.


<DataSource Name="MiscMapsDS">
<Data command="parent.size='10,10' parent.location='1,1'" Name="Misc" text="Misc"/>
<Data command="parent.size='20,20' parent.location='2,2'" Name="World" text="World"/>
<Data command="parent.size='30,30' parent.location='3,3'" Name="The Isle of Refuge" text="The Isle of Refuge"/>

Now we'll add a simple button to recieve the command and exicute it when pressed.


<Button Name="RunCommands" Size="2,2" Visible="false"></Button>
Fianally we'll give the dropdown an OnSelect script to pass the command to the button, and press the button, thus exicuting the command.


<Dropdownbox DataSource="MiscMapsDS" Name="MiscDropdown" OnSelect="parent.RunCommands.OnPress=SelectedItem.command
RowTemplate="/Templates.dropdowntemplate" Size="51,16" Style="/dropdownlist.dropdown_default"/>

Result: We now have a menu that runs any script associated with the selected text ;)

dc_roenfanz 04-08-2005 08:58 PM

So, if I understand this, your sample drop down above is like ... the jump to forum dropdown. Click the down arrow, select forum, hit go. Right? I mean basically not exactly.

Ok, I think I understand that. maybe. OK about a thrid of it but they. thats cool.

Zonx is 133+ !!!


Zonx 04-08-2005 10:06 PM

heh, it can run any script you associate with a menu item. You might make a menu that completely reconfigures a window 5 different ways.

My latest map windows include menus that load any map on disk ;)

I hope tto retool Kosmos emotes to use a few menus insted of a slew of buttons.

Deathbane27 04-09-2005 01:27 AM

Thanks for the info/tutorial, Zonx. :)

I'd sticky this but I think there's already too many in this board. Maybe I will anyway. :p

Kosmos 04-09-2005 08:35 AM

Great stuff! I also had some ideas instore for the emotes, just haven't had the time to get into the project. I wish I could just sit and play all the time! LoL!

That's a neat little way you got it to work by creating the button.
That is basically the way the StartMenu works, They use a button template, such as yours.

On interesting thing about the StartMenu is that the window sizes according to the number of data objects, which is a pretty nice feature. It doesn't actually use a listbox, or dropdown, but basically creates a list of buttons, using the button template.

I'm sure you also noticed using UI Builder, you can easily sort your list of data items. you can just move items up and down the tree, and it moves them in the list!

Ahh.. pour old emotes is going to get basted! LOL! I needs it badly, I knew when I made it that it would not be long until we figured a better way to do that. This is going to be an incredible tool, thanks for the post Zonx!

Kosmos 04-09-2005 08:38 AM

One other thing!

Once this problem was figured out, I wanted to post a generic module for the utilities section for this.

Basically a page that contains all the information for a working list box, with generic names and commands that the Mod people could alter for thier own uses. It woud not reference any other objects in SOE.
Like include it's own styles, and graphics references etc, all under the same page.

Zonx 04-09-2005 09:23 AM

Sounds good with one exception...

DropdownStyles generally want images for their backgrounds. Its probably possible to create a style that only uses fill colors, but it'd be prety lame :p

I'd hate to see a billion mods with a billion itterations of the same DropdownStyle and images baried in them. Not sure, but I suspect this would cause a performance hit. It'd also make it a MAJOR pain to update the menu skin.

Deathbane27 04-09-2005 04:26 PM

Why not have the example dropbox use the default style?

Zonx 04-11-2005 07:37 AM

Some more testing show's Listbox to work virtually identical to dropdown. One interesting difference is the addition of an OnDoubleClick event. Haven't tested this event in game, but it does nothing in UIBuilder.

All times are GMT -5. The time now is 06:31 AM.

vBulletin® - Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.