git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1246 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -43,7 +43,7 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
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), renderer);
|
viewport = new Viewport(new float2(ClientSize), new float2(map.Size), renderer);
|
||||||
|
|
||||||
SheetBuilder.Initialize(renderer.Device);
|
SheetBuilder.Initialize(renderer.Device);
|
||||||
|
|
||||||
|
|||||||
@@ -31,21 +31,17 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
public static Region Create(Viewport v, DockStyle d, int size, MethodInvoker f)
|
public static Region Create(Viewport v, DockStyle d, int size, MethodInvoker f)
|
||||||
{
|
{
|
||||||
Point topLeft = new Point(0, 0);
|
|
||||||
Point bottomRight = new Point(v.Width, v.Height);
|
|
||||||
|
|
||||||
Size s = MakeSize(v, d, size);
|
Size s = MakeSize(v, d, size);
|
||||||
|
|
||||||
switch (d)
|
switch (d)
|
||||||
{
|
{
|
||||||
case DockStyle.Top:
|
case DockStyle.Top:
|
||||||
case DockStyle.Left:
|
case DockStyle.Left:
|
||||||
return new Region(topLeft, s, f);
|
return new Region(new Point(0,0), s, f);
|
||||||
|
|
||||||
case DockStyle.Right:
|
case DockStyle.Right:
|
||||||
case DockStyle.Bottom:
|
case DockStyle.Bottom:
|
||||||
Point origin = bottomRight; origin.Offset( -s.Width, -s.Height );
|
return new Region(new Point( v.Width - s.Width, v.Height - s.Height ), s, f);
|
||||||
return new Region(origin, s, f);
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
@@ -9,16 +9,16 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
class Viewport
|
class Viewport
|
||||||
{
|
{
|
||||||
readonly Size clientSize;
|
readonly float2 size;
|
||||||
readonly float2 mapSize;
|
readonly float2 mapSize;
|
||||||
float2 scrollPosition;
|
float2 scrollPosition;
|
||||||
readonly Renderer renderer;
|
readonly Renderer renderer;
|
||||||
|
|
||||||
public float2 Location { get { return scrollPosition; } }
|
public float2 Location { get { return scrollPosition; } }
|
||||||
public float2 Size { get { return new float2(clientSize); } }
|
public float2 Size { get { return size; } }
|
||||||
|
|
||||||
public int Width { get { return clientSize.Width; } }
|
public int Width { get { return (int)size.X; } }
|
||||||
public int Height { get { return clientSize.Height; } }
|
public int Height { get { return (int)size.Y; } }
|
||||||
|
|
||||||
public void Scroll(float2 delta)
|
public void Scroll(float2 delta)
|
||||||
{
|
{
|
||||||
@@ -26,10 +26,10 @@ namespace OpenRa.Game
|
|||||||
new Range<float2>(float2.Zero, mapSize));
|
new Range<float2>(float2.Zero, mapSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Viewport(Size clientSize, float2 mapSize, Renderer renderer)
|
public Viewport(float2 size, float2 mapSize, Renderer renderer)
|
||||||
{
|
{
|
||||||
this.clientSize = clientSize;
|
this.size = size;
|
||||||
this.mapSize = 24 * mapSize - new float2(clientSize) + new float2(128, 0);
|
this.mapSize = 24 * mapSize - size + new float2(128, 0);
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user