;A^bN
@operation
spset "operation",894
sp "operation:table",{name="img\panel\operation_table.png",a=255,x=1265,y=177,z=2}
%weak=""
if critical==2 then %weak="_w"
sp "operation:lv",{name="img\panel\operation_lv_"+str(atk)+%weak+".png",a=255,x=1370,y=44,z=2}
if charge>0 then
	if charge==1 then
		%x_n=1457
		%x_b=1513
	elseif charge>=2 and charge<=9 then
		%x_n=1476
		%x_b=1530
	elseif charge>=10 and charge<=19 then
		%x_n=1489
		%x_b=1545
	elseif charge>=20 and charge<=99 then
		%x_n=1508
		%x_b=1562
	endif
	sp "operation:charge_brackets_0",{name="img\panel\operation_charge_0.png",a=255,x=1463,y=104,z=0}
	sp "operation:charge_brackets_1",{name="img\panel\operation_charge_1.png",a=255,x=%x_b,y=109,z=0}
	if charge>=10 then sp "operation:charge_num_2",{name="img\panel\num_s_w_"+str(floor(charge/10))+".png",a=255,x=%x_n,y=115,z=0}
	sp "operation:charge_num_1",{name="img\panel\num_s_w_"+str(charge mod 10)+".png",a=255,x=%x_n+32,y=115,z=0}
endif
character_mask

;A^bNݒǍ
gosub @operationdef

;{^`
for %i=1 to 6
	if operation_caption[%i]<>"" then
		%x=zlen(operation_caption[%i])-1
		if atk+charge>=%i or %i==6 then
			%a=255
			sp "operation:label"+str(%i),{name="?"+operation_caption[%i]+",operation",a=%a,x=1409-11*%x,y=137+112*%i,z=0}
			sp "operation:"+str(%i),{name={"img\panel\operation_btn_"+str(%i)+".png","img\panel\operation_btn_"+str(%i)+"_on.png"},a=%a,x=1267,y=95+112*%i,z=1}
		else
			%a=60
			sp "operation:label"+str(%i),{name="?"+operation_caption[%i]+",operation",a=%a,x=1409-11*%x,y=137+112*%i,z=0}
			sp "operation:"+str(%i),{name="img\panel\operation_btn_"+str(%i)+".png",a=%a,x=1267,y=95+112*%i,z=1}
		endif
		if %i<6 then
			if operation_pass[num(mid(operation_order[%i],1,2))][num(mid(operation_order[%i],4,1))]==0 then sp "operation:new"+str(%i),{name="img\panel\operation_new.png",a=%a,x=1522,y=139+112*%i,z=1}
			if _operation_pass[stage][num(mid(operation_order[%i],1,2))][num(mid(operation_order[%i],4,1))]==1 then sp "operation:unlock"+str(%i),{name="img\panel\operation_unlock.png",a=%a,x=1551,y=183+112*%i,z=1}
		endif
	endif
next

print #u,500,"img\rule_06.png"

;}jA|bvAbvU
if _manualpopup==1 and _manualpopup[6]==0 then system_2_popup 6

;{^`
@operation_btndef
for %i=1 to 6
	if operation_caption[%i]<>"" then
		if atk+charge>=%i or %i==6 then btn "operation:"+str(%i)
	endif
next

;{^
@operation_btnexec
btnid="operation"
btnexec btn_operation,"operation",{func=1}
if mid(btn_operation,0,2)=="#F" then goto "@func_"+mid(btn_operation,2,2)
if btn_operation=="" or btn_operation==#r then goto @operation_btnexec
btnclear "operation"
se1 "001"
spsetdelete "operation"
print #c
spdelete "character:mask"
if btn_operation=="6" then
	charge=charge+atk
	if charge>99 then charge=99
	print #u,500,"img\rule_06.png"
else
	charge=charge+atk-num(btn_operation)
	event "operation","operation_"+operation_order[num(btn_operation)]
	;`tO
	pict_diff
	;ʉ߃tO
	if operation_pass[num(mid(operation_order[num(btn_operation)],1,2))][num(right(operation_order[num(btn_operation)],1))]==0 then
		operation_pass[num(mid(operation_order[num(btn_operation)],1,2))][num(right(operation_order[num(btn_operation)],1))]=1
	endif
	;JtO
	if _operation_pass[stage][num(mid(operation_order[num(btn_operation)],1,2))][num(right(operation_order[num(btn_operation)],1))]==0 then
		_operation_pass[stage][num(mid(operation_order[num(btn_operation)],1,2))][num(right(operation_order[num(btn_operation)],1))]=1
	endif
	;JtOiʊJj
	gosub "@operationpass_"+stdp
	;I[KY
	if orgnum>0 then
		%orgnum=2+orgnum
		if %orgnum>10 then %orgnum=10
	else
		%orgnum=0
	endif
	orgasm_update 0,orgmag+num(btn_operation)*5+%orgnum
	character_body
	spsetdelete "event"
	print #u,1000,"img\rule_06.png"
endif
return

;`tO
@pict_diff
if diff_order[num(btn_operation)]<>"" and diff_order[num(btn_operation)]<>diff and diff<>"_a_b" then
	if diff<>"" then diff="_a_b"
	if diff=="" then diff=diff_order[num(btn_operation)]
endif
return

;ʉ߃tO
@operation_pass_format
param %flag
for %depth=1 to 11
	for %lv=1 to 5
		operation_pass[%depth][%lv]=%flag
	next
next
return

;ʉ߃tOC
@operation_pass_fix
param %ope1,%ope2,%ope3
%s=mid(%ope1,0,1)
%ope1_stage=num(%s)
%s=mid(%ope1,1,2)
%ope1_depth=num(%s)
%s=mid(%ope1,4,1)
%ope1_select=num(%s)
%s=mid(%ope2,0,1)
%ope2_stage=num(%s)
%s=mid(%ope2,1,2)
%ope2_depth=num(%s)
%s=mid(%ope2,4,1)
%ope2_select=num(%s)
%s=mid(%ope3,0,1)
if %ope3=="" then
	if operation_pass[%ope1_depth][%ope1_select]==0 and operation_pass[%ope2_depth][%ope2_select]==1 then operation_pass[%ope1_depth][%ope1_select]=1
	if _operation_pass[%ope1_stage][%ope1_depth][%ope1_select]==0 and _operation_pass[%ope2_stage][%ope2_depth][%ope2_select]==1 then _operation_pass[%ope1_stage][%ope1_depth][%ope1_select]=1
else
	%ope3_stage=num(%s)
	%s=mid(%ope3,1,2)
	%ope3_depth=num(%s)
	%s=mid(%ope3,4,1)
	%ope3_select=num(%s)
	if operation_pass[%ope1_depth][%ope1_select]==0 and operation_pass[%ope2_depth][%ope2_select]==1 and operation_pass[%ope3_depth][%ope3_select]==1 then operation_pass[%ope1_depth][%ope1_select]=1
	if _operation_pass[%ope1_stage][%ope1_depth][%ope1_select]==0 and _operation_pass[%ope3_stage][%ope3_depth][%ope3_select]==1 then _operation_pass[%ope1_stage][%ope1_depth][%ope1_select]=1
endif
return
