From 3780c86538ee667bb74f0a70bcf870ec554eda75 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 16 Apr 2021 00:01:57 +0300 Subject: SL-15028 Move guidebook code into own flaoter To help with dispatcher and unify code --- indra/newview/llfloaterhowto.cpp | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 indra/newview/llfloaterhowto.cpp (limited to 'indra/newview/llfloaterhowto.cpp') diff --git a/indra/newview/llfloaterhowto.cpp b/indra/newview/llfloaterhowto.cpp new file mode 100644 index 0000000000..d6c4ed1b20 --- /dev/null +++ b/indra/newview/llfloaterhowto.cpp @@ -0,0 +1,66 @@ +/** + * @file llfloaterhowto.cpp + * @brief A variant of web floater meant to open guidebook + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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 "llfloaterhowto.h" + +#include "llfloaterreg.h" +#include "llviewercontrol.h" +#include "llweb.h" + + +LLFloaterHowTo::LLFloaterHowTo(const Params& key) : + LLFloaterWebContent(key) +{ + mShowPageTitle = false; +} + +BOOL LLFloaterHowTo::postBuild() +{ + LLFloaterWebContent::postBuild(); + + return TRUE; +} + +void LLFloaterHowTo::onOpen(const LLSD& key) +{ + LLFloaterWebContent::Params p(key); + if (!p.url.isProvided() || p.url.getValue().empty()) + { + std::string url = gSavedSettings.getString("GuidebookURL"); + p.url = LLWeb::expandURLSubstitutions(url, LLSD()); + p.show_chrome = false; + p.preferred_media_size = LLRect(0, 500, 300, 0); + } + + LLFloaterWebContent::onOpen(p); +} + +LLFloaterHowTo* LLFloaterHowTo::getInstance() +{ + return LLFloaterReg::getTypedInstance("how_to"); +} -- cgit v1.3 From d298c9983b9ffc9f212fd9325b1ff5f0e6e7aaab Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 20 Apr 2021 20:00:42 +0300 Subject: SL-14906 Fix LLFloaterHowTo overriding stored position preferred_media_size was repositioning the floater --- indra/newview/llfloaterhowto.cpp | 21 ++++++++++++++------- .../newview/skins/default/xui/en/floater_how_to.xml | 6 ++---- 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'indra/newview/llfloaterhowto.cpp') diff --git a/indra/newview/llfloaterhowto.cpp b/indra/newview/llfloaterhowto.cpp index d6c4ed1b20..665955c946 100644 --- a/indra/newview/llfloaterhowto.cpp +++ b/indra/newview/llfloaterhowto.cpp @@ -33,6 +33,9 @@ #include "llweb.h" +const S32 STACK_WIDTH = 300; +const S32 STACK_HEIGHT = 505; // content will be 500 + LLFloaterHowTo::LLFloaterHowTo(const Params& key) : LLFloaterWebContent(key) { @@ -49,15 +52,19 @@ BOOL LLFloaterHowTo::postBuild() void LLFloaterHowTo::onOpen(const LLSD& key) { LLFloaterWebContent::Params p(key); - if (!p.url.isProvided() || p.url.getValue().empty()) - { - std::string url = gSavedSettings.getString("GuidebookURL"); - p.url = LLWeb::expandURLSubstitutions(url, LLSD()); - p.show_chrome = false; - p.preferred_media_size = LLRect(0, 500, 300, 0); - } + std::string url = gSavedSettings.getString("GuidebookURL"); + p.url = LLWeb::expandURLSubstitutions(url, LLSD()); + p.show_chrome = false; LLFloaterWebContent::onOpen(p); + + // Elements from LLFloaterWebContent did not pick up restored size (save_rect) of LLFloaterHowTo + // set the stack size and position (alternative to preferred_media_size) + LLLayoutStack *stack = getChild("stack1"); + LLRect stack_rect = stack->getRect(); + stack->reshape(STACK_WIDTH, STACK_HEIGHT); + stack->setOrigin(stack_rect.mLeft, stack_rect.mTop - STACK_HEIGHT); + stack->updateLayout(); } LLFloaterHowTo* LLFloaterHowTo::getInstance() diff --git a/indra/newview/skins/default/xui/en/floater_how_to.xml b/indra/newview/skins/default/xui/en/floater_how_to.xml index c06ff7be28..b4dd2e252f 100644 --- a/indra/newview/skins/default/xui/en/floater_how_to.xml +++ b/indra/newview/skins/default/xui/en/floater_how_to.xml @@ -4,14 +4,12 @@ can_resize="false" can_minimize="false" can_close="false" - height="775" + height="525" layout="topleft" - top="0" - min_width="335" name="floater_how_to" single_instance="true" save_visibility="true" save_rect="true" title="WELCOME ISLAND GUIDEBOOK" - width="780" + width="310" filename="floater_web_content.xml"/> \ No newline at end of file -- cgit v1.3 From cfb6ca569b2c834520ce50564e857dfc06831675 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 6 May 2021 00:46:14 +0300 Subject: SL-15168 Viewer side functionality for guidebook window opening --- indra/newview/CMakeLists.txt | 2 + indra/newview/llappviewer.cpp | 2 + indra/newview/llenvironment.cpp | 2 +- indra/newview/llfloaterhowto.cpp | 7 +- indra/newview/llstartup.cpp | 2 - indra/newview/llurlfloaterdispatchhandler.cpp | 107 ++++++++++++++++++++++++++ indra/newview/llurlfloaterdispatchhandler.h | 46 +++++++++++ 7 files changed, 163 insertions(+), 5 deletions(-) create mode 100644 indra/newview/llurlfloaterdispatchhandler.cpp create mode 100644 indra/newview/llurlfloaterdispatchhandler.h (limited to 'indra/newview/llfloaterhowto.cpp') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 82dcd402be..e8e5b83957 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -638,6 +638,7 @@ set(viewer_SOURCE_FILES llurl.cpp llurldispatcher.cpp llurldispatcherlistener.cpp + llurlfloaterdispatchhandler.cpp llurlhistory.cpp llurllineeditorctrl.cpp llurlwhitelist.cpp @@ -1269,6 +1270,7 @@ set(viewer_HEADER_FILES llurl.h llurldispatcher.h llurldispatcherlistener.h + llurlfloaterdispatchhandler.h llurlhistory.h llurllineeditorctrl.h llurlwhitelist.h diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 0b2cdff36c..9d03edc060 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -59,6 +59,7 @@ #include "llslurl.h" #include "llstartup.h" #include "llfocusmgr.h" +#include "llurlfloaterdispatchhandler.h" #include "llviewerjoystick.h" #include "llallocator.h" #include "llcalc.h" @@ -917,6 +918,7 @@ bool LLAppViewer::init() // Load translations for tooltips LLFloater::initClass(); + LLUrlFloaterDispatchHandler::registerInDispatcher(); ///////////////////////////////////////////////// diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 90d22c57b0..190051d763 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -327,7 +327,7 @@ namespace std::istringstream llsdData(llsdRaw); if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length())) { - LL_WARNS() << "LLExperienceLogDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL; + LL_WARNS() << "LLEnvironmentPushDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL; } } diff --git a/indra/newview/llfloaterhowto.cpp b/indra/newview/llfloaterhowto.cpp index 665955c946..9db733db25 100644 --- a/indra/newview/llfloaterhowto.cpp +++ b/indra/newview/llfloaterhowto.cpp @@ -52,8 +52,11 @@ BOOL LLFloaterHowTo::postBuild() void LLFloaterHowTo::onOpen(const LLSD& key) { LLFloaterWebContent::Params p(key); - std::string url = gSavedSettings.getString("GuidebookURL"); - p.url = LLWeb::expandURLSubstitutions(url, LLSD()); + if (!p.url.isProvided() || p.url.getValue().empty()) + { + std::string url = gSavedSettings.getString("GuidebookURL"); + p.url = LLWeb::expandURLSubstitutions(url, LLSD()); + } p.show_chrome = false; LLFloaterWebContent::onOpen(p); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 0ea5de8d67..55048b03be 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1905,8 +1905,6 @@ bool idle_startup() // Set the show start location to true, now that the user has logged // on with this install. gSavedSettings.setBOOL("ShowStartLocation", TRUE); - - LLFloaterReg::toggleInstanceOrBringToFront("how_to"); } display_startup(); diff --git a/indra/newview/llurlfloaterdispatchhandler.cpp b/indra/newview/llurlfloaterdispatchhandler.cpp new file mode 100644 index 0000000000..7f9929041d --- /dev/null +++ b/indra/newview/llurlfloaterdispatchhandler.cpp @@ -0,0 +1,107 @@ +/** + * @file llurlfloaterdispatchhandler.cpp + * @brief Handles URLFloater generic message from server + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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 "llurlfloaterdispatchhandler.h" + +#include "llfloaterreg.h" +#include "llfloaterwebcontent.h" +#include "llsdserialize.h" +#include "llviewercontrol.h" +#include "llviewergenericmessage.h" +#include "llweb.h" + +// values specified by server side's dispatcher +const std::string MESSAGE_URL_FLOATER("URLFloater"); +const std::string KEY_ACTION("OpenURL"); +const std::string KEY_PARAMS("floater_params"); +const std::string KEY_FLOATER("floater_title"); +const std::string KEY_URL("floater_url"); + +LLUrlFloaterDispatchHandler LLUrlFloaterDispatchHandler::sUrlDispatchhandler; + +LLUrlFloaterDispatchHandler::LLUrlFloaterDispatchHandler() +{ +} + +LLUrlFloaterDispatchHandler::~LLUrlFloaterDispatchHandler() +{ +} + +void LLUrlFloaterDispatchHandler::registerInDispatcher() +{ + if (!gGenericDispatcher.isHandlerPresent(MESSAGE_URL_FLOATER)) + { + gGenericDispatcher.addHandler(MESSAGE_URL_FLOATER, &sUrlDispatchhandler); + } +} + +//virtual +bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::string& key, const LLUUID& invoice, const sparam_t& strings) +{ + // invoice - transaction id + + LLSD message; + sparam_t::const_iterator it = strings.begin(); + + if (it != strings.end()) + { + const std::string& llsdRaw = *it++; + std::istringstream llsdData(llsdRaw); + if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length())) + { + LL_WARNS("URLFloater") << "Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL; + } + } + + std::string floater = message[KEY_FLOATER]; + LLSD &command_params = message[KEY_PARAMS]; + + LLFloaterWebContent::Params params; + params.url = message[KEY_URL]; + + if (floater == "guidebook" || floater == "how_to") + { + if (command_params.isMap()) // by default is undefines + { + params.trusted_content = command_params.has("trusted_content") ? command_params["trusted_content"] : false; + } + LLFloaterReg::toggleInstanceOrBringToFront("how_to", params); + } + else if (!params.url.getValue().empty()) + { + if (command_params.isMap()) // by default is undefines + { + params.trusted_content = command_params.has("trusted_content") ? command_params["trusted_content"] : false; + params.show_page_title = command_params.has("show_page_title") ? command_params["show_page_title"] : true; + params.allow_address_entry = command_params.has("allow_address_entry") ? command_params["allow_address_entry"] : true; + } + LLFloaterReg::showInstance("web_content", params); + } + + return true; +} diff --git a/indra/newview/llurlfloaterdispatchhandler.h b/indra/newview/llurlfloaterdispatchhandler.h new file mode 100644 index 0000000000..469f76b007 --- /dev/null +++ b/indra/newview/llurlfloaterdispatchhandler.h @@ -0,0 +1,46 @@ +/** + * @file llurlfloaterdispatchhandler.h + * @brief Handles URLFloater generic message from server + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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_LLURLFLOATERDISPATCHHANDLER_H +#define LL_LLURLFLOATERDISPATCHHANDLER_H + +#include "lldispatcher.h" + +class LLUrlFloaterDispatchHandler : public LLDispatchHandler +{ +public: + LLUrlFloaterDispatchHandler(); + virtual ~LLUrlFloaterDispatchHandler(); + virtual bool operator()(const LLDispatcher *, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override; + + static void registerInDispatcher(); + +private: + static LLUrlFloaterDispatchHandler sUrlDispatchhandler; +}; + +#endif // LL_LLURLFLOATERDISPATCHHANDLER_H + -- cgit v1.3 From cb42bc2823931b84ce079423a471a332dc332b0c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 6 May 2021 21:57:46 +0300 Subject: SL-15168 Viewer side functionality for guidebook window opening #2 --- indra/llui/llfloaterreg.cpp | 6 ++ indra/llui/llfloaterreg.h | 1 + indra/newview/llfloaterhowto.cpp | 17 +++--- indra/newview/llfloaterhowto.h | 3 + indra/newview/llurlfloaterdispatchhandler.cpp | 80 ++++++++++++++++++++++++--- indra/newview/llurlfloaterdispatchhandler.h | 3 + 6 files changed, 96 insertions(+), 14 deletions(-) (limited to 'indra/newview/llfloaterhowto.cpp') diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index 7c0933f554..36a0cb0fd0 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -57,6 +57,12 @@ void LLFloaterReg::add(const std::string& name, const std::string& filename, con sGroupMap[groupname] = groupname; // for referencing directly by group name } +//static +bool LLFloaterReg::isRegistered(const std::string& name) +{ + return sBuildMap.find(name) != sBuildMap.end(); +} + //static LLFloater* LLFloaterReg::getLastFloaterInGroup(const std::string& name) { diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index e3b17dcb4f..a457a15673 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -85,6 +85,7 @@ public: static void add(const std::string& name, const std::string& file, const LLFloaterBuildFunc& func, const std::string& groupname = LLStringUtil::null); + static bool isRegistered(const std::string& name); // Helpers static LLFloater* getLastFloaterInGroup(const std::string& name); diff --git a/indra/newview/llfloaterhowto.cpp b/indra/newview/llfloaterhowto.cpp index 9db733db25..ef40060807 100644 --- a/indra/newview/llfloaterhowto.cpp +++ b/indra/newview/llfloaterhowto.cpp @@ -61,13 +61,16 @@ void LLFloaterHowTo::onOpen(const LLSD& key) LLFloaterWebContent::onOpen(p); - // Elements from LLFloaterWebContent did not pick up restored size (save_rect) of LLFloaterHowTo - // set the stack size and position (alternative to preferred_media_size) - LLLayoutStack *stack = getChild("stack1"); - LLRect stack_rect = stack->getRect(); - stack->reshape(STACK_WIDTH, STACK_HEIGHT); - stack->setOrigin(stack_rect.mLeft, stack_rect.mTop - STACK_HEIGHT); - stack->updateLayout(); + if (p.preferred_media_size().isEmpty()) + { + // Elements from LLFloaterWebContent did not pick up restored size (save_rect) of LLFloaterHowTo + // set the stack size and position (alternative to preferred_media_size) + LLLayoutStack *stack = getChild("stack1"); + LLRect stack_rect = stack->getRect(); + stack->reshape(STACK_WIDTH, STACK_HEIGHT); + stack->setOrigin(stack_rect.mLeft, stack_rect.mTop - STACK_HEIGHT); + stack->updateLayout(); + } } LLFloaterHowTo* LLFloaterHowTo::getInstance() diff --git a/indra/newview/llfloaterhowto.h b/indra/newview/llfloaterhowto.h index e08d102e2a..15fc43335a 100644 --- a/indra/newview/llfloaterhowto.h +++ b/indra/newview/llfloaterhowto.h @@ -36,6 +36,9 @@ class LLFloaterHowTo : public LLFloaterWebContent { public: + LOG_CLASS(LLFloaterHowTo); + + typedef LLFloaterWebContent::Params Params; LLFloaterHowTo(const Params& key); diff --git a/indra/newview/llurlfloaterdispatchhandler.cpp b/indra/newview/llurlfloaterdispatchhandler.cpp index 7f9929041d..1a5da79a74 100644 --- a/indra/newview/llurlfloaterdispatchhandler.cpp +++ b/indra/newview/llurlfloaterdispatchhandler.cpp @@ -29,6 +29,7 @@ #include "llurlfloaterdispatchhandler.h" #include "llfloaterreg.h" +#include "llfloaterhowto.h" #include "llfloaterwebcontent.h" #include "llsdserialize.h" #include "llviewercontrol.h" @@ -36,11 +37,14 @@ #include "llweb.h" // values specified by server side's dispatcher +// for llopenfloater const std::string MESSAGE_URL_FLOATER("URLFloater"); -const std::string KEY_ACTION("OpenURL"); -const std::string KEY_PARAMS("floater_params"); +const std::string KEY_ACTION("action"); // "action" will be the string constant "OpenURL" +const std::string VALUE_OPEN_URL("OpenURL"); +const std::string KEY_DATA("action_data"); const std::string KEY_FLOATER("floater_title"); const std::string KEY_URL("floater_url"); +const std::string KEY_PARAMS("floater_params"); LLUrlFloaterDispatchHandler LLUrlFloaterDispatchHandler::sUrlDispatchhandler; @@ -75,26 +79,75 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length())) { LL_WARNS("URLFloater") << "Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL; + return false; + } + } + + std::string floater; + LLSD command_params; + std::string url; + + if (message.has(KEY_ACTION) && message[KEY_ACTION].asString() == VALUE_OPEN_URL) + { + LLSD &action_data = message[KEY_DATA]; + if (action_data.isMap()) + { + floater = action_data[KEY_FLOATER]; + command_params = action_data[KEY_PARAMS]; + url = action_data[KEY_URL]; } } + else if (message.has(KEY_FLOATER)) + { + floater = message[KEY_FLOATER]; + command_params = message[KEY_PARAMS]; + url = message[KEY_URL]; + } + else + { + LL_WARNS("URLFloater") << "Received " << MESSAGE_URL_FLOATER << " with unexpected data format: " << message << LL_ENDL; + return false; + } - std::string floater = message[KEY_FLOATER]; - LLSD &command_params = message[KEY_PARAMS]; + if (url.find("://") == std::string::npos) + { + // try unescaping + url = LLURI::unescape(url); + } LLFloaterWebContent::Params params; - params.url = message[KEY_URL]; + params.url = url; if (floater == "guidebook" || floater == "how_to") { if (command_params.isMap()) // by default is undefines { params.trusted_content = command_params.has("trusted_content") ? command_params["trusted_content"] : false; + + // Script's side argument list can't include other lists, neither + // there is a LLRect type, so expect just width and height + if (command_params.has("width") && command_params.has("height")) + { + LLRect rect(0, command_params["height"].asInteger(), command_params["width"].asInteger(), 0); + params.preferred_media_size.setValue(rect); + } } + + // Some locations will have customized guidebook, which this function easists for + // only one instance of guidebook can exist at a time, so if this command arrives, + // we need to close previous guidebook then reopen it. + + LLFloater* instance = LLFloaterReg::findInstance("how_to"); + if (instance) + { + instance->closeHostedFloater(); + } + LLFloaterReg::toggleInstanceOrBringToFront("how_to", params); } - else if (!params.url.getValue().empty()) + else if (floater == "web_content") { - if (command_params.isMap()) // by default is undefines + if (command_params.isMap()) // by default is undefines, might be better idea to init params from command_params { params.trusted_content = command_params.has("trusted_content") ? command_params["trusted_content"] : false; params.show_page_title = command_params.has("show_page_title") ? command_params["show_page_title"] : true; @@ -102,6 +155,19 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st } LLFloaterReg::showInstance("web_content", params); } + else + { + if (LLFloaterReg::isRegistered(floater)) + { + // A valid floater + LL_INFOS("URLFloater") << "Floater " << floater << " is not supported by llopenfloater or URLFloater" << LL_ENDL; + } + else + { + // A valid message, but no such flaoter + LL_WARNS("URLFloater") << "Recieved a command to open unknown floater: " << floater << LL_ENDL; + } + } return true; } diff --git a/indra/newview/llurlfloaterdispatchhandler.h b/indra/newview/llurlfloaterdispatchhandler.h index 469f76b007..1dff52c66f 100644 --- a/indra/newview/llurlfloaterdispatchhandler.h +++ b/indra/newview/llurlfloaterdispatchhandler.h @@ -32,8 +32,11 @@ class LLUrlFloaterDispatchHandler : public LLDispatchHandler { public: + LOG_CLASS(LLUrlFloaterDispatchHandler); + LLUrlFloaterDispatchHandler(); virtual ~LLUrlFloaterDispatchHandler(); + virtual bool operator()(const LLDispatcher *, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override; static void registerInDispatcher(); -- cgit v1.3 From e886a5e34320c6448293dc05ac89a41b2b4a7f69 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 11 May 2021 01:48:21 +0300 Subject: SL-15168 Reset title of guidebook when opening --- indra/newview/llfloaterhowto.cpp | 6 ++++++ indra/newview/skins/default/xui/en/floater_how_to.xml | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterhowto.cpp') diff --git a/indra/newview/llfloaterhowto.cpp b/indra/newview/llfloaterhowto.cpp index ef40060807..6e913b08ea 100644 --- a/indra/newview/llfloaterhowto.cpp +++ b/indra/newview/llfloaterhowto.cpp @@ -51,6 +51,12 @@ BOOL LLFloaterHowTo::postBuild() void LLFloaterHowTo::onOpen(const LLSD& key) { + // LLFloaterHowTo is intended to be opened as a location specific guidebook + // with custom titles, reset the title, LLUrlFloaterDispatchHandler will + // set needed one later + // todo: make title into general parameter for LLFloaterWebContent + setTitle(getString("default_tittle")); + LLFloaterWebContent::Params p(key); if (!p.url.isProvided() || p.url.getValue().empty()) { diff --git a/indra/newview/skins/default/xui/en/floater_how_to.xml b/indra/newview/skins/default/xui/en/floater_how_to.xml index acfa6a5152..95690219b8 100644 --- a/indra/newview/skins/default/xui/en/floater_how_to.xml +++ b/indra/newview/skins/default/xui/en/floater_how_to.xml @@ -3,7 +3,7 @@ legacy_header_height="18" can_resize="false" can_minimize="false" - can_close="false" + can_close="false" height="525" layout="topleft" name="floater_how_to" @@ -14,4 +14,9 @@ width="310" rel_x="-0.469309" rel_y="-0.011166" - filename="floater_web_content.xml"/> \ No newline at end of file + filename="floater_web_content.xml"> + +WELCOME ISLAND GUIDEBOOK + + \ No newline at end of file -- cgit v1.3 From e4dc39cf19a00ab148de6d1bd6c4cd229cf545f5 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Tue, 11 May 2021 13:25:57 +0300 Subject: SL-15249 FIXED The F1 key does not close the guidebook after clicking a link --- indra/newview/llfloaterhowto.cpp | 13 +++++++++++++ indra/newview/llfloaterhowto.h | 2 ++ 2 files changed, 15 insertions(+) (limited to 'indra/newview/llfloaterhowto.cpp') diff --git a/indra/newview/llfloaterhowto.cpp b/indra/newview/llfloaterhowto.cpp index 6e913b08ea..2bd2c47dd7 100644 --- a/indra/newview/llfloaterhowto.cpp +++ b/indra/newview/llfloaterhowto.cpp @@ -83,3 +83,16 @@ LLFloaterHowTo* LLFloaterHowTo::getInstance() { return LLFloaterReg::getTypedInstance("how_to"); } + +BOOL LLFloaterHowTo::handleKeyHere(KEY key, MASK mask) +{ + BOOL handled = FALSE; + + if (KEY_F1 == key ) + { + closeFloater(); + handled = TRUE; + } + + return handled; +} diff --git a/indra/newview/llfloaterhowto.h b/indra/newview/llfloaterhowto.h index fa1d9cace0..c2703d815b 100644 --- a/indra/newview/llfloaterhowto.h +++ b/indra/newview/llfloaterhowto.h @@ -44,6 +44,8 @@ public: void onOpen(const LLSD& key) override; + virtual BOOL handleKeyHere(KEY key, MASK mask); + static LLFloaterHowTo* getInstance(); bool matchesKey(const LLSD& key) override { return true; /*single instance*/ }; -- cgit v1.3 From 8eede89c0f3edb7eb6289dc023c3b8e67ae33fd9 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 11 May 2021 20:46:11 +0300 Subject: Revert "SL-15168 Changed format" --- indra/newview/llfloaterhowto.cpp | 6 -- indra/newview/llurlfloaterdispatchhandler.cpp | 103 ++++++--------------- .../skins/default/xui/en/floater_how_to.xml | 7 +- 3 files changed, 31 insertions(+), 85 deletions(-) (limited to 'indra/newview/llfloaterhowto.cpp') diff --git a/indra/newview/llfloaterhowto.cpp b/indra/newview/llfloaterhowto.cpp index 2bd2c47dd7..ddb3ea04ba 100644 --- a/indra/newview/llfloaterhowto.cpp +++ b/indra/newview/llfloaterhowto.cpp @@ -51,12 +51,6 @@ BOOL LLFloaterHowTo::postBuild() void LLFloaterHowTo::onOpen(const LLSD& key) { - // LLFloaterHowTo is intended to be opened as a location specific guidebook - // with custom titles, reset the title, LLUrlFloaterDispatchHandler will - // set needed one later - // todo: make title into general parameter for LLFloaterWebContent - setTitle(getString("default_tittle")); - LLFloaterWebContent::Params p(key); if (!p.url.isProvided() || p.url.getValue().empty()) { diff --git a/indra/newview/llurlfloaterdispatchhandler.cpp b/indra/newview/llurlfloaterdispatchhandler.cpp index 6de019d73c..40afafa4c0 100644 --- a/indra/newview/llurlfloaterdispatchhandler.cpp +++ b/indra/newview/llurlfloaterdispatchhandler.cpp @@ -36,30 +36,25 @@ #include "llviewergenericmessage.h" #include "llweb.h" -#include - -// Example: -// llOpenFloater("My Help Title", "secondlife://guidebook", []); - // values specified by server side's dispatcher // for llopenfloater const std::string MESSAGE_URL_FLOATER("URLFloater"); const std::string KEY_ACTION("action"); // "action" will be the string constant "OpenURL" const std::string VALUE_OPEN_URL("OpenURL"); const std::string KEY_DATA("action_data"); -const std::string KEY_FLOATER_TITLE("floater_title"); -const std::string KEY_URI("floater_url"); +const std::string KEY_FLOATER("floater_title"); +const std::string KEY_URL("floater_url"); const std::string KEY_PARAMS("floater_params"); -// Supported floaters, for now it's exact matching, later it might get extended -const std::string FLOATER_GUIDEBOOK("guidebook"); // translates to "how_to" -const std::string FLOATER_WEB_CONTENT("browser"); // translates to "web_content" +// Supported floaters +const std::string FLOATER_GUIDEBOOK("guidebook"); // alias for how_to +const std::string FLOATER_HOW_TO("how_to"); +const std::string FLOATER_WEB_CONTENT("web_content"); -// Web content universal arguments +// Web content universal argument const std::string KEY_TRUSTED_CONTENT("trusted_content"); -const std::string KEY_URL("url"); -// Guidebook ("how_to") specific arguments +// Guidebook specific arguments const std::string KEY_WIDTH("width"); const std::string KEY_HEGHT("height"); const std::string KEY_CAN_CLOSE("can_close"); @@ -106,26 +101,25 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st } } - std::string floater_title; + std::string floater; LLSD command_params; - std::string raw_uri; - std::string floater_identifier; + std::string url; if (message.has(KEY_ACTION) && message[KEY_ACTION].asString() == VALUE_OPEN_URL) { LLSD &action_data = message[KEY_DATA]; if (action_data.isMap()) { - floater_title = action_data[KEY_FLOATER_TITLE].asString(); + floater = action_data[KEY_FLOATER].asString(); command_params = action_data[KEY_PARAMS]; - raw_uri = action_data[KEY_URI].asString(); + url = action_data[KEY_URL].asString(); } } - else if (message.has(KEY_FLOATER_TITLE)) + else if (message.has(KEY_FLOATER)) { - floater_title = message[KEY_FLOATER_TITLE].asString(); + floater = message[KEY_FLOATER].asString(); command_params = message[KEY_PARAMS]; - raw_uri = message[KEY_URI].asString(); + url = message[KEY_URL].asString(); } else { @@ -133,48 +127,16 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st return false; } - if (raw_uri.find(":///") == std::string::npos) + if (url.find("://") == std::string::npos) { // try unescaping - raw_uri = LLURI::unescape(raw_uri); - } - - LLURI floater_uri(raw_uri); - if (floater_uri.scheme().empty() || floater_uri.scheme() != "secondlife") - { - LL_WARNS("URLFloater") << "Received " << raw_uri << " with unexpected scheme in uri: " << floater_uri << LL_ENDL; - return false; - } - - LLSD path_array = floater_uri.pathArray(); - S32 path_parts = path_array.size(); - if (path_parts == 0) - { - LL_WARNS("URLFloater") << "received an empty uri: " << floater_uri << LL_ENDL; - return false; - } - - floater_identifier = path_array[0]; - if (floater_identifier.size() < 3) - { - LL_WARNS("URLFloater") << "received invalid flaoter indentifier: " << floater_identifier << LL_ENDL; - return false; + url = LLURI::unescape(url); } LLFloaterWebContent::Params params; - if (command_params.isMap()) - { - if (command_params.has(KEY_TRUSTED_CONTENT)) - { - params.trusted_content = command_params[KEY_TRUSTED_CONTENT].asBoolean(); - } - if (command_params.has(KEY_URL)) - { - params.url = command_params[KEY_URL].asString(); - } - } + params.url = url; - if (floater_identifier == FLOATER_GUIDEBOOK) + if (floater == FLOATER_GUIDEBOOK || floater == FLOATER_HOW_TO) { if (command_params.isMap()) // by default is undefines { @@ -200,39 +162,34 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st } LLFloaterReg::toggleInstanceOrBringToFront("how_to", params); - - instance = LLFloaterReg::findInstance("how_to"); - instance->setTitle(floater_title); + if (command_params.isMap() && command_params.has(KEY_CAN_CLOSE)) { + LLFloater* instance = LLFloaterReg::findInstance("how_to"); instance->setCanClose(command_params[KEY_CAN_CLOSE].asBoolean()); } } - else if (floater_identifier == FLOATER_WEB_CONTENT) + else if (floater == FLOATER_WEB_CONTENT) { - if (command_params.has(KEY_URL)) + if (command_params.isMap()) // by default is undefines, might be better idea to init params from command_params { - if (command_params.isMap()) // by default is undefines, might be better idea to init params from command_params - { - params.trusted_content = command_params.has(KEY_TRUSTED_CONTENT) ? command_params[KEY_TRUSTED_CONTENT].asBoolean() : false; - params.show_page_title = command_params.has(KEY_SHOW_PAGE_TITLE) ? command_params[KEY_SHOW_PAGE_TITLE].asBoolean() : true; - params.allow_address_entry = command_params.has(KEY_ALLOW_ADRESS_ENTRY) ? command_params[KEY_ALLOW_ADRESS_ENTRY].asBoolean() : true; - } - LLFloater* instance = LLFloaterReg::showInstance("web_content", params); - instance->setTitle(floater_title); + params.trusted_content = command_params.has(KEY_TRUSTED_CONTENT) ? command_params[KEY_TRUSTED_CONTENT].asBoolean() : false; + params.show_page_title = command_params.has(KEY_SHOW_PAGE_TITLE) ? command_params[KEY_SHOW_PAGE_TITLE].asBoolean() : true; + params.allow_address_entry = command_params.has(KEY_ALLOW_ADRESS_ENTRY) ? command_params[KEY_ALLOW_ADRESS_ENTRY].asBoolean() : true; } + LLFloaterReg::showInstance("web_content", params); } else { - if (LLFloaterReg::isRegistered(floater_identifier)) + if (LLFloaterReg::isRegistered(floater)) { // A valid floater - LL_INFOS("URLFloater") << "Floater " << floater_identifier << " is not supported by llopenfloater or URLFloater" << LL_ENDL; + LL_INFOS("URLFloater") << "Floater " << floater << " is not supported by llopenfloater or URLFloater" << LL_ENDL; } else { // A valid message, but no such flaoter - LL_WARNS("URLFloater") << "Recieved a command to open unknown floater: " << raw_uri << LL_ENDL; + LL_WARNS("URLFloater") << "Recieved a command to open unknown floater: " << floater << LL_ENDL; } } diff --git a/indra/newview/skins/default/xui/en/floater_how_to.xml b/indra/newview/skins/default/xui/en/floater_how_to.xml index 95690219b8..baff8e1bc0 100644 --- a/indra/newview/skins/default/xui/en/floater_how_to.xml +++ b/indra/newview/skins/default/xui/en/floater_how_to.xml @@ -14,9 +14,4 @@ width="310" rel_x="-0.469309" rel_y="-0.011166" - filename="floater_web_content.xml"> - -WELCOME ISLAND GUIDEBOOK - - \ No newline at end of file + filename="floater_web_content.xml"/> \ No newline at end of file -- cgit v1.3 From 79f8c024c34efad93ce55ebacf656e6fc9804198 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 9 Jun 2021 19:46:23 +0300 Subject: SL-15363 how_to on older viewers is forced to persist Older how_to floater is not set to persist in between sessions and gets stuck, ranamed new how_to into guidebook to avoid the issue --- indra/newview/app_settings/commands.xml | 4 ++-- indra/newview/llfloaterhowto.cpp | 2 +- indra/newview/llurlfloaterdispatchhandler.cpp | 10 +++++----- indra/newview/llviewerfloaterreg.cpp | 2 +- indra/newview/llviewermenu.cpp | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview/llfloaterhowto.cpp') diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index 91841b970d..d0480ca47e 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -89,9 +89,9 @@ label_ref="Command_HowTo_Label" tooltip_ref="Command_HowTo_Tooltip" execute_function="Floater.ToggleOrBringToFront" - execute_parameters="how_to" + execute_parameters="guidebook" is_running_function="Floater.IsOpen" - is_running_parameters="how_to" + is_running_parameters="guidebook" /> ("how_to"); + return LLFloaterReg::getTypedInstance("guidebook"); } BOOL LLFloaterHowTo::handleKeyHere(KEY key, MASK mask) diff --git a/indra/newview/llurlfloaterdispatchhandler.cpp b/indra/newview/llurlfloaterdispatchhandler.cpp index 2e595390cc..6b1a373beb 100644 --- a/indra/newview/llurlfloaterdispatchhandler.cpp +++ b/indra/newview/llurlfloaterdispatchhandler.cpp @@ -50,8 +50,8 @@ const std::string KEY_URL("floater_url"); const std::string KEY_PARAMS("floater_params"); // Supported floaters -const std::string FLOATER_GUIDEBOOK("guidebook"); // alias for how_to -const std::string FLOATER_HOW_TO("how_to"); +const std::string FLOATER_GUIDEBOOK("guidebook"); +const std::string FLOATER_HOW_TO("how_to"); // alias for guidebook const std::string FLOATER_WEB_CONTENT("web_content"); // All arguments are palceholders! Server side will need to add validation first. @@ -163,17 +163,17 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st // only one instance of guidebook can exist at a time, so if this command arrives, // we need to close previous guidebook then reopen it. - LLFloater* instance = LLFloaterReg::findInstance("how_to"); + LLFloater* instance = LLFloaterReg::findInstance("guidebook"); if (instance) { instance->closeHostedFloater(); } - LLFloaterReg::toggleInstanceOrBringToFront("how_to", params); + LLFloaterReg::toggleInstanceOrBringToFront("guidebook", params); if (command_params.isMap()) { - LLFloater* instance = LLFloaterReg::findInstance("how_to"); + LLFloater* instance = LLFloaterReg::findInstance("guidebook"); if (command_params.has(KEY_CAN_CLOSE)) { instance->setCanClose(command_params[KEY_CAN_CLOSE].asBoolean()); diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index de184392f9..5a05f89758 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -363,7 +363,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("search", "floater_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("my_profile", "floater_my_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create); LLFloaterReg::add("profile", "floater_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create); - LLFloaterReg::add("how_to", "floater_how_to.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("guidebook", "floater_how_to.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("big_preview", "floater_big_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index d3d205d509..fbf057603e 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7739,7 +7739,7 @@ class LLToggleHowTo : public view_listener_t { bool handleEvent(const LLSD& userdata) { - LLFloaterReg::toggleInstanceOrBringToFront("how_to"); + LLFloaterReg::toggleInstanceOrBringToFront("guidebook"); return true; } }; -- cgit v1.3