#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winb.h>
#include <te.h>
#include <fntb.h>
#include <gui.h>
#include "igo.h"
#include "banx.h"
#include "kifuctrl.h"

int	auto_dialogId = -1 ;
int	auto_messageId[7] = -1 ;
int	auto_icon[2] = -1 ;
int	auto_bottonId[3] = -1 ;
int	auto_numbox = -1 ;

/*	initDataMIAUTO:auto_bottonId[0]:MJ_DBUTTONL40の呼び出し関数	*/
/*  設定の関数  */
int	igo_autoset(kobj, messId, argc, pev, trigger)
int		kobj ;
int		messId ;
int		argc ;
EVENT	*pev ;
int		trigger ;
{
	igo_do_autoset();

	return NOERR ;
}

/*	initDataMIAUTO:auto_bottonId[1]:MJ_DBUTTONL40の呼び出し関数	*/
int	igo_autocancel(kobj, messId, argc, pev, trigger)
int		kobj ;
int		messId ;
int		argc ;
EVENT	*pev ;
int		trigger ;
{
	/*	auto_dialogIdで示されるオブジェクトを消す		*/
	MMI_SendMessage( auto_dialogId , MM_ERASE , 0 ) ;

	/*	オブジェクトをダイアログから取り外す	*/
	MMI_SendMessage( auto_dialogId , MM_DETACH , 0 ) ;

	retunrInitMenuFunc();

	return NOERR ;
}

/*	initDataMIAUTO:auto_bottonId[3]:MJ_DBUTTONL40の呼び出し関数	*/
/*  設定即再生の関数  */
int	igo_autoexec(kobj, messId, argc, pev, trigger)
int		kobj ;
int		messId ;
int		argc ;
EVENT	*pev ;
int		trigger ;
{
	igo_do_autoset();
	igo_autorebirth();
	return NOERR ;
}

/*  設定の下請け関数  */
int	igo_do_autoset()
{
	int repeat_flg, change_flg, comment_flg = 0, rebirth_speed;
	int min, max, delta, ptColum; /* 使用していない */

	/*  再生オプションをセット */
	repeat_flg = MTL_checkFlagObj( auto_icon[0] , MS_TOGGLE) ;
	change_flg = MTL_checkFlagObj( auto_icon[1] , MS_TOGGLE) ;

	kifu_rebirth( repeat_flg, change_flg, comment_flg);
	
	/*	数値入力パネルの読み取り	*/
	MMI_SendMessage(auto_numbox, MM_GETNUMBOX, 5,
							&rebirth_speed, &min, &max, &delta, &ptColum) ;

	kifu_rebirth_speed_set( rebirth_speed);
	
	/*	auto_dialogIdで示されるオブジェクトを消す		*/
	MMI_SendMessage( auto_dialogId , MM_ERASE , 0 ) ;

	/*	オブジェクトをダイアログから取り外す	*/
	MMI_SendMessage( auto_dialogId , MM_DETACH , 0 ) ;

	retunrInitMenuFunc();

	return NOERR ;
}
