From e6c9a979c75a12a10fca648dd467d8e180e1a1a8 Mon Sep 17 00:00:00 2001 From: Spoike Date: Thu, 20 May 2021 15:35:26 +0000 Subject: [PATCH] Some obituaries were not getting coloured, others could not be linked. Also underline console links on mouseover to encourage users into realising that they can actually be clicked. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5865 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_parse.c | 96 ++++++++++++++++++++++++---------------- engine/client/console.c | 51 +++++++++++++++++++-- engine/client/keys.c | 2 +- engine/common/common.c | 2 +- 4 files changed, 107 insertions(+), 44 deletions(-) diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index b51c95d9e..0509895f5 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -6240,76 +6240,94 @@ static char acceptedchars[] = {'.', '?', '!', '\'', ',', ':', ' ', '\0'}; static void CL_PrintStandardMessage(char *msgtext, int printlevel) { int i; - player_info_t *p; + player_info_t *p, *foundp = NULL; extern cvar_t cl_standardmsg, msg; char *begin = msgtext; char fullmessage[2048]; + char *found; + if (printlevel < msg.ival) return; fullmessage[0] = 0; - // search for player names in message - for (i = 0, p = cl.players; i < cl.allocated_client_slots; p++, i++) + while(*msgtext) { - char *v; - char *name; - int len; - qboolean coloured; - char c; - - name = p->name; - if (!(*name)) - continue; - len = strlen(name); - v = strstr(msgtext, name); - while (v) + found = NULL; + // search for player names in message + for (i = 0, p = cl.players; i < cl.allocated_client_slots; p++, i++) { - // name parsing rules - if (v != begin && *(v-1) != ' ') // must be space before name - { - v = strstr(v+len, name); - continue; - } + char *v; + char *name; + int len; + name = p->name; + if (!(*name)) + continue; + len = strlen(name); + v = strstr(msgtext, name); + while (v) { - int i; - char aftername = *(v + len); - - // search for accepted chars in char after name in msg - for (i = 0; i < sizeof(acceptedchars); i++) + // name parsing rules + if (v != begin && *(v-1) != ' ') // must be space before name { - if (acceptedchars[i] == aftername) - break; + v = strstr(v+len, name); + continue; } - if (sizeof(acceptedchars) == i) { - v = strstr(v+len, name); - continue; // no accepted char found - } - } + int i; + char aftername = *(v + len); - *v = 0; // cut off message + // search for accepted chars in char after name in msg + for (i = 0; i < sizeof(acceptedchars); i++) + { + if (acceptedchars[i] == aftername) + break; + } + + if (sizeof(acceptedchars) == i) + { + v = strstr(v+len, name); + continue; // no accepted char found + } + } + + if (!found || v < found) + { + found = v; + foundp = p; + } + break; + } + } + + if (found) + { + qboolean coloured; + char c; + int len = strlen(foundp->name); // print msg chunk + *found = 0; // cut off message Q_strncatz(fullmessage, msgtext, sizeof(fullmessage)); - msgtext = v + len; // update search point + msgtext = found + len; // update search point // get name color - if (p->spectator || cl_standardmsg.ival) + if (foundp->spectator || cl_standardmsg.ival) { coloured = false; c = '7'; } else - c = '0' + CL_PlayerColor(p, &coloured); + c = '0' + CL_PlayerColor(foundp, &coloured); // print name - Q_strncatz(fullmessage, va("^[%s^%c%s^d\\player\\%i^]", coloured?"^m":"", c, name, (int)(p - cl.players)), sizeof(fullmessage)); - break; + Q_strncatz(fullmessage, va("^[%s^%c%s^d\\player\\%i^]", coloured?"^m":"", c, foundp->name, (int)(foundp - cl.players)), sizeof(fullmessage)); } + else + break; //nope, can't find anyone in there... } // print final chunk diff --git a/engine/client/console.c b/engine/client/console.c index 889a358b4..a5162c724 100644 --- a/engine/client/console.c +++ b/engine/client/console.c @@ -2574,12 +2574,51 @@ static int Con_DrawConsoleLines(console_t *con, conline_t *l, float displayscrol con->selstartoffset = c - (conchar_t*)(l+1); else con->selstartoffset = 0; + + if (selactive == 2 && s) + { //checking for mouseover + //scan earlier to find any link enclosure + for(; c >= (conchar_t*)(l+1); c--) + { + if (*c == CON_LINKSTART) + { + selactive = 3; //we're mouse-overing a link! + con->selstartoffset = c - (conchar_t*)(l+1); + break; + } + if (*c == CON_LINKEND) + break; //some other link ended here. don't use its start. + } + + if (selactive == 3 && con->selendline==l) + { + for (; c < (conchar_t*)(l+1)+l->length; c++) + if (*c == CON_LINKEND) + { + con->selendoffset = c - (conchar_t*)(l+1); + break; + } + + sstart = picw; + for (c = s; c < (conchar_t*)(l+1)+con->selstartoffset; ) + { + c = Font_Decode(c, &codeflags, &codepoint); + sstart = Font_CharEndCoord(font_console, sstart, codeflags, codepoint); + } + send = sstart; + for (; c < (conchar_t*)(l+1)+con->selendoffset; ) + { + c = Font_Decode(c, &codeflags, &codepoint); + send = Font_CharEndCoord(font_console, send, codeflags, codepoint); + } + } + } } sstart += center; send += center; - if (selactive == 1) + if (selactive != 2) { if (selactive == 1) R2D_ImageColours(SRGBA(0.1,0.1,0.3, alphaval)); //selected @@ -2587,8 +2626,14 @@ static int Con_DrawConsoleLines(console_t *con, conline_t *l, float displayscrol R2D_ImageColours(SRGBA(0.3,0.3,0.3, alphaval)); //mouseover. if (send < sstart) - R2D_FillBlock((send*vid.width)/(float)vid.rotpixelwidth, (y*vid.height)/(float)vid.rotpixelheight, ((sstart - send)*vid.width)/(float)vid.rotpixelwidth, (Font_CharHeight()*vid.height)/(float)vid.rotpixelheight); - else + { + center = sstart; + sstart = send; + send = center; + } + if (selactive == 3) //2 pixels high + R2D_FillBlock((sstart*vid.width)/(float)vid.rotpixelwidth, ((y+Font_CharHeight()-2)*vid.height)/(float)vid.rotpixelheight, ((send - sstart)*vid.width)/(float)vid.rotpixelwidth, (2*vid.height)/(float)vid.rotpixelheight); + else //full height R2D_FillBlock((sstart*vid.width)/(float)vid.rotpixelwidth, (y*vid.height)/(float)vid.rotpixelheight, ((send - sstart)*vid.width)/(float)vid.rotpixelwidth, (Font_CharHeight()*vid.height)/(float)vid.rotpixelheight); R2D_Flush(); } diff --git a/engine/client/keys.c b/engine/client/keys.c index b8e1b567e..a4953bd13 100644 --- a/engine/client/keys.c +++ b/engine/client/keys.c @@ -899,7 +899,7 @@ void Key_DefaultLinkClicked(console_t *con, char *text, char *info) if (*cl.players[player].ip) Con_Footerf(con, true, "\n%s", cl.players[player].ip); - if (cl.playerview[0].spectator || cls.demoplayback) + if (cl.playerview[0].spectator || cls.demoplayback==DPB_MVD||cls.demoplayback==DPB_EZTV) { //we're spectating, or an mvd Con_Footerf(con, true, " ^[Spectate\\player\\%i\\action\\spec^]", player); diff --git a/engine/common/common.c b/engine/common/common.c index f1c1dcde1..ea9b2fb6e 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -3282,7 +3282,7 @@ char *COM_DeFunString(conchar_t *str, conchar_t *stop, char *out, int outsize, q } if (d & CON_2NDCHARSETTEXT) { //FIXME: convert to quake glyphs... - if (!com_parseutf8.ival && !forceutf8 && codepoint >= 32 && codepoint <= 127) + if (!com_parseutf8.ival && !forceutf8 && codepoint >= 32 && codepoint <= 127 && (codeflags&CON_2NDCHARSETTEXT)) { //strip the flag and encode it in private use (so it gets encoded as quake-compatible) codeflags &= ~CON_2NDCHARSETTEXT; codepoint |= 0xe080;