//
// Tools_CutsceneModeAVI.h
//
// Created by Richard Rice - 16/05/2006
// 
// Copyright (C) 2006 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef __TOOLS_CUTSCENEMODEAVI_H__
#define __TOOLS_CUTSCENEMODEAVI_H__

#include "Core/Asura_String.h"
#include "Rendering/Asura_Colour.h"

#include "Misc/list_tem.hpp"

class Tools_CutsceneModeAVI_Config;



class Tools_CutsceneModeAVI
{
public :
	static void Initialise();
	static void Shutdown();

	static void ShowOverlay();
	static void CloseOverlay();

	static void Update();

	static void BeginRenderWorld();
	static void EndRenderWorld();

	static void PreCutsceneRender();
	static void PostCutsceneRender();

	static bool ShouldHideActor(const class Asura_Cutscene_Actor* pxActor);

	static bool IsRecording();
	static bool IsDisablingPFX();


private :
	static void UpdateOverlay();
	static void UpdateStoredAspectRatio();

	static void RecordDefault();
	static void RecordNTSC();
	static void RecordPAL();
	static void RecordPALAndNTSC();
	static void RecordAVI();

	static void ChooseCutscene();
	static void ChooseFilename();

	static void SaveConfig();
	static void LoadConfig();
	static void BatchRecord();
	static bool LoadConfig(Tools_CutsceneModeAVI_Config* pxConfig,const char* szFilename);

	static bool WriteAVI(const Tools_CutsceneModeAVI_Config* pxConfig);
	static void CancelAVIQueue();
	static void EndAVI();

	static void StartFogOverride(const Asura_RGBA& xColour);
	static void EndFogOverride();

	static void BuildActorNameList();
	static void DeleteActorNameList();

	static void SetToDefault();

	//callbacks for list control
	static bool IsActorVisible(int iIndex,int iUserData);
	static void ToggleActorHidden(int iIndex,int iUserData);

	static void HideAllActors();
	static void ShowAllActors();

	///////////////////////////
	
public :
	static Asura_Vector_2 s_xOverlayPosition;

private :
	

	static bool s_bConfigNeedsReset;
	static Tools_CutsceneModeAVI_Config s_xOverlayAVIConfig;

	//For the tickbox for locking the current aspect ratio
	static bool s_bLockAspectRatio;
	static float s_fVideoAspectRatio;
	static float s_fAVIAspectRatio;
	static bool s_bVideoWidthChanged;
	static bool s_bVideoHeightChanged;
	static bool s_bAVIWidthChanged;
	static bool s_bAVIHeightChanged;



	static Tools_CutsceneModeAVI_Config* s_pxCurrentAVI;

	static bool s_bAskForCompressionSettings;

	static List<Tools_CutsceneModeAVI_Config*> s_xQueue;

	static bool s_bInitialVideoModeValid;
	static int s_iInitialWidth;
	static int s_iInitialHeight;

	static int s_iSelectedActor;
	static int s_iActorNameListSize;
	static char** s_pszActorNames;

	static Asura_RandomGenerator s_xHeatHazeRNG;
	
	//for storing backup fog values if it is being messed around with for cutscenee rendering
	static struct Tools_FogBackup s_xFogBackup;

};


class Tools_CutsceneModeAVI_Config
{
public :
	Tools_CutsceneModeAVI_Config(){Reset();}

	void Reset();
	void SetCutscene(const char* szCutsceneName);

	Asura_String m_xCutsceneName;
	Asura_String m_xFilename;

	bool m_bWriteBmps;

	int m_iVideoModeWidth;
	int m_iVideoModeHeight;

	int m_iAVIWidth;
	int m_iAVIHeight;

	bool m_bHalfSize;

	float m_fFrameRate;

	bool m_bUseEnvFog;
	Asura_RGBA m_xEnvFog;

	bool m_bUseActorFog;
	Asura_RGBA m_xActorFog;

	bool m_bDisablePFX;

	List<Asura_String> m_xHideActorList;

};

struct Tools_FogBackup
{
	bool bValid;
	bool bEnabled;
	bool bGraphEnabled;
	float fNearPlane;
	float fFarPlane;
	float fFarPlaneValue;
	float fSkybox;
	Asura_RGBA xColour;
};


#endif //__TOOLS_CUTSCENEMODEAVI_H__