summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-08-29 00:31:59 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-08-29 00:31:59 +0000
commitc8c4fd4850b543215faf4de83cc0f93c17b5a038 (patch)
tree55776c951c1dee2500d645542a3cb548a2f036b0 /src
parent3641a74507d692a7fbababfd8beb738f71e48acb (diff)
downloadmana-c8c4fd4850b543215faf4de83cc0f93c17b5a038.tar.gz
mana-c8c4fd4850b543215faf4de83cc0f93c17b5a038.tar.bz2
mana-c8c4fd4850b543215faf4de83cc0f93c17b5a038.tar.xz
mana-c8c4fd4850b543215faf4de83cc0f93c17b5a038.zip
Made sell dialog resizable and tweaked inventory resize code a bit.
Diffstat (limited to 'src')
-rw-r--r--src/gui/inventorywindow.cpp41
-rw-r--r--src/gui/sell.cpp95
-rw-r--r--src/gui/sell.h16
-rw-r--r--src/particle.h2
-rw-r--r--src/vector.h2
5 files changed, 99 insertions, 57 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 6e5ae84a..35cdde93 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -61,7 +61,6 @@ InventoryWindow::InventoryWindow():
mItems->addSelectionListener(this);
mInvenScroll = new ScrollArea(mItems);
- mInvenScroll->setPosition(8, 8);
mInvenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mItemNameLabel = new gcn::Label("Name:");
@@ -80,7 +79,7 @@ InventoryWindow::InventoryWindow():
add(mItemEffectLabel);
add(mWeightLabel);
- mUseButton->setSize(48, mUseButton->getHeight());
+ mUseButton->setSize(60, mUseButton->getHeight());
addWindowListener(this);
loadWindowState();
@@ -98,7 +97,6 @@ void InventoryWindow::logic()
mWeightLabel->setCaption(
"Total Weight: " + toString(player_node->mTotalWeight) + " - "
"Maximum Weight: " + toString(player_node->mMaxWeight));
- mWeightLabel->adjustSize();
}
void InventoryWindow::action(const gcn::ActionEvent &event)
@@ -150,10 +148,6 @@ void InventoryWindow::selectionChanged(const SelectionEvent &event)
mItemEffectLabel->setCaption(SomeText);
SomeText = "Description: " + itemInfo.getDescription();
mItemDescriptionLabel->setCaption(SomeText);
-
- mItemNameLabel->adjustSize();
- mItemEffectLabel->adjustSize();
- mItemDescriptionLabel->adjustSize();
}
}
@@ -188,17 +182,28 @@ void InventoryWindow::windowResized(const WindowEvent &event)
columns = 1;
}
- // Resize widgets
- mUseButton->setPosition(8, height - 24);
- mDropButton->setPosition(48 + 16, height - 24);
- mInvenScroll->setSize(width - 16, height - 110);
-
- mItemNameLabel->setPosition(8,
- mInvenScroll->getY() + mInvenScroll->getHeight() + 4);
- mItemEffectLabel->setPosition(8,
- mItemNameLabel->getY() + mItemNameLabel->getHeight() + 4);
- mItemDescriptionLabel->setPosition(8,
- mItemEffectLabel->getY() + mItemEffectLabel->getHeight() + 4);
+ // Adjust widgets
+ mUseButton->setPosition(8, height - 8 - mUseButton->getHeight());
+ mDropButton->setPosition(8 + mUseButton->getWidth() + 5,
+ mUseButton->getY());
+
+ mItemNameLabel->setDimension(gcn::Rectangle(8,
+ mUseButton->getY() - 5 - mItemNameLabel->getHeight(),
+ width - 16,
+ mItemNameLabel->getHeight()));
+ mItemEffectLabel->setDimension(gcn::Rectangle(8,
+ mItemNameLabel->getY() - 5 - mItemEffectLabel->getHeight(),
+ width - 16,
+ mItemEffectLabel->getHeight()));
+ mItemDescriptionLabel->setDimension(gcn::Rectangle(8,
+ mItemEffectLabel->getY() - 5 - mItemDescriptionLabel->getHeight(),
+ width - 16,
+ mItemDescriptionLabel->getHeight()));
+
+ mInvenScroll->setSize(width - 16,
+ mItemDescriptionLabel->getY() - mWeightLabel->getHeight() - 18);
+
+ mWeightLabel->setWidth(width - 16);
}
void InventoryWindow::updateButtons()
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 399ae62b..63e7d704 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -49,58 +49,44 @@ SellDialog::SellDialog(Network *network):
mNetwork(network),
mMaxItems(0), mAmountItems(0)
{
+ setResizable(true);
+ setMinWidth(260);
+ setMinHeight(230);
+ setDefaultSize(0, 0, 260, 230);
+
mShopItems = new ShopItems();
mShopItemList = new ShopListBox(mShopItems, mShopItems);
- ScrollArea *scrollArea = new ScrollArea(mShopItemList);
+ mScrollArea = new ScrollArea(mShopItemList);
mSlider = new Slider(1.0);
mQuantityLabel = new gcn::Label("0");
mMoneyLabel = new gcn::Label("Money: 0 GP / Total: 0 GP");
- mItemDescLabel = new gcn::Label("Description:");
- mItemEffectLabel = new gcn::Label("Effect:");
mIncreaseButton = new Button("+", "+", this);
mDecreaseButton = new Button("-", "-", this);
mSellButton = new Button("Sell", "sell", this);
- Button *quitButton = new Button("Quit", "quit", this);
- mSellButton->setEnabled(false);
-
- setContentSize(260, 210);
- scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- scrollArea->setDimension(gcn::Rectangle(5, 5, 250, 110));
- mShopItemList->setDimension(gcn::Rectangle(5, 5, 238, 110));
-
- mSlider->setDimension(gcn::Rectangle(5, 120, 200, 10));
- mSlider->setEnabled(false);
-
- mQuantityLabel->setPosition(215, 120);
+ mQuitButton = new Button("Quit", "quit", this);
+ mItemDescLabel = new gcn::Label("Description:");
+ mItemEffectLabel = new gcn::Label("Effect:");
- mIncreaseButton->setPosition(40, 186);
mIncreaseButton->setSize(20, 20);
- mIncreaseButton->setEnabled(false);
-
- mDecreaseButton->setPosition(10, 186);
mDecreaseButton->setSize(20, 20);
- mDecreaseButton->setEnabled(false);
-
- mMoneyLabel->setPosition(5, 130);
- mItemEffectLabel->setDimension(gcn::Rectangle(5, 150, 240, 14));
- mItemDescLabel->setDimension(gcn::Rectangle(5, 169, 240, 14));
+ mQuantityLabel->setWidth(60);
- mSellButton->setPosition(175, 186);
+ mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
+ mIncreaseButton->setEnabled(false);
+ mDecreaseButton->setEnabled(false);
mSellButton->setEnabled(false);
+ mSlider->setEnabled(false);
- quitButton->setPosition(208, 186);
-
+ mShopItemList->setPriceCheck(false);
mShopItemList->setActionEventId("item");
mSlider->setActionEventId("slider");
- mShopItemList->setPriceCheck(false);
-
mShopItemList->addActionListener(this);
mShopItemList->addSelectionListener(this);
mSlider->addActionListener(this);
- add(scrollArea);
+ add(mScrollArea);
add(mSlider);
add(mQuantityLabel);
add(mMoneyLabel);
@@ -109,8 +95,10 @@ SellDialog::SellDialog(Network *network):
add(mIncreaseButton);
add(mDecreaseButton);
add(mSellButton);
- add(quitButton);
+ add(mQuitButton);
+ addWindowListener(this);
+ loadWindowState();
setLocationRelativeTo(getParent());
}
@@ -226,6 +214,49 @@ void SellDialog::selectionChanged(const SelectionEvent &event)
mSlider->gcn::Slider::setScale(1, mMaxItems);
}
+void SellDialog::windowResized(const WindowEvent &event)
+{
+ gcn::Rectangle area = getChildrenArea();
+ int width = area.width;
+ int height = area.height;
+
+ mDecreaseButton->setPosition(8, height - 8 - mDecreaseButton->getHeight());
+ mIncreaseButton->setPosition(
+ mDecreaseButton->getX() + mDecreaseButton->getWidth() + 5,
+ mDecreaseButton->getY());
+
+ mQuitButton->setPosition(
+ width - 8 - mQuitButton->getWidth(),
+ height - 8 - mQuitButton->getHeight());
+ mSellButton->setPosition(
+ mQuitButton->getX() - 5 - mSellButton->getWidth(),
+ mQuitButton->getY());
+
+ mItemDescLabel->setDimension(gcn::Rectangle(8,
+ mSellButton->getY() - 5 - mItemDescLabel->getHeight(),
+ width - 16,
+ mItemDescLabel->getHeight()));
+ mItemEffectLabel->setDimension(gcn::Rectangle(8,
+ mItemDescLabel->getY() - 5 - mItemEffectLabel->getHeight(),
+ width - 16,
+ mItemEffectLabel->getHeight()));
+ mMoneyLabel->setDimension(gcn::Rectangle(8,
+ mItemEffectLabel->getY() - 5 - mMoneyLabel->getHeight(),
+ width - 16,
+ mMoneyLabel->getHeight()));
+
+ mQuantityLabel->setPosition(
+ width - mQuantityLabel->getWidth() - 8,
+ mMoneyLabel->getY() - 5 - mQuantityLabel->getHeight());
+ mSlider->setDimension(gcn::Rectangle(8,
+ mQuantityLabel->getY(),
+ mQuantityLabel->getX() - 8 - 8,
+ 10));
+
+ mScrollArea->setDimension(gcn::Rectangle(8, 8, width - 16,
+ mSlider->getY() - 5 - 8));
+}
+
void SellDialog::setMoney(int amount)
{
mPlayerMoney = amount;
@@ -269,8 +300,6 @@ SellDialog::updateButtonsAndLabels()
// Update the quantity and money labels
mQuantityLabel->setCaption(
toString(mAmountItems) + " / " + toString(mMaxItems));
- mQuantityLabel->adjustSize();
mMoneyLabel->setCaption("Money: " + toString(income) + " GP / Total: "
+ toString(mPlayerMoney + income) + " GP");
- mMoneyLabel->adjustSize();
}
diff --git a/src/gui/sell.h b/src/gui/sell.h
index d3ea7136..d5c70c45 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -28,6 +28,7 @@
#include "window.h"
#include "selectionlistener.h"
+#include "windowlistener.h"
#include "../guichanfwd.h"
@@ -41,7 +42,8 @@ class ShopListBox;
*
* \ingroup Interface
*/
-class SellDialog : public Window, gcn::ActionListener, SelectionListener
+class SellDialog : public Window, gcn::ActionListener, SelectionListener,
+ WindowListener
{
public:
/**
@@ -79,22 +81,28 @@ class SellDialog : public Window, gcn::ActionListener, SelectionListener
void selectionChanged(const SelectionEvent &event);
/**
+ * Called whenever the window is resized.
+ */
+ void windowResized(const WindowEvent &event);
+
+ /**
* Gives Player's Money amount
*/
void setMoney(int amount);
+ private:
/**
* Updates the state of buttons and labels.
*/
- void
- updateButtonsAndLabels();
+ void updateButtonsAndLabels();
- private:
Network *mNetwork;
gcn::Button *mSellButton;
+ gcn::Button *mQuitButton;
gcn::Button *mIncreaseButton;
gcn::Button *mDecreaseButton;
ShopListBox *mShopItemList;
+ gcn::ScrollArea *mScrollArea;
gcn::Label *mMoneyLabel;
gcn::Label *mItemDescLabel;
gcn::Label *mItemEffectLabel;
diff --git a/src/particle.h b/src/particle.h
index 6a13cca1..dd7c5ee2 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -277,7 +277,7 @@ class Particle : public Sprite
// dynamic particle
Vector mVelocity; /**< Speed in pixels per game-tick. */
- float mGravity; /**< Downward acceleration in pixels per game-tick² */
+ float mGravity; /**< Downward acceleration in pixels per game-tick. */
int mRandomnes; /**< Ammount of random vector change */
float mBounce; /**< How much the particle bounces off when hitting the ground */
diff --git a/src/vector.h b/src/vector.h
index d6a74886..7a5da241 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -18,7 +18,7 @@
* along with The Mana World; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: tileset.h 3218 2007-03-21 21:56:12Z b_lindeijer $
+ * $Id$
*/
#ifndef _TMW_VECTOR_H_