mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Use ChatText methods everywhere now, except for titles.
This commit is contained in:
parent
b9368a8a62
commit
7d1e716eb4
@ -29,8 +29,9 @@ namespace ClassicalSharp.Gui {
|
|||||||
if( keyNames == null )
|
if( keyNames == null )
|
||||||
keyNames = Enum.GetNames( typeof( Key ) );
|
keyNames = Enum.GetNames( typeof( Key ) );
|
||||||
keyFont = new Font( game.FontName, 15, FontStyle.Bold );
|
keyFont = new Font( game.FontName, 15, FontStyle.Bold );
|
||||||
regularFont = new Font( game.FontName, 15, FontStyle.Italic );
|
regularFont = new Font( game.FontName, 16, FontStyle.Italic );
|
||||||
statusWidget = TextWidget.Create( game, 0, 130, "", Anchor.Centre, Anchor.Centre, regularFont );
|
statusWidget = ChatTextWidget.Create( game, 0, 130, "",
|
||||||
|
Anchor.Centre, Anchor.Centre, regularFont );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int index;
|
protected int index;
|
||||||
|
@ -28,7 +28,7 @@ namespace ClassicalSharp.Gui {
|
|||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
titleFont = new Font( game.FontName, 16, FontStyle.Bold );
|
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();
|
InitStandardButtons();
|
||||||
SetText( title, body );
|
SetText( title, body );
|
||||||
}
|
}
|
||||||
@ -58,8 +58,9 @@ namespace ClassicalSharp.Gui {
|
|||||||
labels[0] = TextWidget.Create( game, 0, -120, title,
|
labels[0] = TextWidget.Create( game, 0, -120, title,
|
||||||
Anchor.Centre, Anchor.Centre, titleFont );
|
Anchor.Centre, Anchor.Centre, titleFont );
|
||||||
for( int i = 0; i < body.Length; i++ ) {
|
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 );
|
Anchor.Centre, Anchor.Centre, regularFont );
|
||||||
|
labels[i + 1].Colour = new FastColour( 224, 224, 224 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TextWidget[] labels;
|
TextWidget[] labels;
|
||||||
|
@ -35,7 +35,7 @@ namespace ClassicalSharp.Gui {
|
|||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
DrawTextArgs args = new DrawTextArgs( "I", font, true );
|
DrawTextArgs args = new DrawTextArgs( "I", font, true );
|
||||||
defaultHeight = game.Drawer2D.MeasureSize( ref args ).Height;
|
defaultHeight = game.Drawer2D.MeasureChatSize( ref args ).Height;
|
||||||
Height = defaultHeight;
|
Height = defaultHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ namespace ClassicalSharp.Gui {
|
|||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
DrawTextArgs caretArgs = new DrawTextArgs( "_", boldFont, false );
|
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() );
|
SetText( chatInputText.GetString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,16 @@ namespace ClassicalSharp.Gui {
|
|||||||
chatInputText.Clear();
|
chatInputText.Clear();
|
||||||
chatInputText.Append( 0, value );
|
chatInputText.Append( 0, value );
|
||||||
DrawTextArgs args = new DrawTextArgs( value, font, false );
|
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 ),
|
Size size = new Size( Math.Max( textSize.Width, DesiredMaxWidth ),
|
||||||
Math.Max( textSize.Height, DesiredMaxHeight ) );
|
Math.Max( textSize.Height, DesiredMaxHeight ) );
|
||||||
yOffset = 0;
|
yOffset = 0;
|
||||||
@ -72,18 +81,17 @@ namespace ClassicalSharp.Gui {
|
|||||||
{
|
{
|
||||||
drawer.SetBitmap( bmp );
|
drawer.SetBitmap( bmp );
|
||||||
drawer.DrawRect( backColour, 0, 0, size.Width, size.Height );
|
drawer.DrawRect( backColour, 0, 0, size.Width, size.Height );
|
||||||
args.SkipPartsCheck = true;
|
drawer.DrawChatText( ref args, 3, yOffset );
|
||||||
drawer.DrawText( ref args, 0, 0 );
|
|
||||||
|
|
||||||
args.Text = Validator.Range;
|
args.Text = Validator.Range;
|
||||||
args.SkipPartsCheck = false;
|
args.SkipPartsCheck = false;
|
||||||
Size hintSize = drawer.MeasureSize( ref args );
|
Size hintSize = drawer.MeasureChatSize( ref args );
|
||||||
|
|
||||||
args.SkipPartsCheck = true;
|
args.SkipPartsCheck = true;
|
||||||
int hintX = size.Width - hintSize.Width;
|
int hintX = size.Width - hintSize.Width;
|
||||||
if( textSize.Width < hintX )
|
if( textSize.Width + 3 < hintX )
|
||||||
drawer.DrawText( ref args, hintX, 0 );
|
drawer.DrawChatText( ref args, hintX, yOffset );
|
||||||
chatInputTexture = drawer.Make2DTexture( bmp, size, 0, yOffset );
|
chatInputTexture = drawer.Make2DTexture( bmp, size, 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
X = CalcOffset( game.Width, size.Width, XOffset, HorizontalAnchor );
|
X = CalcOffset( game.Width, size.Width, XOffset, HorizontalAnchor );
|
||||||
|
@ -67,18 +67,25 @@ namespace ClassicalSharp {
|
|||||||
string url = identifier.Substring( 3 );
|
string url = identifier.Substring( 3 );
|
||||||
|
|
||||||
float contentLengthMB = (contentLength / 1024f / 1024f );
|
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?",
|
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" );
|
"Download size: " + contentLengthMB.ToString( "F3" ) + " MB" );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal void RetrieveTexturePack( string url ) {
|
protected internal void RetrieveTexturePack( string url ) {
|
||||||
if( !game.AcceptedUrls.HasUrl( url ) && !game.DeniedUrls.HasUrl( url ) ) {
|
if( !game.AcceptedUrls.HasUrl( url ) && !game.DeniedUrls.HasUrl( url ) ) {
|
||||||
game.AsyncDownloader.RetrieveContentLength( url, true, "CL_" + 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.ShowWarning( new WarningScreen(
|
||||||
game, "CL_" + url, true, true, "Do you want to download the server's texture pack?",
|
game, "CL_" + url, true, true, "Do you want to download the server's texture pack?",
|
||||||
DownloadTexturePack, null, WarningScreenTick,
|
DownloadTexturePack, null, WarningScreenTick,
|
||||||
"Texture pack url:", url,
|
"Texture pack url:", address,
|
||||||
"Download size: Determining..." ) );
|
"Download size: Determining..." ) );
|
||||||
} else {
|
} else {
|
||||||
DownloadTexturePack( url );
|
DownloadTexturePack( url );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user