//	IntroState.cpp - The intro text as a game state.
//  ----------------------------------------------------------------------------
//	This file is part of 'The Future Will Only Be Dystopian if Capitalism
//	Remains Undefeated', a game.
//	Copyright (C) 2009  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 "IntroState.h"
#include "Images.h"

#include "NiallsDrawingLib/ImageLoader.h"
#include "NiallsDrawingLib/Drawer.h"

//------------------------------------------------------------------------------
IntroState::IntroState(Application *app):
GameState(app),
currentText(0)
{
	text[0] = 0;
	text[1] = 0;
	text[2] = 0;
}

//------------------------------------------------------------------------------
IntroState::~IntroState()
{
	
}

//------------------------------------------------------------------------------
void IntroState::draw(Drawer *d)
{
	if(!text[0])
	{
		ImageLoader imLoad;
		ImageData data;

		data = imLoad.loadImage(Images::childrenimagine_png, Images::childrenimagine_pngSize);
		text[0] = d->loadImage(data.data, data.width, data.height);

		data = imLoad.loadImage(Images::leftdecline_png, Images::leftdecline_pngSize);
		text[1] = d->loadImage(data.data, data.width, data.height);

		data = imLoad.loadImage(Images::capitalismfuture_png, Images::capitalismfuture_pngSize);
		text[2] = d->loadImage(data.data, data.width, data.height);
	}

	d->drawImage(text[currentText], 0, 0);
}

//------------------------------------------------------------------------------
void IntroState::keyDown(const SDL_keysym& keyPressed)
{
	if(keyPressed.sym == SDLK_ESCAPE)
		quit();
	else
	{
		++currentText;
		if(currentText >= 3)
			nextState("GamePlay");
	}
}

//------------------------------------------------------------------------------
void IntroState::mouseDown(int button, int posX, int posY)
{
	++currentText;
	if(currentText >= 3)
		nextState("GamePlay");
}
