/////////////////////////////////////////////////////////////////////////////
// Auto_fuel_consume.c
// 
/////////////////////////////////////////////////////////////////////////////
BOOL fuel_sys_status = FALSE;
//	Set up gauge header
GAUGE_CALLBACK			afc_update;
char Auto_fuel_consume_gauge_name[]	= GAUGE_NAME;
extern PELEMENT_HEADER	Auto_fuel_consume_list;
extern MOUSERECT      	Auto_fuel_consume_mouse_rect[];

GAUGE_HEADER_FS700(GAUGE_W, Auto_fuel_consume_gauge_name, &Auto_fuel_consume_list, \
						Auto_fuel_consume_mouse_rect, afc_update, 0, 0, 0);

/*---------------------------------------------------------------------------
---- Functions that ilustrate status of Keys --------------------------------
---------------------------------------------------------------------------*/
FLOAT64 FSAPI	Auto_fuel_consume_icon_cb( PELEMENT_ICON pelement )
{
	if ( Auto_fuel_consume == 0 && Auto_fuel_balance == 0 && Pump_1_L == 0 && Pump_1_R == 0 && Pump_2_L == 0 && Pump_2_R == 0 ){
		fuel_sys_status = TRUE;
	} else {
		fuel_sys_status = FALSE;
	}
	return Auto_fuel_consume;
}

/*---------------------------------------------------------------------------
------------ Make ICONS macroses     ----------------------------------------
---------------------------------------------------------------------------*/

MAKE_ICON
(		
	Auto_fuel_consume_icon,
	BMP_Auto_on_Key,
	NULL,
	NULL,
	IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY,
	0,
	0,0,

	MODULE_VAR_NONE, Auto_fuel_consume_icon_cb,

	ICON_SWITCH_TYPE_SET_CUR_ICON,
	1,
	0,
	0
)

PELEMENT_HEADER		Auto_fuel_consume_icon_list[] =
{
	&Auto_fuel_consume_icon.header,
	NULL
};
/////////////////////////////////////////////////////////////////////////////
MAKE_STATIC
(
	Auto_fuel_consume_background,
	BMP_Auto_off_Key,
	&Auto_fuel_consume_icon_list,
	NULL,
	IMAGE_USE_TRANSPARENCY,
	0,
	0,0
)

PELEMENT_HEADER		Auto_fuel_consume_list= &Auto_fuel_consume_background.header;

/*---------------------------------------------------------------------------
---------------- Call back mouse functions ----------------------------------
---------------------------------------------------------------------------*/

BOOL FSAPI Auto_fuel_consume_mouse_cb( PPIXPOINT relative_point, FLAGS32 mouse_flags )
{	
	//trigger_key_event( KEY_SET_FUEL_TRANSFER_AUTO, 0 );	// Auto transfer on/off
	if (Auto_fuel_consume == -1){
		Auto_fuel_consume = 0;  // Auto consume on
	}
	else {
		Auto_fuel_consume = -1; // Auto consume off
	}
	return TRUE;
}
/////////////////////////////////////////////////////////////////////////////

MOUSE_BEGIN( Auto_fuel_consume_mouse_rect, HELP_NONE, 0, 0 )
	MOUSE_CHILD_FUNCT( 0,0,50,50, CURSOR_HAND, MOUSE_LEFTSINGLE, Auto_fuel_consume_mouse_cb )
MOUSE_END
//---------------------------------------------------------------------------
void FSAPI	afc_update (PGAUGEHDR pgauge, int service_id, UINT32 extra_data)
{
	switch(service_id)
	{

/* "install_routine()" */

		case    PANEL_SERVICE_PRE_INSTALL:
			register_var_by_name(&fuel_sys_status, TYPE_BOOL, "FUEL_SYS_STATUS");
		break;

/* "initialize_routine()" */

		case    PANEL_SERVICE_PRE_INITIALIZE:
		break;

/* "update_routine()" */

		case    PANEL_SERVICE_PRE_UPDATE:

		break;

/* "draw_routine()" */

		case    PANEL_SERVICE_PRE_DRAW:
		break;

/* "kill_routine()" */

		case    PANEL_SERVICE_PRE_KILL:
			unregister_var_by_name ("FUEL_SYS_STATUS");
		break;
	}

}

/////////////////////////////////////////////////////////////////////////////
#undef GAUGE_NAME
#undef GAUGEHDR_VAR_NAME
#undef GAUGE_W
