diff --git a/data/en.mse-locale/locale b/data/en.mse-locale/locale index a42bb812..617022b3 100644 --- a/data/en.mse-locale/locale +++ b/data/en.mse-locale/locale @@ -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". diff --git a/src/gui/control/package_list.cpp b/src/gui/control/package_list.cpp index 1da02a7e..5f6b4a31 100644 --- a/src/gui/control/package_list.cpp +++ b/src/gui/control/package_list.cpp @@ -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 matching; diff --git a/src/gui/new_window.cpp b/src/gui/new_window.cpp index 6c3def1b..e7a44e12 100644 --- a/src/gui/new_window.cpp +++ b/src/gui/new_window.cpp @@ -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()); +void NewSetWindow::onGameFilterUpdate(wxCommandEvent&) { + if (game_list->hasSelection()) { + GameP existingGameSelection = game_list->getSelection(false); + game_list->setFilter(game_filter->getFilter()); + game_list->select(existingGameSelection->name()); + } + else { + game_list->setFilter(game_filter->getFilter()); + } +} + +void NewSetWindow::onStylesheetFilterUpdate(wxCommandEvent&) { + if (stylesheet_list->hasSelection()) { + StyleSheetP existingStylesheetSelection = stylesheet_list->getSelection(false); + stylesheet_list->setFilter(stylesheet_filter->getFilter()); + stylesheet_list->select(existingStylesheetSelection->name()); + } + else { + stylesheet_list->setFilter(stylesheet_filter->getFilter()); + } } 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) diff --git a/src/gui/new_window.hpp b/src/gui/new_window.hpp index 185b7ceb..82109a8d 100644 --- a/src/gui/new_window.hpp +++ b/src/gui/new_window.hpp @@ -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&); diff --git a/src/util/window_id.hpp b/src/util/window_id.hpp index d17de707..96b5cfcf 100644 --- a/src/util/window_id.hpp +++ b/src/util/window_id.hpp @@ -229,6 +229,7 @@ enum ControlID { // New Set Window ID_STYLESHEET_FILTER, + ID_GAME_FILTER, // Controls ID_VIEWER = 1001,