Closed EthanGrahn closed 10 months ago
Noting a potential issue that may need another PR - If show_if
is on the last variables, I expect it to fail because it won't be able to initialize during the next variable.
Wow, this... seems to have been a lot of work.
However:
class_name
s in plugins are generally advised against since they may overlap with class names in the project, and relying on them has a script compilation error that breaks the plugin on first launchshow_if
still works strange: seems to not affect the bottom-most property with this attribute. However, it does seem to work on tables AND regular props now.I will consider the implemented refactorings, and would appreciate a pull with only changes to address #5!
This turned out to be a larger rework than I had thought.
Overview
The
@@show_if
attribute is now aPanelContainer
. All custom attributes and the property itself will be assigned as children to thePanelContainer
. When the expression is true, the container will hide itself which also hides the children. The choice to usePanelContainer
is so that it will automatically scale itself to fit all child elements.@@show_if
works as a "delayed attribute" meaning it will wait until the next property is being parsed to be initialized. This allows the previous property, and any supplemental attributes, to be loaded into the tree for access.Resolves #5
attributes.cfg
To reduce the size of the main plugin script and improve maintainability/readability, I moved the
attribute_scenes
map information into a config file. The section names in the config file match the attributes available for use. This config file is parsed in the main plugin script and constructs theattributes_scenes
map dynamically. Although it's basic right now, this could be extended to allow customizing settings per attribute.Tables
This change is not necessary for this fix, it was an early refactor when I thought adjustments to the tables would be needed. I split
table.gd
into separate table scripts that all inherit from a base table. This avoids the large if statements in the original script and allows checking types if necessary. (e.g.if node is MultiArrayTableAttribute
)I'm open to making any changes, just let me know!