From c54b987a4e4d28d35e8bafb03e1dba33b5fda4ab Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Mon, 23 Feb 2009 13:19:31 -0700 Subject: Hide the buy/sell dialogs when there is no NPC --- src/gui/buy.cpp | 7 +++++++ src/gui/buy.h | 5 +++++ src/gui/buysell.cpp | 7 +++++++ src/gui/buysell.h | 5 +++++ src/gui/sell.cpp | 7 +++++++ src/gui/sell.h | 5 +++++ 6 files changed, 36 insertions(+) (limited to 'src') diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index b31d48e1..c084c7c2 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -241,3 +241,10 @@ void BuyDialog::updateButtonsAndLabels() Units::formatCurrency(price).c_str(), Units::formatCurrency(mMoney - price).c_str())); } + +void BuyDialog::logic() +{ + Window::logic(); + + if (!current_npc) setVisible(false); +} diff --git a/src/gui/buy.h b/src/gui/buy.h index 0f1cfede..55a1898c 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -95,6 +95,11 @@ class BuyDialog : public Window, public gcn::ActionListener, */ void updateButtonsAndLabels(); + /** + * Check for current NPC + */ + void logic(); + private: Network *mNetwork; gcn::Button *mBuyButton; diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index 2d39eac7..8bf5f1f4 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -51,6 +51,13 @@ BuySellDialog::BuySellDialog(): requestFocus(); } +void BuySellDialog::logic() +{ + Window::logic(); + + if (!current_npc) setVisible(false); +} + void BuySellDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "Buy") { diff --git a/src/gui/buysell.h b/src/gui/buysell.h index e3cdc52a..754bb551 100644 --- a/src/gui/buysell.h +++ b/src/gui/buysell.h @@ -42,6 +42,11 @@ class BuySellDialog : public Window, public gcn::ActionListener */ BuySellDialog(); + /** + * Check for current NPC + */ + void logic(); + /** * Called when receiving actions from the widgets. */ diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index dad6af21..20a2a786 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -254,3 +254,10 @@ void SellDialog::updateButtonsAndLabels() Units::formatCurrency(income).c_str(), Units::formatCurrency(mPlayerMoney - income).c_str())); } + +void SellDialog::logic() +{ + Window::logic(); + + if (!current_npc) setVisible(false); +} diff --git a/src/gui/sell.h b/src/gui/sell.h index c11a7b7c..3777b91e 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -81,6 +81,11 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener */ void setMoney(int amount); + /** + * Check for current NPC + */ + void logic(); + private: /** * Updates the state of buttons and labels. -- cgit v1.2.3-70-g09d2