git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1106 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -19,7 +19,7 @@ namespace ShpViewer
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
map = value;
|
map = value;
|
||||||
TileSet = LoadTileSet( Map );
|
TileSet = LoadTileSet(Map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ namespace ShpViewer
|
|||||||
UpdateStyles();
|
UpdateStyles();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Font font = new Font( FontFamily.GenericMonospace, 10 );
|
static Font font = new Font(FontFamily.GenericMonospace, 10);
|
||||||
protected override void OnPaint(PaintEventArgs e)
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnPaint(e);
|
base.OnPaint(e);
|
||||||
@@ -78,49 +78,91 @@ namespace ShpViewer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach( TreeReference tr in Map.Trees )
|
foreach (TreeReference tr in Map.Trees)
|
||||||
{
|
{
|
||||||
int tX = tr.X - Map.XOffset - XScroll;
|
int tX = tr.X - Map.XOffset - XScroll;
|
||||||
int tY = tr.Y - Map.YOffset - YScroll;
|
int tY = tr.Y - Map.YOffset - YScroll;
|
||||||
g.DrawImage( GetTree( tr.Image, TileMix ), tX * 24, tY * 24 );
|
g.DrawImage(GetTree(tr.Image, TileMix), tX * 24, tY * 24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap GetTree( string name, Package mix )
|
Bitmap GetTree(string name, Package mix)
|
||||||
{
|
{
|
||||||
Bitmap ret;
|
Bitmap ret;
|
||||||
if( !TreeCache.TryGetValue( name, out ret ) )
|
if (!TreeCache.TryGetValue(name, out ret))
|
||||||
{
|
{
|
||||||
ShpReader shp = new ShpReader( TileSet.MixFile.GetContent( name + TileSuffix ) );
|
ShpReader shp = new ShpReader(TileSet.MixFile.GetContent(name + TileSuffix));
|
||||||
ret = BitmapBuilder.FromBytes( shp[ 0 ].Image, shp.Width, shp.Height, pal ); ;
|
ret = BitmapBuilder.FromBytes(shp[0].Image, shp.Width, shp.Height, pal); ;
|
||||||
TreeCache.Add( name, ret );
|
TreeCache.Add(name, ret);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileSet LoadTileSet( Map currentMap )
|
TileSet LoadTileSet(Map currentMap)
|
||||||
{
|
{
|
||||||
switch( currentMap.Theater.ToLowerInvariant() )
|
switch (currentMap.Theater.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
case "temperate":
|
case "temperate":
|
||||||
pal = new Palette( File.OpenRead( "../../../temperat.pal" ) );
|
pal = new Palette(File.OpenRead("../../../temperat.pal"));
|
||||||
TileMix = new Package( "../../../temperat.mix" );
|
TileMix = new Package("../../../temperat.mix");
|
||||||
TileSuffix = ".tem";
|
TileSuffix = ".tem";
|
||||||
break;
|
break;
|
||||||
case "snow":
|
case "snow":
|
||||||
pal = new Palette( File.OpenRead( "../../../snow.pal" ) );
|
pal = new Palette(File.OpenRead("../../../snow.pal"));
|
||||||
TileMix = new Package( "../../../snow.mix" );
|
TileMix = new Package("../../../snow.mix");
|
||||||
TileSuffix = ".sno";
|
TileSuffix = ".sno";
|
||||||
break;
|
break;
|
||||||
case "interior":
|
case "interior":
|
||||||
pal = new Palette( File.OpenRead( "../../../interior.pal" ) );
|
pal = new Palette(File.OpenRead("../../../interior.pal"));
|
||||||
TileMix = new Package( "../../../interior.mix" );
|
TileMix = new Package("../../../interior.mix");
|
||||||
TileSuffix = ".int";
|
TileSuffix = ".int";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
return new TileSet( TileMix, TileSuffix, pal );
|
return new TileSet(TileMix, TileSuffix, pal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ux,uy, vx, vy;
|
||||||
|
|
||||||
|
protected override void OnMouseDown(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseDown(e);
|
||||||
|
|
||||||
|
if (e.Button == MouseButtons.Right)
|
||||||
|
{
|
||||||
|
ux = e.X;
|
||||||
|
uy = e.Y;
|
||||||
|
|
||||||
|
vx = XScroll;
|
||||||
|
vy = YScroll;
|
||||||
|
|
||||||
|
Cursor = Cursors.NoMove2D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnMouseMove(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseMove(e);
|
||||||
|
|
||||||
|
if (e.Button == MouseButtons.Right)
|
||||||
|
{
|
||||||
|
int dx = ux - e.X;
|
||||||
|
int dy = uy - e.Y;
|
||||||
|
|
||||||
|
XScroll = vx + dx / 24;
|
||||||
|
YScroll = vy + dy / 24;
|
||||||
|
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnMouseUp(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseUp(e);
|
||||||
|
|
||||||
|
Cursor = Cursors.Default;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,44 +59,10 @@ namespace ShpViewer
|
|||||||
Map map = new Map( iniFile );
|
Map map = new Map( iniFile );
|
||||||
|
|
||||||
flowLayoutPanel1.Visible = false;
|
flowLayoutPanel1.Visible = false;
|
||||||
flowLayoutPanel1.BackColor = Color.Blue;
|
|
||||||
mapViewControl1.Visible = true;
|
mapViewControl1.Visible = true;
|
||||||
mapViewControl1.Map = map;
|
mapViewControl1.Map = map;
|
||||||
mapViewControl1.Invalidate();
|
mapViewControl1.Invalidate();
|
||||||
|
|
||||||
int ux = 0, uy = 0;
|
|
||||||
int vx = 0, vy = 0;
|
|
||||||
|
|
||||||
mapViewControl1.MouseDown += delegate(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Button == MouseButtons.Right)
|
|
||||||
{
|
|
||||||
ux = e.X;
|
|
||||||
uy = e.Y;
|
|
||||||
|
|
||||||
vx = mapViewControl1.XScroll;
|
|
||||||
vy = mapViewControl1.YScroll;
|
|
||||||
|
|
||||||
mapViewControl1.Cursor = Cursors.NoMove2D;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
mapViewControl1.MouseMove += delegate(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Button == MouseButtons.Right)
|
|
||||||
{
|
|
||||||
int dx = ux - e.X;
|
|
||||||
int dy = uy - e.Y;
|
|
||||||
|
|
||||||
mapViewControl1.XScroll = vx + dx / 24;
|
|
||||||
mapViewControl1.YScroll = vy + dy / 24;
|
|
||||||
|
|
||||||
mapViewControl1.Invalidate();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
mapViewControl1.MouseUp += delegate { mapViewControl1.Cursor = Cursors.Default; };
|
|
||||||
|
|
||||||
mapViewControl1.MouseClick += delegate( object sender, MouseEventArgs e )
|
mapViewControl1.MouseClick += delegate( object sender, MouseEventArgs e )
|
||||||
{
|
{
|
||||||
if( e.Button == MouseButtons.Left )
|
if( e.Button == MouseButtons.Left )
|
||||||
|
|||||||
Reference in New Issue
Block a user