aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloateractivespeakers.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:29 -0500
committerJacek Antonelli2008-08-15 23:45:29 -0500
commit7bdb4845afdd157f95281293803567090e3f992a (patch)
treefbcada1c227d7407f9f37ccba360bfe6326d9c5e /linden/indra/newview/llfloateractivespeakers.cpp
parentSecond Life viewer sources 1.19.0.0 (diff)
downloadmeta-impy-7bdb4845afdd157f95281293803567090e3f992a.zip
meta-impy-7bdb4845afdd157f95281293803567090e3f992a.tar.gz
meta-impy-7bdb4845afdd157f95281293803567090e3f992a.tar.bz2
meta-impy-7bdb4845afdd157f95281293803567090e3f992a.tar.xz
Second Life viewer sources 1.19.0.2
Diffstat (limited to 'linden/indra/newview/llfloateractivespeakers.cpp')
-rw-r--r--linden/indra/newview/llfloateractivespeakers.cpp328
1 files changed, 198 insertions, 130 deletions
diff --git a/linden/indra/newview/llfloateractivespeakers.cpp b/linden/indra/newview/llfloateractivespeakers.cpp
index 877ebca..8432d21 100644
--- a/linden/indra/newview/llfloateractivespeakers.cpp
+++ b/linden/indra/newview/llfloateractivespeakers.cpp
@@ -135,6 +135,16 @@ LLSD LLSpeakerVoiceModerationEvent::getValue()
135 return LLString("voice"); 135 return LLString("voice");
136} 136}
137 137
138LLSpeakerListChangeEvent::LLSpeakerListChangeEvent(LLSpeakerMgr* source, const LLUUID& speaker_id)
139: LLEvent(source, "Speaker added/removed from speaker mgr"),
140 mSpeakerID(speaker_id)
141{
142}
143
144LLSD LLSpeakerListChangeEvent::getValue()
145{
146 return mSpeakerID;
147}
138 148
139// helper sort class 149// helper sort class
140struct LLSortRecentSpeakers 150struct LLSortRecentSpeakers
@@ -210,9 +220,9 @@ void* LLFloaterActiveSpeakers::createSpeakersPanel(void* data)
210} 220}
211 221
212// 222//
213// LLPanelActiveSpeakers::LLSpeakerListener 223// LLPanelActiveSpeakers::SpeakerMuteListener
214// 224//
215bool LLPanelActiveSpeakers::LLSpeakerListener::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) 225bool LLPanelActiveSpeakers::SpeakerMuteListener::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
216{ 226{
217 LLPointer<LLSpeaker> speakerp = (LLSpeaker*)event->getSource(); 227 LLPointer<LLSpeaker> speakerp = (LLSpeaker*)event->getSource();
218 if (speakerp.isNull()) return false; 228 if (speakerp.isNull()) return false;
@@ -231,6 +241,35 @@ bool LLPanelActiveSpeakers::LLSpeakerListener::handleEvent(LLPointer<LLEvent> ev
231 241
232 242
233// 243//
244// LLPanelActiveSpeakers::SpeakerAddListener
245//
246bool LLPanelActiveSpeakers::SpeakerAddListener::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
247{
248 mPanel->addSpeaker(event->getValue().asUUID());
249 return true;
250}
251
252
253//
254// LLPanelActiveSpeakers::SpeakerRemoveListener
255//
256bool LLPanelActiveSpeakers::SpeakerRemoveListener::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
257{
258 mPanel->removeSpeaker(event->getValue().asUUID());
259 return true;
260}
261
262//
263// LLPanelActiveSpeakers::SpeakerClearListener
264//
265bool LLPanelActiveSpeakers::SpeakerClearListener::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
266{
267 mPanel->mSpeakerList->clearRows();
268 return true;
269}
270
271
272//
234// LLPanelActiveSpeakers 273// LLPanelActiveSpeakers
235// 274//
236LLPanelActiveSpeakers::LLPanelActiveSpeakers(LLSpeakerMgr* data_source, BOOL show_text_chatters) : 275LLPanelActiveSpeakers::LLPanelActiveSpeakers(LLSpeakerMgr* data_source, BOOL show_text_chatters) :
@@ -243,12 +282,14 @@ LLPanelActiveSpeakers::LLPanelActiveSpeakers(LLSpeakerMgr* data_source, BOOL sho
243 mSpeakerMgr(data_source) 282 mSpeakerMgr(data_source)
244{ 283{
245 setMouseOpaque(FALSE); 284 setMouseOpaque(FALSE);
246 mSpeakerListener = new LLSpeakerListener(this); 285 mSpeakerMuteListener = new SpeakerMuteListener(this);
247} 286 mSpeakerAddListener = new SpeakerAddListener(this);
248 287 mSpeakerRemoveListener = new SpeakerRemoveListener(this);
249LLPanelActiveSpeakers::~LLPanelActiveSpeakers() 288 mSpeakerClearListener = new SpeakerClearListener(this);
250{ 289
251 290 mSpeakerMgr->addListener(mSpeakerAddListener, "add");
291 mSpeakerMgr->addListener(mSpeakerRemoveListener, "remove");
292 mSpeakerMgr->addListener(mSpeakerClearListener, "clear");
252} 293}
253 294
254BOOL LLPanelActiveSpeakers::postBuild() 295BOOL LLPanelActiveSpeakers::postBuild()
@@ -283,6 +324,57 @@ BOOL LLPanelActiveSpeakers::postBuild()
283 return TRUE; 324 return TRUE;
284} 325}
285 326
327void LLPanelActiveSpeakers::addSpeaker(const LLUUID& speaker_id)
328{
329 if (mSpeakerList->getItemIndex(speaker_id) >= 0)
330 {
331 // already have this speaker
332 return;
333 }
334
335 LLPointer<LLSpeaker> speakerp = mSpeakerMgr->findSpeaker(speaker_id);
336 if (speakerp)
337 {
338 // since we are forced to sort by text, encode sort order as string
339 LLString speaking_order_sort_string = llformat("%010d", speakerp->mSortIndex);
340
341 LLSD row;
342 row["id"] = speaker_id;
343
344 LLSD& columns = row["columns"];
345
346 columns[0]["column"] = "icon_speaking_status";
347 columns[0]["type"] = "icon";
348 columns[0]["value"] = gViewerArt.getString("icn_active-speakers-dot-lvl0.tga");
349
350 LLString speaker_name;
351 if (speakerp->mDisplayName.empty())
352 {
353 speaker_name = LLCacheName::getDefaultName();
354 }
355 else
356 {
357 speaker_name = speakerp->mDisplayName;
358 }
359 columns[1]["column"] = "speaker_name";
360 columns[1]["type"] = "text";
361 columns[1]["value"] = speaker_name;
362
363 columns[2]["column"] = "speaking_status";
364 columns[2]["type"] = "text";
365
366 // print speaking ordinal in a text-sorting friendly manner
367 columns[2]["value"] = speaking_order_sort_string;
368
369 mSpeakerList->addElement(row);
370 }
371}
372
373void LLPanelActiveSpeakers::removeSpeaker(const LLUUID& speaker_id)
374{
375 mSpeakerList->deleteSingleItem(mSpeakerList->getItemIndex(speaker_id));
376}
377
286void LLPanelActiveSpeakers::handleSpeakerSelect() 378void LLPanelActiveSpeakers::handleSpeakerSelect()
287{ 379{
288 LLUUID speaker_id = mSpeakerList->getValue().asUUID(); 380 LLUUID speaker_id = mSpeakerList->getValue().asUUID();
@@ -296,8 +388,8 @@ void LLPanelActiveSpeakers::handleSpeakerSelect()
296 childSetValue("moderator_allow_voice", selected_speakerp ? !selected_speakerp->mModeratorMutedVoice : TRUE); 388 childSetValue("moderator_allow_voice", selected_speakerp ? !selected_speakerp->mModeratorMutedVoice : TRUE);
297 childSetValue("moderator_allow_text", selected_speakerp ? !selected_speakerp->mModeratorMutedText : TRUE); 389 childSetValue("moderator_allow_text", selected_speakerp ? !selected_speakerp->mModeratorMutedText : TRUE);
298 390
299 mSpeakerListener->clearDispatchers(); 391 mSpeakerMuteListener->clearDispatchers();
300 selected_speakerp->addListener(mSpeakerListener); 392 selected_speakerp->addListener(mSpeakerMuteListener);
301 } 393 }
302} 394}
303 395
@@ -307,159 +399,131 @@ void LLPanelActiveSpeakers::refreshSpeakers()
307 LLUUID selected_id = mSpeakerList->getSelectedValue().asUUID(); 399 LLUUID selected_id = mSpeakerList->getSelectedValue().asUUID();
308 S32 scroll_pos = mSpeakerList->getScrollInterface()->getScrollPos(); 400 S32 scroll_pos = mSpeakerList->getScrollInterface()->getScrollPos();
309 401
310 BOOL sort_ascending = mSpeakerList->getSortAscending();
311 LLString sort_column = mSpeakerList->getSortColumnName();
312 // TODO: put this in xml
313 // enforces default sort column of speaker status
314 if (sort_column.empty())
315 {
316 sort_column = "speaking_status";
317 }
318
319 mSpeakerMgr->update(); 402 mSpeakerMgr->update();
320 403
321 // clear scrolling list widget of names 404 const LLString icon_image_0 = gViewerArt.getString("icn_active-speakers-dot-lvl0.tga");
322 mSpeakerList->clearRows(); 405 const LLString icon_image_1 = gViewerArt.getString("icn_active-speakers-dot-lvl1.tga");
406 const LLString icon_image_2 = gViewerArt.getString("icn_active-speakers-dot-lvl2.tga");
407
408
409 std::vector<LLScrollListItem*> items = mSpeakerList->getAllData();
410
411 LLUUID mute_icon_image = LLUUID(gViewerArt.getString("mute_icon.tga"));
323 412
324 LLSpeakerMgr::speaker_list_t speaker_list; 413 LLSpeakerMgr::speaker_list_t speaker_list;
325 mSpeakerMgr->getSpeakerList(&speaker_list, mShowTextChatters); 414 mSpeakerMgr->getSpeakerList(&speaker_list, mShowTextChatters);
326 for (LLSpeakerMgr::speaker_list_t::const_iterator speaker_it = speaker_list.begin(); speaker_it != speaker_list.end(); ++speaker_it) 415 for (std::vector<LLScrollListItem*>::iterator item_it = items.begin();
416 item_it != items.end();
417 ++item_it)
327 { 418 {
328 LLUUID speaker_id = (*speaker_it)->mID; 419 LLScrollListItem* itemp = (*item_it);
329 LLPointer<LLSpeaker> speakerp = (*speaker_it); 420 LLUUID speaker_id = itemp->getUUID();
421
422 LLPointer<LLSpeaker> speakerp = mSpeakerMgr->findSpeaker(speaker_id);
423 if (!speakerp)
424 {
425 continue;
426 }
330 427
331 // since we are forced to sort by text, encode sort order as string 428 // since we are forced to sort by text, encode sort order as string
332 LLString speaking_order_sort_string = llformat("%010d", speakerp->mSortIndex); 429 LLString speaking_order_sort_string = llformat("%010d", speakerp->mSortIndex);
333 430
334 LLSD row; 431 LLScrollListCell* icon_cell = itemp->getColumn(0);
335 row["id"] = speaker_id; 432 if (icon_cell)
433 {
336 434
337 row["columns"][0]["column"] = "icon_speaking_status"; 435 LLString icon_image_id;
338 row["columns"][0]["type"] = "icon";
339 LLString icon_image_id;
340 436
341 S32 icon_image_idx = llmin(2, llfloor((speakerp->mSpeechVolume / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f)); 437 S32 icon_image_idx = llmin(2, llfloor((speakerp->mSpeechVolume / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f));
342 switch(icon_image_idx) 438 switch(icon_image_idx)
343 {
344 case 0:
345 icon_image_id = gViewerArt.getString("icn_active-speakers-dot-lvl0.tga");
346 break;
347 case 1:
348 icon_image_id = gViewerArt.getString("icn_active-speakers-dot-lvl1.tga");
349 break;
350 case 2:
351 icon_image_id = gViewerArt.getString("icn_active-speakers-dot-lvl2.tga");
352 break;
353 }
354 //if (speakerp->mTyping)
355 //{
356 // S32 typing_anim_idx = llround(mIconAnimationTimer.getElapsedTimeF32() * TYPING_ANIMATION_FPS) % 3;
357 // switch(typing_anim_idx)
358 // {
359 // case 0:
360 // row["columns"][0]["overlay"] = LLUUID(gViewerArt.getString("icn_active-speakers-typing1.tga"));
361 // break;
362 // case 1:
363 // row["columns"][0]["overlay"] = LLUUID(gViewerArt.getString("icn_active-speakers-typing2.tga"));
364 // break;
365 // case 2:
366 // row["columns"][0]["overlay"] = LLUUID(gViewerArt.getString("icn_active-speakers-typing3.tga"));
367 // break;
368 // default:
369 // break;
370 // }
371 //}
372
373 LLColor4 icon_color;
374 if (speakerp->mStatus == LLSpeaker::STATUS_MUTED)
375 {
376 row["columns"][0]["value"] = gViewerArt.getString("mute_icon.tga");
377 if(speakerp->mModeratorMutedVoice)
378 { 439 {
379 icon_color.setVec(0.5f, 0.5f, 0.5f, 1.f); 440 case 0:
441 icon_image_id = icon_image_0;
442 break;
443 case 1:
444 icon_image_id = icon_image_1;
445 break;
446 case 2:
447 icon_image_id = icon_image_2;
448 break;
449 }
450
451 LLColor4 icon_color;
452 if (speakerp->mStatus == LLSpeaker::STATUS_MUTED)
453 {
454 icon_cell->setValue(mute_icon_image);
455 if(speakerp->mModeratorMutedVoice)
456 {
457 icon_color.setVec(0.5f, 0.5f, 0.5f, 1.f);
458 }
459 else
460 {
461 icon_color.setVec(1.f, 71.f / 255.f, 71.f / 255.f, 1.f);
462 }
380 } 463 }
381 else 464 else
382 { 465 {
383 icon_color.setVec(1.f, 71.f / 255.f, 71.f / 255.f, 1.f); 466 icon_cell->setValue(icon_image_id);
467 icon_color = speakerp->mDotColor;
468
469 if (speakerp->mStatus > LLSpeaker::STATUS_VOICE_ACTIVE) // if voice is disabled for this speaker
470 {
471 // non voice speakers have hidden icons, render as transparent
472 icon_color.setVec(0.f, 0.f, 0.f, 0.f);
473 }
384 } 474 }
385 }
386 else
387 {
388 row["columns"][0]["value"] = icon_image_id;
389 icon_color = speakerp->mDotColor;
390 475
391 if (speakerp->mStatus > LLSpeaker::STATUS_VOICE_ACTIVE) // if voice is disabled for this speaker 476 icon_cell->setColor(icon_color);
477
478 if (speakerp->mStatus > LLSpeaker::STATUS_VOICE_ACTIVE && speakerp->mStatus != LLSpeaker::STATUS_MUTED) // if voice is disabled for this speaker
392 { 479 {
393 // non voice speakers have hidden icons, render as transparent 480 // non voice speakers have hidden icons, render as transparent
394 icon_color.setVec(0.f, 0.f, 0.f, 0.f); 481 icon_cell->setColor(LLColor4::transparent);
395 } 482 }
396 } 483 }
397 484
398 row["columns"][0]["color"] = icon_color.getValue(); 485 // update name column
399 486 LLScrollListCell* name_cell = itemp->getColumn(1);
400 if (speakerp->mStatus > LLSpeaker::STATUS_VOICE_ACTIVE && speakerp->mStatus != LLSpeaker::STATUS_MUTED) // if voice is disabled for this speaker 487 if (name_cell)
401 {
402 // non voice speakers have hidden icons, render as transparent
403 row["columns"][0]["color"] = LLColor4(0.f, 0.f, 0.f, 0.f).getValue();
404 }
405 row["columns"][1]["column"] = "speaker_name";
406 row["columns"][1]["type"] = "text";
407 if (speakerp->mStatus == LLSpeaker::STATUS_NOT_IN_CHANNEL)
408 { 488 {
409 // draw inactive speakers in gray 489 if (speakerp->mStatus == LLSpeaker::STATUS_NOT_IN_CHANNEL)
410 row["columns"][1]["color"] = LLColor4::grey4.getValue(); 490 {
411 } 491 // draw inactive speakers in gray
492 name_cell->setColor(LLColor4::grey4);
493 }
412 494
413 LLString speaker_name; 495 LLString speaker_name;
414 if (speakerp->mDisplayName.empty()) 496 if (speakerp->mDisplayName.empty())
415 { 497 {
416 speaker_name = LLCacheName::getDefaultName(); 498 speaker_name = LLCacheName::getDefaultName();
417 } 499 }
418 else 500 else
419 { 501 {
420 speaker_name = speakerp->mDisplayName; 502 speaker_name = speakerp->mDisplayName;
503 }
504
505 if (speakerp->mIsModerator)
506 {
507 speaker_name += LLString(" ") + getFormattedUIString("moderator_label");
508 }
509
510 name_cell->setValue(speaker_name);
511 ((LLScrollListText*)name_cell)->setFontStyle(speakerp->mIsModerator ? LLFontGL::BOLD : LLFontGL::NORMAL);
421 } 512 }
422 513
423 if (speakerp->mIsModerator) 514 // update speaking order column
515 LLScrollListCell* speaking_status_cell = itemp->getColumn(2);
516 if (speaking_status_cell)
424 { 517 {
425 speaker_name += LLString(" ") + getFormattedUIString("moderator_label"); 518 // print speaking ordinal in a text-sorting friendly manner
519 speaking_status_cell->setValue(speaking_order_sort_string);
426 } 520 }
427 row["columns"][1]["value"] = speaker_name;
428 row["columns"][1]["font-style"] = speakerp->mIsModerator ? "BOLD" : "NORMAL";
429
430 row["columns"][2]["column"] = "speaking_status";
431 row["columns"][2]["type"] = "text";
432
433 // print speaking ordinal in a text-sorting friendly manner
434 row["columns"][2]["value"] = speaking_order_sort_string;
435
436 mSpeakerList->addElement(row);
437 } 521 }
438 522
439 //restore sort order, selection, etc 523 // we potentially modified the sort order by touching the list items
440 mSpeakerList->sortByColumn(sort_column, sort_ascending); 524 mSpeakerList->setSorted(FALSE);
441
442 // temporarily disable commit callback while restoring original selection
443 mSpeakerList->setCommitCallback(NULL);
444
445 // make sure something is selected
446 if (selected_id.isNull())
447 {
448 mSpeakerList->selectFirstItem();
449 handleSpeakerSelect();
450 }
451 else
452 {
453 // reselect original speaker but don't call handleSpeakerSelect()
454 // as that would change the moderation mute checkboxes before they
455 // have had time to get confirmation from the server
456 mSpeakerList->selectByValue(selected_id);
457 }
458
459 mSpeakerList->setCommitCallback(onSelectSpeaker);
460 525
461 LLPointer<LLSpeaker> selected_speakerp = mSpeakerMgr->findSpeaker(selected_id); 526 LLPointer<LLSpeaker> selected_speakerp = mSpeakerMgr->findSpeaker(selected_id);
462
463 527
464 if (gMuteListp) 528 if (gMuteListp)
465 { 529 {
@@ -847,6 +911,7 @@ LLPointer<LLSpeaker> LLSpeakerMgr::setSpeaker(const LLUUID& id, const LLString&
847 speakerp->mStatus = status; 911 speakerp->mStatus = status;
848 mSpeakers.insert(std::make_pair(speakerp->mID, speakerp)); 912 mSpeakers.insert(std::make_pair(speakerp->mID, speakerp));
849 mSpeakersSorted.push_back(speakerp); 913 mSpeakersSorted.push_back(speakerp);
914 fireEvent(new LLSpeakerListChangeEvent(this, speakerp->mID), "add");
850 } 915 }
851 else 916 else
852 { 917 {
@@ -974,6 +1039,8 @@ void LLSpeakerMgr::update()
974 // remove speakers that have been gone too long 1039 // remove speakers that have been gone too long
975 if (speakerp->mStatus == LLSpeaker::STATUS_NOT_IN_CHANNEL && speakerp->mActivityTimer.hasExpired()) 1040 if (speakerp->mStatus == LLSpeaker::STATUS_NOT_IN_CHANNEL && speakerp->mActivityTimer.hasExpired())
976 { 1041 {
1042 fireEvent(new LLSpeakerListChangeEvent(this, speakerp->mID), "remove");
1043
977 mSpeakers.erase(speakerp->mID); 1044 mSpeakers.erase(speakerp->mID);
978 sorted_speaker_it = mSpeakersSorted.erase(sorted_speaker_it); 1045 sorted_speaker_it = mSpeakersSorted.erase(sorted_speaker_it);
979 } 1046 }
@@ -1221,6 +1288,7 @@ void LLActiveSpeakerMgr::updateSpeakerList()
1221 // always populate from active voice channel 1288 // always populate from active voice channel
1222 if (LLVoiceChannel::getCurrentVoiceChannel() != mVoiceChannel) 1289 if (LLVoiceChannel::getCurrentVoiceChannel() != mVoiceChannel)
1223 { 1290 {
1291 fireEvent(new LLSpeakerListChangeEvent(this, LLUUID::null), "clear");
1224 mSpeakers.clear(); 1292 mSpeakers.clear();
1225 mSpeakersSorted.clear(); 1293 mSpeakersSorted.clear();
1226 mVoiceChannel = LLVoiceChannel::getCurrentVoiceChannel(); 1294 mVoiceChannel = LLVoiceChannel::getCurrentVoiceChannel();