Fix demo seeking not working anymore when menu is not active

This commit is contained in:
Robert Müller 2022-08-28 12:23:03 +02:00
parent 4dcdba3563
commit 3dc577f24e
2 changed files with 20 additions and 11 deletions

View file

@ -497,6 +497,7 @@ protected:
static bool DemoFilterChat(const void *pData, int Size, void *pUser);
bool FetchHeader(CDemoItem &Item);
void FetchAllHeaders();
void HandleDemoSeeking(float PositionToSeek, float TimeToSeek);
void RenderDemoPlayer(CUIRect MainView);
void RenderDemoList(CUIRect MainView);

View file

@ -79,6 +79,21 @@ bool CMenus::DemoFilterChat(const void *pData, int Size, void *pUser)
return !Unpacker.Error() && !Sys && Msg == NETMSGTYPE_SV_CHAT;
}
void CMenus::HandleDemoSeeking(float PositionToSeek, float TimeToSeek)
{
if((PositionToSeek >= 0.0f && PositionToSeek <= 1.0f) || TimeToSeek != 0.0f)
{
m_pClient->m_SuppressEvents = true;
if(TimeToSeek != 0.0f)
DemoPlayer()->SeekTime(TimeToSeek);
else
DemoPlayer()->SeekPercent(PositionToSeek);
m_pClient->m_SuppressEvents = false;
m_pClient->m_MapLayersBackGround.EnvelopeUpdate();
m_pClient->m_MapLayersForeGround.EnvelopeUpdate();
}
}
void CMenus::RenderDemoPlayer(CUIRect MainView)
{
const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo();
@ -277,7 +292,10 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
}
if(!m_MenuActive)
{
HandleDemoSeeking(PositionToSeek, TimeToSeek);
return;
}
MainView.HSplitBottom(TotalHeight, 0, &MainView);
MainView.VSplitLeft(50.0f, 0, &MainView);
@ -526,17 +544,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
s_LastSpeedChange = time_get();
}
if((PositionToSeek >= 0.0f && PositionToSeek <= 1.0f) || TimeToSeek != 0.0f)
{
m_pClient->m_SuppressEvents = true;
if(TimeToSeek != 0.0f)
DemoPlayer()->SeekTime(TimeToSeek);
else
DemoPlayer()->SeekPercent(PositionToSeek);
m_pClient->m_SuppressEvents = false;
m_pClient->m_MapLayersBackGround.EnvelopeUpdate();
m_pClient->m_MapLayersForeGround.EnvelopeUpdate();
}
HandleDemoSeeking(PositionToSeek, TimeToSeek);
}
static CUIRect gs_ListBoxOriginalView;