mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Reduce the number of progress updates
Based on which steps actually take long enough to register, and reducing the amount of unnecessary and unhelpful information given.
This commit is contained in:
+5
-5
@@ -167,10 +167,10 @@ LOOT_API unsigned int loot_create_db(loot_db ** const db,
|
||||
const char * const gameLocalPath) {
|
||||
if (db == nullptr
|
||||
|| (clientGame != loot_game_tes4
|
||||
&& clientGame != loot_game_tes5
|
||||
&& clientGame != loot_game_fo3
|
||||
&& clientGame != loot_game_fonv
|
||||
&& clientGame != loot_game_fo4))
|
||||
&& clientGame != loot_game_tes5
|
||||
&& clientGame != loot_game_fo3
|
||||
&& clientGame != loot_game_fonv
|
||||
&& clientGame != loot_game_fo4))
|
||||
return c_error(loot_error_invalid_args, "Null pointer passed.");
|
||||
|
||||
//Set the locale to get encoding conversions working correctly.
|
||||
@@ -336,7 +336,7 @@ LOOT_API unsigned int loot_sort_plugins(loot_db * const db,
|
||||
//Sort plugins into their load order.
|
||||
loot::PluginSorter sorter;
|
||||
|
||||
db->setPluginNames(sorter.Sort(*db, loot_lang_any, [](const std::string& message) {}));
|
||||
db->setPluginNames(sorter.Sort(*db, loot_lang_any));
|
||||
}
|
||||
catch (loot::error &e) {
|
||||
return c_error(e);
|
||||
|
||||
@@ -93,9 +93,7 @@ namespace loot {
|
||||
}
|
||||
};
|
||||
|
||||
std::list<Plugin> PluginSorter::Sort(Game& game,
|
||||
const unsigned int language,
|
||||
std::function<void(const std::string&)> progressCallback) {
|
||||
std::list<Plugin> PluginSorter::Sort(Game& game, const unsigned int language) {
|
||||
// Clear existing data.
|
||||
graph.clear();
|
||||
indexMap.clear();
|
||||
@@ -105,7 +103,6 @@ namespace loot {
|
||||
// state that has been changed by sorting.
|
||||
game.ClearMessages();
|
||||
|
||||
progressCallback(boost::locale::translate("Building plugin graph..."));
|
||||
BuildPluginGraph(game, language);
|
||||
|
||||
// Get the existing load order.
|
||||
@@ -114,9 +111,6 @@ namespace loot {
|
||||
for (const auto &plugin : oldLoadOrder)
|
||||
BOOST_LOG_TRIVIAL(info) << plugin;
|
||||
|
||||
// Now add edges and sort.
|
||||
progressCallback(boost::locale::translate("Adding edges to plugin graph and performing topological sort..."));
|
||||
|
||||
//Now add the interactions between plugins to the graph as edges.
|
||||
BOOST_LOG_TRIVIAL(info) << "Adding edges to plugin graph.";
|
||||
BOOST_LOG_TRIVIAL(debug) << "Adding non-overlap edges.";
|
||||
|
||||
@@ -41,9 +41,7 @@ namespace loot {
|
||||
|
||||
class PluginSorter {
|
||||
public:
|
||||
std::list<Plugin> Sort(Game& game,
|
||||
const unsigned int language,
|
||||
std::function<void(const std::string&)> progressCallback);
|
||||
std::list<Plugin> Sort(Game& game, const unsigned int language);
|
||||
private:
|
||||
PluginGraph graph;
|
||||
std::map<vertex_t, size_t> indexMap;
|
||||
|
||||
+8
-19
@@ -117,6 +117,7 @@ namespace loot {
|
||||
return true;
|
||||
}
|
||||
else if (request == "getGameData") {
|
||||
SendProgressUpdate(frame, loc::translate("Parsing, merging and evaluating metadata..."));
|
||||
return CefPostTask(TID_FILE, base::Bind(&Handler::GetGameData, base::Unretained(this), frame, callback));
|
||||
}
|
||||
else if (request == "cancelFind") {
|
||||
@@ -146,7 +147,7 @@ namespace loot {
|
||||
return true;
|
||||
}
|
||||
else if (request == "updateMasterlist") {
|
||||
return CefPostTask(TID_FILE, base::Bind(&Handler::UpdateMasterlist, base::Unretained(this), frame, callback));
|
||||
return CefPostTask(TID_FILE, base::Bind(&Handler::UpdateMasterlist, base::Unretained(this), callback));
|
||||
}
|
||||
else if (request == "sortPlugins") {
|
||||
return CefPostTask(TID_FILE, base::Bind(&Handler::SortPlugins, base::Unretained(this), frame, callback));
|
||||
@@ -233,7 +234,7 @@ namespace loot {
|
||||
}
|
||||
else if (requestName == "getConflictingPlugins") {
|
||||
// Has one arg, which is the name of the plugin to get conflicts for.
|
||||
CefPostTask(TID_FILE, base::Bind(&Handler::GetConflictingPlugins, base::Unretained(this), request["args"][0].as<string>(), frame, callback));
|
||||
CefPostTask(TID_FILE, base::Bind(&Handler::GetConflictingPlugins, base::Unretained(this), request["args"][0].as<string>(), callback));
|
||||
return true;
|
||||
}
|
||||
else if (requestName == "copyMetadata") {
|
||||
@@ -394,17 +395,14 @@ namespace loot {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Handler::GetConflictingPlugins(const std::string& pluginName, CefRefPtr<CefFrame> frame, CefRefPtr<Callback> callback) {
|
||||
void Handler::GetConflictingPlugins(const std::string& pluginName, CefRefPtr<Callback> callback) {
|
||||
BOOST_LOG_TRIVIAL(debug) << "Searching for plugins that conflict with " << pluginName;
|
||||
|
||||
// Checking for FormID overlap will only work if the plugins have been loaded, so check if
|
||||
// the plugins have been fully loaded, and if not load all plugins.
|
||||
if (!_lootState.CurrentGame().ArePluginsFullyLoaded()) {
|
||||
SendProgressUpdate(frame, loc::translate("Loading plugin contents..."));
|
||||
if (!_lootState.CurrentGame().ArePluginsFullyLoaded())
|
||||
_lootState.CurrentGame().LoadPlugins(false);
|
||||
}
|
||||
|
||||
SendProgressUpdate(frame, loc::translate("Checking for conflicting plugins..."));
|
||||
YAML::Node node;
|
||||
auto plugin = _lootState.CurrentGame().GetPlugin(pluginName);
|
||||
for (const auto& otherPlugin : _lootState.CurrentGame().GetPlugins()) {
|
||||
@@ -625,8 +623,6 @@ namespace loot {
|
||||
BOOST_LOG_TRIVIAL(info) << "Getting data specific to LOOT's active game.";
|
||||
// Get masterlist revision info and parse if it exists. Also get plugin headers info and parse userlist if it exists.
|
||||
|
||||
SendProgressUpdate(frame, loc::translate("Loading plugin headers..."));
|
||||
|
||||
// First clear CRC and condition caches, otherwise they could lead to incorrect evaluations.
|
||||
_lootState.CurrentGame().ClearCachedConditions();
|
||||
|
||||
@@ -647,7 +643,6 @@ namespace loot {
|
||||
if (isFirstLoad) {
|
||||
//Parse masterlist, don't update it.
|
||||
if (fs::exists(_lootState.CurrentGame().MasterlistPath())) {
|
||||
SendProgressUpdate(frame, loc::translate("Parsing masterlist..."));
|
||||
BOOST_LOG_TRIVIAL(debug) << "Parsing masterlist.";
|
||||
try {
|
||||
_lootState.CurrentGame().GetMasterlist().Load(_lootState.CurrentGame().MasterlistPath());
|
||||
@@ -664,7 +659,6 @@ namespace loot {
|
||||
|
||||
//Parse userlist.
|
||||
if (fs::exists(_lootState.CurrentGame().UserlistPath())) {
|
||||
SendProgressUpdate(frame, loc::translate("Parsing userlist..."));
|
||||
BOOST_LOG_TRIVIAL(debug) << "Parsing userlist.";
|
||||
try {
|
||||
_lootState.CurrentGame().GetUserlist().Load(_lootState.CurrentGame().UserlistPath());
|
||||
@@ -708,11 +702,9 @@ namespace loot {
|
||||
}
|
||||
|
||||
// Now store global messages.
|
||||
SendProgressUpdate(frame, loc::translate("Loading general messages..."));
|
||||
gameNode["globalMessages"] = GetGeneralMessages();
|
||||
|
||||
// Now store plugin data.
|
||||
SendProgressUpdate(frame, loc::translate("Merging and evaluating plugin metadata..."));
|
||||
for (const auto& plugin : installed) {
|
||||
/* Each plugin has members while hold its raw masterlist and userlist data for
|
||||
the editor, and also processed data for the main display.
|
||||
@@ -789,13 +781,12 @@ namespace loot {
|
||||
}
|
||||
}
|
||||
|
||||
void Handler::UpdateMasterlist(CefRefPtr<CefFrame> frame, CefRefPtr<Callback> callback) {
|
||||
void Handler::UpdateMasterlist(CefRefPtr<Callback> callback) {
|
||||
try {
|
||||
// Update / parse masterlist.
|
||||
BOOST_LOG_TRIVIAL(debug) << "Updating and parsing masterlist.";
|
||||
bool wasChanged = true;
|
||||
try {
|
||||
SendProgressUpdate(frame, loc::translate("Updating and parsing masterlist..."));
|
||||
wasChanged = _lootState.CurrentGame().GetMasterlist().Update(_lootState.CurrentGame());
|
||||
}
|
||||
catch (loot::error &e) {
|
||||
@@ -817,7 +808,6 @@ namespace loot {
|
||||
}
|
||||
|
||||
// Now regenerate the JS-side masterlist data if the masterlist was changed.
|
||||
SendProgressUpdate(frame, loc::translate("Regenerating displayed content..."));
|
||||
if (wasChanged) {
|
||||
// The data structure is to be set as 'loot.game'.
|
||||
YAML::Node gameNode;
|
||||
@@ -918,10 +908,9 @@ namespace loot {
|
||||
_lootState.CurrentGame().LoadPlugins(false);
|
||||
|
||||
//Sort plugins into their load order.
|
||||
SendProgressUpdate(frame, loc::translate("Sorting load order..."));
|
||||
PluginSorter sorter;
|
||||
list<Plugin> plugins = sorter.Sort(_lootState.CurrentGame(), _lootState.getLanguage().Code(), [this, frame](const string& message) {
|
||||
this->SendProgressUpdate(frame, message);
|
||||
});
|
||||
list<Plugin> plugins = sorter.Sort(_lootState.CurrentGame(), _lootState.getLanguage().Code());
|
||||
|
||||
YAML::Node node;
|
||||
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ namespace loot {
|
||||
std::string GetGameTypes();
|
||||
std::string GetInstalledGames();
|
||||
void GetGameData(CefRefPtr<CefFrame> frame, CefRefPtr<Callback> callback);
|
||||
void UpdateMasterlist(CefRefPtr<CefFrame> frame, CefRefPtr<Callback> callback);
|
||||
void UpdateMasterlist(CefRefPtr<Callback> callback);
|
||||
std::string ClearAllMetadata();
|
||||
void SortPlugins(CefRefPtr<CefFrame> frame, CefRefPtr<Callback> callback);
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace loot {
|
||||
YAML::Node& request,
|
||||
CefRefPtr<Callback> callback);
|
||||
|
||||
void GetConflictingPlugins(const std::string& pluginName, CefRefPtr<CefFrame> frame, CefRefPtr<Callback> callback);
|
||||
void GetConflictingPlugins(const std::string& pluginName, CefRefPtr<Callback> callback);
|
||||
void CopyMetadata(const std::string& pluginName);
|
||||
std::string ClearPluginMetadata(const std::string& pluginName);
|
||||
std::string ApplyUserEdits(const YAML::Node& pluginMetadata);
|
||||
|
||||
@@ -18,7 +18,6 @@ function onChangeGame(evt) {
|
||||
return;
|
||||
}
|
||||
/* Send off a CEF query with the folder name of the new game. */
|
||||
loot.Dialog.showProgress(loot.l10n.translate('Loading game data...'));
|
||||
loot.query('changeGame', evt.detail.item.getAttribute('value')).then((result) => {
|
||||
/* Filters should be re-applied on game change, except the conflicts
|
||||
filter. Don't need to deactivate the others beforehand. Strictly not
|
||||
@@ -48,7 +47,8 @@ function onChangeGame(evt) {
|
||||
}).catch(handlePromiseError);
|
||||
}
|
||||
/* Masterlist update process, minus progress dialog. */
|
||||
function updateMasterlistNoProgress() {
|
||||
function updateMasterlist() {
|
||||
loot.Dialog.showProgress('Updating and parsing masterlist...');
|
||||
return loot.query('updateMasterlist').then(JSON.parse).then((result) => {
|
||||
if (result) {
|
||||
/* Update JS variables. */
|
||||
@@ -76,8 +76,7 @@ function updateMasterlistNoProgress() {
|
||||
}).catch(handlePromiseError);
|
||||
}
|
||||
function onUpdateMasterlist() {
|
||||
loot.Dialog.showProgress(loot.l10n.translate('Updating masterlist...'));
|
||||
updateMasterlistNoProgress().then(() => {
|
||||
updateMasterlist().then(() => {
|
||||
loot.Dialog.closeProgress();
|
||||
}).catch(handlePromiseError);
|
||||
}
|
||||
@@ -89,10 +88,9 @@ function onSortPlugins() {
|
||||
|
||||
let promise = Promise.resolve();
|
||||
if (loot.settings.updateMasterlist) {
|
||||
promise = promise.then(updateMasterlistNoProgress);
|
||||
promise = promise.then(updateMasterlist);
|
||||
}
|
||||
promise.then(() => {
|
||||
loot.Dialog.showProgress(loot.l10n.translate('Sorting plugins...'));
|
||||
return loot.query('sortPlugins').then(JSON.parse);
|
||||
}).then((result) => {
|
||||
if (!result) {
|
||||
@@ -309,7 +307,6 @@ function onCopyLoadOrder() {
|
||||
}
|
||||
function onContentRefresh() {
|
||||
/* Send a query for updated load order and plugin header info. */
|
||||
loot.Dialog.showProgress(loot.l10n.translate('Refreshing data...'));
|
||||
loot.query('getGameData').then((result) => {
|
||||
/* Parse the data sent from C++. */
|
||||
const game = JSON.parse(result, loot.Plugin.fromJson);
|
||||
|
||||
@@ -11,7 +11,7 @@ function getConflictingPlugins(pluginName) {
|
||||
}
|
||||
|
||||
/* Now get conflicts for the plugin. */
|
||||
loot.Dialog.showProgress(loot.l10n.translate('Checking if plugins have been loaded...'));
|
||||
loot.Dialog.showProgress(loot.l10n.translate('Identifying conflicting plugins...'));
|
||||
|
||||
return loot.query('getConflictingPlugins', pluginName).then(JSON.parse).then((result) => {
|
||||
const conflicts = [pluginName];
|
||||
|
||||
@@ -36,8 +36,6 @@ protected:
|
||||
game = loot::Game(loot::Game::tes5);
|
||||
game.SetGamePath(dataPath.parent_path());
|
||||
ASSERT_NO_THROW(game.Init(false, localPath));
|
||||
|
||||
callback = [](const std::string&) {};
|
||||
}
|
||||
|
||||
inline std::list<std::string> GetExpectedSortedOrder() const {
|
||||
@@ -73,7 +71,7 @@ protected:
|
||||
|
||||
TEST_F(PluginSorter, Sort_NoPlugins) {
|
||||
loot::PluginSorter ps;
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english);
|
||||
EXPECT_TRUE(sorted.empty());
|
||||
}
|
||||
|
||||
@@ -83,11 +81,11 @@ TEST_F(PluginSorter, Sort) {
|
||||
loot::PluginSorter ps;
|
||||
std::list<std::string> expectedSortedOrder = GetExpectedSortedOrder();
|
||||
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english);
|
||||
EXPECT_TRUE(std::equal(begin(sorted), end(sorted), begin(expectedSortedOrder)));
|
||||
|
||||
// Check stability.
|
||||
sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
sorted = ps.Sort(game, loot::Language::english);
|
||||
EXPECT_TRUE(std::equal(begin(sorted), end(sorted), begin(expectedSortedOrder)));
|
||||
}
|
||||
|
||||
@@ -97,7 +95,7 @@ TEST_F(PluginSorter, sortingShouldClearExistingGameMessages) {
|
||||
ASSERT_FALSE(game.GetMessages().empty());
|
||||
|
||||
loot::PluginSorter ps;
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english);
|
||||
EXPECT_TRUE(game.GetMessages().empty());
|
||||
}
|
||||
|
||||
@@ -110,7 +108,7 @@ TEST_F(PluginSorter, failedSortShouldNotClearExistingGameMessages) {
|
||||
ASSERT_FALSE(game.GetMessages().empty());
|
||||
|
||||
loot::PluginSorter ps;
|
||||
EXPECT_ANY_THROW(ps.Sort(game, loot::Language::english, callback));
|
||||
EXPECT_ANY_THROW(ps.Sort(game, loot::Language::english));
|
||||
EXPECT_FALSE(game.GetMessages().empty());
|
||||
}
|
||||
|
||||
@@ -120,7 +118,7 @@ TEST_F(PluginSorter, Sort_HeadersOnly) {
|
||||
loot::PluginSorter ps;
|
||||
std::list<std::string> expectedSortedOrder = GetExpectedSortedOrder();
|
||||
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english);
|
||||
EXPECT_TRUE(std::equal(begin(sorted), end(sorted), begin(expectedSortedOrder)));
|
||||
}
|
||||
|
||||
@@ -146,7 +144,7 @@ TEST_F(PluginSorter, Sort_WithPriority) {
|
||||
"Blank - Different Plugin Dependent.esp",
|
||||
});
|
||||
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english);
|
||||
EXPECT_TRUE(std::equal(begin(sorted), end(sorted), begin(expectedSortedOrder)));
|
||||
}
|
||||
|
||||
@@ -197,7 +195,7 @@ TEST_F(PluginSorter, sortingWithPrioritiesShouldInheritRecursivelyRegardlessOfEv
|
||||
"Blank - Different Plugin Dependent.esp",
|
||||
});
|
||||
|
||||
std::list<std::string> actualSortedOrder = GetActualSortedOrder(ps.Sort(game, loot::Language::english, callback));
|
||||
std::list<std::string> actualSortedOrder = GetActualSortedOrder(ps.Sort(game, loot::Language::english));
|
||||
EXPECT_EQ(expectedSortedOrder, actualSortedOrder);
|
||||
}
|
||||
|
||||
@@ -225,7 +223,7 @@ TEST_F(PluginSorter, Sort_WithLoadAfter) {
|
||||
"Blank - Plugin Dependent.esp",
|
||||
});
|
||||
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english);
|
||||
EXPECT_TRUE(std::equal(begin(sorted), end(sorted), begin(expectedSortedOrder)));
|
||||
}
|
||||
|
||||
@@ -253,7 +251,7 @@ TEST_F(PluginSorter, Sort_WithRequirements) {
|
||||
"Blank - Plugin Dependent.esp",
|
||||
});
|
||||
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english);
|
||||
EXPECT_TRUE(std::equal(begin(sorted), end(sorted), begin(expectedSortedOrder)));
|
||||
}
|
||||
|
||||
@@ -264,7 +262,7 @@ TEST_F(PluginSorter, Sort_HasCycle) {
|
||||
game.GetUserlist().AddPlugin(plugin);
|
||||
|
||||
loot::PluginSorter ps;
|
||||
EXPECT_ANY_THROW(ps.Sort(game, loot::Language::english, callback));
|
||||
EXPECT_ANY_THROW(ps.Sort(game, loot::Language::english));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user