Don't draw to framebuffer when the window is minimised, fixes crashing.

This commit is contained in:
UnknownShadow200 2016-01-28 15:34:34 +11:00
parent 09f0a04efa
commit f8866017a1
5 changed files with 12 additions and 1 deletions

View File

@ -22,6 +22,7 @@ namespace Launcher2 {
}
public override void Redraw( IDrawer2D drawer ) {
if( Window.Minimised ) return;
drawer.DrawRect( FastColour.Black, X, Y, Width, Height );
if( Value ) {
DrawTextArgs args = new DrawTextArgs( "X", font, false );

View File

@ -27,6 +27,7 @@ namespace Launcher2 {
}
public override void Redraw( IDrawer2D drawer ) {
if( Window.Minimised ) return;
string text = Text;
if( !Active ) text = "&7" + text;
int xOffset = Width - textSize.Width, yOffset = Height - textSize.Height;
@ -62,11 +63,13 @@ namespace Launcher2 {
}
public void RedrawBackground() {
if( Window.Minimised ) return;
using( FastBitmap dst = new FastBitmap( Window.Framebuffer, true ) )
RedrawBackground( dst );
}
public void RedrawBackground( FastBitmap dst ) {
if( Window.Minimised ) return;
Rectangle rect = new Rectangle( X + border, Y + border, Width - border * 2, Height - border * 2 );
if( Window.ClassicMode ) {
FastColour foreCol = Active ? new FastColour( 126, 136, 191 ) : new FastColour( 111, 111, 111 );

View File

@ -74,6 +74,7 @@ namespace Launcher2 {
Width = Math.Max( ButtonWidth, size.Width + 15 );
textHeight = size.Height;
args.SkipPartsCheck = true;
if( Window.Minimised ) return;
FastColour col = Active ? new FastColour( 240, 240, 240 ) : new FastColour( 180, 180, 180 );
drawer.Clear( col, X + 1, Y, Width - 2, 2 );

View File

@ -24,6 +24,7 @@ namespace Launcher2 {
}
public override void Redraw( IDrawer2D drawer ) {
if( Window.Minimised ) return;
DrawTextArgs args = new DrawTextArgs( Text, font, true );
drawer.DrawText( ref args, X, Y );
}

View File

@ -44,6 +44,10 @@ namespace Launcher2 {
/// <summary> Whether at the next tick, the launcher window should proceed to stop displaying frames and subsequently exit. </summary>
public bool ShouldExit;
public bool Minimised {
get { return Window.WindowState == WindowState.Minimized || (Width == 1 && Height == 1); }
}
/// <summary> Contains metadata attached for different screen instances,
/// typically used to save 'last text entered' text when a screen is disposed. </summary>
public Dictionary<string, Dictionary<string, object>> ScreenMetadata =
@ -60,6 +64,7 @@ namespace Launcher2 {
logoFont = new Font( "Arial", 24, FontStyle.Regular );
string path = Assembly.GetExecutingAssembly().Location;
Window.Icon = Icon.ExtractAssociatedIcon( path );
//Minimised = Window.WindowState == WindowState.Minimized;
if( Configuration.RunningOnWindows )
platformDrawer = new WinPlatformDrawer();