//一時停止中スクリプト

#include"./txt/Info.txt"
#include"./txt/Save.txt"

let SE_Start=GetCurrentScriptDirectory~"se/decide12.wav";
let SE_SelectMove=GetCurrentScriptDirectory~"se/cursor5.wav";
let SE_Decide=GetCurrentScriptDirectory~"se/decide2.wav";
let SE_Cancel=GetCurrentScriptDirectory~"se/cursor3.wav";

///////////////////////////////飾り
let Status_MagicPower=0;
let Status_ShieldRecover=0;
let Status_ShieldReduce=0;
let Status_SpellCardRecover=0;
let Status_SpellCardReduce=0;
let Status_SpiritRecover=0;
let Status_SpiritReduce=0;
let Status_Luck=0;
let Status_Critical=0;
//////////////////////////////


@Initialize
{
	SetCommonData("PauseFlag",GetCommonData("PauseFlag",0)+1);
	if(GetCommonData("PlayerEnd",false))
	{
		SetScriptResult(RESULT_CANCEL);
	}
	else
	{
	SetCommonData("Pause",true);
	TBackgroundCenter();
	TBackgroundFrame;
	TMenu();
	TInitialize;
	}
}

task TInitialize
{
/*
	ObjSound_SetVolumeRate(GetCommonData("Obj_BGM",0),100);
*/
	Obj_PlaySE(SE_Start);

}

@MainLoop
{
	yield;
}

@Finalize
{
	//SaveCommonDataAreaA1("");
}


task TBackgroundFrame
{
	let imgBer = GetTransitionRenderTargetName();
	//let imgBer = GetCurrentScriptDirectory() ~ "img/system.png";
	let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
	ObjPrim_SetTexture(obj, imgBer);
	ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjPrim_SetVertexCount(obj, 4);
//	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	Obj_SetRenderPriorityI(obj,0);
	ObjRender_SetAngleZ(obj,0);

	ObjPrim_SetVertexPosition(obj, 0, 0, 0, 0);
	ObjPrim_SetVertexPosition(obj, 1, 640,0, 0);
	ObjPrim_SetVertexPosition(obj, 2, 640, 480, 0);
	ObjPrim_SetVertexPosition(obj, 3, 0, 480, 0);

	ObjPrim_SetVertexUVT(obj, 0, 0, 0);
	ObjPrim_SetVertexUVT(obj, 1, 640, 0);
	ObjPrim_SetVertexUVT(obj, 2, 640, 480);
	ObjPrim_SetVertexUVT(obj, 3, 0, 480);

	ObjRender_SetPosition(obj,0,0,0);

	ObjRender_SetAlpha(obj, 255);
}

task TBackgroundCenter
{
	//let imgBer = GetTransitionRenderTargetName();
	let imgBer = GetCurrentScriptDirectory() ~ "img/system2.png";
	let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
	ObjPrim_SetTexture(obj, imgBer);
	ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjPrim_SetVertexCount(obj, 4);
//	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	Obj_SetRenderPriorityI(obj,10);
	ObjRender_SetAngleZ(obj,0);

	ObjPrim_SetVertexPosition(obj, 0, 32, 16, 0);
	ObjPrim_SetVertexPosition(obj, 1, 480,16, 0);
	ObjPrim_SetVertexPosition(obj, 2, 480, 464, 0);
	ObjPrim_SetVertexPosition(obj, 3, 32, 464, 0);

	ObjPrim_SetVertexUVT(obj, 0, 32, 16);
	ObjPrim_SetVertexUVT(obj, 1, 480, 16);
	ObjPrim_SetVertexUVT(obj, 2, 480, 464);
	ObjPrim_SetVertexUVT(obj, 3, 32, 464);

	ObjRender_SetPosition(obj,0,0,0);

	let alpha=0;
	loop(30)
	{
	alpha+=255/30;
	ObjRender_SetAlpha(obj, alpha);
	yield;
	}
}

task TMenu
{


let SkillKeyArray=["Shot_Key","Bomb_Key","User1_Key","User2_Key"];

let SkillTypeAll=GetCommonData("SkillType_All",["マジックショット","マジックナパーム","ダッシュ","魔符｢スターダスト｣"]);

//let SkillTypeAll=["マジックショット","マジックナパーム","ダッシュ","a","b","c","d","e","f","G","h","i"];

let SkillTypeAttack=GetCommonData("SkillType_Attack",["マジックショット","マジックナパーム"]);
let SkillTypeEnchant=GetCommonData("SkillType_Enchant",["ダッシュ"]);
let SkillTypeSpell=GetCommonData("SkillType_Spell",["魔符｢スターダスト｣"]);

let SkillTypeArray=[SkillTypeAll,SkillTypeAttack,SkillTypeEnchant,SkillTypeSpell];

let PauseSelect=0;
let PauseState="Title";

let SkillTypeSelect=0;
let SkillSelect=0;

let DisplayType=0;

//let SkillDisplayType=0;

let ListAdjust=0;

let EquipSelect=0;

//SetCommonData("Equip_All",["a","b","c","d","e"]);
//let EquipAll=GetCommonData("Equip_All",[["a","1_01"],["b","1_02"],["c","2_03"],["d","5_04"]]);
let EquipAll=GetCommonData("Equip_All",[["----------"]]);
//EquipAll=[["a","1_01","1_02","2_03"],["b","1_02","0_00"],["c","2_03"],["d","5_04"],["e","1_02","0_00"],["f","2_03"],["g","5_04"],["h","1_02","0_00"],["i","2_03"],["g","5_04"]];
//EquipAll=[["----------"]];
//let EquipAll=[["a","01"],["b","02"],["c","03"],["d","04"]];

let EQ1=GetCommonData("Equip1",["普通の箒"]);
let EQ2=GetCommonData("Equip2",["ミニ八卦路（故障中）"]);
let EQ3=GetCommonData("Equip3",["----------"]);
let EQ4=GetCommonData("Equip4",["----------"]);

if(GetCommonData("Equip1","Defelt"))
{
SetCommonData("Equip1",EQ1);
SetCommonData("Equip2",EQ2);
SetCommonData("Equip3",EQ3);
SetCommonData("Equip4",EQ4);
}

let EquipArray=["Equip1","Equip2","Equip3","Equip4"];

//let EquipDisplayType=0;

MainDraw;
Main;

task Main
{

#include"./player/EquipStatusAdjust.txt"
EquipStatusAdjust;

loop
{

if(PauseState=="Title")
{
	if(GetVirtualKeyState(VK_RIGHT)==KEY_PUSH)
	{
		Obj_PlaySE(SE_SelectMove);
		PauseSelect+=1;
		if(PauseSelect>=5){PauseSelect=0;}
	}
	if(GetVirtualKeyState(VK_LEFT)==KEY_PUSH)
	{
		Obj_PlaySE(SE_SelectMove);
		PauseSelect-=1;
		if(PauseSelect<=-1){PauseSelect=4;}
	}
	
	if(GetVirtualKeyState(VK_SHOT)==KEY_PUSH)
	{
		Obj_PlaySE(SE_Decide);
		if(PauseSelect==1)
		{
			PauseState="Skill";
			PauseSelect=100;
			yield;
		}
		if(PauseSelect==2)
		{
			PauseState="Equip";
			PauseSelect=200;
			yield;
		}
		if(PauseSelect==4)
		{
			PauseState="Option";
			PauseSelect=400;
			yield;
		}
	}
	if(GetVirtualKeyState(VK_BOMB)==KEY_PUSH)
	{
			SetScriptResult(RESULT_CANCEL);
			return;
	}

}


if(PauseState=="Skill")
{

	if(GetVirtualKeyState(VK_UP)==KEY_PUSH)
	{
		Obj_PlaySE(SE_SelectMove);
		PauseSelect-=1;
		if(PauseSelect<=99){PauseSelect=103;}
	}
	if(GetVirtualKeyState(VK_DOWN)==KEY_PUSH)
	{
		Obj_PlaySE(SE_SelectMove);
		PauseSelect+=1;
		if(PauseSelect>=104){PauseSelect=100;}
	}


	if(GetVirtualKeyState(VK_BOMB)==KEY_PUSH)
	{
		Obj_PlaySE(SE_Cancel);
		PauseState="Title";
		PauseSelect=1;
	}

	if(GetVirtualKeyState(VK_SHOT)==KEY_PUSH)
	{
		Obj_PlaySE(SE_Decide);
		PauseState="SkillSelect";
		yield;
	}
	if(GetVirtualKeyState(VK_USER1)==KEY_PUSH)
	{
		DisplayType+=1;
		if(DisplayType>=2){DisplayType=0;}
	}
}

if(PauseState=="SkillSelect")
{

	if(GetVirtualKeyState(VK_RIGHT)==KEY_PUSH)
	{
		Obj_PlaySE(SE_SelectMove);
		SkillTypeSelect+=1;
		SkillSelect=0;
		ListAdjust=0;
		if(SkillTypeSelect>=4){SkillTypeSelect=0;}
	}
	if(GetVirtualKeyState(VK_LEFT)==KEY_PUSH)
	{
		Obj_PlaySE(SE_SelectMove);
		SkillTypeSelect-=1;
		SkillSelect=0;
		ListAdjust=0;
		if(SkillTypeSelect<=-1){SkillTypeSelect=3;}
	}

	if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_FREE)
	{
		if(GetVirtualKeyState(VK_UP)==KEY_PUSH)
		{
		Obj_PlaySE(SE_SelectMove);
		SkillSelect-=1;
		if(SkillSelect<=-1){SkillSelect=length(SkillTypeArray[SkillTypeSelect])-1;}
		}
		if(GetVirtualKeyState(VK_DOWN)==KEY_PUSH)
		{
		Obj_PlaySE(SE_SelectMove);
		SkillSelect+=1;
		if(SkillSelect>=length(SkillTypeArray[SkillTypeSelect])){SkillSelect=0;}
		}
	}
	else
	{
		if(GetVirtualKeyState(VK_UP)==KEY_PUSH)
		{
		SkillSelect-=8;
	//	if(SkillSelect<=-1){SkillSelect=length(SkillTypeArray[SkillTypeSelect])-1;}
		if(SkillSelect<=-1){SkillSelect=0;}
		}
		if(GetVirtualKeyState(VK_DOWN)==KEY_PUSH)
		{
		SkillSelect+=8;
		if(SkillSelect>=length(SkillTypeArray[SkillTypeSelect])){SkillSelect=length(SkillTypeArray[SkillTypeSelect])-1;}
		}
	}

	if(GetVirtualKeyState(VK_SHOT)==KEY_PUSH)
	{
		PauseState="Skill";
		SetCommonData(SkillKeyArray[PauseSelect-100],SkillTypeArray[SkillTypeSelect][SkillSelect]);
		SkillSelect=0;
		ListAdjust=0;
		SkillTypeSelect=0;
		SetCommonData("SkillFlag",GetCommonData("SkillFlag",0)+1);
	}

	if(GetVirtualKeyState(VK_BOMB)==KEY_PUSH)
	{
		Obj_PlaySE(SE_Cancel);
		PauseState="Skill";
		SkillSelect=0;
		ListAdjust=0;
		SkillTypeSelect=0;
	}

	if(GetVirtualKeyState(VK_USER1)==KEY_PUSH)
	{
		DisplayType+=1;
		if(DisplayType>=2){DisplayType=0;}
	}
}

if(PauseState=="Equip")
{
	if(GetVirtualKeyState(VK_UP)==KEY_PUSH)
	{
		Obj_PlaySE(SE_SelectMove);
		PauseSelect-=1;
		if(PauseSelect<=199){PauseSelect=203;}
	}
	if(GetVirtualKeyState(VK_DOWN)==KEY_PUSH)
	{
		Obj_PlaySE(SE_SelectMove);
		PauseSelect+=1;
		if(PauseSelect>=204){PauseSelect=200;}
	}

	if(GetVirtualKeyState(VK_BOMB)==KEY_PUSH)
	{
		Obj_PlaySE(SE_Cancel);
		PauseState="Title";
		PauseSelect=2;
		EquipSelect=0;
	}
	if(GetVirtualKeyState(VK_SHOT)==KEY_PUSH)
	{
		Obj_PlaySE(SE_Decide);
		PauseState="EquipSelect";
		yield;
	}
	if(GetVirtualKeyState(VK_USER1)==KEY_PUSH)
	{
		DisplayType+=1;
		if(DisplayType>=2){DisplayType=0;}
	}

	if(GetVirtualKeyState(VK_USER2)==KEY_PUSH && GetCommonData(EquipArray[PauseSelect-200],["----------"])!=["----------"])
	{
		Obj_PlaySE(SE_Cancel);
		let TempEquip=GetCommonData(EquipArray[PauseSelect-200],["----------"]);
		EquipAll=EquipAll~[TempEquip];
		SetCommonData("Equip_All",EquipAll);
		SetCommonData(EquipArray[PauseSelect-200],["----------"]);
		EquipStatusAdjust;
		yield;
		EquipErase;
		EquipAll=GetCommonData("Equip_All",EquipAll);
	}
}

if(PauseState=="EquipSelect")
{
	if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_FREE)
	{
		if(GetVirtualKeyState(VK_UP)==KEY_PUSH)
		{
		Obj_PlaySE(SE_SelectMove);
		EquipSelect-=1;
		if(EquipSelect<=-1){EquipSelect=length(EquipAll)-1;}
		}
		if(GetVirtualKeyState(VK_DOWN)==KEY_PUSH)
		{
		Obj_PlaySE(SE_SelectMove);
		EquipSelect+=1;
		if(EquipSelect>=length(EquipAll)){EquipSelect=0;}
		}
	}
	else
	{
		if(GetVirtualKeyState(VK_UP)==KEY_PUSH)
		{
		Obj_PlaySE(SE_SelectMove);
		EquipSelect-=8;
	//	if(EquipSelect<=-1){EquipSelect=length(EquipAll)-1;}
		if(EquipSelect<=-1){EquipSelect=-0;}
		}
		if(GetVirtualKeyState(VK_DOWN)==KEY_PUSH)
		{
		Obj_PlaySE(SE_SelectMove);
		EquipSelect+=8;
		if(EquipSelect>=length(EquipAll)){EquipSelect=length(EquipAll)-1;}
		}
	}

	if(GetVirtualKeyState(VK_SHOT)==KEY_PUSH)
	{
		Obj_PlaySE(SE_Decide);
		PauseState="Equip";
		let TempEquip=GetCommonData(EquipArray[PauseSelect-200],"");
		SetCommonData(EquipArray[PauseSelect-200],EquipAll[EquipSelect]);
		EquipAll[EquipSelect]=TempEquip;
		SetCommonData("Equip_All",EquipAll);
		EquipSelect=0;
		ListAdjust=0;

		EquipStatusAdjust;
		yield;
		EquipErase;
		EquipAll=GetCommonData("Equip_All",EquipAll);
		SetCommonData("EquipFlag",GetCommonData("EquipFlag",0)+1);
	}

	if(GetVirtualKeyState(VK_BOMB)==KEY_PUSH)
	{
		Obj_PlaySE(SE_Cancel);
		PauseState="Equip";
		EquipSelect=0;
		ListAdjust=0;
	}

	if(GetVirtualKeyState(VK_USER1)==KEY_PUSH)
	{
		DisplayType+=1;
		if(DisplayType>=2){DisplayType=0;}
	}

//DrawText(GetCommonData("Equip_All",""),280, 80,16,255,[255,128,128]);
}

if(PauseState=="Option")
{
	if(GetVirtualKeyState(VK_UP)==KEY_PUSH)
	{
		Obj_PlaySE(SE_SelectMove);
		PauseSelect-=1;
		if(PauseSelect<=399){PauseSelect=402;}
	}
	if(GetVirtualKeyState(VK_DOWN)==KEY_PUSH)
	{
		Obj_PlaySE(SE_SelectMove);
		PauseSelect+=1;
		if(PauseSelect>=403){PauseSelect=400;}
	}
	if(PauseSelect==400)
	{
	if(GetVirtualKeyState(VK_RIGHT)==KEY_PUSH)
	{
		let TempVol=GetCommonData("BGMVolume",100)+5;
		if(TempVol>100){TempVol=100;}
		SetCommonData("BGMVolume",TempVol);
		Obj_PlaySE(SE_SelectMove);
	}
	if(GetVirtualKeyState(VK_LEFT)==KEY_PUSH)
	{
		let TempVol=GetCommonData("BGMVolume",100)-5;
		if(TempVol<0){TempVol=0;}
		SetCommonData("BGMVolume",TempVol);
		Obj_PlaySE(SE_SelectMove);
	}
	}

	if(PauseSelect==401)
	{
	if(GetVirtualKeyState(VK_RIGHT)==KEY_PUSH)
	{
		let TempVol=GetCommonData("SEVolume",100)+5;
		if(TempVol>100){TempVol=100;}
		SetCommonData("SEVolume",TempVol);
		Obj_PlaySE(SE_SelectMove);
	}
	if(GetVirtualKeyState(VK_LEFT)==KEY_PUSH)
	{
		let TempVol=GetCommonData("SEVolume",100)-5;
		if(TempVol<0){TempVol=0;}
		SetCommonData("SEVolume",TempVol);
		Obj_PlaySE(SE_SelectMove);
	}
	}

	if(GetVirtualKeyState(VK_BOMB)==KEY_PUSH)
	{
		Obj_PlaySE(SE_Cancel);
		PauseState="Title";
		PauseSelect=4;
		EquipSelect=0;
	}

	if(GetVirtualKeyState(VK_SHOT)==KEY_PUSH)
	{
		if(PauseSelect==402)
		{
			Obj_PlaySE(SE_Decide);
			SaveScriptData;
			SetCommonData("SaveFlag",GetCommonData("SaveFlag",0)+1);
			PauseState="Title";
			PauseSelect=4;
			EquipSelect=0;
		}
	}
}
if(PauseSelect==3)
{
	if(GetVirtualKeyState(VK_SHOT)==KEY_PUSH)
	{
	//	SaveScriptData;
	}
}

yield;

}
}

task MainDraw
{

loop
{
	//DrawText(PauseState,120, 12,20,100,[]);

	DrawText("Status",50, 32,20,100,[]);

	DrawText("Skill",125, 32,20,100,[]);
	DrawText("Equip",190, 32,20,100,[]);
	DrawText("Collection",255, 32,20,100,[]);
	DrawText("Option",375, 32,20,100,[]);

	if(PauseState=="Title")
	{

	if(PauseSelect==0)
	{
		DrawText("Status",50, 32,20,255,[]);

		DrawText("魔法力",50, 80,16,255,[]);
		DrawText("シールド回復",50, 110,16,255,[]);
		DrawText("シールド軽減",50, 140,16,255,[]);
		DrawText("符力回復",50, 170,16,255,[]);
		DrawText("符力軽減",50, 200,16,255,[]);
		DrawText("霊力回復",50, 230,16,255,[]);
		DrawText("霊力軽減",50, 260,16,255,[]);
		DrawText("幸運",50, 290,16,255,[]);
		DrawText("クリティカル",50, 320,16,255,[]);

		let MagicPower=GetCommonData("MagicPower",120);
		let ShieldRecover=GetCommonData("ShieldRecover",80);
		let ShieldReduce=GetCommonData("ShieldReduce",80);
		let SpellCardRecover=GetCommonData("SpellCardRecover",60);
		let SpellCardReduce=GetCommonData("SpellCardReduce",120);
		let SpiritRecover=GetCommonData("SpiritRecover",80);
		let SpiritReduce=GetCommonData("SpiritReduce",120);
		let Luck=GetCommonData("Luck",50);
		let Critical=GetCommonData("Critical",40);

		MagicPower+=GetCommonData("Equip_MagicPower",0);
		ShieldRecover+=GetCommonData("Equip_ShieldRecover",0);
		ShieldReduce+=GetCommonData("Equip_ShieldReduce",0);
		SpellCardRecover+=GetCommonData("Equip_SpellCardRecover",0);
		SpellCardReduce+=GetCommonData("Equip_SpellCardReduce",0);
		SpiritRecover+=GetCommonData("Equip_SpiritRecover",0);
		SpiritReduce+=GetCommonData("Equip_SpiritReduce",0);
		Luck+=GetCommonData("Equip_Luck",0);
		Critical+=GetCommonData("Equip_Critical",0);

		DrawText(IntToString(MagicPower),170, 80,16,255,[]);
		DrawText(IntToString(ShieldRecover),170, 110,16,255,[]);
		DrawText(IntToString(ShieldReduce),170, 140,16,255,[]);
		DrawText(IntToString(SpellCardRecover),170, 170,16,255,[]);
		DrawText(IntToString(SpellCardReduce),170, 200,16,255,[]);
		DrawText(IntToString(SpiritRecover),170, 230,16,255,[]);
		DrawText(IntToString(SpiritReduce),170, 260,16,255,[]);
		DrawText(IntToString(Luck),170, 290,16,255,[]);
		DrawText(IntToString(Critical),170, 320,16,255,[]);
/*
		DrawText(IntToString(GetCommonData("MagicPower",120)),170, 80,16,255,[]);
		DrawText(IntToString(GetCommonData("ShieldRecover",80)),170, 110,16,255,[]);
		DrawText(IntToString(GetCommonData("ShieldReduce",80)),170, 140,16,255,[]);
		DrawText(IntToString(GetCommonData("SpellCardRecover",60)),170, 170,16,255,[]);
		DrawText(IntToString(GetCommonData("SpellCardReduce",120)),170, 200,16,255,[]);
		DrawText(IntToString(GetCommonData("SpiritRecover",80)),170, 230,16,255,[]);
		DrawText(IntToString(GetCommonData("SpiritReduce",120)),170, 260,16,255,[]);
		DrawText(IntToString(GetCommonData("Luck",50)),170, 290,16,255,[]);
		DrawText(IntToString(GetCommonData("Critical",40)),170, 320,16,255,[]);
*/
		DrawText("Level",250, 80,16,255,[]);
		DrawText("Exp",250, 110,16,255,[]);
		DrawText("Next",250,140,16,255,[]);

		DrawText("マナ",250, 210,16,255,[]);
		DrawText("円",250,240,16,255,[]);

		DrawText(IntToString(GetCommonData("Level",1)),370, 80,16,255,[]);
		DrawText(IntToString(GetCommonData("Exp",0)),370, 110,16,255,[]);
		DrawText(IntToString(GetCommonData("NextExp",100)),370, 140,16,255,[]);

		DrawText(IntToString(GetCommonData("Mana",0)),370, 210,16,255,[]);
		DrawText(IntToString(GetCommonData("Yen",0)),370,240,16,255,[]);


	//	DrawText("ステージ",50,370,16,255,[]);

		let text;
		text=GetCommonData("StageName","ガレージモード");
		if(GetCommonData("SceneSelect"," ")!=" ")
		{
			loop(2)
			{
				text=text~" ";
			}
			text=text~GetCommonData("ScenePage","");
			if(GetCommonData("SceneSelect","")!="0")
			{
			text=text~" - "~GetCommonData("SceneSelect","");
			}
		}
		DrawText(text,50,370,16,255,[]);
		//DrawInfoText(GetCommonData("Equip2","ミニ八卦路（故障中）"));
	}

	if(PauseSelect==1)
	{
		DrawText("Skill",125, 32,20,255,[]);

		DrawText("ショットキー",50, 80,16,255,[]);
		DrawText("ボムキー",50, 150,16,255,[]);
		DrawText("ユーザーキーその1",50, 220,16,255,[]);
		DrawText("ユーザーキーその2",50, 290,16,255,[]);

		DrawText(GetCommonData("Shot_Key","マジックショット"),70, 110,16,255,[]);
		DrawText(GetCommonData("Bomb_Key","マジックナパーム"),70, 180,16,255,[]);
		DrawText(GetCommonData("User1_Key","魔符｢スターダストレヴァリエ｣"),70, 250,16,255,[]);
		DrawText(GetCommonData("User2_Key","ダッシュ"),70, 320,16,255,[]);
	}

	if(PauseSelect==2)
	{
		DrawText("Equip",190, 32,20,255,[]);

		DrawText("装備品1",50, 80,16,255,[]);
		DrawText("装備品2",50, 150,16,255,[]);
		DrawText("装備品3",50, 220,16,255,[]);
		DrawText("装備品4",50, 290,16,255,[]);

		DrawText(GetCommonData("Equip1","普通の箒")[0],70, 110,16,255,[]);
		DrawText(GetCommonData("Equip2","ミニ八卦路（故障中）")[0],70, 180,16,255,[]);
		DrawText(GetCommonData("Equip3","-----------")[0],70, 250,16,255,[]);
		DrawText(GetCommonData("Equip4","-----------")[0],70, 320,16,255,[]);
	}

	if(PauseSelect==3)
	{
		DrawText("Collection",255, 32,20,255,[]);
	}

	if(PauseSelect==4)
	{
		DrawText("Option",375, 32,20,255,[]);

		DrawText("BGM Volume",50, 80,16,255,[]);
		DrawText("SE Volume",50, 110,16,255,[]);
		DrawText(IntToString(GetCommonData("BGMVolume",100)),170, 80,16,255,[]);
		DrawText(IntToString(GetCommonData("SEVolume",100)),170, 110,16,255,[]);

		DrawText("Save",50, 140,16,255,[]);
	}

	}

	if(PauseState=="Skill" )
	{

		DrawText("Skill",125, 32,20,255,[]);

		DrawText("ショットキー",50, 80,16,255,[]);
		DrawText("ボムキー",50, 150,16,255,[]);
		DrawText("ユーザーキーその1",50, 220,16,255,[]);
		DrawText("ユーザーキーその2",50, 290,16,255,[]);

		if(PauseSelect==100)
		{
			DrawText(GetCommonData("Shot_Key","マジックショット"),70, 110,16,255,[255,128,128]);
			InfoDisplay(GetCommonData("Shot_Key","マジックショット"));
		}
		else
		{
			DrawText(GetCommonData("Shot_Key","マジックショット"),70, 110,16,255,[]);
		}
		if(PauseSelect==101)
		{
			DrawText(GetCommonData("Bomb_Key","マジックナパーム"),70, 180,16,255,[255,128,128]);
			InfoDisplay(GetCommonData("Bomb_Key","マジックショット"));
		}
		else
		{
			DrawText(GetCommonData("Bomb_Key","マジックナパーム"),70, 180,16,255,[]);
		}
		if(PauseSelect==102)
		{
			DrawText(GetCommonData("User1_Key","魔符｢スターダスト｣"),70, 250,16,255,[255,128,128]);
			InfoDisplay(GetCommonData("User1_Key","魔符｢スターダスト｣"));
		}
		else
		{
			DrawText(GetCommonData("User1_Key","魔符｢スターダスト｣"),70, 250,16,255,[]);
		}
		if(PauseSelect==103)
		{
			DrawText(GetCommonData("User2_Key","ダッシュ"),70, 320,16,255,[255,128,128]);
			InfoDisplay(GetCommonData("User2_Key","ダッシュ"));
		}
		else
		{
			DrawText(GetCommonData("User2_Key","ダッシュ"),70, 320,16,255,[]);
		}
	}

	if(PauseState=="SkillSelect")
	{
		DrawText("Skill",125, 32,20,255,[]);

		DrawText("ショットキー",50, 80,16,255,[]);
		DrawText("ボムキー",50, 150,16,255,[]);
		DrawText("ユーザーキーその1",50, 220,16,255,[]);
		DrawText("ユーザーキーその2",50, 290,16,255,[]);

		if(PauseSelect==100)
		{
			DrawText(GetCommonData("Shot_Key","マジックショット"),70, 110,16,255,[255,128,128]);
		}
		else
		{
			DrawText(GetCommonData("Shot_Key","マジックショット"),70, 110,16,255,[]);
		}
		if(PauseSelect==101)
		{
			DrawText(GetCommonData("Bomb_Key","マジックナパーム"),70, 180,16,255,[255,128,128]);
		}
		else
		{
			DrawText(GetCommonData("Bomb_Key","マジックナパーム"),70, 180,16,255,[]);
		}
		if(PauseSelect==102)
		{
			DrawText(GetCommonData("User1_Key","魔符｢スターダスト｣"),70, 250,16,255,[255,128,128]);
		}
		else
		{
			DrawText(GetCommonData("User1_Key","魔符｢スターダスト｣"),70, 250,16,255,[]);
		}
		if(PauseSelect==103)
		{
			DrawText(GetCommonData("User2_Key","ダッシュ"),70, 320,16,255,[255,128,128]);
		}
		else
		{
			DrawText(GetCommonData("User2_Key","ダッシュ"),70, 320,16,255,[]);
		}


		if(SkillTypeSelect==0)
		{
			DrawText("All",270, 80,16,255,[255,255,128]);
		}
		else
		{
			DrawText("All",270, 80,16,100,[]);
		}
		if(SkillTypeSelect==1)
		{
			DrawText("Attack",300, 80,16,255,[255,255,128]);
		}
		else
		{
			DrawText("Attack",300, 80,16,100,[]);
		}
		if(SkillTypeSelect==2)
		{
			DrawText("Assist",360, 80,16,255,[255,255,128]);
		}
		else
		{
			DrawText("Assist",360, 80,16,100,[]);
		}
		if(SkillTypeSelect==3)
		{
			DrawText("Spell",420, 80,16,255,[255,255,128]);
		}
		else
		{
			DrawText("Spell",420, 80,16,100,[]);
		}

		ascent(i in 0..length(SkillTypeArray[SkillTypeSelect]))
		{
		if(i>7){break;}
		if(SkillSelect-ListAdjust>=8)
		{
			ListAdjust+=1;
		}
		if(SkillSelect-ListAdjust<0)
		{
			ListAdjust-=1;
		}

		if(SkillSelect==i+ListAdjust)
		{
			DrawText(SkillTypeArray[SkillTypeSelect][i+ListAdjust],280, 110+30*i,16,255,[255,128,128]);
			DrawInfoText(SkillTypeArray[SkillTypeSelect][i+ListAdjust]);
		}
		else
		{
			DrawText(SkillTypeArray[SkillTypeSelect][i+ListAdjust],280, 110+30*i,16,255,[]);
		}

		}
	}

	if(PauseState=="Equip")
	{
		DrawText("Equip",190, 32,20,255,[]);

		DrawText("装備品1",50, 80,16,255,[]);
		DrawText("装備品2",50, 150,16,255,[]);
		DrawText("装備品3",50, 220,16,255,[]);
		DrawText("装備品4",50, 290,16,255,[]);


		if(PauseSelect==200)
		{
			DrawText(GetCommonData("Equip1","普通の箒")[0],70, 110,16,255,[255,128,128]);
			InfoDisplay(GetCommonData("Equip1","普通の箒"));
		}
		else
		{
			DrawText(GetCommonData("Equip1","普通の箒")[0],70, 110,16,255,[]);
		}
		if(PauseSelect==201)
		{
			DrawText(GetCommonData("Equip2","ミニ八卦路（故障中）")[0],70, 180,16,255,[255,128,128]);
			InfoDisplay(GetCommonData("Equip2","ミニ八卦路（故障中）"));
		}
		else
		{
			DrawText(GetCommonData("Equip2","ミニ八卦路（故障中）")[0],70, 180,16,255,[]);
		}
		if(PauseSelect==202)
		{
			DrawText(GetCommonData("Equip3","----------")[0],70, 250,16,255,[255,128,128]);
			InfoDisplay(GetCommonData("Equip3","----------"));
		}
		else
		{
			DrawText(GetCommonData("Equip3","-----------")[0],70, 250,16,255,[]);
		}
		if(PauseSelect==203)
		{
			DrawText(GetCommonData("Equip4","-----------")[0],70, 320,16,255,[255,128,128]);
			InfoDisplay(GetCommonData("Equip4","-----------"));
		}
		else
		{
			DrawText(GetCommonData("Equip4","-----------")[0],70, 320,16,255,[]);
		}
	}

	if(PauseState=="EquipSelect")
	{
		#include"./player/OnPauseEquipStatusAdjust.txt"

		DrawText("魔法力",50, 80,16,255,[]);
		DrawText("シールド回復",50, 110,16,255,[]);
		DrawText("シールド軽減",50, 140,16,255,[]);
		DrawText("符力回復",50, 170,16,255,[]);
		DrawText("符力軽減",50, 200,16,255,[]);
		DrawText("霊力回復",50, 230,16,255,[]);
		DrawText("霊力軽減",50, 260,16,255,[]);
		DrawText("幸運",50, 290,16,255,[]);
		DrawText("クリティカル",50, 320,16,255,[]);

		let MagicPower=GetCommonData("MagicPower",120);
		let ShieldRecover=GetCommonData("ShieldRecover",80);
		let ShieldReduce=GetCommonData("ShieldReduce",80);
		let SpellCardRecover=GetCommonData("SpellCardRecover",60);
		let SpellCardReduce=GetCommonData("SpellCardReduce",120);
		let SpiritRecover=GetCommonData("SpiritRecover",80);
		let SpiritReduce=GetCommonData("SpiritReduce",120);
		let Luck=GetCommonData("Luck",50);
		let Critical=GetCommonData("Critical",40);

		MagicPower+=GetCommonData("Equip_MagicPower",0);
		ShieldRecover+=GetCommonData("Equip_ShieldRecover",0);
		ShieldReduce+=GetCommonData("Equip_ShieldReduce",0);
		SpellCardRecover+=GetCommonData("Equip_SpellCardRecover",0);
		SpellCardReduce+=GetCommonData("Equip_SpellCardReduce",0);
		SpiritRecover+=GetCommonData("Equip_SpiritRecover",0);
		SpiritReduce+=GetCommonData("Equip_SpiritReduce",0);
		Luck+=GetCommonData("Equip_Luck",0);
		Critical+=GetCommonData("Equip_Critical",0);

		let B_MagicPower=MagicPower;
		let B_ShieldRecover=ShieldRecover;
		let B_ShieldReduce=ShieldReduce;
		let B_SpellCardRecover=SpellCardRecover;
		let B_SpellCardReduce=SpellCardReduce;
		let B_SpiritRecover=SpiritRecover;
		let B_SpiritReduce=SpiritReduce;
		let B_Luck=Luck;
		let B_Critical=Critical;

		StatasChangeDisplay(1,EquipAll[EquipSelect]);
		StatasChangeDisplay(-1,GetCommonData(EquipArray[PauseSelect-200],"普通の箒"));

		DrawText(IntToString(MagicPower),170, 80,16,255,DefineColor(MagicPower-B_MagicPower));
		DrawText(IntToString(ShieldRecover),170, 110,16,255,DefineColor(ShieldRecover-B_ShieldRecover));
		DrawText(IntToString(ShieldReduce),170, 140,16,255,DefineColor(ShieldReduce-B_ShieldReduce));
		DrawText(IntToString(SpellCardRecover),170, 170,16,255,DefineColor(SpellCardRecover-B_SpellCardRecover));
		DrawText(IntToString(SpellCardReduce),170, 200,16,255,DefineColor(SpellCardReduce-B_SpellCardReduce));
		DrawText(IntToString(SpiritRecover),170, 230,16,255,DefineColor(SpiritRecover-B_SpiritRecover));
		DrawText(IntToString(SpiritReduce),170, 260,16,255,DefineColor(SpiritReduce-B_SpiritReduce));
		DrawText(IntToString(Luck),170, 290,16,255,DefineColor(Luck-B_Luck));
		DrawText(IntToString(Critical),170, 320,16,255,DefineColor(Critical-B_Critical));

		ascent(i in 0..length(EquipAll))
		{
		if(i>7){break;}

		if(EquipSelect-ListAdjust>=8)
		{
			ListAdjust+=1;
		}
		if(EquipSelect-ListAdjust<0)
		{
			ListAdjust-=1;
		}
		if(EquipSelect==i+ListAdjust)
		{
			let TempA=EquipAll[i+ListAdjust];
			DrawText(TempA[0],280, 110+30*i,16,255,[255,128,128]);
			InfoDisplay(TempA);
		}
		else
		{
			let TempA=EquipAll[i+ListAdjust];
			DrawText(TempA[0],280, 110+30*i,16,255,[]);
		}


		}

	}

	if(PauseState=="Option")
	{
		DrawText("Option",375, 32,20,255,[]);

		
		
		if(PauseSelect==400)
		{
			DrawText("BGM Volume",50, 80,16,255,[255,128,128]);
			DrawText(IntToString(GetCommonData("BGMVolume",100)),170, 80,16,255,[255,128,128]);
		}
		else
		{
			DrawText("BGM Volume",50, 80,16,255,[]);
			DrawText(IntToString(GetCommonData("BGMVolume",100)),170, 80,16,255,[]);
		}
		if(PauseSelect==401)
		{
			DrawText("SE Volume",50, 110,16,255,[255,128,128]);
			DrawText(IntToString(GetCommonData("SEVolume",100)),170, 110,16,255,[255,128,128]);
		}
		else
		{
			DrawText("SE Volume",50, 110,16,255,[]);
			DrawText(IntToString(GetCommonData("SEVolume",100)),170, 110,16,255,[]);
		}
		if(PauseSelect==402)
		{
			DrawText("Save",50, 140,16,255,[255,128,128]);
		//	DrawText(IntToString(GetCommonData("SEVolume",100)),170, 110,16,255,[255,128,128]);
		}
		else
		{
			DrawText("Save",50, 140,16,255,[]);
		//	DrawText(IntToString(GetCommonData("SEVolume",100)),170, 110,16,255,[]);
		}
}

//DrawText(GetCommonData("Equip_All",[["0"]])[0],70, 350,16,255,[]);
	yield;
}

}


function InfoDisplay(name)
{

if(length(name)>=5)
{
	if(!DisplayType || PauseState=="Skill")
	{
		DrawInfoText(name);
	}
	else
	{
		DrawStatusInfoText(name);
	}
}
else
{
	if(!DisplayType)
	{
		DrawInfoText(name[0]);
	}
	else
	{
		DrawStatusInfoText(name[0]);
		ascent(i in 1..length(name))
		{
			DrawSlotInfoText(name[i],355+i*25);
		}
	}
}

}

}

	task DrawText(let text, let mx, let my,size,alpha,color)
	{
		let obj = ObjText_Create();
		ObjText_SetText(obj, text);
		ObjText_SetFontSize(obj, size);
		ObjText_SetFontBold(obj, true);
		ObjText_SetFontColorTop(obj, 196, 196, 255);
		ObjText_SetFontColorBottom(obj, 128, 128, 255);
		ObjText_SetFontBorderType(obj, BORDER_NONE);
		ObjText_SetFontBorderColor(obj,255, 255, 255);
		ObjText_SetFontBorderWidth(obj, 0);
		Obj_SetRenderPriorityI(obj, 10);
		ObjRender_SetX(obj, mx);
		ObjRender_SetY(obj, my);
		ObjText_SetFontType(obj,"ＭＳ 明朝");

		ObjText_SetMaxWidth(obj,200);

		if(length(text)>=24)
		{
			ObjRender_SetY(obj, my-8);
		}

		if(length(color)!=0)
		{
		ObjText_SetFontColorTop(obj, (color[0]+255)/2, (color[1]+255)/2,(color[2]+255)/2);
		ObjText_SetFontColorBottom(obj, color[0], color[1], color[2]);
		}

	//	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
		ObjRender_SetAlpha(obj,alpha);
		yield;

		Obj_Delete(obj);
	}

	task DrawInfoText(let text)
	{
		text=SetInfo(text);
		let obj = ObjText_Create();
		ObjText_SetText(obj, text);
		ObjText_SetFontSize(obj, 18);
		ObjText_SetFontBold(obj, true);
		ObjText_SetFontColorTop(obj, 196, 196, 255);
		ObjText_SetFontColorBottom(obj, 128, 128, 255);
		ObjText_SetFontBorderType(obj, BORDER_NONE);
		ObjText_SetFontBorderColor(obj,255, 255, 255);
		ObjText_SetFontBorderWidth(obj, 0);
		Obj_SetRenderPriorityI(obj, 10);
		ObjRender_SetX(obj, 50);
		ObjRender_SetY(obj, 360);
		ObjText_SetFontType(obj,"ＭＳ 明朝");

		ObjText_SetMaxWidth(obj,400);

		let NewText=text;

		loop
		{
		let txtL=length(NewText);
		ascent(i in 0..length(NewText)-2)
		{
			if(NewText[i..i+2]=="nn")
			{
				let FText=NewText[0..i];
				let BText=NewText[i+2..length(NewText)];
				NewText=FText;
				if(i<42)
				{
				loop(21-i/2)
				{
					NewText=NewText~"　";
				}
				}
				else if(i<84)
				{
				loop(42-i/2)
				{
					NewText=NewText~"　";
				}
				}

				NewText=NewText~BText;
				break;
			}
		}
		if(txtL==length(NewText)){break;}
		}


		ObjText_SetText(obj, NewText);

	//	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	//	ObjRender_SetAlpha(obj,alpha);
		yield;

		Obj_Delete(obj);
	}

	task DrawStatusInfoText(let text)
	{
		text=SetStatusInfo(text);
		let obj = ObjText_Create();
		ObjText_SetText(obj, text);
		ObjText_SetFontSize(obj, 16);
		ObjText_SetFontBold(obj, true);
		ObjText_SetFontColorTop(obj, 196, 196, 255);
		ObjText_SetFontColorBottom(obj, 128, 128, 255);
		ObjText_SetFontBorderType(obj, BORDER_NONE);
		ObjText_SetFontBorderColor(obj,255, 255, 255);
		ObjText_SetFontBorderWidth(obj, 0);
		Obj_SetRenderPriorityI(obj, 10);
		ObjRender_SetX(obj, 50);
		ObjRender_SetY(obj, 360);
		ObjText_SetFontType(obj,"ＭＳ 明朝");

		ObjText_SetMaxWidth(obj,400);

		let NewText=text;

		loop
		{
		let txtL=length(NewText);
		ascent(i in 0..length(NewText)-2)
		{
			if(NewText[i..i+2]=="nn")
			{
				let FText=NewText[0..i];
				let BText=NewText[i+2..length(NewText)];
				NewText=FText;
				if(i<42)
				{
				loop(21-i/2)
				{
					NewText=NewText~"　";
				}
				}
				else if(i<84)
				{
				loop(42-i/2)
				{
					NewText=NewText~"　";
				}
				}

				NewText=NewText~BText;
				break;
			}
		}
		if(txtL==length(NewText)){break;}
		}


		ObjText_SetText(obj, NewText);

	//	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	//	ObjRender_SetAlpha(obj,alpha);
		yield;

		Obj_Delete(obj);
	}

	task DrawSlotInfoText(let text,y)
	{
		text=SetSlotInfo(text);
		let obj = ObjText_Create();
		ObjText_SetText(obj, text);
		ObjText_SetFontSize(obj, 18);
		ObjText_SetFontBold(obj, true);
		ObjText_SetFontColorTop(obj, 196, 196, 255);
		ObjText_SetFontColorBottom(obj, 128, 128, 255);
		ObjText_SetFontBorderType(obj, BORDER_NONE);
		ObjText_SetFontBorderColor(obj,255, 255, 255);
		ObjText_SetFontBorderWidth(obj, 0);
		Obj_SetRenderPriorityI(obj, 10);
		ObjRender_SetX(obj, 50);
		ObjRender_SetY(obj, y);
		ObjText_SetFontType(obj,"ＭＳ 明朝");

		//ObjText_SetMaxWidth(obj,400);

		let NewText=text;

		loop
		{
		let txtL=length(NewText);
		ascent(i in 0..length(NewText)-2)
		{
			if(NewText[i..i+2]=="nn")
			{
				let FText=NewText[0..i];
				let BText=NewText[i+2..length(NewText)];
				NewText=FText;
				if(i<42)
				{
				loop(21-i/2)
				{
					NewText=NewText~"　";
				}
				}
				else if(i<84)
				{
				loop(42-i/2)
				{
					NewText=NewText~"　";
				}
				}

				NewText=NewText~BText;
				break;
			}
		}
		if(txtL==length(NewText)){break;}
		}


		ObjText_SetText(obj, NewText);

	//	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	//	ObjRender_SetAlpha(obj,alpha);
		yield;

		Obj_Delete(obj);
	}



task Obj_PlaySE(path)
{
	let obj = ObjSound_Create;
	ObjSound_Load(obj,path);
	ObjSound_SetSoundDivision(obj,SOUND_SE);
	ObjSound_SetLoopEnable(obj,false);
	ObjSound_Play(obj);

	ObjSound_SetVolumeRate(obj,GetCommonData("SEVolume",100));
}

task Obj_PlayBGM(path)
{
	let obj = GetCommonData("Obj_BGM",ObjSound_Create);
	ObjSound_Load(obj,path);
	ObjSound_SetSoundDivision(obj,SOUND_BGM);
	ObjSound_SetLoopEnable(obj,true);
	ObjSound_Play(obj);

	ObjSound_SetVolumeRate(obj,GetCommonData("BGMVolume",100));
}



function EquipErase
{
if(length(GetCommonData("Equip_All",[["0"]]))>=2)
{
ascent(i in 0..length(GetCommonData("Equip_All",[["0"]])))
{
	if(GetCommonData("Equip_All",[["0"]])[i]==["----------"])
	{
		let temp=GetCommonData("Equip_All",[["0"]]);
		temp=erase(temp,i);
		SetCommonData("Equip_All",temp);
		return;
	}
}
}

}


