#include <d3d8.h>

#include ".\GSDone.h"
#include ".\GSMenu.h"
#include ".\LD.h"



CGSDone::CGSDone()
{

  m_ButtonReleased = false;

}



CGSDone::~CGSDone()
{
}



void CGSDone::Display( IDirect3DDevice8* pDevice )
{

  theApp.m_Universe.DisplayStars( pDevice, 0 );

  theApp.m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
  theApp.m_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );

  theApp.m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
  theApp.m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
  theApp.m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );

  theApp.m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
  theApp.m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
  theApp.m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );

  theApp.PrintNiceCentered( 320, 40, "WELL DONE!" );

  theApp.PrintNiceCentered( 320, 190, "The first contact is an amazing feat." );
  theApp.PrintNiceCentered( 320, 215, "You manage to make friends. Both species" );
  theApp.PrintNiceCentered( 320, 240, "are apt to a prosperous future." );
  theApp.PrintNiceCentered( 320, 300, "Your name will go down in history..." );

}



void CGSDone::UpdateFrame( const float fElapsedTime )
{

}



void CGSDone::OnChar( int iChar )
{

  if ( ( iChar == 27 )
  ||   ( iChar == ' ' )
  ||   ( iChar == 13 ) )
  {
    theApp.NextState( new CGSMenu() );
  }

}



void CGSDone::OnKeyDown( int iChar )
{

}



void CGSDone::OnMouse( int X, int Y, int Buttons )
{

  if ( Buttons & 1 )
  {
    if ( m_ButtonReleased )
    {
      OnChar( 27 );
    }
  }
  else
  {
    m_ButtonReleased = true;
  }

}