Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/frontend/StarSongbookInterface.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-05-24 12:10:48 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2024-05-24 12:10:48 +1000
commit19986b30a1724ebdda644427152575fd294a2dd8 (patch)
tree6df535abfd9b2130213f4aa2c9fe579462723460 /source/frontend/StarSongbookInterface.cpp
parentae26440bac7eaad4e227544d2095e13192a4f865 (diff)
lmao oops
Diffstat (limited to 'source/frontend/StarSongbookInterface.cpp')
-rw-r--r--source/frontend/StarSongbookInterface.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/source/frontend/StarSongbookInterface.cpp b/source/frontend/StarSongbookInterface.cpp
index b215398..0c5fa4a 100644
--- a/source/frontend/StarSongbookInterface.cpp
+++ b/source/frontend/StarSongbookInterface.cpp
@@ -9,6 +9,8 @@
namespace Star {
+String const SongPathPrefix = "/songs/";
+
SongbookInterface::SongbookInterface(PlayerPtr player) {
m_player = std::move(player);
@@ -60,13 +62,11 @@ 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);
+ eraseWhere(m_files, [](String& song) {
+ if (!song.beginsWith(SongPathPrefix, String::CaseInsensitive)) {
+ Logger::warn("Song '{}' isn't in {}, ignoring", SongPathPrefix.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; });
@@ -81,12 +81,14 @@ void SongbookInterface::refresh(bool reloadFiles) {
auto widget = songList->addItem();
widget->setData(i);
auto songName = widget->fetchChild<LabelWidget>("songName");
- songName->setText(m_files[i]);
+ String const& song = m_files[i];
+ songName->setText(song.substr(SongPathPrefix.size(), song.size() - (SongPathPrefix.size() + 4)));
widget->show();
}
} else {
for (size_t i = 0; i != m_files.size(); ++i) {
StringView song = m_files[i];
+ song = song.substr(SongPathPrefix.size(), song.size() - (SongPathPrefix.size() + 4));
auto find = song.find(search, 0, String::CaseInsensitive);
if (find != NPos) {
auto widget = songList->addItem();