diff options
Diffstat (limited to 'indra/newview/llpanelgroup.cpp')
-rw-r--r-- | indra/newview/llpanelgroup.cpp | 92 |
1 files changed, 39 insertions, 53 deletions
diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp index 206d8428be..4708d7ba36 100644 --- a/indra/newview/llpanelgroup.cpp +++ b/indra/newview/llpanelgroup.cpp @@ -33,19 +33,22 @@ #include "llpanelgroup.h" +// Library includes #include "llbutton.h" #include "lltabcontainer.h" #include "lltextbox.h" -#include "llviewermessage.h" #include "lluictrlfactory.h" + +// Viewer includes +#include "llviewermessage.h" #include "llviewerwindow.h" #include "llappviewer.h" #include "llnotifications.h" #include "llfloaterreg.h" #include "llfloater.h" +#include "llgroupactions.h" #include "llagent.h" -#include "llstatusbar.h" // can_afford_transaction() #include "llsidetraypanelcontainer.h" @@ -274,46 +277,11 @@ void LLPanelGroup::onBtnApply(void* user_data) LLPanelGroup* self = static_cast<LLPanelGroup*>(user_data); self->apply(); } + void LLPanelGroup::onBtnJoin() { lldebugs << "joining group: " << mID << llendl; - - LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mID); - - if (gdatap) - { - S32 cost = gdatap->mMembershipFee; - LLSD args; - args["COST"] = llformat("%d", cost); - LLSD payload; - payload["group_id"] = mID; - - if (can_afford_transaction(cost)) - { - LLNotifications::instance().add("JoinGroupCanAfford", args, payload, LLPanelGroup::joinDlgCB); - } - else - { - LLNotifications::instance().add("JoinGroupCannotAfford", args, payload); - } - } - else - { - llwarns << "LLGroupMgr::getInstance()->getGroupData(" << mID << ") was NULL" << llendl; - } -} -bool LLPanelGroup::joinDlgCB(const LLSD& notification, const LLSD& response) -{ - S32 option = LLNotification::getSelectedOption(notification, response); - - if (option == 1) - { - // user clicked cancel - return false; - } - - LLGroupMgr::getInstance()->sendGroupMemberJoin(notification["payload"]["group_id"].asUUID()); - return false; + LLGroupActions::join(mID); } void LLPanelGroup::onBtnCancel() @@ -341,18 +309,31 @@ void LLPanelGroup::update(LLGroupChange gc) { childSetValue("group_name", gdatap->mName); + LLButton* btn_join = getChild<LLButton>("btn_join"); + LLUICtrl* join_text = getChild<LLUICtrl>("join_cost_text"); + LLGroupData agent_gdatap; bool is_member = gAgent.getGroupData(mID,agent_gdatap); - LLButton* btn_join = getChild<LLButton>("btn_join"); bool join_btn_visible = !is_member && gdatap->mOpenEnrollment; + btn_join->setVisible(join_btn_visible); + join_text->setVisible(join_btn_visible); + if(join_btn_visible) { LLStringUtil::format_map_t string_args; - string_args["[AMOUNT]"] = llformat("%d", gdatap->mMembershipFee); - std::string fee_buff = getString("group_join_btn", string_args); - btn_join->setLabelSelected(fee_buff); - btn_join->setLabelUnselected(fee_buff); + std::string fee_buff; + if(gdatap->mMembershipFee) + { + string_args["[AMOUNT]"] = llformat("%d", gdatap->mMembershipFee); + fee_buff = getString("group_join_btn", string_args); + + } + else + { + fee_buff = getString("group_join_free", string_args); + } + childSetValue("join_cost_text",fee_buff); } } } @@ -361,6 +342,8 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id) { std::string str_group_id; group_id.toString(str_group_id); + + bool is_same_id = group_id == mID; LLGroupMgr::getInstance()->removeObserver(this); mID = group_id; @@ -429,16 +412,19 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id) getChild<LLUICtrl>("group_name")->setVisible(false); getChild<LLUICtrl>("group_name_editor")->setVisible(true); } - else + else { - if(!tab_general->getDisplayChildren()) - tab_general->changeOpenClose(tab_general->getDisplayChildren()); - if(!tab_roles->getDisplayChildren()) - tab_roles->changeOpenClose(tab_roles->getDisplayChildren()); - if(!tab_notices->getDisplayChildren()) - tab_notices->changeOpenClose(tab_notices->getDisplayChildren()); - if(!tab_land->getDisplayChildren()) - tab_land->changeOpenClose(tab_land->getDisplayChildren()); + if(!is_same_id) + { + if(!tab_general->getDisplayChildren()) + tab_general->changeOpenClose(tab_general->getDisplayChildren()); + if(tab_roles->getDisplayChildren()) + tab_roles->changeOpenClose(tab_roles->getDisplayChildren()); + if(tab_notices->getDisplayChildren()) + tab_notices->changeOpenClose(tab_notices->getDisplayChildren()); + if(tab_land->getDisplayChildren()) + tab_land->changeOpenClose(tab_land->getDisplayChildren()); + } tab_roles->canOpenClose(true); tab_notices->canOpenClose(true); |