Use selection priority when picking tooltip actor.
This commit is contained in:
@@ -21,7 +21,7 @@ namespace OpenRA.Orders
|
||||
{
|
||||
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
||||
.Where(a => a.HasTrait<ITargetable>())
|
||||
.OrderByDescending(a => a.SelectionPriority())
|
||||
.OrderByDescending(a => a.Info.SelectionPriority())
|
||||
.FirstOrDefault();
|
||||
|
||||
var orders = world.Selection.Actors
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Orders
|
||||
|
||||
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
||||
.Where(a => a.HasTrait<ITargetable>())
|
||||
.OrderByDescending(a => a.SelectionPriority())
|
||||
.OrderByDescending(a => a.Info.SelectionPriority())
|
||||
.FirstOrDefault();
|
||||
|
||||
if (underCursor != null && (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any()))
|
||||
@@ -135,9 +135,9 @@ namespace OpenRA.Orders
|
||||
|
||||
public static class SelectableExts
|
||||
{
|
||||
public static int SelectionPriority(this Actor a)
|
||||
public static int SelectionPriority(this ActorInfo a)
|
||||
{
|
||||
var selectableInfo = a.Info.Traits.GetOrDefault<SelectableInfo>();
|
||||
var selectableInfo = a.Traits.GetOrDefault<SelectableInfo>();
|
||||
return selectableInfo != null ? selectableInfo.Priority : int.MinValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Orders;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
@@ -101,13 +102,17 @@ namespace OpenRA.Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
var actor = world.FindUnitsAtMouse(Viewport.LastMousePos).FirstOrDefault();
|
||||
if (actor == null)
|
||||
return;
|
||||
var underCursor = world.FindUnitsAtMouse(Viewport.LastMousePos)
|
||||
.Where(a => a.HasTrait<IToolTip>())
|
||||
.OrderByDescending(a => a.Info.SelectionPriority())
|
||||
.FirstOrDefault();
|
||||
|
||||
ActorTooltip = actor.TraitsImplementing<IToolTip>().FirstOrDefault();
|
||||
if (ActorTooltip != null)
|
||||
if (underCursor != null)
|
||||
{
|
||||
ActorTooltip = underCursor.TraitsImplementing<IToolTip>().First();
|
||||
TooltipType = WorldTooltipType.Actor;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetScrollCursor(Widget w, ScrollDirection edge, int2 pos)
|
||||
|
||||
Reference in New Issue
Block a user