Exemplo n.º 1
0
 protected void queueChatChar(char c) {
   if (((head + 1) & (QUEUESIZE - 1)) == tail) {
     plr.message = HUSTR_MSGU;
   } else {
     chatchars[head] = c;
     head = (head + 1) & (QUEUESIZE - 1);
   }
 }
Exemplo n.º 2
0
  @Override
  public void Ticker() {

    int i;
    boolean rc;
    char c;

    // tick down message counter if message is up
    if ((message_counter != 0) && !((--message_counter) != 0)) {
      message_on[0] = false;
      message_nottobefuckedwith = false;
    }

    if (M.getShowMessages() || message_dontfuckwithme) {

      // display message if necessary
      if (((plr.message != null) && !message_nottobefuckedwith)
          || ((plr.message != null) && message_dontfuckwithme)) {
        this.w_message.addMessageToSText(null, plr.message);
        plr.message = null;
        message_on[0] = true;
        message_counter = HU_MSGTIMEOUT;
        message_nottobefuckedwith = message_dontfuckwithme;
        message_dontfuckwithme = false;
      }
    } // else message_on = false;

    // check for incoming chat characters
    if (DM.netgame) {
      for (i = 0; i < MAXPLAYERS; i++) {
        if (!DM.playeringame[i]) continue;
        if ((i != DM.consoleplayer) && ((c = DM.players[i].cmd.chatchar) != 0)) {
          if (c <= HU_BROADCAST) chat_dest[i] = c;
          else {
            if (c >= 'a' && c <= 'z') c = (char) shiftxform[c];
            rc = w_inputbuffer[i].keyInIText(c);
            if (rc && c == KEY_ENTER) {
              if ((w_inputbuffer[i].l.len != 0) && (chat_dest[i] == DM.consoleplayer + 1)
                  || (chat_dest[i] == HU_BROADCAST)) {
                w_message.addMessageToSText(player_names[i], w_inputbuffer[i].l.text.toString());

                message_nottobefuckedwith = true;
                message_on[0] = true;
                message_counter = HU_MSGTIMEOUT;
                if (DM.isCommercial()) S.StartSound(null, sfxenum_t.sfx_radio);
                else S.StartSound(null, sfxenum_t.sfx_tink);
              }
              w_inputbuffer[i].resetIText();
            }
          }
          DM.players[i].cmd.chatchar = 0;
        }
      }
    }
  }
Exemplo n.º 3
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;
  }