mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 03:25:14 -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;
|
i += partLength + 1;
|
||||||
|
|
||||||
if( nextAnd >= 0 && nextAnd + 1 < value.Length ) {
|
if( nextAnd >= 0 && nextAnd + 1 < value.Length ) {
|
||||||
try {
|
if( !Utils.TryParseHex( value[nextAnd + 1], out code ) ) {
|
||||||
code = Utils.ParseHex( value[nextAnd + 1] );
|
|
||||||
} catch( FormatException ) {
|
|
||||||
code = 0xF;
|
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();
|
announcementFont.Dispose();
|
||||||
|
|
||||||
normalChat.Dispose();
|
normalChat.Dispose();
|
||||||
textInput.Dispose();
|
textInput.DisposeFully();
|
||||||
status.Dispose();
|
status.Dispose();
|
||||||
bottomRight.Dispose();
|
bottomRight.Dispose();
|
||||||
graphicsApi.DeleteTexture( ref announcementTex );
|
graphicsApi.DeleteTexture( ref announcementTex );
|
||||||
|
@ -21,6 +21,9 @@ namespace ClassicalSharp {
|
|||||||
defaultWidth = defSize.Width; defaultHeight = defSize.Height;
|
defaultWidth = defSize.Width; defaultHeight = defSize.Height;
|
||||||
Width = defaultWidth; Height = defaultHeight;
|
Width = defaultWidth; Height = defaultHeight;
|
||||||
|
|
||||||
|
args = new DrawTextArgs( "_", boldFont, true );
|
||||||
|
caretTex = game.Drawer2D.MakeChatTextTexture( ref args, 0, 0 );
|
||||||
|
|
||||||
this.font = font;
|
this.font = font;
|
||||||
this.boldFont = boldFont;
|
this.boldFont = boldFont;
|
||||||
altText = new AltTextInputWidget( game, font, boldFont, this );
|
altText = new AltTextInputWidget( game, font, boldFont, this );
|
||||||
@ -65,12 +68,10 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
X = 5;
|
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;
|
maxWidth = 0;
|
||||||
args = new DrawTextArgs( null, font, true );
|
DrawTextArgs args = new DrawTextArgs( null, font, true );
|
||||||
for( int i = 0; i < lines; i++ ) {
|
for( int i = 0; i < lines; i++ ) {
|
||||||
args.Text = parts[i];
|
args.Text = parts[i];
|
||||||
sizes[i] = game.Drawer2D.MeasureChatSize( ref args );
|
sizes[i] = game.Drawer2D.MeasureChatSize( ref args );
|
||||||
@ -151,10 +152,14 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
graphicsApi.DeleteTexture( ref caretTex );
|
|
||||||
graphicsApi.DeleteTexture( ref inputTex );
|
graphicsApi.DeleteTexture( ref inputTex );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DisposeFully() {
|
||||||
|
Dispose();
|
||||||
|
graphicsApi.DeleteTexture( ref caretTex );
|
||||||
|
}
|
||||||
|
|
||||||
public override void MoveTo( int newX, int newY ) {
|
public override void MoveTo( int newX, int newY ) {
|
||||||
int diffX = newX - X, diffY = newY - Y;
|
int diffX = newX - X, diffY = newY - Y;
|
||||||
X = newX; Y = newY;
|
X = newX; Y = newY;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user