Script Debug should link to object, when possible
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user