diff options
author | Jonathan Yap <none@none> | 2010-11-16 18:10:18 -0500 |
---|---|---|
committer | Jonathan Yap <none@none> | 2010-11-16 18:10:18 -0500 |
commit | 3b85391839da9077129830258d4a1d1ce6069cb3 (patch) | |
tree | f6f5551eab69a80adfb3f4d1b3a776bacae4eeca | |
parent | 5cbbb565f1bba870ec6db0b266e8768ecbdb7826 (diff) | |
parent | 978402adea173635c72cf8e81c375bbcc6bdd4ed (diff) |
Viewer 2.4 (as of 15 Nov 2010) with llTextBox support merged in
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llscriptfloater.cpp | 46 | ||||
-rw-r--r-- | indra/newview/llscriptfloater.h | 3 | ||||
-rw-r--r-- | indra/newview/lltoastgroupnotifypanel.cpp | 2 | ||||
-rw-r--r-- | indra/newview/lltoastnotifypanel.cpp | 17 | ||||
-rw-r--r-- | indra/newview/lltoastscripttextbox.cpp | 109 | ||||
-rw-r--r-- | indra/newview/lltoastscripttextbox.h | 58 | ||||
-rw-r--r-- | indra/newview/llviewermessage.cpp | 21 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_notify_textbox.xml | 68 |
9 files changed, 313 insertions, 13 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 09622d3af5..b478270586 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -443,6 +443,7 @@ set(viewer_SOURCE_FILES lltoastimpanel.cpp lltoastnotifypanel.cpp lltoastpanel.cpp + lltoastscripttextbox.cpp lltool.cpp lltoolbrush.cpp lltoolcomp.cpp @@ -971,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/llscriptfloater.cpp b/indra/newview/llscriptfloater.cpp index 2334f0cde5..170e23e4c5 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,32 @@ 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); + 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 371aad64bb..563c27c4d7 100644 --- a/indra/newview/lltoastgroupnotifypanel.cpp +++ b/indra/newview/lltoastgroupnotifypanel.cpp @@ -60,7 +60,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..3f7dc24ade 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" @@ -70,11 +71,11 @@ mCloseNotificationOnDestroy(true) 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 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 @@ -139,6 +140,12 @@ 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. continue; } LLButton* new_button = createButton(form_element, TRUE); @@ -159,7 +166,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 */ @@ -261,7 +268,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/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp new file mode 100644 index 0000000000..c013f521cc --- /dev/null +++ b/indra/newview/lltoastscripttextbox.cpp @@ -0,0 +1,109 @@ +/** + * @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 "llnotifications.h" +#include "llviewertexteditor.h" + +#include "llavatarnamecache.h" +#include "lluiconstants.h" +#include "llui.h" +#include "llviewercontrol.h" +#include "lltrans.h" +#include "llstyle.h" + +#include "llglheaders.h" +#include "llagent.h" + +const S32 LLToastScriptTextbox::DEFAULT_MESSAGE_MAX_LINE_COUNT= 7; + +LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) +: LLToastNotifyPanel(notification) +{ + buildFromFile( "panel_notify_textbox.xml"); + + const LLSD& payload = notification->getPayload(); + + //message body + const std::string& message = payload["message"].asString(); + + LLViewerTextEditor* pMessageText = getChild<LLViewerTextEditor>("message"); + pMessageText->clear(); + + LLStyle::Params style; + style.font = pMessageText->getDefaultFont(); + pMessageText->appendText(message, TRUE, style); + + //submit button + LLButton* pSubmitBtn = getChild<LLButton>("btn_submit"); + pSubmitBtn->setClickedCallback((boost::bind(&LLToastScriptTextbox::onClickSubmit, this))); + setDefaultBtn(pSubmitBtn); + + 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() +{ + die(); +} + +#include "lllslconstants.h" +void LLToastScriptTextbox::onClickSubmit() +{ + LLViewerTextEditor* pMessageText = getChild<LLViewerTextEditor>("message"); + + if (pMessageText) + { + LLSD response = mNotification->getResponseTemplate(); + response[TEXTBOX_MAGIC_TOKEN] = pMessageText->getText(); + if (response[TEXTBOX_MAGIC_TOKEN].asString().empty()) + { + // so we can distinguish between a successfully + // submitted blank textbox, and an ignored toast + response[TEXTBOX_MAGIC_TOKEN] = true; + } + mNotification->respond(response); + close(); + llwarns << response << llendl; + } +} diff --git a/indra/newview/lltoastscripttextbox.h b/indra/newview/lltoastscripttextbox.h new file mode 100644 index 0000000000..ae3b545e0a --- /dev/null +++ b/indra/newview/lltoastscripttextbox.h @@ -0,0 +1,58 @@ +/** + * @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 "lltoastnotifypanel.h" +#include "llnotificationptr.h" + +class LLButton; + +/** + * Toast panel for scripted llTextbox notifications. + */ +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 onClickSubmit(); +private: + static const S32 DEFAULT_MESSAGE_MAX_LINE_COUNT; +}; + +#endif diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 7c0fc681a4..700b5e9fb1 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -39,6 +39,7 @@ #include "llfloaterreg.h" #include "llfollowcamparams.h" #include "llinventorydefines.h" +#include "lllslconstants.h" #include "llregionhandle.h" #include "llsdserialize.h" #include "llteleportflags.h" @@ -6435,8 +6436,22 @@ const char* SCRIPT_DIALOG_HEADER = "Script Dialog:\n"; bool callback_script_dialog(const LLSD& notification, const LLSD& response) { LLNotificationForm form(notification["form"]); - std::string button = LLNotification::getSelectedOptionName(response); - S32 button_idx = LLNotification::getSelectedOption(notification, response); + + std::string rtn_text; + S32 button_idx; + button_idx = LLNotification::getSelectedOption(notification, response); + if (response[TEXTBOX_MAGIC_TOKEN].isDefined()) + { + if (response[TEXTBOX_MAGIC_TOKEN].isString()) + rtn_text = response[TEXTBOX_MAGIC_TOKEN].asString(); + else + rtn_text.clear(); // bool marks empty string + } + else + { + rtn_text = LLNotification::getSelectedOptionName(response); + } + // Didn't click "Ignore" if (button_idx != -1) { @@ -6449,7 +6464,7 @@ bool callback_script_dialog(const LLSD& notification, const LLSD& response) msg->addUUID("ObjectID", notification["payload"]["object_id"].asUUID()); msg->addS32("ChatChannel", notification["payload"]["chat_channel"].asInteger()); msg->addS32("ButtonIndex", button_idx); - msg->addString("ButtonLabel", button); + msg->addString("ButtonLabel", rtn_text); msg->sendReliable(LLHost(notification["payload"]["sender"].asString())); } 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..4634eeed46 --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_notify_textbox.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<panel + background_visible="true" + height="230" + label="instant_message" + layout="topleft" + left="0" + name="panel_notify_textbox" + top="0" + width="305"> + <string + name="message_max_lines_count" + value="7" /> + <panel + bevel_style="none" + follows="left|right|top" + height="150" + label="info_panel" + layout="topleft" + left="0" + name="info_panel" + top="0" + width="305"> + <text_editor + parse_urls="true" + enabled="true" + follows="all" + height="60" + layout="topleft" + left="25" + max_length="250" + name="message" + parse_highlights="true" + read_only="false" + top="40" + type="string" + use_ellipses="true" + value="message" + width="260" + word_wrap="true" > + </text_editor> + parse_urls="false" + <button + top="110" + follows="top|left" + height="20" + label="Submit" + layout="topleft" + left="25" + name="btn_submit" + width="70" /> + </panel> + <panel + background_visible="false" + follows="left|right|bottom" + height="0" + width="290" + label="control_panel" + layout="topleft" + left="10" + name="control_panel" + top_pad="5"> + <!-- + Notes: + This panel holds the Ignore button and possibly other buttons of notification. + --> + </panel> +</panel> |