llstatusbar.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /**
  2. * @file llstatusbar.h
  3. * @brief LLStatusBar class definition
  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. #ifndef LL_LLSTATUSBAR_H
  33. #define LL_LLSTATUSBAR_H
  34. #include "llframetimer.h"
  35. #include "llpanel.h"
  36. #include "llstatgraph.h"
  37. // "Constants" loaded from settings.xml at start time
  38. extern S32 gStatusBarHeight;
  39. class LLButton;
  40. class LLLineEditor;
  41. class LLStatGraph;
  42. class LLTextBox;
  43. class LLUICtrl;
  44. class LLUUID;
  45. class LLStatusBar final : public LLPanel
  46. {
  47. public:
  48. LLStatusBar(const LLRect& rect);
  49. ~LLStatusBar() override;
  50. void draw() override;
  51. void refresh() override;
  52. LL_INLINE void setDirty() { mDirty = true; }
  53. void setIcons();
  54. // MANIPULATORS
  55. void setBalance(S32 balance);
  56. void debitBalance(S32 debit);
  57. void creditBalance(S32 credit);
  58. // Request the latest currency balance from the server
  59. static void sendMoneyBalanceRequest();
  60. void setHealth(S32 percent);
  61. LL_INLINE void setLandCredit(S32 credit) { mSquareMetersCredit = credit; }
  62. LL_INLINE void setLandCommitted(S32 committed) { mSquareMetersCommitted = committed; }
  63. // Causes an agent parcel properties request to be launched and the various
  64. // status bar icons (no-build, no-scripts, no-fly, no-voice, etc) to be
  65. // updated accordingly after the reply is received by the parcel manager.
  66. void setDirtyAgentParcelProperties();
  67. // Some elements should hide in mouselook
  68. void setVisibleForMouselook(bool visible);
  69. LL_INLINE S32 getBalance() const { return mBalance; }
  70. LL_INLINE S32 getHealth() const { return mHealth; }
  71. LL_INLINE bool isUserTiered() const { return mSquareMetersCredit > 0; }
  72. LL_INLINE S32 getSquareMetersCredit() const { return mSquareMetersCredit; }
  73. LL_INLINE S32 getSquareMetersCommitted() const { return mSquareMetersCommitted; }
  74. LL_INLINE S32 getSquareMetersLeft() const { return mSquareMetersCredit -
  75. mSquareMetersCommitted; }
  76. LL_INLINE void incFailedEventPolls() { ++mAgentRegionFailedEventPolls; }
  77. LL_INLINE void resetFailedEventPolls() { mAgentRegionFailedEventPolls = 0; }
  78. LL_INLINE void setFrameRateLimited(bool b) { mFrameRateLimited = b; }
  79. // We collect per-frame statistics of rendered materials, so to inform the
  80. // user when some materials are around (and which type) and display an
  81. // indicator in the status bar to let them know if they are using a
  82. // rendering mode allowing to see these materials or not. HB
  83. LL_INLINE void materialsUsage(bool using_alm, bool using_pbr,
  84. bool lacking_fallbacks,
  85. bool lacking_basecolor)
  86. {
  87. mUsingALM = using_alm;
  88. mUsingPBR = using_pbr;
  89. mLacksLegacyFallback = lacking_fallbacks;
  90. mLacksBaseColorFallback = lacking_basecolor;
  91. }
  92. // Lua status bar button support. HB
  93. void setLuaFunctionButton(const std::string& command,
  94. const std::string& tooltip);
  95. private:
  96. enum
  97. {
  98. TIME_MODE_SL,
  99. TIME_MODE_UTC,
  100. TIME_MODE_LOCAL,
  101. TIME_MODE_END
  102. };
  103. void setNetworkBandwidth();
  104. static void onClickParcelInfo(void* data);
  105. static void onClickTime(void* data);
  106. static void onClickMaterials(void*);
  107. static void onClickBalance(void*);
  108. static void onClickHealth(void* data);
  109. static void onClickFly(void* data);
  110. static void onClickPush(void* data);
  111. static void onClickBuild(void* data);
  112. static void onClickScripts(void* data);
  113. static void onClickPathFinding(void* data);
  114. static void onClickDirtyNavMesh(void* data);
  115. static void onClickAdult(void* data);
  116. static void onClickMature(void* data);
  117. static void onClickPG(void* data);
  118. static void onClickNotifications(void* data);
  119. static void onClickTooComplex(void* data);
  120. static void onClickVoice(void* data);
  121. static void onClickSee(void* data);
  122. static void onClickBuyLand(void* data);
  123. static void onClickScriptDebug(void* data);
  124. static void onCommitSearch(LLUICtrl*, void* data);
  125. static void onClickSearch(void* data);
  126. static void onClickFPS(void*);
  127. static void onClickStatGraph(void*);
  128. static void onClickLuaFunction(void* data);
  129. private:
  130. LLColor4 mParcelTextColor;
  131. LLTextBox* mTextFPS;
  132. LLTextBox* mMaterials;
  133. LLTextBox* mTextBalance;
  134. LLTextBox* mTextHealth;
  135. LLTextBox* mTextTime;
  136. LLTextBox* mTextParcelName;
  137. LLTextBox* mTextStat;
  138. LLTextBox* mTextNotifications;
  139. LLTextBox* mTextTooComplex;
  140. LLStatGraph* mSGBandwidth;
  141. LLStatGraph* mSGPacketLoss;
  142. LLLineEditor* mLineEditSearch;
  143. LLButton* mBtnHealth;
  144. LLButton* mBtnNoFly;
  145. LLButton* mBtnBuyLand;
  146. LLButton* mBtnNoBuild;
  147. LLButton* mBtnNoScript;
  148. LLButton* mBtnNoPush;
  149. LLButton* mBtnNoVoice;
  150. LLButton* mBtnNoSee;
  151. LLButton* mBtnNoPathFinding;
  152. LLButton* mBtnDirtyNavMesh;
  153. LLButton* mBtnAdult;
  154. LLButton* mBtnMature;
  155. LLButton* mBtnPG;
  156. LLButton* mBtnNotificationsOn;
  157. LLButton* mBtnNotificationsOff;
  158. LLButton* mBtnScriptError;
  159. LLButton* mBtnRebaking;
  160. LLButton* mTooComplex;
  161. LLButton* mBtnSearch;
  162. LLButton* mBtnSearchBevel;
  163. LLButton* mBtnLuaFunction;
  164. LLButton* mBtnBuyMoney;
  165. std::string mAllMaterialsOK;
  166. std::string mDiffuseFallback;
  167. std::string mLegacyFallback;
  168. std::string mBasecolorFallback;
  169. std::string mMaterialMissing;
  170. std::string mNoMaterial;
  171. std::string mParcelTooltipOK;
  172. std::string mParcelTooltipWarn1;
  173. std::string mParcelTooltipWarn2;
  174. std::string mParcelTooltipWarn3;
  175. std::string mLuaCommand;
  176. U32 mTimeMode;
  177. S32 mBalance;
  178. S32 mHealth;
  179. S32 mLastNotifications;
  180. S32 mSquareMetersCredit;
  181. S32 mSquareMetersCommitted;
  182. U32 mAgentRegionFailedEventPolls;
  183. F32 mLastZeroBandwidthTime;
  184. F32 mAbsoluteMaxBandwidth;
  185. LLFrameTimer mHealthTimer;
  186. LLFrameTimer mUpdateTimer;
  187. LLFrameTimer mNotificationsTimer;
  188. LLFrameTimer mRefreshAgentParcelTimer;
  189. bool mVisibility;
  190. bool mDirty;
  191. bool mUseOldIcons;
  192. bool mNetworkDown;
  193. bool mFrameRateLimited;
  194. bool mUsingALM;
  195. bool mUsingPBR;
  196. bool mLacksLegacyFallback;
  197. bool mLacksBaseColorFallback;
  198. };
  199. extern LLStatusBar* gStatusBarp;
  200. // *HACK: Status bar owns your cached money balance. JC
  201. LL_INLINE bool can_afford_transaction(S32 cost)
  202. {
  203. return cost <= 0 || (gStatusBarp && gStatusBarp->getBalance() >= cost);
  204. }
  205. #endif