-
Notifications
You must be signed in to change notification settings - Fork 79
Gui tags #1503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Gui tags #1503
Conversation
grilledham
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good idea and I'd accept as is, but I do have a preference to give tags precedence over names for events.
|
I see now what you mean with tags taking precedence over names. Then yes... We don't use elem names much in the codebase to access children I think (gui data replaces the tree names cascade to access children\parents via elem path), but if we indeed free the names from being used as handlers keys, and use always tags, then we could also remove the lookup in the event factory for elem.name and just check tag, then only use names for accesses like parent.flow.table.button.... not the best for complex hierarchies, but still useful for 1-2 deep structures instead of caching all the refs in storage. Would free some ram & keep gui handlers lightweight |
|
Refactoring all the instances of I'm gonna list a few critical files that have been ported but I would like to take another moment to review and test in game: |
Actually, after refactoring all names to tags, I realized that I've left those (+ a few of other exceptions of quick-access), and those elements will have redundant name+tags with same key (or even different, if wanted), because As a rule of thumb, left elements do not have associated handlers, while top|center|screen elements usually have a |
|
|
||
| local b = Gui.add_top_element(player, { | ||
| type = 'button', | ||
| name = toggle_button_name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this case can get away with not needing the name, but I think all other cases of Gui.add_top_element need it, so maybe should keep just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this name is needed cuz Gui.add_top_element indexes children by name (same as cutscene controller which I reverted).
I may be not too happy with top & left having mandatory argument name now that it has been kinda deprecated but oh well... Maybe I'll figure something out while refactoring around, dont have a nice solution yet
|
The |
Thanks for doing this. I know this is a lot of tedious work. I think having elements with the same name and tag value is good in cases where they are both used. |
I did forgot to add the tag for poll, but evolution doesnt need a tag since there's no handler/window associated with it being clicked. (double checking w/ you) |
|
I'm not 100% happy with the current state of this draft, so I will try to refactor Gui util once more to address these issues:
Possible solutions that I'm broadly exploring:
|
|
Regarding this draft, would you (@grilledham ) consider it an improvement if:
|
|
Proposal to extend gui handlers registration to tags as well.
Scope
This PR adds a new
.tagfield (internally__@level-RedMew__event_handler_tag__) to theutils.gui.luamodule, that can be used to associate an handler to the value assigned to this key-value pair inside aLuaGuiElement::tagsThis allows children of the same
LuaGuiELementto share "name" and handlers, and keeps the same syntax currently used forname.Relevant changes:
Examples
Comparison and usage of current/proposed changes
1. Current behavior with
LuaGuiElement::name2. Extension to
LuaGuiElement::tagsIn addition to
name,tagsare also filtered by the gui handler factory, allowing such syntax:Notes:
nameandtagscan be used to register the handlername(more domain specific) will take precedence overtagsEdit:
player.gui.screen|center|left|top)