Important Dates

Currently Online

Latest Posts

Topic: Bundle addons

kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2506
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2024-07-14, 10:43

I have made a map containing an UI-Plugin. More precisely the map contains a button shown below the Add-Ons button in the main menu and clicking this button opens a new window. This window is essential to play the map. This works fine when starting a new game, but when loading a save game the ui-plugin doesn't work because the button isn't shown anymore and thus the window can't be opened.

I think a solution is to make two addons, one for the map and one for the ui-plugin providing the button and window. Since the ui-plugin will work only with this specific map: Is there a way to bundle those two add-ons? Bundling means here

if map will be installed
install also the ui-plugin

And of course vice versa, when uninstalling. I know there is the requires= option in the addon file, but i guess this will handle only installs but no uninstalls?

Or do i have another possibility to insert a button and new window into the map? E.g. add an additional button to the inventory window which will open the map specific window?


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2020
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2024-07-14, 10:53

I've been thinking about providing a "combo" add-on category which essentially does what you suggest, it would act as multiple different types of add-on all in one. The only reason I didn't implement it is because nobody asked for it yet face-wink.png I'll start work on it in a few weeks, when I have more time for Widelands again.

This works fine when starting a new game, but when loading a save game the ui-plugin doesn't work because the button isn't shown anymore

As a workaround, you could use a while true loop to check every few seconds whether the button exists and recreate it if needed. But a combo add-on would allow a much more elegant solution.


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2506
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2024-07-16, 15:27

Yes, a combo add-on category is a good idea.

The categories are somewhat complicated already, from a players point of view, imho. Adding another category will make them more complicated... But this is probably an other issue.

Thanks for the workaround, i will try that.


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2506
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2024-07-17, 18:50

Hm, i can't access the entries of the dropdown:

local mv = wl.ui.MapView()

print("no_of_items", mv.dropdowns.dropdown_menu_plugins.no_of_items)   -- prints: 2 -> How to access those items?

for k, v in pairs(mv.dropdowns.dropdown_menu_plugins.children) do
   print("\nchildren", k, v)                                           -- prints: children        1       Panel: 0x6420fe983ca0

   for l,m in pairs(v.buttons) do
      print(l,m, m.name)                                               -- prints: dropdown_label  Button: 0x6420fd8598e0  dropdown_label
   end

   for l,m in pairs(v.children) do
      print(l,m, m.name)                                               -- prints: 1       Button: 0x6420fdd6a7e0  dropdown_label
   end
end

How can i access the entries in the dropdown? Since the buttons in the dropdown have no names i also can't reach them through wl.ui.MapView():get:child()

Did i overlooked something again?


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2020
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2024-07-18, 13:32

The entries in a dropdown or listselect are not panels, so they can't be accessed via children or get_child(). There currently isn't a getter function to retrieve existing entries, but it should be trivial to add index-to-{entry,label,tooltip} lookup functions for dropdowns and listselects.


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2506
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2024-07-18, 18:57

Ok then, thanks!

I will add the button to the toolbar itself. Probably a better place anyway for a map specific button.

This way there is also no need for indexing dropdowns, currently face-grin.png


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2020
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2024-08-01, 09:39

PR for accessing the properties of dropdown and listselect entries:
https://codeberg.org/wl/widelands/pulls/4848


Top Quote