diff options
author | McCabe Maxsted | 2009-08-11 17:47:40 -0700 |
---|---|---|
committer | McCabe Maxsted | 2009-08-11 17:47:40 -0700 |
commit | c5926546aa73bfb2900dda7d010a4d72550e6787 (patch) | |
tree | c8d48cacdd56f4b8fc191f0c75cff5446b020617 /linden/indra/newview/llfloatermap.cpp | |
parent | Changed range to 96m (diff) | |
download | meta-impy-c5926546aa73bfb2900dda7d010a4d72550e6787.zip meta-impy-c5926546aa73bfb2900dda7d010a4d72550e6787.tar.gz meta-impy-c5926546aa73bfb2900dda7d010a4d72550e6787.tar.bz2 meta-impy-c5926546aa73bfb2900dda7d010a4d72550e6787.tar.xz |
Moved radar back into llfloatermap.cpp, it works
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfloatermap.cpp | 256 |
1 files changed, 256 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloatermap.cpp b/linden/indra/newview/llfloatermap.cpp index 6115404..b420eca 100644 --- a/linden/indra/newview/llfloatermap.cpp +++ b/linden/indra/newview/llfloatermap.cpp | |||
@@ -42,6 +42,20 @@ | |||
42 | #include "llresizebar.h" | 42 | #include "llresizebar.h" |
43 | #include "lluictrlfactory.h" | 43 | #include "lluictrlfactory.h" |
44 | 44 | ||
45 | // radar | ||
46 | #include "llfloateravatarinfo.h" | ||
47 | #include "llfloaterfriends.h" | ||
48 | #include "llfloatergroupinvite.h" | ||
49 | #include "llfloatergroups.h" | ||
50 | #include "llimview.h" | ||
51 | #include "roles_constants.h" | ||
52 | #include "llscrolllistctrl.h" | ||
53 | #include "lltracker.h" | ||
54 | #include "llviewermessage.h" | ||
55 | #include "llworld.h" | ||
56 | |||
57 | LLFloaterMap* LLFloaterMap::sInstance = NULL; | ||
58 | |||
45 | LLFloaterMap::LLFloaterMap(const LLSD& key) | 59 | LLFloaterMap::LLFloaterMap(const LLSD& key) |
46 | : | 60 | : |
47 | LLFloater(std::string("minimap")), | 61 | LLFloater(std::string("minimap")), |
@@ -50,6 +64,7 @@ LLFloaterMap::LLFloaterMap(const LLSD& key) | |||
50 | LLCallbackMap::map_t factory_map; | 64 | LLCallbackMap::map_t factory_map; |
51 | factory_map["mini_mapview"] = LLCallbackMap(createPanelMiniMap, this); | 65 | factory_map["mini_mapview"] = LLCallbackMap(createPanelMiniMap, this); |
52 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_mini_map.xml", &factory_map, FALSE); | 66 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_mini_map.xml", &factory_map, FALSE); |
67 | sInstance = this; | ||
53 | } | 68 | } |
54 | 69 | ||
55 | 70 | ||
@@ -58,6 +73,7 @@ void* LLFloaterMap::createPanelMiniMap(void* data) | |||
58 | { | 73 | { |
59 | LLFloaterMap* self = (LLFloaterMap*)data; | 74 | LLFloaterMap* self = (LLFloaterMap*)data; |
60 | self->mPanelMap = new LLNetMap("Mapview"); | 75 | self->mPanelMap = new LLNetMap("Mapview"); |
76 | self->mSelectedAvatar.setNull(); | ||
61 | return self->mPanelMap; | 77 | return self->mPanelMap; |
62 | } | 78 | } |
63 | 79 | ||
@@ -67,12 +83,28 @@ BOOL LLFloaterMap::postBuild() | |||
67 | sendChildToBack(getDragHandle()); | 83 | sendChildToBack(getDragHandle()); |
68 | sendChildToFront(getChild<LLButton>("llfloater_close_btn")); | 84 | sendChildToFront(getChild<LLButton>("llfloater_close_btn")); |
69 | setIsChrome(TRUE); | 85 | setIsChrome(TRUE); |
86 | |||
87 | mRadarList = getChild<LLScrollListCtrl>("RadarList"); | ||
88 | childSetCommitCallback("RadarList", onList, this); | ||
89 | |||
90 | childSetAction("im_btn", onClickIM, this); | ||
91 | childSetAction("profile_btn", onClickProfile, this); | ||
92 | childSetAction("offer_teleport_btn", onClickOfferTeleport, this); | ||
93 | childSetAction("track_btn", onClickTrack, this); | ||
94 | childSetAction("invite_btn", onClickInvite, this); | ||
95 | childSetAction("add_btn", onClickAddFriend, this); | ||
96 | |||
97 | setDefaultBtn("im_btn"); | ||
98 | |||
99 | populateRadar(); | ||
100 | |||
70 | return TRUE; | 101 | return TRUE; |
71 | } | 102 | } |
72 | 103 | ||
73 | 104 | ||
74 | LLFloaterMap::~LLFloaterMap() | 105 | LLFloaterMap::~LLFloaterMap() |
75 | { | 106 | { |
107 | sInstance = NULL; | ||
76 | } | 108 | } |
77 | 109 | ||
78 | 110 | ||
@@ -122,3 +154,227 @@ void LLFloaterMap::draw() | |||
122 | } | 154 | } |
123 | } | 155 | } |
124 | 156 | ||
157 | |||
158 | // | ||
159 | // Radar | ||
160 | // | ||
161 | |||
162 | //static | ||
163 | void LLFloaterMap::updateRadar() | ||
164 | { | ||
165 | LLFloaterMap* self = sInstance; | ||
166 | self->populateRadar(); | ||
167 | } | ||
168 | |||
169 | void LLFloaterMap::populateRadar() | ||
170 | { | ||
171 | BOOL empty = TRUE; | ||
172 | std::stringstream avatar_count_string; | ||
173 | LLScrollListCtrl* radar_scroller = getChild<LLScrollListCtrl>("RadarList"); | ||
174 | radar_scroller->deleteAllItems(); | ||
175 | |||
176 | LLVector3d current_pos = gAgent.getPositionGlobal(); | ||
177 | |||
178 | std::vector<LLUUID> avatar_ids; | ||
179 | std::vector<LLVector3d> positions; | ||
180 | LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, current_pos, gSavedSettings.getF32("NearMeRange")); | ||
181 | for(U32 i=0; i<avatar_ids.size(); i++) | ||
182 | { | ||
183 | LLUUID& av = avatar_ids[i]; | ||
184 | |||
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 | { | ||
201 | element["columns"][0]["value"] = LLCacheName::getDefaultName(); | ||
202 | } | ||
203 | else | ||
204 | { | ||
205 | element["columns"][0]["value"] = fullname; | ||
206 | } | ||
207 | |||
208 | element["columns"][1]["column"] = "avatar_distance"; | ||
209 | element["columns"][1]["type"] = "text"; | ||
210 | element["columns"][1]["value"] = dist_formatted.str(); | ||
211 | radar_scroller->addElement(element); | ||
212 | empty = FALSE; | ||
213 | } | ||
214 | |||
215 | avatar_count_string.str(""); | ||
216 | if (empty) | ||
217 | { | ||
218 | childSetEnabled("RadarList", false);childSetEnabled("im_btn", false); | ||
219 | radar_scroller->addCommentText(getString("no_one_near")); | ||
220 | avatar_count_string << "0"; | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | childSetEnabled("RadarList", true); | ||
225 | radar_scroller->selectFirstItem(); | ||
226 | avatar_count_string << (int)avatar_ids.size(); | ||
227 | } | ||
228 | LLTextBox* lblAvatarCount = getChild<LLTextBox>("lblAvatarCount"); | ||
229 | lblAvatarCount->setText(avatar_count_string.str()); | ||
230 | |||
231 | onList(radar_scroller, this); | ||
232 | } | ||
233 | |||
234 | // static | ||
235 | void LLFloaterMap::onList(LLUICtrl* ctrl, void* user_data) | ||
236 | { | ||
237 | LLFloaterMap* self = (LLFloaterMap*)user_data; | ||
238 | if (self) | ||
239 | { | ||
240 | self->childSetEnabled("im_btn", self->visibleItemsSelected()); | ||
241 | self->childSetEnabled("profile_btn", self->visibleItemsSelected()); | ||
242 | self->childSetEnabled("offer_teleport_btn", self->visibleItemsSelected()); | ||
243 | self->childSetEnabled("track_btn", self->visibleItemsSelected()); | ||
244 | self->childSetEnabled("invite_btn", self->visibleItemsSelected()); | ||
245 | self->childSetEnabled("add_btn", self->visibleItemsSelected()); | ||
246 | |||
247 | if (self->visibleItemsSelected()) | ||
248 | { | ||
249 | self->mSelectedAvatar = self->mRadarList->getFirstSelected()->getUUID(); | ||
250 | } | ||
251 | else | ||
252 | { | ||
253 | self->mSelectedAvatar.setNull(); | ||
254 | } | ||
255 | } | ||
256 | } | ||
257 | |||
258 | BOOL LLFloaterMap::visibleItemsSelected() const | ||
259 | { | ||
260 | if (mRadarList->getFirstSelectedIndex() >= 0) | ||
261 | { | ||
262 | return TRUE; | ||
263 | } | ||
264 | return FALSE; | ||
265 | } | ||
266 | |||
267 | // static | ||
268 | BOOL LLFloaterMap::isSelected(LLUUID agent) | ||
269 | { | ||
270 | if (sInstance->mSelectedAvatar == agent) | ||
271 | { | ||
272 | return TRUE; | ||
273 | } | ||
274 | return FALSE; | ||
275 | } | ||
276 | |||
277 | // static | ||
278 | void LLFloaterMap::onClickIM(void* user_data) | ||
279 | { | ||
280 | LLFloaterMap* self = (LLFloaterMap*) user_data; | ||
281 | LLScrollListItem *item = self->mRadarList->getFirstSelected(); | ||
282 | if (item != NULL) | ||
283 | { | ||
284 | LLUUID agent_id = item->getUUID(); | ||
285 | std::string fullname; | ||
286 | if(gCacheName->getFullName(agent_id, fullname)) | ||
287 | { | ||
288 | gIMMgr->setFloaterOpen(TRUE); | ||
289 | gIMMgr->addSession(fullname, IM_NOTHING_SPECIAL, agent_id); | ||
290 | } | ||
291 | } | ||
292 | } | ||
293 | |||
294 | // static | ||
295 | void LLFloaterMap::onClickProfile(void* user_data) | ||
296 | { | ||
297 | LLFloaterMap* self = (LLFloaterMap*) user_data; | ||
298 | LLScrollListItem *item = self->mRadarList->getFirstSelected(); | ||
299 | if (item != NULL) | ||
300 | { | ||
301 | LLUUID agent_id = item->getUUID(); | ||
302 | LLFloaterAvatarInfo::show(agent_id); | ||
303 | } | ||
304 | } | ||
305 | |||
306 | // static | ||
307 | void LLFloaterMap::onClickOfferTeleport(void* user_data) | ||
308 | { | ||
309 | LLFloaterMap* self = (LLFloaterMap*) user_data; | ||
310 | LLScrollListItem *item = self->mRadarList->getFirstSelected(); | ||
311 | if (item != NULL) | ||
312 | { | ||
313 | LLUUID agent_id = item->getUUID(); | ||
314 | handle_lure(agent_id); | ||
315 | } | ||
316 | } | ||
317 | |||
318 | // static | ||
319 | void LLFloaterMap::onClickTrack(void* user_data) | ||
320 | { | ||
321 | LLFloaterMap* self = (LLFloaterMap*) user_data; | ||
322 | LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus(); | ||
323 | if (LLTracker::TRACKING_AVATAR == tracking_status) | ||
324 | { | ||
325 | LLTracker::stopTracking(NULL); | ||
326 | } | ||
327 | else | ||
328 | { | ||
329 | LLScrollListItem *item = self->mRadarList->getFirstSelected(); | ||
330 | if (item != NULL) | ||
331 | { | ||
332 | LLUUID agent_id = item->getUUID(); | ||
333 | std::string fullname; | ||
334 | gCacheName->getFullName(agent_id, fullname); | ||
335 | LLTracker::trackAvatar(agent_id, fullname); | ||
336 | } | ||
337 | } | ||
338 | } | ||
339 | |||
340 | // static | ||
341 | void LLFloaterMap::onClickInvite(void* user_data) | ||
342 | { | ||
343 | LLFloaterMap* self = (LLFloaterMap*) user_data; | ||
344 | LLScrollListItem *item = self->mRadarList->getFirstSelected(); | ||
345 | if (item != NULL) | ||
346 | { | ||
347 | LLUUID agent_id = item->getUUID(); | ||
348 | LLFloaterGroupPicker* widget; | ||
349 | widget = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID())); | ||
350 | if (widget) | ||
351 | { | ||
352 | widget->center(); | ||
353 | widget->setPowersMask(GP_MEMBER_INVITE); | ||
354 | widget->setSelectCallback(callback_invite_to_group, (void *)&agent_id); | ||
355 | } | ||
356 | } | ||
357 | } | ||
358 | |||
359 | // static | ||
360 | void LLFloaterMap::callback_invite_to_group(LLUUID group_id, void *user_data) | ||
361 | { | ||
362 | std::vector<LLUUID> agent_ids; | ||
363 | agent_ids.push_back(*(LLUUID *)user_data); | ||
364 | |||
365 | LLFloaterGroupInvite::showForGroup(group_id, &agent_ids); | ||
366 | } | ||
367 | |||
368 | // static | ||
369 | void LLFloaterMap::onClickAddFriend(void* user_data) | ||
370 | { | ||
371 | LLFloaterMap* self = (LLFloaterMap*) user_data; | ||
372 | LLScrollListItem *item = self->mRadarList->getFirstSelected(); | ||
373 | if (item != NULL) | ||
374 | { | ||
375 | LLUUID agent_id = item->getUUID(); | ||
376 | std::string fullname; | ||
377 | gCacheName->getFullName(agent_id, fullname); | ||
378 | LLPanelFriends::requestFriendshipDialog(agent_id, fullname); | ||
379 | } | ||
380 | } | ||