
#if defined _SCEI_COMMON_BG_included
  #endinput
#endif
#define _SCEI_COMMON_BG_included

#include <all.inc>

stock SCEI_BG_NAME[] = "SCEI:CommonBG";

stock load_bg( const xml_id[], float:timer = 1000.0 )
{
	// BGの名前 が既に SCEI:CommonBG であればロードしない
	{
		new name[256];
		if( wndGetName( WND_BG, name )
         && strcmp( name, SCEI_BG_NAME )==0 ) return;
	}

	new bg[256];
	xmlGetAttr( "LINK", xml_id, "href", bg );

    xmlLoadStart( bg, SCEI_BG_NAME, _, XMLLOAD_MODE_BG );
	xmlLoadWait();

	bg_start( timer );
}

stock bg_start( float:timer = 1000.0 )
{
	new obj: bg_scene = wndGetScene( WND_BG );
	if( bg_scene )
	{
		SendMessage( bg_scene, TAG("STRT"), timer );
	}
}

stock bg_star_fade( float:alpha1 = 1.0, float:alpha2 = 0.8, 
                    float:timer = 1000.0 )
{
	new obj: bg_scene = wndGetScene( WND_BG );
	if( bg_scene )
	{
		SendMessage( bg_scene, TAG("FADE"), alpha1, alpha2, timer );
	}
}

stock bg_star_rich( float:timer = 1000.0, float:fout_timer = 0.0 )
{
	new obj: bg_scene = wndGetScene( WND_BG );
	if( bg_scene )
	{
		SendMessage( bg_scene, TAG("RICH"), timer, fout_timer );
	}
}

stock bg_star_poor( float:timer = 1000.0, float:fout_timer = 0.0 )
{
	new obj: bg_scene = wndGetScene( WND_BG );
	if( bg_scene )
	{
		SendMessage( bg_scene, TAG("POOR"), timer, fout_timer );
	}
}

stock bg_cam_attach( float:pos_scale = 0.4, float:rot_scale = 0.4 )
{
	new obj: bg_scene = wndGetScene( WND_BG );
	if( bg_scene )
	{
		SendMessage( bg_scene, TAG("LINK"), Camera(), pos_scale, rot_scale );
	}
}

stock bg_cam_adjust( )
{
	new obj: bg_scene = wndGetScene( WND_BG );
	if( bg_scene )
	{
		SendMessage( bg_scene, TAG("AJST"), Camera() );
	}
}

stock bg_cam_correct( )
{
	new obj: bg_scene = wndGetScene( WND_BG );
	if( bg_scene )
	{
		SendMessage( bg_scene, TAG("CRCT"), Camera() );
	}
}

stock bg_cam_release( bool:smooth = true, float:time = 2000.0 )
{
	new obj: bg_scene = wndGetScene( WND_BG );
	if( bg_scene )
	{
		SendMessage( bg_scene, TAG("RELS"), smooth, time );
	}
}

