Files
OpenRA/ShpViewer/MapViewControl.cs
bob 1438053505 - bugfix in Format80
- fixed heisenburg-endianness in map loader
    - THERES A BUG in the mix loading; I need another 4 bytes padding to load temperat.mix and snow.mix (not interior.mix, though)
    - ShpViewer can now load and view map files
    - Copy TEMPERAT, SNOW, INFERIOR (sic) mixes into $(SolutionDir) for this to work
    - Left-click to reload tile-ID file, middle-click scrolls
    - the tile-id file has some collisions between tile-sets, be careful about ordering if you change anything


git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1081 993157c7-ee19-0410-b2c4-bb4e9862e678
2007-06-26 21:25:20 +00:00

66 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using OpenRa.FileFormats;
using System.Drawing;
namespace ShpViewer
{
public class MapViewControl : Control
{
public int XScroll, YScroll;
public Map Map;
public TileSet TileSet;
public MapViewControl()
{
}
static Font font = new Font( FontFamily.GenericMonospace, 10 );
protected override void OnPaint( PaintEventArgs e )
{
base.OnPaint( e );
if( Map == null || TileSet == null )
return;
using( Graphics g = e.Graphics )
{
for( int x = 50 ; x >= 0 ; x-- )
{
int tX = x + Map.XOffset + XScroll;
if( tX < 1 || tX > 127 )
continue;
for( int y = 50 ; y >= 0 ; y-- )
{
int tY = y + Map.YOffset + YScroll;
if( tY < 1 || tY > 127 )
continue;
Terrain t;
if( TileSet.tiles.TryGetValue( Map.MapTiles[ tX, tY ].tile, out t ) )
{
Bitmap b = t.GetTile( Map.MapTiles[ tX, tY ].image );
if( b == null )
{
g.FillRectangle( Brushes.Blue, x * 24, y * 24, 24, 24 );
g.DrawString( string.Format( "{0:x}", Map.MapTiles[ tX, tY ].image ),
font, Brushes.White, x * 24, y * 24 );
}
else
g.DrawImage( b, x * 24, y * 24 );
}
else
{
g.FillRectangle( Brushes.Red, x * 24, y * 24, 24, 24 );
g.DrawString( string.Format( "{0:x}", Map.MapTiles[ tX, tY ].tile ),
font, Brushes.White, x * 24, y * 24 );
}
}
}
}
}
}
}