Skip to content

Commit

Permalink
MP Client: Add cl_coloredTextShadows cvar
Browse files Browse the repository at this point in the history
This cvar when toggled on will enable the coloredTextShadows that was
present in Jedi Outcast. Set to 0 by default.
  • Loading branch information
Alexander Silva authored and eternalcodes committed Dec 4, 2017
1 parent 3e4ee30 commit 52c5a49
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
4 changes: 4 additions & 0 deletions codemp/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ cvar_t *cl_consoleUseScanCode;

cvar_t *cl_lanForcePackets;

cvar_t *cl_coloredTextShadows;

cvar_t *cl_drawRecording;

cvar_t *cl_colorString;
Expand Down Expand Up @@ -3108,6 +3110,8 @@ void CL_Init( void ) {
// cgame might not be initialized before menu is used
Cvar_Get ("cg_viewsize", "100", CVAR_ARCHIVE_ND );

cl_coloredTextShadows = Cvar_Get("cl_coloredTextShadows", "0", CVAR_ARCHIVE);

cl_afkTime = Cvar_Get("cl_afkTime", "5", CVAR_ARCHIVE, "Minutes to autorename to afk, 0 to disable");
cl_afkTimeUnfocused = Cvar_Get("cl_afkTimeUnfocused", "1", CVAR_ARCHIVE, "Minutes to autorename to afk while unfocused/minimized");
cl_unfocusedTime = 0;
Expand Down
44 changes: 36 additions & 8 deletions codemp/rd-common/tr_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1547,16 +1547,44 @@ void RE_Font_DrawString(int ox, int oy, const char *psText, const float *rgba, c
}

// Draw a dropshadow if required
if(iFontHandle & STYLE_DROPSHADOW)
{
offset = Round(curfont->GetPointSize() * fScale * 0.075f);
if (iFontHandle & STYLE_DROPSHADOW)
if (iFontHandle & STYLE_DROPSHADOW)
{
if (ri->Cvar_VariableIntegerValue("cl_coloredTextShadows")) {
int i = 0, r = 0;
char dropShadowText[1024];
const vec4_t v4DKGREY2 = { 0.15f, 0.15f, 0.15f, rgba ? rgba[3] : 1.0f };

offset = Round(curfont->GetPointSize() * fScale * 0.075f);

//^blah stuff confuses shadows, so parse it out first
while (psText[i] && r < 1024) {
if (psText[i] == '^') {
if ((i < 1 || psText[i - 1] != '^') &&
(!psText[i + 1] || psText[i + 1] != '^')) { //If char before or after ^ is ^ then it prints ^ instead of accepting a colorcode
i += 2;
}
}

const vec4_t v4DKGREY2 = {0.15f, 0.15f, 0.15f, rgba?rgba[3]:1.0f};
dropShadowText[r] = psText[i];
r++;
i++;
}
dropShadowText[r] = 0;

gbInShadow = qtrue;
RE_Font_DrawString(ox + offset, oy + offset, psText, v4DKGREY2, iFontHandle & SET_MASK, iMaxPixelWidth, fScale);
gbInShadow = qfalse;
}
RE_Font_DrawString(ox + offset, oy + offset, dropShadowText, v4DKGREY2, iFontHandle & SET_MASK, iMaxPixelWidth, fScale);
}
else
{
const vec4_t v4DKGREY2 = { 0.15f, 0.15f, 0.15f, rgba ? rgba[3] : 1.0f };

offset = Round(curfont->GetPointSize() * fScale * 0.075f);

gbInShadow = qtrue;
RE_Font_DrawString(ox + offset, oy + offset, psText, v4DKGREY2, iFontHandle & SET_MASK, iMaxPixelWidth, fScale);
gbInShadow = qfalse;
}
}

RE_SetColor( rgba );

Expand Down

0 comments on commit 52c5a49

Please sign in to comment.