From bb06bb5fd0fcaac614ed44df4a9200c81f53f759 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Mon, 10 Feb 2014 18:16:57 +0000 Subject: [PATCH] Mini editor drag 'n' drop improvements. Now doesn't do anything if you try to add the selected plugin or a plugin that's already listed in the box. --- src/gui/editor.cpp | 10 +++++----- src/gui/editor.h | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp index add38b47..661c29a3 100644 --- a/src/gui/editor.cpp +++ b/src/gui/editor.cpp @@ -38,11 +38,11 @@ using namespace std; // TextDropTarget class ////////////////////////////// -TextDropTarget::TextDropTarget(wxListView * owner) { - targetOwner = owner; -} +TextDropTarget::TextDropTarget(wxListView * owner, wxStaticText * name) : targetOwner(owner), targetName(name) {} bool TextDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString &data) { + if (data == targetName->GetLabelText() || targetOwner->FindItem(-1, data) != wxNOT_FOUND) + return false; targetOwner->InsertItem(targetOwner->GetItemCount(), data); return true; } @@ -160,7 +160,7 @@ MiniEditor::MiniEditor(wxWindow *parent, const wxString& title, const std::list< pluginList = new wxListView(this, LIST_Plugins, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); loadAfterList = new wxListView(editingPanel, LIST_LoadAfter, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); - loadAfterList->SetDropTarget(new TextDropTarget(loadAfterList)); + loadAfterList->SetDropTarget(new TextDropTarget(loadAfterList, pluginText)); removeBtn = new wxButton(editingPanel, BUTTON_RemoveRow, translate("Remove Plugin")); @@ -334,7 +334,7 @@ void MiniEditor::OnFilterToggle(wxCommandEvent& event) { for (list::const_iterator it = plugins.begin(); it != plugins.end(); ++it) { //Want to filter to show only those the selected plugin can load after validly, and which also either conflict with it, //or which load a BSA (if the selected plugin loads a BSA). - if (!it->MustLoadAfter(*pos) && (pos->DoFormIDsOverlap(*it) || (loadsBSA && it->LoadsBSA(_game)))) { + if (*it == *pos || !it->MustLoadAfter(*pos) && (pos->DoFormIDsOverlap(*it) || (loadsBSA && it->LoadsBSA(_game)))) { pluginList->InsertItem(i, FromUTF8(it->Name())); pluginList->SetItem(i, 1, FromUTF8(boss::IntToString(it->Priority()))); if (it->FormIDs().empty()) { diff --git a/src/gui/editor.h b/src/gui/editor.h index 116c9b18..1ef7eae5 100644 --- a/src/gui/editor.h +++ b/src/gui/editor.h @@ -53,10 +53,11 @@ class TextDropTarget : public wxTextDropTarget { //Class to override virtual functions. public: - TextDropTarget(wxListView * owner); + TextDropTarget(wxListView * owner, wxStaticText * name); virtual bool OnDropText(wxCoord x, wxCoord y, const wxString &data); private: - wxListView *targetOwner; + wxListView * targetOwner; + wxStaticText * targetName; }; class CommonEditor {