From 74c6c5c96069d0431e2737a8eda0ae0fe9b736fb Mon Sep 17 00:00:00 2001 From: louis Date: Sat, 19 Nov 2022 16:36:57 -0600 Subject: [PATCH 1/5] Add buttons+increased length Added tick step buttons and jump to next/prev marker buttons Increased width of demo controls panel Centered the time multiplier --- src/game/client/components/menus_demo.cpp | 63 ++++++++++++++++++++--- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 072f021db..287f0463a 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -325,18 +325,22 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) MainView.HSplitBottom(TotalHeight, 0, &MainView); MainView.VSplitLeft(50.0f, 0, &MainView); - MainView.VSplitLeft(450.0f, &MainView, 0); + MainView.VSplitLeft(600.0f, &MainView, 0); MainView.Draw(ms_ColorTabbarActive, IGraphics::CORNER_T, 10.0f); MainView.Margin(5.0f, &MainView); - CUIRect SeekBar, ButtonBar, NameBar; + CUIRect SeekBar, ButtonBar, NameBar, SpeedBar{}; MainView.HSplitTop(SeekBarHeight, &SeekBar, &ButtonBar); 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 { @@ -460,7 +464,6 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) GameClient()->m_Tooltips.DoToolTip(&s_PlayPauseButton, &Button, pInfo->m_Paused ? Localize("Play the current demo") : Localize("Pause the current demo")); // stop button - ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static CButtonContainer s_ResetButton; @@ -471,9 +474,25 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) } GameClient()->m_Tooltips.DoToolTip(&s_ResetButton, &Button, Localize("Stop the current demo")); - // slowdown + // one tick back + ButtonBar.VSplitLeft(Margins + 10.0f, 0, &ButtonBar); + ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); + static CButtonContainer s_OneTickBackButton; + if(DoButton_FontIcon(&s_OneTickBackButton, "\xEF\x81\x93", 0, &Button, IGraphics::CORNER_ALL)) + DemoSeekTick(IDemoPlayer::TICK_PREVIOUS); + GameClient()->m_Tooltips.DoToolTip(&s_OneTickBackButton, &Button, Localize("Go back one tick")); + + // one tick forward ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); + static CButtonContainer s_OneTickForwardButton; + if(DoButton_FontIcon(&s_OneTickForwardButton, "\xEF\x81\x94", 0, &Button, IGraphics::CORNER_ALL)) + DemoSeekTick(IDemoPlayer::TICK_NEXT); + GameClient()->m_Tooltips.DoToolTip(&s_OneTickForwardButton, &Button, Localize("Go forward one tick")); + + // slowdown + ButtonBar.VSplitLeft(Margins + 10.0f, 0, &ButtonBar); + ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static CButtonContainer s_SlowDownButton; if(DoButton_FontIcon(&s_SlowDownButton, "\xEF\x81\x8A", 0, &Button, IGraphics::CORNER_ALL)) DecreaseDemoSpeed = true; @@ -491,10 +510,10 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) ButtonBar.VSplitLeft(Margins * 3, 0, &ButtonBar); char aBuffer[64]; str_format(aBuffer, sizeof(aBuffer), "×%g", pInfo->m_Speed); - UI()->DoLabel(&ButtonBar, aBuffer, Button.h * 0.7f, TEXTALIGN_LEFT); + UI()->DoLabel(&SpeedBar, aBuffer, Button.h * 0.7f, TEXTALIGN_CENTER); // slice begin button - ButtonBar.VSplitLeft(Margins * 10, 0, &ButtonBar); + 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)) @@ -513,7 +532,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static CButtonContainer s_SliceSaveButton; - if(DoButton_FontIcon(&s_SliceSaveButton, "\xEF\x80\xBD", 0, &Button, IGraphics::CORNER_ALL)) + if(DoButton_FontIcon(&s_SliceSaveButton, "\xEF\x82\x8E", 0, &Button, IGraphics::CORNER_ALL)) { DemoPlayer()->GetDemoName(m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile)); str_append(m_aCurrentDemoFile, ".demo", sizeof(m_aCurrentDemoFile)); @@ -522,6 +541,36 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) } GameClient()->m_Tooltips.DoToolTip(&s_SliceSaveButton, &Button, Localize("Export cut as a separate demo")); + // one marker back + ButtonBar.VSplitLeft(Margins + 20.0f, 0, &ButtonBar); + ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); + static CButtonContainer s_OneMarkerBackButton; + if(DoButton_FontIcon(&s_OneMarkerBackButton, "\xEF\x81\x88", 0, &Button, IGraphics::CORNER_ALL)) + for(int i = pInfo->m_NumTimelineMarkers-1; i >= 0; i--) + { + if((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) < CurrentTick) + { + DemoPlayer()->SeekPercent(static_cast(pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) / static_cast(TotalTicks)); + break; + } + } + GameClient()->m_Tooltips.DoToolTip(&s_OneMarkerBackButton, &Button, Localize("Go back one marker")); + + // one marker forward + ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); + ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); + static CButtonContainer s_OneMarkerForwardButton; + if(DoButton_FontIcon(&s_OneMarkerForwardButton, "\xEF\x81\x91", 0, &Button, IGraphics::CORNER_ALL)) + for(int i = 0; i < pInfo->m_NumTimelineMarkers; i++) + { + if((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick)-2 > CurrentTick) + { + DemoPlayer()->SeekPercent(static_cast(pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) / static_cast(TotalTicks)); + break; + } + } + GameClient()->m_Tooltips.DoToolTip(&s_OneMarkerForwardButton, &Button, Localize("Go forward one marker")); + // close button ButtonBar.VSplitRight(ButtonbarHeight * 3, &ButtonBar, &Button); static int s_ExitButton = 0; From a1680b30f72e64975459c675e496cd1dc7a4365c Mon Sep 17 00:00:00 2001 From: louis Date: Sat, 19 Nov 2022 17:32:47 -0600 Subject: [PATCH 2/5] Update menus_demo.cpp fix clang style --- src/game/client/components/menus_demo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 287f0463a..b2f32f50d 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -546,7 +546,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static CButtonContainer s_OneMarkerBackButton; if(DoButton_FontIcon(&s_OneMarkerBackButton, "\xEF\x81\x88", 0, &Button, IGraphics::CORNER_ALL)) - for(int i = pInfo->m_NumTimelineMarkers-1; i >= 0; i--) + for(int i = pInfo->m_NumTimelineMarkers - 1; i >= 0; i--) { if((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) < CurrentTick) { @@ -563,7 +563,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) if(DoButton_FontIcon(&s_OneMarkerForwardButton, "\xEF\x81\x91", 0, &Button, IGraphics::CORNER_ALL)) for(int i = 0; i < pInfo->m_NumTimelineMarkers; i++) { - if((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick)-2 > CurrentTick) + if((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) - 2 > CurrentTick) { DemoPlayer()->SeekPercent(static_cast(pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) / static_cast(TotalTicks)); break; From 23287528abe346a8a46f4e49d4ab73e2d6941065 Mon Sep 17 00:00:00 2001 From: louis Date: Sat, 19 Nov 2022 22:00:20 -0600 Subject: [PATCH 3/5] Update menus_demo.cpp --- src/game/client/components/menus_demo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index b2f32f50d..b14be2a0c 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -331,7 +331,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) MainView.Margin(5.0f, &MainView); - CUIRect SeekBar, ButtonBar, NameBar, SpeedBar{}; + CUIRect SeekBar, ButtonBar, NameBar, SpeedBar; MainView.HSplitTop(SeekBarHeight, &SeekBar, &ButtonBar); ButtonBar.HSplitTop(Margins, 0, &ButtonBar); @@ -550,7 +550,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) { if((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) < CurrentTick) { - DemoPlayer()->SeekPercent(static_cast(pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) / static_cast(TotalTicks)); + DemoPlayer()->SeekPercent((float)(pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) / TotalTicks); break; } } @@ -565,7 +565,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) { if((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) - 2 > CurrentTick) { - DemoPlayer()->SeekPercent(static_cast(pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) / static_cast(TotalTicks)); + DemoPlayer()->SeekPercent((float)(pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) / TotalTicks); break; } } From 739c77d3d7d0968091765d3768eb8e5d3ee0b5a7 Mon Sep 17 00:00:00 2001 From: louis Date: Sun, 20 Nov 2022 12:12:00 -0600 Subject: [PATCH 4/5] Added threshold, skips to end/beginning Threshold makes skipping multiple times in a row consistent If no markers ahead or behind, will skip to beginning or end --- src/game/client/components/menus_demo.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index b14be2a0c..fab07d0da 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -541,6 +541,9 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) } GameClient()->m_Tooltips.DoToolTip(&s_SliceSaveButton, &Button, Localize("Export cut as a separate demo")); + // threshold value, accounts for slight inaccuracy when setting demo position + const int Threshold = 10; + // one marker back ButtonBar.VSplitLeft(Margins + 20.0f, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); @@ -548,11 +551,12 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) if(DoButton_FontIcon(&s_OneMarkerBackButton, "\xEF\x81\x88", 0, &Button, IGraphics::CORNER_ALL)) for(int i = pInfo->m_NumTimelineMarkers - 1; i >= 0; i--) { - if((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) < CurrentTick) + 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); break; } + DemoPlayer()->SeekPercent(0.0f); } GameClient()->m_Tooltips.DoToolTip(&s_OneMarkerBackButton, &Button, Localize("Go back one marker")); @@ -563,11 +567,12 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) if(DoButton_FontIcon(&s_OneMarkerForwardButton, "\xEF\x81\x91", 0, &Button, IGraphics::CORNER_ALL)) for(int i = 0; i < pInfo->m_NumTimelineMarkers; i++) { - if((pInfo->m_aTimelineMarkers[i] - pInfo->m_FirstTick) - 2 > CurrentTick) + 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); break; } + DemoPlayer()->SeekPercent(1.0f); } GameClient()->m_Tooltips.DoToolTip(&s_OneMarkerForwardButton, &Button, Localize("Go forward one marker")); From b5eef1b64bf396a6ea1276c294b0effdd99b6882 Mon Sep 17 00:00:00 2001 From: louis Date: Sat, 3 Dec 2022 23:36:03 -0600 Subject: [PATCH 5/5] added offset, fix my git issues added demomarker offset Revert "why is this here" This reverts commit a8c74b612300d6563b28a2bea733a0d3a7dd7f90. fix --- src/game/client/components/menus_demo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index fab07d0da..e580d9a24 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -364,7 +364,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) Graphics()->TextureClear(); Graphics()->QuadsBegin(); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); - IGraphics::CQuadItem QuadItem(SeekBar.x + (SeekBar.w - 10.0f) * Ratio, SeekBar.y, UI()->PixelSize(), SeekBar.h); + IGraphics::CQuadItem QuadItem(8.0f + SeekBar.x + (SeekBar.w - 10.0f) * Ratio, SeekBar.y, UI()->PixelSize(), SeekBar.h); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); }