本文整理汇总了C++中XMLElement::GetInt方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLElement::GetInt方法的具体用法?C++ XMLElement::GetInt怎么用?C++ XMLElement::GetInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLElement
的用法示例。
在下文中一共展示了XMLElement::GetInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
void RenderTargetInfo::Load(const XMLElement& element)
{
name_ = element.GetAttribute("name");
tag_ = element.GetAttribute("tag");
if (element.HasAttribute("enabled"))
enabled_ = element.GetBool("enabled");
String formatName = element.GetAttribute("format");
format_ = Graphics::GetFormat(formatName);
if (element.HasAttribute("filter"))
filtered_ = element.GetBool("filter");
if (element.HasAttribute("srgb"))
sRGB_ = element.GetBool("srgb");
if (element.HasAttribute("size"))
size_ = element.GetIntVector2("size");
if (element.HasAttribute("sizedivisor"))
{
size_ = element.GetIntVector2("sizedivisor");
sizeMode_ = SIZE_VIEWPORTDIVISOR;
}
if (element.HasAttribute("rtsizedivisor"))
{
size_ = element.GetIntVector2("rtsizedivisor");
sizeMode_ = SIZE_RENDERTARGETDIVISOR;
}
if (element.HasAttribute("width"))
size_.x_ = element.GetInt("width");
if (element.HasAttribute("height"))
size_.y_ = element.GetInt("height");
}
示例2:
void TmxLayer2D::LoadInfo(const XMLElement& element)
{
name_ = element.GetAttribute("name");
width_ = element.GetInt("width");
height_ = element.GetInt("height");
if (element.HasAttribute("visible"))
visible_ = element.GetInt("visible") != 0;
else
visible_ = true;
}
示例3: SetParameters
void Texture::SetParameters(const XMLElement& element)
{
XMLElement paramElem = element.GetChild();
while (paramElem)
{
String name = paramElem.GetName();
if (name == "address")
{
String coord = paramElem.GetAttributeLower("coord");
if (coord.Length() >= 1)
{
TextureCoordinate coordIndex = (TextureCoordinate)(coord[0] - 'u');
String mode = paramElem.GetAttributeLower("mode");
SetAddressMode(coordIndex, (TextureAddressMode)GetStringListIndex(mode.CString(), addressModeNames, ADDRESS_WRAP));
}
}
if (name == "border")
SetBorderColor(paramElem.GetColor("color"));
if (name == "filter")
{
String mode = paramElem.GetAttributeLower("mode");
SetFilterMode((TextureFilterMode)GetStringListIndex(mode.CString(), filterModeNames, FILTER_DEFAULT));
}
if (name == "mipmap")
SetNumLevels(paramElem.GetBool("enable") ? 0 : 1);
if (name == "quality")
{
if (paramElem.HasAttribute("low"))
SetMipsToSkip(QUALITY_LOW, paramElem.GetInt("low"));
if (paramElem.HasAttribute("med"))
SetMipsToSkip(QUALITY_MEDIUM, paramElem.GetInt("med"));
if (paramElem.HasAttribute("medium"))
SetMipsToSkip(QUALITY_MEDIUM, paramElem.GetInt("medium"));
if (paramElem.HasAttribute("high"))
SetMipsToSkip(QUALITY_HIGH, paramElem.GetInt("high"));
}
if (name == "srgb")
SetSRGB(paramElem.GetBool("enable"));
paramElem = paramElem.GetNext();
}
}
示例4: LoadParameters
void Font::LoadParameters()
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
String xmlName = ReplaceExtension(GetName(), ".xml");
SharedPtr<XMLFile> xml = cache->GetTempResource<XMLFile>(xmlName, false);
if (!xml)
return;
XMLElement rootElem = xml->GetRoot();
XMLElement absoluteElem = rootElem.GetChild("absoluteoffset");
if (!absoluteElem)
absoluteElem = rootElem.GetChild("absolute");
if (absoluteElem)
{
absoluteOffset_.x_ = absoluteElem.GetInt("x");
absoluteOffset_.y_ = absoluteElem.GetInt("y");
}
XMLElement scaledElem = rootElem.GetChild("scaledoffset");
if (!scaledElem)
scaledElem = rootElem.GetChild("scaled");
if (scaledElem)
{
scaledOffset_.x_ = scaledElem.GetFloat("x");
scaledOffset_.y_ = scaledElem.GetFloat("y");
}
}
示例5: LoadInputMapping
// ----------------------------------------------------------------------------
bool InputMapping::LoadInputMapping(XMLFile* config)
{
XMLElement contextElement = config->GetRoot().GetChild("context");
if(!contextElement)
return false;
while(contextElement)
{
String contextName = contextElement.GetAttribute("name");
if(contextName == "3rd person controls")
{
XMLElement mappingElement = contextElement.GetChild("mapping");
while(mappingElement)
{
String action = mappingElement.GetAttribute("action");
String device = mappingElement.GetAttribute("device");
int value = mappingElement.GetInt("value");
SetMapping(contextName, device, action, value);
mappingElement = mappingElement.GetNext("mapping");
}
}
contextElement = contextElement.GetNext("context");
}
return true;
}
示例6: LoadXML
bool Node::LoadXML(const XMLElement& source, SceneResolver& resolver, bool readChildren, bool rewriteIDs, CreateMode mode)
{
// Remove all children and components first in case this is not a fresh load
RemoveAllChildren();
RemoveAllComponents();
if (!Serializable::LoadXML(source))
return false;
XMLElement compElem = source.GetChild("component");
while (compElem)
{
String typeName = compElem.GetAttribute("type");
unsigned compID = compElem.GetInt("id");
Component* newComponent = CreateComponent(typeName,
(mode == REPLICATED && compID < FIRST_LOCAL_ID) ? REPLICATED : LOCAL, rewriteIDs ? 0 : compID);
if (newComponent)
{
resolver.AddComponent(compID, newComponent);
if (!newComponent->LoadXML(compElem))
return false;
}
compElem = compElem.GetNext("component");
}
if (!readChildren)
return true;
XMLElement childElem = source.GetChild("node");
while (childElem)
{
unsigned nodeID = childElem.GetInt("id");
Node* newNode = CreateChild(rewriteIDs ? 0 : nodeID, (mode == REPLICATED && nodeID < FIRST_LOCAL_ID) ? REPLICATED :
LOCAL);
resolver.AddNode(nodeID, newNode);
if (!newNode->LoadXML(childElem, resolver, readChildren, rewriteIDs, mode))
return false;
childElem = childElem.GetNext("node");
}
return true;
}
示例7: LoadParameters
void Sound::LoadParameters()
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
String xmlName = ReplaceExtension(GetName(), ".xml");
if (!cache->Exists(xmlName))
return;
XMLFile* file = cache->GetResource<XMLFile>(xmlName);
if (!file)
return;
XMLElement rootElem = file->GetRoot();
XMLElement paramElem = rootElem.GetChild();
while (paramElem)
{
String name = paramElem.GetName();
if (name == "format" && !compressed_)
{
if (paramElem.HasAttribute("frequency"))
frequency_ = paramElem.GetInt("frequency");
if (paramElem.HasAttribute("sixteenbit"))
sixteenBit_ = paramElem.GetBool("sixteenbit");
if (paramElem.HasAttribute("16bit"))
sixteenBit_ = paramElem.GetBool("16bit");
if (paramElem.HasAttribute("stereo"))
stereo_ = paramElem.GetBool("stereo");
}
if (name == "loop")
{
if (paramElem.HasAttribute("enable"))
SetLooped(paramElem.GetBool("enable"));
if (paramElem.HasAttribute("start") && paramElem.HasAttribute("end"))
SetLoop(paramElem.GetInt("start"), paramElem.GetInt("end"));
}
paramElem = paramElem.GetNext();
}
}
示例8: LoadRecord
void Board::LoadRecord()
{
if (!GetSubsystem<FileSystem>()->FileExists(GetRecordsFileName()))
return;
XMLFile config(context_);
config.Load(File(context_, GetRecordsFileName(), FILE_READ));
XMLElement root = config.GetRoot();
if (root.IsNull())
return;
if (root.HasAttribute("_1"))
record_ = root.GetInt("_1");
}
示例9: Load
void RenderTargetInfo::Load(const XMLElement& element)
{
name_ = element.GetAttribute("name");
tag_ = element.GetAttribute("tag");
if (element.HasAttribute("enabled"))
enabled_ = element.GetBool("enabled");
if (element.HasAttribute("cubemap"))
cubemap_ = element.GetBool("cubemap");
String formatName = element.GetAttribute("format");
format_ = Graphics::GetFormat(formatName);
if (element.HasAttribute("filter"))
filtered_ = element.GetBool("filter");
if (element.HasAttribute("srgb"))
sRGB_ = element.GetBool("srgb");
if (element.HasAttribute("persistent"))
persistent_ = element.GetBool("persistent");
if (element.HasAttribute("size"))
size_ = element.GetVector2("size");
if (element.HasAttribute("sizedivisor"))
{
size_ = element.GetVector2("sizedivisor");
sizeMode_ = SIZE_VIEWPORTDIVISOR;
}
else if (element.HasAttribute("rtsizedivisor"))
{
// Deprecated rtsizedivisor mode, acts the same as sizedivisor mode now
URHO3D_LOGWARNING("Deprecated rtsizedivisor mode used in rendertarget definition");
size_ = element.GetVector2("rtsizedivisor");
sizeMode_ = SIZE_VIEWPORTDIVISOR;
}
else if (element.HasAttribute("sizemultiplier"))
{
size_ = element.GetVector2("sizemultiplier");
sizeMode_ = SIZE_VIEWPORTMULTIPLIER;
}
if (element.HasAttribute("width"))
size_.x_ = element.GetFloat("width");
if (element.HasAttribute("height"))
size_.y_ = element.GetFloat("height");
if (element.HasAttribute("multisample"))
multiSample_ = Clamp(element.GetInt("multisample"), 1, 16);
if (element.HasAttribute("autoresolve"))
autoResolve_ = element.GetBool("autoresolve");
}
示例10: GetVariantMap
VariantMap XMLElement::GetVariantMap() const
{
VariantMap ret;
XMLElement variantElem = GetChild("variant");
while (variantElem)
{
StringHash key(variantElem.GetInt("hash"));
ret[key] = variantElem.GetVariant();
variantElem = variantElem.GetNext("variant");
}
return ret;
}
示例11: LoadParameters
void Sound::LoadParameters()
{
auto* cache = GetSubsystem<ResourceCache>();
String xmlName = ReplaceExtension(GetName(), ".xml");
SharedPtr<XMLFile> file(cache->GetTempResource<XMLFile>(xmlName, false));
if (!file)
return;
XMLElement rootElem = file->GetRoot();
LoadMetadataFromXML(rootElem);
for (XMLElement paramElem = rootElem.GetChild(); paramElem; paramElem = paramElem.GetNext())
{
String name = paramElem.GetName();
if (name == "format" && !compressed_)
{
if (paramElem.HasAttribute("frequency"))
frequency_ = (unsigned)paramElem.GetInt("frequency");
if (paramElem.HasAttribute("sixteenbit"))
sixteenBit_ = paramElem.GetBool("sixteenbit");
if (paramElem.HasAttribute("16bit"))
sixteenBit_ = paramElem.GetBool("16bit");
if (paramElem.HasAttribute("stereo"))
stereo_ = paramElem.GetBool("stereo");
}
if (name == "loop")
{
if (paramElem.HasAttribute("enable"))
SetLooped(paramElem.GetBool("enable"));
if (paramElem.HasAttribute("start") && paramElem.HasAttribute("end"))
SetLoop((unsigned)paramElem.GetInt("start"), (unsigned)paramElem.GetInt("end"));
}
}
}
示例12: LoadAsyncXML
bool Scene::LoadAsyncXML(File* file)
{
if (!file)
{
LOGERROR("Null file for async loading");
return false;
}
StopAsyncLoading();
SharedPtr<XMLFile> xml(new XMLFile(context_));
if (!xml->Load(*file))
return false;
LOGINFO("Loading scene from " + file->GetName());
Clear();
XMLElement rootElement = xml->GetRoot();
// Store own old ID for resolving possible root node references
unsigned nodeID = rootElement.GetInt("id");
resolver_.AddNode(nodeID, this);
// Load the root level components first
if (!Node::LoadXML(rootElement, resolver_, false))
return false;
// Then prepare for loading all root level child nodes in the async update
XMLElement childNodeElement = rootElement.GetChild("node");
asyncLoading_ = true;
asyncProgress_.file_ = file;
asyncProgress_.xmlFile_ = xml;
asyncProgress_.xmlElement_ = childNodeElement;
asyncProgress_.loadedNodes_ = 0;
asyncProgress_.totalNodes_ = 0;
// Count the amount of child nodes
while (childNodeElement)
{
++asyncProgress_.totalNodes_;
childNodeElement = childNodeElement.GetNext("node");
}
return true;
}
示例13: LoadInfo
bool TmxTileLayer2D::Load(const XMLElement& element, const TileMapInfo2D& info)
{
LoadInfo(element);
XMLElement dataElem = element.GetChild("data");
if (!dataElem)
{
URHO3D_LOGERROR("Could not find data in layer");
return false;
}
if (dataElem.HasAttribute("encoding") && dataElem.GetAttribute("encoding") != "xml")
{
URHO3D_LOGERROR("Encoding not support now");
return false;
}
XMLElement tileElem = dataElem.GetChild("tile");
tiles_.Resize((unsigned)(width_ * height_));
for (int y = 0; y < height_; ++y)
{
for (int x = 0; x < width_; ++x)
{
if (!tileElem)
return false;
int gid = tileElem.GetInt("gid");
if (gid > 0)
{
SharedPtr<Tile2D> tile(new Tile2D());
tile->gid_ = gid;
tile->sprite_ = tmxFile_->GetTileSprite(gid);
tile->propertySet_ = tmxFile_->GetTilePropertySet(gid);
tiles_[y * width_ + x] = tile;
}
tileElem = tileElem.GetNext("tile");
}
}
if (element.HasChild("properties"))
LoadPropertySet(element.GetChild("properties"));
return true;
}
示例14: rectangle
bool SpriteSheet2D::EndLoadFromXMLFile()
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
texture_ = cache->GetResource<Texture2D>(loadTextureName_);
if (!texture_)
{
URHO3D_LOGERROR("Could not load texture " + loadTextureName_);
loadXMLFile_.Reset();
loadTextureName_.Clear();
return false;
}
XMLElement rootElem = loadXMLFile_->GetRoot("TextureAtlas");
XMLElement subTextureElem = rootElem.GetChild("SubTexture");
while (subTextureElem)
{
String name = subTextureElem.GetAttribute("name");
int x = subTextureElem.GetInt("x");
int y = subTextureElem.GetInt("y");
int width = subTextureElem.GetInt("width");
int height = subTextureElem.GetInt("height");
IntRect rectangle(x, y, x + width, y + height);
Vector2 hotSpot(0.5f, 0.5f);
IntVector2 offset(0, 0);
if (subTextureElem.HasAttribute("frameWidth") && subTextureElem.HasAttribute("frameHeight"))
{
offset.x_ = subTextureElem.GetInt("frameX");
offset.y_ = subTextureElem.GetInt("frameY");
int frameWidth = subTextureElem.GetInt("frameWidth");
int frameHeight = subTextureElem.GetInt("frameHeight");
hotSpot.x_ = ((float)offset.x_ + frameWidth / 2) / width;
hotSpot.y_ = 1.0f - ((float)offset.y_ + frameHeight / 2) / height;
}
DefineSprite(name, rectangle, hotSpot, offset);
subTextureElem = subTextureElem.GetNext("SubTexture");
}
loadXMLFile_.Reset();
loadTextureName_.Clear();
return true;
}
示例15: scale
bool AnimationSet2D::LoadAnimation(const XMLElement& animationElem)
{
SharedPtr<Animation2D> animation(new Animation2D(this));
String name = animationElem.GetAttribute("name");
animation->SetName(name);
float length = animationElem.GetFloat("length") * 0.001f;
animation->SetLength(length);
bool looped = true;
if (animationElem.HasAttribute("looping"))
looped = animationElem.GetBool("looping");
animation->SetLooped(looped);
// Load timelines
for (XMLElement timelineElem = animationElem.GetChild("timeline"); timelineElem; timelineElem = timelineElem.GetNext("timeline"))
{
Timeline2D timeline;
timeline.name_ = timelineElem.GetAttribute("name");
if (timelineElem.GetAttribute("object_type") == "bone")
timeline.type_ = OT_BONE;
else
timeline.type_ = OT_SPRITE;
for (XMLElement keyElem = timelineElem.GetChild("key"); keyElem; keyElem = keyElem.GetNext("key"))
{
TimelineKey2D key;
key.time_ = keyElem.GetFloat("time") * 0.001f;
key.spin_ = 1;
if (keyElem.HasAttribute("spin"))
key.spin_ = keyElem.GetInt("spin");
XMLElement childElem = keyElem.GetChild();
Vector2 position;
position.x_ = childElem.GetFloat("x");
position.y_ = childElem.GetFloat("y");
float angle = childElem.GetFloat("angle");
Vector2 scale(Vector2::ONE);
if (childElem.HasAttribute("scale_x"))
scale.x_ = childElem.GetFloat("scale_x");
if (childElem.HasAttribute("scale_y"))
scale.y_ = childElem.GetFloat("scale_y");
key.transform_ = Transform2D(position, angle, scale);
if (timeline.type_ == OT_SPRITE)
{
int folder = childElem.GetUInt("folder");
int file = childElem.GetUInt("file");
key.sprite_ = GetSprite(folder, file);
if (!key.sprite_)
{
LOGERROR("Could not find sprite");
return false;
}
if (childElem.HasAttribute("pivot_x"))
key.hotSpot_.x_ = childElem.GetFloat("pivot_x");
else
key.hotSpot_.x_ = key.sprite_->GetHotSpot().x_;
if (childElem.HasAttribute("pivot_y"))
key.hotSpot_.y_ = childElem.GetFloat("pivot_y");
else
key.hotSpot_.y_ = key.sprite_->GetHotSpot().y_;
if (childElem.HasAttribute("a"))
key.alpha_ = childElem.GetFloat("a");
}
timeline.timelineKeys_.Push(key);
}
// Add end key for looped animation
if (looped && timeline.timelineKeys_.Back().time_ != length)
{
TimelineKey2D key = timeline.timelineKeys_.Front();
key.time_ = length;
timeline.timelineKeys_.Push(key);
}
animation->AddTimeline(timeline);
}
// Load main line
XMLElement mainlineElem = animationElem.GetChild("mainline");
for (XMLElement keyElem = mainlineElem.GetChild("key"); keyElem; keyElem = keyElem.GetNext("key"))
{
MainlineKey2D mainlineKey;
int id = keyElem.GetInt("id");
mainlineKey.time_ = keyElem.GetFloat("time") * 0.001f;
for (XMLElement refElem = keyElem.GetChild(); refElem; refElem = refElem.GetNext())
{
Reference2D ref;
//.........这里部分代码省略.........