diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-01-01 04:01:00 +0100 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-05 20:51:29 -0700 |
commit | d87d6368b23fe11e5217d674ed1a4bad05d9bf90 (patch) | |
tree | d82c7fc1f629fe4806c6d4ce8f8be5902ccc3b8a /src | |
parent | 4a4b1d993a1c230b0769630949187f299ec6072c (diff) | |
download | mana-client-d87d6368b23fe11e5217d674ed1a4bad05d9bf90.tar.gz mana-client-d87d6368b23fe11e5217d674ed1a4bad05d9bf90.tar.bz2 mana-client-d87d6368b23fe11e5217d674ed1a4bad05d9bf90.tar.xz mana-client-d87d6368b23fe11e5217d674ed1a4bad05d9bf90.zip |
Made trade window resizable
Also fixed overlap between description label and the buttons and added the
SDL_ttf library to the Code::Blocks project file.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/npc_text.h | 2 | ||||
-rw-r--r-- | src/gui/setup.cpp | 2 | ||||
-rw-r--r-- | src/gui/trade.cpp | 64 | ||||
-rw-r--r-- | src/gui/trade.h | 10 |
4 files changed, 51 insertions, 27 deletions
diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index b647b9a1..75968fa9 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -50,7 +50,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener NpcTextDialog(); /** - * Called when resizing the window + * Called when resizing the window. * * @param event The calling event */ diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index baa2bf2b..a61d3bb2 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -42,6 +42,7 @@ extern Window *minimap; extern Window *skillDialog; extern Window *statusWindow; extern Window *itemShortcutWindow; +extern Window *tradeWindow; Setup::Setup(): Window("Setup") @@ -134,5 +135,6 @@ void Setup::action(const gcn::ActionEvent &event) helpWindow->resetToDefaultSize(); skillDialog->resetToDefaultSize(); itemShortcutWindow->resetToDefaultSize(); + tradeWindow->resetToDefaultSize(); } } diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 843c9663..bae8daa6 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -50,7 +50,11 @@ TradeWindow::TradeWindow(Network *network): mPartnerInventory(new Inventory(INVENTORY_SIZE)) { setWindowName("Trade"); - setDefaultSize(115, 227, 332, 209); + setDefaultSize(115, 227, 342, 209); + setResizable(true); + + setMinWidth(342); + setMinHeight(209); mAddButton = new Button("Add", "add", this); mOkButton = new Button("Ok", "ok", this); @@ -73,7 +77,8 @@ TradeWindow::TradeWindow(Network *network): mMoneyLabel = new gcn::Label("You get: 0 GP"); mMoneyLabel2 = new gcn::Label("You give:"); - mMoneyField = new TextField(); + mMoneyField = new TextField; + mMoneyField->setWidth(50); mAddButton->adjustSize(); mOkButton->adjustSize(); @@ -98,38 +103,49 @@ TradeWindow::TradeWindow(Network *network): add(mMoneyLabel); loadWindowState(); +} + +TradeWindow::~TradeWindow() +{ +} - gcn::Rectangle area = getChildrenArea(); - int width = area.width; - int height = area.height; +void TradeWindow::widgetResized(const gcn::Event &event) +{ + Window::widgetResized(event); - mMoneyField->setPosition(8 + 60, height - 20); - mMoneyField->setWidth(50); + const gcn::Rectangle &area = getChildrenArea(); + const int width = area.width; + const int height = area.height; + + mMoneyLabel2->setPosition(8, height - 8 - mMoneyLabel2->getHeight()); + mMoneyField->setPosition( + 8 + mMoneyLabel2->getWidth(), + height - 8 - mMoneyField->getHeight()); + mMoneyLabel->setPosition( + mMoneyField->getX() + mMoneyField->getWidth() + 6, + mMoneyLabel2->getY()); - mMoneyLabel->setPosition(8 + 60 + 50 + 6, height - 20); - mMoneyLabel2->setPosition(8, height - 20); + mCancelButton->setPosition(width - 54, height - 8 - mCancelButton->getHeight()); + mTradeButton->setPosition(mCancelButton->getX() - 41, mCancelButton->getY()); + mOkButton->setPosition(mTradeButton->getX() - 24, mCancelButton->getY()); + mAddButton->setPosition(mOkButton->getX() - 31, mCancelButton->getY()); - mCancelButton->setPosition(width - 54, height - 49); - mTradeButton->setPosition(mCancelButton->getX() - 41, height - 49); - mOkButton->setPosition(mTradeButton->getX() - 24, height - 49); - mAddButton->setPosition(mOkButton->getX() - 31, height - 49); + mItemDescriptionLabel->setPosition(8, + mOkButton->getY() - mItemDescriptionLabel->getHeight() - 4); + mItemNameLabel->setPosition(8, + mItemDescriptionLabel->getY() - mItemNameLabel->getHeight() - 4); + + const int remaining = mItemNameLabel->getY() - 4 - 8 - 8; + const int itemContainerHeight = remaining / 2; mMyItemContainer->setSize(width - 24 - 12 - 1, (INVENTORY_SIZE * 24) / (width / 24) - 1); - mMyScroll->setSize(width - 16, (height - 76) / 2); + mMyScroll->setSize(width - 16, itemContainerHeight); mPartnerItemContainer->setSize(width - 24 - 12 - 1, (INVENTORY_SIZE * 24) / (width / 24) - 1); - mPartnerScroll->setSize(width - 16, (height - 76) / 2); - - mItemNameLabel->setPosition(8, - mPartnerScroll->getY() + mPartnerScroll->getHeight() + 4); - mItemDescriptionLabel->setPosition(8, - mItemNameLabel->getY() + mItemNameLabel->getHeight() + 4); -} - -TradeWindow::~TradeWindow() -{ + mPartnerScroll->setSize(width - 16, itemContainerHeight); + mPartnerScroll->setPosition(8, 8 + itemContainerHeight + 8); } void TradeWindow::addMoney(int amount) diff --git a/src/gui/trade.h b/src/gui/trade.h index 5d587991..fafe138a 100644 --- a/src/gui/trade.h +++ b/src/gui/trade.h @@ -56,6 +56,13 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener ~TradeWindow(); /** + * Called when resizing the window. + * + * @param event The calling event + */ + void widgetResized(const gcn::Event &event); + + /** * Add money to the trade window. */ void addMoney(int quantity); @@ -98,8 +105,7 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener /** * Send trade packet. */ - void - tradeItem(Item *item, int quantity); + void tradeItem(Item *item, int quantity); /** * Updates the labels and makes sure only one item is selected in |