Cell - Unit Frames

Cell - Unit Frames

148k Downloads

[Feature] Add conditional & inline text support for custom texts

michaelbull opened this issue ยท 3 comments

commented

Describe the feature

On the back of the change kindly merged in #168 (comment), I would like to be able to both statically & conditionally color text in custom texts.

Describe the implementation

In the case of the merged abs/healabs tag, I would like the text to be green when the sum of my absorb + heal absorb is positive, and red when it is negative.

Ideally this would be implemented with static support for recoloring parts of a text (not all of it, but maybe one word at a time), and conditional support based on the positive/negative/nonempty result of a tag.

commented

So finally getting around to taking a look at this, how would you imagine such a tag would look like?
I'm playing around with the idea of allowing for an {} inner tag that could function as such eg.

[{cnd}>abs:healabs:merge:short].

Could also use +/- operators in place of > to maybe more easily express multiple cnds in one tag. eg.

[{color:green}+{color:red}->abs:healabs:merge:short]

When you say one word at a time, do you mean a tag or..?

commented

When you say one word at a time, do you mean a tag or..?

Yes, exactly. What I was trying to get at is avoiding the trap of just recoloring the entire line of text based on a conditional, and instead recolor the individual parts of specific bits of text.

Consider the example where I have: player health (in yellow), player absorb (in green), player heal asborb (in red) - all in a single line of text. If you were to do it with just a single condition that recolors the entire line, I wouldn't be able to recolor the absorb to green and the heal absorb to red, etc. Other unit frame addons only allow you to recolor the entire line of text, rather than parts of it.

[{color:green}+{color:red}->abs:healabs:merge:short]

If I understand it correctly, then I really like this example so far. From what I understand it will be green if a positive number, red if a negative number, and not recolored if zero?

commented

Well yesnt, it would recolor on +- but since its behind a > it would only show when there is an actual value - ie 0 value is hidden in this case