From: divverent Date: Wed, 10 Sep 2008 06:50:53 +0000 (+0000) Subject: add a half-baked "commandmode" (currently it has, like messagemode, no history, no... X-Git-Tag: xonotic-v0.1.0preview~2089 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d74673bd5a8f28cc3992b9cfb3cc72890f8da11a;p=xonotic%2Fdarkplaces.git add a half-baked "commandmode" (currently it has, like messagemode, no history, no line editing) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8495 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/console.c b/console.c index feb70bac..fb75ba20 100644 --- a/console.c +++ b/console.c @@ -431,7 +431,7 @@ Con_MessageMode_f void Con_MessageMode_f (void) { key_dest = key_message; - chat_team = false; + chat_mode = 0; // "say" } @@ -443,9 +443,24 @@ Con_MessageMode2_f void Con_MessageMode2_f (void) { key_dest = key_message; - chat_team = true; + chat_mode = 1; // "say_team" } +/* +================ +Con_CommandMode_f +================ +*/ +void Con_CommandMode_f (void) +{ + key_dest = key_message; + if(Cmd_Argc() > 1) + { + dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args()); + chat_bufferlen = strlen(chat_buffer); + } + chat_mode = -1; // command +} /* ================ @@ -566,6 +581,7 @@ void Con_Init (void) Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f, "opens or closes the console"); Cmd_AddCommand ("messagemode", Con_MessageMode_f, "input a chat message to say to everyone"); Cmd_AddCommand ("messagemode2", Con_MessageMode2_f, "input a chat message to say to only your team"); + Cmd_AddCommand ("commandmode", Con_CommandMode_f, "input a console command"); Cmd_AddCommand ("clear", Con_Clear_f, "clear console history"); Cmd_AddCommand ("maps", Con_Maps_f, "list information about available maps"); Cmd_AddCommand ("condump", Con_ConDump_f, "output console history to a file (see also log_file)"); @@ -1428,7 +1444,9 @@ void Con_DrawNotify (void) int colorindex = -1; // LordHavoc: speedup, and other improvements - if (chat_team) + if (chat_mode < 0) + dpsnprintf(temptext, sizeof(temptext), "]%s%c", chat_buffer, (int) 10+((int)(realtime*con_cursorspeed)&1)); + else if(chat_mode) dpsnprintf(temptext, sizeof(temptext), "say_team:%s%c", chat_buffer, (int) 10+((int)(realtime*con_cursorspeed)&1)); else dpsnprintf(temptext, sizeof(temptext), "say:%s%c", chat_buffer, (int) 10+((int)(realtime*con_cursorspeed)&1)); diff --git a/keys.c b/keys.c index 2374781c..81cc1bee 100644 --- a/keys.c +++ b/keys.c @@ -523,7 +523,7 @@ Key_Console (int key, char ascii) //============================================================================ -qboolean chat_team; +int chat_mode; char chat_buffer[MAX_INPUTLINE]; unsigned int chat_bufferlen = 0; @@ -535,7 +535,10 @@ Key_Message (int key, char ascii) if (key == K_ENTER || ascii == 10 || ascii == 13) { - Cmd_ForwardStringToServer(va("%s %s", chat_team ? "say_team" : "say ", chat_buffer)); + if(chat_mode < 0) + Cbuf_AddText(va("%s\n", chat_buffer)); + else + Cmd_ForwardStringToServer(va("%s %s", chat_mode ? "say_team" : "say ", chat_buffer)); key_dest = key_game; chat_bufferlen = 0; @@ -543,6 +546,8 @@ Key_Message (int key, char ascii) return; } + // TODO add support for arrow keys and simple editing + if (key == K_ESCAPE) { key_dest = key_game; chat_bufferlen = 0; diff --git a/keys.h b/keys.h index 68bf44dc..c498a621 100644 --- a/keys.h +++ b/keys.h @@ -208,7 +208,7 @@ extern int key_consoleactive; extern char *keybindings[MAX_BINDMAPS][MAX_KEYS]; extern void Key_ClearEditLine(int edit_line); -extern qboolean chat_team; +extern int chat_mode; // 0 for say, 1 for say_team, -1 for command extern char chat_buffer[MAX_INPUTLINE]; extern unsigned int chat_bufferlen;