mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 03:25:14 -04:00
Fix client crashing in classic mode when pasting past 62*3 characters.
This commit is contained in:
parent
119cd745ed
commit
b15106c960
@ -221,7 +221,7 @@ namespace ClassicalSharp.Gui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OtherKey( Key key ) {
|
bool OtherKey( Key key ) {
|
||||||
if( key == Key.V && chatInputText.Length < len ) {
|
if( key == Key.V && chatInputText.Length < TotalChars ) {
|
||||||
string text = Clipboard.GetText();
|
string text = Clipboard.GetText();
|
||||||
if( String.IsNullOrEmpty( text ) ) return true;
|
if( String.IsNullOrEmpty( text ) ) return true;
|
||||||
game.Chat.Add( null, MessageType.ClientStatus4 );
|
game.Chat.Add( null, MessageType.ClientStatus4 );
|
||||||
|
@ -6,7 +6,6 @@ namespace ClassicalSharp.Gui {
|
|||||||
|
|
||||||
public sealed partial class TextInputWidget : Widget {
|
public sealed partial class TextInputWidget : Widget {
|
||||||
|
|
||||||
const int len = 64 * 3;
|
|
||||||
const int lines = 3;
|
const int lines = 3;
|
||||||
internal AltTextInputWidget altText;
|
internal AltTextInputWidget altText;
|
||||||
public TextInputWidget( Game game, Font font, Font boldFont ) : base( game ) {
|
public TextInputWidget( Game game, Font font, Font boldFont ) : base( game ) {
|
||||||
@ -14,7 +13,7 @@ namespace ClassicalSharp.Gui {
|
|||||||
VerticalAnchor = Anchor.BottomOrRight;
|
VerticalAnchor = Anchor.BottomOrRight;
|
||||||
typingLogPos = game.Chat.InputLog.Count; // Index of newest entry + 1.
|
typingLogPos = game.Chat.InputLog.Count; // Index of newest entry + 1.
|
||||||
|
|
||||||
chatInputText = new WrappableStringBuffer( len );
|
chatInputText = new WrappableStringBuffer( TotalChars );
|
||||||
DrawTextArgs args = new DrawTextArgs( "A", boldFont, true );
|
DrawTextArgs args = new DrawTextArgs( "A", boldFont, true );
|
||||||
Size defSize = game.Drawer2D.MeasureChatSize( ref args );
|
Size defSize = game.Drawer2D.MeasureChatSize( ref args );
|
||||||
defaultWidth = defSize.Width; defaultHeight = defSize.Height;
|
defaultWidth = defSize.Width; defaultHeight = defSize.Height;
|
||||||
@ -66,6 +65,7 @@ namespace ClassicalSharp.Gui {
|
|||||||
bool shownWarning;
|
bool shownWarning;
|
||||||
|
|
||||||
int LineLength { get { return game.Network.ServerSupportsPartialMessages ? 64 : 62; } }
|
int LineLength { get { return game.Network.ServerSupportsPartialMessages ? 64 : 62; } }
|
||||||
|
int TotalChars { get { return LineLength * lines; } }
|
||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
X = 5;
|
X = 5;
|
||||||
@ -250,8 +250,8 @@ namespace ClassicalSharp.Gui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void AppendText( string text ) {
|
public void AppendText( string text ) {
|
||||||
if( chatInputText.Length + text.Length > len ) {
|
if( chatInputText.Length + text.Length > TotalChars ) {
|
||||||
text = text.Substring( 0, len - chatInputText.Length );
|
text = text.Substring( 0, TotalChars - chatInputText.Length );
|
||||||
}
|
}
|
||||||
if( text == "" ) return;
|
if( text == "" ) return;
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ namespace ClassicalSharp.Gui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void AppendChar( char c ) {
|
public void AppendChar( char c ) {
|
||||||
if( chatInputText.Length == len ) return;
|
if( chatInputText.Length == TotalChars ) return;
|
||||||
|
|
||||||
if( caretPos == -1 ) {
|
if( caretPos == -1 ) {
|
||||||
chatInputText.InsertAt( chatInputText.Length, c );
|
chatInputText.InsertAt( chatInputText.Length, c );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user