mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-21 20:11:12 +00:00
Fix chat word wrapping by reintroducing some old hacks
This commit is contained in:
parent
e4642c278f
commit
05c97dbd56
1 changed files with 47 additions and 18 deletions
|
@ -1218,27 +1218,36 @@ static void HU_drawMiniChat(void)
|
||||||
INT32 charwidth = 4, charheight = 6;
|
INT32 charwidth = 4, charheight = 6;
|
||||||
INT32 boxw = cv_chatwidth.value;
|
INT32 boxw = cv_chatwidth.value;
|
||||||
INT32 dx = 0, dy = 0;
|
INT32 dx = 0, dy = 0;
|
||||||
|
boolean prev_linereturn = false;
|
||||||
|
|
||||||
if (!chat_nummsg_min)
|
if (!chat_nummsg_min)
|
||||||
return; // needless to say it's useless to do anything if we don't have anything to draw.
|
return; // needless to say it's useless to do anything if we don't have anything to draw.
|
||||||
|
|
||||||
for (size_t i = chat_nummsg_min; i > 0; i--)
|
for (size_t i = chat_nummsg_min; i > 0; i--)
|
||||||
{
|
{
|
||||||
char *msg = V_ChatWordWrap(chatx, boxw-charwidth, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i-1]);
|
char *msg = V_ChatWordWrap(0, boxw-charwidth, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE|V_MONOSPACE, chat_mini[i-1]);
|
||||||
for(size_t j = 0; msg[j]; j++) // iterate through msg
|
for(size_t j = 0; msg[j]; j++) // iterate through msg
|
||||||
{
|
{
|
||||||
if (msg[j] == '\n') // get back down.
|
if (msg[j] == '\n') // get back down.
|
||||||
{
|
{
|
||||||
chatheight += charheight;
|
if (!prev_linereturn)
|
||||||
dx = 0;
|
{
|
||||||
|
chatheight += charheight;
|
||||||
|
dx = 0;
|
||||||
|
}
|
||||||
|
prev_linereturn = true;
|
||||||
}
|
}
|
||||||
else if (msg[j] >= FONTSTART)
|
else if (msg[j] >= FONTSTART)
|
||||||
{
|
{
|
||||||
|
prev_linereturn = false;
|
||||||
|
|
||||||
dx += charwidth;
|
dx += charwidth;
|
||||||
if (dx >= boxw)
|
|
||||||
|
if (dx >= boxw-charwidth-2)
|
||||||
{
|
{
|
||||||
dx = 0;
|
dx = 0;
|
||||||
chatheight += charheight;
|
chatheight += charheight;
|
||||||
|
prev_linereturn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1250,35 +1259,43 @@ static void HU_drawMiniChat(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
y = chaty - (chatheight + charheight);
|
y = chaty - (chatheight + charheight);
|
||||||
|
prev_linereturn = false;
|
||||||
|
|
||||||
for (size_t i = 0; i < chat_nummsg_min; i++) // iterate through our hot messages
|
for (size_t i = 0; i < chat_nummsg_min; i++) // iterate through our hot messages
|
||||||
{
|
{
|
||||||
INT32 timer = ((cv_chattime.value*TICRATE)-chat_timers[i]) - cv_chattime.value*TICRATE+9; // see below...
|
INT32 timer = ((cv_chattime.value*TICRATE)-chat_timers[i]) - cv_chattime.value*TICRATE+9; // see below...
|
||||||
INT32 transflag = (timer >= 0 && timer <= 9) ? (timer*V_10TRANS) : 0; // you can make bad jokes out of this one.
|
INT32 transflag = (timer >= 0 && timer <= 9) ? (timer*V_10TRANS) : 0; // you can make bad jokes out of this one.
|
||||||
char *msg = V_ChatWordWrap(chatx, boxw-charwidth, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i]); // get the current message, and word wrap it.
|
char *msg = V_ChatWordWrap(0, boxw-charwidth, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE|V_MONOSPACE, chat_mini[i]); // get the current message, and word wrap it.
|
||||||
UINT8 *colormap = NULL;
|
UINT8 *colormap = NULL;
|
||||||
|
|
||||||
for(size_t j = 0; msg[j]; j++) // iterate through msg
|
for(size_t j = 0; msg[j]; j++) // iterate through msg
|
||||||
{
|
{
|
||||||
if (msg[j] == '\n') // get back down.
|
if (msg[j] == '\n') // get back down.
|
||||||
{
|
{
|
||||||
dy += charheight;
|
if (!prev_linereturn)
|
||||||
dx = 0;
|
{
|
||||||
|
dy += charheight;
|
||||||
|
dx = 0;
|
||||||
|
}
|
||||||
|
prev_linereturn = true;
|
||||||
}
|
}
|
||||||
else if (msg[j] & 0x80) // get colormap
|
else if (msg[j] & 0x80) // get colormap
|
||||||
colormap = V_GetStringColormap(((msg[j] & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK);
|
colormap = V_GetStringColormap(((msg[j] & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK);
|
||||||
else if (msg[j] >= FONTSTART)
|
else if (msg[j] >= FONTSTART)
|
||||||
{
|
{
|
||||||
|
prev_linereturn = false;
|
||||||
|
|
||||||
if (cv_chatbacktint.value) // on request of wolfy
|
if (cv_chatbacktint.value) // on request of wolfy
|
||||||
V_DrawFillConsoleMap(x + dx + 2, y+dy, charwidth, charheight, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT);
|
V_DrawFillConsoleMap(x + dx + 2, y+dy, charwidth, charheight, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT);
|
||||||
|
|
||||||
V_DrawChatCharacter(x + dx + 2, y+dy, msg[j] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag, true, colormap);
|
V_DrawChatCharacter(x + dx + 2, y+dy, msg[j] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_MONOSPACE|transflag, true, colormap);
|
||||||
|
|
||||||
dx += charwidth;
|
dx += charwidth;
|
||||||
if (dx >= boxw)
|
|
||||||
|
if (dx >= boxw-charwidth-2)
|
||||||
{
|
{
|
||||||
dx = 0;
|
dx = 0;
|
||||||
dy += charheight;
|
dy += charheight;
|
||||||
|
prev_linereturn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1303,6 +1320,7 @@ static void HU_drawChatLog(INT32 offset)
|
||||||
UINT32 i = 0;
|
UINT32 i = 0;
|
||||||
INT32 chat_topy, chat_bottomy;
|
INT32 chat_topy, chat_bottomy;
|
||||||
boolean atbottom = false;
|
boolean atbottom = false;
|
||||||
|
boolean prev_linereturn = false;
|
||||||
|
|
||||||
// make sure that our scroll position isn't "illegal";
|
// make sure that our scroll position isn't "illegal";
|
||||||
if (chat_scroll > chat_maxscroll)
|
if (chat_scroll > chat_maxscroll)
|
||||||
|
@ -1335,27 +1353,38 @@ static void HU_drawChatLog(INT32 offset)
|
||||||
|
|
||||||
for (i=0; i<chat_nummsg_log; i++) // iterate through our chatlog
|
for (i=0; i<chat_nummsg_log; i++) // iterate through our chatlog
|
||||||
{
|
{
|
||||||
char *msg = V_ChatWordWrap(chatx, boxw-charwidth, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_log[i]); // get the current message, and word wrap it.
|
char *msg = V_ChatWordWrap(0, boxw-charwidth, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE|V_MONOSPACE, chat_log[i]); // get the current message, and word wrap it.
|
||||||
UINT8 *colormap = NULL;
|
UINT8 *colormap = NULL;
|
||||||
for(size_t j = 0; msg[j]; j++) // iterate through msg
|
for(size_t j = 0; msg[j]; j++) // iterate through msg
|
||||||
{
|
{
|
||||||
if (msg[j] == '\n') // get back down.
|
if (msg[j] == '\n') // get back down.
|
||||||
{
|
{
|
||||||
dy += charheight;
|
if (!prev_linereturn)
|
||||||
dx = 0;
|
{
|
||||||
|
dy += charheight;
|
||||||
|
dx = 0;
|
||||||
|
}
|
||||||
|
prev_linereturn = true;
|
||||||
}
|
}
|
||||||
else if (msg[j] & 0x80) // get colormap
|
else if (msg[j] & 0x80) // get colormap
|
||||||
colormap = V_GetStringColormap(((msg[j] & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK);
|
colormap = V_GetStringColormap(((msg[j] & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK);
|
||||||
else if (msg[j] >= FONTSTART)
|
else
|
||||||
{
|
{
|
||||||
if ((y+dy+2 >= chat_topy) && (y+dy < (chat_bottomy)))
|
prev_linereturn = false;
|
||||||
V_DrawChatCharacter(x + dx + 2, y+dy+2, msg[j] |V_SNAPTOBOTTOM|V_SNAPTOLEFT, true, colormap);
|
|
||||||
|
|
||||||
dx += charwidth;
|
if (msg[j] >= FONTSTART)
|
||||||
if (dx >= boxw-charwidth-2 && i<chat_nummsg_log) // end of message shouldn't count, nor should invisible characters!!!!
|
{
|
||||||
|
if ((y+dy+2 >= chat_topy) && (y+dy < (chat_bottomy)))
|
||||||
|
V_DrawChatCharacter(x + dx + 2, y+dy+2, msg[j] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_MONOSPACE, true, colormap);
|
||||||
|
|
||||||
|
dx += charwidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dx >= boxw-charwidth-2 && i < chat_nummsg_log) // end of message shouldn't count, nor should invisible characters!!!!
|
||||||
{
|
{
|
||||||
dx = 0;
|
dx = 0;
|
||||||
dy += charheight;
|
dy += charheight;
|
||||||
|
prev_linereturn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue