diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-08-01 21:32:16 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-08-01 21:35:09 -0600 |
commit | a3e61c0e830c46b51c0d135962ad361c02b93243 (patch) | |
tree | 3b94948be5750c8f968ea89723799eb4f119c063 /src/playerinfo.cpp | |
parent | 0e189bbe81c88283438aabb4fec3ba30920d3a36 (diff) | |
download | mana-a3e61c0e830c46b51c0d135962ad361c02b93243.tar.gz mana-a3e61c0e830c46b51c0d135962ad361c02b93243.tar.bz2 mana-a3e61c0e830c46b51c0d135962ad361c02b93243.tar.xz mana-a3e61c0e830c46b51c0d135962ad361c02b93243.zip |
Remove isActive methods from buy/sell windows
Uses a state variable in PlayerInfo instead. Moves isTalking from Being
to PlayerInfo. Also some small cleanups.
Reviewed-by: Chuck Miller
Diffstat (limited to 'src/playerinfo.cpp')
-rw-r--r-- | src/playerinfo.cpp | 80 |
1 files changed, 56 insertions, 24 deletions
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index 28d37c83..7b2a9b19 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -27,24 +27,29 @@ #include "listener.h" #include "log.h" +#include "gui/npcdialog.h" +#include "gui/npcpostdialog.h" + #include "resources/itemdb.h" #include "resources/iteminfo.h" namespace PlayerInfo { -class PlayerInfoListener; +class PlayerLogic; -PlayerInfoListener *mListener = 0; +PlayerLogic *mListener = 0; PlayerInfoBackend mData; Inventory *mInventory = 0; Equipment *mEquipment = 0; +BuySellState mBuySellState = BUYSELL_NONE; +bool mTrading = false; + std::map<int, Special> mSpecials; char mSpecialRechargeUpdateNeeded = 0; -bool mTrading = false; int mLevelProgress = 0; // --- Triggers --------------------------------------------------------------- @@ -201,6 +206,45 @@ void setEquipmentBackend(Equipment::Backend *backend) mEquipment->setBackend(backend); } +// -- Buy/Sell/Trade ---------------------------------------------------------- + +BuySellState getBuySellState() +{ + return mBuySellState; +} + +void setBuySellState(BuySellState buySellState) +{ + BuySellState old = mBuySellState; + mBuySellState = buySellState; + + if (buySellState != old) + { + Mana::Event event("StateChange"); + event.setInt("oldState", old); + event.setInt("newState", buySellState); + Mana::EventManager::trigger("BuySell", event); + } +} + +bool isTrading() +{ + return mTrading; +} + +void setTrading(bool trading) +{ + bool notify = mTrading != trading; + mTrading = trading; + + if (notify) + { + Mana::Event event("Trading"); + event.setBool("trading", trading); + Mana::EventManager::trigger("Status", event); + } +} + // --- Specials --------------------------------------------------------------- void setSpecialStatus(int id, int current, int max, int recharge) @@ -224,6 +268,12 @@ void setBackend(const PlayerInfoBackend &backend) mData = backend; } +bool isTalking() +{ + return NpcDialog::isActive() || NpcPostDialog::isActive() || + PlayerInfo::getBuySellState() != BUYSELL_NONE; +} + void logic() { if ((mSpecialRechargeUpdateNeeded%11) == 0) @@ -242,28 +292,10 @@ void logic() mSpecialRechargeUpdateNeeded++; } -bool isTrading() -{ - return mTrading; -} - -void setTrading(bool trading) -{ - bool notify = mTrading != trading; - mTrading = trading; - - if (notify) - { - Mana::Event event("Trading"); - event.setInt("trading", trading); - Mana::EventManager::trigger("Status", event); - } -} - -class PlayerInfoListener : Mana::Listener +class PlayerLogic : Mana::Listener { public: - PlayerInfoListener() + PlayerLogic() { listen("Client"); listen("Game"); @@ -306,7 +338,7 @@ void init() if (mListener) return; - mListener = new PlayerInfoListener(); + mListener = new PlayerLogic(); } } // namespace PlayerInfo |