/*****************************************************************************\

  Copyright (C) 2013, Solarix <solarix.one1 at gmail dot com>

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software subject to the 
  terms and conditions stated in Car Spawner - License.txt, and the following restrictions:

  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation is required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

\*****************************************************************************/
#pragma once

#include "../ScriptHook/Services/D3DHook.h"
#include "Scripting.h"
#include <d3dx9.h>

class SpeedoRender :
    public ID3DDeviceHook
{
private:
	IDirect3DTexture9 *m_pCursorTexture;
	D3DXVECTOR3 m_CursorPosition;
	ID3DXSprite *m_pSprite;

	b8 m_bMenuVisible;
	b8 bHaveSetTheCursorToMenu;
	u32 m_nCursorColour;
	u32 m_MenuNrPlayers;
	u32 m_MenuNrSpawnedCars;
	Scripting::Player GetPlayer();
	Scripting::Ped GetPlayerPed();
	
    HMODULE m_hModule;

public:
    SpeedoRender();

	inline void SetMenuVisible( b8 visible ) { m_bMenuVisible = visible; }
	inline b8 GetMenuVisible() { return m_bMenuVisible; }
	inline void SetMenuNrSpawnedCars( u32 value) { m_MenuNrSpawnedCars = value; }
	inline void SetMenuNrPlayers( u32 MenuNrPlayers) { m_MenuNrPlayers = MenuNrPlayers; }

    inline void SetResourceModule( HMODULE hModule ) { m_hModule = hModule; }

    void InstallHook();
    void RemoveHook();

    void OnCreateDevice(ID3DDevice *pDevice, PresentParameters *pPresentParameters) { /* nothing to do here */ }	
    void OnResetDevice(ID3DDevice *pDevice, PresentParameters *pPresentParameters);
    void OnLostDevice(ID3DDevice *pDevice);
    void OnDestroyDevice(ID3DDevice *pDevice) { /* nothing to do here */ }
    void OnRender(ID3DDevice *pDevice);
};