本文整理汇总了C++中rocket::core::Element::SetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::SetAttribute方法的具体用法?C++ Element::SetAttribute怎么用?C++ Element::SetAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rocket::core::Element
的用法示例。
在下文中一共展示了Element::SetAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processMultiplayer
void MainMenu::processMultiplayer(Rocket::Core::Event& event)
{
std::random_device device;
std::mt19937 rand(device());
std::uniform_int_distribution<> distribution(0, INT_MAX);
const Rocket::Core::String& id = event.GetCurrentElement()->GetId();
if (id == "back") {
m_mainMenuMultiplayer->Hide();
} else if (id == "host") {
Rocket::Core::Element* playerNameInput = m_mainMenuMultiplayerHost->GetElementById("playerName");
//HACK: pick a random useless name
std::stringstream ss;
ss << "Player";
ss << distribution(rand);
playerNameInput->SetAttribute("value", ss.str().c_str());
m_mainMenuMultiplayerHost->Show();
} else if (id == "join") {
Rocket::Core::Element* playerNameInput = m_mainMenuMultiplayerJoin->GetElementById("playerName");
//HACK: pick a random useless name
std::stringstream ss;
ss << "Player";
ss << distribution(rand);
playerNameInput->SetAttribute("value", ss.str().c_str());
m_mainMenuMultiplayerJoin->Show();
}
}
示例2: processSingleplayer
void MainMenu::processSingleplayer(Rocket::Core::Event& event)
{
const Rocket::Core::String& id = event.GetCurrentElement()->GetId();
//just at the singleplayer sub menu
if (id == "create") {
// FIXME: populate the singleplayer create with values from settings
Rocket::Core::Element* playerNameInput = m_mainMenuSingleplayerCreate->GetElementById("playerName");
//HACK: pick a random useless name
std::stringstream ss;
ss << "Player";
std::random_device device;
std::mt19937 rand(device());
std::uniform_int_distribution<> distribution(0, INT_MAX);
ss << distribution(rand);
playerNameInput->SetAttribute("value", ss.str().c_str());
m_mainMenuSingleplayerCreate->Show();
} else if (id == "load") {
m_mainMenuSingleplayerLoad->Show();
} else if (id == "back") {
m_mainMenuSingleplayer->Hide();
}
}
示例3: UiBase
UiObjectQuantityPicker::UiObjectQuantityPicker(WindowFramework* window, Rocket::Core::Context* context, const Inventory& inventory, const InventoryObject* object) : UiBase(window, context)
{
_max_quantity = inventory.ContainsHowMany(object->GetName());
root = context->LoadDocument("data/object_quantity_picker.rml");
if (root)
{
Rocket::Core::Element* icon = root->GetElementById("item_icon");
_line_edit = root->GetElementById("item_quantity");
if (_line_edit)
{
ToggleEventListener(true, "button_confirm", "click", EventAccepted);
EventAccepted.EventReceived.Connect(*this, &UiObjectQuantityPicker::Accepted);
}
if (icon)
{
Rocket::Core::String src("../textures/itemIcons/");
src += object->GetIcon().c_str();
icon->SetAttribute("src", src);
}
ToggleEventListener(true, "item_minus", "click", EventIncrement);
ToggleEventListener(true, "item_plus", "click", EventIncrement);
ToggleEventListener(true, "item_quantity", "change", EventValueChanged);
ToggleEventListener(true, "button_cancel", "click", EventCanceled);
EventIncrement.EventReceived.Connect(*this, &UiObjectQuantityPicker::Increment);
EventValueChanged.EventReceived.Connect([this](Rocket::Core::Event&) { SetQuantity(GetQuantity()); });
EventCanceled.EventReceived.Connect( [this](Rocket::Core::Event&) { Canceled.Emit(); });
Canceled.Connect(*this, &UiBase::Hide);
SetModal(true);
}
}
示例4: 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);
}
}
示例5: MouseButton
void InteractMenu::MouseButton(Rocket::Core::Event& event)
{
ExecuteForButtonId(event, [this](Rocket::Core::Event& event, const string& event_type, Interactions::Interaction* interaction) -> bool
{
bool mouse_over = event_type == "mousedown";
Rocket::Core::Element* img = event.GetCurrentElement()->GetChild(0);
string id = event.GetCurrentElement()->GetId().CString();
string src = "../textures/buttons/" + id + '-' + (mouse_over ? "pressed" : "normal") + ".png";
img->SetAttribute("src", src.c_str());
return (true);
});
}
示例6: Rocket_SetAttribute
void Rocket_SetAttribute( const char *name, const char *id, const char *attribute, const char *value )
{
if ( ( !*name && !*id ) && activeElement )
{
activeElement->SetAttribute( attribute, value );
}
else
{
Rocket::Core::ElementDocument *document = name[0] ? menuContext->GetDocument( name ) : menuContext->GetFocusElement()->GetOwnerDocument();
if ( document )
{
Rocket::Core::Element *element = document->GetElementById( id );
if ( element )
{
element->SetAttribute( attribute, value );
}
}
}
}