This is a fork of Zandronum Beta for Mac Os (Silicon and Intel)
Revisión | e59a7ded15c3f37cb5ad52118ca6a9c1ab132d2e (tree) |
---|---|
Tiempo | 2022-02-04 10:14:02 |
Autor | Adam Kaminski <kaminskiadam9@gmai...> |
Commiter | Adam Kaminski |
Added CVars: "con_interpolate" and "con_speed" which interpolates and controls how fast the console moves. Based on featues from ZCC.
@@ -77,6 +77,7 @@ | ||
77 | 77 | #include "gi.h" |
78 | 78 | #include "sv_rcon.h" |
79 | 79 | #include "st_hud.h" |
80 | +#include "r_utility.h" | |
80 | 81 | |
81 | 82 | #define CONSOLESIZE 16384 // Number of characters to store in console |
82 | 83 | #define CONSOLELINES 256 // Max number of lines of console text |
@@ -110,6 +111,10 @@ | ||
110 | 111 | int CursorTicker; |
111 | 112 | constate_e ConsoleState = c_up; |
112 | 113 | |
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 | + | |
113 | 118 | // [TP] Some functions print result directly to console.. when we need it to a string |
114 | 119 | // instead. To keep as much ZDoom code unchanged, here's a hack to capture the result |
115 | 120 | // into a string instead. |
@@ -228,6 +233,16 @@ | ||
228 | 233 | // [AK] Add a timestamp to every line printed to the console. |
229 | 234 | CVAR (Bool, con_showtimestamps, false, CVAR_ARCHIVE) |
230 | 235 | |
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 | + | |
231 | 246 | // [BB] Add a timestamp to every string printed to the logfile. |
232 | 247 | CVAR (Bool, sv_logfiletimestamp, true, CVAR_ARCHIVE) |
233 | 248 |
@@ -1254,21 +1269,31 @@ | ||
1254 | 1269 | { |
1255 | 1270 | if (ConsoleState == c_falling) |
1256 | 1271 | { |
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); | |
1258 | 1274 | if (ConBottom >= SCREENHEIGHT / 2) |
1259 | 1275 | { |
1260 | 1276 | ConBottom = SCREENHEIGHT / 2; |
1261 | 1277 | ConsoleState = c_down; |
1262 | 1278 | } |
1279 | + | |
1280 | + // [AK] Save a copy of the current value of ConBottom in case | |
1281 | + // we want to interpolate the console. | |
1282 | + SavedConBottom = ConBottom; | |
1263 | 1283 | } |
1264 | 1284 | else if (ConsoleState == c_rising) |
1265 | 1285 | { |
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); | |
1267 | 1288 | if (ConBottom <= 0) |
1268 | 1289 | { |
1269 | 1290 | ConsoleState = c_up; |
1270 | 1291 | ConBottom = 0; |
1271 | 1292 | } |
1293 | + | |
1294 | + // [AK] Save a copy of the current value of ConBottom in case | |
1295 | + // we want to interpolate the console. | |
1296 | + SavedConBottom = ConBottom; | |
1272 | 1297 | } |
1273 | 1298 | } |
1274 | 1299 |
@@ -1404,11 +1429,20 @@ | ||
1404 | 1429 | int lines, left, offset; |
1405 | 1430 | // [BC] String for drawing the version. |
1406 | 1431 | char szString[64]; |
1432 | + // [AK] Check if we should interpolate the console. | |
1433 | + const bool bInterpolate = ((con_interpolate) && (ConsoleState == c_falling || ConsoleState == c_rising)); | |
1407 | 1434 | |
1408 | 1435 | // [BC] No need to draw the console in server mode. |
1409 | 1436 | if ( NETWORK_GetState( ) == NETSTATE_SERVER ) |
1410 | 1437 | return; |
1411 | 1438 | |
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 | + | |
1412 | 1446 | left = LEFTMARGIN; |
1413 | 1447 | lines = (ConBottom-ConFont->GetHeight()*2)/ConFont->GetHeight(); |
1414 | 1448 | if (-ConFont->GetHeight() + lines*ConFont->GetHeight() > ConBottom - ConFont->GetHeight()*7/2) |
@@ -1607,6 +1641,10 @@ | ||
1607 | 1641 | } |
1608 | 1642 | } |
1609 | 1643 | } |
1644 | + | |
1645 | + // [AK] Restore the saved value of ConBottom in case we interpolated the console. | |
1646 | + if (bInterpolate) | |
1647 | + ConBottom = SavedConBottom; | |
1610 | 1648 | } |
1611 | 1649 | |
1612 | 1650 | void C_FullConsole () |