Skip to content

Commit a33fda4

Browse files
committed
#4339 Remade fix for world map's find button
1 parent 288bce1 commit a33fda4

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

indra/newview/llfloaterworldmap.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ LLFloaterWorldMap::LLFloaterWorldMap(const LLSD& key)
325325
mWaitingForTracker(false),
326326
mIsClosing(false),
327327
mSetToUserPosition(true),
328+
mProcessingSearchUpdate(false),
328329
mTrackedLocation(0.0,0.0,0.0),
329330
mTrackedStatus(LLTracker::TRACKING_NOTHING),
330331
mParcelInfoObserver(nullptr),
@@ -338,7 +339,7 @@ LLFloaterWorldMap::LLFloaterWorldMap(const LLSD& key)
338339
mCommitCallbackRegistrar.add("WMap.Location", boost::bind(&LLFloaterWorldMap::onLocationCommit, this));
339340
mCommitCallbackRegistrar.add("WMap.AvatarCombo", boost::bind(&LLFloaterWorldMap::onAvatarComboCommit, this));
340341
mCommitCallbackRegistrar.add("WMap.Landmark", boost::bind(&LLFloaterWorldMap::onLandmarkComboCommit, this));
341-
mCommitCallbackRegistrar.add("WMap.SearchResult", boost::bind(&LLFloaterWorldMap::onCommitSearchResult, this));
342+
mCommitCallbackRegistrar.add("WMap.SearchResult", [this](LLUICtrl* ctrl, const LLSD& data) { LLFloaterWorldMap::onCommitSearchResult(false); });
342343
mCommitCallbackRegistrar.add("WMap.GoHome", boost::bind(&LLFloaterWorldMap::onGoHome, this));
343344
mCommitCallbackRegistrar.add("WMap.Teleport", boost::bind(&LLFloaterWorldMap::onClickTeleportBtn, this));
344345
mCommitCallbackRegistrar.add("WMap.ShowTarget", boost::bind(&LLFloaterWorldMap::onShowTargetBtn, this));
@@ -783,6 +784,7 @@ void LLFloaterWorldMap::trackGenericItem(const LLItemInfo &item)
783784

784785
void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global)
785786
{
787+
mProcessingSearchUpdate = false;
786788
LLSimInfo* sim_info = LLWorldMap::getInstance()->simInfoFromPosGlobal(pos_global);
787789
if (!sim_info)
788790
{
@@ -922,7 +924,10 @@ void LLFloaterWorldMap::updateLocation()
922924
}
923925
}
924926

925-
mLocationEditor->setValue(sim_name);
927+
if (!mProcessingSearchUpdate)
928+
{
929+
mLocationEditor->setValue(sim_name);
930+
}
926931

927932
// refresh coordinate display to reflect where user clicked.
928933
LLVector3d coord_pos = LLTracker::getTrackedPositionGlobal();
@@ -1196,6 +1201,7 @@ void LLFloaterWorldMap::onGoHome()
11961201
{
11971202
gAgent.teleportHome();
11981203
closeFloater();
1204+
mProcessingSearchUpdate = false;
11991205
}
12001206

12011207

@@ -1365,6 +1371,7 @@ void LLFloaterWorldMap::onLocationCommit()
13651371
{
13661372
return;
13671373
}
1374+
mProcessingSearchUpdate = true;
13681375

13691376
LLStringUtil::toLower(str);
13701377
mCompletingRegionName = str;
@@ -1386,6 +1393,7 @@ void LLFloaterWorldMap::onCoordinatesCommit()
13861393
{
13871394
return;
13881395
}
1396+
mProcessingSearchUpdate = false;
13891397

13901398
S32 x_coord = (S32)mTeleportCoordSpinX->getValue().asReal();
13911399
S32 y_coord = (S32)mTeleportCoordSpinY->getValue().asReal();
@@ -1399,6 +1407,7 @@ void LLFloaterWorldMap::onCoordinatesCommit()
13991407
void LLFloaterWorldMap::onClearBtn()
14001408
{
14011409
mTrackedStatus = LLTracker::TRACKING_NOTHING;
1410+
mProcessingSearchUpdate = false;
14021411
LLTracker::stopTracking(true);
14031412
LLWorldMap::getInstance()->cancelTracking();
14041413
mSLURL = LLSLURL(); // Clear the SLURL since it's invalid
@@ -1415,6 +1424,7 @@ void LLFloaterWorldMap::onShowAgentBtn()
14151424
mMapView->setPanWithInterpTime(0, 0, false, 0.1f); // false == animate
14161425
// Set flag so user's location will be displayed if not tracking anything else
14171426
mSetToUserPosition = true;
1427+
mProcessingSearchUpdate = false;
14181428
}
14191429

14201430
void LLFloaterWorldMap::onClickTeleportBtn()
@@ -1570,6 +1580,12 @@ void LLFloaterWorldMap::teleport()
15701580
gAgent.teleportViaLocation( pos_global );
15711581
}
15721582
}
1583+
1584+
if (mProcessingSearchUpdate)
1585+
{
1586+
mProcessingSearchUpdate = false;
1587+
mTrackedSimName.clear();
1588+
}
15731589
}
15741590

15751591
void LLFloaterWorldMap::flyToLandmark()
@@ -1695,18 +1711,20 @@ void LLFloaterWorldMap::updateSims(bool found_null_sim)
16951711
{
16961712
mSearchResults->selectByValue(match);
16971713
mSearchResults->setFocus(true);
1698-
onCommitSearchResult();
1714+
onCommitSearchResult(false /*fully commit the only option*/);
16991715
}
17001716
// else let user decide
17011717
else
17021718
{
1703-
mSearchResults->operateOnAll(LLCtrlListInterface::OP_DESELECT);
1719+
mSearchResults->selectFirstItem();
17041720
mSearchResults->setFocus(true);
1721+
onCommitSearchResult(true /*don't update text field*/);
17051722
}
17061723
}
17071724
else
17081725
{
17091726
// if we found nothing, say "none"
1727+
mProcessingSearchUpdate = false;
17101728
mSearchResults->setCommentText(LLTrans::getString("worldmap_results_none_found"));
17111729
mSearchResults->operateOnAll(LLCtrlListInterface::OP_DESELECT);
17121730
}
@@ -1720,7 +1738,7 @@ void LLFloaterWorldMap::onTeleportFinished()
17201738
}
17211739
}
17221740

1723-
void LLFloaterWorldMap::onCommitSearchResult()
1741+
void LLFloaterWorldMap::onCommitSearchResult(bool from_search)
17241742
{
17251743
std::string sim_name = mSearchResults->getSelectedValue().asString();
17261744
if (sim_name.empty())
@@ -1751,8 +1769,14 @@ void LLFloaterWorldMap::onCommitSearchResult()
17511769
pos_global.mdV[VY] += (F64)pos_local.mV[VY];
17521770
pos_global.mdV[VZ] = (F64)pos_local.mV[VZ];
17531771

1754-
mLocationEditor->setValue(sim_name);
1772+
// Commiting search string automatically selects first item in the search list,
1773+
// in such case onCommitSearchResult shouldn't modify search string
1774+
if (!from_search)
1775+
{
1776+
mLocationEditor->setValue(sim_name);
1777+
}
17551778
trackLocation(pos_global);
1779+
mProcessingSearchUpdate = from_search;
17561780
mTrackCtrlsPanel->setDefaultBtn(mTeleportButton);
17571781
break;
17581782
}

indra/newview/llfloaterworldmap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class LLFloaterWorldMap : public LLFloater
176176
void onLocationFocusChanged( LLFocusableElement* ctrl );
177177
void onLocationCommit();
178178
void onCoordinatesCommit();
179-
void onCommitSearchResult();
179+
void onCommitSearchResult(bool from_search);
180180

181181
void onTeleportFinished();
182182

@@ -213,6 +213,7 @@ class LLFloaterWorldMap : public LLFloater
213213

214214
bool mIsClosing;
215215
bool mSetToUserPosition;
216+
bool mProcessingSearchUpdate; // Don't update search string from what user set it to
216217

217218
LLVector3d mTrackedLocation;
218219
LLTracker::ETrackingStatus mTrackedStatus;

0 commit comments

Comments
 (0)