//	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 "TitleScreenState.h"
#include "GamePlayState.h"

#include "drawing/GLImmediateDrawer.h"
#include "ExampleSounder.h"

#include <sstream>

using namespace std;

//------------------------------------------------------------------------------
wstring& applicationName = L"Example App";
wstring& applicationVersion = L"1.00";

//------------------------------------------------------------------------------
void AppSettings::initialise(CmdLineParams& cmdLine,
							 Application *app,
							 KeyManager& keyManager,
							 wstring& helpText)
{
	//Register your interest in any command line arguments.
	cmdLine.registerCallback(L"numCats", L"--numCats", L"-c", true, this);
	cmdLine.registerCallback(L"numDogs", L"--numDogs", L"-d", true, this);
	cmdLine.registerCallback(L"spiffyGraphics", L"--spiffyGraphics", L"-sg", false, this);

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

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

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

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

	//Fill out helpText.
	{
		wstringstream tempstr;

		tempstr << "--numCats [val] | -c [val]:\tSets the number of cats.";
		tempstr << endl;
		tempstr << "--numDogs [val] | -d [val]:\tSets the number of dogs.";
		tempstr << endl;
		tempstr << "--spiffyGraphics | -sg:\tTurns on spiffy graphics(tm).";
		tempstr << endl;

		helpText = tempstr.str();
	}
}

//------------------------------------------------------------------------------
DrawerPtr AppSettings::getDrawer()
{
	return DrawerPtr(new GLImmediateDrawer(this));
}

//------------------------------------------------------------------------------
SounderPtr AppSettings::getSounder()
{
	return SounderPtr(new ExampleSounder());
}
