Replace F extension with string interpolation

This commit is contained in:
teinarss
2021-04-24 17:46:24 +02:00
committed by reaperrr
parent 1385aca783
commit 10676be377
300 changed files with 752 additions and 799 deletions

View File

@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var displaySelectionDropDown = panel.Get<DropDownButtonWidget>("DISPLAY_SELECTION_DROPDOWN");
displaySelectionDropDown.OnMouseDown = _ => ShowDisplaySelectionDropdown(displaySelectionDropDown, ds);
var displaySelectionLabel = new CachedTransform<int, string>(i => "Display {0}".F(i + 1));
var displaySelectionLabel = new CachedTransform<int, string>(i => $"Display {i + 1}");
displaySelectionDropDown.GetText = () => displaySelectionLabel.Update(ds.VideoDisplay);
displaySelectionDropDown.IsDisabled = () => Game.Renderer.DisplayCount < 2;
@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
};
var uiScaleDropdown = panel.Get<DropDownButtonWidget>("UI_SCALE_DROPDOWN");
var uiScaleLabel = new CachedTransform<float, string>(s => "{0}%".F((int)(100 * s)));
var uiScaleLabel = new CachedTransform<float, string>(s => $"{(int)(100 * s)}%");
uiScaleDropdown.OnMouseDown = _ => ShowUIScaleDropdown(uiScaleDropdown, ds);
uiScaleDropdown.GetText = () => uiScaleLabel.Update(ds.UIScale);
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var frameLimitCheckbox = panel.Get<CheckboxWidget>("FRAME_LIMIT_CHECKBOX");
var frameLimitOrigLabel = frameLimitCheckbox.Text;
var frameLimitLabel = new CachedTransform<int, string>(fps => frameLimitOrigLabel + " ({0} FPS)".F(fps));
var frameLimitLabel = new CachedTransform<int, string>(fps => frameLimitOrigLabel + $" ({fps} FPS)");
frameLimitCheckbox.GetText = () => frameLimitLabel.Update(ds.MaxFramerate);
// Player profile
@@ -285,7 +285,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
() => s.VideoDisplay == o,
() => s.VideoDisplay = o);
var label = "Display {0}".F(o + 1);
var label = $"Display {o + 1}";
item.Get<LabelWidget>("LABEL").GetText = () => label;
return item;
};
@@ -421,7 +421,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
});
});
var label = "{0}%".F((int)(100 * o));
var label = $"{(int)(100 * o)}%";
item.Get<LabelWidget>("LABEL").GetText = () => label;
return item;
};

View File

@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
};
ConfirmationDialogs.ButtonPrompt(
title: "Reset \"{0}\"".F(panels[activePanel]),
title: $"Reset \"{panels[activePanel]}\"",
text: "Are you sure you want to reset\nall settings in this panel?",
onConfirm: reset,
onCancel: () => { },

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
var field = group.GetType().GetField(pref);
if (field == null)
throw new InvalidOperationException("{0} does not contain a preference type {1}".F(group.GetType().Name, pref));
throw new InvalidOperationException($"{group.GetType().Name} does not contain a preference type {pref}");
var cb = parent.Get<CheckboxWidget>(id);
cb.IsChecked = () => (bool)field.GetValue(group);
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
var field = group.GetType().GetField(pref);
if (field == null)
throw new InvalidOperationException("{0} does not contain a preference type {1}".F(group.GetType().Name, pref));
throw new InvalidOperationException($"{group.GetType().Name} does not contain a preference type {pref}");
var ss = parent.Get<SliderWidget>(id);
ss.Value = (float)field.GetValue(group);
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
var field = group.GetType().GetField(pref);
if (field == null)
throw new InvalidOperationException("{0} does not contain a preference type {1}".F(group.GetType().Name, pref));
throw new InvalidOperationException($"{group.GetType().Name} does not contain a preference type {pref}");
var ss = parent.Get<SliderWidget>(id);
ss.Value = (float)(int)field.GetValue(group);