mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Always suppress events and update envelopes when skipping
This commit is contained in:
parent
bf16875a6f
commit
a24ac108ce
|
@ -167,6 +167,8 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle keyboard shortcuts independent of active menu
|
// handle keyboard shortcuts independent of active menu
|
||||||
|
float PositionToSeek = -1.0f;
|
||||||
|
float TimeToSeek = 0.0f;
|
||||||
if(m_pClient->m_GameConsole.IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE && g_Config.m_ClDemoKeyboardShortcuts)
|
if(m_pClient->m_GameConsole.IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE && g_Config.m_ClDemoKeyboardShortcuts)
|
||||||
{
|
{
|
||||||
// increase/decrease speed
|
// increase/decrease speed
|
||||||
|
@ -200,19 +202,19 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
// seek backward/forward 10/5 seconds
|
// seek backward/forward 10/5 seconds
|
||||||
if(Input()->KeyPress(KEY_J))
|
if(Input()->KeyPress(KEY_J))
|
||||||
{
|
{
|
||||||
DemoPlayer()->SeekTime(-10.0f);
|
TimeToSeek = -10.0f;
|
||||||
}
|
}
|
||||||
else if(Input()->KeyPress(KEY_L))
|
else if(Input()->KeyPress(KEY_L))
|
||||||
{
|
{
|
||||||
DemoPlayer()->SeekTime(10.0f);
|
TimeToSeek = 10.0f;
|
||||||
}
|
}
|
||||||
else if(Input()->KeyPress(KEY_LEFT))
|
else if(Input()->KeyPress(KEY_LEFT))
|
||||||
{
|
{
|
||||||
DemoPlayer()->SeekTime(-5.0f);
|
TimeToSeek = -5.0f;
|
||||||
}
|
}
|
||||||
else if(Input()->KeyPress(KEY_RIGHT))
|
else if(Input()->KeyPress(KEY_RIGHT))
|
||||||
{
|
{
|
||||||
DemoPlayer()->SeekTime(5.0f);
|
TimeToSeek = 5.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// seek to 0-90%
|
// seek to 0-90%
|
||||||
|
@ -221,7 +223,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
{
|
{
|
||||||
if(Input()->KeyPress(aSeekPercentKeys[i]))
|
if(Input()->KeyPress(aSeekPercentKeys[i]))
|
||||||
{
|
{
|
||||||
DemoPlayer()->SeekPercent(i * 0.1f);
|
PositionToSeek = i * 0.1f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,11 +231,11 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
// seek to the beginning/end
|
// seek to the beginning/end
|
||||||
if(Input()->KeyPress(KEY_HOME))
|
if(Input()->KeyPress(KEY_HOME))
|
||||||
{
|
{
|
||||||
DemoPlayer()->SeekPercent(0.0f);
|
PositionToSeek = 0.0f;
|
||||||
}
|
}
|
||||||
else if(Input()->KeyPress(KEY_END))
|
else if(Input()->KeyPress(KEY_END))
|
||||||
{
|
{
|
||||||
DemoPlayer()->SeekPercent(1.0f);
|
PositionToSeek = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advance single frame forward/backward with period/comma key
|
// Advance single frame forward/backward with period/comma key
|
||||||
|
@ -245,6 +247,8 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
DemoPlayer()->SetPos(pInfo->m_CurrentTick + (TickForwards ? 3 : 0));
|
DemoPlayer()->SetPos(pInfo->m_CurrentTick + (TickForwards ? 3 : 0));
|
||||||
m_pClient->m_SuppressEvents = false;
|
m_pClient->m_SuppressEvents = false;
|
||||||
DemoPlayer()->Pause();
|
DemoPlayer()->Pause();
|
||||||
|
m_pClient->m_MapLayersBackGround.EnvelopeUpdate();
|
||||||
|
m_pClient->m_MapLayersForeGround.EnvelopeUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,14 +360,9 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
if(Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT))
|
if(Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT))
|
||||||
{
|
{
|
||||||
AmountSeek = s_PrevAmount + (AmountSeek - s_PrevAmount) * 0.05f;
|
AmountSeek = s_PrevAmount + (AmountSeek - s_PrevAmount) * 0.05f;
|
||||||
|
|
||||||
if(AmountSeek > 0.0f && AmountSeek < 1.0f && absolute(s_PrevAmount - AmountSeek) >= 0.0001f)
|
if(AmountSeek > 0.0f && AmountSeek < 1.0f && absolute(s_PrevAmount - AmountSeek) >= 0.0001f)
|
||||||
{
|
{
|
||||||
m_pClient->m_SuppressEvents = true;
|
PositionToSeek = AmountSeek;
|
||||||
DemoPlayer()->SeekPercent(AmountSeek);
|
|
||||||
m_pClient->m_SuppressEvents = false;
|
|
||||||
m_pClient->m_MapLayersBackGround.EnvelopeUpdate();
|
|
||||||
m_pClient->m_MapLayersForeGround.EnvelopeUpdate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -371,11 +370,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
if(AmountSeek > 0.0f && AmountSeek < 1.0f && absolute(s_PrevAmount - AmountSeek) >= 0.001f)
|
if(AmountSeek > 0.0f && AmountSeek < 1.0f && absolute(s_PrevAmount - AmountSeek) >= 0.001f)
|
||||||
{
|
{
|
||||||
s_PrevAmount = AmountSeek;
|
s_PrevAmount = AmountSeek;
|
||||||
m_pClient->m_SuppressEvents = true;
|
PositionToSeek = AmountSeek;
|
||||||
DemoPlayer()->SeekPercent(AmountSeek);
|
|
||||||
m_pClient->m_SuppressEvents = false;
|
|
||||||
m_pClient->m_MapLayersBackGround.EnvelopeUpdate();
|
|
||||||
m_pClient->m_MapLayersForeGround.EnvelopeUpdate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,7 +388,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
if(CurrentTick == TotalTicks)
|
if(CurrentTick == TotalTicks)
|
||||||
{
|
{
|
||||||
DemoPlayer()->Pause();
|
DemoPlayer()->Pause();
|
||||||
DemoPlayer()->SeekPercent(0.0f);
|
PositionToSeek = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IncreaseDemoSpeed = false, DecreaseDemoSpeed = false;
|
bool IncreaseDemoSpeed = false, DecreaseDemoSpeed = false;
|
||||||
|
@ -511,6 +506,18 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
DemoPlayer()->SetSpeedIndex(-1);
|
DemoPlayer()->SetSpeedIndex(-1);
|
||||||
s_LastSpeedChange = time_get();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CUIRect gs_ListBoxOriginalView;
|
static CUIRect gs_ListBoxOriginalView;
|
||||||
|
|
Loading…
Reference in a new issue