diff --git a/Launcher2/Drawing/Drawer2DExt.cs b/Launcher2/Drawing/Drawer2DExt.cs index 1d7f6905b..7f3ac03d9 100644 --- a/Launcher2/Drawing/Drawer2DExt.cs +++ b/Launcher2/Drawing/Drawer2DExt.cs @@ -50,14 +50,14 @@ namespace Launcher { } } - public static void Clear( FastBitmap dst, Rectangle dstRect, FastColour col ) { + public static void Clear( FastBitmap bmp, Rectangle rect, FastColour col ) { int x, y, width, height; - if( !ClampCoords( dst, dstRect, out x, out y, out width, out height ) ) + if( !ClampCoords( bmp, rect, out x, out y, out width, out height ) ) return; int pixel = col.ToArgb(); for( int yy = 0; yy < height; yy++ ) { - int* row = dst.GetRowPtr( y + yy ); + int* row = bmp.GetRowPtr( y + yy ); for( int xx = 0; xx < width; xx++ ) row[x + xx] = pixel; } diff --git a/Launcher2/Gui/Screens/LauncherInputScreen.cs b/Launcher2/Gui/Screens/LauncherInputScreen.cs index c6f481207..71ee67308 100644 --- a/Launcher2/Gui/Screens/LauncherInputScreen.cs +++ b/Launcher2/Gui/Screens/LauncherInputScreen.cs @@ -45,8 +45,9 @@ namespace Launcher.Gui.Screens { curInput.Redraw( drawer ); Rectangle r = curInput.MeasureCaret( drawer, inputFont ); - if( caretShow ) - drawer.Clear( FastColour.White, r.X, r.Y, r.Width, r.Height ); + if( caretShow ) { + drawer.Clear( FastColour.Black, r.X, r.Y, r.Width, r.Height ); + } if( lastRec == r ) game.DirtyArea = r; lastRec = r; diff --git a/Launcher2/Gui/Views/ResourcesView.cs b/Launcher2/Gui/Views/ResourcesView.cs index 23981a321..123f4688d 100644 --- a/Launcher2/Gui/Views/ResourcesView.cs +++ b/Launcher2/Gui/Views/ResourcesView.cs @@ -66,7 +66,7 @@ namespace Launcher.Gui.Views { const int progWidth = 200, progHalf = 5; internal void DrawProgressBox( int progress ) { progress = (progWidth * progress) / 100; - using( FastBitmap bmp = new FastBitmap( game.Framebuffer, true, false ) ) { + using( FastBitmap bmp = game.LockBits() ) { Rectangle r = new Rectangle( game.Width / 2 - progWidth / 2, game.Height / 2 + 10, progWidth, progHalf ); DrawBoxBounds( bmp, r ); diff --git a/Launcher2/Gui/Widgets/LauncherButtonWidget.cs b/Launcher2/Gui/Widgets/LauncherButtonWidget.cs index 6ce9a8a0d..5faa94b4a 100644 --- a/Launcher2/Gui/Widgets/LauncherButtonWidget.cs +++ b/Launcher2/Gui/Widgets/LauncherButtonWidget.cs @@ -64,7 +64,7 @@ namespace Launcher.Gui.Widgets { public void RedrawBackground() { if( Window.Minimised ) return; - using( FastBitmap dst = new FastBitmap( Window.Framebuffer, true, false ) ) + using( FastBitmap dst = Window.LockBits() ) RedrawBackground( dst ); } diff --git a/Launcher2/Gui/Widgets/LauncherInputWidget.cs b/Launcher2/Gui/Widgets/LauncherInputWidget.cs index 19be2ee2b..6e8984eb1 100644 --- a/Launcher2/Gui/Widgets/LauncherInputWidget.cs +++ b/Launcher2/Gui/Widgets/LauncherInputWidget.cs @@ -1,7 +1,6 @@ // ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT using System; using System.Drawing; -using System.Windows.Forms; using ClassicalSharp; namespace Launcher.Gui.Widgets { @@ -29,7 +28,7 @@ namespace Launcher.Gui.Widgets { } public void SetDrawData( IDrawer2D drawer, string text, Font font, Font hintFont, - Anchor horAnchor, Anchor verAnchor, int width, int height, int x, int y ) { + Anchor horAnchor, Anchor verAnchor, int width, int height, int x, int y ) { ButtonWidth = width; ButtonHeight = height; Width = width; Height = height; SetAnchors( horAnchor, verAnchor ).SetOffsets( x, y ) @@ -53,7 +52,7 @@ namespace Launcher.Gui.Widgets { DrawTextArgs args = new DrawTextArgs( text, font, true ); Size size = drawer.MeasureSize( ref args ); Width = Math.Max( ButtonWidth, size.Width + 15 ); - textHeight = size.Height; + textHeight = size.Height; } public override void Redraw( IDrawer2D drawer ) { @@ -67,7 +66,12 @@ namespace Launcher.Gui.Widgets { args.SkipPartsCheck = true; if( Window.Minimised ) return; - DrawBorders( drawer ); + using( FastBitmap bmp = Window.LockBits() ) { + DrawOuterBorder( bmp ); + DrawInnerBorder( bmp ); + Clear( bmp, FastColour.White, X + 2, Y + 2, Width - 4, Height - 4 ); + BlendBoxTop( bmp ); + } DrawText( drawer, args ); } @@ -75,24 +79,39 @@ namespace Launcher.Gui.Widgets { static FastColour borderOut = new FastColour( 97, 81, 110 ); const int border = 1; - void DrawBorders( IDrawer2D drawer ) { + void DrawOuterBorder( FastBitmap bmp ) { FastColour col = borderOut; if( Active ) { - drawer.Clear( col, X, Y, Width, border ); - drawer.Clear( col, X, Y + Height - border, Width, border ); - drawer.Clear( col, X, Y, border, Height ); - drawer.Clear( col, X + Width - border, Y, border, Height ); + Clear( bmp, col, X, Y, Width, border ); + Clear( bmp, col, X, Y + Height - border, Width, border ); + Clear( bmp, col, X, Y, border, Height ); + Clear( bmp, col, X + Width - border, Y, border, Height ); } else { - //Window.ResetArea( X, Y, Width, + Window.ResetArea( X, Y, Width, border, bmp ); + Window.ResetArea( X, Y + Height - border, Width, border, bmp ); + Window.ResetArea( X, Y, border, Height, bmp ); + Window.ResetArea( X + Width - border, Y, border, Height, bmp ); } - - col = borderIn; - drawer.Clear( col, X + border, Y + border, Width - border * 2, border ); - drawer.Clear( col, X + border, Y + Height - border * 2, Width - border * 2, border ); - drawer.Clear( col, X + border, Y + border, border, Height - border * 2 ); - drawer.Clear( col, X + Width - border * 2, Y + border, border, Height - border * 2 ); - - drawer.Clear( FastColour.White, X + 2, Y + 2, Width - 4, Height - 4 ); + } + + void DrawInnerBorder( FastBitmap bmp ) { + FastColour col = borderIn; + Clear( bmp, col, X + border, Y + border, Width - border * 2, border ); + Clear( bmp, col, X + border, Y + Height - border * 2, Width - border * 2, border ); + Clear( bmp, col, X + border, Y + border, border, Height - border * 2 ); + Clear( bmp, col, X + Width - border * 2, Y + border, border, Height - border * 2 ); + } + + void BlendBoxTop( FastBitmap bmp ) { + Rectangle r = new Rectangle( X + border, Y, Width - border * 2, border ); + r.Y += border; Gradient.Blend( bmp, r, FastColour.Black, 75 ); + r.Y += border; Gradient.Blend( bmp, r, FastColour.Black, 50 ); + r.Y += border; Gradient.Blend( bmp, r, FastColour.Black, 25 ); + } + + void Clear( FastBitmap bmp, FastColour col, + int x, int y, int width, int height ) { + Drawer2DExt.Clear( bmp, new Rectangle( x, y, width, height ), col ); } void DrawText( IDrawer2D drawer, DrawTextArgs args ) { @@ -114,7 +133,7 @@ namespace Launcher.Gui.Widgets { public Rectangle MeasureCaret( IDrawer2D drawer, Font font ) { string text = Text; if( Password ) - text = new String( '*', text.Length ); + text = new String( '*', text.Length ); Rectangle r = new Rectangle( X + 5, Y + Height - 5, 0, 2 ); DrawTextArgs args = new DrawTextArgs( text, font, true ); diff --git a/Launcher2/LauncherWindow.Background.cs b/Launcher2/LauncherWindow.Background.cs index 2933a75c5..5687c0974 100644 --- a/Launcher2/LauncherWindow.Background.cs +++ b/Launcher2/LauncherWindow.Background.cs @@ -92,9 +92,9 @@ namespace Launcher { } if( ClassicBackground && terrainPixels != null ) { - using( FastBitmap dst = new FastBitmap( Framebuffer, true, false ) ) { - ClearTile( 0, 0, Width, 48, tileSize, dst ); - ClearTile( 0, 48, Width, Height - 48, 0, dst ); + using( FastBitmap bmp = LockBits() ) { + ClearTile( 0, 0, Width, 48, tileSize, bmp ); + ClearTile( 0, 48, Width, Height - 48, 0, bmp ); } } else { ResetArea( 0, 0, Width, Height );