diff options
author | McCabe Maxsted | 2009-10-18 17:58:27 -0700 |
---|---|---|
committer | McCabe Maxsted | 2009-10-18 17:58:27 -0700 |
commit | e4b0e7c82d670081c071d8a3da31b5ec407b8e07 (patch) | |
tree | 9410962bbb582eedbec448139e217f2714050777 /linden/indra/newview/llchatbar.cpp | |
parent | Started 1.3.0 branch (diff) | |
parent | Updated and added some Linux libs. (diff) | |
download | meta-impy-e4b0e7c82d670081c071d8a3da31b5ec407b8e07.zip meta-impy-e4b0e7c82d670081c071d8a3da31b5ec407b8e07.tar.gz meta-impy-e4b0e7c82d670081c071d8a3da31b5ec407b8e07.tar.bz2 meta-impy-e4b0e7c82d670081c071d8a3da31b5ec407b8e07.tar.xz |
Merged working branch of 1.2 into LL 1.23 merge
Diffstat (limited to 'linden/indra/newview/llchatbar.cpp')
-rw-r--r-- | linden/indra/newview/llchatbar.cpp | 121 |
1 files changed, 114 insertions, 7 deletions
diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index 41d2e08..44d1ad1 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp | |||
@@ -54,6 +54,7 @@ | |||
54 | #include "llkeyboard.h" | 54 | #include "llkeyboard.h" |
55 | #include "lllineeditor.h" | 55 | #include "lllineeditor.h" |
56 | #include "llstatusbar.h" | 56 | #include "llstatusbar.h" |
57 | #include "llspinctrl.h" | ||
57 | #include "lltextbox.h" | 58 | #include "lltextbox.h" |
58 | #include "lluiconstants.h" | 59 | #include "lluiconstants.h" |
59 | #include "llviewergesture.h" // for triggering gestures | 60 | #include "llviewergesture.h" // for triggering gestures |
@@ -79,7 +80,10 @@ LLChatBar *gChatBar = NULL; | |||
79 | 80 | ||
80 | // legacy calllback glue | 81 | // legacy calllback glue |
81 | void toggleChatHistory(void* user_data); | 82 | void toggleChatHistory(void* user_data); |
82 | void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); | 83 | //void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); |
84 | // [RLVa:KB] - Checked: 2009-07-07 (RLVa-1.0.0d) | Modified: RLVa-0.2.2a | ||
85 | void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel); | ||
86 | // [/RLVa:KB] | ||
83 | 87 | ||
84 | 88 | ||
85 | class LLChatBarGestureObserver : public LLGestureManagerObserver | 89 | class LLChatBarGestureObserver : public LLGestureManagerObserver |
@@ -99,6 +103,7 @@ private: | |||
99 | 103 | ||
100 | LLChatBar::LLChatBar() | 104 | LLChatBar::LLChatBar() |
101 | : LLPanel(LLStringUtil::null, LLRect(), BORDER_NO), | 105 | : LLPanel(LLStringUtil::null, LLRect(), BORDER_NO), |
106 | mChanCtrlEnabled(FALSE), | ||
102 | mInputEditor(NULL), | 107 | mInputEditor(NULL), |
103 | mGestureLabelTimer(), | 108 | mGestureLabelTimer(), |
104 | mLastSpecialChatChannel(0), | 109 | mLastSpecialChatChannel(0), |
@@ -153,6 +158,10 @@ BOOL LLChatBar::postBuild() | |||
153 | mInputEditor->setEnableLineHistory(TRUE); | 158 | mInputEditor->setEnableLineHistory(TRUE); |
154 | } | 159 | } |
155 | 160 | ||
161 | mChannelControl = getChild<LLSpinCtrl>("channel_control"); | ||
162 | |||
163 | toggleChannelControl(); | ||
164 | |||
156 | mIsBuilt = TRUE; | 165 | mIsBuilt = TRUE; |
157 | 166 | ||
158 | return TRUE; | 167 | return TRUE; |
@@ -212,6 +221,7 @@ void LLChatBar::refresh() | |||
212 | 221 | ||
213 | childSetValue("History", LLFloaterChat::instanceVisible(LLSD())); | 222 | childSetValue("History", LLFloaterChat::instanceVisible(LLSD())); |
214 | 223 | ||
224 | //childSetValue("channel_control",( 1.f * ((S32)(mChannelControl->get()))) ); | ||
215 | childSetEnabled("Say", mInputEditor->getText().size() > 0); | 225 | childSetEnabled("Say", mInputEditor->getText().size() > 0); |
216 | childSetEnabled("Shout", mInputEditor->getText().size() > 0); | 226 | childSetEnabled("Shout", mInputEditor->getText().size() > 0); |
217 | 227 | ||
@@ -372,8 +382,11 @@ LLWString LLChatBar::stripChannelNumber(const LLWString &mesg, S32* channel) | |||
372 | } | 382 | } |
373 | else | 383 | else |
374 | { | 384 | { |
375 | // This is normal chat. | 385 | if (!mChanCtrlEnabled) |
376 | *channel = 0; | 386 | { |
387 | // This is normal chat. | ||
388 | *channel = 0; | ||
389 | } | ||
377 | return mesg; | 390 | return mesg; |
378 | } | 391 | } |
379 | } | 392 | } |
@@ -389,7 +402,8 @@ void LLChatBar::sendChat( EChatType type ) | |||
389 | // store sent line in history, duplicates will get filtered | 402 | // store sent line in history, duplicates will get filtered |
390 | if (mInputEditor) mInputEditor->updateHistory(); | 403 | if (mInputEditor) mInputEditor->updateHistory(); |
391 | // Check if this is destined for another channel | 404 | // Check if this is destined for another channel |
392 | S32 channel = 0; | 405 | S32 channel = mChanCtrlEnabled ? (S32)(mChannelControl->get()) : 0; |
406 | |||
393 | stripChannelNumber(text, &channel); | 407 | stripChannelNumber(text, &channel); |
394 | 408 | ||
395 | std::string utf8text = wstring_to_utf8str(text); | 409 | std::string utf8text = wstring_to_utf8str(text); |
@@ -427,6 +441,31 @@ void LLChatBar::sendChat( EChatType type ) | |||
427 | } | 441 | } |
428 | } | 442 | } |
429 | 443 | ||
444 | void LLChatBar::toggleChannelControl() | ||
445 | { | ||
446 | LLRect input_rect = mInputEditor->getRect(); | ||
447 | S32 chan_width = mChannelControl->getRect().getWidth(); | ||
448 | BOOL visible = gSavedSettings.getBOOL("ChatChannelSelect"); | ||
449 | BOOL control = mChannelControl->getVisible(); | ||
450 | |||
451 | if (visible && !control) | ||
452 | { | ||
453 | input_rect.setLeftTopAndSize(input_rect.mLeft+chan_width, input_rect.mTop, | ||
454 | input_rect.getWidth()-chan_width, input_rect.getHeight()); | ||
455 | } | ||
456 | else if (!visible && control) | ||
457 | { | ||
458 | input_rect.setLeftTopAndSize(input_rect.mLeft-chan_width, input_rect.mTop, | ||
459 | input_rect.getWidth()+chan_width, input_rect.getHeight()); | ||
460 | |||
461 | } | ||
462 | mInputEditor->setRect(input_rect); | ||
463 | |||
464 | childSetVisible("channel_control", visible); | ||
465 | childSetEnabled("channel_control", visible); | ||
466 | mChanCtrlEnabled = visible; | ||
467 | } | ||
468 | |||
430 | 469 | ||
431 | //----------------------------------------------------------------------- | 470 | //----------------------------------------------------------------------- |
432 | // Static functions | 471 | // Static functions |
@@ -484,7 +523,10 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata ) | |||
484 | 523 | ||
485 | S32 length = raw_text.length(); | 524 | S32 length = raw_text.length(); |
486 | 525 | ||
487 | if( (length > 0) && (raw_text[0] != '/') ) // forward slash is used for escape (eg. emote) sequences | 526 | //if( (length > 0) && (raw_text[0] != '/') ) // forward slash is used for escape (eg. emote) sequences |
527 | // [RLVa:KB] - Checked: 2009-07-07 (RLVa-1.0.0d) | ||
528 | if ( (length > 0) && (raw_text[0] != '/') && (!gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT)) ) | ||
529 | // [/RLVa:KB] | ||
488 | { | 530 | { |
489 | gAgent.startTyping(); | 531 | gAgent.startTyping(); |
490 | } | 532 | } |
@@ -578,7 +620,8 @@ void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type, | |||
578 | void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) | 620 | void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) |
579 | { | 621 | { |
580 | // Look for "/20 foo" channel chats. | 622 | // Look for "/20 foo" channel chats. |
581 | S32 channel = 0; | 623 | S32 channel = mChanCtrlEnabled ? (S32)(mChannelControl->get()) : 0; |
624 | |||
582 | LLWString out_text = stripChannelNumber(wtext, &channel); | 625 | LLWString out_text = stripChannelNumber(wtext, &channel); |
583 | std::string utf8_out_text = wstring_to_utf8str(out_text); | 626 | std::string utf8_out_text = wstring_to_utf8str(out_text); |
584 | std::string utf8_text = wstring_to_utf8str(wtext); | 627 | std::string utf8_text = wstring_to_utf8str(wtext); |
@@ -589,6 +632,21 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL | |||
589 | utf8_text = utf8str_truncate(utf8_text, MAX_STRING - 1); | 632 | utf8_text = utf8str_truncate(utf8_text, MAX_STRING - 1); |
590 | } | 633 | } |
591 | 634 | ||
635 | // [RLVa:KB] - Checked: 2009-07-07 (RLVa-1.0.0d) | Modified: RLVa-0.2.0b | ||
636 | if ( (0 == channel) && (rlv_handler_t::isEnabled()) ) | ||
637 | { | ||
638 | // Adjust the (public) chat "volume" on chat and gestures (also takes care of playing the proper animation) | ||
639 | if ( ((CHAT_TYPE_SHOUT == type) || (CHAT_TYPE_NORMAL == type)) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATNORMAL)) ) | ||
640 | type = CHAT_TYPE_WHISPER; | ||
641 | else if ( (CHAT_TYPE_SHOUT == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATSHOUT)) ) | ||
642 | type = CHAT_TYPE_NORMAL; | ||
643 | else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATWHISPER)) ) | ||
644 | type = CHAT_TYPE_NORMAL; | ||
645 | |||
646 | animate &= !gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT); | ||
647 | } | ||
648 | // [/RLVa:KB] | ||
649 | |||
592 | // Don't animate for chats people can't hear (chat to scripts) | 650 | // Don't animate for chats people can't hear (chat to scripts) |
593 | if (animate && (channel == 0)) | 651 | if (animate && (channel == 0)) |
594 | { | 652 | { |
@@ -624,8 +682,57 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL | |||
624 | send_chat_from_viewer(utf8_out_text, type, channel); | 682 | send_chat_from_viewer(utf8_out_text, type, channel); |
625 | } | 683 | } |
626 | 684 | ||
627 | void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel) | 685 | // void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel) |
686 | // [RLVa:KB] - Checked: 2009-07-07 (RLVa-1.0.0d) | Modified: RLVa-0.2.2a | ||
687 | void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel) | ||
688 | // [/RLVa:KB] | ||
628 | { | 689 | { |
690 | // [RLVa:KB] - Checked: 2009-08-05 (RLVa-1.0.1e) | Modified: RLVa-1.0.1e | ||
691 | // Only process chat messages (ie not CHAT_TYPE_START, CHAT_TYPE_STOP, etc) | ||
692 | if ( (rlv_handler_t::isEnabled()) && ( (CHAT_TYPE_WHISPER == type) || (CHAT_TYPE_NORMAL == type) || (CHAT_TYPE_SHOUT == type) ) ) | ||
693 | { | ||
694 | if (0 == channel) | ||
695 | { | ||
696 | // (We already did this before, but LLChatHandler::handle() calls this directly) | ||
697 | if ( ((CHAT_TYPE_SHOUT == type) || (CHAT_TYPE_NORMAL == type)) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATNORMAL)) ) | ||
698 | type = CHAT_TYPE_WHISPER; | ||
699 | else if ( (CHAT_TYPE_SHOUT == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATSHOUT)) ) | ||
700 | type = CHAT_TYPE_NORMAL; | ||
701 | else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATWHISPER)) ) | ||
702 | type = CHAT_TYPE_NORMAL; | ||
703 | |||
704 | // Redirect chat if needed | ||
705 | if ( ( (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT) || (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE)) ) && | ||
706 | (gRlvHandler.redirectChatOrEmote(utf8_out_text)) ) ) | ||
707 | { | ||
708 | return; | ||
709 | } | ||
710 | |||
711 | // Filter public chat if sendchat restricted (and filter anything that redirchat didn't redirect) | ||
712 | if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT)) ) | ||
713 | gRlvHandler.filterChat(utf8_out_text, true); | ||
714 | } | ||
715 | else | ||
716 | { | ||
717 | // Don't allow chat on a non-public channel if sendchannel restricted (unless the channel is an exception) | ||
718 | if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHANNEL)) && (!gRlvHandler.isException(RLV_BHVR_SENDCHANNEL, channel)) ) | ||
719 | return; | ||
720 | |||
721 | // Don't allow chat on debug channel if @sendchat, @redirchat or @rediremote restricted (shows as public chat on viewers) | ||
722 | if (channel >= CHAT_CHANNEL_DEBUG) | ||
723 | { | ||
724 | bool fIsEmote = rlvIsEmote(utf8_out_text); | ||
725 | if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT)) || | ||
726 | ((!fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT))) || | ||
727 | ((fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE))) ) | ||
728 | { | ||
729 | return; | ||
730 | } | ||
731 | } | ||
732 | } | ||
733 | } | ||
734 | // [/RLVa:KB] | ||
735 | |||
629 | LLMessageSystem* msg = gMessageSystem; | 736 | LLMessageSystem* msg = gMessageSystem; |
630 | msg->newMessageFast(_PREHASH_ChatFromViewer); | 737 | msg->newMessageFast(_PREHASH_ChatFromViewer); |
631 | msg->nextBlockFast(_PREHASH_AgentData); | 738 | msg->nextBlockFast(_PREHASH_AgentData); |