mirror of
https://github.com/diva/OnLook.git
synced 2026-08-14 00:58:01 +00:00
[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 <floater name= with that same name to work properly.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "lfsimfeaturehandler.h"
|
||||
|
||||
#include "llagent.h"
|
||||
#include "lluictrlfactory.h" // For OnLook Special UI.
|
||||
#include "llviewerregion.h"
|
||||
#include "hippogridmanager.h"
|
||||
|
||||
@@ -66,6 +67,7 @@ void has_feature_or_default(SignaledType<U32>& 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<bool>::slot_t& slot)
|
||||
{
|
||||
return mSupportsExport.connect(slot);
|
||||
|
||||
@@ -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<bool> mSupportsExport;
|
||||
SignaledType<std::string> mDestinationGuideURL;
|
||||
@@ -95,6 +98,7 @@ private:
|
||||
SignaledType<U32> mWhisperRange;
|
||||
SignaledType<U8> mOnLookMask;
|
||||
SignaledType<std::string> mSpecialUI;
|
||||
LLSD mSpecialFloaters;
|
||||
};
|
||||
|
||||
#endif //LFSIMFEATUREHANDLER_H
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user