General > User modifications
Mod that comma delimits some monetary amounts
(1/1)
ChickenLiver:
Not really sure this is the right forum for this, as it requires recompilation, but I'm not submitting it as a patch because of the possibility it breaks some po files...Anyways...
Here's a small mod that adds thousand separators to some prices. Separator character and placement is based on regional settings. Stats screen, purchase screen, the credits display at the top, and only one or two other places currently affected. Makes it easier to parse large values, in my opinion. Replacing "*cvar:value" with "*cvar:formatInt:value" in *.ufo files will use thousand separators on integers. Note that it presumably only works in string fields, and not in functions. The way I modified the ufo syntax is a bit of a hack, but it works.
Not sure if I'll extend this to other screens that display prices. If anyone else cares to play with it, it's basically just replacing "variantOfSprintf(string, _("Possibly some stuff\t %i c"), cost)" with "variantOfSprintf(string, _("Possibly some stuff\t %s c"), FormatInt(cost))" all over the place. Note that this might cause issues with some of the translations in po files.
It also fixes a few minor bugs: No gap between number and c in max debits allowed and no terminating "c" at all on funding screen. Also, there was a bug in string length checking in Com_MacroExpandString().
Requires recompilation to run, unfortunately.
Mattn:
please post patches - not full files
Mattn:
a comma will not work in every language - you should use locales for this. also please watch out the coding guidelines (they are in the coding section of the wiki)
ChickenLiver:
Thanks for the suggestions. I would have used the locale in the first place, but I've always found it rather difficult to find the relevant docs on such things. Managed to find the function, however, and I'm now using it.
I'm using the numeric locale information rather than the currency specific information, because credits are being used instead of the locale's currency. In the US, for example, prefixing the credit amount with 'c' instead of '$' would just look bizarre.
Also fixed up the style, and formatted a couple other large numbers.
Updated diff attached to first post.
Mattn:
https://sourceforge.net/tracker/?func=detail&aid=2955528&group_id=157793&atid=805244
Navigation
[0] Message Index
Go to full version