diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-01-01 04:01:00 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-01-01 04:01:00 +0100 |
commit | 69dddef124d870a874b544e478d4c19616fe8370 (patch) | |
tree | 1a1173d8a2f2a21a52b39304caad8154740dfc91 | |
parent | 68091131170ceec23a4a34f38c05cd233ac2db65 (diff) | |
download | mana-69dddef124d870a874b544e478d4c19616fe8370.tar.gz mana-69dddef124d870a874b544e478d4c19616fe8370.tar.bz2 mana-69dddef124d870a874b544e478d4c19616fe8370.tar.xz mana-69dddef124d870a874b544e478d4c19616fe8370.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.
-rw-r--r-- | src/gui/npc_text.h | 2 | ||||
-rw-r--r-- | src/gui/setup.cpp | 2 | ||||
-rw-r--r-- | src/gui/trade.cpp | 68 | ||||
-rw-r--r-- | src/gui/trade.h | 10 | ||||
-rw-r--r-- | tmw.cbp | 6 |
5 files changed, 57 insertions, 31 deletions
diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 76161f88..b6eccf95 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -45,7 +45,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 2f6c6140..2da9d1b5 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -42,6 +42,7 @@ extern Window *equipmentWindow; extern Window *helpWindow; extern Window *skillDialog; extern Window *itemShortcutWindow; +extern Window *tradeWindow; Setup::Setup(): Window("Setup") @@ -129,5 +130,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 aac6d587..9347cc02 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -46,11 +46,15 @@ TradeWindow::TradeWindow(Network *network): Window("Trade: You"), mNetwork(network), - mMyInventory(new Inventory()), - mPartnerInventory(new Inventory()) + mMyInventory(new Inventory), + mPartnerInventory(new Inventory) { 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 @@ -24,6 +24,7 @@ <Add library="SDL_image" /> <Add library="SDL_mixer" /> <Add library="SDL_net" /> + <Add library="SDL_ttf" /> <Add library="mingw32" /> <Add library="SDLmain" /> <Add library="SDL.dll" /> @@ -58,6 +59,7 @@ <Add library="SDL_mixer" /> <Add library="SDL_net" /> <Add library="SDL_image" /> + <Add library="SDL_ttf" /> <Add library="png" /> </Linker> </Target> @@ -218,8 +220,8 @@ <Unit filename="src\gui\textfield.h" /> <Unit filename="src\gui\trade.cpp" /> <Unit filename="src\gui\trade.h" /> - <Unit filename="src\gui\truetypefont.cpp"/> - <Unit filename="src\gui\truetypefont.h"/> + <Unit filename="src\gui\truetypefont.cpp" /> + <Unit filename="src\gui\truetypefont.h" /> <Unit filename="src\gui\updatewindow.cpp" /> <Unit filename="src\gui\updatewindow.h" /> <Unit filename="src\gui\vbox.cpp" /> |