Remove special-case rollover rendering.
This commit is contained in:
@@ -85,20 +85,21 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
IEnumerable<IRenderable> DrawDecorations(Actor self, WorldRenderer wr)
|
||||
{
|
||||
var selected = self.World.Selection.Contains(self);
|
||||
var rollover = self.World.Selection.RolloverContains(self);
|
||||
var regularWorld = self.World.Type == WorldType.Regular;
|
||||
var statusBars = Game.Settings.Game.StatusBars;
|
||||
|
||||
// Health bars are shown when:
|
||||
// * actor is selected
|
||||
// * actor is selected / in active drag rectangle / under the mouse
|
||||
// * status bar preference is set to "always show"
|
||||
// * status bar preference is set to "when damaged" and actor is damaged
|
||||
var displayHealth = selected || (regularWorld && statusBars == StatusBarsType.AlwaysShow)
|
||||
var displayHealth = selected || rollover || (regularWorld && statusBars == StatusBarsType.AlwaysShow)
|
||||
|| (regularWorld && statusBars == StatusBarsType.DamageShow && self.GetDamageState() != DamageState.Undamaged);
|
||||
|
||||
// Extra bars are shown when:
|
||||
// * actor is selected
|
||||
// * actor is selected / in active drag rectangle / under the mouse
|
||||
// * status bar preference is set to "always show" or "when damaged"
|
||||
var displayExtra = selected || (regularWorld && statusBars != StatusBarsType.Standard);
|
||||
var displayExtra = selected || rollover || (regularWorld && statusBars != StatusBarsType.Standard);
|
||||
|
||||
if (selected)
|
||||
foreach (var r in RenderSelectionBox(self, wr, info.SelectionBoxColor))
|
||||
@@ -125,14 +126,6 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
yield return new TargetLineRenderable(ActivityTargetPath(self), Color.Green);
|
||||
}
|
||||
|
||||
IEnumerable<IRenderable> ISelectionDecorations.RenderRolloverAnnotations(Actor self, WorldRenderer worldRenderer)
|
||||
{
|
||||
if (self.World.Selection.Contains(self))
|
||||
return Enumerable.Empty<IRenderable>();
|
||||
|
||||
return RenderSelectionBars(self, worldRenderer, true, true);
|
||||
}
|
||||
|
||||
IEnumerable<IRenderable> ISelectionDecorations.RenderSelectionAnnotations(Actor self, WorldRenderer worldRenderer, Color color)
|
||||
{
|
||||
return RenderSelectionBox(self, worldRenderer, color);
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public IEnumerable<Actor> Actors { get { return actors; } }
|
||||
|
||||
readonly HashSet<Actor> actors = new HashSet<Actor>();
|
||||
IEnumerable<Actor> rolloverActors;
|
||||
|
||||
INotifySelection[] worldNotifySelection;
|
||||
|
||||
public Selection(SelectionInfo info) { }
|
||||
@@ -143,6 +145,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
UpdateHash();
|
||||
}
|
||||
|
||||
public void SetRollover(IEnumerable<Actor> rollover)
|
||||
{
|
||||
rolloverActors = rollover;
|
||||
}
|
||||
|
||||
public bool RolloverContains(Actor a)
|
||||
{
|
||||
return rolloverActors != null && rolloverActors.Contains(a);
|
||||
}
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
var removed = actors.RemoveWhere(a => !a.IsInWorld || (!a.Owner.IsAlliedWith(self.World.RenderPlayer) && self.World.FogObscures(a)));
|
||||
|
||||
@@ -58,19 +58,10 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
normalSelectionColor = Color.White;
|
||||
}
|
||||
|
||||
void DrawRollover(Actor unit)
|
||||
{
|
||||
var selectionDecorations = unit.TraitOrDefault<ISelectionDecorations>();
|
||||
if (selectionDecorations == null)
|
||||
return;
|
||||
|
||||
foreach (var r in selectionDecorations.RenderRolloverAnnotations(unit, worldRenderer))
|
||||
r.PrepareRender(worldRenderer).Render(worldRenderer);
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
var modifiers = Game.GetModifierKeys();
|
||||
IEnumerable<Actor> rollover;
|
||||
if (IsValidDragbox)
|
||||
{
|
||||
var a = worldRenderer.Viewport.WorldToViewPx(dragStart);
|
||||
@@ -85,15 +76,15 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
Game.Renderer.RgbaColorRenderer.DrawRect(a, b, 1, color);
|
||||
|
||||
// Render actors in the dragbox
|
||||
foreach (var u in SelectActorsInBoxWithDeadzone(World, dragStart, mousePos, modifiers))
|
||||
DrawRollover(u);
|
||||
rollover = SelectActorsInBoxWithDeadzone(World, dragStart, mousePos, modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Render actors under the mouse pointer
|
||||
foreach (var u in SelectActorsInBoxWithDeadzone(World, mousePos, mousePos, modifiers))
|
||||
DrawRollover(u);
|
||||
rollover = SelectActorsInBoxWithDeadzone(World, mousePos, mousePos, modifiers);
|
||||
}
|
||||
|
||||
worldRenderer.World.Selection.SetRollover(rollover);
|
||||
}
|
||||
|
||||
public override bool HandleMouseInput(MouseInput mi)
|
||||
|
||||
Reference in New Issue
Block a user