zachmu / tiled-xna

C# XNA implementation of Tiled map reader. http://www.mapeditor.org/
Other
18 stars 11 forks source link

Culture-insensitive #2

Open Senevri opened 11 years ago

Senevri commented 11 years ago

float parsing blows up; some cultures use comma as a decimal separator and XMLReader localizes it's output, it seems.

fix: in both Layer.Load and ObjectGroup.Load:

CultureInfo ci = (CultureInfo)CultureInfo.CurrentCulture.Clone();
ci.NumberFormat.CurrencyDecimalSeparator = ".";

....

result.Opacity = float.Parse(reader.GetAttribute("opacity"), NumberStyles.Any, ci);
Senevri commented 11 years ago

Also, cannot handle multiple objects with same name.

zachmu commented 11 years ago

Can you send me a pull request for the float parsing issue?

I think I already patched the multiple name issue on my fork, so I can do that patch.