From e9192f232a7c57926b1fd65dc5a7312a30b0a2ed Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 23 Jul 2010 20:55:11 +0000 Subject: [PATCH] Enable messages and says to be 256 chars long, with a scrolling input line across top of screen. Allow tab button in demos. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@237 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/console.c | 41 +++++++++++++++++++++++++---------------- Quake/host_cmd.c | 6 ++++-- Quake/keys.c | 12 +++++++----- 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/Quake/console.c b/Quake/console.c index 265cff20..afd480ee 100644 --- a/Quake/console.c +++ b/Quake/console.c @@ -1043,11 +1043,11 @@ Draws the last few lines of output transparently over the game top */ void Con_DrawNotify (void) { - int x, v; + int x, v; char *text; - int i; + int i; float time; - extern char chat_buffer[]; + extern char chat_buffer[]; GL_SetCanvas (CANVAS_CONSOLE); //johnfitz v = vid.conheight; //johnfitz @@ -1077,27 +1077,36 @@ void Con_DrawNotify (void) if (key_dest == key_message) { - char *say_prompt; //johnfitz + // modified by S.A to support longer lines + + char c[MAXCMDLINE+1], *say_prompt; // extra space == +1 + int say_length, len; clearnotify = 0; - x = 0; - //johnfitz -- distinguish say and say_team if (team_message) say_prompt = "say_team:"; else say_prompt = "say:"; - //johnfitz + + say_length = strlen(say_prompt); Draw_String (8, v, say_prompt); //johnfitz - while(chat_buffer[x]) + text = strcpy(c, chat_buffer); + len = strlen(chat_buffer); + text[len] = ' '; + text[len+1] = 0; + if (len >= con_linewidth - say_length) + text += 1 + len + say_length - con_linewidth; + + while(*text) { - Draw_Character ( (x+strlen(say_prompt)+2)<<3, v, chat_buffer[x]); //johnfitz - x++; + Draw_Character ( (x+say_length+2)<<3, v, *text); //johnfitz + x++; text++; } - Draw_Character ( (x+strlen(say_prompt)+2)<<3, v, 10+((int)(realtime*con_cursorspeed)&1)); //johnfitz + Draw_Character ( (x+say_length+1)<<3, v, 10+((int)(realtime*con_cursorspeed)&1)); v += 8; scr_tileclear_updates = 0; //johnfitz @@ -1113,11 +1122,11 @@ The input line scrolls horizontally if typing goes beyond the right edge */ void Con_DrawInput (void) { - extern qpic_t *pic_ovr, *pic_ins; //johnfitz -- new cursor handling - extern double key_blinktime; - extern int key_insert; - int i, len; - char c[256], *text; + extern qpic_t *pic_ovr, *pic_ins; //johnfitz -- new cursor handling + extern double key_blinktime; + extern int key_insert; + int i, len; + char c[MAXCMDLINE], *text; if (key_dest != key_console && !con_forcedup) return; // don't draw anything diff --git a/Quake/host_cmd.c b/Quake/host_cmd.c index 79dbaa9c..af00243e 100644 --- a/Quake/host_cmd.c +++ b/Quake/host_cmd.c @@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#define MAXCMDLINE 256 + #include "arch_def.h" #include "net_sys.h" /* for net_defs.h */ #include @@ -1279,7 +1281,7 @@ void Host_Say(qboolean teamonly) int j; char *p; // removed unsigned keyword -- kristian - char text[64]; + char text[MAXCMDLINE]; qboolean fromServer = false; if (cmd_source == src_command) @@ -1355,7 +1357,7 @@ void Host_Tell_f(void) client_t *save; int j; char *p; - char text[64]; + char text[MAXCMDLINE]; if (cmd_source == src_command) { diff --git a/Quake/keys.c b/Quake/keys.c index e7391b5e..928aab32 100644 --- a/Quake/keys.c +++ b/Quake/keys.c @@ -267,14 +267,16 @@ void Key_Console (int key) return; case K_PGUP: - //case K_MWHEELUP: + // Mouse events never reach the console, especially in windowed mode + // when mouse is released to the window manager + // case K_MWHEELUP: con_backscroll += keydown[K_CTRL] ? ((con_vislines>>3) - 4) : 2; if (con_backscroll > con_totallines - (vid.height>>3) - 1) con_backscroll = con_totallines - (vid.height>>3) - 1; return; case K_PGDN: - //case K_MWHEELDOWN: + // case K_MWHEELDOWN: con_backscroll -= keydown[K_CTRL] ? ((con_vislines>>3) - 4) : 2; if (con_backscroll < 0) con_backscroll = 0; @@ -428,7 +430,7 @@ void Key_Console (int key) //============================================================================ -char chat_buffer[32]; +char chat_buffer[MAXCMDLINE]; qboolean team_message = false; void Key_Message (int key) @@ -471,7 +473,7 @@ void Key_Message (int key) return; } - if (chat_bufferlen == 31) + if (chat_bufferlen == sizeof(chat_buffer)-1) return; // all full chat_buffer[chat_bufferlen++] = key; @@ -941,7 +943,7 @@ void Key_Event (int key, qboolean down) // // during demo playback, most keys bring up the main menu // - if (cls.demoplayback && down && consolekeys[key] && key_dest == key_game) + if (cls.demoplayback && down && consolekeys[key] && key_dest == key_game && key != K_TAB) { M_ToggleMenu_f (); return;