本文整理汇总了C++中rocket::core::Element::SetInnerRML方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::SetInnerRML方法的具体用法?C++ Element::SetInnerRML怎么用?C++ Element::SetInnerRML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rocket::core::Element
的用法示例。
在下文中一共展示了Element::SetInnerRML方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadWindow
// Loads a window and binds the event handler for it.
bool EventManager::LoadWindow(const Rocket::Core::String& window_name)
{
// Set the event handler for the new screen, if one has been registered.
EventHandler* old_event_handler = event_handler;
EventHandlerMap::iterator iterator = event_handlers.find(window_name);
if (iterator != event_handlers.end())
event_handler = (*iterator).second;
else
event_handler = NULL;
// Attempt to load the referenced RML document.
char path[1024];
GetMmoResourcePath(path, 1024, (window_name + ".rml").CString());
Rocket::Core::ElementDocument* document = gContext->LoadDocument(path);
if (document == NULL)
{
event_handler = old_event_handler;
return false;
}
// Set the element's title on the title; IDd 'title' in the RML.
Rocket::Core::Element* title = document->GetElementById("title");
if (title != NULL)
title->SetInnerRML(document->GetTitle());
document->Focus();
document->Show();
// Remove the caller's reference.
document->RemoveReference();
return true;
}
示例2: updatePopulation
void TimeWindow::updatePopulation()
{
char c[32];
snprintf(c, 32, "%i", game->population);
Rocket::Core::Element * e = window->GetElementById("population");
assert(e);
e->SetInnerRML(c);
}
示例3: 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);
}
}
示例4: AddLogMessage
// Adds a log message to the debug log.
void ElementLog::AddLogMessage(Core::Log::Type type, const Core::String& message)
{
// Add the message to the list of messages for the specified log type.
LogMessage log_message;
log_message.index = current_index++;
log_message.message = Core::String(message).Replace("<", "<").Replace(">", ">");
log_types[type].log_messages.push_back(log_message);
if (log_types[type].log_messages.size() >= MAX_LOG_MESSAGES)
{
log_types[type].log_messages.pop_front();
}
// If this log type is invisible, and there is a button for this log type, then change its text from
// "Off" to "Off*" to signal that there are unread logs.
if (!log_types[type].visible)
{
if (!log_types[type].button_name.Empty())
{
Rocket::Core::Element* button = GetElementById(log_types[type].button_name);
if (button)
{
button->SetInnerRML("Off*");
}
}
}
// Trigger the beacon if we're hidden. Override any lower-level log type if it is already visible.
else
{
if (!IsVisible())
{
if (beacon != NULL)
{
if (type < current_beacon_level)
{
beacon->SetProperty("visibility", "visible");
current_beacon_level = type;
Rocket::Core::Element* beacon_button = beacon->GetFirstChild();
if (beacon_button)
{
beacon_button->SetClassNames(log_types[type].class_name);
beacon_button->SetInnerRML(log_types[type].alert_contents);
}
}
}
}
}
// Force a refresh of the RML.
dirty_logs = true;
}
示例5: 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();
}
示例6:
// Loads a window and binds the event handler for it.
Rocket::Core::ElementDocument* EventManager::LoadWindow(const Rocket::Core::String& window_name)
{
// Set the event handler for the new screen, if one has been registered.
EventHandler* old_event_handler = event_handler;
EventHandlerMap::iterator iterator = event_handlers.find(window_name);
if (iterator != event_handlers.end())
{
event_handler = iterator->second;
//Rocket::Core::Log::Message(Rocket::Core::Log::LT_INFO, "%s", window_name.CString());
}
else
event_handler = NULL;
// Attempt to load the referenced RML document.
Rocket::Core::String document_path = Rocket::Core::String("data/") + window_name + Rocket::Core::String(".rml");
Rocket::Core::ElementDocument* document = Context->LoadDocument(document_path.CString());
if (document == nullptr)
{
event_handler = old_event_handler;
return nullptr;
}
document->SetId(window_name);
// Set the element's title on the title; IDd 'title' in the RML.
Rocket::Core::Element* title = document->GetElementById("title");
if (title != NULL)
title->SetInnerRML(document->GetTitle());
document->Focus();
document->Show();
// Remove the caller's reference.
document->RemoveReference();
return document;
}
示例7: LoadGUI
bool GuiManager::LoadGUI(const String &doc)
{
if (this->UnloadGUI())
{
Log("Loading GUI Document");
pDoc = pContext->LoadDocument(doc.c_str());
if (pDoc != NULL)
{
Rocket::Core::Element *title = pDoc->GetElementById("title");
if (title != NULL)
title->SetInnerRML(pDoc->GetTitle());
pDoc->Focus();
pDoc->Show();
if (pDoc->GetElementById("lifes") != NULL)
pElementLife = pDoc->GetElementById("lifes");
if (pDoc->GetElementById("time") != NULL)
pElementTime = pDoc->GetElementById("time");
if (pDoc->GetElementById("hostages") != NULL)
pElementHostage = pDoc->GetElementById("hostages");
if (pDoc->GetElementById("sfx") != NULL && gGameData->IsSfxEnabled())
pDoc->GetElementById("sfx")->SetAttribute("checked", "");
if (pDoc->GetElementById("bgm") != NULL && gGameData->IsBgmEnabled())
pDoc->GetElementById("bgm")->SetAttribute("checked", "");
}
sDocument = doc;
}
return true;
}
示例8: updateTime
void TimeWindow::updateTime()
{
Time & t = game->time;
window->GetElementById("watch")->SetAttribute<float>("time", t.hour);
Rocket::Core::Element * weekday = window->GetElementById("date-weekday");
Rocket::Core::Element * weekend = window->GetElementById("date-weekend");
weekday->SetInnerRML(t.day == 0 ? "1st WD" : "2nd WD");
weekday->SetProperty("display", (t.day == 2 ? "none" : "inline"));
weekend->SetProperty("display", (t.day != 2 ? "none" : "inline"));
char c[128];
snprintf(c, 128, "%iQ", t.quarter);
window->GetElementById("date-quarter")->SetInnerRML(c);
const char * suffix = "th";
int yl = (t.year % 10);
if (yl == 1) suffix = "st";
if (yl == 2) suffix = "nd";
if (yl == 3) suffix = "rd";
snprintf(c, 128, "%i%s", t.year, suffix);
window->GetElementById("date-year")->SetInnerRML(c);
}
示例9: UiBase
InteractMenu::InteractMenu(WindowFramework* window, Rocket::Core::Context* context, InstanceDynamicObject& object) : UiBase(window, context)
{
Interactions::InteractionList& interactions = object.GetInteractions();
_done = false;
root = context->LoadDocument("data/interact_menu.rml");
if (root)
{
Rocket::Core::Element* element = root->GetElementById("menu");
if (element)
{
// Positioning the interact_menu
{
std::stringstream strTop, strLeft, maxHeight;
MouseData pointer = window->get_graphics_window()->get_pointer(0);
strTop << (pointer.get_y());
strLeft << (pointer.get_x());
maxHeight << (window->get_graphics_window()->get_y_size() - pointer.get_y());
element->SetProperty("position", "absolute");
element->SetProperty("top", strTop.str().c_str());
element->SetProperty("left", strLeft.str().c_str());
element->SetProperty("max-height", maxHeight.str().c_str());
}
// Generating and setting the RML for the interact_menu
{
std::stringstream rml;
for_each(interactions.begin(), interactions.end(), [&rml](Interactions::Interaction& interaction)
{
rml << "<div id='interaction-" << interaction.name << "'>";
rml << "<button id='" << interaction.name << "' class='interact_button'>";
rml << "<img src='../textures/buttons/" + interaction.name + "-normal.png' />";
rml << "</button></div>";
});
element->SetInnerRML(rml.str().c_str());
}
int it = 0;
_listeners.resize(interactions.size());
for_each(interactions.begin(), interactions.end(), [this, &it](Interactions::Interaction& interaction)
{
ToggleEventListener(true, interaction.name, "click", _buttonListener);
ToggleEventListener(true, interaction.name, "mouseover", _buttonHover);
ToggleEventListener(true, interaction.name, "mouseout", _buttonHover);
ToggleEventListener(true, interaction.name, "mousedown", _buttonClick);
ToggleEventListener(true, interaction.name, "mouseup", _buttonClick);
_listeners[it] = &interaction;
_obs.Connect(_buttonListener.EventReceived, *this, &InteractMenu::ButtonClicked);
_obs.Connect(_buttonHover.EventReceived, *this, &InteractMenu::ButtonHovered);
_obs.Connect(_buttonClick.EventReceived, *this, &InteractMenu::MouseButton);
++it;
});
}
Show();
}
}
示例10: updateFunds
void TimeWindow::updateFunds()
{
Rocket::Core::Element * e = window->GetElementById("funds");
assert(e);
e->SetInnerRML(formatMoney(game->funds).c_str());
}