mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-28 05:11:34 +00:00
Changed chat position,
Added chat back tint Fixed word wrapping glitches
This commit is contained in:
parent
03dc4c9680
commit
8747a8529d
5 changed files with 116 additions and 96 deletions
|
@ -684,6 +684,7 @@ void D_RegisterClientCommands(void)
|
|||
CV_RegisterVar(&cv_chatwidth);
|
||||
CV_RegisterVar(&cv_chattime);
|
||||
CV_RegisterVar(&cv_chatspamprotection);
|
||||
CV_RegisterVar(&cv_chatbacktint);
|
||||
CV_RegisterVar(&cv_consolechat);
|
||||
CV_RegisterVar(&cv_chatnotifications);
|
||||
CV_RegisterVar(&cv_crosshair);
|
||||
|
|
|
@ -370,6 +370,9 @@ consvar_t cv_chatnotifications= {"chatnotifications", "On", CV_SAVE, CV_OnOff, N
|
|||
// chat spam protection (why would you want to disable that???)
|
||||
consvar_t cv_chatspamprotection= {"chatspamprotection", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// minichat text background
|
||||
consvar_t cv_chatbacktint = {"chatbacktint", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// old shit console chat. (mostly exists for stuff like terminal, not because I cared if anyone liked the old chat.)
|
||||
consvar_t cv_consolechat= {"consolechat", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ extern tic_t timeinmap; // Ticker for time spent in level (used for levelcard di
|
|||
extern INT16 rw_maximums[NUM_WEAPONS];
|
||||
|
||||
// used in game menu
|
||||
extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, cv_consolechat, cv_chatspamprotection, cv_compactscoreboard;
|
||||
extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, cv_consolechat, cv_chatbacktint, cv_chatspamprotection, cv_compactscoreboard;
|
||||
extern consvar_t cv_crosshair, cv_crosshair2;
|
||||
extern consvar_t cv_invertmouse, cv_alwaysfreelook, cv_mousemove;
|
||||
extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_fireaxis,cv_firenaxis;
|
||||
|
|
|
@ -1223,9 +1223,10 @@ char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string)
|
|||
return newstring;
|
||||
}
|
||||
|
||||
|
||||
// 30/7/18: chaty is now the distance at which the lowest point of the chat will be drawn if that makes any sense.
|
||||
|
||||
INT16 chatx = 16, chaty = 172; // let's use this as our coordinates, shh
|
||||
INT16 chatx = 13, chaty = 169; // let's use this as our coordinates, shh
|
||||
|
||||
// chat stuff by VincyTM LOL XD!
|
||||
|
||||
|
@ -1233,22 +1234,21 @@ INT16 chatx = 16, chaty = 172; // let's use this as our coordinates, shh
|
|||
|
||||
static void HU_drawMiniChat(void)
|
||||
{
|
||||
|
||||
if (!chat_nummsg_min)
|
||||
return; // needless to say it's useless to do anything if we don't have anything to draw.
|
||||
|
||||
|
||||
INT32 x = chatx+2;
|
||||
INT32 charwidth = 4, charheight = 6;
|
||||
INT32 dx = 0, dy = 0;
|
||||
size_t i = chat_nummsg_min;
|
||||
boolean prev_linereturn = false; // a hack to prevent double \n while I have no idea why they happen in the first place.
|
||||
|
||||
INT32 msglines = 0;
|
||||
// process all messages once without rendering anything or doing anything fancy so that we know how many lines each message has...
|
||||
|
||||
for (; i>0; i--)
|
||||
{
|
||||
const char *msg = CHAT_WordWrap(x, cv_chatwidth.value-charwidth, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i-1]);
|
||||
const char *msg = CHAT_WordWrap(x+2, cv_chatwidth.value-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i-1]);
|
||||
size_t j = 0;
|
||||
INT32 linescount = 0;
|
||||
|
||||
|
@ -1259,8 +1259,12 @@ static void HU_drawMiniChat(void)
|
|||
if (msg[j] == '\n') // get back down.
|
||||
{
|
||||
++j;
|
||||
linescount += 1;
|
||||
dx = 0;
|
||||
if (!prev_linereturn)
|
||||
{
|
||||
linescount += 1;
|
||||
dx = 0;
|
||||
}
|
||||
prev_linereturn = true;
|
||||
continue;
|
||||
}
|
||||
else if (msg[j] & 0x80) // stolen from video.c, nice.
|
||||
|
@ -1275,7 +1279,7 @@ static void HU_drawMiniChat(void)
|
|||
{
|
||||
j++;
|
||||
}
|
||||
|
||||
prev_linereturn = false;
|
||||
dx += charwidth;
|
||||
if (dx >= cv_chatwidth.value)
|
||||
{
|
||||
|
@ -1292,15 +1296,15 @@ static void HU_drawMiniChat(void)
|
|||
dx = 0;
|
||||
dy = 0;
|
||||
i = 0;
|
||||
prev_linereturn = false;
|
||||
|
||||
for (; i<=(chat_nummsg_min-1); i++) // iterate through our hot messages
|
||||
{
|
||||
|
||||
INT32 clrflag = 0;
|
||||
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.
|
||||
size_t j = 0;
|
||||
const char *msg = CHAT_WordWrap(x, cv_chatwidth.value-charwidth, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i]); // get the current message, and word wrap it.
|
||||
const char *msg = CHAT_WordWrap(x+2, cv_chatwidth.value-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i]); // get the current message, and word wrap it.
|
||||
|
||||
while(msg[j]) // iterate through msg
|
||||
{
|
||||
|
@ -1309,8 +1313,12 @@ static void HU_drawMiniChat(void)
|
|||
if (msg[j] == '\n') // get back down.
|
||||
{
|
||||
++j;
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
if (!prev_linereturn)
|
||||
{
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
}
|
||||
prev_linereturn = true;
|
||||
continue;
|
||||
}
|
||||
else if (msg[j] & 0x80) // stolen from video.c, nice.
|
||||
|
@ -1325,10 +1333,15 @@ static void HU_drawMiniChat(void)
|
|||
else
|
||||
{
|
||||
UINT8 *colormap = CHAT_GetStringColormap(clrflag);
|
||||
|
||||
if (cv_chatbacktint.value) // on request of wolfy
|
||||
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, !cv_allcaps.value, colormap);
|
||||
}
|
||||
|
||||
dx += charwidth;
|
||||
prev_linereturn = false;
|
||||
if (dx >= cv_chatwidth.value)
|
||||
{
|
||||
dx = 0;
|
||||
|
@ -1388,7 +1401,7 @@ static void HU_drawChatLog(INT32 offset)
|
|||
|
||||
INT32 charwidth = 4, charheight = 6;
|
||||
INT32 x = chatx+2, y = chaty - offset*charheight - (chat_scroll*charheight) - cv_chatheight.value*charheight - 12, dx = 0, dy = 0;
|
||||
size_t i = 0;
|
||||
UINT32 i = 0;
|
||||
INT32 chat_topy = y + chat_scroll*charheight;
|
||||
INT32 chat_bottomy = chat_topy + cv_chatheight.value*charheight;
|
||||
boolean atbottom = false;
|
||||
|
@ -1398,8 +1411,8 @@ static void HU_drawChatLog(INT32 offset)
|
|||
for (i=0; i<chat_nummsg_log; i++) // iterate through our chatlog
|
||||
{
|
||||
INT32 clrflag = 0;
|
||||
size_t j = 0;
|
||||
const char *msg = CHAT_WordWrap(x, cv_chatwidth.value-charwidth, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_log[i]); // get the current message, and word wrap it.
|
||||
INT32 j = 0;
|
||||
const char *msg = CHAT_WordWrap(x+2, cv_chatwidth.value-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_log[i]); // get the current message, and word wrap it.
|
||||
while(msg[j]) // iterate through msg
|
||||
{
|
||||
if (msg[j] < HU_FONTSTART) // don't draw
|
||||
|
@ -1449,9 +1462,11 @@ static void HU_drawChatLog(INT32 offset)
|
|||
chat_scrollmedown = false;
|
||||
|
||||
// getmaxscroll through a lazy hack. We do all these loops, so let's not do more loops that are gonna lag the game more. :P
|
||||
chat_maxscroll = (dy/charheight)-cv_chatheight.value; // welcome to C, we don't know what min() and max() are.
|
||||
if (chat_maxscroll < 0)
|
||||
chat_maxscroll = (dy/charheight); // welcome to C, we don't know what min() and max() are.
|
||||
if (chat_maxscroll <= (UINT32)cv_chatheight.value)
|
||||
chat_maxscroll = 0;
|
||||
else
|
||||
chat_maxscroll -= cv_chatheight.value;
|
||||
|
||||
// if we're not bound by the time, autoscroll for next frame:
|
||||
if (atbottom)
|
||||
|
@ -1479,7 +1494,7 @@ static void HU_DrawChat(void)
|
|||
{
|
||||
INT32 charwidth = 4, charheight = 6;
|
||||
INT32 t = 0, c = 0, y = chaty - (typelines*charheight);
|
||||
size_t i = 0;
|
||||
UINT32 i = 0;
|
||||
const char *ntalk = "Say: ", *ttalk = "Team: ";
|
||||
const char *talk = ntalk;
|
||||
|
||||
|
@ -1549,7 +1564,7 @@ static void HU_DrawChat(void)
|
|||
if (strnicmp(w_chat, "/pm", 3) == 0 && vid.width >= 400 && !teamtalk) // 320x200 unsupported kthxbai
|
||||
{
|
||||
i = 0;
|
||||
int count = 0;
|
||||
INT32 count = 0;
|
||||
INT32 p_dispy = chaty - charheight -1;
|
||||
for(i=0; (i<MAXPLAYERS); i++)
|
||||
{
|
||||
|
@ -1565,7 +1580,7 @@ static void HU_DrawChat(void)
|
|||
|
||||
char *nodenum = (char*) malloc(3);
|
||||
strncpy(nodenum, w_chat+3, 4);
|
||||
INT32 n = atoi((const char*) nodenum); // turn that into a number
|
||||
UINT32 n = atoi((const char*) nodenum); // turn that into a number
|
||||
// special cases:
|
||||
|
||||
if ((n == 0) && !(w_chat[4] == '0'))
|
||||
|
|
13
src/m_menu.c
13
src/m_menu.c
|
@ -1306,12 +1306,13 @@ static menuitem_t OP_GameOptionsMenu[] =
|
|||
|
||||
static menuitem_t OP_ChatOptionsMenu[] =
|
||||
{
|
||||
{IT_STRING | IT_CVAR, NULL, "Chat Width", &cv_chatwidth, 10},
|
||||
{IT_STRING | IT_CVAR, NULL, "Chat Height", &cv_chatheight, 20},
|
||||
{IT_STRING | IT_CVAR, NULL, "Message Timer", &cv_chattime, 30},
|
||||
{IT_STRING | IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 40},
|
||||
{IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 50},
|
||||
{IT_STRING | IT_CVAR, NULL, "Old Console Chat", &cv_consolechat, 60},
|
||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Chat Box Width", &cv_chatwidth, 10},
|
||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Chat Box Height", &cv_chatheight, 20},
|
||||
{IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 30},
|
||||
{IT_STRING | IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 40},
|
||||
{IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 50},
|
||||
{IT_STRING | IT_CVAR, NULL, "Chat background tint", &cv_chatbacktint, 60},
|
||||
{IT_STRING | IT_CVAR, NULL, "Old Console Chat", &cv_consolechat, 70},
|
||||
};
|
||||
|
||||
static menuitem_t OP_ServerOptionsMenu[] =
|
||||
|
|
Loading…
Reference in a new issue