00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "llviewerprecompiledheaders.h"
00032
00033 #include "llvoiceremotectrl.h"
00034
00035 #include "llagent.h"
00036 #include "llui.h"
00037 #include "llbutton.h"
00038 #include "lluictrlfactory.h"
00039 #include "llviewercontrol.h"
00040 #include "llvoiceclient.h"
00041 #include "llimpanel.h"
00042 #include "llfloateractivespeakers.h"
00043 #include "llfloaterchatterbox.h"
00044 #include "lliconctrl.h"
00045 #include "lloverlaybar.h"
00046 #include "lltextbox.h"
00047
00048 LLVoiceRemoteCtrl::LLVoiceRemoteCtrl (const LLString& name) : LLPanel(name)
00049 {
00050 setIsChrome(TRUE);
00051
00052 if (gSavedSettings.getBOOL("ShowVoiceChannelPopup"))
00053 {
00054 LLUICtrlFactory::getInstance()->buildPanel(this, "panel_voice_remote_expanded.xml");
00055 }
00056 else
00057 {
00058 LLUICtrlFactory::getInstance()->buildPanel(this, "panel_voice_remote.xml");
00059 }
00060
00061 setFocusRoot(TRUE);
00062 }
00063
00064 LLVoiceRemoteCtrl::~LLVoiceRemoteCtrl()
00065 {
00066 }
00067
00068 BOOL LLVoiceRemoteCtrl::postBuild()
00069 {
00070 mTalkBtn = getChild<LLButton>("push_to_talk");
00071 mTalkBtn->setClickedCallback(onBtnTalkClicked);
00072 mTalkBtn->setHeldDownCallback(onBtnTalkHeld);
00073 mTalkBtn->setMouseUpCallback(onBtnTalkReleased);
00074
00075 mTalkLockBtn = getChild<LLButton>("ptt_lock");
00076 mTalkLockBtn->setClickedCallback(onBtnLock);
00077 mTalkLockBtn->setCallbackUserData(this);
00078
00079 mSpeakersBtn = getChild<LLButton>("speakers_btn");
00080 mSpeakersBtn->setClickedCallback(onClickSpeakers);
00081 mSpeakersBtn->setCallbackUserData(this);
00082
00083 childSetAction("show_channel", onClickPopupBtn, this);
00084 childSetAction("end_call_btn", onClickEndCall, this);
00085
00086 LLTextBox* text = getChild<LLTextBox>("channel_label");
00087 if (text)
00088 {
00089 text->setUseEllipses(TRUE);
00090 }
00091
00092 childSetAction("voice_channel_bg", onClickVoiceChannel, this);
00093
00094
00095 return TRUE;
00096 }
00097
00098 void LLVoiceRemoteCtrl::draw()
00099 {
00100 BOOL voice_active = FALSE;
00101 LLVoiceChannel* channelp = LLVoiceChannel::getCurrentVoiceChannel();
00102 if (channelp)
00103 {
00104 voice_active = channelp->isActive();
00105 }
00106
00107 mTalkBtn->setEnabled(voice_active);
00108 mTalkLockBtn->setEnabled(voice_active);
00109
00110
00111 if (!mTalkBtn->hasMouseCapture())
00112 {
00113
00114 mTalkBtn->setToggleState(!gSavedSettings.getBOOL("PTTCurrentlyEnabled") || gVoiceClient->getUserPTTState());
00115 }
00116 mSpeakersBtn->setToggleState(LLFloaterActiveSpeakers::instanceVisible(LLSD()));
00117 mTalkLockBtn->setToggleState(!gSavedSettings.getBOOL("PTTCurrentlyEnabled"));
00118
00119 LLString talk_blip_image;
00120 if (gVoiceClient->getIsSpeaking(gAgent.getID()))
00121 {
00122 F32 voice_power = gVoiceClient->getCurrentPower(gAgent.getID());
00123
00124 if (voice_power > LLVoiceClient::OVERDRIVEN_POWER_LEVEL)
00125 {
00126 talk_blip_image = "icn_voice_ptt-on-lvl3.tga";
00127 }
00128 else
00129 {
00130 F32 power = gVoiceClient->getCurrentPower(gAgent.getID());
00131 S32 icon_image_idx = llmin(2, llfloor((power / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f));
00132
00133 switch(icon_image_idx)
00134 {
00135 case 0:
00136 talk_blip_image = "icn_voice_ptt-on.tga";
00137 break;
00138 case 1:
00139 talk_blip_image = "icn_voice_ptt-on-lvl1.tga";
00140 break;
00141 case 2:
00142 talk_blip_image = "icn_voice_ptt-on-lvl2.tga";
00143 break;
00144 }
00145 }
00146 }
00147 else
00148 {
00149 talk_blip_image = "icn_voice_ptt-off.tga";
00150 }
00151
00152 LLIconCtrl* icon = getChild<LLIconCtrl>("voice_volume");
00153 if (icon)
00154 {
00155 icon->setImage(talk_blip_image);
00156 }
00157
00158 LLFloater* voice_floater = LLFloaterChatterBox::getInstance()->getCurrentVoiceFloater();
00159 LLString active_channel_name;
00160 if (voice_floater)
00161 {
00162 active_channel_name = voice_floater->getShortTitle();
00163 }
00164
00165 LLVoiceChannel* current_channel = LLVoiceChannel::getCurrentVoiceChannel();
00166 childSetEnabled("end_call_btn", LLVoiceClient::voiceEnabled()
00167 && current_channel
00168 && current_channel->isActive()
00169 && current_channel != LLVoiceChannelProximal::getInstance());
00170
00171 childSetValue("channel_label", active_channel_name);
00172 childSetToolTip("voice_channel_bg", active_channel_name);
00173
00174 if (current_channel)
00175 {
00176 LLIconCtrl* voice_channel_icon = getChild<LLIconCtrl>("voice_channel_icon");
00177 if (voice_channel_icon && voice_floater)
00178 {
00179 voice_channel_icon->setImage(voice_floater->getUIString("voice_icon"));
00180 }
00181
00182 LLButton* voice_channel_bg = getChild<LLButton>("voice_channel_bg");
00183 if (voice_channel_bg)
00184 {
00185 LLColor4 bg_color;
00186 if (current_channel->isActive())
00187 {
00188 bg_color = lerp(LLColor4::green, LLColor4::white, 0.7f);
00189 }
00190 else if (current_channel->getState() == LLVoiceChannel::STATE_ERROR)
00191 {
00192 bg_color = lerp(LLColor4::red, LLColor4::white, 0.7f);
00193 }
00194 else
00195 {
00196 bg_color = lerp(LLColor4::yellow, LLColor4::white, 0.7f);
00197 }
00198 voice_channel_bg->setImageColor(bg_color);
00199 }
00200 }
00201
00202 LLButton* expand_button = getChild<LLButton>("show_channel");
00203 if (expand_button)
00204 {
00205 if (expand_button->getToggleState())
00206 {
00207 expand_button->setImageOverlay("arrow_down.tga");
00208 }
00209 else
00210 {
00211 expand_button->setImageOverlay("arrow_up.tga");
00212 }
00213 }
00214
00215 LLPanel::draw();
00216 }
00217
00218 void LLVoiceRemoteCtrl::onBtnTalkClicked(void *user_data)
00219 {
00220
00221 if (gSavedSettings.getBOOL("PushToTalkToggle"))
00222 {
00223 gVoiceClient->toggleUserPTTState();
00224 }
00225 }
00226
00227 void LLVoiceRemoteCtrl::onBtnTalkHeld(void *user_data)
00228 {
00229
00230 if (!gSavedSettings.getBOOL("PushToTalkToggle"))
00231 {
00232 gVoiceClient->setUserPTTState(true);
00233 }
00234 }
00235
00236 void LLVoiceRemoteCtrl::onBtnTalkReleased(void* user_data)
00237 {
00238
00239 if (!gSavedSettings.getBOOL("PushToTalkToggle"))
00240 {
00241 gVoiceClient->setUserPTTState(false);
00242 }
00243 }
00244
00245 void LLVoiceRemoteCtrl::onBtnLock(void* user_data)
00246 {
00247 LLVoiceRemoteCtrl* remotep = (LLVoiceRemoteCtrl*)user_data;
00248
00249 gSavedSettings.setBOOL("PTTCurrentlyEnabled", !remotep->mTalkLockBtn->getToggleState());
00250 }
00251
00252
00253 void LLVoiceRemoteCtrl::onClickPopupBtn(void* user_data)
00254 {
00255 LLVoiceRemoteCtrl* remotep = (LLVoiceRemoteCtrl*)user_data;
00256
00257 remotep->deleteAllChildren();
00258 if (gSavedSettings.getBOOL("ShowVoiceChannelPopup"))
00259 {
00260 LLUICtrlFactory::getInstance()->buildPanel(remotep, "panel_voice_remote_expanded.xml");
00261 }
00262 else
00263 {
00264 LLUICtrlFactory::getInstance()->buildPanel(remotep, "panel_voice_remote.xml");
00265 }
00266 gOverlayBar->layoutButtons();
00267 }
00268
00269
00270 void LLVoiceRemoteCtrl::onClickEndCall(void* user_data)
00271 {
00272 LLVoiceChannel* current_channel = LLVoiceChannel::getCurrentVoiceChannel();
00273
00274 if (current_channel && current_channel != LLVoiceChannelProximal::getInstance())
00275 {
00276 current_channel->deactivate();
00277 }
00278 }
00279
00280
00281 void LLVoiceRemoteCtrl::onClickSpeakers(void *user_data)
00282 {
00283 LLFloaterActiveSpeakers::toggleInstance(LLSD());
00284 }
00285
00286
00287 void LLVoiceRemoteCtrl::onClickVoiceChannel(void* user_data)
00288 {
00289 LLFloaterChatterBox::showInstance();
00290 }