Ejemplo n.º 1
0
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;
  }
}
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);
  }
}
Ejemplo n.º 3
0
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();
      }
   }
}
Ejemplo n.º 4
0
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();
    }
}
Ejemplo n.º 5
0
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));
}
Ejemplo n.º 6
0
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();
    }
}
Ejemplo n.º 7
0
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;
    }
}
Ejemplo n.º 8
0
// 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;
}
Ejemplo n.º 9
0
void TimeWindow::updatePopulation()
{
	char c[32];
	snprintf(c, 32, "%i", game->population);
	
	Rocket::Core::Element * e = window->GetElementById("population");
	assert(e);
	e->SetInnerRML(c);
}
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
0
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);
  }
}
Ejemplo n.º 12
0
	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() );
		}
	}
Ejemplo n.º 13
0
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());
    }
}
Ejemplo n.º 14
0
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);
   }
}
Ejemplo n.º 15
0
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);
    });
}
Ejemplo n.º 16
0
Rocket::Core::Element*
    TemplateCloner::getCloneById(const Rocket::Core::String& id)
{
    if(!_templateDoc)
        OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, "The template document is null pointer", "TemplateCloner::getCloneById");
    //find and clone the element.
    Rocket::Core::Element* retEl = _templateDoc->GetElementById(id);

    if(!retEl)
        OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "The element with the given ID was not found in this template document", 
        "TemplateCloner::getCloneById");
    return retEl->Clone();
}
Ejemplo n.º 17
0
// 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("<", "&lt;").Replace(">", "&gt;");
	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;
}
Ejemplo n.º 18
0
void UIContext::set_debugger_size(const Size2i& dims)
{
  if( this->valid() ) {

    Rocket::Core::ElementDocument* target =
      this->context()->GetDocument("rkt-debug-hook");

    NOM_ASSERT( target != nullptr );
    if( target ) {
      // NOM_DUMP( target->GetSourceURL().CString() );

      Rocket::Core::Element* body_tag =
        target->GetParentNode();

      NOM_ASSERT( body_tag != nullptr );
      if( body_tag ) {

        // Sets width of visual debugger's Element Info window
        Rocket::Core::Element* info =
          body_tag->GetElementById("rkt-debug-info");

        NOM_ASSERT( info != nullptr );
        if( info ) {

          Rocket::Core::Property width(dims.w, Rocket::Core::Property::PX);
          info->SetProperty("min-width", width);
          info->SetProperty("width", width);
        } // end if info

        // Sets height of visual debugger's Element Info window
        Rocket::Core::Element* content =
          body_tag->GetElementById("content");

        NOM_ASSERT( content != nullptr );
        if( content ) {

          // As per Rocket/Debugger/MenuSource.h
          // int menu_height = 32;

          // Maximum height shall be no more than half the size of the context,
          // add menu height
          Rocket::Core::Property max_height(  dims.h,
                                              Rocket::Core::Property::PX);
          content->SetProperty("max-height", max_height);
        } // end if debug_content

      } // end if body_tag
    } // end if target
  } // end if valid context
}
Ejemplo n.º 19
0
	ScriptEventListener( const String &s, int uniqueId, Element *target ) : script( s ),
		loaded( false ), released( false ),  uniqueId( uniqueId ), target( target ) {
		asmodule = UI_Main::Get()->getAS();
		if( target ) {
			target->AddReference();
		}
	}
Ejemplo n.º 20
0
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()));
    }
}
Ejemplo n.º 21
0
// Resolves one of this element's properties.
float ElementStyle::ResolveProperty(const String& name, float base_value)
{
	const Property* property = GetProperty(name);
	if (!property)
	{
		ROCKET_ERROR;
		return 0.0f;
	}

	if (property->unit & Property::RELATIVE_UNIT)
	{
		// The calculated value of the font-size property is inherited, so we need to check if this
		// is an inherited property. If so, then we return our parent's font size instead.
		if (name == FONT_SIZE)
		{
			Rocket::Core::Element* parent = element->GetParentNode();
			if (parent == NULL)
				return 0;

			if (GetLocalProperty(FONT_SIZE) == NULL)
				return parent->ResolveProperty(FONT_SIZE, 0);

			// The base value for font size is always the height of *this* element's parent's font.
			base_value = parent->ResolveProperty(FONT_SIZE, 0);
		}

		if (property->unit & Property::PERCENT)
			return base_value * property->value.Get< float >() * 0.01f;
		else if (property->unit & Property::EM)
		{
			// If an em-relative font size is specified, it is expressed relative to the parent's
			// font height.
			if (name == FONT_SIZE)
				return property->value.Get< float >() * base_value;
			else
				return property->value.Get< float >() * ElementUtilities::GetFontSize(element);
		}
	}

	if (property->unit & Property::NUMBER || property->unit & Property::PX)
	{
		return property->value.Get< float >();
	}

	// We're not a numeric property; return 0.
	return 0.0f;
}
Ejemplo n.º 22
0
// 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();
}
Ejemplo n.º 23
0
UiBase::~UiBase()
{
  if (root)
  {
    std::for_each(listeners.begin(), listeners.end(), [this](const Listener& listener)
    {
      Rocket::Core::Element* elem = root->GetElementById(listener.elem.c_str());
      
      if (elem)
        elem->RemoveEventListener(listener.event.c_str(), &(listener.instance));
    });
    if (!root_outlives_this_object)
    {
      root->Hide();
      root->RemoveReference();
      root = 0;
    }
  }
}
void GuiDemo::initRocket()
{
	GK_ASSERT(m_scene && !m_rkContext);

	gkWindow* window = m_scene->getDisplayWindow();
	// Rocket initialisation.
	m_rkOgreRenderer = new RenderInterfaceOgre3D(window->getWidth(), window->getHeight());
	Rocket::Core::SetRenderInterface(m_rkOgreRenderer);

	m_rkOgreSystem = new SystemInterfaceOgre3D();
	Rocket::Core::SetSystemInterface(m_rkOgreSystem);

	Rocket::Core::Initialise();
	Rocket::Controls::Initialise();


	installRocketFonts();

	m_rkContext = Rocket::Core::CreateContext("main", Rocket::Core::Vector2i(window->getWidth(), window->getHeight()));
	Rocket::Debugger::Initialise(m_rkContext);

	m_rkFileInterface = new FileInterfaceOgre3D();
	Rocket::Core::SetFileInterface(m_rkFileInterface);


	// Load the mouse cursor and release the caller's reference.
	Rocket::Core::ElementDocument* cursor = m_rkContext->LoadMouseCursor(ROCKET_CURSOR_PAGE);
	if (cursor)
		cursor->RemoveReference();

	m_document = m_rkContext->LoadDocument(ROCKET_DEMO_PAGE);
	if (m_document)
	{
		Rocket::Core::Element* button = m_document->GetElementById(DEMO_PAGE_BUTTON_ID);
		if (button)
			button->AddEventListener("click", this);
		m_document->Show();		
	}

	m_rkEventListener  = new RocketEventListener(window, m_rkContext);
	m_rkRenderListener = new RocketRenderListener(window->getRenderWindow(), m_scene->getManager(), m_rkContext);
}
Ejemplo n.º 25
0
  bool RocketUIManager::doCapture(Rocket::Core::Context* ctx)
  {
    Rocket::Core::Element* e = ctx->GetHoverElement();

    if(e && e != ctx->GetRootElement())
    {
      if(e->GetTagName() == "body")
        return false;

      bool isVisible = true;
      while(e && (isVisible = e->IsVisible()))
      {
        e = e->GetParentNode();
      }

      return isVisible;
    }

    return false;
  }
Ejemplo n.º 26
0
void InventoryView::ProcessEvent(Rocket::Core::Event& event)
{
  if (event == "dragdrop")
  {
    Rocket::Core::Element* drag_element   = static_cast<Rocket::Core::Element*>(event.GetParameter< void* >("drag_element", NULL));

    if (drag_element->GetParentNode() != &_element)
      ObjectDropped.Emit(this, drag_element);
  }
  else
  {
    Rocket::Core::Element* currentElement = event.GetCurrentElement();
    InventoryObject*       object         = GetObjectFromId(currentElement->GetId().CString());

    if (event == "dblclick")
      ObjectSelected.Emit(object);
    else if (event == "mouseover")
      ObjectFocused.Emit(object);
  }
}
Ejemplo n.º 27
0
void SaveMenu::saveGameClicked(Rocket::Core::Event& event)
{
   Rocket::Core::Element* target = event.GetTargetElement();

   // Move up the DOM to the datagridrow item holding this element
   while(target->GetParentNode() != nullptr && target->GetTagName() != "datagridrow")
   {
      target = target->GetParentNode();
   }

   if(target != nullptr)
   {
      // If we found a row element, cast it and get its index
      Rocket::Controls::ElementDataGridRow* rowElement = dynamic_cast<Rocket::Controls::ElementDataGridRow*>(target);
      if(rowElement != nullptr)
      {
         int saveGameIndex = rowElement->GetParentRelativeIndex();
         showConfirmDialog(saveGameIndex);
      }
   }
}
Ejemplo n.º 28
0
	void releaseFunctionPtr() {
		if( released ) {
			return;
		}

		released = true;
		funcPtr.release();

		if( target ) {
			target->RemoveReference();
			target = NULL;
		}
	}
Ejemplo n.º 29
0
void Rocket_SetPropertyById( const char *id, const char *property, const char *value )
{
    if ( *id )
    {
        Rocket::Core::ElementDocument *document = menuContext->GetFocusElement()->GetOwnerDocument();

        if ( document )
        {
            Rocket::Core::Element *element = document->GetElementById( id );

            if ( element )
            {
                element->SetProperty( property, value );
            }
        }
    }

    else if ( activeElement )
    {
        activeElement->SetProperty( property, value );
    }
}
Ejemplo n.º 30
0
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 );
            }
        }
    }
}