Added searchbar to songbook
This commit is contained in:
parent
89fe1bf15b
commit
81ab5b638b
23
assets/opensb/interface/windowconfig/songbook.config.patch
Normal file
23
assets/opensb/interface/windowconfig/songbook.config.patch
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"paneLayout" : {
|
||||||
|
"group" : {
|
||||||
|
"position" : [8, 71]
|
||||||
|
},
|
||||||
|
"search" : {
|
||||||
|
"type" : "textbox",
|
||||||
|
"position" : [86, 71],
|
||||||
|
"hint" : "Search",
|
||||||
|
"maxWidth" : 50
|
||||||
|
},
|
||||||
|
|
||||||
|
"lblBandInput" : {
|
||||||
|
"position" : [3, 68]
|
||||||
|
},
|
||||||
|
"lblSearchInput" : {
|
||||||
|
"type" : "image",
|
||||||
|
"file" : "/interface/songbook/band.png",
|
||||||
|
"position" : [81, 68],
|
||||||
|
"zlevel" : -3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,15 +23,21 @@ SongbookInterface::SongbookInterface(PlayerPtr player) {
|
|||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
reader.registerCallback("group", [=](Widget*) {});
|
reader.registerCallback("group", [=](Widget*) {});
|
||||||
|
reader.registerCallback("search", [=](Widget*) {});
|
||||||
|
|
||||||
reader.construct(assets->json("/interface/windowconfig/songbook.config:paneLayout"), this);
|
reader.construct(assets->json("/interface/windowconfig/songbook.config:paneLayout"), this);
|
||||||
|
|
||||||
auto songList = fetchChild<ListWidget>("songs.list");
|
auto songList = fetchChild<ListWidget>("songs.list");
|
||||||
|
auto search = fetchChild<TextBoxWidget>("search")->getText();
|
||||||
|
|
||||||
StringList files = assets->scan(".abc");
|
if (m_searchValue != search)
|
||||||
sort(files, [](String const& a, String const& b) -> bool { return b.compare(a, String::CaseInsensitive) > 0; });
|
m_searchValue = search;
|
||||||
for (auto s : files) {
|
|
||||||
|
m_files = assets->scan(".abc");
|
||||||
|
sort(m_files, [](String const& a, String const& b) -> bool { return b.compare(a, String::CaseInsensitive) > 0; });
|
||||||
|
for (auto s : m_files) {
|
||||||
auto song = s.substr(7, s.length() - (7 + 4));
|
auto song = s.substr(7, s.length() - (7 + 4));
|
||||||
|
if (song.contains(m_searchValue, String::CaseInsensitive)) {
|
||||||
auto widget = songList->addItem();
|
auto widget = songList->addItem();
|
||||||
widget->setData(s);
|
widget->setData(s);
|
||||||
auto songName = widget->fetchChild<LabelWidget>("songName");
|
auto songName = widget->fetchChild<LabelWidget>("songName");
|
||||||
@ -39,6 +45,31 @@ SongbookInterface::SongbookInterface(PlayerPtr player) {
|
|||||||
|
|
||||||
widget->show();
|
widget->show();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SongbookInterface::update(float dt) {
|
||||||
|
Pane::update(dt);
|
||||||
|
|
||||||
|
auto search = fetchChild<TextBoxWidget>("search")->getText();
|
||||||
|
if (m_searchValue != search) {
|
||||||
|
m_searchValue = search;
|
||||||
|
|
||||||
|
auto songList = fetchChild<ListWidget>("songs.list");
|
||||||
|
songList->clear();
|
||||||
|
|
||||||
|
for (auto s : m_files) {
|
||||||
|
auto song = s.substr(7, s.length() - (7 + 4));
|
||||||
|
if (song.contains(m_searchValue, String::CaseInsensitive)) {
|
||||||
|
auto widget = songList->addItem();
|
||||||
|
widget->setData(s);
|
||||||
|
auto songName = widget->fetchChild<LabelWidget>("songName");
|
||||||
|
songName->setText(song);
|
||||||
|
|
||||||
|
widget->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SongbookInterface::play() {
|
bool SongbookInterface::play() {
|
||||||
|
@ -13,8 +13,12 @@ class SongbookInterface : public Pane {
|
|||||||
public:
|
public:
|
||||||
SongbookInterface(PlayerPtr player);
|
SongbookInterface(PlayerPtr player);
|
||||||
|
|
||||||
|
void update(float dt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerPtr m_player;
|
PlayerPtr m_player;
|
||||||
|
StringList m_files;
|
||||||
|
String m_searchValue;
|
||||||
bool play();
|
bool play();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user