Fix bad uses of FirstEnabledTraitOrDefault on TraitInfos.
These are not traits so this method does not work. We can use EnabledByDefault on the ConditionalTraitInfo instead.
This commit is contained in:
committed by
Paul Chote
parent
7a7eed4fb7
commit
5338784e45
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (buildable == null)
|
if (buildable == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var tooltip = actorInfo.Value.TraitInfos<TooltipInfo>().FirstEnabledTraitOrDefault();
|
var tooltip = actorInfo.Value.TraitInfos<TooltipInfo>().FirstOrDefault(info => info.EnabledByDefault);
|
||||||
if (tooltip == null)
|
if (tooltip == null)
|
||||||
emitError("The following buildable actor has no (enabled) Tooltip: " + actorInfo.Key);
|
emitError("The following buildable actor has no (enabled) Tooltip: " + actorInfo.Key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Footprint = new ReadOnlyDictionary<CPos, SubCell>(footprint);
|
Footprint = new ReadOnlyDictionary<CPos, SubCell>(footprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
var tooltip = Info.TraitInfos<EditorOnlyTooltipInfo>().FirstEnabledTraitOrDefault() as TooltipInfoBase
|
var tooltip = Info.TraitInfos<EditorOnlyTooltipInfo>().FirstOrDefault(info => info.EnabledByDefault) as TooltipInfoBase
|
||||||
?? Info.TraitInfos<TooltipInfo>().FirstEnabledTraitOrDefault();
|
?? Info.TraitInfos<TooltipInfo>().FirstOrDefault(info => info.EnabledByDefault);
|
||||||
|
|
||||||
Tooltip = (tooltip == null ? " < " + Info.Name + " >" : tooltip.Name) + "\n" + owner.Name + " (" + owner.Faction + ")"
|
Tooltip = (tooltip == null ? " < " + Info.Name + " >" : tooltip.Name) + "\n" + owner.Name + " (" + owner.Faction + ")"
|
||||||
+ "\nID: " + ID + "\nType: " + Info.Name;
|
+ "\nID: " + ID + "\nType: " + Info.Name;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (actor == lastActor && hotkey == lastHotkey && pm.PowerState == lastPowerState)
|
if (actor == lastActor && hotkey == lastHotkey && pm.PowerState == lastPowerState)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var tooltip = actor.TraitInfos<TooltipInfo>().FirstEnabledTraitOrDefault();
|
var tooltip = actor.TraitInfos<TooltipInfo>().FirstOrDefault(info => info.EnabledByDefault);
|
||||||
var name = tooltip != null ? tooltip.Name : actor.Name;
|
var name = tooltip != null ? tooltip.Name : actor.Name;
|
||||||
var buildable = actor.TraitInfo<BuildableInfo>();
|
var buildable = actor.TraitInfo<BuildableInfo>();
|
||||||
var cost = actor.TraitInfo<ValuedInfo>().Cost;
|
var cost = actor.TraitInfo<ValuedInfo>().Cost;
|
||||||
@@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ActorInfo ai;
|
ActorInfo ai;
|
||||||
if (rules.Actors.TryGetValue(a.ToLowerInvariant(), out ai))
|
if (rules.Actors.TryGetValue(a.ToLowerInvariant(), out ai))
|
||||||
{
|
{
|
||||||
var actorTooltip = ai.TraitInfos<TooltipInfo>().FirstEnabledTraitOrDefault();
|
var actorTooltip = ai.TraitInfos<TooltipInfo>().FirstOrDefault(info => info.EnabledByDefault);
|
||||||
if (actorTooltip != null)
|
if (actorTooltip != null)
|
||||||
return actorTooltip.Name;
|
return actorTooltip.Name;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user