function MouseSetup()
{
	var temp;
	var dispgrid;

	dispgrid = sliderconv1( mouse_grid );
	DlogOpen( "３Ｄカーソル移動量設定", 1 );
	DlogSlider( 0, "３Ｄカーソル移動量", SLIDER_HABA, MAX_SLIDER_NUM1, dispgrid, gridconv1 );
	if ( DlogWait() )
	{
		dispgrid = DlogAnswer( 0 );
		mouse_grid = gridconv1( dispgrid );
		SetGrid( mesh_grid, mouse_grid );
	}
}
function ButtonDisp()
{
	if( buttondisp_flag == ON )
	{
		buttondisp_flag = OFF;
		ButtonArea( 0 );
	}
	else
	{
		buttondisp_flag = ON;
		ButtonArea( BUTTONAREA );
	}
	UpdateButton();
}

function ChangeHeimenTosha()
{
	tosha_flag = !tosha_flag;
}

function ChangeSelectMode()
{
	if( AreaMode == SELECT_SUB )
		AreaMode = SELECT_ALL;
	else
		AreaMode = SELECT_SUB;
}

function private ChangeEnvironment()
{
	var	temp, msg1[2], msg2[2];

	msg1 = {"  左  ","  右  "};
	msg2 = {"ＯＦＦ"," ＯＮ "};

	DlogOpen( "環境設定", 15, "  ｷｬﾝｾﾙ ","環境保存" );
	DlogString(  0, "編集できるポリゴンデータの上限(KB)", Modelrc("BufferSize" ), 20 );
	DlogString(  2, "最大オブジェクト数                ", Modelrc("Object" ), 20 );
	DlogString(  4, "最大アトリビュート数              ", Modelrc("Attr" ), 20 );
	DlogString(  6, "１ポリゴンの最大頂点数            ", Modelrc("Vertex" ), 20 );
	DlogSelect(  8, "３Ｄカーソル移動のマウスボタン    ", msg1, atoi(Modelrc("Input_left")));
	DlogSelect( 10, "エキスパートモード                ", msg2, atoi(Modelrc("Expert" )));
	DlogSelect( 12, "メッセージ表示                    ", msg2, atoi(Modelrc("Message")));
	DlogMessage( 14, "注意:環境は次回の起動から有効です" );

	if( DlogWait())
	{
		temp = atoi( DlogAnswer(0));
		if( temp > 0 )
			Modelrc( "BufferSize", tostring(temp));
		temp = atoi( DlogAnswer( 2 ));
		if( temp > 0 )
			Modelrc( "Object", tostring(temp));
		temp = atoi( DlogAnswer( 4 ));
		if( temp > 0 )
			Modelrc( "Attr", tostring(temp));
		temp = atoi( DlogAnswer( 6 ));
		if( temp > 0 )
			Modelrc( "Vertex", tostring(temp));
		temp = DlogAnswer( 8 );
		Modelrc( "Input_left", tostring(temp));
		temp = DlogAnswer( 10 );
		Modelrc( "Expert", tostring(temp));
		temp = DlogAnswer( 12 );
		Modelrc( "Message", tostring(temp));
	}
}

function private ChangeDefault()
{
	var	temp, msg[2];

	msg = {"ＯＦＦ"," ＯＮ "};

	DlogOpen( "初期値設定", 15, "  ｷｬﾝｾﾙ ","環境保存" );
	DlogString(  0, "画面倍率     ", Modelrc("DefaultZoomSize" ), 20 );
	DlogSelect(  2, "点表示       ", msg, atoi(Modelrc("DefaultVertexDisp")));
	DlogSelect(  4, "メッシュ表示 ", msg, atoi(Modelrc("DefaultMeshDisp")));
	DlogString(  6, "メッシュ幅   ", Modelrc("DefaultMeshWidth"), 20 );
	DlogSelect(  8, "法線表示     ", msg, atoi(Modelrc("DefaultNormalVecDisp")));
	DlogSelect( 10, "面の方向表示 ", msg, atoi(Modelrc("DefaultPolyVecDisp")));
	DlogString( 12, "マウス移動量 ", Modelrc("DefaultMouseMove"), 20 );
	DlogMessage( 14, "注意:環境は次回の起動から有効です" );

	if( DlogWait())
	{
		temp = atoi( DlogAnswer(0));
		Modelrc( "DefaultZoomSize", tostring(temp));
		temp = DlogAnswer( 2 );
		Modelrc( "DefaultVertexDisp", tostring(temp));
		temp = DlogAnswer( 4 );
		Modelrc( "DefaultMeshDisp", tostring(temp));
		temp = atoi( DlogAnswer( 6 ));
		if( temp > 0 )
			Modelrc( "DefaultMeshWidth", tostring(temp));
		temp = DlogAnswer( 8 );
		Modelrc( "DefaultNormalVecDisp", tostring(temp));
		temp = DlogAnswer( 10 );
		Modelrc( "DefaultPolyVecDisp", tostring(temp));
		temp = atoi(DlogAnswer( 12 ));
		if( temp > 0 )
			Modelrc( "DefaultMouseMove", tostring(temp));
	}

}

function private Check_flag()
{
	var	temp;

	temp = MenuFunction();
	if( temp == ButtonDisp )
	{
		if( buttondisp_flag == ON )
			MenuEnable( MENU_CHECK );
		else
			MenuEnable( MENU_NOCHECK );
	}
	else if( temp == ChangeSelectMode )
	{
		if( AreaMode == SELECT_ALL )
			MenuEnable( MENU_CHECK );
		else
			MenuEnable( MENU_NOCHECK );
	}
}

MenuPosition(
	Menu( " 操作設定(&S)",
		"ｶｰｿﾙ移動量設定...(&M)",MouseSetup,
		"-----------------",	SEPARATE_MENU,
		"ﾎﾞﾀﾝ表示(&B)",			ButtonDisp,Check_flag,
		"自動平面投射(&A)",		ChangeHeimenTosha,Check_Toshaflag,
		"範囲内の面を選択(&S)",	ChangeSelectMode,Check_flag,
		"-----------------",	SEPARATE_MENU,
		"環境設定...(&O)",			ChangeEnvironment,
		"ﾃﾞﾌｫﾙﾄ値設定...(&D)",		ChangeDefault
	), Menu_control
);
