mirror of
https://github.com/nzp-team/fteqw.git
synced 2025-02-07 07:41:09 +00:00
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
This commit is contained in:
parent
f73e1b7ffc
commit
e6c9a979c7
4 changed files with 107 additions and 44 deletions
|
@ -6240,76 +6240,94 @@ static char acceptedchars[] = {'.', '?', '!', '\'', ',', ':', ' ', '\0'};
|
||||||
static void CL_PrintStandardMessage(char *msgtext, int printlevel)
|
static void CL_PrintStandardMessage(char *msgtext, int printlevel)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
player_info_t *p;
|
player_info_t *p, *foundp = NULL;
|
||||||
extern cvar_t cl_standardmsg, msg;
|
extern cvar_t cl_standardmsg, msg;
|
||||||
char *begin = msgtext;
|
char *begin = msgtext;
|
||||||
char fullmessage[2048];
|
char fullmessage[2048];
|
||||||
|
|
||||||
|
char *found;
|
||||||
|
|
||||||
if (printlevel < msg.ival)
|
if (printlevel < msg.ival)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fullmessage[0] = 0;
|
fullmessage[0] = 0;
|
||||||
|
|
||||||
// search for player names in message
|
while(*msgtext)
|
||||||
for (i = 0, p = cl.players; i < cl.allocated_client_slots; p++, i++)
|
|
||||||
{
|
{
|
||||||
char *v;
|
found = NULL;
|
||||||
char *name;
|
// search for player names in message
|
||||||
int len;
|
for (i = 0, p = cl.players; i < cl.allocated_client_slots; p++, i++)
|
||||||
qboolean coloured;
|
|
||||||
char c;
|
|
||||||
|
|
||||||
name = p->name;
|
|
||||||
if (!(*name))
|
|
||||||
continue;
|
|
||||||
len = strlen(name);
|
|
||||||
v = strstr(msgtext, name);
|
|
||||||
while (v)
|
|
||||||
{
|
{
|
||||||
// name parsing rules
|
char *v;
|
||||||
if (v != begin && *(v-1) != ' ') // must be space before name
|
char *name;
|
||||||
{
|
int len;
|
||||||
v = strstr(v+len, name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
name = p->name;
|
||||||
|
if (!(*name))
|
||||||
|
continue;
|
||||||
|
len = strlen(name);
|
||||||
|
v = strstr(msgtext, name);
|
||||||
|
while (v)
|
||||||
{
|
{
|
||||||
int i;
|
// name parsing rules
|
||||||
char aftername = *(v + len);
|
if (v != begin && *(v-1) != ' ') // must be space before name
|
||||||
|
|
||||||
// search for accepted chars in char after name in msg
|
|
||||||
for (i = 0; i < sizeof(acceptedchars); i++)
|
|
||||||
{
|
{
|
||||||
if (acceptedchars[i] == aftername)
|
v = strstr(v+len, name);
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeof(acceptedchars) == i)
|
|
||||||
{
|
{
|
||||||
v = strstr(v+len, name);
|
int i;
|
||||||
continue; // no accepted char found
|
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
|
// print msg chunk
|
||||||
|
*found = 0; // cut off message
|
||||||
Q_strncatz(fullmessage, msgtext, sizeof(fullmessage));
|
Q_strncatz(fullmessage, msgtext, sizeof(fullmessage));
|
||||||
msgtext = v + len; // update search point
|
msgtext = found + len; // update search point
|
||||||
|
|
||||||
// get name color
|
// get name color
|
||||||
if (p->spectator || cl_standardmsg.ival)
|
if (foundp->spectator || cl_standardmsg.ival)
|
||||||
{
|
{
|
||||||
coloured = false;
|
coloured = false;
|
||||||
c = '7';
|
c = '7';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
c = '0' + CL_PlayerColor(p, &coloured);
|
c = '0' + CL_PlayerColor(foundp, &coloured);
|
||||||
|
|
||||||
// print name
|
// print name
|
||||||
Q_strncatz(fullmessage, va("^[%s^%c%s^d\\player\\%i^]", coloured?"^m":"", c, name, (int)(p - cl.players)), sizeof(fullmessage));
|
Q_strncatz(fullmessage, va("^[%s^%c%s^d\\player\\%i^]", coloured?"^m":"", c, foundp->name, (int)(foundp - cl.players)), sizeof(fullmessage));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
break; //nope, can't find anyone in there...
|
||||||
}
|
}
|
||||||
|
|
||||||
// print final chunk
|
// print final chunk
|
||||||
|
|
|
@ -2574,12 +2574,51 @@ static int Con_DrawConsoleLines(console_t *con, conline_t *l, float displayscrol
|
||||||
con->selstartoffset = c - (conchar_t*)(l+1);
|
con->selstartoffset = c - (conchar_t*)(l+1);
|
||||||
else
|
else
|
||||||
con->selstartoffset = 0;
|
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;
|
sstart += center;
|
||||||
send += center;
|
send += center;
|
||||||
|
|
||||||
if (selactive == 1)
|
if (selactive != 2)
|
||||||
{
|
{
|
||||||
if (selactive == 1)
|
if (selactive == 1)
|
||||||
R2D_ImageColours(SRGBA(0.1,0.1,0.3, alphaval)); //selected
|
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.
|
R2D_ImageColours(SRGBA(0.3,0.3,0.3, alphaval)); //mouseover.
|
||||||
|
|
||||||
if (send < sstart)
|
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_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();
|
R2D_Flush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -899,7 +899,7 @@ void Key_DefaultLinkClicked(console_t *con, char *text, char *info)
|
||||||
if (*cl.players[player].ip)
|
if (*cl.players[player].ip)
|
||||||
Con_Footerf(con, true, "\n%s", 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
|
//we're spectating, or an mvd
|
||||||
Con_Footerf(con, true, " ^[Spectate\\player\\%i\\action\\spec^]", player);
|
Con_Footerf(con, true, " ^[Spectate\\player\\%i\\action\\spec^]", player);
|
||||||
|
|
|
@ -3282,7 +3282,7 @@ char *COM_DeFunString(conchar_t *str, conchar_t *stop, char *out, int outsize, q
|
||||||
}
|
}
|
||||||
if (d & CON_2NDCHARSETTEXT)
|
if (d & CON_2NDCHARSETTEXT)
|
||||||
{ //FIXME: convert to quake glyphs...
|
{ //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)
|
{ //strip the flag and encode it in private use (so it gets encoded as quake-compatible)
|
||||||
codeflags &= ~CON_2NDCHARSETTEXT;
|
codeflags &= ~CON_2NDCHARSETTEXT;
|
||||||
codepoint |= 0xe080;
|
codepoint |= 0xe080;
|
||||||
|
|
Loading…
Reference in a new issue