本文整理汇总了C++中rocket::core::Event::GetCurrentElement方法的典型用法代码示例。如果您正苦于以下问题:C++ Event::GetCurrentElement方法的具体用法?C++ Event::GetCurrentElement怎么用?C++ Event::GetCurrentElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rocket::core::Event
的用法示例。
在下文中一共展示了Event::GetCurrentElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessEvent
virtual void ProcessEvent(Rocket::Core::Event& event)
{
if(event.GetCurrentElement()->GetId() == "loadForm")
{
LevelSelector::GetInstance().OnLoadButtonClick();
}
else if(event.GetCurrentElement()->GetId() == "quitForm")
{
LevelSelector::GetInstance().OnQuitButtonClick();
}
}
示例2: 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);
});
}
示例3: ProcessEvent
void EventHandlerHighScore::ProcessEvent(Rocket::Core::Event& event, const Rocket::Core::String& value)
{
if (value == "add_score")
{
int score = GameDetails::GetScore();
if (score > 0)
{
// Submit the score the player just got to the high scores chart.
HighScores::SubmitScore(GameDetails::GetDefenderColour(), GameDetails::GetWave(), GameDetails::GetScore());
// Reset the score so the chart won't get confused next time we enter.
GameDetails::ResetScore();
}
}
else if (value == "enter_name")
{
if (event.GetParameter< int >("key_identifier", Rocket::Core::Input::KI_UNKNOWN) == Rocket::Core::Input::KI_RETURN)
{
Rocket::Core::String name = event.GetCurrentElement()->GetAttribute< Rocket::Core::String >("value", "Anon.");
HighScores::SubmitName(name);
}
}
else if (value == "check_input")
{
Rocket::Core::Element* name_input_field = event.GetTargetElement()->GetElementById("player_input");
if (name_input_field)
{
name_input_field->Focus();
}
}
else if (value == "check_name")
{
/* TODO: Check if the player hasn't set their name first. */
HighScores::SubmitName("Anon.");
}
}
示例4: 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();
}
}
示例5: processSingleplayerLoad
void MainMenu::processSingleplayerLoad(Rocket::Core::Event& event)
{
const Rocket::Core::String& id = event.GetCurrentElement()->GetId();
if (id == "back") {
m_mainMenuSingleplayerLoad->Hide();
}
}
示例6: 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();
}
}
示例7: ProcessEvent
void Console::ProcessEvent(Rocket::Core::Event& event)
{
String controlId(event.GetCurrentElement()->GetId().CString());
if (controlId == "cmd")
{
int key = event.GetParameters()->Get<int>("key_identifier", 0);
Rocket::Controls::ElementFormControl* inputBox =
static_cast<Rocket::Controls::ElementFormControl*>(event.GetCurrentElement());
if (key == Rocket::Core::Input::KI_RETURN)
{
String command = inputBox->GetValue().CString();
inputBox->SetValue("");
Execute(command);
}
}
}
示例8: Increment
void UiObjectQuantityPicker::Increment(Rocket::Core::Event& event)
{
const short value_change = (event.GetCurrentElement()->GetId() == "item_plus" ? 1 : -1);
const unsigned short quantity = GetQuantity();
if (quantity > 0 || value_change != -1)
SetQuantity(quantity + value_change);
}
示例9: processSingleplayerCreate
void MainMenu::processSingleplayerCreate(Rocket::Core::Event& event)
{
const Rocket::Core::String& id = event.GetCurrentElement()->GetId();
if (id == "back") {
m_mainMenuSingleplayerCreate->Hide();
} else if (id == "start") {
Rocket::Core::Element* playerNameInput = m_mainMenuSingleplayerCreate->GetElementById("playerName");
Rocket::Core::String playerName = playerNameInput->GetAttribute("value")->Get<Rocket::Core::String>();
hideSubmenus();
m_client->startSinglePlayer(playerName.CString());
}
}
示例10: ButtonClicked
void InteractMenu::ButtonClicked(Rocket::Core::Event& event)
{
if (_done) return;
for (unsigned int i = 0 ; i < _listeners.size() ; ++i)
{
if (event.GetCurrentElement()->GetId() == _listeners[i]->name.c_str())
{
_listeners[i]->signal->Emit(_listeners[i]->instance);
_done = true;
Done.Emit();
break ;
}
}
}
示例11: processMainMenu
void MainMenu::processMainMenu(Rocket::Core::Event& event)
{
const Rocket::Core::String& id = event.GetCurrentElement()->GetId();
if (id == "singleplayer") {
m_mainMenuSingleplayer->Show();
} else if (id == "multiplayer") {
m_mainMenuMultiplayer->Show();
} else if (id == "options") {
showOptionsDialog();
} else if (id == "quit") {
// no prompt needed for save, no active connection.
m_client->shutdown();
}
}
示例12: ExecuteForButtonId
void InteractMenu::ExecuteForButtonId(Rocket::Core::Event& event, std::function<bool (Rocket::Core::Event&, const std::string&, Interactions::Interaction*)> callback)
{
if (!_done)
{
string id = event.GetCurrentElement()->GetId().CString();
string event_type = event.GetType().CString();
for (unsigned int i = 0 ; i < _listeners.size() ; ++i)
{
if (id == _listeners[i]->name && (callback(event, event_type, _listeners[i])))
break ;
}
}
}
示例13: processEscapeMenu
void MainMenu::processEscapeMenu(Rocket::Core::Event& event)
{
const Rocket::Core::String& id = event.GetCurrentElement()->GetId();
if (id == "resume") {
hideEscapeMenu();
} else if (id == "disconnect") {
m_client->disconnect();
} else if (id == "options") {
showOptionsDialog();
} else if (id == "quit") {
//FIXME: prompt dialog to disconnect, as we clearly are connected.
m_client->shutdown();
}
}
示例14: processMultiplayerHost
void MainMenu::processMultiplayerHost(Rocket::Core::Event& event)
{
const Rocket::Core::String& id = event.GetCurrentElement()->GetId();
if (id == "back") {
m_mainMenuMultiplayerHost->Hide();
} if (id == "host") {
Rocket::Core::Element* playerNameInput = m_mainMenuMultiplayerHost->GetElementById("playerName");
Rocket::Core::String playerName = playerNameInput->GetAttribute("value")->Get<Rocket::Core::String>();
Rocket::Core::Element* portInput = m_mainMenuMultiplayerHost->GetElementById("port");
Rocket::Core::String port = portInput->GetAttribute("value")->Get<Rocket::Core::String>();
hideSubmenus();
m_client->startMultiplayerHost(playerName.CString(), atoi(port.CString()));
}
}
示例15: ProcessEvent
void DragListener::ProcessEvent(Rocket::Core::Event& event)
{
if (event == "dragdrop")
{
Rocket::Core::Element* dest_container = event.GetCurrentElement();
Rocket::Core::Element* dest_element = event.GetTargetElement();
Rocket::Core::Element* drag_element = static_cast< Rocket::Core::Element* >(event.GetParameter< void* >("drag_element", NULL));
if (dest_container == dest_element)
{
// The dragged element was dragged directly onto a container.
drag_element->GetParentNode()->RemoveChild(drag_element);
dest_container->AppendChild(drag_element);
}
else
{
// The dragged element was dragged onto an item inside a container. In order to get the
// element in the right place, it will be inserted into the container before the item
// it was dragged on top of.
Rocket::Core::Element* insert_before = dest_element;
// Unless of course if it was dragged on top of an item in its own container; we need
// to check then if it was moved up or down with the container.
if (drag_element->GetParentNode() == dest_container)
{
// Check whether we're moving this icon from the left or the right.
Rocket::Core::Element* previous_icon = insert_before->GetPreviousSibling();
while (previous_icon != NULL)
{
if (previous_icon == drag_element)
{
insert_before = insert_before->GetNextSibling();
break;
}
previous_icon = previous_icon->GetPreviousSibling();
}
}
drag_element->GetParentNode()->RemoveChild(drag_element);
dest_container->InsertBefore(drag_element, insert_before);
}
}
}