/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


		#include "project/project.h"
		#include "scene3d/scene.h"
		#include "ui/ui.h"
		#include "core/renderer.h"

		using namespace GS::Core;
		using namespace GS::Render;


//------------------------------------------------------------------------------
void				Project::DrawProfilerText(Renderer &render, RasterFont *font[2], float &x, float &y)
{
	render.SetWorldMatrix(Matrix4::IdentityMatrix(), &Matrix4::IdentityMatrix());
	render.SetViewMatrix(Matrix4::IdentityMatrix(), &Matrix4::IdentityMatrix());
	render.SetProjectionMatrix(Matrix4::IdentityMatrix());

	Color title_color(1, 0.8f, 0);
	Renderer::WriterConfig config(false);

	// Output layer stack.
	render.Write(*font[1], String::Format("Scene list (%d instantiated, %d active):\n\n", GetInstanceCount(), GetActiveCount()), x, y, config, 1, &title_color);
	render.Write(*font[1], "Layer stack:", x, y, config, 1, &Color::White);

	for	(uint n = layer_list.GetCount(); n > 0; --n)
	{
		ProjectLayer *layer = layer_list.ObjectAt(n - 1);
		render.Write(*font[0], String::Format("  -> %s\n", layer->inst ? layer->inst->GetPath().c_str() : "No Instance"), x, y, config, 1, &title_color);
	}
	render.Write(*font[0], "\n", x, y, config);

	// Output scene details.
	x += 16;

	ListForeachPtr(ProjectSceneInstance *, inst, instance_list)
		if	(IsActive(*inst))
		{
			render.Write(*font[0], String::Format("Scene instance '%s':\n\n", inst->GetPath().c_str()), x, y, config, 1, &Color::White);

			switch (inst->GetType())
			{
				case ProjectSceneInstance::Type_Scene2d:
					inst->instance_2d->DrawProfilerText(render, font, x, y);
					break;

				case ProjectSceneInstance::Type_Scene3d:
					inst->instance_3d->DrawProfilerText(render, font, x, y);
					break;
			}
		}

	x -= 16;
}
//------------------------------------------------------------------------------
