;------------------------------------------------------------
; VXeTv(ADV`)
;------------------------------------------------------------
; 00.txt̓VXeLqɎgĂ܂BQ[{҂01.txt珑ĂĂB
; ł邾̂񋟂邽߂ɁA@\͊čŏɂĂ܂B
; XvCg摜ɓւĂ݂AGAj[V߂[A
; VXe@\ǉAbgv@\Ă݂A낢Ă݂ĂB


@start
gosub @system_initialize ; ݒ
goto @scenario_start ; [U[XNvg̎s

;-------------------------------
; EBhEǂݍ݁i800~600j
;-------------------------------
@load_window
spset "window",100
spsetvisible "window",0 ; [U[window߂g\s܂ł͔\ɂĂB

;if novelmode==0 then sp "window:bg",{name="*800,200,#BB111144",x=0,y=350,z=1000}      ; EBhEwii`cuj
;if novelmode==0 then sp "window:name",{name="*160,35,#BB111144",x=0,y=300,z=1000}     ; O̔wii`cuj
if novelmode==0 then sp "window:bg",{name="bg\textw\03_textw.png",x=0,y=0,z=1000}      ; EBhEwii`cuj
if novelmode==0 then sp "window:text",{name="*960,200,#00000000",x=300-50,y=410+40+70,z=900}     ; eLXgpi`cuj
;OtBbNpɈʒûȂ̂ŁAKXxy̏CĂ
;if novelmode==0 then sp "window:text",{name="*960,200,#00000000",x=300-50,y=410+40+70,z=900}     ; eLXgpi`cuj

;if novelmode==1 then sp "window:bg",{name="*#BB111144",x=0,y=0,z=1000}      ; EBhEwiimxj
if novelmode==1 then sp "window:bg",{name="bg\textw\03_textwn.png",x=0,y=0,z=1000}      ; EBhEwiimxj
if novelmode==1 then sp "window:text",{name="*#00000000",x=300-50,y=50,z=900}     ; eLXgpimxj

;`cuEmxʂɂ̂łƂ肠ɕׂĒuĂ܂B
sp "window:erase", {name={"?[ERASE ],sysfont0","?[ERASE ],sysfont1"},x=50+100*0,y=520,z=100};
sp "window:skip",  {name={"?[SKIP  ],sysfont0","?[SKIP  ],sysfont1"},x=50+100*1,y=520,z=100};
sp "window:auto",  {name={"?[AUTO  ],sysfont0","?[AUTO  ],sysfont1"},x=50+100*2,y=520,z=100};
sp "window:save",  {name={"?[SAVE  ],sysfont0","?[SAVE  ],sysfont1"},x=50+100*3,y=520,z=100};
sp "window:load",  {name={"?[LOAD  ],sysfont0","?[LOAD  ],sysfont1"},x=50+100*4,y=520,z=100};
sp "window:log",   {name={"?[LOG   ],sysfont0","?[LOG   ],sysfont1"},x=50+100*5,y=520,z=100};
sp "window:config",{name={"?[CONFIG],sysfont0","?[CONFIG],sysfont1"},x=50+100*6,y=520,z=100};
gosub @sin_btn	;201601ǉE摜{^̒ǉ
return

;-------------------------------
; \
;-------------------------------
@text
param %tag,%text

if tchk()==0 and _already==1 and getskip()==1 then skip 0	;20170914ǃXLbv~ł
spsetvisible "window",1 ; EBhE\Ȃ\ԂɂB

;20190316\ŕϐgꍇ̃eXg
;%textɁOcc邩ׂB́͑̕łBtext_name[1]ύXRłBA[Jϐ͎gȂB
%text=replace(%text,"O",text_name[1])
%text=replace(%text,"G̖O",text_name[2])
%text=replace(%text,"_[W",text_name[3])
%text=replace(%text,"_[WQ",text_name[4])
%text=replace(%text,"ACeP",text_name[5])

save_text=%text ;20200517Z[u̕ƂĎ擾irgꍇ͏ƁIj
				;20231109mxȊOŕ͂𓾂Ȃꍇ̓RgAEgƃV[Ԃ̂ݕc

;mx[hPȂA
if novelmode==1 then
;mx`Ȃ̂ŖO^O͎gȂ̂Ƃđz肵Ă܂B{CXƉ߂܂B

;20190923NbN҂
spdelete "window:cur":print #C

if %tag=="" then
	voiceplay "" ;{CX~߂
else
	if getskip()<>1 then
		voiceplay "voice\"+%tag+".ogg" ;XLbvȊO̓{CXĐ
		;CTRL̓{CX炷悤ɍ邱ƂɂĂ܂i{CXt@C`FbNɕ֗Ȃ̂ŁjB
	end if
end if
spputtext "window:text",0,%text,{font="text",wait=(6-_textspeed)*10,x=24,y=45,w=17,h=17},{font="ruby"}
return


;ȊOȂ
else



split %tag,"/",%name,%voice ; ^O𖼑Oƃ{CXɕ
if %name=="" then
	spdelete "window:nametext" ; O^ÕeLXg
else
	;20190316Ȃ܂ɂAifŕύX
	if %name=="Ȃ܂" then %name=text_name[1000]
	sp "window:nametext",{name="?"+%name+",text",x=250,y=370+40+70,z=900} ; O^ÕeLXg[h
save_text=%name+%text ;20200517Z[u̕ƂĎ擾irgꍇ͏ƁIj
;OtBbNpɒ̂łBl͓KXCĂ
;	sp "window:nametext",{name="?"+%name+",text",x=300,y=370+40,z=900} ; O^ÕeLXg[h
end if
if %voice=="" then
	voiceplay "" ;{CX~߂
else
	if getskip()<>1 then
		voiceplay "voice\"+%voice+".ogg" ;XLbvȊO̓{CXĐ
		;CTRL̓{CX炷悤ɍ邱ƂɂĂ܂i{CXt@C`FbNɕ֗Ȃ̂ŁjB
	end if
end if
spputtext "window:text",0,%text,{font="text",wait=(6-_textspeed)*10,w=20,h=4},{font="ruby"}
;OtBbNpɐlύX
;spputtext "window:text",0,%text,{font="text",wait=(6-_textspeed)*10,w=19,h=4},{font="ruby"}
return

;
endif
@textb

;mx[hPȂA
if novelmode==1 then
param %c_x,%c_y,%newpage
; %c_x%c_y̓eLXg̃J[\ʒuB
; mx[hȂ̂ŁAOԖڂ̃p[^܂B%newpagéAy[W҂Ȃ1AłȂȂ0łB
;20170730eLXgpimxĵAWeLXgJ[\ʒuɒǉ܂BiĂ܂j
if %newpage==1 then
;	sp "window:cur",{name="?,cur",x=%c_x,y=%c_y,z=0}
;	sp "window:cur",{name="bg/textw/00_okuri.png",x=%c_x+120,y=%c_y+50,z=100}
	sp "window:cur",{name="bg/textw/00_okuri.png",x=%c_x+300-50,y=%c_y+50+10,z=100}
;	sp "window:cur",{name="bg/textw/00_okuri.png",x=960-50,y=640-100,z=100}	;20170419J[\ړȂ
else
;	sp "window:cur",{name="?,cur",x=%c_x,y=%c_y,z=0}
;	sp "window:cur",{name="bg/textw/00_okuri1.png",x=%c_x+120,y=%c_y+50,z=100}
	sp "window:cur",{name="bg/textw/00_okuri1.png",x=%c_x+300-50,y=%c_y+50+10,z=100}
;;	sp "window:cur",{name="bg/textw/00_okuri1.png",x=960-50,y=640-100,z=100}	;20170419J[\ړȂ

c_y=%c_y	;20181001mx[ĥ݂̑IpɓĂ

end if

;ȊOȂ
param %c_x,%c_y ; eLXg̃J[\ʒuBNbN҂{^oƂɎgBł͎gȂB
;
c_y=%c_y	;20181001mx[ĥ݂̑IpɓĂ

endif

;20181215CŐ\ɂ
btnclear "window","C(window:erase_s)"
;20181215wvǉ-----------------------------------------------------------------------
btn "window:erase",{on="P(window:erase_s,0)S(rpg_sozai\se\sin_click.ogg)"}
btn "window:skip",{on="P(window:erase_s,1)S(rpg_sozai\se\sin_click.ogg)"}
btn "window:auto",{on="P(window:erase_s,2)S(rpg_sozai\se\sin_click.ogg)"}
if kaisou==0 then btn "window:save",{on="P(window:erase_s,3)S(rpg_sozai\se\sin_click.ogg)"}
if kaisou==0 then btn "window:load",{on="P(window:erase_s,4)S(rpg_sozai\se\sin_click.ogg)"}
btn "window:log",{on="P(window:erase_s,5)",off="C(window:erase_s,5)S(rpg_sozai\se\sin_click.ogg)"}
btn "window:config",{on="P(window:erase_s,6)S(rpg_sozai\se\sin_click.ogg)"}
;20181215ǉ肱܂-----------------------------------------------------------------------

@textb_loop
;if getskip()==1 then return
if tchk()==1 and _already==1 and getskip()==1 then return	;20170914ǃXLbvǉ
if getskip()==2 then
	btnexec %ret,"window",{wheel=1,ctrl=1,automode=1,time=(6-_autospeed)*500,func=1}
else
	btnexec %ret,"window",{wheel=1,ctrl=1,func=1}
end if
if %ret=="#F1" then gosub @sin_ss	;F1ŃXN[VbgƂ
if %ret=="" or %ret==#wd or %ret==#ctrl or %ret==#timeout then return
if %ret=="erase" or %ret==#r then spsetvisible "window",0:lrclick:spsetvisible "window",1:goto @textb_loop
if %ret=="skip" then skip 1:goto @textb_loop
if %ret=="auto" then skip 2:goto @textb_loop
if %ret=="save" then gosub @sin_saveload_gets:spsetvisible "window",0:issave=1:gosub @saveload:spsetvisible "window",1:goto @textb_loop
if %ret=="load" then spsetvisible "window",0:issave=0:gosub @saveload:spsetvisible "window",1:goto @textb_loop
if %ret=="log" or %ret==#wu then spsetvisible "window",0:gosub @backlog:spsetvisible "window",1:print #c:goto @textb_loop
if %ret=="config" then spsetvisible "window",0:gosub @config:spsetvisible "window",1:goto @textb_loop
goto @textb_loop
return

;-------------------------------
; I
;-------------------------------
@selectb
;őIɍ킹Ď󂯎ϐĂBƂ肠SɂĂ܂B
param %cnum,%text0,%lb0,%text1,%lb1,%text2,%lb2,%text3,%lb3
skip 0

if novelmode==0 then
;XvCg̃[h
;sp "window:selwin0",{name={"*800,35,#BB111144","*800,35,#BB3333AA"},x=0,y=100,z=10}
sp "window:selwin0",{name={"bg\textw\03_off.png","bg\textw\03_on.png"},x=0,y=55+60*0,z=10}
sp "window:seltext0",{name="?"+%text0+",text",x=100,y=65+60*0,z=0}

sp "window:selwin1",{name={"*800,35,#BB111144","*800,35,#BB3333AA"},x=0,y=150,z=10}
sp "window:selwin1",{name={"bg\textw\03_off.png","bg\textw\03_on.png"},x=0,y=55+60*1,z=10}
sp "window:seltext1",{name="?"+%text1+",text",x=100,y=65+60*1,z=0}
if %cnum>2 then
	sp "window:selwin2",{name={"*800,35,#BB111144","*800,35,#BB3333AA"},x=0,y=200,z=10}
sp "window:selwin2",{name={"bg\textw\03_off.png","bg\textw\03_on.png"},x=0,y=55+60*2,z=10}
	sp "window:seltext2",{name="?"+%text2+",text",x=100,y=65+60*2,z=0}
end if
if %cnum>3 then
	sp "window:selwin3",{name={"*800,35,#BB111144","*800,35,#BB3333AA"},x=0,y=250,z=10}
sp "window:selwin3",{name={"bg\textw\03_off.png","bg\textw\03_on.png"},x=0,y=55+60*3,z=10}
	sp "window:seltext3",{name="?"+%text3+",text",x=100,y=65+60*3,z=0}
end if
endif
;ȉAmx[hőȈꍇ
if novelmode==1 then

;20200517NbN҂
spdelete "window:cur":print #C

gettextpos %x,%c_y	;20181001\̂ɑI\ꍇ.20230326yCB

newpage ; IƂɉy[WݒɂĂ܂BΉy[W܂B
;okbox str(c_y),""
;XvCg̃[h@IƖ{s󂯂Ă܂B
;sp "window:selwin0",{name={"*1180,40,#00000000","*1180,40,#AAAAAA88"},x=50,y=c_y+42*2,z=10}
;sp "window:seltext0",{name="?"+%text0+",text",x=300-50,y=c_y+42*2,z=0}

sp "window:selwin0",{name={"*1180,40,#00000000","*1180,40,#AAAAAA88"},x=50,y=c_y+42*2,z=10}
sp "window:seltext0",{name="?"+%text0+",text",x=300-50,y=c_y+42*2,z=0}

sp "window:selwin1",{name={"*1180,40,#00000000","*1180,40,#AAAAAA88"},x=50,y=c_y+42*3,z=10}
sp "window:seltext1",{name="?"+%text1+",text",x=300-50,y=c_y+42*3,z=0}

if %cnum>2 then
	sp "window:selwin2",{name={"*1180,40,#00000000","*1180,40,#AAAAAA88"},x=50,y=c_y+42*4,z=10}
	sp "window:seltext2",{name="?"+%text2+",text",x=300-50,y=c_y+42*4,z=0}

end if
if %cnum>3 then
	sp "window:selwin3",{name={"*1180,40,#00000000","*1180,40,#AAAAAA88"},x=50,y=c_y+42*5,z=10}
	sp "window:seltext3",{name="?"+%text3+",text",x=300-50,y=c_y+42*5,z=0}


endif
endif

@sel_start
;20181215CŐ\ɂ
btnclear "window","C(window:erase_s)"
btn "window:selwin0",{on="S(rpg_sozai\se\sin_click.ogg)"}
btn "window:selwin1",{on="S(rpg_sozai\se\sin_click.ogg)"}
btn "window:selwin2",{on="S(rpg_sozai\se\sin_click.ogg)"}
btn "window:selwin3",{on="S(rpg_sozai\se\sin_click.ogg)"}
;20181215wvǉ-----------------------------------------------------------------------
btn "window:erase",{on="P(window:erase_s,0)S(rpg_sozai\se\sin_click.ogg)"}
btn "window:skip",{on="P(window:erase_s,1)S(rpg_sozai\se\sin_click.ogg)"}
btn "window:auto",{on="P(window:erase_s,2)S(rpg_sozai\se\sin_click.ogg)"}
if kaisou==0 then btn "window:save",{on="P(window:erase_s,3)S(rpg_sozai\se\sin_click.ogg)"}
if kaisou==0 then btn "window:load",{on="P(window:erase_s,4)S(rpg_sozai\se\sin_click.ogg)"}
btn "window:log",{on="P(window:erase_s,5)",off="C(window:erase_s,5)S(rpg_sozai\se\sin_click.ogg)"}
btn "window:config",{on="P(window:erase_s,6)S(rpg_sozai\se\sin_click.ogg)"}
;20181215ǉ肱܂-----------------------------------------------------------------------
@sel_loop
btnexec %ret,"window",{wheel=1,func=1}
if %ret=="#F1" then gosub @sin_ss	;F1ŃXN[VbgƂ
if %ret=="selwin0" then spdeletes "window:sel":print #c:return %lb0
if %ret=="selwin1" then spdeletes "window:sel":print #c:return %lb1
if %ret=="selwin2" then spdeletes "window:sel":print #c:return %lb2
if %ret=="selwin3" then spdeletes "window:sel":print #c:return %lb3
if %ret=="erase" or %ret==#r then spsetvisible "window",0:lrclick:spsetvisible "window",1:goto @sel_loop
if %ret=="save" then gosub @sin_saveload_gets:spsetvisible "window",0:issave=1:gosub @saveload:spsetvisible "window",1:goto @sel_loop
if %ret=="load" then spsetvisible "window",0:issave=0:gosub @saveload:spsetvisible "window",1:goto @sel_loop
if %ret=="log" or %ret==#wu then spsetvisible "window",0:gosub @backlog:spsetvisible "window",1:print #c:goto @sel_loop
if %ret=="config" then spsetvisible "window",0:gosub @config:spsetvisible "window",1:goto @sel_loop
goto @sel_loop

;-------------------------------
; Z[u^[h
;-------------------------------
@saveload
;98.txt
	goto @sin_saveload

;Z[uƃ[h͋ʂ̏̂ŕϐŐ؂蕪ďĂ܂B
spset "sl",100
sp "sl:bg",{name="*#BB111144",x=0,y=0,z=1000}
if issave==1 then
	sp "sl:title",{name="?@Z[u@,menu1",x=410,y=50,z=0}
else
	sp "sl:title",{name="?@[h@,menu1",x=410,y=50,z=0}
end if

@saveload_btnload
btnclear "sl"
for %i=0 to 20
	call @saveload_sub,"N",%i
	if issave==1 or schk(%i) then btn "sl:data"+str(%i)
next

@saveload_loop
btnexec %ret,"sl"
if %ret==#r then spsetdelete "sl":return
if left(%ret,4)=="data" then goto @saveload_exec
goto @saveload_loop

@saveload_exec
%num=num(mid(%ret,4,100))
if issave==1 then
	if schk(%num) then
		yesnobox %ret,"Z[uf[^ɑ݂܂B㏑܂H","㏑mF"
		if %ret==0 then goto @saveload_loop
	end if
	save %num
	goto @saveload_btnload
else
	yesnobox %ret,"[h܂H","[hmF"
	if %ret==1 then load %num else goto @saveload_loop
end if

@saveload_sub
param %i
if schk(%i)==1 then
	savetime %i,%year,%month,%day,%hour,%min,%sec
	%str="?"+strf("%4d",%year)+"/"+strf("%02d",%month)+"/"+strf("%02d",%day)+" "+strf("%02d",%hour)+":"+strf("%02d",%min)+":"+strf("%02d",%sec)
	sp "sl:data"+str(%i),{name={%str+",save0",%str+",save1"},x=320,y=90+%i*30,z=0}
else
	sp "sl:data"+str(%i),{name={"?----/--/-- --:--:--,save0","?----/--/-- --:--:--,save1"},x=320,y=90+%i*30,z=0}
end if
return

;-------------------------------
; obNO
;-------------------------------
@backlog
spset "log",100
sp "log:bg",{name="*#BB111144",x=0,y=0,z=1000}
sp "log:up",{name={"?,menu0","?,menu1"},x=930,y=570,z=0}	;20170419ʒuς
sp "log:down",{name={"?,menu0","?,menu1"},x=930,y=600,z=0}	;20170419ʒuς
%page=0
@backlog_pageload
btnclear
call @backlog_pagestart_sub,"SNN","text5",%page+4,10
call @backlog_pagestart_sub,"SNN","text4",%page+3,160
call @backlog_pagestart_sub,"SNN","text3",%page+2,310
call @backlog_pagestart_sub,"SNN","text2",%page+1,460
;call @backlog_pagestart_sub,"SNN","text1",%page  ,610
print #c
btn "log:up"
btn "log:down"

@backlog_loop
btnexec %ret,"log",{spcret=1,wheel=1}
if %ret==#r or %ret=="" then goto @backlog_end
if %ret==#wu or %ret=="up" then goto @backlog_up
if %ret==#wd or %ret=="down" then goto @backlog_down
if %ret=="text5" then call @backlog_voice,"N",%page+4:goto @backlog_loop
if %ret=="text4" then call @backlog_voice,"N",%page+3:goto @backlog_loop
if %ret=="text3" then call @backlog_voice,"N",%page+2:goto @backlog_loop
if %ret=="text2" then call @backlog_voice,"N",%page+1:goto @backlog_loop
if %ret=="text1" then call @backlog_voice,"N",%page:goto @backlog_loop
goto @backlog_loop

@backlog_up
%page=%page+1
if logchk(%page+4)==0 then %page=%page-1
goto @backlog_pageload

@backlog_down
%page=%page-1
if %page<0 then goto @backlog_end
goto @backlog_pageload

@backlog_end
spvisible "window:log_s",0	;20160215{^\
spsetdelete "log"
return

@backlog_pagestart_sub
param %name,%num,%y
getlogtext %num,%vtag,%vtext
;20190923\ŕϐgꍇ̃eXg
;%vtextɁOcc邩ׂB́͑̕łBtext_name[1]ύXRłBA[Jϐ͎gȂB
;Ȍꍇ́AԂA%vname𓯗lɂΑvȂ͂ł
%vtext=replace(%vtext,"O",text_name[1])
%vtext=replace(%vtext,"G̖O",text_name[2])
%vtext=replace(%vtext,"_[W",text_name[3])
%vtext=replace(%vtext,"_[WQ",text_name[4])
if %vtext==#NIL then spdelete "log:"+%name:return
split %vtag,"/",%vname,%vvoice
%vname=replace(%vname,"Ȃ܂",text_name[1000])	;20200523O̕ϊ
if %vname<>"" then
	%vtext="y" + %vname + "z\n" + %vtext
end if
if %vvoice<>"" then
	sp "log:"+%name,{name={"*730,150,#00000000","*730,150,#00000000"},x=50,y=%y,z=30}
	spformat "log:"+%name,0,%vtext,{font="logtext0",x=0,y=0,w=27,h=5},{font="logruby0"}
	spformat "log:"+%name,1,%vtext,{font="logtext1",x=0,y=0,w=27,h=5},{font="logruby1"}
	btn "log:"+%name
else
	sp "log:"+%name,{name="*730,150,#00000000",x=50,y=%y,z=30}
	spformat "log:"+%name,0,%vtext,{font="logtext0",x=0,y=12,w=27,h=5},{font="logruby0"}
end if
return

@backlog_voice
param %num
getlogtext %num,%vtag,%vtext
split %vtag,"/",%vname,%vvoice
voiceplay "voice\"+%vvoice+".ogg"
return

;-------------------------------
; RtBO
;-------------------------------
@config
;98.txt
	goto @sin_config
spset "cfg",100
sp "cfg:bg",{name="*#BB111144",x=0,y=0,z=1000}
sp "cfg:title_top",{name="?RtBOj[,menu1",x=350,y=150,z=10}
sp "cfg:title0",{name="?ʃ[h@@@,menu1",x=170,y=240,z=10}
sp "cfg:title1",{name="?eLXg\x,menu1",x=170,y=280,z=10}
sp "cfg:title2",{name="?I[g[hx,menu1",x=170,y=320,z=10}
sp "cfg:title3",{name="?aflʁ@@@,menu1",x=170,y=360,z=10}
sp "cfg:title4",{name="?{CXʁ@@@,menu1",x=170,y=400,z=10}
sp "cfg:title5",{name="?rdʁ@@@@,menu1",x=170,y=440,z=10}
sp "cfg:title6",{name={"?Zbg,menu0","?Zbg,menu1"},x=170,y=480,z=10}
sp "cfg:title7",{name={"?I,menu0","?I,menu1"},x=170,y=520,z=10}
@config_btnload
btnclear "cfg"

;XN[[hAlt+ENTERő剻{^łω܂BKAԂ`FbNđΉĂB
if getscreen()==0 then
	sp "cfg:window",{name="?EBhE,menu1",x=450,y=240,z=10}
	sp "cfg:full",{name={"?tXN[,menu0","?tXN[,menu1"},x=620,y=240,z=10}
	btn "cfg:full"
else
	sp "cfg:window",{name={"?EBhE,menu0","?EBhE,menu1"},x=450,y=240,z=10}
	sp "cfg:full",{name="?tXN[,menu1",x=620,y=240,z=10}
	btn "cfg:window"
end if

for %i=0 to 6
	;O|Ůe{^ݒ肵Ă܂B
	if _textspeed==%i then
		sp "cfg:text"+str(%i),{name="?"+zenkaku(str(%i))+",menu1",x=450+%i*55,y=280,z=10}
	else
		%str="?"+zenkaku(str(%i))
		sp "cfg:text"+str(%i),{name={%str+",menu0",%str+",menu1"},x=450+%i*55,y=280,z=10}
		btn "cfg:text"+str(%i)
	end if

	if _autospeed==%i then
		sp "cfg:auto"+str(%i),{name="?"+zenkaku(str(%i))+",menu1",x=450+%i*55,y=320,z=10}
	else
		%str="?"+zenkaku(str(%i))
		sp "cfg:auto"+str(%i),{name={%str+",menu0",%str+",menu1"},x=450+%i*55,y=320,z=10}
		btn "cfg:auto"+str(%i)
	end if

	if _bgmvol==%i then
		sp "cfg:bgm"+str(%i),{name="?"+zenkaku(str(%i))+",menu1",x=450+%i*55,y=360,z=10}
	else
		%str="?"+zenkaku(str(%i))
		sp "cfg:bgm"+str(%i),{name={%str+",menu0",%str+",menu1"},x=450+%i*55,y=360,z=10}
		btn "cfg:bgm"+str(%i)
	end if

	if _voicevol==%i then
		sp "cfg:voice"+str(%i),{name="?"+zenkaku(str(%i))+",menu1",x=450+%i*55,y=400,z=10}
	else
		%str="?"+zenkaku(str(%i))
		sp "cfg:voice"+str(%i),{name={%str+",menu0",%str+",menu1"},x=450+%i*55,y=400,z=10}
		btn "cfg:voice"+str(%i)
	end if

	if _sevol==%i then
		sp "cfg:se"+str(%i),{name="?"+zenkaku(str(%i))+",menu1",x=450+%i*55,y=440,z=10}
	else
		%str="?"+zenkaku(str(%i))
		sp "cfg:se"+str(%i),{name={%str+",menu0",%str+",menu1"},x=450+%i*55,y=440,z=10}
		btn "cfg:se"+str(%i)
	end if
next

btn "cfg:title6"
btn "cfg:title7"


@config_loop
btnexec %ret,"cfg",{sizechange=1} ; RtBOł̓EBhETCYωɑΉB\ɔf܂B
if %ret=="title6" then
	yesnobox %ret,"Zbg܂H","ZbgmF"
	if %ret==1 then reset else goto @config_loop
end if
if %ret=="title7" then
	yesnobox %ret,"I܂H","ImF"
	if %ret==1 then quit else goto @config_loop
end if
if %ret==#r then spsetdelete "cfg":return
if %ret=="window" then setscreen 0:goto @config_btnload
if %ret=="full" then setscreen 1:goto @config_btnload
if %ret==#sizechange then goto @config_btnload ; Alt+ENTER͍ő剻{^΍
if left(%ret,4)=="text" then
	_textspeed=num(mid(%ret,4,100))
	goto @config_btnload
end if
if left(%ret,4)=="auto" then
	_autospeed=num(mid(%ret,4,100))
	goto @config_btnload
end if
if left(%ret,3)=="bgm" then
	_bgmvol=num(mid(%ret,3,100))
	gosub @config_exec
	goto @config_btnload
end if
if left(%ret,5)=="voice" then
	_voicevol=num(mid(%ret,5,100))
	gosub @config_exec
	goto @config_btnload
end if
if left(%ret,2)=="se" then
	_sevol=num(mid(%ret,2,100))
	gosub @config_exec
	goto @config_btnload
end if
goto @config_loop

;-------------------------------
; RtBOݒ̎s
;-------------------------------
@config_exec
;{[0͖(-10000)AƂ͌vZŔĂB0ő{[Ȃ̂ŁA60ɁB
if _bgmvol==0 then bgmvolume -10000 else bgmvolume -2400+_bgmvol*400
if _voicevol==0 then voicevolume -10000 else voicevolume -2400+_voicevol*400
if _sevol==0 then sevolume -10000 else sevolume -2400+_sevol*400
return

;-------------------------------
; [`
;-------------------------------
@system_initialize

;ݒŃmx[hȂPAȊOȂO
novelmode 0
;IɂȂȂ邩ȂAmx[hPȂPɂB蓮ő삷B
novelmode=0

if not isdef(_first) then gosub @first_settings
gosub @config_exec
gosub @define_commands
gosub @define_font
gosub @load_window
return

;-------------------------------
;ÑVXeϐݒ
;-------------------------------
@first_settings
_first=1
_textspeed=3        ;eLXg̑x(0-6)
_autospeed=3        ;I[g[h̑x(0-6)
_bgmvol=2           ;BGM̃{[(0-6)
_voicevol=6         ;VOICẼ{[(0-6)
_sevol=6            ;SẼ{[(0-6)
_clickpage=0        ;y[WPʂŕ\邩ǂ̃tOimx[hj
_already=1          ;ǃXLbv
_allclear=0         ;I[NAϐB^CgʂNAς̂ɎgB
_sin_saveload_new=0 ;98.txt̃Z[u[hōŐVZ[ut@Cۑϐ
_saveload[0]=1		;Z[u[h̍ŐVʕ\pϐ

return

;-------------------------------
; tHg`
;-------------------------------
;tHg̓Z[uȂ̂ŁAKNɈ񂾂B
@define_font
;font "text",{name="rounded mplus 1m bold",width=28,height=28,color=#FFFFFFFF}
font "text",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=30,height=30,color=#FFFFFFFF}
font "ruby",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=14,height=14,color=#FFFFFFFF}
font "logtext0",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=25,height=25,color=#FFFFFF22}
font "logruby0",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=12,height=12,color=#FFFFFF22}
font "logtext1",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=25,height=25,color=#FFFFFFFF}
font "logruby1",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=12,height=12,color=#FFFFFFFF}
font "menu0",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=28,height=28,color=#FFBB6666}
font "menu1",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=28,height=28,color=#FFFFFFFF}
;font "save0",{width=20,height=20,color=#FFBB6666}
font "save1",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=20,height=20,color=#FFFFFFFF}
font "sysfont0",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=11,height=23,color=#FFAAFFFF}
font "sysfont1",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=11,height=23,color=#FFFFFFFF}
font "cur",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=32,height=32,color=#FF66FFFF}

;ǉ
font "menu1_1",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=20,height=27,color=#FFFFFFFF}
font "menu2",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=28,height=28,color=#FF2d3570}
font "text2",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=20,height=20,color=#FFFFFFFF}
font "text3",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=35,height=35,color=#FFFFFFFF}
font "menu_text_01",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FFFFFFFF,width=20,height=20,color=#FF310f9d}
font "save0",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FFFFFFFF,width=16,height=16,color=#FF000000}
font "log_text",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FFFFFFFF,width=20,height=20,color=#FF000000}
font "buy_t1",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=25,height=25,color=#FFBB6666}
font "buy_t2",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=25,height=25,color=#FFFFFFFF}
font "sin_item_001",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF8D114A,width=30,height=30,color=#FFFFFFFF}
font "menu2",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=28,height=28,color=#FF999999}
font "sin_ste",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=25,height=25,color=#FFFFFFFF}

font "ruby",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=20,height=20,color=#FFFFFFFF}

;20200907̓tHg傫
font "text",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=40,height=40,color=#FFFFFFFF}
font "new",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=22,height=22,color=#FFFFFFFF}
font "save0",{name="rounded M+ 1m bold",outlinecolor=#FFFFFFFF,width=16,height=16,color=#FFFFFFFF}
font "text_",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=40,height=40,color=#FF999999}
font "text_a",{name="rounded M+ 1m bold",style="outline",outlinecolor=#FF000000,width=30,height=30,color=#FFFFFFFF}


return

;-------------------------------
; oR}h`
;-------------------------------
;o߂͑Sőg܂Ȃ΂Ȃ܂񂪁Adl͎Rɂł܂B
;jýAƂbgm l ȂǂƂ悤Ȗ߂Ɗył傤B

@define_commands
defsub  bg0, "S"       ; bg0 "filename"
defsub   bg, "SS?N?S"  ; bg "filename",#GtFNg[,,[摜]
defsub  ld0, "NS"      ; ld0 pos,"filename"
defsub   ld, "NSS?N?S" ; ld pos,"filename",#GtFNg[,,[摜]
defsub  cl0, "N"       ; cl0 pos
defsub   cl, "NS?N?S"  ; cl pos,#GtFNg[,,[摜]
defsub cla0, ""        ; cla0
defsub  cla, "S?N?S"   ; cla #GtFNg[,,[摜]
defsub window,"N"      ; 0=eLXgEBhE\ 1=eLXgEBhE\
gosub @sin_ld		   ;20170918얽
return

;-------------------------------
; oR}h
;-------------------------------
@bg
;wi[hAGtFNg
param %fn,%ef,%tm,%rule
spdeletes "chr" ; chrŎn܂XvCgA܂藧GS
bg0 %fn
print %ef,%tm,%rule
return

@bg0
;wi[hi\͂܂ȂBƂł܂Ƃ߂printŕ\łj
param %fn
sp "bg",{name=%fn,x=0,y=0,z=1000}
return

@ld
;G[hAGtFNgB
;pos-1A0^񒆁A1E
param %pos,%fn,%ef,%tm,%rule
ld0 %pos,%fn
print %ef,%tm,%rule
return

@ld0
;G[hi\͂܂ȂBƂł܂Ƃ߂printŕ\łj
;pos-1A0^񒆁A1E
param %pos,%fn
%spname="chr"+str(%pos)
ggetsize %w,%h ; Q[ʂ̑傫擾
sp %spname,{name=%fn,x=%w,y=%h} ;ʊOփ[h
getspinfo %spname,%info ;摜̏擾
if %pos==-1 then %x=floor(%w/3-%info.w/2-150)
if %pos==0 then %x=floor(%w/2-%info.w/2)
if %pos==1 then %x=floor(%w*2/3-%info.w/2+150)
%y=%h-%info.h
spmove %spname,%x,%y
return

@cl
;GAGtFNg
param %pos,%ef,%tm,%rule
cl0 %pos
print %ef,%tm,%rule
return

@cl0
;Gi\͂܂ȂBƂł܂Ƃ߂printŕ\łj
param %pos
spdelete "chr"+str(%pos)
return

@cla
;GSAGtFNg
param %ef,%tm,%rule
cla0
print %ef,%tm,%rule
return

@cla0
;GS
spdeletes "chr"
return

@window
;eLXgEBhE̕\E\؂ւ
param %flag
if %flag==0 then spvisible "window",0 else spvisible "window",1
print #c
return
