From 06d5706cdcc690c713dcd832a878e830afbb4a59 Mon Sep 17 00:00:00 2001 From: Eugene Mutavchi Date: Tue, 1 Dec 2009 22:30:04 +0200 Subject: Implemented normal sub-task EXT-2478(Implement a chiclet for the llGiveInventory() processing) --HG-- branch : product-engine --- indra/newview/llchiclet.cpp | 78 +++++++++++++++++++++++++++++++++++++++ indra/newview/llchiclet.h | 72 ++++++++++++++++++++++++++++++++++++ indra/newview/llscriptfloater.cpp | 11 +++++- 3 files changed, 160 insertions(+), 1 deletion(-) diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index d533743cfc..0e83f88989 100644 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -1456,6 +1456,28 @@ void LLChicletGroupIconCtrl::setValue(const LLSD& value ) ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// +LLChicletInvOfferIconCtrl::LLChicletInvOfferIconCtrl(const Params& p) +: LLChicletAvatarIconCtrl(p) + , mDefaultIcon(p.default_icon) +{ +} + +void LLChicletInvOfferIconCtrl::setValue(const LLSD& value ) +{ + if(value.asUUID().isNull()) + { + LLIconCtrl::setValue(mDefaultIcon); + } + else + { + LLChicletAvatarIconCtrl::setValue(value); + } +} + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// + LLChicletSpeakerCtrl::LLChicletSpeakerCtrl(const Params&p) : LLOutputMonitorCtrl(p) { @@ -1507,4 +1529,60 @@ BOOL LLScriptChiclet::handleMouseDown(S32 x, S32 y, MASK mask) return LLChiclet::handleMouseDown(x, y, mask); } +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// + +static const std::string INVENTORY_USER_OFFER ("UserGiveItem"); + +LLInvOfferChiclet::Params::Params() +{ + // *TODO Vadim: Get rid of hardcoded values. + rect(CHICLET_RECT); + icon.rect(CHICLET_ICON_RECT); +} + +LLInvOfferChiclet::LLInvOfferChiclet(const Params&p) + : LLIMChiclet(p) + , mChicletIconCtrl(NULL) +{ + LLChicletInvOfferIconCtrl::Params icon_params = p.icon; + mChicletIconCtrl = LLUICtrlFactory::create(icon_params); + // Let "new message" icon be on top, else it will be hidden behind chiclet icon. + addChildInBack(mChicletIconCtrl); +} + +void LLInvOfferChiclet::setSessionId(const LLUUID& session_id) +{ + setShowNewMessagesIcon( getSessionId() != session_id ); + + LLIMChiclet::setSessionId(session_id); + LLUUID notification_id = LLScriptFloaterManager::getInstance()->findNotificationId(session_id); + LLNotificationPtr notification = LLNotifications::getInstance()->find(notification_id); + if(notification) + { + setToolTip(notification->getSubstitutions()["TITLE"].asString()); + } + + if ( notification && notification->getName() == INVENTORY_USER_OFFER ) + { + mChicletIconCtrl->setValue(notification->getPayload()["from_id"]); + } + else + { + mChicletIconCtrl->setValue(LLUUID::null); + } +} + +void LLInvOfferChiclet::onMouseDown() +{ + LLScriptFloaterManager::instance().toggleScriptFloater(getSessionId()); +} + +BOOL LLInvOfferChiclet::handleMouseDown(S32 x, S32 y, MASK mask) +{ + onMouseDown(); + return LLChiclet::handleMouseDown(x, y, mask); +} + // EOF diff --git a/indra/newview/llchiclet.h b/indra/newview/llchiclet.h index ed4bcbc6ac..c75ad2b546 100644 --- a/indra/newview/llchiclet.h +++ b/indra/newview/llchiclet.h @@ -147,6 +147,39 @@ protected: std::string mDefaultIcon; }; +/** + * Class for displaying icon in inventory offer chiclet. + */ +class LLChicletInvOfferIconCtrl : public LLChicletAvatarIconCtrl +{ +public: + + struct Params : + public LLInitParam::Block + { + Optional default_icon; + + Params() + : default_icon("default_icon", "Generic_Object_Small") + { + avatar_id = LLUUID::null; + }; + }; + + /** + * Sets icon, if value is LLUUID::null - default icon will be set. + */ + virtual void setValue(const LLSD& value ); + +protected: + + LLChicletInvOfferIconCtrl(const Params& p); + friend class LLUICtrlFactory; + +private: + std::string mDefaultIcon; +}; + /** * Class for displaying of speaker's voice indicator */ @@ -584,6 +617,45 @@ private: LLIconCtrl* mChicletIconCtrl; }; +/** + * Chiclet for inventory offer script floaters. + */ +class LLInvOfferChiclet: public LLIMChiclet +{ +public: + + struct Params : public LLInitParam::Block + { + Optional icon; + + Params(); + }; + + /*virtual*/ void setSessionId(const LLUUID& session_id); + + /*virtual*/ void setCounter(S32 counter){} + + /*virtual*/ S32 getCounter() { return 0; } + + /** + * Toggle script floater + */ + /*virtual*/ void onMouseDown(); + + /** + * Override default handler + */ + /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); + + +protected: + LLInvOfferChiclet(const Params&); + friend class LLUICtrlFactory; + +private: + LLChicletInvOfferIconCtrl* mChicletIconCtrl; +}; + /** * Implements Group chat chiclet. */ diff --git a/indra/newview/llscriptfloater.cpp b/indra/newview/llscriptfloater.cpp index 7c4f3d3608..155172128b 100644 --- a/indra/newview/llscriptfloater.cpp +++ b/indra/newview/llscriptfloater.cpp @@ -212,7 +212,16 @@ void LLScriptFloaterManager::onAddNotification(const LLUUID& notification_id) LLNotificationData nd = {notification_id}; mNotifications.insert(std::make_pair(object_id, nd)); - LLBottomTray::getInstance()->getChicletPanel()->createChiclet(object_id); + // Create inventory offer chiclet for offer type notifications + LLNotificationPtr notification = LLNotifications::getInstance()->find(notification_id); + if( notification && notification->getType() == "offer" ) + { + LLBottomTray::instance().getChicletPanel()->createChiclet(object_id); + } + else + { + LLBottomTray::getInstance()->getChicletPanel()->createChiclet(object_id); + } toggleScriptFloater(object_id); } -- cgit v1.2.3