Fix console line bug when resizing

This commit is contained in:
Jupeyy 2022-01-14 22:36:41 +01:00
parent ca07c0a92f
commit 956afed264
2 changed files with 23 additions and 0 deletions

View file

@ -73,6 +73,16 @@ void CGameConsole::CInstance::ClearBacklog()
m_BacklogActPage = 0;
}
void CGameConsole::CInstance::ClearBacklogYOffsets()
{
auto *pEntry = m_Backlog.First();
while(pEntry)
{
pEntry->m_YOffset = -1.0f;
pEntry = m_Backlog.Next(pEntry);
}
}
void CGameConsole::CInstance::ClearHistory()
{
m_History.Init();
@ -993,6 +1003,17 @@ void CGameConsole::OnConsoleInit()
Console()->Chain("console_output_level", ConchainConsoleOutputLevelUpdate, this);
}
void CGameConsole::OnInit()
{
// add resize event
Graphics()->AddWindowResizeListener([this](void *) {
m_LocalConsole.ClearBacklogYOffsets();
m_RemoteConsole.ClearBacklogYOffsets();
m_HasSelection = false;
},
nullptr);
}
void CGameConsole::OnStateChange(int NewState, int OldState)
{
if(OldState == IClient::STATE_ONLINE && NewState < IClient::STATE_LOADING)

View file

@ -59,6 +59,7 @@ class CGameConsole : public CComponent
void Init(CGameConsole *pGameConsole);
void ClearBacklog();
void ClearBacklogYOffsets();
void ClearHistory();
void ExecuteLine(const char *pLine);
@ -125,6 +126,7 @@ public:
virtual void OnStateChange(int NewState, int OldState);
virtual void OnConsoleInit();
virtual void OnInit();
virtual void OnReset();
virtual void OnRender();
virtual void OnMessage(int MsgType, void *pRawMsg);