From 89d8056918e488716076f67c25d6e8f31cbe9980 Mon Sep 17 00:00:00 2001 From: chrisf Date: Sat, 14 Jul 2007 06:33:17 +0000 Subject: [PATCH] git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1222 993157c7-ee19-0410-b2c4-bb4e9862e678 --- OpenRa.Game/MainWindow.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index c8eeabfa6b..3d74cebd1e 100644 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -73,15 +73,12 @@ namespace OpenRa.Game } } - - int x1,y1; + Point lastPos; protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); - - x1 = e.X; - y1 = e.Y; + lastPos = e.Location; } protected override void OnMouseMove(MouseEventArgs e) @@ -91,14 +88,11 @@ namespace OpenRa.Game if (e.Button != 0) { PointF scrollPos = viewport.ScrollPosition; - scrollPos.X += x1 - e.X; - scrollPos.Y += y1 - e.Y; + scrollPos.X = Util.Constrain(scrollPos.X + lastPos.X - e.X, new Range(0, map.Width * 24 - ClientSize.Width + 128)); + scrollPos.Y = Util.Constrain(scrollPos.Y + lastPos.Y - e.Y, new Range(0, map.Height * 24 - ClientSize.Height)); - x1 = e.X; - y1 = e.Y; + lastPos = e.Location; - scrollPos.X = Util.Constrain(scrollPos.X, new Range(0, map.Width * 24 - ClientSize.Width + 128)); - scrollPos.Y = Util.Constrain(scrollPos.Y, new Range(0, map.Height * 24 - ClientSize.Height)); viewport.ScrollPosition = scrollPos; } }