Fix CA1305

This commit is contained in:
RoosterDragon
2023-03-12 15:08:23 +00:00
committed by Matthias Mailänder
parent 486a07602b
commit d83e579dfe
71 changed files with 287 additions and 219 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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;

View File

@@ -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);
}
}
}

View File

@@ -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;

View File

@@ -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));
}
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);
}
}
}

View File

@@ -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);

View File

@@ -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();

View File

@@ -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
})
});

View File

@@ -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
})
});

View File

@@ -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
})
});

View File

@@ -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)

View File

@@ -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)

View File

@@ -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);

View File

@@ -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();

View File

@@ -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;

View File

@@ -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));

View File

@@ -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);

View File

@@ -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");

View File

@@ -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);
}
}
}

View File

@@ -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,

View File

@@ -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));
};
}
}

View File

@@ -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)

View File

@@ -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);

View File

@@ -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");
}

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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");

View File

@@ -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();
};
}
}

View File

@@ -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)
{

View File

@@ -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();

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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)

View File

@@ -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];

View File

@@ -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];
}