本文整理汇总了C++中CL_DomElement::select_nodes方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_DomElement::select_nodes方法的具体用法?C++ CL_DomElement::select_nodes怎么用?C++ CL_DomElement::select_nodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_DomElement
的用法示例。
在下文中一共展示了CL_DomElement::select_nodes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CL_Exception
TileMap::TileMap(CL_GraphicContext& gc, CL_ResourceManager& resmgr, const CL_String& tileset)
: map_width(0), map_height(0), cur_map_x(0), cur_map_y(0) {
CL_Resource res = resmgr.get_resource(tileset);
if (res.get_type() != "tilemap")
throw CL_Exception(cl_format("Resource %1 is not a tilemap", tileset));
CL_DomElement element = res.get_element();
levelname = element.get_attribute("name");
CL_String resource_name = element.get_attribute("resource");
map_width = element.get_attribute_int("width");
map_height = element.get_attribute_int("height");
tiles = CL_Sprite(gc, resource_name, &resmgr);
float scalex, scaley;
tiles.get_scale(scalex, scaley);
tile_width = tiles.get_width() * scalex;
tile_height = tiles.get_height() * scaley;
auto layer_nodes = element.select_nodes("layer");
for (CL_DomNode& idx : layer_nodes) {
CL_DomElement layer_element = idx.to_element();
CL_String layer_tiles = layer_element.get_first_child().get_node_value();
std::vector<CL_String> tile_indices = CL_StringHelp::split_text(layer_tiles, ",");
MapLayer layer;
layer.map.reserve(tile_indices.size());
for (auto& tile : tile_indices)
layer.map.push_back(CL_StringHelp::text_to_int(tile));
layers.push_back(layer);
}
}
示例2: load
void TileMap::load(CL_GraphicContext &gc, const CL_String &level, CL_ResourceManager &resources)
{
CL_Resource resource = resources.get_resource(level);
if (resource.get_type() != "tilemap")
throw CL_Exception(cl_format("Resource %1 is not of type tilemap!", level));
CL_DomElement element = resource.get_element();
CL_String level_name = element.get_attribute("name");
CL_String resource_name = element.get_attribute("resource");
map_width = element.get_attribute_int("width");
map_height = element.get_attribute_int("height");
cl_log_event("Debug", "Loading level %1 (%2x%3)", level_name, map_width, map_height);
sprite_tiles = CL_Sprite(gc, resource_name, &resources);
tile_width = sprite_tiles.get_width();
tile_height = sprite_tiles.get_height();
cl_log_event("Debug", "Loaded resource %1 with %2 tiles", resource_name, sprite_tiles.get_frame_count());
std::vector<CL_DomNode> layer_nodes = element.select_nodes("layer");
for (size_t layer_index = 0; layer_index < layer_nodes.size(); layer_index++)
{
CL_DomElement layer_element = layer_nodes[layer_index].to_element();
CL_String layer_name = layer_element.get_attribute("name");
CL_String layer_tiles = layer_element.get_first_child().get_node_value();
std::vector<CL_String> tile_indices = CL_StringHelp::split_text(layer_tiles, ",");
TileMapLayer layer;
layer.map.reserve(tile_indices.size());
for(size_t i = 0; i < tile_indices.size(); ++i)
layer.map.push_back(CL_StringHelp::text_to_int(tile_indices[i]));
layers.push_back(layer);
cl_log_event("Debug", "Loaded layer %1 with %2 tiles", layer_name, layer.map.size());
}
current_map_position_x = 0;
current_map_position_y = 0;
}
示例3: if
void CL_GUIXMLLoaderVersion_1_0::load(CL_DomElement &element, CL_GUIComponent *parent)
{
CL_DomElement e = element.get_first_child().to_element();
dialog_width = 0;
dialog_height = 0;
while (e.is_element())
{
CL_String tag = e.get_tag_name();
CL_GUIComponent *new_comp = 0;
if (tag == "button")
{
CL_PushButton *co = new CL_PushButton(parent);
if (e.has_attribute("text"))
co->set_text(e.get_attribute("text"));
new_comp = co;
}
else if (tag == "checkbox")
{
CL_CheckBox *co = new CL_CheckBox(parent);
if (e.has_attribute("text"))
co->set_text(e.get_attribute("text"));
new_comp = co;
}
else if (tag == "radiobutton")
{
CL_RadioButton *co = new CL_RadioButton(parent);
if (e.has_attribute("text"))
co->set_text(e.get_attribute("text"));
if (e.has_attribute("group"))
co->set_group_name(e.get_attribute("group"));
new_comp = co;
}
else if (tag == "label")
{
CL_Label *co = new CL_Label(parent);
if (e.has_attribute("text"))
co->set_text(e.get_attribute("text"));
new_comp = co;
}
else if (tag == "toolbar")
{
CL_ToolBar *co = new CL_ToolBar(parent);
new_comp = co;
}
else if (tag == "progressbar")
{
CL_ProgressBar *co = new CL_ProgressBar(parent);
new_comp = co;
}
else if (tag == "lineedit")
{
CL_LineEdit *co = new CL_LineEdit(parent);
if (e.has_attribute("text"))
co->set_text(e.get_attribute("text"));
new_comp = co;
}
else if (tag == "slider")
{
CL_Slider *co = new CL_Slider(parent);
co->set_min(CL_StringHelp::text_to_int(e.get_attribute("min")));
co->set_max(CL_StringHelp::text_to_int(e.get_attribute("max")));
co->set_tick_count(CL_StringHelp::text_to_int(e.get_attribute("ticks")));
co->set_page_step(CL_StringHelp::text_to_int(e.get_attribute("page_step")));
new_comp = co;
}
else if (tag == "listview")
{
CL_ListView *co = new CL_ListView(parent);
CL_ListViewHeader *header = co->get_header();
std::vector<CL_DomNode> columns_nodes = e.select_nodes("listview_header/listview_column");
for(size_t i = 0; i < columns_nodes.size(); ++i)
{
CL_DomElement column_element = columns_nodes[i].to_element();
CL_String id = column_element.get_attribute("col_id");
CL_String caption = column_element.get_attribute("caption");
int width = column_element.get_attribute_int("width");
CL_ListViewColumnHeader column = header->create_column(id, caption);
column.set_width(width);
header->append(column);
}
new_comp = co;
}
else if (tag == "tab")
{
CL_Tab *co = new CL_Tab(parent);
new_comp = co;
CL_DomElement tab_child = e.get_first_child().to_element();
while (tab_child.is_element())
{
if (tab_child.get_tag_name() == "tabpage")
{
CL_String label = tab_child.get_attribute("label", "Error: NO LABEL!");
int id = CL_StringHelp::text_to_int(tab_child.get_attribute("id", "0"));
//.........这里部分代码省略.........