mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-27 15:29:36 -04:00
Fix minor issue with ErrorScreen unnecessarily redrawing the button.
This commit is contained in:
parent
6b2651b8fb
commit
e39be25b3f
@ -84,16 +84,20 @@ namespace ClassicalSharp.Gui {
|
|||||||
|
|
||||||
int lastSecsLeft;
|
int lastSecsLeft;
|
||||||
const int delay = 5;
|
const int delay = 5;
|
||||||
|
bool lastActive = false;
|
||||||
void UpdateReconnectState( double delta ) {
|
void UpdateReconnectState( double delta ) {
|
||||||
ButtonWidget btn = (ButtonWidget)widgets[2];
|
ButtonWidget btn = (ButtonWidget)widgets[2];
|
||||||
double elapsed = (DateTime.UtcNow - initTime).TotalSeconds;
|
double elapsed = (DateTime.UtcNow - initTime).TotalSeconds;
|
||||||
int scsLeft = Math.Max( 0, (int)(delay - elapsed) );
|
int secsLeft = Math.Max( 0, (int)(delay - elapsed) );
|
||||||
if( lastSecsLeft == scsLeft ) return;
|
if( lastSecsLeft == secsLeft && btn.Active == lastActive ) return;
|
||||||
|
|
||||||
|
if( secsLeft == 0 ) btn.SetText( "Try to reconnect" );
|
||||||
|
else btn.SetText( "Try to reconnect.. " + secsLeft );
|
||||||
|
btn.Disabled = secsLeft != 0;
|
||||||
|
|
||||||
string suffix = scsLeft == 0 ? "" : ".. " + scsLeft;
|
|
||||||
btn.SetText( "Try to reconnect" + suffix );
|
|
||||||
btn.Disabled = scsLeft != 0;
|
|
||||||
Redraw( delta );
|
Redraw( delta );
|
||||||
|
lastSecsLeft = secsLeft;
|
||||||
|
lastActive = btn.Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly FastColour top = new FastColour( 64, 32, 32 ), bottom = new FastColour( 80, 16, 16 );
|
readonly FastColour top = new FastColour( 64, 32, 32 ), bottom = new FastColour( 80, 16, 16 );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user