From 60b6ca8dd2641b40712df700906e8d70b5bc877e Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Wed, 14 May 2014 17:48:13 +0100 Subject: [PATCH] Added option to remove all userlist data. Closes #144. --- src/gui/editor.cpp | 32 ++++++++++++++++++++++++++++---- src/gui/editor.h | 1 + src/gui/ids.h | 3 ++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp index 0a342160..fb083cf9 100644 --- a/src/gui/editor.cpp +++ b/src/gui/editor.cpp @@ -571,9 +571,11 @@ Editor::Editor(wxWindow *parent, const wxString& title, const std::string userli dirtyList->AppendColumn(translate("Cleaning Utility")); //Set up plugin right-click menu. - pluginMenu->Append(MENU_CopyName, translate("Copy Name")); - pluginMenu->Append(MENU_CopyMetadata, translate("Copy Metadata As Text")); - pluginMenu->Append(MENU_ClearMetadata, translate("Remove All User-Added Metadata")); + pluginMenu->Append(MENU_CopyName, translate("Copy Plugin Name")); + pluginMenu->Append(MENU_CopyMetadata, translate("Copy Plugin Metadata As Text")); + pluginMenu->Append(MENU_ClearPluginMetadata, translate("Remove Plugin User-Added Metadata")); + pluginMenu->AppendSeparator(); + pluginMenu->Append(MENU_ClearAllMetadata, translate("Remove All User-Added Metadata")); //Initialise control states. addBtn->Enable(false); @@ -605,7 +607,8 @@ Editor::Editor(wxWindow *parent, const wxString& title, const std::string userli Bind(wxEVT_LIST_ITEM_RIGHT_CLICK, &Editor::OnPluginListRightClick, this); Bind(wxEVT_MENU, &Editor::OnPluginCopyName, this, MENU_CopyName); Bind(wxEVT_MENU, &Editor::OnPluginCopyMetadata, this, MENU_CopyMetadata); - Bind(wxEVT_MENU, &Editor::OnPluginClearMetadata, this, MENU_ClearMetadata); + Bind(wxEVT_MENU, &Editor::OnPluginClearMetadata, this, MENU_ClearPluginMetadata); + Bind(wxEVT_MENU, &Editor::OnClearAllMetadata, this, MENU_ClearAllMetadata); //Set up tooltips. pluginList->SetToolTip(translate("Select a plugin to edit its load order metadata.")); @@ -878,6 +881,27 @@ void Editor::OnPluginClearMetadata(wxCommandEvent& event) { } } +void Editor::OnClearAllMetadata(wxCommandEvent& event) { + wxMessageDialog dialog(this, + translate("Are you sure you want to clear all existing user-added metadata from all plugins?"), + translate("LOOT: Warning"), + wxYES_NO | wxCANCEL | wxICON_EXCLAMATION); + + if (dialog.ShowModal() == wxID_YES) { + //Delete all existing userlist entries. + _editedPlugins.clear(); + + //Also clear any unapplied data. Easiest way to do this is to simulate loading the plugin's data again. + pluginText->SetLabelText(""); + long i = pluginList->GetFirstSelected(); + pluginList->Select(i, false); + pluginList->Select(i, true); + for (int i = 0, max = pluginList->GetItemCount(); i < max; ++i) { + pluginList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); + } + } +} + void Editor::OnListBookChange(wxBookCtrlEvent& event) { BOOST_LOG_TRIVIAL(trace) << "Changed list tab."; if (event.GetSelection() == 0 || event.GetSelection() == 1) { diff --git a/src/gui/editor.h b/src/gui/editor.h index 725ceb5a..560790c8 100644 --- a/src/gui/editor.h +++ b/src/gui/editor.h @@ -119,6 +119,7 @@ public: void OnPluginCopyName(wxCommandEvent& event); void OnPluginCopyMetadata(wxCommandEvent& event); void OnPluginClearMetadata(wxCommandEvent& event); + void OnClearAllMetadata(wxCommandEvent& event); void OnListBookChange(wxBookCtrlEvent& event); void OnAddRow(wxCommandEvent& event); void OnEditRow(wxCommandEvent& event); diff --git a/src/gui/ids.h b/src/gui/ids.h index 4494321a..8549ecda 100644 --- a/src/gui/ids.h +++ b/src/gui/ids.h @@ -67,7 +67,8 @@ enum { BOOK_Lists, MENU_CopyName, MENU_CopyMetadata, - MENU_ClearMetadata, + MENU_ClearPluginMetadata, + MENU_ClearAllMetadata, //Main window - dynamically created IDs. MENU_LowestDynamicGameID, LIST_LoadOrder,