Set the chat info key to the appropriate value on key_dest change.

This commit is contained in:
Bill Currie 2012-06-29 17:16:51 +09:00
parent 603fe92cba
commit baa0948bcb
2 changed files with 33 additions and 12 deletions

View File

@ -38,6 +38,5 @@ void CL_Chat_User_Disconnected (int uid);
void CL_Chat_Check_Name (const char *name, int slot);
void CL_Chat_Flush_Ignores (void);
void CL_Chat_Init (void);
void CL_ChatInfo (int val);
#endif

View File

@ -39,6 +39,7 @@
#include "QF/cmd.h"
#include "QF/dstring.h"
#include "QF/info.h"
#include "QF/keys.h"
#include "QF/llist.h"
#include "QF/sys.h"
#include "QF/va.h"
@ -225,17 +226,7 @@ CL_Chat_Flush_Ignores (void)
llist_flush (ignore_list);
}
void
CL_Chat_Init (void)
{
ignore_list = llist_new (CL_Ignore_Free, CL_Ignore_Compare, 0);
dead_ignore_list = llist_new (CL_Ignore_Free, CL_Ignore_Compare, 0);
Cmd_AddCommand ("ignore", CL_Ignore_f, "Ignores chat and name-change messages from a user.");
Cmd_AddCommand ("unignore", CL_Unignore_f, "Removes a previously ignored user from the ignore list.");
}
void
static void
CL_ChatInfo (int val)
{
if (val < 1 || val > 3)
@ -245,3 +236,34 @@ CL_ChatInfo (int val)
Cbuf_AddText(cl_cbuf, va ("setinfo chat \"%d\"\n", val));
}
}
static void
cl_chat_key_dest (void)
{
switch (key_dest) {
case key_game:
CL_ChatInfo (0);
break;
case key_message:
CL_ChatInfo (1);
break;
case key_console:
case key_menu:
CL_ChatInfo (2); // supposed to be for loss of focus...
break;
case key_none: // shouldn't happen
CL_ChatInfo (3);
break;
}
}
void
CL_Chat_Init (void)
{
ignore_list = llist_new (CL_Ignore_Free, CL_Ignore_Compare, 0);
dead_ignore_list = llist_new (CL_Ignore_Free, CL_Ignore_Compare, 0);
Cmd_AddCommand ("ignore", CL_Ignore_f, "Ignores chat and name-change messages from a user.");
Cmd_AddCommand ("unignore", CL_Unignore_f, "Removes a previously ignored user from the ignore list.");
key_dest_callback = cl_chat_key_dest;
}