#include"./EV_const.dnh"

let bgm = ObjSound_Create();
let Current = GetCurrentScriptDirectory();

/*let songlists = [Current ~ "./../../Bgm/pg_prebattle1.ogg",
                 Current ~ "./../../Bgm/pg_prebattle2.ogg",
				 Current ~ "./../../Bgm/pg_boss1.mp3",
				 Current ~ "./../../Bgm/pg_boss2.ogg",
				 Current ~ "./../../Bgm/pg_boss3.ogg"];
				 */
@Initialize
{
yield;
}

@MainLoop
{
yield;
}

@Event
{
	
	alternative(GetEventType())
	case(EV_PLAYMUSIC)
	{
	if(GetCommonData("Menu",false)){
	let data = GetEventArgument(0);
		PlayMusic(songlists[ator(data[0])],ator(data[1]),data[2],data[3]);
	}
	
	}
	case(EV_STOPMUSIC)
	{
	if(GetCommonData("Menu",false)){
	ObjSound_Stop(bgm);
	ObjSound_SetLoopEnable(bgm,false);
	}
	}
}

task PlayMusic(str,v,loopstart,loopend){
	ObjSound_Load(bgm,str);
	ObjSound_SetSoundDivision(bgm,SOUND_BGM);
	ObjSound_SetVolumeRate(bgm,v);
	ObjSound_SetLoopEnable(bgm,true);
	ObjSound_SetLoopSampleCount(bgm,loopstart,loopend);
	//ObjSound_SetRestartEnable(bgm,true);
	ObjSound_Play(bgm);
}