mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 11:06:06 -04:00
Optimise text input bar - don't recreate caret texture unless necessary.
This commit is contained in:
parent
56b0842de8
commit
4431720311
@ -184,11 +184,9 @@ namespace ClassicalSharp {
|
||||
i += partLength + 1;
|
||||
|
||||
if( nextAnd >= 0 && nextAnd + 1 < value.Length ) {
|
||||
try {
|
||||
code = Utils.ParseHex( value[nextAnd + 1] );
|
||||
} catch( FormatException ) {
|
||||
if( !Utils.TryParseHex( value[nextAnd + 1], out code ) ) {
|
||||
code = 0xF;
|
||||
i--; // include the character that isn't a colour code.
|
||||
i--;// include the character that isn't a colour code.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ namespace ClassicalSharp {
|
||||
announcementFont.Dispose();
|
||||
|
||||
normalChat.Dispose();
|
||||
textInput.Dispose();
|
||||
textInput.DisposeFully();
|
||||
status.Dispose();
|
||||
bottomRight.Dispose();
|
||||
graphicsApi.DeleteTexture( ref announcementTex );
|
||||
|
@ -21,6 +21,9 @@ namespace ClassicalSharp {
|
||||
defaultWidth = defSize.Width; defaultHeight = defSize.Height;
|
||||
Width = defaultWidth; Height = defaultHeight;
|
||||
|
||||
args = new DrawTextArgs( "_", boldFont, true );
|
||||
caretTex = game.Drawer2D.MakeChatTextTexture( ref args, 0, 0 );
|
||||
|
||||
this.font = font;
|
||||
this.boldFont = boldFont;
|
||||
altText = new AltTextInputWidget( game, font, boldFont, this );
|
||||
@ -65,12 +68,10 @@ namespace ClassicalSharp {
|
||||
|
||||
public override void Init() {
|
||||
X = 5;
|
||||
DrawTextArgs args = new DrawTextArgs( "_", boldFont, true );
|
||||
caretTex = game.Drawer2D.MakeChatTextTexture( ref args, 0, 0 );
|
||||
chatInputText.WordWrap( ref parts, ref partLens, 64 );
|
||||
|
||||
chatInputText.WordWrap( ref parts, ref partLens, 64 );
|
||||
maxWidth = 0;
|
||||
args = new DrawTextArgs( null, font, true );
|
||||
DrawTextArgs args = new DrawTextArgs( null, font, true );
|
||||
for( int i = 0; i < lines; i++ ) {
|
||||
args.Text = parts[i];
|
||||
sizes[i] = game.Drawer2D.MeasureChatSize( ref args );
|
||||
@ -151,10 +152,14 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
graphicsApi.DeleteTexture( ref caretTex );
|
||||
graphicsApi.DeleteTexture( ref inputTex );
|
||||
}
|
||||
|
||||
public void DisposeFully() {
|
||||
Dispose();
|
||||
graphicsApi.DeleteTexture( ref caretTex );
|
||||
}
|
||||
|
||||
public override void MoveTo( int newX, int newY ) {
|
||||
int diffX = newX - X, diffY = newY - Y;
|
||||
X = newX; Y = newY;
|
||||
|
Loading…
x
Reference in New Issue
Block a user