6086: Make sure components are reset and envelopes are updated when skipping in demo, fix demo name not being shown in demo player r=def- a=Robyt3

Followup for #6060.

Before:

![screenshot_2022-12-04_12-31-35](https://user-images.githubusercontent.com/23437060/205488272-67ea3bd4-fac3-445d-bfb0-46a3f8f5a0fa.png)

After:

![screenshot_2022-12-04_12-35-44](https://user-images.githubusercontent.com/23437060/205488275-a3dafc41-0ff0-45ac-8fb9-97b2369355eb.png)

## Checklist

- [X] Tested the change ingame
- [X] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
bors[bot] 2022-12-04 11:54:01 +00:00 committed by GitHub
commit 8d5d0cbe83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -337,10 +337,6 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
ButtonBar.HSplitTop(Margins, 0, &ButtonBar);
ButtonBar.HSplitBottom(NameBarHeight, &ButtonBar, &NameBar);
NameBar.HSplitTop(4.0f, 0, &NameBar);
SpeedBar.HSplitBottom(NameBarHeight, &SpeedBar, &NameBar);
ButtonBar.HSplitTop(0.0f, 0, &SpeedBar);
SpeedBar.VSplitLeft(123.0f, 0, &SpeedBar);
SpeedBar.VSplitLeft(133.0f, &SpeedBar, 0);
// do seekbar
{
@ -484,7 +480,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
if(DoButton_FontIcon(&s_ResetButton, "\xEF\x81\x8D", false, &Button, IGraphics::CORNER_ALL))
{
DemoPlayer()->Pause();
DemoPlayer()->SeekPercent(0.0f);
PositionToSeek = 0.0f;
}
GameClient()->m_Tooltips.DoToolTip(&s_ResetButton, &Button, Localize("Stop the current demo"));
@ -521,13 +517,12 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
GameClient()->m_Tooltips.DoToolTip(&s_FastForwardButton, &Button, Localize("Speed up the demo"));
// speed meter
ButtonBar.VSplitLeft(Margins * 3, 0, &ButtonBar);
ButtonBar.VSplitLeft(Margins * 12, &SpeedBar, &ButtonBar);
char aBuffer[64];
str_format(aBuffer, sizeof(aBuffer), "×%g", pInfo->m_Speed);
UI()->DoLabel(&SpeedBar, aBuffer, Button.h * 0.7f, TEXTALIGN_CENTER);
// slice begin button
ButtonBar.VSplitLeft(Margins * 7, 0, &ButtonBar);
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
static CButtonContainer s_SliceBeginButton;
if(DoButton_FontIcon(&s_SliceBeginButton, "\xEF\x8B\xB5", 0, &Button, IGraphics::CORNER_ALL))
@ -575,10 +570,10 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
{
if((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) < CurrentTick && absolute(((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) - CurrentTick)) > Threshold)
{
DemoPlayer()->SeekPercent((float)(pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) / TotalTicks);
PositionToSeek = (float)(pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) / TotalTicks;
break;
}
DemoPlayer()->SeekPercent(0.0f);
PositionToSeek = 0.0f;
}
GameClient()->m_Tooltips.DoToolTip(&s_OneMarkerBackButton, &Button, Localize("Go back one marker"));
@ -591,10 +586,10 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
{
if((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) > CurrentTick && absolute(((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) - CurrentTick)) > Threshold)
{
DemoPlayer()->SeekPercent((float)(pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) / TotalTicks);
PositionToSeek = (float)(pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) / TotalTicks;
break;
}
DemoPlayer()->SeekPercent(1.0f);
PositionToSeek = 1.0f;
}
GameClient()->m_Tooltips.DoToolTip(&s_OneMarkerForwardButton, &Button, Localize("Go forward one marker"));