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

SL-20109: Big clean up. Now supports arbitrary mix of folders and entries for...

SL-20109: Big clean up. Now supports arbitrary mix of folders and entries for both items and textures. Better logging output
parent c92d6e3f
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "llinventorymodel.h" #include "llinventorymodel.h"
#include "llinventoryfunctions.h" #include "llinventoryfunctions.h"
#include "lltexteditor.h" #include "lltexteditor.h"
#include "llmediactrl.h"
#include "lluuid.h" #include "lluuid.h"
#include "llaisapi.h" #include "llaisapi.h"
...@@ -58,16 +59,16 @@ BOOL LLFloaterBulkyThumbs::postBuild() ...@@ -58,16 +59,16 @@ BOOL LLFloaterBulkyThumbs::postBuild()
mPasteTexturesBtn = getChild<LLUICtrl>("paste_textures_btn"); mPasteTexturesBtn = getChild<LLUICtrl>("paste_textures_btn");
mPasteTexturesBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onPasteTextures, this)); mPasteTexturesBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onPasteTextures, this));
mInventoryItems = getChild<LLTextEditor>("inventory_items"); mOutputLog = getChild<LLTextEditor>("output_log");
mInventoryItems->setMaxTextLength(0xffff * 0x10); mOutputLog->setMaxTextLength(0xffff * 0x10);
mProcessBulkyThumbsBtn = getChild<LLUICtrl>("process_bulky_thumbs"); mMergeItemsTexturesBtn = getChild<LLUICtrl>("merge_items_textures");
mProcessBulkyThumbsBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onProcessBulkyThumbs, this)); mMergeItemsTexturesBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onMergeItemsTextures, this));
mProcessBulkyThumbsBtn->setEnabled(false); mMergeItemsTexturesBtn->setEnabled(false);
mWriteBulkyThumbsBtn = getChild<LLUICtrl>("write_bulky_thumbs"); mWriteThumbnailsBtn = getChild<LLUICtrl>("write_items_thumbnails");
mWriteBulkyThumbsBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onWriteBulkyThumbs, this)); mWriteThumbnailsBtn->setCommitCallback(boost::bind(&LLFloaterBulkyThumbs::onWriteThumbnails, this));
mWriteBulkyThumbsBtn->setEnabled(false); mWriteThumbnailsBtn->setEnabled(false);
return true; return true;
} }
...@@ -82,36 +83,14 @@ void LLFloaterBulkyThumbs::recordInventoryItemEntry(LLViewerInventoryItem* item) ...@@ -82,36 +83,14 @@ void LLFloaterBulkyThumbs::recordInventoryItemEntry(LLViewerInventoryItem* item)
LLUUID id = item->getUUID(); LLUUID id = item->getUUID();
mItemNamesIDs.insert({name, id}); mItemNamesIDs.insert({name, id});
std::string output_line = "ITEM: "; mOutputLog->appendText(
output_line += name; STRINGIZE(
output_line += "|"; "ITEM " << mItemNamesIDs.size() << "> " <<
output_line += id.asString(); name <<
output_line += "\n"; //" | " <<
mInventoryItems->appendText(output_line, false); //id.asString() <<
} std::endl
else ), false);
{
// 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();
LLUUID id = item->getAssetUUID();
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 else
{ {
...@@ -126,49 +105,85 @@ void LLFloaterBulkyThumbs::onPasteItems() ...@@ -126,49 +105,85 @@ void LLFloaterBulkyThumbs::onPasteItems()
return; return;
} }
mOutputLog->appendText(
STRINGIZE(
"\n==== Pasting items from inventory ====" <<
std::endl
), false);
std::vector<LLUUID> objects; std::vector<LLUUID> objects;
LLClipboard::instance().pasteFromClipboard(objects); LLClipboard::instance().pasteFromClipboard(objects);
size_t count = objects.size(); size_t count = objects.size();
if (count > 0) for (size_t i = 0; i < count; i++)
{ {
for (size_t i = 0; i < count; i++) const LLUUID& entry = objects.at(i);
{
const LLUUID& item_id = objects.at(i);
const LLInventoryCategory* cat = gInventory.getCategory(item_id); const LLInventoryCategory* cat = gInventory.getCategory(entry);
if (cat) 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++)
{ {
LLInventoryModel::cat_array_t cat_array; LLViewerInventoryItem* item = item_array.at(i);
LLInventoryModel::item_array_t item_array; recordInventoryItemEntry(item);
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); LLViewerInventoryItem* item = gInventory.getItem(entry);
if (item) if (item)
{
const LLAssetType::EType item_type = item->getType();
if (item_type == LLAssetType::AT_OBJECT || item_type == LLAssetType::AT_BODYPART)
{ {
if (item->getType() == LLAssetType::AT_OBJECT) recordInventoryItemEntry(item);
{
recordInventoryItemEntry(item);
}
} }
} }
}
mInventoryItems->setCursorAndScrollToEnd(); 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});
mProcessBulkyThumbsBtn->setEnabled(true); mOutputLog->appendText(
STRINGIZE(
"TEXTURE " << mTextureNamesIDs.size() << "> " <<
name <<
//" | " <<
//id.asString() <<
std::endl
), false);
}
else
{
// dupe - do not save
} }
} }
...@@ -179,127 +194,127 @@ void LLFloaterBulkyThumbs::onPasteTextures() ...@@ -179,127 +194,127 @@ void LLFloaterBulkyThumbs::onPasteTextures()
return; return;
} }
mOutputLog->appendText(
STRINGIZE(
"\n==== Pasting textures from inventory ====" <<
std::endl
), false);
std::vector<LLUUID> objects; std::vector<LLUUID> objects;
LLClipboard::instance().pasteFromClipboard(objects); LLClipboard::instance().pasteFromClipboard(objects);
size_t count = objects.size(); size_t count = objects.size();
if (count > 0) for (size_t i = 0; i < count; i++)
{ {
for (size_t i = 0; i < count; i++) const LLUUID& entry = objects.at(i);
const LLInventoryCategory* cat = gInventory.getCategory(entry);
if (cat)
{ {
const LLUUID& item_id = objects.at(i); 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);
const LLInventoryCategory* cat = gInventory.getCategory(item_id); for (size_t i = 0; i < item_array.size(); i++)
if (cat)
{ {
LLInventoryModel::cat_array_t cat_array; LLViewerInventoryItem* item = item_array.at(i);
LLInventoryModel::item_array_t item_array; recordTextureItemEntry(item);
LLIsType is_texture(LLAssetType::AT_TEXTURE);
gInventory.collectDescendentsIf(cat->getUUID(),
cat_array,
item_array,
LLInventoryModel::EXCLUDE_TRASH,
is_texture);
for (size_t i = 0; i < item_array.size(); i++)
{
LLViewerInventoryItem* item = item_array.at(i);
recordTextureItemEntry(item);
}
} }
}
LLViewerInventoryItem* item = gInventory.getItem(item_id); LLViewerInventoryItem* item = gInventory.getItem(entry);
if (item) if (item)
{
const LLAssetType::EType item_type = item->getType();
if (item_type == LLAssetType::AT_TEXTURE)
{ {
if (item->getType() == LLAssetType::AT_TEXTURE) recordTextureItemEntry(item);
{
recordTextureItemEntry(item);
}
} }
} }
}
mInventoryItems->setCursorAndScrollToEnd(); mOutputLog->setCursorAndScrollToEnd();
mProcessBulkyThumbsBtn->setEnabled(true); mMergeItemsTexturesBtn->setEnabled(true);
}
} }
void LLFloaterBulkyThumbs::onProcessBulkyThumbs() 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(); std::map<std::string, LLUUID>::iterator item_iter = mItemNamesIDs.begin();
size_t index = 1;
while (item_iter != mItemNamesIDs.end()) while (item_iter != mItemNamesIDs.end())
{ {
std::string output_line = "PROCESSING: ";
std::string item_name = (*item_iter).first; std::string item_name = (*item_iter).first;
output_line += item_name;
output_line += "\n";
mInventoryItems->appendText(output_line, false);
bool found = false; mOutputLog->appendText(
std::map<std::string, LLUUID>::iterator texture_iter = mTextureNamesIDs.begin(); STRINGIZE(
while (texture_iter != mTextureNamesIDs.end()) "MATCHING ITEM (" << index++ << "/" << mItemNamesIDs.size() << ") " << item_name << "> "
{ ), false);
std::string output_line = " COMPARING WITH: ";
std::string texture_name = (*texture_iter).first;
output_line += texture_name;
if (item_name == texture_name) std::map<std::string, LLUUID>::iterator texture_iter = mTextureNamesIDs.find(item_name);
{ if (texture_iter != mTextureNamesIDs.end())
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)
{ {
mOutputLog->appendText(
STRINGIZE(
"MATCHED" <<
std::endl
), false);
mNameItemIDTextureId.insert({item_name, {(*item_iter).second, (*texture_iter).second}}); mNameItemIDTextureId.insert({item_name, {(*item_iter).second, (*texture_iter).second}});
} }
else else
{ {
std::string output_line = "WARNING: "; mOutputLog->appendText(
output_line += "No texture found for "; STRINGIZE(
output_line += item_name; "NO MATCH FOUND" <<
output_line += "\n"; std::endl
mInventoryItems->appendText(output_line, false); ), false);
mInventoryItems->setCursorAndScrollToEnd();
} }
++item_iter; ++item_iter;
} }
mInventoryItems->appendText("Finished - final list is", true); mOutputLog->appendText(
std::map<std::string, std::pair< LLUUID, LLUUID>>::iterator iter = mNameItemIDTextureId.begin(); STRINGIZE(
while (iter != mNameItemIDTextureId.end()) "==== Matched list of items and textures has " <<
{ mNameItemIDTextureId.size() <<
std::string output_line = (*iter).first; " entries ====" <<
output_line += "\n"; std::endl
output_line += "item ID: "; ), true);
output_line += ((*iter).second).first.asString();
output_line += "\n"; //std::map<std::string, std::pair< LLUUID, LLUUID>>::iterator iter = mNameItemIDTextureId.begin();
output_line += "thumbnail texture ID: "; //while (iter != mNameItemIDTextureId.end())
output_line += ((*iter).second).second.asString(); //{
output_line += "\n"; // std::string output_line = (*iter).first;
mInventoryItems->appendText(output_line, true); // output_line += "\n";
// output_line += "item ID: ";
++iter; // output_line += ((*iter).second).first.asString();
} // output_line += "\n";
mInventoryItems->setCursorAndScrollToEnd(); // output_line += "thumbnail texture ID: ";
// output_line += ((*iter).second).second.asString();
mWriteBulkyThumbsBtn->setEnabled(true); // output_line += "\n";
// mOutputLog->appendText(output_line, true);
// ++iter;
//}
mOutputLog->setCursorAndScrollToEnd();
mWriteThumbnailsBtn->setEnabled(true);
} }
#if 1 #if 1
...@@ -331,41 +346,38 @@ bool writeThumbnailID(LLUUID item_id, LLUUID thumbnail_asset_id) ...@@ -331,41 +346,38 @@ bool writeThumbnailID(LLUUID item_id, LLUUID thumbnail_asset_id)
} }
else else
{ {
LL_WARNS() << "Unable to write inventory thumbnail because AIS API is not available" << LL_ENDL; LL_WARNS() << "Unable to write inventory thumbnail because the AIS API is not available" << LL_ENDL;
return false; return false;
} }
} }
void LLFloaterBulkyThumbs::onWriteBulkyThumbs() void LLFloaterBulkyThumbs::onWriteThumbnails()
{ {
// look at void LLFloaterChangeItemThumbnail::setThumbnailId(const LLUUID& new_thumbnail_id, const LLUUID& object_id, LLInventoryObject* obj) mOutputLog->appendText(
STRINGIZE(
"\n==== Writing thumbnails for " <<
mNameItemIDTextureId.size() <<
" entries ====" <<
std::endl
), false);
/**
* Results I get - compare with what the manual image update code gives us
Senra Blake - bottom - sweatpants - green
item ID: 1daf6aab-e42f-42aa-5a85-4d73458a355d
thumbnail texture ID: cba71b7c-2335-e15c-7646-ead0f9e817fb
Correct values (from mnala path) are:
Updating thumbnail forSenra Blake - bottom - sweatpants - green:
ID: 1daf6aab-e42f-42aa-5a85-4d73458a355d
THUMB_ID: 8f5db9e7-8d09-c8be-0efd-0a5e4f3c925d
*/
mInventoryItems->appendText("Writing thumbnails", true);
std::map<std::string, std::pair< LLUUID, LLUUID>>::iterator iter = mNameItemIDTextureId.begin(); std::map<std::string, std::pair< LLUUID, LLUUID>>::iterator iter = mNameItemIDTextureId.begin();
size_t index = 1;
while (iter != mNameItemIDTextureId.end()) while (iter != mNameItemIDTextureId.end())
{ {
std::string output_line = (*iter).first; mOutputLog->appendText(
output_line += "\n"; STRINGIZE(
output_line += "item ID: "; "WRITING THUMB (" << index++ << "/" << mNameItemIDTextureId.size() << ")> " <<
output_line += ((*iter).second).first.asString(); (*iter).first <<
output_line += "\n"; "\n" <<
output_line += "thumbnail texture ID: "; "item ID: " <<
output_line += ((*iter).second).second.asString(); ((*iter).second).first.asString() <<
output_line += "\n"; "\n" <<
mInventoryItems->appendText(output_line, true); "thumbnail texture ID: " <<
((*iter).second).second.asString() <<
"\n"
), true);
LLUUID item_id = ((*iter).second).first; LLUUID item_id = ((*iter).second).first;
LLUUID thumbnail_asset_id = ((*iter).second).second; LLUUID thumbnail_asset_id = ((*iter).second).second;
...@@ -374,5 +386,5 @@ void LLFloaterBulkyThumbs::onWriteBulkyThumbs() ...@@ -374,5 +386,5 @@ void LLFloaterBulkyThumbs::onWriteBulkyThumbs()
++iter; ++iter;
} }
mInventoryItems->setCursorAndScrollToEnd(); mOutputLog->setCursorAndScrollToEnd();
} }
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "llfloater.h" #include "llfloater.h"
class LLTextEditor; class LLTextEditor;
class LLMediaCtrl;
class LLViewerInventoryItem; class LLViewerInventoryItem;
class LLUUID; class LLUUID;
...@@ -48,13 +49,13 @@ class LLFloaterBulkyThumbs: ...@@ -48,13 +49,13 @@ class LLFloaterBulkyThumbs:
LLUICtrl* mPasteTexturesBtn; LLUICtrl* mPasteTexturesBtn;
void onPasteTextures(); void onPasteTextures();
LLTextEditor* mInventoryItems; LLTextEditor* mOutputLog;
LLUICtrl* mProcessBulkyThumbsBtn; LLUICtrl* mMergeItemsTexturesBtn;
void onProcessBulkyThumbs(); void onMergeItemsTextures();
LLUICtrl* mWriteBulkyThumbsBtn; LLUICtrl* mWriteThumbnailsBtn;
void onWriteBulkyThumbs(); void onWriteThumbnails();
void recordInventoryItemEntry(LLViewerInventoryItem* item); void recordInventoryItemEntry(LLViewerInventoryItem* item);
void recordTextureItemEntry(LLViewerInventoryItem* item); void recordTextureItemEntry(LLViewerInventoryItem* item);
......
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater <floater
legacy_header_height="18" legacy_header_height="18"
can_resize="true" can_resize="true"
height="600" height="600"
layout="topleft" layout="topleft"
min_height="175" min_height="175"
min_width="500" min_width="500"
name="contents" name="contents"
help_topic="contents" help_topic="contents"
title="BULKY THUMBS" title="BULKY THUMBS"
width="500"> width="500">
<button follows="left|top" <button
height="20" follows="left|top"
label="Paste item info from Inventory" height="20"
layout="topleft" label="Paste items from Inventory"
left="10" layout="topleft"
name="paste_items_btn" left="10"
top="26 " name="paste_items_btn"
width="200" /> top="26 "
width="200" />
<button follows="left|top" <button
height="20" follows="left|top"
label="Paste texture info from Inventory" height="20"
layout="topleft" label="Paste textures from Inventory"
left="250" layout="topleft"
name="paste_textures_btn" left="250"
top="26 " name="paste_textures_btn"
width="200" /> top="26 "
width="200" />
<text_editor <text_editor
height="510" height="510"
follows="top|left|right|bottom" follows="top|left|right|bottom"
left="10" left="10"
name="inventory_items" name="output_log"
top_pad="10" top_pad="10"
width="480"> width="480">
</text_editor> </text_editor>
<button follows="left|bottom" <button
height="20" follows="left|bottom"
label="Merge items and textures" height="20"
layout="bottomleft" label="Merge items and textures"
left="10" layout="bottomleft"
name="process_bulky_thumbs" left="10"
bottom="8" name="merge_items_textures"
width="200" /> bottom="8"
width="200" />
<button follows="left|bottom" <button
height="20" follows="left|bottom"
label="Write Thumbnails" height="20"
layout="bottomleft" label="Write Thumbnails"
left="250" layout="bottomleft"
name="write_bulky_thumbs" left="250"
bottom="8" name="write_items_thumbnails"
width="200" /> bottom="8"
</floater> width="200" />
</floater>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment