summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpanelface.cpp')
-rw-r--r--indra/newview/llpanelface.cpp78
1 files changed, 76 insertions, 2 deletions
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 71657239a6..6b3ca43402 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -123,6 +123,7 @@ F32 LLPanelFace::getCurrentShinyScaleU() { return getChild<LLUICtrl>("shinySca
F32 LLPanelFace::getCurrentShinyScaleV() { return getChild<LLUICtrl>("shinyScaleV")->getValue().asReal(); }
F32 LLPanelFace::getCurrentShinyOffsetU() { return getChild<LLUICtrl>("shinyOffsetU")->getValue().asReal(); }
F32 LLPanelFace::getCurrentShinyOffsetV() { return getChild<LLUICtrl>("shinyOffsetV")->getValue().asReal(); }
+LLUUID LLPanelFace::getCurrentMaterialID() { return getChild<LLUICtrl>("materialID")->getValue().asUUID(); }
//
// Methods
@@ -154,9 +155,11 @@ BOOL LLPanelFace::postBuild()
childSetCommitCallback("glossiness",&LLPanelFace::onCommitMaterialGloss, this);
childSetCommitCallback("environment",&LLPanelFace::onCommitMaterialEnv, this);
childSetCommitCallback("maskcutoff",&LLPanelFace::onCommitMaterialMaskCutoff, this);
+ childSetCommitCallback("materialID", &LLPanelFace::onCommitMaterialID, this);
childSetAction("button align",&LLPanelFace::onClickAutoFix,this);
childSetAction("button align textures", &LLPanelFace::onAlignTexture, this);
+ childSetAction("button save material", &LLPanelFace::onSaveMaterial, this);
LLTextureCtrl* mTextureCtrl;
LLTextureCtrl* mShinyTextureCtrl;
@@ -298,7 +301,7 @@ BOOL LLPanelFace::postBuild()
{
mCtrlGlow->setCommitCallback(LLPanelFace::onCommitGlow, this);
}
-
+
clearCtrls();
@@ -1409,7 +1412,15 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
LLMaterialPtr material;
LLSelectedTEMaterial::getCurrent(material, identical);
- if (material && editable)
+ // enable this UI box if a single face is selected.
+ BOOL is_single_face = !LLSelectMgr::getInstance()->getSelection()->isMultipleTESelected();
+ childSetEnabled("button save material", static_cast<bool>(is_single_face));
+ childSetEnabled("materialID", static_cast<bool>(is_single_face)); // doesn't work - why?
+
+ // TODO: 2022-04 conflicts with media button placement. hide the button if applying media
+ // i.e. childSetVisible("button save material", !applying_media);
+
+ if (material && editable)
{
LL_DEBUGS("Materials") << material->asLLSD() << LL_ENDL;
@@ -1518,6 +1529,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
calcp->setVar(LLCalc::TEX_ROTATION, childGetValue("TexRot").asReal());
calcp->setVar(LLCalc::TEX_TRANSPARENCY, childGetValue("ColorTrans").asReal());
calcp->setVar(LLCalc::TEX_GLOW, childGetValue("glow").asReal());
+
+ getChildView("materialID")->setEnabled(editable);
}
else
{
@@ -2302,6 +2315,13 @@ void LLPanelFace::onCommitMaterialMaskCutoff(LLUICtrl* ctrl, void* userdata)
LLSelectedTEMaterial::setAlphaMaskCutoff(self,self->getCurrentAlphaMaskCutoff());
}
+//static
+void LLPanelFace::onCommitMaterialID(LLUICtrl* ctrl, void* userdata)
+{
+ LLPanelFace* self = static_cast<LLPanelFace*>(userdata);
+ LLSelectedTEMaterial::setMaterialID(self, self->getCurrentMaterialID());
+}
+
// static
void LLPanelFace::onCommitTextureInfo( LLUICtrl* ctrl, void* userdata )
{
@@ -2538,6 +2558,60 @@ void LLPanelFace::onAlignTexture(void* userdata)
self->alignTestureLayer();
}
+#include "llagent.h"
+#include "llfilesystem.h"
+#include "llfloaterperms.h"
+#include "llviewerassetupload.h"
+#include "llviewermenufile.h"
+#include "llsd.h"
+#pragma warning (disable: 4189)
+void LLPanelFace::onSaveMaterial(void* userdata)
+{
+ // DRTVWR-559, Q&D material picker - save to inventory goes here
+ LL_DEBUGS("Material") << "saving material to inventory" << LL_ENDL;
+
+ LLPanelFace* self = (LLPanelFace*)userdata;
+
+ std::string name = "New Material";
+
+ LLSD* mat_llsd = new LLSD("Surely you jest...");
+ // TBD populate mat_llsd with material data
+ self->onCloseTexturePicker(*mat_llsd); // certainly wrong, but something like this?
+
+ // gen a new uuid for this asset
+ LLTransactionID tid;
+ tid.generate();
+ LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
+
+ LLFileSystem fmt_file(new_asset_id, LLAssetType::AT_MATERIAL, LLFileSystem::WRITE);
+ fmt_file.write(mat_llsd->asBinary().data(), mat_llsd->size());
+
+ S32 expected_upload_cost = 0;// LLAgentBenefitsMgr::current().getTextureUploadCost();
+
+ std::string res_name = name;
+ std::string res_desc = "Saved Material";
+ LLFolderType::EType folder_type = LLFolderType::FT_MATERIAL;
+ LLInventoryType::EType inv_type = LLInventoryType::IT_MATERIAL;
+
+ auto upload_info = new LLResourceUploadInfo(
+ tid,
+ LLAssetType::AT_MATERIAL,
+ res_name,
+ res_desc,
+ 0,
+ folder_type,
+ inv_type,
+ PERM_ALL,
+ LLFloaterPerms::getGroupPerms("Uploads"),
+ LLFloaterPerms::getEveryonePerms("Uploads"),
+ expected_upload_cost,
+ false);
+
+ LLResourceUploadInfo::ptr_t p_upload_info(upload_info);
+
+ upload_new_resource(p_upload_info);
+}
+
// TODO: I don't know who put these in or what these are for???
void LLPanelFace::setMediaURL(const std::string& url)