Fix IDE0090

This commit is contained in:
RoosterDragon
2023-04-05 19:34:12 +01:00
committed by Pavel Penev
parent 164abfdae1
commit 8a285f9b19
385 changed files with 790 additions and 794 deletions

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Widgets
public readonly string TooltipContainer;
public readonly string TooltipTemplate = "BUTTON_TOOLTIP";
public HotkeyReference Key = new HotkeyReference();
public HotkeyReference Key = new();
public bool DisableKeyRepeat = false;
public bool DisableKeySound = false;

View File

@@ -24,8 +24,7 @@ namespace OpenRA.Mods.Common.Widgets
public Func<bool> IsChecked = () => false;
readonly CachedTransform<(string, bool), CachedTransform<(bool, bool, bool, bool, bool), Sprite>> getCheckmarkImageCache
= new CachedTransform<(string, bool), CachedTransform<(bool, bool, bool, bool, bool), Sprite>>(
((string CheckType, bool Checked) args) =>
= new(((string CheckType, bool Checked) args) =>
{
var variantImageCollection = "checkmark-" + args.CheckType;
var variantBaseName = args.Checked ? "checked" : "unchecked";

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Widgets
readonly Lazy<TooltipContainerWidget> tooltipContainer;
public Func<string> GetTooltipText;
readonly CachedTransform<(string, string), Sprite> getImageCache = new CachedTransform<(string, string), Sprite>(
readonly CachedTransform<(string, string), Sprite> getImageCache = new(
((string collection, string image) args) => ChromeProvider.GetImage(args.collection, args.image));
public ImageWidget()

View File

@@ -430,7 +430,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
currentFrame = currentSprites.Length - 1;
}
readonly Dictionary<string, bool> assetVisByName = new Dictionary<string, bool>();
readonly Dictionary<string, bool> assetVisByName = new();
bool FilterAsset(string filename)
{

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly BackgroundWidget actorEditPanel;
readonly LabelWidget typeLabel;
readonly TextFieldWidget actorIDField;
readonly HashSet<TextFieldWidget> typableFields = new HashSet<TextFieldWidget>();
readonly HashSet<TextFieldWidget> typableFields = new();
readonly LabelWidget actorIDErrorLabel;
readonly Widget initContainer;
@@ -505,7 +505,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
readonly EditorActorPreview actor;
readonly SetActorIdAction setActorIdAction;
readonly List<IEditActorHandle> handles = new List<IEditActorHandle>();
readonly List<IEditActorHandle> handles = new();
public EditActorPreview(EditorActorPreview actor)
{

View File

@@ -40,8 +40,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
protected readonly ScrollPanelWidget Panel;
protected readonly ScrollItemWidget ItemTemplate;
protected readonly HashSet<string> SelectedCategories = new HashSet<string>();
protected readonly List<string> FilteredCategories = new List<string>();
protected readonly HashSet<string> SelectedCategories = new();
protected readonly List<string> FilteredCategories = new();
protected string[] allCategories;
protected string searchFilter;

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly EditorActionManager editorActionManager;
readonly ScrollItemWidget template;
readonly Dictionary<EditorActionContainer, ScrollItemWidget> states = new Dictionary<EditorActionContainer, ScrollItemWidget>();
readonly Dictionary<EditorActionContainer, ScrollItemWidget> states = new();
[ObjectCreator.UseCtor]
public HistoryLogLogic(Widget widget, World world)

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly Widget panel;
readonly ScrollPanelWidget gameList;
readonly TextFieldWidget saveTextField;
readonly List<string> games = new List<string>();
readonly List<string> games = new();
readonly Action onStart;
readonly Action onExit;
readonly ModData modData;

View File

@@ -46,9 +46,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly TextFieldWidget chatText;
readonly CachedTransform<int, string> chatAvailableIn;
readonly string chatDisabled;
readonly Dictionary<TextNotificationPool, Widget> templates = new Dictionary<TextNotificationPool, Widget>();
readonly Dictionary<TextNotificationPool, Widget> templates = new();
readonly TabCompletionLogic tabCompletion = new TabCompletionLogic();
readonly TabCompletionLogic tabCompletion = new();
readonly string chatLineSound = ChromeMetrics.Get<string>("ChatLineSound");

View File

@@ -121,7 +121,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly Widget buttonContainer;
readonly ButtonWidget buttonTemplate;
readonly int2 buttonStride;
readonly List<ButtonWidget> buttons = new List<ButtonWidget>();
readonly List<ButtonWidget> buttons = new();
readonly ModData modData;
readonly Action onExit;

View File

@@ -45,8 +45,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly IOrderedEnumerable<IGrouping<int, CameraOption>> teams;
readonly bool limitViews;
readonly HotkeyReference combinedViewKey = new HotkeyReference();
readonly HotkeyReference worldViewKey = new HotkeyReference();
readonly HotkeyReference combinedViewKey = new();
readonly HotkeyReference worldViewKey = new();
readonly World world;

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
enum PlaybackSpeed { Regular, Slow, Fast, Maximum }
readonly Dictionary<PlaybackSpeed, float> multipliers = new Dictionary<PlaybackSpeed, float>()
readonly Dictionary<PlaybackSpeed, float> multipliers = new()
{
{ PlaybackSpeed.Regular, 1 },
{ PlaybackSpeed.Slow, 2 },

View File

@@ -28,8 +28,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly ScrollPanelWidget scrollPanel;
readonly Widget template;
readonly Dictionary<string, ModContent.ModSource> sources = new Dictionary<string, ModContent.ModSource>();
readonly Dictionary<string, ModContent.ModDownload> downloads = new Dictionary<string, ModContent.ModDownload>();
readonly Dictionary<string, ModContent.ModSource> sources = new();
readonly Dictionary<string, ModContent.ModDownload> downloads = new();
bool sourceAvailable;

View File

@@ -81,18 +81,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly Widget newSpectatorTemplate;
readonly ScrollPanelWidget lobbyChatPanel;
readonly Dictionary<TextNotificationPool, Widget> chatTemplates = new Dictionary<TextNotificationPool, Widget>();
readonly Dictionary<TextNotificationPool, Widget> chatTemplates = new();
readonly TextFieldWidget chatTextField;
readonly CachedTransform<int, string> chatAvailableIn;
readonly string chatDisabled;
readonly ScrollPanelWidget players;
readonly Dictionary<string, LobbyFaction> factions = new Dictionary<string, LobbyFaction>();
readonly Dictionary<string, LobbyFaction> factions = new();
readonly ColorPickerManagerInfo colorManager;
readonly TabCompletionLogic tabCompletion = new TabCompletionLogic();
readonly TabCompletionLogic tabCompletion = new();
MapPreview map;
Session.MapStatus mapStatus;
@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
bool insufficientPlayerSpawns;
bool teamChat;
bool updateDiscordStatus = true;
Dictionary<int, SpawnOccupant> spawnOccupants = new Dictionary<int, SpawnOccupant>();
Dictionary<int, SpawnOccupant> spawnOccupants = new();
readonly string chatLineSound = ChromeMetrics.Get<string>("ChatLineSound");

View File

@@ -77,9 +77,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
MapClassification currentTab;
readonly Dictionary<MapClassification, ScrollPanelWidget> scrollpanels = new Dictionary<MapClassification, ScrollPanelWidget>();
readonly Dictionary<MapClassification, ScrollPanelWidget> scrollpanels = new();
readonly Dictionary<MapClassification, MapPreview[]> tabMaps = new Dictionary<MapClassification, MapPreview[]>();
readonly Dictionary<MapClassification, MapPreview[]> tabMaps = new();
string[] visibleMaps;
string selectedUid;

View File

@@ -103,13 +103,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
[TranslationReference]
const string Defeat = "options-winstate.defeat";
static Filter filter = new Filter();
static Filter filter = new();
readonly Widget panel;
readonly ScrollPanelWidget replayList, playerList;
readonly ScrollItemWidget playerTemplate, playerHeader;
readonly List<ReplayMetadata> replays = new List<ReplayMetadata>();
readonly Dictionary<ReplayMetadata, ReplayState> replayState = new Dictionary<ReplayMetadata, ReplayState>();
readonly List<ReplayMetadata> replays = new();
readonly Dictionary<ReplayMetadata, ReplayState> replayState = new();
readonly Action onStart;
readonly ModData modData;
readonly WebServices services;

View File

@@ -32,8 +32,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
bool isHotkeyDefault;
string currentContext = "Any";
readonly HashSet<string> contexts = new HashSet<string>() { "Any" };
readonly Dictionary<string, HashSet<string>> hotkeyGroups = new Dictionary<string, HashSet<string>>();
readonly HashSet<string> contexts = new() { "Any" };
readonly Dictionary<string, HashSet<string>> hotkeyGroups = new();
TextFieldWidget filterInput;
Widget headerTemplate;

View File

@@ -52,14 +52,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
[TranslationReference]
const string ResetCancel = "dialog-settings-reset.cancel";
readonly Dictionary<string, Func<bool>> leavePanelActions = new Dictionary<string, Func<bool>>();
readonly Dictionary<string, Action> resetPanelActions = new Dictionary<string, Action>();
readonly Dictionary<string, Func<bool>> leavePanelActions = new();
readonly Dictionary<string, Action> resetPanelActions = new();
readonly Widget panelContainer, tabContainer;
readonly ButtonWidget tabTemplate;
readonly int2 buttonStride;
readonly List<ButtonWidget> buttons = new List<ButtonWidget>();
readonly Dictionary<string, string> panels = new Dictionary<string, string>();
readonly List<ButtonWidget> buttons = new();
readonly Dictionary<string, string> panels = new();
string activePanel;
bool needsRestart = false;

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Widgets
{
public class LogicKeyListenerWidget : Widget
{
readonly List<Func<KeyInput, bool>> handlers = new List<Func<KeyInput, bool>>();
readonly List<Func<KeyInput, bool>> handlers = new();
public override bool HandleKeyPress(KeyInput e)
{

View File

@@ -39,9 +39,9 @@ namespace OpenRA.Mods.Common.Widgets
public readonly string TooltipContainer;
readonly Lazy<TooltipContainerWidget> tooltipContainer;
readonly List<ArmyIcon> armyIcons = new List<ArmyIcon>();
readonly List<ArmyIcon> armyIcons = new();
readonly CachedTransform<Player, PlayerStatistics> stats = new CachedTransform<Player, PlayerStatistics>(player => player.PlayerActor.TraitOrDefault<PlayerStatistics>());
readonly CachedTransform<Player, PlayerStatistics> stats = new(player => player.PlayerActor.TraitOrDefault<PlayerStatistics>());
int lastIconIdx;
int currentTooltipToken;

View File

@@ -41,8 +41,8 @@ namespace OpenRA.Mods.Common.Widgets
readonly Dictionary<ProductionQueue, Animation> clocks;
readonly Lazy<TooltipContainerWidget> tooltipContainer;
readonly List<ProductionIcon> productionIcons = new List<ProductionIcon>();
readonly List<Rectangle> productionIconsBounds = new List<Rectangle>();
readonly List<ProductionIcon> productionIcons = new();
readonly List<Rectangle> productionIconsBounds = new();
readonly float2 iconSize;
int lastIconIdx;

View File

@@ -41,8 +41,8 @@ namespace OpenRA.Mods.Common.Widgets
public string ClockPalette = "chrome";
public Func<Player> GetPlayer;
readonly List<SupportPowersWidget.SupportPowerIcon> supportPowerIconsIcons = new List<SupportPowersWidget.SupportPowerIcon>();
readonly List<Rectangle> supportPowerIconsBounds = new List<Rectangle>();
readonly List<SupportPowersWidget.SupportPowerIcon> supportPowerIconsIcons = new();
readonly List<Rectangle> supportPowerIconsBounds = new();
Animation icon;
int lastIconIdx;
int currentTooltipToken;

View File

@@ -44,11 +44,11 @@ namespace OpenRA.Mods.Common.Widgets
public readonly Color TextColor = Color.White;
public readonly Color ReadyTextAltColor = Color.Gold;
public readonly int Columns = 3;
public readonly int2 IconSize = new int2(64, 48);
public readonly int2 IconSize = new(64, 48);
public readonly int2 IconMargin = int2.Zero;
public readonly int2 IconSpriteOffset = int2.Zero;
public readonly float2 QueuedOffset = new float2(4, 2);
public readonly float2 QueuedOffset = new(4, 2);
public readonly TextAlign QueuedTextAlign = TextAlign.Left;
public readonly string ClickSound = ChromeMetrics.Get<string>("ClickSound");
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Widgets
// Note: LinterHotkeyNames assumes that these are disabled by default
public readonly string HotkeyPrefix = null;
public readonly int HotkeyCount = 0;
public readonly HotkeyReference SelectProductionBuildingHotkey = new HotkeyReference();
public readonly HotkeyReference SelectProductionBuildingHotkey = new();
public readonly string ClockAnimation = "clock";
public readonly string ClockSequence = "idle";
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.Common.Widgets
}
public override Rectangle EventBounds => eventBounds;
Dictionary<Rectangle, ProductionIcon> icons = new Dictionary<Rectangle, ProductionIcon>();
Dictionary<Rectangle, ProductionIcon> icons = new();
Animation cantBuild;
Animation clock;
Rectangle eventBounds = Rectangle.Empty;

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Widgets
public class ProductionTabGroup
{
public List<ProductionTab> Tabs = new List<ProductionTab>();
public List<ProductionTab> Tabs = new();
public string Group;
public int NextQueueName = 1;
public bool Alert { get { return Tabs.Any(t => t.Queue.AllQueued().Any(i => i.Done)); } }
@@ -76,8 +76,8 @@ namespace OpenRA.Mods.Common.Widgets
public readonly string ClickSound = ChromeMetrics.Get<string>("ClickSound");
public readonly string ClickDisabledSound = ChromeMetrics.Get<string>("ClickDisabledSound");
public readonly HotkeyReference PreviousProductionTabKey = new HotkeyReference();
public readonly HotkeyReference NextProductionTabKey = new HotkeyReference();
public readonly HotkeyReference PreviousProductionTabKey = new();
public readonly HotkeyReference NextProductionTabKey = new();
public readonly Dictionary<string, ProductionTabGroup> Groups;

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Widgets
{
public string Background = "progressbar-bg";
public string Bar = "progressbar-thumb";
public Size BarMargin = new Size(2, 2);
public Size BarMargin = new(2, 2);
public int Percentage = 0;
public bool Indeterminate = false;

View File

@@ -31,8 +31,8 @@ namespace OpenRA.Mods.Common.Widgets
public Func<float> GetProvided = () => 0;
public Func<float> GetUsed = () => 0;
public Func<Color> GetBarColor = () => Color.White;
readonly EWMA providedLerp = new EWMA(0.3f);
readonly EWMA usedLerp = new EWMA(0.3f);
readonly EWMA providedLerp = new(0.3f);
readonly EWMA usedLerp = new(0.3f);
readonly World world;
Sprite indicator;

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Widgets
public readonly string OverlayFont = "TinyBold";
public readonly int2 IconSize = new int2(64, 48);
public readonly int2 IconSize = new(64, 48);
public readonly int IconMargin = 10;
public readonly int2 IconSpriteOffset = int2.Zero;
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Widgets
Animation icon;
Animation clock;
Dictionary<Rectangle, SupportPowerIcon> icons = new Dictionary<Rectangle, SupportPowerIcon>();
Dictionary<Rectangle, SupportPowerIcon> icons = new();
public SupportPowerIcon TooltipIcon { get; private set; }
public Func<SupportPowerIcon> GetTooltipIcon;

View File

@@ -29,9 +29,9 @@ namespace OpenRA.Mods.Common.Widgets
public string MissionTemplate = "CHAT_LINE_TEMPLATE";
public string FeedbackTemplate = "TRANSIENT_LINE_TEMPLATE";
public string TransientsTemplate = "TRANSIENT_LINE_TEMPLATE";
readonly Dictionary<TextNotificationPool, Widget> templates = new Dictionary<TextNotificationPool, Widget>();
readonly Dictionary<TextNotificationPool, Widget> templates = new();
readonly List<long> expirations = new List<long>();
readonly List<long> expirations = new();
Rectangle overflowDrawBounds = Rectangle.Empty;
public override Rectangle EventBounds => Rectangle.Empty;

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Widgets
static readonly Action Nothing = () => { };
readonly GraphicSettings graphicSettings;
public int2 CursorOffset = new int2(0, 20);
public int2 CursorOffset = new(0, 20);
public int BottomEdgeYOffset = -5;
public Action BeforeRender = Nothing;

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Widgets
{
public class VideoPlayerWidget : Widget
{
public Hotkey CancelKey = new Hotkey(Keycode.ESCAPE, Modifiers.None);
public Hotkey CancelKey = new(Keycode.ESCAPE, Modifiers.None);
public float AspectRatio = 1.2f;
public bool DrawOverlay = true;
public bool Skippable = true;

View File

@@ -27,18 +27,18 @@ namespace OpenRA.Mods.Common.Widgets
readonly ModData modData;
readonly IEnumerable<IResourceRenderer> resourceRenderers;
public readonly HotkeyReference ZoomInKey = new HotkeyReference();
public readonly HotkeyReference ZoomOutKey = new HotkeyReference();
public readonly HotkeyReference ZoomInKey = new();
public readonly HotkeyReference ZoomOutKey = new();
public readonly HotkeyReference ScrollUpKey = new HotkeyReference();
public readonly HotkeyReference ScrollDownKey = new HotkeyReference();
public readonly HotkeyReference ScrollLeftKey = new HotkeyReference();
public readonly HotkeyReference ScrollRightKey = new HotkeyReference();
public readonly HotkeyReference ScrollUpKey = new();
public readonly HotkeyReference ScrollDownKey = new();
public readonly HotkeyReference ScrollLeftKey = new();
public readonly HotkeyReference ScrollRightKey = new();
public readonly HotkeyReference JumpToTopEdgeKey = new HotkeyReference();
public readonly HotkeyReference JumpToBottomEdgeKey = new HotkeyReference();
public readonly HotkeyReference JumpToLeftEdgeKey = new HotkeyReference();
public readonly HotkeyReference JumpToRightEdgeKey = new HotkeyReference();
public readonly HotkeyReference JumpToTopEdgeKey = new();
public readonly HotkeyReference JumpToBottomEdgeKey = new();
public readonly HotkeyReference JumpToLeftEdgeKey = new();
public readonly HotkeyReference JumpToRightEdgeKey = new();
// Note: LinterHotkeyNames assumes that these are disabled by default
public readonly string BookmarkSaveKeyPrefix = null;
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Widgets
public FrozenActor FrozenActorTooltip { get; private set; }
public string ResourceTooltip { get; private set; }
static readonly Dictionary<ScrollDirection, string> ScrollCursors = new Dictionary<ScrollDirection, string>
static readonly Dictionary<ScrollDirection, string> ScrollCursors = new()
{
{ ScrollDirection.Up | ScrollDirection.Left, "scroll-tl" },
{ ScrollDirection.Up | ScrollDirection.Right, "scroll-tr" },
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Widgets
{ ScrollDirection.Right, "scroll-r" },
};
static readonly Dictionary<ScrollDirection, string> JoystickCursors = new Dictionary<ScrollDirection, string>
static readonly Dictionary<ScrollDirection, string> JoystickCursors = new()
{
{ ScrollDirection.Up | ScrollDirection.Left, "joystick-tl-blocked" },
{ ScrollDirection.Up | ScrollDirection.Right, "joystick-tr-blocked" },
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Widgets
{ ScrollDirection.Right, "joystick-r-blocked" },
};
static readonly Dictionary<ScrollDirection, float2> ScrollOffsets = new Dictionary<ScrollDirection, float2>
static readonly Dictionary<ScrollDirection, float2> ScrollOffsets = new()
{
{ ScrollDirection.Up, new float2(0, -1) },
{ ScrollDirection.Down, new float2(0, 1) },