本文整理汇总了C++中rocket::core::Element::HasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::HasAttribute方法的具体用法?C++ Element::HasAttribute怎么用?C++ Element::HasAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rocket::core::Element
的用法示例。
在下文中一共展示了Element::HasAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: usableDropped
void ShortcutBar::usableDropped(Rocket::Core::Event& event)
{
Rocket::Core::Element* dragElement = static_cast<Rocket::Core::Element*>(event.GetParameter< void* >("drag_element", nullptr));
if (dragElement != nullptr)
{
const bool isItem = dragElement->HasAttribute("itemId");
const bool isSkill = dragElement->HasAttribute("skillId") && dragElement->HasAttribute("characterId");
UsableId usableId = 0;
if(isItem)
{
usableId = static_cast<UsableId>(dragElement->GetAttribute<int>("itemId", 0));
}
else if(isSkill)
{
usableId = static_cast<UsableId>(dragElement->GetAttribute<int>("skillId", 0));
}
if(usableId > 0)
{
Rocket::Core::Element* dropElement = event.GetTargetElement();
// Only drops on direct children of the shortcut container count as
// shortcut drops
if(dropElement->GetParentNode() == m_shortcutContainer)
{
// Find the index of the shortcut
int dropTargetIndex = 0;
for(;;)
{
dropElement = dropElement->GetPreviousSibling();
if (dropElement == nullptr) break;
++dropTargetIndex;
}
bool isShortcutSet = false;
if(isItem)
{
DEBUG("Dropping item %d on shortcut index %d.", usableId, dropTargetIndex);
m_playerData.setShortcut(dropTargetIndex, usableId);
isShortcutSet = true;
}
else if(isSkill)
{
const std::string characterId = dragElement->GetAttribute<Rocket::Core::String>("characterId", "").CString();
Character* character = m_playerData.getRoster()->getCharacter(characterId);
if(character != nullptr)
{
DEBUG("Dropping skill %d on shortcut index %d.", usableId, dropTargetIndex);
m_playerData.setShortcut(dropTargetIndex, usableId, characterId);
isShortcutSet = true;
}
}
if(isShortcutSet)
{
// If the drag was initiated from the shortcut bar, then
// clear out the shortcut's original slot
if (dragElement->GetParentNode() == m_shortcutContainer)
{
int dragTargetIndex = 0;
for(;;)
{
dragElement = dragElement->GetPreviousSibling();
if (dragElement == nullptr) break;
++dragTargetIndex;
}
m_playerData.clearShortcut(dragTargetIndex);
}
}
refresh();
}
}
}
}