From e25a02c4071bfca6ca4313297a87eac991aefd30 Mon Sep 17 00:00:00 2001 From: phr0z3nt04st Date: Mon, 5 Jul 2010 12:50:38 -0500 Subject: [PATCH] Fixed default filename for exporter. --- indra/newview/llfloaterexport.cpp | 144 ++++++++++++------------------ indra/newview/llfloaterexport.h | 10 --- 2 files changed, 56 insertions(+), 98 deletions(-) diff --git a/indra/newview/llfloaterexport.cpp b/indra/newview/llfloaterexport.cpp index f131846a5..9ff78e8c8 100644 --- a/indra/newview/llfloaterexport.cpp +++ b/indra/newview/llfloaterexport.cpp @@ -668,6 +668,60 @@ void LLFloaterExport::onClickSaveAs(void* user_data) if(sd.size()) { std::string default_filename = "untitled"; + + // count the number of selected items + LLScrollListCtrl* list = floater->getChild("export_list"); + std::vector items = list->getAllData(); + int item_count = 0; + LLUUID avatarid = (*(items.begin()))->getColumn(LIST_AVATARID)->getValue().asUUID(); + bool all_same_avatarid = true; + std::vector::iterator item_iter = items.begin(); + std::vector::iterator items_end = items.end(); + for( ; item_iter != items_end; ++item_iter) + { + LLScrollListItem* item = (*item_iter); + if(item->getColumn(LIST_CHECKED)->getValue()) + { + item_count++; + if(item->getColumn(LIST_AVATARID)->getValue().asUUID() != avatarid) + { + all_same_avatarid = false; + } + } + } + + if(item_count == 1) + { + // Exporting one item? Use its name for the filename. + // But make sure it's a root! + LLSD target = (*(sd.beginMap())).second; + if(target.has("parent")) + { + std::string parentid = target["parent"].asString(); + target = sd[parentid]; + } + if(target.has("name")) + { + if(target["name"].asString().length() > 0) + { + default_filename = target["name"].asString(); + } + } + } + else + { + // Multiple items? + // If they're all part of the same avatar, use the avatar's name as filename. + if(all_same_avatarid) + { + std::string fullname; + if(gCacheName->getFullName(avatarid, fullname)) + { + default_filename = fullname; + } + } + } + LLFilePicker& file_picker = LLFilePicker::instance(); if(file_picker.getSaveFile( LLFilePicker::FFSAVE_XML, LLDir::getScrubbedFileName(default_filename + ".xml"))) { @@ -737,65 +791,13 @@ void LLFloaterExport::onClickSaveAs(void* user_data) { llinfos << "Requesting texture " << textures.front().asString() << llendl; LLViewerImage* img = gImageList.getImage(textures.front(), MIPMAP_TRUE, FALSE); - img->setBoostLevel(LLViewerImageBoostLevel::BOOST_MAX_LEVEL); + img->setBoostLevel(LLViewerImageBoostLevel::BOOST_MAX_LEVEL); - CacheReadResponder* responder = new CacheReadResponder(textures.front(), std::string(path + textures.front().asString() + ".j2c")); + CacheReadResponder* responder = new CacheReadResponder(textures.front(), std::string(path + textures.front().asString() + ".j2c")); LLAppViewer::getTextureCache()->readFromCache(textures.front(),LLWorkerThread::PRIORITY_HIGH,0,999999,responder); textures.pop_front(); } } - // count the number of selected items - LLScrollListCtrl* list = floater->getChild("export_list"); - std::vector items = list->getAllData(); - int item_count = 0; - LLUUID avatarid = (*(items.begin()))->getColumn(LIST_AVATARID)->getValue().asUUID(); - bool all_same_avatarid = true; - std::vector::iterator item_iter = items.begin(); - std::vector::iterator items_end = items.end(); - for( ; item_iter != items_end; ++item_iter) - { - LLScrollListItem* item = (*item_iter); - if(item->getColumn(LIST_CHECKED)->getValue()) - { - item_count++; - if(item->getColumn(LIST_AVATARID)->getValue().asUUID() != avatarid) - { - all_same_avatarid = false; - } - } - } - - if(item_count == 1) - { - // Exporting one item? Use its name for the filename. - // But make sure it's a root! - LLSD target = (*(sd.beginMap())).second; - if(target.has("parent")) - { - std::string parentid = target["parent"].asString(); - target = sd[parentid]; - } - if(target.has("name")) - { - if(target["name"].asString().length() > 0) - { - default_filename = target["name"].asString(); - } - } - } - else - { - // Multiple items? - // If they're all part of the same avatar, use the avatar's name as filename. - if(all_same_avatarid) - { - std::string fullname; - if(gCacheName->getFullName(avatarid, fullname)) - { - default_filename = fullname; - } - } - } llofstream export_file(file_name); LLSDSerialize::toPrettyXML(sd, export_file); @@ -818,40 +820,6 @@ void LLFloaterExport::onClickSaveAs(void* user_data) floater->close(); } -void LLFloaterExport::onFileLoadedForSave(BOOL success, - LLViewerImage *src_vi, - LLImageRaw* src, - LLImageRaw* aux_src, - S32 discard_level, - BOOL final, - void* userdata) -{ - if(!userdata){ llinfos << "NULL POINTER" << llendl; return;} - if(final) - { - std::string *temp = static_cast(userdata); - std::string path = *temp; - if( success ) - { - LLPointer image_j2c = new LLImageJ2C(); - if(!image_j2c->encode(src,0.0)) - { - //errorencode - llinfos << "Failed to encode " << path << llendl; - }else if(!image_j2c->save( path )) - { - llinfos << "Failed to write " << path << llendl; - //errorwrite - }else - { - llinfos << "Saved texture " << path << llendl; - //success - } - } - delete temp; - } - -} //static void LLFloaterExport::onClickMakeCopy(void* user_data) diff --git a/indra/newview/llfloaterexport.h b/indra/newview/llfloaterexport.h index 97fe994a4..e5f1028c5 100644 --- a/indra/newview/llfloaterexport.h +++ b/indra/newview/llfloaterexport.h @@ -93,16 +93,6 @@ public: static void onClickSelectWearables(void* user_data); static void onClickSaveAs(void* user_data); static void onClickMakeCopy(void* user_data); - - static void onFileLoadedForSave( - BOOL success, - LLViewerImage *src_vi, - LLImageRaw* src, - LLImageRaw* aux_src, - S32 discard_level, - BOOL final, - void* userdata ); - private: virtual ~LLFloaterExport();