summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterbulkythumbs.cpp
diff options
context:
space:
mode:
authorCallum Prentice <callum@lindenlab.com>2023-08-02 17:34:56 -0700
committerCallum Prentice <callum@lindenlab.com>2023-08-02 17:34:56 -0700
commit03ca9468036fc65e1a75d323bfb6d90b410a304b (patch)
tree986d687590efcefc0b1f0b289e1b779ec4bcb0e1 /indra/newview/llfloaterbulkythumbs.cpp
parentfeb40d1a1b53de09ef619d0d681bf03e0ceaa2eb (diff)
SL-20109: now lets user copy a list of items or list of folder of items, copy a list of texture of list of folders of textures, then combine them and find matches by name - saving each match with the name, item ID and thumbnail texture ID - next is actually writing the thumbnails
Diffstat (limited to 'indra/newview/llfloaterbulkythumbs.cpp')
-rw-r--r--indra/newview/llfloaterbulkythumbs.cpp249
1 files changed, 231 insertions, 18 deletions
diff --git a/indra/newview/llfloaterbulkythumbs.cpp b/indra/newview/llfloaterbulkythumbs.cpp
index 64661c6b40..4a6953d96c 100644
--- a/indra/newview/llfloaterbulkythumbs.cpp
+++ b/indra/newview/llfloaterbulkythumbs.cpp
@@ -36,6 +36,7 @@
#include "lluictrlfactory.h"
#include "llclipboard.h"
#include "llinventorymodel.h"
+#include "llinventoryfunctions.h"
#include "lltexteditor.h"
#include "lluuid.h"
@@ -44,29 +45,80 @@ LLFloaterBulkyThumbs::LLFloaterBulkyThumbs(const LLSD& key)
{
}
-LLFloaterBulkyThumbs::~LLFloaterBulkyThumbs() {}
+LLFloaterBulkyThumbs::~LLFloaterBulkyThumbs()
+{
+}
BOOL LLFloaterBulkyThumbs::postBuild()
{
- mPasteFromInventoryBtn = getChild<LLUICtrl>("paste_from_inventory");
- mPasteFromInventoryBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onPasteFromInventory, this));
+ 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));
mInventoryItems = getChild<LLTextEditor>("inventory_items");
- mInventoryItems->setMaxTextLength(0x8000);
- mInventoryItems->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onCommitInventoryItems, this));
+ mInventoryItems->setMaxTextLength(0xffff * 0x10);
mProcessBulkyThumbsBtn = getChild<LLUICtrl>("process_bulky_thumbs");
mProcessBulkyThumbsBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onProcessBulkyThumbs, this));
mProcessBulkyThumbsBtn->setEnabled(false);
+ mWriteBulkyThumbsBtn = getChild<LLUICtrl>("write_bulky_thumbs");
+ mWriteBulkyThumbsBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onWriteBulkyThumbs, this));
+ mWriteBulkyThumbsBtn->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});
+
+ std::string output_line = "ITEM: ";
+ output_line += name;
+ output_line += "|";
+ output_line += id.asString();
+ output_line += "\n";
+ mInventoryItems->appendText(output_line, false);
+ }
+ else
+ {
+ // dupe - do not save
+ }
+}
-void LLFloaterBulkyThumbs::onPasteFromInventory()
+void LLFloaterBulkyThumbs::recordTextureItemEntry(LLViewerInventoryItem* item)
{
- std::cout << "onPasteFromInventory" << std::endl;
+ const std::string name = item->getName();
+ std::map<std::string, LLUUID>::iterator iter = mTextureNamesIDs.find(name);
+ if (iter == mTextureNamesIDs.end())
+ {
+ LLUUID id = item->getUUID();
+ mTextureNamesIDs.insert({name, id});
+
+ std::string output_line = "TEXR: ";
+ output_line += name;
+ output_line += "|";
+ output_line += id.asString();
+ output_line += "\n";
+ mInventoryItems->appendText(output_line, false);
+ }
+ else
+ {
+ // dupe - do not save
+ }
+}
+
+void LLFloaterBulkyThumbs::onPasteItems()
+{
if (!LLClipboard::instance().hasContents())
{
return;
@@ -78,36 +130,197 @@ void LLFloaterBulkyThumbs::onPasteFromInventory()
if (count > 0)
{
- mInventoryItems->clear();
-
for (size_t i = 0; i < count; i++)
{
const LLUUID& item_id = objects.at(i);
- const LLInventoryItem* item = gInventory.getItem(item_id);
+ const LLInventoryCategory* cat = gInventory.getCategory(item_id);
+ 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);
+
+
+ for (size_t i = 0; i < item_array.size(); i++)
+ {
+ LLViewerInventoryItem* item = item_array.at(i);
+ recordInventoryItemEntry(item);
+ }
+ }
+
+ LLViewerInventoryItem* item = gInventory.getItem(item_id);
if (item)
{
if (item->getType() == LLAssetType::AT_OBJECT)
{
- const std::string name = item->getName();
- const std::string item_asset_uuid_str = item->getAssetUUID().asString();
- const std::string thumb_uuid_str = item->getThumbnailUUID().asString();
- const std::string output_line = name + "|" + item_asset_uuid_str + "|" + thumb_uuid_str;
- mInventoryItems->appendText(output_line, "\n");
+ recordInventoryItemEntry(item);
}
}
}
+ mInventoryItems->setCursorAndScrollToEnd();
+
+ mProcessBulkyThumbsBtn->setEnabled(true);
+ }
+}
+
+void LLFloaterBulkyThumbs::onPasteTextures()
+{
+ if (!LLClipboard::instance().hasContents())
+ {
+ return;
+ }
+
+ std::vector<LLUUID> objects;
+ LLClipboard::instance().pasteFromClipboard(objects);
+ size_t count = objects.size();
+
+ if (count > 0)
+ {
+ for (size_t i = 0; i < count; i++)
+ {
+ const LLUUID& item_id = objects.at(i);
+
+ const LLInventoryCategory* cat = gInventory.getCategory(item_id);
+ if (cat)
+ {
+ LLInventoryModel::cat_array_t cat_array;
+ LLInventoryModel::item_array_t item_array;
+ LLIsType is_texture(LLAssetType::AT_TEXTURE);
+ gInventory.collectDescendentsIf(cat->getUUID(),
+ cat_array,
+ item_array,
+ LLInventoryModel::EXCLUDE_TRASH,
+ is_texture);
+
+ std::cout << "CAT: found " << cat_array.size() << " additional categories" << std::endl;
+ std::cout << "ITEM: found " << item_array.size() << " items" << std::endl;
+ for (size_t i = 0; i < item_array.size(); i++)
+ {
+ LLViewerInventoryItem* item = item_array.at(i);
+ recordTextureItemEntry(item);
+ }
+ }
+
+ LLViewerInventoryItem* item = gInventory.getItem(item_id);
+ if (item)
+ {
+ if (item->getType() == LLAssetType::AT_TEXTURE)
+ {
+ recordTextureItemEntry(item);
+ }
+ }
+ }
+
+ mInventoryItems->setCursorAndScrollToEnd();
+
mProcessBulkyThumbsBtn->setEnabled(true);
}
}
void LLFloaterBulkyThumbs::onProcessBulkyThumbs()
{
- std::cout << "onProcessBulkyThumbs" << std::endl;
+ std::map<std::string, LLUUID>::iterator item_iter = mItemNamesIDs.begin();
+ while (item_iter != mItemNamesIDs.end())
+ {
+ std::string output_line = "PROCESSING: ";
+ std::string item_name = (*item_iter).first;
+ output_line += item_name;
+ output_line += "\n";
+ mInventoryItems->appendText(output_line, false);
+
+ bool found = false;
+ std::map<std::string, LLUUID>::iterator texture_iter = mTextureNamesIDs.begin();
+ while (texture_iter != mTextureNamesIDs.end())
+ {
+ std::string output_line = " COMPARING WITH: ";
+ std::string texture_name = (*texture_iter).first;
+ output_line += texture_name;
+
+ if (item_name == texture_name)
+ {
+ output_line += " MATCH";
+ found = true;
+ output_line += "\n";
+ mInventoryItems->appendText(output_line, false);
+ break;
+ }
+ else
+ {
+ output_line += " NO MATCH";
+ }
+ output_line += "\n";
+ mInventoryItems->appendText(output_line, false);
+ mInventoryItems->setCursorAndScrollToEnd();
+
+
+ ++texture_iter;
+ }
+
+ if (found == true)
+ {
+ mNameItemIDTextureId.insert({item_name, {(*item_iter).second, (*texture_iter).second}});
+ }
+ else
+ {
+ std::string output_line = "WARNING: ";
+ output_line += "No texture found for ";
+ output_line += item_name;
+ output_line += "\n";
+ mInventoryItems->appendText(output_line, false);
+ mInventoryItems->setCursorAndScrollToEnd();
+
+ }
+
+ ++item_iter;
+ }
+
+ mInventoryItems->appendText("Finished - final list is", 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";
+ mInventoryItems->appendText(output_line, true);
+
+ ++iter;
+ }
+ mInventoryItems->setCursorAndScrollToEnd();
+
+ mWriteBulkyThumbsBtn->setEnabled(true);
}
-void LLFloaterBulkyThumbs::onCommitInventoryItems()
+void LLFloaterBulkyThumbs::onWriteBulkyThumbs()
{
- std::cout << "onCommitInventoryItems" << std::endl;
+ // look at LLFloaterChangeItemThumbnail::onOpen(const LLSD& key)
+
+ mInventoryItems->appendText("Writing thumbnails", 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";
+ mInventoryItems->appendText(output_line, true);
+
+ ++iter;
+ }
+ mInventoryItems->setCursorAndScrollToEnd();
}