Skip to content

Commit 0d0407e

Browse files
committed
Fix console line not taking all available space at some con_scale settings
1 parent bf1cbaa commit 0d0407e

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

src/client/cl_console.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ void Con_CheckResize (void)
239239

240240
if (cls.glconfig.vidWidth <= 0.0f) // video hasn't been initialized yet
241241
{
242-
con.xadjust = 1;
243-
con.yadjust = 1;
242+
cls.xadjust = 1;
243+
cls.yadjust = 1;
244244
con.charWidth = SMALLCHAR_WIDTH;
245245
con.charHeight = SMALLCHAR_HEIGHT;
246246
con.linewidth = DEFAULT_CONSOLE_WIDTH;
@@ -254,21 +254,20 @@ void Con_CheckResize (void)
254254
}
255255
else
256256
{
257-
float scale = (con_scale && con_scale->value > 0.0f) ? con_scale->value : 1.0f;
257+
float scale = (con_scale && con_scale->value > 0.0f) ? con_scale->value : 1.0f;
258+
int charWidth = scale * SMALLCHAR_WIDTH;
258259

259-
// on wide screens, we will center the text
260-
con.xadjust = 640.0f / cls.glconfig.vidWidth;
261-
con.yadjust = 480.0f / cls.glconfig.vidHeight;
262-
263-
width = (cls.glconfig.vidWidth / (scale * SMALLCHAR_WIDTH)) - 2;
260+
width = (cls.glconfig.vidWidth / charWidth) - 2;
264261

265262
if (width < 20) {
266-
scale = cls.glconfig.vidWidth / (SMALLCHAR_WIDTH * (CON_MIN_WIDTH + 2));
267-
width = (cls.glconfig.vidWidth / (scale * SMALLCHAR_WIDTH)) - 2;
263+
width = 20;
264+
charWidth = cls.glconfig.vidWidth / 22;
265+
scale = charWidth / SMALLCHAR_WIDTH;
268266
}
269-
if ((int) (scale * SMALLCHAR_WIDTH) == 0) {
270-
scale = 1.0f / SMALLCHAR_WIDTH + 0.01f;
271-
width = (cls.glconfig.vidWidth / (scale * SMALLCHAR_WIDTH)) - 2;
267+
if (charWidth == 0) {
268+
charWidth = 1;
269+
width = cls.glconfig.vidWidth - 2;
270+
scale = 1.0f / SMALLCHAR_WIDTH;
272271
}
273272

274273
if (con_timestamps->integer) {
@@ -279,7 +278,7 @@ void Con_CheckResize (void)
279278
return;
280279
}
281280

282-
con.charWidth = scale * SMALLCHAR_WIDTH;
281+
con.charWidth = charWidth;
283282
con.charHeight = scale * SMALLCHAR_HEIGHT;
284283

285284
kg.g_consoleField.widthInChars = width - 1; // Command prompt
@@ -585,7 +584,7 @@ void Con_DrawNotify (void)
585584
int iPixelHeightToAdvance;
586585
if (re.Language_IsAsian())
587586
{
588-
fFontScale = con.xadjust * con.charWidth *
587+
fFontScale = cls.xadjust * con.charWidth *
589588
10.0f / re.Font_StrLenPixels("aaaaaaaaaa", iFontIndex, 1.0f);
590589
iPixelHeightToAdvance = 1.3 * re.Font_HeightPixels(iFontIndex, fFontScale);
591590
}
@@ -635,7 +634,7 @@ void Con_DrawNotify (void)
635634
//
636635
// and print...
637636
//
638-
re.Font_DrawString(cl_conXOffset->integer + con.xadjust*con.charWidth,
637+
re.Font_DrawString(cl_conXOffset->integer + cls.xadjust*con.charWidth,
639638
v, sTemp, g_color_table[currentColor], iFontIndex, -1, fFontScale);
640639

641640
v += iPixelHeightToAdvance;
@@ -765,9 +764,9 @@ void Con_DrawSolidConsole( float frac ) {
765764
int iPixelHeightToAdvance = con.charHeight;
766765
if (re.Language_IsAsian())
767766
{
768-
fFontScale = con.xadjust * con.charWidth *
767+
fFontScale = cls.xadjust * con.charWidth *
769768
10.0f / re.Font_StrLenPixels("aaaaaaaaaa", iFontIndex, 1.0f);
770-
y *= con.yadjust;
769+
y *= cls.yadjust;
771770
iPixelHeightToAdvance = 1.3 * re.Font_HeightPixels(iFontIndex, fFontScale);
772771
}
773772

@@ -804,7 +803,7 @@ void Con_DrawSolidConsole( float frac ) {
804803
//
805804
// and print...
806805
//
807-
re.Font_DrawString(con.xadjust * con.charWidth, y, sTemp,
806+
re.Font_DrawString(cls.xadjust * con.charWidth, y, sTemp,
808807
g_color_table[currentColor], iFontIndex, -1, fFontScale);
809808
}
810809
else

src/client/cl_main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,6 +2606,8 @@ void CL_InitRenderer( void ) {
26062606
cls.consoleShader = re.RegisterShader( "console" );
26072607
cls.recordingShader = re.RegisterShaderNoMip("gfx/2d/demorec");
26082608
cls.ratioFix = (float)(SCREEN_WIDTH * cls.glconfig.vidHeight) / (float)(SCREEN_HEIGHT * cls.glconfig.vidWidth);
2609+
cls.xadjust = (float) SCREEN_WIDTH / cls.glconfig.vidWidth;
2610+
cls.yadjust = (float) SCREEN_HEIGHT / cls.glconfig.vidHeight;
26092611

26102612
kg.yankIndex = -1;
26112613
}

src/client/cl_scrn.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ void SCR_DrawSmallChar( int x, int y, int ch ) {
132132
#endif
133133
size2 = 0.0625;
134134

135-
re.DrawStretchPic( x * con.xadjust, y * con.yadjust,
136-
con.charWidth * con.xadjust, con.charHeight * con.yadjust,
135+
re.DrawStretchPic( x * cls.xadjust, y * cls.yadjust,
136+
con.charWidth * cls.xadjust, con.charHeight * cls.yadjust,
137137
fcol, frow,
138138
fcol + size, frow + size2,
139139
cls.charSetShader );

src/client/client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ typedef struct {
338338

339339
qhandle_t recordingShader;
340340
float ratioFix;
341+
float xadjust;
342+
float yadjust;
341343

342344
blacklistentry_t *downloadBlacklist;
343345
size_t downloadBlacklistLen;

0 commit comments

Comments
 (0)