1
Vote

Globalization

description

i wanted to try your sim to find out, to get a grasp how good mastery is. But it generated data which is just .. strange, wrong, whatever .. so i looked up the source of it.
 
It's the Globalization, or the "." and "," thingy in different countries. My computer is defaulted to German (Austria) (de-AT), which discribes "1,234.56" as "1.234,56"..
 
so all your stored data within BloodSim-Abilities.xml and default data for the settings, are parsed (via TryParse) with my settings and interpret 2.5 as 2500, and 1,500 as 1.5..
 
 
i'm kinda amateur programer but i tried to fix it on your code, feel free to use it
 
 
used codelines are
 
add 14: using Globalization;
 
add 2575: CultureInfo ci = new CultureInfo("en-US");
 
i modified all the int and double tryparses within the LoadAbilityDataFromXML() to parse the contents with the right format.
mod 2576: int.TryParse(abildata.Attributes["RPCost"].Value, NumberStyles.Integer, ci.NumberFormat, out abil.RPCost);
and following int.tryparses
 
mod 2590: double.TryParse(abildata.Attributes["WeaponPercent"].Value, NumberStyles.Float, ci.NumberFormat, out abil.WeaponPercent);
and following double.tryparses
 
 
in addition, you should set the default values of the wTextBoxes to let the system format it for you, eg: txtNonArmorDR.wText = "0.245" should be something like (0.245).ToString();
 
 
i hope my little fix helps in improving this neat program :)
 
 
mfg Parok

comments