boolean HU_Responder(event_t *ev) { static char lastmessage[HU_MAXLINELENGTH+1]; char* macromessage; boolean eatkey = false; static boolean shiftdown = false; static boolean altdown = false; unsigned char c; int i; int numplayers; static int num_nobrainers = 0; numplayers = 0; for (i=0 ; i<MAXPLAYERS ; i++) numplayers += playeringame[i]; if (ev->data1 == KEY_RSHIFT) { shiftdown = ev->type == ev_keydown; return false; } else if (ev->data1 == KEY_RALT || ev->data1 == KEY_LALT) { altdown = ev->type == ev_keydown; return false; } if (ev->type != ev_keydown) return false; if (!chat_on) { if (ev->data1 == key_message_refresh) { message_on = true; message_counter = HU_MSGTIMEOUT; eatkey = true; } else if (netgame && ev->data2 == key_multi_msg) { eatkey = chat_on = true; HUlib_resetIText(&w_chat); HU_queueChatChar(HU_BROADCAST); } else if (netgame && numplayers > 2) { for (i=0; i<MAXPLAYERS ; i++) { if (ev->data2 == key_multi_msgplayer[i]) { if (playeringame[i] && i!=consoleplayer) { eatkey = chat_on = true; HUlib_resetIText(&w_chat); HU_queueChatChar(i+1); break; } else if (i == consoleplayer) { num_nobrainers++; if (num_nobrainers < 3) plr->message = DEH_String(HUSTR_TALKTOSELF1); else if (num_nobrainers < 6) plr->message = DEH_String(HUSTR_TALKTOSELF2); else if (num_nobrainers < 9) plr->message = DEH_String(HUSTR_TALKTOSELF3); else if (num_nobrainers < 32) plr->message = DEH_String(HUSTR_TALKTOSELF4); else plr->message = DEH_String(HUSTR_TALKTOSELF5); } } } } } else { c = ev->data2; // send a macro if (altdown) { c = c - '0'; if (c > 9) return false; // fprintf(stderr, "got here\n"); macromessage = chat_macros[c]; // kill last message with a '\n' HU_queueChatChar(KEY_ENTER); // DEBUG!!! // send the macro message while (*macromessage) HU_queueChatChar(*macromessage++); HU_queueChatChar(KEY_ENTER); // leave chat mode and notify that it was sent chat_on = false; strcpy(lastmessage, chat_macros[c]); plr->message = lastmessage; eatkey = true; } else { if (vanilla_keyboard_mapping) { if (shiftdown || (c >= 'a' && c <= 'z')) { c = shiftxform[c]; } } eatkey = HUlib_keyInIText(&w_chat, c); if (eatkey) { // static unsigned char buf[20]; // DEBUG HU_queueChatChar(c); // sprintf(buf, "KEY: %d => %d", ev->data1, c); // plr->message = buf; } if (c == KEY_ENTER) { chat_on = false; if (w_chat.l.len) { strcpy(lastmessage, w_chat.l.l); plr->message = lastmessage; } } else if (c == KEY_ESCAPE) chat_on = false; } } return eatkey; }
void HU_Ticker(void) { int i, rc; char c; // tick down message counter if message is up if (message_counter && !--message_counter) { message_on = false; message_nottobefuckedwith = false; } if (showMessages || message_dontfuckwithme) { // display message if necessary if ((plr->message && !message_nottobefuckedwith) || (plr->message && message_dontfuckwithme)) { HUlib_addMessageToSText(&w_message, 0, plr->message); plr->message = 0; message_on = true; message_counter = HU_MSGTIMEOUT; message_nottobefuckedwith = message_dontfuckwithme; message_dontfuckwithme = 0; } } // else message_on = false; // check for incoming chat characters if (netgame) { for (i=0 ; i<MAXPLAYERS; i++) { if (!playeringame[i]) continue; if (i != consoleplayer && (c = players[i].cmd.chatchar)) { if (c <= HU_BROADCAST) chat_dest[i] = c; else { rc = HUlib_keyInIText(&w_inputbuffer[i], c); if (rc && c == KEY_ENTER) { if (w_inputbuffer[i].l.len && (chat_dest[i] == consoleplayer+1 || chat_dest[i] == HU_BROADCAST)) { HUlib_addMessageToSText(&w_message, DEH_String(player_names[i]), w_inputbuffer[i].l.l); message_nottobefuckedwith = true; message_on = true; message_counter = HU_MSGTIMEOUT; if ( gamemode == commercial ) S_StartSound(0, sfx_radio); else S_StartSound(0, sfx_tink); } HUlib_resetIText(&w_inputbuffer[i]); } } players[i].cmd.chatchar = 0; } } } }
dboolean HU_Responder(event_t *ev) { static char lastmessage[HU_MAXLINELENGTH+1]; char* macromessage; dboolean eatkey = false; static dboolean shiftdown = false; static dboolean altdown = false; unsigned char c; int i; int numplayers; static char destination_keys[MAXPLAYERS] = { HUSTR_KEYGREEN, HUSTR_KEYINDIGO, HUSTR_KEYBROWN, HUSTR_KEYRED }; static int num_nobrainers = 0; numplayers = 0; for (i=0 ; i<MAXPLAYERS ; i++) numplayers += playeringame[i]; if (ev->data1 == KEY_RSHIFT) { shiftdown = ev->type == ev_keydown; return false; } else if (ev->data1 == KEY_RALT || ev->data1 == KEY_LALT) { altdown = ev->type == ev_keydown; return false; } if (ev->type != ev_keydown) return false; if (!chat_on) { if (ev->data1 == HU_MSGREFRESH) { message_on = true; message_counter = HU_MSGTIMEOUT; eatkey = true; } else if (netgame && ev->data1 == HU_INPUTTOGGLE) { eatkey = chat_on = true; HUlib_resetIText(&w_chat); HU_queueChatChar(HU_BROADCAST); } else if (netgame && numplayers > 2) { for (i=0; i<MAXPLAYERS ; i++) { if (ev->data1 == destination_keys[i]) { if (playeringame[i] && i!=consoleplayer) { eatkey = chat_on = true; HUlib_resetIText(&w_chat); HU_queueChatChar(i+1); break; } else if (i == 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 = ev->data1; // send a macro if (altdown) { c = c - '0'; if (c > 9) return false; // fprintf(stderr, "got here\n"); macromessage = chat_macros[c]; // kill last message with a '\n' HU_queueChatChar(KEY_ENTER); // DEBUG!!! // send the macro message while (*macromessage) HU_queueChatChar(*macromessage++); HU_queueChatChar(KEY_ENTER); // leave chat mode and notify that it was sent chat_on = false; strcpy(lastmessage, chat_macros[c]); plr->message = lastmessage; eatkey = true; } else { if (french) c = ForeignTranslation(c); if (shiftdown || (c >= 'a' && c <= 'z')) c = shiftxform[c]; eatkey = HUlib_keyInIText(&w_chat, c); if (eatkey) { // static unsigned char buf[20]; // DEBUG HU_queueChatChar(c); // sprintf(buf, "KEY: %d => %d", ev->data1, c); // plr->message = buf; } if (c == KEY_ENTER) { chat_on = false; if (w_chat.l.len) { strcpy(lastmessage, w_chat.l.l); plr->message = lastmessage; } } else if (c == KEY_ESCAPE) chat_on = false; } } return eatkey; }
// // HU_Responder() // // Responds to input events that affect the heads up displays // // Passed the event to respond to, returns true if the event was handled // boolean HU_Responder(event_t* ev) { static char lastmessage[HU_MAXLINELENGTH + 1]; char* macromessage; boolean eatkey = false; static boolean shiftdown = false; static boolean altdown = false; unsigned char c; int i; int numplayers; static int num_nobrainers = 0; numplayers = 0; for (i = 0 ; i < MAXPLAYERS ; i++) numplayers += playeringame[i]; if (ev->data1 == key_shift) { shiftdown = ev->type == ev_keydown; return false; } if (ev->data1 == key_alt) { altdown = ev->type == ev_keydown; return false; } if (ev->type != ev_keydown) return false; if (!chat_on) { if (ev->data1 == key_enter) // phares { //jff 2/26/98 toggle list of messages // killough 11/98: // Toggle message list only if a message is actively being reviewed. if (has_message) { if (message_list ? message_list_on && (reviewing_message || !hud_msg_timed) : message_on && reviewing_message) if (!(message_list = !message_list)) { extern boolean setsizeneeded; // killough 12/98: // fix crash at startup if key_enter held down if (gametic && gamestate == GS_LEVEL) HU_Erase(); //jff 4/28/98 erase behind messages message_list_on = false; // killough 11/98: fix background for smaller screens: if (hud_list_bgon && scaledviewheight < 200) setsizeneeded = true; } // killough 11/98: Support timed or continuous message lists if (!message_list) // if not message list, refresh message { message_counter = message_count; reviewing_message = message_on = true; } else { // message list, possibly timed if (hud_msg_timed) message_list_counter = hud_msg_count; reviewing_message = message_list_on = true; } } eatkey = true; } //jff 2/26/98 no chat if message review is displayed else // killough 10/02/98: no chat if demo playback if (!demoplayback) if (!message_list) if (netgame && ev->data1 == key_chat) { eatkey = chat_on = true; HUlib_resetIText(&w_chat); HU_queueChatChar(HU_BROADCAST); }//jff 2/26/98 else // killough 11/98: simplify if (!message_list && netgame && numplayers > 2) for (i = 0; i < MAXPLAYERS ; i++) if (ev->data1 == destination_keys[i]) if (i == consoleplayer) plr->message = ++num_nobrainers < 3 ? HUSTR_TALKTOSELF1 : num_nobrainers < 6 ? HUSTR_TALKTOSELF2 : num_nobrainers < 9 ? HUSTR_TALKTOSELF3 : num_nobrainers < 32 ? HUSTR_TALKTOSELF4 : HUSTR_TALKTOSELF5 ; else if (playeringame[i]) { eatkey = chat_on = true; HUlib_resetIText(&w_chat); HU_queueChatChar((char)(i + 1)); break; } }//jff 2/26/98 no chat functions if message review is displayed else if (!message_list) { c = ev->data1; // send a macro if (altdown) { c = c - '0'; if (c > 9) return false; // fprintf(stderr, "got here\n"); macromessage = chat_macros[c]; // kill last message with a '\n' HU_queueChatChar((char)key_enter); // DEBUG!!! // phares // send the macro message while (*macromessage) HU_queueChatChar(*macromessage++); HU_queueChatChar((char)key_enter); // phares // leave chat mode and notify that it was sent chat_on = false; strcpy(lastmessage, chat_macros[c]); plr->message = lastmessage; eatkey = true; } else { if (shiftdown || (c >= 'a' && c <= 'z')) c = shiftxform[c]; eatkey = HUlib_keyInIText(&w_chat, c); if (eatkey) HU_queueChatChar(c); if (c == key_enter) // phares { chat_on = false; if (w_chat.l.len) { strcpy(lastmessage, w_chat.l.l); plr->message = lastmessage; } } else if (c == key_escape) // phares chat_on = false; } } return eatkey; }
// // HU_Ticker() // // Update the hud displays once per frame // // Passed nothing, returns nothing // void HU_Ticker(void) { // killough 11/98: support counter for message list as well as regular msg if (message_list_counter && !--message_list_counter) { reviewing_message = message_list_on = false; if (hud_list_bgon && scaledviewheight < 200) // killough 11/98 R_FillBackScreen(); } // tick down message counter if message is up if (message_counter && !--message_counter) reviewing_message = message_on = message_nottobefuckedwith = false; // if messages on, or "Messages Off" is being displayed // this allows the notification of turning messages off to be seen // display message if necessary if ((showMessages || message_dontfuckwithme) && plr->message && (!message_nottobefuckedwith || message_dontfuckwithme)) { //post the message to the message widget HUlib_addMessageToSText(&w_message, 0, plr->message); //jff 2/26/98 add message to refresh text widget too HUlib_addMessageToMText(&w_rtext, 0, plr->message); // clear the message to avoid posting multiple times plr->message = 0; // killough 11/98: display message list, possibly timed if (message_list) { if (hud_msg_timed || message_dontfuckwithme) // Messages Off => timed message_list_counter = hud_msg_count; message_list_on = true; } else { message_on = true; // note a message is displayed // start the message persistence counter message_counter = message_count; } has_message = true; // killough 12/98 // transfer "Messages Off" exception to the "being displayed" variable message_nottobefuckedwith = message_dontfuckwithme; // clear the flag that "Messages Off" is being posted message_dontfuckwithme = 0; } // check for incoming chat characters if (netgame) { int i, rc; char c; for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) continue; if (i != consoleplayer && (c = players[i].cmd.chatchar)) { if (c <= HU_BROADCAST) chat_dest[i] = c; else { if (c >= 'a' && c <= 'z') c = (char) shiftxform[(unsigned char) c]; rc = HUlib_keyInIText(&w_inputbuffer[i], c); if (rc && c == KEYD_ENTER) { if (w_inputbuffer[i].l.len && (chat_dest[i] == consoleplayer + 1 || chat_dest[i] == HU_BROADCAST)) { HUlib_addMessageToSText(&w_message, player_names[i], w_inputbuffer[i].l.l); has_message = true; // killough 12/98 message_nottobefuckedwith = true; message_on = true; message_counter = chat_count; // killough 11/98 S_StartSound(0, gamemode == commercial ? sfx_radio : sfx_tink); } HUlib_resetIText(&w_inputbuffer[i]); } } players[i].cmd.chatchar = 0; } } } }
qboolean HU_Responder(event_t *ev) { const char* macromessage; qboolean eatkey = false; unsigned char c; int i; int numplayers; const static char destination_keys[MAXPLAYERS] = { HUSTR_KEYGREEN, HUSTR_KEYINDIGO, HUSTR_KEYBROWN, HUSTR_KEYRED }; numplayers = 0; for (i=0 ; i<MAXPLAYERS ; i++) numplayers += ::g->playeringame[i]; if (ev->data1 == KEY_RSHIFT) { ::g->shiftdown = ev->type == ev_keydown; return false; } else if (ev->data1 == KEY_RALT || ev->data1 == KEY_LALT) { ::g->altdown = ev->type == ev_keydown; return false; } if (ev->type != ev_keydown) return false; if (!::g->chat_on) { if (ev->data1 == HU_MSGREFRESH) { ::g->message_on = true; ::g->message_counter = HU_MSGTIMEOUT; eatkey = true; } else if (::g->netgame && ev->data1 == HU_INPUTTOGGLE) { eatkey = ::g->chat_on = true; HUlib_resetIText(&::g->w_chat); HU_queueChatChar(HU_BROADCAST); } else if (::g->netgame && numplayers > 2) { for (i=0; i<MAXPLAYERS ; i++) { if (ev->data1 == destination_keys[i]) { if (::g->playeringame[i] && i!=::g->consoleplayer) { eatkey = ::g->chat_on = true; HUlib_resetIText(&::g->w_chat); HU_queueChatChar(i+1); break; } else if (i == ::g->consoleplayer) { ::g->num_nobrainers++; if (::g->num_nobrainers < 3) ::g->plr->message = HUSTR_TALKTOSELF1; else if (::g->num_nobrainers < 6) ::g->plr->message = HUSTR_TALKTOSELF2; else if (::g->num_nobrainers < 9) ::g->plr->message = HUSTR_TALKTOSELF3; else if (::g->num_nobrainers < 32) ::g->plr->message = HUSTR_TALKTOSELF4; else ::g->plr->message = HUSTR_TALKTOSELF5; } } } } } else { c = ev->data1; // send a macro if (::g->altdown) { c = c - '0'; if (c > 9) return false; // I_PrintfE( "got here\n"); macromessage = temp_chat_macros[c]; // kill last message with a '\n' HU_queueChatChar(KEY_ENTER); // DEBUG!!! // send the macro message while (*macromessage) HU_queueChatChar(*macromessage++); HU_queueChatChar(KEY_ENTER); // leave chat mode and notify that it was sent ::g->chat_on = false; strcpy(::g->lastmessage, temp_chat_macros[c]); ::g->plr->message = ::g->lastmessage; eatkey = true; } else { if (::g->shiftdown || (c >= 'a' && c <= 'z')) c = shiftxform[c]; eatkey = HUlib_keyInIText(&::g->w_chat, c); if (eatkey) { // static unsigned char buf[20]; // DEBUG HU_queueChatChar(c); // sprintf(buf, "KEY: %d => %d", ev->data1, c); // ::g->plr->message = buf; } if (c == KEY_ENTER) { ::g->chat_on = false; if (::g->w_chat.l.len) { strcpy(::g->lastmessage, ::g->w_chat.l.l); ::g->plr->message = ::g->lastmessage; } } else if (c == KEY_ESCAPE) ::g->chat_on = false; } } return eatkey; }