diff options
author | elektrahesse | 2010-09-09 18:48:15 +0200 |
---|---|---|
committer | elektrahesse | 2010-09-09 18:48:15 +0200 |
commit | af338294a706e88ddad4eb0924781c2fe68e0713 (patch) | |
tree | 40a04e58809c46e4c37305212103aa3d2849402a /linden/indra/newview | |
parent | Added a Extra tab in adv. preferences to enable/disable chat colors and to se... (diff) | |
download | meta-impy-af338294a706e88ddad4eb0924781c2fe68e0713.zip meta-impy-af338294a706e88ddad4eb0924781c2fe68e0713.tar.gz meta-impy-af338294a706e88ddad4eb0924781c2fe68e0713.tar.bz2 meta-impy-af338294a706e88ddad4eb0924781c2fe68e0713.tar.xz |
Fixed chat colors and added group im colors
Diffstat (limited to 'linden/indra/newview')
-rw-r--r-- | linden/indra/newview/app_settings/settings.xml | 11 | ||||
-rw-r--r-- | linden/indra/newview/llfloaterchat.cpp | 91 | ||||
-rw-r--r-- | linden/indra/newview/llfloaterchat.h | 2 | ||||
-rw-r--r-- | linden/indra/newview/llimview.cpp | 38 | ||||
-rw-r--r-- | linden/indra/newview/llprefsadvanced.cpp | 2 | ||||
-rw-r--r-- | linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml | 6 |
6 files changed, 117 insertions, 33 deletions
diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index 6d07ece..6b1c707 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml | |||
@@ -4,6 +4,17 @@ | |||
4 | 4 | ||
5 | <!-- Imprudence-specific settings --> | 5 | <!-- Imprudence-specific settings --> |
6 | 6 | ||
7 | <key>HighlightOwnNameInIM</key> | ||
8 | <map> | ||
9 | <key>Comment</key> | ||
10 | <string>Show GroupIM messages containing your name in a different color</string> | ||
11 | <key>Persist</key> | ||
12 | <integer>1</integer> | ||
13 | <key>Type</key> | ||
14 | <string>Boolean</string> | ||
15 | <key>Value</key> | ||
16 | <integer>1</integer> | ||
17 | </map> | ||
7 | <key>HighlightFriendsChat</key> | 18 | <key>HighlightFriendsChat</key> |
8 | <map> | 19 | <map> |
9 | <key>Comment</key> | 20 | <key>Comment</key> |
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 | } |
diff --git a/linden/indra/newview/llfloaterchat.h b/linden/indra/newview/llfloaterchat.h index f894675..5a26567 100644 --- a/linden/indra/newview/llfloaterchat.h +++ b/linden/indra/newview/llfloaterchat.h | |||
@@ -40,6 +40,7 @@ | |||
40 | 40 | ||
41 | #include "llfloater.h" | 41 | #include "llfloater.h" |
42 | #include "lllogchat.h" | 42 | #include "lllogchat.h" |
43 | |||
43 | class LLButton; | 44 | class LLButton; |
44 | class LLChat; | 45 | class LLChat; |
45 | class LLComboBox; | 46 | class LLComboBox; |
@@ -72,6 +73,7 @@ public: | |||
72 | // Add chat to console and history list. | 73 | // Add chat to console and history list. |
73 | // Color based on source, type, distance. | 74 | // Color based on source, type, distance. |
74 | static void addChat(const LLChat& chat, BOOL from_im = FALSE, BOOL local_agent = FALSE); | 75 | static void addChat(const LLChat& chat, BOOL from_im = FALSE, BOOL local_agent = FALSE); |
76 | static BOOL isOwnNameInText(const std::string &text_line); | ||
75 | 77 | ||
76 | // Add chat to history alone. | 78 | // Add chat to history alone. |
77 | static void addChatHistory(const LLChat& chat, bool log_to_file = true); | 79 | static void addChatHistory(const LLChat& chat, bool log_to_file = true); |
diff --git a/linden/indra/newview/llimview.cpp b/linden/indra/newview/llimview.cpp index e3ec5e6..b5b1df2 100644 --- a/linden/indra/newview/llimview.cpp +++ b/linden/indra/newview/llimview.cpp | |||
@@ -544,6 +544,26 @@ LLIMMgr::~LLIMMgr() | |||
544 | // Children all cleaned up by default view destructor. | 544 | // Children all cleaned up by default view destructor. |
545 | } | 545 | } |
546 | 546 | ||
547 | LLColor4 get_extended_text_color(const LLUUID session_id, const LLUUID other_partecipant_id, const std::string& msg, LLColor4 defaultColor) | ||
548 | { | ||
549 | if (gSavedSettings.getBOOL("HighlightOwnNameInIM") && (other_partecipant_id != LLUUID::null)) | ||
550 | { | ||
551 | LLDynamicArray<LLGroupData>::iterator i; | ||
552 | for (i = gAgent.mGroups.begin(); i != gAgent.mGroups.end(); i++) | ||
553 | { | ||
554 | if (i->mID == session_id) | ||
555 | { | ||
556 | if (LLFloaterChat::isOwnNameInText(msg)) | ||
557 | return gSavedSettings.getColor4("OwnNameChatColor"); | ||
558 | else | ||
559 | break; | ||
560 | } | ||
561 | } | ||
562 | } | ||
563 | |||
564 | return defaultColor; | ||
565 | } | ||
566 | |||
547 | // Add a message to a session. | 567 | // Add a message to a session. |
548 | void LLIMMgr::addMessage( | 568 | void LLIMMgr::addMessage( |
549 | const LLUUID& session_id, | 569 | const LLUUID& session_id, |
@@ -660,9 +680,21 @@ void LLIMMgr::addMessage( | |||
660 | 680 | ||
661 | // now add message to floater | 681 | // now add message to floater |
662 | bool is_from_system = target_id.isNull() || (from == SYSTEM_FROM); | 682 | bool is_from_system = target_id.isNull() || (from == SYSTEM_FROM); |
663 | const LLColor4& color = ( is_from_system ? | 683 | |
664 | gSavedSettings.getColor4("SystemChatColor") : | 684 | LLColor4 color; |
665 | gSavedSettings.getColor("IMChatColor")); | 685 | if (is_from_system) |
686 | color = gSavedSettings.getColor4("SystemChatColor"); | ||
687 | else | ||
688 | { | ||
689 | std::string new_line = std::string(msg); | ||
690 | if (new_line.find(": ") == 0) | ||
691 | new_line = new_line.substr(2); | ||
692 | else | ||
693 | new_line = new_line.substr(1); | ||
694 | |||
695 | color = get_extended_text_color(session_id, other_participant_id, msg, gSavedSettings.getColor("IMChatColor")); | ||
696 | } | ||
697 | |||
666 | if ( !link_name ) | 698 | if ( !link_name ) |
667 | { | 699 | { |
668 | floater->addHistoryLine(msg,color); // No name to prepend, so just add the message normally | 700 | floater->addHistoryLine(msg,color); // No name to prepend, so just add the message normally |
diff --git a/linden/indra/newview/llprefsadvanced.cpp b/linden/indra/newview/llprefsadvanced.cpp index 695e604..898ba2c 100644 --- a/linden/indra/newview/llprefsadvanced.cpp +++ b/linden/indra/newview/llprefsadvanced.cpp | |||
@@ -112,6 +112,7 @@ BOOL LLPrefsAdvanced::postBuild() | |||
112 | 112 | ||
113 | initHelpBtn("EmeraldHelp_SpellCheck", "EmeraldHelp_SpellCheck"); | 113 | initHelpBtn("EmeraldHelp_SpellCheck", "EmeraldHelp_SpellCheck"); |
114 | 114 | ||
115 | childSetValue("HighlightOwnNameInIM", gSavedSettings.getBOOL("HighlightOwnNameInIM")); | ||
115 | childSetValue("HighlightFriendsChat", gSavedSettings.getBOOL("HighlightFriendsChat")); | 116 | childSetValue("HighlightFriendsChat", gSavedSettings.getBOOL("HighlightFriendsChat")); |
116 | getChild<LLColorSwatchCtrl>("FriendsChatColor")->set(gSavedSettings.getColor4("FriendsChatColor")); | 117 | getChild<LLColorSwatchCtrl>("FriendsChatColor")->set(gSavedSettings.getColor4("FriendsChatColor")); |
117 | childSetValue("HighlightOwnNameInChat", gSavedSettings.getBOOL("HighlightOwnNameInChat")); | 118 | childSetValue("HighlightOwnNameInChat", gSavedSettings.getBOOL("HighlightOwnNameInChat")); |
@@ -139,6 +140,7 @@ void LLPrefsAdvanced::apply() | |||
139 | gSavedSettings.setU32("LightShareAllowed", | 140 | gSavedSettings.setU32("LightShareAllowed", |
140 | (U32)childGetValue("lightshare_combo").asInteger()); | 141 | (U32)childGetValue("lightshare_combo").asInteger()); |
141 | 142 | ||
143 | gSavedSettings.setBOOL("HighlightOwnNameInIM", childGetValue("HighlightOwnNameInIM")); | ||
142 | gSavedSettings.setBOOL("HighlightFriendsChat", childGetValue("HighlightFriendsChat")); | 144 | gSavedSettings.setBOOL("HighlightFriendsChat", childGetValue("HighlightFriendsChat")); |
143 | gSavedSettings.setColor4("FriendsChatColor", getChild<LLColorSwatchCtrl>("FriendsChatColor")->get()); | 145 | gSavedSettings.setColor4("FriendsChatColor", getChild<LLColorSwatchCtrl>("FriendsChatColor")->get()); |
144 | gSavedSettings.setBOOL("HighlightOwnNameInChat", childGetValue("HighlightOwnNameInChat")); | 146 | gSavedSettings.setBOOL("HighlightOwnNameInChat", childGetValue("HighlightOwnNameInChat")); |
diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml index 65d118d..b344d14 100644 --- a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml +++ b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml | |||
@@ -190,7 +190,11 @@ | |||
190 | label="Show chat messages containing your name in a different color" left="12" mouse_opaque="true" | 190 | label="Show chat messages containing your name in a different color" left="12" mouse_opaque="true" |
191 | name="HighlightOwnNameInChat" radio_style="false" width="217" /> | 191 | name="HighlightOwnNameInChat" radio_style="false" width="217" /> |
192 | 192 | ||
193 | <color_swatch border_color="0.45098 0.517647 0.607843 1" bottom="-180" | 193 | <check_box bottom_delta="-30" enabled="true" follows="left|top" font="SansSerifSmall" height="16" |
194 | initial_value="true" label="Show GroupIM messages containing your name in a different color" left="12" | ||
195 | mouse_opaque="true" name="HighlightOwnNameInIM" radio_style="false" width="270"/> | ||
196 | |||
197 | <color_swatch border_color="0.45098 0.517647 0.607843 1" bottom="-210" | ||
194 | can_apply_immediately="true" color="1 1 1 1" control_name="OwnNameChatColor" | 198 | can_apply_immediately="true" color="1 1 1 1" control_name="OwnNameChatColor" |
195 | enabled="true" follows="left|top" height="56" label="Own Name" left_delta="68" | 199 | enabled="true" follows="left|top" height="56" label="Own Name" left_delta="68" |
196 | mouse_opaque="true" name="OwnNameChatColor" width="54" /> | 200 | mouse_opaque="true" name="OwnNameChatColor" width="54" /> |