Use ChatText methods everywhere now, except for titles.

This commit is contained in:
UnknownShadow200 2016-04-19 12:18:25 +10:00
parent b9368a8a62
commit 7d1e716eb4
5 changed files with 32 additions and 15 deletions

View File

@ -29,8 +29,9 @@ namespace ClassicalSharp.Gui {
if( keyNames == null )
keyNames = Enum.GetNames( typeof( Key ) );
keyFont = new Font( game.FontName, 15, FontStyle.Bold );
regularFont = new Font( game.FontName, 15, FontStyle.Italic );
statusWidget = TextWidget.Create( game, 0, 130, "", Anchor.Centre, Anchor.Centre, regularFont );
regularFont = new Font( game.FontName, 16, FontStyle.Italic );
statusWidget = ChatTextWidget.Create( game, 0, 130, "",
Anchor.Centre, Anchor.Centre, regularFont );
}
protected int index;

View File

@ -28,7 +28,7 @@ namespace ClassicalSharp.Gui {
public override void Init() {
titleFont = new Font( game.FontName, 16, FontStyle.Bold );
regularFont = new Font( game.FontName, 14, FontStyle.Regular );
regularFont = new Font( game.FontName, 16, FontStyle.Regular );
InitStandardButtons();
SetText( title, body );
}
@ -58,8 +58,9 @@ namespace ClassicalSharp.Gui {
labels[0] = TextWidget.Create( game, 0, -120, title,
Anchor.Centre, Anchor.Centre, titleFont );
for( int i = 0; i < body.Length; i++ ) {
labels[i + 1] = TextWidget.Create( game, 0, -70 + 20 * i, body[i],
labels[i + 1] = ChatTextWidget.Create( game, 0, -70 + 20 * i, body[i],
Anchor.Centre, Anchor.Centre, regularFont );
labels[i + 1].Colour = new FastColour( 224, 224, 224 );
}
}
TextWidget[] labels;

View File

@ -35,7 +35,7 @@ namespace ClassicalSharp.Gui {
public override void Init() {
DrawTextArgs args = new DrawTextArgs( "I", font, true );
defaultHeight = game.Drawer2D.MeasureSize( ref args ).Height;
defaultHeight = game.Drawer2D.MeasureChatSize( ref args ).Height;
Height = defaultHeight;
}

View File

@ -51,7 +51,7 @@ namespace ClassicalSharp.Gui {
public override void Init() {
DrawTextArgs caretArgs = new DrawTextArgs( "_", boldFont, false );
chatCaretTexture = game.Drawer2D.MakeTextTexture( ref caretArgs, 0, 0 );
chatCaretTexture = game.Drawer2D.MakeChatTextTexture( ref caretArgs, 0, 0 );
SetText( chatInputText.GetString() );
}
@ -60,7 +60,16 @@ namespace ClassicalSharp.Gui {
chatInputText.Clear();
chatInputText.Append( 0, value );
DrawTextArgs args = new DrawTextArgs( value, font, false );
Size textSize = game.Drawer2D.MeasureSize( ref args );
Size textSize = game.Drawer2D.MeasureChatSize( ref args );
// Ensure we don't have 0 text height
if( textSize.Height == 0 ) {
args.Text = Validator.Range;
textSize.Height = game.Drawer2D.MeasureChatSize( ref args ).Height;
args.Text = value;
} else {
args.SkipPartsCheck = true;
}
Size size = new Size( Math.Max( textSize.Width, DesiredMaxWidth ),
Math.Max( textSize.Height, DesiredMaxHeight ) );
yOffset = 0;
@ -72,18 +81,17 @@ namespace ClassicalSharp.Gui {
{
drawer.SetBitmap( bmp );
drawer.DrawRect( backColour, 0, 0, size.Width, size.Height );
args.SkipPartsCheck = true;
drawer.DrawText( ref args, 0, 0 );
drawer.DrawChatText( ref args, 3, yOffset );
args.Text = Validator.Range;
args.SkipPartsCheck = false;
Size hintSize = drawer.MeasureSize( ref args );
Size hintSize = drawer.MeasureChatSize( ref args );
args.SkipPartsCheck = true;
int hintX = size.Width - hintSize.Width;
if( textSize.Width < hintX )
drawer.DrawText( ref args, hintX, 0 );
chatInputTexture = drawer.Make2DTexture( bmp, size, 0, yOffset );
if( textSize.Width + 3 < hintX )
drawer.DrawChatText( ref args, hintX, yOffset );
chatInputTexture = drawer.Make2DTexture( bmp, size, 0, 0 );
}
X = CalcOffset( game.Width, size.Width, XOffset, HorizontalAnchor );

View File

@ -67,18 +67,25 @@ namespace ClassicalSharp {
string url = identifier.Substring( 3 );
float contentLengthMB = (contentLength / 1024f / 1024f );
string address = url;
if( url.StartsWith( "https://" ) ) address = url.Substring( 8 );
if( url.StartsWith( "http://" ) ) address = url.Substring( 7 );
screen.SetText( "Do you want to download the server's texture pack?",
"Texture pack url:", url,
"Texture pack url:", address,
"Download size: " + contentLengthMB.ToString( "F3" ) + " MB" );
}
protected internal void RetrieveTexturePack( string url ) {
if( !game.AcceptedUrls.HasUrl( url ) && !game.DeniedUrls.HasUrl( url ) ) {
game.AsyncDownloader.RetrieveContentLength( url, true, "CL_" + url );
string address = url;
if( url.StartsWith( "https://" ) ) address = url.Substring( 8 );
if( url.StartsWith( "http://" ) ) address = url.Substring( 7 );
game.ShowWarning( new WarningScreen(
game, "CL_" + url, true, true, "Do you want to download the server's texture pack?",
DownloadTexturePack, null, WarningScreenTick,
"Texture pack url:", url,
"Texture pack url:", address,
"Download size: Determining..." ) );
} else {
DownloadTexturePack( url );