MCPcopy Create free account
hub / github.com/demoth/jake2 / Message

Method Message

client/src/main/java/jake2/client/Key.java:487–586  ·  view source on GitHub ↗
(int key)

Source from the content-addressed store, hash-verified

485 }
486
487 private static void Message(int key) {
488
489 // sfranzyshen -- start
490 StringBuffer buffer = new StringBuffer();
491 buffer.append(ClientGlobals.chat_buffer);
492 int offset = buffer.length() - ClientGlobals.chat_backedit;
493
494 if (key == K_ENTER || key == K_KP_ENTER) {
495 if (ClientGlobals.chat_team)
496 Cbuf.AddText("say_team \"");
497 else
498 Cbuf.AddText("say \"");
499
500 Cbuf.AddText(ClientGlobals.chat_buffer);
501 Cbuf.AddText("\"\n");
502
503 ClientGlobals.cls.key_dest = Defines.key_game;
504 ClientGlobals.chat_buffer = "";
505 ClientGlobals.chat_backedit = 0;
506 return;
507 }
508
509
510 if (key == K_ESCAPE) {
511 ClientGlobals.cls.key_dest = Defines.key_game;
512 ClientGlobals.chat_buffer = "";
513 ClientGlobals.chat_backedit = 0;
514 return;
515 }
516 if (key == K_END || key == K_KP_END) {
517 ClientGlobals.chat_backedit = 0;
518 return;
519 }
520 if (key == K_HOME || key == K_KP_HOME) {
521 ClientGlobals.chat_backedit = ClientGlobals.chat_buffer.length();
522 return;
523 }
524 if (key == K_BACKSPACE) {
525 if (buffer.length() > 0) { // we have a buffer to edit
526 if (ClientGlobals.chat_backedit > 0) { // we are somewhere mid line
527 if (offset == 0) { // we are at the start of the line
528 return;
529 }
530 buffer.deleteCharAt(offset-1);
531 }
532 else { // we are at the end of line
533 buffer.deleteCharAt(buffer.length()-1);
534 }
535 }
536 ClientGlobals.chat_buffer = buffer.toString();
537 return;
538 }
539
540 if (key == K_DEL || key == K_KP_DEL) {
541 if (buffer.length() > 0 && ClientGlobals.chat_backedit > 0) { // we have a buffer & we are somewhere mid line
542 buffer.deleteCharAt(offset);
543 ClientGlobals.chat_backedit--;
544 if (ClientGlobals.chat_backedit < 0) {

Callers 1

EventMethod · 0.95

Calls 2

AddTextMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected