Change mouse cursors while joystick scrolling

This patch adds mouse cursors to the joystick scrolling feature.

On Tiberian Sun, which itself had joystick scrolling, the same cursors are
used as in the original game.

As the older games did not have joystick scrolling, I've had to make a
best-effort guess as to what were suitable cursors.
  -> When scrolling in all directions is available, the default arrow
     cursor is used.
  -> When a direction is blocked, the edge-scrolling blocked direction
     cursor is used.
This commit is contained in:
Joppy Furr
2015-10-16 11:53:53 +13:00
parent fd37869a88
commit 6ded247d0c
5 changed files with 117 additions and 1 deletions

View File

@@ -48,6 +48,18 @@ namespace OpenRA.Mods.Common.Widgets
{ ScrollDirection.Right, "scroll-r" },
};
static readonly Dictionary<ScrollDirection, string> JoystickCursors = new Dictionary<ScrollDirection, string>
{
{ ScrollDirection.Up | ScrollDirection.Left, "joystick-tl-blocked" },
{ ScrollDirection.Up | ScrollDirection.Right, "joystick-tr-blocked" },
{ ScrollDirection.Down | ScrollDirection.Left, "joystick-bl-blocked" },
{ ScrollDirection.Down | ScrollDirection.Right, "joystick-br-blocked" },
{ ScrollDirection.Up, "joystick-t-blocked" },
{ ScrollDirection.Down, "joystick-b-blocked" },
{ ScrollDirection.Left, "joystick-l-blocked" },
{ ScrollDirection.Right, "joystick-r-blocked" },
};
static readonly Dictionary<ScrollDirection, float2> ScrollOffsets = new Dictionary<ScrollDirection, float2>
{
{ ScrollDirection.Up, new float2(0, -1) },
@@ -147,10 +159,20 @@ namespace OpenRA.Mods.Common.Widgets
public override string GetCursor(int2 pos)
{
if (!Game.Settings.Game.ViewportEdgeScroll || Ui.MouseOverWidget != this)
if (!IsJoystickScrolling &&
(!Game.Settings.Game.ViewportEdgeScroll || Ui.MouseOverWidget != this))
return null;
var blockedDirections = worldRenderer.Viewport.GetBlockedDirections();
if (IsJoystickScrolling)
{
foreach (var dir in JoystickCursors)
if (blockedDirections.Includes(dir.Key))
return dir.Value;
return "joystick-all";
}
foreach (var dir in ScrollCursors)
if (edgeDirections.Includes(dir.Key))
return dir.Value + (blockedDirections.Includes(dir.Key) ? "-blocked" : "");