diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index 990f01fe..21f85253 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -400,21 +400,13 @@ namespace boss { } } - void Plugin::Merge(const Plugin& plugin, bool ifDisabled) { + void Plugin::MergeMetadata(const Plugin& plugin) { BOOST_LOG_TRIVIAL(trace) << "Merging metadata for: " << name; - //If 'name' differs or if 'enabled' is false for the given plugin, don't change anything. - if ((!plugin.Enabled() && !ifDisabled)) - return; - //The following should be replaced. + //For 'enabled' and 'priority' metadata, use the given plugin's values, but if the 'priority' user value is zero, ignore it. enabled = plugin.Enabled(); - priority = plugin.Priority(); - if (!plugin.Masters().empty()) - masters = plugin.Masters(); - if (!plugin.FormIDs().empty()) - formIDs = plugin.FormIDs(); - if (!isMaster) - isMaster = plugin.IsMaster(); + if (plugin.Priority() != 0) + priority = plugin.Priority(); //Merge the following. If any files in the source already exist in the destination, they will be skipped. Files have display strings and condition strings which aren't considered when comparing them, so will be lost if the plugin being merged in has additional data in these strings. std::set files = plugin.LoadAfter(); @@ -444,8 +436,11 @@ namespace boss { BOOST_LOG_TRIVIAL(trace) << "Calculating metadata difference for: " << name; Plugin p(*this); - if (p.Priority() == plugin.Priority()) - p.Priority(0); //So that non-zero priorities don't get written to the userlist if they're already in the masterlist. + p.Enabled(plugin.Enabled()); + if (priority != plugin.Priority()) + p.Priority(plugin.Priority()); + else + p.Priority(0); //Compare this plugin against the given plugin. set files = plugin.LoadAfter(); diff --git a/src/backend/metadata.h b/src/backend/metadata.h index e3b32d65..992476ea 100644 --- a/src/backend/metadata.h +++ b/src/backend/metadata.h @@ -158,7 +158,13 @@ namespace boss { Plugin(const std::string& name); Plugin(boss::Game& game, const std::string& name, const bool headerOnly); - void Merge(const Plugin& plugin, bool ifdDisabled = false); + //Merges from the given plugin into this one, unless there is already equal metadata present. + //For 'enabled' and 'priority' metadata, use the given plugin's values, but if the 'priority' user value is zero, ignore it. + void MergeMetadata(const Plugin& plugin); + + //Returns the difference in metadata between the two plugins. + //For 'enabled', use the given plugin's value. + //For 'priority', use the given plugin's value, unless it is equal to this plugin's value, in which case return 0. Plugin DiffMetadata(const Plugin& plugin) const; std::string Name() const; diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp index 7e264d02..95ef6d27 100644 --- a/src/gui/editor.cpp +++ b/src/gui/editor.cpp @@ -301,8 +301,9 @@ void Editor::OnPluginSelect(wxListEvent& event) { if (!currentPlugin.empty()) ApplyEdits(currentPlugin); - boss::Plugin plugin = GetUserData(selectedPlugin); - plugin.Merge(GetMasterData(selectedPlugin), true); + //Merge metadata. + boss::Plugin plugin = GetMasterData(selectedPlugin); + plugin.MergeMetadata(GetUserData(selectedPlugin)); //Now fill editor fields with new plugin's info and update control states. BOOST_LOG_TRIVIAL(debug) << "Filling editor fields with plugin info."; @@ -845,10 +846,10 @@ void Editor::OnQuit(wxCommandEvent& event) { void Editor::ApplyEdits(const wxString& plugin) { BOOST_LOG_TRIVIAL(debug) << "Applying edits to plugin: " << plugin.ToUTF8(); - boss::Plugin initial = GetMasterData(plugin); + boss::Plugin master = GetMasterData(plugin); boss::Plugin edited = GetNewData(plugin); - boss::Plugin diff = edited.DiffMetadata(initial); + boss::Plugin diff = master.DiffMetadata(edited); vector::iterator it = std::find(_editedPlugins.begin(), _editedPlugins.end(), diff); diff --git a/src/gui/main.cpp b/src/gui/main.cpp index c3c77181..1d2e0df9 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -601,15 +601,15 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { if (pos != mlist_plugins.end()) { BOOST_LOG_TRIVIAL(trace) << "Merging masterlist data down to plugin list data."; - graph[*vit].Merge(*pos); + graph[*vit].MergeMetadata(*pos); } //Check if there is a plugin entry in the userlist. This will also find matching regex entries. pos = std::find(ulist_plugins.begin(), ulist_plugins.end(), graph[*vit]); - if (pos != ulist_plugins.end()) { + if (pos != ulist_plugins.end() && pos->Enabled()) { BOOST_LOG_TRIVIAL(trace) << "Merging userlist data down to plugin list data."; - graph[*vit].Merge(*pos); + graph[*vit].MergeMetadata(*pos); } progDia->Pulse(); @@ -701,7 +701,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { list::iterator jt = find(ulist_plugins.begin(), ulist_plugins.end(), *it); if (jt != ulist_plugins.end()) { - jt->Merge(*it); + jt->MergeMetadata(*it); } else { ulist_plugins.push_back(*it); } @@ -897,7 +897,7 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { vector::iterator pos = find(installed.begin(), installed.end(), *it); if (pos != installed.end()) - pos->Merge(*it); + pos->MergeMetadata(*it); }