From db3f7eafa05636a3079037109d3d21514b25a8bb Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 4 Jun 2024 02:08:12 +0300 Subject: viewer#1588 Upload directly to Specified Inventory Folder --- indra/newview/llfloaterbvhpreview.cpp | 7 +- indra/newview/llfloaterbvhpreview.h | 2 +- indra/newview/llfloaterimagepreview.cpp | 4 +- indra/newview/llfloaterimagepreview.h | 2 +- indra/newview/llfloatermodelpreview.cpp | 8 +- indra/newview/llfloatermodelpreview.h | 7 +- indra/newview/llfloaternamedesc.cpp | 32 +++-- indra/newview/llfloaternamedesc.h | 9 +- indra/newview/llinventorybridge.cpp | 3 + indra/newview/llinventoryfunctions.cpp | 51 ++++++++ indra/newview/llinventoryfunctions.h | 1 + indra/newview/llinventorygallerymenu.cpp | 19 +-- indra/newview/llinventorypanel.cpp | 22 +--- indra/newview/llmaterialeditor.cpp | 29 +++-- indra/newview/llmaterialeditor.h | 14 ++- indra/newview/llmeshrepository.cpp | 19 ++- indra/newview/llmeshrepository.h | 9 +- indra/newview/llsnapshotlivepreview.cpp | 2 +- indra/newview/llviewerassetupload.cpp | 26 +++-- indra/newview/llviewerassetupload.h | 5 + indra/newview/llviewermenufile.cpp | 44 ++++--- indra/newview/llviewermenufile.h | 10 ++ .../default/xui/en/menu_gallery_inventory.xml | 130 +++++++++++++++++++++ .../skins/default/xui/en/menu_inventory.xml | 103 +++++++++++++--- 24 files changed, 429 insertions(+), 129 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterbvhpreview.cpp b/indra/newview/llfloaterbvhpreview.cpp index 1fb0a72d3e..5c80d9cdc9 100644 --- a/indra/newview/llfloaterbvhpreview.cpp +++ b/indra/newview/llfloaterbvhpreview.cpp @@ -118,8 +118,8 @@ std::string STATUS[] = //----------------------------------------------------------------------------- // LLFloaterBvhPreview() //----------------------------------------------------------------------------- -LLFloaterBvhPreview::LLFloaterBvhPreview(const std::string& filename) : - LLFloaterNameDesc(filename) +LLFloaterBvhPreview::LLFloaterBvhPreview(const LLSD& args) : + LLFloaterNameDesc(args) { mLastMouseX = 0; mLastMouseY = 0; @@ -1013,7 +1013,8 @@ void LLFloaterBvhPreview::onBtnOK(void* userdata) LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - expected_upload_cost)); + expected_upload_cost, + floaterp->mDestinationFolderId)); upload_new_resource(assetUploadInfo); } diff --git a/indra/newview/llfloaterbvhpreview.h b/indra/newview/llfloaterbvhpreview.h index 9de74c39cd..4dd28389a5 100644 --- a/indra/newview/llfloaterbvhpreview.h +++ b/indra/newview/llfloaterbvhpreview.h @@ -70,7 +70,7 @@ protected: class LLFloaterBvhPreview : public LLFloaterNameDesc { public: - LLFloaterBvhPreview(const std::string& filename); + LLFloaterBvhPreview(const LLSD& args); virtual ~LLFloaterBvhPreview(); BOOL postBuild(); diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp index 7851c5403b..9fa3dd0c47 100644 --- a/indra/newview/llfloaterimagepreview.cpp +++ b/indra/newview/llfloaterimagepreview.cpp @@ -71,8 +71,8 @@ const S32 PREVIEW_TEXTURE_HEIGHT = 320; //----------------------------------------------------------------------------- // LLFloaterImagePreview() //----------------------------------------------------------------------------- -LLFloaterImagePreview::LLFloaterImagePreview(const std::string& filename) : - LLFloaterNameDesc(filename), +LLFloaterImagePreview::LLFloaterImagePreview(const LLSD& args) : + LLFloaterNameDesc(args), mAvatarPreview(NULL), mSculptedPreview(NULL), diff --git a/indra/newview/llfloaterimagepreview.h b/indra/newview/llfloaterimagepreview.h index 9e764e4972..47228d7676 100644 --- a/indra/newview/llfloaterimagepreview.h +++ b/indra/newview/llfloaterimagepreview.h @@ -110,7 +110,7 @@ protected: class LLFloaterImagePreview : public LLFloaterNameDesc { public: - LLFloaterImagePreview(const std::string& filename); + LLFloaterImagePreview(const LLSD& args); virtual ~LLFloaterImagePreview(); virtual BOOL postBuild(); diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 66f89d88d3..ab5766f260 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -349,14 +349,14 @@ void LLFloaterModelPreview::initModelPreview() } //static -bool LLFloaterModelPreview::showModelPreview() +void LLFloaterModelPreview::showModelPreview(const LLUUID& dest_folder) { LLFloaterModelPreview* fmp = (LLFloaterModelPreview*)LLFloaterReg::getInstance("upload_model"); if (fmp && !fmp->isModelLoading()) { + fmp->setUploadDestination(dest_folder); fmp->loadHighLodModel(); } - return true; } void LLFloaterModelPreview::onUploadOptionChecked(LLUICtrl* ctrl) @@ -505,7 +505,7 @@ void LLFloaterModelPreview::onClickCalculateBtn() gMeshRepo.uploadModel(mModelPreview->mUploadData, mModelPreview->mPreviewScale, childGetValue("upload_textures").asBoolean(), upload_skinweights, upload_joint_positions, lock_scale_if_joint_position, - mUploadModelUrl, false, + mUploadModelUrl, mDestinationFolderId, false, getWholeModelFeeObserverHandle()); toggleCalculateButton(false); @@ -1655,7 +1655,7 @@ void LLFloaterModelPreview::onUpload(void* user_data) gMeshRepo.uploadModel(mp->mModelPreview->mUploadData, mp->mModelPreview->mPreviewScale, mp->childGetValue("upload_textures").asBoolean(), upload_skinweights, upload_joint_positions, lock_scale_if_joint_position, - mp->mUploadModelUrl, + mp->mUploadModelUrl, mp->mDestinationFolderId, true, LLHandle(), mp->getWholeModelUploadObserverHandle()); } diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index 20e645532b..018014ba04 100644 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -73,7 +73,8 @@ public: /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); void initModelPreview(); - static bool showModelPreview(); + void setUploadDestination(const LLUUID& dest_folder) { mDestinationFolderId = dest_folder; } + static void showModelPreview(const LLUUID& dest_folder = LLUUID::null); BOOL handleMouseDown(S32 x, S32 y, MASK mask); BOOL handleMouseUp(S32 x, S32 y, MASK mask); @@ -164,9 +165,6 @@ protected: static void onPhysicsBrowse(LLUICtrl* ctrl, void* userdata); static void onPhysicsUseLOD(LLUICtrl* ctrl, void* userdata); - static void onPhysicsOptimize(LLUICtrl* ctrl, void* userdata); - static void onPhysicsDecomposeBack(LLUICtrl* ctrl, void* userdata); - static void onPhysicsSimplifyBack(LLUICtrl* ctrl, void* userdata); void draw(); @@ -225,6 +223,7 @@ private: void createSmoothComboBox(LLComboBox* combo_box, float min, float max); + LLUUID mDestinationFolderId; LLButton* mUploadBtn; LLButton* mCalculateBtn; LLViewerTextEditor* mUploadLogText; diff --git a/indra/newview/llfloaternamedesc.cpp b/indra/newview/llfloaternamedesc.cpp index b47deb838b..ffb21f34c9 100644 --- a/indra/newview/llfloaternamedesc.cpp +++ b/indra/newview/llfloaternamedesc.cpp @@ -62,11 +62,20 @@ const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE; //----------------------------------------------------------------------------- // LLFloaterNameDesc() //----------------------------------------------------------------------------- -LLFloaterNameDesc::LLFloaterNameDesc(const LLSD& filename ) - : LLFloater(filename), - mIsAudio(FALSE) +LLFloaterNameDesc::LLFloaterNameDesc(const LLSD& args) + : LLFloater(args) + , mIsAudio(FALSE) + , mIsText(FALSE) { - mFilenameAndPath = filename.asString(); + if (args.isString()) + { + mFilenameAndPath = args.asString(); + } + else + { + mFilenameAndPath = args["filename"].asString(); + mDestinationFolderId = args["dest"].asUUID(); + } mFilename = gDirUtilp->getBaseFileName(mFilenameAndPath, false); } @@ -203,7 +212,8 @@ void LLFloaterNameDesc::onBtnOK( ) LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - expected_upload_cost)); + expected_upload_cost, + mDestinationFolderId)); upload_new_resource(uploadInfo, callback, nruserdata); } @@ -230,8 +240,8 @@ void LLFloaterNameDesc::onBtnCancel() // LLFloaterSoundPreview() //----------------------------------------------------------------------------- -LLFloaterSoundPreview::LLFloaterSoundPreview(const LLSD& filename ) - : LLFloaterNameDesc(filename) +LLFloaterSoundPreview::LLFloaterSoundPreview(const LLSD& args ) + : LLFloaterNameDesc(args) { mIsAudio = TRUE; } @@ -251,8 +261,8 @@ BOOL LLFloaterSoundPreview::postBuild() // LLFloaterAnimPreview() //----------------------------------------------------------------------------- -LLFloaterAnimPreview::LLFloaterAnimPreview(const LLSD& filename ) - : LLFloaterNameDesc(filename) +LLFloaterAnimPreview::LLFloaterAnimPreview(const LLSD& args ) + : LLFloaterNameDesc(args) { } @@ -270,8 +280,8 @@ BOOL LLFloaterAnimPreview::postBuild() // LLFloaterScriptPreview() //----------------------------------------------------------------------------- -LLFloaterScriptPreview::LLFloaterScriptPreview(const LLSD& filename ) - : LLFloaterNameDesc(filename) +LLFloaterScriptPreview::LLFloaterScriptPreview(const LLSD& args ) + : LLFloaterNameDesc(args) { mIsText = TRUE; } diff --git a/indra/newview/llfloaternamedesc.h b/indra/newview/llfloaternamedesc.h index 148da6912a..f2dc8cfaa7 100644 --- a/indra/newview/llfloaternamedesc.h +++ b/indra/newview/llfloaternamedesc.h @@ -39,7 +39,7 @@ class LLRadioGroup; class LLFloaterNameDesc : public LLFloater { public: - LLFloaterNameDesc(const LLSD& filename); + LLFloaterNameDesc(const LLSD& args); virtual ~LLFloaterNameDesc(); virtual BOOL postBuild(); @@ -58,26 +58,27 @@ protected: std::string mFilenameAndPath; std::string mFilename; + LLUUID mDestinationFolderId; }; class LLFloaterSoundPreview : public LLFloaterNameDesc { public: - LLFloaterSoundPreview(const LLSD& filename ); + LLFloaterSoundPreview(const LLSD& args ); virtual BOOL postBuild(); }; class LLFloaterAnimPreview : public LLFloaterNameDesc { public: - LLFloaterAnimPreview(const LLSD& filename ); + LLFloaterAnimPreview(const LLSD& args ); virtual BOOL postBuild(); }; class LLFloaterScriptPreview : public LLFloaterNameDesc { public: - LLFloaterScriptPreview(const LLSD& filename ); + LLFloaterScriptPreview(const LLSD& args ); virtual BOOL postBuild(); }; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index fbb4ac8801..b4a3054d07 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -4263,6 +4263,7 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items } disabled_items.push_back(std::string("New Folder")); + disabled_items.push_back(std::string("upload_options")); disabled_items.push_back(std::string("upload_def")); disabled_items.push_back(std::string("create_new")); } @@ -4286,6 +4287,7 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items if (getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK) { disabled_items.push_back(std::string("New Folder")); + disabled_items.push_back(std::string("upload_options")); disabled_items.push_back(std::string("upload_def")); disabled_items.push_back(std::string("create_new")); } @@ -4351,6 +4353,7 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items } if (!isMarketplaceListingsFolder()) { + items.push_back(std::string("upload_options")); items.push_back(std::string("upload_def")); items.push_back(std::string("create_new")); items.push_back(std::string("New Script")); diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index be9a20b924..909dea050e 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -51,6 +51,7 @@ #include "lldirpicker.h" #include "lldonotdisturbnotificationstorage.h" #include "llfloatermarketplacelistings.h" +#include "llfloatermodelpreview.h" #include "llfloatersidepanelcontainer.h" #include "llfocusmgr.h" #include "llfolderview.h" @@ -62,6 +63,7 @@ #include "llinventorymodel.h" #include "llinventorypanel.h" #include "lllineeditor.h" +#include "llmaterialeditor.h" #include "llmarketplacenotifications.h" #include "llmarketplacefunctions.h" #include "llmenugl.h" @@ -86,6 +88,7 @@ #include "llviewermessage.h" #include "llviewerfoldertype.h" #include "llviewerobjectlist.h" +#include "llviewermenufile.h" #include "llviewerregion.h" #include "llviewerwindow.h" #include "llvoavatarself.h" @@ -3548,6 +3551,54 @@ void LLInventoryAction::removeItemFromDND(LLFolderView* root) } } +void LLInventoryAction::fileUploadLocation(const LLUUID& dest_id, const std::string& action) +{ + if (action == "def_model") + { + gSavedPerAccountSettings.setString("ModelUploadFolder", dest_id.asString()); + } + else if (action == "def_texture") + { + gSavedPerAccountSettings.setString("TextureUploadFolder", dest_id.asString()); + } + else if (action == "def_sound") + { + gSavedPerAccountSettings.setString("SoundUploadFolder", dest_id.asString()); + } + else if (action == "def_animation") + { + gSavedPerAccountSettings.setString("AnimationUploadFolder", dest_id.asString()); + } + else if (action == "def_pbr_material") + { + gSavedPerAccountSettings.setString("PBRUploadFolder", dest_id.asString()); + } + else if (action == "upload_texture") + { + LLFilePickerReplyThread::startPicker(boost::bind(&upload_single_file, _1, _2, dest_id), LLFilePicker::FFLOAD_IMAGE, false); + } + else if (action == "upload_sound") + { + LLFilePickerReplyThread::startPicker(boost::bind(&upload_single_file, _1, _2, dest_id), LLFilePicker::FFLOAD_WAV, false); + } + else if (action == "upload_animation") + { + LLFilePickerReplyThread::startPicker(boost::bind(&upload_single_file, _1, _2, dest_id), LLFilePicker::FFLOAD_ANIM, false); + } + else if (action == "upload_model") + { + LLFloaterModelPreview::showModelPreview(dest_id); + } + else if (action == "upload_pbr_material") + { + LLMaterialEditor::importMaterial(dest_id); + } + else if (action == "upload_bulk") + { + LLFilePickerReplyThread::startPicker(boost::bind(&upload_bulk, _1, _2, dest_id), LLFilePicker::FFLOAD_ALL, true); + } +} + void LLInventoryAction::onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response, LLHandle root) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 5cb996ad54..f8403f890c 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -583,6 +583,7 @@ struct LLInventoryAction static void callback_copySelected(const LLSD& notification, const LLSD& response, class LLInventoryModel* model, class LLFolderView* root, const std::string& action); static void onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response, LLHandle root); static void removeItemFromDND(LLFolderView* root); + static void fileUploadLocation(const LLUUID& dest_id, const std::string& action); static void saveMultipleTextures(const std::vector& filenames, std::set selected_items, LLInventoryModel* model); diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 4b47346473..77bdb4d1f5 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -344,22 +344,7 @@ void LLInventoryGalleryContextMenu::onRename(const LLSD& notification, const LLS void LLInventoryGalleryContextMenu::fileUploadLocation(const LLSD& userdata) { const std::string param = userdata.asString(); - if (param == "model") - { - gSavedPerAccountSettings.setString("ModelUploadFolder", mUUIDs.front().asString()); - } - else if (param == "texture") - { - gSavedPerAccountSettings.setString("TextureUploadFolder", mUUIDs.front().asString()); - } - else if (param == "sound") - { - gSavedPerAccountSettings.setString("SoundUploadFolder", mUUIDs.front().asString()); - } - else if (param == "animation") - { - gSavedPerAccountSettings.setString("AnimationUploadFolder", mUUIDs.front().asString()); - } + LLInventoryAction::fileUploadLocation(mUUIDs.front(), param); } bool LLInventoryGalleryContextMenu::canSetUploadLocation(const LLSD& userdata) @@ -525,6 +510,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men { items.push_back(std::string("New Folder")); } + items.push_back(std::string("upload_options")); items.push_back(std::string("upload_def")); } @@ -714,6 +700,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men } disabled_items.push_back(std::string("New Folder")); + disabled_items.push_back(std::string("upload_options")); disabled_items.push_back(std::string("upload_def")); } } diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 4ac43ea6b2..f1471e81c7 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -1727,26 +1727,8 @@ bool LLInventoryPanel::beginIMSession() void LLInventoryPanel::fileUploadLocation(const LLSD& userdata) { const std::string param = userdata.asString(); - if (param == "model") - { - gSavedPerAccountSettings.setString("ModelUploadFolder", LLFolderBridge::sSelf.get()->getUUID().asString()); - } - else if (param == "texture") - { - gSavedPerAccountSettings.setString("TextureUploadFolder", LLFolderBridge::sSelf.get()->getUUID().asString()); - } - else if (param == "sound") - { - gSavedPerAccountSettings.setString("SoundUploadFolder", LLFolderBridge::sSelf.get()->getUUID().asString()); - } - else if (param == "animation") - { - gSavedPerAccountSettings.setString("AnimationUploadFolder", LLFolderBridge::sSelf.get()->getUUID().asString()); - } - else if (param == "pbr_material") - { - gSavedPerAccountSettings.setString("PBRUploadFolder", LLFolderBridge::sSelf.get()->getUUID().asString()); - } + const LLUUID dest = LLFolderBridge::sSelf.get()->getUUID(); + LLInventoryAction::fileUploadLocation(dest, param); } void LLInventoryPanel::openSingleViewInventory(LLUUID folder_id) diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index b7811dfb43..f3b2339893 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -1398,7 +1398,7 @@ bool LLMaterialEditor::saveIfNeeded() } std::string res_desc = buildMaterialDescription(); - createInventoryItem(buffer, mMaterialName, res_desc, local_permissions); + createInventoryItem(buffer, mMaterialName, res_desc, local_permissions, mUploadFolder); // We do not update floater with uploaded asset yet, so just close it. closeFloater(); @@ -1568,12 +1568,12 @@ private: std::string mNewName; }; -void LLMaterialEditor::createInventoryItem(const std::string &buffer, const std::string &name, const std::string &desc, const LLPermissions& permissions) +void LLMaterialEditor::createInventoryItem(const std::string &buffer, const std::string &name, const std::string &desc, const LLPermissions& permissions, const LLUUID& upload_folder) { // gen a new uuid for this asset LLTransactionID tid; tid.generate(); // timestamp-based randomization + uniquification - LLUUID parent = gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_MATERIAL); + LLUUID parent = upload_folder.isNull() ? gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_MATERIAL) : upload_folder; const U8 subtype = NO_INV_SUBTYPE; // TODO maybe use AT_SETTINGS and LLSettingsType::ST_MATERIAL ? LLPointer cb = new LLObjectsMaterialItemCallback(permissions, buffer, name); @@ -1887,7 +1887,11 @@ static void pack_textures( } } -void LLMaterialEditor::uploadMaterialFromModel(const std::string& filename, tinygltf::Model& model_in, S32 index) +void LLMaterialEditor::uploadMaterialFromModel( + const std::string& filename, + tinygltf::Model& model_in, + S32 index, + const LLUUID& dest) { if (index < 0 || !LLMaterialEditor::capabilitiesAvailable()) { @@ -1910,12 +1914,13 @@ void LLMaterialEditor::uploadMaterialFromModel(const std::string& filename, tiny // This uses 'filename' to make sure multiple bulk uploads work // instead of fighting for a single instance. LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", LLSD().with("filename", filename).with("index", LLSD::Integer(index))); + me->mUploadFolder = dest; me->loadMaterial(model_in, filename, index, false); me->saveIfNeeded(); } -void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 index) +void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 index, const LLUUID& dest_folder) { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; @@ -1961,6 +1966,7 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 ind } LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor"); + me->mUploadFolder = dest_folder; if (index >= 0) { @@ -2411,17 +2417,15 @@ void LLMaterialEditor::onSaveObjectsMaterialAsMsgCallback(const LLSD& notificati return; } - createInventoryItem(str.str(), new_name, std::string(), permissions); + createInventoryItem(str.str(), new_name, std::string(), permissions, LLUUID::null); } -const void upload_bulk(const std::vector& filenames, LLFilePicker::ELoadFilter type); - void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std::string &filename, S32 index, bool open_floater) { if (index == model_in.materials.size()) { // bulk upload all the things - upload_bulk({ filename }, LLFilePicker::FFLOAD_MATERIAL); + upload_bulk({ filename }, LLFilePicker::FFLOAD_MATERIAL, mUploadFolder); return; } @@ -2828,10 +2832,10 @@ void LLMaterialEditor::setFromGltfMetaData(const std::string& filename, const ti } } -void LLMaterialEditor::importMaterial() +void LLMaterialEditor::importMaterial(const LLUUID dest_folder) { LLFilePickerReplyThread::startPicker( - [](const std::vector& filenames, LLFilePicker::ELoadFilter load_filter, LLFilePicker::ESaveFilter save_filter) + [dest_folder](const std::vector& filenames, LLFilePicker::ELoadFilter load_filter, LLFilePicker::ESaveFilter save_filter) { if (LLAppViewer::instance()->quitRequested()) { @@ -2839,7 +2843,7 @@ void LLMaterialEditor::importMaterial() } if (filenames.size() > 0) { - LLMaterialEditor::loadMaterialFromFile(filenames[0], -1); + LLMaterialEditor::loadMaterialFromFile(filenames[0], -1, dest_folder); } }, LLFilePicker::FFLOAD_MATERIAL, @@ -3521,6 +3525,7 @@ void LLMaterialEditor::saveTexture(LLImageJ2C* img, const std::string& name, con LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), expected_upload_cost, + mUploadFolder, false, cb, failed_upload)); diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index dda65476af..68b957a489 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -94,7 +94,7 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener void setFromGltfMetaData(const std::string& filename, const tinygltf::Model& model, S32 index); // open a file dialog and select a gltf/glb file for import - static void importMaterial(); + static void importMaterial(const LLUUID dest_folder = LLUUID::null); // for live preview, apply current material to currently selected object void applyToSelection(); @@ -105,8 +105,11 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener void loadAsset() override; // @index if -1 and file contains more than one material, // will promt to select specific one - static void uploadMaterialFromModel(const std::string& filename, tinygltf::Model& model, S32 index); - static void loadMaterialFromFile(const std::string& filename, S32 index = -1); + static void uploadMaterialFromModel(const std::string& filename, + tinygltf::Model& model, + S32 index, + const LLUUID& dest_folder_id = LLUUID::null); + static void loadMaterialFromFile(const std::string& filename, S32 index = -1, const LLUUID& dest_folder = LLUUID::null); void onSelectionChanged(); // live overrides selection changes @@ -134,8 +137,6 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener void onClickSave(); - void getGLTFModel(tinygltf::Model& model); - std::string getEncodedAsset(); bool decodeAsset(const std::vector& buffer); @@ -239,7 +240,7 @@ private: static void saveObjectsMaterialAs(const LLGLTFMaterial *render_material, const LLLocalGLTFMaterial *local_material, const LLPermissions& permissions, const LLUUID& object_id /* = LLUUID::null */, const LLUUID& item /* = LLUUID::null */); static bool updateInventoryItem(const std::string &buffer, const LLUUID &item_id, const LLUUID &task_id); - static void createInventoryItem(const std::string &buffer, const std::string &name, const std::string &desc, const LLPermissions& permissions); + static void createInventoryItem(const std::string &buffer, const std::string &name, const std::string &desc, const LLPermissions& permissions, const LLUUID& upload_folder); void setFromGLTFMaterial(LLGLTFMaterial* mat); bool setFromSelection(); @@ -249,6 +250,7 @@ private: friend class LLMaterialFilePicker; LLUUID mAssetID; + LLUUID mUploadFolder; LLTextureCtrl* mBaseColorTextureCtrl; LLTextureCtrl* mMetallicTextureCtrl; diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index f6441f8404..66cad13739 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -2094,7 +2094,7 @@ EMeshProcessingResult LLMeshRepoThread::physicsShapeReceived(const LLUUID& mesh_ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, LLVector3& scale, bool upload_textures, bool upload_skin, bool upload_joints, bool lock_scale_if_joint_position, - const std::string & upload_url, bool do_upload, + const std::string & upload_url, LLUUID destination_folder_id, bool do_upload, LLHandle fee_observer, LLHandle upload_observer) : LLThread("mesh upload"), @@ -2102,6 +2102,7 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, mDiscarded(false), mDoUpload(do_upload), mWholeModelUploadURL(upload_url), + mDestinationFolderId(destination_folder_id), mFeeObserverHandle(fee_observer), mUploadObserverHandle(upload_observer) { @@ -2224,8 +2225,16 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures) LLSD result; LLSD res; - result["folder_id"] = gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_OBJECT); - result["texture_folder_id"] = gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_TEXTURE); + if (mDestinationFolderId.isNull()) + { + result["folder_id"] = gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_OBJECT); + result["texture_folder_id"] = gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_TEXTURE); + } + else + { + result["folder_id"] = mDestinationFolderId; + result["texture_folder_id"] = mDestinationFolderId; + } result["asset_type"] = "mesh"; result["inventory_type"] = "object"; result["description"] = "(No Description)"; @@ -4338,12 +4347,12 @@ bool LLMeshRepoThread::hasHeader(const LLUUID& mesh_id) void LLMeshRepository::uploadModel(std::vector& data, LLVector3& scale, bool upload_textures, bool upload_skin, bool upload_joints, bool lock_scale_if_joint_position, - std::string upload_url, bool do_upload, + std::string upload_url, const LLUUID& destination_folder_id, bool do_upload, LLHandle fee_observer, LLHandle upload_observer) { LLMeshUploadThread* thread = new LLMeshUploadThread(data, scale, upload_textures, upload_skin, upload_joints, lock_scale_if_joint_position, - upload_url, do_upload, fee_observer, upload_observer); + upload_url, destination_folder_id, do_upload, fee_observer, upload_observer); mUploadWaitList.push_back(thread); } diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index b31d726004..e77a4a6af7 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -501,10 +501,13 @@ public: LLHost mHost; std::string mWholeModelFeeCapability; std::string mWholeModelUploadURL; + LLUUID mDestinationFolderId; LLMeshUploadThread(instance_list& data, LLVector3& scale, bool upload_textures, bool upload_skin, bool upload_joints, bool lock_scale_if_joint_position, - const std::string & upload_url, bool do_upload = true, + const std::string & upload_url, + const LLUUID destination_folder_id = LLUUID::null, + bool do_upload = true, LLHandle fee_observer = (LLHandle()), LLHandle upload_observer = (LLHandle())); ~LLMeshUploadThread(); @@ -663,7 +666,9 @@ public: void uploadModel(std::vector& data, LLVector3& scale, bool upload_textures, bool upload_skin, bool upload_joints, bool lock_scale_if_joint_position, - std::string upload_url, bool do_upload = true, + std::string upload_url, + const LLUUID& destination_folder_id = LLUUID::null, + bool do_upload = true, LLHandle fee_observer= (LLHandle()), LLHandle upload_observer = (LLHandle())); diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index ef0f58ff7a..1310826d06 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -1028,7 +1028,7 @@ void LLSnapshotLivePreview::saveTexture(BOOL outfit_snapshot, std::string name) tid, LLAssetType::AT_TEXTURE, res_name, res_desc, 0, folder_type, inv_type, PERM_ALL, LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - expected_upload_cost, !outfit_snapshot)); + expected_upload_cost, LLUUID::null, !outfit_snapshot)); upload_new_resource(assetUploadInfo); diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 078db565f5..daf635cc57 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -62,7 +62,8 @@ LLResourceUploadInfo::LLResourceUploadInfo(LLTransactionID transactId, LLAssetType::EType assetType, std::string name, std::string description, S32 compressionInfo, LLFolderType::EType destinationType, LLInventoryType::EType inventoryType, U32 nextOWnerPerms, - U32 groupPerms, U32 everyonePerms, S32 expectedCost, bool showInventory) : + U32 groupPerms, U32 everyonePerms, S32 expectedCost, + const LLUUID& destFolderId, bool showInventory) : mTransactionId(transactId), mAssetType(assetType), mName(name), @@ -75,7 +76,7 @@ LLResourceUploadInfo::LLResourceUploadInfo(LLTransactionID transactId, mEveryonePerms(everyonePerms), mExpectedUploadCost(expectedCost), mShowInventory(showInventory), - mFolderId(LLUUID::null), + mFolderId(destFolderId), mItemId(LLUUID::null), mAssetId(LLAssetID::null) { } @@ -84,7 +85,8 @@ LLResourceUploadInfo::LLResourceUploadInfo(LLTransactionID transactId, LLResourceUploadInfo::LLResourceUploadInfo(std::string name, std::string description, S32 compressionInfo, LLFolderType::EType destinationType, LLInventoryType::EType inventoryType, - U32 nextOWnerPerms, U32 groupPerms, U32 everyonePerms, S32 expectedCost, bool showInventory) : + U32 nextOWnerPerms, U32 groupPerms, U32 everyonePerms, S32 expectedCost, + const LLUUID& destFolderId, bool showInventory) : mName(name), mDescription(description), mCompressionInfo(compressionInfo), @@ -97,7 +99,7 @@ LLResourceUploadInfo::LLResourceUploadInfo(std::string name, mShowInventory(showInventory), mTransactionId(), mAssetType(LLAssetType::AT_NONE), - mFolderId(LLUUID::null), + mFolderId(destFolderId), mItemId(LLUUID::null), mAssetId(LLAssetID::null) { @@ -299,9 +301,12 @@ void LLResourceUploadInfo::assignDefaults() mDescription = "(No Description)"; } - mFolderId = gInventory.findUserDefinedCategoryUUIDForType( - (mDestinationFolderType == LLFolderType::FT_NONE) ? - (LLFolderType::EType)mAssetType : mDestinationFolderType); + if (mFolderId.isNull()) + { + mFolderId = gInventory.findUserDefinedCategoryUUIDForType( + (mDestinationFolderType == LLFolderType::FT_NONE) ? + (LLFolderType::EType)mAssetType : mDestinationFolderType); + } } std::string LLResourceUploadInfo::getDisplayName() const @@ -358,10 +363,12 @@ LLNewFileResourceUploadInfo::LLNewFileResourceUploadInfo( U32 groupPerms, U32 everyonePerms, S32 expectedCost, + const LLUUID& destFolderId, bool show_inventory) : LLResourceUploadInfo(name, description, compressionInfo, destinationType, inventoryType, - nextOWnerPerms, groupPerms, everyonePerms, expectedCost, show_inventory), + nextOWnerPerms, groupPerms, everyonePerms, expectedCost, + destFolderId, show_inventory), mFileName(fileName) { } @@ -566,12 +573,13 @@ LLNewBufferedResourceUploadInfo::LLNewBufferedResourceUploadInfo( U32 groupPerms, U32 everyonePerms, S32 expectedCost, + const LLUUID& destFolderId, bool show_inventory, uploadFinish_f finish, uploadFailure_f failure) : LLResourceUploadInfo(name, description, compressionInfo, destinationType, inventoryType, - nextOWnerPerms, groupPerms, everyonePerms, expectedCost, show_inventory) + nextOWnerPerms, groupPerms, everyonePerms, expectedCost, destFolderId, show_inventory) , mBuffer(buffer) , mFinishFn(finish) , mFailureFn(failure) diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 5a07fbf802..dbe2c7e7ea 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -54,6 +54,7 @@ public: U32 groupPerms, U32 everyonePerms, S32 expectedCost, + const LLUUID &destFolderId = LLUUID::null, bool showInventory = true); virtual ~LLResourceUploadInfo() @@ -104,6 +105,7 @@ protected: U32 groupPerms, U32 everyonePerms, S32 expectedCost, + const LLUUID& destFolderId = LLUUID::null, bool showInventory = true); LLResourceUploadInfo( @@ -155,6 +157,7 @@ public: U32 groupPerms, U32 everyonePerms, S32 expectedCost, + const LLUUID &destFolderId = LLUUID::null, bool show_inventory = true); virtual LLSD prepareUpload(); @@ -191,6 +194,7 @@ public: U32 groupPerms, U32 everyonePerms, S32 expectedCost, + const LLUUID& destFolderId, // use null for default bool show_inventory, uploadFinish_f finish, uploadFailure_f failure); @@ -217,6 +221,7 @@ public: typedef std::function taskUploadFinish_f; typedef std::function uploadFailed_f; + // destFolderId is the folder to put the new item in, leave null for default LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish, uploadFailed_f failed); LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer image, invnUploadFinish_f finish); LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish, uploadFailed_f failed); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 2fd75498d2..c312cadafe 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -478,13 +478,19 @@ const bool check_file_extension(const std::string& filename, LLFilePicker::ELoad return true; } -const void upload_single_file(const std::vector& filenames, LLFilePicker::ELoadFilter type) +void upload_single_file( + const std::vector& filenames, + LLFilePicker::ELoadFilter type, + const LLUUID& dest) { std::string filename = filenames[0]; if (!check_file_extension(filename, type)) return; if (!filename.empty()) { + LLSD args; + args["filename"] = filename; + args["dest"] = dest; if (type == LLFilePicker::FFLOAD_WAV) { // pre-qualify wavs to make sure the format is acceptable @@ -499,12 +505,12 @@ const void upload_single_file(const std::vector& filenames, LLFileP } else { - LLFloaterReg::showInstance("upload_sound", LLSD(filename)); + LLFloaterReg::showInstance("upload_sound", args); } } if (type == LLFilePicker::FFLOAD_IMAGE) { - LLFloaterReg::showInstance("upload_image", LLSD(filename)); + LLFloaterReg::showInstance("upload_image", args); } if (type == LLFilePicker::FFLOAD_ANIM) { @@ -512,18 +518,22 @@ const void upload_single_file(const std::vector& filenames, LLFileP LLStringUtil::toLower(filename_lc); if (filename_lc.rfind(".anim") != std::string::npos) { - LLFloaterReg::showInstance("upload_anim_anim", LLSD(filename)); + LLFloaterReg::showInstance("upload_anim_anim", args); } else { - LLFloaterReg::showInstance("upload_anim_bvh", LLSD(filename)); + LLFloaterReg::showInstance("upload_anim_bvh", args); } } } return; } -void do_bulk_upload(std::vector filenames, const LLSD& notification, const LLSD& response) +void do_bulk_upload( + std::vector filenames, + const LLSD& notification, + const LLSD& response, + const LLUUID& dest) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option != 0) @@ -558,7 +568,8 @@ void do_bulk_upload(std::vector filenames, const LLSD& notification LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - expected_upload_cost)); + expected_upload_cost, + dest)); upload_new_resource(uploadInfo); } @@ -576,7 +587,7 @@ void do_bulk_upload(std::vector filenames, const LLSD& notification // Todo: // 1. Decouple bulk upload from material editor // 2. Take into account possiblity of identical textures - LLMaterialEditor::uploadMaterialFromModel(filename, model, i); + LLMaterialEditor::uploadMaterialFromModel(filename, model, i, dest); } } } @@ -657,7 +668,10 @@ bool get_bulk_upload_expected_cost(const std::vector& filenames, S3 return file_count > 0; } -const void upload_bulk(const std::vector& filenames, LLFilePicker::ELoadFilter type) +void upload_bulk( + const std::vector& filenames, + LLFilePicker::ELoadFilter type, + const LLUUID& dest) { // TODO: // Check user balance for entire cost @@ -688,7 +702,7 @@ const void upload_bulk(const std::vector& filenames, LLFilePicker:: LLSD args; args["COST"] = expected_upload_cost; args["COUNT"] = expected_upload_count; - LLNotificationsUtil::add("BulkUploadCostConfirmation", args, LLSD(), boost::bind(do_bulk_upload, filtered_filenames, _1, _2)); + LLNotificationsUtil::add("BulkUploadCostConfirmation", args, LLSD(), boost::bind(do_bulk_upload, filtered_filenames, _1, _2, dest)); if (filtered_filenames.size() > expected_upload_count) { @@ -721,7 +735,7 @@ class LLFileUploadImage : public view_listener_t { gAgentCamera.changeCameraToDefault(); } - LLFilePickerReplyThread::startPicker(boost::bind(&upload_single_file, _1, _2), LLFilePicker::FFLOAD_IMAGE, false); + LLFilePickerReplyThread::startPicker(boost::bind(&upload_single_file, _1, _2, LLUUID::null), LLFilePicker::FFLOAD_IMAGE, false); return true; } }; @@ -752,7 +766,7 @@ class LLFileUploadSound : public view_listener_t { gAgentCamera.changeCameraToDefault(); } - LLFilePickerReplyThread::startPicker(boost::bind(&upload_single_file, _1, _2), LLFilePicker::FFLOAD_WAV, false); + LLFilePickerReplyThread::startPicker(boost::bind(&upload_single_file, _1, _2, LLUUID::null), LLFilePicker::FFLOAD_WAV, false); return true; } }; @@ -765,7 +779,7 @@ class LLFileUploadAnim : public view_listener_t { gAgentCamera.changeCameraToDefault(); } - LLFilePickerReplyThread::startPicker(boost::bind(&upload_single_file, _1, _2), LLFilePicker::FFLOAD_ANIM, false); + LLFilePickerReplyThread::startPicker(boost::bind(&upload_single_file, _1, _2, LLUUID::null), LLFilePicker::FFLOAD_ANIM, false); return true; } }; @@ -778,7 +792,7 @@ class LLFileUploadBulk : public view_listener_t { gAgentCamera.changeCameraToDefault(); } - LLFilePickerReplyThread::startPicker(boost::bind(&upload_bulk, _1, _2), LLFilePicker::FFLOAD_ALL, true); + LLFilePickerReplyThread::startPicker(boost::bind(&upload_bulk, _1, _2, LLUUID::null), LLFilePicker::FFLOAD_ALL, true); return true; } }; @@ -1066,7 +1080,7 @@ LLUUID upload_new_resource( name, desc, compression_info, destination_folder_type, inv_type, next_owner_perms, group_perms, everyone_perms, - expected_upload_cost, show_inventory)); + expected_upload_cost, LLUUID::null, show_inventory)); upload_new_resource(uploadInfo, callback, userdata); return LLUUID::null; diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 1acb701d50..f58b7b42c1 100644 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -72,6 +72,16 @@ void assign_defaults_and_show_upload_message( const std::string& display_name, std::string& description); +void upload_single_file( + const std::vector& filenames, + LLFilePicker::ELoadFilter type, + const LLUUID& dest); + +void upload_bulk( + const std::vector& filenames, + LLFilePicker::ELoadFilter type, + const LLUUID& dest); + //consider moving all file pickers below to more suitable place class LLFilePickerThread : public LLThread { //multi-threaded file picker (runs system specific file picker in background and calls "notify" from main thread) diff --git a/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml b/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml index c11f1c88cb..ef9e26d8be 100644 --- a/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml +++ b/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml @@ -486,6 +486,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + parameter="def_texture" /> - + - + - + - +