mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +01:00
fixed some number parsing not using invariant culture
This commit is contained in:
parent
602f19a2a8
commit
35af9eee25
3 changed files with 11 additions and 6 deletions
|
@ -78,8 +78,8 @@ namespace MLEM.Data {
|
||||||
if (match.Groups[8].Success) {
|
if (match.Groups[8].Success) {
|
||||||
for (var i = 0; i < match.Groups[8].Captures.Count; i++) {
|
for (var i = 0; i < match.Groups[8].Captures.Count; i++) {
|
||||||
region.SetData(match.Groups[8].Captures[i].Value, new Vector2(
|
region.SetData(match.Groups[8].Captures[i].Value, new Vector2(
|
||||||
float.Parse(match.Groups[9].Captures[i].Value) - (pivotRelative ? 0 : loc.X),
|
float.Parse(match.Groups[9].Captures[i].Value, CultureInfo.InvariantCulture) - (pivotRelative ? 0 : loc.X),
|
||||||
float.Parse(match.Groups[10].Captures[i].Value) - (pivotRelative ? 0 : loc.Y)));
|
float.Parse(match.Groups[10].Captures[i].Value, CultureInfo.InvariantCulture) - (pivotRelative ? 0 : loc.Y)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
atlas.regions.Add(name, region);
|
atlas.regions.Add(name, region);
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace MLEM.Extended.Tiled {
|
||||||
/// <param name="key">The key by which to get a property</param>
|
/// <param name="key">The key by which to get a property</param>
|
||||||
/// <returns>The float property, or 0 if there is none</returns>
|
/// <returns>The float property, or 0 if there is none</returns>
|
||||||
public static float GetFloat(this TiledMapProperties properties, string key) {
|
public static float GetFloat(this TiledMapProperties properties, string key) {
|
||||||
float.TryParse(properties.Get(key), NumberStyles.Number, NumberFormatInfo.InvariantInfo, out var val);
|
float.TryParse(properties.Get(key), NumberStyles.Number, CultureInfo.InvariantCulture, out var val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ namespace MLEM.Extended.Tiled {
|
||||||
/// <param name="key">The key by which to get a property</param>
|
/// <param name="key">The key by which to get a property</param>
|
||||||
/// <returns>The int property, or 0 if there is none</returns>
|
/// <returns>The int property, or 0 if there is none</returns>
|
||||||
public static int GetInt(this TiledMapProperties properties, string key) {
|
public static int GetInt(this TiledMapProperties properties, string key) {
|
||||||
int.TryParse(properties.Get(key), NumberStyles.Number, NumberFormatInfo.InvariantInfo, out var val);
|
int.TryParse(properties.Get(key), NumberStyles.Number, CultureInfo.InvariantCulture, out var val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
@ -33,7 +34,9 @@ namespace MLEM.Formatting {
|
||||||
// font codes
|
// font codes
|
||||||
this.Codes.Add(new Regex("<b>"), (f, m, r) => new FontCode(m, r, fnt => fnt.Bold));
|
this.Codes.Add(new Regex("<b>"), (f, m, r) => new FontCode(m, r, fnt => fnt.Bold));
|
||||||
this.Codes.Add(new Regex("<i>"), (f, m, r) => new FontCode(m, r, fnt => fnt.Italic));
|
this.Codes.Add(new Regex("<i>"), (f, m, r) => new FontCode(m, r, fnt => fnt.Italic));
|
||||||
this.Codes.Add(new Regex(@"<s(?: #([0-9\w]{6,8}) (([+-.0-9]*)))?>"), (f, m, r) => new ShadowCode(m, r, m.Groups[1].Success ? ColorHelper.FromHexString(m.Groups[1].Value) : Color.Black, new Vector2(float.TryParse(m.Groups[2].Value, out var offset) ? offset : 2)));
|
this.Codes.Add(new Regex(@"<s(?: #([0-9\w]{6,8}) (([+-.0-9]*)))?>"), (f, m, r) => new ShadowCode(m, r,
|
||||||
|
m.Groups[1].Success ? ColorHelper.FromHexString(m.Groups[1].Value) : Color.Black,
|
||||||
|
new Vector2(float.TryParse(m.Groups[2].Value, NumberStyles.Number, CultureInfo.InvariantCulture, out var offset) ? offset : 2)));
|
||||||
this.Codes.Add(new Regex("<u>"), (f, m, r) => new UnderlineCode(m, r, 1 / 16F, 0.85F));
|
this.Codes.Add(new Regex("<u>"), (f, m, r) => new UnderlineCode(m, r, 1 / 16F, 0.85F));
|
||||||
this.Codes.Add(new Regex("</(b|i|s|u|l)>"), (f, m, r) => new FontCode(m, r, null));
|
this.Codes.Add(new Regex("</(b|i|s|u|l)>"), (f, m, r) => new FontCode(m, r, null));
|
||||||
|
|
||||||
|
@ -48,7 +51,9 @@ namespace MLEM.Formatting {
|
||||||
this.Codes.Add(new Regex("</c>"), (f, m, r) => new ColorCode(m, r, null));
|
this.Codes.Add(new Regex("</c>"), (f, m, r) => new ColorCode(m, r, null));
|
||||||
|
|
||||||
// animation codes
|
// animation codes
|
||||||
this.Codes.Add(new Regex(@"<a wobbly(?: ([+-.0-9]*) ([+-.0-9]*))?>"), (f, m, r) => new WobblyCode(m, r, float.TryParse(m.Groups[1].Value, out var mod) ? mod : 5, float.TryParse(m.Groups[2].Value, out var heightMod) ? heightMod : 1 / 8F));
|
this.Codes.Add(new Regex(@"<a wobbly(?: ([+-.0-9]*) ([+-.0-9]*))?>"), (f, m, r) => new WobblyCode(m, r,
|
||||||
|
float.TryParse(m.Groups[1].Value, NumberStyles.Number, CultureInfo.InvariantCulture, out var mod) ? mod : 5,
|
||||||
|
float.TryParse(m.Groups[2].Value, NumberStyles.Number, CultureInfo.InvariantCulture, out var heightMod) ? heightMod : 1 / 8F));
|
||||||
this.Codes.Add(new Regex("</a>"), (f, m, r) => new AnimatedCode(m, r));
|
this.Codes.Add(new Regex("</a>"), (f, m, r) => new AnimatedCode(m, r));
|
||||||
|
|
||||||
// macros
|
// macros
|
||||||
|
|
Loading…
Reference in a new issue