summaryrefslogtreecommitdiff
path: root/src/gui/sell.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-19 20:20:11 -0600
committerIra Rice <irarice@gmail.com>2009-03-19 20:20:11 -0600
commitabffda81e5bab1fbf4870238e803bb5bae9d0df0 (patch)
tree661e6d5de6bc258b5fc2366bc5f46b0d73a7bdf6 /src/gui/sell.cpp
parentabeaa1184ae1f30adeeb6684748b3cf8e3f16b11 (diff)
downloadmana-client-abffda81e5bab1fbf4870238e803bb5bae9d0df0.tar.gz
mana-client-abffda81e5bab1fbf4870238e803bb5bae9d0df0.tar.bz2
mana-client-abffda81e5bab1fbf4870238e803bb5bae9d0df0.tar.xz
mana-client-abffda81e5bab1fbf4870238e803bb5bae9d0df0.zip
Reformatted the item amount window and the buy/sell windows so that
their guis are similarly laid out. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/sell.cpp')
-rw-r--r--src/gui/sell.cpp66
1 files changed, 44 insertions, 22 deletions
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index ed023227..47e44ffe 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -21,6 +21,7 @@
*/
#include "button.h"
+#include "gui.h"
#include "label.h"
#include "scrollarea.h"
#include "sell.h"
@@ -39,12 +40,13 @@
#include "../utils/strprintf.h"
SellDialog::SellDialog(Network *network):
- Window(_("Sell")),
+ Window("Sell"),
mNetwork(network),
mMaxItems(0), mAmountItems(0)
{
- setWindowName("Sell");
+ setWindowName(_("Sell"));
setResizable(true);
+ setCloseButton(true);
setMinWidth(260);
setMinHeight(230);
setDefaultSize(260, 230, ImageRect::CENTER);
@@ -54,21 +56,26 @@ SellDialog::SellDialog(Network *network):
mShopItemList = new ShopListBox(mShopItems, mShopItems);
mScrollArea = new ScrollArea(mShopItemList);
+ mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
+
mSlider = new Slider(1.0);
- mQuantityLabel = new Label("0");
+
+ mQuantityLabel = new Label(strprintf("%d / %d", mAmountItems, mMaxItems));
+ mQuantityLabel->setAlignment(gcn::Graphics::CENTER);
mMoneyLabel = new Label(
strprintf(_("Price: %d GP / Total: %d GP"), 0, 0));
+
mIncreaseButton = new Button("+", "+", this);
mDecreaseButton = new Button("-", "-", this);
mSellButton = new Button(_("Sell"), "sell", this);
mQuitButton = new Button(_("Quit"), "quit", this);
+ mAddMaxButton = new Button(_("Max"), "max", this);
mItemDescLabel = new Label(strprintf(_("Description: %s"), ""));
mItemEffectLabel = new Label(strprintf(_("Effect: %s"), ""));
- mIncreaseButton->setSize(20, 20);
- mDecreaseButton->setSize(20, 20);
+ mIncreaseButton->setSize(gui->getFontHeight(), gui->getFontHeight());
+ mDecreaseButton->setSize(gui->getFontHeight(), gui->getFontHeight());
- mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mIncreaseButton->setEnabled(false);
mDecreaseButton->setEnabled(false);
mSellButton->setEnabled(false);
@@ -79,16 +86,21 @@ SellDialog::SellDialog(Network *network):
mSlider->setActionEventId("slider");
mSlider->addActionListener(this);
- place(0, 0, mScrollArea, 5).setPadding(3);
- place(0, 1, mQuantityLabel, 2);
- place(2, 1, mSlider, 3);
- place(0, 2, mMoneyLabel, 5);
- place(0, 3, mItemEffectLabel, 5);
- place(0, 4, mItemDescLabel, 5);
+ ContainerPlacer place;
+ place = getPlacer(0, 0);
+
+ place(0, 0, mScrollArea, 8, 5).setPadding(3);
place(0, 5, mDecreaseButton);
- place(1, 5, mIncreaseButton);
- place(3, 5, mSellButton);
- place(4, 5, mQuitButton);
+ place(1, 5, mSlider, 3);
+ place(4, 5, mIncreaseButton);
+ place(5, 5, mQuantityLabel, 2);
+ place(7, 5, mAddMaxButton);
+ place(0, 6, mMoneyLabel, 8);
+ place(0, 7, mItemEffectLabel, 8);
+ place(0, 8, mItemDescLabel, 8);
+ place(6, 9, mSellButton);
+ place(7, 9, mQuitButton);
+
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
@@ -114,9 +126,7 @@ void SellDialog::reset()
void SellDialog::addItem(const Item *item, int price)
{
if (!item)
- {
return;
- }
mShopItems->addItem(item->getInvIndex(), item->getId(),
item->getQuantity(), price);
@@ -126,15 +136,14 @@ void SellDialog::addItem(const Item *item, int price)
void SellDialog::action(const gcn::ActionEvent &event)
{
- int selectedItem = mShopItemList->getSelected();
-
if (event.getId() == "quit")
{
- setVisible(false);
- current_npc = 0;
+ close();
return;
}
+ int selectedItem = mShopItemList->getSelected();
+
// The following actions require a valid item selection
if (selectedItem == -1 ||
selectedItem >= (int) mShopItems->getNumberOfElements())
@@ -159,6 +168,12 @@ void SellDialog::action(const gcn::ActionEvent &event)
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
+ else if (event.getId() == "max")
+ {
+ mAmountItems = mMaxItems;
+ mSlider->setValue(mAmountItems);
+ updateButtonsAndLabels();
+ }
else if (event.getId() == "sell" && mAmountItems > 0
&& mAmountItems <= mMaxItems)
{
@@ -270,5 +285,12 @@ void SellDialog::setVisible(bool visible)
{
Window::setVisible(visible);
- if (visible) requestFocus();
+ if (visible)
+ requestFocus();
+}
+
+void SellDialog::close()
+{
+ setVisible(false);
+ current_npc = 0;
}