diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-05-24 12:00:53 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-05-24 12:00:53 +1000 |
commit | ae26440bac7eaad4e227544d2095e13192a4f865 (patch) | |
tree | d6a69e9681899b6a8899beb9146473bfdbf9a834 /source/frontend/StarSongbookInterface.cpp | |
parent | 8f8220f517310552294e2f1600b1fa7581cab3d3 (diff) |
fix Songbook interface no longer excluding /songs/ & .abc
Diffstat (limited to 'source/frontend/StarSongbookInterface.cpp')
-rw-r--r-- | source/frontend/StarSongbookInterface.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/frontend/StarSongbookInterface.cpp b/source/frontend/StarSongbookInterface.cpp index 28145b6..b215398 100644 --- a/source/frontend/StarSongbookInterface.cpp +++ b/source/frontend/StarSongbookInterface.cpp @@ -60,9 +60,18 @@ bool SongbookInterface::play() { void SongbookInterface::refresh(bool reloadFiles) { if (reloadFiles) { m_files = Root::singleton().assets()->scanExtension(".abc").values(); + String prefix = "/songs/"; + eraseWhere(m_files, [&](String& song) { + if (!song.beginsWith(prefix, String::CaseInsensitive)) { + Logger::warn("Song '{}' isn't in {}, ignoring", prefix.size(), song); + return true; + } + song = song.substr(prefix.size(), song.size() - (prefix.size() + 4)); + return false; + }); sort(m_files, [](String const& a, String const& b) -> bool { return b.compare(a, String::CaseInsensitive) > 0; }); } - auto search = fetchChild<TextBoxWidget>("search")->getText(); + auto& search = fetchChild<TextBoxWidget>("search")->getText(); if (m_lastSearch != search || reloadFiles) { m_lastSearch = search; auto songList = fetchChild<ListWidget>("songs.list"); |