albinaask / SEAL

Settings Encapsulation and Abstraction Layer
MIT License
9 stars 0 forks source link

Option to override views without editing scripts? #2

Open Mondanzo opened 1 month ago

Mondanzo commented 1 month ago

Hey there, trying out this settings plugin and one thing I'm struggling with at the moment is the UI.

I have a very strong core ideology of not overriding any third-party extension files, because of the potential of breaking something. Now I also want to edit the theme and maybe even replace some controls with slight variations, but from what I'm getting that's only possible through editing the direct files?

Is there a way to override painters without editing the loaded files directly?

albinaask commented 1 month ago

I wholesomely agree with your ideology. Regarding the theme, it is meant to be changed. The Idea is the following:

  1. You create a Dialog either through code or as a node in a scene.
  2. You set the theme property to your project's theme.
  3. If you have no theme yet, you can just duplicate the standard theme, place it outside the addon folder and make your changes.

If you'd like to make small changes to a painter, I'd do the following:

  1. Make a new script that extends the SettingsPanel script.
  2. Use set_script([your_script]) or set the script manually for your dialog.
  3. Override the _on_panel_visibility_changed()
  4. Call super() as your first action in that method.
  5. Acess the painters as children of the SettingsPanel. So looping thrgough get_children() and filter on SettingsPainter, will get a basic filter.
  6. Make the changes to the painters you want in code.

An option is to do the following, for example changing the boolSettingsPainter from a checkbox to a CheckButton:

  1. Create a derived scene from the BoolSettingsPainter Scene or make a new one that fits your liking and save it outside your plugin.
  2. Create a new script that extends BoolSetting.
  3. Override the get_settings_painter_scene() to point to your new scene.
  4. Call it something different for _TYPE.
  5. Register it as a new type according to the documentation.
  6. (If you use the addon without protocol backing, you also need to update the static initializer from creating a BoolSetting to your new type).

Another option, if you feel like other people would benefit from your work, add your code to the painter scene directly and make an option for it in the setting, just like "use_alpha" in ColorSettings&Painter, make a PR, and I'll just add it as part of the addon.

Feel free to continue asking since it only makes it more clear what is not good enough in the documentation and something I have to document better ;)

To finish off, I'll say that I don't think I'll be changing any of the core code in the coming years except for adding more functionality in the form of more setting types. So there shouldn't be any major breakages. My core Ideology as an addon developer is "Make no breaking changes".