mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-25 14:14:46 -04:00
Launcher: Blend input box top
This commit is contained in:
parent
ffacf8e8e2
commit
88ee8aa432
@ -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;
|
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;
|
return;
|
||||||
int pixel = col.ToArgb();
|
int pixel = col.ToArgb();
|
||||||
|
|
||||||
for( int yy = 0; yy < height; yy++ ) {
|
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++ )
|
for( int xx = 0; xx < width; xx++ )
|
||||||
row[x + xx] = pixel;
|
row[x + xx] = pixel;
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,9 @@ namespace Launcher.Gui.Screens {
|
|||||||
curInput.Redraw( drawer );
|
curInput.Redraw( drawer );
|
||||||
|
|
||||||
Rectangle r = curInput.MeasureCaret( drawer, inputFont );
|
Rectangle r = curInput.MeasureCaret( drawer, inputFont );
|
||||||
if( caretShow )
|
if( caretShow ) {
|
||||||
drawer.Clear( FastColour.White, r.X, r.Y, r.Width, r.Height );
|
drawer.Clear( FastColour.Black, r.X, r.Y, r.Width, r.Height );
|
||||||
|
}
|
||||||
|
|
||||||
if( lastRec == r ) game.DirtyArea = r;
|
if( lastRec == r ) game.DirtyArea = r;
|
||||||
lastRec = r;
|
lastRec = r;
|
||||||
|
@ -66,7 +66,7 @@ namespace Launcher.Gui.Views {
|
|||||||
const int progWidth = 200, progHalf = 5;
|
const int progWidth = 200, progHalf = 5;
|
||||||
internal void DrawProgressBox( int progress ) {
|
internal void DrawProgressBox( int progress ) {
|
||||||
progress = (progWidth * progress) / 100;
|
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,
|
Rectangle r = new Rectangle( game.Width / 2 - progWidth / 2,
|
||||||
game.Height / 2 + 10, progWidth, progHalf );
|
game.Height / 2 + 10, progWidth, progHalf );
|
||||||
DrawBoxBounds( bmp, r );
|
DrawBoxBounds( bmp, r );
|
||||||
|
@ -64,7 +64,7 @@ namespace Launcher.Gui.Widgets {
|
|||||||
|
|
||||||
public void RedrawBackground() {
|
public void RedrawBackground() {
|
||||||
if( Window.Minimised ) return;
|
if( Window.Minimised ) return;
|
||||||
using( FastBitmap dst = new FastBitmap( Window.Framebuffer, true, false ) )
|
using( FastBitmap dst = Window.LockBits() )
|
||||||
RedrawBackground( dst );
|
RedrawBackground( dst );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT
|
// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
|
||||||
using ClassicalSharp;
|
using ClassicalSharp;
|
||||||
|
|
||||||
namespace Launcher.Gui.Widgets {
|
namespace Launcher.Gui.Widgets {
|
||||||
@ -29,7 +28,7 @@ namespace Launcher.Gui.Widgets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void SetDrawData( IDrawer2D drawer, string text, Font font, Font hintFont,
|
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;
|
ButtonWidth = width; ButtonHeight = height;
|
||||||
Width = width; Height = height;
|
Width = width; Height = height;
|
||||||
SetAnchors( horAnchor, verAnchor ).SetOffsets( x, y )
|
SetAnchors( horAnchor, verAnchor ).SetOffsets( x, y )
|
||||||
@ -53,7 +52,7 @@ namespace Launcher.Gui.Widgets {
|
|||||||
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
||||||
Size size = drawer.MeasureSize( ref args );
|
Size size = drawer.MeasureSize( ref args );
|
||||||
Width = Math.Max( ButtonWidth, size.Width + 15 );
|
Width = Math.Max( ButtonWidth, size.Width + 15 );
|
||||||
textHeight = size.Height;
|
textHeight = size.Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Redraw( IDrawer2D drawer ) {
|
public override void Redraw( IDrawer2D drawer ) {
|
||||||
@ -67,7 +66,12 @@ namespace Launcher.Gui.Widgets {
|
|||||||
args.SkipPartsCheck = true;
|
args.SkipPartsCheck = true;
|
||||||
if( Window.Minimised ) return;
|
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 );
|
DrawText( drawer, args );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,24 +79,39 @@ namespace Launcher.Gui.Widgets {
|
|||||||
static FastColour borderOut = new FastColour( 97, 81, 110 );
|
static FastColour borderOut = new FastColour( 97, 81, 110 );
|
||||||
const int border = 1;
|
const int border = 1;
|
||||||
|
|
||||||
void DrawBorders( IDrawer2D drawer ) {
|
void DrawOuterBorder( FastBitmap bmp ) {
|
||||||
FastColour col = borderOut;
|
FastColour col = borderOut;
|
||||||
if( Active ) {
|
if( Active ) {
|
||||||
drawer.Clear( col, X, Y, Width, border );
|
Clear( bmp, col, X, Y, Width, border );
|
||||||
drawer.Clear( col, X, Y + Height - border, Width, border );
|
Clear( bmp, col, X, Y + Height - border, Width, border );
|
||||||
drawer.Clear( col, X, Y, border, Height );
|
Clear( bmp, col, X, Y, border, Height );
|
||||||
drawer.Clear( col, X + Width - border, Y, border, Height );
|
Clear( bmp, col, X + Width - border, Y, border, Height );
|
||||||
} else {
|
} 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 );
|
void DrawInnerBorder( FastBitmap bmp ) {
|
||||||
drawer.Clear( col, X + border, Y + Height - border * 2, Width - border * 2, border );
|
FastColour col = borderIn;
|
||||||
drawer.Clear( col, X + border, Y + border, border, Height - border * 2 );
|
Clear( bmp, col, X + border, Y + border, Width - border * 2, border );
|
||||||
drawer.Clear( col, X + Width - border * 2, Y + border, border, Height - border * 2 );
|
Clear( bmp, col, X + border, Y + Height - border * 2, Width - border * 2, border );
|
||||||
|
Clear( bmp, col, X + border, Y + border, border, Height - border * 2 );
|
||||||
drawer.Clear( FastColour.White, X + 2, Y + 2, Width - 4, Height - 4 );
|
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 ) {
|
void DrawText( IDrawer2D drawer, DrawTextArgs args ) {
|
||||||
@ -114,7 +133,7 @@ namespace Launcher.Gui.Widgets {
|
|||||||
public Rectangle MeasureCaret( IDrawer2D drawer, Font font ) {
|
public Rectangle MeasureCaret( IDrawer2D drawer, Font font ) {
|
||||||
string text = Text;
|
string text = Text;
|
||||||
if( Password )
|
if( Password )
|
||||||
text = new String( '*', text.Length );
|
text = new String( '*', text.Length );
|
||||||
Rectangle r = new Rectangle( X + 5, Y + Height - 5, 0, 2 );
|
Rectangle r = new Rectangle( X + 5, Y + Height - 5, 0, 2 );
|
||||||
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
||||||
|
|
||||||
|
@ -92,9 +92,9 @@ namespace Launcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( ClassicBackground && terrainPixels != null ) {
|
if( ClassicBackground && terrainPixels != null ) {
|
||||||
using( FastBitmap dst = new FastBitmap( Framebuffer, true, false ) ) {
|
using( FastBitmap bmp = LockBits() ) {
|
||||||
ClearTile( 0, 0, Width, 48, tileSize, dst );
|
ClearTile( 0, 0, Width, 48, tileSize, bmp );
|
||||||
ClearTile( 0, 48, Width, Height - 48, 0, dst );
|
ClearTile( 0, 48, Width, Height - 48, 0, bmp );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ResetArea( 0, 0, Width, Height );
|
ResetArea( 0, 0, Width, Height );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user