//	OptionsScreen.h - Simple options screen.
//  ----------------------------------------------------------------------------
//	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/>.
//	----------------------------------------------------------------------------

#ifndef OPTIONSSCREEN_H_
#define OPTIONSSCREEN_H_

#include "gui/WidgetContainer.h"
#include "gui/Callbacks.h"
#include "ThreeFloats.h"
#include "Snowflakes.h"
#include "GameState.h"
#include "Tweener.h"

class TankYouGlobalData;
class HorizontalSlider;
class RadioButtons;
class Button;

///	Simple options screen.
class OptionsScreen : public GameState,
					  public ChangeCallback,
					  public TriggerCallback
{
  public:
	///	Constructor.
	OptionsScreen(Application& app, SounderPtr& sound);
	///	Destructor.
	~OptionsScreen();

	///	Called frequently to update the state.
	void update();
	///	Called to draw the state.
	void draw(DrawerPtr& d, float timestepInterp);

	///	Called when a key down event is received.
	void keyDown(const std::wstring& action,
				 const std::wstring& keyPressed,
				 int keyModifier);

	///	Called when a mouse down event is received.
	void mouseDown(int button, const TwoFloats& pos);
	///	Called when a mouse up event is received.
	void mouseUp(int button, const TwoFloats& pos);
	///	Called when a mouse move event is received.
	void mouseMove(const TwoFloats& pos);

	///	Called when a floating-point value is changed.
	void valueChanged(Widget *w, float val, const std::wstring& id);
	///	Called when the user has finished interacting with the widget for now.
	void finishedChanging(Widget *w);

	///	Called when something is triggered.
	void triggered(Widget *w, bool val, const std::wstring& id);

	///	Returns the name of this state.
	const std::wstring getName() const {return L"OptionsScreen";};
	///	Used to construct instances of this state.
	static GameStateCreator<OptionsScreen> creator;
  private:
	///	The current background colour.
	ThreeFloats backgroundColour;
	///	Tweener for the background colour.
	STweener<ThreeFloats> backgroundTweener;
	///	The current border colour.
	ThreeFloats borderColour;
	///	Tweener for the border colour.
	STweener<ThreeFloats> borderTweener;
	///	Used to shake the screen.
	float shake;
	///	Used to shake the screen.
	float shakeIndex;

	///	The line left colour.
	ThreeFloats lineLeft;
	///	Tweener for the line left colour.
	STweener<ThreeFloats> lineLeftTweener;
	///	The line right colour.
	ThreeFloats lineRight;
	///	Tweener for the line right colour.
	STweener<ThreeFloats> lineRightTweener;
	///	The top and bottom lines.
	std::vector<TwoFloats> linePos[2];
	///	The top and bottom lines.
	std::vector<float> lineSize;
	///	The top and bottom lines.
	std::vector<ThreeFloats> lineCol;
	///	The top and bottom lines.
	std::vector<float> lineAlpha;

	///	Our widget container.
	WidgetContainer widgets;

	///	The screen shake slider.
	HorizontalSlider *screenShakeSlider;
	///	The background flash slider.
	HorizontalSlider *backgroundFlashSlider;
	///	The border flash slider.
	HorizontalSlider *borderFlashSlider;
	///	The snowflakes slider if it's December.
	HorizontalSlider *snowflakesSlider;
	///	The pickup generation method radio buttons.
	RadioButtons *pickupGenButtons;
	///	The max number of pickups on screen radio buttons.
	RadioButtons *maxPickupsButtons;
	///	The number of players radio buttons.
	RadioButtons *numPlayersButtons;
	///	The music radio buttons.
	RadioButtons *musicButtons;

	///	The start game button.
	Button *startButton;
	///	Used to trigger the next state once the start button's been pressed.
	bool startGame;

	///	Snowflakes if it's December.
	Snowflakes snowflakes;

	///	Our global data.
	shared_ptr<TankYouGlobalData> globalData;
	///	Our sounder.
	shared_ptr<GenericFileSounder> sounder;
};

#endif
