Improve edge-scroll behavior

This commit is contained in:
Paul Chote
2011-07-05 21:03:04 +12:00
parent ca8605d3ee
commit 5f3483ed17
7 changed files with 261 additions and 137 deletions

View File

@@ -8,6 +8,7 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@@ -16,6 +17,16 @@ using OpenRA.Support;
namespace OpenRA.Graphics
{
[Flags]
public enum ScrollDirection
{
None = 0,
Up = 1,
Left = 2,
Down = 4,
Right = 8
}
public class Viewport
{
readonly int2 screenSize;
@@ -164,4 +175,17 @@ namespace OpenRA.Graphics
return (b.HasValue) ? Rectangle.Intersect(cachedRect, b.Value) : cachedRect;
}
}
public static class ViewportExts
{
public static bool Includes(this ScrollDirection d, ScrollDirection s)
{
return (d & s) == s;
}
public static ScrollDirection Set(this ScrollDirection d, ScrollDirection s, bool val)
{
return (d.Includes(s) != val) ? d ^ s : d;
}
}
}