# HG changeset patch # User Adam Kaminski # Date 1643937242 18000 # Thu Feb 03 20:14:02 2022 -0500 # Node ID c7e616baee77c645b50ca34c2aa47b1a95577568 # Parent 14983b3f8a580aeac7d91046570b851d92a710f1 Added CVars: "con_interpolate" and "con_speed" which interpolates and controls how fast the console moves. Based on featues from ZCC. diff -r 14983b3f8a58 -r c7e616baee77 src/c_console.cpp --- a/src/c_console.cpp Tue Feb 01 09:35:13 2022 -0500 +++ b/src/c_console.cpp Thu Feb 03 20:14:02 2022 -0500 @@ -77,6 +77,7 @@ #include "gi.h" #include "sv_rcon.h" #include "st_hud.h" +#include "r_utility.h" #define CONSOLESIZE 16384 // Number of characters to store in console #define CONSOLELINES 256 // Max number of lines of console text @@ -110,6 +111,10 @@ int CursorTicker; constate_e ConsoleState = c_up; +// [AK] In case we interpolate the console, we need to save an old copy of ConBottom +// so that we can restore the old vale after drawing the console. +static int SavedConBottom; + // [TP] Some functions print result directly to console.. when we need it to a string // instead. To keep as much ZDoom code unchanged, here's a hack to capture the result // into a string instead. @@ -228,6 +233,16 @@ // [AK] Add a timestamp to every line printed to the console. CVAR (Bool, con_showtimestamps, false, CVAR_ARCHIVE) +// [AK] Interpolates the movement of the console. This doesn't work if the game is paused. +CVAR (Bool, con_interpolate, true, CVAR_ARCHIVE) + +// [AK] Controls how fast the console moves. +CUSTOM_CVAR (Int, con_speed, 25, CVAR_ARCHIVE) +{ + if ( self < 1 ) + self = 1; +} + // [BB] Add a timestamp to every string printed to the logfile. CVAR (Bool, sv_logfiletimestamp, true, CVAR_ARCHIVE) @@ -1254,21 +1269,31 @@ { if (ConsoleState == c_falling) { - ConBottom += (gametic - lasttic) * (SCREENHEIGHT*2/25); + // [AK] Change ConBottom based on con_speed rather than a constant value of 25. + ConBottom += (gametic - lasttic) * (SCREENHEIGHT*2/con_speed); if (ConBottom >= SCREENHEIGHT / 2) { ConBottom = SCREENHEIGHT / 2; ConsoleState = c_down; } + + // [AK] Save a copy of the current value of ConBottom in case + // we want to interpolate the console. + SavedConBottom = ConBottom; } else if (ConsoleState == c_rising) { - ConBottom -= (gametic - lasttic) * (SCREENHEIGHT*2/25); + // [AK] Change ConBottom based on con_speed rather than a constant value of 25. + ConBottom -= (gametic - lasttic) * (SCREENHEIGHT*2/con_speed); if (ConBottom <= 0) { ConsoleState = c_up; ConBottom = 0; } + + // [AK] Save a copy of the current value of ConBottom in case + // we want to interpolate the console. + SavedConBottom = ConBottom; } } @@ -1409,6 +1434,13 @@ if ( NETWORK_GetState( ) == NETSTATE_SERVER ) return; + // [AK] Interpolate the console while it's moving if we want to. + if ((con_interpolate) && (ConsoleState == c_falling || ConsoleState == c_rising)) + { + int offset = static_cast(FIXED2FLOAT(r_TicFrac) * static_cast(SCREENHEIGHT * 2 / con_speed)); + ConBottom = clamp(SavedConBottom + offset * (ConsoleState == c_falling ? 1 : -1), 0, SCREENHEIGHT / 2); + } + left = LEFTMARGIN; lines = (ConBottom-ConFont->GetHeight()*2)/ConFont->GetHeight(); if (-ConFont->GetHeight() + lines*ConFont->GetHeight() > ConBottom - ConFont->GetHeight()*7/2) @@ -1607,6 +1639,10 @@ } } } + + // [AK] Restore the saved value of ConBottom in case we interpolated the console. + if (ConsoleState == c_falling || ConsoleState == c_rising) + ConBottom = SavedConBottom; } void C_FullConsole ()