From 475ed2961ff01daf72a0247621f7f3967efe41f0 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Sun, 26 Jan 2014 21:48:40 +0000 Subject: [PATCH 1/3] Started to implement issue #79. Plugins that contain only a TES4 record will show up in the load order confirmation dialog with grey text. Plugins with more than just a TES4 record that have accompanying BSAs will show up with light blue text. --- src/backend/metadata.cpp | 4 ++++ src/backend/metadata.h | 1 + src/gui/main.cpp | 9 +++++++-- src/gui/main.h | 3 ++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index c0aa917c..e582c47e 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -720,6 +720,10 @@ namespace boss { return issues; } + bool Plugin::HasBSA(const Game& game) const { + return boost::filesystem::exists(game.DataPath() / (name.substr(0, name.length() - 4) + ".bsa")); + } + bool operator == (const File& lhs, const Plugin& rhs) { return boost::iequals(lhs.Name(), rhs.Name()); } diff --git a/src/backend/metadata.h b/src/backend/metadata.h index 699ca21e..e73758b3 100644 --- a/src/backend/metadata.h +++ b/src/backend/metadata.h @@ -190,6 +190,7 @@ namespace boss { void EvalAllConditions(boss::Game& game, const unsigned int language); bool HasNameOnly() const; bool IsRegexPlugin() const; + bool HasBSA(const Game& game) const; //Compare name strings. bool operator == (const Plugin& rhs) const; diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 21942baf..b8c8f623 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -687,7 +687,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { progDia = NULL; BOOST_LOG_TRIVIAL(debug) << "Displaying load order preview."; - LoadOrderPreview preview(this, translate("BOSS: Calculated Load Order"), plugins); + LoadOrderPreview preview(this, translate("BOSS: Calculated Load Order"), plugins, _game); if (preview.ShowModal() == wxID_OK) { BOOST_LOG_TRIVIAL(debug) << "Load order accepted."; @@ -1102,7 +1102,7 @@ void Launcher::OnAbout(wxCommandEvent& event) { wxAboutBox(aboutInfo); } -LoadOrderPreview::LoadOrderPreview(wxWindow *parent, const wxString title, const std::list& plugins) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER), _plugins(plugins) { +LoadOrderPreview::LoadOrderPreview(wxWindow *parent, const wxString title, const std::list& plugins, const boss::Game& game) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), _plugins(plugins), _game(game) { //Init controls. _loadOrder = new wxListView(this, LIST_LoadOrder, wxDefaultPosition, wxDefaultSize, wxLC_REPORT); @@ -1115,6 +1115,11 @@ LoadOrderPreview::LoadOrderPreview(wxWindow *parent, const wxString title, const size_t i=0; for (list::const_iterator it=plugins.begin(), endit=plugins.end(); it != endit; ++it, ++i) { _loadOrder->InsertItem(i, FromUTF8(it->Name())); + if (it->FormIDs().empty()) { + _loadOrder->SetItemTextColour(i, wxColour(122, 122, 122)); + } else if (it->HasBSA(_game)) { + _loadOrder->SetItemTextColour(i, wxColour(0, 142, 219)); + } } _loadOrder->SetColumnWidth(0, wxLIST_AUTOSIZE); diff --git a/src/gui/main.h b/src/gui/main.h index e9611e9d..d79a2720 100644 --- a/src/gui/main.h +++ b/src/gui/main.h @@ -72,7 +72,7 @@ private: class LoadOrderPreview : public wxDialog { public: - LoadOrderPreview(wxWindow *parent, const wxString title, const std::list& plugins); + LoadOrderPreview(wxWindow *parent, const wxString title, const std::list& plugins, const boss::Game& game); void OnPluginSelect(wxListEvent& event); void OnMoveUp(wxCommandEvent& event); @@ -86,6 +86,7 @@ private: const std::list _plugins; std::set _movedPlugins; + const boss::Game& _game; }; #endif From 22b128014a4d8f05b0c57952cb597344d01212b4 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Sun, 26 Jan 2014 23:07:29 +0000 Subject: [PATCH 2/3] Issue #79 fixes. Forgot that BSAs only need to start with the plugin basename. --- src/backend/metadata.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index e582c47e..d38a9eff 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -621,8 +621,8 @@ namespace boss { bool Plugin::operator == (const Plugin& rhs) const { return (boost::iequals(name, rhs.Name()) - || (IsRegexPlugin() && boost::regex_match(rhs.Name(), boost::regex(name, boost::regex::extended|boost::regex::icase))) - || (rhs.IsRegexPlugin() && boost::regex_match(name, boost::regex(rhs.Name(), boost::regex::extended|boost::regex::icase)))); + || (IsRegexPlugin() && boost::regex_match(rhs.Name(), boost::regex(name, boost::regex::perl|boost::regex::icase))) + || (rhs.IsRegexPlugin() && boost::regex_match(name, boost::regex(rhs.Name(), boost::regex::perl|boost::regex::icase)))); } bool Plugin::operator != (const Plugin& rhs) const { @@ -721,7 +721,18 @@ namespace boss { } bool Plugin::HasBSA(const Game& game) const { - return boost::filesystem::exists(game.DataPath() / (name.substr(0, name.length() - 4) + ".bsa")); + //BSAs must start with the plugin basename and have the extension .bsa. + for (boost::filesystem::directory_iterator it(game.DataPath()); it != boost::filesystem::directory_iterator(); ++it) { + if (boost::filesystem::is_regular_file(it->status()) && boost::iequals(it->path().extension().string(), ".bsa")) { + BOOST_LOG_TRIVIAL(info) << name << " | " << it->path().filename().string(); + if (!IsRegexPlugin() && boost::istarts_with(it->path().filename().string(), name.substr(0, name.length() - 4))) + return true; + else if (IsRegexPlugin() && boost::regex_search(it->path().filename().string(), boost::regex(name.substr(0, name.length() - 5), boost::regex::perl | boost::regex::icase), boost::match_continuous)) { + return true; + } + } + } + return false; } bool operator == (const File& lhs, const Plugin& rhs) { From e16906f49cc0d7887fbdc2b90c6bab11d1b9bbc4 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Sun, 26 Jan 2014 23:36:13 +0000 Subject: [PATCH 3/3] Issue #79 work. This should complete it, I can't think of any other plugin lists that need colours added. The plugin list in the Editor now displays plugins with accompanying BSAs in light blue. The grey text for empty plugins is not used here because record parsing is skipped for the Editor, so they all appear empty. --- src/gui/editor.cpp | 5 ++++- src/gui/editor.h | 3 ++- src/gui/main.cpp | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp index b0304b8c..a90314b5 100644 --- a/src/gui/editor.cpp +++ b/src/gui/editor.cpp @@ -106,7 +106,7 @@ wxString MessageList::OnGetItemText(long item, long column) const { } } -Editor::Editor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::vector& basePlugins, std::vector& editedPlugins, const unsigned int language) : wxFrame(parent, wxID_ANY, title), _userlistPath(userlistPath), _basePlugins(basePlugins), _editedPlugins(editedPlugins) { +Editor::Editor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::vector& basePlugins, std::vector& editedPlugins, const unsigned int language, const boss::Game& game) : wxFrame(parent, wxID_ANY, title), _userlistPath(userlistPath), _basePlugins(basePlugins), _editedPlugins(editedPlugins), _game(game) { //Initialise child windows. listBook = new wxNotebook(this, BOOK_Lists); @@ -265,6 +265,9 @@ Editor::Editor(wxWindow *parent, const wxString& title, const std::string userli //Fill pluginList with the contents of basePlugins. for (int i=0, max=_basePlugins.size(); i < max; ++i) { pluginList->InsertItem(i, FromUTF8(_basePlugins[i].Name())); + if (_basePlugins[i].HasBSA(_game)) { + pluginList->SetItemTextColour(i, wxColour(0, 142, 219)); + } } pluginList->SetColumnWidth(0, wxLIST_AUTOSIZE); diff --git a/src/gui/editor.h b/src/gui/editor.h index 18ada887..5f28c5c1 100644 --- a/src/gui/editor.h +++ b/src/gui/editor.h @@ -54,7 +54,7 @@ private: class Editor : public wxFrame { public: - Editor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::vector& basePlugins, std::vector& editedPlugins, const unsigned int language); + Editor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::vector& basePlugins, std::vector& editedPlugins, const unsigned int language, const boss::Game& game); void OnPluginSelect(wxListEvent& event); void OnEnabledToggle(wxCommandEvent& event); @@ -89,6 +89,7 @@ private: const std::string _userlistPath; const std::vector _basePlugins; + const boss::Game& _game; std::vector _editedPlugins; std::vector currentMessages; diff --git a/src/gui/main.cpp b/src/gui/main.cpp index b8c8f623..f0f1ce73 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -936,7 +936,7 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { //Create editor window. BOOST_LOG_TRIVIAL(debug) << "Opening editor window."; - Editor *editor = new Editor(this, translate("BOSS: Metadata Editor"), _game.UserlistPath().string(), installed, ulist_plugins, lang); + Editor *editor = new Editor(this, translate("BOSS: Metadata Editor"), _game.UserlistPath().string(), installed, ulist_plugins, lang, _game); progDia->Destroy(); @@ -1023,7 +1023,7 @@ void Launcher::OnOpenSettings(wxCommandEvent& event) { BOOST_LOG_TRIVIAL(debug) << "Opening settings window..."; SettingsFrame *settings = new SettingsFrame(this, translate("BOSS: Settings"), _settings, _games); settings->ShowModal(); - BOOST_LOG_TRIVIAL(debug) << "Editor window opened."; + BOOST_LOG_TRIVIAL(debug) << "Settings window opened."; } void Launcher::OnGameChange(wxCommandEvent& event) {