Ejemplo n.º 1
0
 public String toString() {
   sb.setLength(0);
   sb.append(this.lines[0].text);
   sb.append(this.lines[1].text);
   sb.append(this.lines[2].text);
   sb.append(this.lines[3].text);
   return sb.toString();
 }
Ejemplo n.º 2
0
  @Override
  public boolean Responder(event_t ev) {

    // System.out.println("Player "+DM.players[0].mo.x);
    char[] macromessage;
    boolean eatkey = false;

    char c;
    int i;
    int numplayers;

    numplayers = 0;
    // MAES: Adding BOOLEANS to ints, are we ?!
    for (i = 0; i < MAXPLAYERS; i++) {
      numplayers += (DM.playeringame[i]) ? 1 : 0;
    }

    if (ev.data1 == KEY_SHIFT) {
      shiftdown = (ev.type == evtype_t.ev_keydown);
      return false;
    } else if (ev.data1 == KEY_ALT || ev.data1 == KEY_ALT) {
      altdown = (ev.type == evtype_t.ev_keydown);
      return false;
    }

    if (ev.type != evtype_t.ev_keydown) return false;

    if (!chat_on[0]) {
      if (ev.data1 == HU_MSGREFRESH) {
        message_on[0] = true;
        message_counter = HU_MSGTIMEOUT;
        eatkey = true;
      } else if (DM.netgame && ev.data1 == HU_INPUTTOGGLE) {
        eatkey = chat_on[0] = true;
        w_chat.resetIText();
        this.queueChatChar(HU_BROADCAST);
      } else if (DM.netgame && numplayers > 2) {
        for (i = 0; i < MAXPLAYERS; i++) {
          if (ev.data1 == destination_keys[i]) {
            if (DM.playeringame[i] && i != DM.consoleplayer) {
              eatkey = chat_on[0] = true;
              w_chat.resetIText();
              this.queueChatChar((char) (i + 1));
              break;
            } else if (i == DM.consoleplayer) {
              num_nobrainers++;
              if (num_nobrainers < 3) plr.message = HUSTR_TALKTOSELF1;
              else if (num_nobrainers < 6) plr.message = HUSTR_TALKTOSELF2;
              else if (num_nobrainers < 9) plr.message = HUSTR_TALKTOSELF3;
              else if (num_nobrainers < 32) plr.message = HUSTR_TALKTOSELF4;
              else plr.message = HUSTR_TALKTOSELF5;
            }
          }
        }
      }
    } else {
      c = (char) ev.data1;
      // send a macro
      if (altdown) {
        c = (char) (c - '0');
        if (c > 9) return false;
        // fprintf(stderr, "got here\n");
        macromessage = chat_macros[c].toCharArray();

        // kill last message with a '\n'
        this.queueChatChar(KEY_ENTER); // DEBUG!!!

        // send the macro message
        int index = 0;
        while (macromessage[index] != 0) {
          this.queueChatChar(macromessage[index]);
        }
        this.queueChatChar(KEY_ENTER);

        // leave chat mode and notify that it was sent
        chat_on[0] = false;
        lastmessage.setLength(0);
        lastmessage.append(chat_macros[c]);
        plr.message = lastmessage.toString();
        eatkey = true;
      } else {
        if (DM.language == Language.french) c = ForeignTranslation(c);
        if (shiftdown || (c >= 'a' && c <= 'z')) c = shiftxform[c];
        eatkey = w_chat.keyInIText(c);
        if (eatkey) {
          // static unsigned char buf[20]; // DEBUG
          this.queueChatChar(c);

          // sprintf(buf, "KEY: %d => %d", ev->data1, c);
          // plr->message = buf;
        }
        if (c == KEY_ENTER) {
          chat_on[0] = false;
          if ((w_chat.l.len != 0)) {
            lastmessage.setLength(0);
            lastmessage.append(w_chat.l.text);
            plr.message = new String(lastmessage);
          }
        } else if (c == KEY_ESCAPE) chat_on[0] = false;
      }
    }

    return eatkey;
  }