Fixed decimal for Scandinavian and similar Culture#105
Fixed decimal for Scandinavian and similar Culture#105ManlyMarco merged 2 commits intoBepInEx:masterfrom
Conversation
Scandinavian and some other regions use Comma (,) instead of Period (.) for decimal places. This causes some issues when entering float values, so this fixes it by just replacing the comma.
ManlyMarco
left a comment
There was a problem hiding this comment.
Where does the comma come from? Rather than replacing it, the better way would be to fix whatever is producing it. I would guess it's some conversion that is missing StringConverter.InvariantCulture in its parameters.
From what I could gather, it's due to the .ToString() when converting from floats/double to string. I tried adding this check and it has the same result. It's just a lot more code. // Original code
// var strVal = value.ToString().AppendZeroIfFloat(setting.SettingType);
// My change
var strVal = "";
if (setting.SettingType == typeof(float))
{
strVal = ((float)value).ToString(nfi);
}
else if (setting.SettingType == typeof(double))
{
strVal = ((double)value).ToString(nfi);
}
else if (setting.SettingType == typeof(decimal))
{
strVal = ((decimal)value).ToString(nfi);
}
strVal = strVal.AppendZeroIfFloat(setting.SettingType);I can update the PR if this solution is more favorable. |
|
Just do |
object.ToString() does not have any overload functions, meaning the example you are stating, does not exist. The issue with that is in the function private void DrawUnknownField(SettingEntryBase setting, int rightColumnWidth) at the line I have updated the PR, is this an acceptable solution? |
Scandinavian and some other regions use Comma (,) instead of Period (.) for decimal places. This causes some issues when entering float values. (cherry picked from commit 1ca4951)
Scandinavian and some other regions use Comma (,) instead of Period (.) for decimal places.

This causes some issues when entering float values, by the values going haywire and jumping all over the place.
This simple fix just replaces the comma with a period and seems to fix the issue.
NOTE: I have only tried this with Danish Culture, so there might be some issue with other cultures I haven't happened upon.