llfirstuse.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /**
  2. * @file llfirstuse.cpp
  3. * @brief Methods that spawn "first-use" dialogs
  4. *
  5. * $LicenseInfo:firstyear=2003&license=viewergpl$
  6. *
  7. * Copyright (c) 2003-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 "llfirstuse.h"
  34. #include "llnotifications.h"
  35. #include "lltrans.h"
  36. #include "llagent.h" // For gAgent.inPrelude()
  37. #include "lltracker.h"
  38. #include "llviewercontrol.h"
  39. // First clean starts at 3 AM
  40. constexpr S32 SANDBOX_FIRST_CLEAN_HOUR = 3;
  41. // Clean every <n> hours
  42. constexpr S32 SANDBOX_CLEAN_FREQ = 12;
  43. //static
  44. std::vector<std::string> LLFirstUse::sConfigVariables;
  45. //static
  46. void LLFirstUse::populate()
  47. {
  48. sConfigVariables.reserve(16);
  49. sConfigVariables.emplace_back("FirstAppearance");
  50. sConfigVariables.emplace_back("FirstBalanceDecrease");
  51. sConfigVariables.emplace_back("FirstBalanceIncrease");
  52. sConfigVariables.emplace_back("FirstBuild");
  53. sConfigVariables.emplace_back("FirstInventory");
  54. sConfigVariables.emplace_back("FirstJellyDoll");
  55. sConfigVariables.emplace_back("FirstLeftClickNoHit");
  56. sConfigVariables.emplace_back("FirstMap");
  57. sConfigVariables.emplace_back("FirstMedia");
  58. sConfigVariables.emplace_back("FirstOverrideKeys");
  59. sConfigVariables.emplace_back("FirstSandbox");
  60. sConfigVariables.emplace_back("FirstSculptedPrim");
  61. sConfigVariables.emplace_back("FirstSit");
  62. sConfigVariables.emplace_back("FirstStreamingMusic");
  63. sConfigVariables.emplace_back("FirstStreamingVideo");
  64. sConfigVariables.emplace_back("FirstVoice");
  65. }
  66. //static
  67. void LLFirstUse::disableFirstUse()
  68. {
  69. if (sConfigVariables.empty())
  70. {
  71. populate();
  72. }
  73. // Set all first-use warnings to disabled
  74. for (S32 i = 0, count = sConfigVariables.size(); i < count; ++i)
  75. {
  76. gSavedSettings.setWarning(sConfigVariables[i], false);
  77. }
  78. }
  79. //static
  80. void LLFirstUse::resetFirstUse()
  81. {
  82. if (sConfigVariables.empty())
  83. {
  84. populate();
  85. }
  86. // Set all first-use warnings to enabled
  87. for (S32 i = 0, count = sConfigVariables.size(); i < count; ++i)
  88. {
  89. gSavedSettings.setWarning(sConfigVariables[i], true);
  90. }
  91. }
  92. // Called whenever the viewer detects that your balance went up
  93. void LLFirstUse::useBalanceIncrease(S32 delta)
  94. {
  95. if (gSavedSettings.getWarning("FirstBalanceIncrease"))
  96. {
  97. gSavedSettings.setWarning("FirstBalanceIncrease", false);
  98. LLSD args;
  99. args["AMOUNT"] = llformat("%d",delta);
  100. gNotifications.add("FirstBalanceIncrease", args);
  101. }
  102. }
  103. // Called whenever the viewer detects your balance went down
  104. void LLFirstUse::useBalanceDecrease(S32 delta)
  105. {
  106. if (gSavedSettings.getWarning("FirstBalanceDecrease"))
  107. {
  108. gSavedSettings.setWarning("FirstBalanceDecrease", false);
  109. LLSD args;
  110. args["AMOUNT"] = llformat("%d",-delta);
  111. gNotifications.add("FirstBalanceDecrease", args);
  112. }
  113. }
  114. //static
  115. void LLFirstUse::simpleNotification(const std::string& name)
  116. {
  117. if (gSavedSettings.getWarning(name))
  118. {
  119. gSavedSettings.setWarning(name, false);
  120. gNotifications.add(name);
  121. }
  122. }
  123. //static
  124. void LLFirstUse::useSit()
  125. {
  126. // SL's orientation island uses sitting to teach vehicle driving so just
  127. // never show this messagein prelude
  128. if (!gAgent.inPrelude())
  129. {
  130. simpleNotification("FirstSit");
  131. }
  132. }
  133. //static
  134. void LLFirstUse::useMap()
  135. {
  136. simpleNotification("FirstMap");
  137. }
  138. //static
  139. void LLFirstUse::useBuild()
  140. {
  141. simpleNotification("FirstBuild");
  142. }
  143. //static
  144. void LLFirstUse::useLeftClickNoHit()
  145. {
  146. simpleNotification("FirstLeftClickNoHit");
  147. }
  148. //static
  149. void LLFirstUse::useOverrideKeys()
  150. {
  151. // SL's orientation island uses key overrides to teach vehicle driving
  152. // so don't show this message until you get off OI. JC
  153. if (!gAgent.inPrelude())
  154. {
  155. simpleNotification("FirstOverrideKeys");
  156. }
  157. }
  158. //static
  159. void LLFirstUse::useAppearance()
  160. {
  161. simpleNotification("FirstAppearance");
  162. }
  163. //static
  164. void LLFirstUse::useInventory()
  165. {
  166. simpleNotification("FirstInventory");
  167. }
  168. //static
  169. void LLFirstUse::useSandbox()
  170. {
  171. if (gSavedSettings.getWarning("FirstSandbox"))
  172. {
  173. gSavedSettings.setWarning("FirstSandbox", false);
  174. LLSD args;
  175. args["HOURS"] = llformat("%d", SANDBOX_CLEAN_FREQ);
  176. args["TIME"] = llformat("%d", SANDBOX_FIRST_CLEAN_HOUR);
  177. gNotifications.add("FirstSandbox", args);
  178. }
  179. }
  180. //static
  181. void LLFirstUse::useSculptedPrim()
  182. {
  183. simpleNotification("FirstSculptedPrim");
  184. }
  185. //static
  186. void LLFirstUse::useMedia()
  187. {
  188. simpleNotification("FirstMedia");
  189. }
  190. //static
  191. void LLFirstUse::useJellyDoll()
  192. {
  193. // We cache the setting in a static variable, because this method may get
  194. // called a lot...
  195. static bool warn = gSavedSettings.getWarning("FirstJellyDoll");
  196. if (warn)
  197. {
  198. gSavedSettings.setWarning("FirstJellyDoll", false);
  199. gNotifications.add("FirstJellyDoll");
  200. warn = false;
  201. }
  202. }