Fix #2720 - Diagonal scrolling area in viewport corners are too small
I added two options, one is for EdgeScrollThreshold and the other one is EdgeCornerScrollThreshold. You can modify these threshold as much as you want. [Squashed down into one commit -- chrisf]
This commit is contained in:
committed by
Chris Forbes
parent
9db06ca222
commit
7cbc4a29bf
@@ -18,6 +18,7 @@ namespace OpenRA.Widgets
|
||||
public class ViewportScrollControllerWidget : Widget
|
||||
{
|
||||
public int EdgeScrollThreshold = 15;
|
||||
public int EdgeCornerScrollThreshold = 35;
|
||||
|
||||
ScrollDirection Keyboard;
|
||||
ScrollDirection Edge;
|
||||
@@ -94,17 +95,59 @@ namespace OpenRA.Widgets
|
||||
Edge = ScrollDirection.None;
|
||||
if (Game.Settings.Game.ViewportEdgeScroll && Game.HasInputFocus)
|
||||
{
|
||||
// Check for edge-scroll
|
||||
if (Viewport.LastMousePos.X < EdgeScrollThreshold)
|
||||
Edge = Edge.Set(ScrollDirection.Left, true);
|
||||
if (Viewport.LastMousePos.Y < EdgeScrollThreshold)
|
||||
Edge = Edge.Set(ScrollDirection.Up, true);
|
||||
if (Viewport.LastMousePos.X >= Game.viewport.Width - EdgeScrollThreshold)
|
||||
Edge = Edge.Set(ScrollDirection.Right, true);
|
||||
if (Viewport.LastMousePos.Y >= Game.viewport.Height - EdgeScrollThreshold)
|
||||
Edge = Edge.Set(ScrollDirection.Down, true);
|
||||
Edge = CheckForDirections();
|
||||
Scroll();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
ScrollDirection CheckForDirections()
|
||||
{
|
||||
// First let's check if the mouse is on the corners:
|
||||
if (Viewport.LastMousePos.X >= Game.viewport.Width - EdgeCornerScrollThreshold &&
|
||||
Viewport.LastMousePos.Y >= Game.viewport.Height - EdgeCornerScrollThreshold) //Bottom Right
|
||||
{
|
||||
return ScrollDirection.Right | ScrollDirection.Down;
|
||||
}
|
||||
else if (Viewport.LastMousePos.X < EdgeCornerScrollThreshold &&
|
||||
Viewport.LastMousePos.Y >= Game.viewport.Height - EdgeCornerScrollThreshold) //Bottom Left
|
||||
{
|
||||
return ScrollDirection.Down | ScrollDirection.Left;
|
||||
}
|
||||
|
||||
else if (Viewport.LastMousePos.X >= Game.viewport.Width - EdgeCornerScrollThreshold &&
|
||||
Viewport.LastMousePos.Y < EdgeCornerScrollThreshold) //Top Right
|
||||
{
|
||||
return ScrollDirection.Right | ScrollDirection.Up;
|
||||
}
|
||||
|
||||
else if (Viewport.LastMousePos.X < EdgeCornerScrollThreshold &&
|
||||
Viewport.LastMousePos.Y < EdgeCornerScrollThreshold) //Top Left
|
||||
{
|
||||
return ScrollDirection.Left | ScrollDirection.Up;
|
||||
}
|
||||
|
||||
//Check for corner ends here now let's check the edges:
|
||||
|
||||
// Check for edge-scroll
|
||||
if (Viewport.LastMousePos.X < EdgeScrollThreshold)
|
||||
return ScrollDirection.Left;
|
||||
if (Viewport.LastMousePos.Y < EdgeScrollThreshold)
|
||||
return ScrollDirection.Up;
|
||||
if (Viewport.LastMousePos.X >= Game.viewport.Width - EdgeScrollThreshold)
|
||||
return ScrollDirection.Right;
|
||||
if (Viewport.LastMousePos.Y >= Game.viewport.Height - EdgeScrollThreshold)
|
||||
return ScrollDirection.Down;
|
||||
|
||||
|
||||
//Check for edge-scroll ends here.If none of above then return none.
|
||||
return ScrollDirection.None;
|
||||
}
|
||||
|
||||
|
||||
void Scroll()
|
||||
{
|
||||
if (Keyboard != ScrollDirection.None || Edge != ScrollDirection.None)
|
||||
{
|
||||
var scroll = new float2(0, 0);
|
||||
|
||||
Reference in New Issue
Block a user