diff options
Diffstat (limited to 'linden/indra/newview/llviewermenu.cpp')
-rw-r--r-- | linden/indra/newview/llviewermenu.cpp | 105 |
1 files changed, 6 insertions, 99 deletions
diff --git a/linden/indra/newview/llviewermenu.cpp b/linden/indra/newview/llviewermenu.cpp index 3bf390e..97f3761 100644 --- a/linden/indra/newview/llviewermenu.cpp +++ b/linden/indra/newview/llviewermenu.cpp | |||
@@ -303,8 +303,6 @@ void near_sit_object(); | |||
303 | void label_sit_or_stand(std::string& label, void*); | 303 | void label_sit_or_stand(std::string& label, void*); |
304 | // buy and take alias into the same UI positions, so these | 304 | // buy and take alias into the same UI positions, so these |
305 | // declarations handle this mess. | 305 | // declarations handle this mess. |
306 | BOOL is_selection_buy_not_take(); | ||
307 | S32 selection_price(); | ||
308 | BOOL enable_take(); | 306 | BOOL enable_take(); |
309 | void handle_take(); | 307 | void handle_take(); |
310 | void confirm_take(S32 option, void* data); | 308 | void confirm_take(S32 option, void* data); |
@@ -3928,7 +3926,7 @@ BOOL enable_take() | |||
3928 | return FALSE; | 3926 | return FALSE; |
3929 | } | 3927 | } |
3930 | 3928 | ||
3931 | class LLToolsBuyOrTake : public view_listener_t | 3929 | class LLToolsTake : public view_listener_t |
3932 | { | 3930 | { |
3933 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | 3931 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) |
3934 | { | 3932 | { |
@@ -3936,115 +3934,24 @@ class LLToolsBuyOrTake : public view_listener_t | |||
3936 | { | 3934 | { |
3937 | return true; | 3935 | return true; |
3938 | } | 3936 | } |
3939 | |||
3940 | if (is_selection_buy_not_take()) | ||
3941 | { | ||
3942 | S32 total_price = selection_price(); | ||
3943 | |||
3944 | if (total_price <= gStatusBar->getBalance() || total_price == 0) | ||
3945 | { | ||
3946 | handle_buy(NULL); | ||
3947 | } | ||
3948 | else | ||
3949 | { | ||
3950 | LLFloaterBuyCurrency::buyCurrency( | ||
3951 | "Buying this costs", total_price); | ||
3952 | } | ||
3953 | } | ||
3954 | else | 3937 | else |
3955 | { | 3938 | { |
3956 | handle_take(); | 3939 | handle_take(); |
3940 | return true; | ||
3957 | } | 3941 | } |
3958 | return true; | ||
3959 | } | 3942 | } |
3960 | }; | 3943 | }; |
3961 | 3944 | ||
3962 | class LLToolsEnableBuyOrTake : public view_listener_t | 3945 | class LLToolsEnableTake : public view_listener_t |
3963 | { | 3946 | { |
3964 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | 3947 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) |
3965 | { | 3948 | { |
3966 | bool is_buy = is_selection_buy_not_take(); | 3949 | bool new_value = enable_take(); |
3967 | bool new_value = is_buy ? enable_buy(NULL) : enable_take(); | ||
3968 | gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); | 3950 | gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); |
3969 | |||
3970 | // Update label | ||
3971 | std::string label; | ||
3972 | std::string buy_text; | ||
3973 | std::string take_text; | ||
3974 | std::string param = userdata["data"].asString(); | ||
3975 | std::string::size_type offset = param.find(","); | ||
3976 | if (offset != param.npos) | ||
3977 | { | ||
3978 | buy_text = param.substr(0, offset); | ||
3979 | take_text = param.substr(offset+1); | ||
3980 | } | ||
3981 | if (is_buy) | ||
3982 | { | ||
3983 | label = buy_text; | ||
3984 | } | ||
3985 | else | ||
3986 | { | ||
3987 | label = take_text; | ||
3988 | } | ||
3989 | gMenuHolder->childSetText("Pie Object Take", label); | ||
3990 | gMenuHolder->childSetText("Menu Object Take", label); | ||
3991 | |||
3992 | return true; | 3951 | return true; |
3993 | } | 3952 | } |
3994 | }; | 3953 | }; |
3995 | 3954 | ||
3996 | // This is a small helper function to determine if we have a buy or a | ||
3997 | // take in the selection. This method is to help with the aliasing | ||
3998 | // problems of putting buy and take in the same pie menu space. After | ||
3999 | // a fair amont of discussion, it was determined to prefer buy over | ||
4000 | // take. The reasoning follows from the fact that when users walk up | ||
4001 | // to buy something, they will click on one or more items. Thus, if | ||
4002 | // anything is for sale, it becomes a buy operation, and the server | ||
4003 | // will group all of the buy items, and copyable/modifiable items into | ||
4004 | // one package and give the end user as much as the permissions will | ||
4005 | // allow. If the user wanted to take something, they will select fewer | ||
4006 | // and fewer items until only 'takeable' items are left. The one | ||
4007 | // exception is if you own everything in the selection that is for | ||
4008 | // sale, in this case, you can't buy stuff from yourself, so you can | ||
4009 | // take it. | ||
4010 | // return value = TRUE if selection is a 'buy'. | ||
4011 | // FALSE if selection is a 'take' | ||
4012 | BOOL is_selection_buy_not_take() | ||
4013 | { | ||
4014 | for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); | ||
4015 | iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) | ||
4016 | { | ||
4017 | LLSelectNode* node = *iter; | ||
4018 | LLViewerObject* obj = node->getObject(); | ||
4019 | if(obj && !(obj->permYouOwner()) && (node->mSaleInfo.isForSale())) | ||
4020 | { | ||
4021 | // you do not own the object and it is for sale, thus, | ||
4022 | // it's a buy | ||
4023 | return TRUE; | ||
4024 | } | ||
4025 | } | ||
4026 | return FALSE; | ||
4027 | } | ||
4028 | |||
4029 | S32 selection_price() | ||
4030 | { | ||
4031 | S32 total_price = 0; | ||
4032 | for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); | ||
4033 | iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) | ||
4034 | { | ||
4035 | LLSelectNode* node = *iter; | ||
4036 | LLViewerObject* obj = node->getObject(); | ||
4037 | if(obj && !(obj->permYouOwner()) && (node->mSaleInfo.isForSale())) | ||
4038 | { | ||
4039 | // you do not own the object and it is for sale. | ||
4040 | // Add its price. | ||
4041 | total_price += node->mSaleInfo.getSalePrice(); | ||
4042 | } | ||
4043 | } | ||
4044 | |||
4045 | return total_price; | ||
4046 | } | ||
4047 | |||
4048 | void callback_show_buy_currency(S32 option, void*) | 3955 | void callback_show_buy_currency(S32 option, void*) |
4049 | { | 3956 | { |
4050 | if (0 == option) | 3957 | if (0 == option) |
@@ -9858,7 +9765,7 @@ void initialize_menus() | |||
9858 | addMenu(new LLToolsReleaseKeys(), "Tools.ReleaseKeys"); | 9765 | addMenu(new LLToolsReleaseKeys(), "Tools.ReleaseKeys"); |
9859 | addMenu(new LLToolsEnableReleaseKeys(), "Tools.EnableReleaseKeys"); | 9766 | addMenu(new LLToolsEnableReleaseKeys(), "Tools.EnableReleaseKeys"); |
9860 | addMenu(new LLToolsLookAtSelection(), "Tools.LookAtSelection"); | 9767 | addMenu(new LLToolsLookAtSelection(), "Tools.LookAtSelection"); |
9861 | addMenu(new LLToolsBuyOrTake(), "Tools.BuyOrTake"); | 9768 | addMenu(new LLToolsTake(), "Tools.Take"); |
9862 | addMenu(new LLToolsTakeCopy(), "Tools.TakeCopy"); | 9769 | addMenu(new LLToolsTakeCopy(), "Tools.TakeCopy"); |
9863 | addMenu(new LLToolsSaveToInventory(), "Tools.SaveToInventory"); | 9770 | addMenu(new LLToolsSaveToInventory(), "Tools.SaveToInventory"); |
9864 | addMenu(new LLToolsSaveToObjectInventory(), "Tools.SaveToObjectInventory"); | 9771 | addMenu(new LLToolsSaveToObjectInventory(), "Tools.SaveToObjectInventory"); |
@@ -9868,7 +9775,7 @@ void initialize_menus() | |||
9868 | addMenu(new LLToolsEnableToolNotPie(), "Tools.EnableToolNotPie"); | 9775 | addMenu(new LLToolsEnableToolNotPie(), "Tools.EnableToolNotPie"); |
9869 | addMenu(new LLToolsEnableLink(), "Tools.EnableLink"); | 9776 | addMenu(new LLToolsEnableLink(), "Tools.EnableLink"); |
9870 | addMenu(new LLToolsEnableUnlink(), "Tools.EnableUnlink"); | 9777 | addMenu(new LLToolsEnableUnlink(), "Tools.EnableUnlink"); |
9871 | addMenu(new LLToolsEnableBuyOrTake(), "Tools.EnableBuyOrTake"); | 9778 | addMenu(new LLToolsEnableTake(), "Tools.EnableTake"); |
9872 | addMenu(new LLToolsEnableTakeCopy(), "Tools.EnableTakeCopy"); | 9779 | addMenu(new LLToolsEnableTakeCopy(), "Tools.EnableTakeCopy"); |
9873 | addMenu(new LLToolsEnableSaveToInventory(), "Tools.SaveToInventory"); | 9780 | addMenu(new LLToolsEnableSaveToInventory(), "Tools.SaveToInventory"); |
9874 | addMenu(new LLToolsEnableSaveToObjectInventory(), "Tools.SaveToObjectInventory"); | 9781 | addMenu(new LLToolsEnableSaveToObjectInventory(), "Tools.SaveToObjectInventory"); |