git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1226 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -41,12 +41,13 @@ namespace OpenRa.Game
|
||||
Visible = true;
|
||||
|
||||
renderer = new Renderer(this, GetResolution(settings), false);
|
||||
viewport = new Viewport(ClientSize);
|
||||
|
||||
SheetBuilder.Initialize(renderer.Device);
|
||||
|
||||
map = new Map(new IniFile(File.OpenRead("../../../" + settings.GetValue("map", "scm12ea.ini"))));
|
||||
|
||||
viewport = new Viewport(ClientSize, new float2(map.Size));
|
||||
|
||||
SheetBuilder.Initialize(renderer.Device);
|
||||
|
||||
TileMix = new Package("../../../" + map.Theater + ".mix");
|
||||
|
||||
renderer.SetPalette(new HardwarePalette(renderer.Device, map));
|
||||
@@ -91,14 +92,10 @@ namespace OpenRa.Game
|
||||
if (e.Button == 0)
|
||||
return;
|
||||
|
||||
float2 scrollPos = new float2(viewport.ScrollPosition) + lastPos - new float2(e.Location);
|
||||
float2 mapSize = 24 * new float2(map.Size) - viewport.Size + new float2(128, 0);
|
||||
float2 p = new float2(e.Location);
|
||||
|
||||
scrollPos = scrollPos.Constrain(new Range<float2>(float2.Zero, mapSize));
|
||||
|
||||
lastPos = new float2(e.Location);
|
||||
|
||||
viewport.ScrollPosition = scrollPos.ToPointF();
|
||||
viewport.Scroll(lastPos - p);
|
||||
lastPos = p;
|
||||
}
|
||||
|
||||
void Frame()
|
||||
|
||||
@@ -2,18 +2,26 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using BluntDirectX.Direct3D;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
class Viewport
|
||||
{
|
||||
readonly Size clientSize;
|
||||
readonly float2 mapSize;
|
||||
PointF scrollPosition;
|
||||
|
||||
public PointF ScrollPosition
|
||||
{
|
||||
get { return scrollPosition; }
|
||||
set { scrollPosition = value; }
|
||||
}
|
||||
|
||||
public void Scroll(float2 delta)
|
||||
{
|
||||
float2 scrollPos = new float2(ScrollPosition) + delta;
|
||||
scrollPos = scrollPos.Constrain(new Range<float2>(float2.Zero, mapSize));
|
||||
scrollPosition = scrollPos.ToPointF();
|
||||
}
|
||||
|
||||
public Size ClientSize
|
||||
@@ -21,9 +29,10 @@ namespace OpenRa.Game
|
||||
get { return clientSize; }
|
||||
}
|
||||
|
||||
public Viewport(Size clientSize)
|
||||
public Viewport(Size clientSize, float2 mapSize)
|
||||
{
|
||||
this.clientSize = clientSize;
|
||||
this.mapSize = 24 * mapSize - Size + new float2(128, 0);
|
||||
}
|
||||
|
||||
public float2 Size { get { return new float2(clientSize); } }
|
||||
|
||||
Reference in New Issue
Block a user