00001
00035 #include "llviewerprecompiledheaders.h"
00036
00037 #include "llfloaterchatterbox.h"
00038 #include "lluictrlfactory.h"
00039 #include "llfloaterchat.h"
00040 #include "llfloaterfriends.h"
00041 #include "llfloatergroups.h"
00042 #include "llviewercontrol.h"
00043 #include "llimview.h"
00044 #include "llimpanel.h"
00045
00046
00047
00048
00049
00050 LLFloaterMyFriends::LLFloaterMyFriends(const LLSD& seed)
00051 {
00052 mFactoryMap["friends_panel"] = LLCallbackMap(LLFloaterMyFriends::createFriendsPanel, NULL);
00053 mFactoryMap["groups_panel"] = LLCallbackMap(LLFloaterMyFriends::createGroupsPanel, NULL);
00054
00055 BOOL no_open = FALSE;
00056 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_my_friends.xml", &getFactoryMap(), no_open);
00057 }
00058
00059 LLFloaterMyFriends::~LLFloaterMyFriends()
00060 {
00061 }
00062
00063 BOOL LLFloaterMyFriends::postBuild()
00064 {
00065 mTabs = getChild<LLTabContainer>("friends_and_groups");
00066
00067 return TRUE;
00068 }
00069
00070
00071 void LLFloaterMyFriends::onClose(bool app_quitting)
00072 {
00073 setVisible(FALSE);
00074 }
00075
00076
00077 void* LLFloaterMyFriends::createFriendsPanel(void* data)
00078 {
00079 return new LLPanelFriends();
00080 }
00081
00082
00083 void* LLFloaterMyFriends::createGroupsPanel(void* data)
00084 {
00085 return new LLPanelGroups();
00086 }
00087
00088
00089
00090
00091 LLFloaterChatterBox::LLFloaterChatterBox(const LLSD& seed) :
00092 mActiveVoiceFloater(NULL)
00093 {
00094 mAutoResize = FALSE;
00095
00096 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_chatterbox.xml", NULL, FALSE);
00097 if (gSavedSettings.getBOOL("ContactsTornOff"))
00098 {
00099 LLFloaterMyFriends* floater_contacts = LLFloaterMyFriends::getInstance(0);
00100
00101 addFloater(floater_contacts, FALSE);
00102 removeFloater(floater_contacts);
00103
00104 gFloaterView->addChild(floater_contacts);
00105 }
00106 else
00107 {
00108 addFloater(LLFloaterMyFriends::getInstance(0), TRUE);
00109 }
00110
00111 if (gSavedSettings.getBOOL("ChatHistoryTornOff"))
00112 {
00113 LLFloaterChat* floater_chat = LLFloaterChat::getInstance();
00114
00115 addFloater(floater_chat, FALSE);
00116 removeFloater(floater_chat);
00117
00118 gFloaterView->addChild(floater_chat);
00119 }
00120 else
00121 {
00122 addFloater(LLFloaterChat::getInstance(LLSD()), FALSE);
00123 }
00124 mTabContainer->lockTabs();
00125 }
00126
00127 LLFloaterChatterBox::~LLFloaterChatterBox()
00128 {
00129 }
00130
00131 BOOL LLFloaterChatterBox::handleKeyHere(KEY key, MASK mask)
00132 {
00133 if (key == 'W' && mask == MASK_CONTROL)
00134 {
00135 LLFloater* floater = getActiveFloater();
00136
00137 if (floater && floater->canClose())
00138 {
00139 if (floater->isCloseable())
00140 {
00141 floater->close();
00142 }
00143 else
00144 {
00145
00146
00147 close();
00148 }
00149 }
00150 return TRUE;
00151 }
00152
00153 return LLMultiFloater::handleKeyHere(key, mask);
00154 }
00155
00156 void LLFloaterChatterBox::draw()
00157 {
00158
00159 if (!isMinimized())
00160 {
00161 gIMMgr->clearNewIMNotification();
00162 }
00163 LLFloater* current_active_floater = getCurrentVoiceFloater();
00164
00165 if(mActiveVoiceFloater != current_active_floater)
00166 {
00167
00168 if (mActiveVoiceFloater)
00169 {
00170 mTabContainer->setTabImage(mActiveVoiceFloater, "");
00171 }
00172 }
00173
00174
00175 if (current_active_floater)
00176 {
00177 LLColor4 icon_color = LLColor4::white;
00178 LLVoiceChannel* channelp = LLVoiceChannel::getCurrentVoiceChannel();
00179 if (channelp)
00180 {
00181 if (channelp->isActive())
00182 {
00183 icon_color = LLColor4::green;
00184 }
00185 else if (channelp->getState() == LLVoiceChannel::STATE_ERROR)
00186 {
00187 icon_color = LLColor4::red;
00188 }
00189 else
00190 {
00191 icon_color = LLColor4::yellow;
00192 }
00193 }
00194 mTabContainer->setTabImage(current_active_floater, "active_voice_tab.tga", icon_color);
00195 }
00196
00197 mActiveVoiceFloater = current_active_floater;
00198
00199 LLMultiFloater::draw();
00200 }
00201
00202 void LLFloaterChatterBox::onOpen()
00203 {
00204 gSavedSettings.setBOOL("ShowCommunicate", TRUE);
00205 }
00206
00207 void LLFloaterChatterBox::onClose(bool app_quitting)
00208 {
00209 setVisible(FALSE);
00210 gSavedSettings.setBOOL("ShowCommunicate", FALSE);
00211 }
00212
00213 void LLFloaterChatterBox::setMinimized(BOOL minimized)
00214 {
00215 LLFloater::setMinimized(minimized);
00216
00217 LLFloaterChat::getInstance()->updateConsoleVisibility();
00218 }
00219
00220 void LLFloaterChatterBox::removeFloater(LLFloater* floaterp)
00221 {
00222 if (floaterp->getName() == "chat floater")
00223 {
00224
00225 mTabContainer->lockTabs(mTabContainer->getNumLockedTabs() - 1);
00226 gSavedSettings.setBOOL("ChatHistoryTornOff", TRUE);
00227 floaterp->setCanClose(TRUE);
00228 }
00229 else if (floaterp->getName() == "floater_my_friends")
00230 {
00231
00232 mTabContainer->lockTabs(mTabContainer->getNumLockedTabs() - 1);
00233 gSavedSettings.setBOOL("ContactsTornOff", TRUE);
00234 floaterp->setCanClose(TRUE);
00235 }
00236 LLMultiFloater::removeFloater(floaterp);
00237 }
00238
00239 void LLFloaterChatterBox::addFloater(LLFloater* floaterp,
00240 BOOL select_added_floater,
00241 LLTabContainer::eInsertionPoint insertion_point)
00242 {
00243 S32 num_locked_tabs = mTabContainer->getNumLockedTabs();
00244
00245
00246 if (floaterp->getHost() == this) return;
00247
00248
00249 if (floaterp->getName() == "chat floater")
00250 {
00251 mTabContainer->unlockTabs();
00252
00253 if (getChildView("floater_my_friends"))
00254 {
00255
00256 mTabContainer->selectFirstTab();
00257
00258 LLMultiFloater::addFloater(floaterp, select_added_floater, LLTabContainer::RIGHT_OF_CURRENT);
00259 }
00260 else
00261 {
00262 LLMultiFloater::addFloater(floaterp, select_added_floater, LLTabContainer::START);
00263 }
00264
00265
00266 mTabContainer->lockTabs(num_locked_tabs + 1);
00267 gSavedSettings.setBOOL("ChatHistoryTornOff", FALSE);
00268 floaterp->setCanClose(FALSE);
00269 }
00270 else if (floaterp->getName() == "floater_my_friends")
00271 {
00272 mTabContainer->unlockTabs();
00273
00274 LLMultiFloater::addFloater(floaterp, select_added_floater, LLTabContainer::START);
00275
00276 mTabContainer->lockTabs(num_locked_tabs + 1);
00277 gSavedSettings.setBOOL("ContactsTornOff", FALSE);
00278 floaterp->setCanClose(FALSE);
00279 }
00280 else
00281 {
00282 LLMultiFloater::addFloater(floaterp, select_added_floater, insertion_point);
00283 }
00284
00285
00286 if (floaterp == mActiveVoiceFloater)
00287 {
00288 mTabContainer->setTabImage(floaterp, "active_voice_tab.tga");
00289 }
00290 }
00291
00292
00293 LLFloater* LLFloaterChatterBox::getCurrentVoiceFloater()
00294 {
00295 if (!LLVoiceClient::voiceEnabled())
00296 {
00297 return NULL;
00298 }
00299 if (LLVoiceChannelProximal::getInstance() == LLVoiceChannel::getCurrentVoiceChannel())
00300 {
00301
00302 return LLFloaterChat::getInstance(LLSD());
00303 }
00304 else
00305 {
00306 LLFloaterChatterBox* floater = LLFloaterChatterBox::getInstance(LLSD());
00307
00308 for (S32 i = 0; i < floater->getFloaterCount(); i++)
00309 {
00310 LLPanel* panelp = floater->mTabContainer->getPanelByIndex(i);
00311 if (panelp->getName() == "im_floater")
00312 {
00313
00314 LLFloaterIMPanel* im_floaterp = (LLFloaterIMPanel*)panelp;
00315 if (im_floaterp->getVoiceChannel() == LLVoiceChannel::getCurrentVoiceChannel())
00316 {
00317 return im_floaterp;
00318 }
00319 }
00320 }
00321 }
00322 return NULL;
00323 }