Merge pull request #7267 from atimoschenkow/fix-selection-after-radar
Selection rectangle is drawn after exiting radar widget while dragging the viewport
This commit is contained in:
@@ -26,7 +26,8 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
protected readonly World World;
|
protected readonly World World;
|
||||||
readonly WorldRenderer worldRenderer;
|
readonly WorldRenderer worldRenderer;
|
||||||
int2 dragStart, dragEnd;
|
int2? dragStart, dragEnd;
|
||||||
|
int2 lastMousePosition;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public WorldInteractionControllerWidget(World world, WorldRenderer worldRenderer)
|
public WorldInteractionControllerWidget(World world, WorldRenderer worldRenderer)
|
||||||
@@ -37,15 +38,15 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
var selbox = SelectionBox;
|
if (!IsDragging)
|
||||||
if (selbox == null)
|
|
||||||
{
|
{
|
||||||
foreach (var u in SelectActorsInBox(World, dragStart, dragStart, _ => true))
|
foreach (var u in SelectActorsInBox(World, lastMousePosition, lastMousePosition, _ => true))
|
||||||
worldRenderer.DrawRollover(u);
|
worldRenderer.DrawRollover(u);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var selbox = SelectionBox;
|
||||||
Game.Renderer.WorldLineRenderer.DrawRect(selbox.Value.First.ToFloat2(), selbox.Value.Second.ToFloat2(), Color.White);
|
Game.Renderer.WorldLineRenderer.DrawRect(selbox.Value.First.ToFloat2(), selbox.Value.Second.ToFloat2(), Color.White);
|
||||||
foreach (var u in SelectActorsInBox(World, selbox.Value.First, selbox.Value.Second, _ => true))
|
foreach (var u in SelectActorsInBox(World, selbox.Value.First, selbox.Value.Second, _ => true))
|
||||||
worldRenderer.DrawRollover(u);
|
worldRenderer.DrawRollover(u);
|
||||||
@@ -62,13 +63,13 @@ namespace OpenRA.Widgets
|
|||||||
if (!TakeMouseFocus(mi))
|
if (!TakeMouseFocus(mi))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dragStart = dragEnd = xy;
|
dragStart = xy;
|
||||||
|
|
||||||
// place buildings
|
// place buildings
|
||||||
ApplyOrders(World, xy, mi);
|
ApplyOrders(World, xy, mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Move)
|
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Move && dragStart.HasValue)
|
||||||
dragEnd = xy;
|
dragEnd = xy;
|
||||||
|
|
||||||
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up)
|
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up)
|
||||||
@@ -85,33 +86,40 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
World.Selection.Combine(World, newSelection2, true, false);
|
World.Selection.Combine(World, newSelection2, true, false);
|
||||||
}
|
}
|
||||||
else
|
else if (dragStart.HasValue)
|
||||||
{
|
{
|
||||||
var newSelection = SelectActorsInBox(World, dragStart, xy, _ => true);
|
var newSelection = SelectActorsInBox(World, dragStart.Value, xy, _ => true);
|
||||||
World.Selection.Combine(World, newSelection, mi.Modifiers.HasModifier(Modifiers.Shift), dragStart == xy);
|
World.Selection.Combine(World, newSelection, mi.Modifiers.HasModifier(Modifiers.Shift), dragStart == xy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dragStart = dragEnd = xy;
|
dragStart = dragEnd = null;
|
||||||
YieldMouseFocus(mi);
|
YieldMouseFocus(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mi.Button == MouseButton.None && mi.Event == MouseInputEvent.Move)
|
|
||||||
dragStart = dragEnd = xy;
|
|
||||||
|
|
||||||
// don't issue orders while selecting
|
// don't issue orders while selecting
|
||||||
if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down && !hasBox)
|
if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down && !hasBox)
|
||||||
ApplyOrders(World, xy, mi);
|
ApplyOrders(World, xy, mi);
|
||||||
|
|
||||||
|
lastMousePosition = xy;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsDragging
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return dragStart.HasValue && dragEnd.HasValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Pair<int2, int2>? SelectionBox
|
public Pair<int2, int2>? SelectionBox
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (dragStart == dragEnd) return null;
|
if (!IsDragging) return null;
|
||||||
return Pair.New(dragStart, dragEnd);
|
return Pair.New(dragStart.Value, dragEnd.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user