clean up ViewportScrollControllerWidget.GetCursor
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
@@ -49,61 +50,30 @@ namespace OpenRA.Widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
static readonly Dictionary<ScrollDirection, string> directions = new Dictionary<ScrollDirection, string>
|
||||
{
|
||||
{ ScrollDirection.Up | ScrollDirection.Left, "scroll-tl" },
|
||||
{ ScrollDirection.Up | ScrollDirection.Right, "scroll-tr" },
|
||||
{ ScrollDirection.Down | ScrollDirection.Left, "scroll-bl" },
|
||||
{ ScrollDirection.Down | ScrollDirection.Right, "scroll-br" },
|
||||
|
||||
{ ScrollDirection.Up, "scroll-t" },
|
||||
{ ScrollDirection.Down, "scroll-b" },
|
||||
{ ScrollDirection.Left, "scroll-l" },
|
||||
{ ScrollDirection.Right, "scroll-r" },
|
||||
};
|
||||
|
||||
public override string GetCursor(int2 pos)
|
||||
{
|
||||
if (!Game.Settings.Game.ViewportEdgeScroll)
|
||||
return null;
|
||||
|
||||
if (Edge.Includes(ScrollDirection.Up) && Edge.Includes(ScrollDirection.Left)){
|
||||
ScrollDirection BlockedDirections = Game.viewport.GetBlockedDirections();
|
||||
if(BlockedDirections.Includes(ScrollDirection.Up) && BlockedDirections.Includes(ScrollDirection.Left))
|
||||
return "scroll-tl-blocked";
|
||||
else
|
||||
return "scroll-tl";
|
||||
}
|
||||
if (Edge.Includes(ScrollDirection.Up) && Edge.Includes(ScrollDirection.Right)){
|
||||
ScrollDirection BlockedDirections = Game.viewport.GetBlockedDirections();
|
||||
if (BlockedDirections.Includes(ScrollDirection.Up) && BlockedDirections.Includes(ScrollDirection.Right))
|
||||
return "scroll-tr-blocked";
|
||||
else
|
||||
return "scroll-tr";
|
||||
}
|
||||
if (Edge.Includes(ScrollDirection.Down) && Edge.Includes(ScrollDirection.Left)){
|
||||
ScrollDirection BlockedDirections = Game.viewport.GetBlockedDirections();
|
||||
if (BlockedDirections.Includes(ScrollDirection.Down) && BlockedDirections.Includes(ScrollDirection.Left))
|
||||
return "scroll-bl-blocked";
|
||||
else
|
||||
return "scroll-bl";
|
||||
}
|
||||
if (Edge.Includes(ScrollDirection.Down) && Edge.Includes(ScrollDirection.Right)){
|
||||
ScrollDirection BlockedDirections = Game.viewport.GetBlockedDirections();
|
||||
if (BlockedDirections.Includes(ScrollDirection.Down) && BlockedDirections.Includes(ScrollDirection.Right))
|
||||
return "scroll-br-blocked";
|
||||
else
|
||||
return "scroll-br";
|
||||
}
|
||||
|
||||
if (Edge.Includes(ScrollDirection.Up))
|
||||
if (Game.viewport.GetBlockedDirections().Includes(ScrollDirection.Up))
|
||||
return "scroll-t-blocked";
|
||||
else
|
||||
return "scroll-t";
|
||||
if (Edge.Includes(ScrollDirection.Down))
|
||||
if (Game.viewport.GetBlockedDirections().Includes(ScrollDirection.Down))
|
||||
return "scroll-b-blocked";
|
||||
else
|
||||
return "scroll-b";
|
||||
if (Edge.Includes(ScrollDirection.Left))
|
||||
if (Game.viewport.GetBlockedDirections().Includes(ScrollDirection.Left))
|
||||
return "scroll-l-blocked";
|
||||
else
|
||||
return "scroll-l";
|
||||
if (Edge.Includes(ScrollDirection.Right))
|
||||
if (Game.viewport.GetBlockedDirections().Includes(ScrollDirection.Right))
|
||||
return "scroll-r-blocked";
|
||||
else
|
||||
return "scroll-r";
|
||||
var blockedDirections = Game.viewport.GetBlockedDirections();
|
||||
|
||||
foreach( var dir in directions )
|
||||
if (Edge.Includes( dir.Key ))
|
||||
return dir.Value + (blockedDirections.Includes( dir.Key ) ? "-blocked" : "");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user