本文整理汇总了C++中LLXUIParser类的典型用法代码示例。如果您正苦于以下问题:C++ LLXUIParser类的具体用法?C++ LLXUIParser怎么用?C++ LLXUIParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LLXUIParser类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LLXMLNode
void LLUIColorTable::saveUserSettings() const
{
Params params;
for(string_color_map_t::const_iterator it = mUserSetColors.begin();
it != mUserSetColors.end();
++it)
{
ColorEntryParams color_entry;
color_entry.name = it->first;
color_entry.color.value = it->second;
params.color_entries.add(color_entry);
}
LLXMLNodePtr output_node = new LLXMLNode("colors", false);
LLXUIParser parser;
parser.writeXUI(output_node, params);
if(!output_node->isNull())
{
const std::string& filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "colors.xml");
LLFILE *fp = LLFile::fopen(filename, "w");
if(fp != NULL)
{
LLXMLNode::writeHeaderToFile(fp);
output_node->writeToFile(fp);
fclose(fp);
}
}
}
示例2: loadFromFilename
bool LLUIColorTable::loadFromFilename(const std::string& filename, string_color_map_t& table)
{
LLXMLNodePtr root;
if(!LLXMLNode::parseFile(filename, root, NULL))
{
llwarns << "Unable to parse color file " << filename << llendl;
return false;
}
if(!root->hasName("colors"))
{
llwarns << filename << " is not a valid color definition file" << llendl;
return false;
}
Params params;
LLXUIParser parser;
parser.readXUI(root, params, filename);
if(params.validateBlock())
{
insertFromParams(params, table);
}
else
{
llwarns << filename << " failed to load" << llendl;
return false;
}
return true;
}
示例3: parseLanguageStrings
//static
bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root)
{
std::string xml_filename = "(language strings file)";
if (!root->hasName("strings"))
{
llerrs << "Invalid root node name in " << xml_filename
<< ": was " << root->getName() << ", expected \"strings\"" << llendl;
}
StringTable string_table;
LLXUIParser parser;
parser.readXUI(root, string_table, xml_filename);
if (!string_table.validateBlock())
{
llerrs << "Problem reading strings: " << xml_filename << llendl;
return false;
}
for(LLInitParam::ParamIterator<StringDef>::const_iterator it = string_table.strings.begin();
it != string_table.strings.end();
++it)
{
// share the same map with parseStrings() so we can search the strings using the same getString() function.- angela
LLTransTemplate xml_template(it->name, it->value);
sStringTemplates[xml_template.mName] = xml_template;
}
return true;
}
示例4: addToToolset
void LLToolBarView::saveToolbars() const
{
if (!mToolbarsLoaded)
return;
// Build the parameter tree from the toolbar data
LLToolBarView::ToolbarSet toolbar_set;
if (mToolbars[TOOLBAR_LEFT])
{
toolbar_set.left_toolbar.button_display_mode = mToolbars[TOOLBAR_LEFT]->getButtonType();
toolbar_set.left_toolbar.button_alignment = mToolbars[TOOLBAR_LEFT]->getAlignment(); // <FS_Zi>
toolbar_set.left_toolbar.button_layout_style = mToolbars[TOOLBAR_LEFT]->getLayoutStyle(); // <FS_Zi>
addToToolset(mToolbars[TOOLBAR_LEFT]->getCommandsList(), toolbar_set.left_toolbar);
}
if (mToolbars[TOOLBAR_RIGHT])
{
toolbar_set.right_toolbar.button_display_mode = mToolbars[TOOLBAR_RIGHT]->getButtonType();
toolbar_set.right_toolbar.button_alignment = mToolbars[TOOLBAR_RIGHT]->getAlignment(); // <FS_Zi>
toolbar_set.right_toolbar.button_layout_style = mToolbars[TOOLBAR_RIGHT]->getLayoutStyle(); // <FS_Zi>
addToToolset(mToolbars[TOOLBAR_RIGHT]->getCommandsList(), toolbar_set.right_toolbar);
}
if (mToolbars[TOOLBAR_BOTTOM])
{
toolbar_set.bottom_toolbar.button_display_mode = mToolbars[TOOLBAR_BOTTOM]->getButtonType();
toolbar_set.bottom_toolbar.button_alignment = mToolbars[TOOLBAR_BOTTOM]->getAlignment(); // <FS_Zi>
toolbar_set.bottom_toolbar.button_layout_style = mToolbars[TOOLBAR_BOTTOM]->getLayoutStyle(); // <FS_Zi>
addToToolset(mToolbars[TOOLBAR_BOTTOM]->getCommandsList(), toolbar_set.bottom_toolbar);
}
// Serialize the parameter tree
LLXMLNodePtr output_node = new LLXMLNode("toolbars", false);
LLXUIParser parser;
parser.writeXUI(output_node, toolbar_set);
// Write the resulting XML to file
if(!output_node->isNull())
{
const std::string& filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml");
LLFILE *fp = LLFile::fopen(filename, "w");
if (fp != NULL)
{
LLXMLNode::writeHeaderToFile(fp);
output_node->writeToFile(fp);
fclose(fp);
}
}
}
示例5: parseStrings
//static
bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& default_args)
{
std::string xml_filename = "(strings file)";
if (!root->hasName("strings"))
{
llerrs << "Invalid root node name in " << xml_filename
<< ": was " << root->getName() << ", expected \"strings\"" << llendl;
}
StringTable string_table;
LLXUIParser parser;
parser.readXUI(root, string_table, xml_filename);
if (!string_table.validateBlock())
{
llerrs << "Problem reading strings: " << xml_filename << llendl;
return false;
}
sStringTemplates.clear();
sDefaultArgs.clear();
for(LLInitParam::ParamIterator<StringDef>::const_iterator it = string_table.strings.begin();
it != string_table.strings.end();
++it)
{
LLTransTemplate xml_template(it->name, it->value);
sStringTemplates[xml_template.mName] = xml_template;
std::set<std::string>::const_iterator iter = default_args.find(xml_template.mName);
if (iter != default_args.end())
{
std::string name = *iter;
if (name[0] != '[')
name = llformat("[%s]",name.c_str());
sDefaultArgs[name] = xml_template.mText;
}
}
return true;
}
示例6: get_accordion_tab_params
const outfit_accordion_tab_params& get_accordion_tab_params()
{
static outfit_accordion_tab_params tab_params;
static bool initialized = false;
if (!initialized)
{
initialized = true;
LLXMLNodePtr xmlNode;
if (LLUICtrlFactory::getLayeredXMLNode("outfit_accordion_tab.xml", xmlNode))
{
LLXUIParser parser;
parser.readXUI(xmlNode, tab_params, "outfit_accordion_tab.xml");
}
else
{
llwarns << "Failed to read xml of Outfit's Accordion Tab from outfit_accordion_tab.xml" << llendl;
}
}
return tab_params;
}
示例7: params
BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node, const LLPanel::Params& default_params)
{
Params params(default_params);
{
LLFastTimer timer(FTM_PANEL_SETUP);
LLXMLNodePtr referenced_xml;
std::string xml_filename = mXMLFilename;
// if the panel didn't provide a filename, check the node
if (xml_filename.empty())
{
node->getAttributeString("filename", xml_filename);
setXMLFilename(xml_filename);
}
LLXUIParser parser;
if (!xml_filename.empty())
{
LLUICtrlFactory::instance().pushFileName(xml_filename);
LLFastTimer timer(FTM_EXTERNAL_PANEL_LOAD);
if (output_node)
{
//if we are exporting, we want to export the current xml
//not the referenced xml
parser.readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName());
Params output_params(params);
setupParamsForExport(output_params, parent);
output_node->setName(node->getName()->mString);
parser.writeXUI(output_node, output_params, &default_params);
return TRUE;
}
if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml))
{
llwarns << "Couldn't parse panel from: " << xml_filename << llendl;
return FALSE;
}
parser.readXUI(referenced_xml, params, LLUICtrlFactory::getInstance()->getCurFileName());
// add children using dimensions from referenced xml for consistent layout
setShape(params.rect);
LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance());
LLUICtrlFactory::instance().popFileName();
}
// ask LLUICtrlFactory for filename, since xml_filename might be empty
parser.readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName());
if (output_node)
{
Params output_params(params);
setupParamsForExport(output_params, parent);
output_node->setName(node->getName()->mString);
parser.writeXUI(output_node, output_params, &default_params);
}
params.from_xui = true;
applyXUILayout(params, parent);
{
LLFastTimer timer(FTM_PANEL_CONSTRUCTION);
initFromParams(params);
}
// add children
LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node);
// Connect to parent after children are built, because tab containers
// do a reshape() on their child panels, which requires that the children
// be built/added. JC
if (parent)
{
S32 tab_group = params.tab_group.isProvided() ? params.tab_group() : parent->getLastTabGroup();
parent->addChild(this, tab_group);
}
{
LLFastTimer timer(FTM_PANEL_POSTBUILD);
postBuild();
}
}
return TRUE;
}
示例8: if
bool LLToolBarView::loadToolbars(bool force_default)
{
LLToolBarView::ToolbarSet toolbar_set;
bool err = false;
// Load the toolbars.xml file
std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml");
if (force_default)
{
toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_TOP_SKIN, "toolbars.xml"); // FS:AO - Look in skin directory, not settings
}
else if (!gDirUtilp->fileExists(toolbar_file))
{
LL_WARNS() << "User toolbars def not found -> use selected skin" << LL_ENDL;
toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_TOP_SKIN, "toolbars.xml"); // FS:AO - Look in skin directory, not settings
}
if (!gDirUtilp->fileExists(toolbar_file)) // FS:AO - Look in skin default dir as fallback
{
LL_WARNS() << "Skin toolbars def not found -> use default skin" << LL_ENDL;
toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_DEFAULT_SKIN, "toolbars.xml");
}
LLXMLNodePtr root;
if(!LLXMLNode::parseFile(toolbar_file, root, NULL))
{
LL_WARNS() << "Unable to load toolbars from file: " << toolbar_file << LL_ENDL;
err = true;
}
if (!err && !root->hasName("toolbars"))
{
LL_WARNS() << toolbar_file << " is not a valid toolbars definition file" << LL_ENDL;
err = true;
}
// Parse the toolbar settings
LLXUIParser parser;
if (!err)
{
parser.readXUI(root, toolbar_set, toolbar_file);
}
if (!err && !toolbar_set.validateBlock())
{
LL_WARNS() << "Unable to validate toolbars from file: " << toolbar_file << LL_ENDL;
err = true;
}
if (err)
{
if (force_default)
{
LL_ERRS() << "Unable to load toolbars from default file : " << toolbar_file << LL_ENDL;
return false;
}
// Try to load the default toolbars
return loadToolbars(true);
}
// Clear the toolbars now before adding the loaded commands and settings
for (S32 i = LLToolBarEnums::TOOLBAR_FIRST; i <= LLToolBarEnums::TOOLBAR_LAST; i++)
{
if (mToolbars[i])
{
mToolbars[i]->clearCommandsList();
}
}
// Add commands to each toolbar
if (toolbar_set.left_toolbar.isProvided() && mToolbars[LLToolBarEnums::TOOLBAR_LEFT])
{
if (toolbar_set.left_toolbar.button_display_mode.isProvided())
{
LLToolBarEnums::ButtonType button_type = toolbar_set.left_toolbar.button_display_mode;
mToolbars[LLToolBarEnums::TOOLBAR_LEFT]->setButtonType(button_type);
}
// <FS:Zi> Load left toolbar layout and alignment from XML
if (toolbar_set.left_toolbar.button_alignment.isProvided())
{
LLToolBarEnums::Alignment alignment = toolbar_set.left_toolbar.button_alignment;
mToolbars[LLToolBarEnums::TOOLBAR_LEFT]->setAlignment(alignment);
}
if (toolbar_set.left_toolbar.button_layout_style.isProvided())
{
LLToolBarEnums::LayoutStyle layout_style = toolbar_set.left_toolbar.button_layout_style;
mToolbars[LLToolBarEnums::TOOLBAR_LEFT]->setLayoutStyle(layout_style);
}
// </FS:Zi>
BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.left_toolbar.commands)
{
if (addCommandInternal(LLCommandId(command_params), mToolbars[LLToolBarEnums::TOOLBAR_LEFT]))
{
LL_WARNS() << "Error adding command '" << command_params.name() << "' to left toolbar." << LL_ENDL;
}
}
}
if (toolbar_set.right_toolbar.isProvided() && mToolbars[LLToolBarEnums::TOOLBAR_RIGHT])
{
//.........这里部分代码省略.........