@ECHO OFF
:0
TITLE %~n0
CLS
ECHO ============================
ECHO    ポモナ イベント の設定
ECHO ============================

perl -ne "print """[期間 $1]""" if m/active="""(.+?)"""/" < game/data/scripts/events/SquashEvent/config.xml
REM ----------------------------------------------
PUSHD tools
if not exist vars.txt (
	echo Error: 'vars.txt' not found.
	pause
	exit
)
ren vars.txt *.bat
call vars.bat
ren vars.bat *.txt
SET MYSQLCMD="%mysqlPath%" --default-character-set=utf8 -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb%
POPD
REM ----------------------------------------------
ECHO.
ECHO (1) イベント開始処理
ECHO (2) イベント終了処理
ECHO (8) config.xmlを開く
ECHO (9) おわり
ECHO.
SET mode=1
:100
SET /P mode="番号をキー入力してください。(default is '%mode%'): "
IF %mode%==1 GOTO :1
IF %mode%==2 GOTO :2
IF %mode%==8 GOTO :8
IF %mode%==9 GOTO :EOF
GOTO 100

REM イベント開始処理
:1
@ECHO ON
IF EXIST game/data/scripts/events/SquashEvent/OnEventBegin.sql %MYSQLCMD% < game/data/scripts/events/SquashEvent/OnEventBegin.sql
perl -i.BAK -pe "s{#(?=events/SquashEvent/SquashEvent\.java)}{}" game/data/scripts.cfg
@ECHO OFF
PAUSE
GOTO :EOF

REM イベント終了処理
:2
@ECHO ON
IF EXIST game/data/scripts/events/SquashEvent/OnEventEnd.sql %MYSQLCMD% < game/data/scripts/events/SquashEvent/OnEventEnd.sql
perl -i.BAK -pe "s{(?<!#)(?=events/SquashEvent/SquashEvent\.java)}{#}" game/data/scripts.cfg
@ECHO OFF
PAUSE
GOTO :EOF

REM xml編集
:8
@ECHO ON
notepad game/data/scripts/events/SquashEvent/config.xml
@ECHO OFF
GOTO :0
