Skip to content

Commit 430b387

Browse files
committed
Implement con_persistOnMapChange
If enabled, the current console input will be kept on map change the first time the console is opened after the new map is loaded.
1 parent f8a8f95 commit 430b387

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/engine/client/cl_console.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ cvar_t *con_animationSpeed;
5353
cvar_t *con_animationType;
5454

5555
cvar_t *con_autoclear;
56+
Cvar::Cvar<bool> con_persistOnMapChange( "con_persistOnMapChange", "Current console input will be saved when changing map", Cvar::NONE, false );
5657

5758
/**
5859
* 0: no scroll lock at all, scroll down on any message arriving
@@ -97,11 +98,13 @@ Con_ToggleConsole_f
9798
void Con_ToggleConsole_f()
9899
{
99100
// ydnar: persistent console input is more useful
100-
if ( con_autoclear->integer )
101+
if ( con_autoclear->integer && !( con_persistOnMapChange.Get() && consoleState.changedMap ) )
101102
{
102103
g_consoleField.Clear();
103104
}
104105

106+
consoleState.changedMap = false;
107+
105108
g_consoleField.SetWidth(g_console_field_width);
106109

107110
if (consoleState.isOpened) {
@@ -413,7 +416,9 @@ void Con_Init()
413416

414417
// Done defining cvars for console colors
415418

416-
g_consoleField.Clear();
419+
if ( !con_persistOnMapChange.Get() ) {
420+
g_consoleField.Clear();
421+
}
417422
g_consoleField.SetWidth(g_console_field_width);
418423

419424
Cmd_AddCommand( "toggleConsole", Con_ToggleConsole_f );
@@ -1299,9 +1304,12 @@ void Con_Close()
12991304
return;
13001305
}
13011306

1302-
g_consoleField.Clear();
1307+
if ( !con_persistOnMapChange.Get() ) {
1308+
g_consoleField.Clear();
1309+
}
13031310
cls.keyCatchers &= ~KEYCATCH_CONSOLE;
13041311
consoleState.isOpened = false;
1312+
consoleState.changedMap = true;
13051313

13061314
//instant disappearance, if we need it for situations where this is not called by the user
13071315
consoleState.currentAnimationFraction = 0;

src/engine/client/client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ struct consoleBoxWidth_t
580580
struct console_t
581581
{
582582
bool initialized;
583+
bool changedMap;
583584

584585
std::vector<std::string> lines;
585586

0 commit comments

Comments
 (0)