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

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