mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Fixes issue #103 fix.
This commit is contained in:
@@ -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<File> 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<File> files = plugin.LoadAfter();
|
||||
|
||||
@@ -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;
|
||||
|
||||
+5
-4
@@ -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<boss::Plugin>::iterator it = std::find(_editedPlugins.begin(), _editedPlugins.end(), diff);
|
||||
|
||||
|
||||
+5
-5
@@ -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<boss::Plugin>::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<boss::Plugin>::iterator pos = find(installed.begin(), installed.end(), *it);
|
||||
|
||||
if (pos != installed.end())
|
||||
pos->Merge(*it);
|
||||
pos->MergeMetadata(*it);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user