;z[h
@log
pageid="log"
playback=0
playback_skip=0
playback_auto=0
stage=1
st=str(stage)
depth=1
select=0
btn_operation="1"
org=0
orgnum=0
orgmode=0
diff=""
operation_pass_format 1
backlog_format
stage_spset
system_menu
se2 "921",0
btn_log=""
bgmchange=1
bgmfix=0
gosub @log_reload
print #u,1000,"img\rule_00.png"
gosub "@bgmdef_"+stdp

;{^`
@log_btndef
system_btndef
btn "command:body"
btn "command:avan"
if orgmag>-1 then btn "command:org"
btn "command:eve"
for %i=1 to 5
	if operation_caption[%i]<>"" and _operation_pass[stage][depth][%i]==1 then
		btn "command:opa"+str(%i)
	endif
next
for %i=1 to 5
	if _mode==0 and %i>1 then exit
	%s=str(%i)
	zeropad 2,%s
	if _operation_pass[%i][1][0]==1 and %i<>stage then
		btn "command:sta"+%s
	endif
next
for %i=1 to 5
	if _mode==0 and %i>1 then exit
	%s=str(%i)
	zeropad 2,%s
	if _operation_pass[%i][1][0]==1 and %i<>bgmchange then
		btn "command:bgm"+%s
	endif
next
if _mode==1 and _operation_pass[5][10][0]==1 and bgmchange<>6 then
	btn "command:bgm06"
endif
if _operation_pass[1][11][0]==1 and bgmchange<>7 then
	btn "command:bgm07"
endif
btn "command:fix"
for %i=1 to 11
	%s=str(%i)
	zeropad 2,%s
	if _operation_pass[stage][%i][0]==1 and %i<>depth then
		btn "command:dep"+%s
	endif
next
for %i=1 to 3
	btn "command:play"+str(%i)
next

;{^
@log_btnexec
btnid="log"
btnexec btn_log,"command",{func=1}
if mid(btn_log,0,2)=="#F" then goto "@func_"+mid(btn_log,2,2)
if btn_log=="" then goto @log_btnexec
btnclear "command"

;VXe
if btn_log==#r then btn_log="sys4"
if mid(btn_log,0,3)=="sys" then system 0,num(mid(btn_log,3,1))

;L\
if btn_log=="body" then goto @log_body

;vCobN
if mid(btn_log,0,4)=="play" then
	se1 "001"
	spset "event",892
	sp "event:mask",{name="*#000000",a=230,x=0,y=0,z=2}
	playback=num(mid(btn_log,4,1))
	backlog_format
	btn_log=""
	for %stage=1 to 5
		%skip=0
		if _operation_pass[%stage][1][0]==0 then %skip=1
		if playback_skip==1 then %skip=1
		%flag=0
		if %skip==0 and playback==1 then
			%flag=1
			stage=%stage
		elseif %skip==0 and playback>=2 and %stage==stage then
			%flag=1
		endif
		if %flag==1 then
			playback_end=0
			diff=""
			if playback<=2 then
				bgmfade 1000
				depth=1
				event "avan","avan_"+str(stage)
				spdelete "event:pict"
				if playback_skip==2 then playback_skip=0
			endif
			for %depth=1 to 11
				%skip=0
				if %stage>0 then
					if _operation_pass[%stage][%depth][0]==0 then %skip=1
				endif
				if playback_skip==3 then %stage=%stage-1:stage=stage-1:%depth=11:depth=11:playback_skip=0
				if playback_skip==5 then %stage=stage-2:playback_skip=4
				if playback_skip==6 then %depth=11:depth=11:playback_skip=0
				if playback_skip==1 or playback_skip==4 then %skip=1
				%flag=0
				if %skip==0 and playback<=2 then
					%flag=1
					depth=%depth
				elseif %skip==0 and playback==3 and %depth==depth then
					%flag=1
				endif
				if %flag==1 then
					playback_end=0
					if depth==11 then
						if playback==1 then
							if stage==5 then
								playback_end=1
							else
								if _operation_pass[stage+1][1][0]==0 then playback_end=1
							endif
						endif
						if playback==2 then playback_end=1
						bgmfade 1000
						depth=10
						gosub @log_reload
						pict_order=stdp
						if diff<>"" and filechk("img\log\"+pict_order+diff+".png")==1 then pict_order=pict_order+diff
						sp "event:pict",{name="img\log\"+pict_order+".png",a=255,x=0,y=0,z=0}
						print #u,1000,"img\rule_06.png"
						trans_stdp
						gosub "@depthdef_"+str(stage)+"10"
						depth=11
						spsetvisible "orgasm",1
						print #f,300
						orgasm_update 1,100-org
						wait 1000
					endif
					trans_stdp
					gosub "@bgmdef_"+stdp
					if depth<11 then
						if playback==1 or playback==2 then
							if _operation_pass[stage][depth+1][0]==0 then playback_end=1
						endif
						eventse
						pict_order=stdp
						if diff<>"" and filechk("img\log\"+pict_order+diff+".png")==1 then pict_order=pict_order+diff
						sp "event:pict",{name="img\log\"+pict_order+".png",a=255,x=0,y=0,z=0}
						gosub @log_reload
						print #u,1000,"img\rule_06.png"
						wait 500
					endif
					select=0
					gosub @log_reload
					event "event","event_"+stdp
					spdelete "event:pict"
					%flag=1
					if depth==11 and orgmag==-1 then
						%flag=0
						if playback==1 and playback_end==0 then print #u,1000,"img\rule_06.png"
					endif
					if playback_skip==3 and depth==1 then %stage=stage-1:playback_skip=4
					if playback_skip==3 and depth>=2 then %depth=depth-2:playback_skip=2
					if playback_skip==5 then %stage=stage-2:playback_skip=4
					if playback_skip==6 then %depth=10:depth=10:playback_skip=2
					if playback_skip==1 or playback_skip==2 or playback_skip==4 then %flag=0
					if %flag==1 then
						gosub @operationdef
						for select=1 to 5
							%skip=0
							if %stage>0 and %depth>0 then
								if _operation_pass[%stage][%depth][select]==0 then %skip=1
							endif
							if operation_caption[select]=="" then %skip=1
							if playback_skip==3 and depth==1 then %stage=stage-1:playback_skip=4
							if playback_skip==3 and depth>=2 then %depth=depth-2:playback_skip=2
							if playback_skip==5 then %stage=stage-2:playback_skip=4
							if playback_skip==6 then %depth=10:depth=10:playback_skip=2
							if playback_skip==1 or playback_skip==2 or playback_skip==4 then %skip=1
							operation_order[select]=""
							if %skip==0 then
								print #u,1000,"img\rule_06.png"
								btn_operation=str(select)
								gosub @log_reload
								event "operation","operation_"+operation_order[select]
								pict_diff
								if playback_skip==0 and orgmag>-1 then
									spsetvisible "orgasm",1
									print #f,300
									orgasm_update 0,orgmag+select*5
									spsetvisible "orgasm",0
									print #f,300
								endif
								spdelete "event:pict"
								%flag=1
								if playback_skip>=1 then %flag=0
								%end=0
								if playback==1 and %stage==5 and %depth==11 then %end=1
								if playback==2 and %depth==11 then %end=1
								if playback==3 then %end=1
								if %end==1 and select<=4 then
									if _operation_pass[%stage][%depth][select+1]==0 then %flag=0
									if operation_caption[select+1]=="" then %flag=0
								endif
								if %end==1 and select==5 then %flag=0
								if %flag==1 then print #u,1000,"img\rule_06.png"
							endif
						next
					endif
					if playback_skip==2 then playback_skip=0
				endif
			next
		endif
		if playback_skip==4 then playback_skip=0
	next
	spsetdelete "event"
	playback=0
	playback_skip=0
	playback_auto=0
	spsetvisible "orgasm",1
	gosub @log_reload
	if bgmnum=="" then gosub "@bgmdef_"+stdp
	print #u,1000,"img\rule_06.png"
endif

;Ao
if btn_log=="avan" then
	spsetvisible "orgasm",0
	event "avan","avan_"+st
	spsetdelete "event"
	spsetvisible "orgasm",1
	print #u,1000,"img\rule_06.png"
endif

;I[KY
if btn_log=="org" then
	se1 "013"
	trans_stdp
	orgasm_update 0,100-org
	spsetdelete "event"
	print #u,1000,"img\rule_06.png"
endif

;Cxg
if btn_log=="eve" then
	se1 "001"
	spcell "command:eve",1
	print #c
	trans_stdp
	event "event","event_"+stdp
	spsetdelete "event"
	spcell "command:eve",0
	print #u,1000,"img\rule_06.png"
endif

;A^bN
if mid(btn_log,0,3)=="opa" then
	se1 "001"
	btn_operation=mid(btn_log,3,1)
	event "operation","operation_"+operation_order[num(btn_operation)]
	pict_diff
	if depth==11 then gosub "@depthdef_"+stdp
	if orgmag>-1 then orgasm_update 0,orgmag+num(mid(btn_log,3,1))*5
	if depth<11 then character_body
	spsetdelete "event"
	print #u,1000,"img\rule_06.png"
endif

;rs`fdύX
if mid(btn_log,0,3)=="sta" then
	se1 "013"
	stage=num(mid(btn_log,3,2))
	st=str(stage)
	depth=1
	org=0
	orgnum=0
	selpstopall
	if bgmfix==0 then
		trans_stdp
		gosub "@bgmdef_"+stdp
	endif
	diff=""
	btn_operation="1"
	gosub @log_reload
	print #u,1000,"img\rule_06.png"
endif

;aflύX
if mid(btn_log,0,3)=="bgm" then
	se1 "013"
	bgmfix=1
	bgmchange=num(mid(btn_log,3,2))
	if bgmchange<=5 then
		gosub "@bgmdef_"+str(bgmchange)+"01"
	elseif bgmchange==6 then
		gosub @bgmdef_510
	elseif bgmchange==7 then
		gosub @bgmdef_111
	endif
	gosub @log_reload
endif

;aflŒ
if btn_log=="fix" then
	se1 "013"
	if bgmfix==0 then
		bgmfix=1
	elseif bgmfix==1 then
		bgmfix=0
	endif
	gosub @log_reload
endif

;cdosgύX
if mid(btn_log,0,3)=="dep" then
	se1 "013"
	depth=num(mid(btn_log,3,2))
	selpstopall
	if bgmfix==0 then
		trans_stdp
		gosub "@bgmdef_"+stdp
	endif
	eventse
	btn_operation="1"
	gosub @log_reload
	print #u,1000,"img\rule_06.png"
endif

goto @log_btndef

;L\
@log_body
se1 "013"
spsetvisible "caption",0
spvisible "command:org",0
spsetvisible "orgasm",0
spset "event",892
sp "event:mask",{name="*960,1080,#000000",a=230,x=960,y=0,z=2}
pagemax=0
line=0
batch=1
gosub "@event_"+stdp
print #c
@log_body_btnexec
btnid="log_body"
sp "event:btn1",{name={"img\panel\event_1.png","img\panel\event_1_on.png"},a=255,x=1860,y=946,z=0}
btn "event:btn1"
btnexec btn_log_body,"event",{func=1}
if mid(btn_log_body,0,2)=="#F" then goto "@func_"+mid(btn_log_body,2,2)
btnclear "event"
if btn_log_body=="btn1" then
	gosub @shot
	goto @log_body_btnexec
endif
spsetvisible "caption",1
spvisible "command:org",1
spsetvisible "orgasm",1
spsetdelete "event"
goto @log_btndef

;[h
@log_reload
st=str(stage)
trans_stdp
gosub "@depthdef_"+stdp
caption_stage
state_depth
if bgmnum=="407" then bgmchange=1
if bgmnum=="408" then bgmchange=2
if bgmnum=="409" then bgmchange=3
if bgmnum=="410" then bgmchange=4
if bgmnum=="411" then bgmchange=5
if bgmnum=="801" then bgmchange=6
if bgmnum=="214" then bgmchange=7
sp "orgasm:table",{name="img\panel\orgasm_table.png",a=255,x=28,y=995,z=1}
orgasm org
orgasm_orgnum
if orgmag>-1 then
	sp "command:body",{name={"*960,1080,#00000000","img\panel\log_btn0_00_on.png"},a=255,x=0,y=0,z=1}
else
	sp "command:body",{name={"*960,1080,#00000000","img\panel\log_btn0_00e_on.png"},a=255,x=0,y=0,z=1}
endif
sp "command:avan",{name={"*940,116,#00000000","img\panel\log_btn0_01_on.png"},a=255,x=10,y=10,z=0}
sp "command:org",{name={"*940,90,#00000000","img\panel\log_btn0_02_on.png"},a=255,x=10,y=980,z=0}
sp "command:face",{name="img\log\event_"+stdp+".png",a=255,cx=1582,cy=541,xs=0.5,ys=0.5,rot=0,z=2}
sp "command:blend",{name="img\panel\log_blend.png",a=128,x=1342,y=271,z=1,blend=1}
if playback>0 and select==0 then
	sp "command:eve",{name="img\panel\log_btn0_03_on.png",a=255,x=1339,y=268,z=0}
else
	sp "command:eve",{name={"*486,546,#00000000","img\panel\log_btn0_03_on.png"},a=255,x=1339,y=268,z=0}
endif
spdeletes "command:label"
spdeletes "command:opa"
spdeletes "command:lock"
for %i=1 to 5
	operation_caption[%i]=""
	diff_order[%i]=""
	operation_order[%i]=stdp+"_"+str(%i)
	gosub "@operationdef_"+stdp
	if operation_caption[%i]<>"" and _operation_pass[stage][depth][%i]==1 then
		%x=zlen(operation_caption[%i])-1
		sp "command:label"+str(%i),{name="?"+operation_caption[%i]+",operation",a=255,x=1142-11*%x,y=193+112*%i,z=0}
		if playback>0 and %i==select then
			sp "command:opa"+str(%i),{name="img\panel\operation_btn_"+str(%i)+"_on.png",a=255,x=1000,y=151+112*%i,z=1}
		else
			sp "command:opa"+str(%i),{name={"img\panel\operation_btn_"+str(%i)+".png","img\panel\operation_btn_"+str(%i)+"_on.png"},a=255,x=1000,y=151+112*%i,z=1}
		endif
	elseif operation_caption[%i]<>"" and _operation_pass[stage][depth][%i]==0 then
		%x=zlen(operation_caption[%i])-1
		sp "command:label"+str(%i),{name="?"+operation_caption[%i]+",operation",a=60,x=1142-11*%x,y=193+112*%i,z=0}
		sp "command:opa"+str(%i),{name="img\panel\operation_btn_"+str(%i)+".png",a=60,x=1000,y=151+112*%i,z=1}
		sp "command:lock"+str(%i),{name="img\panel\operation_lock.png",a=255,x=1248,y=187+112*%i,z=0}
	endif
next
for %i=1 to 5
	if _mode==1 then
		%flag=1
	elseif _mode==0 and %i==1 then
		%flag=1
	else
		%flag=0
	endif
	%s=str(%i)
	zeropad 2,%s
	if %flag==1 and _operation_pass[%i][1][0]==1 and %i<>stage then
		sp "command:sta"+%s,{name={"img\panel\log_btn1_"+%s+".png","img\panel\log_btn1_"+%s+"_on.png"},a=255,x=892+84*%i,y=887,z=0}
	elseif _operation_pass[%i][1][0]==1 and %i==stage then
		sp "command:sta"+%s,{name="img\panel\log_btn1_"+%s+"_on.png",a=255,x=892+84*%i,y=887,z=0}
	else
		sp "command:sta"+%s,{name="img\panel\log_btn1_lock.png",a=255,x=892+84*%i,y=887,z=0}
	endif
next
for %i=1 to 5
	if _mode==1 then
		%flag=1
	elseif _mode==0 and %i==1 then
		%flag=1
	else
		%flag=0
	endif
	%s=str(%i)
	zeropad 2,%s
	if %flag==1 and _operation_pass[%i][1][0]==1 and %i<>bgmchange then
		sp "command:bgm"+%s,{name={"img\panel\log_btn2_"+%s+".png","img\panel\log_btn2_"+%s+"_on.png"},a=255,x=1340+70*%i,y=887,z=0}
	elseif _operation_pass[%i][1][0]==1 and %i==bgmchange then
		sp "command:bgm"+%s,{name="img\panel\log_btn2_"+%s+"_on.png",a=255,x=1340+70*%i,y=887,z=0}
	else
		sp "command:bgm"+%s,{name="img\panel\log_btn2_lock.png",a=255,x=1340+70*%i,y=887,z=0}
	endif
next
if _mode==1 and _operation_pass[5][10][0]==1 and bgmchange<>6 then
	sp "command:bgm06",{name={"img\panel\log_btn2_06.png","img\panel\log_btn2_06_on.png"},a=255,x=1340+70*6,y=887,z=0}
elseif _operation_pass[5][10][0]==1 and bgmchange==6 then
	sp "command:bgm06",{name="img\panel\log_btn2_06_on.png",a=255,x=1340+70*6,y=887,z=0}
else
	sp "command:bgm06",{name="img\panel\log_btn2_lock.png",a=255,x=1340+70*6,y=887,z=0}
endif
if _operation_pass[1][11][0]==1 and bgmchange<>7 then
	sp "command:bgm07",{name={"img\panel\log_btn2_07.png","img\panel\log_btn2_07_on.png"},a=255,x=1340+70*7,y=887,z=0}
elseif _operation_pass[1][11][0]==1 and bgmchange==7 then
	sp "command:bgm07",{name="img\panel\log_btn2_07_on.png",a=255,x=1340+70*7,y=887,z=0}
else
	sp "command:bgm07",{name="img\panel\log_btn2_lock.png",a=255,x=1340+70*7,y=887,z=0}
endif
sp "command:fix",{name={"img\panel\log_btn2_fix_"+str(bgmfix)+".png","img\panel\log_btn2_fix_"+str(bgmfix)+"_on.png"},a=255,x=1468,y=858,z=1}
for %i=1 to 11
	%s=str(%i)
	zeropad 2,%s
	if _operation_pass[stage][%i][0]==1 and %i<>depth then
		sp "command:dep"+%s,{name={"img\panel\log_btn1_"+%s+".png","img\panel\log_btn1_"+%s+"_on.png"},a=255,x=892+84*%i,y=992,z=0}
	elseif _operation_pass[stage][%i][0]==1 and %i==depth then
		sp "command:dep"+%s,{name="img\panel\log_btn1_"+%s+"_on.png",a=255,x=892+84*%i,y=992,z=0}
	else
		sp "command:dep"+%s,{name="img\panel\log_btn1_lock.png",a=255,x=892+84*%i,y=992,z=0}
	endif
next
for %i=1 to 3
	if playback>0 and %i==playback then
		sp "command:play"+str(%i),{name="img\panel\log_btn3_"+str(%i)+"_on.png",a=255,x=1339,y=-5+55*%i,z=0}
	else
		sp "command:play"+str(%i),{name={"img\panel\log_btn3_"+str(%i)+".png","img\panel\log_btn3_"+str(%i)+"_on.png"},a=255,x=1339,y=-5+55*%i,z=0}
	endif
next
if btn_log<>"" then print #c
if depth<11 then
	character_body
else
	sp "character:body",{name="img\log\event_"+str(stage)+"11.png",a=255,x=0,y=0,z=0}
endif
sp "bg:bg",{name="img\panel\log_"+st+".png",a=255,x=0,y=0,z=0}
return
