Skip to content

Commit

Permalink
added an option to change scale of center string (cg_centerScale)
Browse files Browse the repository at this point in the history
  • Loading branch information
entdark committed Feb 23, 2023
1 parent a1f2e4b commit 468c3aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
18 changes: 10 additions & 8 deletions codemp/cgame/cg_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -4766,10 +4766,11 @@ qboolean BG_IsWhiteSpace( char c )
static void CG_DrawCenterString( void ) {
char *start;
int l, len;
int x, y, w;
int h;
float x, y;
int w, h;
float *color;
const float scale = 1.0; //0.5
const float scale = Q_max(cg_centerScale.value, 0.0f);
const float lineSpace = 6 * scale;

if ( !cg.centerPrintTime ) {
return;
Expand All @@ -4795,7 +4796,8 @@ static void CG_DrawCenterString( void ) {
if(strncmp(cg.centerPrint,sKilledStr,strlen(sKilledStr))!=0)return;
}

y = cg.centerPrintY - cg.centerPrintLines * BIGCHAR_HEIGHT / 2;
y = cg.centerPrintY - cg.centerPrintLines * BIGCHAR_HEIGHT / 2 + CG_Text_Height(0, 1.0f, FONT_MEDIUM);
y += (cg.centerPrintLines*CG_Text_Height(0, (1.0f-scale)*0.5f, FONT_MEDIUM) - (cg.centerPrintLines-1*lineSpace));

while ( 1 ) {
if (cg.centerPrintLines > 1) {
Expand Down Expand Up @@ -4834,8 +4836,8 @@ static void CG_DrawCenterString( void ) {
w = CG_Text_Width(linebuffer, scale, FONT_MEDIUM);
h = CG_Text_Height(linebuffer, scale, FONT_MEDIUM);
x = (SCREEN_WIDTH - w) / 2;
CG_Text_Paint(x, y + h, scale, color, linebuffer, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE, FONT_MEDIUM);
y += h + 6;
CG_Text_Paint(x, y, scale, color, linebuffer, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE, FONT_MEDIUM);
y += h + lineSpace;

//[BugFix19]
//this method of advancing to new line from the start of the array was causing long lines without
Expand Down Expand Up @@ -4869,8 +4871,8 @@ static void CG_DrawCenterString( void ) {
w = CG_Text_Width(linebuffer, scale, FONT_MEDIUM);
h = CG_Text_Height(linebuffer, scale, FONT_MEDIUM);
x = (SCREEN_WIDTH - w) / 2;
CG_Text_Paint(x, y + h, scale, color, linebuffer, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE, FONT_MEDIUM);
y += h + 6;
CG_Text_Paint(x, y, scale, color, linebuffer, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE, FONT_MEDIUM);
y += h + lineSpace;

while ( *start && ( *start != '\n' ) ) {
start++;
Expand Down
1 change: 1 addition & 0 deletions codemp/cgame/cg_xcvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ XCVAR_DEF( cg_bobUp, "0.005", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_cameraOrbit, "0", NULL, CVAR_CHEAT )
XCVAR_DEF( cg_cameraOrbitDelay, "50", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_centerTime, "3", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_centerScale, "1.0", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_chatBox, "10000", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_chatBoxHeight, "350", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_commandSmooth, "2", NULL, CVAR_ARCHIVE )
Expand Down

0 comments on commit 468c3aa

Please sign in to comment.