当前位置: 首页>>代码示例>>C++>>正文


C++ core::Element类代码示例

本文整理汇总了C++中rocket::core::Element的典型用法代码示例。如果您正苦于以下问题:C++ Element类的具体用法?C++ Element怎么用?C++ Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ToggleEventListener

void UiBase::ToggleEventListener(bool toggle_on, const std::string& id, const std::string& event, RocketListener& listener)
{
  if (root)
  {
    Rocket::Core::Element* element = root->GetElementById(id.c_str());

    if (element)
    {
      Listener             registered(element, event, listener);
      auto                 it      = std::find(listeners.begin(), listeners.end(), registered);

      if (toggle_on)
      {
        if (it == listeners.end())
          listeners.push_back(registered);
        else
          element->RemoveEventListener(event.c_str(), &listener);
        element->AddEventListener(event.c_str(), &listener);
      }
      else
      {
        element->RemoveEventListener(event.c_str(), &listener);
        if (it != listeners.end())
          listeners.erase(it);
      }
    }
    else
      cout << "[WARNING] Element '" << id << "' doesn't exist." << endl;
  }
}
开发者ID:655473,项目名称:fallout-equestria,代码行数:30,代码来源:ui_base.cpp

示例2: 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);
  }
}
开发者ID:655473,项目名称:fallout-equestria,代码行数:32,代码来源:ui_object_quantity_picker.cpp

示例3: shortcutClicked

void ShortcutBar::shortcutClicked(Rocket::Core::Event& event)
{
   Rocket::Core::Element* shortcutElement = event.GetTargetElement();

   while(shortcutElement != nullptr && shortcutElement->GetParentNode() != m_shortcutContainer)
   {
      shortcutElement = shortcutElement->GetParentNode();
   }

   // Only handle the click if it went to a shortcut
   // (direct child of the shortcut bar container)
   if (shortcutElement != nullptr)
   {
      // Find the index of the shortcut
      int shortcutIndex = 0;

      for(;;)
      {
         shortcutElement = shortcutElement->GetPreviousSibling();
         if (shortcutElement == nullptr) break;
         ++shortcutIndex;
      }

      bool shortcutInvoked = invokeShortcut(shortcutIndex);
      if (shortcutInvoked)
      {
         refresh();
      }
   }
}
开发者ID:noam-c,项目名称:EDEn,代码行数:30,代码来源:ShortcutBar.cpp

示例4: 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();
    }
}
开发者ID:EmmetCooper,项目名称:ore-infinium,代码行数:25,代码来源:mainmenu.cpp

示例5: BindEvent

void Layout::BindEvent(const string& id, UIEvent event)
{
    // Map event ID to string
    string eventID;
    switch (event)
    {
    case UI_CLICK:
        eventID = "click";
        break;

    case UI_SUBMIT:
        eventID = "submit";
        break;

    default:
        break;
    }
    
    // Look up the element
    Rocket::Core::Element* elem = mDocument->GetElementById(id.c_str());
    assert(elem);
    
    // Add the listener
    elem->AddEventListener(eventID.c_str(), mInterfaceMgr);
    mListeners.push_back(make_tuple(id, eventID, mInterfaceMgr));
}
开发者ID:davedissian,项目名称:dawnengine,代码行数:26,代码来源:Layout.cpp

示例6: 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();
    }
}
开发者ID:EmmetCooper,项目名称:ore-infinium,代码行数:31,代码来源:mainmenu.cpp

示例7: OnDocumentLoad

void RocketMenuPlugin::OnDocumentLoad(Rocket::Core::ElementDocument* document) {
    DocumentData *doc_data = new DocumentData();

    doc_data->cursor_left = document->GetElementById("cursor-left");
    doc_data->cursor_right = document->GetElementById("cursor-right");
    doc_data->menu = document->GetElementById("menu");

    if (doc_data->menu == NULL) {
        for (int i = 0, n = document->GetNumChildren(); i!=n; i++) {
            Rocket::Core::Element *element = document->GetChild(i);
            if (element->IsClassSet("game-menu")) {
                doc_data->menu = element;
                break;
            }
        }
    }

    if (doc_data->menu != NULL) {
        for (int i = 0, n = doc_data->menu->GetNumChildren(); i < n; i++) {
            Rocket::Core::Element *e = doc_data->menu->GetChild(i);
            SetupMenuItem(e);
        }
        SetDocumentData(document, doc_data);
    } else {
        delete doc_data;
    }
}
开发者ID:ppiecuch,项目名称:libRocket,代码行数:27,代码来源:RocketMenuPlugin.cpp

示例8: 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;
}
开发者ID:ktj007,项目名称:mmo,代码行数:36,代码来源:EventManager.cpp

示例9: 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);
}
开发者ID:Hmaal,项目名称:OpenSkyscraper,代码行数:9,代码来源:TimeWindow.cpp

示例10: while

Rocket::Core::Element* RocketMenuPlugin::FindPreviousItem(Rocket::Core::Element *menu_item) {
    Rocket::Core::Element *next = menu_item;
    do {
        next = next->GetPreviousSibling();
        if (next == NULL) {
            next = menu_item->GetParentNode()->GetChild(menu_item->GetParentNode()->GetNumChildren()-1);
        }
    } while (next->IsClassSet("disabled") && next != menu_item);
    return next;
}
开发者ID:ppiecuch,项目名称:libRocket,代码行数:10,代码来源:RocketMenuPlugin.cpp

示例11:

void             InventoryView::Destroy()
{
  Rocket::Core::Element* element;
  
  for (int i = 0 ; (element = _element.GetChild(i)) != 0 ; ++i)
  {
    element->RemoveEventListener("dblclick",  this);
    element->RemoveEventListener("mouseover", this);
    element->RemoveEventListener("click",     this);
  }
}
开发者ID:655473,项目名称:fallout-equestria,代码行数:11,代码来源:inventory_ui.cpp

示例12: ProcessEvent

	virtual void ProcessEvent( Event &event )
	{
		if( !target ) {
			return;
		}
		if( released ) {
			// the function pointer has been released, but
			// we're hanging around, waiting for shutdown or GC
			return;
		}

		Element *elem = event.GetTargetElement();

		if( elem->GetOwnerDocument() != target->GetOwnerDocument() ) {
			// make sure the event originated from the same document as the original target
			return;
		}

		UI_ScriptDocument *document = dynamic_cast<UI_ScriptDocument *>(elem->GetOwnerDocument());
		if( !document || document->IsLoading() ) {
			return;
		}

		fetchFunctionPtr( document->GetModule() );

		// push elem and event as parameters to the internal function
		// and call it

		if( UI_Main::Get()->debugOn() ) {
			Com_Printf( "ScriptEventListener: Event %s, target %s, script %s\n",
				event.GetType().CString(),
				event.GetTargetElement()->GetTagName().CString(),
				script.CString() );
		}

		if( funcPtr.isValid() ) {
			target->AddReference();
			event.AddReference();
			try {
				asIScriptContext *context = asmodule->getContext();

				// the context may actually be NULL after AS shutdown
				if( context ) {
					funcPtr.setContext( context );
					funcPtr( target, &event );
				}
			} catch( ASBind::Exception & ) {
				Com_Printf( S_COLOR_RED "ScriptEventListener: Failed to call function %s %s\n", funcName.CString(), script.CString() );
			}
		}
		else {
			Com_Printf( S_COLOR_RED "ScriptEventListener: Not gonna call invalid function %s %s\n", funcName.CString(), script.CString() );
		}
	}
开发者ID:MGXRace,项目名称:racesow,代码行数:54,代码来源:asui_scriptevent.cpp

示例13: 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());
    }
}
开发者ID:EmmetCooper,项目名称:ore-infinium,代码行数:12,代码来源:mainmenu.cpp

示例14: 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);
   }
}
开发者ID:noam-c,项目名称:EDEn,代码行数:57,代码来源:ShortcutBar.cpp

示例15: 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);
    });
}
开发者ID:655473,项目名称:fallout-equestria,代码行数:13,代码来源:interact_menu.cpp


注:本文中的rocket::core::Element类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。