本文整理汇总了C++中rocket::core::Element::AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::AppendChild方法的具体用法?C++ Element::AppendChild怎么用?C++ Element::AppendChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rocket::core::Element
的用法示例。
在下文中一共展示了Element::AppendChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: refresh
void ShortcutBar::refresh()
{
DEBUG("Refreshing shortcut bar...");
m_shortcutContainer->SetInnerRML("");
for (int i = 0; i < PlayerData::SHORTCUT_BAR_SIZE; ++i)
{
const Shortcut& shortcut = m_playerData.getShortcut(i);
const Usable* usable =
shortcut.usableType == Shortcut::UsableType::ITEM ?
static_cast<const Usable*>(m_metadata.getItem(shortcut.usableId)) :
static_cast<const Usable*>(m_metadata.getSkill(shortcut.usableId));
Rocket::Core::Element* shortcutElement = m_shortcutBarDocument->CreateElement("div");
Rocket::Core::ElementAttributes shortcutElementAttributes;
shortcutElementAttributes.Set("class", "shortcut");
if(usable != nullptr)
{
if (shortcut.usableType == Shortcut::UsableType::ITEM)
{
DEBUG("Adding shortcut for item %d", shortcut.usableId);
shortcutElementAttributes.Set("itemId", static_cast<int>(shortcut.usableId));
}
else
{
DEBUG("Adding shortcut for skill %d", shortcut.usableId);
shortcutElementAttributes.Set("skillId", static_cast<int>(shortcut.usableId));
shortcutElementAttributes.Set("characterId", shortcut.characterId.c_str());
}
Rocket::Core::String shortcutIconPath("../../");
shortcutIconPath += usable->getIconPath().c_str();
Rocket::Core::Element* shortcutIconElement = m_shortcutBarDocument->CreateElement("img");
Rocket::Core::ElementAttributes shortcutIconElementAttributes;
shortcutIconElementAttributes.Set("src", shortcutIconPath);
shortcutIconElementAttributes.Set("class", "shortcutIcon");
if (shortcut.usableType == Shortcut::UsableType::ITEM)
{
const Rocket::Core::String shortcutQuantity(8, "%d", m_playerData.getInventory()->getItemQuantity(shortcut.usableId));
Rocket::Core::Element* shortcutQuantityElement = m_shortcutBarDocument->CreateElement("span");
shortcutQuantityElement->SetInnerRML(shortcutQuantity);
shortcutQuantityElement->SetAttribute("class", "shortcutQuantity");
shortcutElement->AppendChild(shortcutQuantityElement);
}
shortcutIconElement->SetAttributes(&shortcutIconElementAttributes);
shortcutElement->AppendChild(shortcutIconElement);
}
shortcutElement->SetAttributes(&shortcutElementAttributes);
m_shortcutContainer->AppendChild(shortcutElement);
}
}
示例2: AddItem
// Adds a brand-new item into this inventory.
void Inventory::AddItem(const Rocket::Core::String& name)
{
if (document == NULL)
return;
Rocket::Core::Element* content = document->GetElementById("content");
if (content == NULL)
return;
// Create the new 'icon' element.
Rocket::Core::Element* icon = Rocket::Core::Factory::InstanceElement(content, "icon", "icon", Rocket::Core::XMLAttributes());
icon->SetInnerRML(name);
content->AppendChild(icon);
// Release the initial reference on the element now that the document has it.
icon->RemoveReference();
}