-
Notifications
You must be signed in to change notification settings - Fork 1
Enhancement: Dividing up the enormous t2da_dock.gd script. #1
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The current implementation of the Texture Array Tools addon resides almost entirely within a single, large GDScript file (addons/texture_array_tools/t2da_dock.gd)
This script handles:
- UI node references (@onready var) for the entire dock.
- Signal connections for all UI elements.
- Logic for the Texture2DArray Generator.
- Logic for the Image Resizer.
- Logic for transferring data between the two tools.
- Utility functions (dialog configuration, status labels, maybe themes or smth)
- State management for both tools (input/output lists, UI settings)
Next Changes?
In order to make the addon easier for people to collaborate, suggest improvements or fixes and generally just 'read-through' - I have some current plans on restructuring the script logic to be spread across multiple .gd files.
plugin_system_theme_ui_applier.gd
- How might this be better implemented?
- It would help to have the workload of this script split up - just for readability and comprehensions' sake.
- We have a very, overly complicated way of finding styles from the base Editor theme. Some entries are entirely unnecessary.
- Those theme-ing rules are crazy. Probably why I shouldn't have relied on AI to resolve all of my issues with accessing, storing and applying Editor theme settings.
- Could elaborate on this forever and ever.
- It's really going to boil down to separating the T2DA Generator and Image Resizer from one another.
- We can certainly divide it up into a few different scripts:
tat_utils.gd?
- Anything that could be considered a helper function all-around.
- Stuff like setting status labels, getting format names, maybe even configuring the file dialog if needed by more than one part.
- Could be an autoload or maybe just a static helper class (
class_name TATUtils)
t2da_gen_ui.gd & image_resizer_ui.gd?
- Maybe not separate scripts for just UI nodes/signals? That might be overkill.
- The main dock script could still handle connecting signals from the UI elements.
- Or maybe these could be simple containers holding the
@onready vars and basic signal connections for their respective sections, delegating the actual work? Less mind-bending line-hopping? Undecided.
t2da_gen_logic.gd & image_resizer_logic.gd?
t2da_gen_logic.gdwould have all the functions for validating inputs, converting formats, and actually building theTexture2DArray. It would manage the T2DA input list.image_resizer_logic.gdwould have the functions for finding the largest size, processing the resize batch (stretch/pad/crop), handling naming, formats, quality, etc. It would manage the Resizer input/output path lists.- Classes? Inherit
RefCountedvs them being Nodes? The main dock script would create instances of these. (TBD)
Retain, yet de-bloat t2da_dock.gd? Or split into t2da_gen_dock.gd and image_resizer_dock.gd?
Option 1
- Keep
t2da_dock.gdas the main script attached to the panel. It would handle all the@onreadyvars, connect all signals, create instances of the_logic.gdscripts, and act as the "controller" telling the logic scripts what to do based on UI events. - It would also handle transferring data between the Generator and Resizer logic components. This keeps the UI scene simple.
That sounds good at 2 am.
Option 2
- Split the UI scene itself into maybe two separate container nodes within the main dock panel.. each with its own script (
t2da_gen_dock.gd,image_resizer_dock.gd) - Each script COULD manage its own UI stuff.
- Maybe a handler or something to communicate between panels instantaneously. Idk how docks work lol.
Too much? Idk.
Next Steps
- Decide on the best overall structure (Leaning towards Option 1: main controller + logic classes + utils)
- Start breaking apart the
t2da_dock.gdinto digestible scripts. - Figure out how state/data is passed between the UI handler/controller and other logic scripts. (probably signals)
- Create that dedicated utility script. Global/Autoload???
Testing and not pushing possibly destructive code is probably the best thing for me to keep in mind.
Ultimately.. they could be two separate plugins, but I'm not gonna do that because I'm stubborn. 😴
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request