Fix IDE0074
This commit is contained in:
committed by
Pavel Penev
parent
cbd0583289
commit
bd2b3d9793
@@ -137,7 +137,7 @@ dotnet_diagnostic.IDE0050.severity = silent
|
|||||||
# IDE0054/IDE0074 Use compound assignment/Use coalesce compound assignment
|
# IDE0054/IDE0074 Use compound assignment/Use coalesce compound assignment
|
||||||
#dotnet_style_prefer_compound_assignment = true
|
#dotnet_style_prefer_compound_assignment = true
|
||||||
dotnet_diagnostic.IDE0054.severity = warning
|
dotnet_diagnostic.IDE0054.severity = warning
|
||||||
dotnet_diagnostic.IDE0074.severity = silent # Requires C# 8 - TODO Consider enabling
|
dotnet_diagnostic.IDE0074.severity = warning
|
||||||
|
|
||||||
# IDE0056 Use index operator
|
# IDE0056 Use index operator
|
||||||
#csharp_style_prefer_index_operator = true
|
#csharp_style_prefer_index_operator = true
|
||||||
|
|||||||
@@ -600,8 +600,7 @@ namespace OpenRA
|
|||||||
Lazy<ScriptActorInterface> luaInterface;
|
Lazy<ScriptActorInterface> luaInterface;
|
||||||
public void OnScriptBind(ScriptContext context)
|
public void OnScriptBind(ScriptContext context)
|
||||||
{
|
{
|
||||||
if (luaInterface == null)
|
luaInterface ??= Exts.Lazy(() => new ScriptActorInterface(context, this));
|
||||||
luaInterface = Exts.Lazy(() => new ScriptActorInterface(context, this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LuaValue this[LuaRuntime runtime, LuaValue keyValue]
|
public LuaValue this[LuaRuntime runtime, LuaValue keyValue]
|
||||||
|
|||||||
@@ -535,8 +535,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
object val;
|
object val;
|
||||||
|
|
||||||
if (md == null)
|
md ??= my.ToDictionary();
|
||||||
md = my.ToDictionary();
|
|
||||||
if (fli.Loader != null)
|
if (fli.Loader != null)
|
||||||
{
|
{
|
||||||
if (!fli.Attribute.Required || md.ContainsKey(fli.YamlName))
|
if (!fli.Attribute.Required || md.ContainsKey(fli.YamlName))
|
||||||
|
|||||||
@@ -167,8 +167,7 @@ namespace OpenRA.Graphics
|
|||||||
CalculateSpriteGeometry(tl, br, 1, out var spriteSize, out var spriteOffset);
|
CalculateSpriteGeometry(tl, br, 1, out var spriteSize, out var spriteOffset);
|
||||||
CalculateSpriteGeometry(stl, sbr, 2, out var shadowSpriteSize, out var shadowSpriteOffset);
|
CalculateSpriteGeometry(stl, sbr, 2, out var shadowSpriteSize, out var shadowSpriteOffset);
|
||||||
|
|
||||||
if (sheetBuilderForFrame == null)
|
sheetBuilderForFrame ??= new SheetBuilder(SheetType.BGRA, AllocateSheet);
|
||||||
sheetBuilderForFrame = new SheetBuilder(SheetType.BGRA, AllocateSheet);
|
|
||||||
|
|
||||||
var sprite = sheetBuilderForFrame.Allocate(spriteSize, 0, spriteOffset);
|
var sprite = sheetBuilderForFrame.Allocate(spriteSize, 0, spriteOffset);
|
||||||
var shadowSprite = sheetBuilderForFrame.Allocate(shadowSpriteSize, 0, shadowSpriteOffset);
|
var shadowSprite = sheetBuilderForFrame.Allocate(shadowSpriteSize, 0, shadowSpriteOffset);
|
||||||
|
|||||||
@@ -151,8 +151,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
static List<MiniYamlNode> FromLines(IEnumerable<ReadOnlyMemory<char>> lines, string filename, bool discardCommentsAndWhitespace, Dictionary<string, string> stringPool)
|
static List<MiniYamlNode> FromLines(IEnumerable<ReadOnlyMemory<char>> lines, string filename, bool discardCommentsAndWhitespace, Dictionary<string, string> stringPool)
|
||||||
{
|
{
|
||||||
if (stringPool == null)
|
stringPool ??= new Dictionary<string, string>();
|
||||||
stringPool = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
var levels = new List<List<MiniYamlNode>>
|
var levels = new List<List<MiniYamlNode>>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -294,8 +294,7 @@ namespace OpenRA
|
|||||||
Lazy<ScriptPlayerInterface> luaInterface;
|
Lazy<ScriptPlayerInterface> luaInterface;
|
||||||
public void OnScriptBind(ScriptContext context)
|
public void OnScriptBind(ScriptContext context)
|
||||||
{
|
{
|
||||||
if (luaInterface == null)
|
luaInterface ??= Exts.Lazy(() => new ScriptPlayerInterface(context, this));
|
||||||
luaInterface = Exts.Lazy(() => new ScriptPlayerInterface(context, this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LuaValue this[LuaRuntime runtime, LuaValue keyValue]
|
public LuaValue this[LuaRuntime runtime, LuaValue keyValue]
|
||||||
|
|||||||
@@ -55,8 +55,7 @@ namespace OpenRA.Support
|
|||||||
Write();
|
Write();
|
||||||
else if (ElapsedMs > thresholdMs)
|
else if (ElapsedMs > thresholdMs)
|
||||||
{
|
{
|
||||||
if (parent.children == null)
|
parent.children ??= new List<PerfTimer>();
|
||||||
parent.children = new List<PerfTimer>();
|
|
||||||
parent.children.Add(this);
|
parent.children.Add(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
|
|
||||||
protected override void OnFirstRun(Actor self)
|
protected override void OnFirstRun(Actor self)
|
||||||
{
|
{
|
||||||
if (minefield == null)
|
minefield ??= new List<CPos> { self.Location };
|
||||||
minefield = new List<CPos> { self.Location };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CPos? NextValidCell(Actor self)
|
CPos? NextValidCell(Actor self)
|
||||||
|
|||||||
@@ -71,8 +71,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
var prefix = match.Groups["prefix"].Value;
|
var prefix = match.Groups["prefix"].Value;
|
||||||
if (framePrefix == null)
|
framePrefix ??= prefix;
|
||||||
framePrefix = prefix;
|
|
||||||
|
|
||||||
if (prefix != framePrefix)
|
if (prefix != framePrefix)
|
||||||
throw new InvalidDataException($"Frame prefix mismatch: `{prefix}` != `{framePrefix}`");
|
throw new InvalidDataException($"Frame prefix mismatch: `{prefix}` != `{framePrefix}`");
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.AudioLoaders
|
|||||||
count -= count % format.reader.Channels;
|
count -= count % format.reader.Channels;
|
||||||
|
|
||||||
// Get the buffer, creating a new one if none exists or the existing one is too small.
|
// Get the buffer, creating a new one if none exists or the existing one is too small.
|
||||||
var floatBuffer = conversionBuffer ?? (conversionBuffer = new float[count]);
|
var floatBuffer = conversionBuffer ??= new float[count];
|
||||||
if (floatBuffer.Length < count)
|
if (floatBuffer.Length < count)
|
||||||
floatBuffer = conversionBuffer = new float[count];
|
floatBuffer = conversionBuffer = new float[count];
|
||||||
|
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Start the timer on the first render
|
// Start the timer on the first render
|
||||||
if (lastUpdate == null)
|
lastUpdate ??= Stopwatch.StartNew();
|
||||||
lastUpdate = Stopwatch.StartNew();
|
|
||||||
|
|
||||||
// Check for window DPI changes
|
// Check for window DPI changes
|
||||||
// We can't trust notifications to be working during initialization, so must do this manually
|
// We can't trust notifications to be working during initialization, so must do this manually
|
||||||
|
|||||||
@@ -802,8 +802,7 @@ namespace OpenRA.Mods.Common.Pathfinder
|
|||||||
sourcesWithPathableNodes.Add(source);
|
sourcesWithPathableNodes.Add(source);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (unpathableNodes == null)
|
unpathableNodes ??= new List<CPos>();
|
||||||
unpathableNodes = new List<CPos>();
|
|
||||||
unpathableNodes.Add(adjacentSource);
|
unpathableNodes.Add(adjacentSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -814,8 +813,7 @@ namespace OpenRA.Mods.Common.Pathfinder
|
|||||||
sourcesWithPathableNodes.Add(source);
|
sourcesWithPathableNodes.Add(source);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (unpathableNodes == null)
|
unpathableNodes ??= new List<CPos>();
|
||||||
unpathableNodes = new List<CPos>();
|
|
||||||
unpathableNodes.Add(adjacentSource);
|
unpathableNodes.Add(adjacentSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -453,8 +453,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
// If all are out of ammo, just use valid armament with highest range
|
// If all are out of ammo, just use valid armament with highest range
|
||||||
armaments = armaments.OrderByDescending(x => x.MaxRange());
|
armaments = armaments.OrderByDescending(x => x.MaxRange());
|
||||||
var a = armaments.FirstOrDefault(x => !x.IsTraitPaused);
|
var a = armaments.FirstOrDefault(x => !x.IsTraitPaused);
|
||||||
if (a == null)
|
a ??= armaments.First();
|
||||||
a = armaments.First();
|
|
||||||
|
|
||||||
var outOfRange = !target.IsInRange(self.CenterPosition, a.MaxRange()) ||
|
var outOfRange = !target.IsInRange(self.CenterPosition, a.MaxRange()) ||
|
||||||
(!forceAttack && target.Type == TargetType.FrozenActor && !ab.Info.TargetFrozenActors);
|
(!forceAttack && target.Type == TargetType.FrozenActor && !ab.Info.TargetFrozenActors);
|
||||||
@@ -491,8 +490,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
// If all are out of ammo, just use valid armament with highest range
|
// If all are out of ammo, just use valid armament with highest range
|
||||||
armaments = armaments.OrderByDescending(x => x.MaxRange());
|
armaments = armaments.OrderByDescending(x => x.MaxRange());
|
||||||
var a = armaments.FirstOrDefault(x => !x.IsTraitPaused);
|
var a = armaments.FirstOrDefault(x => !x.IsTraitPaused);
|
||||||
if (a == null)
|
a ??= armaments.First();
|
||||||
a = armaments.First();
|
|
||||||
|
|
||||||
cursor = !target.IsInRange(self.CenterPosition, a.MaxRange())
|
cursor = !target.IsInRange(self.CenterPosition, a.MaxRange())
|
||||||
? ab.Info.OutsideRangeCursor ?? a.Info.OutsideRangeCursor
|
? ab.Info.OutsideRangeCursor ?? a.Info.OutsideRangeCursor
|
||||||
|
|||||||
@@ -272,16 +272,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (Info.AirUnitsTypes.Contains(a.Info.Name))
|
if (Info.AirUnitsTypes.Contains(a.Info.Name))
|
||||||
{
|
{
|
||||||
var air = GetSquadOfType(SquadType.Air);
|
var air = GetSquadOfType(SquadType.Air);
|
||||||
if (air == null)
|
air ??= RegisterNewSquad(bot, SquadType.Air);
|
||||||
air = RegisterNewSquad(bot, SquadType.Air);
|
|
||||||
|
|
||||||
air.Units.Add(a);
|
air.Units.Add(a);
|
||||||
}
|
}
|
||||||
else if (Info.NavalUnitsTypes.Contains(a.Info.Name))
|
else if (Info.NavalUnitsTypes.Contains(a.Info.Name))
|
||||||
{
|
{
|
||||||
var ships = GetSquadOfType(SquadType.Naval);
|
var ships = GetSquadOfType(SquadType.Naval);
|
||||||
if (ships == null)
|
ships ??= RegisterNewSquad(bot, SquadType.Naval);
|
||||||
ships = RegisterNewSquad(bot, SquadType.Naval);
|
|
||||||
|
|
||||||
ships.Units.Add(a);
|
ships.Units.Add(a);
|
||||||
}
|
}
|
||||||
@@ -336,8 +334,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
var target = enemies.Count > 0 ? enemies.Random(World.LocalRandom) : b;
|
var target = enemies.Count > 0 ? enemies.Random(World.LocalRandom) : b;
|
||||||
var rush = GetSquadOfType(SquadType.Rush);
|
var rush = GetSquadOfType(SquadType.Rush);
|
||||||
if (rush == null)
|
rush ??= RegisterNewSquad(bot, SquadType.Rush, target);
|
||||||
rush = RegisterNewSquad(bot, SquadType.Rush, target);
|
|
||||||
|
|
||||||
foreach (var a3 in ownUnits)
|
foreach (var a3 in ownUnits)
|
||||||
rush.Units.Add(a3);
|
rush.Units.Add(a3);
|
||||||
@@ -350,8 +347,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
void ProtectOwn(IBot bot, Actor attacker)
|
void ProtectOwn(IBot bot, Actor attacker)
|
||||||
{
|
{
|
||||||
var protectSq = GetSquadOfType(SquadType.Protection);
|
var protectSq = GetSquadOfType(SquadType.Protection);
|
||||||
if (protectSq == null)
|
protectSq ??= RegisterNewSquad(bot, SquadType.Protection, attacker);
|
||||||
protectSq = RegisterNewSquad(bot, SquadType.Protection, attacker);
|
|
||||||
|
|
||||||
if (!protectSq.IsTargetValid)
|
if (!protectSq.IsTargetValid)
|
||||||
protectSq.TargetActor = attacker;
|
protectSq.TargetActor = attacker;
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (r.IsTraitDisabled)
|
if (r.IsTraitDisabled)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (acceptedReplacements == null)
|
acceptedReplacements ??= new HashSet<string>();
|
||||||
acceptedReplacements = new HashSet<string>();
|
|
||||||
|
|
||||||
acceptedReplacements.UnionWith(r.Info.Types);
|
acceptedReplacements.UnionWith(r.Info.Types);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void INotifyLineBuildSegmentsChanged.SegmentAdded(Actor self, Actor segment)
|
void INotifyLineBuildSegmentsChanged.SegmentAdded(Actor self, Actor segment)
|
||||||
{
|
{
|
||||||
if (segments == null)
|
segments ??= new HashSet<Actor>();
|
||||||
segments = new HashSet<Actor>();
|
|
||||||
|
|
||||||
segments.Add(segment);
|
segments.Add(segment);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,8 +120,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public bool CanEnterCell(World world, Actor self, CPos cell, SubCell subCell = SubCell.FullCell, Actor ignoreActor = null, BlockedByActor check = BlockedByActor.All)
|
public bool CanEnterCell(World world, Actor self, CPos cell, SubCell subCell = SubCell.FullCell, Actor ignoreActor = null, BlockedByActor check = BlockedByActor.All)
|
||||||
{
|
{
|
||||||
// PERF: Avoid repeated trait queries on the hot path
|
// PERF: Avoid repeated trait queries on the hot path
|
||||||
if (locomotor == null)
|
locomotor ??= world.WorldActor.TraitsImplementing<Locomotor>()
|
||||||
locomotor = world.WorldActor.TraitsImplementing<Locomotor>()
|
|
||||||
.SingleOrDefault(l => l.Info.Name == Locomotor);
|
.SingleOrDefault(l => l.Info.Name == Locomotor);
|
||||||
|
|
||||||
return locomotor.MovementCostToEnterCell(
|
return locomotor.MovementCostToEnterCell(
|
||||||
@@ -131,8 +130,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public bool CanStayInCell(World world, CPos cell)
|
public bool CanStayInCell(World world, CPos cell)
|
||||||
{
|
{
|
||||||
// PERF: Avoid repeated trait queries on the hot path
|
// PERF: Avoid repeated trait queries on the hot path
|
||||||
if (locomotor == null)
|
locomotor ??= world.WorldActor.TraitsImplementing<Locomotor>()
|
||||||
locomotor = world.WorldActor.TraitsImplementing<Locomotor>()
|
|
||||||
.SingleOrDefault(l => l.Info.Name == Locomotor);
|
.SingleOrDefault(l => l.Info.Name == Locomotor);
|
||||||
|
|
||||||
if (cell.Layer == CustomMovementLayerType.Tunnel)
|
if (cell.Layer == CustomMovementLayerType.Tunnel)
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
mo.MarkFailed(self.Owner, objectiveID);
|
mo.MarkFailed(self.Owner, objectiveID);
|
||||||
|
|
||||||
// Players, NonCombatants, and IsAlliedWith are all fixed once the game starts, so we can cache the result.
|
// Players, NonCombatants, and IsAlliedWith are all fixed once the game starts, so we can cache the result.
|
||||||
if (otherPlayers == null)
|
otherPlayers ??= self.World.Players.Where(p => !p.NonCombatant && !p.IsAlliedWith(self.Owner)).ToArray();
|
||||||
otherPlayers = self.World.Players.Where(p => !p.NonCombatant && !p.IsAlliedWith(self.Owner)).ToArray();
|
|
||||||
|
|
||||||
if (otherPlayers.Length == 0) return;
|
if (otherPlayers.Length == 0) return;
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,8 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
// Per-actor queue
|
// Per-actor queue
|
||||||
var queue = ai.TraitInfos<ProductionQueueInfo>().FirstOrDefault(q => ProductionType == q.Type);
|
var queue = ai.TraitInfos<ProductionQueueInfo>().FirstOrDefault(q => ProductionType == q.Type);
|
||||||
|
|
||||||
// No queues available - check for classic production queues
|
// If no queues available - check for classic production queues
|
||||||
if (queue == null)
|
queue ??= rules.Actors[SystemActors.Player].TraitInfos<ProductionQueueInfo>().FirstOrDefault(q => ProductionType == q.Type);
|
||||||
queue = rules.Actors[SystemActors.Player].TraitInfos<ProductionQueueInfo>().FirstOrDefault(q => ProductionType == q.Type);
|
|
||||||
|
|
||||||
if (queue == null)
|
if (queue == null)
|
||||||
throw new YamlException($"Can't find a queue with ProductionType '{ProductionType}'");
|
throw new YamlException($"Can't find a queue with ProductionType '{ProductionType}'");
|
||||||
@@ -67,12 +66,9 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
queue = self.TraitsImplementing<ProductionQueue>()
|
queue = self.TraitsImplementing<ProductionQueue>()
|
||||||
.FirstOrDefault(q => Info.ProductionType == q.Info.Type);
|
.FirstOrDefault(q => Info.ProductionType == q.Info.Type);
|
||||||
|
|
||||||
if (queue == null)
|
// If no queues available - check for classic production queues
|
||||||
{
|
queue ??= self.Owner.PlayerActor.TraitsImplementing<ProductionQueue>()
|
||||||
// No queues available - check for classic production queues
|
.FirstOrDefault(q => Info.ProductionType == q.Info.Type);
|
||||||
queue = self.Owner.PlayerActor.TraitsImplementing<ProductionQueue>()
|
|
||||||
.FirstOrDefault(q => Info.ProductionType == q.Info.Type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ITick.Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
|
|||||||
@@ -101,8 +101,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
|
|
||||||
if (selected && self.World.LocalPlayer != null)
|
if (selected && self.World.LocalPlayer != null)
|
||||||
{
|
{
|
||||||
if (developerMode == null)
|
developerMode ??= self.World.LocalPlayer.PlayerActor.Trait<DeveloperMode>();
|
||||||
developerMode = self.World.LocalPlayer.PlayerActor.Trait<DeveloperMode>();
|
|
||||||
|
|
||||||
if (developerMode.PathDebug)
|
if (developerMode.PathDebug)
|
||||||
yield return new TargetLineRenderable(ActivityTargetPath(self), Color.Green, 1, 2);
|
yield return new TargetLineRenderable(ActivityTargetPath(self), Color.Green, 1, 2);
|
||||||
|
|||||||
@@ -307,8 +307,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
}
|
}
|
||||||
|
|
||||||
var worldNode = Map.RuleDefinitions.Nodes.FirstOrDefault(n => n.Key == "World");
|
var worldNode = Map.RuleDefinitions.Nodes.FirstOrDefault(n => n.Key == "World");
|
||||||
if (worldNode == null)
|
worldNode ??= new MiniYamlNode("World", new MiniYaml("", new List<MiniYamlNode>()));
|
||||||
worldNode = new MiniYamlNode("World", new MiniYaml("", new List<MiniYamlNode>()));
|
|
||||||
|
|
||||||
if (scorches.Count > 0)
|
if (scorches.Count > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,14 +56,12 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
var isDisabled = IsDisabled();
|
var isDisabled = IsDisabled();
|
||||||
var isHover = Ui.MouseOverWidget == this || Children.Any(c => c == Ui.MouseOverWidget);
|
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()));
|
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)));
|
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()));
|
var separatorImage = getSeparatorImage.Update((isDisabled, Depressed, isHover, false, IsHighlighted()));
|
||||||
if (separatorImage != null)
|
if (separatorImage != null)
|
||||||
|
|||||||
@@ -147,13 +147,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (map.Package != null)
|
if (map.Package != null)
|
||||||
{
|
{
|
||||||
selectedDirectory = writableDirectories.FirstOrDefault(k => k.Folder.Contains(map.Package.Name));
|
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
|
// 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.GetText = () => selectedDirectory?.DisplayName ?? "";
|
||||||
directoryDropdown.OnClick = () =>
|
directoryDropdown.OnClick = () =>
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
|
|||||||
.Skip(1)
|
.Skip(1)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (next == null)
|
next ??= bases.First();
|
||||||
next = bases.First();
|
|
||||||
|
|
||||||
selection.Combine(world, new Actor[] { next }, false, true);
|
selection.Combine(world, new Actor[] { next }, false, true);
|
||||||
viewport.Center(selection.Actors);
|
viewport.Center(selection.Actors);
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
|
|||||||
.Skip(1)
|
.Skip(1)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (next == null)
|
next ??= harvesters.First();
|
||||||
next = harvesters.First();
|
|
||||||
|
|
||||||
selection.Combine(world, new Actor[] { next }, false, true);
|
selection.Combine(world, new Actor[] { next }, false, true);
|
||||||
viewport.Center(selection.Actors);
|
viewport.Center(selection.Actors);
|
||||||
|
|||||||
@@ -58,8 +58,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
|
|||||||
.Skip(1)
|
.Skip(1)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (next == null)
|
next ??= facilities.First();
|
||||||
next = facilities.First();
|
|
||||||
|
|
||||||
Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", clickSound, null);
|
Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", clickSound, null);
|
||||||
|
|
||||||
|
|||||||
@@ -292,8 +292,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ orderByDate, m => -m.ModifiedDate.Ticks }
|
{ orderByDate, m => -m.ModifiedDate.Ticks }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (orderByFunc == null)
|
orderByFunc ??= orderByDict[orderByPlayer];
|
||||||
orderByFunc = orderByDict[orderByPlayer];
|
|
||||||
|
|
||||||
ScrollItemWidget SetupItem(string o, ScrollItemWidget template)
|
ScrollItemWidget SetupItem(string o, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
public static bool PromptConfirmReplayCompatibility(ReplayMetadata replayMeta, ModData modData, Action onCancel = null)
|
public static bool PromptConfirmReplayCompatibility(ReplayMetadata replayMeta, ModData modData, Action onCancel = null)
|
||||||
{
|
{
|
||||||
if (onCancel == null)
|
onCancel ??= DoNothing;
|
||||||
onCancel = DoNothing;
|
|
||||||
|
|
||||||
if (replayMeta == null)
|
if (replayMeta == null)
|
||||||
return IncompatibleReplayDialog(IncompatibleReplayPrompt, null, modData, onCancel);
|
return IncompatibleReplayDialog(IncompatibleReplayPrompt, null, modData, onCancel);
|
||||||
|
|||||||
@@ -194,8 +194,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
if (added.Add(hd))
|
if (added.Add(hd))
|
||||||
{
|
{
|
||||||
if (selectedHotkeyDefinition == null)
|
selectedHotkeyDefinition ??= hd;
|
||||||
selectedHotkeyDefinition = hd;
|
|
||||||
|
|
||||||
BindHotkeyPref(hd, template);
|
BindHotkeyPref(hd, template);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,8 +155,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
var panel = panelContainer.Get(panelID);
|
var panel = panelContainer.Get(panelID);
|
||||||
|
|
||||||
if (activePanel == null)
|
activePanel ??= panelID;
|
||||||
activePanel = panelID;
|
|
||||||
|
|
||||||
panel.IsVisible = () => activePanel == panelID;
|
panel.IsVisible = () => activePanel == panelID;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user