CDialogBox::CDialogBox( const CXMLTreeNode& aNode, const Math::Vect2i& screenResolution ) : CGuiElement( aNode, screenResolution ) , m_bDialogClicked(false) , m_ButtonClose( aNode, screenResolution) //, m_ButtonMove( aNode, screenResolution ) , m_pBackGroundTexture(aNode.GetAttribute<CTexture>( "quad" )) , m_BackGroundColor(Math::colWHITE) , m_bStart_to_Move(false) , m_PreviousPosMouse(Math::v2iZERO) , m_fButtonHeight( 0.0f ) , m_fButtonWidth( 0.0f ) { m_ButtonClose.SetParent(this); m_ButtonClose.SetName("buttonClose"); m_ButtonClose.SetLiteral( "" ); m_ButtonClose.SetTextures ( aNode.GetAttribute<CTexture>( "buttonClose_normal" ), aNode.GetAttribute<CTexture>( "buttonClose_over" ), aNode.GetAttribute<CTexture>( "buttonClose_clicked" ), aNode.GetAttribute<CTexture>( "buttonClose_deactivated" ) ); m_ButtonClose.SetPositionPercent(m_PositionPercent + aNode.GetAttribute<Math::Vect2f>("pos_button", Math::Vect2f(0,0))); m_ButtonClose.SetWidthPercent(aNode.GetAttribute<float>("width_button",0.0f)); m_ButtonClose.SetHeightPercent(aNode.GetAttribute<float>("height_button", 0.0f)); for ( int i = 0, count = aNode.GetNumChildren(); i < count; ++i ) { CXMLTreeNode SubTreeNode = aNode( i ); const std::string& TagName = SubTreeNode.GetName(); if( TagName == "Dialog" ) { CStaticText* lTexto1 = new CStaticText(SubTreeNode(0), screenResolution ); CStaticText* lTexto2 = new CStaticText(SubTreeNode(1), screenResolution ); CStaticText* lTexto3 = new CStaticText(SubTreeNode(2), screenResolution ); lTexto1->SetPositionPercent(m_PositionPercent + lTexto1->GetPositionPercent()); lTexto2->SetPositionPercent(m_PositionPercent + lTexto2->GetPositionPercent()); lTexto3->SetPositionPercent(m_PositionPercent + lTexto3->GetPositionPercent()); CDialog* lDialog = new CDialog(lTexto1, lTexto2, lTexto3); m_Dialogo.push_back(lDialog); } } m_CurrentDialog = m_Dialogo.begin(); }
CSetRenderTargetSceneRendererCommand::CSetRenderTargetSceneRendererCommand(CXMLTreeNode &TreeNode) :CStagedTexturedSceneRendererCommand(TreeNode) { setName(TreeNode.GetPszProperty("name")); for (int i = 0; i < TreeNode.GetNumChildren(); i++){ CXMLTreeNode text = TreeNode(i); if (text.GetName()==std::string("dynamic_texture")) { //XML SceneRenderCommands: //<dynamic_texture name="DiffuseMapTexture" texture_width_as_frame_buffer="true" format_type="A8R8G8B8" create_depth_stencil_buffer="false"/> CDynamicTexture * dynText = new CDynamicTexture(text); m_DynamicTextures.push_back(dynText); CEngine::GetSingleton().getTextureManager()->add(dynText->getName(), dynText); } } CreateRenderTargetViewVector(); }
void CGUIWindow::LoadRadioBox(CRadioBox** radioBox_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<RadioBox name="pepito" posx="0" posy="2" height="10" width="10" default_checkButton="bla" visible="true" active="true" texture_back="" // columns="3" rows="3" OnCheckOn="blabla" OnCheckOff="blabla" OnOverButton="blabla" // OnSaveValue="blabl" OnLoadValue="" Literal="blabla" widthOffset="" heightOffset=""/> // <texture name="q3dm1" on="gui_q3dm1_on.jpg" off="gui_q3dm1_off.jpg" deactivated="gui_q3dm1_on.jpg" /> // <texture name="q3dm2" on="gui_q3dm2_on.jpg" off="gui_q3dm2_off.jpg" deactivated="gui_q3dm2_on.jpg" /> // ... //</RadioBox> CRadioBox* radioBox; std::string name = pNewNode.GetPszProperty("name", "defaultGuiElement"); float posx = pNewNode.GetFloatProperty("posx", 0.f); float posy = pNewNode.GetFloatProperty("posy", 0.f); float w = pNewNode.GetFloatProperty("width", 50.f); float h = pNewNode.GetFloatProperty("height", 50.f); bool visible = pNewNode.GetBoolProperty("visible", true); bool activated = pNewNode.GetBoolProperty("active", true); std::string default_checkButton = pNewNode.GetPszProperty("default_checkButton", ""); std::string texture_back = pNewNode.GetPszProperty("texture_back", ""); uint32 columns = pNewNode.GetIntProperty("columns", 0); uint32 rows = pNewNode.GetIntProperty("rows", 0); std::string OnCheckOn = pNewNode.GetPszProperty("OnCheckOn", ""); std::string OnCheckOff = pNewNode.GetPszProperty("OnCheckOff", ""); std::string OnOverButton = pNewNode.GetPszProperty("OnOverButton", ""); std::string OnSaveValue = pNewNode.GetPszProperty("OnSaveValue", ""); std::string OnLoadValue = pNewNode.GetPszProperty("OnLoadValue", ""); std::string l_literal = pNewNode.GetPszProperty("Literal", ""); float widthOffsetPercent = pNewNode.GetFloatProperty("widthOffset", 0.f); float heightOffsetPercent = pNewNode.GetFloatProperty("heightOffset", 0.f); uint32 widthOffset = (uint32) (screenResolution.x * 0.01f * widthOffsetPercent ); uint32 heightOffset = (uint32) (screenResolution.y * 0.01f * heightOffsetPercent ); radioBox = new CRadioBox( screenResolution.y,screenResolution.x,h, w, Vect2f(posx,posy), columns, rows, default_checkButton, l_literal, heightOffset, widthOffset, visible, activated); if (texture_back!="") { CTexture* quad = tm->GetTexture(texture_back); radioBox->SetTextureBack(quad); } radioBox->SetName(name); radioBox->SetOnLoadValueAction(OnLoadValue); radioBox->SetOnSaveValueAction(OnSaveValue); //radioBox->SetCheckButtonActions(OnCheckOn, OnCheckOff, OnOverButton); int count = pNewNode.GetNumChildren(); for (int j = 0; j < count; ++j) { CXMLTreeNode pTexture = pNewNode(j); std::string tagName = pTexture.GetName(); if (tagName.compare("texture")==0) { std::string name = pTexture.GetPszProperty("name"); std::string on = pTexture.GetPszProperty("on"); std::string off = pTexture.GetPszProperty("off"); std::string deactivated = pTexture.GetPszProperty("deactivated"); CTexture* texture_on = tm->GetTexture(on); CTexture* texture_off = tm->GetTexture(off); CTexture* texture_deactivated = tm->GetTexture(deactivated); radioBox->SetCheckButton(name, texture_on, texture_off, texture_deactivated); } } radioBox->SetCheckButtonActions(OnCheckOn, OnCheckOff, OnOverButton); *radioBox_aux = radioBox; }
void CGUIWindow::LoadAnimatedImage(CAnimatedImage** image_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<AnimatedImage name="imageRoomSelected_gameserver2" posx="35" posy="20" height="40" width="30" visible="true" active="true" //default="q3dm1" isAnimated="true", time="0" loop="true" OnSaveValue="blabla" OnLoadValue="blabla" Literal="blabla" //widthOffset="" heightOffset="" flip="" Literal="blabla" widthOffset="" heightOffset=""/> // <texture name="q3dm1" texture="gui_q3dm1_off.jpg"/> // <texture name="q3dm2" texture="gui_q3dm2_off.jpg"/> // ... //</Image> CAnimatedImage* image; std::string name = pNewNode.GetPszProperty("name", "defaultGuiElement"); float posx = pNewNode.GetFloatProperty("posx", 0.f); float posy = pNewNode.GetFloatProperty("posy", 0.f); float w = pNewNode.GetFloatProperty("width", 50.f); float h = pNewNode.GetFloatProperty("height", 50.f); bool visible = pNewNode.GetBoolProperty("visible", true); bool activated = pNewNode.GetBoolProperty("active", true); uint16 initFrame = pNewNode.GetIntProperty("initFrame", true); bool playOnLoad = pNewNode.GetBoolProperty("playOnLoad", true); std::string OnSaveValue = pNewNode.GetPszProperty("OnSaveValue", ""); std::string OnLoadValue = pNewNode.GetPszProperty("OnLoadValue", ""); std::string flip = pNewNode.GetPszProperty("flip", ""); bool backGround = pNewNode.GetBoolProperty("backGround", false); std::string l_literal = pNewNode.GetPszProperty("Literal", ""); float widthOffsetPercent = pNewNode.GetFloatProperty("widthOffset", 0.f); float heightOffsetPercent = pNewNode.GetFloatProperty("heightOffset", 0.f); uint32 widthOffset = (uint32) (screenResolution.x * 0.01f * widthOffsetPercent ); uint32 heightOffset = (uint32) (screenResolution.y * 0.01f * heightOffsetPercent ); image = new CAnimatedImage( screenResolution.y,screenResolution.x, h, w, Vect2f(posx,posy), l_literal, heightOffset, widthOffset, visible, activated); image->SetName(name); image->SetOnLoadValueAction(OnLoadValue); image->SetOnSaveValueAction(OnSaveValue); image->SetBackGround(backGround); if( flip.compare("FLIP_X") == 0) { image->SetFlip(FLIP_X); } else if (flip.compare("FLIP_Y") == 0) { image->SetFlip(FLIP_Y); } else { image->SetFlip(NONE_FLIP); } int count = pNewNode.GetNumChildren(); for (int j = 0; j < count; ++j) { CXMLTreeNode pTexture = pNewNode(j); std::string tagName = pTexture.GetName(); if (tagName.compare("texture")==0) { std::string texture = pNewNode(j).GetPszProperty("name_texture"); CTexture* texture_image = tm->GetTexture(texture); image->AddFrame(texture_image); } } image->GoToFrame(initFrame); if (playOnLoad) { //image->PlayAnimation(); } *image_aux = image; }
bool CGUIWindow::LoadXML( const std::string &xmlGuiFile, const Vect2i& screenResolution) { //Read the xml gui file LOGGER->AddNewLog(ELL_INFORMATION, "CGUIWindow:: Iniciando el parseo del fichero %s", xmlGuiFile.c_str()); bool isOK = false; CXMLTreeNode newFile; if (!newFile.LoadFile(xmlGuiFile.c_str())) { LOGGER->AddNewLog(ELL_ERROR, "CGUIWindow:: No se ha podido leer correctamente el fichero ->%s", xmlGuiFile.c_str()); isOK = false; } else { CTextureManager* textureM = CORE->GetTextureManager(); CXMLTreeNode windows = newFile["Windows"]; m_sLuaCode_OnLoadWindows = windows.GetPszProperty("OnLoadWindows"); m_sLuaCode_OnSaveWindows = windows.GetPszProperty("OnSaveWindows"); m_sLuaCode_OnUpdateWindows = windows.GetPszProperty("OnUpdateWindows"); if (windows.Exists()) { int count = windows.GetNumChildren(); for (int i = 0; i < count; ++i) { CXMLTreeNode pNewNode = windows(i); //Para cada guielement leemos su informacion comun--> std::string name = pNewNode.GetPszProperty("name", "defaultGuiElement"); float posx = pNewNode.GetFloatProperty("posx", 0.f); float posy = pNewNode.GetFloatProperty("posy", 0.f); float w = pNewNode.GetFloatProperty("width", 50.f); float h = pNewNode.GetFloatProperty("height", 50.f); bool visible = pNewNode.GetBoolProperty("visible", true); bool activated = pNewNode.GetBoolProperty("active", true); std::string tagName = pNewNode.GetName(); if (tagName.compare("Button")==0) { CButton* newButton = NULL; LoadButton(&newButton,pNewNode,screenResolution, textureM); AddGuiElement(newButton); } else if (tagName.compare("CheckButton")==0) { CCheckButton* new_checkButton = NULL; LoadCheckButton(&new_checkButton,pNewNode,screenResolution, textureM); AddGuiElement(new_checkButton); } else if (tagName.compare("Slider")==0) { CSlider* new_slider = NULL; LoadSlider(&new_slider,pNewNode,screenResolution, textureM); AddGuiElement(new_slider); } else if (tagName.compare("DialogBox")==0) { CDialogBox* new_dialogBox = NULL; LoadDialogBox(&new_dialogBox,pNewNode,screenResolution, textureM); AddGuiElement(new_dialogBox); } else if (tagName.compare("EditableTextBox")==0) { CEditableTextBox* new_editableTextBox = NULL; LoadEditableTextBox(&new_editableTextBox,pNewNode,screenResolution, textureM); AddGuiElement(new_editableTextBox); } else if (tagName.compare("RadioBox")==0) { CRadioBox* new_radioBox = NULL; LoadRadioBox(&new_radioBox,pNewNode,screenResolution, textureM); AddGuiElement(new_radioBox); } else if (tagName.compare("Image")==0) { CImage* new_image = NULL; _LoadImage(&new_image,pNewNode,screenResolution, textureM); AddGuiElement(new_image); } else if (tagName.compare("AnimatedImage")==0) { CAnimatedImage* new_image = NULL; LoadAnimatedImage(&new_image,pNewNode,screenResolution, textureM); AddGuiElement(new_image); } else if (tagName.compare("ProgressBar")==0) { CProgressBar* new_progressBar = NULL; LoadProgressBar(&new_progressBar,pNewNode,screenResolution, textureM); AddGuiElement(new_progressBar); } else if (tagName.compare("StaticText")==0) { CStaticText* new_staticText = NULL; LoadStaticText(&new_staticText,pNewNode,screenResolution, textureM); AddGuiElement(new_staticText); } else if (tagName.compare("KeyBoard_Back")==0) { //<KeyBoard_Back input="DIK_A" OnKeyDown="blablaLua"/> m_sLuaCode_OnKeyDown = pNewNode.GetPszProperty("OnKeyDown", ""); m_uInputKeyDown = pNewNode.GetIntProperty("input", 0); } else { //Warning LOGGER->AddNewLog(ELL_WARNING, "GUIWindow:: No se reconoce el tag %s del fichero %s", tagName.c_str(), xmlGuiFile.c_str()); } } isOK = true; } else { LOGGER->AddNewLog(ELL_ERROR, "GUIWindow:: No se ha podido leer el tag Windows del fichero ->%s", xmlGuiFile.c_str()); isOK = false; } }//END else de if (!newFile.LoadFile(xmlGuiFile.c_str())) if (!isOK) { LOGGER->AddNewLog(ELL_ERROR, "GUIWindow:: No se ha podido leer correctamente el fichero -->%s", xmlGuiFile.c_str()); isOK = false; } else { LOGGER->AddNewLog(ELL_INFORMATION, "GUIWindow:: Finalizado correctamente el parseo el fichero %s", xmlGuiFile.c_str()); } return isOK; }