mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 17:43:08 -05:00
Core: Remove the 'clipboard contained invalid chars' warning.
This commit is contained in:
parent
da43eff85e
commit
ad1848d5ce
3 changed files with 8 additions and 34 deletions
|
@ -415,12 +415,6 @@ namespace ClassicalSharp.Gui.Screens {
|
||||||
" have viruses, or things you may not want to open/see." );
|
" have viruses, or things you may not want to open/see." );
|
||||||
game.Gui.ShowWarning( warning );
|
game.Gui.ShowWarning( warning );
|
||||||
} else if( game.ClickableChat ) {
|
} else if( game.ClickableChat ) {
|
||||||
for( int i = 0; i < text.Length; i++ ) {
|
|
||||||
if( !Utils.IsValidInputChar( text[i], game ) ) {
|
|
||||||
game.Chat.Add( "&eChatline contained characters that can't be sent on this server." );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
textInput.Append( text );
|
textInput.Append( text );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -236,6 +236,7 @@ namespace ClassicalSharp.Gui.Widgets {
|
||||||
bool AppendChar( char c ) {
|
bool AppendChar( char c ) {
|
||||||
int totalChars = MaxCharsPerLine * lines.Length;
|
int totalChars = MaxCharsPerLine * lines.Length;
|
||||||
if( buffer.Length == totalChars ) return false;
|
if( buffer.Length == totalChars ) return false;
|
||||||
|
if( !AllowedChar( c ) ) return false;
|
||||||
|
|
||||||
if( caret == -1 ) {
|
if( caret == -1 ) {
|
||||||
buffer.InsertAt( buffer.Length, c );
|
buffer.InsertAt( buffer.Length, c );
|
||||||
|
@ -247,6 +248,10 @@ namespace ClassicalSharp.Gui.Widgets {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual bool AllowedChar( char c ) {
|
||||||
|
return Utils.IsValidInputChar( c, game );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected bool ControlDown() {
|
protected bool ControlDown() {
|
||||||
return OpenTK.Configuration.RunningOnMacOS ?
|
return OpenTK.Configuration.RunningOnMacOS ?
|
||||||
|
@ -255,13 +260,8 @@ namespace ClassicalSharp.Gui.Widgets {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesKeyPress( char key ) {
|
public override bool HandlesKeyPress( char key ) {
|
||||||
if( game.HideGui ) return true;
|
if( !game.HideGui ) Append( key );
|
||||||
|
return true;
|
||||||
if( Utils.IsValidInputChar( key, game ) ) {
|
|
||||||
Append( key );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesKeyDown( Key key ) {
|
public override bool HandlesKeyDown( Key key ) {
|
||||||
|
@ -402,15 +402,6 @@ namespace ClassicalSharp.Gui.Widgets {
|
||||||
}
|
}
|
||||||
|
|
||||||
if( String.IsNullOrEmpty( text ) ) return true;
|
if( String.IsNullOrEmpty( text ) ) return true;
|
||||||
game.Chat.Add( null, MessageType.ClientStatus4 );
|
|
||||||
|
|
||||||
for( int i = 0; i < text.Length; i++ ) {
|
|
||||||
if( Utils.IsValidInputChar( text[i], game ) ) continue;
|
|
||||||
const string warning = "&eClipboard contained some characters that can't be sent.";
|
|
||||||
game.Chat.Add( warning, MessageType.ClientStatus4 );
|
|
||||||
text = RemoveInvalidChars( text );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Append( text );
|
Append( text );
|
||||||
return true;
|
return true;
|
||||||
} else if( key == Key.C ) {
|
} else if( key == Key.C ) {
|
||||||
|
@ -427,17 +418,6 @@ namespace ClassicalSharp.Gui.Widgets {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string RemoveInvalidChars( string input ) {
|
|
||||||
char[] chars = new char[input.Length];
|
|
||||||
int length = 0;
|
|
||||||
for( int i = 0; i < input.Length; i++ ) {
|
|
||||||
char c = input[i];
|
|
||||||
if( !Utils.IsValidInputChar( c, game ) ) continue;
|
|
||||||
chars[length++] = c;
|
|
||||||
}
|
|
||||||
return new String( chars, 0, length );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
unsafe void SetCaretToCursor( int mouseX, int mouseY ) {
|
unsafe void SetCaretToCursor( int mouseX, int mouseY ) {
|
||||||
mouseX -= inputTex.X1; mouseY -= inputTex.Y1;
|
mouseX -= inputTex.X1; mouseY -= inputTex.Y1;
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace ClassicalSharp {
|
||||||
// client defined message ids
|
// client defined message ids
|
||||||
ClientStatus1 = 256,
|
ClientStatus1 = 256,
|
||||||
ClientStatus2 = 257,
|
ClientStatus2 = 257,
|
||||||
ClientStatus3 = 258,
|
ClientStatus3 = 258, // cuboid messages
|
||||||
ClientStatus4 = 259, // clipboard invalid characters
|
ClientStatus4 = 259, // clipboard invalid characters
|
||||||
ClientStatus5 = 260, // tab list matching names
|
ClientStatus5 = 260, // tab list matching names
|
||||||
ClientStatus6 = 261, // no LongerMessages warning
|
ClientStatus6 = 261, // no LongerMessages warning
|
||||||
|
|
Loading…
Add table
Reference in a new issue