summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelo Castellani <udp.castellani@gmail.com>2011-05-22 19:07:41 -0400
committerStefan Dombrowski <stefan@uni-bonn.de>2011-05-25 19:34:25 +0200
commitb02081c00450d274c23b7198620ee7748756bd72 (patch)
treeaadc24f7ce866f916fb24b940eaf1f1db8ea8e88
parent6d9936d160b197fe68c5bb21972b197fb1b64ba4 (diff)
downloadmana-client-b02081c00450d274c23b7198620ee7748756bd72.tar.gz
mana-client-b02081c00450d274c23b7198620ee7748756bd72.tar.bz2
mana-client-b02081c00450d274c23b7198620ee7748756bd72.tar.xz
mana-client-b02081c00450d274c23b7198620ee7748756bd72.zip
Added more double clickable actions
- double clicking a do_choice item submits it - double clicking the npc chat will hit 'next' - double click to buy/sell a single item - clicking on no item in the inventory now deselects - double click to use/activate items in inventory
-rw-r--r--src/gui/buy.cpp10
-rw-r--r--src/gui/buy.h5
-rw-r--r--src/gui/inventorywindow.cpp12
-rw-r--r--src/gui/npcdialog.cpp15
-rw-r--r--src/gui/npcdialog.h10
-rw-r--r--src/gui/sell.cpp10
-rw-r--r--src/gui/sell.h5
-rw-r--r--src/gui/widgets/itemcontainer.cpp8
8 files changed, 69 insertions, 6 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 8e9f13e8..0ef187be 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -21,6 +21,7 @@
#include "gui/buy.h"
+#include "client.h"
#include "playerinfo.h"
#include "shopitem.h"
#include "units.h"
@@ -222,6 +223,15 @@ void BuyDialog::valueChanged(const gcn::SelectionEvent &event)
mSlider->gcn::Slider::setScale(1, mMaxItems);
}
+void BuyDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
+{
+ if (mouseEvent.getSource() == mShopItemList &&
+ isDoubleClick(mShopItemList->getSelected()))
+ {
+ action(gcn::ActionEvent(mBuyButton, mBuyButton->getActionEventId()));
+ }
+}
+
void BuyDialog::updateButtonsAndLabels()
{
const int selectedItem = mShopItemList->getSelected();
diff --git a/src/gui/buy.h b/src/gui/buy.h
index 68d318eb..2ecf89e1 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -77,6 +77,11 @@ class BuyDialog : public Window, public gcn::ActionListener,
void valueChanged(const gcn::SelectionEvent &event);
/**
+ * Allows for quick-buying by extending double-click events.
+ */
+ void mouseClicked(gcn::MouseEvent &mouseEvent);
+
+ /**
* Returns the name of item number i in the shop inventory.
*/
std::string getElementAt(int i);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 6a897700..54215ffc 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -21,6 +21,7 @@
#include "gui/inventorywindow.h"
+#include "client.h"
#include "inventory.h"
#include "item.h"
#include "units.h"
@@ -240,10 +241,17 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
{
Window::mouseClicked(event);
- if (event.getButton() == gcn::MouseEvent::RIGHT)
+ Item *item = mItems->getSelectedItem();
+
+ if (event.getSource() == mItems && item && isDoubleClick((int)item))
{
- Item *item = mItems->getSelectedItem();
+ if (isMainInventory() && item->getInfo().getActivatable())
+ action(gcn::ActionEvent(mUseButton, mUseButton->getActionEventId()));
+ }
+
+ if (event.getButton() == gcn::MouseEvent::RIGHT)
+ {
if (!item)
return;
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index bb508184..5209d69b 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -21,6 +21,7 @@
#include "gui/npcdialog.h"
+#include "client.h"
#include "configuration.h"
#include "event.h"
#include "eventlistener.h"
@@ -399,6 +400,20 @@ void NpcDialog::event(Event::Channel channel, const Event &event)
}
}
+void NpcDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
+{
+ if (mouseEvent.getSource() == mItemList &&
+ isDoubleClick(mItemList->getSelected()))
+ {
+ action(gcn::ActionEvent(mButton, mButton->getActionEventId()));
+ }
+ if (mouseEvent.getSource() == mTextBox && isDoubleClick((int)mTextBox))
+ {
+ if (mActionState == NPC_ACTION_NEXT || mActionState == NPC_ACTION_CLOSE)
+ action(gcn::ActionEvent(mButton, mButton->getActionEventId()));
+ }
+}
+
NpcDialog *NpcDialog::getActive()
{
if (instances.size() == 1)
diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h
index 433c045e..86a0e70c 100644
--- a/src/gui/npcdialog.h
+++ b/src/gui/npcdialog.h
@@ -44,8 +44,10 @@ class Button;
*
* \ingroup Interface
*/
-class NpcDialog : public Window, public gcn::ActionListener,
- public gcn::ListModel, public EventListener
+class NpcDialog : public Window,
+ public gcn::ActionListener,
+ public gcn::ListModel,
+ public EventListener
{
public:
NpcDialog(int npcId);
@@ -125,7 +127,7 @@ class NpcDialog : public Window, public gcn::ActionListener,
static bool isAnyInputFocused();
/**
- * Requests a interger from the user.
+ * Requests an integer from the user.
*/
void integerRequest(int defaultValue, int min, int max);
@@ -142,6 +144,8 @@ class NpcDialog : public Window, public gcn::ActionListener,
void event(Event::Channel channel, const Event &event);
+ void mouseClicked(gcn::MouseEvent &mouseEvent);
+
/**
* Returns the first active instance. Useful for pushing user
* interaction.
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index f33111d7..46bef092 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -21,6 +21,7 @@
#include "gui/sell.h"
+#include "client.h"
#include "playerinfo.h"
#include "shopitem.h"
#include "units.h"
@@ -248,6 +249,15 @@ void SellDialog::valueChanged(const gcn::SelectionEvent &event)
mSlider->gcn::Slider::setScale(1, mMaxItems);
}
+void SellDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
+{
+ if (mouseEvent.getSource() == mShopItemList &&
+ isDoubleClick(mShopItemList->getSelected()))
+ {
+ action(gcn::ActionEvent(mSellButton, mSellButton->getActionEventId()));
+ }
+}
+
void SellDialog::setMoney(int amount)
{
mPlayerMoney = amount;
diff --git a/src/gui/sell.h b/src/gui/sell.h
index 8db0b573..6b879d2f 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -68,6 +68,11 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener
void valueChanged(const gcn::SelectionEvent &event);
/**
+ * Allows for quick-selling by extending double-click events.
+ */
+ void mouseClicked(gcn::MouseEvent &mouseEvent);
+
+ /**
* Gives Player's Money amount
*/
void setMoney(int amount);
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 0967055b..2cd0fa23 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -278,12 +278,19 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
{
const int index = getSlotIndex(event.getX(), event.getY());
if (index == Inventory::NO_SLOT_INDEX)
+ {
+ mSelectionStatus = SEL_DESELECTING;
return;
+ }
Item *item = getItemAt(index);
if (!item)
+ {
+ mSelectionStatus = SEL_DESELECTING;
return;
+ }
+
// put item name into chat window
if (mDescItems)
@@ -293,7 +300,6 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
if (mSelectedIndex == index)
{
- mSelectionStatus = SEL_DESELECTING;
}
else if (item && item->getId())
{