From 6cffb2ebb5de27fbc3e9d3c07540535ea6824c14 Mon Sep 17 00:00:00 2001 From: chrisf Date: Sat, 14 Jul 2007 07:10:35 +0000 Subject: [PATCH] git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1227 993157c7-ee19-0410-b2c4-bb4e9862e678 --- OpenRa.Game/Viewport.cs | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/OpenRa.Game/Viewport.cs b/OpenRa.Game/Viewport.cs index 38d1eadf75..0d535a4bf1 100644 --- a/OpenRa.Game/Viewport.cs +++ b/OpenRa.Game/Viewport.cs @@ -10,31 +10,20 @@ namespace OpenRa.Game { readonly Size clientSize; readonly float2 mapSize; - PointF scrollPosition; + float2 scrollPosition; - public PointF ScrollPosition - { - get { return scrollPosition; } - } + public PointF ScrollPosition { get { return scrollPosition.ToPointF(); } } + public Size ClientSize { get { return clientSize; } } public void Scroll(float2 delta) { - float2 scrollPos = new float2(ScrollPosition) + delta; - scrollPos = scrollPos.Constrain(new Range(float2.Zero, mapSize)); - scrollPosition = scrollPos.ToPointF(); + scrollPosition = (scrollPosition + delta).Constrain(new Range(float2.Zero, mapSize)); } - public Size ClientSize - { - get { return clientSize; } - } - public Viewport(Size clientSize, float2 mapSize) { this.clientSize = clientSize; - this.mapSize = 24 * mapSize - Size + new float2(128, 0); + this.mapSize = 24 * mapSize - new float2(clientSize) + new float2(128, 0); } - - public float2 Size { get { return new float2(clientSize); } } } }