#pragma once
#include <Widgets/Panel.h>
#include <Widgets/Label.h>
#include "../Mechanics/PlayerGame.h"
#include <sstream>
#include <Widgets/Window.h>

//for vs
#undef interface

namespace interface {

	class GameLog : public gge::widgets::Window {

	public:

		GameLog() {
			setshowvscroll(false);

			Padding=2;
			Resize(240, 140);
			Move(0, gge::widgets::TopLevel.GetHeight()-140);

			Title="Log";

			SetContainer(gge::widgets::TopLevel);
			text.SetContainer(this);
			text.SetWidth(220);

			gge::Main.BeforeRenderEvent.Register(this, &GameLog::update);
		}

		void update() {
			if(!mechanics::PlayerGame::isInGame()) return;

			auto gamelog = mechanics::PlayerGame::current().getGameLog();
			std::string s;
			for(auto it=gamelog.begin();it != gamelog.end();++it) {
				s+=*it+"\n";
			}

			text.Text=s;
			text.SetY(110-text.GetHeight());
		}


	protected:
		gge::widgets::Label text;

	};

};
