Text Widgets string formatting request/discussion for variables/tokens:
Number grouping is a very useful feature, I am wondering if it can be expanded to token_format or something similar and then move
the number_grouping definition inside a collection of token_formats.
My challenge here is that I am interested in showing scores on my machine something similar to this:
47,150 = 47.15k
5,130,000 = 5.130m
I am wondering if the idea of variable/token tranformation definitions would be a useful feature.
These would be string formatting transformation on tokens/variables used in text widgets (score, player, etc...)
for display only and chained in order of their index in the collection. I am not familiar with python code, but in .NET
it is basically string.Format().
Here are a few examples:
# just two decimal places
String.Format("{0:0.00}", 123.4567); # "123.46"
String.Format("{0:0.00}", 123.4); # "123.40"
String.Format("{0:0.00}", 123.0); # "123.00
# max. two decimal places
String.Format("{0:0.##}", 123.4567); # "123.46"
String.Format("{0:0.##}", 123.4); # "123.4"
String.Format("{0:0.##}", 123.0); # "123"
# at least two digits before decimal point
String.Format("{0:00.0}", 123.4567); # "123.5"
String.Format("{0:00.0}", 23.4567); # "23.5"
String.Format("{0:00.0}", 3.4567); # "03.5"
String.Format("{0:00.0}", -3.4567); # "-03.5"
# thousands seperator
String.Format("{0:0,0.0}", 12345.67); # "12,345.7"
String.Format("{0:0,0}", 12345.67); # "12,346"
# zero formatting
String.Format("{0:0.0}", 0.0); # "0.0"
String.Format("{0:0.#}", 0.0); # "0"
String.Format("{0:#.0}", 0.0); # ".0"
String.Format("{0:#.#}", 0.0); # ""
So a text widget could be configured something like this:
slides:
score_slide:
- type: text
text: score (score)
token_format:
- number_as_m
- number_grouping
We could have a few built into the system, and we add, override at the config and mode config level.
Example:
token_format:
number_grouping:
number_as_money
formatting_definition:
"$(value)"
Just food for thought. If this is currently doable in configuration. I am sorry for adding to the noise.
Thank you.