From d8a7eaa14ef0fad24e19f6363db708a397f7f98b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 21 Sep 2016 18:43:26 +0300 Subject: Allow copy items from outfit into chat. --- src/gui/popups/popupmenu.cpp | 4 ++++ src/gui/windows/outfitwindow.cpp | 24 ++++++++++++++++++++++++ src/gui/windows/outfitwindow.h | 2 ++ 3 files changed, 30 insertions(+) (limited to 'src/gui') diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 5eb9d5813..2284e4cda 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -783,6 +783,10 @@ void PopupMenu::showOutfitsWindowPopup(const int x, const int y) // TRANSLATORS: popup menu header mBrowserBox->addRow(_("Outfits")); // TRANSLATORS: popup menu item + // TRANSLATORS: copy selected outfit to chat input + mBrowserBox->addRow("/outfittochat", _("Add to chat")); + mBrowserBox->addRow("##3---"); + // TRANSLATORS: popup menu item // TRANSLATORS: clear selected outfit mBrowserBox->addRow("clear outfit", _("Clear outfit")); mBrowserBox->addRow("##3---"); diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index 290cf924c..2a6ba3d6e 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -722,3 +722,27 @@ void OutfitWindow::clearCurrentOutfit() } save(); } + +std::string OutfitWindow::getOutfitString() const +{ + std::string str; + for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++) + { + const int id = mItems[mCurrentOutfit][i]; + if (id < 0) + continue; + + const ItemColor color = mItemColors[mCurrentOutfit][i]; + std::vector ids; + ids.push_back(id); + ids.push_back(CAST_S32(color)); + + const std::string name = ItemDB::getNamesStr(ids); + if (name.empty()) + continue; + str.append("["); + str.append(name); + str.append("] "); + } + return str; +} diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h index a6d31d3be..227a16737 100644 --- a/src/gui/windows/outfitwindow.h +++ b/src/gui/windows/outfitwindow.h @@ -97,6 +97,8 @@ class OutfitWindow final : public Window, void clearCurrentOutfit(); + std::string getOutfitString() const; + private: int getIndexFromGrid(const int pointX, const int pointY) const A_WARN_UNUSED; -- cgit v1.2.3-70-g09d2