summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/buydialog.cpp27
-rw-r--r--src/gui/selldialog.cpp22
-rw-r--r--src/gui/widgets/listbox.cpp1
3 files changed, 28 insertions, 22 deletions
diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp
index 30eed9ae2..fd2e3a5f3 100644
--- a/src/gui/buydialog.cpp
+++ b/src/gui/buydialog.cpp
@@ -119,6 +119,10 @@ void BuyDialog::init()
mSlider->setActionEventId("slider");
mSlider->addActionListener(this);
+
+ mShopItemList->setDistributeMousePressed(false);
+ mShopItemList->setActionEventId("buy");
+ mShopItemList->addActionListener(this);
mShopItemList->addSelectionListener(this);
ContainerPlacer placer;
@@ -184,49 +188,47 @@ void BuyDialog::addItem(const int id, const unsigned char color,
void BuyDialog::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "quit")
+ const std::string &eventId = event.getId();
+
+ if (eventId == "quit")
{
close();
return;
}
-
const int selectedItem = mShopItemList->getSelected();
// The following actions require a valid selection
- if (selectedItem < 0 ||
- selectedItem >= mShopItems->getNumberOfElements())
- {
+ if (selectedItem < 0 || selectedItem >= mShopItems->getNumberOfElements())
return;
- }
- if (event.getId() == "slider")
+ if (eventId == "slider")
{
mAmountItems = static_cast<int>(mSlider->getValue());
mAmountField->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (event.getId() == "inc" && mAmountItems < mMaxItems)
+ else if (eventId == "inc" && mAmountItems < mMaxItems)
{
mAmountItems++;
mSlider->setValue(mAmountItems);
mAmountField->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (event.getId() == "dec" && mAmountItems > 1)
+ else if (eventId == "dec" && mAmountItems > 1)
{
mAmountItems--;
mSlider->setValue(mAmountItems);
mAmountField->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (event.getId() == "max")
+ else if (eventId == "max")
{
mAmountItems = mMaxItems;
mSlider->setValue(mAmountItems);
mAmountField->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (event.getId() == "amount")
+ else if (eventId == "amount")
{
mAmountItems = mAmountField->getValue();
mSlider->setValue(mAmountItems);
@@ -235,8 +237,7 @@ void BuyDialog::action(const gcn::ActionEvent &event)
// TODO: Actually we'd have a bug elsewhere if this check for the number
// of items to be bought ever fails, Bertram removed the assertions, is
// there a better way to ensure this fails in an _obvious_ way in C++?
- else if (event.getId() == "buy" && mAmountItems > 0 &&
- mAmountItems <= mMaxItems)
+ else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems)
{
if (mNpcId != -1)
{
diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp
index 06b622930..e299362cc 100644
--- a/src/gui/selldialog.cpp
+++ b/src/gui/selldialog.cpp
@@ -105,8 +105,12 @@ void SellDialog::init()
mSellButton->setEnabled(false);
mSlider->setEnabled(false);
+ mShopItemList->setDistributeMousePressed(false);
mShopItemList->setPriceCheck(false);
mShopItemList->addSelectionListener(this);
+ mShopItemList->setActionEventId("sell");
+ mShopItemList->addActionListener(this);
+
mSlider->setActionEventId("slider");
mSlider->addActionListener(this);
@@ -174,7 +178,9 @@ void SellDialog::addItem(const int id, const unsigned char color,
void SellDialog::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "quit")
+ const std::string &eventId = event.getId();
+
+ if (eventId == "quit")
{
close();
return;
@@ -183,36 +189,36 @@ void SellDialog::action(const gcn::ActionEvent &event)
const int selectedItem = mShopItemList->getSelected();
// The following actions require a valid item selection
- if (selectedItem == -1 ||
- selectedItem >= mShopItems->getNumberOfElements())
+ if (selectedItem == -1
+ || selectedItem >= mShopItems->getNumberOfElements())
{
return;
}
- if (event.getId() == "slider")
+ if (eventId == "slider")
{
mAmountItems = static_cast<int>(mSlider->getValue());
updateButtonsAndLabels();
}
- else if (event.getId() == "inc" && mAmountItems < mMaxItems)
+ else if (eventId == "inc" && mAmountItems < mMaxItems)
{
mAmountItems++;
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (event.getId() == "dec" && mAmountItems > 1)
+ else if (eventId == "dec" && mAmountItems > 1)
{
mAmountItems--;
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (event.getId() == "max")
+ else if (eventId == "max")
{
mAmountItems = mMaxItems;
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (event.getId() == "sell" && mAmountItems > 0
+ else if (eventId == "sell" && mAmountItems > 0
&& mAmountItems <= mMaxItems)
{
if (mNpcId != -1)
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 978907f78..499d7b07c 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -145,7 +145,6 @@ void ListBox::mouseWheelMovedDown(gcn::MouseEvent &mouseEvent A_UNUSED)
void ListBox::mousePressed(gcn::MouseEvent &event)
{
-
if (mDistributeMousePressed)
{
gcn::ListBox::mousePressed(event);