Refactor JS<->C++ query execution

Use Query-based classes to contain the actual execution logic.
This commit is contained in:
Oliver Hamlet
2016-09-10 10:57:33 +01:00
parent f136fbf74f
commit e0907a33ce
33 changed files with 2314 additions and 997 deletions
+30
View File
@@ -234,6 +234,36 @@ set (LOOT_GUI_HEADERS "${CMAKE_SOURCE_DIR}/src/gui/editor_message.h"
"${CMAKE_SOURCE_DIR}/src/gui/loot_handler.h"
"${CMAKE_SOURCE_DIR}/src/gui/loot_app.h"
"${CMAKE_SOURCE_DIR}/src/gui/loot_scheme_handler_factory.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/apply_sort_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/cancel_find_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/cancel_sort_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/change_game_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/clear_all_metadata_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/clear_plugin_metadata_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/clipboard_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/close_settings_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/copy_content_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/copy_load_order_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/copy_metadata_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/discard_unapplied_changes_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/editor_opened_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/editor_closed_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/get_conflicting_plugins_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/get_game_data_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/get_game_types_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/get_init_errors_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/get_installed_games_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/get_languages_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/get_settings_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/get_version_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/metadata_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/open_log_location_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/open_readme_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/redate_plugins_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/save_filter_state_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/sort_plugins_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query/update_masterlist_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/query_handler.h"
"${CMAKE_SOURCE_DIR}/src/gui/resource.h"
"${CMAKE_SOURCE_DIR}/src/gui/yaml_simple_message_helpers.h")
+49
View File
@@ -0,0 +1,49 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_APPLY_SORT_QUERY
#define LOOT_GUI_QUERY_APPLY_SORT_QUERY
#include "gui/query/query.h"
namespace loot {
class ApplySortQuery : public Query {
public:
ApplySortQuery(LootState& state, const std::vector<std::string>& plugins) :
state_(state), plugins_(plugins) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
BOOST_LOG_TRIVIAL(trace) << "User has accepted sorted load order, applying it.";
state_.decrementUnappliedChangeCounter();
state_.getCurrentGame().SetLoadOrder(plugins_);
callback->Success("");
}
private:
LootState& state_;
std::vector<std::string> plugins_;
};
}
#endif
+47
View File
@@ -0,0 +1,47 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_CANCEL_FIND_QUERY
#define LOOT_GUI_QUERY_CANCEL_FIND_QUERY
#include <include/cef_browser.h>
#include "gui/query/query.h"
namespace loot {
class CancelFindQuery : public Query {
public:
CancelFindQuery(CefRefPtr<CefBrowser> browser) : browser_(browser) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
browser_->GetHost()->StopFinding(true);
callback->Success("");
}
private:
CefRefPtr<CefBrowser> browser_;
};
}
#endif
+52
View File
@@ -0,0 +1,52 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_CANCEL_SORT_QUERY
#define LOOT_GUI_QUERY_CANCEL_SORT_QUERY
#include "backend/app/loot_state.h"
#include "backend/helpers/json.h"
#include "gui/query/metadata_query.h"
namespace loot {
class CancelSortQuery : public MetadataQuery {
public:
CancelSortQuery(LootState& state) :
MetadataQuery(state.getCurrentGame(), state.getLanguage().GetCode()),
state_(state) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
state_.decrementUnappliedChangeCounter();
state_.getCurrentGame().DecrementLoadOrderSortCount();
YAML::Node node(getGeneralMessages());
callback->Success(JSON::stringify(node));
}
private:
LootState& state_;
};
}
#endif
+53
View File
@@ -0,0 +1,53 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_CHANGE_GAME_QUERY
#define LOOT_GUI_QUERY_CHANGE_GAME_QUERY
#include <boost/locale.hpp>
#include "backend/helpers/json.h"
#include "gui/query/get_game_data_query.h"
namespace loot {
class ChangeGameQuery : public GetGameDataQuery {
public:
ChangeGameQuery(LootState& state, CefRefPtr<CefFrame> frame, const std::string& gameFolder) :
GetGameDataQuery(state, frame),
state_(state),
gameFolder_(gameFolder) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
state_.changeGame(gameFolder_);
GetGameDataQuery::execute(callback);
}
private:
LootState& state_;
const std::string gameFolder_;
};
}
#endif
+83
View File
@@ -0,0 +1,83 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_CLEAR_ALL_METADATA_QUERY
#define LOOT_GUI_QUERY_CLEAR_ALL_METADATA_QUERY
#include "backend/game/game.h"
#include "backend/helpers/json.h"
#include "gui/query/metadata_query.h"
namespace loot {
class ClearAllMetadataQuery : public MetadataQuery {
public:
ClearAllMetadataQuery(LootState& state) :
MetadataQuery(state.getCurrentGame(), state.getLanguage().GetCode()),
game_(state.getCurrentGame()) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
BOOST_LOG_TRIVIAL(debug) << "Clearing all user metadata.";
// Record which plugins have userlist entries.
auto userlistPluginNames = getUserlistPluginNames();
// Clear the user metadata.
game_.GetUserlist().Clear();
game_.GetUserlist().Save(game_.UserlistPath());
BOOST_LOG_TRIVIAL(trace) << "Rederiving display metadata for " << userlistPluginNames.size() << " plugins that had user metadata.";
callback->Success(getDerivedMetadataJson(userlistPluginNames));
}
private:
std::vector<std::string> getUserlistPluginNames() const {
auto userlistPlugins = game_.GetUserlist().Plugins();
std::vector<std::string> userlistPluginNames(userlistPlugins.size());
std::transform(begin(userlistPlugins),
end(userlistPlugins),
begin(userlistPluginNames),
[](const PluginMetadata& plugin) {
return plugin.Name();
});
return userlistPluginNames;
}
std::string getDerivedMetadataJson(const std::vector<std::string>& userlistPluginNames) {
YAML::Node pluginsNode;
for (const auto &pluginName : userlistPluginNames) {
pluginsNode.push_back(generateDerivedMetadata(pluginName));
}
if (pluginsNode.size() > 0)
return JSON::stringify(pluginsNode);
else
return "[]";
}
Game& game_;
};
}
#endif
@@ -0,0 +1,60 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_CLEAR_PLUGIN_METADATA_QUERY
#define LOOT_GUI_QUERY_CLEAR_PLUGIN_METADATA_QUERY
#include "backend/game/game.h"
#include "backend/helpers/json.h"
#include "gui/query/metadata_query.h"
namespace loot {
class ClearPluginMetadataQuery : public MetadataQuery {
public:
ClearPluginMetadataQuery(LootState& state, const std::string& pluginName) :
MetadataQuery(state.getCurrentGame(), state.getLanguage().GetCode()),
game_(state.getCurrentGame()),
pluginName_(pluginName) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
BOOST_LOG_TRIVIAL(debug) << "Clearing user metadata for plugin " << pluginName_;
game_.GetUserlist().ErasePlugin(PluginMetadata(pluginName_));
game_.GetUserlist().Save(game_.UserlistPath());
// Now rederive the displayed metadata from the masterlist.
YAML::Node derivedMetadata = generateDerivedMetadata(pluginName_);
if (derivedMetadata.size() > 0)
callback->Success(JSON::stringify(derivedMetadata));
else
callback->Success("null");
}
private:
Game& game_;
std::string pluginName_;
};
}
#endif
+64
View File
@@ -0,0 +1,64 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_CLIPBOARD_QUERY
#define LOOT_GUI_QUERY_CLIPBOARD_QUERY
#include "backend/helpers/helpers.h"
#include "gui/query/query.h"
#include "loot/error.h"
namespace loot {
class ClipboardQuery : public Query {
protected:
void copyToClipboard(const std::string& text) {
#ifdef _WIN32
if (!OpenClipboard(NULL)) {
throw Error(Error::Code::windows_error, "Failed to open the Windows clipboard.");
}
if (!EmptyClipboard()) {
throw Error(Error::Code::windows_error, "Failed to empty the Windows clipboard.");
}
// The clipboard takes a Unicode (ie. UTF-16) string that it then owns and must not
// be destroyed by LOOT. Convert the string, then copy it into a new block of
// memory for the clipboard.
std::wstring wtext = ToWinWide(text);
wchar_t * wcstr = new wchar_t[wtext.length() + 1];
wcscpy(wcstr, wtext.c_str());
if (SetClipboardData(CF_UNICODETEXT, wcstr) == NULL) {
throw Error(Error::Code::windows_error, "Failed to copy metadata to the Windows clipboard.");
}
if (!CloseClipboard()) {
throw Error(Error::Code::windows_error, "Failed to close the Windows clipboard.");
}
#endif
}
};
}
#endif
+50
View File
@@ -0,0 +1,50 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_CLOSE_SETTINGS_QUERY
#define LOOT_GUI_QUERY_CLOSE_SETTINGS_QUERY
#include "backend/app/loot_state.h"
#include "gui/query/get_installed_games_query.h"
namespace loot {
class CloseSettingsQuery : public GetInstalledGamesQuery {
public:
CloseSettingsQuery(LootState& state, YAML::Node settings) :
GetInstalledGamesQuery(state), state_(state), settings_(settings) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
BOOST_LOG_TRIVIAL(trace) << "Settings dialog closed and changes accepted, updating settings object.";
state_.load(settings_);
GetInstalledGamesQuery::execute(callback);
}
private:
LootState& state_;
YAML::Node settings_;
};
}
#endif
+60
View File
@@ -0,0 +1,60 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_COPY_CONTENT_QUERY
#define LOOT_GUI_QUERY_COPY_CONTENT_QUERY
#include <yaml-cpp/yaml.h>
#include "gui/query/clipboard_query.h"
namespace loot {
class CopyContentQuery : public ClipboardQuery {
public:
CopyContentQuery(const YAML::Node& content) : content_(content) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
std::string text = "[spoiler][code]" + getContentAsText() + "[/code][/spoiler]";
copyToClipboard(text);
callback->Success("");
}
private:
std::string getContentAsText() const {
YAML::Emitter out;
out.SetIndent(2);
out << content_;
std::string text = out.c_str();
boost::replace_all(text, "!<!> ", "");
return text;
}
YAML::Node content_;
};
}
#endif
+74
View File
@@ -0,0 +1,74 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_COPY_LOAD_ORDER_QUERY
#define LOOT_GUI_QUERY_COPY_LOAD_ORDER_QUERY
#include "gui/query/clipboard_query.h"
namespace loot {
class CopyLoadOrderQuery : public ClipboardQuery {
public:
CopyLoadOrderQuery(LootState& state, const std::vector<std::string>& plugins) :
state_(state), plugins_(plugins) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
int numberOfIndexDigits = getNumberOfIndexDigits();
size_t activeIndex = 0;
std::stringstream stream;
for (const auto& pluginName : plugins_) {
activeIndex += writePluginLine(stream, pluginName, activeIndex);
}
copyToClipboard(stream.str());
callback->Success("");
}
private:
unsigned short getNumberOfIndexDigits() const {
if (plugins_.size() > 99)
return 3;
else if (plugins_.size() > 9)
return 2;
else
return 1;
}
size_t writePluginLine(std::ostream& stream, const std::string& plugin, size_t activeIndex) {
if (state_.getCurrentGame().IsPluginActive(plugin)) {
stream << std::setw(getNumberOfIndexDigits()) << activeIndex << " " << std::hex << std::setw(2) << activeIndex << std::dec << " " << plugin << "\r\n";
return 1;
}
stream << std::setw(getNumberOfIndexDigits() + 4) << " " << plugin << "\r\n";
return 0;
}
LootState& state_;
std::vector<std::string> plugins_;
};
}
#endif
+70
View File
@@ -0,0 +1,70 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_COPY_METADATA_QUERY
#define LOOT_GUI_QUERY_COPY_METADATA_QUERY
#include <yaml-cpp/yaml.h>
#include "gui/query/clipboard_query.h"
namespace loot {
class CopyMetadataQuery : public ClipboardQuery {
public:
CopyMetadataQuery(LootState& state, const std::string& pluginName) :
state_(state), pluginName_(pluginName) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
BOOST_LOG_TRIVIAL(debug) << "Copying metadata for plugin " << pluginName_;
// Get metadata from masterlist and userlist.
PluginMetadata metadata = state_.getCurrentGame().GetMasterlist().FindPlugin(pluginName_);
metadata.MergeMetadata(state_.getCurrentGame().GetUserlist().FindPlugin(pluginName_));
// Generate text representation.
std::string text = "[spoiler][code]" + asText(metadata) + "[/code][/spoiler]";
copyToClipboard(text);
BOOST_LOG_TRIVIAL(info) << "Exported userlist metadata text for \"" << pluginName_ << "\": " << text;
}
private:
static std::string asText(const PluginMetadata& metadata) {
YAML::Emitter out;
out.SetIndent(2);
out << metadata;
std::string text = out.c_str();
boost::replace_all(text, "!<!> ", "");
return text;
}
LootState& state_;
std::string pluginName_;
};
}
#endif
@@ -0,0 +1,47 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_DISCARD_UNAPPLIED_CHANGES_QUERY
#define LOOT_GUI_QUERY_DISCARD_UNAPPLIED_CHANGES_QUERY
#include "backend/app/loot_state.h"
#include "gui/query/query.h"
namespace loot {
class DiscardUnappliedChangesQuery : public Query {
public:
DiscardUnappliedChangesQuery(LootState& state) : state_(state) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
while (state_.hasUnappliedChanges())
state_.decrementUnappliedChangeCounter();
callback->Success("");
}
private:
LootState& state_;
};
}
#endif
+176
View File
@@ -0,0 +1,176 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_EDITOR_CLOSED_QUERY
#define LOOT_GUI_QUERY_EDITOR_CLOSED_QUERY
#include "backend/app/loot_state.h"
#include "gui/query/metadata_query.h"
namespace loot {
class EditorClosedQuery : public MetadataQuery {
public:
EditorClosedQuery(LootState& state, YAML::Node metadata) :
MetadataQuery(state.getCurrentGame(), state.getLanguage().GetCode()),
state_(state), metadata_(metadata) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
try {
callback->Success(applyUserEdits());
} catch (Error&) {
throw;
} catch (std::exception& e) {
// If this was a YAML conversion error, cut off the line and column numbers,
// since the YAML wasn't written to a file.
std::string error = e.what();
size_t pos = std::string::npos;
if ((pos = error.find("bad conversion")) != std::string::npos) {
error = error.substr(pos);
}
throw std::runtime_error(error);
}
state_.decrementUnappliedChangeCounter();
}
private:
static PluginMetadata convertMetadata(YAML::Node& newMetadata, PluginMetadata& existingUserMetadata) {
PluginMetadata newUserlistEntry(existingUserMetadata.Name());
// First sort out the priority value. This is only given if it was changed.
BOOST_LOG_TRIVIAL(trace) << "Calculating userlist metadata local priority value from Javascript variables.";
if (newMetadata["priority"]) {
BOOST_LOG_TRIVIAL(trace) << "Local priority value was changed, recalculating...";
// Priority value was changed, so add it to the userlist data.
newUserlistEntry.LocalPriority(Priority(newMetadata["priority"].as<int>()));
} else {
// Priority value wasn't changed, use the existing userlist value.
BOOST_LOG_TRIVIAL(trace) << "Local priority value is unchanged, using existing userlist value (if it exists).";
newUserlistEntry.LocalPriority(existingUserMetadata.LocalPriority());
}
if (newMetadata["globalPriority"]) {
BOOST_LOG_TRIVIAL(trace) << "Global priority value was changed, recalculating...";
// Priority value was changed, so add it to the userlist data.
newUserlistEntry.GlobalPriority(Priority(newMetadata["globalPriority"].as<int>()));
} else {
BOOST_LOG_TRIVIAL(trace) << "Global priority value is unchanged, using existing userlist value (if it exists).";
newUserlistEntry.GlobalPriority(existingUserMetadata.GlobalPriority());
}
// Now the enabled flag.
newUserlistEntry.Enabled(newMetadata["userlist"]["enabled"].as<bool>());
// Now metadata lists. These are given in their entirety, so replace anything that
// currently exists.
BOOST_LOG_TRIVIAL(trace) << "Recording metadata lists from Javascript variables.";
if (newMetadata["userlist"]["after"])
newUserlistEntry.LoadAfter(newMetadata["userlist"]["after"].as<std::set<File>>());
if (newMetadata["userlist"]["req"])
newUserlistEntry.Reqs(newMetadata["userlist"]["req"].as<std::set<File>>());
if (newMetadata["userlist"]["inc"])
newUserlistEntry.Incs(newMetadata["userlist"]["inc"].as<std::set<File>>());
if (newMetadata["userlist"]["msg"])
newUserlistEntry.Messages(toMessages(newMetadata["userlist"]["msg"].as<std::vector<EditorMessage>>()));
if (newMetadata["userlist"]["tag"])
newUserlistEntry.Tags(newMetadata["userlist"]["tag"].as<std::set<Tag>>());
if (newMetadata["userlist"]["dirty"])
newUserlistEntry.DirtyInfo(newMetadata["userlist"]["dirty"].as<std::set<PluginCleaningData>>());
if (newMetadata["userlist"]["clean"])
newUserlistEntry.CleanInfo(newMetadata["userlist"]["clean"].as<std::set<PluginCleaningData>>());
if (newMetadata["userlist"]["url"])
newUserlistEntry.Locations(newMetadata["userlist"]["url"].as<std::set<Location>>());
return newUserlistEntry;
}
PluginMetadata getUniqueMetadata(const PluginMetadata& metadata) {
BOOST_LOG_TRIVIAL(trace) << "Removing any user metadata that duplicates masterlist metadata.";
try {
Plugin tempPlugin(state_.getCurrentGame().GetPlugin(metadata.Name()));
tempPlugin.MergeMetadata(state_.getCurrentGame().GetMasterlist().FindPlugin(metadata));
return metadata.NewMetadata(tempPlugin);
} catch (...) {
return metadata.NewMetadata(state_.getCurrentGame().GetMasterlist().FindPlugin(metadata));
}
}
std::string applyUserEdits() {
if (!metadata_.IsMap()) // No edits to apply.
return "null";
const std::string pluginName = metadata_["name"].as<std::string>();
BOOST_LOG_TRIVIAL(trace) << "Applying user edits for: " << pluginName;
// Find existing userlist entry.
PluginMetadata ulistPlugin = state_.getCurrentGame().GetUserlist().FindPlugin(pluginName);
// Create new object for userlist entry.
PluginMetadata newMetadata = getUniqueMetadata(convertMetadata(metadata_, ulistPlugin));
// Now erase any existing userlist entry.
if (!ulistPlugin.HasNameOnly()) {
BOOST_LOG_TRIVIAL(trace) << "Erasing the existing userlist entry.";
state_.getCurrentGame().GetUserlist().ErasePlugin(ulistPlugin);
}
// Add a new userlist entry if necessary.
if (!newMetadata.HasNameOnly()) {
BOOST_LOG_TRIVIAL(trace) << "Adding new metadata to new userlist entry.";
state_.getCurrentGame().GetUserlist().AddPlugin(newMetadata);
}
// Save edited userlist.
state_.getCurrentGame().GetUserlist().Save(state_.getCurrentGame().UserlistPath());
// Now rederive the derived metadata.
BOOST_LOG_TRIVIAL(trace) << "Returning newly derived display metadata.";
YAML::Node derivedMetadata = generateDerivedMetadata(newMetadata.Name());
if (derivedMetadata.size() > 0)
return JSON::stringify(derivedMetadata);
else
return "null";
}
static std::vector<Message> toMessages(std::vector<EditorMessage> messages) {
std::vector<Message> list;
for (const auto& message : messages) {
list.push_back(Message(
message.type,
{{message.text, message.language}},
message.condition));
}
return list;
}
LootState& state_;
YAML::Node metadata_;
};
}
#endif
+46
View File
@@ -0,0 +1,46 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_EDITOR_OPENED_QUERY
#define LOOT_GUI_QUERY_EDITOR_OPENED_QUERY
#include "backend/app/loot_state.h"
#include "gui/query/query.h"
namespace loot {
class EditorOpenedQuery : public Query {
public:
EditorOpenedQuery(LootState& state) : state_(state) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
state_.incrementUnappliedChangeCounter();
callback->Success("");
}
private:
LootState& state_;
};
}
#endif
@@ -0,0 +1,83 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_GET_CONFLICTING_PLUGINS_QUERY
#define LOOT_GUI_QUERY_GET_CONFLICTING_PLUGINS_QUERY
#include "backend/game/game.h"
#include "backend/helpers/json.h"
#include "gui/query/metadata_query.h"
namespace loot {
class GetConflictingPluginsQuery : public MetadataQuery {
public:
GetConflictingPluginsQuery(LootState& state, const std::string& pluginName) :
MetadataQuery(state.getCurrentGame(), state.getLanguage().GetCode()),
game_(state.getCurrentGame()),
pluginName_(pluginName) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::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 (!game_.ArePluginsFullyLoaded())
game_.LoadAllInstalledPlugins(false);
YAML::Node node;
auto plugin = game_.GetPlugin(pluginName_);
for (const auto& otherPlugin : game_.GetPlugins()) {
node.push_back(getConflictMetadata(plugin, otherPlugin));
}
if (node.size() > 0)
callback->Success(JSON::stringify(node));
else
callback->Success("[]");
}
private:
YAML::Node getConflictMetadata(const Plugin& plugin, const Plugin& otherPlugin) {
YAML::Node pluginNode = generateDerivedMetadata(otherPlugin.Name());
pluginNode["name"] = otherPlugin.Name();
pluginNode["crc"] = otherPlugin.Crc();
pluginNode["isEmpty"] = otherPlugin.IsEmpty();
if (plugin.DoFormIDsOverlap(otherPlugin)) {
BOOST_LOG_TRIVIAL(debug) << "Found conflicting plugin: " << otherPlugin.Name();
pluginNode["conflicts"] = true;
} else {
pluginNode["conflicts"] = false;
}
return pluginNode;
}
Game& game_;
std::string pluginName_;
};
}
#endif
+205
View File
@@ -0,0 +1,205 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_GET_GAME_DATA_QUERY
#define LOOT_GUI_QUERY_GET_GAME_DATA_QUERY
#include <boost/locale.hpp>
#include "loot/error.h"
#include "loot/loot_version.h"
#include "backend/helpers/json.h"
#include "backend/helpers/version.h"
#include "gui/query/metadata_query.h"
namespace loot {
class GetGameDataQuery : public MetadataQuery {
public:
GetGameDataQuery(LootState& state, CefRefPtr<CefFrame> frame) :
MetadataQuery(state.getCurrentGame(), state.getLanguage().GetCode()),
state_(state),
frame_(frame) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
sendProgressUpdate(frame_, boost::locale::translate("Parsing, merging and evaluating metadata..."));
// First clear CRC and condition caches, otherwise they could lead to incorrect evaluations.
state_.getCurrentGame().ClearCachedConditions();
/* If the game's plugins object is empty, this is the first time loading
the game data, so also load the metadata lists. */
if (state_.getCurrentGame().GetPlugins().empty())
loadMetadataLists();
state_.getCurrentGame().LoadAllInstalledPlugins(true);
//Sort plugins into their load order.
std::vector<Plugin> installed;
std::vector<std::string> loadOrder = state_.getCurrentGame().GetLoadOrder();
for (const auto &pluginName : loadOrder) {
try {
const auto plugin = state_.getCurrentGame().GetPlugin(pluginName);
installed.push_back(plugin);
} catch (...) {}
}
callback->Success(generateJsonResponse(installed));
}
private:
void loadMetadataLists() {
if (exists(state_.getCurrentGame().MasterlistPath())) {
BOOST_LOG_TRIVIAL(debug) << "Parsing masterlist.";
try {
state_.getCurrentGame().GetMasterlist().Load(state_.getCurrentGame().MasterlistPath());
} catch (std::exception &e) {
state_.getCurrentGame().GetMasterlist().AppendMessage(Message(MessageType::error, (boost::format(boost::locale::translate(
"An error occurred while parsing the masterlist: %1%. "
"This probably happened because an update to LOOT changed "
"its metadata syntax support. Try updating your masterlist "
"to resolve the error."
)) % e.what()).str()));
}
}
if (exists(state_.getCurrentGame().UserlistPath())) {
BOOST_LOG_TRIVIAL(debug) << "Parsing userlist.";
try {
state_.getCurrentGame().GetUserlist().Load(state_.getCurrentGame().UserlistPath());
} catch (std::exception &e) {
state_.getCurrentGame().GetUserlist().AppendMessage(Message(MessageType::error, (boost::format(boost::locale::translate(
"An error occurred while parsing the userlist: %1%. "
"This probably happened because an update to LOOT changed "
"its metadata syntax support. Your user metadata will have "
"to be updated manually.\n\n"
"To do so, use the 'Open Debug Log Location' in LOOT's main "
"menu to open its data folder, then open your 'userlist.yaml' "
"file in the relevant game folder. You can then edit the "
"metadata it contains with reference to the "
"[syntax documentation](https://loot.github.io/docs/%2%.%3%.%4%/LOOT%%20Metadata%%20Syntax.html).\n\n"
"You can also seek support on LOOT's forum thread, which is "
"linked to on [LOOT's website](https://loot.github.io/)."
)) % e.what() % LootVersion::major % LootVersion::minor % LootVersion::patch).str()));
}
}
}
YAML::Node convertMasterlistMetadata() {
YAML::Node masterlistNode;
try {
Masterlist::Info info = state_.getCurrentGame().GetMasterlist().GetInfo(state_.getCurrentGame().MasterlistPath(), true);
masterlistNode["revision"] = info.revision;
masterlistNode["date"] = info.date;
} catch (Error &e) {
masterlistNode["revision"] = e.what();
masterlistNode["date"] = e.what();
}
return masterlistNode;
}
static std::vector<EditorMessage> toEditorMessages(std::vector<Message> messages, const LanguageCode language) {
std::vector<EditorMessage> list;
for (const auto& message : messages) {
list.push_back(EditorMessage(message, language));
}
return list;
}
static YAML::Node convertPluginMetadata(const PluginMetadata& metadata, const LanguageCode language) {
YAML::Node node;
node["enabled"] = metadata.Enabled();
node["after"] = metadata.LoadAfter();
node["req"] = metadata.Reqs();
node["inc"] = metadata.Incs();
node["msg"] = toEditorMessages(metadata.Messages(), language);
node["tag"] = metadata.Tags();
node["dirty"] = metadata.DirtyInfo();
node["clean"] = metadata.CleanInfo();
node["url"] = metadata.Locations();
return node;
}
YAML::Node generateDerivedMetadata(const Plugin& plugin) {
YAML::Node pluginNode;
pluginNode["__type"] = "Plugin"; // For conversion back into a JS typed object.
pluginNode["name"] = plugin.Name();
pluginNode["isActive"] = plugin.IsActive();
pluginNode["isEmpty"] = plugin.IsEmpty();
pluginNode["isMaster"] = plugin.isMasterFile();
pluginNode["loadsArchive"] = plugin.LoadsArchive();
pluginNode["crc"] = plugin.Crc();
pluginNode["version"] = Version(plugin.getDescription()).AsString();
BOOST_LOG_TRIVIAL(trace) << "Getting masterlist metadata for: " << plugin.Name();
Plugin mlistPlugin(plugin);
mlistPlugin.MergeMetadata(state_.getCurrentGame().GetMasterlist().FindPlugin(plugin));
if (!mlistPlugin.HasNameOnly())
pluginNode["masterlist"] = convertPluginMetadata(mlistPlugin, state_.getLanguage().GetCode());
BOOST_LOG_TRIVIAL(trace) << "Getting userlist metadata for: " << plugin.Name();
PluginMetadata ulistPlugin(state_.getCurrentGame().GetUserlist().FindPlugin(plugin));
if (!ulistPlugin.HasNameOnly())
pluginNode["userlist"] = convertPluginMetadata(ulistPlugin, state_.getLanguage().GetCode());
// Now merge masterlist and userlist metadata and evaluate,
// putting any resulting metadata into the base of the pluginNode.
YAML::Node derivedNode = MetadataQuery::generateDerivedMetadata(plugin, mlistPlugin, ulistPlugin);
for (auto it = derivedNode.begin(); it != derivedNode.end(); ++it) {
const std::string key = it->first.as<std::string>();
pluginNode[key] = it->second;
}
return pluginNode;
}
std::string generateJsonResponse(std::vector<Plugin> plugins) {
YAML::Node gameNode;
// ID the game using its folder value.
gameNode["folder"] = state_.getCurrentGame().FolderName();
gameNode["masterlist"] = convertMasterlistMetadata();
gameNode["globalMessages"] = getGeneralMessages();
gameNode["bashTags"] = state_.getCurrentGame().GetMasterlist().BashTags();
// Now store plugin data.
for (const auto& plugin : plugins) {
gameNode["plugins"].push_back(generateDerivedMetadata(plugin));
}
return JSON::stringify(gameNode);
}
LootState& state_;
CefRefPtr<CefFrame> frame_;
};
}
#endif
+55
View File
@@ -0,0 +1,55 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_GET_GAME_TYPES_QUERY
#define LOOT_GUI_QUERY_GET_GAME_TYPES_QUERY
#include "backend/game/game_settings.h"
#include "backend/helpers/json.h"
#include "gui/query/query.h"
namespace loot {
class GetGameTypesQuery : public Query {
public:
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
BOOST_LOG_TRIVIAL(info) << "Getting LOOT's supported languages.";
callback->Success(getGameTypesAsJson());
}
private:
static std::string getGameTypesAsJson() {
YAML::Node temp;
temp.push_back(GameSettings(GameType::tes4).FolderName());
temp.push_back(GameSettings(GameType::tes5).FolderName());
temp.push_back(GameSettings(GameType::fo3).FolderName());
temp.push_back(GameSettings(GameType::fonv).FolderName());
temp.push_back(GameSettings(GameType::fo4).FolderName());
return JSON::stringify(temp);
}
};
}
#endif
+50
View File
@@ -0,0 +1,50 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_GET_INIT_ERRORS_QUERY
#define LOOT_GUI_QUERY_GET_INIT_ERRORS_QUERY
#include "backend/app/loot_state.h"
#include "backend/helpers/json.h"
#include "gui/query/query.h"
namespace loot {
class GetInitErrorsQuery : public Query {
public:
GetInitErrorsQuery(LootState& state) : state_(state) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
YAML::Node node(state_.getInitErrors());
if (node.size() > 0)
callback->Success(JSON::stringify(node));
else
callback->Success("null");
}
private:
LootState& state_;
};
}
#endif
+55
View File
@@ -0,0 +1,55 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2014-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_GUI_QUERY_GET_INSTALLED_GAMES_QUERY
#define LOOT_GUI_QUERY_GET_INSTALLED_GAMES_QUERY
#include "backend/app/loot_state.h"
#include "backend/helpers/json.h"
#include "gui/query/query.h"
namespace loot {
class GetInstalledGamesQuery : public Query {
public:
GetInstalledGamesQuery(LootState& state) : state_(state) {}
void execute(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
BOOST_LOG_TRIVIAL(info) << "Getting LOOT's detected games.";
callback->Success(getInstalledGamesAsJson());
}
private:
std::string getInstalledGamesAsJson() const {
YAML::Node temp = YAML::Node(state_.getInstalledGames());
if (temp.size() > 0)
return JSON::stringify(temp);
else
return "[]";
}
LootState& state_;
};
}
#endif

Some files were not shown because too many files have changed in this diff Show More