00001
00035 #include "llviewerprecompiledheaders.h"
00036
00037 #include "llfloaterchatterbox.h"
00038 #include "llvieweruictrlfactory.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 gUICtrlFactory->buildFloater(this, "floater_my_friends.xml", &getFactoryMap(), no_open);
00057 }
00058
00059 LLFloaterMyFriends::~LLFloaterMyFriends()
00060 {
00061 }
00062
00063 BOOL LLFloaterMyFriends::postBuild()
00064 {
00065 mTabs = LLUICtrlFactory::getTabContainerByName(this, "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 LLFloaterMyFriends* LLFloaterMyFriends::showInstance(const LLSD& id)
00078 {
00079 LLFloaterMyFriends* floaterp = LLUIInstanceMgr<LLFloaterMyFriends>::showInstance(id);
00080
00081 floaterp->mTabs->selectTab(id);
00082
00083 return floaterp;
00084 }
00085
00086
00087 void LLFloaterMyFriends::hideInstance(const LLSD& id)
00088 {
00089 if(instanceVisible(id))
00090 {
00091 LLFloaterChatterBox::hideInstance(LLSD());
00092 }
00093 }
00094
00095
00096
00097 BOOL LLFloaterMyFriends::instanceVisible(const LLSD& id)
00098 {
00099
00100 if (!findInstance(id)) return FALSE;
00101
00102 LLFloaterMyFriends* floaterp = getInstance(id);
00103 return floaterp->isInVisibleChain() && floaterp->mTabs->getCurrentPanelIndex() == id.asInteger();
00104 }
00105
00106
00107 void* LLFloaterMyFriends::createFriendsPanel(void* data)
00108 {
00109 return new LLPanelFriends();
00110 }
00111
00112
00113 void* LLFloaterMyFriends::createGroupsPanel(void* data)
00114 {
00115 return new LLPanelGroups();
00116 }
00117
00118
00119
00120
00121 LLFloaterChatterBox::LLFloaterChatterBox(const LLSD& seed) :
00122 mActiveVoiceFloater(NULL)
00123 {
00124 mAutoResize = FALSE;
00125
00126 gUICtrlFactory->buildFloater(this, "floater_chatterbox.xml", NULL, FALSE);
00127 addFloater(LLFloaterMyFriends::getInstance(0), TRUE);
00128 if (gSavedSettings.getBOOL("ChatHistoryTornOff"))
00129 {
00130 LLFloaterChat* floater_chat = LLFloaterChat::getInstance(LLSD());
00131
00132 addFloater(floater_chat, FALSE);
00133 removeFloater(floater_chat);
00134
00135 gFloaterView->addChild(floater_chat);
00136 }
00137 else
00138 {
00139 addFloater(LLFloaterChat::getInstance(LLSD()), FALSE);
00140 }
00141 mTabContainer->lockTabs();
00142 }
00143
00144 LLFloaterChatterBox::~LLFloaterChatterBox()
00145 {
00146 }
00147
00148 BOOL LLFloaterChatterBox::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
00149 {
00150 if (getEnabled()
00151 && mask == MASK_CONTROL)
00152 {
00153 if (key == 'W')
00154 {
00155 LLFloater* floater = getActiveFloater();
00156
00157 if (floater && floater->canClose())
00158 {
00159 if (floater->isCloseable())
00160 {
00161 floater->close();
00162 }
00163 else
00164 {
00165
00166
00167 close();
00168 }
00169 }
00170 return TRUE;
00171 }
00172 }
00173
00174 return LLMultiFloater::handleKeyHere(key, mask, called_from_parent);
00175 }
00176
00177 void LLFloaterChatterBox::draw()
00178 {
00179
00180 if (!isMinimized())
00181 {
00182 gIMMgr->clearNewIMNotification();
00183 }
00184 LLFloater* current_active_floater = getCurrentVoiceFloater();
00185
00186 if(mActiveVoiceFloater != current_active_floater)
00187 {
00188
00189 if (mActiveVoiceFloater)
00190 {
00191 mTabContainer->setTabImage(mActiveVoiceFloater, "");
00192 }
00193 }
00194
00195
00196 if (current_active_floater)
00197 {
00198 LLColor4 icon_color = LLColor4::white;
00199 LLVoiceChannel* channelp = LLVoiceChannel::getCurrentVoiceChannel();
00200 if (channelp)
00201 {
00202 if (channelp->isActive())
00203 {
00204 icon_color = LLColor4::green;
00205 }
00206 else if (channelp->getState() == LLVoiceChannel::STATE_ERROR)
00207 {
00208 icon_color = LLColor4::red;
00209 }
00210 else
00211 {
00212 icon_color = LLColor4::yellow;
00213 }
00214 }
00215 mTabContainer->setTabImage(current_active_floater, "active_voice_tab.tga", icon_color);
00216 }
00217
00218 mActiveVoiceFloater = current_active_floater;
00219
00220 LLFloater::draw();
00221 }
00222
00223 void LLFloaterChatterBox::onOpen()
00224 {
00225 gSavedSettings.setBOOL("ShowCommunicate", TRUE);
00226 }
00227
00228 void LLFloaterChatterBox::onClose(bool app_quitting)
00229 {
00230 setVisible(FALSE);
00231 gSavedSettings.setBOOL("ShowCommunicate", FALSE);
00232 }
00233
00234 void LLFloaterChatterBox::removeFloater(LLFloater* floaterp)
00235 {
00236 if (floaterp->getName() == "chat floater")
00237 {
00238
00239 mTabContainer->lockTabs(1);
00240 gSavedSettings.setBOOL("ChatHistoryTornOff", TRUE);
00241 floaterp->setCanClose(TRUE);
00242 }
00243 LLMultiFloater::removeFloater(floaterp);
00244 }
00245
00246 void LLFloaterChatterBox::addFloater(LLFloater* floaterp,
00247 BOOL select_added_floater,
00248 LLTabContainerCommon::eInsertionPoint insertion_point)
00249 {
00250
00251 if (floaterp->getName() == "chat floater")
00252 {
00253
00254 mTabContainer->selectFirstTab();
00255
00256
00257 LLMultiFloater::addFloater(floaterp, select_added_floater, LLTabContainer::RIGHT_OF_CURRENT);
00258
00259 mTabContainer->lockTabs(2);
00260 gSavedSettings.setBOOL("ChatHistoryTornOff", FALSE);
00261 floaterp->setCanClose(FALSE);
00262 }
00263 else
00264 {
00265 LLMultiFloater::addFloater(floaterp, select_added_floater, insertion_point);
00266 }
00267
00268
00269 if (floaterp == mActiveVoiceFloater)
00270 {
00271 mTabContainer->setTabImage(floaterp, "active_voice_tab.tga");
00272 }
00273 }
00274
00275
00276
00277 LLFloaterChatterBox* LLFloaterChatterBox::showInstance(const LLSD& seed)
00278 {
00279 LLFloaterChatterBox* floater = LLUISingleton<LLFloaterChatterBox>::showInstance(seed);
00280
00281
00282 if (seed.asBoolean())
00283 {
00284 LLFloater* floater_to_show = getCurrentVoiceFloater();
00285 if (floater_to_show)
00286 {
00287 floater_to_show->open();
00288 }
00289 else
00290 {
00291
00292 LLUISingleton<LLFloaterChatterBox>::getInstance(seed)->open();
00293 }
00294 }
00295
00296 return floater;
00297 }
00298
00299
00300 BOOL LLFloaterChatterBox::instanceVisible(const LLSD &seed)
00301 {
00302 if (seed.asBoolean())
00303 {
00304 LLFloater* floater_to_show = getCurrentVoiceFloater();
00305 if (floater_to_show)
00306 {
00307 return floater_to_show->isInVisibleChain();
00308 }
00309 }
00310
00311 return LLUISingleton<LLFloaterChatterBox>::instanceVisible(seed);
00312 }
00313
00314
00315 LLFloater* LLFloaterChatterBox::getCurrentVoiceFloater()
00316 {
00317 if (!LLVoiceClient::voiceEnabled())
00318 {
00319 return NULL;
00320 }
00321 if (LLVoiceChannelProximal::getInstance() == LLVoiceChannel::getCurrentVoiceChannel())
00322 {
00323
00324 return LLFloaterChat::getInstance(LLSD());
00325 }
00326 else
00327 {
00328 LLFloaterChatterBox* floater = LLFloaterChatterBox::getInstance(LLSD());
00329
00330 for (S32 i = 0; i < floater->getFloaterCount(); i++)
00331 {
00332 LLPanel* panelp = floater->mTabContainer->getPanelByIndex(i);
00333 if (panelp->getName() == "im_floater")
00334 {
00335
00336 LLFloaterIMPanel* im_floaterp = (LLFloaterIMPanel*)panelp;
00337 if (im_floaterp->getVoiceChannel() == LLVoiceChannel::getCurrentVoiceChannel())
00338 {
00339 return im_floaterp;
00340 }
00341 }
00342 }
00343 }
00344 return NULL;
00345 }