diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-03-18 14:20:14 -0600 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-03-18 19:55:11 -0600 |
commit | 6f0d88e781c8b1a75858c769b3641aa8cd477314 (patch) | |
tree | 98891d219272074e437cd58087a7aaafc463c40a /src/gui | |
parent | 74fa304602e0e7ad845e606db8868b32f1d10864 (diff) | |
download | mana-6f0d88e781c8b1a75858c769b3641aa8cd477314.tar.gz mana-6f0d88e781c8b1a75858c769b3641aa8cd477314.tar.bz2 mana-6f0d88e781c8b1a75858c769b3641aa8cd477314.tar.xz mana-6f0d88e781c8b1a75858c769b3641aa8cd477314.zip |
Fix up the NPC interraction widnows a bit
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/buy.cpp | 7 | ||||
-rw-r--r-- | src/gui/buy.h | 1 | ||||
-rw-r--r-- | src/gui/buysell.cpp | 16 | ||||
-rw-r--r-- | src/gui/buysell.h | 10 | ||||
-rw-r--r-- | src/gui/item_amount.cpp | 24 | ||||
-rw-r--r-- | src/gui/npcstringdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/sell.cpp | 7 | ||||
-rw-r--r-- | src/gui/sell.h | 1 | ||||
-rw-r--r-- | src/gui/storagewindow.h | 4 | ||||
-rw-r--r-- | src/gui/trade.cpp | 27 | ||||
-rw-r--r-- | src/gui/trade.h | 13 | ||||
-rw-r--r-- | src/gui/window.cpp | 2 |
12 files changed, 78 insertions, 36 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 367a041e..ea1df204 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -236,3 +236,10 @@ void BuyDialog::updateButtonsAndLabels() mMoneyLabel->setCaption (strprintf(_("Price: %d GP / Total: %d GP"), price, mMoney - price)); } + +void BuyDialog::setVisible(bool visible) +{ + Window::setVisible(visible); + + if (visible) requestFocus(); +} diff --git a/src/gui/buy.h b/src/gui/buy.h index 17ab6e19..08697889 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -96,6 +96,7 @@ class BuyDialog : public Window, public gcn::ActionListener, */ void updateButtonsAndLabels(); + void setVisible(bool visible); private: Network *mNetwork; gcn::Button *mBuyButton; diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index 64ffdc3f..df222797 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -54,8 +54,22 @@ BuySellDialog::BuySellDialog(Network *network): getTitleBarHeight()), ImageRect::CENTER); loadWindowState(); +} + +void BuySellDialog::logic() +{ + Window::logic(); + + if (isVisible() && !current_npc) + setVisible(false); +} + +void BuySellDialog::setVisible(bool visible) +{ + Window::setVisible(visible); - requestFocus(); + if (visible) + requestFocus(); } void BuySellDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/buysell.h b/src/gui/buysell.h index 0842c0e1..c6989709 100644 --- a/src/gui/buysell.h +++ b/src/gui/buysell.h @@ -46,6 +46,16 @@ class BuySellDialog : public Window, public gcn::ActionListener BuySellDialog(Network *network); /** +<<<<<<< HEAD:src/gui/buysell.h +======= + * Check for current NPC + */ + void logic(); + + void setVisible(bool visible); + + /** +>>>>>>> f64903f... Fix up the NPC interraction widnows a bit:src/gui/buysell.h * Called when receiving actions from the widgets. */ void action(const gcn::ActionEvent &event); diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp index 8208d323..c5b27524 100644 --- a/src/gui/item_amount.cpp +++ b/src/gui/item_amount.cpp @@ -36,7 +36,9 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): Window("", true, parent), - mItem(item), mUsage(usage), mMax(mItem->getQuantity()) + mItem(item), + mMax(item->getQuantity()), + mUsage(usage) { // Integer field mItemAmountTextField = new IntTextField(1); @@ -53,10 +55,8 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): // Buttons Button *minusButton = new Button("-", "Minus", this); - minusButton->setSize(20, 20); Button *plusButton = new Button("+", "Plus", this); - plusButton->setSize(20, 20); - Button *okButton = new Button(_("Ok"), "Drop", this); + Button *okButton = new Button(_("Ok"), "Ok", this); Button *cancelButton = new Button(_("Cancel"), "Cancel", this); Button *addAllButton = new Button(_("All"), "All", this); @@ -64,10 +64,10 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): place(0, 0, minusButton); place(1, 0, mItemAmountTextField).setPadding(2); place(2, 0, plusButton); - place(4, 0, addAllButton, 2); + place(5, 0, addAllButton); place(0, 1, mItemAmountSlide, 6); - place(4, 2, okButton); - place(5, 2, cancelButton); + place(4, 2, cancelButton); + place(5, 2, okButton); reflowLayout(250, 0); resetAmount(); @@ -101,17 +101,17 @@ void ItemAmountWindow::resetAmount() void ItemAmountWindow::action(const gcn::ActionEvent &event) { - int amount = mItemAmountTextField->getValue(); + int amount = mItemAmountSlide->getValue(); if (event.getId() == "Cancel") { scheduleDelete(); } - else if (event.getId() == "Plus") + else if (event.getId() == "Plus" && amount < mMax) { amount++; } - else if (event.getId() == "Minus") + else if (event.getId() == "Minus" && amount > 0) { amount--; } @@ -121,9 +121,8 @@ void ItemAmountWindow::action(const gcn::ActionEvent &event) } else if (event.getId() == "Ok" || event.getId() == "All") { - if (event.getId() == "All") { + if (event.getId() == "All") amount = mMax; - } switch (mUsage) { @@ -145,6 +144,7 @@ void ItemAmountWindow::action(const gcn::ActionEvent &event) } scheduleDelete(); + return; } mItemAmountTextField->setValue(amount); diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index f50136ba..43d0722f 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -64,9 +64,7 @@ void NpcStringDialog::setValue(const std::string &value) void NpcStringDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "cancel") - { mValueField->setText(""); - } setVisible(false); NPC::mTalking = false; diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index b780b02b..ed023227 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -265,3 +265,10 @@ void SellDialog::updateButtonsAndLabels() (strprintf(_("Price: %d GP / Total: %d GP"), income, mPlayerMoney + income)); } + +void SellDialog::setVisible(bool visible) +{ + Window::setVisible(visible); + + if (visible) requestFocus(); +} diff --git a/src/gui/sell.h b/src/gui/sell.h index 5fb94c4e..c67a25b9 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -82,6 +82,7 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener */ void setMoney(int amount); + void setVisible(bool visible); private: /** * Updates the state of buttons and labels. diff --git a/src/gui/storagewindow.h b/src/gui/storagewindow.h index 86451bfe..8f02a618 100644 --- a/src/gui/storagewindow.h +++ b/src/gui/storagewindow.h @@ -80,6 +80,10 @@ class StorageWindow : public Window, gcn::ActionListener, gcn::SelectionListener */ void removeStore(Item* item, int ammount); + /** + * Closes the Storage Window, as well as telling the server that the + * window has been closed. + */ void close(); private: diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index bae0b651..18b86d4b 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -54,6 +54,7 @@ TradeWindow::TradeWindow(Network *network): setWindowName(_("Trade")); setDefaultSize(342, 209, ImageRect::CENTER); setResizable(true); + setCloseButton(true); setMinWidth(342); setMinHeight(209); @@ -90,10 +91,10 @@ TradeWindow::TradeWindow(Network *network): place(0, 0, mMoneyLabel2); place(1, 0, mMoneyField); place = getPlacer(0, 2); - place(0, 0, mAddButton); - place(1, 0, mOkButton); - place(2, 0, mTradeButton); - place(3, 0, mCancelButton); + place(4, 0, mCancelButton); + place(5, 0, mTradeButton); + place(6, 0, mAddButton); + place(7, 0, mOkButton); Layout &layout = getLayout(); layout.extend(0, 2, 2, 1); layout.setRowHeight(1, Layout::AUTO_SET); @@ -108,14 +109,6 @@ TradeWindow::~TradeWindow() { } -void TradeWindow::widgetResized(const gcn::Event &event) -{ - mMyItemContainer->setWidth(mMyScroll->getWidth()); - mPartnerItemContainer->setWidth(mPartnerScroll->getWidth()); - - Window::widgetResized(event); -} - void TradeWindow::addMoney(int amount) { mMoneyLabel->setCaption(strprintf(_("You get %d GP."), amount)); @@ -212,6 +205,7 @@ void TradeWindow::receivedOk(bool own) void TradeWindow::tradeItem(Item *item, int quantity) { + addItem(item->getId(), true, quantity, item->isEquipment()); MessageOut outMsg(mNetwork); outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST); outMsg.writeInt16(item->getInvIndex()); @@ -249,7 +243,8 @@ void TradeWindow::action(const gcn::ActionEvent &event) if (mMyInventory->contains(item)) { chatWindow->chatLog(_("Failed adding item. You can not " - "overlap one kind of item on the window."), BY_SERVER); + "overlap one kind of item on the window."), + BY_SERVER); return; } @@ -295,3 +290,9 @@ void TradeWindow::action(const gcn::ActionEvent &event) outMsg.writeInt16(CMSG_TRADE_OK); } } + +void TradeWindow::close() +{ + MessageOut outMsg(mNetwork); + outMsg.writeInt16(CMSG_TRADE_CANCEL_REQUEST); +} diff --git a/src/gui/trade.h b/src/gui/trade.h index f4a6b5cd..c4d3076a 100644 --- a/src/gui/trade.h +++ b/src/gui/trade.h @@ -57,13 +57,6 @@ 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); @@ -119,6 +112,12 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener */ void action(const gcn::ActionEvent &event); + /** + * Closes the Trade Window, as well as telling the server that the + * window has been closed. + */ + void close(); + private: Network *mNetwork; diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 404f5746..13c8f4ce 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -536,7 +536,7 @@ void Window::loadWindowState() void Window::saveWindowState() { // Saving X, Y and Width and Height for resizables in the config - if (!mWindowName.empty()) + if (!mWindowName.empty() && mWindowName != "window") { config.setValue(mWindowName + "WinX", getX()); config.setValue(mWindowName + "WinY", getY()); |