llstatusbar.cpp 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392
  1. /**
  2. * @file llstatusbar.cpp
  3. * @brief LLStatusBar 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. #include "llviewerprecompiledheaders.h"
  33. #include "llstatusbar.h"
  34. #include "llbutton.h"
  35. #include "llcachename.h"
  36. #include "llmenugl.h" // For gMenuBarHeight
  37. #include "llparcel.h"
  38. #include "lllineeditor.h"
  39. #include "lllocale.h"
  40. #include "llnotifications.h"
  41. #include "llsys.h"
  42. #include "lltextbox.h"
  43. #include "lluictrlfactory.h"
  44. #include "llmessage.h"
  45. #include "llagent.h"
  46. #include "llappearancemgr.h"
  47. #include "llappviewer.h" // For gFrameTimeSeconds
  48. #include "llcommandhandler.h"
  49. #include "llfloaterbuycurrency.h"
  50. #include "llfloaterlagmeter.h"
  51. #include "llfloaterland.h"
  52. #include "llfloaterregioninfo.h"
  53. #include "llfloaterscriptdebug.h"
  54. #include "hbfloatersearch.h" // To spawn search
  55. #include "llfloaterstats.h"
  56. #include "llgridmanager.h"
  57. #include "llgroupnotify.h"
  58. #include "llnotify.h"
  59. #include "lloverlaybar.h"
  60. #include "llpipeline.h"
  61. //MK
  62. #include "mkrlinterface.h"
  63. //mk
  64. #include "llstatgraph.h"
  65. #include "hbviewerautomation.h"
  66. #include "llviewercontrol.h"
  67. #include "llviewermenu.h" // gMenuBarViewp, handle_rebake_textures()
  68. #include "llviewerparceloverlay.h"
  69. #include "llviewerparcelmgr.h"
  70. #include "llviewerregion.h"
  71. #include "llviewerstats.h"
  72. #include "llvoavatarself.h"
  73. #include "llworld.h"
  74. //
  75. // Globals
  76. //
  77. // Instance created in LLViewerWindow::initWorldUI()
  78. LLStatusBar* gStatusBarp = NULL;
  79. S32 gStatusBarHeight = 26; // Loaded from settings.xml in llappviewer.cpp
  80. // *TODO: the there following values ought to be in the XML too
  81. constexpr S32 TEXT_HEIGHT = 18;
  82. constexpr S32 SIM_STAT_WIDTH = 8;
  83. // Distance from right of menu item to parcel information:
  84. constexpr S32 MENU_PARCEL_SPACING = 1;
  85. // Memory stats graph and health icon flash duration and rate:
  86. constexpr F32 FLASH_TIMER_EXPIRY = 5.f; // Flash duration in seconds
  87. constexpr F32 FLASH_FREQUENCY = 2.f; // Flash rate in Hertz
  88. // Parcel status refresh rate (necessary so that parcel permissions changes
  89. // get updated without needing to exit and re-enter the parcel...).
  90. constexpr F32 PARCEL_TIMER_EXPIRY = 60.f;
  91. // Do not refresh the status bar layout and icons visibility more than 5 times
  92. // per second to avoid wasting precious CPU cycles for nothing...).
  93. constexpr F32 STATUS_REFRESH_INTERVAL = 0.2f;
  94. // Ellapsed delay after the first 0 UDP bandwith detection, beyond which the
  95. // network will be considered down.
  96. constexpr F32 NET_TIMEOUT = 4.f * STATUS_REFRESH_INTERVAL;
  97. ///////////////////////////////////////////////////////////////////////////////
  98. // Implements secondlife:///app/balance/request to request a L$ balance update
  99. // via UDP message system. JC
  100. class LLBalanceHandler final : public LLCommandHandler
  101. {
  102. public:
  103. // Requires "trusted" browser/URL source
  104. LLBalanceHandler()
  105. : LLCommandHandler("balance", UNTRUSTED_BLOCK)
  106. {
  107. }
  108. bool handle(const LLSD& tokens, const LLSD&, LLMediaCtrl*) override
  109. {
  110. if (tokens.size() == 1 && tokens[0].asString() == "request")
  111. {
  112. LLStatusBar::sendMoneyBalanceRequest();
  113. return true;
  114. }
  115. return false;
  116. }
  117. };
  118. // register with command dispatch system
  119. LLBalanceHandler gBalanceHandler;
  120. ///////////////////////////////////////////////////////////////////////////////
  121. // LLStatusBar class
  122. LLStatusBar::LLStatusBar(const LLRect& rect)
  123. : LLPanel("status bar", LLRect(), false), // Not mouse opaque
  124. mUseOldIcons(true),
  125. mParcelTextColor(LLColor4(gColors.getColor("ParcelTextColor"))),
  126. mVisibility(true),
  127. mDirty(true),
  128. mBalance(0),
  129. mHealth(100),
  130. mLastNotifications(0),
  131. mSquareMetersCredit(0),
  132. mSquareMetersCommitted(0),
  133. mAgentRegionFailedEventPolls(0),
  134. mLastZeroBandwidthTime(0.f),
  135. mNetworkDown(false),
  136. mFrameRateLimited(false),
  137. mUsingALM(false),
  138. mUsingPBR(false),
  139. mLacksLegacyFallback(false),
  140. mLacksBaseColorFallback(false)
  141. {
  142. LLUICtrlFactory::getInstance()->buildPanel(this, "panel_status_bar.xml");
  143. mTimeMode = llmin(gSavedSettings.getU32("StatusBarTimeMode"),
  144. U32(TIME_MODE_END - 1));
  145. // Note: this is just an approximation so we use the smallest expected
  146. // "max" bandwidth for UDP, which should be OpenSim's one (when this
  147. // constructor is called, the viewer is not yet logged to a simulator, so
  148. // we do not yet know what grid we will connect to). HB
  149. mAbsoluteMaxBandwidth = gSavedSettings.getU32("ThrottleBandwidthKbpsOS");
  150. mTextParcelName = getChild<LLTextBox>("ParcelNameText");
  151. mTextParcelName->setClickedCallback(onClickParcelInfo);
  152. mBtnScriptError = getChild<LLButton>("script_error");
  153. mBtnScriptError->setClickedCallback(onClickScriptDebug, this);
  154. mBtnLuaFunction = getChild<LLButton>("lua");
  155. mBtnLuaFunction->setClickedCallback(onClickLuaFunction, this);
  156. mBtnRebaking = getChild<LLButton>("not_rezzed");
  157. mBtnRebaking->setClickedCallback(handle_rebake_textures, NULL);
  158. mTooComplex = getChild<LLButton>("too_complex");
  159. mTooComplex->setClickedCallback(onClickTooComplex, this);
  160. mTextTooComplex = getChild<LLTextBox>("too_complex_reports");
  161. mBtnHealth = getChild<LLButton>("health");
  162. mBtnHealth->setClickedCallback(onClickHealth, this);
  163. mTextHealth = getChild<LLTextBox>("HealthText");
  164. mBtnNoFly = getChild<LLButton>("no_fly");
  165. mBtnNoFly->setClickedCallback(onClickFly, this);
  166. mBtnNoBuild = getChild<LLButton>("no_build");
  167. mBtnNoBuild->setClickedCallback(onClickBuild, this);
  168. mBtnNoScript = getChild<LLButton>("no_scripts");
  169. mBtnNoScript->setClickedCallback(onClickScripts, this);
  170. mBtnNoPush = getChild<LLButton>("no_push");
  171. mBtnNoPush->setClickedCallback(onClickPush, this);
  172. mBtnNoVoice = getChild<LLButton>("no_voice");
  173. mBtnNoVoice->setClickedCallback(onClickVoice, this);
  174. mBtnNoSee = getChild<LLButton>("no_see");
  175. mBtnNoSee->setClickedCallback(onClickSee, this);
  176. mBtnNoPathFinding = getChild<LLButton>("no_path_finding");
  177. mBtnNoPathFinding->setClickedCallback(onClickPathFinding, this);
  178. mBtnDirtyNavMesh = getChild<LLButton>("dirty_nav_mesh");
  179. mBtnDirtyNavMesh->setClickedCallback(onClickDirtyNavMesh, this);
  180. mBtnBuyLand = getChild<LLButton>("buy_land");
  181. mBtnBuyLand->setClickedCallback(onClickBuyLand, this);
  182. mBtnNotificationsOn = getChild<LLButton>("notifications_on");
  183. mBtnNotificationsOn->setClickedCallback(onClickNotifications, this);
  184. mBtnNotificationsOff = getChild<LLButton>("notifications_off");
  185. mBtnNotificationsOff->setClickedCallback(onClickNotifications, this);
  186. mTextNotifications = getChild<LLTextBox>("notifications");
  187. mBtnAdult = getChild<LLButton>("adult");
  188. mBtnAdult->setClickedCallback(onClickAdult, this);
  189. mBtnMature = getChild<LLButton>("mature");
  190. mBtnMature->setClickedCallback(onClickMature, this);
  191. mBtnPG = getChild<LLButton>("pg");
  192. mBtnPG->setClickedCallback(onClickPG, this);
  193. mTextTime = getChild<LLTextBox>("TimeText");
  194. mTextTime->setClickedCallback(onClickTime, this);
  195. mTextBalance = getChild<LLTextBox>("BalanceText");
  196. mTextBalance->setClickedCallback(onClickBalance);
  197. mBtnBuyMoney = getChild<LLButton>("buy_money");
  198. mBtnBuyMoney->setClickedCallback(onClickBalance, this);
  199. mTextFPS = getChild<LLTextBox>("fps");
  200. mTextFPS->setClickedCallback(onClickFPS);
  201. mMaterials = getChild<LLTextBox>("materials");
  202. mMaterials->setClickedCallback(onClickMaterials, this);
  203. bool search_bar = gSavedSettings.getBool("ShowSearchBar");
  204. mBtnSearch = getChild<LLButton>("search_btn");
  205. mBtnSearch->setVisible(search_bar);
  206. mBtnSearch->setClickedCallback(onClickSearch, this);
  207. mBtnSearchBevel = getChild<LLButton>("menubar_search_bevel_bg");
  208. mBtnSearchBevel->setVisible(search_bar);
  209. mLineEditSearch = getChild<LLLineEditor>("search_editor");
  210. mLineEditSearch->setVisible(search_bar);
  211. mLineEditSearch->setCommitCallback(onCommitSearch);
  212. mLineEditSearch->setCallbackUserData(this);
  213. // Adding Net Stat Graph
  214. S32 x = getRect().getWidth() - 2;
  215. S32 y = 0;
  216. LLRect r;
  217. r.set(x - SIM_STAT_WIDTH, y + gMenuBarHeight - 1, x, y + 1);
  218. mSGBandwidth = new LLStatGraph("BandwidthGraph", r);
  219. mSGBandwidth->setFollows(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
  220. mSGBandwidth->setStat(&gViewerStats.mKBitStat);
  221. std::string text = getString("bandwidth_tooltip") + " ";
  222. mSGBandwidth->setLabel(text);
  223. mSGBandwidth->setUnits("kbps", "Mbps");
  224. mSGBandwidth->setUnitDivisor(1024.f);
  225. mSGBandwidth->setPrecision(0);
  226. mSGBandwidth->setLogScale();
  227. // Logarithmic indicators thresholds are always expressed in percent of the
  228. // full range.
  229. mSGBandwidth->setThreshold(0, 0.85f);
  230. mSGBandwidth->setThreshold(1, 0.95f);
  231. mSGBandwidth->setThreshold(2, 0.98f);
  232. mSGBandwidth->setClickedCallback(onClickStatGraph);
  233. setNetworkBandwidth();
  234. addChild(mSGBandwidth);
  235. x -= SIM_STAT_WIDTH + 2;
  236. r.set(x - SIM_STAT_WIDTH, y + gMenuBarHeight - 1, x, y + 1);
  237. mSGPacketLoss = new LLStatGraph("PacketLossPercent", r);
  238. mSGPacketLoss->setFollows(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
  239. mSGPacketLoss->setStat(&gViewerStats.mPacketsLostPercentStat);
  240. text = getString("packet_loss_tooltip") + " ";
  241. mSGPacketLoss->setLabel(text);
  242. mSGPacketLoss->setUnits("%");
  243. mSGPacketLoss->setMax(1.f);
  244. mSGPacketLoss->setThreshold(0, 0.1f);
  245. mSGPacketLoss->setThreshold(1, 0.25f);
  246. mSGPacketLoss->setThreshold(2, 0.5f);
  247. mSGPacketLoss->setPrecision(1);
  248. mSGPacketLoss->setPerSec(false);
  249. mSGPacketLoss->setClickedCallback(onClickStatGraph);
  250. addChild(mSGPacketLoss);
  251. x -= SIM_STAT_WIDTH + 2;
  252. mTextStat = getChild<LLTextBox>("stat_btn");
  253. mTextStat->setClickedCallback(onClickStatGraph);
  254. mRefreshAgentParcelTimer.setTimerExpirySec(PARCEL_TIMER_EXPIRY);
  255. // Tool tips for the rendered materials indicator.
  256. std::string account = " " + getString("attachments_stats");
  257. mAllMaterialsOK = getString("all_mats") + account;
  258. mDiffuseFallback = getString("diffuse") + account;
  259. mLegacyFallback = getString("fallback") + account;
  260. mBasecolorFallback = getString("basecolor") + account;
  261. mMaterialMissing = getString("missing") + account;
  262. mNoMaterial = getString("diffuse_only") + account;
  263. // Tool tips for the parcel name.
  264. mParcelTooltipOK = getString("parcel_tool_tip");
  265. mParcelTooltipWarn1 = getString("parcel_tool_tip_yellow");
  266. mParcelTooltipWarn2 = getString("parcel_tool_tip_orange");
  267. mParcelTooltipWarn3 = getString("parcel_tool_tip_red");
  268. setIcons();
  269. // The status bar can never get focused
  270. setFocusRoot(false);
  271. setMouseOpaque(false);
  272. setIsChrome(true);
  273. }
  274. LLStatusBar::~LLStatusBar()
  275. {
  276. gStatusBarp = NULL;
  277. }
  278. void LLStatusBar::setIcons()
  279. {
  280. mUseOldIcons = gSavedSettings.getBool("UseOldStatusBarIcons");
  281. std::string prefix = mUseOldIcons ? "legacy_status_" : "status_";
  282. mBtnNoFly->setImages(prefix + "no_fly.tga");
  283. mBtnNoBuild->setImages(prefix + "no_build.tga");
  284. mBtnNoScript->setImages(prefix + "no_scripts.tga");
  285. mBtnNoPush->setImages(prefix + "no_push.tga");
  286. mBtnNoVoice->setImages(prefix + "no_voice.tga");
  287. mBtnNoSee->setImages(prefix + "no_see.tga");
  288. mDirty = true;
  289. }
  290. void LLStatusBar::setNetworkBandwidth()
  291. {
  292. // Change the indicator max scale
  293. mSGBandwidth->setMax(mNetworkDown ? 0.f : mAbsoluteMaxBandwidth);
  294. // Refresh the indicator tool tip suffix with the max encountered bandwidth
  295. // so far.
  296. static const char* max_kpbs = " / %dkbps";
  297. static const char* max_mbps = " / %dMbps";
  298. const char* fmt;
  299. S32 maxbw = mAbsoluteMaxBandwidth;
  300. if (maxbw >= 1024)
  301. {
  302. maxbw /= 1024;
  303. fmt = max_mbps;
  304. }
  305. else
  306. {
  307. fmt = max_kpbs;
  308. }
  309. mSGBandwidth->setLabelSuffix(llformat(fmt, maxbw));
  310. }
  311. //virtual
  312. void LLStatusBar::draw()
  313. {
  314. if (!gMenuBarViewp) return;
  315. if (mDirty ||
  316. mUpdateTimer.getElapsedTimeF32() >= STATUS_REFRESH_INTERVAL ||
  317. !mHealthTimer.hasExpired() || !mNotificationsTimer.hasExpired())
  318. {
  319. mDirty = false;
  320. refresh();
  321. mUpdateTimer.reset();
  322. }
  323. if (isBackgroundVisible())
  324. {
  325. gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0,
  326. LLUI::sColorDropShadow, LLUI::sDropShadowFloater);
  327. }
  328. LLPanel::draw();
  329. }
  330. // Update of visibility
  331. void LLStatusBar::refresh()
  332. {
  333. bool net_down_now = false;
  334. // Note: absolute maximum = 1Gbps
  335. F32 cur_bandwidth = llmin(mSGBandwidth->getStat()->getMeanPerSec(),
  336. 1000000.f);
  337. if (cur_bandwidth > 0.f)
  338. {
  339. mLastZeroBandwidthTime = 0.f;
  340. }
  341. else if (mLastZeroBandwidthTime == 0.f)
  342. {
  343. mLastZeroBandwidthTime = gFrameTimeSeconds;
  344. }
  345. else if (gFrameTimeSeconds - mLastZeroBandwidthTime >= NET_TIMEOUT)
  346. {
  347. net_down_now = true;
  348. }
  349. bool showing = true;
  350. bool update_bw_scale = mNetworkDown != net_down_now;
  351. if (net_down_now)
  352. {
  353. showing = ((S32)(gFrameTimeSeconds * FLASH_FREQUENCY) & 1) != 0;
  354. }
  355. else if (cur_bandwidth > mAbsoluteMaxBandwidth)
  356. {
  357. mAbsoluteMaxBandwidth = cur_bandwidth;
  358. update_bw_scale = true;
  359. }
  360. if (update_bw_scale)
  361. {
  362. mNetworkDown = net_down_now;
  363. setNetworkBandwidth();
  364. }
  365. mSGBandwidth->setVisible(mVisibility && showing);
  366. // Clock display, switchable between SLT, UTC or local time
  367. struct tm* internal_time;
  368. std::string time_string;
  369. std::string time_zone;
  370. if (mTimeMode == TIME_MODE_SL)
  371. {
  372. // Get current UTC time, adjusted for the user's clock being off.
  373. time_t utc_time = time_corrected();
  374. // Convert to Pacific, based on server's opinion of whether
  375. // It is daylight savings time there.
  376. internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
  377. time_zone = gPacificDaylightTime ? " PDT" : " PST";
  378. }
  379. else if (mTimeMode == TIME_MODE_UTC)
  380. {
  381. // Get current UTC time, adjusted for the user's clock being off.
  382. time_t utc_time = time_corrected();
  383. internal_time = utc_time_to_tm(utc_time);
  384. time_zone = " UTC";
  385. }
  386. else
  387. {
  388. time_t local_time = computer_time();
  389. internal_time = local_time_to_tm(local_time);
  390. }
  391. static LLCachedControl<std::string> short_date_format(gSavedSettings,
  392. "ShortTimeFormat");
  393. timeStructToFormattedString(internal_time, short_date_format, time_string);
  394. mTextTime->setText(time_string + time_zone);
  395. static LLCachedControl<std::string> long_date_format(gSavedSettings,
  396. "LongDateFormat");
  397. timeStructToFormattedString(internal_time, long_date_format, time_string);
  398. mTextTime->setToolTip(time_string);
  399. LLRect r;
  400. const S32 menu_right = gMenuBarViewp->getRightmostMenuEdge();
  401. S32 x = menu_right + MENU_PARCEL_SPACING;
  402. S32 y = 0;
  403. // Reshape menu bar to its content's width
  404. if (menu_right != gMenuBarViewp->getRect().getWidth())
  405. {
  406. gMenuBarViewp->reshape(menu_right,
  407. gMenuBarViewp->getRect().getHeight());
  408. }
  409. LLViewerRegion* region = gAgent.getRegion();
  410. LLParcel* parcel = gViewerParcelMgr.getAgentParcel();
  411. LLRect brect;
  412. showing = gViewerParcelMgr.allowAgentDamage(region, parcel);
  413. mTextHealth->setVisible(showing);
  414. if (showing)
  415. {
  416. // Set visibility based on flashing
  417. if (!mHealthTimer.hasExpired())
  418. {
  419. showing = ((S32)(mHealthTimer.getElapsedTimeF32() *
  420. FLASH_FREQUENCY) & 1) != 0;
  421. }
  422. // Health
  423. brect = mBtnHealth->getRect();
  424. r.setOriginAndSize(x, y, brect.getWidth(), brect.getHeight());
  425. mBtnHealth->setRect(r);
  426. x += brect.getWidth();
  427. static const S32 health_width =
  428. S32(LLFontGL::getFontSansSerifSmall()->getWidth("100%")) + 2;
  429. r.set(x, y + TEXT_HEIGHT - 2, x + health_width, y);
  430. mTextHealth->setRect(r);
  431. x += health_width;
  432. }
  433. mBtnHealth->setVisible(showing);
  434. showing = !gViewerParcelMgr.allowAgentFly(region, parcel);
  435. mBtnNoFly->setVisible(showing);
  436. if (showing)
  437. {
  438. brect = mBtnNoFly->getRect();
  439. r.setOriginAndSize(x, y, brect.getWidth(), brect.getHeight());
  440. mBtnNoFly->setRect(r);
  441. x += brect.getWidth();
  442. }
  443. showing = !gViewerParcelMgr.allowAgentBuild();
  444. mBtnNoBuild->setVisible(showing);
  445. if (showing)
  446. {
  447. brect = mBtnNoBuild->getRect();
  448. // No Build Zone
  449. r.setOriginAndSize(x, y, brect.getWidth(), brect.getHeight());
  450. mBtnNoBuild->setRect(r);
  451. x += brect.getWidth();
  452. }
  453. showing = !gViewerParcelMgr.allowAgentScripts(region, parcel);
  454. mBtnNoScript->setVisible(showing);
  455. if (showing)
  456. {
  457. brect = mBtnNoScript->getRect();
  458. r.setOriginAndSize(x, y, brect.getWidth(), brect.getHeight());
  459. mBtnNoScript->setRect(r);
  460. x += brect.getWidth();
  461. }
  462. showing = !gViewerParcelMgr.allowAgentPush(region, parcel);
  463. mBtnNoPush->setVisible(showing);
  464. if (showing)
  465. {
  466. brect = mBtnNoPush->getRect();
  467. r.setOriginAndSize(x, y, brect.getWidth(), brect.getHeight());
  468. mBtnNoPush->setRect(r);
  469. x += brect.getWidth();
  470. }
  471. showing = gIsInSecondLife ? !gViewerParcelMgr.allowAgentVoice()
  472. : !parcel || !parcel->getParcelFlagAllowVoice();
  473. mBtnNoVoice->setVisible(showing);
  474. if (showing)
  475. {
  476. brect = mBtnNoVoice->getRect();
  477. r.setOriginAndSize(x, y, brect.getWidth(), brect.getHeight());
  478. mBtnNoVoice->setRect(r);
  479. x += brect.getWidth();
  480. }
  481. showing = parcel && parcel->getHaveNewParcelLimitData() &&
  482. !parcel->getSeeAVs();
  483. mBtnNoSee->setVisible(showing);
  484. if (showing)
  485. {
  486. brect = mBtnNoSee->getRect();
  487. r.setOriginAndSize(x, y, brect.getWidth(), brect.getHeight());
  488. mBtnNoSee->setRect(r);
  489. x += brect.getWidth();
  490. }
  491. // *HACK: layout tweak
  492. if (!mUseOldIcons)
  493. {
  494. x += 6;
  495. }
  496. showing = false;
  497. bool navmesh_dirty = false;
  498. if (gOverlayBarp)
  499. {
  500. showing = gOverlayBarp->isNavmeshRebaking();
  501. navmesh_dirty = showing || gOverlayBarp->isNavmeshDirty();
  502. }
  503. mBtnDirtyNavMesh->setVisible(navmesh_dirty);
  504. if (navmesh_dirty)
  505. {
  506. mBtnNoPathFinding->setVisible(false);
  507. brect = mBtnDirtyNavMesh->getRect();
  508. r.setOriginAndSize(x, y, brect.getWidth(), brect.getHeight());
  509. mBtnDirtyNavMesh->setRect(r);
  510. x += brect.getWidth();
  511. mBtnDirtyNavMesh->setEnabled(!showing);
  512. }
  513. else
  514. {
  515. bool no_path_finding = region && region->hasDynamicPathfinding() &&
  516. !region->dynamicPathfindingEnabled();
  517. mBtnNoPathFinding->setVisible(no_path_finding);
  518. if (no_path_finding)
  519. {
  520. mBtnDirtyNavMesh->setVisible(false);
  521. brect = mBtnNoPathFinding->getRect();
  522. r.setOriginAndSize(x, y, brect.getWidth(), brect.getHeight());
  523. mBtnNoPathFinding->setRect(r);
  524. x += brect.getWidth();
  525. }
  526. }
  527. showing = parcel && !parcel->isPublic() &&
  528. gViewerParcelMgr.canAgentBuyParcel(parcel, false);
  529. mBtnBuyLand->setVisible(showing);
  530. if (showing)
  531. {
  532. // *HACK: layout tweak
  533. x += 9;
  534. brect = mBtnBuyLand->getRect();
  535. r.setOriginAndSize(x, y, brect.getWidth(), brect.getHeight());
  536. mBtnBuyLand->setRect(r);
  537. x += brect.getWidth();
  538. }
  539. // Hide all maturity buttons
  540. mBtnAdult->setVisible(false);
  541. mBtnMature->setVisible(false);
  542. mBtnPG->setVisible(false);
  543. std::string location_name, parcel_name;
  544. if (region)
  545. {
  546. // Show the right maturity button. Note: we do not display any icon if
  547. // the rating is unknown
  548. LLButton* maturity_btn = NULL;
  549. U8 sim_access = region->getSimAccess();
  550. if (sim_access == SIM_ACCESS_PG)
  551. {
  552. maturity_btn = mBtnPG;
  553. }
  554. else if (sim_access == SIM_ACCESS_MATURE)
  555. {
  556. maturity_btn = mBtnMature;
  557. }
  558. else if (sim_access == SIM_ACCESS_ADULT)
  559. {
  560. maturity_btn = mBtnAdult;
  561. }
  562. if (maturity_btn)
  563. {
  564. maturity_btn->setVisible(true);
  565. brect = maturity_btn->getRect();
  566. // *HACK: layout tweak
  567. x += 6;
  568. y = 1;
  569. r.setOriginAndSize(x, y, brect.getWidth(), brect.getHeight());
  570. maturity_btn->setRect(r);
  571. x += brect.getWidth();
  572. }
  573. const LLVector3& agent_pos_region = gAgent.getPositionAgent();
  574. S32 pos_x = lltrunc(agent_pos_region.mV[VX]);
  575. S32 pos_y = lltrunc(agent_pos_region.mV[VY]);
  576. S32 pos_z = lltrunc(agent_pos_region.mV[VZ]);
  577. location_name = region->getName();
  578. if (parcel)
  579. {
  580. parcel_name = parcel->getName();
  581. location_name += llformat(" %d, %d, %d - %s", pos_x, pos_y, pos_z,
  582. parcel_name.c_str());
  583. if (mRefreshAgentParcelTimer.hasExpired())
  584. {
  585. mRefreshAgentParcelTimer.reset();
  586. mRefreshAgentParcelTimer.setTimerExpirySec(PARCEL_TIMER_EXPIRY);
  587. gViewerParcelMgr.requestParcelProperties(gAgent.getPositionGlobal());
  588. }
  589. }
  590. else
  591. {
  592. parcel_name = "Unknown";
  593. location_name += llformat(" %d, %d, %d", pos_x, pos_y, pos_z);
  594. }
  595. }
  596. else
  597. {
  598. // No region
  599. parcel_name = "Unknown";
  600. location_name = "(Unknown)";
  601. }
  602. //MK
  603. gRLInterface.mParcelName = parcel_name;
  604. if (gRLenabled && region && gRLInterface.mContainsShowloc)
  605. {
  606. location_name = "(Hidden)";
  607. }
  608. //mk
  609. mTextParcelName->setText(location_name);
  610. static U32 last_event_poll_failures = 0;
  611. if (mAgentRegionFailedEventPolls != last_event_poll_failures)
  612. {
  613. last_event_poll_failures = mAgentRegionFailedEventPolls;
  614. if (mAgentRegionFailedEventPolls == 0)
  615. {
  616. mTextParcelName->setColor(mParcelTextColor);
  617. mTextParcelName->setToolTip(mParcelTooltipOK);
  618. }
  619. // NOTE: keep failures numbers coherent with MAX_EVENT_POLL_HTTP_ERRORS
  620. // * 2 in lleventpoll.cpp.
  621. else if (mAgentRegionFailedEventPolls >= 15)
  622. {
  623. mTextParcelName->setColor(LLColor4::red);
  624. mTextParcelName->setToolTip(mParcelTooltipWarn3);
  625. }
  626. else if (mAgentRegionFailedEventPolls >= 10)
  627. {
  628. mTextParcelName->setColor(LLColor4::orange);
  629. mTextParcelName->setToolTip(mParcelTooltipWarn2);
  630. }
  631. else
  632. {
  633. mTextParcelName->setColor(LLColor4::yellow);
  634. mTextParcelName->setToolTip(mParcelTooltipWarn1);
  635. }
  636. }
  637. S32 new_right = getRect().getWidth();
  638. // Stats graph pseudo-button (textbox) rect
  639. r = mTextStat->getRect();
  640. r.translate(new_right - r.mRight, 0);
  641. mTextStat->setRect(r);
  642. new_right -= r.getWidth() + 15;
  643. mTextStat->setEnabled(true);
  644. // FPS rect, text and color
  645. r = mTextFPS->getRect();
  646. r.translate(new_right - r.mRight, 0);
  647. mTextFPS->setRect(r);
  648. new_right -= r.getWidth() + 6;
  649. F32 fps = gViewerStats.mFPSStat.getMeanPerSec();
  650. if (gAutomationp)
  651. {
  652. gAutomationp->onAveragedFPS(fps, mFrameRateLimited,
  653. gViewerStats.getRenderTimeStat());
  654. }
  655. mTextFPS->setText(llformat("%d", (S32)(fps + 0.5f)));
  656. static LLColor4 fps_color;
  657. if (mFrameRateLimited)
  658. {
  659. fps_color.set(1.f, 1.f, 1.f, 1.f);
  660. }
  661. // The following clamping and parameters have been determined empirically
  662. // to get the right color range, from red below 10 fps to blue at 60fps and
  663. // above, going through orange, yellow and green (around 35fps) in between.
  664. // HB
  665. else
  666. {
  667. if (fps > 60.f)
  668. {
  669. fps = 60.f;
  670. }
  671. else if (fps < 5.f)
  672. {
  673. fps = 5.f;
  674. }
  675. constexpr F32 HUE_FACTOR = 0.01f;
  676. constexpr F32 HUE_OFFSET = 0.94f;
  677. constexpr F32 SATURATION = 0.9f;
  678. constexpr F32 LUMINANCE = 0.6f;
  679. fps_color.setHSL(fps * HUE_FACTOR + HUE_OFFSET, SATURATION, LUMINANCE);
  680. }
  681. mTextFPS->setColor(fps_color);
  682. // Materials indicator
  683. static LLCachedControl<bool> attachments(gSavedSettings,
  684. "AccountAttachmentsMaterials");
  685. r = mMaterials->getRect();
  686. r.translate(new_right - r.mRight, 0);
  687. mMaterials->setRect(r);
  688. new_right -= r.getWidth() + 6;
  689. if (mUsingPBR)
  690. {
  691. mMaterials->setText("PBR");
  692. if (gUsePBRShaders)
  693. {
  694. mMaterials->setColor(LLColor4::green);
  695. mMaterials->setToolTip(mAllMaterialsOK);
  696. }
  697. else if (mLacksLegacyFallback)
  698. {
  699. if (mLacksBaseColorFallback)
  700. {
  701. mMaterials->setColor(LLColor4::red);
  702. mMaterials->setToolTip(mMaterialMissing);
  703. }
  704. else
  705. {
  706. mMaterials->setColor(LLColor4::orange1);
  707. mMaterials->setToolTip(mBasecolorFallback);
  708. }
  709. }
  710. else
  711. {
  712. mMaterials->setColor(LLColor4::yellow);
  713. mMaterials->setToolTip(mLegacyFallback);
  714. }
  715. }
  716. else if (mUsingALM)
  717. {
  718. mMaterials->setText("ALM");
  719. if (LLPipeline::sRenderDeferred)
  720. {
  721. mMaterials->setColor(LLColor4::green);
  722. mMaterials->setToolTip(mAllMaterialsOK);
  723. }
  724. else
  725. {
  726. mMaterials->setColor(LLColor4::yellow);
  727. mMaterials->setToolTip(mDiffuseFallback);
  728. }
  729. }
  730. else
  731. {
  732. mMaterials->setText("DIF");
  733. mMaterials->setColor(LLColor4::green);
  734. mMaterials->setToolTip(mNoMaterial);
  735. }
  736. mMaterials->setFontStyle(attachments ? LLFontGL::BOLD : LLFontGL::NORMAL);
  737. // Money balance rect
  738. static LLCachedControl<bool> show_balance(gSavedSettings, "ShowBalance");
  739. static LLCachedControl<bool> show_buy(gSavedSettings, "ShowBuyCurrency");
  740. mTextBalance->setVisible(mVisibility && show_balance);
  741. mBtnBuyMoney->setVisible(mVisibility && !show_balance && show_buy);
  742. if (show_balance)
  743. {
  744. r = mTextBalance->getRect();
  745. r.translate(new_right - r.mRight, 0);
  746. mTextBalance->setRect(r);
  747. new_right -= r.getWidth() + 6;
  748. }
  749. else if (show_buy)
  750. {
  751. r = mBtnBuyMoney->getRect();
  752. r.translate(new_right - r.mRight, 0);
  753. mBtnBuyMoney->setRect(r);
  754. new_right -= r.getWidth() + 6;
  755. }
  756. // Time rect
  757. r = mTextTime->getRect();
  758. r.translate(new_right - r.mRight, 0);
  759. mTextTime->setRect(r);
  760. new_right -= r.getWidth() + 6;
  761. static LLCachedControl<bool> show_search_bar(gSavedSettings,
  762. "ShowSearchBar");
  763. showing = mVisibility && show_search_bar;
  764. if (showing)
  765. {
  766. r = mBtnSearchBevel->getRect();
  767. r.translate(new_right - r.mRight, 0);
  768. mBtnSearchBevel->setRect(r);
  769. r = mBtnSearch->getRect();
  770. r.translate(new_right - r.mRight, 0);
  771. mBtnSearch->setRect(r);
  772. new_right -= r.getWidth();
  773. r = mLineEditSearch->getRect();
  774. r.translate(new_right - r.mRight, 0);
  775. mLineEditSearch->setRect(r);
  776. new_right -= r.getWidth();
  777. }
  778. mLineEditSearch->setVisible(showing);
  779. mBtnSearch->setVisible(showing);
  780. mBtnSearchBevel->setVisible(showing);
  781. // Rebaking/complexity icons and text
  782. r = mTextTooComplex->getRect();
  783. r.translate(new_right - r.mRight, 0);
  784. mTextTooComplex->setRect(r);
  785. new_right -= r.getWidth() + 6;
  786. showing = gAppearanceMgr.isRebaking();
  787. U32 too_complex = gViewerStats.getTooComplexReports();
  788. if (showing || too_complex == 0)
  789. {
  790. mTextTooComplex->setVisible(false);
  791. mTooComplex->setVisible(false);
  792. r = mBtnRebaking->getRect();
  793. r.translate(new_right - r.mRight, 0);
  794. mBtnRebaking->setRect(r);
  795. }
  796. else
  797. {
  798. mTextTooComplex->setVisible(true);
  799. mTooComplex->setVisible(true);
  800. mTextTooComplex->setText(llformat("%d", too_complex));
  801. r = mTooComplex->getRect();
  802. r.translate(new_right - r.mRight, 0);
  803. mTooComplex->setRect(r);
  804. }
  805. new_right -= r.getWidth() + 6;
  806. mBtnRebaking->setVisible(showing);
  807. // Script error icon
  808. r = mBtnScriptError->getRect();
  809. r.translate(new_right - r.mRight, 0);
  810. mBtnScriptError->setRect(r);
  811. new_right -= r.getWidth() + 6;
  812. mBtnScriptError->setVisible(LLFloaterScriptDebug::hasRecentError());
  813. // Lua function icon
  814. r = mBtnLuaFunction->getRect();
  815. r.translate(new_right - r.mRight, 0);
  816. mBtnLuaFunction->setRect(r);
  817. new_right -= r.getWidth() + 6;
  818. mBtnLuaFunction->setVisible(mVisibility && !mLuaCommand.empty());
  819. S32 left = mBtnLuaFunction->getRect().mLeft;
  820. S32 notifications = LLNotifyBox::getNotifyBoxCount() +
  821. LLGroupNotifyBox::getGroupNotifyBoxCount();
  822. if (notifications > 0)
  823. {
  824. showing = LLNotifyBox::areNotificationsShown();
  825. if (showing)
  826. {
  827. // Do not flash the indicator when notifications are shown
  828. mNotificationsTimer.reset();
  829. }
  830. else if (mLastNotifications < notifications)
  831. {
  832. // Flash the indicator when notifications are added
  833. mNotificationsTimer.reset();
  834. mNotificationsTimer.setTimerExpirySec(FLASH_TIMER_EXPIRY);
  835. }
  836. bool visible = true;
  837. if (!showing && !mNotificationsTimer.hasExpired())
  838. {
  839. // Set visibility based on flashing
  840. visible = ((S32)(mNotificationsTimer.getElapsedTimeF32() *
  841. FLASH_FREQUENCY) & 1) != 0;
  842. }
  843. mBtnNotificationsOn->setVisible(showing);
  844. mBtnNotificationsOff->setVisible(!showing && visible);
  845. mTextNotifications->setText(llformat("%d", notifications));
  846. mTextNotifications->setVisible(true);
  847. r = mTextNotifications->getRect();
  848. r.translate(new_right - r.mRight, 0);
  849. mTextNotifications->setRect(r);
  850. new_right -= r.getWidth() + 6;
  851. r = mBtnNotificationsOn->getRect();
  852. r.translate(new_right - r.mRight, 0);
  853. mBtnNotificationsOn->setRect(r);
  854. mBtnNotificationsOff->setRect(r);
  855. //new_right -= r.getWidth() + 6;
  856. left = mBtnNotificationsOn->getRect().mLeft;
  857. }
  858. else
  859. {
  860. mBtnNotificationsOn->setVisible(false);
  861. mBtnNotificationsOff->setVisible(false);
  862. mTextNotifications->setVisible(false);
  863. }
  864. mLastNotifications = notifications;
  865. // Adjust region name and parcel name
  866. x += 8;
  867. const S32 parcel_right =
  868. llmin(left - 10, mTextParcelName->getTextPixelWidth() + x + 5);
  869. r.set(x + 4, getRect().getHeight() - 1, parcel_right, 0);
  870. mTextParcelName->setRect(r);
  871. }
  872. void LLStatusBar::setVisibleForMouselook(bool visible)
  873. {
  874. mVisibility = visible;
  875. static LLCachedControl<bool> show_balance(gSavedSettings, "ShowBalance");
  876. static LLCachedControl<bool> show_buy(gSavedSettings, "ShowBuyCurrency");
  877. mTextBalance->setVisible(visible && show_balance);
  878. mBtnBuyMoney->setVisible(visible && !show_balance && show_buy);
  879. mTextTime->setVisible(visible);
  880. mLineEditSearch->setVisible(visible);
  881. mBtnSearch->setVisible(visible);
  882. mBtnSearchBevel->setVisible(visible);
  883. mSGBandwidth->setVisible(visible);
  884. mSGPacketLoss->setVisible(visible);
  885. mBtnLuaFunction->setVisible(visible);
  886. setBackgroundVisible(visible);
  887. mDirty = true;
  888. }
  889. void LLStatusBar::setDirtyAgentParcelProperties()
  890. {
  891. mRefreshAgentParcelTimer.reset();
  892. // We delay the refresh by two seconds, so to let the time for the parcel
  893. // properties to be updated (the call to this method being done by the
  894. // LLViewerParcelMgr::sendParcelPropertiesUpdate() method) and also as a
  895. // requests rate throttling.
  896. mRefreshAgentParcelTimer.setTimerExpirySec(2.f);
  897. }
  898. void LLStatusBar::debitBalance(S32 debit)
  899. {
  900. setBalance(getBalance() - debit);
  901. }
  902. void LLStatusBar::creditBalance(S32 credit)
  903. {
  904. setBalance(getBalance() + credit);
  905. }
  906. void LLStatusBar::setBalance(S32 balance)
  907. {
  908. std::string balance_str = "L$" + LLLocale::getMonetaryString(balance);
  909. mTextBalance->setText(balance_str);
  910. static const std::string tootlip = getString("balance_tool_tip");
  911. mBtnBuyMoney->setToolTip(tootlip + " " + balance_str);
  912. F32 threshold = gSavedSettings.getF32("UISndMoneyChangeThreshold");
  913. S32 change = mBalance - balance;
  914. if (mBalance && change && fabs((F32)change) >= threshold)
  915. {
  916. if (mBalance > balance)
  917. {
  918. make_ui_sound("UISndMoneyChangeDown");
  919. }
  920. else
  921. {
  922. make_ui_sound("UISndMoneyChangeUp");
  923. }
  924. }
  925. mBalance = balance;
  926. mDirty = true;
  927. }
  928. //static
  929. void LLStatusBar::sendMoneyBalanceRequest()
  930. {
  931. LLMessageSystem* msg = gMessageSystemp;
  932. msg->newMessageFast(_PREHASH_MoneyBalanceRequest);
  933. msg->nextBlockFast(_PREHASH_AgentData);
  934. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  935. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  936. msg->nextBlockFast(_PREHASH_MoneyData);
  937. msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null);
  938. gAgent.sendReliableMessage(2);
  939. }
  940. void LLStatusBar::setHealth(S32 health)
  941. {
  942. mTextHealth->setText(llformat("%d%%", health));
  943. if (mHealth > health)
  944. {
  945. if (mHealth > health + gSavedSettings.getF32("UISndHealthReductionThreshold"))
  946. {
  947. bool male_ok = gSavedSettings.getBool("UISndHealthReductionMEnable");
  948. bool female_ok = gSavedSettings.getBool("UISndHealthReductionFEnable");
  949. if (male_ok && female_ok)
  950. {
  951. male_ok &= isAgentAvatarValid() &&
  952. gAgentAvatarp->getSex() == SEX_MALE;
  953. female_ok &= !male_ok;
  954. }
  955. if (male_ok)
  956. {
  957. make_ui_sound("UISndHealthReductionM");
  958. }
  959. else if (female_ok)
  960. {
  961. make_ui_sound("UISndHealthReductionF");
  962. }
  963. }
  964. mHealthTimer.reset();
  965. mHealthTimer.setTimerExpirySec(FLASH_TIMER_EXPIRY);
  966. }
  967. mHealth = health;
  968. mDirty = true;
  969. }
  970. //static
  971. void LLStatusBar::onClickParcelInfo(void* data)
  972. {
  973. LLStatusBar* self = (LLStatusBar*)data;
  974. if (self)
  975. {
  976. self->mRefreshAgentParcelTimer.reset();
  977. }
  978. gViewerParcelMgr.selectParcelAt(gAgent.getPositionGlobal());
  979. //MK
  980. if (gRLenabled && gRLInterface.mContainsShowloc)
  981. {
  982. return;
  983. }
  984. //mk
  985. LLFloaterLand::showInstance();
  986. }
  987. //static
  988. void LLStatusBar::onClickTime(void* data)
  989. {
  990. LLStatusBar* self = (LLStatusBar*)data;
  991. if (self)
  992. {
  993. if (++self->mTimeMode >= TIME_MODE_END)
  994. {
  995. self->mTimeMode = 0;
  996. }
  997. gSavedSettings.setU32("StatusBarTimeMode", self->mTimeMode);
  998. self->mDirty = true;
  999. }
  1000. }
  1001. //static
  1002. void LLStatusBar::onClickMaterials(void*)
  1003. {
  1004. static LLCachedControl<bool> attachments(gSavedSettings,
  1005. "AccountAttachmentsMaterials");
  1006. gSavedSettings.setBool("AccountAttachmentsMaterials", !attachments);
  1007. if (attachments)
  1008. {
  1009. gNotifications.add("RenderedAttachmentsAccounted");
  1010. }
  1011. else
  1012. {
  1013. gNotifications.add("RenderedAttachmentsIgnored");
  1014. }
  1015. }
  1016. //static
  1017. void LLStatusBar::onClickBalance(void*)
  1018. {
  1019. LLFloaterBuyCurrency::buyCurrency();
  1020. sendMoneyBalanceRequest();
  1021. }
  1022. //static
  1023. void LLStatusBar::onClickHealth(void* data)
  1024. {
  1025. LLStatusBar* self = (LLStatusBar*)data;
  1026. if (self)
  1027. {
  1028. self->mRefreshAgentParcelTimer.reset();
  1029. }
  1030. gNotifications.add("NotSafe");
  1031. }
  1032. //static
  1033. void LLStatusBar::onClickScriptDebug(void* data)
  1034. {
  1035. LLStatusBar* self = (LLStatusBar*)data;
  1036. if (self)
  1037. {
  1038. self->mRefreshAgentParcelTimer.reset();
  1039. }
  1040. LLFloaterScriptDebug::show(LLUUID::null);
  1041. }
  1042. //static
  1043. void LLStatusBar::onClickFly(void* data)
  1044. {
  1045. LLStatusBar* self = (LLStatusBar*)data;
  1046. if (self)
  1047. {
  1048. self->mRefreshAgentParcelTimer.reset();
  1049. }
  1050. gNotifications.add("NoFly");
  1051. }
  1052. //static
  1053. void LLStatusBar::onClickPush(void* data)
  1054. {
  1055. LLStatusBar* self = (LLStatusBar*)data;
  1056. if (self)
  1057. {
  1058. self->mRefreshAgentParcelTimer.reset();
  1059. }
  1060. gNotifications.add("PushRestricted");
  1061. }
  1062. //static
  1063. void LLStatusBar::onClickVoice(void* data)
  1064. {
  1065. LLStatusBar* self = (LLStatusBar*)data;
  1066. if (self)
  1067. {
  1068. self->mRefreshAgentParcelTimer.reset();
  1069. }
  1070. gNotifications.add("NoVoice");
  1071. }
  1072. //static
  1073. void LLStatusBar::onClickSee(void* data)
  1074. {
  1075. LLStatusBar* self = (LLStatusBar*)data;
  1076. if (self)
  1077. {
  1078. self->mRefreshAgentParcelTimer.reset();
  1079. }
  1080. gNotifications.add("NoSee");
  1081. }
  1082. //static
  1083. void LLStatusBar::onClickBuild(void* data)
  1084. {
  1085. LLStatusBar* self = (LLStatusBar*)data;
  1086. if (self)
  1087. {
  1088. self->mRefreshAgentParcelTimer.reset();
  1089. }
  1090. gNotifications.add("NoBuild");
  1091. }
  1092. //static
  1093. void LLStatusBar::onClickPathFinding(void* data)
  1094. {
  1095. LLStatusBar* self = (LLStatusBar*)data;
  1096. if (self)
  1097. {
  1098. self->mRefreshAgentParcelTimer.reset();
  1099. }
  1100. gNotifications.add("NoPathFinding");
  1101. }
  1102. //static
  1103. void LLStatusBar::onClickDirtyNavMesh(void* data)
  1104. {
  1105. LLStatusBar* self = (LLStatusBar*)data;
  1106. if (self)
  1107. {
  1108. self->mRefreshAgentParcelTimer.reset();
  1109. }
  1110. gNotifications.add("DirtyNavMesh");
  1111. }
  1112. //static
  1113. void LLStatusBar::onClickAdult(void* data)
  1114. {
  1115. LLStatusBar* self = (LLStatusBar*)data;
  1116. if (self)
  1117. {
  1118. self->mRefreshAgentParcelTimer.reset();
  1119. }
  1120. gNotifications.add("AdultRating");
  1121. }
  1122. //static
  1123. void LLStatusBar::onClickMature(void* data)
  1124. {
  1125. LLStatusBar* self = (LLStatusBar*)data;
  1126. if (self)
  1127. {
  1128. self->mRefreshAgentParcelTimer.reset();
  1129. }
  1130. gNotifications.add("MatureRating");
  1131. }
  1132. //static
  1133. void LLStatusBar::onClickPG(void* data)
  1134. {
  1135. LLStatusBar* self = (LLStatusBar*)data;
  1136. if (self)
  1137. {
  1138. self->mRefreshAgentParcelTimer.reset();
  1139. }
  1140. gNotifications.add("PGRating");
  1141. }
  1142. //static
  1143. void LLStatusBar::onClickNotifications(void*)
  1144. {
  1145. LLNotifyBox::setShowNotifications(!LLNotifyBox::areNotificationsShown());
  1146. }
  1147. //static
  1148. void LLStatusBar::onClickTooComplex(void*)
  1149. {
  1150. if (!isAgentAvatarValid()) return;
  1151. LLSD args;
  1152. args["REPORTERS"] = llformat("%d", gViewerStats.getComplexityReports());
  1153. args["JELLYDOLLS"] = llformat("%d", gViewerStats.getTooComplexReports());
  1154. args["COMPLEXITY"] = llformat("%d", gAgentAvatarp->getVisualComplexity());
  1155. args["AREA"] = llformat("%.1f", gAgentAvatarp->getAttachmentSurfaceArea());
  1156. args["GEOMETRY"] = llformat("%d",
  1157. gAgentAvatarp->getAttachmentSurfaceBytes() /
  1158. 1024);
  1159. U32 attachments = gAgentAvatarp->getNumAttachments();
  1160. args["ATTACHMENTS"] = llformat("%d", attachments);
  1161. args["[SLOTS]"] = llformat("%d", gMaxSelfAttachments - attachments);
  1162. gNotifications.add("AvatarComplexityReport", args);
  1163. }
  1164. //static
  1165. void LLStatusBar::onClickScripts(void* data)
  1166. {
  1167. LLStatusBar* self = (LLStatusBar*)data;
  1168. if (self)
  1169. {
  1170. self->mRefreshAgentParcelTimer.reset();
  1171. }
  1172. LLViewerRegion* region = gAgent.getRegion();
  1173. if (region && region->getRegionFlag(REGION_FLAGS_ESTATE_SKIP_SCRIPTS))
  1174. {
  1175. gNotifications.add("ScriptsStopped");
  1176. }
  1177. else if (region && region->getRegionFlag(REGION_FLAGS_SKIP_SCRIPTS))
  1178. {
  1179. gNotifications.add("ScriptsNotRunning");
  1180. }
  1181. else
  1182. {
  1183. gNotifications.add("NoOutsideScripts");
  1184. }
  1185. }
  1186. //static
  1187. void LLStatusBar::onClickBuyLand(void* data)
  1188. {
  1189. //MK
  1190. if (gRLenabled && gRLInterface.mContainsShowloc)
  1191. {
  1192. return;
  1193. }
  1194. //mk
  1195. LLStatusBar* self = (LLStatusBar*)data;
  1196. if (self)
  1197. {
  1198. self->mRefreshAgentParcelTimer.reset();
  1199. }
  1200. gViewerParcelMgr.selectParcelAt(gAgent.getPositionGlobal());
  1201. gViewerParcelMgr.startBuyLand();
  1202. }
  1203. //static
  1204. void LLStatusBar::onCommitSearch(LLUICtrl*, void* data)
  1205. {
  1206. // Committing is the same as clicking "search"
  1207. onClickSearch(data);
  1208. }
  1209. //static
  1210. void LLStatusBar::onClickSearch(void* data)
  1211. {
  1212. LLStatusBar* self = (LLStatusBar*)data;
  1213. if (self)
  1214. {
  1215. std::string search_text = self->mLineEditSearch->getText();
  1216. HBFloaterSearch::showFindAll(search_text);
  1217. }
  1218. }
  1219. //static
  1220. void LLStatusBar::onClickFPS(void*)
  1221. {
  1222. LLFloaterStats::showInstance();
  1223. }
  1224. //static
  1225. void LLStatusBar::onClickStatGraph(void*)
  1226. {
  1227. LLFloaterLagMeter::showInstance();
  1228. }
  1229. //static
  1230. void LLStatusBar::setLuaFunctionButton(const std::string& command,
  1231. const std::string& tooltip)
  1232. {
  1233. mLuaCommand = command;
  1234. mBtnLuaFunction->setToolTip(tooltip);
  1235. mDirty = true;
  1236. }
  1237. //static
  1238. void LLStatusBar::onClickLuaFunction(void* data)
  1239. {
  1240. LLStatusBar* self = (LLStatusBar*)data;
  1241. if (self && !self->mLuaCommand.empty())
  1242. {
  1243. HBViewerAutomation::eval(self->mLuaCommand);
  1244. }
  1245. }