Fix underline on default.png backend (Thanks FabTheZen), reduce padding in chat.

This commit is contained in:
UnknownShadow200 2016-04-18 20:24:51 +10:00
parent 790e1f783a
commit a3d2a46baa
5 changed files with 26 additions and 12 deletions

View File

@ -144,7 +144,8 @@ namespace ClassicalSharp {
void DrawUnderline( FastBitmap dst, int x, int yOffset, ref DrawTextArgs args, bool shadowCol ) { void DrawUnderline( FastBitmap dst, int x, int yOffset, ref DrawTextArgs args, bool shadowCol ) {
int point = Utils.Floor( args.Font.Size ); int point = Utils.Floor( args.Font.Size );
int height = PtToPx( point, boxSize ); int padding = CellSize( point ) - AdjTextSize( point );
int height = AdjTextSize( point ) + Utils.CeilDiv(padding, 2);
int offset = ShadowOffset( args.Font.Size ); int offset = ShadowOffset( args.Font.Size );
int col = FastColour.White.ToArgb(); int col = FastColour.White.ToArgb();

View File

@ -84,7 +84,7 @@ namespace ClassicalSharp.Gui {
} }
public override void Init() { public override void Init() {
playerFont = new Font( game.FontName, 12 ); playerFont = new Font( game.FontName, 14 );
chat = new ChatScreen( game ); chat = new ChatScreen( game );
chat.Init(); chat.Init();
hotbar = new BlockHotbarWidget( game ); hotbar = new BlockHotbarWidget( game );

View File

@ -16,15 +16,18 @@ namespace ClassicalSharp {
public Rectangle Bounds { get { return new Rectangle( X1, Y1, Width, Height ); } } public Rectangle Bounds { get { return new Rectangle( X1, Y1, Width, Height ); } }
public Texture( int id, int x, int y, int width, int height, float u2, float v2 ) public Texture( int id, int x, int y, int width, int height,
float u2, float v2 )
: this( id, x, y, width, height, 0, u2, 0, v2 ) { : this( id, x, y, width, height, 0, u2, 0, v2 ) {
} }
public Texture( int id, int x, int y, int width, int height, TextureRec rec ) public Texture( int id, int x, int y, int width, int height,
TextureRec rec )
: this( id, x, y, width, height, rec.U1, rec.U2, rec.V1, rec.V2 ) { : this( id, x, y, width, height, rec.U1, rec.U2, rec.V1, rec.V2 ) {
} }
public Texture( int id, int x, int y, int width, int height, float u1, float u2, float v1, float v2 ) { public Texture( int id, int x, int y, int width, int height,
float u1, float u2, float v1, float v2 ) {
ID = id; ID = id;
X1 = x; Y1 = y; X1 = x; Y1 = y;
Width = width; Height = height; Width = width; Height = height;

View File

@ -16,6 +16,8 @@ namespace ClassicalSharp.Gui {
if( !String.IsNullOrEmpty( text ) ) { if( !String.IsNullOrEmpty( text ) ) {
Texture tex = NextToken( text, 0, ref prevFlags ) == -1 ? DrawSimple( ref args ) : Texture tex = NextToken( text, 0, ref prevFlags ) == -1 ? DrawSimple( ref args ) :
DrawAdvanced( ref args, index, text ); DrawAdvanced( ref args, index, text );
ReducePadding( ref tex, Utils.Floor( args.Font.Size ) );
tex.X1 = CalcOffset( game.Width, tex.Width, XOffset, HorizontalAnchor ); tex.X1 = CalcOffset( game.Width, tex.Width, XOffset, HorizontalAnchor );
tex.Y1 = CalcY( index, tex.Height ); tex.Y1 = CalcY( index, tex.Height );
Textures[index] = tex; Textures[index] = tex;
@ -29,6 +31,15 @@ namespace ClassicalSharp.Gui {
UpdateDimensions(); UpdateDimensions();
} }
void ReducePadding( ref Texture tex, int point ) {
int padding = tex.Height - Utils.Floor( font.Size );
padding /= 4;
float vAdj = (float)padding / Utils.NextPowerOf2( tex.Height );
tex.V1 += vAdj; tex.V2 -= vAdj;
tex.Height -= padding * 2;
}
Texture DrawSimple( ref DrawTextArgs args ) { Texture DrawSimple( ref DrawTextArgs args ) {
return game.Drawer2D.MakeChatTextTexture( ref args, 0, 0 ); return game.Drawer2D.MakeChatTextTexture( ref args, 0, 0 );
} }

View File

@ -35,11 +35,10 @@ namespace ClassicalSharp.Gui {
api.Texturing = true; api.Texturing = true;
for( int i = 0; i < namesCount; i++ ) { for( int i = 0; i < namesCount; i++ ) {
Texture texture = textures[i]; Texture texture = textures[i];
if( texture.IsValid ) { if( texture.IsValid )
texture.Render( api ); texture.Render( api );
} }
} }
}
public override void Dispose() { public override void Dispose() {
for( int i = 0; i < namesCount; i++ ) { for( int i = 0; i < namesCount; i++ ) {