From 231c618a844cee26a3779b703c88d8807df872e6 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 27 Jun 2022 09:59:11 -0500 Subject: SL-17653 Make changes in material editor apply to selection immediately and enable "apply now" checkbox in color swatches. --- indra/newview/llmaterialeditor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llmaterialeditor.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index e3206947d5..7335669f09 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -37,6 +37,7 @@ #include "llviewertexture.h" #include "llselectmgr.h" #include "llvovolume.h" +#include "llcolorswatch.h" #include "tinygltf/tiny_gltf.h" @@ -73,6 +74,7 @@ BOOL LLMaterialEditor::postBuild() // Albedo childSetCommitCallback("albedo color", changes_callback, NULL); + getChild("albedo color")->setCanApplyImmediately(TRUE); childSetCommitCallback("transparency", changes_callback, NULL); childSetCommitCallback("alpha mode", changes_callback, NULL); childSetCommitCallback("alpha cutoff", changes_callback, NULL); @@ -87,6 +89,7 @@ BOOL LLMaterialEditor::postBuild() // Emissive childSetCommitCallback("emissive color", changes_callback, NULL); + getChild("emissive color")->setCanApplyImmediately(TRUE); childSetVisible("unsaved_changes", mHasUnsavedChanges); @@ -273,6 +276,9 @@ void LLMaterialEditor::setHasUnsavedChanges(bool value) mHasUnsavedChanges = value; childSetVisible("unsaved_changes", value); } + + // HACK -- apply any changes to selection immediately + applyToSelection(); } void LLMaterialEditor::onCommitAlbedoTexture(LLUICtrl * ctrl, const LLSD & data) -- cgit v1.2.3 From fbb6eb216f5dc06ff5c7c1cabc6ab46a94918e1b Mon Sep 17 00:00:00 2001 From: Brad Kittenbrink Date: Mon, 27 Jun 2022 10:10:00 -0700 Subject: Initial pass at SL-17602 saving material to inventory from material editor floater. --- indra/newview/llmaterialeditor.cpp | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'indra/newview/llmaterialeditor.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 8b4d3b832b..828b368063 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -27,11 +27,18 @@ #include "llviewerprecompiledheaders.h" #include "llmaterialeditor.h" + +#include "llagent.h" #include "llcombobox.h" +#include "llinventorymodel.h" #include "llviewermenufile.h" #include "llappviewer.h" #include "llviewertexture.h" +#include "llnotificationsutil.h" +#include "llsdutil.h" #include "llselectmgr.h" +#include "llviewerinventory.h" +#include "llviewerregion.h" #include "llvovolume.h" #include "tinygltf/tiny_gltf.h" @@ -266,6 +273,44 @@ void LLMaterialEditor::onClickSave() std::string dump = str.str(); LL_INFOS() << dump << LL_ENDL; + + // gen a new uuid for this asset + LLTransactionID tid; + tid.generate(); // timestamp-based randomization + uniquification + LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); + std::string res_name = "New Material"; + std::string res_desc = "Saved Material"; + U32 next_owner_perm = LLPermissions::DEFAULT.getMaskNextOwner(); + LLUUID parent = gInventory.findCategoryUUIDForType(LLFolderType::FT_MATERIAL); + const U8 subtype = NO_INV_SUBTYPE; // TODO maybe use AT_SETTINGS and LLSettingsType::ST_MATERIAL ? + + create_inventory_item(gAgent.getID(), gAgent.getSessionID(), parent, tid, res_name, res_desc, + LLAssetType::AT_MATERIAL, LLInventoryType::IT_MATERIAL, subtype, next_owner_perm, + new LLBoostFuncInventoryCallback([output=dump](LLUUID const & inv_item_id){ + // from reference in LLSettingsVOBase::createInventoryItem()/updateInventoryItem() + LLResourceUploadInfo::ptr_t uploadInfo = + std::make_shared( + inv_item_id, + LLAssetType::AT_SETTINGS, // TODO switch to AT_MATERIAL + output, + [](LLUUID item_id, LLUUID new_asset_id, LLUUID new_item_id, LLSD response) { + LL_INFOS("Material") << "inventory item uploaded. item: " << item_id << " asset: " << new_asset_id << " new_item_id: " << new_item_id << " response: " << response << LL_ENDL; + LLSD params = llsd::map("ASSET_ID", new_asset_id); + LLNotificationsUtil::add("MaterialCreated", params); + }); + + const LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); + if (agent_url.empty()) + { + LL_ERRS() << "missing required agent inventory cap url" << LL_ENDL; + } + LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); + } + }) + ); } class LLMaterialFilePicker : public LLFilePickerThread -- cgit v1.2.3 From 00a04b87a9fae83fd42419a5b3ace632095405ef Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 27 Jun 2022 22:30:14 +0300 Subject: SL-17640 Fix name usage, fix "apply now" This reverts commit 231c618a844cee26a3779b703c88d8807df872e6, instead color swatched get enabled 'apply now' in xml. --- indra/newview/llmaterialeditor.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'indra/newview/llmaterialeditor.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 1744bf9033..f1166fbc0d 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -42,7 +42,6 @@ #include "llviewerinventory.h" #include "llviewerregion.h" #include "llvovolume.h" -#include "llcolorswatch.h" #include "tinygltf/tiny_gltf.h" @@ -73,13 +72,17 @@ BOOL LLMaterialEditor::postBuild() childSetAction("save_as", boost::bind(&LLMaterialEditor::onClickSaveAs, this)); childSetAction("cancel", boost::bind(&LLMaterialEditor::onClickCancel, this)); - boost::function changes_callback = [this](LLUICtrl * ctrl, void*) { setHasUnsavedChanges(true); }; + boost::function changes_callback = [this](LLUICtrl * ctrl, void*) + { + setHasUnsavedChanges(true); + // Apply changes to object live + applyToSelection(); + }; childSetCommitCallback("double sided", changes_callback, NULL); // Albedo childSetCommitCallback("albedo color", changes_callback, NULL); - getChild("albedo color")->setCanApplyImmediately(TRUE); childSetCommitCallback("transparency", changes_callback, NULL); childSetCommitCallback("alpha mode", changes_callback, NULL); childSetCommitCallback("alpha cutoff", changes_callback, NULL); @@ -94,10 +97,13 @@ BOOL LLMaterialEditor::postBuild() // Emissive childSetCommitCallback("emissive color", changes_callback, NULL); - getChild("emissive color")->setCanApplyImmediately(TRUE); childSetVisible("unsaved_changes", mHasUnsavedChanges); + // Todo: + // Disable/enable setCanApplyImmediately() based on + // working from inventory, upload or editing inworld + return LLFloater::postBuild(); } @@ -281,9 +287,6 @@ void LLMaterialEditor::setHasUnsavedChanges(bool value) mHasUnsavedChanges = value; childSetVisible("unsaved_changes", value); } - - // HACK -- apply any changes to selection immediately - applyToSelection(); } void LLMaterialEditor::onCommitAlbedoTexture(LLUICtrl * ctrl, const LLSD & data) @@ -300,6 +303,7 @@ void LLMaterialEditor::onCommitAlbedoTexture(LLUICtrl * ctrl, const LLSD & data) childSetValue("albedo_upload_fee", getString("no_upload_fee_string")); } setHasUnsavedChanges(true); + applyToSelection(); } void LLMaterialEditor::onCommitMetallicTexture(LLUICtrl * ctrl, const LLSD & data) @@ -314,6 +318,7 @@ void LLMaterialEditor::onCommitMetallicTexture(LLUICtrl * ctrl, const LLSD & dat childSetValue("metallic_upload_fee", getString("no_upload_fee_string")); } setHasUnsavedChanges(true); + applyToSelection(); } void LLMaterialEditor::onCommitEmissiveTexture(LLUICtrl * ctrl, const LLSD & data) @@ -328,6 +333,7 @@ void LLMaterialEditor::onCommitEmissiveTexture(LLUICtrl * ctrl, const LLSD & dat childSetValue("emissive_upload_fee", getString("no_upload_fee_string")); } setHasUnsavedChanges(true); + applyToSelection(); } void LLMaterialEditor::onCommitNormalTexture(LLUICtrl * ctrl, const LLSD & data) @@ -342,6 +348,7 @@ void LLMaterialEditor::onCommitNormalTexture(LLUICtrl * ctrl, const LLSD & data) childSetValue("normal_upload_fee", getString("no_upload_fee_string")); } setHasUnsavedChanges(true); + applyToSelection(); } @@ -444,13 +451,12 @@ void LLMaterialEditor::onClickSave() LLTransactionID tid; tid.generate(); // timestamp-based randomization + uniquification LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); - std::string res_name = "New Material"; std::string res_desc = "Saved Material"; U32 next_owner_perm = LLPermissions::DEFAULT.getMaskNextOwner(); LLUUID parent = gInventory.findCategoryUUIDForType(LLFolderType::FT_MATERIAL); const U8 subtype = NO_INV_SUBTYPE; // TODO maybe use AT_SETTINGS and LLSettingsType::ST_MATERIAL ? - create_inventory_item(gAgent.getID(), gAgent.getSessionID(), parent, tid, res_name, res_desc, + create_inventory_item(gAgent.getID(), gAgent.getSessionID(), parent, tid, mMaterialName, res_desc, LLAssetType::AT_MATERIAL, LLInventoryType::IT_MATERIAL, subtype, next_owner_perm, new LLBoostFuncInventoryCallback([output=dump](LLUUID const & inv_item_id){ // from reference in LLSettingsVOBase::createInventoryItem()/updateInventoryItem() @@ -827,6 +833,10 @@ void LLMaterialEditor::importMaterial() void LLMaterialEditor::applyToSelection() { + // Todo: associate with a specific 'selection' instead + // of modifying something that is selected + // This should be disabled when working from agent's + // inventory and for initial upload LLViewerObject* objectp = LLSelectMgr::instance().getSelection()->getFirstObject(); if (objectp && objectp->getVolume()) { -- cgit v1.2.3