From db37dcd73f3116917584e81a474f70e0d0786bc4 Mon Sep 17 00:00:00 2001 From: David Athay Date: Tue, 13 Jan 2009 12:48:36 +0000 Subject: Added WoW style item adding to chat window. Right Ctrl and Left click to put the item in the chat input. Left click the item link to show a popup description, and click the link again to remove the popup. --- src/gui/itemcontainer.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/gui/itemcontainer.cpp') diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 141b4360..4a90510c 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -20,6 +20,7 @@ */ #include "itemcontainer.h" +#include "chat.h" #include #include @@ -61,7 +62,8 @@ ItemContainer::ItemContainer(Inventory *inventory, mSelectedItem(NULL), mHighlightedItem(NULL), mSelectionStatus(SEL_NONE), - mSwapItems(false) + mSwapItems(false), + mDescItems(false) { mItemPopup = new ItemPopup(); setFocusable(true); @@ -195,6 +197,10 @@ ItemContainer::keyPressed(gcn::KeyEvent &event) case Key::LEFT_ALT: case Key::RIGHT_ALT: mSwapItems = true; + break; + case Key::RIGHT_CONTROL: + mDescItems = true; + break; } } @@ -206,13 +212,16 @@ ItemContainer::keyReleased(gcn::KeyEvent &event) case Key::LEFT_ALT: case Key::RIGHT_ALT: mSwapItems = false; + break; + case Key::RIGHT_CONTROL: + mDescItems = false; + break; } } void ItemContainer::mousePressed(gcn::MouseEvent &event) { - const int button = event.getButton(); if (button == gcn::MouseEvent::LEFT || button == gcn::MouseEvent::RIGHT) { @@ -223,6 +232,12 @@ ItemContainer::mousePressed(gcn::MouseEvent &event) Item *item = mInventory->getItem(index); + // put item name into chat window + if (mDescItems) + { + chatWindow->addItemText(item->getId(), item->getInfo().getName()); + } + if (mSelectedItem && mSelectedItem == item) { mSelectionStatus = SEL_DESELECTING; @@ -288,7 +303,7 @@ void ItemContainer::mouseMoved(gcn::MouseEvent &event) { mItemPopup->setPosition(getParent()->getParent()->getX() + getParent()->getParent()->getWidth(), getParent()->getParent()->getY()); - mItemPopup->setItem(item); + mItemPopup->setItem(item->getInfo()); mItemPopup->setVisible(true); } -- cgit v1.2.3-70-g09d2