Jump to content

How to add items to a dropdown from a script?


Vantha
 Share

Recommended Posts

I have a dropdown in an XML for a GUI page like this:

<object name="dropdown" type="dropdown"/>

I know I can add items like this:

<item>name of the first item</item>
<item>name of the second item</item>

The problem is that I want to have more than ten items in the dropdown, and preferably add them from a JavaScript script instead of listing all of them in the XML. How can I do that?

I found list functions here: https://trac.wildfiregames.com/wiki/Exposed_GUI_Functions#List_functions. But I'm not sure how to use them. And from a quick search not a single instance of 'addItem' or 'pushItem' was found in 0ad's code.

  • Like 1
Link to comment
Share on other sites

3 hours ago, Vantha said:

The problem is that I want to have more than ten items in the dropdown, and preferably add them from a JavaScript script instead of listing all of them in the XML. How can I do that?

If you just want dropdown values then you might take a look at binaries/data/mods/public/gui/options/. We add dropdown values dynamically via JS for options.

30 minutes ago, Stan&#x60; said:

You can't add dynamic GUI objects.

If I'm not mistaken the question is about many values not many dropdowns.

  • Like 3
Link to comment
Share on other sites

1 hour ago, vladislavbelov said:

If you just want dropdown values then you might take a look at binaries/data/mods/public/gui/options/. We add dropdown values dynamically via JS for options.

Thanks. I found there what I've been searching for.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...