diff options
author | McCabe Maxsted | 2009-01-12 13:09:41 -0700 |
---|---|---|
committer | McCabe Maxsted | 2009-01-12 13:09:41 -0700 |
commit | 13c27361136819af0d0a0f72eeb807f56829337f (patch) | |
tree | 29c739c02c7c02c46d3679d7014bd1a43820bffc /linden/indra/newview/llviewermenu.cpp | |
parent | Moved common options out of Advanced (diff) | |
parent | Buy and Take now separated in the pie menu. (diff) | |
download | meta-impy-13c27361136819af0d0a0f72eeb807f56829337f.zip meta-impy-13c27361136819af0d0a0f72eeb807f56829337f.tar.gz meta-impy-13c27361136819af0d0a0f72eeb807f56829337f.tar.bz2 meta-impy-13c27361136819af0d0a0f72eeb807f56829337f.tar.xz |
Various pie menu improvements.
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 0ea92f1..f99a324 100644 --- a/linden/indra/newview/llviewermenu.cpp +++ b/linden/indra/newview/llviewermenu.cpp | |||
@@ -305,8 +305,6 @@ void near_sit_object(); | |||
305 | void label_sit_or_stand(std::string& label, void*); | 305 | void label_sit_or_stand(std::string& label, void*); |
306 | // buy and take alias into the same UI positions, so these | 306 | // buy and take alias into the same UI positions, so these |
307 | // declarations handle this mess. | 307 | // declarations handle this mess. |
308 | BOOL is_selection_buy_not_take(); | ||
309 | S32 selection_price(); | ||
310 | BOOL enable_take(); | 308 | BOOL enable_take(); |
311 | void handle_take(); | 309 | void handle_take(); |
312 | void confirm_take(S32 option, void* data); | 310 | void confirm_take(S32 option, void* data); |
@@ -3912,7 +3910,7 @@ BOOL enable_take() | |||
3912 | return FALSE; | 3910 | return FALSE; |
3913 | } | 3911 | } |
3914 | 3912 | ||
3915 | class LLToolsBuyOrTake : public view_listener_t | 3913 | class LLToolsTake : public view_listener_t |
3916 | { | 3914 | { |
3917 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | 3915 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) |
3918 | { | 3916 | { |
@@ -3920,115 +3918,24 @@ class LLToolsBuyOrTake : public view_listener_t | |||
3920 | { | 3918 | { |
3921 | return true; | 3919 | return true; |
3922 | } | 3920 | } |
3923 | |||
3924 | if (is_selection_buy_not_take()) | ||
3925 | { | ||
3926 | S32 total_price = selection_price(); | ||
3927 | |||
3928 | if (total_price <= gStatusBar->getBalance() || total_price == 0) | ||
3929 | { | ||
3930 | handle_buy(NULL); | ||
3931 | } | ||
3932 | else | ||
3933 | { | ||
3934 | LLFloaterBuyCurrency::buyCurrency( | ||
3935 | "Buying this costs", total_price); | ||
3936 | } | ||
3937 | } | ||
3938 | else | 3921 | else |
3939 | { | 3922 | { |
3940 | handle_take(); | 3923 | handle_take(); |
3924 | return true; | ||
3941 | } | 3925 | } |
3942 | return true; | ||
3943 | } | 3926 | } |
3944 | }; | 3927 | }; |
3945 | 3928 | ||
3946 | class LLToolsEnableBuyOrTake : public view_listener_t | 3929 | class LLToolsEnableTake : public view_listener_t |
3947 | { | 3930 | { |
3948 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | 3931 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) |
3949 | { | 3932 | { |
3950 | bool is_buy = is_selection_buy_not_take(); | 3933 | bool new_value = enable_take(); |
3951 | bool new_value = is_buy ? enable_buy(NULL) : enable_take(); | ||
3952 | gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); | 3934 | gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); |
3953 | |||
3954 | // Update label | ||
3955 | std::string label; | ||
3956 | std::string buy_text; | ||
3957 | std::string take_text; | ||
3958 | std::string param = userdata["data"].asString(); | ||
3959 | std::string::size_type offset = param.find(","); | ||
3960 | if (offset != param.npos) | ||
3961 | { | ||
3962 | buy_text = param.substr(0, offset); | ||
3963 | take_text = param.substr(offset+1); | ||
3964 | } | ||
3965 | if (is_buy) | ||
3966 | { | ||
3967 | label = buy_text; | ||
3968 | } | ||
3969 | else | ||
3970 | { | ||
3971 | label = take_text; | ||
3972 | } | ||
3973 | gMenuHolder->childSetText("Pie Object Take", label); | ||
3974 | gMenuHolder->childSetText("Menu Object Take", label); | ||
3975 | |||
3976 | return true; | 3935 | return true; |
3977 | } | 3936 | } |
3978 | }; | 3937 | }; |
3979 | 3938 | ||
3980 | // This is a small helper function to determine if we have a buy or a | ||
3981 | // take in the selection. This method is to help with the aliasing | ||
3982 | // problems of putting buy and take in the same pie menu space. After | ||
3983 | // a fair amont of discussion, it was determined to prefer buy over | ||
3984 | // take. The reasoning follows from the fact that when users walk up | ||
3985 | // to buy something, they will click on one or more items. Thus, if | ||
3986 | // anything is for sale, it becomes a buy operation, and the server | ||
3987 | // will group all of the buy items, and copyable/modifiable items into | ||
3988 | // one package and give the end user as much as the permissions will | ||
3989 | // allow. If the user wanted to take something, they will select fewer | ||
3990 | // and fewer items until only 'takeable' items are left. The one | ||
3991 | // exception is if you own everything in the selection that is for | ||
3992 | // sale, in this case, you can't buy stuff from yourself, so you can | ||
3993 | // take it. | ||
3994 | // return value = TRUE if selection is a 'buy'. | ||
3995 | // FALSE if selection is a 'take' | ||
3996 | BOOL is_selection_buy_not_take() | ||
3997 | { | ||
3998 | for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); | ||
3999 | iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) | ||
4000 | { | ||
4001 | LLSelectNode* node = *iter; | ||
4002 | LLViewerObject* obj = node->getObject(); | ||
4003 | if(obj && !(obj->permYouOwner()) && (node->mSaleInfo.isForSale())) | ||
4004 | { | ||
4005 | // you do not own the object and it is for sale, thus, | ||
4006 | // it's a buy | ||
4007 | return TRUE; | ||
4008 | } | ||
4009 | } | ||
4010 | return FALSE; | ||
4011 | } | ||
4012 | |||
4013 | S32 selection_price() | ||
4014 | { | ||
4015 | S32 total_price = 0; | ||
4016 | for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); | ||
4017 | iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) | ||
4018 | { | ||
4019 | LLSelectNode* node = *iter; | ||
4020 | LLViewerObject* obj = node->getObject(); | ||
4021 | if(obj && !(obj->permYouOwner()) && (node->mSaleInfo.isForSale())) | ||
4022 | { | ||
4023 | // you do not own the object and it is for sale. | ||
4024 | // Add its price. | ||
4025 | total_price += node->mSaleInfo.getSalePrice(); | ||
4026 | } | ||
4027 | } | ||
4028 | |||
4029 | return total_price; | ||
4030 | } | ||
4031 | |||
4032 | void callback_show_buy_currency(S32 option, void*) | 3939 | void callback_show_buy_currency(S32 option, void*) |
4033 | { | 3940 | { |
4034 | if (0 == option) | 3941 | if (0 == option) |
@@ -9853,7 +9760,7 @@ void initialize_menus() | |||
9853 | addMenu(new LLToolsReleaseKeys(), "Tools.ReleaseKeys"); | 9760 | addMenu(new LLToolsReleaseKeys(), "Tools.ReleaseKeys"); |
9854 | addMenu(new LLToolsEnableReleaseKeys(), "Tools.EnableReleaseKeys"); | 9761 | addMenu(new LLToolsEnableReleaseKeys(), "Tools.EnableReleaseKeys"); |
9855 | addMenu(new LLToolsLookAtSelection(), "Tools.LookAtSelection"); | 9762 | addMenu(new LLToolsLookAtSelection(), "Tools.LookAtSelection"); |
9856 | addMenu(new LLToolsBuyOrTake(), "Tools.BuyOrTake"); | 9763 | addMenu(new LLToolsTake(), "Tools.Take"); |
9857 | addMenu(new LLToolsTakeCopy(), "Tools.TakeCopy"); | 9764 | addMenu(new LLToolsTakeCopy(), "Tools.TakeCopy"); |
9858 | addMenu(new LLToolsSaveToInventory(), "Tools.SaveToInventory"); | 9765 | addMenu(new LLToolsSaveToInventory(), "Tools.SaveToInventory"); |
9859 | addMenu(new LLToolsSaveToObjectInventory(), "Tools.SaveToObjectInventory"); | 9766 | addMenu(new LLToolsSaveToObjectInventory(), "Tools.SaveToObjectInventory"); |
@@ -9863,7 +9770,7 @@ void initialize_menus() | |||
9863 | addMenu(new LLToolsEnableToolNotPie(), "Tools.EnableToolNotPie"); | 9770 | addMenu(new LLToolsEnableToolNotPie(), "Tools.EnableToolNotPie"); |
9864 | addMenu(new LLToolsEnableLink(), "Tools.EnableLink"); | 9771 | addMenu(new LLToolsEnableLink(), "Tools.EnableLink"); |
9865 | addMenu(new LLToolsEnableUnlink(), "Tools.EnableUnlink"); | 9772 | addMenu(new LLToolsEnableUnlink(), "Tools.EnableUnlink"); |
9866 | addMenu(new LLToolsEnableBuyOrTake(), "Tools.EnableBuyOrTake"); | 9773 | addMenu(new LLToolsEnableTake(), "Tools.EnableTake"); |
9867 | addMenu(new LLToolsEnableTakeCopy(), "Tools.EnableTakeCopy"); | 9774 | addMenu(new LLToolsEnableTakeCopy(), "Tools.EnableTakeCopy"); |
9868 | addMenu(new LLToolsEnableSaveToInventory(), "Tools.SaveToInventory"); | 9775 | addMenu(new LLToolsEnableSaveToInventory(), "Tools.SaveToInventory"); |
9869 | addMenu(new LLToolsEnableSaveToObjectInventory(), "Tools.SaveToObjectInventory"); | 9776 | addMenu(new LLToolsEnableSaveToObjectInventory(), "Tools.SaveToObjectInventory"); |