TellMeWhen

TellMeWhen

24M Downloads

[CF 1495] When creating a new IconType I cannot get condition opacity to work

tmw-issue-import opened this issue ยท 4 comments

commented

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

commented

You'll need to register the panel regardless of whether your icon has any custom states or not. 

 
Type:RegisterConfigPanel_XMLTemplate(165, "TellMeWhen_IconStates", {})
 
An unfortunate consequence of this is that the panel will show up as empty if there are no conditions. I've already fixed this in the BfA version of TMW. Your question also led me to notice the meta icons were also missing this config panel, so thanks!
 
In regards to the icon:SetInfo("state", 1) line - the 1 here is corresponding to the default settings for TMW.CONST.STATE.DEFAULT_SHOW (https://github.com/ascott18/TellMeWhen/blob/master/TellMeWhen.lua#L179, https://github.com/ascott18/TellMeWhen/blob/master/TellMeWhen.lua#L261). No other icon type has this because all other icon types set the state of the icon through all code paths of their update function. Since yours doesn't, you need to initialize it in Type:Setup().
 
You will want to use at least one custom state (DEFAULT_SHOW, at least) with your icon, for the following reasons:
  • 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

commented

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

commented

Check out the pull request I made on GitHub.


Posted by CurseForge user Cybeloras

commented

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