SubRegion formatting options.
nullKomplex opened this issue · 4 comments
Is your feature request related to a problem? Please describe.
It is an incredibly common request in the WA discord to make the ever infinite precision of text replacements such as percentpower
, critpercent
, and tooltip1
shorter, sometimes removing all decimals altogether or rounding to a specific decimal point. Currently this requires the use of custom code, which may cause users to struggle when requesting something not exactly what the bot responses detail.
This would be an extension of the already existing system when using %p
as a text replacement (after a quick investigation this feature appears to be missing in 2.14.4?).
This would cover both strings and numbers.
Describe the solution you'd like
My proposed solution is that upon entering an appropriate text replacement into a text subRegion a section appears with a drop down. The drop down would specify "Automatic", "None", and more.
I'm imagining that the box will reduce in size upon selecting an option that requires additional input, instead of adding a new line. That part is purely flair.
Automatic would attempt to replicate the previous behavior, if possible. If not possible I suppose it could be omitted, as I'm not sure how it could be done.
None would leave it completely intact.
Potential more options:
Numbers
- Decimal Points: Enables a text box, which takes a number input specifying the number of decimals to round to.
- Abbreviate Numbers
- Abbreviate Large Numbers
Strings
- Length: Enables a text box, number input. Recommend adjusting for the weird ascii characters counting as two.
- Abbreviate Front: Takes only the first letter of words from multi-word string.
Dungeoneer's Training Dummy
would turn intoD. T. Dummy
- Abbreviate Back: Backwards of previous:
Dungeoneer's Training Dummy
->Dungeoneer's T. D.
- Abbreviate All:
Dungeoneer's Training Dummy
->D. T. D.
Potential additional options:
Numbers could have additional options to choose the method of rounding (round, floor, ceil).
Strings could have an additional checkbox for whether or not to include ...
when truncating.
This would have to cover more than the standard formatted strings (in fact formatted strings could even be deprecated with this system), to suit users' needs.
This would never touch custom texts, as all formatting should be handled within the custom text code.
These formatting options would be per subRegion. Per aura wouldn't be precise enough and per text replacement would result in unnecessary bloat and complexity when setting up and editing auras. They could be under a new pencil category as well.
Describe alternatives you've considered
I considered suggesting to include it in the text replacements system. For example, %2.name.abbreviateLargeNumbers
or %p.3
or %tooltip2.floor
with the ability to chain, but I felt that method unwieldy (especially in the context of editing a long text), unintuitive, and likely difficult to learn as a new feature for users.
Additional context
This would help alleviate: #1617
(Obviously) Not all suggested features from this suggestion would need to be added, and I implore discussion surrounding them.
Since null mentioned wanting to work on this, I'll put a few suggestions on how to tackle this.
First of all, the current formatting options are problematic. The setting is global and affets all text sub regions equally. That's something that doesn't actually fit too well into the sub regions concept. And thus I'd like to get rid of it.
(Although no matter what, the custom function will remain shared between all text sub regions.)
Instead I think the formatting options should be per text field. (Do note that in addition to the text sub region, there are text replacements for Action/Chat, Condition/Send Chat.)
The way I think this should work, is that in addition to the text field, we have a table of formatting options, e.g. in the sub region data this would look like this:
text = "%percentpower %percentcrit %p %xyz",
textformat = {
"percentpower" = "format.2",
"percentcrit" = "format.1",
"p" = "smart2",
"xyz" = ALN"
}
In the UI this would look like this:
Text: [____________________]
Formatting Options:
percentpower: [Round to 2| V ]
percentcrit: [Round to 1| V ]
p: [Smart 12.3] V ]
xyz: [__Abrreviate Large Numbers __| V ]
Basically, we parse the text and show a combobox per replacement that we have found. In that combobox are the different formatting options. Some work just like the existing format functions, some do use the Blizzard functions, some use format. And some might come later.
This is a superset of the existing functionality, thus on Modernize all that needs to happen, is to convert the existing settings to textformat.
Implementation wise, the central function is: WeakAuras.ReplacePlaceHolders that function needs a additional parameter the textformat table.
That function parses the text string and calls "ValueForSymbol", which
- For the modern replacements just looks up in regionState, thus the formatting must be applied immediately after this. So this functions needs the format table.
or - For the legacy replacements (%p, %t, %s) calls ReplaceValuePlaceHolders.
This uses WeakAuras.dynamic_texts. That function currently fetches the formatting options directly from the region. Instead it should be passed the format table too.
(There's also a shortcut from ReplacePlaceHolders to ReaplaceValuePlaceHolders if the string is just 2 chars long.)
As how to implemt this:
a) Figure out how to parse the text and show the additional format options for sub texts
b) for actions/chat
c) Actually pass on that format table to ReplacePlaceHolders for each of these
d) Make use of the format table
e) Modify ReplaceValuePlaceHolders to use the format table too.
f) Write the Modernize code that converts the existing setting to a format table
g) Get rid of all the old format options
I want to note that @InfusOnWoW’s suggestion may block us from being able to have multiple formatting options for the same replacement pattern, depending on the precise implementation. But if a user wishes to have 2 invocations of %percentPower format differently in the same text area, then I’m of the opinion that they can just write a custom function.
for %unit type text replacements we should offer:
- class color
- ambiguate
- and shorten
In reference to the above mentioned PR, the solution here would be great if it could include a method for selecting a rounding type for timers.
The current default in WA is for timers to round to nearest. It is my contention that floor or ceil are clearer and more informative, with floor being most preferable/intuitive. If this solution could change the default used but provide settings for those that want to change it, that would be ideal I guess.