diff options
Diffstat (limited to 'linden/indra/newview/llchatbar.cpp')
-rw-r--r-- | linden/indra/newview/llchatbar.cpp | 119 |
1 files changed, 112 insertions, 7 deletions
diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index 59aa572..1de3690 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp | |||
@@ -53,6 +53,7 @@ | |||
53 | #include "llkeyboard.h" | 53 | #include "llkeyboard.h" |
54 | #include "lllineeditor.h" | 54 | #include "lllineeditor.h" |
55 | #include "llstatusbar.h" | 55 | #include "llstatusbar.h" |
56 | #include "llspinctrl.h" | ||
56 | #include "lltextbox.h" | 57 | #include "lltextbox.h" |
57 | #include "lluiconstants.h" | 58 | #include "lluiconstants.h" |
58 | #include "llviewergesture.h" // for triggering gestures | 59 | #include "llviewergesture.h" // for triggering gestures |
@@ -78,7 +79,10 @@ LLChatBar *gChatBar = NULL; | |||
78 | 79 | ||
79 | // legacy calllback glue | 80 | // legacy calllback glue |
80 | void toggleChatHistory(void* user_data); | 81 | void toggleChatHistory(void* user_data); |
81 | void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); | 82 | //void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); |
83 | // [RLVa:KB] - Checked: 2009-07-07 (RLVa-1.0.0d) | Modified: RLVa-0.2.2a | ||
84 | void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel); | ||
85 | // [/RLVa:KB] | ||
82 | 86 | ||
83 | 87 | ||
84 | class LLChatBarGestureObserver : public LLGestureManagerObserver | 88 | class LLChatBarGestureObserver : public LLGestureManagerObserver |
@@ -98,6 +102,7 @@ private: | |||
98 | 102 | ||
99 | LLChatBar::LLChatBar() | 103 | LLChatBar::LLChatBar() |
100 | : LLPanel(LLStringUtil::null, LLRect(), BORDER_NO), | 104 | : LLPanel(LLStringUtil::null, LLRect(), BORDER_NO), |
105 | mChannelControl(FALSE), | ||
101 | mInputEditor(NULL), | 106 | mInputEditor(NULL), |
102 | mGestureLabelTimer(), | 107 | mGestureLabelTimer(), |
103 | mLastSpecialChatChannel(0), | 108 | mLastSpecialChatChannel(0), |
@@ -151,6 +156,8 @@ BOOL LLChatBar::postBuild() | |||
151 | mInputEditor->setEnableLineHistory(TRUE); | 156 | mInputEditor->setEnableLineHistory(TRUE); |
152 | } | 157 | } |
153 | 158 | ||
159 | toggleChannelControl(); | ||
160 | |||
154 | mIsBuilt = TRUE; | 161 | mIsBuilt = TRUE; |
155 | 162 | ||
156 | return TRUE; | 163 | return TRUE; |
@@ -210,6 +217,7 @@ void LLChatBar::refresh() | |||
210 | 217 | ||
211 | childSetValue("History", LLFloaterChat::instanceVisible(LLSD())); | 218 | childSetValue("History", LLFloaterChat::instanceVisible(LLSD())); |
212 | 219 | ||
220 | childSetValue("channel_control",( 1.f * ((S32)(getChild<LLSpinCtrl>("channel_control")->get()))) ); | ||
213 | childSetEnabled("Say", mInputEditor->getText().size() > 0); | 221 | childSetEnabled("Say", mInputEditor->getText().size() > 0); |
214 | childSetEnabled("Shout", mInputEditor->getText().size() > 0); | 222 | childSetEnabled("Shout", mInputEditor->getText().size() > 0); |
215 | 223 | ||
@@ -370,8 +378,11 @@ LLWString LLChatBar::stripChannelNumber(const LLWString &mesg, S32* channel) | |||
370 | } | 378 | } |
371 | else | 379 | else |
372 | { | 380 | { |
373 | // This is normal chat. | 381 | if (!mChannelControl) |
374 | *channel = 0; | 382 | { |
383 | // This is normal chat. | ||
384 | *channel = 0; | ||
385 | } | ||
375 | return mesg; | 386 | return mesg; |
376 | } | 387 | } |
377 | } | 388 | } |
@@ -387,7 +398,8 @@ void LLChatBar::sendChat( EChatType type ) | |||
387 | // store sent line in history, duplicates will get filtered | 398 | // store sent line in history, duplicates will get filtered |
388 | if (mInputEditor) mInputEditor->updateHistory(); | 399 | if (mInputEditor) mInputEditor->updateHistory(); |
389 | // Check if this is destined for another channel | 400 | // Check if this is destined for another channel |
390 | S32 channel = 0; | 401 | S32 channel = mChannelControl ? (S32)(getChild<LLSpinCtrl>("channel_control")->get()) : 0; |
402 | |||
391 | stripChannelNumber(text, &channel); | 403 | stripChannelNumber(text, &channel); |
392 | 404 | ||
393 | std::string utf8text = wstring_to_utf8str(text); | 405 | std::string utf8text = wstring_to_utf8str(text); |
@@ -425,6 +437,31 @@ void LLChatBar::sendChat( EChatType type ) | |||
425 | } | 437 | } |
426 | } | 438 | } |
427 | 439 | ||
440 | void LLChatBar::toggleChannelControl() | ||
441 | { | ||
442 | LLRect input_rect = mInputEditor->getRect(); | ||
443 | S32 chan_width = getChild<LLSpinCtrl>("channel_control")->getRect().getWidth(); | ||
444 | BOOL visible = gSavedSettings.getBOOL("ChatChannelSelect"); | ||
445 | BOOL control = getChild<LLSpinCtrl>("channel_control")->getVisible(); | ||
446 | |||
447 | if (visible && !control) | ||
448 | { | ||
449 | input_rect.setLeftTopAndSize(input_rect.mLeft+chan_width, input_rect.mTop, | ||
450 | input_rect.getWidth()-chan_width, input_rect.getHeight()); | ||
451 | } | ||
452 | else if (!visible && control) | ||
453 | { | ||
454 | input_rect.setLeftTopAndSize(input_rect.mLeft-chan_width, input_rect.mTop, | ||
455 | input_rect.getWidth()+chan_width, input_rect.getHeight()); | ||
456 | |||
457 | } | ||
458 | mInputEditor->setRect(input_rect); | ||
459 | |||
460 | childSetVisible("channel_control", visible); | ||
461 | childSetEnabled("channel_control", visible); | ||
462 | mChannelControl = visible; | ||
463 | } | ||
464 | |||
428 | 465 | ||
429 | //----------------------------------------------------------------------- | 466 | //----------------------------------------------------------------------- |
430 | // Static functions | 467 | // Static functions |
@@ -482,7 +519,10 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata ) | |||
482 | 519 | ||
483 | S32 length = raw_text.length(); | 520 | S32 length = raw_text.length(); |
484 | 521 | ||
485 | if( (length > 0) && (raw_text[0] != '/') ) // forward slash is used for escape (eg. emote) sequences | 522 | //if( (length > 0) && (raw_text[0] != '/') ) // forward slash is used for escape (eg. emote) sequences |
523 | // [RLVa:KB] - Checked: 2009-07-07 (RLVa-1.0.0d) | ||
524 | if ( (length > 0) && (raw_text[0] != '/') && (!gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT)) ) | ||
525 | // [/RLVa:KB] | ||
486 | { | 526 | { |
487 | gAgent.startTyping(); | 527 | gAgent.startTyping(); |
488 | } | 528 | } |
@@ -575,7 +615,8 @@ void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type, | |||
575 | void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) | 615 | void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) |
576 | { | 616 | { |
577 | // Look for "/20 foo" channel chats. | 617 | // Look for "/20 foo" channel chats. |
578 | S32 channel = 0; | 618 | S32 channel = mChannelControl ? (S32)(getChild<LLSpinCtrl>("channel_control")->get()) : 0; |
619 | |||
579 | LLWString out_text = stripChannelNumber(wtext, &channel); | 620 | LLWString out_text = stripChannelNumber(wtext, &channel); |
580 | std::string utf8_out_text = wstring_to_utf8str(out_text); | 621 | std::string utf8_out_text = wstring_to_utf8str(out_text); |
581 | std::string utf8_text = wstring_to_utf8str(wtext); | 622 | std::string utf8_text = wstring_to_utf8str(wtext); |
@@ -586,6 +627,21 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL | |||
586 | utf8_text = utf8str_truncate(utf8_text, MAX_STRING - 1); | 627 | utf8_text = utf8str_truncate(utf8_text, MAX_STRING - 1); |
587 | } | 628 | } |
588 | 629 | ||
630 | // [RLVa:KB] - Checked: 2009-07-07 (RLVa-1.0.0d) | Modified: RLVa-0.2.0b | ||
631 | if ( (0 == channel) && (rlv_handler_t::isEnabled()) ) | ||
632 | { | ||
633 | // Adjust the (public) chat "volume" on chat and gestures (also takes care of playing the proper animation) | ||
634 | if ( ((CHAT_TYPE_SHOUT == type) || (CHAT_TYPE_NORMAL == type)) && (gRlvHandler.hasBehaviour("chatnormal")) ) | ||
635 | type = CHAT_TYPE_WHISPER; | ||
636 | else if ( (CHAT_TYPE_SHOUT == type) && (gRlvHandler.hasBehaviour("chatshout")) ) | ||
637 | type = CHAT_TYPE_NORMAL; | ||
638 | else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour("chatwhisper")) ) | ||
639 | type = CHAT_TYPE_NORMAL; | ||
640 | |||
641 | animate &= !gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT); | ||
642 | } | ||
643 | // [/RLVa:KB] | ||
644 | |||
589 | // Don't animate for chats people can't hear (chat to scripts) | 645 | // Don't animate for chats people can't hear (chat to scripts) |
590 | if (animate && (channel == 0)) | 646 | if (animate && (channel == 0)) |
591 | { | 647 | { |
@@ -621,8 +677,57 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL | |||
621 | send_chat_from_viewer(utf8_out_text, type, channel); | 677 | send_chat_from_viewer(utf8_out_text, type, channel); |
622 | } | 678 | } |
623 | 679 | ||
624 | void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel) | 680 | // void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel) |
681 | // [RLVa:KB] - Checked: 2009-07-07 (RLVa-1.0.0d) | Modified: RLVa-0.2.2a | ||
682 | void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel) | ||
683 | // [/RLVa:KB] | ||
625 | { | 684 | { |
685 | // [RLVa:KB] - Checked: 2009-08-05 (RLVa-1.0.1e) | Modified: RLVa-1.0.1e | ||
686 | // Only process chat messages (ie not CHAT_TYPE_START, CHAT_TYPE_STOP, etc) | ||
687 | if ( (rlv_handler_t::isEnabled()) && ( (CHAT_TYPE_WHISPER == type) || (CHAT_TYPE_NORMAL == type) || (CHAT_TYPE_SHOUT == type) ) ) | ||
688 | { | ||
689 | if (0 == channel) | ||
690 | { | ||
691 | // (We already did this before, but LLChatHandler::handle() calls this directly) | ||
692 | if ( ((CHAT_TYPE_SHOUT == type) || (CHAT_TYPE_NORMAL == type)) && (gRlvHandler.hasBehaviour("chatnormal")) ) | ||
693 | type = CHAT_TYPE_WHISPER; | ||
694 | else if ( (CHAT_TYPE_SHOUT == type) && (gRlvHandler.hasBehaviour("chatshout")) ) | ||
695 | type = CHAT_TYPE_NORMAL; | ||
696 | else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour("chatwhisper")) ) | ||
697 | type = CHAT_TYPE_NORMAL; | ||
698 | |||
699 | // Redirect chat if needed | ||
700 | if ( ( (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT) || (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE)) ) && | ||
701 | (gRlvHandler.redirectChatOrEmote(utf8_out_text)) ) ) | ||
702 | { | ||
703 | return; | ||
704 | } | ||
705 | |||
706 | // Filter public chat if sendchat restricted (and filter anything that redirchat didn't redirect) | ||
707 | if ( (gRlvHandler.hasBehaviour("sendchat")) || (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT)) ) | ||
708 | gRlvHandler.filterChat(utf8_out_text, true); | ||
709 | } | ||
710 | else | ||
711 | { | ||
712 | // Don't allow chat on a non-public channel if sendchannel restricted (unless the channel is an exception) | ||
713 | if ( (gRlvHandler.hasBehaviour("sendchannel")) && (!gRlvHandler.hasBehaviour("sendchannel", llformat("%d", channel))) ) | ||
714 | return; | ||
715 | |||
716 | // Don't allow chat on debug channel if @sendchat, @redirchat or @rediremote restricted (shows as public chat on viewers) | ||
717 | if (channel >= CHAT_CHANNEL_DEBUG) | ||
718 | { | ||
719 | bool fIsEmote = rlvIsEmote(utf8_out_text); | ||
720 | if ( (gRlvHandler.hasBehaviour("sendchat")) || | ||
721 | ((!fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT))) || | ||
722 | ((fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE))) ) | ||
723 | { | ||
724 | return; | ||
725 | } | ||
726 | } | ||
727 | } | ||
728 | } | ||
729 | // [/RLVa:KB] | ||
730 | |||
626 | LLMessageSystem* msg = gMessageSystem; | 731 | LLMessageSystem* msg = gMessageSystem; |
627 | msg->newMessageFast(_PREHASH_ChatFromViewer); | 732 | msg->newMessageFast(_PREHASH_ChatFromViewer); |
628 | msg->nextBlockFast(_PREHASH_AgentData); | 733 | msg->nextBlockFast(_PREHASH_AgentData); |