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 2
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...