diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llvoiceremotectrl.cpp | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/linden/indra/newview/llvoiceremotectrl.cpp b/linden/indra/newview/llvoiceremotectrl.cpp new file mode 100644 index 0000000..720eb17 --- /dev/null +++ b/linden/indra/newview/llvoiceremotectrl.cpp | |||
@@ -0,0 +1,180 @@ | |||
1 | /** | ||
2 | * @file llvoiceremotectrl.cpp | ||
3 | * @brief A remote control for voice chat | ||
4 | * | ||
5 | * Copyright (c) 2005-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * Second Life Viewer Source Code | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #include "llviewerprecompiledheaders.h" | ||
30 | |||
31 | #include "llvoiceremotectrl.h" | ||
32 | |||
33 | #include "llagent.h" | ||
34 | #include "llui.h" | ||
35 | #include "llbutton.h" | ||
36 | #include "llvieweruictrlfactory.h" | ||
37 | #include "llviewercontrol.h" | ||
38 | #include "llvoiceclient.h" | ||
39 | #include "llimpanel.h" | ||
40 | #include "llfloateractivespeakers.h" | ||
41 | #include "lliconctrl.h" | ||
42 | |||
43 | LLVoiceRemoteCtrl::LLVoiceRemoteCtrl (const LLString& name) : LLPanel(name) | ||
44 | { | ||
45 | setIsChrome(TRUE); | ||
46 | |||
47 | gUICtrlFactory->buildPanel(this, "panel_voice_remote.xml"); | ||
48 | |||
49 | mTalkBtn = LLUICtrlFactory::getButtonByName(this, "push_to_talk"); | ||
50 | mTalkBtn->setClickedCallback(onBtnTalkClicked); | ||
51 | mTalkBtn->setHeldDownCallback(onBtnTalkHeld); | ||
52 | mTalkBtn->setMouseUpCallback(onBtnTalkReleased); | ||
53 | |||
54 | mTalkLockBtn = LLUICtrlFactory::getButtonByName(this, "ptt_lock"); | ||
55 | mTalkLockBtn->setClickedCallback(onBtnLock); | ||
56 | |||
57 | mSpeakersBtn = LLUICtrlFactory::getButtonByName(this, "speakers_btn"); | ||
58 | mSpeakersBtn->setClickedCallback(onClickSpeakers); | ||
59 | |||
60 | mIsFocusRoot = TRUE; | ||
61 | } | ||
62 | |||
63 | LLVoiceRemoteCtrl::~LLVoiceRemoteCtrl() | ||
64 | { | ||
65 | } | ||
66 | |||
67 | void LLVoiceRemoteCtrl::draw() | ||
68 | { | ||
69 | BOOL voice_active = FALSE; | ||
70 | LLVoiceChannel* channelp = LLVoiceChannel::getCurrentVoiceChannel(); | ||
71 | if (channelp) | ||
72 | { | ||
73 | voice_active = channelp->isActive(); | ||
74 | } | ||
75 | |||
76 | mTalkBtn->setEnabled(voice_active); | ||
77 | mTalkLockBtn->setEnabled(voice_active); | ||
78 | |||
79 | // if (voice_active) | ||
80 | // { | ||
81 | // mTalkBtn->setToolTip(""); | ||
82 | // mTalkLockBtn->setToolTip(""); | ||
83 | // } | ||
84 | // else | ||
85 | // { | ||
86 | // mTalkBtn->setToolTip(""); | ||
87 | // mTalkLockBtn->setToolTip(""); | ||
88 | // } | ||
89 | |||
90 | // propagate ptt state to button display, | ||
91 | if (!mTalkBtn->hasMouseCapture()) | ||
92 | { | ||
93 | // not in push to talk mode, or push to talk is active means I'm talking | ||
94 | mTalkBtn->setToggleState(!gSavedSettings.getBOOL("PTTCurrentlyEnabled") || gVoiceClient->getUserPTTState()); | ||
95 | } | ||
96 | mSpeakersBtn->setToggleState(LLFloaterActiveSpeakers::instanceVisible(LLSD())); | ||
97 | mTalkLockBtn->setToggleState(!gSavedSettings.getBOOL("PTTCurrentlyEnabled")); | ||
98 | |||
99 | LLUUID talk_blip_image_id; | ||
100 | if (gVoiceClient->getIsSpeaking(gAgent.getID())) | ||
101 | { | ||
102 | F32 voice_power = gVoiceClient->getCurrentPower(gAgent.getID()); | ||
103 | |||
104 | if (voice_power > LLVoiceClient::OVERDRIVEN_POWER_LEVEL) | ||
105 | { | ||
106 | talk_blip_image_id = LLUUID(gViewerArt.getString("icn_voice_ptt-on-lvl3.tga")); | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | F32 power = gVoiceClient->getCurrentPower(gAgent.getID()); | ||
111 | S32 icon_image_idx = llmin(2, llfloor((power / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f)); | ||
112 | |||
113 | switch(icon_image_idx) | ||
114 | { | ||
115 | case 0: | ||
116 | talk_blip_image_id = LLUUID(gViewerArt.getString("icn_voice_ptt-on.tga")); | ||
117 | break; | ||
118 | case 1: | ||
119 | talk_blip_image_id = LLUUID(gViewerArt.getString("icn_voice_ptt-on-lvl1.tga")); | ||
120 | break; | ||
121 | case 2: | ||
122 | talk_blip_image_id = LLUUID(gViewerArt.getString("icn_voice_ptt-on-lvl2.tga")); | ||
123 | break; | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | talk_blip_image_id = LLUUID(gViewerArt.getString("icn_voice_ptt-off.tga")); | ||
130 | } | ||
131 | |||
132 | LLIconCtrl* icon = LLUICtrlFactory::getIconByName(this, "voice_volume"); | ||
133 | if (icon) | ||
134 | { | ||
135 | icon->setImage(talk_blip_image_id); | ||
136 | } | ||
137 | |||
138 | LLPanel::draw(); | ||
139 | } | ||
140 | |||
141 | void LLVoiceRemoteCtrl::onBtnTalkClicked(void *user_data) | ||
142 | { | ||
143 | // when in toggle mode, clicking talk button turns mic on/off | ||
144 | if (gSavedSettings.getBOOL("PushToTalkToggle")) | ||
145 | { | ||
146 | gVoiceClient->toggleUserPTTState(); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | void LLVoiceRemoteCtrl::onBtnTalkHeld(void *user_data) | ||
151 | { | ||
152 | // when not in toggle mode, holding down talk button turns on mic | ||
153 | if (!gSavedSettings.getBOOL("PushToTalkToggle")) | ||
154 | { | ||
155 | gVoiceClient->setUserPTTState(true); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | void LLVoiceRemoteCtrl::onBtnTalkReleased(void* user_data) | ||
160 | { | ||
161 | // when not in toggle mode, releasing talk button turns off mic | ||
162 | if (!gSavedSettings.getBOOL("PushToTalkToggle")) | ||
163 | { | ||
164 | gVoiceClient->setUserPTTState(false); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | void LLVoiceRemoteCtrl::onBtnLock(void* user_data) | ||
169 | { | ||
170 | LLVoiceRemoteCtrl* remotep = (LLVoiceRemoteCtrl*)user_data; | ||
171 | |||
172 | remotep->mTalkLockBtn->toggleState(); | ||
173 | gSavedSettings.setBOOL("PTTCurrentlyEnabled", !remotep->mTalkLockBtn->getToggleState()); | ||
174 | } | ||
175 | |||
176 | void LLVoiceRemoteCtrl::onClickSpeakers(void *user_data) | ||
177 | { | ||
178 | LLFloaterActiveSpeakers::toggleInstance(LLSD()); | ||
179 | } | ||
180 | |||