diff options
author | elektrahesse | 2010-09-09 18:48:15 +0200 |
---|---|---|
committer | McCabe Maxsted | 2010-09-10 19:11:30 -0700 |
commit | 0fbdd7d10de8fa253cb008504e9e8dc44ed16b29 (patch) | |
tree | bbc9e681097656d61c2b3d5368ebb6491de62421 /linden/indra/newview/llfloaterchat.cpp | |
parent | Removed Object-Object Occlusion shortcut as it interferes with the AO (diff) | |
download | meta-impy-0fbdd7d10de8fa253cb008504e9e8dc44ed16b29.zip meta-impy-0fbdd7d10de8fa253cb008504e9e8dc44ed16b29.tar.gz meta-impy-0fbdd7d10de8fa253cb008504e9e8dc44ed16b29.tar.bz2 meta-impy-0fbdd7d10de8fa253cb008504e9e8dc44ed16b29.tar.xz |
Fixed chat colors and added group im colors
Diffstat (limited to 'linden/indra/newview/llfloaterchat.cpp')
-rw-r--r-- | linden/indra/newview/llfloaterchat.cpp | 91 |
1 files changed, 62 insertions, 29 deletions
diff --git a/linden/indra/newview/llfloaterchat.cpp b/linden/indra/newview/llfloaterchat.cpp index a38684a..d7465fa 100644 --- a/linden/indra/newview/llfloaterchat.cpp +++ b/linden/indra/newview/llfloaterchat.cpp | |||
@@ -78,6 +78,8 @@ | |||
78 | #include "llstylemap.h" | 78 | #include "llstylemap.h" |
79 | #include "llviewermenu.h" | 79 | #include "llviewermenu.h" |
80 | 80 | ||
81 | #include "regex.h" | ||
82 | |||
81 | // Used for LCD display | 83 | // Used for LCD display |
82 | extern void AddNewIMToLCD(const std::string &newLine); | 84 | extern void AddNewIMToLCD(const std::string &newLine); |
83 | extern void AddNewChatToLCD(const std::string &newLine); | 85 | extern void AddNewChatToLCD(const std::string &newLine); |
@@ -383,7 +385,6 @@ void LLFloaterChat::setHistoryCursorAndScrollToEnd() | |||
383 | } | 385 | } |
384 | } | 386 | } |
385 | 387 | ||
386 | |||
387 | //static | 388 | //static |
388 | void LLFloaterChat::onClickMute(void *data) | 389 | void LLFloaterChat::onClickMute(void *data) |
389 | { | 390 | { |
@@ -452,6 +453,65 @@ void LLFloaterChat::updateSettings() | |||
452 | LLFloaterChat::getInstance(LLSD())->getChild<LLCheckBoxCtrl>("translate chat")->set(translate_chat); | 453 | LLFloaterChat::getInstance(LLSD())->getChild<LLCheckBoxCtrl>("translate chat")->set(translate_chat); |
453 | } | 454 | } |
454 | 455 | ||
456 | BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) | ||
457 | { | ||
458 | std::string my_name = gSavedSettings.getString("FirstName"); | ||
459 | |||
460 | std::transform(my_name.begin(), my_name.end(), my_name.begin(), tolower); | ||
461 | |||
462 | std::string lower_chat = std::string(text_line); | ||
463 | std::transform(lower_chat.begin(), lower_chat.end(), lower_chat.begin(), tolower); | ||
464 | |||
465 | std::string blank = " "; | ||
466 | |||
467 | // yes yes, this sucks, will move to a nicer regexp as soon as i have time to make it lol | ||
468 | if (lower_chat.find(my_name + blank) == 0 || // at the beginning of the text | ||
469 | (lower_chat.find(my_name) == 0 && lower_chat.length() == my_name.length()) || // only my name in the text | ||
470 | lower_chat.find(blank + my_name + blank) != std::string::npos || // my name in the middle of the text | ||
471 | lower_chat.rfind(blank + my_name) == lower_chat.length() - (blank + my_name).length()) // my name at the end of the text | ||
472 | { | ||
473 | return TRUE; | ||
474 | } | ||
475 | |||
476 | /* | ||
477 | regex_t compiled; | ||
478 | // ^.*([\.\?!:;\*\(\s]+)(elektra)([,\.\?!:;\*\)\s$]+).* <--- this works :) | ||
479 | std::string pre_pattern = "^.*([\\.\\?!:;\\*\\(\\s]+)("; | ||
480 | std::string post_pattern = ")([,\\.\\?!:;\\*\\)\\s$]+).*"; | ||
481 | std::string pattern_s = pre_pattern + my_name + post_pattern; | ||
482 | regcomp(&compiled, pattern_s.c_str(), REG_ICASE); | ||
483 | |||
484 | if (regexec(&compiled, text_line.c_str(), 0, NULL, 0) == 0) | ||
485 | return TRUE; | ||
486 | */ | ||
487 | return FALSE; | ||
488 | } | ||
489 | |||
490 | LLColor4 get_extended_text_color(const LLChat& chat, LLColor4 defaultColor) | ||
491 | { | ||
492 | if (gSavedSettings.getBOOL("HighlightOwnNameInChat")) | ||
493 | { | ||
494 | std::string new_line = std::string(chat.mText); | ||
495 | int name_pos = new_line.find(chat.mFromName); | ||
496 | if (name_pos == 0) | ||
497 | { | ||
498 | new_line = new_line.substr(chat.mFromName.length()); | ||
499 | if (new_line.find(": ") == 0) | ||
500 | new_line = new_line.substr(2); | ||
501 | else | ||
502 | new_line = new_line.substr(1); | ||
503 | } | ||
504 | |||
505 | if (LLFloaterChat::isOwnNameInText(new_line)) | ||
506 | return gSavedSettings.getColor4("OwnNameChatColor"); | ||
507 | } | ||
508 | |||
509 | if (gSavedSettings.getBOOL("HighlightFriendsChat") && is_agent_friend(chat.mFromID)) | ||
510 | return gSavedSettings.getColor4("FriendsChatColor"); | ||
511 | |||
512 | return defaultColor; | ||
513 | } | ||
514 | |||
455 | // Put a line of chat in all the right places | 515 | // Put a line of chat in all the right places |
456 | void LLFloaterChat::addChat(const LLChat& chat, | 516 | void LLFloaterChat::addChat(const LLChat& chat, |
457 | BOOL from_instant_message, | 517 | BOOL from_instant_message, |
@@ -565,34 +625,7 @@ LLColor4 get_text_color(const LLChat& chat) | |||
565 | } | 625 | } |
566 | else | 626 | else |
567 | { | 627 | { |
568 | if (gSavedSettings.getBOOL("HighlightOwnNameInChat")) | 628 | text_color = get_extended_text_color(chat, gSavedSettings.getColor4("AgentChatColor")); |
569 | { | ||
570 | std::string my_name = gSavedSettings.getString("FirstName"); | ||
571 | std::transform(my_name.begin(), my_name.end(), my_name.begin(), tolower); | ||
572 | |||
573 | std::string lower_chat = std::string(chat.mText); | ||
574 | std::transform(lower_chat.begin(), lower_chat.end(), lower_chat.begin(), tolower); | ||
575 | |||
576 | std::string blank = " "; | ||
577 | |||
578 | // yes yes, this sucks, will move to a nicer regexp as soon as i have time to make it lol | ||
579 | if (lower_chat.find(my_name + blank) == 0 || // at the beginning of the text | ||
580 | (lower_chat.find(my_name) == 0 && lower_chat.length() == my_name.length()) || // only my name in the text | ||
581 | lower_chat.find(blank + my_name + blank) != std::string::npos || // my name in the middle of the text | ||
582 | lower_chat.rfind(blank + my_name) == lower_chat.length() - (blank + my_name).length()) // my name at the end of the text | ||
583 | { | ||
584 | text_color = gSavedSettings.getColor4("OwnNameChatColor"); | ||
585 | break; | ||
586 | } | ||
587 | } | ||
588 | |||
589 | if (gSavedSettings.getBOOL("HighlightFriendsChat") && is_agent_friend(chat.mFromID)) | ||
590 | { | ||
591 | text_color = gSavedSettings.getColor4("FriendsChatColor"); | ||
592 | break; | ||
593 | } | ||
594 | |||
595 | text_color = gSavedSettings.getColor4("AgentChatColor"); | ||
596 | } | 629 | } |
597 | } | 630 | } |
598 | } | 631 | } |