CBillboardAnimation::CBillboardAnimation ( CXMLTreeNode &_Node ) : m_fTimePerImage ( 0.f ) , m_fCurrentTime ( 0.f ) , m_uiImage ( 0 ) , m_vColor ( Vect4f(0.f,0.f,0.f,0.f) ) , m_fSize ( 0.f ) , m_uiNumTextures ( 0 ) , m_bLoop ( false ) { m_Name = _Node.GetPszProperty ( "name", "" ); m_vColor = _Node.GetVect4fProperty( "color", Vect4f(0.f,0.f,0.f,0.f) ); m_fSize = _Node.GetFloatProperty("size", 1.f); m_fTimePerImage = _Node.GetFloatProperty("timePerImage", 1.f); m_bLoop = _Node.GetBoolProperty("loop", false); uint16 l_TotalAnimationNodes = _Node.GetNumChildren (); for ( uint16 i = 0; i < l_TotalAnimationNodes; ++i ) { std::string l_Node = _Node(i).GetName(); if ( l_Node == "Texture" ) { std::string l_TextureName = _Node(i).GetPszProperty("file", ""); CTexture *l_Tex = CORE->GetTextureManager()->GetTexture( l_TextureName ); m_vTextures.push_back( l_Tex ); } } m_uiNumTextures = m_vTextures.size(); }
C3DElement::C3DElement(const CXMLTreeNode &XMLTreeNode) { const char *l_Pos=XMLTreeNode.GetPszProperty("pos", "0.0 0.0 0.0"); sscanf_s(l_Pos, "%f %f %f", m_Position[0], m_Position[1], m_Position[2]); m_Yaw=XMLTreeNode.GetFloatProperty("yaw", 0.0f); m_Pitch=XMLTreeNode.GetFloatProperty("pitch", 0.0f); m_Roll=XMLTreeNode.GetFloatProperty("roll", 0.0f); }
CLight::CLight(CXMLTreeNode &TreeNode) : CNamed(TreeNode) { m_Type = GetLightTypeByName(TreeNode.GetPszProperty("type")); m_Position = TreeNode.GetVect3fProperty("pos", Vect3f(0.0f, 0.0f, 0.0f), true); m_Color = CColor(TreeNode.GetVect4fProperty("color", Vect4f(255.0f, 255.0f, 255.0f, 0.0f), true)); m_StartRangeAttenuation = TreeNode.GetFloatProperty("att_start_range"); m_EndRangeAttenuation = TreeNode.GetFloatProperty("att_end_range"); m_Intensity = TreeNode.GetFloatProperty("intensity"); }
void CGUIWindow::LoadCheckButton (CCheckButton** checkButton_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<CheckButton name="debug_thps" posx="0" posy="2" height="10" width="10" visible="true" active="true" isOn="true" // texture_on="blabla" texture_off="bla" texture_deactivated"bla" // OnCheckOn="blabla" OnCheckOff="blabla" OnOverButton="blabla" // OnSaveValue="blabl" OnLoadValue="" Literal="blabla" widthOffset="" heightOffset=""/> CCheckButton* checkButton; 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); bool isOn = pNewNode.GetBoolProperty("isOn", ""); std::string texture_on = pNewNode.GetPszProperty("texture_on", ""); std::string texture_off = pNewNode.GetPszProperty("texture_off", ""); std::string texture_deactivated = pNewNode.GetPszProperty("texture_deactivated", ""); 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); CTexture* on = tm->GetTexture(texture_on); CTexture* off = tm->GetTexture(texture_off); CTexture* deactivated = tm->GetTexture(texture_deactivated); uint32 widthOffset = (uint32) (screenResolution.x * 0.01f * widthOffsetPercent ); uint32 heightOffset = (uint32) (screenResolution.y * 0.01f * heightOffsetPercent ); checkButton = new CCheckButton(screenResolution.y,screenResolution.x, h, w, Vect2f(posx,posy), isOn, l_literal, heightOffset, widthOffset, visible, activated); checkButton->SetName(name); checkButton->SetTextures(on, off, deactivated); checkButton->SetOnCheckOnAction(OnCheckOn); checkButton->SetOnCheckOffAction(OnCheckOff); checkButton->SetOnLoadValueAction(OnLoadValue); checkButton->SetOnSaveValueAction(OnSaveValue); checkButton->SetOnOverAction(OnOverButton); *checkButton_aux = checkButton; }
CBillboardAnimation::CBillboardAnimation(CXMLTreeNode &parser){ SetColor(CColor(parser.GetVect3fProperty("color",Vect3f(1.0f)))); float size=parser.GetFloatProperty("size",2.0f); SetHeight(size); SetWidth(size); m_TimePerImage=parser.GetFloatProperty("time",0.2f); m_Loop=parser.GetBoolProperty("loop",false); CXMLTreeNode l_Node = parser["Textures"]; for(int i=0;i<l_Node.GetNumChildren();i++){ std::string l_TexturePath=l_Node(i).GetPszProperty("tex",""); CTexture *l_Texture = CORE->GetTextureManager()->GetTexture(l_TexturePath); m_Textures.push_back(l_Texture); } m_Index=0; m_fTime=0.0f; SetTexture(m_Textures[m_Index]); SetPos(Vect3f(0.0f,0.0f,0.0f)); }
void CGUIWindow::LoadStaticText(CStaticText** staticText_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<StaticText name="pepito" posx="0" posy="2" literal="blabla" visible="true" active="true"/> CStaticText* staticText; 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 l_literal = pNewNode.GetPszProperty("Literal", ""); staticText = new CStaticText(screenResolution.y, screenResolution.x, h, w, Vect2f(posx,posy), l_literal, visible, activated); staticText->SetName(name); *staticText_aux = staticText; }
void CGUIWindow::LoadButton (CButton** button_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<Button name="play" posx="0" posy="0" height="10" width="10" visible="true" activated="true" // texture_normal="blabla" texture_over="bla" texture_clicked="bla" texture_deactivated="bla" // OnClickedAction="blabla" OnOverAction="blabla" Literal="blabla" widthOffset="" heightOffset=""/> CButton* button; 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 texture_normal = pNewNode.GetPszProperty("texture_normal", ""); std::string texture_over = pNewNode.GetPszProperty("texture_over", ""); std::string texture_clicked = pNewNode.GetPszProperty("texture_clicked", ""); std::string texture_deactivated = pNewNode.GetPszProperty("texture_deactivated", ""); std::string OnClickedAction = pNewNode.GetPszProperty("OnClickedAction", ""); std::string OnOverAction = pNewNode.GetPszProperty("OnOverAction", ""); std::string l_literal = pNewNode.GetPszProperty("Literal", ""); float widthOffsetPercent = pNewNode.GetFloatProperty("widthOffset", 0.f); float heightOffsetPercent = pNewNode.GetFloatProperty("heightOffset", 0.f); CTexture* normal = tm->GetTexture(texture_normal); CTexture* over = tm->GetTexture(texture_over); CTexture* clicked = tm->GetTexture(texture_clicked); CTexture* deactivated = tm->GetTexture(texture_deactivated); uint32 widthOffset = (uint32) (screenResolution.x * 0.01f * widthOffsetPercent ); uint32 heightOffset = (uint32) (screenResolution.y * 0.01f * heightOffsetPercent ); button = new CButton(screenResolution.y,screenResolution.x, h, w, Vect2f(posx,posy), l_literal, heightOffset, widthOffset, visible, activated); button->SetName(name); button->SetTextures(normal,over,clicked,deactivated); button->SetOnClickedAction(OnClickedAction); button->SetOnOverAction(OnOverAction); *button_aux = button; }
void CGUIWindow::LoadSlider (CSlider** slider_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<Slider name="debug_fps" posx="0" posy="2" height="10" width="10" visible="true" active="true" value="0.5" buttonH="10" buttonW="10" // button_normal="blabla" button_over="bla" button_clicked"bla" button_deactivated="bla" quad="bla" // OnOverAction="" OnClickedAction="" OnChangeValue="" OnSaveValue="blabl" OnLoadValue="" Literal="blabla" widthOffset="" heightOffset=""/> CSlider* slider; 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); float value = pNewNode.GetFloatProperty("value", 0.f); float buttonH = pNewNode.GetFloatProperty("buttonH", 10.f); float buttonW = pNewNode.GetFloatProperty("buttonW", 10.f); std::string button_normal = pNewNode.GetPszProperty("button_normal", ""); std::string button_over = pNewNode.GetPszProperty("button_over", ""); std::string button_clicked = pNewNode.GetPszProperty("button_clicked", ""); std::string button_deactivated = pNewNode.GetPszProperty("button_deactivated", ""); std::string quad = pNewNode.GetPszProperty("quad", ""); std::string OnChangeValue = pNewNode.GetPszProperty("OnChangeValue", ""); std::string OnClickedAction = pNewNode.GetPszProperty("OnClickedAction", ""); std::string OnOverAction = pNewNode.GetPszProperty("OnOverAction", ""); 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); CTexture* normal = tm->GetTexture(button_normal); CTexture* over = tm->GetTexture(button_over); CTexture* deac = tm->GetTexture(button_deactivated); CTexture* clicked = tm->GetTexture(button_clicked); CTexture* back = tm->GetTexture(quad); uint32 widthOffset = (uint32) (screenResolution.x * 0.01f * widthOffsetPercent ); uint32 heightOffset = (uint32) (screenResolution.y * 0.01f * heightOffsetPercent ); slider = new CSlider( screenResolution.y, screenResolution.x, h, w, Vect2f(posx,posy), buttonW, buttonH, value, l_literal, heightOffset, widthOffset, visible, activated); slider->SetName(name); slider->SetButtonTextures(normal, over, clicked, deac); slider->SetBackGroundTexture(back); slider->SetOnChangeValueAction(OnChangeValue); slider->SetOnClickedAction(OnClickedAction); slider->SetOnOverAction(OnOverAction); slider->SetOnLoadValueAction(OnLoadValue); slider->SetOnSaveValueAction(OnSaveValue); *slider_aux = slider; }
void CGUIWindow::LoadDialogBox (CDialogBox** dialogBox_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<DialogBox name="debug_fps" posx="0" posy="2" height="10" width="10" visible="true" active="true" buttonH="10" buttonW="10" // buttonClose_normal="blabla" buttonClose_over="bla" buttonClose_clicked"bla" buttonClose_deactivated"bla" buttonMove_normal="blabla" buttonMove_over="bla" // buttonMove_clicked"bla" buttonMove_deactivated"bla" quad="bla" Literal="blabla" widthOffset="" heightOffset=""/> CDialogBox* dialogBox; 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); float buttonH = pNewNode.GetFloatProperty("buttonH", 10.f); float buttonW = pNewNode.GetFloatProperty("buttonW", 10.f); std::string buttonClose_normal = pNewNode.GetPszProperty("buttonClose_normal", ""); std::string buttonClose_over = pNewNode.GetPszProperty("buttonClose_over", ""); std::string buttonClose_clicked = pNewNode.GetPszProperty("buttonClose_clicked", ""); std::string buttonClose_deactivated = pNewNode.GetPszProperty("buttonClose_deactivated", ""); std::string buttonMove_normal = pNewNode.GetPszProperty("buttonMove_normal", ""); std::string buttonMove_over = pNewNode.GetPszProperty("buttonMove_over", ""); std::string buttonMove_clicked = pNewNode.GetPszProperty("buttonMove_clicked", ""); std::string buttonMove_deactivated = pNewNode.GetPszProperty("buttonMove_deactivated", ""); std::string quad = pNewNode.GetPszProperty("quad"); std::string l_literal = pNewNode.GetPszProperty("Literal", ""); float widthOffsetPercent = pNewNode.GetFloatProperty("widthOffset", 0.f); float heightOffsetPercent = pNewNode.GetFloatProperty("heightOffset", 0.f); CTexture* Close_normal = tm->GetTexture(buttonClose_normal); CTexture* Close_over = tm->GetTexture(buttonClose_over); CTexture* Close_clicked = tm->GetTexture(buttonClose_clicked); CTexture* Close_deactivated = tm->GetTexture(buttonClose_deactivated); CTexture* Move_normal = tm->GetTexture(buttonMove_normal); CTexture* Move_over = tm->GetTexture(buttonMove_over); CTexture* Move_clicked = tm->GetTexture(buttonMove_clicked); CTexture* Move_deactivated = tm->GetTexture(buttonMove_deactivated); CTexture* back = tm->GetTexture(quad); uint32 widthOffset = (uint32) (screenResolution.x * 0.01f * widthOffsetPercent ); uint32 heightOffset = (uint32) (screenResolution.y * 0.01f * heightOffsetPercent ); dialogBox = new CDialogBox( screenResolution.y,screenResolution.x, h, w, Vect2f(posx,posy), buttonW, buttonH, l_literal, heightOffset, widthOffset, visible, activated); dialogBox->SetName(name); dialogBox->SetCloseButtonTextures(Close_normal, Close_over, Close_clicked, Close_deactivated); dialogBox->SetMoveButtonTextures(Move_normal, Move_over, Move_clicked, Move_deactivated); dialogBox->SetDialogTexture(back); *dialogBox_aux = dialogBox; }
CFreeCameraComponent::CFreeCameraComponent(CXMLTreeNode& node, CElement* Owner) : CComponent(node, Owner) { SetNameFromParentName( Owner->getName() ); m_camController = new CFreeCameraController(); Vect3f fwd = node.GetVect3fProperty("forward", Vect3f( 1, 0, 0), false); Vect3f off = node.GetVect3fProperty( "offset", Vect3f( 0, 0, 0 ), false ); float fov = node.GetFloatProperty( "fov", -1, false ); m_camController->SetForward( fwd ); m_camController->SetOffset( off ); if ( fov > 0 ) { m_camController->SetFOV( mathUtils::Deg2Rad(fov)/2 ); } }
void CGUIWindow::LoadEditableTextBox (CEditableTextBox** editableTextBox_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<EditableTextBox name="debug_fps" posx="0" posy="2" height="10" width="10" visible="true" active="true" // texture_quad="blabla" id_font="0" color_font_r="0" color_font_g="0" color_font_b="0" // buffer="" OnSaveValue="blabla" OnLoadValue="blabla" Literal="blabla" widthOffset="" heightOffset="" // Literal="blabla" widthOffset="" heightOffset=""/> CEditableTextBox* editableTextBox; 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 quad = pNewNode.GetPszProperty("texture_quad", ""); std::string OnSaveValue = pNewNode.GetPszProperty("OnSaveValue", ""); std::string OnLoadValue = pNewNode.GetPszProperty("OnLoadValue", ""); uint32 idFont = pNewNode.GetIntProperty("id_font", 0); float color_font_r = pNewNode.GetFloatProperty("color_font_r", 0.f); float color_font_g = pNewNode.GetFloatProperty("color_font_g", 0.f); float color_font_b = pNewNode.GetFloatProperty("color_font_b", 0.f); std::string buffer = pNewNode.GetPszProperty("buffer", ""); 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 ); CTexture* quad_texture = tm->GetTexture(quad); editableTextBox = new CEditableTextBox( screenResolution.y,screenResolution.x,h, w, Vect2f(posx,posy), CColor(color_font_r,color_font_g,color_font_b),idFont, l_literal, heightOffset, widthOffset, visible, activated); editableTextBox->SetName(name); editableTextBox->SetBackGroundTexture(quad_texture); editableTextBox->SetBuffer(buffer); editableTextBox->SetOnLoadValueAction(OnSaveValue); editableTextBox->SetOnSaveValueAction(OnLoadValue); *editableTextBox_aux = editableTextBox; }
void CGUIWindow::LoadProgressBar(CProgressBar** progressBar_aux, CXMLTreeNode& pNewNode, const Vect2i& screenResolution, CTextureManager* tm) { //<ProgressBar name="progressBar1" posx="200" posy="600" height="10" width="100" visible="true" active="true" // texture_back="hola" texture_bar="hola2" id_font="0" color_font_r="0" color_font_g="0" color_font_b="0" // Literal="blabla" widthOffset="" heightOffset="" OnComplete="blabla"/> CProgressBar* progressBar; 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 texture_bar = pNewNode.GetPszProperty("texture_bar", ""); std::string texture_back = pNewNode.GetPszProperty("texture_back", ""); std::string OnComplete = pNewNode.GetPszProperty("OnComplete", ""); uint32 idFont = pNewNode.GetIntProperty("id_font", 0); float color_font_r = pNewNode.GetFloatProperty("color_font_r", 0.f); float color_font_g = pNewNode.GetFloatProperty("color_font_g", 0.f); float color_font_b = pNewNode.GetFloatProperty("color_font_b", 0.f); std::string l_literal = pNewNode.GetPszProperty("Literal", ""); float widthOffsetPercent = pNewNode.GetFloatProperty("widthOffset", 0.f); float heightOffsetPercent = pNewNode.GetFloatProperty("heightOffset", 0.f); CTexture* bar = tm->GetTexture(texture_bar); CTexture* back = tm->GetTexture(texture_back); uint32 widthOffset = (uint32) (screenResolution.x * 0.01f * widthOffsetPercent ); uint32 heightOffset = (uint32) (screenResolution.y * 0.01f * heightOffsetPercent ); progressBar = new CProgressBar( screenResolution.y,screenResolution.x, h, w, Vect2f(posx, posy), l_literal, heightOffset, widthOffset, visible, activated); progressBar->SetName(name); progressBar->SetTextures(back, bar); progressBar->SetFont(idFont, CColor(color_font_r,color_font_g,color_font_b)); progressBar->SetOnComplete(OnComplete); *progressBar_aux = progressBar; }
//---------------------------------------------- void CBoxTrigger::ReadData( CXMLTreeNode &_Node ) { m_bIsActive = _Node.GetBoolProperty("active", false); m_Name = _Node.GetPszProperty("name", ""); m_Position = _Node.GetVect3fProperty("position", v3fZERO); m_Size = _Node.GetVect3fProperty("size", v3fZERO); m_fYaw = _Node.GetFloatProperty("yaw", 0.f); m_RenderColor = CColor( _Node.GetVect4fProperty("color", Vect4f(1.f, 1.f, 1.f, 1.f)) ); std::string l_ROName = _Node.GetPszProperty("renderable_object", "", false); std::string l_Layer = _Node.GetPszProperty("layer", "", false); CRenderableObjectsManager *l_pROM = CORE->GetRenderableObjectsLayersManager()->GetRenderableObjectManager(l_Layer); if( l_pROM != NULL ) { m_pTriggerObject = l_pROM->GetInstance(l_ROName); if( m_pTriggerObject == NULL ) { LOGGER->AddNewLog(ELL_WARNING, "CBoxTrigger::ReadData->No se ha podido obtener el objeto: %s de la capa Solid.", l_ROName.c_str()); } } m_fYaw = mathUtils::Deg2Rad(m_fYaw); }
void CParticleEmitter::Load(CXMLTreeNode &parser) { m_vColors.clear(); m_vDirections.clear(); m_vAcelerations.clear(); m_vSizes.clear(); //m_Type = parser.GetPszProperty("type", "point"); m_bGravity = parser.GetBoolProperty("gravity"); m_fMinTimeLife = parser.GetFloatProperty("life_time_min", 0.0f); m_fMaxTimeLife = parser.GetFloatProperty("life_time_max", 0.0f); m_fMinEmitRate = parser.GetFloatProperty("emit_rate_min", 1.0f); m_fMaxEmitRate = parser.GetFloatProperty("emit_rate_max", 1.0f); std::string l_texturePath = parser.GetPszProperty("tex", ""); m_fAngle = parser.GetFloatProperty("angle", 0.0f); m_sTexture = CORE->GetTextureManager()->GetTexture(l_texturePath); //Variación de los colores CXMLTreeNode l_Node = parser["color"]; m_vColors.push_back(SColor()); //SColor l_color = new SColor(); m_vColors[m_vColors.size()-1].time = l_Node.GetFloatProperty("time", 0.0f); m_vColors[m_vColors.size()-1].col1.SetArgb(l_Node.GetVect4fProperty("color1",Vect4f(1.0f,1.0f,1.0f,1.0f))); m_vColors[m_vColors.size()-1].col2.SetArgb(l_Node.GetVect4fProperty("color2",Vect4f(1.0f,1.0f,1.0f,1.0f))); //m_vColors.push_back(l_color); for(int i=0;i<l_Node.GetNumChildren();i++){ m_vColors.push_back(SColor()); m_vColors[m_vColors.size()-1].time = l_Node(i).GetFloatProperty("time", 0.0f); m_vColors[m_vColors.size()-1].col1.SetArgb(l_Node(i).GetVect4fProperty("color1",Vect4f(1.0f,1.0f,1.0f,1.0f))); m_vColors[m_vColors.size()-1].col2.SetArgb(l_Node(i).GetVect4fProperty("color2",Vect4f(1.0f,1.0f,1.0f,1.0f))); } //Variación de los vectores directores l_Node = parser["direction"]; m_vDirections.push_back(SDirection()); //SDirection* l_direction = new SDirection(); m_vDirections[m_vDirections.size()-1].time = l_Node.GetFloatProperty("time", 0.0f); m_vDirections[m_vDirections.size()-1].dir1 = l_Node.GetVect3fProperty("dir1", Vect3f(0.0f,0.0f,0.0f)); m_vDirections[m_vDirections.size()-1].dir2 = l_Node.GetVect3fProperty("dir2", Vect3f(0.0f,0.0f,0.0f)); //m_vDirections.push_back(l_direction); for(int i=0;i<l_Node.GetNumChildren();i++){ m_vDirections.push_back(SDirection()); m_vDirections[m_vDirections.size()-1].time = l_Node(i).GetFloatProperty("time", 0.0f); m_vDirections[m_vDirections.size()-1].dir1 = l_Node(i).GetVect3fProperty("dir1",Vect3f(0.0f,0.0f,0.0f)); m_vDirections[m_vDirections.size()-1].dir2 = l_Node(i).GetVect3fProperty("dir2",Vect3f(0.0f,0.0f,0.0f)); } //Variación de los tamaños l_Node = parser["size"]; m_vSizes.push_back(SSize()); //SSize* l_size = new SSize(); m_vSizes[m_vSizes.size()-1].time = l_Node.GetFloatProperty("time", 0.0f); m_vSizes[m_vSizes.size()-1].size1 = l_Node.GetFloatProperty("mins", 1.0f); m_vSizes[m_vSizes.size()-1].size2 = l_Node.GetFloatProperty("maxs", 1.0f); //m_vSizes.push_back(l_size); for(int i=0;i<l_Node.GetNumChildren();i++){ m_vSizes.push_back(SSize()); m_vSizes[m_vSizes.size()-1].time = l_Node(i).GetFloatProperty("time", 0.0f); m_vSizes[m_vSizes.size()-1].size1 = l_Node(i).GetFloatProperty("mins",1.0f); m_vSizes[m_vSizes.size()-1].size2 = l_Node(i).GetFloatProperty("maxs",1.0f); } //Variación de las aceleraciones l_Node = parser["aceleration"]; m_vAcelerations.push_back(SAceleration()); //SAceleration* l_aceleration = new SAceleration(); m_vAcelerations[m_vAcelerations.size()-1].time = l_Node.GetFloatProperty("time", 0.0f); m_vAcelerations[m_vAcelerations.size()-1].acel1 = l_Node.GetVect3fProperty("acel1", Vect3f(0.0f,0.0f,0.0f)); m_vAcelerations[m_vAcelerations.size()-1].acel2 = l_Node.GetVect3fProperty("acel2", Vect3f(0.0f,0.0f,0.0f)); //m_vAcelerations.push_back(l_aceleration); for(int i=0;i<l_Node.GetNumChildren();i++){ m_vAcelerations.push_back(SAceleration()); m_vAcelerations[m_vAcelerations.size()-1].time = l_Node(i).GetFloatProperty("time", 0.0f); m_vAcelerations[m_vAcelerations.size()-1].acel1 = l_Node(i).GetVect3fProperty("acel1", Vect3f(0.0f,0.0f,0.0f)); m_vAcelerations[m_vAcelerations.size()-1].acel1 = l_Node(i).GetVect3fProperty("acel2", Vect3f(0.0f,0.0f,0.0f)); } }
CCameraKey::CCameraKey( CXMLTreeNode &treeNode ) : m_CameraInfo(treeNode) { m_Time = treeNode.GetFloatProperty( "time" ); }
bool CEnemyManager::Init(const char* _pcFile) { CXMLTreeNode FileXML; FileXML.LoadFile(_pcFile); //CXMLTreeNode Enemies = fileXML(0); { CXMLTreeNode Templates = FileXML["templates"]; int iNumChildren = Templates.GetNumChildren(); for(int i = 0; i < iNumChildren; i++) { CXMLTreeNode EnemyTemplate = Templates(i); const char* pcId = EnemyTemplate.GetPszProperty("id"); const char* pcMesh = EnemyTemplate.GetPszProperty("mesh"); CEnemyResource* pResource = new CEnemyResource(); std::string szId = pcId; //TODO comprovar errors pResource->Init(pcId,pcMesh); m_Resources[szId] = pResource; } } { Vect3f Default(0,0,0); CXMLTreeNode Instances = FileXML["instances"]; int iNumChildren = Instances.GetNumChildren(); for(int i = 0; i < iNumChildren; i++) { CXMLTreeNode EnemyInstance = Instances(i); const char* pcType = EnemyInstance.GetPszProperty("type"); const Vect3f vPos = EnemyInstance.GetVect3fProperty("pos",Default); const Vect3f vRot = EnemyInstance.GetVect3fProperty("rot",Default); const float fMoveSpeed = EnemyInstance.GetFloatProperty("move_speed"); const float fRotateSpeed = EnemyInstance.GetFloatProperty("rotate_speed"); const float fHealth = EnemyInstance.GetFloatProperty("health"); if(strcmp(pcType,"PATROLLER") == 0) { const char* pcPaths = EnemyInstance.GetPszProperty("paths"); CPatroller* pPatroller = new CPatroller(); pPatroller->Init(vPos,vRot,fMoveSpeed,fRotateSpeed,fHealth,pcPaths); m_Instances.push_back(pPatroller); } else if(strcmp(pcType,"SNIPER") == 0) { float fAimDistance = EnemyInstance.GetFloatProperty("aim_distance"); CSniper* pSniper = new CSniper(); pSniper->Init(vPos,vRot,fMoveSpeed,fRotateSpeed,fHealth,fAimDistance); m_Instances.push_back(pSniper); } else if(strcmp(pcType,"TURRET") == 0) { Vect3f vMaxAngle = EnemyInstance.GetVect3fProperty("max_angle",Default); Vect3f vMinAngle = EnemyInstance.GetVect3fProperty("min_angle",Default); CTurret* pTurret = new CTurret(); pTurret->Init(vPos,vRot,fMoveSpeed,fRotateSpeed,fHealth,vMaxAngle,vMinAngle); m_Instances.push_back(pTurret); } else if(strcmp(pcType,"CAMERA") == 0) { Vect3f vMaxAngle = EnemyInstance.GetVect3fProperty("max_angle",Default); Vect3f vMinAngle = EnemyInstance.GetVect3fProperty("min_angle",Default); CCamera* pCamera = new CCamera(); pCamera->Init(vPos,vRot,fMoveSpeed,fRotateSpeed,fHealth,vMaxAngle,vMinAngle); m_Instances.push_back(pCamera); } else { //TODO errors } } } return true; }
bool CTextureRenderTarget::Init(CXMLTreeNode& _treeRenderTarget) { string l_szName = _treeRenderTarget.GetPszISOProperty("name","",false); string l_szTextureName = _treeRenderTarget.GetPszISOProperty("texture","",false); string l_szFormat = _treeRenderTarget.GetPszISOProperty("format","A8R8G8B8"); int l_iWidth = (int)CORE->GetRenderManager()->GetScreenWidth(); float l_fSize = _treeRenderTarget.GetFloatProperty("size",1.f,false); m_iWidth = _treeRenderTarget.GetIntProperty("width" ,(int)(RENDER_MANAGER->GetScreenWidth() * l_fSize),false); m_iHeight = _treeRenderTarget.GetIntProperty("height",(int)(RENDER_MANAGER->GetScreenHeight() * l_fSize),false); CRenderTarget::Init(m_iWidth, m_iHeight); SetOk(true); if(l_szName != "") { SetName(l_szName); if(l_szTextureName != "") { m_szTextureName = l_szTextureName; CTexture* l_pTexture = new CTexture(); if(l_pTexture->Create(l_szTextureName, m_iWidth, m_iHeight, 1, CTexture::RENDERTARGET, CTexture::DEFAULT, CTexture::GetFormatTypeFromString(l_szFormat))) { m_pSurface = l_pTexture->GetSurface(); m_pSurface->AddRef(); } else { m_pSurface = 0; } if(l_pTexture->IsOk() && m_pSurface) { SetOk(true); CORE->GetTextureManager()->AddResource(l_szTextureName, l_pTexture); } else { if(!l_pTexture->IsOk()) LOGGER->AddNewLog(ELL_ERROR, "CTextureRenderTarget::Init Texture is not Ok."); if(!m_pSurface) LOGGER->AddNewLog(ELL_ERROR, "CTextureRenderTarget::Init Surface is not Ok."); SetOk(false); CHECKED_DELETE(l_pTexture); } }else{ LOGGER->AddNewLog(ELL_WARNING,"CTextureRenderTarget::Init render_target sense textura"); SetOk(false); } }else{ LOGGER->AddNewLog(ELL_WARNING,"CTextureRenderTarget::Init render_target sense nom"); SetOk(false); } return IsOk(); }
bool CSpirit::LoadXML(std::string fileName) { m_pFileName = fileName; CXMLTreeNode header; if(!header.LoadFile(fileName.c_str())) { //Guardar el mensaje de error en el LOGGER std::string msg_error = " CSpirit::Load->Error al intentar abrir el archivo: "; msg_error.append(fileName.c_str()); LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str()); //throw CException(__FILE__, __LINE__, msg_error); return false; } else { //<spirit> //<parameters posini="3 2 -3" apertura="0.2" speedup="3.3" speeddown="0.5" heightflymax="3.0" heightflymin="1.9" //speedslow="1.0" speedfast="1.5" distnear="4.0" distfar="6.0" //timeidle="5.0" timechase="5.0" //numlaps="2" speedcontento="4.0" ///> //</spirit> //solo un spirit**** CXMLTreeNode tag = header["spirit"]; if(tag.Exists()) { if (!tag.IsComment()) { CXMLTreeNode params = tag(0)["parameters"]; if (params.Exists()) { m_V3PosIni = params.GetVect3fProperty("posini", Vect3f(3.0f, 1.5f, -3.8f)); // m_V3Pos = params.GetVect3fProperty("posini", Vect3f(3.0f, 1.5f, -3.8f)); //quitado para dejar estatico el espiritu m_fSpeed_YUp = params.GetFloatProperty("speedup",3.3f); m_fSpeed_YDown = params.GetFloatProperty("speeddown",0.5f); m_fPosYMax = params.GetFloatProperty("heightflymax",3.f); m_fPosYMin = params.GetFloatProperty("heightflymin",1.9f); m_fAperturaEmisor = params.GetFloatProperty("apertura",0.2f); m_fSpeedMax = params.GetFloatProperty("speedfast",1.5f); m_fSpeedMin = params.GetFloatProperty("speedslow",1.f); m_fDistFar = params.GetFloatProperty("distfar",6.f); m_fDistNear = params.GetFloatProperty("distnear",10.f); m_fDelayTimeIdle = params.GetFloatProperty("timeidle",5.f); m_fDelayTimeChase = params.GetFloatProperty("timechase",5.f); m_uiNumeroVueltasContento = params.GetIntProperty("numlaps",1); m_fSpeedRotationContento = params.GetFloatProperty("speedcontento",3.f); m_pLight = CORE->GetLigthManager()->GetResource(params.GetPszProperty("light", "")); } } } else { //Guardar el mensaje de error en el LOGGER std::string msg_error = " CSpirit::Load->Parametros mal configurados "; msg_error.append(fileName.c_str()); LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str()); //throw CException(__FILE__, __LINE__, msg_error); return false; } } return true; }
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; }
bool CPostSceneRendererStep::Init(CXMLTreeNode& _treePostSceneRenderer, const string& _szDefaultRenderTarget, bool _bNeedsEffect) { string l_szEffect = _treePostSceneRenderer.GetPszISOProperty("effect","",!_bNeedsEffect); if(!CRendererStep::Init(_treePostSceneRenderer, _szDefaultRenderTarget)) { LOGGER->AddNewLog(ELL_ERROR,"CPostSceneRendererStep::Init PostSceneRenderer sense nom"); SetOk(false); } else if(l_szEffect == "" && _bNeedsEffect) { LOGGER->AddNewLog(ELL_ERROR,"CPostSceneRendererStep::Init PostSceneRenderer sense effect"); SetOk(false); } else { LOGGER->AddNewLog(ELL_INFORMATION,"CPostSceneRendererStep::Init iniciant %s",GetName().c_str()); CRendererStep::Init(_treePostSceneRenderer, _szDefaultRenderTarget); CXMLTreeNode l_treeSamplers = _treePostSceneRenderer.GetChild("input_samplers"); CXMLTreeNode l_treeRenderTargets = _treePostSceneRenderer.GetChild("render_targets"); if(!InitInputSamplers(l_treeSamplers)) { LOGGER->AddNewLog(ELL_ERROR,"CPostSceneRendererStep::Init error inicialitzant input_samplers"); SetOk(false); } else { m_szEffect = l_szEffect; m_bUseTime = _treePostSceneRenderer.GetBoolProperty("use_time",false,false); if(m_bUseTime) { m_bUseDeltaTime = _treePostSceneRenderer.GetBoolProperty("use_delta_time",false,false); } else { m_bUseDeltaTime = false; } m_bUseCenter = _treePostSceneRenderer.GetBoolProperty("use_center",false,false); string l_szAlignment = _treePostSceneRenderer.GetPszISOProperty("alignment","",false); if(l_szAlignment == "center") { m_Alignment = CENTER; } Vect2f l_fPos = _treePostSceneRenderer.GetVect2fProperty("position",Vect2f(0),false); m_iPos.x = (int) (l_fPos.x * RENDER_MANAGER->GetScreenWidth()); m_iPos.y = (int) (l_fPos.y * RENDER_MANAGER->GetScreenHeight()); if(_treePostSceneRenderer.ExistsProperty("size")) { float l_fSizeX = _treePostSceneRenderer.GetFloatProperty("size",1.0,false); if(_treePostSceneRenderer.GetBoolProperty("absolute_size",false,false)) { m_iSize.x = (int) l_fSizeX; m_iSize.y = m_iSize.x; } else { m_iSize.x = (int) (l_fSizeX * RENDER_MANAGER->GetScreenWidth()); m_iSize.y = m_iSize.x; } if(_treePostSceneRenderer.ExistsProperty("aspect_ratio")) { bool l_bAspectRatio = _treePostSceneRenderer.GetBoolProperty("aspect_ratio",true,false); if(l_bAspectRatio) { m_iSize.y = (int)(m_iSize.x * RENDER_MANAGER->GetScreenHeight()/(float)RENDER_MANAGER->GetScreenWidth()); } } } else if(_treePostSceneRenderer.ExistsProperty("size_x")) { float l_fSizeX = _treePostSceneRenderer.GetFloatProperty("size_x",1.0,false); float l_fSizeY = _treePostSceneRenderer.GetFloatProperty("size_y",1.0,false); if(_treePostSceneRenderer.GetBoolProperty("absolute_size",false,false)) { m_iSize.x = (int) l_fSizeX; m_iSize.y = (int) l_fSizeY; } else { m_iSize.x = (int) (l_fSizeX * RENDER_MANAGER->GetScreenWidth()); m_iSize.y = (int) (l_fSizeY * RENDER_MANAGER->GetScreenHeight()); } } else { m_iSize.x = RENDER_MANAGER->GetScreenWidth(); m_iSize.y = RENDER_MANAGER->GetScreenHeight(); } SetOk(true); } } return IsOk(); }
CFont::CFont(CXMLTreeNode& fontNode, CGUI* gui) : CNamed(fontNode) , m_glyphs( MAX_GLYPHS_BATCH ) , m_gui(gui) , m_textAlign(Rectf::Alignment::TOP_LEFT) { auto mm = CEngine::GetSingleton().getMaterialManager(); auto tm = CEngine::GetSingleton().getTextureManager(); std::string fontFile = fontNode.GetPszProperty("path", "", false); std::string fontName = fontNode.GetPszProperty("name", "", false); DEBUG_ASSERT(fontFile.size() != 0 && fontName.size() != 0); if (fontFile.size() == 0 || fontName.size() == 0) { return; } for (int i = 0; i < fontNode.GetNumChildren(); ++i) { auto matNode = fontNode(i); if (matNode.GetName() == std::string("material")) { std::string matName = "font-material-" + fontName; CMaterial *mat = new CMaterial(matNode); mat->setName(matName); mm->add(matName, mat); m_material = mat; break; } } std::string fontPath; size_t pathEnd = fontFile.find_last_of('\\'); if (pathEnd == fontFile.npos) { pathEnd = fontFile.find_last_of('/'); } if (pathEnd != fontFile.npos) { fontPath = fontFile.substr(0, pathEnd+1); } CXMLTreeNode ff; if (!ff.LoadFile(fontFile.c_str())) { DEBUG_ASSERT(false); return; } CXMLTreeNode font = ff["font"]; CXMLTreeNode common = font["common"]; CXMLTreeNode info = font["info"]; Vect2f pageSize(common.GetFloatProperty("scaleW", 0, false), common.GetFloatProperty("scaleH", 0, false)); m_fontSize = info.GetFloatProperty( "size", 0, false ); DEBUG_ASSERT( m_fontSize != 0); m_lineHeight = common.GetFloatProperty( "lineHeight", m_fontSize, false ); m_base = common.GetFloatProperty( "base", m_fontSize, false ); CXMLTreeNode pages = font["pages"]; for (int i = 0; i < pages.GetNumChildren(); ++i) { auto page = pages(i); if (page.GetName() == std::string("page")) { std::string texFile = page.GetPszProperty("file", "", false); DEBUG_ASSERT(texFile.size() > 0); texFile = fontPath + texFile; CTexture *tex = new CTexture(); tex->load(texFile, false); tm->add(tex->getName(), tex); m_pages.push_back(tex); } } auto chars = font["chars"]; for (int i = 0; i < chars.GetNumChildren(); ++i) { auto ch = chars(i); if (ch.GetName() != std::string("char")) { continue; } uchar chId = ch.GetIntProperty("id"); CharDesc_t cdesc; cdesc.offset = Vect2f(ch.GetFloatProperty("xoffset", 0, false), ch.GetFloatProperty("yoffset", 0, false)); cdesc.page = ch.GetIntProperty("page"); cdesc.size = Vect2f(ch.GetFloatProperty("width", 0, false), ch.GetFloatProperty("height", 0, false)); cdesc.xAdvance = ch.GetFloatProperty("xadvance", 0, false); cdesc.uvRect.position = Vect2f(ch.GetFloatProperty("x", 0, false), ch.GetFloatProperty("y", 0, false)); cdesc.uvRect.position = Vect2f(cdesc.uvRect.position.x / pageSize.x, cdesc.uvRect.position.y / pageSize.y); cdesc.uvRect.size = Vect2f(cdesc.size.x / pageSize.x, cdesc.size.y / pageSize.y); m_chars[chId] = cdesc; } auto kerns = font["kernings"]; if (kerns.Exists()) { for (int i = 0; i < kerns.GetNumChildren(); ++i) { auto k = kerns(i); uchar f = k.GetIntProperty("first", 0, false); uchar s = k.GetIntProperty("second", 0, false); uchar a = k.GetIntProperty("amount", 0, false); m_kernings[std::make_pair(f, s)] = a; } } m_glyphsVtxs = new CPointsListRenderableVertexs<GUI_TEXT_VERTEX>(m_glyphs.data(), MAX_GLYPHS_BATCH, MAX_GLYPHS_BATCH, true); }
CDirectionalLight::CDirectionalLight(CXMLTreeNode &TreeNode) : CLight(TreeNode) { m_Direction = TreeNode.GetFloatProperty("dir"); }
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; }