]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
add a half-baked "commandmode" (currently it has, like messagemode, no history, no...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 10 Sep 2008 06:50:53 +0000 (06:50 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 10 Sep 2008 06:50:53 +0000 (06:50 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8495 d7cf8633-e32d-0410-b094-e92efae38249

console.c
keys.c
keys.h

index feb70bacfbdc1474ef315c0b0baa01fc966711b9..fb75ba209b6af6cb1c3a7da0eff667880552fe41 100644 (file)
--- 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 2374781c8df937b078329a4046782b46084ae3da..81cc1beeac5aee48df0e81b26a052145e3a7c154 100644 (file)
--- 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 68bf44dcbfd7b2dec1b852709d7cc4707064c178..c498a621155b798794fc8997cf5c0e06861cb7dc 100644 (file)
--- 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;