Precompute dirt texture too for the launcher, also fix 'selected entry' in the servers list in the launcher drawing over other widgets when it is the last element in the list and the user scrolls back up. (Thanks Lemon)

This commit is contained in:
UnknownShadow200 2016-04-04 12:24:56 +10:00
parent f9afc9e3ee
commit eb081bca76
2 changed files with 11 additions and 13 deletions

View File

@ -87,8 +87,11 @@ namespace Launcher {
for( int i = CurrentIndex; i < Count; i++ ) { for( int i = CurrentIndex; i < Count; i++ ) {
args = new DrawTextArgs( filter( usedEntries[i] ), font, true ); args = new DrawTextArgs( filter( usedEntries[i] ), font, true );
if( i == SelectedIndex && !separator ) if( i == SelectedIndex && !separator ) {
drawer.Clear( foreGridCol, X, y - 3, Width, defaultInputHeight + 4 ); int startY = y - 3;
int height = Math.Min( startY + (defaultInputHeight + 4), Y + Height ) - startY;
drawer.Clear( foreGridCol, X, startY, Width, height );
}
if( !DrawColumnEntry( drawer, ref args, maxWidth, x, ref y, ref usedEntries[i] ) ) { if( !DrawColumnEntry( drawer, ref args, maxWidth, x, ref y, ref usedEntries[i] ) ) {
maxIndex = i; break; maxIndex = i; break;

View File

@ -65,7 +65,7 @@ namespace Launcher {
using( FastBitmap src = new FastBitmap( bmp, true ) ) { using( FastBitmap src = new FastBitmap( bmp, true ) ) {
Drawer2DExt.DrawScaledPixels( src, terrainPixels, size, Drawer2DExt.DrawScaledPixels( src, terrainPixels, size,
new Rectangle( 2 * elemSize, 0, elemSize, elemSize ), new Rectangle( 2 * elemSize, 0, elemSize, elemSize ),
new Rectangle( tileSize, 0, tileSize, tileSize ), 255, 255 ); new Rectangle( tileSize, 0, tileSize, tileSize ), 128, 64 );
Drawer2DExt.DrawScaledPixels( src, terrainPixels, size, Drawer2DExt.DrawScaledPixels( src, terrainPixels, size,
new Rectangle( 1 * elemSize, 0, elemSize, elemSize ), new Rectangle( 1 * elemSize, 0, elemSize, elemSize ),
new Rectangle( 0, 0, tileSize, tileSize ), 96, 96 ); new Rectangle( 0, 0, tileSize, tileSize ), 96, 96 );
@ -81,8 +81,8 @@ namespace Launcher {
if( ClassicBackground ) { if( ClassicBackground ) {
using( FastBitmap dst = new FastBitmap( Framebuffer, true ) ) { using( FastBitmap dst = new FastBitmap( Framebuffer, true ) ) {
ClearTile( 0, 0, Width, 48, tileSize, 128, 64, dst, true ); ClearTile( 0, 0, Width, 48, tileSize, dst );
ClearTile( 0, 48, Width, Height - 48, 0, 96, 96, dst, false ); ClearTile( 0, 48, Width, Height - 48, 0, dst );
} }
} else { } else {
ClearArea( 0, 0, Width, Height ); ClearArea( 0, 0, Width, Height );
@ -112,26 +112,21 @@ namespace Launcher {
public void ClearArea( int x, int y, int width, int height, FastBitmap dst ) { public void ClearArea( int x, int y, int width, int height, FastBitmap dst ) {
if( ClassicBackground ) { if( ClassicBackground ) {
ClearTile( x, y, width, height, 0, 96, 96, dst, false ); ClearTile( x, y, width, height, 0, dst );
} else { } else {
FastColour col = LauncherSkin.BackgroundCol; FastColour col = LauncherSkin.BackgroundCol;
Drawer2DExt.DrawNoise( dst, new Rectangle( x, y, width, height ), col, 6 ); Drawer2DExt.DrawNoise( dst, new Rectangle( x, y, width, height ), col, 6 );
} }
} }
void ClearTile( int x, int y, int width, int height, int srcX, void ClearTile( int x, int y, int width, int height, int srcX, FastBitmap dst ) {
byte scaleA, byte scaleB, FastBitmap dst, bool scale ) {
if( x >= Width || y >= Height ) return; if( x >= Width || y >= Height ) return;
Rectangle srcRect = new Rectangle( srcX, 0, tileSize, tileSize ); Rectangle srcRect = new Rectangle( srcX, 0, tileSize, tileSize );
Size size = new Size( tileSize, tileSize ); Size size = new Size( tileSize, tileSize );
Rectangle area = new Rectangle( x, y, width, height ); Rectangle area = new Rectangle( x, y, width, height );
area.Width = Math.Min( area.X + area.Width, dst.Width ) - area.X; area.Width = Math.Min( area.X + area.Width, dst.Width ) - area.X;
area.Height = Math.Min( area.Y + area.Height, dst.Height ) - area.Y; area.Height = Math.Min( area.Y + area.Height, dst.Height ) - area.Y;
Drawer2DExt.DrawTiledPixels( terrainPixels, dst, srcRect, area );
if( scale )
Drawer2DExt.DrawScaledPixels( terrainPixels, dst, size, srcRect, area, scaleA, scaleB );
else
Drawer2DExt.DrawTiledPixels( terrainPixels, dst, srcRect, area );
} }
} }
} }