Skip to content

Commit

Permalink
Merge pull request ddnet#7365 from Robyt3/Menus-Demo-Fixes
Browse files Browse the repository at this point in the history
Fix crash when directly rendering demo after slicing, fix demo slice confirmation popup not being shown anymore
  • Loading branch information
def- authored Oct 23, 2023
2 parents 61ff171 + 7c06553 commit 31031f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/game/client/components/menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,8 +1565,6 @@ int CMenus::Render()
#if defined(CONF_VIDEORECORDER)
else if(m_Popup == POPUP_RENDER_DEMO)
{
dbg_assert(m_DemolistSelectedIndex >= 0 && !m_vpFilteredDemos[m_DemolistSelectedIndex]->m_IsDir, "m_DemolistSelectedIndex invalid for POPUP_RENDER_DEMO");

CUIRect Row, Ok, Abort;
Box.VMargin(60.0f, &Box);
Box.HMargin(20.0f, &Box);
Expand Down Expand Up @@ -1826,12 +1824,12 @@ int CMenus::Render()
void CMenus::PopupConfirmDemoReplaceVideo()
{
char aBuf[IO_MAX_PATH_LENGTH];
str_format(aBuf, sizeof(aBuf), "%s/%s", m_aCurrentDemoFolder, m_vpFilteredDemos[m_DemolistSelectedIndex]->m_aFilename);
str_format(aBuf, sizeof(aBuf), "%s/%s.demo", m_aCurrentDemoFolder, m_aCurrentDemoSelectionName);
char aVideoName[IO_MAX_PATH_LENGTH];
str_copy(aVideoName, m_DemoRenderInput.GetString());
if(!str_endswith(aVideoName, ".mp4"))
str_append(aVideoName, ".mp4");
const char *pError = Client()->DemoPlayer_Render(aBuf, m_vpFilteredDemos[m_DemolistSelectedIndex]->m_StorageType, aVideoName, m_Speed, m_StartPaused);
const char *pError = Client()->DemoPlayer_Render(aBuf, m_DemolistStorageType, aVideoName, m_Speed, m_StartPaused);
m_Speed = 4;
m_StartPaused = false;
m_LastPauseChange = -1.0f;
Expand Down
4 changes: 3 additions & 1 deletion src/game/client/components/menus_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
else
{
char aPath[IO_MAX_PATH_LENGTH];
str_format(aPath, sizeof(aPath), "%s/%s", m_aCurrentDemoFolder, m_DemoSliceInput.GetString());
str_format(aPath, sizeof(aPath), "%s/%s.demo", m_aCurrentDemoFolder, m_DemoSliceInput.GetString());
if(Storage()->FileExists(aPath, IStorage::TYPE_SAVE))
{
s_ConfirmPopupContext.Reset();
Expand Down Expand Up @@ -880,6 +880,8 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
m_StartPaused = false;
m_DemoRenderInput.Set(m_aCurrentDemoSelectionName);
UI()->SetActiveItem(&m_DemoRenderInput);
if(m_DemolistStorageType != IStorage::TYPE_ALL && m_DemolistStorageType != IStorage::TYPE_SAVE)
m_DemolistStorageType = IStorage::TYPE_ALL; // Select a storage type containing the sliced demo
}
#endif
}
Expand Down

0 comments on commit 31031f5

Please sign in to comment.