void CGUIWindow::Render (CRenderManager *renderManager, CFontManager* fm) { std::vector<CGuiElement*>::iterator it(m_GuiElementsVector.begin()); std::vector<CGuiElement*>::iterator itEnd(m_GuiElementsVector.end()); while (it != itEnd) { CGuiElement* guiElement = *it; guiElement->Render (renderManager, fm); it++; } }
void CGuiElement::Update (CInputManager* input, float elapsedTime) { if (m_bIsVisible && m_bIsActive) { //Renderizamos todos los hijos que cuelgan de este CGuiElement: std::vector<CGuiElement*>::iterator it = m_Children.begin(); std::vector<CGuiElement*>::iterator itEnd = m_Children.end(); while(it!=itEnd) { CGuiElement* guiElement = *it; guiElement->Update(input, elapsedTime); it++; } } }
void CGuiElement::Update() { if ( IsVisible() && m_bIsActive ) { //Renderizamos todos los hijos que cuelgan de este CGuiElement: std::vector<CGuiElement*>::iterator it = m_Children.begin(); std::vector<CGuiElement*>::iterator itEnd = m_Children.end(); while ( it != itEnd ) { CGuiElement* guiElement = *it; guiElement->Update(); it++; } } }
void CGuiElement::Render() { if ( IsVisible() ) { //Renderizamos todos los hijos que cuelgan de este CGuiElement: std::vector<CGuiElement*>::iterator it = m_Children.begin(); std::vector<CGuiElement*>::iterator itEnd = m_Children.end(); while ( it != itEnd ) { CGuiElement* guiElement = *it; guiElement->Render(); it++; } }//if (m_sLiteral != "") }
void CGUIWindow::SaveWindows( void ) { std::vector<CGuiElement*>::iterator it; std::vector<CGuiElement*>::iterator itEnd(m_GuiElementsVector.end()); for( it = m_GuiElementsVector.begin(); it != itEnd; ++it ) { CGuiElement * guiElement = (*it); guiElement->OnSaveValue(); } if (m_sLuaCode_OnSaveWindows.compare("")) { //Lanzar acción en Lua: CScriptManager* scriptManager = CORE->GetScriptManager(); scriptManager->RunCode(m_sLuaCode_OnSaveWindows); //scriptManager->RunScript(m_sLuaCode_OnSaveWindows); } }
void CGUIWindow::RegisterElements( std::map<std::string,CGuiElement*>& elements ) { std::map<std::string,CGuiElement*>::const_iterator it_aux; std::vector<CGuiElement*>::iterator it(m_GuiElementsVector.begin()); std::vector<CGuiElement*>::iterator itEnd(m_GuiElementsVector.end()); while (it != itEnd) { CGuiElement* element = (*it); //Antes de insertarlo en el mapa debemos comprobar que no este registrado ya un GuiElement con el mismo identificado(mismo string): if (elements.find(element->GetName()) != elements.end()) { LOGGER->AddNewLog(ELL_ERROR, "CGUIWindow:: El GuiElement %s ya se ha registrado en el GuiManager", element->GetName().c_str()); } else { elements.insert(std::pair<std::string,CGuiElement*>(element->GetName(), element)); } it++; } }
void CMyPicture::OnMoveToBack() { //Se selecciona un elemento std::string name_window = CORE->GetGUIManager()->GetCurrentWindow(); CGUIWindow *window = CORE->GetGUIManager()->GetWindow(name_window); CGuiElement *element = NULL; //Mira sobre qué elemento está el mouse uint16 count = window->GetNumElements(); for( uint16 i = count; i > 0; --i) { element = window->GetElementById(i-1); Vect2i mousePosition; CORE->GetInputManager()->GetPosition(IDV_MOUSE, mousePosition); element->CalculatePosMouse(mousePosition); if( element->IsInside() ) { //Está adentro window->MoveElementToBack(element); break; } } }
void CMyPicture::OnLButtonUp(UINT nFlags, CPoint point) { if( m_bIsLMouseDown ) { //Se selecciona un elemento std::string name_window = CORE->GetGUIManager()->GetCurrentWindow(); CGUIWindow *window = CORE->GetGUIManager()->GetWindow(name_window); CGuiElement *element = NULL; //hace reset de todos los controles uint32 count = window->GetNumElements(); for( uint32 i = 0; i < count; ++i) { element = window->GetElementById(i); element->SetIsSelected(false); } bool isElementSelected = false; //Mira sobre qué elemento está el mouse for( uint32 i = count; i > 0; --i) { element = window->GetElementById(i-1); Vect2i mousePosition; CORE->GetInputManager()->GetPosition(IDV_MOUSE, mousePosition); element->CalculatePosMouse(mousePosition); if( element->IsInside() ) { element->SetIsSelected(true); CElementProperties::ElementProperties(element); isElementSelected = true; break; } } //No hay nada seleccionado y ponemos las propiedades de la window if( !isElementSelected ) { CElementProperties::WindowProperties(window); } } else { //Se hace Drag & drop CElementManager *l_pElementManager = CElementManager::GetInstance(); TElement element = l_pElementManager->GetElementToAdd(); std::string window = l_pElementManager->GetWindowToAdd(); if( element != NONE ) { l_pElementManager->SetElementToAdd(NONE); AddElementToActiveWindow(element); } else if( window != "" ) { std::string current_window = CORE->GetGUIManager()->GetCurrentWindow(); current_window = current_window; CGUIWindow *windowcurrent = CORE->GetGUIManager()->GetWindow( current_window ); windowcurrent->ClearSelectElements(); window = window; CORE->GetGUIManager()->ActiveWindows( window ); CORE->GetGUIManager()->GetWindow( window )->ClearSelectElements(); CElementProperties::WindowProperties( CORE->GetGUIManager()->GetWindow( window ) ); } } m_bIsLMouseDown = false; CStatic::OnLButtonUp(nFlags, point); }