Finished adding logging statements to code (issue #11).

This commit is contained in:
WrinklyNinja
2013-09-20 20:33:44 +01:00
parent 12c84a72ab
commit bdf91663ad
8 changed files with 208 additions and 129 deletions
+9
View File
@@ -103,6 +103,8 @@ namespace boss {
Game& Game::SetDetails(const std::string& name, const std::string& masterFile,
const std::string& url, const std::string& path, const std::string& registry) {
BOOST_LOG_TRIVIAL(trace) << "Setting new details for game: " << _name;
if (!name.empty())
_name = name;
@@ -122,6 +124,8 @@ namespace boss {
}
Game& Game::Init() {
BOOST_LOG_TRIVIAL(trace) << "Initialising filesystem-related data for game: " << _name;
//First look for local install, then look for Registry.
if (gamePath.empty() || !fs::exists(gamePath / "Data" / _masterFile)) {
if (fs::exists(fs::path("..") / "Data" / _masterFile))
@@ -150,6 +154,7 @@ namespace boss {
}
bool Game::IsInstalled() const {
BOOST_LOG_TRIVIAL(trace) << "Checking if game \"" << _name << "\" is installed.";
if (!gamePath.empty() && fs::exists(gamePath / "Data" / _masterFile))
return true;
@@ -221,6 +226,8 @@ namespace boss {
}
void Game::RefreshActivePluginsList() {
BOOST_LOG_TRIVIAL(trace) << "Refreshing active plugins list for game: " << _name;
lo_game_handle gh;
char ** pluginArr;
size_t pluginArrSize;
@@ -277,6 +284,8 @@ namespace boss {
}
void Game::SetLoadOrder(const std::list<Plugin>& loadOrder) const {
BOOST_LOG_TRIVIAL(trace) << "Setting load order for game: " << _name;
lo_game_handle gh;
char ** pluginArr;
size_t pluginArrSize;
+18
View File
@@ -51,6 +51,7 @@ namespace boss {
};
inline void GetGraphWidthHeight(const boost::filesystem::path& filepath, std::string& width, std::string& height) {
BOOST_LOG_TRIVIAL(trace) << "Getting the dimensions of the plugin interactions graph image.";
boss::ifstream in(filepath);
@@ -128,6 +129,7 @@ namespace boss {
}
inline void GenerateHead(pugi::xml_document& doc) {
BOOST_LOG_TRIVIAL(trace) << "Creating BOSS report head.";
//Add DOCTYPE node.
doc.append_child(pugi::node_doctype).set_value("html");
@@ -170,6 +172,8 @@ namespace boss {
}
inline void AppendNav(pugi::xml_node& body, bool createGraphTab) {
BOOST_LOG_TRIVIAL(trace) << "Appending navigation bar to BOSS report.";
pugi::xml_node nav, div;
nav = body.append_child();
@@ -240,6 +244,8 @@ namespace boss {
int errorNo,
const std::list<Message>& messages) {
BOOST_LOG_TRIVIAL(trace) << "Appending summary tab to BOSS report.";
pugi::xml_node summary = main.append_child();
summary.set_name("div");
summary.append_attribute("id").set_value("summary");
@@ -282,6 +288,7 @@ namespace boss {
cell.text().set(boost::locale::translate("Disabled").str().c_str());
if (!hasChanged) {
BOOST_LOG_TRIVIAL(info) << "No changes in the BOSS report details tab since the last run.";
pugi::xml_node note = summary.append_child();
note.set_name("div");
note.append_attribute("id").set_value("noChanges");
@@ -321,6 +328,8 @@ namespace boss {
inline bool AppendDetails(pugi::xml_node& main, const std::list<Plugin>& plugins, int& messageNo, int& warnNo, int& errorNo, const std::string& oldDetails) {
BOOST_LOG_TRIVIAL(trace) << "Appending details tab to BOSS report.";
pugi::xml_node details = main.append_child();
details.set_name("div");
details.append_attribute("id").set_value("plugins");
@@ -332,6 +341,7 @@ namespace boss {
details.set_name("ul");
for (std::list<Plugin>::const_iterator it=plugins.begin(), endit=plugins.end(); it != endit; ++it) {
BOOST_LOG_TRIVIAL(trace) << "Appending details for plugin: " << it->Name();
pugi::xml_node plugin = details.append_child();
plugin.set_name("li");
@@ -394,6 +404,8 @@ namespace boss {
int& pluginMessageNo
) {
BOOST_LOG_TRIVIAL(trace) << "Appending main content to BOSS report.";
pugi::xml_node main = body.append_child();
main.set_name("div");
main.append_attribute("id").set_value("main");
@@ -435,6 +447,8 @@ namespace boss {
inline void AppendFilters(pugi::xml_node& body, int messageNo, int pluginNo) {
BOOST_LOG_TRIVIAL(trace) << "Appending filters to BOSS report.";
pugi::xml_node filters = body.append_child();
filters.set_name("div");
filters.append_attribute("id").set_value("filters");
@@ -521,6 +535,8 @@ namespace boss {
inline void AppendScripts(pugi::xml_node& body) {
BOOST_LOG_TRIVIAL(trace) << "Appending scripts to BOSS report.";
pugi::xml_node node;
node = body.append_child();
@@ -565,6 +581,8 @@ namespace boss {
inline void GenerateDefaultSettingsFile(const std::string& file) {
BOOST_LOG_TRIVIAL(info) << "Generating default settings file.";
YAML::Node root;
std::vector<Game> games;
+4
View File
@@ -190,9 +190,11 @@ namespace boss {
else if (keyStr == "HKEY_USERS")
key = HKEY_USERS;
BOOST_LOG_TRIVIAL(trace) << "Getting registry object for key and subkey: " << keyStr << " + " << subkey;
LONG ret = RegOpenKeyEx(key, fs::path(subkey).wstring().c_str(), 0, KEY_READ|KEY_WOW64_32KEY, &hKey);
if (ret == ERROR_SUCCESS) {
BOOST_LOG_TRIVIAL(trace) << "Getting value for entry: " << value;
ret = RegQueryValueEx(hKey, fs::path(value).wstring().c_str(), NULL, NULL, (LPBYTE)&val, &BufferSize);
RegCloseKey(hKey);
@@ -212,6 +214,7 @@ namespace boss {
HWND owner;
TCHAR path[MAX_PATH];
BOOST_LOG_TRIVIAL(trace) << "Getting path to %LOCALAPPDATA%.";
HRESULT res = SHGetFolderPath(owner, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path);
if (res == S_OK)
@@ -225,6 +228,7 @@ namespace boss {
//Turns an absolute filesystem path into a valid file:// URL.
std::string ToFileURL(const fs::path& file) {
BOOST_LOG_TRIVIAL(trace) << "Converting file path " << file << " to a URL.";
//URLs are UTF-8 encoded then any characters (equiv. their corresponding bytes) not in the unreserved set (equiv. their corresponding bytes) are replaced by a percentage sign followed by the hex representation of their binary value.
string unreserved = "-.0123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~"; //Unreserved in byte value order, plus the colon character since that's allowed for drive paths.
+5 -12
View File
@@ -48,7 +48,7 @@ namespace boss {
id = formID & ~((uint32_t)index << 24);
if (index >= sourcePlugins.size()) {
//cout << hex << formID << dec << " in " << sourcePlugins.back() << " has a higher modIndex than expected." << endl;
BOOST_LOG_TRIVIAL(trace) << hex << formID << dec << " in " << sourcePlugins.back() << " has a higher modIndex than expected.";
index = sourcePlugins.size() - 1;
}
@@ -170,7 +170,6 @@ namespace boss {
BOOST_LOG_TRIVIAL(trace) << "Choosing message language.";
if (_content.size() > 1) {
if (language == g_lang_any) //Can use a message of any language, so use the first string.
_content.resize(1);
@@ -194,6 +193,7 @@ namespace boss {
}
MessageContent Message::ChooseContent(const unsigned int language) const {
BOOST_LOG_TRIVIAL(trace) << "Choosing message content.";
if (_content.size() == 1 || language == g_lang_any)
return _content[0];
else {
@@ -367,6 +367,7 @@ namespace boss {
}
void Plugin::Merge(const Plugin& plugin, bool ifDisabled) {
BOOST_LOG_TRIVIAL(trace) << "Merging plugin metadata.";
//If 'name' differs or if 'enabled' is false for the given plugin, don't change anything.
if ((!plugin.Enabled() && !ifDisabled))
return;
@@ -403,6 +404,7 @@ namespace boss {
}
Plugin Plugin::DiffMetadata(const Plugin& plugin) const {
BOOST_LOG_TRIVIAL(trace) << "Calculating metadata difference between plugins.";
Plugin p(*this);
//Compare this plugin against the given plugin.
@@ -562,6 +564,7 @@ namespace boss {
bool Plugin::DoFormIDsOverlap(const Plugin& plugin) const {
//Basically std::set_intersection except with an early exit instead of an append to results.
BOOST_LOG_TRIVIAL(trace) << "Checking for FormID overlap between \"" << name << "\" and \"" << plugin.Name() << "\".";
set<FormID>::const_iterator i = formIDs.begin(),
j = plugin.FormIDs().begin(),
@@ -588,16 +591,6 @@ namespace boss {
set<FormID> otherFormIDs = plugin.FormIDs();
set<FormID> overlap;
/* for (set<FormID>::iterator it=formIDs.begin(),endit=formIDs.end(); it != endit; ++it) {
if (otherFormIDs.find(*it) != otherFormIDs.end())
overlap.insert(*it);
}
for (set<FormID>::iterator it=otherFormIDs.begin(),endit=otherFormIDs.end(); it != endit; ++it) {
if (formIDs.find(*it) != formIDs.end())
overlap.insert(*it);
}
*/
set_intersection(formIDs.begin(), formIDs.end(), otherFormIDs.begin(), otherFormIDs.end(), inserter(overlap, overlap.end()));
return overlap;
+153 -90
View File
@@ -268,6 +268,8 @@ void Editor::OnPluginSelect(wxListEvent& event) {
//Check if the selected plugin is the same as the current plugin.
if (selectedPlugin != currentPlugin) {
BOOST_LOG_TRIVIAL(debug) << "User selected plugin: " << selectedPlugin.ToUTF8();
//Apply any current edits.
if (!currentPlugin.empty())
ApplyEdits(currentPlugin);
@@ -276,6 +278,7 @@ void Editor::OnPluginSelect(wxListEvent& event) {
plugin.Merge(GetUserData(selectedPlugin), true);
//Now fill editor fields with new plugin's info and update control states.
BOOST_LOG_TRIVIAL(debug) << "Filling editor fields with plugin info.";
pluginText->SetLabelText(FromUTF8(plugin.Name()));
prioritySpin->SetValue(plugin.Priority());
@@ -342,6 +345,7 @@ void Editor::OnPluginSelect(wxListEvent& event) {
}
void Editor::OnListBookChange(wxBookCtrlEvent& event) {
BOOST_LOG_TRIVIAL(trace) << "Changed list tab.";
if (event.GetSelection() == 0 || event.GetSelection() == 1) {
addBtn->SetLabel(translate("Add File"));
editBtn->SetLabel(translate("Edit File"));
@@ -373,72 +377,88 @@ void Editor::OnListBookChange(wxBookCtrlEvent& event) {
void Editor::OnAddRow(wxCommandEvent& event) {
if (listBook->GetSelection() < 3) {
BOOST_LOG_TRIVIAL(debug) << "Adding new file row.";
FileEditDialog * rowDialog = new FileEditDialog(this, translate("BOSS: Add File/Plugin"));
if (rowDialog->ShowModal() == wxID_OK) {
if (rowDialog->GetName().empty()) {
wxMessageBox(
translate("Error: No filename specified. Row will not be added."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
return;
}
wxListView * list;
if (listBook->GetSelection() == 0)
list = reqsList;
else if (listBook->GetSelection() == 1)
list = incsList;
else
list = loadAfterList;
long i = list->GetItemCount();
list->InsertItem(i, rowDialog->GetName());
list->SetItem(i, 1, rowDialog->GetDisplayName());
list->SetItem(i, 2, rowDialog->GetCondition());
if (rowDialog->ShowModal() != wxID_OK) {
BOOST_LOG_TRIVIAL(debug) << "Cancelled adding new file row.";
return;
}
if (rowDialog->GetName().empty()) {
BOOST_LOG_TRIVIAL(error) << "No filename specified. Row will not be added.";
wxMessageBox(
translate("Error: No filename specified. Row will not be added."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
return;
}
wxListView * list;
if (listBook->GetSelection() == 0)
list = reqsList;
else if (listBook->GetSelection() == 1)
list = incsList;
else
list = loadAfterList;
long i = list->GetItemCount();
list->InsertItem(i, rowDialog->GetName());
list->SetItem(i, 1, rowDialog->GetDisplayName());
list->SetItem(i, 2, rowDialog->GetCondition());
} else if (listBook->GetSelection() == 3) {
BOOST_LOG_TRIVIAL(debug) << "Adding new message row.";
MessageEditDialog * rowDialog = new MessageEditDialog(this, translate("BOSS: Add Message"));
if (rowDialog->ShowModal() == wxID_OK) {
if (rowDialog->GetMessage().Content().empty()) {
wxMessageBox(
translate("Error: No content specified. Row will not be added."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
return;
}
messageList->AppendItem(rowDialog->GetMessage());
if (rowDialog->ShowModal() != wxID_OK) {
BOOST_LOG_TRIVIAL(debug) << "Cancelled adding new message row.";
return;
}
if (rowDialog->GetMessage().Content().empty()) {
BOOST_LOG_TRIVIAL(error) << "No content specified. Row will not be added.";
wxMessageBox(
translate("Error: No content specified. Row will not be added."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
return;
}
messageList->AppendItem(rowDialog->GetMessage());
} else if (listBook->GetSelection() == 4) {
BOOST_LOG_TRIVIAL(debug) << "Adding new tag row.";
TagEditDialog * rowDialog = new TagEditDialog(this, translate("BOSS: Add Tag"));
if (rowDialog->ShowModal() == wxID_OK) {
if (rowDialog->GetName().empty()) {
wxMessageBox(
translate("Error: No Bash Tag specified. Row will not be added."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
return;
}
long i = tagsList->GetItemCount();
tagsList->InsertItem(i, rowDialog->GetState());
tagsList->SetItem(i, 1, rowDialog->GetName());
tagsList->SetItem(i, 2, rowDialog->GetCondition());
if (rowDialog->ShowModal() != wxID_OK) {
BOOST_LOG_TRIVIAL(debug) << "Cancelled adding new tag row.";
return;
}
if (rowDialog->GetName().empty()) {
BOOST_LOG_TRIVIAL(error) << "No Bash Tag specified. Row will not be added.";
wxMessageBox(
translate("Error: No Bash Tag specified. Row will not be added."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
return;
}
long i = tagsList->GetItemCount();
tagsList->InsertItem(i, rowDialog->GetState());
tagsList->SetItem(i, 1, rowDialog->GetName());
tagsList->SetItem(i, 2, rowDialog->GetCondition());
}
}
void Editor::OnEditRow(wxCommandEvent& event) {
if (listBook->GetSelection() < 3) {
BOOST_LOG_TRIVIAL(debug) << "Editing file row.";
FileEditDialog * rowDialog = new FileEditDialog(this, translate("BOSS: Edit File/Plugin"));
wxListView * list;
@@ -453,42 +473,50 @@ void Editor::OnEditRow(wxCommandEvent& event) {
rowDialog->SetValues(list->GetItemText(i, 0), list->GetItemText(i, 1), list->GetItemText(i, 2));
if (rowDialog->ShowModal() == wxID_OK) {
if (rowDialog->GetName().empty()) {
wxMessageBox(
translate("Error: No filename specified. Row will not be edited."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
return;
}
list->SetItem(i, 0, rowDialog->GetName());
list->SetItem(i, 1, rowDialog->GetDisplayName());
list->SetItem(i, 2, rowDialog->GetCondition());
if (rowDialog->ShowModal() != wxID_OK) {
BOOST_LOG_TRIVIAL(debug) << "Cancelled editing file row.";
return;
}
if (rowDialog->GetName().empty()) {
BOOST_LOG_TRIVIAL(error) << "No filename specified. Row will not be edited.";
wxMessageBox(
translate("Error: No filename specified. Row will not be edited."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
return;
}
list->SetItem(i, 0, rowDialog->GetName());
list->SetItem(i, 1, rowDialog->GetDisplayName());
list->SetItem(i, 2, rowDialog->GetCondition());
} else if (listBook->GetSelection() == 3) {
BOOST_LOG_TRIVIAL(debug) << "Editing message row.";
MessageEditDialog * rowDialog = new MessageEditDialog(this, translate("BOSS: Edit Message"));
long i = messageList->GetFirstSelected();
rowDialog->SetMessage(messageList->GetItem(i));
if (rowDialog->ShowModal() == wxID_OK) {
if (rowDialog->GetMessage().Content().empty()) {
wxMessageBox(
translate("Error: No content specified. Row will not be edited."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
return;
}
messageList->SetItem(i, rowDialog->GetMessage());
if (rowDialog->ShowModal() != wxID_OK) {
BOOST_LOG_TRIVIAL(debug) << "Cancelled editing message row.";
return;
}
if (rowDialog->GetMessage().Content().empty()) {
BOOST_LOG_TRIVIAL(error) << "No content specified. Row will not be edited.";
wxMessageBox(
translate("Error: No content specified. Row will not be edited."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
return;
}
messageList->SetItem(i, rowDialog->GetMessage());
} else if (listBook->GetSelection() == 4) {
BOOST_LOG_TRIVIAL(debug) << "Editing tag row.";
TagEditDialog * rowDialog = new TagEditDialog(this, translate("BOSS: Edit Tag"));
long i = tagsList->GetFirstSelected();
@@ -501,25 +529,29 @@ void Editor::OnEditRow(wxCommandEvent& event) {
rowDialog->SetValues(stateNo, tagsList->GetItemText(i, 1), tagsList->GetItemText(i, 2));
if (rowDialog->ShowModal() == wxID_OK) {
if (rowDialog->GetName().empty()) {
wxMessageBox(
translate("Error: No Bash Tag specified. Row will not be edited."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
return;
}
tagsList->SetItem(i, 0, rowDialog->GetState());
tagsList->SetItem(i, 1, rowDialog->GetName());
tagsList->SetItem(i, 2, rowDialog->GetCondition());
if (rowDialog->ShowModal() != wxID_OK) {
BOOST_LOG_TRIVIAL(debug) << "Cancelled editing tag row.";
return;
}
if (rowDialog->GetName().empty()) {
BOOST_LOG_TRIVIAL(error) << "No Bash Tag specified. Row will not be edited.";
wxMessageBox(
translate("Error: No Bash Tag specified. Row will not be edited."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
return;
}
tagsList->SetItem(i, 0, rowDialog->GetState());
tagsList->SetItem(i, 1, rowDialog->GetName());
tagsList->SetItem(i, 2, rowDialog->GetCondition());
}
}
void Editor::OnRemoveRow(wxCommandEvent& event) {
BOOST_LOG_TRIVIAL(debug) << "Removing row.";
wxListView * list;
if (listBook->GetSelection() == 0)
list = reqsList;
@@ -549,13 +581,17 @@ void Editor::OnRowSelect(wxListEvent& event) {
if (it != _basePlugins.end())
plugin = *it;
else
BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name();
set<boss::File> reqs = plugin.Reqs();
if (reqs.find(file) == reqs.end()) {
BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Editing enabled.";
editBtn->Enable(true);
removeBtn->Enable(true);
} else {
BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was found in base plugin metadata. Editing disabled.";
editBtn->Enable(false);
removeBtn->Enable(false);
}
@@ -569,13 +605,17 @@ void Editor::OnRowSelect(wxListEvent& event) {
if (it != _basePlugins.end())
plugin = *it;
else
BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name();
set<boss::File> incs = plugin.Incs();
if (incs.find(file) == incs.end()) {
BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Editing enabled.";
editBtn->Enable(true);
removeBtn->Enable(true);
} else {
BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was found in base plugin metadata. Editing disabled.";
editBtn->Enable(false);
removeBtn->Enable(false);
}
@@ -589,13 +629,17 @@ void Editor::OnRowSelect(wxListEvent& event) {
if (it != _basePlugins.end())
plugin = *it;
else
BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name();
set<boss::File> loadAfter = plugin.LoadAfter();
if (loadAfter.find(file) == loadAfter.end()) {
BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Editing enabled.";
editBtn->Enable(true);
removeBtn->Enable(true);
} else {
BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was found in base plugin metadata. Editing disabled.";
editBtn->Enable(false);
removeBtn->Enable(false);
}
@@ -609,13 +653,17 @@ void Editor::OnRowSelect(wxListEvent& event) {
if (it != _basePlugins.end())
plugin = *it;
else
BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name();
list<boss::Message> messages = plugin.Messages();
if (find(messages.begin(), messages.end(), message) == messages.end()) {
BOOST_LOG_TRIVIAL(trace) << "Message \"" << message.ChooseContent(boss::g_lang_any).Str() << "\" was not found in base plugin metadata. Editing enabled.";
editBtn->Enable(true);
removeBtn->Enable(true);
} else {
BOOST_LOG_TRIVIAL(trace) << "Message \"" << message.ChooseContent(boss::g_lang_any).Str() << "\" was found in base plugin metadata. Editing disabled.";
editBtn->Enable(false);
removeBtn->Enable(false);
}
@@ -629,13 +677,17 @@ void Editor::OnRowSelect(wxListEvent& event) {
if (it != _basePlugins.end())
plugin = *it;
else
BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name();
set<boss::Tag> tags = plugin.Tags();
if (tags.find(tag) == tags.end()) {
BOOST_LOG_TRIVIAL(trace) << "Bash Tag \"" << tag.Name() << "\" was not found in base plugin metadata. Editing enabled.";
editBtn->Enable(true);
removeBtn->Enable(true);
} else {
BOOST_LOG_TRIVIAL(trace) << "Bash Tag \"" << tag.Name() << "\" was found in base plugin metadata. Editing disabled.";
editBtn->Enable(false);
removeBtn->Enable(false);
}
@@ -656,6 +708,8 @@ void Editor::OnExport(wxCommandEvent& event) {
yout << diff;
string text = yout.c_str();
BOOST_LOG_TRIVIAL(info) << "Exported metadata text for \"" << currentPlugin.ToUTF8() << "\": " << text;
if (!text.empty() && wxTheClipboard->Open()) {
wxTheClipboard->SetData( new wxTextDataObject(FromUTF8(text)) );
wxTheClipboard->Close();
@@ -663,6 +717,7 @@ void Editor::OnExport(wxCommandEvent& event) {
}
void Editor::OnQuit(wxCommandEvent& event) {
BOOST_LOG_TRIVIAL(debug) << "Exiting metadata editor.";
if (event.GetId() == BUTTON_Apply) {
//Apply any current edits.
@@ -670,6 +725,8 @@ void Editor::OnQuit(wxCommandEvent& event) {
if (!currentPlugin.empty())
ApplyEdits(currentPlugin);
BOOST_LOG_TRIVIAL(debug) << "Saving metadata edits to userlist.";
//Save edits to userlist.
YAML::Emitter yout;
yout.SetIndent(2);
@@ -686,6 +743,7 @@ 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 edited = GetNewData(plugin);
@@ -700,6 +758,7 @@ void Editor::ApplyEdits(const wxString& plugin) {
}
boss::Plugin Editor::GetMasterData(const wxString& plugin) const {
BOOST_LOG_TRIVIAL(debug) << "Getting hardcoded and masterlist metadata for plugin: " << plugin.ToUTF8();
boss::Plugin p;
boss::Plugin p_in(string(plugin.ToUTF8()));
@@ -712,6 +771,7 @@ boss::Plugin Editor::GetMasterData(const wxString& plugin) const {
}
boss::Plugin Editor::GetUserData(const wxString& plugin) const {
BOOST_LOG_TRIVIAL(debug) << "Getting userlist metadata for plugin: " << plugin.ToUTF8();
boss::Plugin p;
boss::Plugin p_in(string(plugin.ToUTF8()));
@@ -724,6 +784,7 @@ boss::Plugin Editor::GetUserData(const wxString& plugin) const {
}
boss::Plugin Editor::GetNewData(const wxString& plugin) const {
BOOST_LOG_TRIVIAL(debug) << "Getting metadata from editor fields for plugin: " << plugin.ToUTF8();
boss::Plugin p(string(plugin.ToUTF8()));
p.Priority(prioritySpin->GetValue());
@@ -985,6 +1046,7 @@ void MessageEditDialog::OnAdd(wxCommandEvent& event) {
void MessageEditDialog::OnEdit(wxCommandEvent& event) {
if (_content->GetFirstSelected() == -1) {
BOOST_LOG_TRIVIAL(error) << "Attempting to edit message content, but no content row selected.";
wxMessageBox(
translate("Error: No content row selected."),
translate("BOSS: Error"),
@@ -999,6 +1061,7 @@ void MessageEditDialog::OnEdit(wxCommandEvent& event) {
void MessageEditDialog::OnRemove(wxCommandEvent& event) {
if (_content->GetFirstSelected() == -1) {
BOOST_LOG_TRIVIAL(error) << "Attempting to remove message content, but no content row selected.";
wxMessageBox(
translate("Error: No content row selected."),
translate("BOSS: Error"),
+13 -26
View File
@@ -76,9 +76,7 @@ struct plugin_loader {
}
void operator () () {
BOOST_LOG_TRIVIAL(info) << "Loading: " << _plugin.Name();
_plugin = boss::Plugin(_game, _plugin.Name(), false);
BOOST_LOG_TRIVIAL(info) << "Finished loading: " << _plugin.Name();
}
boss::Plugin& _plugin;
@@ -94,9 +92,7 @@ struct plugin_list_loader {
boss::vertex_it vit, vitend;
for (boost::tie(vit, vitend) = boost::vertices(_graph); vit != vitend; ++vit) {
if (skipPlugins.find(_graph[*vit].Name()) == skipPlugins.end()) {
BOOST_LOG_TRIVIAL(info) << "Loading: " << _graph[*vit].Name();
_graph[*vit] = boss::Plugin(_game, _graph[*vit].Name(), false);
BOOST_LOG_TRIVIAL(info) << "Finished loading: " << _graph[*vit].Name();
}
}
}
@@ -112,7 +108,7 @@ struct masterlist_updater_parser {
void operator () () {
if (_doUpdate) {
BOOST_LOG_TRIVIAL(trace) << "Updating masterlist";
BOOST_LOG_TRIVIAL(debug) << "Updating masterlist";
try {
_revision = UpdateMasterlist(_game, _errors, _plugins, _messages);
} catch (boss::error& e) {
@@ -125,7 +121,7 @@ struct masterlist_updater_parser {
if (_plugins.empty() && _messages.empty() && fs::exists(_game.MasterlistPath())) {
BOOST_LOG_TRIVIAL(trace) << "Parsing masterlist...";
BOOST_LOG_TRIVIAL(debug) << "Parsing masterlist...";
try {
YAML::Node mlist = YAML::LoadFile(_game.MasterlistPath().string());
@@ -137,7 +133,7 @@ struct masterlist_updater_parser {
BOOST_LOG_TRIVIAL(error) << "Masterlist parsing failed. Details: " << e.what();
_errors.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Masterlist parsing failed. Details: %1%")) % e.what()).str()));
}
BOOST_LOG_TRIVIAL(trace) << "Finished parsing masterlist.";
BOOST_LOG_TRIVIAL(debug) << "Finished parsing masterlist.";
}
}
@@ -185,7 +181,6 @@ bool BossGUI::OnInit() {
try {
_settings = YAML::LoadFile(g_path_settings.string());
} catch (YAML::ParserException& e) {
//LOG_ERROR("Error: %s", e.getString().c_str());
wxMessageBox(
FromUTF8(format(loc::translate("Error: Settings parsing failed. %1%")) % e.what()),
translate("BOSS: Error"),
@@ -512,7 +507,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
//Now load userlist.
if (fs::exists(_game.UserlistPath())) {
BOOST_LOG_TRIVIAL(trace) << "Parsing userlist...";
BOOST_LOG_TRIVIAL(debug) << "Parsing userlist...";
try {
YAML::Node ulist = YAML::LoadFile(_game.UserlistPath().string());
@@ -530,7 +525,6 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
progDia->Pulse();
if (fs::exists(_game.MasterlistPath()) || fs::exists(_game.UserlistPath())) {
BOOST_LOG_TRIVIAL(trace) << "Merging plugin lists, evaluating conditions and checking for install validity...";
//Set language.
unsigned int lang;
@@ -548,7 +542,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
messages.insert(messages.end(), ulist_messages.begin(), ulist_messages.end());
//Evaluate any conditions in the global messages.
BOOST_LOG_TRIVIAL(trace) << "Evaluating global message conditions...";
BOOST_LOG_TRIVIAL(trace) << "Evaluating global message conditions.";
try {
list<boss::Message>::iterator it=messages.begin();
while (it != messages.end()) {
@@ -563,7 +557,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
}
//Merge plugin list, masterlist and userlist plugin data.
BOOST_LOG_TRIVIAL(trace) << "Merging plugin list, masterlist and userlist data.";
BOOST_LOG_TRIVIAL(debug) << "Merging plugin list, masterlist and userlist data, evaluating conditions and checking for install validity.";
boss::vertex_it vit, vitend;
for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) {
BOOST_LOG_TRIVIAL(trace) << "Merging for plugin \"" << graph[*vit].Name() << "\"";
@@ -617,10 +611,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
progDia->Pulse();
BOOST_LOG_TRIVIAL(trace) << "Building the plugin dependency graph...";
//Use an adjacency list (don't know yet if list or matrix is the better choice), and use "listS" as the VertexList type. We need a possible multi-graph to catch some forms of cyclic dependency (a working graph would not be a multi-graph though), so use "listS". Want a directed graph where we can access in-edges, so use "bidirectionalS". Also provide the boss::Plugin class as the vertex property type.
BOOST_LOG_TRIVIAL(debug) << "Building the plugin dependency graph...";
//Now add the interactions between plugins to the graph as edges.
BOOST_LOG_TRIVIAL(trace) << "Adding non-overlap edges.";
@@ -632,7 +623,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
//First delete any existing graph file.
fs::remove(_game.GraphPath());
if (_settings["Generate Graph Image"] && _settings["Generate Graph Image"].as<bool>() && fs::exists(g_path_graphvis)) {
BOOST_LOG_TRIVIAL(trace) << "Outputting the graph.";
BOOST_LOG_TRIVIAL(debug) << "Generating the graph image.";
fs::path temp = fs::path(_game.GraphPath().string() + ".temp");
boss::SaveGraph(graph, temp);
@@ -651,12 +642,12 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
//Check for back-edges, then perform a topological sort.
try {
BOOST_LOG_TRIVIAL(trace) << "Checking to see if the graph is cyclic.";
BOOST_LOG_TRIVIAL(debug) << "Checking to see if the graph is cyclic.";
boss::CheckForCycles(graph);
progDia->Pulse();
BOOST_LOG_TRIVIAL(trace) << "Performing a topological sort.";
BOOST_LOG_TRIVIAL(debug) << "Performing a topological sort.";
boss::Sort(graph, plugins);
progDia->Pulse();
@@ -665,7 +656,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
LoadOrderPreview preview(this, translate("BOSS: Calculated Load Order"), plugins);
if (preview.ShowModal() == wxID_OK) {
BOOST_LOG_TRIVIAL(trace) << "Load order accepted.";
BOOST_LOG_TRIVIAL(debug) << "Load order accepted.";
list<boss::Plugin> newPluginsList, editedPlugins;
newPluginsList = preview.GetLoadOrder();
@@ -735,7 +726,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
}
//Now set load order.
BOOST_LOG_TRIVIAL(trace) << "Setting load order.";
BOOST_LOG_TRIVIAL(debug) << "Setting load order.";
try {
_game.SetLoadOrder(plugins);
} catch (boss::error& e) {
@@ -743,7 +734,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Failed to set the load order. Details: %1%")) % e.what()).str()));
}
} else {
BOOST_LOG_TRIVIAL(debug) << "The load order calculated was not applied as sorting was canceled.";
BOOST_LOG_TRIVIAL(info) << "The load order calculated was not applied as sorting was canceled.";
messages.push_back(boss::Message(boss::g_message_warn, loc::translate("The load order displayed in the Details tab was not applied as sorting was canceled.")));
}
@@ -1202,7 +1193,3 @@ std::list<boss::Plugin> LoadOrderPreview::GetLoadOrder() const {
return plugins;
}
std::set<std::string> LoadOrderPreview::GetMovedPlugins() const {
return _movedPlugins;
}
-1
View File
@@ -77,7 +77,6 @@ public:
void OnMoveDown(wxCommandEvent& event);
std::list<boss::Plugin> GetLoadOrder() const;
std::set<std::string> GetMovedPlugins() const;
private:
wxListView * _loadOrder;
wxButton * _moveUp;
+6
View File
@@ -274,6 +274,8 @@ void SettingsFrame::OnGameSelect(wxListEvent& event) {
}
void SettingsFrame::OnAddGame(wxCommandEvent& event) {
BOOST_LOG_TRIVIAL(debug) << "Adding new game to settings.";
GameEditDialog * rowDialog = new GameEditDialog(this, translate("BOSS: Add Game"));
if (rowDialog->ShowModal() == wxID_OK) {
@@ -329,6 +331,8 @@ void SettingsFrame::OnAddGame(wxCommandEvent& event) {
}
void SettingsFrame::OnEditGame(wxCommandEvent& event) {
BOOST_LOG_TRIVIAL(debug) << "Editing game settings.";
GameEditDialog * rowDialog = new GameEditDialog(this, translate("BOSS: Edit Game"));
long i = gamesList->GetFirstSelected();
@@ -376,6 +380,8 @@ void SettingsFrame::OnEditGame(wxCommandEvent& event) {
}
void SettingsFrame::OnRemoveGame(wxCommandEvent& event) {
BOOST_LOG_TRIVIAL(debug) << "Removing game from settings.";
gamesList->DeleteItem(gamesList->GetFirstSelected());
editBtn->Enable(false);