[CF 1495] When creating a new IconType I cannot get condition opacity to work
tmw-issue-import opened this issue ยท 4 comments
I have implemented a new Bar Type, however, I cannot get the condition sliders to affect my UI- my bar is always 100% visible, no matter what the state of my condition is.
If I remove the registration of the XML Templates I can get the condition to hide my icon but then I don't get the opacity settings.
I suspect it might have to do with this line (note that this is part of Type:Setup so it only runs once) which is not present in any other type I looked at but if I remove it my icon is always hidden.
I noticed all icons, when a condition is present, have a condition failed slider appear on them. Is there a simple way for me to inherit this functionality?
I know this is a very deep dive but I'm not sure where to look, so any help will be greatly appreciated.
Posted by CurseForge user ariehg | Imported from CurseForge issue #1495 | Raw
You'll need to register the panel regardless of whether your icon has any custom states or not.
- You'll run into some unfortunate consequences if someone configures the opacity/color for that state with some other icon type, and then switches to your icon type - your icon will use that setting but be unable to configure it.
- Users will be unable to configure a baseline opacity/icon color for the icon type without it.
- The config weirdness I mentioned with the panel being empty until BfA.
I see you already have a "show" member on your icon.script_values object. You could set state to DEFAULT_SHOW if this is true and set it to 0 otherwise (0 is a magic number that isn't a real state, but effectively means "hide").
I'm going to submit a PR in a little bit with some other tweaks you could make to the icon type. But so far, its looking good!
Edited May 11, 2018
Posted by CurseForge user Cybeloras
Thanks for the response!
To make sure I understand correctly - what I want to add is something like:
Type:RegisterConfigPanel_XMLTemplate(165, "TellMeWhen_IconStates", {
[ DEFAULT_SHOW ] : "Show me",
[ DEFAULT_HIDE ] : "Hide me"
})
And this will both make my icons appear by default and allow the condition opacity slider to appear?
Edit - tried it - sliders appear but icons are always hidden and playing with sliders has not effect....
Edited May 12, 2018
Posted by CurseForge user ariehg
Oh I didnt notice :) (though you did write so :) )
Thanks a lot for giving it such a deep look! This makes a lot of sense to me :)
I know there are some "over optimizations" there, but I feel like it's a safe coding thing, especially since I'm so unfamiliar with a lot of how to code works.
As mentioned before - it's quite amazing to me how extensible the framework behind TMW is. It's my first time going into LUA and it's a great learning source :)
Posted by CurseForge user ariehg