Fix CA1305
This commit is contained in:
committed by
Matthias Mailänder
parent
486a07602b
commit
d83e579dfe
@@ -667,6 +667,9 @@ dotnet_diagnostic.CA1200.severity = warning
|
||||
# Specify 'CultureInfo'.
|
||||
dotnet_diagnostic.CA1304.severity = warning
|
||||
|
||||
# Specify 'IFormatProvider'.
|
||||
dotnet_diagnostic.CA1305.severity = warning
|
||||
|
||||
### Portability and Interoperability Rules
|
||||
### https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/interoperability-warnings
|
||||
|
||||
|
||||
@@ -250,13 +250,13 @@ namespace OpenRA
|
||||
public static string SHA1Hash(Stream data)
|
||||
{
|
||||
using (var csp = SHA1.Create())
|
||||
return new string(csp.ComputeHash(data).SelectMany(a => a.ToString("x2")).ToArray());
|
||||
return new string(csp.ComputeHash(data).SelectMany(a => a.ToStringInvariant("x2")).ToArray());
|
||||
}
|
||||
|
||||
public static string SHA1Hash(byte[] data)
|
||||
{
|
||||
using (var csp = SHA1.Create())
|
||||
return new string(csp.ComputeHash(data).SelectMany(a => a.ToString("x2")).ToArray());
|
||||
return new string(csp.ComputeHash(data).SelectMany(a => a.ToStringInvariant("x2")).ToArray());
|
||||
}
|
||||
|
||||
public static string SHA1Hash(string data)
|
||||
|
||||
@@ -22,6 +22,16 @@ namespace OpenRA
|
||||
{
|
||||
public static class Exts
|
||||
{
|
||||
public static string FormatInvariant(this string format, params object[] args)
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, format, args);
|
||||
}
|
||||
|
||||
public static string FormatCurrent(this string format, params object[] args)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, format, args);
|
||||
}
|
||||
|
||||
public static T WithDefault<T>(T def, Func<T> f)
|
||||
{
|
||||
try { return f(); }
|
||||
@@ -488,17 +498,22 @@ namespace OpenRA
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int ParseIntegerInvariant(string s)
|
||||
{
|
||||
return int.Parse(s, NumberStyles.Integer, NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
|
||||
public static byte ParseByte(string s)
|
||||
public static byte ParseByteInvariant(string s)
|
||||
{
|
||||
return byte.Parse(s, NumberStyles.Integer, NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
|
||||
public static bool TryParseIntegerInvariant(string s, out int i)
|
||||
public static short ParseInt16Invariant(string s)
|
||||
{
|
||||
return short.Parse(s, NumberStyles.Integer, NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
|
||||
public static int ParseInt32Invariant(string s)
|
||||
{
|
||||
return int.Parse(s, NumberStyles.Integer, NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
|
||||
public static bool TryParseInt32Invariant(string s, out int i)
|
||||
{
|
||||
return int.TryParse(s, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out i);
|
||||
}
|
||||
@@ -508,6 +523,26 @@ namespace OpenRA
|
||||
return long.TryParse(s, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out i);
|
||||
}
|
||||
|
||||
public static string ToStringInvariant(this byte i)
|
||||
{
|
||||
return i.ToString(NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
|
||||
public static string ToStringInvariant(this byte i, string format)
|
||||
{
|
||||
return i.ToString(format, NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
|
||||
public static string ToStringInvariant(this int i)
|
||||
{
|
||||
return i.ToString(NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
|
||||
public static string ToStringInvariant(this int i, string format)
|
||||
{
|
||||
return i.ToString(format, NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
|
||||
public static bool IsTraitEnabled<T>(this T trait)
|
||||
{
|
||||
return trait is not IDisabledTrait disabledTrait || !disabledTrait.IsTraitDisabled;
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace OpenRA
|
||||
|
||||
static object ParseInt(string fieldName, Type fieldType, string value, MemberInfo field)
|
||||
{
|
||||
if (Exts.TryParseIntegerInvariant(value, out var res))
|
||||
if (Exts.TryParseInt32Invariant(value, out var res))
|
||||
{
|
||||
if (res >= 0 && res < BoxedInts.Length)
|
||||
return BoxedInts[res];
|
||||
@@ -249,7 +249,7 @@ namespace OpenRA
|
||||
|
||||
static object ParseWAngle(string fieldName, Type fieldType, string value, MemberInfo field)
|
||||
{
|
||||
if (Exts.TryParseIntegerInvariant(value, out var res))
|
||||
if (Exts.TryParseInt32Invariant(value, out var res))
|
||||
return new WAngle(res);
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
}
|
||||
@@ -261,9 +261,9 @@ namespace OpenRA
|
||||
var parts = value.Split(SplitComma);
|
||||
if (parts.Length == 3)
|
||||
{
|
||||
if (Exts.TryParseIntegerInvariant(parts[0], out var rr)
|
||||
&& Exts.TryParseIntegerInvariant(parts[1], out var rp)
|
||||
&& Exts.TryParseIntegerInvariant(parts[2], out var ry))
|
||||
if (Exts.TryParseInt32Invariant(parts[0], out var rr)
|
||||
&& Exts.TryParseInt32Invariant(parts[1], out var rp)
|
||||
&& Exts.TryParseInt32Invariant(parts[2], out var ry))
|
||||
return new WRot(new WAngle(rr), new WAngle(rp), new WAngle(ry));
|
||||
}
|
||||
}
|
||||
@@ -278,10 +278,10 @@ namespace OpenRA
|
||||
var parts = value.Split(SplitComma, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length == 3)
|
||||
return new CPos(
|
||||
Exts.ParseIntegerInvariant(parts[0]),
|
||||
Exts.ParseIntegerInvariant(parts[1]),
|
||||
Exts.ParseByte(parts[2]));
|
||||
return new CPos(Exts.ParseIntegerInvariant(parts[0]), Exts.ParseIntegerInvariant(parts[1]));
|
||||
Exts.ParseInt32Invariant(parts[0]),
|
||||
Exts.ParseInt32Invariant(parts[1]),
|
||||
Exts.ParseByteInvariant(parts[2]));
|
||||
return new CPos(Exts.ParseInt32Invariant(parts[0]), Exts.ParseInt32Invariant(parts[1]));
|
||||
}
|
||||
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
@@ -292,7 +292,7 @@ namespace OpenRA
|
||||
if (value != null)
|
||||
{
|
||||
var parts = value.Split(SplitComma, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new CVec(Exts.ParseIntegerInvariant(parts[0]), Exts.ParseIntegerInvariant(parts[1]));
|
||||
return new CVec(Exts.ParseInt32Invariant(parts[0]), Exts.ParseInt32Invariant(parts[1]));
|
||||
}
|
||||
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
@@ -385,7 +385,7 @@ namespace OpenRA
|
||||
|
||||
var ints = new int2[parts.Length / 2];
|
||||
for (var i = 0; i < ints.Length; i++)
|
||||
ints[i] = new int2(Exts.ParseIntegerInvariant(parts[2 * i]), Exts.ParseIntegerInvariant(parts[2 * i + 1]));
|
||||
ints[i] = new int2(Exts.ParseInt32Invariant(parts[2 * i]), Exts.ParseInt32Invariant(parts[2 * i + 1]));
|
||||
|
||||
return ints;
|
||||
}
|
||||
@@ -398,7 +398,7 @@ namespace OpenRA
|
||||
if (value != null)
|
||||
{
|
||||
var parts = value.Split(SplitComma, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new Size(Exts.ParseIntegerInvariant(parts[0]), Exts.ParseIntegerInvariant(parts[1]));
|
||||
return new Size(Exts.ParseInt32Invariant(parts[0]), Exts.ParseInt32Invariant(parts[1]));
|
||||
}
|
||||
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
@@ -412,7 +412,7 @@ namespace OpenRA
|
||||
if (parts.Length != 2)
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
|
||||
return new int2(Exts.ParseIntegerInvariant(parts[0]), Exts.ParseIntegerInvariant(parts[1]));
|
||||
return new int2(Exts.ParseInt32Invariant(parts[0]), Exts.ParseInt32Invariant(parts[1]));
|
||||
}
|
||||
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
@@ -460,10 +460,10 @@ namespace OpenRA
|
||||
{
|
||||
var parts = value.Split(SplitComma, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new Rectangle(
|
||||
Exts.ParseIntegerInvariant(parts[0]),
|
||||
Exts.ParseIntegerInvariant(parts[1]),
|
||||
Exts.ParseIntegerInvariant(parts[2]),
|
||||
Exts.ParseIntegerInvariant(parts[3]));
|
||||
Exts.ParseInt32Invariant(parts[0]),
|
||||
Exts.ParseInt32Invariant(parts[1]),
|
||||
Exts.ParseInt32Invariant(parts[2]),
|
||||
Exts.ParseInt32Invariant(parts[3]));
|
||||
}
|
||||
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
var d = info.ToDictionary();
|
||||
|
||||
Start = Exts.ParseIntegerInvariant(d["Start"].Value);
|
||||
Start = Exts.ParseInt32Invariant(d["Start"].Value);
|
||||
Palette = palette;
|
||||
Name = name;
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace OpenRA.Graphics
|
||||
(d.TryGetValue("End", out yaml) && yaml.Value == "*"))
|
||||
Length = Frames.Length;
|
||||
else if (d.TryGetValue("Length", out yaml))
|
||||
Length = Exts.ParseIntegerInvariant(yaml.Value);
|
||||
Length = Exts.ParseInt32Invariant(yaml.Value);
|
||||
else if (d.TryGetValue("End", out yaml))
|
||||
Length = Exts.ParseIntegerInvariant(yaml.Value) - Start;
|
||||
Length = Exts.ParseInt32Invariant(yaml.Value) - Start;
|
||||
else
|
||||
Length = 1;
|
||||
|
||||
@@ -54,13 +54,13 @@ namespace OpenRA.Graphics
|
||||
|
||||
if (d.TryGetValue("X", out yaml))
|
||||
{
|
||||
Exts.TryParseIntegerInvariant(yaml.Value, out var x);
|
||||
Exts.TryParseInt32Invariant(yaml.Value, out var x);
|
||||
Hotspot = Hotspot.WithX(x);
|
||||
}
|
||||
|
||||
if (d.TryGetValue("Y", out yaml))
|
||||
{
|
||||
Exts.TryParseIntegerInvariant(yaml.Value, out var y);
|
||||
Exts.TryParseInt32Invariant(yaml.Value, out var y);
|
||||
Hotspot = Hotspot.WithY(y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace OpenRA.Network
|
||||
|
||||
var traitData = MiniYaml.FromString(rs.ReadString(Encoding.UTF8, Connection.MaxOrderLength));
|
||||
foreach (var td in traitData)
|
||||
TraitData.Add(int.Parse(td.Key), td.Value);
|
||||
TraitData.Add(Exts.ParseInt32Invariant(td.Key), td.Value);
|
||||
|
||||
rs.Seek(0, SeekOrigin.Begin);
|
||||
ordersStream.Write(rs.ReadBytes(metadataOffset), 0, metadataOffset);
|
||||
@@ -238,7 +238,7 @@ namespace OpenRA.Network
|
||||
// Send the trait data first to guarantee that it is available when needed
|
||||
foreach (var kv in TraitData)
|
||||
{
|
||||
var data = new List<MiniYamlNode>() { new MiniYamlNode(kv.Key.ToString(), kv.Value) }.WriteToString();
|
||||
var data = new List<MiniYamlNode>() { new MiniYamlNode(kv.Key.ToStringInvariant(), kv.Value) }.WriteToString();
|
||||
packetFn(0, 0, Order.FromTargetString("SaveTraitData", data, true).Serialize());
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ namespace OpenRA.Network
|
||||
file.Write(BitConverter.GetBytes(TraitDataMarker), 0, 4);
|
||||
|
||||
var traitDataNodes = TraitData
|
||||
.Select(kv => new MiniYamlNode(kv.Key.ToString(), kv.Value))
|
||||
.Select(kv => new MiniYamlNode(kv.Key.ToStringInvariant(), kv.Value))
|
||||
.ToList();
|
||||
file.WriteString(Encoding.UTF8, traitDataNodes.WriteToString());
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace OpenRA.Network
|
||||
Name = server.Settings.Name;
|
||||
|
||||
// IP address will be replaced with a real value by the master server / receiving LAN client
|
||||
Address = "0.0.0.0:" + server.Settings.ListenPort.ToString();
|
||||
Address = "0.0.0.0:" + server.Settings.ListenPort.ToStringInvariant();
|
||||
State = (int)server.State;
|
||||
MaxPlayers = server.LobbyInfo.Slots.Count(s => !s.Value.Closed) - server.LobbyInfo.Clients.Count(c1 => c1.Bot != null);
|
||||
Map = server.Map.Uid;
|
||||
@@ -234,7 +234,7 @@ namespace OpenRA.Network
|
||||
|
||||
public string ToPOSTData(bool lanGame)
|
||||
{
|
||||
var root = new List<MiniYamlNode>() { new MiniYamlNode("Protocol", ProtocolVersion.ToString()) };
|
||||
var root = new List<MiniYamlNode>() { new MiniYamlNode("Protocol", ProtocolVersion.ToStringInvariant()) };
|
||||
foreach (var field in SerializeFields)
|
||||
root.Add(FieldSaver.SaveField(this, field));
|
||||
|
||||
@@ -243,9 +243,9 @@ namespace OpenRA.Network
|
||||
// Add fields that are normally generated by the master server
|
||||
// LAN games overload the Id with a GUID string (rather than an ID) to allow deduplication
|
||||
root.Add(new MiniYamlNode("Id", Platform.SessionGUID.ToString()));
|
||||
root.Add(new MiniYamlNode("Players", Clients.Count(c => !c.IsBot && !c.IsSpectator).ToString()));
|
||||
root.Add(new MiniYamlNode("Spectators", Clients.Count(c => c.IsSpectator).ToString()));
|
||||
root.Add(new MiniYamlNode("Bots", Clients.Count(c => c.IsBot).ToString()));
|
||||
root.Add(new MiniYamlNode("Players", Clients.Count(c => !c.IsBot && !c.IsSpectator).ToStringInvariant()));
|
||||
root.Add(new MiniYamlNode("Spectators", Clients.Count(c => c.IsSpectator).ToStringInvariant()));
|
||||
root.Add(new MiniYamlNode("Bots", Clients.Count(c => c.IsBot).ToStringInvariant()));
|
||||
|
||||
// Included for backwards compatibility with older clients that don't support separated Mod/Version.
|
||||
root.Add(new MiniYamlNode("Mods", Mod + "@" + Version));
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA.Network
|
||||
{
|
||||
var root = new List<MiniYamlNode>
|
||||
{
|
||||
new MiniYamlNode("Protocol", ProtocolVersion.ToString()),
|
||||
new MiniYamlNode("Protocol", ProtocolVersion.ToStringInvariant()),
|
||||
new MiniYamlNode("Key", key)
|
||||
};
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace OpenRA.Network
|
||||
case "SaveTraitData":
|
||||
{
|
||||
var data = MiniYaml.FromString(order.TargetString)[0];
|
||||
var traitIndex = int.Parse(data.Key);
|
||||
var traitIndex = Exts.ParseInt32Invariant(data.Key);
|
||||
|
||||
world?.AddGameSaveTraitData(traitIndex, data.Value);
|
||||
|
||||
@@ -343,7 +343,7 @@ namespace OpenRA.Network
|
||||
var strings = node.Key.Split('@');
|
||||
if (strings[0] == "ConnectionQuality")
|
||||
{
|
||||
var client = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.Index == int.Parse(strings[1]));
|
||||
var client = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.Index == Exts.ParseInt32Invariant(strings[1]));
|
||||
if (client != null)
|
||||
client.ConnectionQuality = FieldLoader.GetValue<Session.ConnectionQuality>("ConnectionQuality", node.Value.Value);
|
||||
}
|
||||
|
||||
@@ -224,9 +224,9 @@ namespace OpenRA.Primitives
|
||||
public override string ToString()
|
||||
{
|
||||
if (A == 255)
|
||||
return R.ToString("X2") + G.ToString("X2") + B.ToString("X2");
|
||||
return R.ToStringInvariant("X2") + G.ToStringInvariant("X2") + B.ToStringInvariant("X2");
|
||||
|
||||
return R.ToString("X2") + G.ToString("X2") + B.ToString("X2") + A.ToString("X2");
|
||||
return R.ToStringInvariant("X2") + G.ToStringInvariant("X2") + B.ToStringInvariant("X2") + A.ToStringInvariant("X2");
|
||||
}
|
||||
|
||||
public static Color Transparent => FromArgb(0x00FFFFFF);
|
||||
|
||||
@@ -968,7 +968,7 @@ namespace OpenRA.Server
|
||||
|
||||
void WriteLineWithTimeStamp(string line)
|
||||
{
|
||||
Console.WriteLine($"[{DateTime.Now.ToString(Settings.TimestampFormat)}] {line}");
|
||||
Console.WriteLine($"[{DateTime.Now.ToString(Settings.TimestampFormat, CultureInfo.CurrentCulture)}] {line}");
|
||||
}
|
||||
|
||||
void InterpretServerOrder(Connection conn, Order o)
|
||||
@@ -1019,7 +1019,7 @@ namespace OpenRA.Server
|
||||
if (GameSave != null)
|
||||
{
|
||||
var data = MiniYaml.FromString(o.TargetString)[0];
|
||||
GameSave.AddTraitData(int.Parse(data.Key), data.Value);
|
||||
GameSave.AddTraitData(OpenRA.Exts.ParseInt32Invariant(data.Key), data.Value);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1375,8 +1375,8 @@ namespace OpenRA.Server
|
||||
{
|
||||
startGameData = new List<MiniYamlNode>()
|
||||
{
|
||||
new MiniYamlNode("SaveLastOrdersFrame", GameSave.LastOrdersFrame.ToString()),
|
||||
new MiniYamlNode("SaveSyncFrame", GameSave.LastSyncFrame.ToString())
|
||||
new MiniYamlNode("SaveLastOrdersFrame", GameSave.LastOrdersFrame.ToStringInvariant()),
|
||||
new MiniYamlNode("SaveSyncFrame", GameSave.LastSyncFrame.ToStringInvariant())
|
||||
}.WriteToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
@@ -110,7 +111,7 @@ namespace OpenRA
|
||||
writer.WriteLine(item.Text);
|
||||
else
|
||||
{
|
||||
var timestamp = DateTime.Now.ToString(Game.Settings.Server.TimestampFormat);
|
||||
var timestamp = DateTime.Now.ToString(Game.Settings.Server.TimestampFormat, CultureInfo.CurrentCulture);
|
||||
writer.WriteLine("[{0}] {1}", timestamp, item.Text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,10 +68,10 @@ namespace OpenRA.Support
|
||||
Log.Write("perf", GetHeader(Indentation, name));
|
||||
foreach (var child in children)
|
||||
child.Write();
|
||||
Log.Write("perf", string.Format(FormatString, ElapsedMs, GetFooter(Indentation)));
|
||||
Log.Write("perf", FormatString.FormatInvariant(ElapsedMs, GetFooter(Indentation)));
|
||||
}
|
||||
else if (ticks >= thresholdTicks)
|
||||
Log.Write("perf", string.Format(FormatString, ElapsedMs, Indentation + name));
|
||||
Log.Write("perf", FormatString.FormatInvariant(ElapsedMs, Indentation + name));
|
||||
}
|
||||
|
||||
public static long MillisToTicks(float millis)
|
||||
@@ -85,7 +85,7 @@ namespace OpenRA.Support
|
||||
{
|
||||
var type = item.GetType();
|
||||
var label = type == typeof(string) || type.IsGenericType ? item.ToString() : type.Name;
|
||||
Log.Write("perf", string.Format(FormatStringLongTick,
|
||||
Log.Write("perf", FormatStringLongTick.FormatInvariant(
|
||||
1000f * (endStopwatchTicks - startStopwatchTicks) / Stopwatch.Frequency,
|
||||
Game.LocalTick,
|
||||
name,
|
||||
|
||||
@@ -354,7 +354,7 @@ namespace OpenRA.Support
|
||||
if (cc != CharClass.Digit)
|
||||
{
|
||||
if (cc != CharClass.Whitespace && cc != CharClass.Operator && cc != CharClass.Mixed)
|
||||
throw new InvalidDataException($"Number {int.Parse(expression[start..i])} and variable merged at index {start}");
|
||||
throw new InvalidDataException($"Number {Exts.ParseInt32Invariant(expression[start..i])} and variable merged at index {start}");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -571,7 +571,7 @@ namespace OpenRA.Support
|
||||
public NumberToken(int index, string symbol)
|
||||
: base(TokenType.Number, index)
|
||||
{
|
||||
Value = int.Parse(symbol);
|
||||
Value = Exts.ParseInt32Invariant(symbol);
|
||||
this.symbol = symbol;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace OpenRA
|
||||
|
||||
public static void Debug(string format, params object[] args)
|
||||
{
|
||||
AddSystemLine("Debug", string.Format(format, args));
|
||||
AddSystemLine("Debug", format.FormatCurrent(args));
|
||||
}
|
||||
|
||||
static void AddTextNotification(TextNotificationPool pool, int clientId, string prefix, string text, Color? prefixColor = null, Color? textColor = null)
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace OpenRA
|
||||
public float RendererRadians() { return (float)(Angle * Math.PI / 512f); }
|
||||
public float RendererDegrees() { return Angle * 0.3515625f; }
|
||||
|
||||
public override string ToString() { return Angle.ToString(); }
|
||||
public override string ToString() { return Angle.ToStringInvariant(); }
|
||||
|
||||
static readonly int[] CosineTable =
|
||||
{
|
||||
|
||||
@@ -71,12 +71,12 @@ namespace OpenRA
|
||||
switch (components.Length)
|
||||
{
|
||||
case 2:
|
||||
if (!Exts.TryParseIntegerInvariant(components[0], out cell) ||
|
||||
!Exts.TryParseIntegerInvariant(components[1], out subcell))
|
||||
if (!Exts.TryParseInt32Invariant(components[0], out cell) ||
|
||||
!Exts.TryParseInt32Invariant(components[1], out subcell))
|
||||
return false;
|
||||
break;
|
||||
case 1:
|
||||
if (!Exts.TryParseIntegerInvariant(components[0], out subcell))
|
||||
if (!Exts.TryParseInt32Invariant(components[0], out subcell))
|
||||
return false;
|
||||
break;
|
||||
default: return false;
|
||||
@@ -107,7 +107,7 @@ namespace OpenRA
|
||||
public override string ToString()
|
||||
{
|
||||
var absLength = Math.Abs(Length);
|
||||
var absValue = (absLength / 1024).ToString() + "c" + (absLength % 1024).ToString();
|
||||
var absValue = (absLength / 1024).ToStringInvariant() + "c" + (absLength % 1024).ToStringInvariant();
|
||||
return Length < 0 ? "-" + absValue : absValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -573,7 +573,7 @@ namespace OpenRA
|
||||
var data = tp.Trait.IssueTraitData(tp.Actor);
|
||||
if (data != null)
|
||||
{
|
||||
var yaml = new List<MiniYamlNode>() { new MiniYamlNode(i.ToString(), new MiniYaml("", data)) };
|
||||
var yaml = new List<MiniYamlNode>() { new MiniYamlNode(i.ToStringInvariant(), new MiniYaml("", data)) };
|
||||
IssueOrder(Order.FromTargetString("GameSaveTraitData", yaml.WriteToString(), true));
|
||||
}
|
||||
|
||||
|
||||
@@ -121,10 +121,10 @@ namespace OpenRA.Mods.Cnc.AudioLoaders
|
||||
if (vfh.DatablockOffset != 26)
|
||||
throw new InvalidDataException("Voc header offset is wrong");
|
||||
if (vfh.Version < 0x0100 || vfh.Version >= 0x0200)
|
||||
throw new InvalidDataException("Voc header version " + vfh.Version.ToString("X") + " not supported");
|
||||
throw new InvalidDataException("Voc header version " + vfh.Version.ToStringInvariant("X") + " not supported");
|
||||
if (vfh.ID != ~vfh.Version + 0x1234)
|
||||
throw new InvalidDataException("Voc header id is bogus - expected: " +
|
||||
(~vfh.Version + 0x1234).ToString("X") + " but value is : " + vfh.ID.ToString("X"));
|
||||
(~vfh.Version + 0x1234).ToStringInvariant("X") + " but value is : " + vfh.ID.ToStringInvariant("X"));
|
||||
}
|
||||
|
||||
static int GetSampleRateFromVocRate(int vocSampleRate)
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
|
||||
|
||||
static int ParseGroup(Match match, string group)
|
||||
{
|
||||
return int.Parse(match.Groups[group].Value);
|
||||
return Exts.ParseInt32Invariant(match.Groups[group].Value);
|
||||
}
|
||||
|
||||
public IReadOnlyList<ISpriteFrame> Frames { get; }
|
||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
|
||||
if (prefix != framePrefix)
|
||||
throw new InvalidDataException($"Frame prefix mismatch: `{prefix}` != `{framePrefix}`");
|
||||
|
||||
frameCount = Math.Max(frameCount, int.Parse(match.Groups["frame"].Value) + 1);
|
||||
frameCount = Math.Max(frameCount, Exts.ParseInt32Invariant(match.Groups["frame"].Value) + 1);
|
||||
}
|
||||
|
||||
var frames = new ISpriteFrame[frameCount];
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
{
|
||||
var iniFormat = basicSection.GetValue("NewINIFormat", "0");
|
||||
|
||||
Exts.TryParseIntegerInvariant(iniFormat, out var iniFormatVersion);
|
||||
Exts.TryParseInt32Invariant(iniFormat, out var iniFormatVersion);
|
||||
|
||||
return iniFormatVersion;
|
||||
}
|
||||
@@ -193,10 +193,10 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
|
||||
static void SetBounds(Map map, IniSection mapSection)
|
||||
{
|
||||
var offsetX = Exts.ParseIntegerInvariant(mapSection.GetValue("X", "0"));
|
||||
var offsetY = Exts.ParseIntegerInvariant(mapSection.GetValue("Y", "0"));
|
||||
var width = Exts.ParseIntegerInvariant(mapSection.GetValue("Width", "0"));
|
||||
var height = Exts.ParseIntegerInvariant(mapSection.GetValue("Height", "0"));
|
||||
var offsetX = Exts.ParseInt32Invariant(mapSection.GetValue("X", "0"));
|
||||
var offsetY = Exts.ParseInt32Invariant(mapSection.GetValue("Y", "0"));
|
||||
var width = Exts.ParseInt32Invariant(mapSection.GetValue("Width", "0"));
|
||||
var height = Exts.ParseInt32Invariant(mapSection.GetValue("Height", "0"));
|
||||
|
||||
var tl = new PPos(offsetX, offsetY);
|
||||
var br = new PPos(offsetX + width - 1, offsetY + height - 1);
|
||||
@@ -279,9 +279,9 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
void LoadWaypoints(IniSection waypointSection)
|
||||
{
|
||||
var wps = waypointSection
|
||||
.Where(kv => Exts.ParseIntegerInvariant(kv.Value) > 0)
|
||||
.Select(kv => (WaypointNumber: Exts.ParseIntegerInvariant(kv.Key),
|
||||
Location: LocationFromMapOffset(Exts.ParseIntegerInvariant(kv.Value), MapSize)));
|
||||
.Where(kv => Exts.ParseInt32Invariant(kv.Value) > 0)
|
||||
.Select(kv => (WaypointNumber: Exts.ParseInt32Invariant(kv.Key),
|
||||
Location: LocationFromMapOffset(Exts.ParseInt32Invariant(kv.Value), MapSize)));
|
||||
|
||||
// Add waypoint actors skipping duplicate entries
|
||||
var nodes = new List<MiniYamlNode>();
|
||||
@@ -327,7 +327,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
{
|
||||
// loc=type,loc,depth
|
||||
var parts = s.Value.Split(',');
|
||||
var loc = Exts.ParseIntegerInvariant(parts[1]);
|
||||
var loc = Exts.ParseInt32Invariant(parts[1]);
|
||||
var type = parts[0].ToLowerInvariant();
|
||||
var key = $"{loc % MapSize},{loc / MapSize}";
|
||||
var value = $"{type},{parts[2]}";
|
||||
@@ -425,9 +425,9 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
if (!players.Contains(parts[0]))
|
||||
players.Add(parts[0]);
|
||||
|
||||
var loc = Exts.ParseIntegerInvariant(parts[3]);
|
||||
var health = Exts.ParseIntegerInvariant(parts[2]) * 100 / 256;
|
||||
var facing = (section == "INFANTRY") ? Exts.ParseIntegerInvariant(parts[6]) : Exts.ParseIntegerInvariant(parts[4]);
|
||||
var loc = Exts.ParseInt32Invariant(parts[3]);
|
||||
var health = Exts.ParseInt32Invariant(parts[2]) * 100 / 256;
|
||||
var facing = (section == "INFANTRY") ? Exts.ParseInt32Invariant(parts[6]) : Exts.ParseInt32Invariant(parts[4]);
|
||||
|
||||
var actorType = parts[1].ToLowerInvariant();
|
||||
|
||||
@@ -443,7 +443,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
actor.Add(new FacingInit(new WAngle(1024 - 4 * facing)));
|
||||
|
||||
if (section == "INFANTRY")
|
||||
actor.Add(new SubCellInit((SubCell)Exts.ParseByte(parts[4])));
|
||||
actor.Add(new SubCellInit((SubCell)Exts.ParseByteInvariant(parts[4])));
|
||||
|
||||
if (!map.Rules.Actors.ContainsKey(parts[1].ToLowerInvariant()))
|
||||
Console.WriteLine($"Ignoring unknown actor type: `{parts[1].ToLowerInvariant()}`");
|
||||
@@ -470,7 +470,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
var nodes = new List<MiniYamlNode>();
|
||||
foreach (var kv in terrain)
|
||||
{
|
||||
var loc = Exts.ParseIntegerInvariant(kv.Key);
|
||||
var loc = Exts.ParseInt32Invariant(kv.Key);
|
||||
var treeActor = ParseTreeActor(kv.Value);
|
||||
|
||||
var ar = new ActorReference(treeActor)
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
var waypointsSection = file.GetSection("Waypoints", true);
|
||||
foreach (var kv in waypointsSection)
|
||||
{
|
||||
var pos = int.Parse(kv.Value);
|
||||
var pos = Exts.ParseInt32Invariant(kv.Value);
|
||||
var ry = pos / 1000;
|
||||
var rx = pos - ry * 1000;
|
||||
var cell = ToMPos(rx, ry, fullSize.X).ToCPos(map);
|
||||
@@ -230,7 +230,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
var terrainSection = file.GetSection("Terrain", true);
|
||||
foreach (var kv in terrainSection)
|
||||
{
|
||||
var pos = int.Parse(kv.Key);
|
||||
var pos = Exts.ParseInt32Invariant(kv.Key);
|
||||
var ry = pos / 1000;
|
||||
var rx = pos - ry * 1000;
|
||||
var cell = ToMPos(rx, ry, fullSize.X).ToCPos(map);
|
||||
@@ -268,10 +268,10 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
isDeployed = true;
|
||||
}
|
||||
|
||||
var health = short.Parse(entries[2]);
|
||||
var rx = int.Parse(entries[3]);
|
||||
var ry = int.Parse(entries[4]);
|
||||
var facing = (byte)(224 - byte.Parse(entries[type == "Infantry" ? 7 : 5]));
|
||||
var health = Exts.ParseInt16Invariant(entries[2]);
|
||||
var rx = Exts.ParseInt32Invariant(entries[3]);
|
||||
var ry = Exts.ParseInt32Invariant(entries[4]);
|
||||
var facing = (byte)(224 - Exts.ParseByteInvariant(entries[type == "Infantry" ? 7 : 5]));
|
||||
|
||||
var cell = ToMPos(rx, ry, fullSize.X).ToCPos(map);
|
||||
|
||||
@@ -284,7 +284,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
if (type == "Infantry")
|
||||
{
|
||||
var subcell = 0;
|
||||
switch (byte.Parse(entries[5]))
|
||||
switch (Exts.ParseByteInvariant(entries[5]))
|
||||
{
|
||||
case 2: subcell = 3; break;
|
||||
case 3: subcell = 1; break;
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 1; ; i++)
|
||||
{
|
||||
var line = mapPackSection.GetValue(i.ToString(), null);
|
||||
var line = mapPackSection.GetValue(i.ToStringInvariant(), null);
|
||||
if (line == null)
|
||||
break;
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
var nodes = new List<MiniYamlNode>();
|
||||
foreach (var kv in overlay)
|
||||
{
|
||||
var loc = Exts.ParseIntegerInvariant(kv.Key);
|
||||
var loc = Exts.ParseInt32Invariant(kv.Key);
|
||||
var cell = new CPos(loc % MapSize, loc / MapSize);
|
||||
|
||||
var res = (Type: (byte)0, Index: (byte)0);
|
||||
|
||||
@@ -62,8 +62,8 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
var size = foundation.Split('x');
|
||||
if (size.Length == 2)
|
||||
{
|
||||
var x = int.Parse(size[0]);
|
||||
var y = int.Parse(size[1]);
|
||||
var x = Exts.ParseInt32Invariant(size[0]);
|
||||
var y = Exts.ParseInt32Invariant(size[1]);
|
||||
|
||||
var xOffset = (x - y) * grid.TileSize.Width / 4;
|
||||
var yOffset = (x + y) * grid.TileSize.Height / 4;
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
{
|
||||
var section = file.GetSection($"TileSet{tilesetGroupIndex:D4}");
|
||||
|
||||
var sectionCount = int.Parse(section.GetValue("TilesInSet", "1"));
|
||||
var sectionCount = Exts.ParseInt32Invariant(section.GetValue("TilesInSet", "1"));
|
||||
var sectionFilename = section.GetValue("FileName", "").ToLowerInvariant();
|
||||
var sectionCategory = section.GetValue("SetName", "");
|
||||
if (!string.IsNullOrEmpty(sectionCategory) && sectionFilename != "blank")
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common
|
||||
return;
|
||||
|
||||
var server = args.Secret.Split('|');
|
||||
Game.RunAfterTick(() => Game.RemoteDirectConnect(new ConnectionTarget(server[0], int.Parse(server[1]))));
|
||||
Game.RunAfterTick(() => Game.RemoteDirectConnect(new ConnectionTarget(server[0], Exts.ParseInt32Invariant(server[1]))));
|
||||
}
|
||||
|
||||
void SetStatus(DiscordState state, string details = null, string secret = null, int? players = null, int? slots = null)
|
||||
|
||||
@@ -487,7 +487,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
|
||||
var slot = server.LobbyInfo.Slots[parts[0]];
|
||||
var bot = server.LobbyInfo.ClientInSlot(parts[0]);
|
||||
if (!Exts.TryParseIntegerInvariant(parts[1], out var controllerClientIndex))
|
||||
if (!Exts.TryParseInt32Invariant(parts[1], out var controllerClientIndex))
|
||||
{
|
||||
Log.Write("server", $"Invalid bot controller client index: {parts[1]}");
|
||||
return false;
|
||||
@@ -738,7 +738,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Exts.TryParseIntegerInvariant(raw, out var teamCount))
|
||||
if (!Exts.TryParseInt32Invariant(raw, out var teamCount))
|
||||
{
|
||||
server.SendLocalizedMessageTo(conn, NumberTeams, Translation.Arguments("raw", raw));
|
||||
return true;
|
||||
@@ -788,7 +788,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
return true;
|
||||
}
|
||||
|
||||
var kickConn = Exts.TryParseIntegerInvariant(split[0], out var kickClientID)
|
||||
var kickConn = Exts.TryParseInt32Invariant(split[0], out var kickClientID)
|
||||
? server.Conns.SingleOrDefault(c => server.GetClient(c)?.Index == kickClientID) : null;
|
||||
|
||||
if (kickConn == null)
|
||||
@@ -839,7 +839,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
return true;
|
||||
}
|
||||
|
||||
var newAdminConn = Exts.TryParseIntegerInvariant(s, out var newAdminId)
|
||||
var newAdminConn = Exts.TryParseInt32Invariant(s, out var newAdminId)
|
||||
? server.Conns.SingleOrDefault(c => server.GetClient(c)?.Index == newAdminId) : null;
|
||||
|
||||
if (newAdminConn == null)
|
||||
@@ -876,7 +876,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
return true;
|
||||
}
|
||||
|
||||
var targetConn = Exts.TryParseIntegerInvariant(s, out var targetId)
|
||||
var targetConn = Exts.TryParseInt32Invariant(s, out var targetId)
|
||||
? server.Conns.SingleOrDefault(c => server.GetClient(c)?.Index == targetId) : null;
|
||||
|
||||
if (targetConn == null)
|
||||
@@ -923,7 +923,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
lock (server.LobbyInfo)
|
||||
{
|
||||
var parts = s.Split(' ');
|
||||
var targetClient = server.LobbyInfo.ClientWithIndex(Exts.ParseIntegerInvariant(parts[0]));
|
||||
var targetClient = server.LobbyInfo.ClientWithIndex(Exts.ParseInt32Invariant(parts[0]));
|
||||
|
||||
// Only the host can change other client's info
|
||||
if (targetClient.Index != client.Index && !client.IsAdmin)
|
||||
@@ -956,7 +956,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
lock (server.LobbyInfo)
|
||||
{
|
||||
var parts = s.Split(' ');
|
||||
var targetClient = server.LobbyInfo.ClientWithIndex(Exts.ParseIntegerInvariant(parts[0]));
|
||||
var targetClient = server.LobbyInfo.ClientWithIndex(Exts.ParseInt32Invariant(parts[0]));
|
||||
|
||||
// Only the host can change other client's info
|
||||
if (targetClient.Index != client.Index && !client.IsAdmin)
|
||||
@@ -966,7 +966,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
if (server.LobbyInfo.Slots[targetClient.Slot].LockTeam)
|
||||
return true;
|
||||
|
||||
if (!Exts.TryParseIntegerInvariant(parts[1], out var team))
|
||||
if (!Exts.TryParseInt32Invariant(parts[1], out var team))
|
||||
{
|
||||
Log.Write("server", $"Invalid team: {s}");
|
||||
return false;
|
||||
@@ -984,7 +984,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
lock (server.LobbyInfo)
|
||||
{
|
||||
var parts = s.Split(' ');
|
||||
var targetClient = server.LobbyInfo.ClientWithIndex(Exts.ParseIntegerInvariant(parts[0]));
|
||||
var targetClient = server.LobbyInfo.ClientWithIndex(Exts.ParseInt32Invariant(parts[0]));
|
||||
|
||||
// Only the host can change other client's info
|
||||
if (targetClient.Index != client.Index && !client.IsAdmin)
|
||||
@@ -994,7 +994,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
if (server.LobbyInfo.Slots[targetClient.Slot].LockHandicap)
|
||||
return true;
|
||||
|
||||
if (!Exts.TryParseIntegerInvariant(parts[1], out var handicap))
|
||||
if (!Exts.TryParseInt32Invariant(parts[1], out var handicap))
|
||||
{
|
||||
Log.Write("server", $"Invalid handicap: {s}");
|
||||
return false;
|
||||
@@ -1017,7 +1017,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
|
||||
static bool ClearPlayerSpawn(S server, Connection conn, Session.Client client, string s)
|
||||
{
|
||||
var spawnPoint = Exts.ParseIntegerInvariant(s);
|
||||
var spawnPoint = Exts.ParseInt32Invariant(s);
|
||||
if (spawnPoint == 0)
|
||||
return true;
|
||||
|
||||
@@ -1059,7 +1059,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
lock (server.LobbyInfo)
|
||||
{
|
||||
var parts = s.Split(' ');
|
||||
var targetClient = server.LobbyInfo.ClientWithIndex(Exts.ParseIntegerInvariant(parts[0]));
|
||||
var targetClient = server.LobbyInfo.ClientWithIndex(Exts.ParseInt32Invariant(parts[0]));
|
||||
|
||||
// Only the host can change other client's info
|
||||
if (targetClient.Index != client.Index && !client.IsAdmin)
|
||||
@@ -1073,7 +1073,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
if (server.LobbyInfo.Slots[targetClient.Slot].LockSpawn)
|
||||
return true;
|
||||
|
||||
if (!Exts.TryParseIntegerInvariant(parts[1], out var spawnPoint)
|
||||
if (!Exts.TryParseInt32Invariant(parts[1], out var spawnPoint)
|
||||
|| spawnPoint < 0 || spawnPoint > server.Map.SpawnPoints.Length)
|
||||
{
|
||||
Log.Write("server", $"Invalid spawn point: {parts[1]}");
|
||||
@@ -1114,7 +1114,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
lock (server.LobbyInfo)
|
||||
{
|
||||
var parts = s.Split(' ');
|
||||
var targetClient = server.LobbyInfo.ClientWithIndex(Exts.ParseIntegerInvariant(parts[0]));
|
||||
var targetClient = server.LobbyInfo.ClientWithIndex(Exts.ParseInt32Invariant(parts[0]));
|
||||
|
||||
// Only the host can change other client's info
|
||||
if (targetClient.Index != client.Index && !client.IsAdmin)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -61,11 +62,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
|
||||
{
|
||||
var startingCash = SelectableCash.ToDictionary(c => c.ToString(), c => "$" + c.ToString());
|
||||
var startingCash = SelectableCash.ToDictionary(c => c.ToStringInvariant(), c => "$" + c.ToString(NumberFormatInfo.CurrentInfo));
|
||||
|
||||
if (startingCash.Count > 0)
|
||||
yield return new LobbyOption(map, "startingcash", DefaultCashDropdownLabel, DefaultCashDropdownDescription, DefaultCashDropdownVisible, DefaultCashDropdownDisplayOrder,
|
||||
startingCash, DefaultCash.ToString(), DefaultCashDropdownLocked);
|
||||
startingCash, DefaultCash.ToStringInvariant(), DefaultCashDropdownLocked);
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new PlayerResources(init.Self, this); }
|
||||
@@ -82,7 +83,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
owner = self.Owner;
|
||||
|
||||
var startingCash = self.World.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("startingcash", info.DefaultCash.ToString());
|
||||
.OptionOrDefault("startingcash", info.DefaultCash.ToStringInvariant());
|
||||
|
||||
if (!int.TryParse(startingCash, out Cash))
|
||||
Cash = info.DefaultCash;
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (cg.Count > 0)
|
||||
{
|
||||
var actorIds = cg.Select(a => a.ActorID).ToArray();
|
||||
groups.Add(new MiniYamlNode(i.ToString(), FieldSaver.FormatValue(actorIds)));
|
||||
groups.Add(new MiniYamlNode(i.ToStringInvariant(), FieldSaver.FormatValue(actorIds)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var group = FieldLoader.GetValue<uint[]>(n.Key, n.Value.Value)
|
||||
.Select(a => self.World.GetActorById(a)).Where(a => a != null);
|
||||
controlGroups[int.Parse(n.Key)].AddRange(group);
|
||||
controlGroups[Exts.ParseInt32Invariant(n.Key)].AddRange(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var kv in mp)
|
||||
{
|
||||
var name = kv.Key;
|
||||
var index = int.Parse(name[5..]);
|
||||
var index = Exts.ParseInt32Invariant(name[5..]);
|
||||
|
||||
if (index >= newCount)
|
||||
{
|
||||
@@ -303,12 +303,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
string NextActorName()
|
||||
{
|
||||
var id = previews.Count;
|
||||
var possibleName = "Actor" + id.ToString();
|
||||
var possibleName = "Actor" + id.ToStringInvariant();
|
||||
|
||||
while (previews.Any(p => p.ID == possibleName))
|
||||
{
|
||||
id++;
|
||||
possibleName = "Actor" + id.ToString();
|
||||
possibleName = "Actor" + id.ToStringInvariant();
|
||||
}
|
||||
|
||||
return possibleName;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Commands;
|
||||
@@ -133,7 +134,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
(cost.Destination.X + nodeCell.X) / 2,
|
||||
(cost.Destination.Y + nodeCell.Y) / 2);
|
||||
var centerPos = self.World.Map.CenterOfSubCell(centerCell, SubCell.FullCell);
|
||||
yield return new TextAnnotationRenderable(font, centerPos, 0, lineColor, cost.Cost.ToString());
|
||||
yield return new TextAnnotationRenderable(font, centerPos, 0, lineColor, cost.Cost.ToString(NumberFormatInfo.CurrentInfo));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
|
||||
{
|
||||
var timelimits = TimeLimitOptions.ToDictionary(m => m.ToString(), m =>
|
||||
var timelimits = TimeLimitOptions.ToDictionary(m => m.ToStringInvariant(), m =>
|
||||
{
|
||||
if (m == 0)
|
||||
return TranslationProvider.GetString(NoTimeLimit);
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
});
|
||||
|
||||
yield return new LobbyOption(map, "timelimit", TimeLimitLabel, TimeLimitDescription, TimeLimitDropdownVisible, TimeLimitDisplayOrder,
|
||||
timelimits, TimeLimitDefault.ToString(), TimeLimitLocked);
|
||||
timelimits, TimeLimitDefault.ToStringInvariant(), TimeLimitLocked);
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new TimeLimitManager(init.Self, this); }
|
||||
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Notification = info.Notification;
|
||||
ticksPerSecond = 1000 / self.World.Timestep;
|
||||
|
||||
var tl = self.World.LobbyInfo.GlobalSettings.OptionOrDefault("timelimit", info.TimeLimitDefault.ToString());
|
||||
var tl = self.World.LobbyInfo.GlobalSettings.OptionOrDefault("timelimit", info.TimeLimitDefault.ToStringInvariant());
|
||||
if (!int.TryParse(tl, out TimeLimit))
|
||||
TimeLimit = info.TimeLimitDefault;
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (countdownLabel != null)
|
||||
{
|
||||
countdown = new CachedTransform<int, string>(t =>
|
||||
string.Format(info.CountdownText, WidgetUtils.FormatTime(t, w.Timestep)));
|
||||
info.CountdownText.FormatCurrent(WidgetUtils.FormatTime(t, w.Timestep)));
|
||||
countdownLabel.GetText = () => TimeLimit > 0 ? countdown.Update(ticksRemaining) : "";
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
if (ticksRemaining == m * 60 * ticksPerSecond)
|
||||
{
|
||||
TextNotificationsManager.AddSystemLine(string.Format(Notification, m, m > 1 ? "s" : null));
|
||||
TextNotificationsManager.AddSystemLine(Notification.FormatCurrent(m, m > 1 ? "s" : null));
|
||||
|
||||
var faction = self.World.LocalPlayer?.Faction.InternalName;
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.World.LocalPlayer, "Speech", info.TimeLimitWarnings[m], faction);
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
foreach (var dltt in actorNode.ChildrenMatching("DrawLineToTarget", includeRemovals: false))
|
||||
{
|
||||
var delayNode = dltt.LastChildMatching("Delay", false);
|
||||
if (delayNode != null && Exts.TryParseIntegerInvariant(delayNode.Value.Value, out var delay))
|
||||
delayNode.ReplaceValue((delay * 1000 / 25).ToString());
|
||||
if (delayNode != null && Exts.TryParseInt32Invariant(delayNode.Value.Value, out var delay))
|
||||
delayNode.ReplaceValue((delay * 1000 / 25).ToStringInvariant());
|
||||
}
|
||||
|
||||
yield break;
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
}
|
||||
|
||||
var size = 2 * range + 1;
|
||||
power.AddNode(new MiniYamlNodeBuilder("Dimensions", size.ToString() + ", " + size.ToString()));
|
||||
power.AddNode(new MiniYamlNodeBuilder("Dimensions", size.ToStringInvariant() + ", " + size.ToStringInvariant()));
|
||||
|
||||
var footprint = string.Empty;
|
||||
|
||||
|
||||
@@ -382,7 +382,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
foreach (var node in combineNode.Value.Nodes)
|
||||
{
|
||||
ProcessNode(modData, node, node, node.Key);
|
||||
node.Key = i++.ToString();
|
||||
node.Key = i++.ToStringInvariant();
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using OpenRA.Mods.Common.FileFormats;
|
||||
|
||||
@@ -46,7 +47,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
if (!section.Contains("Height"))
|
||||
continue;
|
||||
|
||||
selectionHeight[section.Name] = (int)(float.Parse(section.GetValue("Height", "1")) * grid.TileSize.Height);
|
||||
selectionHeight[section.Name] = (int)(float.Parse(section.GetValue("Height", "1"), NumberFormatInfo.InvariantInfo) * grid.TileSize.Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
}
|
||||
|
||||
var output = string.Format(HtmlTemplate.JoinWith("\n"), zoom, Convert.ToBase64String(modData.ModFiles.Open(image).ReadAllBytes()), "[" + regions.JoinWith(",") + "]");
|
||||
var output = HtmlTemplate.JoinWith("\n").FormatInvariant(zoom, Convert.ToBase64String(modData.ModFiles.Open(image).ReadAllBytes()), "[" + regions.JoinWith(",") + "]");
|
||||
var outputPath = Path.ChangeExtension(image, ".html");
|
||||
File.WriteAllLines(outputPath, new[] { output });
|
||||
Console.WriteLine("Saved {0}", outputPath);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using OpenRA.Scripting;
|
||||
@@ -162,7 +163,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
Console.WriteLine(enumType.Name + " = {");
|
||||
|
||||
foreach (var value in Enum.GetValues(enumType))
|
||||
Console.WriteLine($" {value} = {Convert.ChangeType(value, typeof(int))},");
|
||||
Console.WriteLine($" {value} = {Convert.ChangeType(value, typeof(int), NumberFormatInfo.InvariantInfo)},");
|
||||
|
||||
Console.WriteLine("}");
|
||||
Console.WriteLine();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
@@ -96,7 +97,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
type.Name,
|
||||
Values = Enum.GetNames(type).Select(x => new
|
||||
{
|
||||
Key = Convert.ToInt32(Enum.Parse(type, x)),
|
||||
Key = Convert.ToInt32(Enum.Parse(type, x), NumberFormatInfo.InvariantInfo),
|
||||
Value = x
|
||||
})
|
||||
});
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using OpenRA.Primitives;
|
||||
@@ -102,7 +103,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
type.Name,
|
||||
Values = Enum.GetNames(type).Select(x => new
|
||||
{
|
||||
Key = Convert.ToInt32(Enum.Parse(type, x)),
|
||||
Key = Convert.ToInt32(Enum.Parse(type, x), NumberFormatInfo.InvariantInfo),
|
||||
Value = x
|
||||
})
|
||||
});
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using OpenRA.GameRules;
|
||||
@@ -105,7 +106,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
type.Name,
|
||||
Values = Enum.GetNames(type).Select(x => new
|
||||
{
|
||||
Key = Convert.ToInt32(Enum.Parse(type, x)),
|
||||
Key = Convert.ToInt32(Enum.Parse(type, x), NumberFormatInfo.InvariantInfo),
|
||||
Value = x
|
||||
})
|
||||
});
|
||||
|
||||
@@ -81,16 +81,16 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
if (parts.Length == 3)
|
||||
{
|
||||
foreach (var c in parts)
|
||||
Console.Write(byte.Parse(c).ToString("X2"));
|
||||
Console.Write(Exts.ParseByteInvariant(c).ToStringInvariant("X2"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write(byte.Parse(parts[0]).ToString("X2"));
|
||||
Console.Write(byte.Parse(parts[1]).ToString("X2"));
|
||||
Console.Write(byte.Parse(parts[2]).ToString("X2"));
|
||||
var alpha = byte.Parse(parts[3]);
|
||||
Console.Write(Exts.ParseByteInvariant(parts[0]).ToStringInvariant("X2"));
|
||||
Console.Write(Exts.ParseByteInvariant(parts[1]).ToStringInvariant("X2"));
|
||||
Console.Write(Exts.ParseByteInvariant(parts[2]).ToStringInvariant("X2"));
|
||||
var alpha = Exts.ParseByteInvariant(parts[3]);
|
||||
if (alpha < 255)
|
||||
Console.Write(alpha.ToString("X2"));
|
||||
Console.Write(alpha.ToStringInvariant("X2"));
|
||||
}
|
||||
|
||||
if (++i != args.Length)
|
||||
@@ -186,16 +186,16 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
if (parts.Length == 3)
|
||||
{
|
||||
foreach (var c in parts)
|
||||
Console.Write(byte.Parse(c).ToString("X2"));
|
||||
Console.Write(Exts.ParseByteInvariant(c).ToStringInvariant("X2"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write(byte.Parse(parts[1]).ToString("X2"));
|
||||
Console.Write(byte.Parse(parts[2]).ToString("X2"));
|
||||
Console.Write(byte.Parse(parts[3]).ToString("X2"));
|
||||
var alpha = byte.Parse(parts[0]);
|
||||
Console.Write(Exts.ParseByteInvariant(parts[1]).ToStringInvariant("X2"));
|
||||
Console.Write(Exts.ParseByteInvariant(parts[2]).ToStringInvariant("X2"));
|
||||
Console.Write(Exts.ParseByteInvariant(parts[3]).ToStringInvariant("X2"));
|
||||
var alpha = Exts.ParseByteInvariant(parts[0]);
|
||||
if (alpha < 255)
|
||||
Console.Write(alpha.ToString("X2"));
|
||||
Console.Write(alpha.ToStringInvariant("X2"));
|
||||
}
|
||||
|
||||
if (++i != args.Length)
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var suffix = (i + 1).ToString("D2");
|
||||
var suffix = (i + 1).ToStringInvariant("D2");
|
||||
yield return selectPrefix + suffix;
|
||||
yield return createPrefix + suffix;
|
||||
yield return addToPrefix + suffix;
|
||||
@@ -111,19 +111,19 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
base.Initialize(args);
|
||||
|
||||
selectGroupHotkeys = Exts.MakeArray(hotkeyCount,
|
||||
i => modData.Hotkeys[SelectGroupKeyPrefix + (i + 1).ToString("D2")]);
|
||||
i => modData.Hotkeys[SelectGroupKeyPrefix + (i + 1).ToStringInvariant("D2")]);
|
||||
|
||||
createGroupHotkeys = Exts.MakeArray(hotkeyCount,
|
||||
i => modData.Hotkeys[CreateGroupKeyPrefix + (i + 1).ToString("D2")]);
|
||||
i => modData.Hotkeys[CreateGroupKeyPrefix + (i + 1).ToStringInvariant("D2")]);
|
||||
|
||||
addToGroupHotkeys = Exts.MakeArray(hotkeyCount,
|
||||
i => modData.Hotkeys[AddToGroupKeyPrefix + (i + 1).ToString("D2")]);
|
||||
i => modData.Hotkeys[AddToGroupKeyPrefix + (i + 1).ToStringInvariant("D2")]);
|
||||
|
||||
combineWithGroupHotkeys = Exts.MakeArray(hotkeyCount,
|
||||
i => modData.Hotkeys[CombineWithGroupKeyPrefix + (i + 1).ToString("D2")]);
|
||||
i => modData.Hotkeys[CombineWithGroupKeyPrefix + (i + 1).ToStringInvariant("D2")]);
|
||||
|
||||
jumpToGroupHotkeys = Exts.MakeArray(hotkeyCount,
|
||||
i => modData.Hotkeys[JumpToGroupKeyPrefix + (i + 1).ToString("D2")]);
|
||||
i => modData.Hotkeys[JumpToGroupKeyPrefix + (i + 1).ToStringInvariant("D2")]);
|
||||
}
|
||||
|
||||
public override bool HandleKeyPress(KeyInput e)
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
var scale = 200 / Math.Max(5000, (float)Math.Ceiling(maxValue / 1000) * 1000);
|
||||
|
||||
var widthMaxValue = labelFont.Measure(string.Format(GetYAxisValueFormat(), height / scale)).X;
|
||||
var widthMaxValue = labelFont.Measure(GetYAxisValueFormat().FormatCurrent(height / scale)).X;
|
||||
var widthLongestName = labelFont.Measure(longestName).X;
|
||||
|
||||
// y axis label
|
||||
@@ -164,7 +164,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
}), 1, color);
|
||||
|
||||
if (lastPoint != 0f)
|
||||
labelFont.DrawTextWithShadow(string.Format(GetValueFormat(), lastPoint), graphOrigin + new float2(lastX * xStep, -lastPoint * scale - 2),
|
||||
labelFont.DrawTextWithShadow(GetValueFormat().FormatCurrent(lastPoint), graphOrigin + new float2(lastX * xStep, -lastPoint * scale - 2),
|
||||
color, BackgroundColorDark, BackgroundColorLight, 1);
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (n % XAxisTicksPerLabel != 0)
|
||||
continue;
|
||||
|
||||
var xAxisText = string.Format(GetXAxisValueFormat(), n / XAxisTicksPerLabel);
|
||||
var xAxisText = GetXAxisValueFormat().FormatCurrent(n / XAxisTicksPerLabel);
|
||||
var xAxisTickTextWidth = labelFont.Measure(xAxisText).X;
|
||||
var xLocation = x - xAxisTickTextWidth / 2;
|
||||
labelFont.DrawTextWithShadow(xAxisText,
|
||||
@@ -202,7 +202,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
var yValue = y / scale;
|
||||
cr.DrawLine(graphOrigin + new float2(0, -y), graphOrigin + new float2(5, -y), 1, Color.White);
|
||||
var text = string.Format(GetYAxisValueFormat(), yValue);
|
||||
var text = GetYAxisValueFormat().FormatCurrent(yValue);
|
||||
|
||||
var textWidth = labelFont.Measure(text);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
@@ -45,7 +46,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
joinButton.OnClick = () =>
|
||||
{
|
||||
var port = Exts.WithDefault(1234, () => Exts.ParseIntegerInvariant(portField.Text));
|
||||
var port = Exts.WithDefault(1234, () => int.Parse(portField.Text, NumberFormatInfo.CurrentInfo));
|
||||
|
||||
Game.Settings.Player.LastServer = $"{ipField.Text}:{port}";
|
||||
Game.Settings.Save();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
@@ -318,7 +319,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var valueField = sliderContainer.GetOrNull<TextFieldWidget>("VALUE");
|
||||
if (valueField != null)
|
||||
{
|
||||
void UpdateValueField(float f) => valueField.Text = ((int)f).ToString();
|
||||
void UpdateValueField(float f) => valueField.Text = ((int)f).ToString(NumberFormatInfo.CurrentInfo);
|
||||
UpdateValueField(so.GetValue(actor));
|
||||
slider.OnChange += UpdateValueField;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -32,7 +33,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
Template = template;
|
||||
Categories = template.Categories;
|
||||
Tooltip = template.Id.ToString();
|
||||
Tooltip = template.Id.ToString(NumberFormatInfo.CurrentInfo);
|
||||
SearchTerms = new[] { Tooltip };
|
||||
}
|
||||
}
|
||||
@@ -71,7 +72,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (!string.IsNullOrEmpty(searchFilter))
|
||||
FilteredCategories.AddRange(
|
||||
allTemplates.Where(t => t.SearchTerms.Any(
|
||||
s => s.IndexOf(searchFilter, StringComparison.OrdinalIgnoreCase) >= 0))
|
||||
s => s.Contains(searchFilter, StringComparison.CurrentCultureIgnoreCase)))
|
||||
.SelectMany(t => t.Categories)
|
||||
.Distinct()
|
||||
.OrderBy(CategoryOrder));
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using OpenRA.Network;
|
||||
@@ -254,7 +255,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var label = item.Get<LabelWithTooltipWidget>("TITLE");
|
||||
WidgetUtils.TruncateLabelToTooltip(label, title);
|
||||
|
||||
var date = File.GetLastWriteTime(savePath).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
var date = File.GetLastWriteTime(savePath).ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture);
|
||||
item.Get<LabelWidget>("DATE").GetText = () => date;
|
||||
|
||||
gameList.AddChild(item);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
@@ -140,7 +141,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
: TranslationProvider.GetString(NoTeam);
|
||||
teamHeader.Get<LabelWidget>("TEAM").GetText = () => team;
|
||||
var teamRating = teamHeader.Get<LabelWidget>("TEAM_SCORE");
|
||||
var scoreCache = new CachedTransform<int, string>(s => s.ToString());
|
||||
var scoreCache = new CachedTransform<int, string>(s => s.ToString(NumberFormatInfo.CurrentInfo));
|
||||
var teamMemberScores = t.Select(tt => tt.PlayerStatistics).Where(s => s != null).ToArray().Select(s => s.Experience);
|
||||
teamRating.GetText = () => scoreCache.Update(teamMemberScores.Sum());
|
||||
|
||||
@@ -172,7 +173,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
WidgetUtils.TruncateLabelToTooltip(item.Get<LabelWithTooltipWidget>("FACTION"), factionName);
|
||||
|
||||
var scoreCache = new CachedTransform<int, string>(s => s.ToString());
|
||||
var scoreCache = new CachedTransform<int, string>(s => s.ToString(NumberFormatInfo.CurrentInfo));
|
||||
item.Get<LabelWidget>("SCORE").GetText = () => scoreCache.Update(p.PlayerStatistics?.Experience ?? 0);
|
||||
|
||||
var muteCheckbox = item.Get<CheckboxWidget>("MUTE");
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
@@ -77,7 +78,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
siloUsageTooltip = siloUsageTooltipCache.Update((playerResources.Resources, playerResources.ResourceCapacity));
|
||||
cashLabel.Text = displayResources.ToString();
|
||||
cashLabel.Text = displayResources.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Globalization;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Widgets;
|
||||
@@ -36,7 +37,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var capacity = developerMode.UnlimitedPower ?
|
||||
TranslationProvider.GetString(Infinite) :
|
||||
powerManager.PowerProvided.ToString();
|
||||
powerManager.PowerProvided.ToString(NumberFormatInfo.CurrentInfo);
|
||||
|
||||
return TranslationProvider.GetString(
|
||||
PowerUsage,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Globalization;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Widgets;
|
||||
@@ -35,20 +36,23 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
powerIcon.GetImageName = () => powerManager.ExcessPower < 0 ? "power-critical" : "power-normal";
|
||||
power.GetColor = () => powerManager.ExcessPower < 0 ? Color.Red : Color.White;
|
||||
power.GetText = () => developerMode.UnlimitedPower ? unlimitedCapacity : powerManager.ExcessPower.ToString();
|
||||
power.GetText = () => developerMode.UnlimitedPower ? unlimitedCapacity : powerManager.ExcessPower.ToString(NumberFormatInfo.CurrentInfo);
|
||||
|
||||
var tooltipTextCached = new CachedTransform<(string, string), string>(((string Usage, string Capacity) args) =>
|
||||
var tooltipTextCached = new CachedTransform<(int, int?), string>(((int Usage, int? Capacity) args) =>
|
||||
{
|
||||
var capacity = args.Capacity == null ? unlimitedCapacity : args.Capacity.Value.ToString(NumberFormatInfo.CurrentInfo);
|
||||
return TranslationProvider.GetString(
|
||||
PowerUsage,
|
||||
Translation.Arguments("usage", args.Usage, "capacity", args.Capacity));
|
||||
Translation.Arguments(
|
||||
"usage", args.Usage.ToString(NumberFormatInfo.CurrentInfo),
|
||||
"capacity", capacity));
|
||||
});
|
||||
|
||||
power.GetTooltipText = () =>
|
||||
{
|
||||
var capacity = developerMode.UnlimitedPower ? unlimitedCapacity : powerManager.PowerProvided.ToString();
|
||||
var capacity = developerMode.UnlimitedPower ? (int?)null : powerManager.PowerProvided;
|
||||
|
||||
return tooltipTextCached.Update((powerManager.PowerDrained.ToString(), capacity));
|
||||
return tooltipTextCached.Update((powerManager.PowerDrained, capacity));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Lint;
|
||||
@@ -320,25 +321,25 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (stats == null)
|
||||
return template;
|
||||
|
||||
var destroyedText = new CachedTransform<int, string>(i => "$" + i);
|
||||
var destroyedText = new CachedTransform<int, string>(i => "$" + i.ToString(NumberFormatInfo.CurrentInfo));
|
||||
template.Get<LabelWidget>("ASSETS_DESTROYED").GetText = () => destroyedText.Update(stats.KillsCost);
|
||||
|
||||
var lostText = new CachedTransform<int, string>(i => "$" + i);
|
||||
var lostText = new CachedTransform<int, string>(i => "$" + i.ToString(NumberFormatInfo.CurrentInfo));
|
||||
template.Get<LabelWidget>("ASSETS_LOST").GetText = () => lostText.Update(stats.DeathsCost);
|
||||
|
||||
var unitsKilledText = new CachedTransform<int, string>(i => i.ToString());
|
||||
var unitsKilledText = new CachedTransform<int, string>(i => i.ToString(NumberFormatInfo.CurrentInfo));
|
||||
template.Get<LabelWidget>("UNITS_KILLED").GetText = () => unitsKilledText.Update(stats.UnitsKilled);
|
||||
|
||||
var unitsDeadText = new CachedTransform<int, string>(i => i.ToString());
|
||||
var unitsDeadText = new CachedTransform<int, string>(i => i.ToString(NumberFormatInfo.CurrentInfo));
|
||||
template.Get<LabelWidget>("UNITS_DEAD").GetText = () => unitsDeadText.Update(stats.UnitsDead);
|
||||
|
||||
var buildingsKilledText = new CachedTransform<int, string>(i => i.ToString());
|
||||
var buildingsKilledText = new CachedTransform<int, string>(i => i.ToString(NumberFormatInfo.CurrentInfo));
|
||||
template.Get<LabelWidget>("BUILDINGS_KILLED").GetText = () => buildingsKilledText.Update(stats.BuildingsKilled);
|
||||
|
||||
var buildingsDeadText = new CachedTransform<int, string>(i => i.ToString());
|
||||
var buildingsDeadText = new CachedTransform<int, string>(i => i.ToString(NumberFormatInfo.CurrentInfo));
|
||||
template.Get<LabelWidget>("BUILDINGS_DEAD").GetText = () => buildingsDeadText.Update(stats.BuildingsDead);
|
||||
|
||||
var armyText = new CachedTransform<int, string>(i => "$" + i);
|
||||
var armyText = new CachedTransform<int, string>(i => "$" + i.ToString(NumberFormatInfo.CurrentInfo));
|
||||
template.Get<LabelWidget>("ARMY_VALUE").GetText = () => armyText.Update(stats.ArmyValue);
|
||||
|
||||
var visionText = new CachedTransform<int, string>(i => Vision(i));
|
||||
@@ -446,15 +447,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
template.Get<LabelWidget>("ASSETS").GetText = () => assetsText.Update(stats.AssetsValue);
|
||||
|
||||
var harvesters = template.Get<LabelWidget>("HARVESTERS");
|
||||
harvesters.GetText = () => world.ActorsWithTrait<Harvester>().Count(a => a.Actor.Owner == player && !a.Actor.IsDead && !a.Trait.IsTraitDisabled).ToString();
|
||||
harvesters.GetText = () => world.ActorsWithTrait<Harvester>().Count(a => a.Actor.Owner == player && !a.Actor.IsDead && !a.Trait.IsTraitDisabled).ToString(NumberFormatInfo.CurrentInfo);
|
||||
|
||||
var carryalls = template.GetOrNull<LabelWidget>("CARRYALLS");
|
||||
if (carryalls != null)
|
||||
carryalls.GetText = () => world.ActorsWithTrait<AutoCarryall>().Count(a => a.Actor.Owner == player && !a.Actor.IsDead).ToString();
|
||||
carryalls.GetText = () => world.ActorsWithTrait<AutoCarryall>().Count(a => a.Actor.Owner == player && !a.Actor.IsDead).ToString(NumberFormatInfo.CurrentInfo);
|
||||
|
||||
var derricks = template.GetOrNull<LabelWidget>("DERRICKS");
|
||||
if (derricks != null)
|
||||
derricks.GetText = () => world.ActorsHavingTrait<UpdatesDerrickCount>().Count(a => a.Owner == player && !a.IsDead).ToString();
|
||||
derricks.GetText = () => world.ActorsHavingTrait<UpdatesDerrickCount>().Count(a => a.Owner == player && !a.IsDead).ToString(NumberFormatInfo.CurrentInfo);
|
||||
|
||||
return template;
|
||||
}
|
||||
@@ -491,19 +492,19 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (stats == null)
|
||||
return template;
|
||||
|
||||
var killsText = new CachedTransform<int, string>(i => i.ToString());
|
||||
var killsText = new CachedTransform<int, string>(i => i.ToString(NumberFormatInfo.CurrentInfo));
|
||||
template.Get<LabelWidget>("KILLS").GetText = () => killsText.Update(stats.UnitsKilled + stats.BuildingsKilled);
|
||||
|
||||
var deathsText = new CachedTransform<int, string>(i => i.ToString());
|
||||
var deathsText = new CachedTransform<int, string>(i => i.ToString(NumberFormatInfo.CurrentInfo));
|
||||
template.Get<LabelWidget>("DEATHS").GetText = () => deathsText.Update(stats.UnitsDead + stats.BuildingsDead);
|
||||
|
||||
var destroyedText = new CachedTransform<int, string>(i => "$" + i);
|
||||
var destroyedText = new CachedTransform<int, string>(i => "$" + i.ToString(NumberFormatInfo.CurrentInfo));
|
||||
template.Get<LabelWidget>("ASSETS_DESTROYED").GetText = () => destroyedText.Update(stats.KillsCost);
|
||||
|
||||
var lostText = new CachedTransform<int, string>(i => "$" + i);
|
||||
var lostText = new CachedTransform<int, string>(i => "$" + i.ToString(NumberFormatInfo.CurrentInfo));
|
||||
template.Get<LabelWidget>("ASSETS_LOST").GetText = () => lostText.Update(stats.DeathsCost);
|
||||
|
||||
var experienceText = new CachedTransform<int, string>(i => i.ToString());
|
||||
var experienceText = new CachedTransform<int, string>(i => i.ToString(NumberFormatInfo.CurrentInfo));
|
||||
template.Get<LabelWidget>("EXPERIENCE").GetText = () => experienceText.Update(stats.Experience);
|
||||
|
||||
var actionsText = new CachedTransform<double, string>(d => AverageOrdersPerMinute(d));
|
||||
@@ -573,12 +574,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
string AverageOrdersPerMinute(double orders)
|
||||
{
|
||||
return (world.WorldTick == 0 ? 0 : orders / (world.WorldTick / 1500.0)).ToString("F1");
|
||||
return (world.WorldTick == 0 ? 0 : orders / (world.WorldTick / 1500.0)).ToString("F1", NumberFormatInfo.CurrentInfo);
|
||||
}
|
||||
|
||||
string Vision(int revealedCells)
|
||||
{
|
||||
return Math.Ceiling(revealedCells / (float)world.Map.ProjectedCells.Length * 100).ToString("F0") + "%";
|
||||
return (Math.Ceiling(revealedCells * 100d / world.Map.ProjectedCells.Length) / 100).ToString("P0", NumberFormatInfo.CurrentInfo);
|
||||
}
|
||||
|
||||
static Color GetPowerColor(PowerState state)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Primitives;
|
||||
@@ -117,7 +118,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (pm != null)
|
||||
{
|
||||
var power = actor.TraitInfos<PowerInfo>().Where(i => i.EnabledByDefault).Sum(i => i.Amount);
|
||||
powerLabel.Text = power.ToString();
|
||||
powerLabel.Text = power.ToString(NumberFormatInfo.CurrentInfo);
|
||||
powerLabel.GetColor = () => (pm.PowerProvided - pm.PowerDrained >= -power || power > 0)
|
||||
? Color.White : Color.Red;
|
||||
powerLabel.Visible = power != 0;
|
||||
@@ -132,7 +133,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
timeLabel.TextColor = (pm != null && pm.PowerState != PowerState.Normal && tooltipIcon.ProductionQueue.Info.LowPowerModifier > 100) ? Color.Red : Color.White;
|
||||
var timeSize = font.Measure(timeLabel.Text);
|
||||
|
||||
costLabel.Text = cost.ToString();
|
||||
costLabel.Text = cost.ToString(NumberFormatInfo.CurrentInfo);
|
||||
costLabel.GetColor = () => pr.Cash + pr.Resources >= cost ? Color.White : Color.Red;
|
||||
var costSize = font.Measure(costLabel.Text);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
@@ -156,7 +157,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => client.Team == ii,
|
||||
() => orderManager.IssueOrder(Order.Command($"team {client.Index} {ii}")));
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString();
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString(NumberFormatInfo.CurrentInfo);
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -576,7 +577,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
dropdown.IsVisible = () => true;
|
||||
dropdown.IsDisabled = () => s.LockTeam || orderManager.LocalClient.IsReady;
|
||||
dropdown.OnMouseDown = _ => ShowTeamDropDown(dropdown, c, orderManager, map.PlayerCount);
|
||||
dropdown.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
||||
dropdown.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString(NumberFormatInfo.CurrentInfo);
|
||||
|
||||
HideChildWidget(parent, "TEAM");
|
||||
}
|
||||
@@ -585,7 +586,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var team = parent.Get<LabelWidget>("TEAM");
|
||||
team.IsVisible = () => true;
|
||||
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
||||
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString(NumberFormatInfo.CurrentInfo);
|
||||
HideChildWidget(parent, "TEAM_DROPDOWN");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -430,7 +431,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var authorDateTimeLabel = newsItem.Get<LabelWidget>("AUTHOR_DATETIME");
|
||||
var authorDateTime = TranslationProvider.GetString(AuthorDateTime, Translation.Arguments(
|
||||
"author", item.Author,
|
||||
"datetime", item.DateTime.ToLocalTime().ToString()));
|
||||
"datetime", item.DateTime.ToLocalTime().ToString(CultureInfo.CurrentCulture)));
|
||||
|
||||
authorDateTimeLabel.GetText = () => authorDateTime;
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
return;
|
||||
|
||||
var host = server.Address.Split(':')[0];
|
||||
var port = Exts.ParseIntegerInvariant(server.Address.Split(':')[1]);
|
||||
var port = Exts.ParseInt32Invariant(server.Address.Split(':')[1]);
|
||||
|
||||
ConnectionLogic.Connect(new ConnectionTarget(host, port), "", OpenLobby, DoNothing);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Primitives;
|
||||
@@ -136,7 +137,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
settings.Server.Name = serverName.Text;
|
||||
};
|
||||
|
||||
panel.Get<TextFieldWidget>("LISTEN_PORT").Text = settings.Server.ListenPort.ToString();
|
||||
panel.Get<TextFieldWidget>("LISTEN_PORT").Text = settings.Server.ListenPort.ToString(NumberFormatInfo.CurrentInfo);
|
||||
|
||||
advertiseOnline = Game.Settings.Server.AdvertiseOnline;
|
||||
|
||||
@@ -221,7 +222,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
void CreateAndJoin()
|
||||
{
|
||||
var name = Game.Settings.SanitizedServerName(panel.Get<TextFieldWidget>("SERVER_NAME").Text);
|
||||
if (!Exts.TryParseIntegerInvariant(panel.Get<TextFieldWidget>("LISTEN_PORT").Text, out var listenPort))
|
||||
if (!int.TryParse(panel.Get<TextFieldWidget>("LISTEN_PORT").Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out var listenPort))
|
||||
listenPort = 1234;
|
||||
|
||||
var passwordField = panel.GetOrNull<PasswordFieldWidget>("PASSWORD");
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (reloadIcon != null)
|
||||
{
|
||||
var disabledFrame = 0;
|
||||
var disabledImage = "disabled-" + disabledFrame.ToString();
|
||||
var disabledImage = "disabled-" + disabledFrame.ToStringInvariant();
|
||||
reloadIcon.GetImageName = () => searchStatus == SearchStatus.Fetching ? disabledImage : reloadIcon.ImageName;
|
||||
|
||||
var reloadTicker = reloadIcon.Get<LogicTickerWidget>("ANIMATION");
|
||||
@@ -309,7 +309,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
reloadTicker.OnTick = () =>
|
||||
{
|
||||
disabledFrame = searchStatus == SearchStatus.Fetching ? (disabledFrame + 1) % 12 : 0;
|
||||
disabledImage = "disabled-" + disabledFrame.ToString();
|
||||
disabledImage = "disabled-" + disabledFrame.ToStringInvariant();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
void ShowAudioDeviceDropdown(DropDownButtonWidget dropdown, SoundDevice[] devices, ScrollPanelWidget scrollPanel)
|
||||
{
|
||||
var i = 0;
|
||||
var options = devices.ToDictionary(d => i++.ToString(), d => d);
|
||||
var options = devices.ToDictionary(d => i++.ToStringInvariant(), d => d);
|
||||
|
||||
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
@@ -215,11 +216,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
panel.Get("DISPLAY_SELECTION_CONTAINER").IsVisible = () => ds.Mode != WindowMode.Windowed;
|
||||
panel.Get("WINDOW_RESOLUTION_CONTAINER").IsVisible = () => ds.Mode == WindowMode.Windowed;
|
||||
var windowWidth = panel.Get<TextFieldWidget>("WINDOW_WIDTH");
|
||||
var origWidthText = windowWidth.Text = ds.WindowedSize.X.ToString();
|
||||
var origWidthText = windowWidth.Text = ds.WindowedSize.X.ToString(NumberFormatInfo.CurrentInfo);
|
||||
|
||||
var windowHeight = panel.Get<TextFieldWidget>("WINDOW_HEIGHT");
|
||||
var origHeightText = windowHeight.Text = ds.WindowedSize.Y.ToString();
|
||||
windowHeight.Text = ds.WindowedSize.Y.ToString();
|
||||
var origHeightText = windowHeight.Text = ds.WindowedSize.Y.ToString(NumberFormatInfo.CurrentInfo);
|
||||
windowHeight.Text = ds.WindowedSize.Y.ToString(NumberFormatInfo.CurrentInfo);
|
||||
|
||||
var restartDesc = panel.Get("RESTART_REQUIRED_DESC");
|
||||
restartDesc.IsVisible = () => ds.Mode != OriginalGraphicsMode || ds.VideoDisplay != OriginalVideoDisplay || ds.GLProfile != OriginalGLProfile ||
|
||||
@@ -283,8 +284,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
return () =>
|
||||
{
|
||||
Exts.TryParseIntegerInvariant(windowWidth.Text, out var x);
|
||||
Exts.TryParseIntegerInvariant(windowHeight.Text, out var y);
|
||||
int.TryParse(windowWidth.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out var x);
|
||||
int.TryParse(windowHeight.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out var y);
|
||||
ds.WindowedSize = new int2(x, y);
|
||||
nameTextfield.YieldKeyboardFocus();
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
@@ -137,7 +138,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var bold = Game.Renderer.Fonts["TinyBold"];
|
||||
foreach (var armyIcon in armyIcons)
|
||||
{
|
||||
var text = armyIcon.Unit.Count.ToString();
|
||||
var text = armyIcon.Unit.Count.ToString(NumberFormatInfo.CurrentInfo);
|
||||
bold.DrawTextWithContrast(text, armyIcon.Bounds.Location + new float2(iconSize.X, 0) - new float2(bold.Measure(text).X, bold.TopOffset),
|
||||
Color.White, Color.Black, 1);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
@@ -201,7 +202,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
if (icon.Queued.Count > 1)
|
||||
{
|
||||
text = icon.Queued.Count.ToString();
|
||||
text = icon.Queued.Count.ToString(NumberFormatInfo.CurrentInfo);
|
||||
bold.DrawTextWithContrast(text, icon.Pos + new float2(16, 0) - new float2(bold.Measure(text).X / 2, 0),
|
||||
Color.White, Color.Black, 1);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Lint;
|
||||
@@ -146,7 +147,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (string.IsNullOrEmpty(prefix))
|
||||
emitError($"{widgetNode.Location} must define HotkeyPrefix if HotkeyCount > 0.");
|
||||
|
||||
return Exts.MakeArray(count, i => prefix + (i + 1).ToString("D2"));
|
||||
return Exts.MakeArray(count, i => prefix + (i + 1).ToStringInvariant("D2"));
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
@@ -169,7 +170,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
cantBuild = new Animation(World, NotBuildableAnimation);
|
||||
cantBuild.PlayFetchIndex(NotBuildableSequence, () => 0);
|
||||
hotkeys = Exts.MakeArray(HotkeyCount,
|
||||
i => modData.Hotkeys[HotkeyPrefix + (i + 1).ToString("D2")]);
|
||||
i => modData.Hotkeys[HotkeyPrefix + (i + 1).ToStringInvariant("D2")]);
|
||||
|
||||
overlayFont = Game.Renderer.Fonts[OverlayFont];
|
||||
Game.Renderer.Fonts.TryGetValue(SymbolsFont, out symbolFont);
|
||||
@@ -584,14 +585,14 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var pos = QueuedOffset;
|
||||
if (QueuedTextAlign != TextAlign.Left)
|
||||
{
|
||||
var size = overlayFont.Measure(total.ToString());
|
||||
var size = overlayFont.Measure(total.ToString(NumberFormatInfo.CurrentInfo));
|
||||
|
||||
pos = QueuedTextAlign == TextAlign.Center ?
|
||||
new float2(QueuedOffset.X - size.X / 2, QueuedOffset.Y) :
|
||||
new float2(QueuedOffset.X - size.X, QueuedOffset.Y);
|
||||
}
|
||||
|
||||
overlayFont.DrawTextWithContrast(total.ToString(),
|
||||
overlayFont.DrawTextWithContrast(total.ToString(NumberFormatInfo.CurrentInfo),
|
||||
icon.Pos + pos,
|
||||
TextColor, Color.Black, 1);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
@@ -46,7 +47,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
tabs.Add(t);
|
||||
queues.Remove(t.Queue);
|
||||
largestUsedName = Math.Max(int.Parse(t.Name), largestUsedName);
|
||||
largestUsedName = Math.Max(int.Parse(t.Name, NumberFormatInfo.CurrentInfo), largestUsedName);
|
||||
}
|
||||
|
||||
NextQueueName = largestUsedName + 1;
|
||||
@@ -55,7 +56,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
foreach (var queue in queues)
|
||||
tabs.Add(new ProductionTab()
|
||||
{
|
||||
Name = NextQueueName++.ToString(),
|
||||
Name = NextQueueName++.ToString(NumberFormatInfo.CurrentInfo),
|
||||
Queue = queue
|
||||
});
|
||||
Tabs = tabs;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
var self = p.Instances[0].Self;
|
||||
var time = WidgetUtils.FormatTime(p.RemainingTicks, false, self.World.Timestep);
|
||||
var text = string.Format(Format, self.Owner.PlayerName, p.Info.Name, time);
|
||||
var text = Format.FormatCurrent(self.Owner.PlayerName, p.Info.Name, time);
|
||||
var playerColor = self.Owner.Color;
|
||||
|
||||
if (Game.Settings.Game.UsePlayerStanceColors)
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (string.IsNullOrEmpty(prefix))
|
||||
emitError($"{widgetNode.Location} must define HotkeyPrefix if HotkeyCount > 0.");
|
||||
|
||||
return Exts.MakeArray(count, i => prefix + (i + 1).ToString("D2"));
|
||||
return Exts.MakeArray(count, i => prefix + (i + 1).ToStringInvariant("D2"));
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
base.Initialize(args);
|
||||
|
||||
hotkeys = Exts.MakeArray(HotkeyCount,
|
||||
i => modData.Hotkeys[HotkeyPrefix + (i + 1).ToString("D2")]);
|
||||
i => modData.Hotkeys[HotkeyPrefix + (i + 1).ToStringInvariant("D2")]);
|
||||
|
||||
overlayFont = Game.Renderer.Fonts[OverlayFont];
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var suffix = (i + 1).ToString("D2");
|
||||
var suffix = (i + 1).ToStringInvariant("D2");
|
||||
yield return savePrefix + suffix;
|
||||
yield return restorePrefix + suffix;
|
||||
}
|
||||
@@ -153,10 +153,10 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
base.Initialize(args);
|
||||
|
||||
saveBookmarkHotkeys = Exts.MakeArray(BookmarkKeyCount,
|
||||
i => modData.Hotkeys[BookmarkSaveKeyPrefix + (i + 1).ToString("D2")]);
|
||||
i => modData.Hotkeys[BookmarkSaveKeyPrefix + (i + 1).ToStringInvariant("D2")]);
|
||||
|
||||
restoreBookmarkHotkeys = Exts.MakeArray(BookmarkKeyCount,
|
||||
i => modData.Hotkeys[BookmarkRestoreKeyPrefix + (i + 1).ToString("D2")]);
|
||||
i => modData.Hotkeys[BookmarkRestoreKeyPrefix + (i + 1).ToStringInvariant("D2")]);
|
||||
|
||||
bookmarkPositions = new WPos?[BookmarkKeyCount];
|
||||
}
|
||||
|
||||
@@ -751,7 +751,7 @@ namespace OpenRA.Platforms.Default
|
||||
return;
|
||||
|
||||
string errorText;
|
||||
errorText = ErrorToText.TryGetValue(type, out errorText) ? errorText : type.ToString("X");
|
||||
errorText = ErrorToText.TryGetValue(type, out errorText) ? errorText : type.ToStringInvariant("X");
|
||||
var error = $"GL Error: {errorText}\n{new StackTrace()}";
|
||||
|
||||
WriteGraphicsLog(error);
|
||||
@@ -788,9 +788,9 @@ namespace OpenRA.Platforms.Default
|
||||
string typeText;
|
||||
string severityText;
|
||||
|
||||
sourceText = DebugSourceToText.TryGetValue(source, out sourceText) ? sourceText : source.ToString("X");
|
||||
typeText = DebugTypeToText.TryGetValue(type, out typeText) ? typeText : type.ToString("X");
|
||||
severityText = DebugSeverityToText.TryGetValue(severity, out severityText) ? severityText : severity.ToString("X");
|
||||
sourceText = DebugSourceToText.TryGetValue(source, out sourceText) ? sourceText : source.ToStringInvariant("X");
|
||||
typeText = DebugTypeToText.TryGetValue(type, out typeText) ? typeText : type.ToStringInvariant("X");
|
||||
severityText = DebugSeverityToText.TryGetValue(severity, out severityText) ? severityText : severity.ToStringInvariant("X");
|
||||
var messageText = message.ToString();
|
||||
|
||||
return $"{severityText} - GL Debug {sourceText} Output: {typeText} - {messageText}\n{new StackTrace()}";
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
@@ -113,7 +114,7 @@ namespace OpenRA.Server
|
||||
|
||||
static void WriteLineWithTimeStamp(string line)
|
||||
{
|
||||
Console.WriteLine($"[{DateTime.Now.ToString(Game.Settings.Server.TimestampFormat)}] {line}");
|
||||
Console.WriteLine($"[{DateTime.Now.ToString(Game.Settings.Server.TimestampFormat, CultureInfo.CurrentCulture)}] {line}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user