Example #1
0
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;
}
Example #2
0
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;
}
Example #3
0
void CStaticMesh::Render(CRenderManager *RM) const
{
	uint16 l_Size = static_cast<uint16>(m_RVs.size());
	for(uint16 i=0; i<l_Size; ++i)
	{
		uint16 l_NumTexs = static_cast<uint16>(m_Textures[i].size());
		for( uint16 j=0; j < l_NumTexs; ++j)
		{
			CORE->GetEffectManager()->SetTextureDim(Vect2f((float)m_Textures[i][j]->GetWidth(), (float)m_Textures[i][j]->GetHeight()));
			m_Textures[i][j]->Activate(j);
		}
		m_RVs[i]->Render( RM, m_RenderableObjectsTechniques[i]->GetEffectTechnique() );
	}
}
Example #4
0
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;
}
Example #5
0
void CStaticMesh::RenderInstance(CRenderManager* RM, LPDIRECT3DVERTEXBUFFER9 instanceBuffer, uint32 count) const
{
	uint16 l_Size = static_cast<uint16>(m_RVs.size());

	for(uint16 i=0; i<l_Size; ++i)
	{
		uint16 l_NumTexs = static_cast<uint16>(m_Textures[i].size());
		for( uint16 j=0; j < l_NumTexs; ++j)
		{
			CORE->GetEffectManager()->SetTextureDim(Vect2f((float)m_Textures[i][j]->GetWidth(), (float)m_Textures[i][j]->GetHeight()));
			m_Textures[i][j]->Activate(j);
		}
		
		m_RVs[i]->RenderInstance(RM, m_RenderableObjectsTechniquesInstance[i]->GetEffectTechnique(), instanceBuffer, count);
	}
}
Example #6
0
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;
}
//---Constructor
CDialogBox::CDialogBox(	uint32 windowsHeight, uint32 windowsWidth, float height_precent, float witdh_percent,
											 const Vect2f position_percent,  float buttonWidthPercent, float buttonHeightPercent,
											 std::string lit, uint32 textHeightOffset, uint32 textWidthOffset, bool isVisible, bool isActive)
: CGuiElement( windowsHeight, windowsWidth, height_precent, witdh_percent, position_percent, DIALOG_BOX, lit, textHeightOffset, textWidthOffset, isVisible, isActive)

, m_bDialogClicked(false)
, m_ButtonClose(windowsHeight, windowsWidth, buttonHeightPercent, buttonWidthPercent,  
								position_percent + Vect2f(witdh_percent-buttonWidthPercent,0.f), "", 0, 0, isVisible, isActive )
, m_ButtonMove(windowsHeight, windowsWidth, buttonHeightPercent, witdh_percent-buttonWidthPercent,  position_percent, "", 0, 0, isVisible, isActive )
, m_pBackGroundTexture(NULL)
, m_BackGroundColor(colWHITE)
, m_bStart_to_Move(false)
, m_PreviousPosMouse(v2iZERO)
, m_fButtonHeight( buttonHeightPercent )
, m_fButtonWidth( buttonWidthPercent )
{
	m_ButtonClose.SetParent(this);
	m_ButtonClose.SetName("buttonClose");
}
Example #8
0
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;
}
Example #9
0
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;
}
Example #10
0
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;
}
Example #11
0
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 CComponentPlayerController::Force()
{
  if(!m_bForceActive)
  {
    return;
  }
  CGameEntity* l_pPlayerEntity = GetEntity();
  CComponentEnergy* l_pEnergy = l_pPlayerEntity->GetComponent<CComponentEnergy>();

  if(m_bGodMode || l_pEnergy->Decrease(ENERGY_FORCE))
  {
    CRenderer *l_pRenderer = CORE->GetRenderer();

    assert(l_pPlayerEntity);

    CComponentObject3D* l_pObject3d = l_pPlayerEntity->GetComponent<CComponentObject3D>();

    assert(l_pObject3d);

    CPostSceneRendererStep* l_pShockWave = l_pRenderer->GetPostSceneRendererStep("shock_wave");

    assert(l_pShockWave);
    
    l_pShockWave->SetCenter(Vect2f(0.3f,0.5f));

    l_pRenderer->ActivateRenderPath("shock_wave");
    m_fForceTime = 0.0f;

    Vect3f l_vPos = l_pObject3d->GetPosition();
    vector<CPhysicUserData*> l_vImpactObjects;
    CPhysicsManager *l_pPM = PHYSICS_MANAGER;

    Mat33f l_mRot;
    l_mRot.SetIdentity();
    l_mRot.RotByAngleY(m_pObject3D->GetYaw());

    Vect3f l_vDir = l_mRot*Vect3f(1.0f,0.0f,0.0f);

    ENTITY_MANAGER->InitLifeOmni(0.2f,CColor(0.0f,0.0f,2.0f, 1.0f),2.0f,10.0f,l_vPos+1.2f*l_vDir);

    l_pPM->OverlapSphereActor(2.0f,l_vPos+3.0f*l_vDir,l_vImpactObjects,l_pPM->GetCollisionMask(ECG_FORCE));

    vector<CPhysicUserData*>::iterator l_itUserData;
    vector<CPhysicUserData*>::iterator l_itUserDataEnd = l_vImpactObjects.end();

    set<CGameEntity*> l_vImpactEntities;

    for(l_itUserData = l_vImpactObjects.begin(); l_itUserData != l_itUserDataEnd; ++l_itUserData)
    {
      CPhysicUserData* l_pUserData = *l_itUserData;
      l_vImpactEntities.insert(l_pUserData->GetEntity());
    }

    set<CGameEntity*>::iterator l_itEntity;
    set<CGameEntity*>::iterator l_itEntityEnd = l_vImpactEntities.end();

    for(l_itEntity = l_vImpactEntities.begin(); l_itEntity != l_itEntityEnd; ++l_itEntity)
    {
      CGameEntity* l_pEntity = *l_itEntity;

      if(l_pPlayerEntity != l_pEntity)
      {
        Vect3f l_v = l_vPos + Vect3f(0.0f,0.25f,0.0f);

        SEvent l_impacte;
        l_impacte.Msg = SEvent::REBRE_FORCE;
        l_impacte.Info[0].Type = SEventInfo::FLOAT;
        l_impacte.Info[0].f    = DAMAGE_FORCE;
        l_impacte.Info[1].Type = SEventInfo::VECTOR;
        l_impacte.Info[1].v.x    = l_v.x;
        l_impacte.Info[1].v.y    = l_v.y;
        l_impacte.Info[1].v.z    = l_v.z;
        l_impacte.Receiver = l_pEntity->GetGUID();
        l_impacte.Sender = l_pPlayerEntity->GetGUID();

        ENTITY_MANAGER->SendEvent(l_impacte);
      }
    }
  }
}
Example #13
0
 Vect2f operator+(Vect2f const & rhs) {
     return Vect2f(x + rhs.x, y + rhs.y);
 }
Example #14
0
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;
}
Example #15
0
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();
}
Example #16
0
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);
}
Example #17
0
CMaterial::CMaterial(CXMLTreeNode &TreeNode)
	: CNamed(TreeNode)
{
	/*m_RenderableObjectTechnique = new CRenderableObjectTechnique(TreeNode.GetPszProperty("effect_technique"),
		CEngine::GetSingletonPtr()->getEffectsManager()->get(TreeNode.GetPszProperty("effect_technique")));*/

	std::string name;
	const char * rot = TreeNode.GetPszProperty("renderable_object_technique", 0, false);
	if (rot)
	{
		name = rot;
	}
	else
	{
		name = TreeNode.GetPszProperty("vertex_type", "", true);
		DEBUG_ASSERT( name != std::string("") );
	}

	m_RenderableObjectTechnique = CEngine::GetSingleton().getRenderableObjectTechniqueManager()->get(name);
	void *nextDir = &CEffectManager::m_MaterialEffectParameters.m_RawData[0];
	int l_NextStage = 0;
	for (int i = 0; i < TreeNode.GetNumChildren(); ++i)
	{
		CXMLTreeNode l_paramMat = TreeNode(i);
		if (l_paramMat.GetName() == std::string("texture"))
		{
			CXMLTreeNode l_Texture = l_paramMat;
			CTexture * Texture = CEngine::GetSingleton().getTextureManager()->GetTexture(l_Texture.GetPszProperty("filename"));
			int stage = GetTextureStage(l_Texture.GetPszProperty("type", "", false));
			if (stage < 0)
			{
				stage = l_paramMat.GetIntProperty("stage", -1, false);
			}
			if (stage < 0)
			{
				stage = l_NextStage;
			}
			m_textures.push_back(std::make_pair(stage,Texture));
			l_NextStage++;
		}
		else if (l_paramMat.GetName() == std::string("parameter"))
		{
			CMaterialParameter::TMaterialType type;
			if (l_paramMat.GetPszProperty("type") == std::string("float"))
			{
				type = CMaterialParameter::TMaterialType::FLOAT;
				CTemplatedMaterialParameter<float> *param = new CTemplatedMaterialParameter<float>(
					l_paramMat,
					nextDir,
					l_paramMat.GetFloatProperty("value"),
					type);
				m_Parameters.push_back(param);
			}
			else if (l_paramMat.GetPszProperty("type") == std::string("Vect2f"))
			{
				type = CMaterialParameter::TMaterialType::VECT2F;
				CTemplatedMaterialParameter<Vect2f> *param = new CTemplatedMaterialParameter<Vect2f>(
					l_paramMat,
					nextDir,
					l_paramMat.GetVect2fProperty("value", Vect2f(0, 0)),
					type);
				m_Parameters.push_back(param);
}
			else if (l_paramMat.GetPszProperty("type") == std::string("Vect3f"))
			{
				type = CMaterialParameter::TMaterialType::VECT3F;
				CTemplatedMaterialParameter<Vect3f> *param = new CTemplatedMaterialParameter<Vect3f>(
					l_paramMat,
					nextDir,
					l_paramMat.GetVect3fProperty("value", Vect3f(0, 0, 0)),
					type);
				m_Parameters.push_back(param);
			}
			else if (l_paramMat.GetPszProperty("type") == std::string("Vect4f"))
			{
				type = CMaterialParameter::TMaterialType::VECT4F;
				CTemplatedMaterialParameter<Vect4f> *param = new CTemplatedMaterialParameter<Vect4f>(
					l_paramMat,
					nextDir,
					l_paramMat.GetVect4fProperty("value", Vect4f(0, 0, 0, 0)),
					type);
				m_Parameters.push_back(param);
			}

			nextDir = reinterpret_cast<unsigned char*>(nextDir)+sizeof(Vect4f);
		}
	}
}