llstatusbar.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:18k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2. * @file llstatusbar.cpp
  3. * @brief LLStatusBar class implementation
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. * Copyright (c) 2002-2010, Linden Research, Inc.
  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://secondlifegrid.net/programs/open_source/licensing/gplv2
  14. * There are special exceptions to the terms and conditions of the GPL as
  15. * it is applied to this Source Code. View the full text of the exception
  16. * in the file doc/FLOSS-exception.txt in this software distribution, or
  17. * online at
  18. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  19. * By copying, modifying or distributing this software, you acknowledge
  20. * that you have read and understood your obligations described above,
  21. * and agree to abide by those obligations.
  22. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  23. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  24. * COMPLETENESS OR PERFORMANCE.
  25. * $/LicenseInfo$
  26. */
  27. #include "llviewerprecompiledheaders.h"
  28. #include "llstatusbar.h"
  29. // viewer includes
  30. #include "llagent.h"
  31. #include "llbutton.h"
  32. #include "llcommandhandler.h"
  33. #include "llviewercontrol.h"
  34. #include "llfloaterbuycurrency.h"
  35. #include "llfloaterlagmeter.h"
  36. #include "llpanelnearbymedia.h"
  37. #include "llpanelvolumepulldown.h"
  38. #include "llfloaterregioninfo.h"
  39. #include "llfloaterscriptdebug.h"
  40. #include "llhudicon.h"
  41. #include "llnavigationbar.h"
  42. #include "llkeyboard.h"
  43. #include "lllineeditor.h"
  44. #include "llmenugl.h"
  45. #include "llrootview.h"
  46. #include "llsd.h"
  47. #include "lltextbox.h"
  48. #include "llui.h"
  49. #include "llviewerparceloverlay.h"
  50. #include "llviewerregion.h"
  51. #include "llviewerstats.h"
  52. #include "llviewerwindow.h"
  53. #include "llframetimer.h"
  54. #include "llvoavatarself.h"
  55. #include "llresmgr.h"
  56. #include "llworld.h"
  57. #include "llstatgraph.h"
  58. #include "llviewermedia.h"
  59. #include "llviewermenu.h" // for gMenuBarView
  60. #include "llviewerparcelmgr.h"
  61. #include "llviewerthrottle.h"
  62. #include "lluictrlfactory.h"
  63. #include "lltoolmgr.h"
  64. #include "llfocusmgr.h"
  65. #include "llappviewer.h"
  66. #include "lltrans.h"
  67. // library includes
  68. #include "imageids.h"
  69. #include "llfloaterreg.h"
  70. #include "llfontgl.h"
  71. #include "llrect.h"
  72. #include "llerror.h"
  73. #include "llnotificationsutil.h"
  74. #include "llparcel.h"
  75. #include "llstring.h"
  76. #include "message.h"
  77. // system includes
  78. #include <iomanip>
  79. //
  80. // Globals
  81. //
  82. LLStatusBar *gStatusBar = NULL;
  83. S32 STATUS_BAR_HEIGHT = 26;
  84. extern S32 MENU_BAR_HEIGHT;
  85. // TODO: these values ought to be in the XML too
  86. const S32 MENU_PARCEL_SPACING = 1; // Distance from right of menu item to parcel information
  87. const S32 SIM_STAT_WIDTH = 8;
  88. const F32 SIM_WARN_FRACTION = 0.75f;
  89. const F32 SIM_FULL_FRACTION = 0.98f;
  90. const LLColor4 SIM_OK_COLOR(0.f, 1.f, 0.f, 1.f);
  91. const LLColor4 SIM_WARN_COLOR(1.f, 1.f, 0.f, 1.f);
  92. const LLColor4 SIM_FULL_COLOR(1.f, 0.f, 0.f, 1.f);
  93. const F32 ICON_TIMER_EXPIRY = 3.f; // How long the balance and health icons should flash after a change.
  94. const F32 ICON_FLASH_FREQUENCY = 2.f;
  95. const S32 TEXT_HEIGHT = 18;
  96. static void onClickHealth(void*);
  97. static void onClickScriptDebug(void*);
  98. static void onClickVolume(void*);
  99. std::vector<std::string> LLStatusBar::sDays;
  100. std::vector<std::string> LLStatusBar::sMonths;
  101. const U32 LLStatusBar::MAX_DATE_STRING_LENGTH = 2000;
  102. LLStatusBar::LLStatusBar(const LLRect& rect)
  103. : LLPanel(),
  104. mTextHealth(NULL),
  105. mTextTime(NULL),
  106. mSGBandwidth(NULL),
  107. mSGPacketLoss(NULL),
  108. mBtnVolume(NULL),
  109. mBalance(0),
  110. mHealth(100),
  111. mSquareMetersCredit(0),
  112. mSquareMetersCommitted(0)
  113. {
  114. setRect(rect);
  115. // status bar can possible overlay menus?
  116. setMouseOpaque(FALSE);
  117. // size of day of the weeks and year
  118. sDays.reserve(7);
  119. sMonths.reserve(12);
  120. mBalanceTimer = new LLFrameTimer();
  121. mHealthTimer = new LLFrameTimer();
  122. LLUICtrlFactory::getInstance()->buildPanel(this,"panel_status_bar.xml");
  123. }
  124. LLStatusBar::~LLStatusBar()
  125. {
  126. delete mBalanceTimer;
  127. mBalanceTimer = NULL;
  128. delete mHealthTimer;
  129. mHealthTimer = NULL;
  130. // LLView destructor cleans up children
  131. }
  132. //-----------------------------------------------------------------------
  133. // Overrides
  134. //-----------------------------------------------------------------------
  135. // virtual
  136. void LLStatusBar::draw()
  137. {
  138. refresh();
  139. LLPanel::draw();
  140. }
  141. BOOL LLStatusBar::handleRightMouseDown(S32 x, S32 y, MASK mask)
  142. {
  143. show_navbar_context_menu(this,x,y);
  144. return TRUE;
  145. }
  146. BOOL LLStatusBar::postBuild()
  147. {
  148. gMenuBarView->setRightMouseDownCallback(boost::bind(&show_navbar_context_menu, _1, _2, _3));
  149. // build date necessary data (must do after panel built)
  150. setupDate();
  151. mTextHealth = getChild<LLTextBox>("HealthText" );
  152. mTextTime = getChild<LLTextBox>("TimeText" );
  153. getChild<LLUICtrl>("buycurrency")->setCommitCallback( 
  154. boost::bind(&LLStatusBar::onClickBuyCurrency, this));
  155. getChild<LLUICtrl>("buyL")->setCommitCallback(
  156. boost::bind(&LLStatusBar::onClickBuyCurrency, this));
  157. mBtnVolume = getChild<LLButton>( "volume_btn" );
  158. mBtnVolume->setClickedCallback( onClickVolume, this );
  159. mBtnVolume->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterVolume, this));
  160. mMediaToggle = getChild<LLButton>("media_toggle_btn");
  161. mMediaToggle->setClickedCallback( &LLStatusBar::onClickMediaToggle, this );
  162. mMediaToggle->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterNearbyMedia, this));
  163. gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2));
  164. childSetAction("scriptout", onClickScriptDebug, this);
  165. childSetAction("health", onClickHealth, this);
  166. // Adding Net Stat Graph
  167. S32 x = getRect().getWidth() - 2;
  168. S32 y = 0;
  169. LLRect r;
  170. r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
  171. LLStatGraph::Params sgp;
  172. sgp.name("BandwidthGraph");
  173. sgp.rect(r);
  174. sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
  175. sgp.mouse_opaque(false);
  176. mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp);
  177. mSGBandwidth->setStat(&LLViewerStats::getInstance()->mKBitStat);
  178. mSGBandwidth->setUnits("Kbps");
  179. mSGBandwidth->setPrecision(0);
  180. addChild(mSGBandwidth);
  181. x -= SIM_STAT_WIDTH + 2;
  182. r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
  183. //these don't seem to like being reused
  184. LLStatGraph::Params pgp;
  185. pgp.name("PacketLossPercent");
  186. pgp.rect(r);
  187. pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
  188. pgp.mouse_opaque(false);
  189. mSGPacketLoss = LLUICtrlFactory::create<LLStatGraph>(pgp);
  190. mSGPacketLoss->setStat(&LLViewerStats::getInstance()->mPacketsLostPercentStat);
  191. mSGPacketLoss->setUnits("%");
  192. mSGPacketLoss->setMin(0.f);
  193. mSGPacketLoss->setMax(5.f);
  194. mSGPacketLoss->setThreshold(0, 0.5f);
  195. mSGPacketLoss->setThreshold(1, 1.f);
  196. mSGPacketLoss->setThreshold(2, 3.f);
  197. mSGPacketLoss->setPrecision(1);
  198. mSGPacketLoss->mPerSec = FALSE;
  199. addChild(mSGPacketLoss);
  200. childSetActionTextbox("stat_btn", onClickStatGraph);
  201. mPanelVolumePulldown = new LLPanelVolumePulldown();
  202. addChild(mPanelVolumePulldown);
  203. mPanelNearByMedia = new LLPanelNearByMedia();
  204. LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
  205. popup_holder->addChild(mPanelNearByMedia);
  206. gViewerWindow->getRootView()->addMouseDownCallback(boost::bind(&LLStatusBar::onClickScreen, this, _1, _2));
  207. mPanelNearByMedia->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
  208. mPanelNearByMedia->setVisible(FALSE);
  209. LLRect volume_pulldown_rect = mPanelVolumePulldown->getRect();
  210. LLButton* volbtn =  getChild<LLButton>( "volume_btn" );
  211. volume_pulldown_rect.setLeftTopAndSize(volbtn->getRect().mLeft -
  212.      (volume_pulldown_rect.getWidth() - volbtn->getRect().getWidth())/2,
  213.        volbtn->calcScreenRect().mBottom,
  214.        volume_pulldown_rect.getWidth(),
  215.        volume_pulldown_rect.getHeight());
  216. mPanelVolumePulldown->setShape(volume_pulldown_rect);
  217. mPanelVolumePulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
  218. mPanelVolumePulldown->setVisible(FALSE);
  219. return TRUE;
  220. }
  221. // Per-frame updates of visibility
  222. void LLStatusBar::refresh()
  223. {
  224. bool net_stats_visible = gSavedSettings.getBOOL("ShowNetStats");
  225. if (net_stats_visible)
  226. {
  227. // Adding Net Stat Meter back in
  228. F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f;
  229. mSGBandwidth->setMin(0.f);
  230. mSGBandwidth->setMax(bwtotal*1.25f);
  231. mSGBandwidth->setThreshold(0, bwtotal*0.75f);
  232. mSGBandwidth->setThreshold(1, bwtotal);
  233. mSGBandwidth->setThreshold(2, bwtotal);
  234. }
  235. // Get current UTC time, adjusted for the user's clock
  236. // being off.
  237. time_t utc_time;
  238. utc_time = time_corrected();
  239. std::string timeStr = getString("time");
  240. LLSD substitution;
  241. substitution["datetime"] = (S32) utc_time;
  242. LLStringUtil::format (timeStr, substitution);
  243. mTextTime->setText(timeStr);
  244. // set the tooltip to have the date
  245. std::string dtStr = getString("timeTooltip");
  246. LLStringUtil::format (dtStr, substitution);
  247. mTextTime->setToolTip (dtStr);
  248. LLRect r;
  249. const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge();
  250. S32 x = MENU_RIGHT + MENU_PARCEL_SPACING;
  251. S32 y = 0;
  252. // reshape menu bar to its content's width
  253. if (MENU_RIGHT != gMenuBarView->getRect().getWidth())
  254. {
  255. gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight());
  256. }
  257. LLViewerRegion *region = gAgent.getRegion();
  258. LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
  259. LLRect buttonRect;
  260. if (LLHUDIcon::iconsNearby())
  261. {
  262. childGetRect( "scriptout", buttonRect );
  263. r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
  264. childSetRect("scriptout",r);
  265. childSetVisible("scriptout", true);
  266. x += buttonRect.getWidth();
  267. }
  268. else
  269. {
  270. childSetVisible("scriptout", false);
  271. }
  272. if (gAgent.getCameraMode() == CAMERA_MODE_MOUSELOOK &&
  273. ((region && region->getAllowDamage()) || (parcel && parcel->getAllowDamage())))
  274. {
  275. // set visibility based on flashing
  276. if( mHealthTimer->hasExpired() )
  277. {
  278. childSetVisible("health", true);
  279. }
  280. else
  281. {
  282. BOOL flash = S32(mHealthTimer->getElapsedSeconds() * ICON_FLASH_FREQUENCY) & 1;
  283. childSetVisible("health", flash);
  284. }
  285. mTextHealth->setVisible(TRUE);
  286. // Health
  287. childGetRect( "health", buttonRect );
  288. r.setOriginAndSize( x, y, buttonRect.getWidth(), buttonRect.getHeight());
  289. childSetRect("health", r);
  290. x += buttonRect.getWidth();
  291. const S32 health_width = S32( LLFontGL::getFontSansSerifSmall()->getWidth(std::string("100%")) );
  292. r.set(x, y+TEXT_HEIGHT - 2, x+health_width, y);
  293. mTextHealth->setRect(r);
  294. x += health_width;
  295. }
  296. else
  297. {
  298. // invisible if region doesn't allow damage
  299. childSetVisible("health", false);
  300. mTextHealth->setVisible(FALSE);
  301. }
  302. mSGBandwidth->setVisible(net_stats_visible);
  303. mSGPacketLoss->setVisible(net_stats_visible);
  304. childSetEnabled("stat_btn", net_stats_visible);
  305. // update the master volume button state
  306. bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
  307. mBtnVolume->setToggleState(mute_audio);
  308. // Don't show media toggle if there's no media, parcel media, and no parcel audio
  309. mMediaToggle->setVisible(LLViewerMedia::hasInWorldMedia() || LLViewerMedia::hasParcelMedia() || LLViewerMedia::hasParcelAudio());
  310. // Note the "sense" of the toggle is opposite whether media is playing or not
  311. mMediaToggle->setValue(! (LLViewerMedia::isAnyMediaShowing() || 
  312.   LLViewerMedia::isParcelMediaPlaying() ||
  313.   LLViewerMedia::isParcelAudioPlaying()));
  314. }
  315. void LLStatusBar::setVisibleForMouselook(bool visible)
  316. {
  317. mTextTime->setVisible(visible);
  318. getChild<LLUICtrl>("buycurrency")->setVisible(visible);
  319. getChild<LLUICtrl>("buyL")->setVisible(visible);
  320. mSGBandwidth->setVisible(visible);
  321. mSGPacketLoss->setVisible(visible);
  322. setBackgroundVisible(visible);
  323. }
  324. void LLStatusBar::debitBalance(S32 debit)
  325. {
  326. setBalance(getBalance() - debit);
  327. }
  328. void LLStatusBar::creditBalance(S32 credit)
  329. {
  330. setBalance(getBalance() + credit);
  331. }
  332. void LLStatusBar::setBalance(S32 balance)
  333. {
  334. std::string money_str = LLResMgr::getInstance()->getMonetaryString( balance );
  335. LLButton* btn_buy_currency = getChild<LLButton>("buycurrency");
  336. LLStringUtil::format_map_t string_args;
  337. string_args["[AMT]"] = llformat("%s", money_str.c_str());
  338. std::string label_str = getString("buycurrencylabel", string_args);
  339. btn_buy_currency->setLabel(label_str);
  340. // Resize the balance button so that the label fits it, and the button expands to the left.
  341. // *TODO: LLButton should have an option where to expand.
  342. {
  343. S32 saved_right = btn_buy_currency->getRect().mRight;
  344. btn_buy_currency->autoResize();
  345. btn_buy_currency->translate(saved_right - btn_buy_currency->getRect().mRight, 0);
  346. }
  347. if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold")))
  348. {
  349. if (mBalance > balance)
  350. make_ui_sound("UISndMoneyChangeDown");
  351. else
  352. make_ui_sound("UISndMoneyChangeUp");
  353. }
  354. if( balance != mBalance )
  355. {
  356. mBalanceTimer->reset();
  357. mBalanceTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
  358. mBalance = balance;
  359. }
  360. }
  361. // static
  362. void LLStatusBar::sendMoneyBalanceRequest()
  363. {
  364. LLMessageSystem* msg = gMessageSystem;
  365. msg->newMessageFast(_PREHASH_MoneyBalanceRequest);
  366. msg->nextBlockFast(_PREHASH_AgentData);
  367. msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
  368. msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
  369. msg->nextBlockFast(_PREHASH_MoneyData);
  370. msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null );
  371. gAgent.sendReliableMessage();
  372. }
  373. void LLStatusBar::setHealth(S32 health)
  374. {
  375. //llinfos << "Setting health to: " << buffer << llendl;
  376. mTextHealth->setText(llformat("%d%%", health));
  377. if( mHealth > health )
  378. {
  379. if (mHealth > (health + gSavedSettings.getF32("UISndHealthReductionThreshold")))
  380. {
  381. LLVOAvatar *me;
  382. if ((me = gAgent.getAvatarObject()))
  383. {
  384. if (me->getSex() == SEX_FEMALE)
  385. {
  386. make_ui_sound("UISndHealthReductionF");
  387. }
  388. else
  389. {
  390. make_ui_sound("UISndHealthReductionM");
  391. }
  392. }
  393. }
  394. mHealthTimer->reset();
  395. mHealthTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
  396. }
  397. mHealth = health;
  398. }
  399. S32 LLStatusBar::getBalance() const
  400. {
  401. return mBalance;
  402. }
  403. S32 LLStatusBar::getHealth() const
  404. {
  405. return mHealth;
  406. }
  407. void LLStatusBar::setLandCredit(S32 credit)
  408. {
  409. mSquareMetersCredit = credit;
  410. }
  411. void LLStatusBar::setLandCommitted(S32 committed)
  412. {
  413. mSquareMetersCommitted = committed;
  414. }
  415. BOOL LLStatusBar::isUserTiered() const
  416. {
  417. return (mSquareMetersCredit > 0);
  418. }
  419. S32 LLStatusBar::getSquareMetersCredit() const
  420. {
  421. return mSquareMetersCredit;
  422. }
  423. S32 LLStatusBar::getSquareMetersCommitted() const
  424. {
  425. return mSquareMetersCommitted;
  426. }
  427. S32 LLStatusBar::getSquareMetersLeft() const
  428. {
  429. return mSquareMetersCredit - mSquareMetersCommitted;
  430. }
  431. void LLStatusBar::onClickBuyCurrency()
  432. {
  433. LLFloaterBuyCurrency::buyCurrency();
  434. }
  435. static void onClickHealth(void* )
  436. {
  437. LLNotificationsUtil::add("NotSafe");
  438. }
  439. static void onClickScriptDebug(void*)
  440. {
  441. LLFloaterScriptDebug::show(LLUUID::null);
  442. }
  443. void LLStatusBar::onMouseEnterVolume()
  444. {
  445. // show the master volume pull-down
  446. mPanelVolumePulldown->setVisible(TRUE);
  447. }
  448. void LLStatusBar::onMouseEnterNearbyMedia()
  449. {
  450. LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
  451. LLRect nearby_media_rect = mPanelNearByMedia->getRect();
  452. LLButton* nearby_media_btn =  getChild<LLButton>( "media_toggle_btn" );
  453. LLRect nearby_media_btn_rect = nearby_media_btn->calcScreenRect();
  454. nearby_media_rect.setLeftTopAndSize(nearby_media_btn_rect.mLeft - 
  455. (nearby_media_rect.getWidth() - nearby_media_btn_rect.getWidth())/2,
  456. nearby_media_btn_rect.mBottom,
  457. nearby_media_rect.getWidth(),
  458. nearby_media_rect.getHeight());
  459. // force onscreen
  460. nearby_media_rect.translate(popup_holder->getRect().getWidth() - nearby_media_rect.mRight, 0);
  461. // show the master volume pull-down
  462. mPanelNearByMedia->setShape(nearby_media_rect);
  463. mPanelNearByMedia->setVisible(TRUE);
  464. }
  465. static void onClickVolume(void* data)
  466. {
  467. // toggle the master mute setting
  468. bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
  469. LLAppViewer::instance()->setMasterSystemAudioMute(!mute_audio);
  470. }
  471. //static 
  472. void LLStatusBar::onClickMediaToggle(void* data)
  473. {
  474. LLStatusBar *status_bar = (LLStatusBar*)data;
  475. // "Selected" means it was showing the "play" icon (so media was playing), and now it shows "pause", so turn off media
  476. bool enable = ! status_bar->mMediaToggle->getValue();
  477. LLViewerMedia::setAllMediaEnabled(enable);
  478. }
  479. // sets the static variables necessary for the date
  480. void LLStatusBar::setupDate()
  481. {
  482. // fill the day array with what's in the xui
  483. std::string day_list = getString("StatBarDaysOfWeek");
  484. size_t length = day_list.size();
  485. // quick input check
  486. if(length < MAX_DATE_STRING_LENGTH)
  487. {
  488. // tokenize it and put it in the array
  489. std::string cur_word;
  490. for(size_t i = 0; i < length; ++i)
  491. {
  492. if(day_list[i] == ':')
  493. {
  494. sDays.push_back(cur_word);
  495. cur_word.clear();
  496. }
  497. else
  498. {
  499. cur_word.append(1, day_list[i]);
  500. }
  501. }
  502. sDays.push_back(cur_word);
  503. }
  504. // fill the day array with what's in the xui
  505. std::string month_list = getString( "StatBarMonthsOfYear" );
  506. length = month_list.size();
  507. // quick input check
  508. if(length < MAX_DATE_STRING_LENGTH)
  509. {
  510. // tokenize it and put it in the array
  511. std::string cur_word;
  512. for(size_t i = 0; i < length; ++i)
  513. {
  514. if(month_list[i] == ':')
  515. {
  516. sMonths.push_back(cur_word);
  517. cur_word.clear();
  518. }
  519. else
  520. {
  521. cur_word.append(1, month_list[i]);
  522. }
  523. }
  524. sMonths.push_back(cur_word);
  525. }
  526. // make sure we have at least 7 days and 12 months
  527. if(sDays.size() < 7)
  528. {
  529. sDays.resize(7);
  530. }
  531. if(sMonths.size() < 12)
  532. {
  533. sMonths.resize(12);
  534. }
  535. }
  536. // static
  537. void LLStatusBar::onClickStatGraph(void* data)
  538. {
  539. LLFloaterReg::showInstance("lagmeter");
  540. }
  541. void LLStatusBar::onClickScreen(S32 x, S32 y)
  542. {
  543. if (mPanelNearByMedia->getVisible())
  544. {
  545. LLRect screen_rect = mPanelNearByMedia->calcScreenRect();
  546. if (!screen_rect.pointInRect(x, y))
  547. {
  548. mPanelNearByMedia->setVisible(FALSE);
  549. }
  550. }
  551. }
  552. BOOL can_afford_transaction(S32 cost)
  553. {
  554. return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost)));
  555. }
  556. void LLStatusBar::onVolumeChanged(const LLSD& newvalue)
  557. {
  558. refresh();
  559. }
  560. // Implements secondlife:///app/balance/request to request a L$ balance
  561. // update via UDP message system. JC
  562. class LLBalanceHandler : public LLCommandHandler
  563. {
  564. public:
  565. // Requires "trusted" browser/URL source
  566. LLBalanceHandler() : LLCommandHandler("balance", UNTRUSTED_BLOCK) { }
  567. bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web)
  568. {
  569. if (tokens.size() == 1
  570. && tokens[0].asString() == "request")
  571. {
  572. LLStatusBar::sendMoneyBalanceRequest();
  573. return true;
  574. }
  575. return false;
  576. }
  577. };
  578. // register with command dispatch system
  579. LLBalanceHandler gBalanceHandler;