/indra/newview/llfirstuse.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 202 lines · 118 code · 27 blank · 57 comment · 11 complexity · 8a83ffdaed0136cd1c60341823b58083 MD5 · raw file

  1. /**
  2. * @file llfirstuse.cpp
  3. * @brief Methods that spawn "first-use" dialogs
  4. *
  5. * $LicenseInfo:firstyear=2003&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llfirstuse.h"
  28. // library includes
  29. #include "indra_constants.h"
  30. #include "llnotifications.h"
  31. // viewer includes
  32. #include "llagent.h" // for gAgent.inPrelude()
  33. #include "llviewercontrol.h"
  34. #include "llui.h"
  35. #include "llappviewer.h"
  36. #include "lltracker.h"
  37. // static
  38. std::set<std::string> LLFirstUse::sConfigVariables;
  39. // static
  40. void LLFirstUse::addConfigVariable(const std::string& var)
  41. {
  42. sConfigVariables.insert(var);
  43. }
  44. // static
  45. void LLFirstUse::disableFirstUse()
  46. {
  47. // Set all first-use warnings to disabled
  48. for (std::set<std::string>::iterator iter = sConfigVariables.begin();
  49. iter != sConfigVariables.end(); ++iter)
  50. {
  51. gWarningSettings.setBOOL(*iter, FALSE);
  52. }
  53. }
  54. // static
  55. void LLFirstUse::resetFirstUse()
  56. {
  57. // Set all first-use warnings to disabled
  58. for (std::set<std::string>::iterator iter = sConfigVariables.begin();
  59. iter != sConfigVariables.end(); ++iter)
  60. {
  61. gWarningSettings.setBOOL(*iter, TRUE);
  62. }
  63. }
  64. // static
  65. void LLFirstUse::otherAvatarChatFirst(bool enable)
  66. {
  67. firstUseNotification("FirstOtherChatBeforeUser", enable, "HintChat", LLSD(), LLSD().with("target", "chat_bar").with("direction", "top_right").with("distance", 24));
  68. }
  69. // static
  70. void LLFirstUse::speak(bool enable)
  71. {
  72. firstUseNotification("FirstSpeak", enable, "HintSpeak", LLSD(), LLSD().with("target", "speak_btn").with("direction", "top"));
  73. }
  74. // static
  75. void LLFirstUse::sit(bool enable)
  76. {
  77. firstUseNotification("FirstSit", enable, "HintSit", LLSD(), LLSD().with("target", "stand_btn").with("direction", "top"));
  78. }
  79. // static
  80. void LLFirstUse::newInventory(bool enable)
  81. {
  82. // turning this off until bug EXP-62 can be fixed (inventory hint appears for new users when their initial inventory is acquired)
  83. // firstUseNotification("FirstInventoryOffer", enable, "HintInventory", LLSD(), LLSD().with("target", "inventory_btn").with("direction", "left"));
  84. }
  85. // static
  86. void LLFirstUse::useSandbox()
  87. {
  88. firstUseNotification("FirstSandbox", true, "FirstSandbox", LLSD().with("HOURS", SANDBOX_CLEAN_FREQ).with("TIME", SANDBOX_FIRST_CLEAN_HOUR));
  89. }
  90. // static
  91. void LLFirstUse::notUsingDestinationGuide(bool enable)
  92. {
  93. // not doing this yet
  94. firstUseNotification("FirstNotUseDestinationGuide", enable, "HintDestinationGuide", LLSD(), LLSD().with("target", "dest_guide_btn").with("direction", "top"));
  95. }
  96. // static
  97. void LLFirstUse::notUsingSidePanel(bool enable)
  98. {
  99. // not doing this yet
  100. //firstUseNotification("FirstNotUseSidePanel", enable, "HintSidePanel", LLSD(), LLSD().with("target", "side_panel_btn").with("direction", "left"));
  101. }
  102. // static
  103. void LLFirstUse::notMoving(bool enable)
  104. {
  105. // fire off 2 notifications and rely on filtering to select the relevant one
  106. firstUseNotification("FirstNotMoving", enable, "HintMove", LLSD(), LLSD().with("target", "move_btn").with("direction", "top"));
  107. firstUseNotification("FirstNotMoving", enable, "HintMoveClick", LLSD(), LLSD()
  108. .with("target", "nav_bar")
  109. .with("direction", "bottom")
  110. .with("hint_image", "click_to_move.png")
  111. .with("up_arrow", ""));
  112. }
  113. // static
  114. void LLFirstUse::viewPopup(bool enable)
  115. {
  116. // firstUseNotification("FirstViewPopup", enable, "HintView", LLSD(), LLSD().with("target", "view_popup").with("direction", "right"));
  117. }
  118. // static
  119. void LLFirstUse::setDisplayName(bool enable)
  120. {
  121. firstUseNotification("FirstDisplayName", enable, "HintDisplayName", LLSD(), LLSD().with("target", "set_display_name").with("direction", "left"));
  122. }
  123. // static
  124. void LLFirstUse::receiveLindens(bool enable)
  125. {
  126. firstUseNotification("FirstReceiveLindens", enable, "HintLindenDollar", LLSD(), LLSD().with("target", "linden_balance").with("direction", "bottom"));
  127. }
  128. //static
  129. void LLFirstUse::firstUseNotification(const std::string& control_var, bool enable, const std::string& notification_name, LLSD args, LLSD payload)
  130. {
  131. init();
  132. if (enable)
  133. {
  134. if (gSavedSettings.getBOOL("EnableUIHints"))
  135. {
  136. LL_DEBUGS("LLFirstUse") << "Trigger first use notification " << notification_name << LL_ENDL;
  137. // if notification doesn't already exist and this notification hasn't been disabled...
  138. if (gWarningSettings.getBOOL(control_var))
  139. { // create new notification
  140. LLNotifications::instance().add(LLNotification::Params().name(notification_name).substitutions(args).payload(payload.with("control_var", control_var)));
  141. }
  142. }
  143. }
  144. else
  145. {
  146. LL_DEBUGS("LLFirstUse") << "Disabling first use notification " << notification_name << LL_ENDL;
  147. LLNotifications::instance().cancelByName(notification_name);
  148. // redundantly clear settings var here, in case there are no notifications to cancel
  149. gWarningSettings.setBOOL(control_var, FALSE);
  150. }
  151. }
  152. // static
  153. void LLFirstUse::init()
  154. {
  155. static bool initialized = false;
  156. if (!initialized)
  157. {
  158. LLNotifications::instance().getChannel("Hints")->connectChanged(&processNotification);
  159. }
  160. initialized = true;
  161. }
  162. //static
  163. bool LLFirstUse::processNotification(const LLSD& notify)
  164. {
  165. if (notify["sigtype"].asString() == "delete")
  166. {
  167. LLNotificationPtr notification = LLNotifications::instance().find(notify["id"].asUUID());
  168. if (notification)
  169. {
  170. // disable any future notifications
  171. gWarningSettings.setBOOL(notification->getPayload()["control_var"], FALSE);
  172. }
  173. }
  174. return false;
  175. }