From 64434da9221fb7b4f1bd2922106c45111bbbeeb2 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Fri, 7 Nov 2014 13:18:44 -0500 Subject: [PATCH] [OnLook] Allow opening special codeless floaters from the toolbar Moves toolbar buffer into "toolbar" field of "special-ui", if "special-ui" exists, it will always have "toolbar" inside it Adds support for "floaters" field of "special-ui", ["floaters"][name] should be an xml buffer containing & type, const LLSD& features, const type = (features.has(feature)) ? features[feature].asInteger() : type.getDefault(); } +void close_if_built(const std::string& name) { if (LLFloater* floater = LLUICtrlFactory::instance().getBuiltFloater(name)) floater->close(); } void LFSimFeatureHandler::setSupportedFeatures() { if (LLViewerRegion* region = gAgent.getRegion()) @@ -92,8 +94,16 @@ void LFSimFeatureHandler::setSupportedFeatures() if (extras.has("camera-only-mode")) onlook_mask |= 1; if (extras.has("special-ui")) { - mSpecialUI = extras["special-ui"].asString(); + mSpecialUI = extras["special-ui"]["toolbar"].asString(); onlook_mask |= 2; + if (extras["special-ui"].has("floaters")) + { + const LLSD& floaters(extras["special-ui"]["floaters"]); + for (LLSD::map_const_iterator it = mSpecialFloaters.beginMap(), end = mSpecialFloaters.endMap(); it != end; ++it) + if (!floaters.has(it->first)) close_if_built(it->first); + mSpecialFloaters = floaters; + } + else resetSpecialFloaters(); } else mSpecialUI.reset(); } @@ -110,11 +120,19 @@ void LFSimFeatureHandler::setSupportedFeatures() mShoutRange.reset(); mWhisperRange.reset(); mSpecialUI.reset(); + resetSpecialFloaters(); } mOnLookMask = onlook_mask; } } +void LFSimFeatureHandler::resetSpecialFloaters() +{ + for (LLSD::map_const_iterator it = mSpecialFloaters.beginMap(), end = mSpecialFloaters.endMap(); it != end; ++it) + close_if_built(it->first); + mSpecialFloaters.clear(); +} + boost::signals2::connection LFSimFeatureHandler::setSupportsExportCallback(const SignaledType::slot_t& slot) { return mSupportsExport.connect(slot); diff --git a/indra/newview/lfsimfeaturehandler.h b/indra/newview/lfsimfeaturehandler.h index e843b7a54..ec8ba7ffc 100644 --- a/indra/newview/lfsimfeaturehandler.h +++ b/indra/newview/lfsimfeaturehandler.h @@ -79,12 +79,15 @@ public: U32 shoutRange() const { return mShoutRange; } U32 whisperRange() const { return mWhisperRange; } U8 getOnLookMask() const { return mOnLookMask; } + const LLSD& specialFloaters() const { return mSpecialFloaters; } ExportPolicy exportPolicy() const; // Mutators void setOnLookMask(const U8& mask) { mOnLookMask = mask; } private: + void resetSpecialFloaters(); + // SignaledTypes SignaledType mSupportsExport; SignaledType mDestinationGuideURL; @@ -95,6 +98,7 @@ private: SignaledType mWhisperRange; SignaledType mOnLookMask; SignaledType mSpecialUI; + LLSD mSpecialFloaters; }; #endif //LFSIMFEATUREHANDLER_H diff --git a/indra/newview/llmenucommands.cpp b/indra/newview/llmenucommands.cpp index 6183c6942..bc023ac29 100644 --- a/indra/newview/llmenucommands.cpp +++ b/indra/newview/llmenucommands.cpp @@ -39,6 +39,7 @@ #include "floaterlocalassetbrowse.h" #include "hbfloatergrouptitles.h" #include "jcfloaterareasearch.h" +#include "lfsimfeaturehandler.h" #include "llagentcamera.h" #include "llchatbar.h" #include "llconsole.h" @@ -279,10 +280,15 @@ void show_floater(const std::string& floater_name) MenuFloaterDict::menu_floater_map_t::iterator it = MenuFloaterDict::instance().mEntries.find(floater_name); if (it == MenuFloaterDict::instance().mEntries.end()) // Simple codeless floater { - if (LLFloater* floater = LLUICtrlFactory::getInstance()->getBuiltFloater(floater_name)) + LLUICtrlFactory& inst(LLUICtrlFactory::instance()); + if (LLFloater* floater = inst.getBuiltFloater(floater_name)) floater->isFrontmost() ? floater->close() : gFloaterView->bringToFront(floater); else - LLUICtrlFactory::getInstance()->buildFloater(new LLFloater(), floater_name); + { + const LLSD& special(LFSimFeatureHandler::instance().specialFloaters()); + LLFloater* f(new LLFloater); + special.has(floater_name) ? inst.buildFloaterFromBuffer(f, special[floater_name]) : inst.buildFloater(f, floater_name); + } } else if (it->second.first) {