diff options
author | maxim_productengine <mnikolenko@productengine.com> | 2019-02-19 18:24:06 +0200 |
---|---|---|
committer | maxim_productengine <mnikolenko@productengine.com> | 2019-02-19 18:24:06 +0200 |
commit | 54818e189404e0d8444a7731c0082e03a5f12ef7 (patch) | |
tree | 4c230f3e45874787d69047a52c0897cef25cfbec /indra/newview/llfloaterscriptlimits.cpp | |
parent | 344a3a040fb1c664108830ac784c6e4593a57553 (diff) |
SL-10412 Move My Avatar/Scripts to Me drop down menu
Diffstat (limited to 'indra/newview/llfloaterscriptlimits.cpp')
-rw-r--r-- | indra/newview/llfloaterscriptlimits.cpp | 299 |
1 files changed, 2 insertions, 297 deletions
diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp index 21df769d0c..3746b9b6c2 100644 --- a/indra/newview/llfloaterscriptlimits.cpp +++ b/indra/newview/llfloaterscriptlimits.cpp @@ -90,19 +90,6 @@ LLFloaterScriptLimits::LLFloaterScriptLimits(const LLSD& seed) BOOL LLFloaterScriptLimits::postBuild() { - // a little cheap and cheerful - if there's an about land panel open default to showing parcel info, - // otherwise default to showing attachments (avatar appearance) - bool selectParcelPanel = false; - - LLFloaterLand* instance = LLFloaterReg::getTypedInstance<LLFloaterLand>("about_land"); - if(instance) - { - if(instance->isShown()) - { - selectParcelPanel = true; - } - } - mTab = getChild<LLTabContainer>("scriptlimits_panels"); if(!mTab) @@ -111,28 +98,12 @@ BOOL LLFloaterScriptLimits::postBuild() return FALSE; } - // contruct the panels + // contruct the panel LLPanelScriptLimitsRegionMemory* panel_memory = new LLPanelScriptLimitsRegionMemory; mInfoPanels.push_back(panel_memory); panel_memory->buildFromFile( "panel_script_limits_region_memory.xml"); mTab->addTabPanel(panel_memory); - - LLPanelScriptLimitsAttachment* panel_attachments = new LLPanelScriptLimitsAttachment; - mInfoPanels.push_back(panel_attachments); - panel_attachments->buildFromFile("panel_script_limits_my_avatar.xml"); - mTab->addTabPanel(panel_attachments); - - - if(mInfoPanels.size() > 0) - { - mTab->selectTab(0); - } - - if(!selectParcelPanel && (mInfoPanels.size() > 1)) - { - mTab->selectTab(1); - } - + mTab->selectTab(0); return TRUE; } @@ -969,269 +940,3 @@ void LLPanelScriptLimitsRegionMemory::onClickReturn(void* userdata) } } -///---------------------------------------------------------------------------- -// Attachment Panel -///---------------------------------------------------------------------------- - -BOOL LLPanelScriptLimitsAttachment::requestAttachmentDetails() -{ - if (!gAgent.getRegion()) return FALSE; - - LLSD body; - std::string url = gAgent.getRegion()->getCapability("AttachmentResources"); - if (!url.empty()) - { - LLCoros::instance().launch("LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro", - boost::bind(&LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro, this, url)); - return TRUE; - } - else - { - return FALSE; - } -} - -void LLPanelScriptLimitsAttachment::getAttachmentLimitsCoro(std::string url) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getAttachmentLimitsCoro", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - - LLSD result = httpAdapter->getAndSuspend(httpRequest, url); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status) - { - LL_WARNS() << "Unable to retrieve attachment limits." << LL_ENDL; - return; - } - - LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits"); - - if (!instance) - { - LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL; - return; - } - - LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - if (!tab) - { - LL_WARNS() << "Failed to get scriptlimits_panels" << LL_ENDL; - return; - } - - LLPanelScriptLimitsAttachment* panel = (LLPanelScriptLimitsAttachment*)tab->getChild<LLPanel>("script_limits_my_avatar_panel"); - if (!panel) - { - LL_WARNS() << "Failed to get script_limits_my_avatar_panel" << LL_ENDL; - return; - } - - panel->getChild<LLUICtrl>("loading_text")->setValue(LLSD(std::string(""))); - - LLButton* btn = panel->getChild<LLButton>("refresh_list_btn"); - if (btn) - { - btn->setEnabled(true); - } - - result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); - panel->setAttachmentDetails(result); -} - - -void LLPanelScriptLimitsAttachment::setAttachmentDetails(LLSD content) -{ - LLScrollListCtrl *list = getChild<LLScrollListCtrl>("scripts_list"); - - if(!list) - { - return; - } - - S32 number_attachments = content["attachments"].size(); - - for(int i = 0; i < number_attachments; i++) - { - std::string humanReadableLocation = ""; - if(content["attachments"][i].has("location")) - { - std::string actualLocation = content["attachments"][i]["location"]; - humanReadableLocation = LLTrans::getString(actualLocation.c_str()); - } - - S32 number_objects = content["attachments"][i]["objects"].size(); - for(int j = 0; j < number_objects; j++) - { - LLUUID task_id = content["attachments"][i]["objects"][j]["id"].asUUID(); - S32 size = 0; - if(content["attachments"][i]["objects"][j]["resources"].has("memory")) - { - size = content["attachments"][i]["objects"][j]["resources"]["memory"].asInteger() / SIZE_OF_ONE_KB; - } - S32 urls = 0; - if(content["attachments"][i]["objects"][j]["resources"].has("urls")) - { - urls = content["attachments"][i]["objects"][j]["resources"]["urls"].asInteger(); - } - std::string name = content["attachments"][i]["objects"][j]["name"].asString(); - - LLSD element; - - element["id"] = task_id; - element["columns"][0]["column"] = "size"; - element["columns"][0]["value"] = llformat("%d", size); - element["columns"][0]["font"] = "SANSSERIF"; - element["columns"][0]["halign"] = LLFontGL::RIGHT; - - element["columns"][1]["column"] = "urls"; - element["columns"][1]["value"] = llformat("%d", urls); - element["columns"][1]["font"] = "SANSSERIF"; - element["columns"][1]["halign"] = LLFontGL::RIGHT; - - element["columns"][2]["column"] = "name"; - element["columns"][2]["value"] = name; - element["columns"][2]["font"] = "SANSSERIF"; - - element["columns"][3]["column"] = "location"; - element["columns"][3]["value"] = humanReadableLocation; - element["columns"][3]["font"] = "SANSSERIF"; - - list->addElement(element); - } - } - - setAttachmentSummary(content); - - getChild<LLUICtrl>("loading_text")->setValue(LLSD(std::string(""))); - - LLButton* btn = getChild<LLButton>("refresh_list_btn"); - if(btn) - { - btn->setEnabled(true); - } -} - -BOOL LLPanelScriptLimitsAttachment::postBuild() -{ - childSetAction("refresh_list_btn", onClickRefresh, this); - - std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestWaiting"); - getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_waiting)); - return requestAttachmentDetails(); -} - -void LLPanelScriptLimitsAttachment::clearList() -{ - LLCtrlListInterface *list = childGetListInterface("scripts_list"); - - if (list) - { - list->operateOnAll(LLCtrlListInterface::OP_DELETE); - } - - std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestWaiting"); - getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_waiting)); -} - -void LLPanelScriptLimitsAttachment::setAttachmentSummary(LLSD content) -{ - if(content["summary"]["used"][0]["type"].asString() == std::string("memory")) - { - mAttachmentMemoryUsed = content["summary"]["used"][0]["amount"].asInteger() / SIZE_OF_ONE_KB; - mAttachmentMemoryMax = content["summary"]["available"][0]["amount"].asInteger() / SIZE_OF_ONE_KB; - mGotAttachmentMemoryUsed = true; - } - else if(content["summary"]["used"][1]["type"].asString() == std::string("memory")) - { - mAttachmentMemoryUsed = content["summary"]["used"][1]["amount"].asInteger() / SIZE_OF_ONE_KB; - mAttachmentMemoryMax = content["summary"]["available"][1]["amount"].asInteger() / SIZE_OF_ONE_KB; - mGotAttachmentMemoryUsed = true; - } - else - { - LL_WARNS() << "attachment details don't contain memory summary info" << LL_ENDL; - return; - } - - if(content["summary"]["used"][0]["type"].asString() == std::string("urls")) - { - mAttachmentURLsUsed = content["summary"]["used"][0]["amount"].asInteger(); - mAttachmentURLsMax = content["summary"]["available"][0]["amount"].asInteger(); - mGotAttachmentURLsUsed = true; - } - else if(content["summary"]["used"][1]["type"].asString() == std::string("urls")) - { - mAttachmentURLsUsed = content["summary"]["used"][1]["amount"].asInteger(); - mAttachmentURLsMax = content["summary"]["available"][1]["amount"].asInteger(); - mGotAttachmentURLsUsed = true; - } - else - { - LL_WARNS() << "attachment details don't contain urls summary info" << LL_ENDL; - return; - } - - if((mAttachmentMemoryUsed >= 0) && (mAttachmentMemoryMax >= 0)) - { - LLStringUtil::format_map_t args_attachment_memory; - args_attachment_memory["[COUNT]"] = llformat ("%d", mAttachmentMemoryUsed); - std::string translate_message = "ScriptLimitsMemoryUsedSimple"; - - if (0 < mAttachmentMemoryMax) - { - S32 attachment_memory_available = mAttachmentMemoryMax - mAttachmentMemoryUsed; - - args_attachment_memory["[MAX]"] = llformat ("%d", mAttachmentMemoryMax); - args_attachment_memory["[AVAILABLE]"] = llformat ("%d", attachment_memory_available); - translate_message = "ScriptLimitsMemoryUsed"; - } - - getChild<LLUICtrl>("memory_used")->setValue(LLTrans::getString(translate_message, args_attachment_memory)); - } - - if((mAttachmentURLsUsed >= 0) && (mAttachmentURLsMax >= 0)) - { - S32 attachment_urls_available = mAttachmentURLsMax - mAttachmentURLsUsed; - - LLStringUtil::format_map_t args_attachment_urls; - args_attachment_urls["[COUNT]"] = llformat ("%d", mAttachmentURLsUsed); - args_attachment_urls["[MAX]"] = llformat ("%d", mAttachmentURLsMax); - args_attachment_urls["[AVAILABLE]"] = llformat ("%d", attachment_urls_available); - std::string msg_attachment_urls = LLTrans::getString("ScriptLimitsURLsUsed", args_attachment_urls); - getChild<LLUICtrl>("urls_used")->setValue(LLSD(msg_attachment_urls)); - } -} - -// static -void LLPanelScriptLimitsAttachment::onClickRefresh(void* userdata) -{ - LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits"); - if(instance) - { - LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - LLPanelScriptLimitsAttachment* panel_attachments = (LLPanelScriptLimitsAttachment*)tab->getChild<LLPanel>("script_limits_my_avatar_panel"); - LLButton* btn = panel_attachments->getChild<LLButton>("refresh_list_btn"); - - //To stop people from hammering the refesh button and accidentally dosing themselves - enough requests can crash the viewer! - //turn the button off, then turn it on when we get a response - if(btn) - { - btn->setEnabled(false); - } - panel_attachments->clearList(); - panel_attachments->requestAttachmentDetails(); - - return; - } - else - { - LL_WARNS() << "could not find LLPanelScriptLimitsRegionMemory instance after refresh button clicked" << LL_ENDL; - return; - } -} - |