Slightly optimise when table selected changes, by only redrawing the table. (And not the other widgets and top bit of the background)

This commit is contained in:
UnknownShadow200 2016-04-01 13:21:59 +11:00
parent 31e9f24693
commit a47118e652

View File

@ -75,7 +75,7 @@ namespace Launcher {
return; return;
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex]; LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
table.SetSelected( widgets[hashIndex].Text ); table.SetSelected( widgets[hashIndex].Text );
Resize(); RedrawTable();
} }
public override void Init() { public override void Init() {
@ -121,15 +121,19 @@ namespace Launcher {
void DrawBackground() { void DrawBackground() {
using( FastBitmap dst = new FastBitmap( game.Framebuffer, true ) ) { using( FastBitmap dst = new FastBitmap( game.Framebuffer, true ) ) {
game.ClearArea( 0, 0, game.Width, tableY, dst ); game.ClearArea( 0, 0, game.Width, tableY, dst );
int tableHeight = Math.Max( game.Height - tableY - 50, 1 ); DrawTableBackground( dst );
Rectangle rec = new Rectangle( tableX, tableY, game.Width - tableX, tableHeight ); }
}
if( !game.ClassicBackground ) { void DrawTableBackground( FastBitmap dst ) {
FastColour col = LauncherTableWidget.backGridCol; int tableHeight = Math.Max( game.Height - tableY - 50, 1 );
Drawer2DExt.FastClear( dst, rec, col ); Rectangle rec = new Rectangle( tableX, tableY, game.Width - tableX, tableHeight );
} else {
game.ClearArea( rec.X, rec.Y, rec.Width, rec.Height, dst ); if( !game.ClassicBackground ) {
} FastColour col = LauncherTableWidget.backGridCol;
Drawer2DExt.FastClear( dst, rec, col );
} else {
game.ClearArea( rec.X, rec.Y, rec.Width, rec.Height, dst );
} }
} }
@ -145,7 +149,7 @@ namespace Launcher {
widget.SetDrawData( drawer, tableFont, inputFont, inputFont, widget.SetDrawData( drawer, tableFont, inputFont, inputFont,
Anchor.LeftOrTop, Anchor.LeftOrTop, tableX, tableY ); Anchor.LeftOrTop, Anchor.LeftOrTop, tableX, tableY );
widget.NeedRedraw = Resize; widget.NeedRedraw = RedrawTable;
widget.SelectedChanged = SelectedChanged; widget.SelectedChanged = SelectedChanged;
widget.SortDefault(); widget.SortDefault();
widgets[widgetIndex] = widget; widgets[widgetIndex] = widget;
@ -160,8 +164,7 @@ namespace Launcher {
return; return;
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex]; LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
table.FilterEntries( lastInput.Text ); table.FilterEntries( lastInput.Text );
table.ClampIndex(); RedrawTable();
Resize();
} }
void SelectedChanged( string hash ) { void SelectedChanged( string hash ) {
@ -180,8 +183,7 @@ namespace Launcher {
protected override void MouseWheelChanged( object sender, MouseWheelEventArgs e ) { protected override void MouseWheelChanged( object sender, MouseWheelEventArgs e ) {
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex]; LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
table.CurrentIndex -= e.Delta; table.CurrentIndex -= e.Delta;
table.ClampIndex(); RedrawTable();
Resize();
} }
string HashFilter( string input ) { string HashFilter( string input ) {
@ -208,5 +210,20 @@ namespace Launcher {
table.DraggingScrollbar = false; table.DraggingScrollbar = false;
} }
} }
void RedrawTable() {
using( FastBitmap dst = new FastBitmap( game.Framebuffer, true ) )
DrawTableBackground( dst );
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
table.ClampIndex();
int tableHeight = Math.Max( game.Height - tableY - 50, 1 );
table.Height = tableHeight;
using( drawer ) {
drawer.SetBitmap( game.Framebuffer );
table.Redraw( drawer );
}
Dirty = true;
}
} }
} }