From 4005a820f26d4287bf5c14ec011d4f792c5b82bc Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 11 Nov 2011 01:37:41 +0200 Subject: EXP-1563 FIXED Negative upload cost displayed on the "Save to My Inventory" button. Update upload cost in the button label when economy data arrives from server. --- indra/llinventory/lleconomy.cpp | 27 +++++++++++++++++++++++++++ indra/llinventory/lleconomy.h | 16 ++++++++++++++++ 2 files changed, 43 insertions(+) (limited to 'indra/llinventory') diff --git a/indra/llinventory/lleconomy.cpp b/indra/llinventory/lleconomy.cpp index c6eaa6d3e1..d643ea6ed9 100644 --- a/indra/llinventory/lleconomy.cpp +++ b/indra/llinventory/lleconomy.cpp @@ -48,6 +48,31 @@ LLGlobalEconomy::LLGlobalEconomy() LLGlobalEconomy::~LLGlobalEconomy() { } +void LLGlobalEconomy::addObserver(LLEconomyObserver* observer) +{ + mObservers.push_back(observer); +} + +void LLGlobalEconomy::removeObserver(LLEconomyObserver* observer) +{ + std::list::iterator it = + std::find(mObservers.begin(), mObservers.end(), observer); + if (it != mObservers.end()) + { + mObservers.erase(it); + } +} + +void LLGlobalEconomy::notifyObservers() +{ + for (std::list::iterator it = mObservers.begin(); + it != mObservers.end(); + ++it) + { + (*it)->onEconomyDataChange(); + } +} + // static void LLGlobalEconomy::processEconomyData(LLMessageSystem *msg, LLGlobalEconomy* econ_data) { @@ -88,6 +113,8 @@ void LLGlobalEconomy::processEconomyData(LLMessageSystem *msg, LLGlobalEconomy* econ_data->setTeleportPriceExponent(f); msg->getS32Fast(_PREHASH_Info, _PREHASH_PriceGroupCreate, i); econ_data->setPriceGroupCreate(i); + + econ_data->notifyObservers(); } S32 LLGlobalEconomy::calculateTeleportCost(F32 distance) const diff --git a/indra/llinventory/lleconomy.h b/indra/llinventory/lleconomy.h index cc6643f955..eb2ecf71ba 100644 --- a/indra/llinventory/lleconomy.h +++ b/indra/llinventory/lleconomy.h @@ -31,6 +31,16 @@ class LLMessageSystem; class LLVector3; +/** + * Register an observer to be notified of economy data updates coming from server. + */ +class LLEconomyObserver +{ +public: + virtual ~LLEconomyObserver() {} + virtual void onEconomyDataChange() = 0; +}; + class LLGlobalEconomy { public: @@ -46,6 +56,10 @@ public: virtual void print(); + void addObserver(LLEconomyObserver* observer); + void removeObserver(LLEconomyObserver* observer); + void notifyObservers(); + static void processEconomyData(LLMessageSystem *msg, LLGlobalEconomy* econ_data); S32 calculateTeleportCost(F32 distance) const; @@ -89,6 +103,8 @@ private: S32 mTeleportMinPrice; F32 mTeleportPriceExponent; S32 mPriceGroupCreate; + + std::list mObservers; }; -- cgit v1.2.3