Some mostly backend changes.

Metadata editor now lists plugins in their load order though.
This commit is contained in:
WrinklyNinja
2014-03-21 00:00:38 +00:00
parent 81cc91109f
commit c2eddf2140
6 changed files with 33 additions and 33 deletions
+21 -5
View File
@@ -313,7 +313,7 @@ namespace loot {
return activePlugins.find(boost::to_lower_copy(plugin)) != activePlugins.end();
}
void Game::GetLoadOrder(std::list<Plugin>& loadOrder) const {
void Game::GetLoadOrder(std::list<std::string>& loadOrder) const {
BOOST_LOG_TRIVIAL(trace) << "Setting load order for game: " << _name;
lo_game_handle gh;
@@ -480,21 +480,21 @@ namespace loot {
if (id != tes5)
return;
list<loot::Plugin> loadorder;
list<string> loadorder;
GetLoadOrder(loadorder);
if (!loadorder.empty()) {
time_t lastTime, thisTime;
fs::path filepath = DataPath() / loadorder.begin()->Name();
fs::path filepath = DataPath() / *loadorder.begin();
if (!fs::exists(filepath) && fs::exists(filepath.string() + ".ghost"))
filepath += ".ghost";
lastTime = fs::last_write_time(filepath);
for (list<loot::Plugin>::const_iterator it = loadorder.begin(), itend = loadorder.end(); it != itend; ++it) {
for (list<string>::const_iterator it = loadorder.begin(), itend = loadorder.end(); it != itend; ++it) {
filepath = DataPath() / it->Name();
filepath = DataPath() / *it;
if (!fs::exists(filepath) && fs::exists(filepath.string() + ".ghost"))
filepath += ".ghost";
@@ -513,6 +513,22 @@ namespace loot {
}
}
void Game::LoadPlugins(bool headersOnly) {
//Add all plugins in data folder not already in the hashset to the hashset, and load them.
for (fs::directory_iterator it(DataPath()); it != fs::directory_iterator(); ++it) {
if (fs::is_regular_file(it->status()) && IsPlugin(it->path().string())) {
const string filename = it->path().filename().string();
if (plugins.find(filename) == plugins.end())
plugins.insert(std::pair<string, Plugin>(filename, Plugin(filename)));
}
}
for (boost::unordered_map<string, Plugin>::iterator it = plugins.begin(), itend = plugins.end(); it != itend; ++it) {
it->second = Plugin(*this, it->second.Name(), headersOnly);
}
}
void Game::CreateLOOTGameFolder() {
//Make sure that the LOOT game path exists.
try {
+3 -2
View File
@@ -85,11 +85,12 @@ namespace loot {
bool IsActive(const std::string& plugin) const;
void GetLoadOrder(std::list<Plugin>& loadOrder) const;
void GetLoadOrder(std::list<std::string>& loadOrder) const;
void SetLoadOrder(const std::list<Plugin>& loadOrder) const; //Modifies game load order, even though const.
void RefreshActivePluginsList();
void RedatePlugins(); //Change timestamps to match load order (Skyrim only).
void LoadPlugins(bool headersOnly); //Loads all installed plugins.
//Caches for condition results, active plugins and CRCs.
boost::unordered_map<std::string, bool> conditionCache; //Holds lowercased strings.
@@ -98,7 +99,7 @@ namespace loot {
//Plugin data and metadata lists.
MetadataList masterlist;
MetadataList userlist;
boost::unordered_set<Plugin, plugin_hash> plugins;
boost::unordered_map<std::string, Plugin> plugins; //Map so that plugin data can be edited.
espm::Settings espm_settings;
-11
View File
@@ -795,17 +795,6 @@ namespace loot {
return rhs == lhs;
}
bool alpha_sort(const Plugin& lhs, const Plugin& rhs) {
return boost::ilexicographical_compare(rhs.Name(), lhs.Name());
}
bool master_sort(const Plugin& lhs, const Plugin& rhs) {
if (lhs.IsMaster() && !rhs.IsMaster())
return true;
else
return false;
}
bool IsPlugin(const std::string& file) {
if (boost::iends_with(file, ".esp") || boost::iends_with(file, ".esm")
|| boost::iends_with(file, ".esp.ghost") || boost::iends_with(file, ".esm.ghost"))
-4
View File
@@ -260,10 +260,6 @@ namespace loot {
bool operator == (const std::string& lhs, const Plugin& rhs);
bool alpha_sort(const Plugin& lhs, const Plugin& rhs);
bool master_sort(const Plugin& lhs, const Plugin& rhs);
bool IsPlugin(const std::string& file);
}
+1
View File
@@ -649,6 +649,7 @@ Editor::Editor(wxWindow *parent, const wxString& title, const std::string userli
if (std::find(_editedPlugins.begin(), _editedPlugins.end(), *it) != _editedPlugins.end()) {
pluginList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold());
}
++i;
}
pluginList->SetColumnWidth(0, wxLIST_AUTOSIZE);
+8 -11
View File
@@ -955,12 +955,15 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) {
//Scan for installed plugins.
BOOST_LOG_TRIVIAL(debug) << "Reading installed plugins' headers.";
for (fs::directory_iterator it(_game.DataPath()); it != fs::directory_iterator(); ++it) {
if (fs::is_regular_file(it->status()) && IsPlugin(it->path().string())) {
installed.push_back(loot::Plugin(_game, it->path().filename().string(), true));
_game.LoadPlugins(true);
//Sort plugins into their load order.
list<string> loadOrder;
_game.GetLoadOrder(loadOrder);
for (list<string>::const_iterator it = loadOrder.begin(), itend = loadOrder.end(); it != itend; ++it) {
boost::unordered_map<string, loot::Plugin>::const_iterator pos = _game.plugins.find(*it);
progDia->Pulse();
}
if (pos != _game.plugins.end())
installed.push_back(pos->second);
}
//Parse masterlist.
@@ -1027,12 +1030,6 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) {
progDia->Pulse();
//Sort into alphabetical order.
BOOST_LOG_TRIVIAL(debug) << "Sorting plugin list into alphabetical order.";
installed.sort(loot::alpha_sort);
progDia->Pulse();
//Set language.
unsigned int lang;
if (_settings["Language"])