feat: apply filtering to game list, correct selections after filtering

Will need to propogate these filtering options to the other places these things are present, there's a dedicated variant for just the stylesheet dialog window and also the Style tab.
This commit is contained in:
Brendan Hagan
2022-06-19 23:38:38 -04:00
parent 52f1724449
commit 766a99fbc4
5 changed files with 55 additions and 17 deletions
+3 -1
View File
@@ -461,8 +461,10 @@ label:
# New set window
game type: &Game type:
style type: &Card style:
search game list : Filter Games
search game list control: Filter the game list. Use - to exclude games. Use field: to search in a specific field. Use quotes for literal search. Separate multiple queries with a space.
search stylesheet list: Filter Stylesheets
search stylesheet list control: Filter the card list. Use - to exclude cards. Use field: to search in a specific field. Use quotes for literal search. Separate multiple queries with a space.
search stylesheet list control: Filter the stylesheet list. Use - to exclude styles. Use field: to search in a specific field. Use quotes for literal search. Separate multiple queries with a space.
stylesheet not found :
The set you are trying to open uses the stylesheet "%s".
+2
View File
@@ -68,6 +68,8 @@ struct PackageList::ComparePackagePosHint {
void PackageList::showData(const String& pattern) {
// clear
packages.clear();
filtered_packages.clear();
filter.reset();
// find matching packages
vector<PackagedP> matching;
+41 -13
View File
@@ -34,18 +34,26 @@ NewSetWindow::NewSetWindow(Window* parent)
stylesheet_list = new PackageList (this, ID_STYLESHEET_LIST, wxHORIZONTAL, false);
wxStaticText* game_text = new wxStaticText(this, ID_GAME_LIST, _LABEL_("game type"));
wxStaticText* stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
filter = new FilterCtrl(this, ID_STYLESHEET_FILTER, _LABEL_("search stylesheet list"), _HELP_("search stylesheet list control"));
filter->setFilter(filter_value);
game_filter = new FilterCtrl(this, ID_GAME_FILTER, _LABEL_("search game list"), _HELP_("search game list control"));
game_filter->setFilter(game_filter_value);
stylesheet_filter = new FilterCtrl(this, ID_STYLESHEET_FILTER, _LABEL_("search stylesheet list"), _HELP_("search stylesheet list control"));
stylesheet_filter->setFilter(stylesheet_filter_value);
// init sizer
wxSizer* s = new wxBoxSizer(wxVERTICAL);
s->Add(game_text, 0, wxALL, 4);
s->Add(game_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
wxSizer* s2 = new wxBoxSizer(wxHORIZONTAL);
s2->Add(stylesheet_text, 0, wxALL & ~wxLEFT, 4);
s2->AddSpacer(2);
s2->Add(filter, 0, wxALL & ~wxRIGHT, 4);
s2->Add(game_text, 0, wxALL & ~wxLEFT, 4);
s2->AddSpacer(2);
s2->Add(game_filter, 0, wxALL & ~wxRIGHT, 4);
s->Add(s2);
s->Add(game_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
wxSizer* s3 = new wxBoxSizer(wxHORIZONTAL);
s3->Add(stylesheet_text, 0, wxALL & ~wxLEFT, 4);
s3->AddSpacer(2);
s3->Add(stylesheet_filter, 0, wxALL & ~wxRIGHT, 4);
s->Add(s3);
s->Add(stylesheet_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8);
s->SetSizeHints(this);
@@ -87,12 +95,31 @@ void NewSetWindow::onStyleSheetSelect(wxCommandEvent&) {
settings.gameSettingsFor(*game).default_stylesheet = stylesheet->name();
UpdateWindowUI(wxUPDATE_UI_RECURSE);
}
void NewSetWindow::onStyleSheetActivate(wxCommandEvent&) {
done();
}
void NewSetWindow::onFilterUpdate(wxCommandEvent&) {
stylesheet_list->setFilter(filter->getFilter<PackageData>());
void NewSetWindow::onGameFilterUpdate(wxCommandEvent&) {
if (game_list->hasSelection()) {
GameP existingGameSelection = game_list->getSelection<Game>(false);
game_list->setFilter(game_filter->getFilter<PackageData>());
game_list->select(existingGameSelection->name());
}
else {
game_list->setFilter(game_filter->getFilter<PackageData>());
}
}
void NewSetWindow::onStylesheetFilterUpdate(wxCommandEvent&) {
if (stylesheet_list->hasSelection()) {
StyleSheetP existingStylesheetSelection = stylesheet_list->getSelection<StyleSheet>(false);
stylesheet_list->setFilter(stylesheet_filter->getFilter<PackageData>());
stylesheet_list->select(existingStylesheetSelection->name());
}
else {
stylesheet_list->setFilter(stylesheet_filter->getFilter<PackageData>());
}
}
void NewSetWindow::OnOK(wxCommandEvent&) {
@@ -128,10 +155,11 @@ void NewSetWindow::onIdle(wxIdleEvent& ev) {
}
BEGIN_EVENT_TABLE(NewSetWindow, wxDialog)
EVT_GALLERY_SELECT(ID_GAME_LIST, NewSetWindow::onGameSelect)
EVT_GALLERY_SELECT(ID_STYLESHEET_LIST, NewSetWindow::onStyleSheetSelect)
EVT_GALLERY_ACTIVATE(ID_STYLESHEET_LIST, NewSetWindow::onStyleSheetActivate)
EVT_COMMAND_RANGE(ID_STYLESHEET_FILTER, ID_STYLESHEET_FILTER, wxEVT_COMMAND_TEXT_UPDATED, NewSetWindow::onFilterUpdate)
EVT_GALLERY_SELECT(ID_GAME_LIST, NewSetWindow::onGameSelect)
EVT_GALLERY_SELECT(ID_STYLESHEET_LIST, NewSetWindow::onStyleSheetSelect)
EVT_GALLERY_ACTIVATE(ID_STYLESHEET_LIST, NewSetWindow::onStyleSheetActivate)
EVT_COMMAND_RANGE(ID_STYLESHEET_FILTER, ID_STYLESHEET_FILTER, wxEVT_COMMAND_TEXT_UPDATED, NewSetWindow::onStylesheetFilterUpdate)
EVT_COMMAND_RANGE(ID_GAME_FILTER, ID_GAME_FILTER, wxEVT_COMMAND_TEXT_UPDATED, NewSetWindow::onGameFilterUpdate)
EVT_BUTTON (wxID_OK, NewSetWindow::OnOK)
EVT_UPDATE_UI (wxID_ANY, NewSetWindow::onUpdateUI)
EVT_IDLE ( NewSetWindow::onIdle)
+8 -3
View File
@@ -35,8 +35,12 @@ private:
// gui items
PackageList* game_list, *stylesheet_list;
FilterCtrl* filter;
String filter_value;
FilterCtrl* game_filter;
String game_filter_value;
FilterCtrl* stylesheet_filter;
String stylesheet_filter_value;
// --------------------------------------------------- : events
@@ -44,7 +48,8 @@ private:
void onStyleSheetSelect (wxCommandEvent&);
void onStyleSheetActivate(wxCommandEvent&);
void onFilterUpdate(wxCommandEvent&);
void onStylesheetFilterUpdate(wxCommandEvent&);
void onGameFilterUpdate(wxCommandEvent&);
virtual void OnOK(wxCommandEvent&);
+1
View File
@@ -229,6 +229,7 @@ enum ControlID {
// New Set Window
ID_STYLESHEET_FILTER,
ID_GAME_FILTER,
// Controls
ID_VIEWER = 1001,