///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_FMV.cpp
// Author : Catalin Arsenescu
// Date   : 24/04/08
//
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

//Asura main header
#include "Core/Asura.h"

//This files header
#include "AVP_FMV.h"

//Asura Headers
#include "Core/Asura_LocalisedText.h"
#include "Core/Asura_String.h"
#include "FMV/Asura_FMV.h"
#include "Debugging/Asura_Assert.h"
#include "Interface/Asura_CommandConsole.h"

////////////////////////////////////////////////////////////////////////////////
//  CLASS    :  AVP_FMV
//  NAME     :  Initialise() - Public
//  CREATED  :  Catalin Arsenescu 24/04/08
////////////////////////////////////////////////////////////////////////////////

void AVP_FMV::Initialise( void )
{
	Platform_Initialise();
}

////////////////////////////////////////////////////////////////////////////////
//  CLASS    :  AVP_FMV
//  NAME     :  InitialiseFMVConsoleCommands() - Public
//  CREATED  :  CAH (23.8.2008)
//  DESC     :  Adds the needed commands to the consol for access by the GUI menu system
//				Not in the normal initialise because FMV support is not initialised when in tool mode, but the commands are needed. 				
////////////////////////////////////////////////////////////////////////////////

void AVP_FMV::InitialiseFMVConsoleCommands( void )
{
	Asura_CommandConsole::AddCmd( L"FMV.CMD.PlayFmv",	AVP_FMV::ConsoleCmd_PlayFmvViaMenuByString,	Asura_CommandConsole::REMOVE_AT_SHUTDOWN );
}

////////////////////////////////////////////////////////////////////////////////
//  CLASS    :  AVP_FMV
//  NAME     :  Shutdown() - Public
//  CREATED  :  Catalin Arsenescu 24/04/08
////////////////////////////////////////////////////////////////////////////////

void AVP_FMV::Shutdown( void )
{
	Platform_Shutdown();
}

////////////////////////////////////////////////////////////////////////////////
//  CLASS    :  AVP_FMV
//  NAME     :  Play() - Public
//  CREATED  :  Catalin Arsenescu 24/04/08
//  DESC     :  Interface function to the platform specific code needed to play FMVs of various formats. 
////////////////////////////////////////////////////////////////////////////////

bool AVP_FMV::Play( const char* szFilename, bool bLoop /*= false*/, Asura_LocalisedText_Language eOverrideLanguage /*= ASURA_LT_L_NUM_LANGUAGES*/ )
{
	bool bRet = false;

#ifdef ASURA_USE_NEW_FMV_SYSTEM
	bRet = Asura_FMV::Play(szFilename, bLoop, eOverrideLanguage);
#else
	Asura_LocalisedText_Language eLang = ( eOverrideLanguage == ASURA_LT_L_NUM_LANGUAGES ) ? Asura_LocalisedText::GetCurrentLanguage() : eOverrideLanguage;
	bRet = Platform_Play( szFilename, eLang, bLoop );
#endif

	Asura_Assertf( bRet, ( "FMV Playback failed\nFile: '%s'\n" , szFilename ) );

	return bRet;
}

////////////////////////////////////////////////////////////////////////////////
//  CLASS    :  AVP_FMV
//  NAME     :  ConsoleCmd_PlayFmvViaMenuByString() - Public
//  CREATED  :  CAH (23.8.2008)
//  DESC     :  Interface to the Play funcitnality from a GUI menu screen. Accessed by console commands set in GUI pages. 
//				FMV filename used to be stored in this file and referenced by int in the menu. But not the Menu system send in the file name string
//				SO: you must define the fmv to play in the Asura GUI Menu Tool
////////////////////////////////////////////////////////////////////////////////

bool AVP_FMV::ConsoleCmd_PlayFmvViaMenuByString( const char* szFilename, bool bInterrogate, bool bHelp )
{ 
	if ( bInterrogate || bHelp )
	{ 
		return true; 
	} 
	
	Asura_Char szBuffer[256];
	Asura_PrintfToBfr( szBuffer, "Animatics\\%s", 256, true, szFilename );

	Play( szBuffer, false, Asura_LocalisedText::GetCurrentLanguage() );

	return true;
}
//eof
