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

@@ -56,14 +56,12 @@ namespace OpenRA.Mods.Common.Widgets
var isDisabled = IsDisabled();
var isHover = Ui.MouseOverWidget == this || Children.Any(c => c == Ui.MouseOverWidget);
if (getMarkerImage == null)
getMarkerImage = WidgetUtils.GetCachedStatefulImage(Decorations, DecorationMarker);
getMarkerImage ??= WidgetUtils.GetCachedStatefulImage(Decorations, DecorationMarker);
var arrowImage = getMarkerImage.Update((isDisabled, Depressed, isHover, false, IsHighlighted()));
WidgetUtils.DrawSprite(arrowImage, stateOffset + new float2(rb.Right - (int)((rb.Height + arrowImage.Size.X) / 2), rb.Top + (int)((rb.Height - arrowImage.Size.Y) / 2)));
if (getSeparatorImage == null)
getSeparatorImage = WidgetUtils.GetCachedStatefulImage(Separators, SeparatorImage);
getSeparatorImage ??= WidgetUtils.GetCachedStatefulImage(Separators, SeparatorImage);
var separatorImage = getSeparatorImage.Update((isDisabled, Depressed, isHover, false, IsHighlighted()));
if (separatorImage != null)

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;