//	AppSettingsExample.cpp - Example of how to implement the unimplemented
//							 AppSettings bits.
//  ----------------------------------------------------------------------------
//	This file is part of 'NiallsAVLib', base code for any kind of audiovisual
//	apps.
//	Copyright (C) 2012  Niall Moody
//	
//	This program is free software: you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation, either version 3 of the License, or
//	(at your option) any later version.
//
//	This program is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//
//	You should have received a copy of the GNU General Public License
//	along with this program.  If not, see <http://www.gnu.org/licenses/>.
//	----------------------------------------------------------------------------

#include "AppSettings.h"
#include "Application.h"
#include "DebugHeaders.h"

#include "GamePlayState.h"
#include "TitleScreen.h"

#include "drawing/GLImmediateDrawer.h"
#include "drawing/GLESDrawer.h"
#include "DwindlingSounder.h"
#include "GlobalData.h"

#include <sstream>

using namespace std;

//------------------------------------------------------------------------------
wstring AppSettings::applicationName = L"Dwindling Worlds";
wstring AppSettings::applicationVersion = L"1.00";

//------------------------------------------------------------------------------
void AppSettings::initialise(CmdLineParams& cmdLine,
							 Application *app,
							 KeyManager& keyManager,
							 wstring& helpText)
{
	//Register your interest in any command line arguments.

	//Setup the dimensions of the drawing area.
	setDrawingDimensions(1280, 720, AlterRatio);

	//Register all possible GameStates.
	app->registerGameState(L"TitleScreen", &TitleScreen::creator, true);
	app->registerGameState(L"GamePlayState", &GamePlayState::creator);

	//Setup some default key mappings.
	// - Player 1 movement.
	keyManager.addMapping(L"P1Up", L"CursorUp", true);
	keyManager.addMapping(L"P1Left", L"CursorLeft", true);
	keyManager.addMapping(L"P1Right", L"CursorRight", true);
	keyManager.addMapping(L"P1Down", L"CursorDown", true);

	// - General.
	keyManager.addMapping(L"Escape", L"Escape", true);
	keyManager.addMapping(L"Action", L"Space", true);
	keyManager.addMapping(L"Action", L"z", true);

	//Fill out helpText.
}

//------------------------------------------------------------------------------
DrawerPtr AppSettings::getDrawer()
{
	if(GLESDrawer::isSupported())
		return DrawerPtr(new GLESDrawer());
	else
	{
		DebugStatement(L"GLESDrawer not supported. Falling back to GLImmediateDrawer");
		return DrawerPtr(new GLImmediateDrawer());
	}
}

//------------------------------------------------------------------------------
Sounder *AppSettings::getSounder()
{
	return new DwindlingSounder();
}

//------------------------------------------------------------------------------
GlobalDataPtr AppSettings::getGlobalData()
{
	return GlobalDataPtr(new GlobalData());
}
