[GUI] selecting multipage
Moderator: Forum Moderators
-
- Posts: 1280
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
[GUI] selecting multipage
Currently, I'm doing this:
I'd like to be doing this:
However, I believe add_item_of_type is currently broken, always returning -1 for pos.
https://github.com/wesnoth/wesnoth/issues/8490
Is there an alternative to selected_index that uses item instead of position, or can I somehow get the (real) position from item, for example:
or
I don't think those examples make a lot of sense, but hopefully they convey what I'm trying to accomplish.
It's really not a big deal either way, I'm just trying to break a bad habit before it takes hold.
Code: Select all
dialog.unit_info_mp:add_item_of_type("empty_page")
dialog.unit_info_mp:add_item_of_type("unit_info_page")
...
dialog.unit_info_mp[2].unit_info_preview.unit = wesnoth.units.find{ id = unit.id }[1]
dialog.unit_info_mp.selected_index = 2
Code: Select all
empty_item, empty_pos = dialog.unit_info_mp:add_item_of_type("empty_page")
unit_item, unit_pos = dialog.unit_info_mp:add_item_of_type("unit_info_page")
...
unit_item.unit_info_preview.unit = wesnoth.units.find{ id = unit.id }[1]
dialog.unit_info_mp.selected_index = unit_pos
https://github.com/wesnoth/wesnoth/issues/8490
Is there an alternative to selected_index that uses item instead of position, or can I somehow get the (real) position from item, for example:
Code: Select all
dialog.unit_info_mp.selected_item = item
Code: Select all
dialog.unit_info_mp.selected_index = item.pos
It's really not a big deal either way, I'm just trying to break a bad habit before it takes hold.
Speak softly, and carry Doombringer.