Fix IDE0074

This commit is contained in:
RoosterDragon
2023-04-05 19:20:51 +01:00
committed by Pavel Penev
parent cbd0583289
commit bd2b3d9793
30 changed files with 42 additions and 81 deletions

View File

@@ -147,13 +147,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (map.Package != null)
{
selectedDirectory = writableDirectories.FirstOrDefault(k => k.Folder.Contains(map.Package.Name));
if (selectedDirectory == null)
selectedDirectory = writableDirectories.FirstOrDefault(k => Directory.GetDirectories(k.Folder.Name).Any(f => f.Contains(map.Package.Name)));
selectedDirectory ??= writableDirectories.FirstOrDefault(k => Directory.GetDirectories(k.Folder.Name).Any(f => f.Contains(map.Package.Name)));
}
// Prioritize MapClassification.User directories over system directories
if (selectedDirectory == null)
selectedDirectory = writableDirectories.OrderByDescending(kv => kv.Classification).First();
selectedDirectory ??= writableDirectories.OrderByDescending(kv => kv.Classification).First();
directoryDropdown.GetText = () => selectedDirectory?.DisplayName ?? "";
directoryDropdown.OnClick = () =>

View File

@@ -65,8 +65,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
.Skip(1)
.FirstOrDefault();
if (next == null)
next = bases.First();
next ??= bases.First();
selection.Combine(world, new Actor[] { next }, false, true);
viewport.Center(selection.Actors);

View File

@@ -51,8 +51,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
.Skip(1)
.FirstOrDefault();
if (next == null)
next = harvesters.First();
next ??= harvesters.First();
selection.Combine(world, new Actor[] { next }, false, true);
viewport.Center(selection.Actors);

View File

@@ -58,8 +58,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
.Skip(1)
.FirstOrDefault();
if (next == null)
next = facilities.First();
next ??= facilities.First();
Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", clickSound, null);

View File

@@ -292,8 +292,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ orderByDate, m => -m.ModifiedDate.Ticks }
};
if (orderByFunc == null)
orderByFunc = orderByDict[orderByPlayer];
orderByFunc ??= orderByDict[orderByPlayer];
ScrollItemWidget SetupItem(string o, ScrollItemWidget template)
{

View File

@@ -45,8 +45,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
public static bool PromptConfirmReplayCompatibility(ReplayMetadata replayMeta, ModData modData, Action onCancel = null)
{
if (onCancel == null)
onCancel = DoNothing;
onCancel ??= DoNothing;
if (replayMeta == null)
return IncompatibleReplayDialog(IncompatibleReplayPrompt, null, modData, onCancel);

View File

@@ -194,8 +194,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
if (added.Add(hd))
{
if (selectedHotkeyDefinition == null)
selectedHotkeyDefinition = hd;
selectedHotkeyDefinition ??= hd;
BindHotkeyPref(hd, template);
}

View File

@@ -155,8 +155,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
var panel = panelContainer.Get(panelID);
if (activePanel == null)
activePanel = panelID;
activePanel ??= panelID;
panel.IsVisible = () => activePanel == panelID;