PageRenderTime 77ms CodeModel.GetById 35ms app.highlight 38ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 27#include "llviewerprecompiledheaders.h"
 28
 29#include "llfirstuse.h"
 30
 31// library includes
 32#include "indra_constants.h"
 33#include "llnotifications.h"
 34
 35// viewer includes
 36#include "llagent.h"	// for gAgent.inPrelude()
 37#include "llviewercontrol.h"
 38#include "llui.h"
 39#include "llappviewer.h"
 40#include "lltracker.h"
 41
 42
 43// static
 44std::set<std::string> LLFirstUse::sConfigVariables;
 45
 46// static
 47void LLFirstUse::addConfigVariable(const std::string& var)
 48{
 49	sConfigVariables.insert(var);
 50}
 51
 52// static
 53void LLFirstUse::disableFirstUse()
 54{
 55	// Set all first-use warnings to disabled
 56	for (std::set<std::string>::iterator iter = sConfigVariables.begin();
 57		 iter != sConfigVariables.end(); ++iter)
 58	{
 59		gWarningSettings.setBOOL(*iter, FALSE);
 60	}
 61}
 62
 63// static
 64void LLFirstUse::resetFirstUse()
 65{
 66	// Set all first-use warnings to disabled
 67	for (std::set<std::string>::iterator iter = sConfigVariables.begin();
 68		 iter != sConfigVariables.end(); ++iter)
 69	{
 70		gWarningSettings.setBOOL(*iter, TRUE);
 71	}
 72}
 73
 74// static
 75void LLFirstUse::otherAvatarChatFirst(bool enable)
 76{
 77	firstUseNotification("FirstOtherChatBeforeUser", enable, "HintChat", LLSD(), LLSD().with("target", "chat_bar").with("direction", "top_right").with("distance", 24));
 78}
 79
 80// static
 81void LLFirstUse::speak(bool enable)
 82{
 83	firstUseNotification("FirstSpeak", enable, "HintSpeak", LLSD(), LLSD().with("target", "speak_btn").with("direction", "top"));
 84}
 85
 86// static
 87void LLFirstUse::sit(bool enable)
 88{
 89	firstUseNotification("FirstSit", enable, "HintSit", LLSD(), LLSD().with("target", "stand_btn").with("direction", "top"));
 90}
 91
 92// static
 93void LLFirstUse::newInventory(bool enable)
 94{
 95	// turning this off until bug EXP-62 can be fixed (inventory hint appears for new users when their initial inventory is acquired)
 96	// firstUseNotification("FirstInventoryOffer", enable, "HintInventory", LLSD(), LLSD().with("target", "inventory_btn").with("direction", "left"));
 97}
 98
 99// static
100void LLFirstUse::useSandbox()
101{
102	firstUseNotification("FirstSandbox", true, "FirstSandbox", LLSD().with("HOURS", SANDBOX_CLEAN_FREQ).with("TIME", SANDBOX_FIRST_CLEAN_HOUR));
103}
104
105// static
106void LLFirstUse::notUsingDestinationGuide(bool enable)
107{
108	// not doing this yet
109	firstUseNotification("FirstNotUseDestinationGuide", enable, "HintDestinationGuide", LLSD(), LLSD().with("target", "dest_guide_btn").with("direction", "top"));
110}
111
112// static
113void LLFirstUse::notUsingSidePanel(bool enable)
114{
115	// not doing this yet
116	//firstUseNotification("FirstNotUseSidePanel", enable, "HintSidePanel", LLSD(), LLSD().with("target", "side_panel_btn").with("direction", "left"));
117}
118
119// static
120void LLFirstUse::notMoving(bool enable)
121{
122	// fire off 2 notifications and rely on filtering to select the relevant one
123	firstUseNotification("FirstNotMoving", enable, "HintMove", LLSD(), LLSD().with("target", "move_btn").with("direction", "top"));
124	firstUseNotification("FirstNotMoving", enable, "HintMoveClick", LLSD(), LLSD()
125		.with("target", "nav_bar")
126		.with("direction", "bottom")
127		.with("hint_image", "click_to_move.png")
128		.with("up_arrow", ""));
129}
130
131// static
132void LLFirstUse::viewPopup(bool enable)
133{
134//	firstUseNotification("FirstViewPopup", enable, "HintView", LLSD(), LLSD().with("target", "view_popup").with("direction", "right"));
135}
136
137// static
138void LLFirstUse::setDisplayName(bool enable)
139{
140	firstUseNotification("FirstDisplayName", enable, "HintDisplayName", LLSD(), LLSD().with("target", "set_display_name").with("direction", "left"));
141}
142
143// static
144void LLFirstUse::receiveLindens(bool enable)
145{
146	firstUseNotification("FirstReceiveLindens", enable, "HintLindenDollar", LLSD(), LLSD().with("target", "linden_balance").with("direction", "bottom"));
147}
148
149
150//static 
151void LLFirstUse::firstUseNotification(const std::string& control_var, bool enable, const std::string& notification_name, LLSD args, LLSD payload)
152{
153	init();
154
155	if (enable)
156	{
157		if (gSavedSettings.getBOOL("EnableUIHints"))
158		{
159			LL_DEBUGS("LLFirstUse") << "Trigger first use notification " << notification_name << LL_ENDL;
160
161			// if notification doesn't already exist and this notification hasn't been disabled...
162			if (gWarningSettings.getBOOL(control_var))
163			{ // create new notification
164				LLNotifications::instance().add(LLNotification::Params().name(notification_name).substitutions(args).payload(payload.with("control_var", control_var)));
165			}
166		}
167	}	
168	else
169	{
170		LL_DEBUGS("LLFirstUse") << "Disabling first use notification " << notification_name << LL_ENDL;
171		LLNotifications::instance().cancelByName(notification_name);
172		// redundantly clear settings var here, in case there are no notifications to cancel
173		gWarningSettings.setBOOL(control_var, FALSE);
174	}
175
176}
177
178// static
179void LLFirstUse::init()
180{
181	static bool initialized = false;
182	if (!initialized)
183	{
184		LLNotifications::instance().getChannel("Hints")->connectChanged(&processNotification);
185	}
186	initialized = true;
187}
188
189//static 
190bool LLFirstUse::processNotification(const LLSD& notify)
191{
192	if (notify["sigtype"].asString() == "delete")
193	{
194		LLNotificationPtr notification = LLNotifications::instance().find(notify["id"].asUUID());
195		if (notification)
196		{
197			// disable any future notifications
198			gWarningSettings.setBOOL(notification->getPayload()["control_var"], FALSE);
199		}
200	}
201	return false;
202}