summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llpublishedobjectmgr.cpp1
-rw-r--r--indra/newview/llpublishedobjectmgr.h2
-rw-r--r--indra/newview/llscripteditorws.cpp80
-rw-r--r--indra/newview/llscripteditorws.h1
-rw-r--r--indra/newview/llviewermenu.cpp34
-rw-r--r--indra/newview/llviewermenu.h2
6 files changed, 117 insertions, 3 deletions
diff --git a/indra/newview/llpublishedobjectmgr.cpp b/indra/newview/llpublishedobjectmgr.cpp
index 6f78ba82d9..e9d13c1213 100644
--- a/indra/newview/llpublishedobjectmgr.cpp
+++ b/indra/newview/llpublishedobjectmgr.cpp
@@ -404,6 +404,7 @@ LLSD LLPublishedObjectMgr::buildObjectListLLSD() const
{
pub["region"] = info.mRegionName;
}
+ pub["can_save_back"] = info.mCanSaveBackToContents;
pub["inventory"] = buildPrimInventoryLLSD(root);
LLSD linked_objects = LLSD::emptyArray();
diff --git a/indra/newview/llpublishedobjectmgr.h b/indra/newview/llpublishedobjectmgr.h
index d7eca09d80..99ffa34b39 100644
--- a/indra/newview/llpublishedobjectmgr.h
+++ b/indra/newview/llpublishedobjectmgr.h
@@ -67,6 +67,8 @@ public:
std::string mObjectName;
std::string mObjectDescription;
std::string mRegionName;
+ bool mCanSaveBackToContents{ false };
+ LLUUID mSourceTaskID;
std::vector<PublishedPrimInfo> mPrims;
std::vector<std::unique_ptr<LLPublishedPrimListener>> mListeners;
};
diff --git a/indra/newview/llscripteditorws.cpp b/indra/newview/llscripteditorws.cpp
index d9a4e4b064..2b77ff1481 100644
--- a/indra/newview/llscripteditorws.cpp
+++ b/indra/newview/llscripteditorws.cpp
@@ -208,6 +208,12 @@ LLScriptEditorWSServer::LLScriptEditorWSServer(const std::string& name, U16 port
response["success"] = true;
return response;
});
+
+ registerCommand({ "viewer.object.save_back_to_contents", "Save an in-world object back to source object contents" },
+ [this](U32 connection_id, const LLSD& p) -> LLSD
+ {
+ return this->handleSaveBackToObjectContents(connection_id, p);
+ });
}
LLScriptEditorWSServer::ptr_t LLScriptEditorWSServer::getServer()
@@ -918,6 +924,65 @@ bool LLScriptEditorWSConnection::hasFeature(const std::string& feature) const
return mFeatures.count(feature) > 0;
}
+LLSD LLScriptEditorWSServer::handleSaveBackToObjectContents(U32 connection_id, const LLSD& params)
+{
+ LLUUID object_id = params["object_id"].asUUID();
+ if (object_id.isNull())
+ {
+ throw LLJSONRPCConnection::InvalidParams("object_id is required");
+ }
+
+ const LLPublishedObjectMgr::PublishedObjectInfo* published_info =
+ mPublishedObjectManager.getPublished(object_id);
+ if (!published_info)
+ {
+ LLSD response;
+ response["success"] = false;
+ response["error_code"] = WSCommandError::InvalidParams;
+ response["message"] = "Object is not published";
+ return response;
+ }
+
+ if (!published_info->mCanSaveBackToContents || published_info->mSourceTaskID.isNull())
+ {
+ LLSD response;
+ response["success"] = false;
+ response["error_code"] = WSCommandError::NotPermitted;
+ response["message"] = "Save back is not available for this object";
+ return response;
+ }
+
+ LLViewerObject* root = gObjectList.findObject(object_id);
+ if (!root)
+ {
+ LLSD response;
+ response["success"] = false;
+ response["error_code"] = WSCommandError::InvalidParams;
+ response["message"] = "object_id not found";
+ return response;
+ }
+
+ if (!save_object_back_to_contents(root, published_info->mSourceTaskID))
+ {
+ LLSD response;
+ response["success"] = false;
+ response["error_code"] = WSCommandError::ExecutionError;
+ response["message"] = "Failed to save object back to contents";
+ return response;
+ }
+
+ LL_DEBUGS("ScriptEditorWS") << "Save-back requested via command for object "
+ << object_id << " on connection " << connection_id << LL_ENDL;
+
+ LLSD response;
+ response["success"] = true;
+
+ LLSD result;
+ result["object_id"] = object_id;
+ response["result"] = result;
+ return response;
+}
+
LLSD LLScriptEditorWSServer::handleCommandExecute(U32 connection_id, const LLSD& params)
{
const std::string command = params["command"].asString();
@@ -2228,6 +2293,20 @@ void LLScriptEditorWSServer::buildAndSendPublish(const LLUUID& object_id)
{
info.mRegionName = root->getRegion()->getName();
}
+ LLSelectNode* root_select_node = LLSelectMgr::instance().getSelection()->findNode(root);
+ if (root_select_node
+ && root_select_node->mValid
+ && !root_select_node->mFromTaskID.isNull()
+ && !root->isAttachment())
+ {
+ info.mCanSaveBackToContents = true;
+ info.mSourceTaskID = root_select_node->mFromTaskID;
+ }
+ else
+ {
+ info.mCanSaveBackToContents = false;
+ info.mSourceTaskID.setNull();
+ }
S32 link_num = 1;
std::vector<LLViewerObject*> prims = collect_linkset(root);
@@ -2246,6 +2325,7 @@ void LLScriptEditorWSServer::buildAndSendPublish(const LLUUID& object_id)
// Align outgoing publish payload with any property responses that arrived
// while inventory-gated publish was still pending.
pub["object_name"] = published_info.mObjectName;
+ pub["can_save_back"] = published_info.mCanSaveBackToContents;
pub["object_description"] = published_info.mObjectDescription;
if (pub.has("linked_objects"))
{
diff --git a/indra/newview/llscripteditorws.h b/indra/newview/llscripteditorws.h
index 63b60335ff..ded83e6369 100644
--- a/indra/newview/llscripteditorws.h
+++ b/indra/newview/llscripteditorws.h
@@ -247,6 +247,7 @@ protected:
LLSD handleObjectModify(U32 connection_id, const LLSD& params);
LLSD handleObjectItemModify(U32 connection_id, const LLSD& params);
LLSD handleCommandExecute(U32 connection_id, const LLSD& params);
+ LLSD handleSaveBackToObjectContents(U32 connection_id, const LLSD& params);
LLSD handleCommandList();
void sendCommandExecute(U32 connection_id, const std::string& command, const LLSD& params);
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index dc509479c4..eaaa923b59 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -5136,6 +5136,31 @@ static void derez_objects(EDeRezDestination dest, const LLUUID& dest_id)
derez_objects(dest, dest_id, first_region, error, NULL);
}
+bool save_object_back_to_contents(LLViewerObject* object, const LLUUID& source_task_id)
+{
+ if (!object || source_task_id.isNull())
+ {
+ return false;
+ }
+
+ LLViewerRegion* first_region = object->getRegion();
+ if (!first_region)
+ {
+ return false;
+ }
+
+ std::vector<LLViewerObjectPtr> objects;
+ objects.push_back(object);
+
+ std::string error;
+ derez_objects(DRD_SAVE_INTO_TASK_INVENTORY, source_task_id, first_region, error, &objects);
+ if (!error.empty())
+ {
+ return false;
+ }
+ return true;
+}
+
static void derez_objects_separate(EDeRezDestination dest, const LLUUID &dest_id)
{
std::vector<LLViewerObjectPtr> derez_object_list;
@@ -5710,10 +5735,13 @@ class LLToolsSaveToObjectInventory : public view_listener_t
bool handleEvent(const LLSD& userdata)
{
LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
- if(node && (node->mValid) && (!node->mFromTaskID.isNull()))
+ if (node && node->mValid && !node->mFromTaskID.isNull())
{
- // *TODO: check to see if the fromtaskid object exists.
- derez_objects(DRD_SAVE_INTO_TASK_INVENTORY, node->mFromTaskID);
+ LLViewerObject* object = node->getObject();
+ if (object)
+ {
+ save_object_back_to_contents(object, node->mFromTaskID);
+ }
}
return true;
}
diff --git a/indra/newview/llviewermenu.h b/indra/newview/llviewermenu.h
index 522c7e8109..6699780a76 100644
--- a/indra/newview/llviewermenu.h
+++ b/indra/newview/llviewermenu.h
@@ -37,6 +37,7 @@ class LLView;
class LLParcelSelection;
class LLObjectSelection;
class LLSelectNode;
+class LLViewerObject;
void initialize_edit_menu();
void initialize_spellcheck_menu();
@@ -74,6 +75,7 @@ void handle_take(bool take_separate = false);
void handle_take_copy();
void handle_look_at_selection(const LLSD& param);
bool handle_zoom_to_object(const LLUUID& object_id);
+bool save_object_back_to_contents(LLViewerObject* object, const LLUUID& source_task_id);
void handle_object_return();
void handle_object_delete();
void handle_object_edit();