mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 11:06:06 -04:00
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:
parent
31e9f24693
commit
a47118e652
@ -54,7 +54,7 @@ namespace Launcher {
|
|||||||
if( table.Count >= 1 && curServer == "" ) {
|
if( table.Count >= 1 && curServer == "" ) {
|
||||||
widgets[hashIndex].Text = table.usedEntries[0].Hash;
|
widgets[hashIndex].Text = table.usedEntries[0].Hash;
|
||||||
ConnectToServer( 0, 0 );
|
ConnectToServer( 0, 0 );
|
||||||
} else if( curServer != "" &&
|
} else if( curServer != "" &&
|
||||||
(selectedWidget == null || selectedWidget == widgets[tableIndex]) ) {
|
(selectedWidget == null || selectedWidget == widgets[tableIndex]) ) {
|
||||||
ConnectToServer( 0, 0 );
|
ConnectToServer( 0, 0 );
|
||||||
}
|
}
|
||||||
@ -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() {
|
||||||
@ -93,7 +93,7 @@ namespace Launcher {
|
|||||||
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
|
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
|
||||||
if( table != null )
|
if( table != null )
|
||||||
table.ClampIndex();
|
table.ClampIndex();
|
||||||
MakeWidgets();
|
MakeWidgets();
|
||||||
RedrawAllButtonBackgrounds();
|
RedrawAllButtonBackgrounds();
|
||||||
|
|
||||||
using( drawer ) {
|
using( drawer ) {
|
||||||
@ -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 ) {
|
|
||||||
FastColour col = LauncherTableWidget.backGridCol;
|
void DrawTableBackground( FastBitmap dst ) {
|
||||||
Drawer2DExt.FastClear( dst, rec, col );
|
int tableHeight = Math.Max( game.Height - tableY - 50, 1 );
|
||||||
} else {
|
Rectangle rec = new Rectangle( tableX, tableY, game.Width - tableX, tableHeight );
|
||||||
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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,8 +148,8 @@ namespace Launcher {
|
|||||||
widget.SetEntries( game.Session.Servers );
|
widget.SetEntries( game.Session.Servers );
|
||||||
|
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user