Skip to content
Snippets Groups Projects
Commit 03ca9468 authored by Callum Prentice's avatar Callum Prentice
Browse files

SL-20109: now lets user copy a list of items or list of folder of items, copy...

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
parent feb40d1a
No related branches found
No related tags found
No related merge requests found
......@@ -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::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->getUUID();
mTextureNamesIDs.insert({name, id});
void LLFloaterBulkyThumbs::onPasteFromInventory()
std::string output_line = "TEXR: ";
output_line += name;
output_line += "|";
output_line += id.asString();
output_line += "\n";
mInventoryItems->appendText(output_line, false);
}
else
{
std::cout << "onPasteFromInventory" << std::endl;
// 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();
void LLFloaterBulkyThumbs::onCommitInventoryItems()
++texture_iter;
}
if (found == true)
{
mNameItemIDTextureId.insert({item_name, {(*item_iter).second, (*texture_iter).second}});
}
else
{
std::cout << "onCommitInventoryItems" << std::endl;
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::onWriteBulkyThumbs()
{
// 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();
}
......@@ -30,6 +30,7 @@
#include "llfloater.h"
class LLTextEditor;
class LLViewerInventoryItem;
class LLUUID;
class LLFloaterBulkyThumbs:
......@@ -41,14 +42,27 @@ class LLFloaterBulkyThumbs:
BOOL postBuild() override;
~LLFloaterBulkyThumbs();
LLUICtrl* mPasteFromInventoryBtn;
void onPasteFromInventory();
LLUICtrl* mPasteItemsBtn;
void onPasteItems();
LLUICtrl* mPasteTexturesBtn;
void onPasteTextures();
LLTextEditor* mInventoryItems;
void onCommitInventoryItems();
LLUICtrl* mProcessBulkyThumbsBtn;
void onProcessBulkyThumbs();
LLUICtrl* mWriteBulkyThumbsBtn;
void onWriteBulkyThumbs();
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
......@@ -5,38 +5,52 @@
height="600"
layout="topleft"
min_height="175"
min_width="250"
min_width="500"
name="contents"
help_topic="contents"
title="BULKY THUMBS"
width="500">
<button follows="left|top"
height="20"
label="Paste from Inventory copy"
label="Paste item info from Inventory"
layout="topleft"
left="10"
name="paste_from_inventory"
name="paste_items_btn"
top="26 "
width="200" />
<button follows="left|top"
height="20"
label="Paste texture info from Inventory"
layout="topleft"
left="250"
name="paste_textures_btn"
top="26 "
width="200" />
<text_editor
height="510"
follows="top|left|right|bottom"
left_delta="0"
left="10"
name="inventory_items"
top_pad="10"
width="480">
Entry 1
Entry 2
Entry 3
Entry 4
</text_editor>
<button follows="left|bottom"
height="20"
label="Process!"
label="Merge items and textures"
layout="bottomleft"
left="10"
name="process_bulky_thumbs"
bottom="8"
width="200" />
<button follows="left|bottom"
height="20"
label="Write Thumbnails"
layout="bottomleft"
left="250"
name="write_bulky_thumbs"
bottom="8"
width="200" />
</floater>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment