Remove drag support from BackgroundWidget
This was not used anywhere, was somewhat buggy and could be implemented in a better way when needed.
This commit is contained in:
@@ -16,7 +16,6 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public class BackgroundWidget : Widget
|
public class BackgroundWidget : Widget
|
||||||
{
|
{
|
||||||
public readonly bool ClickThrough = false;
|
public readonly bool ClickThrough = false;
|
||||||
public readonly bool Draggable = false;
|
|
||||||
public string Background = "dialog";
|
public string Background = "dialog";
|
||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
@@ -26,37 +25,11 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
|
|
||||||
public BackgroundWidget() { }
|
public BackgroundWidget() { }
|
||||||
|
|
||||||
bool moving;
|
|
||||||
int2? prevMouseLocation;
|
|
||||||
|
|
||||||
public override bool HandleMouseInput(MouseInput mi)
|
public override bool HandleMouseInput(MouseInput mi)
|
||||||
{
|
{
|
||||||
if (ClickThrough || !RenderBounds.Contains(mi.Location))
|
if (ClickThrough || !RenderBounds.Contains(mi.Location))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!Draggable || (moving && (!TakeMouseFocus(mi) || mi.Button != MouseButton.Left)))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (prevMouseLocation == null)
|
|
||||||
prevMouseLocation = mi.Location;
|
|
||||||
var vec = mi.Location - (int2)prevMouseLocation;
|
|
||||||
prevMouseLocation = mi.Location;
|
|
||||||
switch (mi.Event)
|
|
||||||
{
|
|
||||||
case MouseInputEvent.Up:
|
|
||||||
moving = false;
|
|
||||||
YieldMouseFocus(mi);
|
|
||||||
break;
|
|
||||||
case MouseInputEvent.Down:
|
|
||||||
moving = true;
|
|
||||||
Bounds = new WidgetBounds(Bounds.X + vec.X, Bounds.Y + vec.Y, Bounds.Width, Bounds.Height);
|
|
||||||
break;
|
|
||||||
case MouseInputEvent.Move:
|
|
||||||
if (moving)
|
|
||||||
Bounds = new WidgetBounds(Bounds.X + vec.X, Bounds.Y + vec.Y, Bounds.Width, Bounds.Height);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +38,6 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
Background = other.Background;
|
Background = other.Background;
|
||||||
ClickThrough = other.ClickThrough;
|
ClickThrough = other.ClickThrough;
|
||||||
Draggable = other.Draggable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone() { return new BackgroundWidget(this); }
|
public override Widget Clone() { return new BackgroundWidget(this); }
|
||||||
|
|||||||
Reference in New Issue
Block a user