mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 04:11:18 +00:00
Chat wordwrap fix + Minichat bg highlight
This commit is contained in:
parent
ad15ad4b89
commit
ee5ebd978a
6 changed files with 32 additions and 15 deletions
2
objs/Mingw/SDL/Release/.gitignore
vendored
2
objs/Mingw/SDL/Release/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
# DON'T REMOVE
|
|
||||||
# This keeps the folder from disappearing
|
|
|
@ -787,6 +787,7 @@ void D_RegisterClientCommands(void)
|
||||||
CV_RegisterVar(&cv_chatspamprotection);
|
CV_RegisterVar(&cv_chatspamprotection);
|
||||||
CV_RegisterVar(&cv_consolechat);
|
CV_RegisterVar(&cv_consolechat);
|
||||||
CV_RegisterVar(&cv_chatnotifications);
|
CV_RegisterVar(&cv_chatnotifications);
|
||||||
|
CV_RegisterVar(&cv_chatbackteint);
|
||||||
CV_RegisterVar(&cv_crosshair);
|
CV_RegisterVar(&cv_crosshair);
|
||||||
CV_RegisterVar(&cv_crosshair2);
|
CV_RegisterVar(&cv_crosshair2);
|
||||||
CV_RegisterVar(&cv_crosshair3);
|
CV_RegisterVar(&cv_crosshair3);
|
||||||
|
|
|
@ -421,6 +421,9 @@ consvar_t cv_chatnotifications = {"chatnotifications", "On", CV_SAVE, CV_OnOff,
|
||||||
// chat spam protection (why would you want to disable that???)
|
// 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};
|
consvar_t cv_chatspamprotection = {"chatspamprotection", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
|
// minichat text background
|
||||||
|
consvar_t cv_chatbackteint = {"chatbackteint", "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.)
|
// old shit console chat. (mostly exists for stuff like terminal, not because I cared if anyone liked the old chat.)
|
||||||
//static CV_PossibleValue_t consolechat_cons_t[] = {{0, "Box"}, {1, "Console"}, {0, NULL}}; -- for menu, but menu disabled...
|
//static CV_PossibleValue_t consolechat_cons_t[] = {{0, "Box"}, {1, "Console"}, {0, NULL}}; -- for menu, but menu disabled...
|
||||||
consvar_t cv_consolechat = {"consolechat", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
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];
|
extern INT16 rw_maximums[NUM_WEAPONS];
|
||||||
|
|
||||||
// used in game menu
|
// 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_chatspamprotection, cv_compactscoreboard, cv_chatbackteint;
|
||||||
extern consvar_t cv_crosshair, cv_crosshair2, cv_crosshair3, cv_crosshair4;
|
extern consvar_t cv_crosshair, cv_crosshair2, cv_crosshair3, cv_crosshair4;
|
||||||
extern consvar_t cv_invertmouse, cv_alwaysfreelook, cv_mousemove;
|
extern consvar_t cv_invertmouse, cv_alwaysfreelook, cv_mousemove;
|
||||||
extern consvar_t cv_turnaxis,cv_moveaxis,cv_brakeaxis,cv_aimaxis,cv_lookaxis,cv_fireaxis,cv_driftaxis;
|
extern consvar_t cv_turnaxis,cv_moveaxis,cv_brakeaxis,cv_aimaxis,cv_lookaxis,cv_fireaxis,cv_driftaxis;
|
||||||
|
|
|
@ -1189,7 +1189,7 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string)
|
||||||
size_t chw, i, lastusablespace = 0;
|
size_t chw, i, lastusablespace = 0;
|
||||||
size_t slen;
|
size_t slen;
|
||||||
char *newstring = Z_StrDup(string);
|
char *newstring = Z_StrDup(string);
|
||||||
INT32 spacewidth = (vid.width < 640) ? 8 : 4, charwidth = (vid.width < 640) ? 8 : 4;
|
INT32 charwidth = 4;
|
||||||
|
|
||||||
slen = strlen(string);
|
slen = strlen(string);
|
||||||
x = 0;
|
x = 0;
|
||||||
|
@ -1213,7 +1213,7 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string)
|
||||||
|
|
||||||
if (c < 0 || c >= HU_FONTSIZE || !hu_font[c])
|
if (c < 0 || c >= HU_FONTSIZE || !hu_font[c])
|
||||||
{
|
{
|
||||||
chw = spacewidth;
|
chw = charwidth;
|
||||||
lastusablespace = i;
|
lastusablespace = i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1250,13 +1250,14 @@ static void HU_drawMiniChat(void)
|
||||||
INT32 charwidth = 4, charheight = 6;
|
INT32 charwidth = 4, charheight = 6;
|
||||||
INT32 dx = 0, dy = 0;
|
INT32 dx = 0, dy = 0;
|
||||||
size_t i = chat_nummsg_min;
|
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;
|
INT32 msglines = 0;
|
||||||
// process all messages once without rendering anything or doing anything fancy so that we know how many lines each message has...
|
// 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--)
|
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;
|
size_t j = 0;
|
||||||
INT32 linescount = 0;
|
INT32 linescount = 0;
|
||||||
|
|
||||||
|
@ -1267,8 +1268,12 @@ static void HU_drawMiniChat(void)
|
||||||
if (msg[j] == '\n') // get back down.
|
if (msg[j] == '\n') // get back down.
|
||||||
{
|
{
|
||||||
++j;
|
++j;
|
||||||
linescount += 1;
|
if (!prev_linereturn)
|
||||||
dx = 0;
|
{
|
||||||
|
linescount += 1;
|
||||||
|
dx = 0;
|
||||||
|
}
|
||||||
|
prev_linereturn = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (msg[j] & 0x80) // stolen from video.c, nice.
|
else if (msg[j] & 0x80) // stolen from video.c, nice.
|
||||||
|
@ -1283,7 +1288,7 @@ static void HU_drawMiniChat(void)
|
||||||
{
|
{
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
prev_linereturn = false;
|
||||||
dx += charwidth;
|
dx += charwidth;
|
||||||
if (dx >= cv_chatwidth.value)
|
if (dx >= cv_chatwidth.value)
|
||||||
{
|
{
|
||||||
|
@ -1300,6 +1305,7 @@ static void HU_drawMiniChat(void)
|
||||||
dx = 0;
|
dx = 0;
|
||||||
dy = 0;
|
dy = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
prev_linereturn = false;
|
||||||
|
|
||||||
for (; i<=(chat_nummsg_min-1); i++) // iterate through our hot messages
|
for (; i<=(chat_nummsg_min-1); i++) // iterate through our hot messages
|
||||||
{
|
{
|
||||||
|
@ -1307,7 +1313,7 @@ static void HU_drawMiniChat(void)
|
||||||
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.
|
||||||
size_t j = 0;
|
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
|
while(msg[j]) // iterate through msg
|
||||||
{
|
{
|
||||||
|
@ -1316,8 +1322,12 @@ static void HU_drawMiniChat(void)
|
||||||
if (msg[j] == '\n') // get back down.
|
if (msg[j] == '\n') // get back down.
|
||||||
{
|
{
|
||||||
++j;
|
++j;
|
||||||
dy += charheight;
|
if (!prev_linereturn)
|
||||||
dx = 0;
|
{
|
||||||
|
dy += charheight;
|
||||||
|
dx = 0;
|
||||||
|
}
|
||||||
|
prev_linereturn = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (msg[j] & 0x80) // stolen from video.c, nice.
|
else if (msg[j] & 0x80) // stolen from video.c, nice.
|
||||||
|
@ -1331,11 +1341,15 @@ static void HU_drawMiniChat(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (cv_chatbackteint.value) // on request of wolfy
|
||||||
|
V_DrawFillConsoleMap(x + dx + 2, y+dy, charwidth, charheight, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT);
|
||||||
|
|
||||||
UINT8 *colormap = CHAT_GetStringColormap(clrflag);
|
UINT8 *colormap = CHAT_GetStringColormap(clrflag);
|
||||||
V_DrawChatCharacter(x + dx + 2, y+dy, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag, !cv_allcaps.value, colormap);
|
V_DrawChatCharacter(x + dx + 2, y+dy, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag, !cv_allcaps.value, colormap);
|
||||||
}
|
}
|
||||||
|
|
||||||
dx += charwidth;
|
dx += charwidth;
|
||||||
|
prev_linereturn = false;
|
||||||
if (dx >= cv_chatwidth.value)
|
if (dx >= cv_chatwidth.value)
|
||||||
{
|
{
|
||||||
dx = 0;
|
dx = 0;
|
||||||
|
@ -1406,7 +1420,7 @@ static void HU_drawChatLog(INT32 offset)
|
||||||
{
|
{
|
||||||
INT32 clrflag = 0;
|
INT32 clrflag = 0;
|
||||||
INT32 j = 0;
|
INT32 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.
|
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
|
while(msg[j]) // iterate through msg
|
||||||
{
|
{
|
||||||
if (msg[j] < HU_FONTSTART) // don't draw
|
if (msg[j] < HU_FONTSTART) // don't draw
|
||||||
|
|
|
@ -1412,9 +1412,10 @@ static menuitem_t OP_HUDOptionsMenu[] =
|
||||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER,
|
{IT_STRING | IT_CVAR | IT_CV_SLIDER,
|
||||||
NULL, "Chat box height", &cv_chatheight, 105},
|
NULL, "Chat box height", &cv_chatheight, 105},
|
||||||
{IT_STRING | IT_CVAR, NULL, "Chat fadeout time", &cv_chattime, 115},
|
{IT_STRING | IT_CVAR, NULL, "Chat fadeout time", &cv_chattime, 115},
|
||||||
|
{IT_STRING | IT_CVAR, NULL, "Chat background teint", &cv_chatbackteint, 125},
|
||||||
|
|
||||||
{IT_STRING | IT_CVAR, NULL, "Background Color", &cons_backcolor, 130},
|
{IT_STRING | IT_CVAR, NULL, "Background Color", &cons_backcolor, 140},
|
||||||
{IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 140},
|
{IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 150},
|
||||||
};
|
};
|
||||||
|
|
||||||
static menuitem_t OP_GameOptionsMenu[] =
|
static menuitem_t OP_GameOptionsMenu[] =
|
||||||
|
|
Loading…
Reference in a new issue