mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-14 00:50:38 +00:00
some merges from uhexen2: clean up some crap in long chat line support.
do not set messagemode when not really connected. made chat_buffer[] and chat_bufferlen static to keys.c. console.c uses new Key_GetChatBuffer() and Key_GetChatMsgLen() accessor functions. renamed team_message global to chat_team as in qw/q2. added Key_EndChat() as a new helper. called Key_EndChat() from within CL_Disconnect() to not get stuck in chat mode. now that key_message is guaranteed to be set only in game mode, removed its cases from Key_ForceDest(). several other cleanups. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@771 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
73aee2dd56
commit
9a78c9e829
7 changed files with 107 additions and 103 deletions
|
@ -112,6 +112,9 @@ This is also called on Host_Error, so it shouldn't cause any errors
|
||||||
*/
|
*/
|
||||||
void CL_Disconnect (void)
|
void CL_Disconnect (void)
|
||||||
{
|
{
|
||||||
|
if (key_dest == key_message)
|
||||||
|
Key_EndChat (); // don't get stuck in chat mode
|
||||||
|
|
||||||
// stop sounds (especially looping!)
|
// stop sounds (especially looping!)
|
||||||
S_StopAllSounds (true);
|
S_StopAllSounds (true);
|
||||||
BGM_Stop();
|
BGM_Stop();
|
||||||
|
|
|
@ -321,9 +321,6 @@ void CL_UpdateTEnts (void);
|
||||||
|
|
||||||
void CL_ClearState (void);
|
void CL_ClearState (void);
|
||||||
|
|
||||||
float CL_KeyState (kbutton_t *key);
|
|
||||||
const char *Key_KeynumToString (int keynum);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// cl_demo.c
|
// cl_demo.c
|
||||||
//
|
//
|
||||||
|
|
|
@ -37,6 +37,7 @@ float con_cursorspeed = 4;
|
||||||
|
|
||||||
#define CON_TEXTSIZE 65536 //johnfitz -- new default size
|
#define CON_TEXTSIZE 65536 //johnfitz -- new default size
|
||||||
#define CON_MINSIZE 16384 //johnfitz -- old default, now the minimum size
|
#define CON_MINSIZE 16384 //johnfitz -- old default, now the minimum size
|
||||||
|
|
||||||
int con_buffersize; //johnfitz -- user can now override default
|
int con_buffersize; //johnfitz -- user can now override default
|
||||||
|
|
||||||
qboolean con_forcedup; // because no entities to refresh
|
qboolean con_forcedup; // because no entities to refresh
|
||||||
|
@ -60,10 +61,6 @@ int con_vislines;
|
||||||
|
|
||||||
qboolean con_debuglog = false;
|
qboolean con_debuglog = false;
|
||||||
|
|
||||||
extern char key_lines[32][MAXCMDLINE];
|
|
||||||
extern int edit_line;
|
|
||||||
extern int key_linepos;
|
|
||||||
|
|
||||||
qboolean con_initialized;
|
qboolean con_initialized;
|
||||||
|
|
||||||
extern void M_Menu_Main_f (void);
|
extern void M_Menu_Main_f (void);
|
||||||
|
@ -108,7 +105,7 @@ extern int history_line; //johnfitz
|
||||||
|
|
||||||
void Con_ToggleConsole_f (void)
|
void Con_ToggleConsole_f (void)
|
||||||
{
|
{
|
||||||
if (key_dest == key_console)
|
if (key_dest == key_console/* || (key_dest == key_game && con_forcedup)*/)
|
||||||
{
|
{
|
||||||
if (cls.state == ca_connected)
|
if (cls.state == ca_connected)
|
||||||
{
|
{
|
||||||
|
@ -139,7 +136,7 @@ void Con_ToggleConsole_f (void)
|
||||||
Con_Clear_f
|
Con_Clear_f
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Con_Clear_f (void)
|
static void Con_Clear_f (void)
|
||||||
{
|
{
|
||||||
if (con_text)
|
if (con_text)
|
||||||
Q_memset (con_text, ' ', con_buffersize); //johnfitz -- con_buffersize replaces CON_TEXTSIZE
|
Q_memset (con_text, ' ', con_buffersize); //johnfitz -- con_buffersize replaces CON_TEXTSIZE
|
||||||
|
@ -151,7 +148,7 @@ void Con_Clear_f (void)
|
||||||
Con_Dump_f -- johnfitz -- adapted from quake2 source
|
Con_Dump_f -- johnfitz -- adapted from quake2 source
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Con_Dump_f (void)
|
static void Con_Dump_f (void)
|
||||||
{
|
{
|
||||||
int l, x;
|
int l, x;
|
||||||
const char *line;
|
const char *line;
|
||||||
|
@ -245,12 +242,12 @@ void Con_ClearNotify (void)
|
||||||
Con_MessageMode_f
|
Con_MessageMode_f
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
extern qboolean team_message;
|
static void Con_MessageMode_f (void)
|
||||||
|
|
||||||
void Con_MessageMode_f (void)
|
|
||||||
{
|
{
|
||||||
|
if (cls.state != ca_connected || cls.demoplayback)
|
||||||
|
return;
|
||||||
|
chat_team = false;
|
||||||
key_dest = key_message;
|
key_dest = key_message;
|
||||||
team_message = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -259,10 +256,12 @@ void Con_MessageMode_f (void)
|
||||||
Con_MessageMode2_f
|
Con_MessageMode2_f
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Con_MessageMode2_f (void)
|
static void Con_MessageMode2_f (void)
|
||||||
{
|
{
|
||||||
|
if (cls.state != ca_connected || cls.demoplayback)
|
||||||
|
return;
|
||||||
|
chat_team = true;
|
||||||
key_dest = key_message;
|
key_dest = key_message;
|
||||||
team_message = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -372,7 +371,7 @@ void Con_Init (void)
|
||||||
Con_Linefeed
|
Con_Linefeed
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
void Con_Linefeed (void)
|
static void Con_Linefeed (void)
|
||||||
{
|
{
|
||||||
//johnfitz -- improved scrolling
|
//johnfitz -- improved scrolling
|
||||||
if (con_backscroll)
|
if (con_backscroll)
|
||||||
|
@ -383,8 +382,7 @@ void Con_Linefeed (void)
|
||||||
|
|
||||||
con_x = 0;
|
con_x = 0;
|
||||||
con_current++;
|
con_current++;
|
||||||
Q_memset (&con_text[(con_current%con_totallines)*con_linewidth]
|
Q_memset (&con_text[(con_current%con_totallines)*con_linewidth], ' ', con_linewidth);
|
||||||
, ' ', con_linewidth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -396,7 +394,7 @@ All console printing must go through this in order to be logged to disk
|
||||||
If no console is visible, the notify window will pop up.
|
If no console is visible, the notify window will pop up.
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Con_Print (const char *txt)
|
static void Con_Print (const char *txt)
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
int c, l;
|
int c, l;
|
||||||
|
@ -608,7 +606,6 @@ void Con_DPrintf2 (const char *fmt, ...)
|
||||||
va_start (argptr, fmt);
|
va_start (argptr, fmt);
|
||||||
q_vsnprintf (msg, sizeof(msg), fmt, argptr);
|
q_vsnprintf (msg, sizeof(msg), fmt, argptr);
|
||||||
va_end (argptr);
|
va_end (argptr);
|
||||||
|
|
||||||
Con_Printf ("%s", msg);
|
Con_Printf ("%s", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1064,13 +1061,10 @@ Con_DrawNotify
|
||||||
Draws the last few lines of output transparently over the game top
|
Draws the last few lines of output transparently over the game top
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
extern char chat_buffer[];
|
|
||||||
|
|
||||||
void Con_DrawNotify (void)
|
void Con_DrawNotify (void)
|
||||||
{
|
{
|
||||||
int x, v;
|
int i, x, v;
|
||||||
char *text;
|
const char *text;
|
||||||
int i;
|
|
||||||
float time;
|
float time;
|
||||||
|
|
||||||
GL_SetCanvas (CANVAS_CONSOLE); //johnfitz
|
GL_SetCanvas (CANVAS_CONSOLE); //johnfitz
|
||||||
|
@ -1100,37 +1094,32 @@ void Con_DrawNotify (void)
|
||||||
|
|
||||||
if (key_dest == key_message)
|
if (key_dest == key_message)
|
||||||
{
|
{
|
||||||
// modified by S.A to support longer lines
|
|
||||||
|
|
||||||
char c[MAXCMDLINE+1]; // extra space == +1
|
|
||||||
const char *say_prompt;
|
|
||||||
int say_length, len;
|
|
||||||
|
|
||||||
clearnotify = 0;
|
clearnotify = 0;
|
||||||
x = 0;
|
|
||||||
|
|
||||||
if (team_message)
|
if (chat_team)
|
||||||
say_prompt = "say_team:";
|
{
|
||||||
|
Draw_String (8, v, "say_team:");
|
||||||
|
x = 11;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
say_prompt = "say:";
|
{
|
||||||
|
Draw_String (8, v, "say:");
|
||||||
|
x = 6;
|
||||||
|
}
|
||||||
|
|
||||||
say_length = strlen(say_prompt);
|
text = Key_GetChatBuffer();
|
||||||
|
i = Key_GetChatMsgLen();
|
||||||
Draw_String (8, v, say_prompt); //johnfitz
|
if (i > con_linewidth - x - 1)
|
||||||
|
text += i - con_linewidth + x + 1;
|
||||||
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)
|
while (*text)
|
||||||
{
|
{
|
||||||
Draw_Character ( (x+say_length+2)<<3, v, *text); //johnfitz
|
Draw_Character (x<<3, v, *text);
|
||||||
x++; text++;
|
x++;
|
||||||
|
text++;
|
||||||
}
|
}
|
||||||
Draw_Character ( (x+say_length+1)<<3, v, 10+((int)(realtime*con_cursorspeed)&1));
|
|
||||||
|
Draw_Character (x<<3, v, 10 + ((int)(realtime*con_cursorspeed)&1));
|
||||||
v += 8;
|
v += 8;
|
||||||
|
|
||||||
scr_tileclear_updates = 0; //johnfitz
|
scr_tileclear_updates = 0; //johnfitz
|
||||||
|
@ -1145,8 +1134,6 @@ The input line scrolls horizontally if typing goes beyond the right edge
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
extern qpic_t *pic_ovr, *pic_ins; //johnfitz -- new cursor handling
|
extern qpic_t *pic_ovr, *pic_ins; //johnfitz -- new cursor handling
|
||||||
extern double key_blinktime;
|
|
||||||
extern int key_insert;
|
|
||||||
|
|
||||||
void Con_DrawInput (void)
|
void Con_DrawInput (void)
|
||||||
{
|
{
|
||||||
|
@ -1184,8 +1171,8 @@ The typing input line at the bottom should only be drawn if typing is allowed
|
||||||
void Con_DrawConsole (int lines, qboolean drawinput)
|
void Con_DrawConsole (int lines, qboolean drawinput)
|
||||||
{
|
{
|
||||||
int i, x, y, j, sb, rows;
|
int i, x, y, j, sb, rows;
|
||||||
|
const char *text;
|
||||||
char ver[32];
|
char ver[32];
|
||||||
char *text;
|
|
||||||
|
|
||||||
if (lines <= 0)
|
if (lines <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -39,13 +39,11 @@ void Con_DrawCharacter (int cx, int line, int num);
|
||||||
void Con_CheckResize (void);
|
void Con_CheckResize (void);
|
||||||
void Con_Init (void);
|
void Con_Init (void);
|
||||||
void Con_DrawConsole (int lines, qboolean drawinput);
|
void Con_DrawConsole (int lines, qboolean drawinput);
|
||||||
void Con_Print (const char *txt);
|
|
||||||
void Con_Printf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
void Con_Printf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
||||||
void Con_Warning (const char *fmt, ...) __attribute__((__format__(__printf__,1,2))); //johnfitz
|
void Con_Warning (const char *fmt, ...) __attribute__((__format__(__printf__,1,2))); //johnfitz
|
||||||
void Con_DPrintf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
void Con_DPrintf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
||||||
void Con_DPrintf2 (const char *fmt, ...) __attribute__((__format__(__printf__,1,2))); //johnfitz
|
void Con_DPrintf2 (const char *fmt, ...) __attribute__((__format__(__printf__,1,2))); //johnfitz
|
||||||
void Con_SafePrintf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
void Con_SafePrintf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)));
|
||||||
void Con_Clear_f (void);
|
|
||||||
void Con_DrawNotify (void);
|
void Con_DrawNotify (void);
|
||||||
void Con_ClearNotify (void);
|
void Con_ClearNotify (void);
|
||||||
void Con_ToggleConsole_f (void);
|
void Con_ToggleConsole_f (void);
|
||||||
|
|
|
@ -93,7 +93,6 @@ Max_Edicts_f -- johnfitz
|
||||||
static void Max_Edicts_f (cvar_t *var)
|
static void Max_Edicts_f (cvar_t *var)
|
||||||
{
|
{
|
||||||
//TODO: clamp it here?
|
//TODO: clamp it here?
|
||||||
|
|
||||||
if (cls.state == ca_connected || sv.active)
|
if (cls.state == ca_connected || sv.active)
|
||||||
Con_Printf ("Changes to max_edicts will not take effect until the next time a map is loaded.\n");
|
Con_Printf ("Changes to max_edicts will not take effect until the next time a map is loaded.\n");
|
||||||
}
|
}
|
||||||
|
@ -686,10 +685,8 @@ void _Host_Frame (float time)
|
||||||
if (!Host_FilterTime (time))
|
if (!Host_FilterTime (time))
|
||||||
return; // don't run too fast, or packets will flood out
|
return; // don't run too fast, or packets will flood out
|
||||||
|
|
||||||
// Force key_dest
|
|
||||||
Key_ForceDest ();
|
|
||||||
|
|
||||||
// get new key events
|
// get new key events
|
||||||
|
Key_ForceDest ();
|
||||||
Sys_SendKeyEvents ();
|
Sys_SendKeyEvents ();
|
||||||
|
|
||||||
// allow mice or other external controllers to add commands
|
// allow mice or other external controllers to add commands
|
||||||
|
|
41
Quake/keys.c
41
Quake/keys.c
|
@ -466,33 +466,45 @@ void Key_Console (int key)
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
char chat_buffer[MAXCMDLINE];
|
qboolean chat_team = false;
|
||||||
qboolean team_message = false;
|
static char chat_buffer[MAXCMDLINE];
|
||||||
|
static int chat_bufferlen = 0;
|
||||||
|
|
||||||
|
const char *Key_GetChatBuffer (void)
|
||||||
|
{
|
||||||
|
return chat_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Key_GetChatMsgLen (void)
|
||||||
|
{
|
||||||
|
return chat_bufferlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Key_EndChat (void)
|
||||||
|
{
|
||||||
|
key_dest = key_game;
|
||||||
|
chat_bufferlen = 0;
|
||||||
|
chat_buffer[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Key_Message (int key)
|
void Key_Message (int key)
|
||||||
{
|
{
|
||||||
static int chat_bufferlen = 0;
|
|
||||||
|
|
||||||
if (key == K_ENTER)
|
if (key == K_ENTER)
|
||||||
{
|
{
|
||||||
if (team_message)
|
if (chat_team)
|
||||||
Cbuf_AddText ("say_team \"");
|
Cbuf_AddText ("say_team \"");
|
||||||
else
|
else
|
||||||
Cbuf_AddText ("say \"");
|
Cbuf_AddText ("say \"");
|
||||||
Cbuf_AddText(chat_buffer);
|
Cbuf_AddText(chat_buffer);
|
||||||
Cbuf_AddText("\"\n");
|
Cbuf_AddText("\"\n");
|
||||||
|
|
||||||
key_dest = key_game;
|
Key_EndChat ();
|
||||||
chat_bufferlen = 0;
|
|
||||||
chat_buffer[0] = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == K_ESCAPE)
|
if (key == K_ESCAPE)
|
||||||
{
|
{
|
||||||
key_dest = key_game;
|
Key_EndChat ();
|
||||||
chat_bufferlen = 0;
|
|
||||||
chat_buffer[0] = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1051,17 +1063,14 @@ void Key_ForceDest (void)
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
}
|
}
|
||||||
return;
|
break;
|
||||||
case key_game:
|
case key_game:
|
||||||
case key_message:
|
|
||||||
if (cls.state != ca_connected)
|
if (cls.state != ca_connected)
|
||||||
{
|
{
|
||||||
forced = true;
|
forced = true;
|
||||||
if (key_dest == key_message)
|
|
||||||
Key_Message(K_ESCAPE);
|
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_console;
|
key_dest = key_console;
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
default:
|
default:
|
||||||
|
|
19
Quake/keys.h
19
Quake/keys.h
|
@ -142,23 +142,36 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define K_MOUSE5 242
|
#define K_MOUSE5 242
|
||||||
|
|
||||||
|
|
||||||
typedef enum {key_game, key_console, key_message, key_menu} keydest_t;
|
|
||||||
|
|
||||||
#define MAXCMDLINE 256
|
#define MAXCMDLINE 256
|
||||||
|
|
||||||
|
typedef enum {key_game, key_console, key_message, key_menu} keydest_t;
|
||||||
|
|
||||||
extern keydest_t key_dest;
|
extern keydest_t key_dest;
|
||||||
extern char *keybindings[256];
|
extern char *keybindings[256];
|
||||||
extern int key_repeats[256];
|
extern int key_repeats[256];
|
||||||
extern int key_count; // incremented every key event
|
extern int key_count; // incremented every key event
|
||||||
extern int key_lastpress;
|
extern int key_lastpress;
|
||||||
|
|
||||||
|
extern char key_lines[32][MAXCMDLINE];
|
||||||
|
extern int edit_line;
|
||||||
|
extern int key_linepos;
|
||||||
|
extern int key_insert;
|
||||||
|
extern double key_blinktime;
|
||||||
|
|
||||||
void Key_Event (int key, qboolean down);
|
void Key_Event (int key, qboolean down);
|
||||||
void Key_Init (void);
|
void Key_Init (void);
|
||||||
void Key_WriteBindings (FILE *f);
|
void Key_WriteBindings (FILE *f);
|
||||||
void Key_SetBinding (int keynum, const char *binding);
|
|
||||||
void Key_ClearStates (void);
|
void Key_ClearStates (void);
|
||||||
void Key_ForceDest (void);
|
void Key_ForceDest (void);
|
||||||
|
|
||||||
|
void Key_SetBinding (int keynum, const char *binding);
|
||||||
|
const char *Key_KeynumToString (int keynum);
|
||||||
|
|
||||||
|
extern qboolean chat_team;
|
||||||
|
void Key_EndChat (void);
|
||||||
|
const char *Key_GetChatBuffer (void);
|
||||||
|
int Key_GetChatMsgLen (void);
|
||||||
|
|
||||||
void History_Init (void);
|
void History_Init (void);
|
||||||
void History_Shutdown (void);
|
void History_Shutdown (void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue