From ae26440bac7eaad4e227544d2095e13192a4f865 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Fri, 24 May 2024 12:00:53 +1000 Subject: [PATCH] fix Songbook interface no longer excluding /songs/ & .abc --- source/frontend/StarSongbookInterface.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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("search")->getText(); + auto& search = fetchChild("search")->getText(); if (m_lastSearch != search || reloadFiles) { m_lastSearch = search; auto songList = fetchChild("songs.list");