Jump to content
  • Advertisement
Sign in to follow this  
Nimnaur

Need a help for render a dialog

This topic is 3918 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to make a GUI. And I'm not powerfull on textures. There are images here. The first one is my texture file for controls. And the second one is a screenshot :P Free Image Hosting at www.ImageShack.usFree Image Hosting at www.ImageShack.us Here, there is my code for rendering a dialog. I didn't like that code. I'm not happy with it. [headshake]
HRESULT TARDialog::Render(float ElapsedTime)
{	
	HRESULT hr;

	RECT rc;
	D3DXVECTOR3 vPos;
	D3DXMATRIXA16 mTransform;
	TARTextWriter* writer = &m_pUIManager->m_TextWriter;

	if (!m_Hide)
	{		
		int Width = m_width - 43;
		//Bottom  -O-
		SetRect( &rc, 21, 202, 40, 222 );
		for (int i=0; i<(int)(Width/19)+1; i++)
		{
			vPos = D3DXVECTOR3 ( (float)m_x + (i+1)*19 - 5.0f, (float)m_y + m_height - 20.0f , 0.0f );
			V_RETURN( m_pUIManager->m_pSprite->Draw(m_pUIManager->m_pTexture, &rc, NULL, &vPos, D3DCOLOR_RGBA(255, 255, 255, 255)) );
		}

		int Height = m_height - 20;
		//Left Side
		SetRect( &rc, 0, 181, 4, 200 );
		for (int i=0; i<(int)(Height/19); i++)
		{
			vPos = D3DXVECTOR3 ( (float)m_x + 13.0f, (float)m_y + (i)*19 + 19.0f, 0.0f );
			V_RETURN( m_pUIManager->m_pSprite->Draw(m_pUIManager->m_pTexture, &rc, NULL, &vPos, D3DCOLOR_RGBA(255, 255, 255, 255)) );
		}

		Height = m_height - 20;
		//Left Side
		SetRect( &rc, 57, 181, 61, 200 );
		for (int i=0; i<(int)(Height/19); i++)
		{
			vPos = D3DXVECTOR3 ( (float)m_x + m_width - 15.0f, (float)m_y + (i)*19 + 19.0f, 0.0f );
			V_RETURN( m_pUIManager->m_pSprite->Draw(m_pUIManager->m_pTexture, &rc, NULL, &vPos, D3DCOLOR_RGBA(255, 255, 255, 255)) );
		}

		//Bottom  O--
		SetRect( &rc, 0, 202, 19, 222 );
		vPos = D3DXVECTOR3 ( (float)m_x + 13.0f, (float)m_y + m_height - 20.0f , 0.0f );
		V_RETURN( m_pUIManager->m_pSprite->Draw(m_pUIManager->m_pTexture, &rc, NULL, &vPos, D3DCOLOR_RGBA(255, 255, 255, 255)) );

		//Bottom  --O
		SetRect( &rc, 42, 202, 61, 222 );
		vPos = D3DXVECTOR3 ( (float)m_x + m_width - 30.0f, (float)m_y + m_height - 20.0f , 0.0f );
		V_RETURN( m_pUIManager->m_pSprite->Draw(m_pUIManager->m_pTexture, &rc, NULL, &vPos, D3DCOLOR_RGBA(255, 255, 255, 255)) );

		//Caption  -O-
		SetRect( &rc, 30, 125, 55, 152 );
		vPos = D3DXVECTOR3 ( ((float)m_x + 25.0f) / (((float)m_width-50.0f)/25.0f) , (float)m_y, 0.0f );
		D3DXMatrixScaling( &mTransform, (((float)m_width-50.0f)/25.0f), 1.0f, 1.0f );
		V_RETURN( m_pUIManager->m_pSprite->SetTransform( &mTransform ) );
		V_RETURN( m_pUIManager->m_pSprite->Draw(m_pUIManager->m_pTexture, &rc, NULL, &vPos, D3DCOLOR_RGBA(255, 255, 255, 255)) );
		D3DXMatrixScaling( &mTransform, 1.0f, 1.0f, 1.0f );
		V_RETURN( m_pUIManager->m_pSprite->SetTransform( &mTransform ) );

		//Caption  O--
		SetRect( &rc, 0, 125, 27, 152 );
		vPos = D3DXVECTOR3 ( (float)m_x, (float)m_y, 0.0f );
		V_RETURN( m_pUIManager->m_pSprite->Draw(m_pUIManager->m_pTexture, &rc, NULL, &vPos, D3DCOLOR_RGBA(255, 255, 255, 255)) );

		//Caption  --O
		SetRect( &rc, 57, 125, 84, 152 );
		vPos = D3DXVECTOR3 ( (float)m_x + m_width - 27, (float)m_y, 0.0f );
		V_RETURN( m_pUIManager->m_pSprite->Draw(m_pUIManager->m_pTexture, &rc, NULL, &vPos, D3DCOLOR_RGBA(255, 255, 255, 255)) );


		writer->SetRect( m_x+20, m_y+4, m_x+20 + 100, m_y+4 + 40);
		writer->SetProperties( false, TAR_ALIGN_LEFT, L"", 0);
		writer->SetText( m_Text );
		V_RETURN( writer->DrawText() );
	}

	//Render Controls
	for (int i=0; i<m_Controls.GetSize(); i++)
		V_RETURN( m_Controls.GetAt(i)->Render(ElapsedTime) );

	return S_OK;
}



I know that my code is not good. That's it why I posted that topic. Can you tell me an other way which one is better? Because I am not good at rendering the textures. Thank you!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!