// // HU_ChatRespond // // Responds to chat-related events. // static bool HU_ChatRespond(const event_t *ev) { char ch = 0; static bool shiftdown; static bool discardinput = false; // haleyjd 06/11/08: get HUD actions int action = G_KeyResponder(ev, kac_hud); if(ev->data1 == KEYD_RSHIFT) shiftdown = (ev->type == ev_keydown); (void)shiftdown; if(action == ka_frags) hu_showfrags = (ev->type == ev_keydown); if(ev->type != ev_keydown && ev->type != ev_text) return false; if(!chat_active) { if(ev->data1 == key_chat && netgame) { chat_active = true; // activate chat chatinput[0] = 0; // empty input string if(ectype::isPrint(ev->data1)) discardinput = true; // avoid activation key also appearing in input string return true; } return false; } if(ev->type == ev_text && discardinput) { discardinput = false; return true; } if(altdown && ev->type == ev_keydown && ev->data1 >= '0' && ev->data1 <= '9') { // chat macro char tempstr[100]; psnprintf(tempstr, sizeof(tempstr), "say \"%s\"", chat_macros[ev->data1-'0']); C_RunTextCmd(tempstr); chat_active = false; return true; } if(ev->data1 == KEYD_ESCAPE) // kill chat { chat_active = false; return true; } if(ev->data1 == KEYD_BACKSPACE && chatinput[0]) { chatinput[strlen(chatinput)-1] = 0; // remove last char return true; } if(ev->data1 == KEYD_ENTER) { char tempstr[100]; psnprintf(tempstr, sizeof(tempstr), "say \"%s\"", chatinput); C_RunTextCmd(tempstr); chat_active = false; return true; } if(ev->type == ev_keydown && ectype::isPrint(ev->data1)) return true; // eat keydown inputs that have text equivalent if(ev->type == ev_text) ch = ev->data1; if(ectype::isPrint(ch)) { psnprintf(chatinput, sizeof(chatinput), "%s%c", chatinput, ch); return true; } return false; }
// // HU_ChatRespond // // Responds to chat-related events. // static bool HU_ChatRespond(event_t *ev) { char ch = 0; static bool shiftdown; // haleyjd 06/11/08: get HUD actions int action = G_KeyResponder(ev, kac_hud); if(ev->data1 == KEYD_RSHIFT) shiftdown = (ev->type == ev_keydown); if(action == ka_frags) hu_showfrags = (ev->type == ev_keydown); if(ev->type != ev_keydown) return false; if(!chat_active) { if(ev->data1 == key_chat && netgame) { chat_active = true; // activate chat chatinput[0] = 0; // empty input string return true; } return false; } if(altdown && ev->type == ev_keydown && ev->data1 >= '0' && ev->data1 <= '9') { // chat macro char tempstr[100]; psnprintf(tempstr, sizeof(tempstr), "say \"%s\"", chat_macros[ev->data1-'0']); C_RunTextCmd(tempstr); chat_active = false; return true; } if(ev->data1 == KEYD_ESCAPE) // kill chat { chat_active = false; return true; } if(ev->data1 == KEYD_BACKSPACE && chatinput[0]) { chatinput[strlen(chatinput)-1] = 0; // remove last char return true; } if(ev->data1 == KEYD_ENTER) { char tempstr[100]; psnprintf(tempstr, sizeof(tempstr), "say \"%s\"", chatinput); C_RunTextCmd(tempstr); chat_active = false; return true; } if(ev->character) ch = ev->character; else if(ev->data1 > 31 && ev->data1 < 127) ch = shiftdown ? shiftxform[ev->data1] : ev->data1; // shifted? if(ch > 31 && ch < 127) { psnprintf(chatinput, sizeof(chatinput), "%s%c", chatinput, ch); return true; } return false; }