#include <d3d8.h>

#include ".\gsmenu.h"
#include ".\gsgame.h"
#include ".\LD.h"



CGSMenu::CGSMenu()
{

}

CGSMenu::~CGSMenu()
{
}



void CGSMenu::Display( IDirect3DDevice8* pDevice )
{

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

  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.RenderTextureSection2d( 0, 0, theApp.m_TexSec[LD::TEX_TITLE] );


  theApp.PrintNiceCentered( 321, 21, "ADVANCED MITOSIS", 0xff000000 );
  theApp.PrintNiceCentered( 320, 20, "ADVANCED MITOSIS" );

  theApp.PrintNiceCentered( 320, 320, "Ludum Dare #38" );
  theApp.PrintNiceCentered( 320, 350, "Georg \"Endurion\" Rottensteiner" );

  theApp.PrintNiceCentered( 320, 420, "http://www.georg-rottensteiner.de" );

  /*
  theApp.RenderButton( 320 - 5 - 120 - 10 - 120, 380, 120, 40, LD::TEX_GUI_BUTTON_1, LD::TEX_GUI_BUTTON_2, LD::TEX_GUI_BUTTON_3 );
  theApp.PrintNiceCentered( 320 - 5 - 120 - 10 - 120 + 60, 385, "PLAY" );

  theApp.RenderButton( 320 - 5 - 120, 380, 120, 40, LD::TEX_GUI_BUTTON_1, LD::TEX_GUI_BUTTON_2, LD::TEX_GUI_BUTTON_3 );
  theApp.PrintNiceCentered( 320 - 5 - 120 + 60, 385, "INFO" );

  theApp.RenderButton( 320 + 5 + 120 + 10, 380, 120, 40, LD::TEX_GUI_BUTTON_1, LD::TEX_GUI_BUTTON_2, LD::TEX_GUI_BUTTON_3 );*/
  //theApp.PrintNiceCentered( 320 + 5 + 120 + 10 + 60, 385, "QUIT" );

  theApp.Print( 250, 460, "P to Play, Escape to Quit" );
}



void CGSMenu::UpdateFrame( const float fElapsedTime )
{

}



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

}



void CGSMenu::OnChar( int iChar )
{
  if ( iChar == 'p' )
  {
    theApp.NextState( new CGSGame() );
  }
  else if ( iChar == 'i' )
  {
    //theApp.NextState( new CGSInstructions() );
  }
  else if ( iChar == 27 )
  {
    PostMessage( theApp.m_hWnd, WM_CLOSE, 0, 0 );
  }
}



void CGSMenu::OnKeyDown( int iChar )
{

}