diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-06-24 01:02:01 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-06-24 08:36:50 +0300 |
commit | da1d9139b3412e391b5ed7c868d350760719ee9e (patch) | |
tree | 00aeca98043b71a50128b3c5b2936eded2a71603 | |
parent | 0bc7fee11fe43281d5d3c97e95249f9c26af0eb1 (diff) |
SL-17640 Materials Upload UI #2
New Fee fields
New Buttons
-rw-r--r-- | indra/newview/llmaterialeditor.cpp | 158 | ||||
-rw-r--r-- | indra/newview/llmaterialeditor.h | 24 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_material_editor.xml | 178 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 34 |
4 files changed, 353 insertions, 41 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index f4bf400844..86f629db95 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -31,6 +31,7 @@ #include "llappviewer.h" #include "llcombobox.h" #include "llnotificationsutil.h" +#include "lltexturectrl.h" #include "lltrans.h" #include "llviewermenufile.h" #include "llviewertexture.h" @@ -51,18 +52,41 @@ LLMaterialEditor::LLMaterialEditor(const LLSD& key) BOOL LLMaterialEditor::postBuild() { + mAlbedoTextureCtrl = getChild<LLTextureCtrl>("albedo_texture"); + mMetallicTextureCtrl = getChild<LLTextureCtrl>("metallic_roughness_texture"); + mEmissiveTextureCtrl = getChild<LLTextureCtrl>("emissive_texture"); + mNormalTextureCtrl = getChild<LLTextureCtrl>("normal_texture"); + + mAlbedoTextureCtrl->setCommitCallback(boost::bind(&LLMaterialEditor::onCommitAlbedoTexture, this, _1, _2)); + mMetallicTextureCtrl->setCommitCallback(boost::bind(&LLMaterialEditor::onCommitMetallicTexture, this, _1, _2)); + mEmissiveTextureCtrl->setCommitCallback(boost::bind(&LLMaterialEditor::onCommitEmissiveTexture, this, _1, _2)); + mNormalTextureCtrl->setCommitCallback(boost::bind(&LLMaterialEditor::onCommitNormalTexture, this, _1, _2)); + childSetAction("save", boost::bind(&LLMaterialEditor::onClickSave, this)); + childSetAction("save_as", boost::bind(&LLMaterialEditor::onClickSaveAs, this)); + childSetAction("cancel", boost::bind(&LLMaterialEditor::onClickCancel, this)); + return LLFloater::postBuild(); } LLUUID LLMaterialEditor::getAlbedoId() { - return childGetValue("albedo texture").asUUID(); + return mAlbedoTextureCtrl->getValue().asUUID(); } void LLMaterialEditor::setAlbedoId(const LLUUID& id) { - childSetValue("albedo texture", id); + mAlbedoTextureCtrl->setValue(id); + mAlbedoTextureCtrl->setDefaultImageAssetID(id); + + if (id.notNull()) + { + // todo: this does not account for posibility of texture + // being from inventory, need to check that + childSetValue("albedo_upload_fee", getString("upload_fee_string")); + // Only set if we will need to upload this texture + mAlbedoTextureUploadId = id; + } } LLColor4 LLMaterialEditor::getAlbedoColor() @@ -72,7 +96,6 @@ LLColor4 LLMaterialEditor::getAlbedoColor() return ret; } - void LLMaterialEditor::setAlbedoColor(const LLColor4& color) { childSetValue("albedo color", color.getValue()); @@ -107,16 +130,26 @@ void LLMaterialEditor::setAlphaCutoff(F32 alpha_cutoff) void LLMaterialEditor::setMaterialName(const std::string &name) { setTitle(name); + mMaterialName = name; } LLUUID LLMaterialEditor::getMetallicRoughnessId() { - return childGetValue("metallic-roughness texture").asUUID(); + return mMetallicTextureCtrl->getValue().asUUID(); } void LLMaterialEditor::setMetallicRoughnessId(const LLUUID& id) { - childSetValue("metallic-roughness texture", id); + mMetallicTextureCtrl->setValue(id); + mMetallicTextureCtrl->setDefaultImageAssetID(id); + + if (id.notNull()) + { + // todo: this does not account for posibility of texture + // being from inventory, need to check that + childSetValue("metallic_upload_fee", getString("upload_fee_string")); + mMetallicTextureUploadId = id; + } } F32 LLMaterialEditor::getMetalnessFactor() @@ -141,12 +174,21 @@ void LLMaterialEditor::setRoughnessFactor(F32 factor) LLUUID LLMaterialEditor::getEmissiveId() { - return childGetValue("emissive texture").asUUID(); + return mEmissiveTextureCtrl->getValue().asUUID(); } void LLMaterialEditor::setEmissiveId(const LLUUID& id) { - childSetValue("emissive texture", id); + mEmissiveTextureCtrl->setValue(id); + mEmissiveTextureCtrl->setDefaultImageAssetID(id); + + if (id.notNull()) + { + // todo: this does not account for posibility of texture + // being from inventory, need to check that + childSetValue("emissive_upload_fee", getString("upload_fee_string")); + mEmissiveTextureUploadId = id; + } } LLColor4 LLMaterialEditor::getEmissiveColor() @@ -161,12 +203,21 @@ void LLMaterialEditor::setEmissiveColor(const LLColor4& color) LLUUID LLMaterialEditor::getNormalId() { - return childGetValue("normal texture").asUUID(); + return mNormalTextureCtrl->getValue().asUUID(); } void LLMaterialEditor::setNormalId(const LLUUID& id) { - childSetValue("normal texture", id); + mNormalTextureCtrl->setValue(id); + mNormalTextureCtrl->setDefaultImageAssetID(id); + + if (id.notNull()) + { + // todo: this does not account for posibility of texture + // being from inventory, need to check that + childSetValue("normal_upload_fee", getString("upload_fee_string")); + mNormalTextureUploadId = id; + } } bool LLMaterialEditor::getDoubleSided() @@ -179,6 +230,60 @@ void LLMaterialEditor::setDoubleSided(bool double_sided) childSetValue("double sided", double_sided); } +void LLMaterialEditor::onCommitAlbedoTexture(LLUICtrl * ctrl, const LLSD & data) +{ + // might be better to use arrays, to have a single callback + // and not to repeat the same thing for each tecture controls + LLUUID new_val = mAlbedoTextureCtrl->getValue().asUUID(); + if (new_val == mAlbedoTextureUploadId && mAlbedoTextureUploadId.notNull()) + { + childSetValue("albedo_upload_fee", getString("upload_fee_string")); + } + else + { + childSetValue("albedo_upload_fee", getString("no_upload_fee_string")); + } +} + +void LLMaterialEditor::onCommitMetallicTexture(LLUICtrl * ctrl, const LLSD & data) +{ + LLUUID new_val = mMetallicTextureCtrl->getValue().asUUID(); + if (new_val == mMetallicTextureUploadId && mMetallicTextureUploadId.notNull()) + { + childSetValue("metallic_upload_fee", getString("upload_fee_string")); + } + else + { + childSetValue("metallic_upload_fee", getString("no_upload_fee_string")); + } +} + +void LLMaterialEditor::onCommitEmissiveTexture(LLUICtrl * ctrl, const LLSD & data) +{ + LLUUID new_val = mEmissiveTextureCtrl->getValue().asUUID(); + if (new_val == mEmissiveTextureUploadId && mEmissiveTextureUploadId.notNull()) + { + childSetValue("emissive_upload_fee", getString("upload_fee_string")); + } + else + { + childSetValue("emissive_upload_fee", getString("no_upload_fee_string")); + } +} + +void LLMaterialEditor::onCommitNormalTexture(LLUICtrl * ctrl, const LLSD & data) +{ + LLUUID new_val = mNormalTextureCtrl->getValue().asUUID(); + if (new_val == mNormalTextureUploadId && mNormalTextureUploadId.notNull()) + { + childSetValue("normal_upload_fee", getString("upload_fee_string")); + } + else + { + childSetValue("normal_upload_fee", getString("no_upload_fee_string")); + } +} + static void write_color(const LLColor4& color, std::vector<double>& c) { @@ -273,7 +378,40 @@ void LLMaterialEditor::onClickSave() std::string dump = str.str(); - LL_INFOS() << dump << LL_ENDL; + LL_INFOS() << mMaterialName << ": " << dump << LL_ENDL; +} + +void LLMaterialEditor::onClickSaveAs() +{ + LLSD args; + args["DESC"] = mMaterialName; + + LLNotificationsUtil::add("SaveMaterialAs", args, LLSD(), boost::bind(&LLMaterialEditor::onSaveAsCommitCallback, this, _1, _2)); +} + +void LLMaterialEditor::onSaveAsCommitCallback(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (0 == option) + { + std::string new_name = response["message"].asString(); + LLStringUtil::trim(new_name); + if (!new_name.empty()) + { + setMaterialName(new_name); + onClickSave(); + } + else + { + LLNotificationsUtil::add("InvalidMaterialName"); + } + } +} + +void LLMaterialEditor::onClickCancel() +{ + // Todo: confirm usaved changes + closeFloater(); } class LLMaterialFilePicker : public LLFilePickerThread diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index 2af4ccf885..1584f2c136 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -28,6 +28,8 @@ #include "llfloater.h" +class LLTextureCtrl; + class LLMaterialEditor : public LLFloater { public: @@ -40,6 +42,9 @@ public: void applyToSelection(); void onClickSave(); + void onClickSaveAs(); + void onSaveAsCommitCallback(const LLSD& notification, const LLSD& response); + void onClickCancel(); // llpanel BOOL postBuild() override; @@ -82,5 +87,24 @@ public: bool getDoubleSided(); void setDoubleSided(bool double_sided); + + void onCommitAlbedoTexture(LLUICtrl* ctrl, const LLSD& data); + void onCommitMetallicTexture(LLUICtrl* ctrl, const LLSD& data); + void onCommitEmissiveTexture(LLUICtrl* ctrl, const LLSD& data); + void onCommitNormalTexture(LLUICtrl* ctrl, const LLSD& data); + +private: + LLTextureCtrl* mAlbedoTextureCtrl; + LLTextureCtrl* mMetallicTextureCtrl; + LLTextureCtrl* mEmissiveTextureCtrl; + LLTextureCtrl* mNormalTextureCtrl; + + // 'Default' texture, unless it's null or from inventory is the one with the fee + LLUUID mAlbedoTextureUploadId; + LLUUID mMetallicTextureUploadId; + LLUUID mEmissiveTextureUploadId; + LLUUID mNormalTextureUploadId; + + std::string mMaterialName; }; diff --git a/indra/newview/skins/default/xui/en/floater_material_editor.xml b/indra/newview/skins/default/xui/en/floater_material_editor.xml index 8482795f6f..815a53a887 100644 --- a/indra/newview/skins/default/xui/en/floater_material_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_material_editor.xml @@ -3,12 +3,14 @@ legacy_header_height="18" can_resize="false" default_tab_group="1" - height="777" + height="887" layout="topleft" name="material editor" help_topic="material_editor" title="[MATERIAL_NAME]" width="256"> + <string name="no_upload_fee_string">no upload fee</string> + <string name="upload_fee_string">L$10 upload fee</string> <check_box follows="left|top" label="Double Sided" @@ -30,6 +32,7 @@ > <text type="string" + font.style="BOLD" length="1" follows="left|top" height="10" @@ -49,9 +52,23 @@ height="151" layout="topleft" left="10" - name="albedo texture" + name="albedo_texture" tool_tip="Albedo map. Alpha channel is optional and used for transparency." width="128" /> + <text + type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + width="128" + layout="topleft" + left="10" + top_pad="-17" + name="albedo_upload_fee" + > + No upload fee + </text> <text type="string" length="1" @@ -59,7 +76,7 @@ height="10" layout="topleft" left_pad="5" - top_delta="-15" + top="8" > Tint </text> @@ -161,7 +178,7 @@ border="true" follows="left|top" width="246" - height="160" + height="175" layout="topleft" left="5" mouse_opaque="false" @@ -170,12 +187,13 @@ > <text type="string" + font.style="BOLD" length="1" follows="left|top" height="10" layout="topleft" left="10" - top_pad="5" + top="5" > Metallic-Roughness: </text> @@ -189,18 +207,32 @@ height="151" layout="topleft" left="10" - name="metallic-roughness texture" + name="metallic_roughness_texture" tool_tip="GLTF metallic-roughness map with optional occlusion. Red channel is occlusion, green channel is roughness, blue channel is metalness." top_pad="8" /> <text type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + width="128" + layout="topleft" + left="10" + top_pad="-17" + name="metallic_upload_fee" + > + No upload fee + </text> + <text + type="string" length="1" follows="left|top" height="10" layout="topleft" left_pad="5" - top_delta="-15" + top="8" > Metallic Factor </text> @@ -247,7 +279,7 @@ border="true" follows="left|top" width="246" - height="160" + height="175" layout="topleft" left="5" mouse_opaque="false" @@ -256,6 +288,7 @@ > <text type="string" + font.style="BOLD" length="1" follows="left|top" height="10" @@ -275,16 +308,30 @@ height="151" layout="topleft" left="10" - name="emissive texture" + name="emissive_texture" width="128" /> <text type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + width="128" + layout="topleft" + left="10" + top_pad="-17" + name="emissive_upload_fee" + > + No upload fee + </text> + <text + type="string" length="1" follows="left|top" height="10" layout="topleft" left_pad="5" - top_delta="-15" + top="8" > Tint </text> @@ -327,7 +374,7 @@ border="true" follows="left|top" width="246" - height="160" + height="175" layout="topleft" left="5" mouse_opaque="false" @@ -335,6 +382,7 @@ > <text type="string" + font.style="BOLD" length="1" follows="left|top" height="10" @@ -354,25 +402,95 @@ height="151" layout="topleft" left="10" - name="normal texture" + name="normal_texture" width="128" /> - <!--<check_box - follows="left|top" - label="Mikkt Space" - left_pad="10" - top_delta="0" - height="25" - width="120" />--> + <text + type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + width="128" + layout="topleft" + left="10" + top_pad="-17" + name="normal_upload_fee" + > + No upload fee + </text> + </panel> + + <panel + follows="right|bottom" + width="246" + height="82" + layout="bottomright" + top_delta="-2" + left="0" + name="button_panel" + > + <text + type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + width="200" + layout="topleft" + left="10" + top="0" + > + Usaved changes + </text> + <button + follows="left|top" + height="25" + label="Save" + layout="topleft" + name="save" + top_pad="7" + left="5" + width="120" /> + <button + follows="left|top" + height="25" + label="Save As..." + layout="topleft" + name="save_as" + top_delta="0" + left_pad="6" + width="120" /> + <text + type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + width="240" + layout="topleft" + left="10" + top_pad="5" + > + Total upload fee: L$ [FEE] + </text> + + <view_border + bevel_style="none" + height="0" + layout="topleft" + left="5" + name="button_border" + top_pad="7" + width="246"/> + + <button + follows="left|top" + height="25" + label="Cancel" + layout="topleft" + name="cancel" + top_pad="7" + left="61" + width="121" /> </panel> - <button - follows="right|bottom" - height="25" - label="Save" - layout="bottomright" - name="save" - tool_tip="Browse for an editor (executable) to edit floater XML files" - top_delta="-2" - left="5" - width="246" /> - </floater> diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 8670aa92f4..23a9632ada 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -9033,7 +9033,39 @@ Unable to upload texture. There was a problem uploading the file <tag>fail</tag> </notification> - + + <notification + icon="alertmodal.tga" + label="Save Material" + name="SaveMaterialAs" + type="alertmodal"> + <unique/> + Name this material: + <tag>confirm</tag> + <form name="form"> + <input name="message" type="text"> + [DESC] + </input> + <button + default="true" + index="0" + name="OK" + text="OK"/> + <button + index="1" + name="Cancel" + text="Cancel"/> + </form> + </notification> + + <notification + icon="alertmodal.tga" + name="InvalidMaterialName" + type="alertmodal"> +Please enter a non-empty name + <tag>fail</tag> + </notification> + <notification icon="alertmodal.tga" name="LivePreviewUnavailable" |