//
// Tools_InGameCutsceneAVI.h
//
// Created by Richard Rice - 26/09/2005
// 
// Copyright (C) 2005 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif


#ifndef _TOOLS_INGAMECUTSCENEAVI_H_
#define _TOOLS_INGAMECUTSCENEAVI_H_

#include "Core/Asura_String.h"

/*
System for recording cutscenes as AVI while in game (to allow any specialFX etc that don't
work in tools to be used).

It requires various calls in project specific code to work.

Update() : Should be called at a point at which cutscene updates are done.
Render() : Should be called when cutscene rendering is done.
WriteFrame() : Should be called once everything that should appear in the AVI has been rendered.
               This should be done before the command console is drawn.

AddConsoleCommands() : Should be done when the other console commands are being initialised.
               
These actions should probably be prevented while recording AVIs :
Entering tools
Skipping cutscenes
Restarting/winning/losing level.

Use IsWritingAVI() to check if an AVI is being written , and then either prevent the action ,
or use Abort() to stop AVI writing.

               
RAR 27/09/2005

*/


struct Tools_CutsceneAVIConfig;
template<class T>
class List;

class Tools_InGameCutsceneAVI
{
public :
	//per frame update.. needs to be called at a point at which cutscene updates can be done
	static void Update();

	//per frame render.. needs to be called at a point at which cutscene renders can be done
	static void Render();

	//Write next frame to avi (does nothing if no avi currently being done)
	static void WriteFrame();

	//abort current avi and any queued avis.
	static void Abort();	

	static void AddConsoleCommands();

	static bool IsWritingAVI();

private :

	static bool ConsoleCmd_WriteCutsceneAVI(const char* pszText,bool bInterrogate, bool bHelp);

	static bool ParseCommand(Tools_CutsceneAVIConfig* pxAVIConfig,const char* pszText);
	static bool GetNextString(const char*& pszText,Asura_String* pxOutput);

	static void EndAVI();
	static void PlayNextInQueue();

	static class Asura_Cutscene* s_pxCurrentCutscene;
	static Tools_CutsceneAVIConfig* s_pxCurrentAVI;

	static List<Tools_CutsceneAVIConfig*> s_xQueue;

	static bool s_bStartOfBatch;

	static int s_iInitialVideoWidth;
	static int s_iInitialVideoHeight;
	static bool s_bInitialIgnoreAssert;

};


struct Tools_CutsceneAVIConfig
{

	Asura_String m_xCutsceneName;
	Asura_String m_xExtraFormatText;
	Asura_String m_xFilename;
	
	int m_iVideoModeWidth;
	int m_iVideoModeHeight;

	int m_iAVIWidth;
	int m_iAVIHeight;

	bool m_bHalfSize;

	int m_iFrameRate;
};


#endif //_TOOLS_INGAMECUTSCENEAVI_H_

