本文整理汇总了C++中DataPtr::setType方法的典型用法代码示例。如果您正苦于以下问题:C++ DataPtr::setType方法的具体用法?C++ DataPtr::setType怎么用?C++ DataPtr::setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataPtr
的用法示例。
在下文中一共展示了DataPtr::setType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseSkin
void SkinExportSerializer::parseSkin(pugi::xml_node _node)
{
DataPtr data = Data::CreateInstance();
data->setType(DataTypeManager::getInstance().getType("Skin"));
data->setPropertyValue("Name", _node.attribute("name").value());
data->setPropertyValue("Texture", _node.attribute("texture").value());
DataManager::getInstance().getRoot()->addChild(data);
SkinDataUtility::CreateSkinData(data);
fillStateData(data, _node);
DataPtr state = getChildData(data, "State", "Normal");
std::string value = state != nullptr ? state->getPropertyValue("Point") : "";
MyGUI::IntPoint point = MyGUI::IntPoint::parse(value);
MyGUI::IntSize size = MyGUI::IntSize::parse(_node.attribute("size").value());
data->setPropertyValue("Size", MyGUI::IntCoord(point.left, point.top, size.width, size.height).print());
fillSeparatorData(data, _node);
MyGUI::IntRect separators = SkinDataUtility::getSeparatorsOffset(data);
SkinDataUtility::VectorCoord coords = SkinDataUtility::getRegions(size, separators);
SkinDataUtility::fillRegionCoords(data, coords);
SkinDataUtility::RectVisible visible = SkinDataUtility::getSeparatorsVisible(data);
SkinDataUtility::fillRegionEnable(data, visible);
fillRegionData(data, _node);
}
示例2: parseFont
void FontExportSerializer::parseFont(pugi::xml_node _node)
{
DataPtr data = Data::CreateInstance();
data->setType(DataTypeManager::getInstance().getType("Font"));
data->setPropertyValue("Name", _node.attribute("name").value());
std::string value = _node.select_single_node("Property[@key=\"Source\"]/@value").attribute().value();
data->setPropertyValue("Source", value);
value = _node.select_single_node("Property[@key=\"Size\"]/@value").attribute().value();
data->setPropertyValue("Size", MyGUI::utility::parseValue<float>(value));
value = _node.select_single_node("Property[@key=\"Hinting\"]/@value").attribute().value();
if (value.empty())
value = "use_native";
data->setPropertyValue("Hinting", value);
value = _node.select_single_node("Property[@key=\"Resolution\"]/@value").attribute().value();
if (!value.empty())
data->setPropertyValue("Resolution", MyGUI::utility::parseValue<int>(value));
value = _node.select_single_node("Property[@key=\"Antialias\"]/@value").attribute().value();
if (!value.empty())
data->setPropertyValue("Antialias", MyGUI::utility::parseValue<bool>(value));
value = _node.select_single_node("Property[@key=\"TabWidth\"]/@value").attribute().value();
if (!value.empty())
data->setPropertyValue("TabWidth", MyGUI::utility::parseValue<float>(value));
value = _node.select_single_node("Property[@key=\"OffsetHeight\"]/@value").attribute().value();
if (!value.empty())
data->setPropertyValue("OffsetHeight", MyGUI::utility::parseValue<int>(value));
value = _node.select_single_node("Property[@key=\"SubstituteCode\"]/@value").attribute().value();
if (!value.empty())
data->setPropertyValue("SubstituteCode", MyGUI::utility::parseValue<int>(value));
value = _node.select_single_node("Property[@key=\"Distance\"]/@value").attribute().value();
if (!value.empty())
data->setPropertyValue("Distance", MyGUI::utility::parseValue<int>(value));
value = "";
pugi::xpath_node_set codes = _node.select_nodes("Codes/Code/@range");
for (pugi::xpath_node_set::const_iterator code = codes.begin(); code != codes.end(); code ++)
{
if (!value.empty())
value += "|";
std::vector<std::string> values = MyGUI::utility::split((*code).attribute().value());
if (values.size() == 1)
value += MyGUI::utility::toString(values[0], " ", values[0]);
else if (values.size() == 2)
value += MyGUI::utility::toString(values[0], " ", values[1]);
}
data->setPropertyValue("FontCodeRanges", value);
DataManager::getInstance().getRoot()->addChild(data);
}
示例3: parseFrame
void ImageExportSerializer::parseFrame(pugi::xml_node _node, DataPtr _parent)
{
DataPtr data = Data::CreateInstance();
data->setType(DataTypeManager::getInstance().getType("Frame"));
data->setPropertyValue("Point", _node.attribute("point").value());
std::string value = _node.attribute("count").value();
if (value.empty())
value = "1";
data->setPropertyValue("Count", value);
_parent->addChild(data);
}
示例4: parseImage
void ImageExportSerializer::parseImage(pugi::xml_node _node)
{
DataPtr data = Data::CreateInstance();
data->setType(DataTypeManager::getInstance().getType("Image"));
data->setPropertyValue("Name", _node.attribute("name").value());
DataManager::getInstance().getRoot()->addChild(data);
pugi::xpath_node_set nodes = _node.select_nodes("Group");
for (pugi::xpath_node_set::const_iterator node = nodes.begin(); node != nodes.end(); node ++)
parseGroup((*node).node(), data);
}
示例5: parseIndex
void ImageExportSerializer::parseIndex(pugi::xml_node _node, DataPtr _parent)
{
DataPtr data = Data::CreateInstance();
data->setType(DataTypeManager::getInstance().getType("Index"));
std::string value = _node.attribute("name").value();
if (value.empty())
value = "unnamed";
data->setPropertyValue("Name", value);
data->setPropertyValue("Rate", _node.attribute("rate").value());
_parent->addChild(data);
pugi::xpath_node_set nodes = _node.select_nodes("Frame");
for (pugi::xpath_node_set::const_iterator node = nodes.begin(); node != nodes.end(); node ++)
parseFrame((*node).node(), data);
}
示例6: parseGroup
void ImageExportSerializer::parseGroup(pugi::xml_node _node, DataPtr _parent)
{
DataPtr data = Data::CreateInstance();
data->setType(DataTypeManager::getInstance().getType("Group"));
std::string value = _node.attribute("name").value();
if (value.empty())
value = "unnamed";
data->setPropertyValue("Name", value);
data->setPropertyValue("Texture", _node.attribute("texture").value());
MyGUI::IntSize size = MyGUI::IntSize::parse(_node.attribute("size").value());
data->setPropertyValue("Size", MyGUI::IntCoord(0, 0, size.width, size.height).print());
_parent->addChild(data);
pugi::xpath_node_set nodes = _node.select_nodes("Index");
for (pugi::xpath_node_set::const_iterator node = nodes.begin(); node != nodes.end(); node ++)
parseIndex((*node).node(), data);
}
示例7: cloneData
void DataUtility::cloneData(DataPtr _target, DataPtr _prototype)
{
MYGUI_ASSERT(_target != _prototype, "Error clone self");
MYGUI_ASSERT(_target->getType() == _prototype->getType(), "Error clone different types");
MYGUI_ASSERT(_target->getChilds().size() == 0, "Target not empty");
copyProperty(_target, _prototype);
for (Data::VectorData::const_iterator child = _prototype->getChilds().begin(); child != _prototype->getChilds().end(); child ++)
{
DataPtr data = Data::CreateInstance();
data->setType((*child)->getType());
_target->addChild(data);
cloneData(data, *child);
}
}
示例8: fillStateData
void SkinExportSerializer::fillStateData(DataPtr _data, pugi::xml_node _node)
{
typedef std::map<std::string, MyGUI::IntPoint> MapPoint;
MapPoint values;
pugi::xpath_node_set states = _node.select_nodes("BasisSkin/State");
for (pugi::xpath_node_set::const_iterator state = states.begin(); state != states.end(); state ++)
{
MyGUI::IntCoord coord((std::numeric_limits<int>::max)(), (std::numeric_limits<int>::max)(), 0, 0);
pugi::xml_attribute attribute = (*state).node().attribute("offset");
if (!attribute.empty())
coord = MyGUI::IntCoord::parse(attribute.value());
std::string name = (*state).node().attribute("name").value();
MapPoint::iterator valuesIterator = values.find(name);
if (valuesIterator != values.end())
{
(*valuesIterator).second = MyGUI::IntPoint(
(std::min)((*valuesIterator).second.left, coord.left),
(std::min)((*valuesIterator).second.top, coord.top));
}
else
{
values[name] = coord.point();
}
// create, if there is no data
name = convertExportToEditorStateName(name);
DataPtr childData = getChildData(_data, "State", name);
if (childData == nullptr)
{
childData = Data::CreateInstance();
childData->setType(DataTypeManager::getInstance().getType("State"));
childData->setPropertyValue("Name", name);
_data->addChild(childData);
}
}
for (Data::VectorData::const_iterator child = _data->getChilds().begin(); child != _data->getChilds().end(); child ++)
{
if ((*child)->getType()->getName() != "State")
continue;
DataPtr childData = (*child);
MapPoint::iterator result = values.find(convertEditorToExportStateName(childData->getPropertyValue("Name")));
if (result != values.end())
{
childData->setPropertyValue("Visible", "True");
if ((*result).second.left != (std::numeric_limits<int>::max)() &&
(*result).second.top != (std::numeric_limits<int>::max)())
childData->setPropertyValue("Point", (*result).second);
}
}
states = _node.select_nodes("BasisSkin/State[@colour]");
for (pugi::xpath_node_set::const_iterator state = states.begin(); state != states.end(); state ++)
{
std::string name = (*state).node().attribute("name").value();
int textShift = MyGUI::utility::parseValue<int>((*state).node().attribute("shift").value());
MyGUI::Colour textColour = MyGUI::utility::parseValue<MyGUI::Colour>((*state).node().attribute("colour").value());
for (Data::VectorData::const_iterator child = _data->getChilds().begin(); child != _data->getChilds().end(); child ++)
{
if ((*child)->getType()->getName() != "State")
continue;
DataPtr childData = (*child);
if (convertEditorToExportStateName(childData->getPropertyValue("Name")) == name)
{
childData->setPropertyValue("TextShift", textShift);
childData->setPropertyValue("TextColour", MyGUI::utility::toString(textColour.red, " ", textColour.green, " ", textColour.blue));
}
}
}
}