remove duplicated edgescroll code in cnc

This commit is contained in:
Chris Forbes
2011-10-22 10:25:50 +13:00
parent 52cec1e170
commit eec751f76a
2 changed files with 7 additions and 57 deletions

View File

@@ -55,20 +55,22 @@ namespace OpenRA.Widgets
{ ScrollDirection.Right, "scroll-r" },
};
public override string GetCursor(int2 pos)
public static string GetScrollCursor(Widget w, ScrollDirection edge, int2 pos)
{
if (!Game.Settings.Game.ViewportEdgeScroll)
if (!Game.Settings.Game.ViewportEdgeScroll || Widget.MouseOverWidget != w)
return null;
var blockedDirections = Game.viewport.GetBlockedDirections();
foreach( var dir in directions )
if (Edge.Includes( dir.Key ))
if (edge.Includes( dir.Key ))
return dir.Value + (blockedDirections.Includes( dir.Key ) ? "-blocked" : "");
return null;
}
public override string GetCursor(int2 pos) { return GetScrollCursor(this, Edge, pos); }
public override bool LoseFocus (MouseInput mi)
{
Keyboard = ScrollDirection.None;