lloverlaybar.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916
  1. /**
  2. * @file lloverlaybar.cpp
  3. * @brief LLOverlayBar class implementation
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. // Temporary buttons that appear at the bottom of the screen when you
  33. // are in a mode.
  34. #include "llviewerprecompiledheaders.h"
  35. #include "lloverlaybar.h"
  36. #include "llaudioengine.h"
  37. #include "llbutton.h"
  38. #include "llnotifications.h"
  39. #include "llparcel.h"
  40. #include "llrender.h"
  41. #include "lltextbox.h"
  42. #include "lluictrlfactory.h"
  43. #include "llagent.h"
  44. #include "llfloatercustomize.h"
  45. #include "llimmgr.h"
  46. #include "llmediactrl.h"
  47. #include "llmediaremotectrl.h"
  48. #include "llpanelaudiovolume.h"
  49. #include "llpathfindingmanager.h"
  50. #include "llpathfindingnavmeshstatus.h"
  51. //MK
  52. #include "mkrlinterface.h"
  53. //mk
  54. #include "llselectmgr.h"
  55. #include "hbviewerautomation.h"
  56. #include "llviewerjoystick.h"
  57. #include "llviewermedia.h"
  58. #include "llviewermenu.h" // For handle_reset_view()
  59. #include "llviewerparcelmedia.h"
  60. #include "llviewerparcelmgr.h"
  61. #include "llviewertexturelist.h"
  62. #include "llviewerwindow.h" // For gBottomPanelp
  63. #include "llvoavatarself.h"
  64. #include "llviewercontrol.h"
  65. #include "llvoiceclient.h"
  66. #include "llvoiceremotectrl.h"
  67. //
  68. // Globals
  69. //
  70. //Instance created in LLViewerWindow::initWorldUI()
  71. LLOverlayBar* gOverlayBarp = NULL;
  72. constexpr S32 MAX_BUTTON_WIDTH = 128; // Maximum buttons width
  73. // Number of media controls (parcel music + parcel media + shared media +
  74. // master volume):
  75. constexpr S32 NUM_MEDIA_CONTROLS = 4;
  76. // Do not refresh the overlay bar layout and icons visibility more than 5 times
  77. // per second to avoid wasting precious CPU cycles for nothing...).
  78. constexpr F32 OVERLAYBAR_REFRESH_INTERVAL = 0.2f;
  79. //
  80. // Functions
  81. //
  82. //static
  83. void* LLOverlayBar::createMasterRemote(void* userdata)
  84. {
  85. LLOverlayBar* self = (LLOverlayBar*)userdata;
  86. self->mMasterRemote =
  87. new LLMediaRemoteCtrl("master_volume", LLRect(),
  88. "panel_master_volume.xml",
  89. LLMediaRemoteCtrl::REMOTE_MASTER_VOLUME);
  90. return self->mMasterRemote;
  91. }
  92. //static
  93. void* LLOverlayBar::createParcelMediaRemote(void* userdata)
  94. {
  95. LLOverlayBar* self = (LLOverlayBar*)userdata;
  96. self->mParcelMediaRemote =
  97. new LLMediaRemoteCtrl("parcel_media_remote", LLRect(),
  98. "panel_media_remote.xml",
  99. LLMediaRemoteCtrl::REMOTE_PARCEL_MEDIA);
  100. return self->mParcelMediaRemote;
  101. }
  102. //static
  103. void* LLOverlayBar::createSharedMediaRemote(void* userdata)
  104. {
  105. LLOverlayBar* self = (LLOverlayBar*)userdata;
  106. self->mSharedMediaRemote =
  107. new LLMediaRemoteCtrl("shared_media_remote", LLRect(),
  108. "panel_shared_media_remote.xml",
  109. LLMediaRemoteCtrl::REMOTE_SHARED_MEDIA);
  110. return self->mSharedMediaRemote;
  111. }
  112. //static
  113. void* LLOverlayBar::createParcelMusicRemote(void* userdata)
  114. {
  115. LLOverlayBar* self = (LLOverlayBar*)userdata;
  116. self->mParcelMusicRemote =
  117. new LLMediaRemoteCtrl("parcel_music_remote", LLRect(),
  118. "panel_music_remote.xml",
  119. LLMediaRemoteCtrl::REMOTE_PARCEL_MUSIC);
  120. return self->mParcelMusicRemote;
  121. }
  122. //static
  123. void* LLOverlayBar::createVoiceRemote(void* userdata)
  124. {
  125. LLOverlayBar* self = (LLOverlayBar*)userdata;
  126. self->mVoiceRemote = new LLVoiceRemoteCtrl("voice_remote");
  127. return self->mVoiceRemote;
  128. }
  129. LLOverlayBar::LLOverlayBar(const LLRect& rect)
  130. : LLPanel("overlay_bar", rect, BORDER_NO),
  131. mMasterRemote(NULL),
  132. mParcelMusicRemote(NULL),
  133. mParcelMediaRemote(NULL),
  134. mSharedMediaRemote(NULL),
  135. mVoiceRemote(NULL),
  136. mStatusBarPad(LLCachedControl<S32>(gSavedSettings, "StatusBarPad")),
  137. mLastIMsCount(0),
  138. mCanRebakeRegion(false),
  139. mRebakeNavMeshMode(kRebakeNavMesh_Default),
  140. mNavMeshSlot(),
  141. mRegionCrossingSlot(),
  142. mAgentStateSlot(),
  143. mRebakingNotificationID(LLUUID::null),
  144. mBuilt(false),
  145. mDirty(false)
  146. {
  147. llassert_always(gOverlayBarp == NULL); // Only one instance allowed
  148. setMouseOpaque(false);
  149. setIsChrome(true);
  150. LLCallbackMap::map_t factory_map;
  151. factory_map["master_volume"] = LLCallbackMap(createMasterRemote, this);
  152. factory_map["parcel_music_remote"] =
  153. LLCallbackMap(createParcelMusicRemote, this);
  154. factory_map["parcel_media_remote"] =
  155. LLCallbackMap(createParcelMediaRemote, this);
  156. factory_map["shared_media_remote"] =
  157. LLCallbackMap(createSharedMediaRemote, this);
  158. factory_map["voice_remote"] = LLCallbackMap(createVoiceRemote, this);
  159. LLUICtrlFactory::getInstance()->buildPanel(this, "panel_overlaybar.xml",
  160. &factory_map);
  161. mBtnIMReceiced = getChild<LLButton>("IM Received");
  162. mBtnIMReceiced->setClickedCallback(onClickIMReceived, this);
  163. mIMReceivedlabel = mBtnIMReceiced->getLabelUnselected();
  164. mBtnSetNotBusy = getChild<LLButton>("Set Not Busy");
  165. mBtnSetNotBusy->setClickedCallback(onClickSetNotBusy, this);
  166. mBtnFlyCam = getChild<LLButton>("Flycam");
  167. mBtnFlyCam->setClickedCallback(onClickFlycam, this);
  168. mBtnMouseLook = getChild<LLButton>("Mouselook");
  169. mBtnMouseLook->setClickedCallback(onClickMouselook, this);
  170. mBtnStandUp = getChild<LLButton>("Stand Up");
  171. mBtnStandUp->setClickedCallback(onClickStandUp, this);
  172. mBtnPublicBaking = getChild<LLButton>("Public Baking");
  173. mBtnPublicBaking->setClickedCallback(onClickPublicBaking, this);
  174. mBtnRebakeRegion = getChild<LLButton>("Rebake Region");
  175. mBtnRebakeRegion->setClickedCallback(onClickRebakeRegion, this);
  176. mBtnLuaFunction = getChild<LLButton>("Lua function");
  177. mBtnLuaFunction->setClickedCallback(onClickLuaFunction, this);
  178. // Navmesh stuff
  179. createNavMeshStatusListenerForCurrentRegion();
  180. if (!mRegionCrossingSlot.connected())
  181. {
  182. mRegionCrossingSlot =
  183. gAgent.addRegionChangedCB(boost::bind(&LLOverlayBar::handleRegionBoundaryCrossed,
  184. this));
  185. }
  186. LLPathfindingManager* pfmgr = LLPathfindingManager::getInstance();
  187. if (!mAgentStateSlot.connected())
  188. {
  189. mAgentStateSlot =
  190. pfmgr->registerAgentStateListener(boost::bind(&LLOverlayBar::handleAgentState,
  191. this, _1));
  192. }
  193. pfmgr->requestGetAgentState();
  194. setFocusRoot(true);
  195. mBuilt = true;
  196. // Make overlay bar conform to window size
  197. setRect(rect);
  198. layoutButtons();
  199. mDirty = true;
  200. gOverlayBarp = this;
  201. }
  202. //virtual
  203. LLOverlayBar::~LLOverlayBar()
  204. {
  205. // LLView destructor cleans up children
  206. gOverlayBarp = NULL;
  207. }
  208. //virtual
  209. void LLOverlayBar::reshape(S32 width, S32 height, bool called_from_parent)
  210. {
  211. LLView::reshape(width, height, called_from_parent);
  212. if (mBuilt)
  213. {
  214. layoutButtons();
  215. }
  216. }
  217. //virtual
  218. void LLOverlayBar::setVisible(bool visible)
  219. {
  220. mDirty = visible;
  221. LLPanel::setVisible(visible);
  222. }
  223. void LLOverlayBar::layoutButtons()
  224. {
  225. S32 width = getRect().getWidth();
  226. S32 count = getChildCount();
  227. if (mVoiceRemote)
  228. {
  229. mVoiceRemoteWidth = mVoiceRemote->getRect().getWidth();
  230. }
  231. else
  232. {
  233. mVoiceRemoteWidth = 0;
  234. }
  235. if (mParcelMediaRemote)
  236. {
  237. mParcelMediaRemoteWidth = mParcelMediaRemote->getRect().getWidth();
  238. }
  239. else
  240. {
  241. mParcelMediaRemoteWidth = 0;
  242. }
  243. if (mSharedMediaRemote)
  244. {
  245. mSharedMediaRemoteWidth = mSharedMediaRemote->getRect().getWidth();
  246. }
  247. else
  248. {
  249. mSharedMediaRemoteWidth = 0;
  250. }
  251. if (mParcelMusicRemote)
  252. {
  253. mParcelMusicRemoteWidth = mParcelMusicRemote->getRect().getWidth();
  254. }
  255. else
  256. {
  257. mParcelMusicRemoteWidth = 0;
  258. }
  259. if (mMasterRemote)
  260. {
  261. mMasterRemoteWidth = mMasterRemote->getRect().getWidth();
  262. }
  263. else
  264. {
  265. mMasterRemoteWidth = 0;
  266. }
  267. // total reserved width for all media remotes
  268. constexpr S32 ENDPAD = 8;
  269. S32 remote_total_width = mParcelMediaRemoteWidth + mStatusBarPad +
  270. mSharedMediaRemoteWidth + mStatusBarPad +
  271. mParcelMusicRemoteWidth + mStatusBarPad +
  272. mVoiceRemoteWidth + mStatusBarPad +
  273. mMasterRemoteWidth + ENDPAD;
  274. // calculate button widths
  275. F32 segment_width = (F32)(width - remote_total_width) /
  276. (F32)(count - NUM_MEDIA_CONTROLS);
  277. S32 btn_width = llmin(lltrunc(segment_width - mStatusBarPad),
  278. MAX_BUTTON_WIDTH);
  279. // Evenly space all views
  280. LLRect r;
  281. S32 i = 0;
  282. for (child_list_const_iter_t child_iter = getChildList()->begin(),
  283. end = getChildList()->end();
  284. child_iter != end; ++child_iter)
  285. {
  286. LLView* view = *child_iter;
  287. r = view->getRect();
  288. r.mLeft = width - ll_round(remote_total_width +
  289. (i++ - NUM_MEDIA_CONTROLS + 1) *
  290. segment_width);
  291. r.mRight = r.mLeft + btn_width;
  292. view->setRect(r);
  293. }
  294. // Fix up remotes to have constant width because they cannot shrink
  295. S32 right = getRect().getWidth() - ENDPAD;
  296. if (mMasterRemote)
  297. {
  298. r = mMasterRemote->getRect();
  299. r.mRight = right;
  300. r.mLeft = right - mMasterRemoteWidth;
  301. right = r.mLeft - mStatusBarPad;
  302. mMasterRemote->setRect(r);
  303. }
  304. if (mParcelMusicRemote)
  305. {
  306. r = mParcelMusicRemote->getRect();
  307. r.mRight = right;
  308. r.mLeft = right - mParcelMusicRemoteWidth;
  309. right = r.mLeft - mStatusBarPad;
  310. mParcelMusicRemote->setRect(r);
  311. }
  312. if (mParcelMediaRemote)
  313. {
  314. r = mParcelMediaRemote->getRect();
  315. r.mRight = right;
  316. r.mLeft = right - mParcelMediaRemoteWidth;
  317. right = r.mLeft - mStatusBarPad;
  318. mParcelMediaRemote->setRect(r);
  319. }
  320. if (mSharedMediaRemote)
  321. {
  322. r = mSharedMediaRemote->getRect();
  323. r.mRight = right;
  324. r.mLeft = right - mSharedMediaRemoteWidth;
  325. right = r.mLeft - mStatusBarPad;
  326. mSharedMediaRemote->setRect(r);
  327. }
  328. if (mVoiceRemote)
  329. {
  330. r = mVoiceRemote->getRect();
  331. r.mRight = right;
  332. r.mLeft = right - mVoiceRemoteWidth;
  333. mVoiceRemote->setRect(r);
  334. }
  335. updateBoundingRect();
  336. }
  337. //virtual
  338. void LLOverlayBar::draw()
  339. {
  340. // Do not run all the refresh() cruft every frame: it is pointless !
  341. if (mDirty ||
  342. mUpdateTimer.getElapsedTimeF32() >= OVERLAYBAR_REFRESH_INTERVAL)
  343. {
  344. refresh();
  345. mDirty = false;
  346. mUpdateTimer.reset();
  347. }
  348. if (gBottomPanelp)
  349. {
  350. static const S32 tex_width = LLUIImage::sRoundedSquareWidth;
  351. static const S32 tex_height = LLUIImage::sRoundedSquareHeight;
  352. gGL.getTexUnit(0)->bind(LLUIImage::sRoundedSquare->getImage());
  353. // Draw rounded rect tabs behind all children
  354. LLRect r;
  355. // Focus highlights
  356. LLColor4 color = LLUI::sFloaterFocusBorderColor;
  357. gGL.color4fv(color.mV);
  358. if (gFocusMgr.childHasKeyboardFocus(gBottomPanelp))
  359. {
  360. for (child_list_const_iter_t child_iter = getChildList()->begin(),
  361. end = getChildList()->end();
  362. child_iter != end; ++child_iter)
  363. {
  364. LLView* view = *child_iter;
  365. if (view->getEnabled() && view->getVisible())
  366. {
  367. r = view->getRect();
  368. gl_segmented_rect_2d_tex(r.mLeft - mStatusBarPad / 3 - 1,
  369. r.mTop + 3,
  370. r.mRight + mStatusBarPad / 3 + 1,
  371. r.mBottom, tex_width, tex_height,
  372. 16, ROUNDED_RECT_TOP);
  373. }
  374. }
  375. }
  376. // Main tabs
  377. for (child_list_const_iter_t child_iter = getChildList()->begin(),
  378. end = getChildList()->end();
  379. child_iter != end; ++child_iter)
  380. {
  381. LLView* view = *child_iter;
  382. if (view->getEnabled() && view->getVisible())
  383. {
  384. r = view->getRect();
  385. // Draw a nice little pseudo-3D outline
  386. color = LLUI::sDefaultShadowDark;
  387. gGL.color4fv(color.mV);
  388. gl_segmented_rect_2d_tex(r.mLeft - mStatusBarPad / 3 + 1,
  389. r.mTop + 2,
  390. r.mRight + mStatusBarPad / 3,
  391. r.mBottom, tex_width, tex_height, 16,
  392. ROUNDED_RECT_TOP);
  393. color = LLUI::sDefaultHighlightLight;
  394. gGL.color4fv(color.mV);
  395. gl_segmented_rect_2d_tex(r.mLeft - mStatusBarPad / 3,
  396. r.mTop + 2,
  397. r.mRight + mStatusBarPad / 3 - 3,
  398. r.mBottom, tex_width, tex_height,
  399. 16, ROUNDED_RECT_TOP);
  400. // Here is the main background. Note that it overhangs on the
  401. // bottom so as to hide the focus highlight on the bottom
  402. // panel, thus producing the illusion that the focus highlight
  403. // continues around the tabs.
  404. color = LLUI::sFocusBackgroundColor;
  405. gGL.color4fv(color.mV);
  406. gl_segmented_rect_2d_tex(r.mLeft - mStatusBarPad / 3 + 1,
  407. r.mTop + 1,
  408. r.mRight + mStatusBarPad / 3 - 1,
  409. r.mBottom - 1, tex_width, tex_height,
  410. 16, ROUNDED_RECT_TOP);
  411. }
  412. }
  413. }
  414. // draw children on top
  415. LLPanel::draw();
  416. }
  417. //virtual
  418. void LLOverlayBar::refresh()
  419. {
  420. U32 ims_received = gIMMgrp ? gIMMgrp->getIMsReceived() : 0U;
  421. if (ims_received != mLastIMsCount)
  422. {
  423. mLastIMsCount = ims_received;
  424. std::string label = mIMReceivedlabel;
  425. if (gIMMgrp && gIMMgrp->isPrivateIMReceived())
  426. {
  427. label += llformat(" (%d*)", ims_received);
  428. }
  429. else if (ims_received > 0)
  430. {
  431. label += llformat(" (%d)", ims_received);
  432. }
  433. mBtnIMReceiced->setLabel(label);
  434. }
  435. bool visible = ims_received > 0;
  436. mBtnIMReceiced->setVisible(visible);
  437. mBtnIMReceiced->setEnabled(visible);
  438. static bool old_busy = false;
  439. static bool old_auto_reply = false;
  440. bool busy = gAgent.getBusy();
  441. bool auto_reply = gAgent.getAutoReply();
  442. if (busy != old_busy || auto_reply != old_auto_reply)
  443. {
  444. if (auto_reply)
  445. {
  446. mBtnSetNotBusy->setLabel(getString("no_auto_reply_label"));
  447. mBtnSetNotBusy->setToolTip(getString("no_auto_reply_tooltip"));
  448. }
  449. else
  450. {
  451. mBtnSetNotBusy->setLabel(getString("set_not_busy_label"));
  452. mBtnSetNotBusy->setToolTip(getString("set_not_busy_tooltip"));
  453. }
  454. old_busy = busy;
  455. old_auto_reply = auto_reply;
  456. }
  457. visible = busy || auto_reply;
  458. mBtnSetNotBusy->setVisible(visible);
  459. mBtnSetNotBusy->setEnabled(visible);
  460. visible = LLViewerJoystick::getInstance()->getOverrideCamera();
  461. mBtnFlyCam->setVisible(visible);
  462. mBtnFlyCam->setEnabled(visible);
  463. visible = gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_DOWN_INDEX) ||
  464. gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_UP_INDEX);
  465. mBtnMouseLook->setVisible(visible);
  466. mBtnMouseLook->setEnabled(visible);
  467. if (isAgentAvatarValid())
  468. {
  469. //MK
  470. if (gRLenabled && gRLInterface.mContainsUnsit)
  471. {
  472. visible = false;
  473. }
  474. else
  475. //mk
  476. {
  477. visible = gAgentAvatarp->mIsSitting;
  478. }
  479. mBtnStandUp->setVisible(visible);
  480. mBtnStandUp->setEnabled(visible);
  481. }
  482. visible = !LLFloaterCustomize::isVisible() && isAgentAvatarValid() &&
  483. gAgentAvatarp->isEditingAppearance();
  484. mBtnPublicBaking->setVisible(visible);
  485. mBtnPublicBaking->setEnabled(visible);
  486. visible = mCanRebakeRegion &&
  487. mRebakeNavMeshMode == kRebakeNavMesh_Available;
  488. mBtnRebakeRegion->setVisible(visible);
  489. mBtnRebakeRegion->setEnabled(visible);
  490. visible = !mLuaCommand.empty();
  491. mBtnLuaFunction->setVisible(visible);
  492. mBtnLuaFunction->setEnabled(visible);
  493. constexpr S32 ENDPAD = 8;
  494. S32 right = getRect().getWidth() - mMasterRemoteWidth - mStatusBarPad -
  495. ENDPAD;
  496. LLRect r;
  497. static LLCachedControl<bool> hide_master_remote(gSavedSettings,
  498. "HideMasterRemote");
  499. visible = !hide_master_remote;
  500. LLParcel* parcel = gViewerParcelMgr.getAgentParcel();
  501. if (mParcelMusicRemote)
  502. {
  503. static LLCachedControl<bool> audio_streaming_music(gSavedSettings,
  504. "EnableStreamingMusic");
  505. if (gAudiop && audio_streaming_music && parcel &&
  506. !parcel->getMusicURL().empty())
  507. {
  508. mParcelMusicRemote->setEnabled(true);
  509. r = mParcelMusicRemote->getRect();
  510. r.mRight = right;
  511. r.mLeft = right - mParcelMusicRemoteWidth;
  512. right = r.mLeft - mStatusBarPad;
  513. mParcelMusicRemote->setRect(r);
  514. mParcelMusicRemote->setVisible(true);
  515. visible = true;
  516. }
  517. else
  518. {
  519. mParcelMusicRemote->setVisible(false);
  520. mParcelMusicRemote->setEnabled(false);
  521. }
  522. }
  523. static LLCachedControl<bool> enable_streaming_media(gSavedSettings,
  524. "EnableStreamingMedia");
  525. if (mParcelMediaRemote)
  526. {
  527. if (gAudiop && enable_streaming_media && parcel &&
  528. !parcel->getMediaURL().empty())
  529. {
  530. // display remote control
  531. mParcelMediaRemote->setEnabled(true);
  532. r = mParcelMediaRemote->getRect();
  533. r.mRight = right;
  534. r.mLeft = right - mParcelMediaRemoteWidth;
  535. right = r.mLeft - mStatusBarPad;
  536. mParcelMediaRemote->setRect(r);
  537. mParcelMediaRemote->setVisible(true);
  538. visible = true;
  539. }
  540. else
  541. {
  542. mParcelMediaRemote->setVisible(false);
  543. mParcelMediaRemote->setEnabled(false);
  544. }
  545. }
  546. if (mSharedMediaRemote)
  547. {
  548. static LLCachedControl<bool> enable_shared_media(gSavedSettings,
  549. "PrimMediaMasterEnabled");
  550. if (gAudiop && enable_streaming_media && enable_shared_media &&
  551. (LLViewerMedia::isAnyMediaEnabled() ||
  552. LLViewerMedia::isAnyMediaDisabled()))
  553. {
  554. // display remote control
  555. mSharedMediaRemote->setEnabled(true);
  556. r = mSharedMediaRemote->getRect();
  557. r.mRight = right;
  558. r.mLeft = right - mSharedMediaRemoteWidth;
  559. right = r.mLeft - mStatusBarPad;
  560. mSharedMediaRemote->setRect(r);
  561. mSharedMediaRemote->setVisible(true);
  562. visible = true;
  563. }
  564. else
  565. {
  566. mSharedMediaRemote->setVisible(false);
  567. mSharedMediaRemote->setEnabled(false);
  568. }
  569. }
  570. if (mVoiceRemote)
  571. {
  572. if (LLVoiceClient::voiceEnabled())
  573. {
  574. r = mVoiceRemote->getRect();
  575. r.mRight = right;
  576. r.mLeft = right - mVoiceRemoteWidth;
  577. mVoiceRemote->setRect(r);
  578. mVoiceRemote->setVisible(true);
  579. visible = true;
  580. }
  581. else
  582. {
  583. mVoiceRemote->setVisible(false);
  584. }
  585. }
  586. mMasterRemote->setVisible(visible);
  587. mMasterRemote->setEnabled(visible);
  588. updateBoundingRect();
  589. }
  590. void LLOverlayBar::setLuaFunctionButton(const std::string& label,
  591. const std::string& command,
  592. const std::string& tooltip)
  593. {
  594. mLuaCommand = command;
  595. mBtnLuaFunction->setLabel(label);
  596. mBtnLuaFunction->setToolTip(tooltip);
  597. mDirty = true;
  598. }
  599. //static
  600. void LLOverlayBar::onClickLuaFunction(void* data)
  601. {
  602. LLOverlayBar* self = (LLOverlayBar*)data;
  603. if (self && !self->mLuaCommand.empty())
  604. {
  605. HBViewerAutomation::eval(self->mLuaCommand);
  606. self->mDirty = true;
  607. }
  608. }
  609. //static
  610. void LLOverlayBar::onClickIMReceived(void* data)
  611. {
  612. LLOverlayBar* self = (LLOverlayBar*)data;
  613. if (self && gIMMgrp)
  614. {
  615. gIMMgrp->setFloaterOpen(true);
  616. self->mDirty = true;
  617. }
  618. }
  619. //static
  620. void LLOverlayBar::onClickSetNotBusy(void* data)
  621. {
  622. LLOverlayBar* self = (LLOverlayBar*)data;
  623. if (self)
  624. {
  625. gAgent.clearBusy();
  626. gAgent.clearAutoReply();
  627. self->mDirty = true;
  628. }
  629. }
  630. //static
  631. void LLOverlayBar::onClickFlycam(void* data)
  632. {
  633. LLOverlayBar* self = (LLOverlayBar*)data;
  634. if (self)
  635. {
  636. LLViewerJoystick::getInstance()->toggleFlycam();
  637. self->mDirty = true;
  638. }
  639. }
  640. //static
  641. void LLOverlayBar::onClickResetView(void* data)
  642. {
  643. LLOverlayBar* self = (LLOverlayBar*)data;
  644. if (self)
  645. {
  646. handle_reset_view();
  647. self->mDirty = true;
  648. }
  649. }
  650. //static
  651. void LLOverlayBar::onClickMouselook(void* data)
  652. {
  653. LLOverlayBar* self = (LLOverlayBar*)data;
  654. if (self)
  655. {
  656. gAgent.changeCameraToMouselook();
  657. self->mDirty = true;
  658. }
  659. }
  660. //static
  661. void LLOverlayBar::onClickStandUp(void* data)
  662. {
  663. LLOverlayBar* self = (LLOverlayBar*)data;
  664. if (!self) return;
  665. //MK
  666. if (gRLenabled && gRLInterface.mContainsUnsit &&
  667. isAgentAvatarValid() && gAgentAvatarp->mIsSitting)
  668. {
  669. return;
  670. }
  671. //mk
  672. gSelectMgr.deselectAllForStandingUp();
  673. LL_DEBUGS("AgentSit") << "Sending agent unsit request" << LL_ENDL;
  674. gAgent.setControlFlags(AGENT_CONTROL_STAND_UP);
  675. //MK
  676. if (gRLenabled && gRLInterface.mContainsStandtp)
  677. {
  678. gRLInterface.backToLastStandingLoc();
  679. }
  680. //mk
  681. self->mDirty = true;
  682. }
  683. //static
  684. void LLOverlayBar::onClickPublicBaking(void* data)
  685. {
  686. LLOverlayBar* self = (LLOverlayBar*)data;
  687. if (!self) return;
  688. if (isAgentAvatarValid() && gAgentAvatarp->isEditingAppearance() &&
  689. !LLFloaterCustomize::isVisible())
  690. {
  691. LLVOAvatarSelf::onCustomizeEnd();
  692. }
  693. self->mDirty = true;
  694. }
  695. ///////////////////////////////////////////////////////////////////////////////
  696. // Navmesh stuff
  697. void LLOverlayBar::setRebakeMode(ERebakeNavMeshMode mode)
  698. {
  699. if (mode == kRebakeNavMesh_Available)
  700. {
  701. gNotifications.add("PathfindingRebakeNavmesh");
  702. }
  703. else if (mode == kRebakeNavMesh_RequestSent)
  704. {
  705. LLNotificationPtr n = gNotifications.add("RebakeNavmeshSent");
  706. if (n)
  707. {
  708. mRebakingNotificationID = n->getID();
  709. }
  710. }
  711. else if (mode != kRebakeNavMesh_InProgress &&
  712. mRebakingNotificationID.notNull())
  713. {
  714. LLNotificationPtr n = gNotifications.find(mRebakingNotificationID);
  715. if (n)
  716. {
  717. gNotifications.cancel(n);
  718. }
  719. mRebakingNotificationID.setNull();
  720. }
  721. mRebakeNavMeshMode = mode;
  722. mDirty = true;
  723. }
  724. void LLOverlayBar::handleAgentState(bool can_rebake_region)
  725. {
  726. LL_DEBUGS("NavMesh") << "Received agent state. Rebake region flag: "
  727. << can_rebake_region << LL_ENDL;
  728. mCanRebakeRegion = can_rebake_region;
  729. mDirty = true;
  730. }
  731. void LLOverlayBar::handleRebakeNavMeshResponse(bool status_response)
  732. {
  733. if (mRebakeNavMeshMode == kRebakeNavMesh_RequestSent)
  734. {
  735. setRebakeMode(status_response ? kRebakeNavMesh_InProgress
  736. : kRebakeNavMesh_Default);
  737. }
  738. LL_DEBUGS("NavMesh") << "Received rebake navmesh response. New rebake mode is: "
  739. << mRebakeNavMeshMode << LL_ENDL;
  740. if (!status_response)
  741. {
  742. gNotifications.add("PathfindingCannotRebakeNavmesh");
  743. }
  744. }
  745. void LLOverlayBar::handleNavMeshStatus(const LLPathfindingNavMeshStatus& statusp)
  746. {
  747. ERebakeNavMeshMode mode = kRebakeNavMesh_Default;
  748. if (statusp.isValid())
  749. {
  750. switch (statusp.getStatus())
  751. {
  752. case LLPathfindingNavMeshStatus::kPending:
  753. case LLPathfindingNavMeshStatus::kRepending:
  754. mode = kRebakeNavMesh_Available;
  755. break;
  756. case LLPathfindingNavMeshStatus::kBuilding:
  757. mode = kRebakeNavMesh_InProgress;
  758. break;
  759. case LLPathfindingNavMeshStatus::kComplete:
  760. mode = kRebakeNavMesh_NotAvailable;
  761. break;
  762. default:
  763. mode = kRebakeNavMesh_Default;
  764. llwarns << "Invalid rebake mode: " << statusp.getStatus()
  765. << llendl;
  766. llassert(false);
  767. }
  768. }
  769. setRebakeMode(mode);
  770. LL_DEBUGS("NavMesh") << "Received navmesh status. New rebake mode: "
  771. << mode << LL_ENDL;
  772. }
  773. void LLOverlayBar::handleRegionBoundaryCrossed()
  774. {
  775. createNavMeshStatusListenerForCurrentRegion();
  776. mCanRebakeRegion = false;
  777. mDirty = true;
  778. LLPathfindingManager::getInstance()->requestGetAgentState();
  779. }
  780. void LLOverlayBar::createNavMeshStatusListenerForCurrentRegion()
  781. {
  782. if (mNavMeshSlot.connected())
  783. {
  784. mNavMeshSlot.disconnect();
  785. }
  786. LLViewerRegion* region = gAgent.getRegion();
  787. if (!region) return;
  788. LLPathfindingManager* pfmgr = LLPathfindingManager::getInstance();
  789. mNavMeshSlot =
  790. pfmgr->registerNavMeshListenerForRegion(region,
  791. boost::bind(&LLOverlayBar::handleNavMeshStatus,
  792. this, _2));
  793. pfmgr->requestGetNavMeshForRegion(region, true);
  794. }
  795. //static
  796. void LLOverlayBar::onClickRebakeRegion(void* userdata)
  797. {
  798. LLOverlayBar* self = (LLOverlayBar*)userdata;
  799. if (!self) return;
  800. self->setRebakeMode(kRebakeNavMesh_RequestSent);
  801. LLPathfindingManager* pfmgr = LLPathfindingManager::getInstance();
  802. pfmgr->requestRebakeNavMesh(boost::bind(&LLOverlayBar::handleRebakeNavMeshResponse,
  803. self, _1));
  804. }
  805. ///////////////////////////////////////////////////////////////////////////////
  806. // static media helpers
  807. //static
  808. void LLOverlayBar::toggleAudioVolumeFloater(void* user_data)
  809. {
  810. LLFloaterAudioVolume::toggleInstance(LLSD());
  811. }