Skip to content

Commit 49f03a2

Browse files
committed
#2923 Add 'Create Landmark' button to the agent profile floater
1 parent 5517a49 commit 49f03a2

File tree

5 files changed

+94
-28
lines changed

5 files changed

+94
-28
lines changed

indra/newview/lllandmarkactions.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,21 @@ void LLLandmarkActions::showFloaterCreateLandmarkForUrl(const std::string& url,
277277
return;
278278
}
279279

280+
S32 x = (S32)std::round(slurl.getPosition()[VX]);
281+
S32 y = (S32)std::round(slurl.getPosition()[VY]);
282+
S32 z = (S32)std::round(slurl.getPosition()[VZ]);
283+
// When title == url we provide an empty string to create a human-readable title
284+
showFloaterCreateLandmarkForCoords(slurl.getRegion(), x, y, z, title == url ? LLStringUtil::null : title);
285+
}
286+
287+
void LLLandmarkActions::showFloaterCreateLandmarkForCoords(const std::string& region_name, S32 x, S32 y, S32 z, const std::string& title)
288+
{
280289
LLSD data;
281-
data["region"] = slurl.getRegion();
282-
data["x"] = (S32)std::round(slurl.getPosition()[VX]);
283-
data["y"] = (S32)std::round(slurl.getPosition()[VY]);
284-
data["z"] = (S32)std::round(slurl.getPosition()[VZ]);
285-
data["title"] = title.empty() ? slurl.getRegion() : title;
290+
data["region"] = region_name;
291+
data["x"] = x;
292+
data["y"] = y;
293+
data["z"] = z;
294+
data["title"] = title.empty() ? llformat("%s (%d, %d, %d)", region_name.c_str(), x, y, z) : title;
286295

287296
LLFloaterReg::showInstance("add_landmark", data);
288297
}

indra/newview/lllandmarkactions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ class LLLandmarkActions
9090
*/
9191
static void showFloaterCreateLandmarkForUrl(const std::string& url, const std::string& title);
9292

93+
/**
94+
* @brief Shows floater to create landmark for specified coordinates.
95+
*/
96+
static void showFloaterCreateLandmarkForCoords(const std::string& region_name, S32 x, S32 y, S32 z,
97+
const std::string& title = LLStringUtil::null);
98+
9399
/**
94100
* @brief Checks possibility to create landmark for specified URL.
95101
*/

indra/newview/llpanelprofilepicks.cpp

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@
3636
#include "lldispatcher.h"
3737
#include "llfloaterreg.h"
3838
#include "llfloaterworldmap.h"
39+
#include "lllandmarkactions.h"
3940
#include "lllineeditor.h"
4041
#include "llnotificationsutil.h"
4142
#include "llpanelavatar.h"
4243
#include "llpanelprofile.h"
4344
#include "llparcel.h"
45+
#include "llregionhandle.h"
4446
#include "llstartup.h"
4547
#include "lltabcontainer.h"
4648
#include "lltextbox.h"
@@ -51,6 +53,7 @@
5153
#include "llviewergenericmessage.h" // send_generic_message
5254
#include "llviewerparcelmgr.h"
5355
#include "llviewerregion.h"
56+
#include "llworldmap.h"
5457

5558
static LLPanelInjector<LLPanelProfilePicks> t_panel_profile_picks("panel_profile_picks");
5659
static LLPanelInjector<LLPanelProfilePick> t_panel_profile_pick("panel_profile_pick");
@@ -589,26 +592,28 @@ bool LLPanelProfilePick::postBuild()
589592
mSaveButton = getChild<LLButton>("save_changes_btn");
590593
mCreateButton = getChild<LLButton>("create_changes_btn");
591594
mCancelButton = getChild<LLButton>("cancel_changes_btn");
595+
mCreateLandmarkButton = getChild<LLButton>("create_landmark_btn");
592596
mSetCurrentLocationButton = getChild<LLButton>("set_to_curr_location_btn");
593597

594598
mSnapshotCtrl = getChild<LLTextureCtrl>("pick_snapshot");
595-
mSnapshotCtrl->setCommitCallback(boost::bind(&LLPanelProfilePick::onSnapshotChanged, this));
599+
mSnapshotCtrl->setCommitCallback([&](LLUICtrl*, const LLSD&) { onSnapshotChanged(); });
596600
mSnapshotCtrl->setAllowLocalTexture(false);
597601
mSnapshotCtrl->setBakeTextureEnabled(false);
598602

599-
childSetAction("teleport_btn", boost::bind(&LLPanelProfilePick::onClickTeleport, this));
600-
childSetAction("show_on_map_btn", boost::bind(&LLPanelProfilePick::onClickMap, this));
603+
childSetAction("teleport_btn", [&](LLUICtrl*, const LLSD&) { onClickTeleport(); });
604+
childSetAction("show_on_map_btn", [&](LLUICtrl*, const LLSD&) { onClickMap(); });
601605

602-
mSaveButton->setCommitCallback(boost::bind(&LLPanelProfilePick::onClickSave, this));
603-
mCreateButton->setCommitCallback(boost::bind(&LLPanelProfilePick::onClickSave, this));
604-
mCancelButton->setCommitCallback(boost::bind(&LLPanelProfilePick::onClickCancel, this));
605-
mSetCurrentLocationButton->setCommitCallback(boost::bind(&LLPanelProfilePick::onClickSetLocation, this));
606+
mSaveButton->setCommitCallback([&](LLUICtrl*, const LLSD&) { onClickSave(); });
607+
mCreateButton->setCommitCallback([&](LLUICtrl*, const LLSD&) { onClickSave(); });
608+
mCancelButton->setCommitCallback([&](LLUICtrl*, const LLSD&) { onClickCancel(); });
609+
mCreateLandmarkButton->setCommitCallback([&](LLUICtrl*, const LLSD&) { onClickCreateLandmark(); });
610+
mSetCurrentLocationButton->setCommitCallback([&](LLUICtrl*, const LLSD&) { onClickSetLocation(); });
606611

607-
mPickName->setKeystrokeCallback(boost::bind(&LLPanelProfilePick::onPickChanged, this, _1), NULL);
612+
mPickName->setKeystrokeCallback([&](LLLineEditor* ctrl, void*) { onPickChanged(ctrl); }, NULL);
608613
mPickName->setEnabled(false);
609614

610-
mPickDescription->setKeystrokeCallback(boost::bind(&LLPanelProfilePick::onPickChanged, this, _1));
611-
mPickDescription->setFocusReceivedCallback(boost::bind(&LLPanelProfilePick::onDescriptionFocusReceived, this));
615+
mPickDescription->setKeystrokeCallback([&](LLTextEditor* ctrl) { onPickChanged(ctrl); });
616+
mPickDescription->setFocusReceivedCallback([&](LLFocusableElement*) { onDescriptionFocusReceived(); });
612617

613618
getChild<LLUICtrl>("pick_location")->setEnabled(false);
614619

@@ -765,6 +770,27 @@ bool LLPanelProfilePick::isDirty() const
765770
return false;
766771
}
767772

773+
void LLPanelProfilePick::onClickCreateLandmark()
774+
{
775+
if (gAgent.getRegion() &&
776+
!gAgent.getRegion()->getCapability("CreateLandmarkForPosition").empty())
777+
{
778+
U64 handle = to_region_handle(mPosGlobal);
779+
if (LLSimInfo* info = LLWorldMap::getInstance()->simInfoFromHandle(handle))
780+
{
781+
std::string region_name = info->getName();
782+
S32 x = llclamp(ll_round((F32)mPosGlobal.mdV[VX]), 0, REGION_WIDTH_UNITS);
783+
S32 y = llclamp(ll_round((F32)mPosGlobal.mdV[VY]), 0, REGION_WIDTH_UNITS);
784+
S32 z = ll_round(llclamp((F32)mPosGlobal.mdV[VZ], MIN_OBJECT_Z, MAX_OBJECT_Z));
785+
std::string title = getChild<LLUICtrl>("pick_location")->getValue().asString();
786+
LLLandmarkActions::showFloaterCreateLandmarkForCoords(region_name, x, y, z, title);
787+
return;
788+
}
789+
}
790+
791+
LLNotificationsUtil::add("CantCreateLandmark");
792+
}
793+
768794
void LLPanelProfilePick::onClickSetLocation()
769795
{
770796
// Save location for later use.
@@ -899,14 +925,14 @@ void LLPanelProfilePick::sendUpdate()
899925
std::string LLPanelProfilePick::createLocationText(const std::string& owner_name, const std::string& original_name, const std::string& sim_name, const LLVector3d& pos_global)
900926
{
901927
std::string location_text(owner_name);
928+
902929
if (!original_name.empty())
903930
{
904931
if (!location_text.empty())
905932
{
906933
location_text.append(", ");
907934
}
908935
location_text.append(original_name);
909-
910936
}
911937

912938
if (!sim_name.empty())
@@ -918,18 +944,18 @@ std::string LLPanelProfilePick::createLocationText(const std::string& owner_name
918944
location_text.append(sim_name);
919945
}
920946

921-
if (!location_text.empty())
922-
{
923-
location_text.append(" ");
924-
}
925-
926947
if (!pos_global.isNull())
927948
{
949+
if (!location_text.empty())
950+
{
951+
location_text.append(" ");
952+
}
928953
S32 region_x = ll_round((F32)pos_global.mdV[VX]) % REGION_WIDTH_UNITS;
929954
S32 region_y = ll_round((F32)pos_global.mdV[VY]) % REGION_WIDTH_UNITS;
930955
S32 region_z = ll_round((F32)pos_global.mdV[VZ]);
931-
location_text.append(llformat(" (%d, %d, %d)", region_x, region_y, region_z));
956+
location_text.append(llformat("(%d, %d, %d)", region_x, region_y, region_z));
932957
}
958+
933959
return location_text;
934960
}
935961

indra/newview/llpanelprofilepicks.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ class LLPanelProfilePick
201201
*/
202202
void resetDirty() override;
203203

204+
/**
205+
* Callback for "CreateLandmark" button click
206+
*/
207+
void onClickCreateLandmark();
208+
204209
/**
205210
* Callback for "Set Location" button click
206211
*/
@@ -228,6 +233,7 @@ class LLPanelProfilePick
228233
LLTextureCtrl* mSnapshotCtrl;
229234
LLLineEditor* mPickName;
230235
LLTextEditor* mPickDescription;
236+
LLButton* mCreateLandmarkButton;
231237
LLButton* mSetCurrentLocationButton;
232238
LLButton* mSaveButton;
233239
LLButton* mCreateButton;

indra/newview/skins/default/xui/en/panel_profile_pick.xml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,25 @@
160160
width="1">
161161
</layout_panel>
162162

163+
<layout_panel
164+
follows="all"
165+
layout="bottomleft"
166+
left_pad="2"
167+
name="tp_btn_lp"
168+
auto_resize="false"
169+
width="80">
170+
<button
171+
name="teleport_btn"
172+
label="Teleport"
173+
left="0"
174+
top="0"
175+
height="23"
176+
width="80"
177+
follows="left|top"
178+
layout="topleft"
179+
/>
180+
</layout_panel>
181+
163182
<layout_panel
164183
follows="all"
165184
layout="bottomleft"
@@ -176,23 +195,23 @@
176195
width="100"
177196
follows="left|top"
178197
layout="topleft"
179-
/>
198+
/>
180199
</layout_panel>
181200

182201
<layout_panel
183202
follows="all"
184203
layout="bottomleft"
185204
left_pad="2"
186-
name="tp_btn_lp"
205+
name="cl_btn_lp"
187206
auto_resize="false"
188-
width="100">
207+
width="120">
189208
<button
190-
name="teleport_btn"
191-
label="Teleport"
209+
name="create_landmark_btn"
210+
label="Create Landmark"
192211
left="0"
193212
top="0"
194213
height="23"
195-
width="100"
214+
width="120"
196215
follows="left|top"
197216
layout="topleft"
198217
/>

0 commit comments

Comments
 (0)