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