shadowmage45 / TexturesUnlimited

KSP Shader, Texture, and Modeling Utilities
GNU General Public License v3.0
29 stars 17 forks source link

Recolor GUI Bug - Default Section #28

Closed Electrocutor closed 6 years ago

Electrocutor commented 6 years ago

The recolor gui defaults to changing the first sectionName of the switcher, even if the TextureSet currently selected has recolorable = false.

Suggested behavior: If all KSPTextureSwitch's on a part are set to a textureset with recolorable = false, then the right-click menu hides the GUI button.

If any section currently is set to a textureset with recolorable = false, then the recolor GUI will not default to that section, but instead the first available section set to a textureset with recolorable = true.

shadowmage45 commented 6 years ago

If all KSPTextureSwitch's on a part are set to a textureset with recolorable = false, then the right-click menu hides the GUI button.

If none of the texture sets are recolorable -- why is the recoloring-GUI module being added to the part?

More precisely, the recoloring GUI-module (the bit that adds the button to the part-right-click-menu) has no knowledge of what a texture-set is. It has no method to tell if the part even has texture sets on it. I cannot simply link it in with the texture-switch module, as the recoloring GUI is also used in SSTU, through other partmodules.

I'll try to think up some method to check for texture-sets / recolorability -- but not sure it will be doable (without massive changes in all texture/recoloring code in SSTU as well).


As to the other problem:

If any section currently is set to a textureset with recolorable = false, then the recolor GUI will not default to that section, but instead the first available section set to a textureset with recolorable = true.

That sounds like a legitimate bug. Should have it fixed up for the next release.

Electrocutor commented 6 years ago

"If none of the texture sets are recolorable -- why is the recoloring-GUI module being added to the part?" It's to do with which texture sets are currently selected: for example, you may have 3 sections and among the choices for texturesets, two are recolorable and two are not. If any of the 3 sections are set to a recolorable one, the button can be used to recolor it: if all are set to one of the two texture sets that are not recolorable, then setting anything in the gui changes nothing because all sections are not using the Mask shader.

"It has no method to tell if the part even has texture sets on it." Then how does it list all the different TextureSwitch section names inside and allow you to set different colors for each section?

shadowmage45 commented 6 years ago

Then how does it list all the different TextureSwitch section names inside and allow you to set different colors for each section?

Two different bits of code. The PartModule simply adds a button that opens the GUI. Literally, that is all it does, is add a KSPEvent to create the button. (okay, so it has a tiny bit more code to refresh the GUI on texture-set changes, called through a blind interface; it still has no reference to texture-sets, only an update method that is called from the texture-switch module)

All the rest of the functional code to gather the section names/etc, is handled from within the GUI code itself.


It's to do with which texture sets are currently selected: for example, you may have 3 sections and among the choices for texturesets, two are recolorable and two are not.

Okay, that makes a bit more sense in context. You are talking about 'current' configuration though, and not just 'if any texture sets at all on the part are recolorable'.

The 'current' configuration might able to be polled through existing methods -- recolorable modules already implement an interface that allows for checking the 'current' texture set, which does track if it can be recolored. The module also already implements callbacks/hooks for 'on editor ship modified' and 'on texture set changed', so should be able to hook into those existing methods to force-update the current gui-button status whenever texture sets are changed.

shadowmage45 commented 6 years ago

Can confirm that the 'Open Recolor GUI' button will now only show up on parts where at least one of the -current- texture set(s) is re-colorable. Should also disable the GUI if it happens to get added to a part with no recolorable/texture-set modules.

This is being driven by an event/callback that is fired whenever the texture sets are changed through the TextureSwitch PartModule.

Will continue with testing and verification of this change, but it should be available with the next update.