Merge pull request #7191 from furo321/demo-slice-dotdemo

Don't include .demo in demo slice input
This commit is contained in:
Dennis Felsing 2023-09-16 22:16:23 +00:00 committed by GitHub
commit f2451c7c93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -686,7 +686,6 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
char aDemoName[IO_MAX_PATH_LENGTH]; char aDemoName[IO_MAX_PATH_LENGTH];
DemoPlayer()->GetDemoName(aDemoName, sizeof(aDemoName)); DemoPlayer()->GetDemoName(aDemoName, sizeof(aDemoName));
m_DemoSliceInput.Set(aDemoName); m_DemoSliceInput.Set(aDemoName);
m_DemoSliceInput.Append(".demo");
UI()->SetActiveItem(&m_DemoSliceInput); UI()->SetActiveItem(&m_DemoSliceInput);
m_DemoPlayerState = DEMOPLAYER_SLICE_SAVE; m_DemoPlayerState = DEMOPLAYER_SLICE_SAVE;
} }
@ -828,11 +827,11 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &OkButton) || (!UI()->IsPopupOpen() && UI()->ConsumeHotkey(CUI::HOTKEY_ENTER))) if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &OkButton) || (!UI()->IsPopupOpen() && UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)))
{ {
char aDemoName[IO_MAX_PATH_LENGTH]; char aDemoName[IO_MAX_PATH_LENGTH];
char aNameWithoutExt[IO_MAX_PATH_LENGTH];
DemoPlayer()->GetDemoName(aDemoName, sizeof(aDemoName)); DemoPlayer()->GetDemoName(aDemoName, sizeof(aDemoName));
str_append(aDemoName, ".demo");
if(!str_endswith(m_DemoSliceInput.GetString(), ".demo")) fs_split_file_extension(m_DemoSliceInput.GetString(), aNameWithoutExt, sizeof(aNameWithoutExt));
m_DemoSliceInput.Append(".demo"); m_DemoSliceInput.Set(aNameWithoutExt);
if(str_comp(aDemoName, m_DemoSliceInput.GetString()) == 0) if(str_comp(aDemoName, m_DemoSliceInput.GetString()) == 0)
{ {
@ -860,7 +859,7 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
if(s_ConfirmPopupContext.m_Result == CUI::SConfirmPopupContext::CONFIRMED) if(s_ConfirmPopupContext.m_Result == CUI::SConfirmPopupContext::CONFIRMED)
{ {
char aPath[IO_MAX_PATH_LENGTH]; 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());
str_copy(m_aCurrentDemoSelectionName, m_DemoSliceInput.GetString()); str_copy(m_aCurrentDemoSelectionName, m_DemoSliceInput.GetString());
if(str_endswith(m_aCurrentDemoSelectionName, ".demo")) if(str_endswith(m_aCurrentDemoSelectionName, ".demo"))
m_aCurrentDemoSelectionName[str_length(m_aCurrentDemoSelectionName) - str_length(".demo")] = '\0'; m_aCurrentDemoSelectionName[str_length(m_aCurrentDemoSelectionName) - str_length(".demo")] = '\0';