diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-01-17 19:04:48 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-01-17 19:19:58 +0300 |
commit | ae651b87a1db4131733eaccc5736a287a06a0e6b (patch) | |
tree | a8ace476dd6daaf037692825120cb07714b0689f | |
parent | 55cbf74cbe2c40b4592e72621e40f8858fc376d9 (diff) | |
download | plus-ae651b87a1db4131733eaccc5736a287a06a0e6b.tar.gz plus-ae651b87a1db4131733eaccc5736a287a06a0e6b.tar.bz2 plus-ae651b87a1db4131733eaccc5736a287a06a0e6b.tar.xz plus-ae651b87a1db4131733eaccc5736a287a06a0e6b.zip |
Add support for add from context menu into chat item links with cards.
-rw-r--r-- | src/being/flooritem.cpp | 7 | ||||
-rw-r--r-- | src/being/flooritem.h | 2 | ||||
-rw-r--r-- | src/gui/popups/popupmenu.cpp | 43 | ||||
-rw-r--r-- | src/gui/popups/popupmenu.h | 3 |
4 files changed, 51 insertions, 4 deletions
diff --git a/src/being/flooritem.cpp b/src/being/flooritem.cpp index ae10a57aa..d0d0bf259 100644 --- a/src/being/flooritem.cpp +++ b/src/being/flooritem.cpp @@ -197,3 +197,10 @@ void FloorItem::draw(Graphics *const graphics, } BLOCK_END("FloorItem::draw") } + +int FloorItem::getCard(const int index) const +{ + if (index < 0 || index >= maxCards) + return 0; + return mCards[index]; +} diff --git a/src/being/flooritem.h b/src/being/flooritem.h index cedcaf96e..bb57039e1 100644 --- a/src/being/flooritem.h +++ b/src/being/flooritem.h @@ -116,6 +116,8 @@ class FloorItem final : public ActorSprite void setCards(const int *const cards, int sz); + int getCard(const int index) const; + int getRefine() const A_WARN_UNUSED { return mRefine; } diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index f60377b19..b1b33155c 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -573,6 +573,8 @@ void PopupMenu::showPopup(const int x, const int y, mY = y; mFloorItemId = floorItem->getId(); mType = ActorType::FloorItem; + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = floorItem->getCard(f); mBrowserBox->clearRows(); const std::string name = floorItem->getName(); mNick = name; @@ -601,7 +603,7 @@ void PopupMenu::showPopup(const int x, const int y, addProtection(); // TRANSLATORS: popup menu item // TRANSLATORS: add item name to chat - mBrowserBox->addRow("/addchat 'FLOORID'", _("Add to chat")); + mBrowserBox->addRow("/addchat 'FLOORID''CARDS'", _("Add to chat")); mBrowserBox->addRow("##3---"); // TRANSLATORS: popup menu item // TRANSLATORS: close menu @@ -957,6 +959,8 @@ void PopupMenu::showChangePos(const int x, const int y) mFloorItemId = BeingId_zero; mItemIndex = -1; mItemId = 0; + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = 0; mMapItem = nullptr; mNick.clear(); mType = ActorType::Unknown; @@ -1524,6 +1528,8 @@ void PopupMenu::handleLink(const std::string &link, if (item) { mFloorItemId = item->getId(); + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = item->getCard(f); showPopup(getX(), getY(), item); return; } @@ -1599,6 +1605,17 @@ void PopupMenu::handleLink(const std::string &link, replaceAll(cmd, "'MAPY'", toString(mY)); } + std::string cards; + for (int f = 0; f < maxCards; f ++) + { + const int id = mItemCards[f]; + if (id) + { + cards.append(","); + cards.append(toString(id)); + } + } + replaceAll(cmd, "'CARDS'", cards); const size_t pos = cmd.find(' '); const std::string type(cmd, 0, pos); std::string args(cmd, pos == std::string::npos ? cmd.size() : pos + 1); @@ -1617,6 +1634,8 @@ void PopupMenu::handleLink(const std::string &link, mFloorItemId = BeingId_zero; mItemId = 0; mItemIndex = -1; + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = 0; mItemColor = ItemColor_one; mMapItem = nullptr; mTab = nullptr; @@ -1641,6 +1660,8 @@ void PopupMenu::showPopup(Window *const parent, mItemId = item->getId(); mItemIndex = item->getInvIndex(); + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = item->getCard(f); mItemColor = item->getColor(); mWindow = parent; mX = x; @@ -1766,7 +1787,7 @@ void PopupMenu::showPopup(Window *const parent, } // TRANSLATORS: popup menu item // TRANSLATORS: add item name to chat - mBrowserBox->addRow("/addchat 'ITEMID'", _("Add to chat")); + mBrowserBox->addRow("/addchat 'ITEMID''CARDS'", _("Add to chat")); mBrowserBox->addRow("##3---"); // TRANSLATORS: popup menu item // TRANSLATORS: close menu @@ -1793,6 +1814,8 @@ void PopupMenu::showItemPopup(const int x, const int y, mItemId = itemId; mItemIndex = -1; mItemColor = color; + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = 0; mX = x; mY = y; mBrowserBox->clearRows(); @@ -1823,12 +1846,16 @@ void PopupMenu::showItemPopup(const int x, const int y, mItemId = item->getId(); mItemColor = item->getColor(); mItemIndex = item->getInvIndex(); + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = item->getCard(f); } else { mItemId = 0; mItemColor = ItemColor_one; mItemIndex = -1; + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = 0; } mNick.clear(); mBrowserBox->clearRows(); @@ -1845,7 +1872,7 @@ void PopupMenu::showItemPopup(const int x, const int y, } // TRANSLATORS: popup menu item // TRANSLATORS: add item name to chat - mBrowserBox->addRow("/addchat 'ITEMID'", _("Add to chat")); + mBrowserBox->addRow("/addchat 'ITEMID''CARDS'", _("Add to chat")); if (config.getBoolValue("enablePickupFilter")) { @@ -1876,6 +1903,8 @@ void PopupMenu::showDropPopup(const int x, const int y, Item *const item) mItemId = item->getId(); mItemColor = item->getColor(); mItemIndex = item->getInvIndex(); + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = item->getCard(f); const bool isProtected = PlayerInfo::isItemProtected(mItemId); addUseDrop(item, isProtected); if (InventoryWindow::isStorageActive()) @@ -1887,7 +1916,7 @@ void PopupMenu::showDropPopup(const int x, const int y, Item *const item) addProtection(); // TRANSLATORS: popup menu item // TRANSLATORS: add item name to chat - mBrowserBox->addRow("/addchat 'ITEMID'", _("Add to chat")); + mBrowserBox->addRow("/addchat 'ITEMID''CARDS'", _("Add to chat")); if (config.getBoolValue("enablePickupFilter")) { mNick = item->getName(); @@ -2140,6 +2169,8 @@ void PopupMenu::showUndressPopup(const int x, const int y, mItemId = item->getId(); mItemColor = item->getColor(); mItemIndex = item->getInvIndex(); + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = item->getCard(f); mX = x; mY = y; @@ -2250,6 +2281,8 @@ void PopupMenu::showSkillPopup(const SkillInfo *const info) // using mItemId as skill id mItemId = info->id; + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = 0; mBrowserBox->clearRows(); for (int f = 1; f <= info->level; f ++) { @@ -2594,6 +2627,8 @@ void PopupMenu::clear() } mItemIndex = -1; mItemId = 0; + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = 0; mMapItem = nullptr; mTab = nullptr; mSpell = nullptr; diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index 5c68254ac..798a4359a 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -25,6 +25,8 @@ #ifndef DYECMD +#include "const/resources/item/cards.h" + #include "enums/inventorytype.h" #include "enums/simpletypes/beingid.h" @@ -215,6 +217,7 @@ class PopupMenu final : public Popup, public LinkHandler BeingId mFloorItemId; int mItemId; int mItemIndex; + int mItemCards[maxCards]; ItemColor mItemColor; MapItem *mMapItem; ChatTab *mTab; |