Fix IDE0039
This commit is contained in:
@@ -156,7 +156,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var i = 0;
|
||||
var options = devices.ToDictionary(d => i++.ToString(), d => d);
|
||||
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => soundDevice == options[o],
|
||||
@@ -171,9 +171,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var label = WidgetUtils.TruncateText(options[o].Label, deviceLabel.Bounds.Width, font);
|
||||
deviceLabel.GetText = () => label;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ modData.Translation.GetString(Windowed), WindowMode.Windowed },
|
||||
};
|
||||
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => s.Mode == options[o],
|
||||
@@ -354,31 +354,31 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||
}
|
||||
|
||||
public static void BindTextNotificationPoolFilterSettings(Widget panel, GameSettings gs)
|
||||
{
|
||||
Action<TextNotificationPoolFilters> toggleFilterFlag = f =>
|
||||
void ToggleFilterFlag(TextNotificationPoolFilters f)
|
||||
{
|
||||
gs.TextNotificationPoolFilters ^= f;
|
||||
Game.Settings.Save();
|
||||
};
|
||||
}
|
||||
|
||||
var feedbackCheckbox = panel.GetOrNull<CheckboxWidget>("UI_FEEDBACK_CHECKBOX");
|
||||
if (feedbackCheckbox != null)
|
||||
{
|
||||
feedbackCheckbox.IsChecked = () => gs.TextNotificationPoolFilters.HasFlag(TextNotificationPoolFilters.Feedback);
|
||||
feedbackCheckbox.OnClick = () => toggleFilterFlag(TextNotificationPoolFilters.Feedback);
|
||||
feedbackCheckbox.OnClick = () => ToggleFilterFlag(TextNotificationPoolFilters.Feedback);
|
||||
}
|
||||
|
||||
var transientsCheckbox = panel.GetOrNull<CheckboxWidget>("TRANSIENTS_CHECKBOX");
|
||||
if (transientsCheckbox != null)
|
||||
{
|
||||
transientsCheckbox.IsChecked = () => gs.TextNotificationPoolFilters.HasFlag(TextNotificationPoolFilters.Transients);
|
||||
transientsCheckbox.OnClick = () => toggleFilterFlag(TextNotificationPoolFilters.Transients);
|
||||
transientsCheckbox.OnClick = () => ToggleFilterFlag(TextNotificationPoolFilters.Transients);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ modData.Translation.GetString(AlwaysShow), StatusBarsType.AlwaysShow },
|
||||
};
|
||||
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => s.StatusBars == options[o],
|
||||
@@ -399,14 +399,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||
}
|
||||
|
||||
static void ShowDisplaySelectionDropdown(DropDownButtonWidget dropdown, GraphicSettings s)
|
||||
{
|
||||
Func<int, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
ScrollItemWidget SetupItem(int o, ScrollItemWidget itemTemplate)
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => s.VideoDisplay == o,
|
||||
@@ -415,14 +415,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var label = $"Display {o + 1}";
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, Enumerable.Range(0, Game.Renderer.DisplayCount), setupItem);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, Enumerable.Range(0, Game.Renderer.DisplayCount), SetupItem);
|
||||
}
|
||||
|
||||
static void ShowGLProfileDropdown(DropDownButtonWidget dropdown, GraphicSettings s)
|
||||
{
|
||||
Func<GLProfile, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
ScrollItemWidget SetupItem(GLProfile o, ScrollItemWidget itemTemplate)
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => s.GLProfile == o,
|
||||
@@ -431,10 +431,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var label = o.ToString();
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
var profiles = new[] { GLProfile.Automatic }.Concat(Game.Renderer.SupportedGLProfiles);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, profiles, setupItem);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, profiles, SetupItem);
|
||||
}
|
||||
|
||||
static void ShowTargetLinesDropdown(ModData modData, DropDownButtonWidget dropdown, GameSettings s)
|
||||
@@ -446,7 +446,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ modData.Translation.GetString(Disabled), TargetLinesType.Disabled },
|
||||
};
|
||||
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => s.TargetLines == options[o],
|
||||
@@ -454,14 +454,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||
}
|
||||
|
||||
public static void ShowBattlefieldCameraDropdown(ModData modData, DropDownButtonWidget dropdown, WorldViewportSizes viewportSizes, GraphicSettings gs)
|
||||
{
|
||||
Func<WorldViewport, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
ScrollItemWidget SetupItem(WorldViewport o, ScrollItemWidget itemTemplate)
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => gs.ViewportDistance == o,
|
||||
@@ -470,7 +470,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var label = GetViewportSizeName(modData, o);
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
var windowHeight = Game.Renderer.NativeResolution.Height;
|
||||
|
||||
@@ -485,7 +485,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (viewportSizes.AllowNativeZoom && farRange.Y < windowHeight)
|
||||
validSizes.Add(WorldViewport.Native);
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, validSizes, setupItem);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, validSizes, SetupItem);
|
||||
}
|
||||
|
||||
static void RecalculateWidgetLayout(Widget w, bool insideScrollPanel = false)
|
||||
@@ -533,7 +533,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
public static void ShowUIScaleDropdown(DropDownButtonWidget dropdown, GraphicSettings gs)
|
||||
{
|
||||
Func<float, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
ScrollItemWidget SetupItem(float o, ScrollItemWidget itemTemplate)
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => gs.UIScale == o,
|
||||
@@ -553,14 +553,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var label = $"{(int)(100 * o)}%";
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
var viewportSizes = Game.ModData.Manifest.Get<WorldViewportSizes>();
|
||||
var maxScales = new float2(Game.Renderer.NativeResolution) / new float2(viewportSizes.MinEffectiveResolution);
|
||||
var maxScale = Math.Min(maxScales.X, maxScales.Y);
|
||||
|
||||
var validScales = new[] { 1f, 1.25f, 1.5f, 1.75f, 2f }.Where(x => x <= maxScale);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, validScales, setupItem);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, validScales, SetupItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,16 +170,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ modData.Translation.GetString(Modern), false },
|
||||
};
|
||||
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => s.UseClassicMouseStyle == options[o],
|
||||
() => s.UseClassicMouseStyle = options[o]);
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||
}
|
||||
|
||||
static void ShowMouseScrollDropdown(ModData modData, DropDownButtonWidget dropdown, GameSettings s)
|
||||
@@ -192,16 +192,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ modData.Translation.GetString(Joystick), MouseScrollType.Joystick },
|
||||
};
|
||||
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => s.MouseScroll == options[o],
|
||||
() => s.MouseScroll = options[o]);
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||
}
|
||||
|
||||
static void ShowZoomModifierDropdown(ModData modData, DropDownButtonWidget dropdown, GameSettings s)
|
||||
@@ -215,16 +215,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ modData.Translation.GetString(None), Modifiers.None }
|
||||
};
|
||||
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => s.ZoomModifier == options[o],
|
||||
() => s.ZoomModifier = options[o]);
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||
}
|
||||
|
||||
static void MakeMouseFocusSettingsLive()
|
||||
|
||||
@@ -105,46 +105,46 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var current = Game.Settings;
|
||||
current.Save();
|
||||
|
||||
Action closeAndExit = () => { Ui.CloseWindow(); onExit(); };
|
||||
void CloseAndExit() { Ui.CloseWindow(); onExit(); }
|
||||
if (needsRestart)
|
||||
{
|
||||
Action noRestart = () => ConfirmationDialogs.ButtonPrompt(modData,
|
||||
void NoRestart() => ConfirmationDialogs.ButtonPrompt(modData,
|
||||
title: SettingsSaveTitle,
|
||||
text: SettingsSavePrompt,
|
||||
onCancel: closeAndExit,
|
||||
onCancel: CloseAndExit,
|
||||
cancelText: SettingsSaveCancel);
|
||||
|
||||
if (!Game.ExternalMods.TryGetValue(ExternalMod.MakeKey(Game.ModData.Manifest), out var external))
|
||||
{
|
||||
noRestart();
|
||||
NoRestart();
|
||||
return;
|
||||
}
|
||||
|
||||
ConfirmationDialogs.ButtonPrompt(modData,
|
||||
title: RestartTitle,
|
||||
text: RestartPrompt,
|
||||
onConfirm: () => Game.SwitchToExternalMod(external, null, noRestart),
|
||||
onCancel: closeAndExit,
|
||||
onConfirm: () => Game.SwitchToExternalMod(external, null, NoRestart),
|
||||
onCancel: CloseAndExit,
|
||||
confirmText: RestartAccept,
|
||||
cancelText: RestartCancel);
|
||||
}
|
||||
else
|
||||
closeAndExit();
|
||||
CloseAndExit();
|
||||
};
|
||||
|
||||
widget.Get<ButtonWidget>("RESET_BUTTON").OnClick = () =>
|
||||
{
|
||||
Action reset = () =>
|
||||
void Reset()
|
||||
{
|
||||
resetPanelActions[activePanel]();
|
||||
Game.Settings.Save();
|
||||
};
|
||||
}
|
||||
|
||||
ConfirmationDialogs.ButtonPrompt(modData,
|
||||
title: ResetTitle,
|
||||
titleArguments: Translation.Arguments("panel", panels[activePanel]),
|
||||
text: ResetPrompt,
|
||||
onConfirm: reset,
|
||||
onConfirm: Reset,
|
||||
onCancel: () => { },
|
||||
confirmText: ResetAccept,
|
||||
cancelText: ResetCancel);
|
||||
|
||||
Reference in New Issue
Block a user