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;
|
Visible = true;
|
||||||
|
|
||||||
renderer = new Renderer(this, GetResolution(settings), false);
|
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"))));
|
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");
|
TileMix = new Package("../../../" + map.Theater + ".mix");
|
||||||
|
|
||||||
renderer.SetPalette(new HardwarePalette(renderer.Device, map));
|
renderer.SetPalette(new HardwarePalette(renderer.Device, map));
|
||||||
@@ -91,14 +92,10 @@ namespace OpenRa.Game
|
|||||||
if (e.Button == 0)
|
if (e.Button == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float2 scrollPos = new float2(viewport.ScrollPosition) + lastPos - new float2(e.Location);
|
float2 p = new float2(e.Location);
|
||||||
float2 mapSize = 24 * new float2(map.Size) - viewport.Size + new float2(128, 0);
|
|
||||||
|
|
||||||
scrollPos = scrollPos.Constrain(new Range<float2>(float2.Zero, mapSize));
|
viewport.Scroll(lastPos - p);
|
||||||
|
lastPos = p;
|
||||||
lastPos = new float2(e.Location);
|
|
||||||
|
|
||||||
viewport.ScrollPosition = scrollPos.ToPointF();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame()
|
void Frame()
|
||||||
|
|||||||
@@ -2,18 +2,26 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using BluntDirectX.Direct3D;
|
||||||
|
|
||||||
namespace OpenRa.Game
|
namespace OpenRa.Game
|
||||||
{
|
{
|
||||||
class Viewport
|
class Viewport
|
||||||
{
|
{
|
||||||
readonly Size clientSize;
|
readonly Size clientSize;
|
||||||
|
readonly float2 mapSize;
|
||||||
PointF scrollPosition;
|
PointF scrollPosition;
|
||||||
|
|
||||||
public PointF ScrollPosition
|
public PointF ScrollPosition
|
||||||
{
|
{
|
||||||
get { return 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
|
public Size ClientSize
|
||||||
@@ -21,9 +29,10 @@ namespace OpenRa.Game
|
|||||||
get { return clientSize; }
|
get { return clientSize; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Viewport(Size clientSize)
|
public Viewport(Size clientSize, float2 mapSize)
|
||||||
{
|
{
|
||||||
this.clientSize = clientSize;
|
this.clientSize = clientSize;
|
||||||
|
this.mapSize = 24 * mapSize - Size + new float2(128, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float2 Size { get { return new float2(clientSize); } }
|
public float2 Size { get { return new float2(clientSize); } }
|
||||||
|
|||||||
Reference in New Issue
Block a user