fixes flicker

git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1083 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
chrisf
2007-06-27 01:36:23 +00:00
parent 284072765b
commit 8296c7c9bc

View File

@@ -16,47 +16,49 @@ namespace ShpViewer
public MapViewControl() public MapViewControl()
{ {
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
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);
if( Map == null || TileSet == null ) if (Map == null || TileSet == null)
return; return;
using( Graphics g = e.Graphics )
Graphics g = e.Graphics;
for (int x = 50; x >= 0; x--)
{ {
for( int x = 50 ; x >= 0 ; x-- ) int tX = x + Map.XOffset + XScroll;
if (tX < Map.XOffset || tX >= Map.XOffset + Map.Width)
continue;
for (int y = 50; y >= 0; y--)
{ {
int tX = x + Map.XOffset + XScroll; int tY = y + Map.YOffset + YScroll;
if( tX < Map.XOffset || tX >= Map.XOffset + Map.Width ) if (tY < Map.YOffset || tY >= Map.YOffset + Map.Height)
continue; continue;
for( int y = 50 ; y >= 0 ; y-- ) Terrain t;
if (TileSet.tiles.TryGetValue(Map.MapTiles[tX, tY].tile, out t))
{ {
int tY = y + Map.YOffset + YScroll; Bitmap b = t.GetTile(Map.MapTiles[tX, tY].image);
if( tY < Map.YOffset || tY >= Map.YOffset + Map.Height ) if (b == null)
continue;
Terrain t;
if( TileSet.tiles.TryGetValue( Map.MapTiles[ tX, tY ].tile, out t ) )
{ {
Bitmap b = t.GetTile( Map.MapTiles[ tX, tY ].image ); g.FillRectangle(Brushes.Blue, x * 24, y * 24, 24, 24);
if( b == null ) g.DrawString(string.Format("{0:x}", Map.MapTiles[tX, tY].image),
{ font, Brushes.White, x * 24, y * 24);
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 else
{ g.DrawImage(b, x * 24, y * 24);
g.FillRectangle( Brushes.Red, x * 24, y * 24, 24, 24 ); }
g.DrawString( string.Format( "{0:x}", Map.MapTiles[ tX, tY ].tile ), else
font, Brushes.White, x * 24, y * 24 ); {
} 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);
} }
} }
} }