diff options
| -rw-r--r-- | indra/llui/llnotifications.cpp | 8 | ||||
| -rw-r--r-- | indra/llui/llnotifications.h | 2 | ||||
| -rw-r--r-- | indra/newview/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | indra/newview/llnotificationhandler.h | 22 | ||||
| -rw-r--r-- | indra/newview/llnotificationmanager.cpp | 1 | ||||
| -rw-r--r-- | indra/newview/llnotificationscripthandler.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/llnotificationscripttextboxhandler.cpp | 174 | ||||
| -rw-r--r-- | indra/newview/llscriptfloater.cpp | 47 | ||||
| -rw-r--r-- | indra/newview/llscriptfloater.h | 3 | ||||
| -rw-r--r-- | indra/newview/lltoastgroupnotifypanel.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/lltoastnotifypanel.cpp | 62 | ||||
| -rw-r--r-- | indra/newview/lltoastnotifypanel.h | 2 | ||||
| -rw-r--r-- | indra/newview/lltoastscripttextbox.cpp | 215 | ||||
| -rw-r--r-- | indra/newview/lltoastscripttextbox.h | 79 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/panel_notify_textbox.xml | 101 | 
15 files changed, 702 insertions, 21 deletions
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 67b3c5cfce..30cd85619e 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -1060,12 +1060,12 @@ std::string LLNotificationChannel::summarize()  // LLNotifications implementation  // ---  LLNotifications::LLNotifications() : LLNotificationChannelBase(LLNotificationFilters::includeEverything, -															   LLNotificationComparators::orderByUUID()), -									mIgnoreAllNotifications(false) +							       LLNotificationComparators::orderByUUID()), +				     mIgnoreAllNotifications(false)  {  	LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Notification.Show", boost::bind(&LLNotifications::addFromCallback, this, _2)); - -    mListener.reset(new LLNotificationsListener(*this)); +	 +	mListener.reset(new LLNotificationsListener(*this));  } diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 4fe1687f0e..f075c44520 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -504,7 +504,7 @@ public:  	std::string getLabel() const;  	std::string getURL() const;  	S32 getURLOption() const; -    S32 getURLOpenExternally() const; +	S32 getURLOpenExternally() const;  	const LLNotificationFormPtr getForm(); diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 1f4302d870..300103929b 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -309,6 +309,7 @@ set(viewer_SOURCE_FILES      llnotificationmanager.cpp      llnotificationofferhandler.cpp      llnotificationscripthandler.cpp +    llnotificationscripttextboxhandler.cpp      llnotificationstorage.cpp      llnotificationtiphandler.cpp      lloutfitslist.cpp @@ -443,6 +444,7 @@ set(viewer_SOURCE_FILES      lltoastimpanel.cpp      lltoastnotifypanel.cpp      lltoastpanel.cpp +    lltoastscripttextbox.cpp      lltool.cpp      lltoolbrush.cpp      lltoolcomp.cpp @@ -970,6 +972,7 @@ set(viewer_HEADER_FILES      lltoastimpanel.h      lltoastnotifypanel.h      lltoastpanel.h +    lltoastscripttextbox.h      lltool.h      lltoolbrush.h      lltoolcomp.h diff --git a/indra/newview/llnotificationhandler.h b/indra/newview/llnotificationhandler.h index 28a69f2373..a9ae2bd21f 100644 --- a/indra/newview/llnotificationhandler.h +++ b/indra/newview/llnotificationhandler.h @@ -197,9 +197,29 @@ protected:  	virtual void initChannel();  	// own handlers -	void onRejectToast(LLUUID& id); +	virtual void onRejectToast(LLUUID& id);  }; +/** + * Handler for specific textbox-based script notices. + */ + +class LLScriptTextboxHandler : public LLSysHandler +{ + public: +	LLScriptTextboxHandler(e_notification_type type, const LLSD& id); +	virtual ~LLScriptTextboxHandler(); + +	// base interface functions +	virtual bool processNotification(const LLSD& notify); + +protected: +	virtual void onDeleteToast(LLToast* toast); +	virtual void initChannel(); + +	// own handlers +	virtual void onRejectToast(LLUUID& id); +};  /**   * Handler for group system notices. diff --git a/indra/newview/llnotificationmanager.cpp b/indra/newview/llnotificationmanager.cpp index 6988227128..3967117fc8 100644 --- a/indra/newview/llnotificationmanager.cpp +++ b/indra/newview/llnotificationmanager.cpp @@ -74,6 +74,7 @@ void LLNotificationManager::init()  	LLNotifications::instance().getChannel("Browser")->connectChanged(boost::bind(&LLBrowserNotification::processNotification, LLBrowserNotification::getInstance(), _1));  	mNotifyHandlers["notify"] = boost::shared_ptr<LLEventHandler>(new LLScriptHandler(NT_NOTIFY, LLSD())); +	//mNotifyHandlers["notify"] = boost::shared_ptr<LLEventHandler>(new LLScriptTextboxHandler(NT_NOTIFY, LLSD()));  	mNotifyHandlers["notifytip"] =  boost::shared_ptr<LLEventHandler>(new LLTipHandler(NT_NOTIFY, LLSD()));  	mNotifyHandlers["groupnotify"] = boost::shared_ptr<LLEventHandler>(new LLGroupHandler(NT_GROUPNOTIFY, LLSD()));  	mNotifyHandlers["alert"] = boost::shared_ptr<LLEventHandler>(new LLAlertHandler(NT_ALERT, LLSD())); diff --git a/indra/newview/llnotificationscripthandler.cpp b/indra/newview/llnotificationscripthandler.cpp index 45590c3cdb..eed0bdc15d 100644 --- a/indra/newview/llnotificationscripthandler.cpp +++ b/indra/newview/llnotificationscripthandler.cpp @@ -97,10 +97,12 @@ bool LLScriptHandler::processNotification(const LLSD& notify)  		if(SCRIPT_DIALOG == notification->getName() || SCRIPT_DIALOG_GROUP == notification->getName() || SCRIPT_LOAD_URL == notification->getName())  		{ +			llwarns << "DUMB ROUTE" << llendl;  			LLScriptFloaterManager::getInstance()->onAddNotification(notification->getID());  		}  		else  		{ +			llwarns << "SMART ROUTE" << llendl;  			LLToastNotifyPanel* notify_box = new LLToastNotifyPanel(notification);  			LLToast::Params p; diff --git a/indra/newview/llnotificationscripttextboxhandler.cpp b/indra/newview/llnotificationscripttextboxhandler.cpp new file mode 100644 index 0000000000..9556501c42 --- /dev/null +++ b/indra/newview/llnotificationscripttextboxhandler.cpp @@ -0,0 +1,174 @@ +/**  + * @file llnotificationscripthandler.cpp + * @brief Notification Handler Class for Simple Notifications and Notification Tips + * + * $LicenseInfo:firstyear=2000&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + *  + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + *  + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * Lesser General Public License for more details. + *  + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA + *  + * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA + * $/LicenseInfo$ + */ + + +#include "llviewerprecompiledheaders.h" // must be first include + +#include "llnotificationhandler.h" +#include "lltoastnotifypanel.h" +#include "llviewercontrol.h" +#include "llviewerwindow.h" +#include "llnotificationmanager.h" +#include "llnotifications.h" +#include "llscriptfloater.h" +#include "lltoastscripttextbox.h" + +using namespace LLNotificationsUI; + +static const std::string SCRIPT_DIALOG				("ScriptDialog"); +static const std::string SCRIPT_DIALOG_GROUP		("ScriptDialogGroup"); +static const std::string SCRIPT_LOAD_URL			("LoadWebPage"); + +//-------------------------------------------------------------------------- +LLScriptTextboxHandler::LLScriptTextboxHandler(e_notification_type type, const LLSD& id) +{ +	mType = type; + +	// Getting a Channel for our notifications +	mChannel = LLChannelManager::getInstance()->createNotificationChannel(); +	mChannel->setControlHovering(true); +	 +	LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel); +	if(channel) +		channel->setOnRejectToastCallback(boost::bind(&LLScriptTextboxHandler::onRejectToast, this, _1)); + +} + +//-------------------------------------------------------------------------- +LLScriptTextboxHandler::~LLScriptTextboxHandler() +{ +} + +//-------------------------------------------------------------------------- +void LLScriptTextboxHandler::initChannel() +{ +	S32 channel_right_bound = gViewerWindow->getWorldViewRectScaled().mRight - gSavedSettings.getS32("NotificationChannelRightMargin");  +	S32 channel_width = gSavedSettings.getS32("NotifyBoxWidth"); +	mChannel->init(channel_right_bound - channel_width, channel_right_bound); +} + +//-------------------------------------------------------------------------- +bool LLScriptTextboxHandler::processNotification(const LLSD& notify) +{ +	if(!mChannel) +	{ +		return false; +	} + +	LLNotificationPtr notification = LLNotifications::instance().find(notify["id"].asUUID()); + +	if(!notification) +		return false; + +	// arrange a channel on a screen +	if(!mChannel->getVisible()) +	{ +		initChannel(); +	} +	 +	if(notify["sigtype"].asString() == "add" || notify["sigtype"].asString() == "change") +	{ +		if (LLHandlerUtil::canLogToIM(notification)) +		{ +			LLHandlerUtil::logToIMP2P(notification); +		} + +		if(0)//(SCRIPT_DIALOG == notification->getName() || SCRIPT_DIALOG_GROUP == notification->getName() || SCRIPT_LOAD_URL == notification->getName()) +		{ +			LLScriptFloaterManager::getInstance()->onAddNotification(notification->getID()); +		} +		else +		{ +			LLToastScriptTextbox* notify_box = new LLToastScriptTextbox(notification); + +			LLToast::Params p; +			p.notif_id = notification->getID(); +			p.notification = notification; +			p.panel = notify_box;	 +			p.on_delete_toast = boost::bind(&LLScriptTextboxHandler::onDeleteToast, this, _1); + +			LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel); +			if(channel) +			{ +				channel->addToast(p); +			} + +			// send a signal to the counter manager +			mNewNotificationSignal(); +		} +	} +	else if (notify["sigtype"].asString() == "delete") +	{ +		if(SCRIPT_DIALOG == notification->getName() || SCRIPT_DIALOG_GROUP == notification->getName() || SCRIPT_LOAD_URL == notification->getName()) +		{ +			LLScriptFloaterManager::getInstance()->onRemoveNotification(notification->getID()); +		} +		else +		{ +			mChannel->killToastByNotificationID(notification->getID()); +		} +	} +	return false; +} + +//-------------------------------------------------------------------------- + +void LLScriptTextboxHandler::onDeleteToast(LLToast* toast) +{ +	// send a signal to the counter manager +	mDelNotificationSignal(); + +	// send a signal to a listener to let him perform some action +	// in this case listener is a SysWellWindow and it will remove a corresponding item from its list +	mNotificationIDSignal(toast->getNotificationID()); + +	LLNotificationPtr notification = LLNotifications::getInstance()->find(toast->getNotificationID()); +	 +	if( notification &&  +		(SCRIPT_DIALOG == notification->getName() || SCRIPT_DIALOG_GROUP == notification->getName()) ) +	{ +		LLScriptFloaterManager::getInstance()->onRemoveNotification(notification->getID()); +	} +} + +//-------------------------------------------------------------------------- +void LLScriptTextboxHandler::onRejectToast(LLUUID& id) +{ +	LLNotificationPtr notification = LLNotifications::instance().find(id); + +	if (notification +			&& LLNotificationManager::getInstance()->getHandlerForNotification( +					notification->getType()) == this) +	{ +		LLNotifications::instance().cancel(notification); +	} +} + +//-------------------------------------------------------------------------- + + + + diff --git a/indra/newview/llscriptfloater.cpp b/indra/newview/llscriptfloater.cpp index 2334f0cde5..53a5881f4b 100644 --- a/indra/newview/llscriptfloater.cpp +++ b/indra/newview/llscriptfloater.cpp @@ -32,11 +32,13 @@  #include "llchannelmanager.h"  #include "llchiclet.h"  #include "llfloaterreg.h" +#include "lllslconstants.h"  #include "llnotifications.h"  #include "llnotificationsutil.h"  #include "llscreenchannel.h"  #include "llsyswellwindow.h"  #include "lltoastnotifypanel.h" +#include "lltoastscripttextbox.h"  #include "lltrans.h"  #include "llviewerwindow.h"  #include "llimfloater.h" @@ -151,10 +153,18 @@ void LLScriptFloater::createForm(const LLUUID& notification_id)  	// create new form  	LLRect toast_rect = getRect(); -	// LLToastNotifyPanel will fit own content in vertical direction, -	// but it needs an initial rect to properly calculate  its width - 	// Use an initial rect of the script floater to make the floater window more configurable. -	mScriptForm = new LLToastNotifyPanel(notification, toast_rect);  +	if (isScriptTextbox(notification)) +	{ +		mScriptForm = new LLToastScriptTextbox(notification); +	} +	else +	{ +		// LLToastNotifyPanel will fit own content in vertical direction, +		// but it needs an initial rect to properly calculate  its width +		// Use an initial rect of the script floater to make the floater +		// window more configurable. +		mScriptForm = new LLToastNotifyPanel(notification, toast_rect);  +	}  	addChild(mScriptForm);  	// position form on floater @@ -564,4 +574,33 @@ void LLScriptFloaterManager::setFloaterVisible(const LLUUID& notification_id, bo  	}  } +////////////////////////////////////////////////////////////////// + +bool LLScriptFloater::isScriptTextbox(LLNotificationPtr notification) +{ +	// get a form for the notification +	LLNotificationFormPtr form(notification->getForm()); + +	if (form) +	{ +		// get number of elements in the form +		int num_options = form->getNumElements(); +	 +		// if ANY of the buttons have the magic lltextbox string as +		// name, then treat the whole dialog as a simple text entry +		// box (i.e. mixed button and textbox forms are not supported) +		for (int i=0; i<num_options; ++i) +		{ +			LLSD form_element = form->getElement(i); +			llwarns << form_element << llendl; +			if (form_element["name"].asString() == TEXTBOX_MAGIC_TOKEN) +			{ +				return true; +			} +		} +	} + +	return false; +} +  // EOF diff --git a/indra/newview/llscriptfloater.h b/indra/newview/llscriptfloater.h index da70bb4334..dc52baa115 100644 --- a/indra/newview/llscriptfloater.h +++ b/indra/newview/llscriptfloater.h @@ -28,6 +28,7 @@  #define LL_SCRIPTFLOATER_H  #include "lltransientdockablefloater.h" +#include "llnotificationptr.h"  class LLToastNotifyPanel; @@ -203,6 +204,8 @@ protected:  	void dockToChiclet(bool dock);  private: +	bool isScriptTextbox(LLNotificationPtr notification); +  	LLToastNotifyPanel* mScriptForm;  	LLUUID mNotificationId;  	LLUUID mObjectId; diff --git a/indra/newview/lltoastgroupnotifypanel.cpp b/indra/newview/lltoastgroupnotifypanel.cpp index 78cc96b353..3fb65368c3 100644 --- a/indra/newview/lltoastgroupnotifypanel.cpp +++ b/indra/newview/lltoastgroupnotifypanel.cpp @@ -59,7 +59,7 @@ LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(LLNotificationPtr& notification  	LLGroupData groupData;  	if (!gAgent.getGroupData(payload["group_id"].asUUID(),groupData))  	{ -		llwarns << "Group notice for unkown group: " << payload["group_id"].asUUID() << llendl; +		llwarns << "Group notice for unknown group: " << payload["group_id"].asUUID() << llendl;  	}  	//group icon diff --git a/indra/newview/lltoastnotifypanel.cpp b/indra/newview/lltoastnotifypanel.cpp index 9017f5ec55..51f32331d8 100644 --- a/indra/newview/lltoastnotifypanel.cpp +++ b/indra/newview/lltoastnotifypanel.cpp @@ -33,6 +33,7 @@  // library includes  #include "lldbstrings.h" +#include "lllslconstants.h"  #include "llnotifications.h"  #include "lluiconstants.h"  #include "llrect.h" @@ -54,6 +55,7 @@ LLToastNotifyPanel::button_click_signal_t LLToastNotifyPanel::sButtonClickSignal  LLToastNotifyPanel::LLToastNotifyPanel(LLNotificationPtr& notification, const LLRect& rect, bool show_images) :   LLToastPanel(notification),  mTextBox(NULL), +mUserInputBox(NULL),  mInfoPanel(NULL),  mControlPanel(NULL),  mNumOptions(0), @@ -66,15 +68,43 @@ mCloseNotificationOnDestroy(true)  	{  		this->setShape(rect);  	}		  +	// get a form for the notification +	LLNotificationFormPtr form(notification->getForm()); +	// get number of elements +	mNumOptions = form->getNumElements(); +  	mInfoPanel = getChild<LLPanel>("info_panel");  	mControlPanel = getChild<LLPanel>("control_panel");  	BUTTON_WIDTH = gSavedSettings.getS32("ToastButtonWidth"); +  	// customize panel's attributes -	// is it intended for displaying a tip + +	// is it intended for displaying a tip?  	mIsTip = notification->getType() == "notifytip"; -	// is it a script dialog +	// is it a script dialog?  	mIsScriptDialog = (notification->getName() == "ScriptDialog" || notification->getName() == "ScriptDialogGroup"); -	// is it a caution +	// is it a script dialog with llTextBox()? +	mIsScriptTextBox = false; +	if (mIsScriptDialog) +	{ +		// if ANY of the buttons have the magic lltextbox string as name, then +		// treat the whole dialog as a simple text entry box (i.e. mixed button +		// and textbox forms are not supported) +		for (int i=0; i<mNumOptions; ++i) +		{ +			LLSD form_element = form->getElement(i); +			llwarns << form_element << llendl; +			if (form_element["name"].asString() == TEXTBOX_MAGIC_TOKEN) +			{ +				mIsScriptTextBox = true; +				break; +			} +		} +	} +	llwarns << "FORM ELEMS " << int(form->getNumElements()) << llendl; +	llwarns << "isScriptDialog? " << int(mIsScriptDialog) << llendl; +	llwarns << "isScriptTextBox? " << int(mIsScriptTextBox) << llendl; +	// is it a caution?  	//  	// caution flag can be set explicitly by specifying it in the notification payload, or it can be set implicitly if the  	// notify xml template specifies that it is a caution @@ -94,10 +124,6 @@ mCloseNotificationOnDestroy(true)  	setIsChrome(TRUE);  	// initialize  	setFocusRoot(!mIsTip); -	// get a form for the notification -	LLNotificationFormPtr form(notification->getForm()); -	// get number of elements -	mNumOptions = form->getNumElements();  	// customize panel's outfit  	// preliminary adjust panel's layout @@ -123,6 +149,11 @@ mCloseNotificationOnDestroy(true)  	mTextBox->setPlainText(!show_images);  	mTextBox->setValue(notification->getMessage()); +	mUserInputBox = getChild<LLTextEditor>("user_input_box");  +	mUserInputBox->setMaxTextLength(254);// FIXME +	mUserInputBox->setVisible(FALSE); +	mUserInputBox->setEnabled(FALSE); +  	// add buttons for a script notification  	if (mIsTip)  	{ @@ -139,6 +170,17 @@ mCloseNotificationOnDestroy(true)  			LLSD form_element = form->getElement(i);  			if (form_element["type"].asString() != "button")  			{ +				// not a button. +				continue; +			} +			if (form_element["name"].asString() == TEXTBOX_MAGIC_TOKEN) +			{ +				// a textbox pretending to be a button. +				// (re)enable the textbox for this panel, and continue. +				mUserInputBox->setVisible(TRUE); +				mUserInputBox->setEnabled(TRUE); +				mUserInputBox->setFocus(TRUE); +				mUserInputBox->insertText("FOOOOOO!!!!");  				continue;  			}  			LLButton* new_button = createButton(form_element, TRUE); @@ -159,7 +201,7 @@ mCloseNotificationOnDestroy(true)  			if(h_pad < 2*HPAD)  			{  				/* -				 * Probably it is  a scriptdialog toast +				 * Probably it is a scriptdialog toast  				 * for a scriptdialog toast h_pad can be < 2*HPAD if we have a lot of buttons.  				 * In last case set default h_pad to avoid heaping of buttons   				 */ @@ -253,7 +295,7 @@ LLButton* LLToastNotifyPanel::createButton(const LLSD& form_element, BOOL is_opt  		p.image_color(LLUIColorTable::instance().getColor("ButtonCautionImageColor"));  		p.image_color_disabled(LLUIColorTable::instance().getColor("ButtonCautionImageColor"));  	} -	// for the scriptdialog buttons we use fixed button size. This  is a limit! +	// for the scriptdialog buttons we use fixed button size. This is a limit!  	if (!mIsScriptDialog && font->getWidth(form_element["text"].asString()) > BUTTON_WIDTH)  	{  		p.rect.width = 1; @@ -261,7 +303,7 @@ LLButton* LLToastNotifyPanel::createButton(const LLSD& form_element, BOOL is_opt  	}  	else if (mIsScriptDialog && is_ignore_btn)  	{ -		// this is ignore button,make it smaller +		// this is ignore button, make it smaller  		p.rect.height = BTN_HEIGHT_SMALL;  		p.rect.width = 1;  		p.auto_resize = true; diff --git a/indra/newview/lltoastnotifypanel.h b/indra/newview/lltoastnotifypanel.h index 57711b3d80..06f6767ccd 100644 --- a/indra/newview/lltoastnotifypanel.h +++ b/indra/newview/lltoastnotifypanel.h @@ -99,6 +99,7 @@ protected:  	// panel elements  	LLTextBase*		mTextBox; +	LLTextEditor*           mUserInputBox;  	LLPanel*		mInfoPanel;		// a panel, that contains an information  	LLPanel*		mControlPanel;	// a panel, that contains buttons (if present) @@ -121,6 +122,7 @@ protected:  	void disableRespondedOptions(LLNotificationPtr& notification);  	bool mIsTip; +	bool mIsScriptTextBox;  	bool mAddedDefaultBtn;  	bool mIsScriptDialog;  	bool mIsCaution;  diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp new file mode 100644 index 0000000000..64360b9e48 --- /dev/null +++ b/indra/newview/lltoastscripttextbox.cpp @@ -0,0 +1,215 @@ +/** + * @file lltoastscripttextbox.cpp + * @brief Panel for script llTextBox dialogs + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + *  + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + *  + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * Lesser General Public License for more details. + *  + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA + *  + * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "lltoastscripttextbox.h" + +#include "llfocusmgr.h" + +#include "llbutton.h" +#include "lliconctrl.h" +#include "llinventoryfunctions.h" +#include "llnotifications.h" +#include "llviewertexteditor.h" + +#include "lluiconstants.h" +#include "llui.h" +#include "llviewercontrol.h" +#include "lltrans.h" +#include "llstyle.h" + +#include "llglheaders.h" +#include "llagent.h" +#include "llavatariconctrl.h" +#include "llfloaterinventory.h" +#include "llinventorytype.h" + +const S32 LLToastScriptTextbox::DEFAULT_MESSAGE_MAX_LINE_COUNT	= 7; + +LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) +:	LLToastNotifyPanel(notification), +	mInventoryOffer(NULL) +{ +	buildFromFile( "panel_notify_textbox.xml"); + +	const LLSD& payload = notification->getPayload(); +	LLGroupData groupData; +	if (!gAgent.getGroupData(payload["group_id"].asUUID(),groupData)) +	{ +		llwarns << "Group notice for unknown group: " << payload["group_id"].asUUID() << llendl; +	} + +	//group icon +	LLIconCtrl* pGroupIcon = getChild<LLIconCtrl>("group_icon", TRUE); +	pGroupIcon->setValue(groupData.mInsigniaID); + +	//header title +	const std::string& from_name = payload["sender_name"].asString(); +	std::stringstream from; +	from << from_name << "/" << groupData.mName; +	LLTextBox* pTitleText = getChild<LLTextBox>("title"); +	pTitleText->setValue(from.str()); + +	//message subject +	const std::string& subject = payload["subject"].asString(); +	//message body +	const std::string& message = payload["message"].asString(); + +	std::string timeStr = "["+LLTrans::getString("UTCTimeWeek")+"],[" +		+LLTrans::getString("UTCTimeDay")+"] [" +		+LLTrans::getString("UTCTimeMth")+"] [" +		+LLTrans::getString("UTCTimeYr")+"] [" +		+LLTrans::getString("UTCTimeHr")+"]:[" +		+LLTrans::getString("UTCTimeMin")+"]:[" +		+LLTrans::getString("UTCTimeSec")+"] [" +		+LLTrans::getString("UTCTimeTimezone")+"]"; +	const LLDate timeStamp = notification->getDate(); +	LLDate notice_date = timeStamp.notNull() ? timeStamp : LLDate::now(); +	LLSD substitution; +	substitution["datetime"] = (S32) notice_date.secondsSinceEpoch(); +	LLStringUtil::format(timeStr, substitution); + +	LLViewerTextEditor* pMessageText = getChild<LLViewerTextEditor>("message"); +	pMessageText->clear(); + +	LLStyle::Params style; +	LLFontGL* subject_font = LLFontGL::getFontByName(getString("subject_font")); +	if (subject_font)  +		style.font = subject_font; +	pMessageText->appendText(subject, FALSE, style); + +	LLFontGL* date_font = LLFontGL::getFontByName(getString("date_font")); +	if (date_font) +		style.font = date_font; +	pMessageText->appendText(timeStr + "\n", TRUE, style); +	 +	style.font = pMessageText->getDefaultFont(); +	pMessageText->appendText(message, TRUE, style); + +	//attachment +	BOOL hasInventory = payload["inventory_offer"].isDefined(); + +	//attachment text +	LLTextBox * pAttachLink = getChild<LLTextBox>("attachment"); +	//attachment icon +	LLIconCtrl* pAttachIcon = getChild<LLIconCtrl>("attachment_icon", TRUE); + +	//If attachment is empty let it be invisible and not take place at the panel +	pAttachLink->setVisible(hasInventory); +	pAttachIcon->setVisible(hasInventory); +	if (hasInventory) { +		pAttachLink->setValue(payload["inventory_name"]); + +		mInventoryOffer = new LLOfferInfo(payload["inventory_offer"]); +		getChild<LLTextBox>("attachment")->setClickedCallback(boost::bind( +				&LLToastScriptTextbox::onClickAttachment, this)); + +		LLUIImagePtr attachIconImg = LLInventoryIcon::getIcon(mInventoryOffer->mType, +												LLInventoryType::IT_TEXTURE); +		pAttachIcon->setValue(attachIconImg->getName()); +	} + +	//ok button +	LLButton* pOkBtn = getChild<LLButton>("btn_ok"); +	pOkBtn->setClickedCallback((boost::bind(&LLToastScriptTextbox::onClickOk, this))); +	setDefaultBtn(pOkBtn); + +	S32 maxLinesCount; +	std::istringstream ss( getString("message_max_lines_count") ); +	if (!(ss >> maxLinesCount)) +	{ +		maxLinesCount = DEFAULT_MESSAGE_MAX_LINE_COUNT; +	} +	snapToMessageHeight(pMessageText, maxLinesCount); +} + +// virtual +LLToastScriptTextbox::~LLToastScriptTextbox() +{ +} + +void LLToastScriptTextbox::close() +{ +	// The group notice dialog may be an inventory offer. +	// If it has an inventory save button and that button is still enabled +	// Then we need to send the inventory declined message +	if(mInventoryOffer != NULL) +	{ +		mInventoryOffer->forceResponse(IOR_DECLINE); +		mInventoryOffer = NULL; +	} + +	die(); +} + +void LLToastScriptTextbox::onClickOk() +{ +	LLSD response = mNotification->getResponseTemplate(); +	mNotification->respond(response); +	close(); +} + +void LLToastScriptTextbox::onClickAttachment() +{ +	if (mInventoryOffer != NULL) { +		mInventoryOffer->forceResponse(IOR_ACCEPT); + +		LLTextBox * pAttachLink = getChild<LLTextBox> ("attachment"); +		static const LLUIColor textColor = LLUIColorTable::instance().getColor( +				"GroupNotifyDimmedTextColor"); +		pAttachLink->setColor(textColor); + +		LLIconCtrl* pAttachIcon = +				getChild<LLIconCtrl> ("attachment_icon", TRUE); +		pAttachIcon->setEnabled(FALSE); + +		//if attachment isn't openable - notify about saving +		if (!isAttachmentOpenable(mInventoryOffer->mType)) { +			LLNotifications::instance().add("AttachmentSaved", LLSD(), LLSD()); +		} + +		mInventoryOffer = NULL; +	} +} + +//static +bool LLToastScriptTextbox::isAttachmentOpenable(LLAssetType::EType type) +{ +	switch(type) +	{ +	case LLAssetType::AT_LANDMARK: +	case LLAssetType::AT_NOTECARD: +	case LLAssetType::AT_IMAGE_JPEG: +	case LLAssetType::AT_IMAGE_TGA: +	case LLAssetType::AT_TEXTURE: +	case LLAssetType::AT_TEXTURE_TGA: +		return true; +	default: +		return false; +	} +} + diff --git a/indra/newview/lltoastscripttextbox.h b/indra/newview/lltoastscripttextbox.h new file mode 100644 index 0000000000..86fe93cf66 --- /dev/null +++ b/indra/newview/lltoastscripttextbox.h @@ -0,0 +1,79 @@ +/** + * @file lltoastscripttextbox.h + * @brief Panel for script llTextBox dialogs + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + *  + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + *  + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * Lesser General Public License for more details. + *  + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA + *  + * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLTOASTSCRIPTTEXTBOX_H +#define LL_LLTOASTSCRIPTTEXTBOX_H + +#include "llfontgl.h" +#include "lltoastnotifypanel.h" +#include "lldarray.h" +#include "lltimer.h" +#include "llviewermessage.h" +#include "llnotificationptr.h" + +class LLButton; + +/** + * Toast panel for group notification. + * + * Replaces class LLGroupNotifyBox. + */ +class LLToastScriptTextbox +:	public LLToastNotifyPanel +{ +public: +	void close(); + +	static bool onNewNotification(const LLSD& notification); + + +	// Non-transient messages.  You can specify non-default button +	// layouts (like one for script dialogs) by passing various +	// numbers in for "layout". +	LLToastScriptTextbox(LLNotificationPtr& notification); + +	/*virtual*/ ~LLToastScriptTextbox(); +protected: +	void onClickOk(); +	void onClickAttachment(); +private: +	static bool isAttachmentOpenable(LLAssetType::EType); + +	static const S32 DEFAULT_MESSAGE_MAX_LINE_COUNT; + +	LLButton* mSaveInventoryBtn; + +	LLUUID mGroupID; +	LLOfferInfo* mInventoryOffer; +}; + +// This view contains the stack of notification windows. +//extern LLView* gGroupNotifyBoxView; + +const S32 GROUP_LAYOUT_DEFAULT = 0; +const S32 GROUP_LAYOUT_SCRIPT_DIALOG = 1; + +#endif diff --git a/indra/newview/skins/default/xui/en/panel_notify_textbox.xml b/indra/newview/skins/default/xui/en/panel_notify_textbox.xml new file mode 100644 index 0000000000..a0d103e2a3 --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_notify_textbox.xml @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<panel + background_visible="true" + height="90" + label="instant_message" + layout="topleft" + left="0" + name="panel_notify_textbox" + top="0" + width="305"> +    <string +     name="message_max_lines_count" +     value="7" /> +    <string +     name="subject_font" +     value="SANSSERIF_BIG" /> +    <string +     name="date_font" +     value="SANSSERIF" /> +    <panel +     background_visible="true" +     follows="top" +     height="30" +     label="header" +     layout="topleft" +     left="0" +     name="header" +     top="0" +     width="305"> +        <icon +         follows="all" +         height="20" +         layout="topleft" +         left="5" +         mouse_opaque="true" +         name="group_icon" +         top="5" +         width="20" /> +        <text +         follows="all" +         font="SansSerifBig" +         height="20" +         layout="topleft" +         left_pad="10" +         name="title" +         text_color="GroupNotifyTextColor" +         top="5" +         use_ellipses="true" +         value="Sender Name / Group Name" +         width="230" /> +    </panel> +    <text_editor +     parse_urls="true" +     enabled="true" +     follows="all" +     height="0" +     layout="topleft" +     left="25" +     max_length="2147483647" +     name="message" +     parse_highlights="true" +     read_only="true" +     text_color="GroupNotifyTextColor" +     top="40" +     type="string" +     use_ellipses="true" +     value="message" +     width="270" +	 word_wrap="true" > +    </text_editor> +    <icon +     bottom="60" +     follows="left|bottom|right" +     height="15" +     layout="topleft" +     left="25" +     mouse_opaque="true" +     name="attachment_icon" +     width="15" /> +    <text +     bottom="60" +     follows="left|bottom|right" +     font="SansSerif" +     height="15" +     layout="topleft" +     left="45" +     name="attachment" +     text_color="GroupNotifyTextColor" +     value="Attachment" +     use_ellipses="true" +     width="250" /> +    <button +     bottom="85" +     follows="bottom" +     height="20" +     label="OK" +     layout="topleft" +     right="-10" +     name="btn_ok" +     width="70" /> +</panel>  | 
