From ee5ebd978a89611e02f04b0b3b031dd97298a733 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sun, 5 Aug 2018 13:08:27 +0200 Subject: [PATCH] Chat wordwrap fix + Minichat bg highlight --- objs/Mingw/SDL/Release/.gitignore | 2 -- src/d_netcmd.c | 1 + src/g_game.c | 3 +++ src/g_game.h | 2 +- src/hu_stuff.c | 34 ++++++++++++++++++++++--------- src/m_menu.c | 5 +++-- 6 files changed, 32 insertions(+), 15 deletions(-) delete mode 100644 objs/Mingw/SDL/Release/.gitignore diff --git a/objs/Mingw/SDL/Release/.gitignore b/objs/Mingw/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c..00000000 --- a/objs/Mingw/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f87ebcfa..c7647e02 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -787,6 +787,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_chatspamprotection); CV_RegisterVar(&cv_consolechat); CV_RegisterVar(&cv_chatnotifications); + CV_RegisterVar(&cv_chatbackteint); CV_RegisterVar(&cv_crosshair); CV_RegisterVar(&cv_crosshair2); CV_RegisterVar(&cv_crosshair3); diff --git a/src/g_game.c b/src/g_game.c index 762cac85..7af11dc6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -421,6 +421,9 @@ consvar_t cv_chatnotifications = {"chatnotifications", "On", CV_SAVE, CV_OnOff, // 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_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.) //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}; diff --git a/src/g_game.h b/src/g_game.h index 47c51d93..08ac73f2 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -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_chatspamprotection, cv_compactscoreboard, cv_chatbackteint; extern consvar_t cv_crosshair, cv_crosshair2, cv_crosshair3, cv_crosshair4; 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; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 338fd26c..22dc7fc5 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -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 slen; char *newstring = Z_StrDup(string); - INT32 spacewidth = (vid.width < 640) ? 8 : 4, charwidth = (vid.width < 640) ? 8 : 4; + INT32 charwidth = 4; slen = strlen(string); 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]) { - chw = spacewidth; + chw = charwidth; lastusablespace = i; } else @@ -1250,13 +1250,14 @@ static void HU_drawMiniChat(void) 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; @@ -1267,8 +1268,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. @@ -1283,7 +1288,7 @@ static void HU_drawMiniChat(void) { j++; } - + prev_linereturn = false; dx += charwidth; if (dx >= cv_chatwidth.value) { @@ -1300,6 +1305,7 @@ 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 { @@ -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 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 { @@ -1316,8 +1322,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. @@ -1331,11 +1341,15 @@ static void HU_drawMiniChat(void) } 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); 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; @@ -1406,7 +1420,7 @@ static void HU_drawChatLog(INT32 offset) { INT32 clrflag = 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 { if (msg[j] < HU_FONTSTART) // don't draw diff --git a/src/m_menu.c b/src/m_menu.c index 16d04af1..eb5ffb6c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1412,9 +1412,10 @@ static menuitem_t OP_HUDOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Chat box height", &cv_chatheight, 105}, {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, "Console Text Size", &cv_constextsize, 140}, + {IT_STRING | IT_CVAR, NULL, "Background Color", &cons_backcolor, 140}, + {IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 150}, }; static menuitem_t OP_GameOptionsMenu[] =