void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content) { LLScrollListCtrl *list = getChild<LLScrollListCtrl>("scripts_list"); if(!list) { LL_WARNS() << "Error getting the scripts_list control" << LL_ENDL; return; } S32 number_parcels = content["parcels"].size(); LLStringUtil::format_map_t args_parcels; args_parcels["[PARCELS]"] = llformat ("%d", number_parcels); std::string msg_parcels = LLTrans::getString("ScriptLimitsParcelsOwned", args_parcels); getChild<LLUICtrl>("parcels_listed")->setValue(LLSD(msg_parcels)); uuid_vec_t names_requested; // This makes the assumption that all objects will have the same set // of attributes, ie they will all have, or none will have locations // This is a pretty safe assumption as it's reliant on server version. bool has_locations = false; bool has_local_ids = false; for(S32 i = 0; i < number_parcels; i++) { std::string parcel_name = content["parcels"][i]["name"].asString(); LLUUID parcel_id = content["parcels"][i]["id"].asUUID(); S32 number_objects = content["parcels"][i]["objects"].size(); S32 local_id = 0; if(content["parcels"][i].has("local_id")) { // if any locations are found flag that we can use them and turn on the highlight button has_local_ids = true; local_id = content["parcels"][i]["local_id"].asInteger(); } for(S32 j = 0; j < number_objects; j++) { S32 size = content["parcels"][i]["objects"][j]["resources"]["memory"].asInteger() / SIZE_OF_ONE_KB; S32 urls = content["parcels"][i]["objects"][j]["resources"]["urls"].asInteger(); std::string name_buf = content["parcels"][i]["objects"][j]["name"].asString(); LLUUID task_id = content["parcels"][i]["objects"][j]["id"].asUUID(); LLUUID owner_id = content["parcels"][i]["objects"][j]["owner_id"].asUUID(); // This field may not be sent by all server versions, but it's OK if // it uses the LLSD default of false bool is_group_owned = content["parcels"][i]["objects"][j]["is_group_owned"].asBoolean(); F32 location_x = 0.0f; F32 location_y = 0.0f; F32 location_z = 0.0f; if(content["parcels"][i]["objects"][j].has("location")) { // if any locations are found flag that we can use them and turn on the highlight button LLVector3 vec = ll_vector3_from_sd(content["parcels"][i]["objects"][j]["location"]); has_locations = true; location_x = vec.mV[0]; location_y = vec.mV[1]; location_z = vec.mV[2]; } std::string owner_buf; // in the future the server will give us owner names, so see if we're there yet: if(content["parcels"][i]["objects"][j].has("owner_name")) { owner_buf = content["parcels"][i]["objects"][j]["owner_name"].asString(); } // ...and if not use the slightly more painful method of disovery: else { BOOL name_is_cached; if (is_group_owned) { name_is_cached = gCacheName->getGroupName(owner_id, owner_buf); } else { name_is_cached = LLAvatarNameCache::getNSName(owner_id, owner_buf); // username } if(!name_is_cached) { if(std::find(names_requested.begin(), names_requested.end(), owner_id) == names_requested.end()) { names_requested.push_back(owner_id); gCacheName->get(owner_id, is_group_owned, // username boost::bind(&LLPanelScriptLimitsRegionMemory::onNameCache, this, _1, _2)); } } } LLScrollListItem::Params item_params; item_params.value = task_id; LLScrollListCell::Params cell_params; //cell_params.font = LLFontGL::getFontSansSerif(); cell_params.column = "size"; cell_params.value = size; item_params.columns.add(cell_params); cell_params.column = "urls"; cell_params.value = urls; item_params.columns.add(cell_params); cell_params.column = "name"; cell_params.value = name_buf; item_params.columns.add(cell_params); cell_params.column = "owner"; cell_params.value = owner_buf; item_params.columns.add(cell_params); cell_params.column = "parcel"; cell_params.value = parcel_name; item_params.columns.add(cell_params); cell_params.column = "location"; cell_params.value = has_locations ? llformat("<%0.1f,%0.1f,%0.1f>", location_x, location_y, location_z) : ""; item_params.columns.add(cell_params); list->addRow(item_params); LLSD element; element["owner_id"] = owner_id; element["id"] = task_id; element["local_id"] = local_id; mObjectListItems.push_back(element); } } if (has_locations) { LLButton* btn = getChild<LLButton>("highlight_btn"); if(btn) { btn->setVisible(true); } } if (has_local_ids) { LLButton* btn = getChild<LLButton>("return_btn"); if(btn) { btn->setVisible(true); } } // save the structure to make object return easier mContent = content; }