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,10 +144,11 @@ namespace ClassicalSharp {
void DrawUnderline( FastBitmap dst, int x, int yOffset, ref DrawTextArgs args, bool shadowCol ) {
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 col = FastColour.White.ToArgb();
int col = FastColour.White.ToArgb();
string text = args.Text;
if( args.UseShadow ) height += offset;
int startX = x;

View File

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

View File

@ -16,15 +16,18 @@ namespace ClassicalSharp {
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 ) {
}
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 ) {
}
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;
X1 = x; Y1 = y;
Width = width; Height = height;

View File

@ -16,6 +16,8 @@ namespace ClassicalSharp.Gui {
if( !String.IsNullOrEmpty( text ) ) {
Texture tex = NextToken( text, 0, ref prevFlags ) == -1 ? DrawSimple( ref args ) :
DrawAdvanced( ref args, index, text );
ReducePadding( ref tex, Utils.Floor( args.Font.Size ) );
tex.X1 = CalcOffset( game.Width, tex.Width, XOffset, HorizontalAnchor );
tex.Y1 = CalcY( index, tex.Height );
Textures[index] = tex;
@ -29,6 +31,15 @@ namespace ClassicalSharp.Gui {
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 ) {
return game.Drawer2D.MakeChatTextTexture( ref args, 0, 0 );
}
@ -104,10 +115,10 @@ namespace ClassicalSharp.Gui {
return data;
}
void UpdatePreviousUrls( int i, string url ) {
void UpdatePreviousUrls( int i, string url ) {
while( i >= 0 && linkData[i].urls != null && (linkData[i].flags & LinkFlags.Continue) != 0 ) {
linkData[i].LastUrl = url;
if( linkData[i].urls.Length > 2 || (linkData[i].flags & LinkFlags.NewLink) != 0 )
if( linkData[i].urls.Length > 2 || (linkData[i].flags & LinkFlags.NewLink) != 0 )
break;
i--;
}
@ -137,7 +148,7 @@ namespace ClassicalSharp.Gui {
return 2;
}
prevFlags = 0;
prevFlags = 0;
int nextHttp = line.IndexOf( "http://", start );
int nextHttps = line.IndexOf( "https://", start );
return nextHttp == -1 ? nextHttps : nextHttp;
@ -172,7 +183,7 @@ namespace ClassicalSharp.Gui {
urls[index] = part;
}
public string LastUrl {
public string LastUrl {
get { return urls[parts.Length - 1]; }
set { urls[parts.Length - 1] = value; }
}

View File

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