'#################
'Magnitola Script
'#################

'(c) 26.05.2013 Dmitrij

'Script Version: 1.0


'Revision History:
'	-\\-

'------------------------------------------------------------------------------------------
{trigger:am_bt1}
	1 (S.L.bt_am_bt1)
	0 (S.L.am_number_line) (S.L.am_number_symbol)
	"          " (S.$.magnitola_1) (S.$.magnitola_1_new) (S.$.magnitola_1_old)
	(L.L.bt_elec_12v) (L.L.elec_busbar_main) &&
	{if}
		(L.L.am_power) ! (S.L.am_power)
	{endif}
{end}

{trigger:am_bt1_off}
	0 (S.L.bt_am_bt1)
{end}

'-------------
{trigger:am_bt2}
	1 (S.L.bt_am_bt2)
	0 (S.L.mp3_play_time)
	(L.L.bt_elec_12v) (L.L.elec_busbar_main) &&
	(L.L.am_power) &&
	{if}
		(L.L.mp3_number_track) 0  >
		{if}
			(L.L.mp3_number_track) 1 - (S.L.mp3_number_track)
		{else}
			(L.L.mp3_max_number_track) (S.L.mp3_number_track)
		{endif}
		{endif}
	{endif}
{end}

{trigger:am_bt2_off}
	0 (S.L.bt_am_bt2)
	(L.L.am_power)
	{if}
		(L.L.play)
		{if}
			(M.L.mp3_play)
		{endif}
	{endif}
{end}

'-------------
{trigger:am_bt3}
	1 (S.L.bt_am_bt3)
	0 (S.L.mp3_play_time)
	(L.L.bt_elec_12v) (L.L.elec_busbar_main) &&
	(L.L.am_power) &&
	{if}
		(L.L.mp3_number_track) (L.L.mp3_max_number_track) <
		{if}
			(L.L.mp3_number_track) 1 + (S.L.mp3_number_track)
		{else}
			0 (S.L.mp3_number_track)
		{endif}
	{endif}
{end}

{trigger:am_bt3_off}
	0 (S.L.bt_am_bt3)
	(L.L.am_power)
	{if}
		(L.L.play)
		{if}
			(M.L.mp3_play)
		{endif}
	{endif}
{end}

'-------------
{trigger:am_bt4}
	1 (S.L.bt_am_bt4)
	0 (S.L.mp3_play_time)
	(L.L.am_power)
	{if}
		(L.L.mp3_number_track) 0 <
		{if}
			0 (S.L.mp3_number_track)
		{endif}
		(L.L.play) !
		{if}
			1 (S.L.play)
		{endif}
	{endif}
	
{end}

{trigger:am_bt4_off}
	0 (S.L.bt_am_bt4)
	(L.L.am_power)
	{if}
		(L.L.play)
		{if}
			(M.L.mp3_play)
		{endif}
	{endif}
{end}

'-------------
{trigger:am_bt5}
	1 (S.L.bt_am_bt5)
	(L.L.play)
	{if}
		0 (S.L.play)
	{endif}
{end}

{trigger:am_bt5_off}
	0 (S.L.bt_am_bt5)
{end}

'-------------
{trigger:am_bt6}
	1 (S.L.bt_am_bt6)
	(L.L.disp_mode) ! (S.L.disp_mode)
{end}

{trigger:am_bt6_off}
	0 (S.L.bt_am_bt6)
{end}

'-------------
{trigger:am_bt7}
	1 (S.L.bt_am_bt7)
{end}

{trigger:am_bt7_off}
	0 (S.L.bt_am_bt7)
{end}

'-------------
{trigger:am_bt8}
	1 (S.L.bt_am_bt8)
	0 (S.L.am_visible) (S.L.am_power) (S.L.play)
{end}

{trigger:am_bt8_off}
	0 (S.L.bt_am_bt8)
{end}

'-------------
{trigger:am_bt9_drag}
	1 (S.L.am_bt9_draged)
	
	(L.S.mouse_x) (L.L.am_bt9_pos) + (S.L.am_bt9_pos)
	
	(L.L.am_bt9_pos) (L.L.am_bt9_lastpos) - -10 max 10 min (S.L.am_bt9_speed)
	(L.L.am_bt9_pos) (S.L.am_bt9_lastpos)
	
{end}

{trigger:am_bt9_off}
	0 (S.L.am_bt9_draged)
	0 (S.L.am_bt9_speed)
{end}


'-------------
{trigger:am_visible}
	1 (S.L.am_visible)
{end}


{macro:magnitola_init}
	-1 (S.L.mp3_number_track)
	0 (S.L.mp3_play_time) (S.L.play)
	1.5 (S.L.am_vol)
{end}

'----------------------
'	Frame
'----------------------
{macro:magnitola_frame}
	
	(L.L.play_next) (L.L.play_next_last) ! &&
	{if}
		(M.L.mp3_play)
	{endif}
	(L.L.play_next) (S.L.play_next_last)
	
	
	
	(L.L.bt_elec_12v) (L.L.elec_busbar_main) &&
	(L.L.am_power) &&
	{if}
		(L.L.play)
		{if}
			(L.L.mp3_play_time) (L.L.mp3_track_time) <
			{if}
				(L.L.mp3_play_time) (L.S.Timegap) + (S.L.mp3_play_time)
			{else}
				(L.L.mp3_number_track) (L.L.mp3_max_number_track) <
				{if}
					(L.L.mp3_number_track) 1 + (S.L.mp3_number_track)
				{else}
					0 (S.L.mp3_number_track)
				{endif}
				0 (S.L.mp3_play_time)
				(L.L.play_next) ! (S.L.play_next)
			{endif}
		{endif}
	{else}
		0 (S.L.play) (S.L.am_power)
	{endif}
		
'--------------------------------------
'	Направление движения
	(L.$.mp3_display_track_name) $length (S.L.length_track_name)
	(L.L.length_track_name) 10 - (S.L.length_track_name_cut)
	(L.L.disp_mov_left) 0 =
	{if}
		(L.L.disp_name_cut) (L.S.Timegap) (C.L.am_speed_display1) * - 0 max (S.L.disp_name_cut)
		(L.L.disp_name_cut) 0 =
		{if}
			1 (S.L.disp_mov_left)
		{endif}
	{else}
		(L.L.disp_name_cut) (L.S.Timegap) (C.L.am_speed_display1) * + (L.L.length_track_name_cut) min (S.L.disp_name_cut)
		(L.L.disp_name_cut) (L.L.length_track_name_cut) =
		{if}
			0 (S.L.disp_mov_left)
		{endif}
	{endif}
	

		
	(L.L.play) ! (L.L.play_last) &&
	{if}
		(L.L.mp3_number_track) (S.L.mp3_number_track_last)
		-1 (S.L.mp3_number_track)
		0 (S.L.mp3_play_time) (S.L.play)
		(L.L.play_next) ! (S.L.play_next)
	{endif}

	(L.L.play) (S.L.play_last)

	
	
	(L.L.am_change_symbol) (S.L.am_change_symbol_last)

	(L.L.am_change_symbol) 1 <
	{if}
		(L.L.am_change_symbol) (L.S.Timegap) (C.L.am_speed) * + (S.L.am_change_symbol)
	{else}
		0 (S.L.am_change_symbol)
	{endif}

	(L.L.am_change_symbol) (L.L.am_change_symbol_last) !
	{if}
		(L.L.am_number_symbol) 10 <
		{if}
			(L.L.am_number_symbol) 1 + (S.L.am_number_symbol)
		{else}
			0 (S.L.am_number_symbol)
			(L.$.magnitola_1) (S.$.magnitola_1_old)
			(L.L.am_number_line) 1 + (S.L.am_number_line)
		{endif}
	{endif}
	
	
	
	(L.L.bt_elec_12v) (L.L.elec_busbar_main) &&
	{if}
		(L.L.am_power)
		{if}
			(L.L.mp3_number_track) 1 + " 2" $IntToStrEnh (S.$.magnitola_2)
'--------------------------------------
'	Приветствие
			0 (S.L.show_buy_time)
			(L.L.show_wel_time) 1 (C.L.am_speed) / 30 * <
			{if}
				(L.L.am_number_line) 0 =
				{if}
					" WELCOME  " (S.$.magnitola_1_new)
				{endif}
				
				(L.L.am_number_line) 1 = 
				{if}
					"          " (S.$.magnitola_1_new)
				{endif}

				(L.$.magnitola_1_old) 10 (L.L.am_number_symbol) - $SetLengthR
				(L.$.magnitola_1_new) (L.L.am_number_symbol) $SetLengthL $+
				(S.$.magnitola_1)
				
				(L.L.show_wel_time) (L.S.Timegap) + (S.L.show_wel_time)
			{else}
'--------------------------------------
'	Громкость
				(L.L.am_vol) (L.L.am_bt9_speed) 100 / + 0 max 10 min (S.L.am_vol)
				(L.L.am_bt9_draged)
				{if}
					"VOL  "
					(L.L.am_vol) 10 * abs " 5" $IntToStrEnh $+
					(S.$.magnitola_1)
				{else}
'--------------------------------------
'	Название трека
					(L.L.disp_mode) 0 =
					{if}
						(L.$.mp3_display_track_name) 10 (L.L.disp_name_cut) + $SetLengthR 10 $SetLengthL
					{else}
						(L.L.mp3_track_time) (L.L.mp3_play_time) - /-/ (S.L.mp3_track_timer)
						"MP3"
						(L.L.play)
						{if}
							(L.L.mp3_track_timer) " 7" $IntToStrEnh $+
						{else}
							"   STOP" $+
						{endif}
					{endif}
						(S.$.magnitola_1)
					
				{endif}
			{endif}
		{else}
			"  " (S.$.magnitola_2)
'--------------------------------------
'	Прощание
			0 (S.L.show_wel_time)
			(L.L.show_buy_time) 1 (C.L.am_speed) / 30 * <
			{if}
				(L.L.am_number_line) 0 =
				{if}
					" GOODBYE  " (S.$.magnitola_1_new)
				{endif}
				
				(L.L.am_number_line) 1 = 
				{if}
					"          " (S.$.magnitola_1_new)
				{endif}

				(L.$.magnitola_1_old) 10 (L.L.am_number_symbol) - $SetLengthR
				(L.$.magnitola_1_new) (L.L.am_number_symbol) $SetLengthL $+
				(S.$.magnitola_1)
				
				(L.L.show_buy_time) (L.S.Timegap) + (S.L.show_buy_time)
			{endif}
		{endif}
	{else}
		"          " (S.$.magnitola_1) (S.$.magnitola_1_new) (S.$.magnitola_1_old)
		"  " (S.$.magnitola_2)
		0 (S.L.show_wel_time) (S.L.am_number_line) (S.L.am_number_symbol)
	{endif}
	
{end}

{macro:mp3_play}
		(L.L.length_track_name_cut) (S.L.disp_name_cut)
		0 (S.L.play_next)
		(L.L.mp3_number_track) -1 =
		{if}
			(L.L.mp3_number_track_last) (S.L.mp3_number_track)
		{endif}
		
		"..\..\..\Vehicles\LiAZ_5292.30\Music\"
		(L.$.mp3_track_name) $+
		".wav" $+
		$msg
		(T.F.ev_mp3_play)
	{endif}

{end}