diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/CMakeLists.txt | 4 | ||||
-rw-r--r-- | indra/newview/llfloaterbulkythumbs.cpp | 390 | ||||
-rw-r--r-- | indra/newview/llfloaterbulkythumbs.h | 69 | ||||
-rw-r--r-- | indra/newview/llfloaterinventorythumbnailshelper.cpp | 434 | ||||
-rw-r--r-- | indra/newview/llfloaterinventorythumbnailshelper.h | 72 | ||||
-rw-r--r-- | indra/newview/llviewerfloaterreg.cpp | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_bulky_thumbs.xml | 57 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_inventory_thumbnails_helper.xml | 82 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_viewer.xml | 18 |
9 files changed, 1129 insertions, 1 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index c37d03221c..79fa3ec5b5 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -185,6 +185,7 @@ set(viewer_SOURCE_FILES llfloaterbigpreview.cpp llfloaterbuildoptions.cpp llfloaterbulkpermission.cpp + llfloaterbulkythumbs.cpp llfloaterbump.cpp llfloaterbuy.cpp llfloaterbuycontents.cpp @@ -231,6 +232,7 @@ set(viewer_SOURCE_FILES llfloaterimcontainer.cpp llfloaterinspect.cpp llfloaterinventorysettings.cpp + llfloaterinventorythumbnailshelper.cpp llfloaterjoystick.cpp llfloaterlagmeter.cpp llfloaterland.cpp @@ -831,6 +833,7 @@ set(viewer_HEADER_FILES llfloaterbigpreview.h llfloaterbuildoptions.h llfloaterbulkpermission.h + llfloaterbulkythumbs.h llfloaterbump.h llfloaterbuy.h llfloaterbuycontents.h @@ -880,6 +883,7 @@ set(viewer_HEADER_FILES llfloaterimcontainer.h llfloaterinspect.h llfloaterinventorysettings.h + llfloaterinventorythumbnailshelper.h llfloaterjoystick.h llfloaterlagmeter.h llfloaterland.h diff --git a/indra/newview/llfloaterbulkythumbs.cpp b/indra/newview/llfloaterbulkythumbs.cpp new file mode 100644 index 0000000000..9ffb71b394 --- /dev/null +++ b/indra/newview/llfloaterbulkythumbs.cpp @@ -0,0 +1,390 @@ +/** + * @file llfloaterbulkythumbs.cpp + * @author Callum Prentice + * @brief LLFloaterBulkyThumbs class implementation + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/** + * Floater that appears when buying an object, giving a preview + * of its contents and their permissions. + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloaterbulkythumbs.h" +#include "lluictrlfactory.h" +#include "llclipboard.h" +#include "llinventorymodel.h" +#include "llinventoryfunctions.h" +#include "lltexteditor.h" +#include "llmediactrl.h" +#include "lluuid.h" +#include "llaisapi.h" + +LLFloaterBulkyThumbs::LLFloaterBulkyThumbs(const LLSD& key) + : LLFloater("floater_bulky_thumbs") +{ +} + +LLFloaterBulkyThumbs::~LLFloaterBulkyThumbs() +{ +} + +BOOL LLFloaterBulkyThumbs::postBuild() +{ + mPasteItemsBtn = getChild<LLUICtrl>("paste_items_btn"); + mPasteItemsBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onPasteItems, this)); + + mPasteTexturesBtn = getChild<LLUICtrl>("paste_textures_btn"); + mPasteTexturesBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onPasteTextures, this)); + + mOutputLog = getChild<LLTextEditor>("output_log"); + mOutputLog->setMaxTextLength(0xffff * 0x10); + + mMergeItemsTexturesBtn = getChild<LLUICtrl>("merge_items_textures"); + mMergeItemsTexturesBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onMergeItemsTextures, this)); + mMergeItemsTexturesBtn->setEnabled(false); + + mWriteThumbnailsBtn = getChild<LLUICtrl>("write_items_thumbnails"); + mWriteThumbnailsBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onWriteThumbnails, this)); + mWriteThumbnailsBtn->setEnabled(false); + + return true; +} + +void LLFloaterBulkyThumbs::recordInventoryItemEntry(LLViewerInventoryItem* item) +{ + const std::string name = item->getName(); + + std::map<std::string, LLUUID>::iterator iter = mItemNamesIDs.find(name); + if (iter == mItemNamesIDs.end()) + { + LLUUID id = item->getUUID(); + mItemNamesIDs.insert({name, id}); + + mOutputLog->appendText( + STRINGIZE( + "ITEM " << mItemNamesIDs.size() << "> " << + name << + //" | " << + //id.asString() << + std::endl + ), false); + } + else + { + // dupe - do not save + } +} + +void LLFloaterBulkyThumbs::onPasteItems() +{ + if (!LLClipboard::instance().hasContents()) + { + return; + } + + mOutputLog->appendText( + STRINGIZE( + "\n==== Pasting items from inventory ====" << + std::endl + ), false); + + std::vector<LLUUID> objects; + LLClipboard::instance().pasteFromClipboard(objects); + size_t count = objects.size(); + + for (size_t i = 0; i < count; i++) + { + const LLUUID& entry = objects.at(i); + + const LLInventoryCategory* cat = gInventory.getCategory(entry); + if (cat) + { + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + + LLIsType is_object(LLAssetType::AT_OBJECT); + gInventory.collectDescendentsIf(cat->getUUID(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + is_object); + + LLIsType is_bodypart(LLAssetType::AT_BODYPART); + gInventory.collectDescendentsIf(cat->getUUID(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + is_bodypart); + + for (size_t i = 0; i < item_array.size(); i++) + { + LLViewerInventoryItem* item = item_array.at(i); + recordInventoryItemEntry(item); + } + } + + LLViewerInventoryItem* item = gInventory.getItem(entry); + if (item) + { + const LLAssetType::EType item_type = item->getType(); + if (item_type == LLAssetType::AT_OBJECT || item_type == LLAssetType::AT_BODYPART) + { + recordInventoryItemEntry(item); + } + } + } + + mOutputLog->setCursorAndScrollToEnd(); + + mMergeItemsTexturesBtn->setEnabled(true); +} + +void LLFloaterBulkyThumbs::recordTextureItemEntry(LLViewerInventoryItem* item) +{ + const std::string name = item->getName(); + + std::map<std::string, LLUUID>::iterator iter = mTextureNamesIDs.find(name); + if (iter == mTextureNamesIDs.end()) + { + LLUUID id = item->getAssetUUID(); + mTextureNamesIDs.insert({name, id}); + + mOutputLog->appendText( + STRINGIZE( + "TEXTURE " << mTextureNamesIDs.size() << "> " << + name << + //" | " << + //id.asString() << + std::endl + ), false); + } + else + { + // dupe - do not save + } +} + +void LLFloaterBulkyThumbs::onPasteTextures() +{ + if (!LLClipboard::instance().hasContents()) + { + return; + } + + mOutputLog->appendText( + STRINGIZE( + "\n==== Pasting textures from inventory ====" << + std::endl + ), false); + + std::vector<LLUUID> objects; + LLClipboard::instance().pasteFromClipboard(objects); + size_t count = objects.size(); + + for (size_t i = 0; i < count; i++) + { + const LLUUID& entry = objects.at(i); + + const LLInventoryCategory* cat = gInventory.getCategory(entry); + if (cat) + { + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + + LLIsType is_object(LLAssetType::AT_TEXTURE); + gInventory.collectDescendentsIf(cat->getUUID(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + is_object); + + for (size_t i = 0; i < item_array.size(); i++) + { + LLViewerInventoryItem* item = item_array.at(i); + recordTextureItemEntry(item); + } + } + + LLViewerInventoryItem* item = gInventory.getItem(entry); + if (item) + { + const LLAssetType::EType item_type = item->getType(); + if (item_type == LLAssetType::AT_TEXTURE) + { + recordTextureItemEntry(item); + } + } + } + + mOutputLog->setCursorAndScrollToEnd(); + + mMergeItemsTexturesBtn->setEnabled(true); +} + +void LLFloaterBulkyThumbs::onMergeItemsTextures() +{ + mOutputLog->appendText( + STRINGIZE( + "\n==== Matching items and textures for " << + mItemNamesIDs.size() << + " entries ====" << + std::endl + ), false); + + std::map<std::string, LLUUID>::iterator item_iter = mItemNamesIDs.begin(); + size_t index = 1; + + while (item_iter != mItemNamesIDs.end()) + { + std::string item_name = (*item_iter).first; + + mOutputLog->appendText( + STRINGIZE( + "MATCHING ITEM (" << index++ << "/" << mItemNamesIDs.size() << ") " << item_name << "> " + ), false); + + std::map<std::string, LLUUID>::iterator texture_iter = mTextureNamesIDs.find(item_name); + if (texture_iter != mTextureNamesIDs.end()) + { + mOutputLog->appendText( + STRINGIZE( + "MATCHED" << + std::endl + ), false); + + mNameItemIDTextureId.insert({item_name, {(*item_iter).second, (*texture_iter).second}}); + } + else + { + mOutputLog->appendText( + STRINGIZE( + "NO MATCH FOUND" << + std::endl + ), false); + } + + ++item_iter; + } + + mOutputLog->appendText( + STRINGIZE( + "==== Matched list of items and textures has " << + mNameItemIDTextureId.size() << + " entries ====" << + std::endl + ), true); + + //std::map<std::string, std::pair< LLUUID, LLUUID>>::iterator iter = mNameItemIDTextureId.begin(); + //while (iter != mNameItemIDTextureId.end()) + //{ + // std::string output_line = (*iter).first; + // output_line += "\n"; + // output_line += "item ID: "; + // output_line += ((*iter).second).first.asString(); + // output_line += "\n"; + // output_line += "thumbnail texture ID: "; + // output_line += ((*iter).second).second.asString(); + // output_line += "\n"; + // mOutputLog->appendText(output_line, true); + + // ++iter; + //} + mOutputLog->setCursorAndScrollToEnd(); + + mWriteThumbnailsBtn->setEnabled(true); +} + +#if 1 +// *TODO$: LLInventoryCallback should be deprecated to conform to the new boost::bind/coroutine model. +// temp code in transition +void bulkyInventoryCb(LLPointer<LLInventoryCallback> cb, LLUUID id) +{ + if (cb.notNull()) + { + cb->fire(id); + } +} +#endif + +bool writeThumbnailID(LLUUID item_id, LLUUID thumbnail_asset_id) +{ + if (AISAPI::isAvailable()) + { + + LLSD updates; + updates["thumbnail"] = LLSD().with("asset_id", thumbnail_asset_id.asString()); + + LLPointer<LLInventoryCallback> cb; + + AISAPI::completion_t cr = boost::bind(&bulkyInventoryCb, cb, _1); + AISAPI::UpdateItem(item_id, updates, cr); + + return true; + } + else + { + LL_WARNS() << "Unable to write inventory thumbnail because the AIS API is not available" << LL_ENDL; + return false; + } +} + +void LLFloaterBulkyThumbs::onWriteThumbnails() +{ + mOutputLog->appendText( + STRINGIZE( + "\n==== Writing thumbnails for " << + mNameItemIDTextureId.size() << + " entries ====" << + std::endl + ), false); + + std::map<std::string, std::pair< LLUUID, LLUUID>>::iterator iter = mNameItemIDTextureId.begin(); + size_t index = 1; + + while (iter != mNameItemIDTextureId.end()) + { + mOutputLog->appendText( + STRINGIZE( + "WRITING THUMB (" << index++ << "/" << mNameItemIDTextureId.size() << ")> " << + (*iter).first << + "\n" << + "item ID: " << + ((*iter).second).first.asString() << + "\n" << + "thumbnail texture ID: " << + ((*iter).second).second.asString() << + "\n" + ), true); + + LLUUID item_id = ((*iter).second).first; + LLUUID thumbnail_asset_id = ((*iter).second).second; + + writeThumbnailID(item_id, thumbnail_asset_id); + + ++iter; + } + mOutputLog->setCursorAndScrollToEnd(); +} diff --git a/indra/newview/llfloaterbulkythumbs.h b/indra/newview/llfloaterbulkythumbs.h new file mode 100644 index 0000000000..75657002b3 --- /dev/null +++ b/indra/newview/llfloaterbulkythumbs.h @@ -0,0 +1,69 @@ +/** + * @file llfloaterbulkythumbs.h + * @author Callum Prentice + * @brief Helper floater for bulk processing of inventory thumbnails + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATERBULKYTHUMBS_H +#define LL_LLFLOATERBULKYTHUMBS_H + +#include "llfloater.h" +class LLTextEditor; +class LLMediaCtrl; +class LLViewerInventoryItem; +class LLUUID; + +class LLFloaterBulkyThumbs: + public LLFloater +{ + friend class LLFloaterReg; + private: + LLFloaterBulkyThumbs(const LLSD& key); + BOOL postBuild() override; + ~LLFloaterBulkyThumbs(); + + LLUICtrl* mPasteItemsBtn; + void onPasteItems(); + + LLUICtrl* mPasteTexturesBtn; + void onPasteTextures(); + + LLTextEditor* mOutputLog; + + LLUICtrl* mMergeItemsTexturesBtn; + void onMergeItemsTextures(); + + LLUICtrl* mWriteThumbnailsBtn; + void onWriteThumbnails(); + + void recordInventoryItemEntry(LLViewerInventoryItem* item); + void recordTextureItemEntry(LLViewerInventoryItem* item); + + std::map<std::string, LLUUID> mItemNamesIDs; + std::map<std::string, LLUUID> mTextureNamesIDs; + + std::map<std::string, std::pair< LLUUID, LLUUID>> mNameItemIDTextureId; +}; + +#endif // LL_LLFLOATERBULKYTHUMBS_H diff --git a/indra/newview/llfloaterinventorythumbnailshelper.cpp b/indra/newview/llfloaterinventorythumbnailshelper.cpp new file mode 100644 index 0000000000..9697fc3d51 --- /dev/null +++ b/indra/newview/llfloaterinventorythumbnailshelper.cpp @@ -0,0 +1,434 @@ +/** + * @file llfloaterinventorythumbnailshelper.cpp + * @author Callum Prentice + * @brief LLFloaterInventoryThumbnailsHelper class implementation + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/** + * Floater that appears when buying an object, giving a preview + * of its contents and their permissions. + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloaterinventorythumbnailshelper.h" +#include "lluictrlfactory.h" +#include "llclipboard.h" +#include "llinventorymodel.h" +#include "llinventoryfunctions.h" +#include "lltexteditor.h" +#include "llscrolllistctrl.h" +#include "llmediactrl.h" +#include "lluuid.h" +#include "llaisapi.h" + +LLFloaterInventoryThumbnailsHelper::LLFloaterInventoryThumbnailsHelper(const LLSD& key) + : LLFloater("floater_inventory_thumbnails_helper") +{ +} + +LLFloaterInventoryThumbnailsHelper::~LLFloaterInventoryThumbnailsHelper() +{ +} + +BOOL LLFloaterInventoryThumbnailsHelper::postBuild() +{ + mPasteItemsBtn = getChild<LLUICtrl>("paste_items_btn"); + mPasteItemsBtn->setCommitCallback(boost::bind(&LLFloaterInventoryThumbnailsHelper::onPasteItems, this)); + + mPasteTexturesBtn = getChild<LLUICtrl>("paste_textures_btn"); + mPasteTexturesBtn->setCommitCallback(boost::bind(&LLFloaterInventoryThumbnailsHelper::onPasteTextures, this)); + + mOutputLog = getChild<LLTextEditor>("output_log"); + mOutputLog->setMaxTextLength(0xffff * 0x10); + + //mMergeItemsTexturesBtn = getChild<LLUICtrl>("merge_items_textures"); + //mMergeItemsTexturesBtn->setCommitCallback(boost::bind(&LLFloaterInventoryThumbnailsHelper::onMergeItemsTextures, this)); + //mMergeItemsTexturesBtn->setEnabled(false); + + mInventoryThumbnailsList = getChild<LLScrollListCtrl>("inventory_thumbnails_list"); + mInventoryThumbnailsList->setAllowMultipleSelection(true); + mInventoryThumbnailsList->deleteAllItems(); + + mWriteThumbnailsBtn = getChild<LLUICtrl>("write_thumbnails_btn"); + mWriteThumbnailsBtn->setCommitCallback(boost::bind(&LLFloaterInventoryThumbnailsHelper::onWriteThumbnails, this)); + mWriteThumbnailsBtn->setEnabled(false); + + return true; +} + +void LLFloaterInventoryThumbnailsHelper::recordInventoryItemEntry(LLViewerInventoryItem* item) +{ + const std::string name = item->getName(); + + std::map<std::string, LLUUID>::iterator iter = mItemNamesIDs.find(name); + if (iter == mItemNamesIDs.end()) + { + LLUUID id = item->getUUID(); + mItemNamesIDs.insert({name, id}); + + mOutputLog->appendText( + STRINGIZE( + "ITEM " << mItemNamesIDs.size() << "> " << + name << + //" | " << + //id.asString() << + std::endl + ), false); + + // TODO: use this ID to get name of texture and display that + const LLUUID current_thumbnail_id = item->getThumbnailUUID(); + + std::string texture_display = std::string("Not Present"); + if (!current_thumbnail_id.isNull()) + { + texture_display = current_thumbnail_id.asString(); + } + + LLSD row; + row["columns"][0]["column"] = "name"; + row["columns"][0]["type"] = "text"; + row["columns"][0]["value"] = name; + row["columns"][1]["column"] = "texture"; + row["columns"][1]["type"] = "text"; + row["columns"][1]["value"] = texture_display; + mInventoryThumbnailsList->addElement(row); + } + else + { + // dupe - do not save + } +} + +void LLFloaterInventoryThumbnailsHelper::onPasteItems() +{ + if (!LLClipboard::instance().hasContents()) + { + return; + } + + mOutputLog->appendText( + STRINGIZE( + "\n==== Pasting items from inventory ====" << + std::endl + ), false); + + std::vector<LLUUID> objects; + LLClipboard::instance().pasteFromClipboard(objects); + size_t count = objects.size(); + + for (size_t i = 0; i < count; i++) + { + const LLUUID& entry = objects.at(i); + + const LLInventoryCategory* cat = gInventory.getCategory(entry); + if (cat) + { + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + + LLIsType is_object(LLAssetType::AT_OBJECT); + gInventory.collectDescendentsIf(cat->getUUID(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + is_object); + + LLIsType is_bodypart(LLAssetType::AT_BODYPART); + gInventory.collectDescendentsIf(cat->getUUID(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + is_bodypart); + + for (size_t i = 0; i < item_array.size(); i++) + { + LLViewerInventoryItem* item = item_array.at(i); + recordInventoryItemEntry(item); + } + } + + LLViewerInventoryItem* item = gInventory.getItem(entry); + if (item) + { + const LLAssetType::EType item_type = item->getType(); + if (item_type == LLAssetType::AT_OBJECT || item_type == LLAssetType::AT_BODYPART) + { + recordInventoryItemEntry(item); + } + } + } + + mOutputLog->setCursorAndScrollToEnd(); +} + +void LLFloaterInventoryThumbnailsHelper::recordTextureItemEntry(LLViewerInventoryItem* item) +{ + const std::string name = item->getName(); + + std::map<std::string, LLUUID>::iterator iter = mTextureNamesIDs.find(name); + if (iter == mTextureNamesIDs.end()) + { + LLUUID id = item->getAssetUUID(); + mTextureNamesIDs.insert({name, id}); + + mOutputLog->appendText( + STRINGIZE( + "TEXTURE " << mTextureNamesIDs.size() << "> " << + name << + //" | " << + //id.asString() << + std::endl + ), false); + } + else + { + // dupe - do not save + } +} + +void LLFloaterInventoryThumbnailsHelper::onPasteTextures() +{ + if (!LLClipboard::instance().hasContents()) + { + return; + } + + mOutputLog->appendText( + STRINGIZE( + "\n==== Pasting textures from inventory ====" << + std::endl + ), false); + + std::vector<LLUUID> objects; + LLClipboard::instance().pasteFromClipboard(objects); + size_t count = objects.size(); + + for (size_t i = 0; i < count; i++) + { + const LLUUID& entry = objects.at(i); + + const LLInventoryCategory* cat = gInventory.getCategory(entry); + if (cat) + { + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + + LLIsType is_object(LLAssetType::AT_TEXTURE); + gInventory.collectDescendentsIf(cat->getUUID(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH, + is_object); + + for (size_t i = 0; i < item_array.size(); i++) + { + LLViewerInventoryItem* item = item_array.at(i); + recordTextureItemEntry(item); + } + } + + LLViewerInventoryItem* item = gInventory.getItem(entry); + if (item) + { + const LLAssetType::EType item_type = item->getType(); + if (item_type == LLAssetType::AT_TEXTURE) + { + recordTextureItemEntry(item); + } + } + } + + mOutputLog->setCursorAndScrollToEnd(); + + populateThumbnailNames(); +} + + +void LLFloaterInventoryThumbnailsHelper::populateThumbnailNames() +{ + std::map<std::string, LLUUID>::iterator item_iter = mItemNamesIDs.begin(); + + while (item_iter != mItemNamesIDs.end()) + { + std::string item_name = (*item_iter).first; + + std::map<std::string, LLUUID>::iterator texture_iter = mTextureNamesIDs.find(item_name); + if (texture_iter != mTextureNamesIDs.end()) + { + const bool case_sensitive = true; + LLScrollListItem* entry = mInventoryThumbnailsList->getItemByLabel(item_name, case_sensitive); + + const std::string texture_name = (*texture_iter).first; + entry->getColumn(1)->setValue(LLSD(texture_name)); + } + + ++item_iter; + } +} + +void LLFloaterInventoryThumbnailsHelper::mergeItemsTextures() +{ + mOutputLog->appendText( + STRINGIZE( + "\n==== Matching items and textures for " << + mItemNamesIDs.size() << + " entries ====" << + std::endl + ), false); + + std::map<std::string, LLUUID>::iterator item_iter = mItemNamesIDs.begin(); + size_t index = 1; + + while (item_iter != mItemNamesIDs.end()) + { + std::string item_name = (*item_iter).first; + + mOutputLog->appendText( + STRINGIZE( + "MATCHING ITEM (" << index++ << "/" << mItemNamesIDs.size() << ") " << item_name << "> " + ), false); + + std::map<std::string, LLUUID>::iterator texture_iter = mTextureNamesIDs.find(item_name); + if (texture_iter != mTextureNamesIDs.end()) + { + mOutputLog->appendText( + STRINGIZE( + "MATCHED" << + std::endl + ), false); + + mNameItemIDTextureId.insert({item_name, {(*item_iter).second, (*texture_iter).second}}); + } + else + { + mOutputLog->appendText( + STRINGIZE( + "NO MATCH FOUND" << + std::endl + ), false); + } + + ++item_iter; + } + + mOutputLog->appendText( + STRINGIZE( + "==== Matched list of items and textures has " << + mNameItemIDTextureId.size() << + " entries ====" << + std::endl + ), true); + + //std::map<std::string, std::pair< LLUUID, LLUUID>>::iterator iter = mNameItemIDTextureId.begin(); + //while (iter != mNameItemIDTextureId.end()) + //{ + // std::string output_line = (*iter).first; + // output_line += "\n"; + // output_line += "item ID: "; + // output_line += ((*iter).second).first.asString(); + // output_line += "\n"; + // output_line += "thumbnail texture ID: "; + // output_line += ((*iter).second).second.asString(); + // output_line += "\n"; + // mOutputLog->appendText(output_line, true); + + // ++iter; + //} + mOutputLog->setCursorAndScrollToEnd(); + + mWriteThumbnailsBtn->setEnabled(true); +} + +#if 1 +// *TODO$: LLInventoryCallback should be deprecated to conform to the new boost::bind/coroutine model. +// temp code in transition +void inventoryThumbnailsHelperCb(LLPointer<LLInventoryCallback> cb, LLUUID id) +{ + if (cb.notNull()) + { + cb->fire(id); + } +} +#endif + +bool writeInventoryThumbnailID(LLUUID item_id, LLUUID thumbnail_asset_id) +{ + if (AISAPI::isAvailable()) + { + + LLSD updates; + updates["thumbnail"] = LLSD().with("asset_id", thumbnail_asset_id.asString()); + + LLPointer<LLInventoryCallback> cb; + + AISAPI::completion_t cr = boost::bind(&inventoryThumbnailsHelperCb, cb, _1); + AISAPI::UpdateItem(item_id, updates, cr); + + return true; + } + else + { + LL_WARNS() << "Unable to write inventory thumbnail because the AIS API is not available" << LL_ENDL; + return false; + } +} + +void LLFloaterInventoryThumbnailsHelper::onWriteThumbnails() +{ + mOutputLog->appendText( + STRINGIZE( + "\n==== Writing thumbnails for " << + mNameItemIDTextureId.size() << + " entries ====" << + std::endl + ), false); + + std::map<std::string, std::pair< LLUUID, LLUUID>>::iterator iter = mNameItemIDTextureId.begin(); + size_t index = 1; + + while (iter != mNameItemIDTextureId.end()) + { + mOutputLog->appendText( + STRINGIZE( + "WRITING THUMB (" << index++ << "/" << mNameItemIDTextureId.size() << ")> " << + (*iter).first << + "\n" << + "item ID: " << + ((*iter).second).first.asString() << + "\n" << + "thumbnail texture ID: " << + ((*iter).second).second.asString() << + "\n" + ), true); + + LLUUID item_id = ((*iter).second).first; + LLUUID thumbnail_asset_id = ((*iter).second).second; + + writeInventoryThumbnailID(item_id, thumbnail_asset_id); + + ++iter; + } + mOutputLog->setCursorAndScrollToEnd(); +} diff --git a/indra/newview/llfloaterinventorythumbnailshelper.h b/indra/newview/llfloaterinventorythumbnailshelper.h new file mode 100644 index 0000000000..ec83d5b7e0 --- /dev/null +++ b/indra/newview/llfloaterinventorythumbnailshelper.h @@ -0,0 +1,72 @@ +/** + * @file llfloaterinventorythumbnailshelper.h + * @author Callum Prentice + * @brief Helper floater for bulk processing of inventory thumbnails + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATERINVENTORYTHUMBNAILSHELPER_H +#define LL_LLFLOATERINVENTORYTHUMBNAILSHELPER_H + +#include "llfloater.h" +class LLTextEditor; +class LLScrollListCtrl; +class LLMediaCtrl; +class LLViewerInventoryItem; +class LLUUID; + +class LLFloaterInventoryThumbnailsHelper: + public LLFloater +{ + friend class LLFloaterReg; + private: + LLFloaterInventoryThumbnailsHelper(const LLSD& key); + BOOL postBuild() override; + ~LLFloaterInventoryThumbnailsHelper(); + + LLScrollListCtrl* mInventoryThumbnailsList; + + LLUICtrl* mPasteItemsBtn; + void onPasteItems(); + + LLUICtrl* mPasteTexturesBtn; + void onPasteTextures(); + + LLTextEditor* mOutputLog; + + void mergeItemsTextures(); + + LLUICtrl* mWriteThumbnailsBtn; + void onWriteThumbnails(); + + void recordInventoryItemEntry(LLViewerInventoryItem* item); + void recordTextureItemEntry(LLViewerInventoryItem* item); + void populateThumbnailNames(); + + std::map<std::string, LLUUID> mItemNamesIDs; + std::map<std::string, LLUUID> mTextureNamesIDs; + + std::map<std::string, std::pair< LLUUID, LLUUID>> mNameItemIDTextureId; +}; + +#endif // LL_LLFLOATERINVENTORYTHUMBNAILSHELPER_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 060bdb6995..093fc0d7b3 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -47,6 +47,7 @@ #include "llfloaterbeacons.h" #include "llfloaterbuildoptions.h" #include "llfloaterbulkpermission.h" +#include "llfloaterbulkythumbs.h" #include "llfloaterbump.h" #include "llfloaterbuy.h" #include "llfloaterbuycontents.h" @@ -86,6 +87,7 @@ #include "llfloaterimsession.h" #include "llfloaterinspect.h" #include "llfloaterinventorysettings.h" +#include "llfloaterinventorythumbnailshelper.h" #include "llfloaterjoystick.h" #include "llfloaterlagmeter.h" #include "llfloaterland.h" @@ -328,6 +330,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("build", "floater_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTools>); LLFloaterReg::add("build_options", "floater_build_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuildOptions>); LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>); + LLFloaterReg::add("bulky_thumbs", "floater_bulky_thumbs.xml", (LLFloaterBuildFunc) &LLFloaterReg::build<LLFloaterBulkyThumbs>); LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCamera>); LLFloaterReg::add("camera_presets", "floater_camera_presets.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCameraPresets>); @@ -375,6 +378,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("incoming_call", "floater_incoming_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIncomingCallDialog>); LLFloaterReg::add("inventory", "floater_my_inventory.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>); LLFloaterReg::add("inspect", "floater_inspect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterInspect>); + LLFloaterReg::add("inventory_thumbnails_helper", "floater_inventory_thumbnails_helper.xml", (LLFloaterBuildFunc) &LLFloaterReg::build<LLFloaterInventoryThumbnailsHelper>); LLFloaterReg::add("item_properties", "floater_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterItemProperties>); LLFloaterReg::add("task_properties", "floater_task_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterItemProperties>); LLFloaterReg::add("inventory_settings", "floater_inventory_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterInventorySettings>); diff --git a/indra/newview/skins/default/xui/en/floater_bulky_thumbs.xml b/indra/newview/skins/default/xui/en/floater_bulky_thumbs.xml new file mode 100644 index 0000000000..e94717f947 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_bulky_thumbs.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + legacy_header_height="18" + can_resize="true" + height="600" + layout="topleft" + min_height="175" + min_width="500" + name="contents" + help_topic="contents" + title="BULKY THUMBS" + width="500"> + <button + follows="left|top" + height="20" + label="Paste items from Inventory" + layout="topleft" + left="10" + name="paste_items_btn" + top="26 " + width="200" /> + <button + follows="left|top" + height="20" + label="Paste textures from Inventory" + layout="topleft" + left="250" + name="paste_textures_btn" + top="26 " + width="200" /> + <text_editor + height="510" + follows="top|left|right|bottom" + left="10" + name="output_log" + top_pad="10" + width="480"> + </text_editor> + <button + follows="left|bottom" + height="20" + label="Merge items and textures" + layout="bottomleft" + left="10" + name="merge_items_textures" + bottom="8" + width="200" /> + <button + follows="left|bottom" + height="20" + label="Write Thumbnails" + layout="bottomleft" + left="250" + name="write_items_thumbnails" + bottom="8" + width="200" /> +</floater>
\ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/floater_inventory_thumbnails_helper.xml b/indra/newview/skins/default/xui/en/floater_inventory_thumbnails_helper.xml new file mode 100644 index 0000000000..512bce2475 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_inventory_thumbnails_helper.xml @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + legacy_header_height="18" + can_resize="false" + height="600" + layout="topleft" + min_height="175" + min_width="500" + name="contents" + help_topic="contents" + title="Inventory Thumbnails Helper" + width="500"> + <scroll_list + top="20" + height="350" + draw_stripes="true" + draw_heading="true" + follows="all" + layout="topleft" + left="8" + multi_select="true" + name="inventory_thumbnails_list" + right="-8" + tool_tip="Paste items from your inventory"> + <scroll_list.columns + label="Inventory Item" + name="name" + relative_width="0.40" /> + <scroll_list.columns + dynamic_width="true" + label="Texture Name" + name="texture" + relative_width="0.6" /> + </scroll_list> + <text_editor + top="375" + height="140" + follows="all" + left="8" + right="-8" + name="output_log" + font="Monospace" + text_color="0.1 0.5 0.1 1.0" + width="480"> + </text_editor> + <button + follows="left|bottom" + height="20" + label="Paste items from Inventory" + layout="topleft" + left="10" + name="paste_items_btn" + bottom="-60" + width="235" /> + <button + follows="left|bottom" + height="20" + label="Paste textures from Inventory" + layout="topleft" + left_delta="0" + name="paste_textures_btn" + top_delta="26 " + width="235" /> + <button + follows="left|bottom" + height="20" + label="Write Thumbnails" + layout="topleft" + left_delta="0" + name="write_thumbnails_btn" + top_delta="26 " + width="235" /> + <button + follows="left|bottom" + height="20" + label="List items with no thumb" + layout="bottomleft" + right="-10" + name="list_items_no_thumb_btn" + bottom="60" + width="235" /> +</floater>
\ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index f72d1f0bf9..1fe26cee2c 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -3485,7 +3485,23 @@ function="World.EnvPreset" function="Advanced.WebContentTest" parameter="http://duckduckgo.com"/> </menu_item_call> - <menu_item_call + <menu_item_call + label="Bulky Thumbs" + name="Bulky Thumbs" + shortcut="control|alt|shift|Y"> + <menu_item_call.on_click + function="Floater.Show" + parameter="bulky_thumbs" /> + </menu_item_call> + <menu_item_call + label="Inventory Thumbnails Helper" + name="Inventory Thumbnails Helper" + shortcut="control|alt|shift|X"> + <menu_item_call.on_click + function="Floater.Show" + parameter="inventory_thumbnails_helper" /> + </menu_item_call> + <menu_item_call label="FB Connect Test" name="FB Connect Test"> <menu_item_call.on_click |