diff options
author | McCabe Maxsted | 2009-08-12 11:48:21 -0700 |
---|---|---|
committer | McCabe Maxsted | 2009-08-12 11:48:21 -0700 |
commit | d5dc47ac672165a19fff6e57c866eca6439ea7e0 (patch) | |
tree | ab997a353090706d59e36466403ad8f13c92489c /linden/indra/newview/llfloatermap.cpp | |
parent | Moved radar back into llfloatermap.cpp, it works (diff) | |
download | meta-impy-d5dc47ac672165a19fff6e57c866eca6439ea7e0.zip meta-impy-d5dc47ac672165a19fff6e57c866eca6439ea7e0.tar.gz meta-impy-d5dc47ac672165a19fff6e57c866eca6439ea7e0.tar.bz2 meta-impy-d5dc47ac672165a19fff6e57c866eca6439ea7e0.tar.xz |
Fixed radar list scrolling issue, still missing toggle
Diffstat (limited to 'linden/indra/newview/llfloatermap.cpp')
-rw-r--r-- | linden/indra/newview/llfloatermap.cpp | 135 |
1 files changed, 93 insertions, 42 deletions
diff --git a/linden/indra/newview/llfloatermap.cpp b/linden/indra/newview/llfloatermap.cpp index b420eca..9ade3bf 100644 --- a/linden/indra/newview/llfloatermap.cpp +++ b/linden/indra/newview/llfloatermap.cpp | |||
@@ -86,6 +86,7 @@ BOOL LLFloaterMap::postBuild() | |||
86 | 86 | ||
87 | mRadarList = getChild<LLScrollListCtrl>("RadarList"); | 87 | mRadarList = getChild<LLScrollListCtrl>("RadarList"); |
88 | childSetCommitCallback("RadarList", onList, this); | 88 | childSetCommitCallback("RadarList", onList, this); |
89 | mRadarList->setDoubleClickCallback(onClickIM); | ||
89 | 90 | ||
90 | childSetAction("im_btn", onClickIM, this); | 91 | childSetAction("im_btn", onClickIM, this); |
91 | childSetAction("profile_btn", onClickProfile, this); | 92 | childSetAction("profile_btn", onClickProfile, this); |
@@ -154,6 +155,7 @@ void LLFloaterMap::draw() | |||
154 | } | 155 | } |
155 | } | 156 | } |
156 | 157 | ||
158 | // TODO: make this detachable | ||
157 | 159 | ||
158 | // | 160 | // |
159 | // Radar | 161 | // Radar |
@@ -168,67 +170,113 @@ void LLFloaterMap::updateRadar() | |||
168 | 170 | ||
169 | void LLFloaterMap::populateRadar() | 171 | void LLFloaterMap::populateRadar() |
170 | { | 172 | { |
171 | BOOL empty = TRUE; | ||
172 | std::stringstream avatar_count_string; | 173 | std::stringstream avatar_count_string; |
173 | LLScrollListCtrl* radar_scroller = getChild<LLScrollListCtrl>("RadarList"); | ||
174 | radar_scroller->deleteAllItems(); | ||
175 | |||
176 | LLVector3d current_pos = gAgent.getPositionGlobal(); | 174 | LLVector3d current_pos = gAgent.getPositionGlobal(); |
177 | 175 | ||
178 | std::vector<LLUUID> avatar_ids; | 176 | // find what avatars you can see |
179 | std::vector<LLVector3d> positions; | 177 | std::vector<LLUUID> avatar_ids_new; |
180 | LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, current_pos, gSavedSettings.getF32("NearMeRange")); | 178 | std::vector<LLVector3d> positions_new; |
181 | for(U32 i=0; i<avatar_ids.size(); i++) | 179 | LLWorld::getInstance()->getAvatars(&avatar_ids_new, &positions_new, current_pos, gSavedSettings.getF32("NearMeRange")); |
180 | |||
181 | // add an avatar to the list if it doesn't exist | ||
182 | std::vector<LLUUID>::iterator result; | ||
183 | for (U32 i=0; i<avatar_ids_new.size(); i++) | ||
182 | { | 184 | { |
183 | LLUUID& av = avatar_ids[i]; | 185 | result = find(mAvatarIDs.begin(), mAvatarIDs.end(), avatar_ids_new[i]); |
184 | 186 | if (result == mAvatarIDs.end()) | |
185 | if(av == gAgent.getID()) | ||
186 | continue; | ||
187 | |||
188 | LLVector3d avatar_pos = positions[i]; | ||
189 | F64 distance = dist_vec(current_pos, avatar_pos); | ||
190 | std::stringstream dist_formatted; | ||
191 | dist_formatted << (double)((int)((distance + 0.05)*10.0))/10.0 << "m"; | ||
192 | |||
193 | LLSD element; | ||
194 | element["id"] = av; // value | ||
195 | element["columns"][0]["column"] = "avatar_name"; | ||
196 | element["columns"][0]["type"] = "text"; | ||
197 | |||
198 | std::string fullname; | ||
199 | if(!gCacheName->getFullName(av, fullname)) | ||
200 | { | 187 | { |
201 | element["columns"][0]["value"] = LLCacheName::getDefaultName(); | 188 | mAvatarIDs.push_back(avatar_ids_new[i]); |
202 | } | 189 | mPositions.push_back(positions_new[i]); |
203 | else | 190 | addToList(avatar_ids_new[i], positions_new[i], current_pos); |
191 | } | ||
192 | else // avatar exists, check for updated position | ||
204 | { | 193 | { |
205 | element["columns"][0]["value"] = fullname; | 194 | if (mPositions[i] != positions_new[i]) |
195 | { | ||
196 | removeFromList(mAvatarIDs[i]); | ||
197 | mPositions[i] = positions_new[i]; | ||
198 | addToList(mAvatarIDs[i], mPositions[i], current_pos); | ||
199 | } | ||
206 | } | 200 | } |
201 | } | ||
202 | |||
203 | // pull out dead entries | ||
204 | for (U32 i=0; i<mAvatarIDs.size(); i++) | ||
205 | { | ||
206 | result = find(avatar_ids_new.begin(), avatar_ids_new.end(), mAvatarIDs[i]); | ||
207 | if (result == avatar_ids_new.end()) | ||
208 | { | ||
209 | removeFromList(mAvatarIDs[i]); | ||
207 | 210 | ||
208 | element["columns"][1]["column"] = "avatar_distance"; | 211 | // pop_back is faster |
209 | element["columns"][1]["type"] = "text"; | 212 | std::swap(mAvatarIDs[i], mAvatarIDs.back()); |
210 | element["columns"][1]["value"] = dist_formatted.str(); | 213 | mAvatarIDs.pop_back(); |
211 | radar_scroller->addElement(element); | 214 | std::swap(mPositions[i], mPositions.back()); |
212 | empty = FALSE; | 215 | mPositions.pop_back(); |
216 | } | ||
213 | } | 217 | } |
214 | 218 | ||
215 | avatar_count_string.str(""); | 219 | avatar_count_string.str(""); |
216 | if (empty) | 220 | if (mAvatarIDs.empty()) |
217 | { | 221 | { |
218 | childSetEnabled("RadarList", false);childSetEnabled("im_btn", false); | 222 | childSetEnabled("RadarList", false);childSetEnabled("im_btn", false); |
219 | radar_scroller->addCommentText(getString("no_one_near")); | 223 | mRadarList->addCommentText(getString("no_one_near")); |
220 | avatar_count_string << "0"; | 224 | avatar_count_string << "0"; |
221 | } | 225 | } |
222 | else | 226 | else |
223 | { | 227 | { |
224 | childSetEnabled("RadarList", true); | 228 | childSetEnabled("RadarList", true); |
225 | radar_scroller->selectFirstItem(); | 229 | avatar_count_string << (int)mAvatarIDs.size(); |
226 | avatar_count_string << (int)avatar_ids.size(); | ||
227 | } | 230 | } |
228 | LLTextBox* lblAvatarCount = getChild<LLTextBox>("lblAvatarCount"); | 231 | LLTextBox* lblAvatarCount = getChild<LLTextBox>("lblAvatarCount"); |
229 | lblAvatarCount->setText(avatar_count_string.str()); | 232 | lblAvatarCount->setText(avatar_count_string.str()); |
233 | onList(mRadarList, this); | ||
234 | } | ||
230 | 235 | ||
231 | onList(radar_scroller, this); | 236 | void LLFloaterMap::addToList(const LLUUID& agent_id, const LLVector3d& agent_pos, const LLVector3d& current_pos) |
237 | { | ||
238 | if (agent_id == gAgent.getID()) | ||
239 | return; | ||
240 | |||
241 | F64 distance = dist_vec(current_pos, agent_pos); | ||
242 | std::stringstream dist_formatted; | ||
243 | dist_formatted << (double)((int)((distance + 0.05)*10.0))/10.0 << "m"; | ||
244 | |||
245 | LLSD element; | ||
246 | element["id"] = agent_id; // value | ||
247 | element["columns"][0]["column"] = "avatar_name"; | ||
248 | element["columns"][0]["type"] = "text"; | ||
249 | |||
250 | std::string fullname; | ||
251 | if(!gCacheName->getFullName(agent_id, fullname)) | ||
252 | { | ||
253 | element["columns"][0]["value"] = LLCacheName::getDefaultName(); | ||
254 | } | ||
255 | else | ||
256 | { | ||
257 | element["columns"][0]["value"] = fullname; | ||
258 | } | ||
259 | |||
260 | element["columns"][1]["column"] = "avatar_distance"; | ||
261 | element["columns"][1]["type"] = "text"; | ||
262 | element["columns"][1]["value"] = dist_formatted.str(); | ||
263 | |||
264 | mRadarList->addElement(element); | ||
265 | mRadarList->selectByID(mSelectedAvatar); | ||
266 | |||
267 | onList(mRadarList, this); | ||
268 | } | ||
269 | |||
270 | void LLFloaterMap::removeFromList(const LLUUID& agent_id) | ||
271 | { | ||
272 | S32 index = mRadarList->getItemIndex(agent_id); | ||
273 | if (index >= 0) | ||
274 | { | ||
275 | mRadarList->deleteSingleItem(index); | ||
276 | mRadarList->selectByID(mSelectedAvatar); | ||
277 | |||
278 | onList(mRadarList, this); | ||
279 | } | ||
232 | } | 280 | } |
233 | 281 | ||
234 | // static | 282 | // static |
@@ -246,7 +294,10 @@ void LLFloaterMap::onList(LLUICtrl* ctrl, void* user_data) | |||
246 | 294 | ||
247 | if (self->visibleItemsSelected()) | 295 | if (self->visibleItemsSelected()) |
248 | { | 296 | { |
249 | self->mSelectedAvatar = self->mRadarList->getFirstSelected()->getUUID(); | 297 | if (self->mSelectedAvatar != self->mRadarList->getFirstSelected()->getUUID()) |
298 | { | ||
299 | self->mSelectedAvatar = self->mRadarList->getFirstSelected()->getUUID(); | ||
300 | } | ||
250 | } | 301 | } |
251 | else | 302 | else |
252 | { | 303 | { |