#pragma once

#include <Widgets/Panel.h>
#include <Widgets/Label.h>
#include "../Mechanics/PlayerGame.h"
#include <sstream>
#include <Widgets/Organizers/LinearOrganizer.h>
#include "../Mechanics/Townsfolk.h"
#include "../Mechanics/Soldier.h"
#include <Widgets/Window.h>
#include <Widgets/DialogWindow.h>
#include <Widgets/Listbox.h>
#include "../Assets/Buildings.h"
#include "../Mechanics/Artisan.h"
#include "Actions.h"
#include "Credits.h"
#include <Widgets/Slider.h>

//for vs
#undef interface

namespace interface {

	class Settings : public gge::widgets::Window {
	public:
		Settings() {
			SetOrganizer(organizer);

			SetWidth(160);

			Title="Settings";

			auto nl=organizer.nextline;

			close.Text="Close";
			close.ClickEvent.Register(this, &Settings::Close);

			taxrate.Max=50;
			taxrate.Min=0;
			taxrate.ChangeEvent.RegisterLambda([&]{
				mechanics::PlayerGame::current().taxRate(this->taxrate.Value);
			});

			speed.Max=300;
			speed.Min=80;
			speed.ChangeEvent.RegisterLambda([&]{
				mechanics::PlayerGame::current().gameSpeed(int(this->speed.Value)/100.f);
			});

			organizer
				<<"Tax rate: "<<nl
				<<taxrate<<nl
				<<"Speed: "<<nl
				<<speed<<nl
				<<close
			;

			Hide();

			ClosingEvent.RegisterLambda([&] {
			});
		}

		virtual void Show() {
			taxrate.Value=mechanics::PlayerGame::current().taxRate();
			speed.Value=mechanics::PlayerGame::current().gameSpeed()*100;

			gge::widgets::Window::Show(true);
			MoveToCenter();
		}

	protected:
		gge::widgets::LinearOrganizer organizer;

		gge::widgets::Slider<int> taxrate, speed;

		gge::widgets::Button close;
	};

}
