Skip to content

Commit

Permalink
[Shared] Add con_height cvar to set console height. Set to 0 to resto…
Browse files Browse the repository at this point in the history
…re previous behaviour.

(cherry picked from commit c007dfd)
  • Loading branch information
Daggolin authored and taysta committed Feb 19, 2024
1 parent 707d8d2 commit 25fdba9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions codemp/client/cl_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ cvar_t *con_autoclear;
cvar_t *con_notifywords;
cvar_t *con_notifyconnect;
cvar_t *con_notifyvote;
cvar_t *con_height;

#define DEFAULT_CONSOLE_WIDTH 78
#define TIMESTAMP_LENGTH 9
Expand Down Expand Up @@ -452,19 +453,19 @@ void Con_CheckResize (void)
else
{
float scale = (con_scale && con_scale->value > 0.0f) ? con_scale->value : 1.0f;

width = (cls.glconfig.vidWidth / (scale * SMALLCHAR_WIDTH)) - 2;

if (width == con.linewidth)
return;

con.charWidth = scale * SMALLCHAR_WIDTH;
con.charHeight = scale * SMALLCHAR_HEIGHT;

g_consoleField.widthInChars = width;
for (i = 0; i < COMMAND_HISTORY; i++) {
historyEditLines[i].widthInChars = width;

}

// on wide screens, we will center the text
Expand Down Expand Up @@ -542,6 +543,7 @@ void Con_Init (void) {
con_notifywords = Cvar_Get("con_notifywords", "0", CVAR_ARCHIVE, "Notifies you when defined words are mentioned");
con_notifyconnect = Cvar_Get("con_notifyconnect", "0", CVAR_ARCHIVE, "Notifies you when someone connects to the server");
con_notifyvote = Cvar_Get("con_notifyvote", "1", CVAR_ARCHIVE, "Notifies you when someone calls a vote");
con_height = Cvar_Get ("con_height", "0.5", CVAR_ARCHIVE_ND);

Field_Clear( &g_consoleField );
g_consoleField.widthInChars = DEFAULT_CONSOLE_WIDTH;
Expand Down Expand Up @@ -1104,7 +1106,7 @@ Scroll it up or down
void Con_RunConsole (void) {
// decide on the destination height of the console
if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE )
con.finalFrac = con.tempFrac; // visibility
con.finalFrac = (con_height->value != 0) ? con_height->value : con.tempFrac;
else
con.finalFrac = 0; // none visible

Expand Down

0 comments on commit 25fdba9

Please sign in to comment.