#include "sceneswitcher.h"
#include "storage.h"
#include "config.h"
#include "sceneobjectfabric.h"
#include "video.h"
#include "video_int.h"
#include <iostream>

ObjectFabric<SceneSwitcher> SceneSwitcherFabric;


SceneSwitcher::SceneSwitcher ( ): 
        SceneImage ( ), 
        _next_scene_ ( "" )
{}


SceneSwitcher::~SceneSwitcher()
{}


bool SceneSwitcher::load ( std::string storage_name, std::string storage_prefix, std::string scene_name, std::string object_name )
{
	Config_Interface *intf = config_get_interface ( storage_name );
	std::cerr<<"intf="<<intf<<std::endl;
	if ( !intf ) return false;
	_next_scene_=intf->_get_value ( storage_prefix+"scene_switch->to_scene", "" );
	bool img_state, ttf_state;
	img_state=SceneImage::load ( storage_name, storage_prefix, scene_name, object_name );
	ttf_state=TextObject::load( storage_name, storage_prefix, scene_name, object_name );
	std::cerr<<"imgstate="<<img_state<<"ttf_state="<<ttf_state<<std::endl;
	return img_state|ttf_state;
}
void SceneSwitcher::draw ()
{
	SceneImage::draw();
	TextObject::draw();
}

DEFINE_SLOT( SceneSwitcher, _on_mouse_release )
{
	set_next_scene(_next_scene_);
        return true;
}
