Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 3316949

Browse files
committed
Fix console not scaling to new width after resolution change
1 parent d95a7a0 commit 3316949

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

Main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ void ReinitMainMenu() {
186186
g_pScenarioGUI->Destroy();
187187
g_MetaMan.GetGUI()->Destroy();
188188

189+
g_ConsoleMan.Destroy();
190+
g_ConsoleMan.Create();
191+
189192
InitMainMenu();
190193
g_FrameMan.DestroyTempBackBuffers();
191194
g_HadResolutionChange = true;

Managers/ConsoleMan.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace RTE {
3333
m_InputLogPosition = m_InputLog.begin();
3434
m_LastInputString.clear();
3535
m_LastLogMove = 0;
36+
m_ConsoleTextBackup.clear();
3637
}
3738

3839
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -65,24 +66,40 @@ namespace RTE {
6566
m_ParentBox->SetEnabled(false);
6667
m_ParentBox->SetVisible(false);
6768

68-
m_ConsoleText->SetText("- RTE Lua Console -\nSee the Data Realms Wiki for commands: http://www.datarealms.com/wiki/\nPress F1 for a list of helpful shortcuts\n-------------------------------------");
69+
if (!g_FrameMan.ResolutionChanged()) {
70+
m_ConsoleText->SetText("- RTE Lua Console -\nSee the Data Realms Wiki for commands: http://www.datarealms.com/wiki/\nPress F1 for a list of helpful shortcuts\n-------------------------------------");
6971

70-
m_InputLogPosition = m_InputLog.begin();
71-
m_LastLogMove = 0;
72+
m_InputLogPosition = m_InputLog.begin();
73+
m_LastLogMove = 0;
74+
} else {
75+
m_ConsoleText->SetText(m_ConsoleTextBackup);
76+
m_ConsoleTextBackup.clear();
77+
}
7278

7379
return 0;
7480
}
7581

7682
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7783

7884
void ConsoleMan::Destroy() {
79-
SaveAllText("LogConsole.txt");
85+
if (g_FrameMan.ResolutionChanged()) {
86+
m_ConsoleTextBackup = m_ConsoleText->GetText();
87+
} else {
88+
SaveAllText("LogConsole.txt");
89+
}
8090

8191
delete m_GUIControlManager;
8292
delete m_GUIInput;
8393
delete m_GUIScreen;
8494

85-
Clear();
95+
if (g_FrameMan.ResolutionChanged()) {
96+
m_GUIScreen = nullptr;
97+
m_GUIInput = nullptr;
98+
m_GUIControlManager = nullptr;
99+
m_ParentBox = nullptr;
100+
} else {
101+
Clear();
102+
}
86103
}
87104

88105
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Managers/ConsoleMan.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ namespace RTE {
176176
std::string m_LastInputString; //!< Place to save the last worked on input string before deactivating the console.
177177
short m_LastLogMove; //!< The last direction the log marker was moved. Needed so that changing directions won't need double tapping.
178178

179+
std::string m_ConsoleTextBackup; //!< A copy of the whole console text at the time of destruction. Used to restore console text when ConsoleMan is re-created after a resolution change.
180+
179181
private:
180182

181183
/// <summary>

0 commit comments

Comments
 (0)