• R/O
  • SSH

zandronum-sandbox-stable: Commit


Commit MetaInfo

Revisione59a7ded15c3f37cb5ad52118ca6a9c1ab132d2e (tree)
Time2022-02-04 10:14:02
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Added CVars: "con_interpolate" and "con_speed" which interpolates and controls how fast the console moves. Based on featues from ZCC.

Change Summary

Incremental Difference

diff -r 0aa403d1ba1c -r e59a7ded15c3 src/c_console.cpp
--- a/src/c_console.cpp Sun Feb 06 10:52:32 2022 -0500
+++ b/src/c_console.cpp Thu Feb 03 20:14:02 2022 -0500
@@ -77,6 +77,7 @@
7777 #include "gi.h"
7878 #include "sv_rcon.h"
7979 #include "st_hud.h"
80+#include "r_utility.h"
8081
8182 #define CONSOLESIZE 16384 // Number of characters to store in console
8283 #define CONSOLELINES 256 // Max number of lines of console text
@@ -110,6 +111,10 @@
110111 int CursorTicker;
111112 constate_e ConsoleState = c_up;
112113
114+// [AK] In case we interpolate the console, we need to save an old copy of ConBottom
115+// so that we can restore the old vale after drawing the console.
116+static int SavedConBottom;
117+
113118 // [TP] Some functions print result directly to console.. when we need it to a string
114119 // instead. To keep as much ZDoom code unchanged, here's a hack to capture the result
115120 // into a string instead.
@@ -228,6 +233,16 @@
228233 // [AK] Add a timestamp to every line printed to the console.
229234 CVAR (Bool, con_showtimestamps, false, CVAR_ARCHIVE)
230235
236+// [AK] Interpolates the movement of the console. This doesn't work if the game is paused.
237+CVAR (Bool, con_interpolate, true, CVAR_ARCHIVE)
238+
239+// [AK] Controls how fast the console moves.
240+CUSTOM_CVAR (Int, con_speed, 25, CVAR_ARCHIVE)
241+{
242+ if ( self < 1 )
243+ self = 1;
244+}
245+
231246 // [BB] Add a timestamp to every string printed to the logfile.
232247 CVAR (Bool, sv_logfiletimestamp, true, CVAR_ARCHIVE)
233248
@@ -1254,21 +1269,31 @@
12541269 {
12551270 if (ConsoleState == c_falling)
12561271 {
1257- ConBottom += (gametic - lasttic) * (SCREENHEIGHT*2/25);
1272+ // [AK] Change ConBottom based on con_speed rather than a constant value of 25.
1273+ ConBottom += (gametic - lasttic) * (SCREENHEIGHT*2/con_speed);
12581274 if (ConBottom >= SCREENHEIGHT / 2)
12591275 {
12601276 ConBottom = SCREENHEIGHT / 2;
12611277 ConsoleState = c_down;
12621278 }
1279+
1280+ // [AK] Save a copy of the current value of ConBottom in case
1281+ // we want to interpolate the console.
1282+ SavedConBottom = ConBottom;
12631283 }
12641284 else if (ConsoleState == c_rising)
12651285 {
1266- ConBottom -= (gametic - lasttic) * (SCREENHEIGHT*2/25);
1286+ // [AK] Change ConBottom based on con_speed rather than a constant value of 25.
1287+ ConBottom -= (gametic - lasttic) * (SCREENHEIGHT*2/con_speed);
12671288 if (ConBottom <= 0)
12681289 {
12691290 ConsoleState = c_up;
12701291 ConBottom = 0;
12711292 }
1293+
1294+ // [AK] Save a copy of the current value of ConBottom in case
1295+ // we want to interpolate the console.
1296+ SavedConBottom = ConBottom;
12721297 }
12731298 }
12741299
@@ -1404,11 +1429,20 @@
14041429 int lines, left, offset;
14051430 // [BC] String for drawing the version.
14061431 char szString[64];
1432+ // [AK] Check if we should interpolate the console.
1433+ const bool bInterpolate = ((con_interpolate) && (ConsoleState == c_falling || ConsoleState == c_rising));
14071434
14081435 // [BC] No need to draw the console in server mode.
14091436 if ( NETWORK_GetState( ) == NETSTATE_SERVER )
14101437 return;
14111438
1439+ // [AK] Interpolate the console while it's moving.
1440+ if (bInterpolate)
1441+ {
1442+ int offset = static_cast<int>(FIXED2FLOAT(r_TicFrac) * static_cast<float>(SCREENHEIGHT * 2 / con_speed));
1443+ ConBottom = clamp<int>(SavedConBottom + offset * (ConsoleState == c_falling ? 1 : -1), 0, SCREENHEIGHT / 2);
1444+ }
1445+
14121446 left = LEFTMARGIN;
14131447 lines = (ConBottom-ConFont->GetHeight()*2)/ConFont->GetHeight();
14141448 if (-ConFont->GetHeight() + lines*ConFont->GetHeight() > ConBottom - ConFont->GetHeight()*7/2)
@@ -1607,6 +1641,10 @@
16071641 }
16081642 }
16091643 }
1644+
1645+ // [AK] Restore the saved value of ConBottom in case we interpolated the console.
1646+ if (bInterpolate)
1647+ ConBottom = SavedConBottom;
16101648 }
16111649
16121650 void C_FullConsole ()
Show on old repository browser