From d701bdeef850c02feff246f60e83003b36df1270 Mon Sep 17 00:00:00 2001 From: Andrew Plotner Date: Mon, 11 Mar 2024 01:38:09 -0400 Subject: [PATCH] Work around std::filesystem being unavailable on mac w/ warnings The version of the macOS sdk we're using doesn't implement it, see more detailed in-code comment included in this commit --- .../Screen/Others/ScreenSelectMusic.cpp | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/Etterna/Screen/Others/ScreenSelectMusic.cpp b/src/Etterna/Screen/Others/ScreenSelectMusic.cpp index 416f8f73a1..a8612b463a 100644 --- a/src/Etterna/Screen/Others/ScreenSelectMusic.cpp +++ b/src/Etterna/Screen/Others/ScreenSelectMusic.cpp @@ -37,7 +37,7 @@ #include "Etterna/Actor/Gameplay/Player.h" #include "Etterna/Models/NoteData/NoteDataUtil.h" #include "Etterna/Singletons/ReplayManager.h" -#include "Etterna/Screen/Others/ScreenPrompt.h" +#include "Etterna/Screen/Others/ScreenPrompt.h" #include #include @@ -484,12 +484,12 @@ ScreenSelectMusic::Input(const InputEventPlus& input) if (CachePackForRanking(GAMESTATE->m_sLastSongGroup)) return true; } else { - // most likely hovering a non pack section + // most likely hovering a non pack section } } else { if (CachePackForRanking(GAMESTATE->m_pCurSong->m_sGroupName)) return true; - } + } } else if (bHoldingCtrl && input.DeviceI.button == KEY_BACK && input.type == IET_FIRST_PRESS && m_MusicWheel.IsSettled()) { @@ -950,11 +950,11 @@ ScreenSelectMusic::ChangeSteps(PlayerNumber pn, int dir) void ScreenSelectMusic::HandleMessage(const Message& msg) { - if (msg == Message_FavoritesUpdated) { + if (msg == Message_FavoritesUpdated) { // this makes the favorite icon appear if the wheel isnt moving if (m_MusicWheel.IsSettled()) { m_MusicWheel.RebuildWheelItems(0); - } + } } ScreenWithMenuElements::HandleMessage(msg); @@ -1143,6 +1143,12 @@ ScreenSelectMusic::HandleScreenMessage(const ScreenMessage& SM) void ScreenSelectMusic::OnConfirmSongDeletion() { + //Temporary hacky workaround -- std::filesystem is unavailable before the macOS 10.15 sdk, and we're currently using an old sdk for backwards compatibility. + //Do nothing until this is properly implemented +#if defined(__APPLE__) + #warning "ScreenSelectMusic::OnConfirmSongDeletion is unimplemented for mac target!" + Locator::getLogger()->warn("Deleting songs unimplemented on macOS! (ScreenSelectMusic::OnConfirmSongDeletion)"); +#else auto* deletedSong = m_pSongAwaitingDeletionConfirmation; if (!deletedSong) { Locator::getLogger()->warn("Attempted to delete a null song (ScreenSelectMusic::OnConfirmSongDeletion)"); @@ -1155,14 +1161,14 @@ ScreenSelectMusic::OnConfirmSongDeletion() const std::filesystem::path songDir = std::filesystem::u8path(p); // flush the deleted song from any caches - SONGMAN->UnlistSong(deletedSong); - + SONGMAN->UnlistSong(deletedSong); + // stop the music because this holds a file handle SOUND->StopMusic(); - SOUND->Flush(); + SOUND->Flush(); // refresh the song list - m_MusicWheel.ReloadSongList(false, ""); + m_MusicWheel.ReloadSongList(false, ""); // delete the song directory from disk Locator::getLogger()->info("Deleting song directory: {}", songDir.generic_string()); @@ -1177,11 +1183,12 @@ ScreenSelectMusic::OnConfirmSongDeletion() Locator::getLogger()->error("There was an error while trying to remove " "the song directory {} - {}", songDir.generic_string(), - e.what()); + e.what()); } - m_pSongAwaitingDeletionConfirmation = nullptr; + m_pSongAwaitingDeletionConfirmation = nullptr; MESSAGEMAN->Broadcast("DeletedCurrentSong"); +#endif } bool @@ -1382,7 +1389,7 @@ ScreenSelectMusic::AfterMusicChange() GAMESTATE->m_pCurSteps.Set(nullptr); if (GAMESTATE->m_SortOrder == SORT_GROUP) { // when hovering groups, set group to the hovered one - GAMESTATE->m_sLastSongGroup = m_MusicWheel.GetSelectedSection(); + GAMESTATE->m_sLastSongGroup = m_MusicWheel.GetSelectedSection(); } if (b_PreviewNoteFieldIsActive) // if previewnotefield we are moving out of a pack @@ -1602,15 +1609,15 @@ ScreenSelectMusic::PauseSampleMusic() // us we didnt really pause anything (wow who would have thought) GAMESTATE->SetPaused(success && pMusic->m_bPaused); }); -} - +} + bool -ScreenSelectMusic::DeleteCurrentSong() +ScreenSelectMusic::DeleteCurrentSong() { Song* songToDelete = GAMESTATE->m_pCurSong; if (songToDelete != nullptr && PREFSMAN->m_bAllowSongDeletion.Get()) { - m_pSongAwaitingDeletionConfirmation = songToDelete; + m_pSongAwaitingDeletionConfirmation = songToDelete; ScreenPrompt::s_bMustResetInputRedirAtClose = true; ScreenPrompt::Prompt(SM_ConfirmDeleteSong, @@ -1749,8 +1756,8 @@ ScreenSelectMusic::AddCurrentChartToActivePlaylist() GAMESTATE->m_pCurSong->GetDisplayMainTitle().c_str(), SONGMAN->activeplaylist.c_str())); return true; -} - +} + bool ScreenSelectMusic::CachePackForRanking(const std::string& pack) { @@ -2044,7 +2051,7 @@ class LunaScreenSelectMusic : public Luna { p->PlayCurrentSongSampleMusic(true, BArg(1), BArg(2)); return 0; - } + } static int DeleteCurrentSong(T* p, lua_State* L) { lua_pushboolean(L, p->DeleteCurrentSong()); @@ -2079,15 +2086,15 @@ class LunaScreenSelectMusic : public Luna { lua_pushboolean(L, p->AddCurrentChartToActivePlaylist()); return 1; - } - static int CachePackForRanking(T* p, lua_State* L) + } + static int CachePackForRanking(T* p, lua_State* L) { if (lua_isnoneornil(L, 1)) { lua_pushboolean( L, - p->CachePackForRanking(p->GetMusicWheel()->GetSelectedSection())); + p->CachePackForRanking(p->GetMusicWheel()->GetSelectedSection())); } else { - lua_pushboolean(L, p->CachePackForRanking(SArg(1))); + lua_pushboolean(L, p->CachePackForRanking(SArg(1))); } return 1;