task MenuBackDraw
{//メニューの黒背景を描画するタスク。現在未使用。
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgBG);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	//	ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, 0, 0);
		ObjEffect_SetVertexXY(obj, 1, 640,  0);
		ObjEffect_SetVertexXY(obj, 2, 640, 480);
		ObjEffect_SetVertexXY(obj, 3,  0,  480);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  384, 0);
		ObjEffect_SetVertexUV(obj, 2, 384,  448);
		ObjEffect_SetVertexUV(obj, 3, 0, 448);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetScale(obj, 1.0,1.0);

		Obj_SetPosition(obj,0,0);
	/*	loop
		{
		if(Select==No+2000 && StageState==Menu && MenuState==Menu && DetailDrawing)
		{
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,255,255,255,255);
			}
		}
		else
		{
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,0,255,255,255);
			}
		}
		yield;
		}
*/
}


task BestPhotoDraw
{//ベストショット及びその情報を描画する関数を呼ぶ
yield;
	ascent(let i in 1..100)
	{
	BestPhotoDrawing(i);
	BestPhotoDetailDrawing(i);
	}	
}

task BestPhotoDrawing(No)
{//写真を描画する
	let DrawShootPhoto=false;
	if(SelectedCharacter==DefinedPlayer1)
	{
		if(GetCommonDataDefaultEx(NsScore,Player1AllPhoto[No],0)!=0)
		{
		DrawShootPhoto=true;
		}
	}
	if(SelectedCharacter==DefinedPlayer2)
	{
		if(GetCommonDataDefaultEx(NsScore,Player2AllPhoto[No],0)!=0)
		{
		DrawShootPhoto=true;
		}
	}
		let X=((170/2)^2+(225/2)^2)^0.5;
		let X=((160/2)^2+(215/2)^2)^0.5;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgBestShot[No]);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -X, -X);
		ObjEffect_SetVertexXY(obj, 1, X,  -X);
		ObjEffect_SetVertexXY(obj, 2, X, X);
		ObjEffect_SetVertexXY(obj, 3,  -X,  X);
		
		ObjEffect_SetVertexUV(obj, 0,  GetCenterX-X,  GetCenterY-55-X);
		ObjEffect_SetVertexUV(obj, 1,  GetCenterX+X, GetCenterY-55-X);
		ObjEffect_SetVertexUV(obj, 2, GetCenterX+X,  GetCenterY-55+X);
		ObjEffect_SetVertexUV(obj, 3, GetCenterX-X, GetCenterY-55+X);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetScale(obj, 0.9,0.9);

		Obj_SetPosition(obj,GetCenterX+70,GetCenterY-55);
		loop
		{
		if(SpellSelect+(SpellLevel)*10==No && StageState==Menu && MenuState==Menu && PhotoDrawing && ShootFlag[SpellLevel] && DrawShootPhoto)
		{
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,255,255,255,255);
			}
		}
		else
		{
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,0,255,255,255);
			}
		}
		yield;
		}
}

task BestPhotoDetailDrawing(No)
{//写真の詳細を描画する
	let DrawShootPhoto=false;
	if(SelectedCharacter==DefinedPlayer1)
	{
		if(GetCommonDataDefaultEx(NsScore,Player1AllPhoto[No],0)!=0)
		{
		DrawShootPhoto=true;
		}
	}
	if(SelectedCharacter==DefinedPlayer2)
	{
		if(GetCommonDataDefaultEx(NsScore,Player2AllPhoto[No],0)!=0)
		{
		DrawShootPhoto=true;
		}
	}
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgBestShotDetail[No]);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -75, -87);
		ObjEffect_SetVertexXY(obj, 1, 75,  -87);
		ObjEffect_SetVertexXY(obj, 2, 75, 82);
		ObjEffect_SetVertexXY(obj, 3,  -75,  82);
		
		ObjEffect_SetVertexUV(obj, 0,  220,  295);
		ObjEffect_SetVertexUV(obj, 1,  370, 295);
		ObjEffect_SetVertexUV(obj, 2, 370,  464);
		ObjEffect_SetVertexUV(obj, 3, 220, 464);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetScale(obj, 0.9,0.9);

		Obj_SetPosition(obj,GetCenterX+110,GetCenterY-25);
		loop
		{
		if(No==SpellSelect+(SpellLevel)*10 && StageState==Menu && MenuState==Menu && DetailDrawing && ShootFlag[SpellLevel] && DrawShootPhoto)
		{
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,255,255,255,255);
			}
		}
		else
		{
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,0,255,255,255);
			}
		}
		yield;
		}
}

task DetailDraw//スペル終了時に写真のスコア詳細を表示するかどうかの切り替え
{
loop
{
	while(GetKeyState(VK_SKIP)!=KEY_PUSH){yield;}
		DetailDrawing=false;
		wait(1);
	while(GetKeyState(VK_SKIP)!=KEY_PUSH){yield;}
		DetailDrawing=true;
		PhotoDrawing=false;
		wait(1);
	while(GetKeyState(VK_SKIP)!=KEY_PUSH){yield;}
		DetailDrawing=true;
		PhotoDrawing=true;
		wait(1);
yield;
}
}

task DrawSpellName(img,left,up,right,down)//スペル名とフレームを表示する。入力座標を左揃えで表示する。
{
		let bx=GetClipMaxX-8;
		let by=302;
		let sx=0.5;
		let sy=0.5;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgSpellName);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);

		ObjEffect_SetVertexXY(obj, 0, left-right, -(down-up)/2);
		ObjEffect_SetVertexXY(obj, 1, 0,  -(down-up)/2);
		ObjEffect_SetVertexXY(obj, 2, 0, (down-up)/2);
		ObjEffect_SetVertexXY(obj, 3,  left-right,  (down-up)/2);
		
		ObjEffect_SetVertexUV(obj, 0,  left,  up);
		ObjEffect_SetVertexUV(obj, 1,  right, up);
		ObjEffect_SetVertexUV(obj, 2, right,  down);
		ObjEffect_SetVertexUV(obj, 3, left,down);

		ObjEffect_SetScale(obj, sx,sy);
		Obj_SetPosition(obj,bx,by);
		ObjEffect_SetLayer(obj,8);
		
		yield;
		Obj_Delete(obj);
}
