summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2023-04-24 19:48:55 +0300
committerGitHub <noreply@github.com>2023-04-24 19:48:55 +0300
commitf9cb6a13b23df14c2dcc7709fafdb28c578a934e (patch)
tree72f13d8c4735474fa9bb3cadc1bb7e939b903eae /indra/newview
parent124acddce50f6ad8c7b4cbe2860e9ffba640b8f1 (diff)
SL-19362 Add teleport button to Top Scripts and Top Colliders floaters (#190)
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llfloatertopobjects.cpp49
-rw-r--r--indra/newview/llfloatertopobjects.h4
-rw-r--r--indra/newview/skins/default/xui/en/floater_top_objects.xml13
3 files changed, 62 insertions, 4 deletions
diff --git a/indra/newview/llfloatertopobjects.cpp b/indra/newview/llfloatertopobjects.cpp
index bd49405f34..9f277021c8 100644
--- a/indra/newview/llfloatertopobjects.cpp
+++ b/indra/newview/llfloatertopobjects.cpp
@@ -49,6 +49,7 @@
#include "llviewerparcelmgr.h"
#include "llviewerregion.h"
#include "lluictrlfactory.h"
+#include "llviewerobjectlist.h"
#include "llviewerwindow.h"
#include "llfloaterregioninfo.h"
@@ -83,6 +84,8 @@ LLFloaterTopObjects::LLFloaterTopObjects(const LLSD& key)
mCommitCallbackRegistrar.add("TopObjects.GetByOwnerName", boost::bind(&LLFloaterTopObjects::onGetByOwnerName, this));
mCommitCallbackRegistrar.add("TopObjects.GetByParcelName", boost::bind(&LLFloaterTopObjects::onGetByParcelName, this));
mCommitCallbackRegistrar.add("TopObjects.CommitObjectsList",boost::bind(&LLFloaterTopObjects::onCommitObjectsList, this));
+
+ mCommitCallbackRegistrar.add("TopObjects.TeleportToSelected", boost::bind(&LLFloaterTopObjects::teleportToSelectedObject, this));
}
LLFloaterTopObjects::~LLFloaterTopObjects()
@@ -92,10 +95,11 @@ LLFloaterTopObjects::~LLFloaterTopObjects()
// virtual
BOOL LLFloaterTopObjects::postBuild()
{
- LLScrollListCtrl *objects_list = getChild<LLScrollListCtrl>("objects_list");
- getChild<LLUICtrl>("objects_list")->setFocus(TRUE);
- objects_list->setDoubleClickCallback(onDoubleClickObjectsList, this);
- objects_list->setCommitOnSelectionChange(TRUE);
+ mObjectsScrollList = getChild<LLScrollListCtrl>("objects_list");
+ mObjectsScrollList->setFocus(TRUE);
+ mObjectsScrollList->setDoubleClickCallback(onDoubleClickObjectsList, this);
+ mObjectsScrollList->setCommitOnSelectionChange(TRUE);
+ mObjectsScrollList->setCommitCallback(boost::bind(&LLFloaterTopObjects::onSelectionChanged, this));
setDefaultBtn("show_beacon_btn");
@@ -421,6 +425,8 @@ void LLFloaterTopObjects::clearList()
mObjectListData.clear();
mObjectListIDs.clear();
mtotalScore = 0.f;
+
+ onSelectionChanged();
}
@@ -507,3 +513,38 @@ void LLFloaterTopObjects::showBeacon()
std::string tooltip("");
LLTracker::trackLocation(pos_global, name, tooltip, LLTracker::LOCATION_ITEM);
}
+
+void LLFloaterTopObjects::teleportToSelectedObject()
+{
+ std::vector<LLScrollListItem*> selected_items = mObjectsScrollList->getAllSelected();
+ if (selected_items.size() == 1)
+ {
+ LLScrollListItem* first_selected = selected_items.front();
+
+ LLVector3d teleport_location;
+ LLViewerObject *viewer_object = gObjectList.findObject(first_selected->getUUID());
+ if (viewer_object == NULL)
+ {
+ // If we cannot find the object in the viewer list, teleport to the last reported position
+ std::string pos_string = first_selected->getColumn(3)->getValue().asString();
+
+ F32 x, y, z;
+ S32 matched = sscanf(pos_string.c_str(), "<%g,%g,%g>", &x, &y, &z);
+ if (matched != 3) return;
+
+ LLVector3 pos_agent(x, y, z);
+ teleport_location = gAgent.getPosGlobalFromAgent(pos_agent);
+ }
+ else
+ {
+ // If we can find the object in the viewer list, teleport to the known current position
+ teleport_location = viewer_object->getPositionGlobal();
+ }
+ gAgent.teleportViaLocationLookAt(teleport_location);
+ }
+}
+
+void LLFloaterTopObjects::onSelectionChanged()
+{
+ getChildView("teleport_btn")->setEnabled(mObjectsScrollList->getNumSelected() == 1);
+}
diff --git a/indra/newview/llfloatertopobjects.h b/indra/newview/llfloatertopobjects.h
index 3138249c7a..b73401e50d 100644
--- a/indra/newview/llfloatertopobjects.h
+++ b/indra/newview/llfloatertopobjects.h
@@ -30,6 +30,7 @@
#include "llfloater.h"
class LLUICtrl;
+class LLScrollListCtrl;
// Bits for simulator performance query flags
enum LAND_STAT_FLAGS
@@ -75,6 +76,7 @@ private:
void initColumns(LLCtrlListInterface *list);
void onCommitObjectsList();
+ void onSelectionChanged();
static void onDoubleClickObjectsList(void* data);
void onClickShowBeacon();
@@ -90,6 +92,7 @@ private:
void onGetByParcelName();
void showBeacon();
+ void teleportToSelectedObject();
private:
std::string mMethod;
@@ -106,6 +109,7 @@ private:
F32 mtotalScore;
static LLFloaterTopObjects* sInstance;
+ LLScrollListCtrl* mObjectsScrollList;
};
#endif
diff --git a/indra/newview/skins/default/xui/en/floater_top_objects.xml b/indra/newview/skins/default/xui/en/floater_top_objects.xml
index b82fe43e74..a8b4b84ab7 100644
--- a/indra/newview/skins/default/xui/en/floater_top_objects.xml
+++ b/indra/newview/skins/default/xui/en/floater_top_objects.xml
@@ -273,4 +273,17 @@
<button.commit_callback
function="TopObjects.ReturnAll" />
</button>
+ <button
+ follows="bottom|left"
+ height="23"
+ label="Teleport to selected"
+ layout="topleft"
+ left_pad="10"
+ name="teleport_btn"
+ enabled="false"
+ top_delta="0"
+ width="160">
+ <button.commit_callback
+ function="TopObjects.TeleportToSelected" />
+</button>
</floater>