mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Merge #6058
6058: Fix invalid demo cutting, Add slice highlighting r=Chairn a=VoxelDoesCode Before, you could place an end slice before the beginning, creating a "zero second" demo, which doesn't play in client, and renders a corrupt file. I implemented a check where if the playhead is before the beginning slice, it won't place an end slice, and vice versa. I also added highlighting in between the slices, so that it's easier to see. ![image](https://user-images.githubusercontent.com/95713843/202870840-216df4d7-975e-496d-b122-c819ce7ae6ee.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 - [x] 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: VoxelDoesCode <bluheadcat@gmail.com>
This commit is contained in:
commit
2333f8e353
|
@ -353,6 +353,20 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
FilledBar.w = 10.0f + (FilledBar.w - 10.0f) * Amount;
|
FilledBar.w = 10.0f + (FilledBar.w - 10.0f) * Amount;
|
||||||
FilledBar.Draw(ColorRGBA(1, 1, 1, 0.5f), IGraphics::CORNER_ALL, 5.0f);
|
FilledBar.Draw(ColorRGBA(1, 1, 1, 0.5f), IGraphics::CORNER_ALL, 5.0f);
|
||||||
|
|
||||||
|
// draw highlighting
|
||||||
|
if(g_Config.m_ClDemoSliceBegin != -1 && g_Config.m_ClDemoSliceEnd != -1)
|
||||||
|
{
|
||||||
|
float RatioBegin = (g_Config.m_ClDemoSliceBegin - pInfo->m_FirstTick) / (float)TotalTicks;
|
||||||
|
float RatioEnd = (g_Config.m_ClDemoSliceEnd - pInfo->m_FirstTick) / (float)TotalTicks;
|
||||||
|
float Span = ((SeekBar.w - 10.0f) * RatioEnd) - ((SeekBar.w - 10.0f) * RatioBegin);
|
||||||
|
Graphics()->TextureClear();
|
||||||
|
Graphics()->QuadsBegin();
|
||||||
|
Graphics()->SetColor(1.0f, 0.0f, 0.0f, 0.25f);
|
||||||
|
IGraphics::CQuadItem QuadItem(10.0f + SeekBar.x + (SeekBar.w - 10.0f) * RatioBegin, SeekBar.y, Span, SeekBar.h);
|
||||||
|
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
||||||
|
Graphics()->QuadsEnd();
|
||||||
|
}
|
||||||
|
|
||||||
// draw markers
|
// draw markers
|
||||||
for(int i = 0; i < pInfo->m_NumTimelineMarkers; i++)
|
for(int i = 0; i < pInfo->m_NumTimelineMarkers; i++)
|
||||||
{
|
{
|
||||||
|
@ -498,7 +512,11 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
|
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
|
||||||
static CButtonContainer s_SliceBeginButton;
|
static CButtonContainer s_SliceBeginButton;
|
||||||
if(DoButton_FontIcon(&s_SliceBeginButton, "\xEF\x8B\xB5", 0, &Button, IGraphics::CORNER_ALL))
|
if(DoButton_FontIcon(&s_SliceBeginButton, "\xEF\x8B\xB5", 0, &Button, IGraphics::CORNER_ALL))
|
||||||
|
{
|
||||||
Client()->DemoSliceBegin();
|
Client()->DemoSliceBegin();
|
||||||
|
if(CurrentTick > (g_Config.m_ClDemoSliceEnd - pInfo->m_FirstTick))
|
||||||
|
g_Config.m_ClDemoSliceEnd = -1;
|
||||||
|
}
|
||||||
GameClient()->m_Tooltips.DoToolTip(&s_SliceBeginButton, &Button, Localize("Mark the beginning of a cut"));
|
GameClient()->m_Tooltips.DoToolTip(&s_SliceBeginButton, &Button, Localize("Mark the beginning of a cut"));
|
||||||
|
|
||||||
// slice end button
|
// slice end button
|
||||||
|
@ -506,7 +524,11 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
||||||
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
|
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
|
||||||
static CButtonContainer s_SliceEndButton;
|
static CButtonContainer s_SliceEndButton;
|
||||||
if(DoButton_FontIcon(&s_SliceEndButton, "\xEF\x8B\xB6", 0, &Button, IGraphics::CORNER_ALL))
|
if(DoButton_FontIcon(&s_SliceEndButton, "\xEF\x8B\xB6", 0, &Button, IGraphics::CORNER_ALL))
|
||||||
|
{
|
||||||
Client()->DemoSliceEnd();
|
Client()->DemoSliceEnd();
|
||||||
|
if(CurrentTick < (g_Config.m_ClDemoSliceBegin - pInfo->m_FirstTick))
|
||||||
|
g_Config.m_ClDemoSliceBegin = -1;
|
||||||
|
}
|
||||||
GameClient()->m_Tooltips.DoToolTip(&s_SliceEndButton, &Button, Localize("Mark the end of a cut"));
|
GameClient()->m_Tooltips.DoToolTip(&s_SliceEndButton, &Button, Localize("Mark the end of a cut"));
|
||||||
|
|
||||||
// slice save button
|
// slice save button
|
||||||
|
|
Loading…
Reference in a new issue