fixed so that you can bind chat to enter and it still works

This commit is contained in:
Magnus Auvinen 2008-03-18 02:14:35 +00:00
parent c662df41ee
commit 6d07a560a6
4 changed files with 30 additions and 24 deletions

View file

@ -741,6 +741,9 @@ void chat_enable_mode(int team)
mem_zero(chat_input, sizeof(chat_input));
chat_input_len = 0;
// make sure that we don't trigger something weird
inp_clear_events();
}
}
@ -779,7 +782,7 @@ void render_game()
anim_eval(&data->animations[ANIM_BASE], 0, &idlestate);
anim_eval_add(&idlestate, &data->animations[ANIM_IDLE], 0, 1.0f);
if (inp_key_down(KEY_ESC))
if(inp_key_down(KEY_ESC))
{
if (chat_mode)
chat_mode = CHATMODE_NONE;
@ -806,15 +809,6 @@ void render_game()
{
if(chat_mode != CHATMODE_NONE)
{
if(inp_key_down(KEY_ENTER) || inp_key_down(KEY_KP_ENTER))
{
// send message
if(chat_input_len)
chat_say(chat_mode == CHATMODE_ALL ? 0 : 1, chat_input);
chat_mode = CHATMODE_NONE;
}
for(int i = 0; i < inp_num_events(); i++)
{
INPUT_EVENT e = inp_get_event(i);
@ -829,6 +823,16 @@ void render_game()
}
}
if((e.key == KEY_ENTER || e.key == KEY_KP_ENTER) && (e.flags&INPFLAG_PRESS))
{
// send message
if(chat_input_len)
chat_say(chat_mode == CHATMODE_ALL ? 0 : 1, chat_input);
chat_mode = CHATMODE_NONE;
break;
}
if(e.key == KEY_BACKSPACE && (e.flags&INPFLAG_PRESS))
{
if(chat_input_len > 0)

View file

@ -215,6 +215,20 @@ static void con_sayteam(void *result, void *user_data)
chat_say(1, console_arg_string(result, 0));
}
static void con_chat(void *result, void *user_data)
{
const char *mode = console_arg_string(result, 0);
if(strcmp(mode, "all") == 0)
chat_enable_mode(0);
else if(strcmp(mode, "team") == 0)
chat_enable_mode(1);
else
dbg_msg("console", "expected all or team as mode");
}
void send_kill(int client_id);
static void con_kill(void *result, void *user_data)
@ -330,17 +344,6 @@ static void con_key_input_weapon(void *result, void *user_data)
input_data.wanted_weapon = w;
}
static void con_chat(void *result, void *user_data)
{
const char *mode = console_arg_string(result, 0);
if(strcmp(mode, "all") == 0)
chat_enable_mode(0);
else if(strcmp(mode, "team") == 0)
chat_enable_mode(1);
else
dbg_msg("console", "expected all or team as mode");
}
static void con_toggle_local_console(void *result, void *user_data)
{
console_toggle(0);

View file

@ -197,7 +197,7 @@ message cl_say
end
message sv_chat
range(0, 1) team
range(-1, 1) team
range(-1,MAX_CLIENTS-1) cid
string message
end

View file

@ -2070,13 +2070,12 @@ void mods_message(int msgtype, int client_id)
if(msgtype == NETMSGTYPE_CL_SAY)
{
NETMSG_CL_SAY *msg = (NETMSG_CL_SAY *)rawmsg;
int team = msg->team;
if(team)
team = players[client_id].team;
else
team = -1;
send_chat(client_id, msg->team, msg->message);
send_chat(client_id, team, msg->message);
}
else if (msgtype == NETMSGTYPE_CL_SETTEAM)
{