#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 "kiffile.h"
#include "title.h"

extern int	backId ;
extern int	warningId ;

int	samesave_dialogId = -1 ;
int	samesave_btnId[2] = -1 ;

/*	initDataMISSAVE:samesave_btnId[0]:MJ_DBUTTONL40の呼び出し関数	*/
int	igo_samesave_set(kobj, messId, argc, pev, trigger)
int		kobj ;
int		messId ;
int		argc ;
EVENT	*pev ;
int		trigger ;
{
char *filename;
	/*	オブジェクトを消す		*/
	MMI_SendMessage( samesave_dialogId , MM_ERASE , 0 ) ;

	/*	オブジェクトをダイアログから取り外す	*/
	MMI_SendMessage( samesave_dialogId , MM_DETACH , 0 ) ;

	retunrInitMenuFunc();

	filename = title_fname_read();
	if(kifu_write(filename) != 0){
		
		/*	オブジェクトをダイアログに取り付ける	*/
		MMI_SendMessage( warningId , MM_ATTACH , 1 , backId ) ;

		/*	warningIdで示されるオブジェクトを表示する	*/
		MMI_SendMessage( warningId , MM_SHOW , 0 ) ; 
			
		return NOERR;
	}

	title_fsave_off();

	return NOERR ;
}

/*	initDataMISSAVE:samesave_btnId[1]:MJ_DBUTTONL40の呼び出し関数	*/
int	igo_savesave_cancel(kobj, messId, argc, pev, trigger)
int		kobj ;
int		messId ;
int		argc ;
EVENT	*pev ;
int		trigger ;
{
	/*	オブジェクトを消す		*/
	MMI_SendMessage( samesave_dialogId , MM_ERASE , 0 ) ;

	/*	オブジェクトをダイアログから取り外す	*/
	MMI_SendMessage( samesave_dialogId , MM_DETACH , 0 ) ;

	retunrInitMenuFunc();

	return NOERR ;
}

