/** 
 * \file Movie.h
 * \brief Contains CMovie class for playing scripted animations.
 *
 * Movies will be played in 'engine' of the game. They will be scripted in txt files.
 * This module would read given movie script from the file and play it.
 * Game movies can be played between levels to explain/amuse/relax/and mostly explain whats happening.
 * \author Petar Bajic, MPE (C) All Rights Reserved, Homepage: www.mystic-peanut.com
 * \date January, 16 2007.
 */

#include "d3dx9.h"
#include <dmusici.h>
#include "MyDrawSprite.h"
#include "Turtle.h"
#include "Sheep.h"
#include "Media.h"

//make these classes visible and usable without including their h files
class CTerrain;
class CLanguage;

/**
 * \brief Movie class. This class plays Movie in game engine.
 *
 * This class should be made more generic. Right now, it is progremmed to play Intro movie.
 * It loads terrain, and game models, it animates the camera, models and plays the music theme.
 * Everything is hardcoded, no scripting, so to make another movie would mean to write it all from scratch.
 * \author Petar Bajic \date January, 16 2007.
 */
class CMovie {

public:

	CMovie();
	~CMovie();

	bool Init(HWND hWnd, LPDIRECT3DDEVICE9 pd3dDevice, int screenWidth, int screenHeight, CTerrain* pTerrain, CTurtle* pTurtle, CSheep* pSheep, CLanguage* language);
	bool OnEvent(LPDIRECT3DDEVICE9 pd3dDevice, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, int* code);
	void OnFrameMove(LPDIRECT3DDEVICE9 pd3dDevice, double fTime, float fElapsedTime);
	void OnRender(LPDIRECT3DDEVICE9 pd3dDevice);

	//additional functions
	void stopMovie();
	void playMovie();
	
	void OnLostDevice();
	void OnResetDevice(LPDIRECT3DDEVICE9 pd3dDevice, int screenWidth, int screenHeight);

	LPDIRECT3DTEXTURE9 m_textureBlack;
	LPD3DXSPRITE m_sprite;
	LPD3DXFONT m_pFont, m_pFontBig;
	D3DXVECTOR3 m_vEye;
	D3DXVECTOR3 m_vAt;
	D3DXVECTOR3 m_vUp;
	D3DXVECTOR2 m_textPos;
	float m_screenWidth;
	float m_screenHeight;
	CTurtle* m_pTurtle;
	CSheep* m_pSheep;
	CTerrain* m_pTerrain;
	CMedia* m_movieTheme;
	CLanguage* m_Language;
	float m_MovieTime;

	bool m_Blinking;

	IDirectMusicLoader8*		m_pLoader;
	IDirectMusicPerformance8*	m_pPerformance;
	IDirectMusicSegment8*		m_pSegment;  //Movie Music
};