diff options
-rw-r--r-- | indra/newview/llavataractions.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llfloaterpay.cpp | 77 | ||||
-rw-r--r-- | indra/newview/llfloaterpay.h | 78 | ||||
-rw-r--r-- | indra/newview/llviewerfloaterreg.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 6 |
5 files changed, 99 insertions, 67 deletions
diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index f020ff4704..2b5e2369bb 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -306,7 +306,7 @@ bool LLAvatarActions::handlePay(const LLSD& notification, const LLSD& response, gAgent.clearBusy(); } - LLFloaterPay::payDirectly(&give_money, avatar_id, /*is_group=*/FALSE); + LLFloaterPayUtil::payDirectly(&give_money, avatar_id, /*is_group=*/false); return false; } diff --git a/indra/newview/llfloaterpay.cpp b/indra/newview/llfloaterpay.cpp index 1c1e8445ad..8eaa4566ea 100644 --- a/indra/newview/llfloaterpay.cpp +++ b/indra/newview/llfloaterpay.cpp @@ -36,6 +36,9 @@ #include "llfloaterpay.h" #include "message.h" +#include "llfloater.h" +#include "lllslconstants.h" // MAX_PAY_BUTTONS +#include "lluuid.h" #include "llagent.h" #include "llfloaterreg.h" @@ -62,6 +65,7 @@ // // A small class used to track callback information //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class LLFloaterPay; struct LLGiveMoneyInfo { @@ -75,6 +79,52 @@ struct LLGiveMoneyInfo /// Class LLFloaterPay ///---------------------------------------------------------------------------- +class LLFloaterPay : public LLFloater +{ +public: + LLFloaterPay(const LLSD& key); + virtual ~LLFloaterPay(); + /*virtual*/ BOOL postBuild(); + + void setCallback(money_callback callback) { mCallback = callback; } + + void onClose(); + + static void payViaObject(money_callback callback, LLSafeHandle<LLObjectSelection> selection); + + static void payDirectly(money_callback callback, + const LLUUID& target_id, + bool is_group); + +private: + static void onCancel(void* data); + static void onKeystroke(LLLineEditor* editor, void* data); + static void onGive(void* data); + void give(S32 amount); + static void processPayPriceReply(LLMessageSystem* msg, void **userdata); + void onCacheOwnerName(const LLUUID& owner_id, + const std::string& firstname, + const std::string& lastname, + BOOL is_group); + void finishPayUI(const LLUUID& target_id, BOOL is_group); + +protected: + std::vector<LLGiveMoneyInfo*> mCallbackData; + money_callback mCallback; + LLTextBox* mObjectNameText; + LLUUID mTargetUUID; + BOOL mTargetIsGroup; + BOOL mHaveName; + + LLButton* mQuickPayButton[MAX_PAY_BUTTONS]; + LLGiveMoneyInfo* mQuickPayInfo[MAX_PAY_BUTTONS]; + + LLSafeHandle<LLObjectSelection> mObjectSelection; + + static S32 sLastAmount; +}; + + S32 LLFloaterPay::sLastAmount = 0; const S32 MAX_AMOUNT_LENGTH = 10; const S32 FASTPAY_BUTTON_WIDTH = 80; @@ -352,7 +402,7 @@ void LLFloaterPay::payViaObject(money_callback callback, LLSafeHandle<LLObjectSe void LLFloaterPay::payDirectly(money_callback callback, const LLUUID& target_id, - BOOL is_group) + bool is_group) { LLFloaterPay *floater = LLFloaterReg::showTypedInstance<LLFloaterPay>("pay_resident", LLSD(target_id)); if (!floater) @@ -496,3 +546,28 @@ void LLFloaterPay::give(S32 amount) } } } + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Namespace LLFloaterPayUtil +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +void LLFloaterPayUtil::registerFloater() +{ + // Sneaky, use same code but different XML for dialogs + LLFloaterReg::add("pay_resident", "floater_pay.xml", + &LLFloaterReg::build<LLFloaterPay>); + LLFloaterReg::add("pay_object", "floater_pay_object.xml", + &LLFloaterReg::build<LLFloaterPay>); +} + +void LLFloaterPayUtil::payViaObject(money_callback callback, + LLSafeHandle<LLObjectSelection> selection) +{ + LLFloaterPay::payViaObject(callback, selection); +} + +void LLFloaterPayUtil::payDirectly(money_callback callback, + const LLUUID& target_id, + bool is_group) +{ + LLFloaterPay::payDirectly(callback, target_id, is_group); +} diff --git a/indra/newview/llfloaterpay.h b/indra/newview/llfloaterpay.h index c6ce595186..161ed78acb 100644 --- a/indra/newview/llfloaterpay.h +++ b/indra/newview/llfloaterpay.h @@ -32,72 +32,30 @@ #ifndef LLFLOATERPAY_H #define LLFLOATERPAY_H -#include "lluuid.h" -#include "llfloater.h" -#include "lllslconstants.h" +#include "llsafehandle.h" -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Class LLFloaterPay -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -class LLViewerRegion; -class LLLineEditor; -class LLTextBox; -class LLButton; class LLObjectSelection; -struct LLGiveMoneyInfo; +class LLUUID; +class LLViewerRegion; typedef void (*money_callback)(const LLUUID&, LLViewerRegion*,S32,BOOL,S32,const std::string&); -class LLFloaterPay : public LLFloater +namespace LLFloaterPayUtil { -public: - LLFloaterPay(const LLSD& key); - virtual ~LLFloaterPay(); - /*virtual*/ BOOL postBuild(); - - void setCallback(money_callback callback) { mCallback = callback; } - - void onClose(); - - // Pay into an in-world object, which will trigger scripts and eventually - // transfer the L$ to the resident or group that owns the object. - // Object must be selected. It may be a child. - static void payViaObject(money_callback callback, LLSafeHandle<LLObjectSelection> selection); + /// Register with LLFloaterReg + void registerFloater(); + + /// Pay into an in-world object, which will trigger scripts and eventually + /// transfer the L$ to the resident or group that owns the object. + /// Objects must be selected. Recipient (primary) object may be a child. + void payViaObject(money_callback callback, + LLSafeHandle<LLObjectSelection> selection); - // Pay an avatar or group directly, not via an object in the world. - // Scripts are not notified, L$ can be direcly transferred. - static void payDirectly(money_callback callback, - const LLUUID& target_id, - BOOL is_group); - -private: - static void onCancel(void* data); - static void onKeystroke(LLLineEditor* editor, void* data); - static void onGive(void* data); - void give(S32 amount); - static void processPayPriceReply(LLMessageSystem* msg, void **userdata); - void onCacheOwnerName(const LLUUID& owner_id, - const std::string& firstname, - const std::string& lastname, - BOOL is_group); - void finishPayUI(const LLUUID& target_id, BOOL is_group); - -protected: - std::vector<LLGiveMoneyInfo*> mCallbackData; - money_callback mCallback; - LLTextBox* mObjectNameText; - LLUUID mTargetUUID; - BOOL mTargetIsGroup; - BOOL mHaveName; - - LLButton* mQuickPayButton[MAX_PAY_BUTTONS]; - LLGiveMoneyInfo* mQuickPayInfo[MAX_PAY_BUTTONS]; - - LLSafeHandle<LLObjectSelection> mObjectSelection; - - static S32 sLastAmount; -}; - + /// Pay an avatar or group directly, not via an object in the world. + /// Scripts are not notified, L$ can be direcly transferred. + void payDirectly(money_callback callback, + const LLUUID& target_id, + bool is_group); +} #endif // LLFLOATERPAY_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index ab29311aaf..8c46949d70 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -195,8 +195,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("openobject", "floater_openobject.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOpenObject>); LLFloaterReg::add("parcel_info", "floater_preview_url.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterParcelInfo>); - LLFloaterReg::add("pay_resident", "floater_pay.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPay>); - LLFloaterReg::add("pay_object", "floater_pay_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPay>); + LLFloaterPayUtil::registerFloater(); LLFloaterReg::add("postcard", "floater_postcard.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPostcard>); LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 3e036f4978..dde7b1c7ee 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -5437,14 +5437,14 @@ bool complete_give_money(const LLSD& notification, const LLSD& response, LLObjec { if (objectp->isAvatar()) { - const BOOL is_group = FALSE; - LLFloaterPay::payDirectly(&give_money, + const bool is_group = false; + LLFloaterPayUtil::payDirectly(&give_money, objectp->getID(), is_group); } else { - LLFloaterPay::payViaObject(&give_money, selection); + LLFloaterPayUtil::payViaObject(&give_money, selection); } } return false; |