diff options
author | Dave Parks <davep@lindenlab.com> | 2022-09-29 19:01:41 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2022-09-29 19:01:41 -0500 |
commit | 6f2acc8e60da1699265c38acc5bd0d2871d0c9f7 (patch) | |
tree | fc4d8fbabc1ef3d39fa8b46f7cc3026e7e7339ff /indra/newview/llmaterialeditor.cpp | |
parent | 10b2d1be01978261ee0c452fdfabe2ec68ad1642 (diff) | |
parent | f2867c71dba95b21771dc1f6edacaed6755ab6da (diff) |
Merge branch 'DRTVWR-559' of ssh://bitbucket.org/lindenlab/viewer into DRTVWR-559
Diffstat (limited to 'indra/newview/llmaterialeditor.cpp')
-rw-r--r-- | indra/newview/llmaterialeditor.cpp | 85 |
1 files changed, 40 insertions, 45 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 27694e9ce4..a72d38223f 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -1152,38 +1152,6 @@ void LLMaterialEditor::onCancelMsgCallback(const LLSD& notification, const LLSD& } } -class LLMaterialFilePicker : public LLFilePickerThread -{ -public: - LLMaterialFilePicker(); - virtual void notify(const std::vector<std::string>& filenames); - static void textureLoadedCallback(BOOL success, LLViewerFetchedTexture* src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata); - -}; - -LLMaterialFilePicker::LLMaterialFilePicker() - : LLFilePickerThread(LLFilePicker::FFLOAD_MATERIAL) -{ -} - -void LLMaterialFilePicker::notify(const std::vector<std::string>& filenames) -{ - if (LLAppViewer::instance()->quitRequested()) - { - return; - } - - - if (filenames.size() > 0) - { - LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor"); - if (me) - { - me->loadMaterialFromFile(filenames[0]); - } - } -} - static void pack_textures( LLPointer<LLImageRaw>& base_color_img, LLPointer<LLImageRaw>& normal_img, @@ -1231,11 +1199,7 @@ static void pack_textures( } } -void LLMaterialFilePicker::textureLoadedCallback(BOOL success, LLViewerFetchedTexture* src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata) -{ -} - -void LLMaterialEditor::loadMaterialFromFile(const std::string& filename) +void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 index) { tinygltf::TinyGLTF loader; std::string error_msg; @@ -1271,12 +1235,28 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename) return; } - if (model_in.materials.size() == 1) + if (index >= 0 && model_in.materials.size() <= index) { - loadMaterial(model_in, filename_lc, 0); + // material is missing + LLNotificationsUtil::add("CannotUploadMaterial"); + return; + } + + LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor"); + + if (index >= 0) + { + // Prespecified material + me->loadMaterial(model_in, filename_lc, index); + } + else if (model_in.materials.size() == 1) + { + // Only one, just load it + me->loadMaterial(model_in, filename_lc, 0); } else { + // Promt user to select material std::list<std::string> material_list; std::vector<tinygltf::Material>::const_iterator mat_iter = model_in.materials.begin(); std::vector<tinygltf::Material>::const_iterator mat_end = model_in.materials.end(); @@ -1293,12 +1273,12 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename) } } LLFloaterComboOptions::showUI( - [this, model_in, filename_lc](const std::string& option, S32 index) + [me, model_in, filename_lc](const std::string& option, S32 index) { - loadMaterial(model_in, filename_lc, index); + me->loadMaterial(model_in, filename_lc, index); }, - getString("material_selection_title"), - getString("material_selection_text"), + me->getString("material_selection_title"), + me->getString("material_selection_text"), material_list ); } @@ -1306,7 +1286,7 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename) void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std::string &filename_lc, S32 index) { - if (model_in.materials.size() < index) + if (model_in.materials.size() <= index) { return; } @@ -1401,7 +1381,9 @@ void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std:: setFromGltfMetaData(filename_lc, model_in, index); setHasUnsavedChanges(true); + openFloater(); + setFocus(TRUE); applyToSelection(); } @@ -1695,7 +1677,20 @@ void LLMaterialEditor::setFromGltfMetaData(const std::string& filename, const ti void LLMaterialEditor::importMaterial() { - (new LLMaterialFilePicker())->getFile(); + LLFilePickerReplyThread::startPicker( + [](const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter load_filter, LLFilePicker::ESaveFilter save_filter) + { + if (LLAppViewer::instance()->quitRequested()) + { + return; + } + if (filenames.size() > 0) + { + LLMaterialEditor::loadMaterialFromFile(filenames[0], -1); + } + }, + LLFilePicker::FFLOAD_MATERIAL, + true); } class LLRemderMaterialFunctor : public LLSelectedTEFunctor |