diff options
author | Dave Parks <davep@lindenlab.com> | 2024-06-07 09:51:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-07 09:51:32 -0500 |
commit | 33ddedd6b557ed9130dd8cd3b8327a697614a3ac (patch) | |
tree | 6c4ad8ce0e9bbaa1b7f5838470cd15a415210e87 /indra/newview | |
parent | 40197e89491af5a34c5ba11cdeeeacbee9fccf4f (diff) |
#1638 Add permissions checks to GLTF Save As and Upload buttons (#1653)
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/gltf/asset.h | 4 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 30 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_viewer.xml | 4 |
3 files changed, 36 insertions, 2 deletions
diff --git a/indra/newview/gltf/asset.h b/indra/newview/gltf/asset.h index 022fc484c2..fd7ea17f05 100644 --- a/indra/newview/gltf/asset.h +++ b/indra/newview/gltf/asset.h @@ -368,6 +368,10 @@ namespace LL // remove the bufferview at the given index // updates all bufferview indices in this Asset as needed void eraseBufferView(S32 bufferView); + + // return true if this Asset has been loaded as a local preview + // Local previews may be uploaded or exported to disk + bool isLocalPreview() { return !mFilename.empty(); } }; Material::AlphaMode gltf_alpha_mode_to_enum(const std::string& alpha_mode); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 6a61c8bac8..7e58a604f6 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -143,6 +143,7 @@ #include "llcleanup.h" #include "llviewershadermgr.h" #include "gltfscenemanager.h" +#include "gltf/asset.h" using namespace LLAvatarAppearanceDefines; @@ -3325,6 +3326,33 @@ bool enable_gltf() return enablegltf; } +bool enable_gltf_save_as() +{ + if (enable_gltf()) + { + LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(); + if (obj) + { + if (obj->mGLTFAsset && obj->mGLTFAsset->isLocalPreview()) + { + return true; + } + + LLPermissions* permissions = LLSelectMgr::getInstance()->findObjectPermissions(obj); + if (permissions) + { + return permissions->allowExportBy(gAgent.getID()); + } + } + } + return false; +} + +bool enable_gltf_upload() +{ + return enable_gltf_save_as(); +} + class LLSelfRemoveAllAttachments : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -10091,6 +10119,8 @@ void initialize_menus() enable.add("EnableSelectInPathfindingCharacters", boost::bind(&enable_object_select_in_pathfinding_characters)); enable.add("Advanced.EnableErrorOSException", boost::bind(&enable_os_exception)); enable.add("EnableGLTF", boost::bind(&enable_gltf)); + enable.add("EnableGLTFSaveAs", boost::bind(&enable_gltf_save_as)); + enable.add("EnableGLTFUpload", boost::bind(&enable_gltf_upload)); view_listener_t::addMenu(new LLFloaterVisible(), "FloaterVisible"); view_listener_t::addMenu(new LLShowSidetrayPanel(), "ShowSidetrayPanel"); diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index daf8dd4208..0e7c522f74 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -2875,7 +2875,7 @@ function="World.EnvPreset" label="Save As..." name="Save As..."> <menu_item_call.on_enable - function="EnableGLTF"/> + function="EnableGLTFSaveAs"/> <menu_item_call.on_click function="Advanced.ClickGLTFSaveAs" /> </menu_item_call> @@ -2883,7 +2883,7 @@ function="World.EnvPreset" label="Upload..." name="Upload..."> <menu_item_call.on_enable - function="EnableGLTF"/> + function="EnableGLTFUpload"/> <menu_item_call.on_click function="Advanced.ClickGLTFUpload" /> </menu_item_call> |