From 124bc854dd7c3dffc044f306cf836a5d6c68bd2e Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 16 Aug 2010 17:44:23 -0700 Subject: moved buildFloater out of lluictrlfactory to llfloater.cpp --- indra/llui/llfloater.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'indra/llui/llfloater.cpp') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 838f93d3f9..d66b3c1707 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -42,6 +42,7 @@ #include "lluictrlfactory.h" #include "llbutton.h" #include "llcheckboxctrl.h" +#include "lldir.h" #include "lldraghandle.h" #include "llfloaterreg.h" #include "llfocusmgr.h" @@ -2883,3 +2884,65 @@ bool LLFloater::isVisible(const LLFloater* floater) { return floater && floater->getVisible(); } + +static LLFastTimer::DeclareTimer FTM_BUILD_FLOATERS("Build Floaters"); + +/* static */ +bool LLFloater::buildFloater(LLFloater* floaterp, const std::string& filename, LLXMLNodePtr output_node) +{ + LLFastTimer timer(FTM_BUILD_FLOATERS); + LLXMLNodePtr root; + + //if exporting, only load the language being exported, + //instead of layering localized version on top of english + if (output_node) + { + if (!LLUICtrlFactory::getLocalizedXMLNode(filename, root)) + { + llwarns << "Couldn't parse floater from: " << LLUI::getLocalizedSkinPath() + gDirUtilp->getDirDelimiter() + filename << llendl; + return false; + } + } + else if (!LLUICtrlFactory::getLayeredXMLNode(filename, root)) + { + llwarns << "Couldn't parse floater from: " << LLUI::getSkinPath() + gDirUtilp->getDirDelimiter() + filename << llendl; + return false; + } + + // root must be called floater + if( !(root->hasName("floater") || root->hasName("multi_floater")) ) + { + llwarns << "Root node should be named floater in: " << filename << llendl; + return false; + } + + bool res = true; + + lldebugs << "Building floater " << filename << llendl; + LLUICtrlFactory::instance().pushFileName(filename); + { + if (!floaterp->getFactoryMap().empty()) + { + LLPanel::sFactoryStack.push_front(&floaterp->getFactoryMap()); + } + + // for local registry callbacks; define in constructor, referenced in XUI or postBuild + floaterp->getCommitCallbackRegistrar().pushScope(); + floaterp->getEnableCallbackRegistrar().pushScope(); + + res = floaterp->initFloaterXML(root, floaterp->getParent(), filename, output_node); + + floaterp->setXMLFilename(filename); + + floaterp->getCommitCallbackRegistrar().popScope(); + floaterp->getEnableCallbackRegistrar().popScope(); + + if (!floaterp->getFactoryMap().empty()) + { + LLPanel::sFactoryStack.pop_front(); + } + } + LLUICtrlFactory::instance().popFileName(); + + return res; +} -- cgit v1.2.3 From 02d8197019dcecec7aee80a104c4644ddb4807ca Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Fri, 20 Aug 2010 10:14:28 -0700 Subject: changed buildPanel/buildFloater to member functions buildFromFile streamlined LLUICtrlFactory's interface --- indra/llui/llfloater.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'indra/llui/llfloater.cpp') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index d66b3c1707..0cd692b4a4 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2887,8 +2887,7 @@ bool LLFloater::isVisible(const LLFloater* floater) static LLFastTimer::DeclareTimer FTM_BUILD_FLOATERS("Build Floaters"); -/* static */ -bool LLFloater::buildFloater(LLFloater* floaterp, const std::string& filename, LLXMLNodePtr output_node) +bool LLFloater::buildFromFile(const std::string& filename, LLXMLNodePtr output_node) { LLFastTimer timer(FTM_BUILD_FLOATERS); LLXMLNodePtr root; @@ -2921,23 +2920,23 @@ bool LLFloater::buildFloater(LLFloater* floaterp, const std::string& filename, L lldebugs << "Building floater " << filename << llendl; LLUICtrlFactory::instance().pushFileName(filename); { - if (!floaterp->getFactoryMap().empty()) + if (!getFactoryMap().empty()) { - LLPanel::sFactoryStack.push_front(&floaterp->getFactoryMap()); + LLPanel::sFactoryStack.push_front(&getFactoryMap()); } // for local registry callbacks; define in constructor, referenced in XUI or postBuild - floaterp->getCommitCallbackRegistrar().pushScope(); - floaterp->getEnableCallbackRegistrar().pushScope(); + getCommitCallbackRegistrar().pushScope(); + getEnableCallbackRegistrar().pushScope(); - res = floaterp->initFloaterXML(root, floaterp->getParent(), filename, output_node); + res = initFloaterXML(root, getParent(), filename, output_node); - floaterp->setXMLFilename(filename); + setXMLFilename(filename); - floaterp->getCommitCallbackRegistrar().popScope(); - floaterp->getEnableCallbackRegistrar().popScope(); + getCommitCallbackRegistrar().popScope(); + getEnableCallbackRegistrar().popScope(); - if (!floaterp->getFactoryMap().empty()) + if (!getFactoryMap().empty()) { LLPanel::sFactoryStack.pop_front(); } -- cgit v1.2.3 From 65c9914d23022df6a39db50ce295750f08695893 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 23 Aug 2010 11:03:19 -0700 Subject: made Params parsers not act as singletons --- indra/llui/llfloater.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llui/llfloater.cpp') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 0cd692b4a4..e7d0950846 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2780,7 +2780,8 @@ LLFastTimer::DeclareTimer POST_BUILD("Floater Post Build"); bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::string& filename, LLXMLNodePtr output_node) { Params params(LLUICtrlFactory::getDefaultParams()); - LLXUIParser::instance().readXUI(node, params, filename); // *TODO: Error checking + LLXUIParser parser; + parser.readXUI(node, params, filename); // *TODO: Error checking if (output_node) { @@ -2788,8 +2789,7 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str setupParamsForExport(output_params, parent); Params default_params(LLUICtrlFactory::getDefaultParams()); output_node->setName(node->getName()->mString); - LLXUIParser::instance().writeXUI( - output_node, output_params, &default_params); + parser.writeXUI(output_node, output_params, &default_params); } // Default floater position to top-left corner of screen -- cgit v1.2.3