From fa869f21ad7d332f17c33a2c0714efb60949e240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liru=20F=C3=A6rs?= Date: Sun, 3 Nov 2019 16:08:43 -0500 Subject: [PATCH] Script Debug should link to object, when possible --- indra/newview/llfloaterscriptdebug.cpp | 71 +++++++++++++++----------- indra/newview/llfloaterscriptdebug.h | 5 +- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/indra/newview/llfloaterscriptdebug.cpp b/indra/newview/llfloaterscriptdebug.cpp index ce70602a5..a9c74a067 100644 --- a/indra/newview/llfloaterscriptdebug.cpp +++ b/indra/newview/llfloaterscriptdebug.cpp @@ -32,21 +32,16 @@ #include "llviewerprecompiledheaders.h" -#include "lluictrlfactory.h" #include "llfloaterscriptdebug.h" -#include "llfontgl.h" -#include "llrect.h" -#include "llerror.h" -#include "llstring.h" -#include "llvoavatarself.h" -#include "message.h" +#include "lluictrlfactory.h" // project include -#include "llviewertexteditor.h" -#include "llviewercontrol.h" +#include "llslurl.h" #include "llviewerobjectlist.h" -#include "llviewertexturelist.h" +#include "llviewerregion.h" +#include "llviewertexteditor.h" +#include "llvoavatarself.h" // // Statics @@ -123,8 +118,12 @@ LLFloater* LLFloaterScriptDebug::addOutputWindow(const LLUUID &object_id) return floaterp; } -void LLFloaterScriptDebug::addScriptLine(const std::string &utf8mesg, const std::string &user_name, const LLColor4& color, const LLUUID& source_id) +void LLFloaterScriptDebug::addScriptLine(LLChat& chat, const LLColor4& color) { + const auto& utf8mesg = chat.mText; + const auto& user_name = chat.mFromName; + const auto& source_id = chat.mFromID; + LLViewerObject* objectp = gObjectList.findObject(source_id); std::string floater_label; @@ -132,6 +131,7 @@ void LLFloaterScriptDebug::addScriptLine(const std::string &utf8mesg, const std: std::string prefix = utf8mesg.substr(0, 4); std::string message = (prefix == "/me " || prefix == "/me'") ? user_name + utf8mesg.substr(3) : utf8mesg; + LLSD sdQuery = LLSD().with("name", user_name); if (objectp) { if(objectp->isHUDAttachment()) @@ -145,32 +145,39 @@ void LLFloaterScriptDebug::addScriptLine(const std::string &utf8mesg, const std: { objectp->setIcon(LLViewerTextureManager::getFetchedTextureFromFile("script_error.j2c", FTT_LOCAL_FILE, TRUE, LLGLTexture::BOOST_UI)); } + + const auto& pos = objectp->getPositionRegion(); + sdQuery.with("owner", objectp->mOwnerID) + .with("groupowned", objectp->flagObjectGroupOwned()) + .with("slurl", LLSLURL(objectp->getRegion()->getName(), pos).getLocationString()); + floater_label = llformat("%s(%.0f, %.0f, %.0f)", user_name.c_str(), - objectp->getPositionRegion().mV[VX], - objectp->getPositionRegion().mV[VY], - objectp->getPositionRegion().mV[VZ]); + pos.mV[VX], + pos.mV[VY], + pos.mV[VZ]); } else { floater_label = user_name; } + chat.mURL = LLSLURL("objectim", source_id, LLURI::mapToQueryString(sdQuery)).getLocationString(); + addOutputWindow(LLUUID::null); addOutputWindow(source_id); // add to "All" floater - LLFloaterScriptDebugOutput* floaterp = LLFloaterScriptDebugOutput::getFloaterByID(LLUUID::null); - if (floaterp) + if (auto floaterp = LLFloaterScriptDebugOutput::getFloaterByID(LLUUID::null)) { - floaterp->addLine(message, user_name, color); + floaterp->addLine(chat, message, color); } // add to specific script instance floater - floaterp = LLFloaterScriptDebugOutput::getFloaterByID(source_id); - if (floaterp) + if (auto floaterp = LLFloaterScriptDebugOutput::getFloaterByID(source_id)) { - floaterp->addLine(message, floater_label, color); + floaterp->setTitle(floater_label); // Update title + floaterp->addLine(chat, message, color); } } @@ -236,20 +243,15 @@ LLFloaterScriptDebugOutput::~LLFloaterScriptDebugOutput() sInstanceMap.erase(mObjectID); } -void LLFloaterScriptDebugOutput::addLine(const std::string &utf8mesg, const std::string &user_name, const LLColor4& color) +void LLFloaterScriptDebugOutput::addLine(const LLChat& chat, std::string message, const LLColor4& color) { - if (mObjectID.isNull()) + if (!chat.mURL.empty()) { - //setTitle("[All scripts]"); - setCanTearOff(FALSE); - setCanClose(FALSE); + message.erase(0, chat.mFromName.size()); + mHistoryEditor->appendText(chat.mURL, false, true); } - else - { - setTitle(user_name); - } - - mHistoryEditor->appendColoredText(utf8mesg, false, true, color); + LLStyleSP style(new LLStyle(true, color, LLStringUtil::null)); + mHistoryEditor->appendText(message, false, true, style, false); } //static @@ -262,6 +264,13 @@ LLFloaterScriptDebugOutput* LLFloaterScriptDebugOutput::show(const LLUUID& objec floaterp = new LLFloaterScriptDebugOutput(object_id); sInstanceMap[object_id] = floaterp; floaterp->open(); /* Flawfinder: ignore*/ + + if (object_id.isNull()) + { + //floaterp->setTitle("[All scripts]"); + floaterp->setCanTearOff(FALSE); + floaterp->setCanClose(FALSE); + } } else { diff --git a/indra/newview/llfloaterscriptdebug.h b/indra/newview/llfloaterscriptdebug.h index 0d5bc7411..8e28ea33d 100644 --- a/indra/newview/llfloaterscriptdebug.h +++ b/indra/newview/llfloaterscriptdebug.h @@ -35,6 +35,7 @@ #include "llmultifloater.h" +class LLChat; class LLTextEditor; class LLUUID; @@ -45,7 +46,7 @@ public: virtual void onClose(bool app_quitting) { setVisible(FALSE); } virtual BOOL postBuild(); static void show(const LLUUID& object_id); - static void addScriptLine(const std::string &utf8mesg, const std::string &user_name, const LLColor4& color, const LLUUID& source_id); + static void addScriptLine(LLChat& chat, const LLColor4& color); protected: LLFloaterScriptDebug(); @@ -67,7 +68,7 @@ public: S32 min_width, S32 min_height, BOOL drag_on_left, BOOL minimizable, BOOL close_btn); - void addLine(const std::string &utf8mesg, const std::string &user_name, const LLColor4& color); + void addLine(const LLChat& chat, std::string message, const LLColor4& color); static LLFloaterScriptDebugOutput* show(const LLUUID& object_id); static LLFloaterScriptDebugOutput* getFloaterByID(const LLUUID& id);