sr2lua/music_store.lua

  1. ----------------- 
  2. -- MUSIC STORE -- 
  3. ----------------- 
  4. -- "global" variables 
  5. MUSIC_STORE_FOOTER_FADE_TIME = .25 
  6.  
  7. Music_store_data = { } 
  8. Music_store_footer = { } 
  9. Music_store_current_selection = 0 
  10. Music_store_menu = { } 
  11. MUSIC_STORE_DOC_HANDLE = vint_document_find("music_store") 
  12. Music_store_sort_data = { sort_by_artist = true, sorted_menu = -1 } 
  13. Music_store_dont_preview = false 
  14.  
  15. ---------------------- 
  16. --	SYSTEM FUNCTIONS -- 
  17. ---------------------- 
  18. --[ INITIALIZE AND SHUTDOWN ]-- 
  19. ------------------------------- 
  20. --	Initialize the menu 
  21. function music_store_init() 
  22.  
  23. 	--Event Tracking 
  24. 	event_tracking_interface_enter("Music Store") 
  25.  
  26. 	menu_store_init(true) 
  27.  
  28. 	music_store_build_horz_menu() 
  29. 	 
  30. 	menu_init() 
  31. 	menu_horz_init(Music_store_horz_menu) 
  32. end 
  33.  
  34. -- Shutdown and cleanup the menu 
  35. function music_store_cleanup() 
  36. end 
  37.  
  38. --[ EXIT ]-- 
  39. ------------ 
  40. function music_store_exit(menu_data) 
  41. 	local body = "MUSIC_STORE_EXIT_PROMPT" 
  42. 	local heading = "MENU_TITLE_WARNING" 
  43. 	 
  44. 	dialog_box_confirmation(heading, body, "music_store_exit_confirm") 
  45. end 
  46. function music_store_exit_confirm(result, action) 
  47. 	if action ~= DIALOG_ACTION_CLOSE then 
  48. 		return 
  49. 	end 
  50. 	 
  51. 	if result == 0 then 
  52. 		menu_close(music_store_exit_final) 
  53. 	end 
  54. end 
  55. function music_store_exit_final() 
  56. 	vint_document_unload(MUSIC_STORE_DOC_HANDLE)	 
  57. end 
  58. -------------------------- 
  59. -- FOOTER FUNCTIONALITY -- 
  60. -------------------------- 
  61. function music_store_clean_footer() 
  62. 		vint_set_property(Music_store_footer.artist_h, "offset", 0, 0)	 
  63. 		vint_set_property(Music_store_footer.artist_h, "alpha", 1) 
  64. 		vint_set_property(Music_store_footer.track_h, "offset", 0, 0)	 
  65. 		vint_set_property(Music_store_footer.track_h, "alpha", 1) 
  66.  
  67. 		--	Clean up stale threads/tweens 
  68. 		if Music_store_footer.restart_thread ~= nil then 
  69. 			thread_kill(Music_store_footer.restart_thread) 
  70. 			Music_store_footer.track_thread = nil 
  71. 		end 
  72. 	 
  73. 		if Music_store_footer.fade_thread ~= nil then 
  74. 			thread_kill(Music_store_footer.fade_thread) 
  75. 			Music_store_footer.fade_thread = nil 
  76. 		end 
  77. 		 
  78. 		if Music_store_footer.track_fade_twn ~= nil then 
  79. 			vint_object_destroy(Music_store_footer.track_fade_twn) 
  80. 			Music_store_footer.track_fade_twn = nil 
  81. 		end 
  82. 		 
  83. 		if Music_store_footer.track_twn ~= nil then 
  84. 			vint_object_destroy(Music_store_footer.track_twn) 
  85. 			Music_store_footer.track_twn = nil 
  86. 		end 
  87. 		 
  88. 		if Music_store_footer.artist_fade_twn ~= nil then 
  89. 			vint_object_destroy(Music_store_footer.artist_fade_twn) 
  90. 			Music_store_footer.artist_fade_twn = nil 
  91. 		end 
  92. 		 
  93. 		if Music_store_footer.artist_twn ~= nil then 
  94. 			vint_object_destroy(Music_store_footer.artist_twn) 
  95. 			Music_store_footer.artist_twn = nil 
  96. 		end 
  97. end 
  98.  
  99. function music_store_build_footer(menu_data) 
  100. 	if menu_data.footer_height ~= nil and menu_data.footer_height ~= 0 then 
  101. 		 
  102. 		music_store_clean_footer() 
  103. 						 
  104. 		Music_store_footer.clip_width = nil 
  105. 		 
  106. 		--	Find the footer 
  107. 		local grp = vint_object_clone(vint_object_find("music_store_footer"), Menu_option_labels.control_parent) 
  108. 		vint_set_property(grp, "visible", true) 
  109.  
  110. 		--	Destroy the stale footer 
  111. 		if menu_data.footer ~= nil and menu_data.footer.footer_grp ~= nil and menu_data.footer.footer_grp ~= 0 then 
  112. 			vint_object_destroy(menu_data.footer.footer_grp) 
  113. 		end 
  114.  
  115. 		menu_data.footer = { } 
  116. 		menu_data.footer.footer_grp = grp 
  117. 		 
  118. 		-- Initialize everything 
  119. 		Music_store_footer.clip_h = vint_object_find("music_footer_clip", grp) 
  120. 		Music_store_footer.artist_h = vint_object_find("artist_label", grp) 
  121. 		Music_store_footer.track_h = vint_object_find("track_label", grp) 
  122. 		Music_store_footer.price_h = vint_object_find("price_amount", grp) 
  123. 		 
  124. 		vint_set_property(Music_store_footer.artist_h, "offset", 0, 0) 
  125. 		vint_set_property(Music_store_footer.track_h, "offset", 0, 0) 
  126. 		 
  127. 		vint_set_property(Music_store_footer.artist_h, "visible", true) 
  128. 		vint_set_property(Music_store_footer.track_h, "visible", true) 
  129. 		vint_set_property(Music_store_footer.price_h , "visible", true) 
  130. 	end 
  131. end 
  132.  
  133. function music_store_update_footer(idx) 
  134. 	local menu_item = Music_store_menu[idx] 
  135. 	--	Make sure we have a footer 
  136. 	if Music_store_menu.footer_height ~= nil and Music_store_menu.footer_height ~= 0 then 
  137. 		-- Tint it according to the price (if the player can afford it 
  138. 		if menu_store_get_player_cash() < menu_item.price then 
  139. 			vint_set_property(Music_store_footer.price_h, "tint", 1, 0, 0) 
  140. 		else 
  141. 			vint_set_property(Music_store_footer.price_h, "tint", 0.88, 0.749, 0.05) 
  142. 		end 
  143. 		--	Set the other properties to reflect the track 
  144. 		vint_set_property(Music_store_footer.price_h, "text_tag", "$" .. format_cash(menu_item.price)) 
  145. 		vint_set_property(Music_store_footer.artist_h, "text_tag", menu_item.artist_name) 
  146. 		vint_set_property(Music_store_footer.track_h, "text_tag", menu_item.track_name) 
  147. 	end 
  148. end 
  149.  
  150. function music_store_finalize_footer(menu_data) 
  151. 	--	Make sure we have a footer 
  152. 	if menu_data.footer_height ~= nil and menu_data.footer_height ~= 0 then 
  153. 		local price_size_x, price_size_y = vint_get_property(Music_store_footer.price_h, "screen_size") 
  154. 		local clip_width = menu_data.menu_width - price_size_x - 23 
  155. 		Music_store_footer.clip_width = clip_width 
  156. 		 
  157. 		--	Correct the position of the price 
  158. 		vint_set_property(Music_store_footer.price_h, "anchor", menu_data.menu_width - 20, 0) 
  159. 		vint_set_property(Music_store_footer.clip_h, "clip_size", clip_width, 60) 
  160.  
  161. 		music_store_scroll_footer() 
  162. 	end 
  163. 	 
  164. 	btn_tips_update() 
  165. end 
  166.  
  167. function music_store_scroll_footer() 
  168. 	music_store_clean_footer() 
  169.  
  170. 	-- If the clip_width is messed up, carry on 
  171. 	if Music_store_footer.clip_width == nil or Music_store_footer.clip_width == 0 then 
  172. 		return 
  173. 	end 
  174. 	 
  175. 	if Music_store_menu.footer_height ~= nil and Music_store_menu.footer_height ~= 0 then 
  176. 		local artist_duration = 0 
  177. 		local track_duration = 0 
  178. 		local duration = 0 
  179. 		local twn = 0 
  180.  
  181. 		-- Cleaning up a mess a little bit by putting these 2 together. 
  182. 		for i = 0, 1 do 
  183. 			local handle = 0 
  184. 			if i == 0 then 
  185. 				handle = Music_store_footer.artist_h 
  186. 			else 
  187. 				handle = Music_store_footer.track_h 
  188. 			end 
  189. 			 
  190. 			local text_width, text_height = element_get_actual_size(handle, "screen_size") 
  191. 			local clipped_width = text_width - Music_store_footer.clip_width 
  192.  
  193. 			-- Doesn't need to scroll if clipped width is under 0 
  194. 			if clipped_width > 0 then 
  195. 				clipped_width = clipped_width + 15 
  196. 				duration = MENU_MARQUEE_SPEED * clipped_width 	--	Store the duration 
  197. 			 
  198. 				twn = vint_object_create("footer_tween", "tween", vint_object_find("root_animation", nil, MUSIC_STORE_DOC_HANDLE)) 
  199. 				vint_set_property(twn, "target_handle", handle) 
  200. 				vint_set_property(twn, "target_property", "offset") 
  201. 				vint_set_property(twn, "start_value", 0, 0) 
  202. 				vint_set_property(twn, "end_value", 0 - clipped_width, 0)	 
  203. 				vint_set_property(twn, "duration", duration) 
  204. 				vint_set_property(twn, "start_time", vint_get_time_index() + MENU_MARQUEE_DELAY) 
  205. 			 
  206. 				if i == 0 then 
  207. 					artist_duration = duration 
  208. 					Music_store_footer.artist_twn = twn 
  209. 					Music_store_footer.artist_clipped_width = clipped_width 
  210. 				else 
  211. 					track_duration = duration 
  212. 					Music_store_footer.track_twn = twn 
  213. 					Music_store_footer.track_clipped_width = clipped_width 
  214. 				end 
  215. 			end 
  216. 		end 
  217. 		 
  218. 		--	Set the call back on the longer one 
  219. 		if (Music_store_footer.artist_twn == nil or Music_store_footer.artist_twn == 0) and (Music_store_footer.track_twn == nil or Music_store_footer.track_twn == 0) then 
  220. 			return 
  221. 		end 
  222. 		 
  223. 		if artist_duration > track_duration then 
  224. 			twn = Music_store_footer.artist_twn 
  225. 		else 
  226. 			twn = Music_store_footer.track_twn 
  227. 		end 
  228. 		 
  229. 		vint_set_property(twn, "end_event", "music_footer_scroll_twn_end") 
  230. 	end 
  231. end 
  232.  
  233. function music_footer_scroll_twn_end() 
  234.    if Music_store_footer.fade_thread ~= nil then 
  235. 		thread_kill(Music_store_footer.fade_thread) 
  236. 	end 
  237. 	 
  238. 	Music_store_footer.fade_thread = thread_new("music_footer_fade_twn_start") 
  239. end 
  240.  
  241. function music_footer_fade_twn_start() 
  242. 	delay(MENU_MARQUEE_DELAY) 
  243. 	local twn = 0 
  244.  
  245. 	if Music_store_footer.artist_twn ~= nil and Music_store_footer.artist_twn ~= 0 then 
  246. 		twn =	vint_object_create("footer_fade_twn", "tween", vint_object_find("root_animation", nil, MUSIC_STORE_DOC_HANDLE)) 
  247. 		vint_set_property(twn, "target_handle", Music_store_footer.artist_h) 
  248. 		vint_set_property(twn, "target_property", "alpha") 
  249. 		vint_set_property(twn, "start_value", 1) 
  250. 		vint_set_property(twn, "end_value", 0) 
  251. 		vint_set_property(twn, "duration", MUSIC_STORE_FOOTER_FADE_TIME) 
  252. 		vint_set_property(twn, "start_time", vint_get_time_index()) 
  253. 		vint_set_property(twn, "end_event", "music_footer_fade_twn_end") 
  254. 	end 
  255. 	 
  256. 	if Music_store_footer.artist_fade_twn ~= nil and Music_store_footer.artist_fade_twn ~= 0 then 
  257. 		vint_object_destroy(Music_store_footer.artist_fade_twn) 
  258. 	end 
  259. 	 
  260. 	Music_store_footer.artist_fade_twn = twn 
  261. 	twn = 0 
  262. 	 
  263. 	if Music_store_footer.track_twn ~= nil and Music_store_footer.track_twn ~= 0 then 
  264. 		twn =	vint_object_create("footer_fade_twn", "tween", vint_object_find("root_animation", nil, MUSIC_STORE_DOC_HANDLE)) 
  265. 		vint_set_property(twn, "target_handle", Music_store_footer.track_h) 
  266. 		vint_set_property(twn, "target_property", "alpha") 
  267. 		vint_set_property(twn, "start_value", 1) 
  268. 		vint_set_property(twn, "end_value", 0) 
  269. 		vint_set_property(twn, "duration", MUSIC_STORE_FOOTER_FADE_TIME) 
  270. 		vint_set_property(twn, "start_time", vint_get_time_index()) 
  271. 		if Music_store_footer.artist_fade_twn == 0 then 
  272. 			vint_set_property(twn, "end_event", "music_footer_fade_twn_end") 
  273. 		end 
  274. 	end 
  275. 	 
  276. 	if Music_store_footer.track_fade_twn ~= nil and Music_store_footer.track_fade_twn ~= 0 then 
  277. 		vint_object_destroy(Music_store_footer.track_fade_twn) 
  278. 	end 
  279. 		 
  280. 	Music_store_footer.track_fade_twn = twn 
  281. end 
  282.  
  283. function music_footer_fade_twn_end() 
  284.    if Music_store_footer.restart_thread ~= nil then 
  285. 		thread_kill(Music_store_footer.restart_thread) 
  286. 	end 
  287. 	 
  288. 	Music_store_footer.restart_thread = thread_new("music_footer_twn_restart") 
  289. end 
  290.  
  291. function music_footer_twn_restart() 
  292. 	delay(MENU_MARQUEE_DELAY) 
  293. 	vint_set_property(Music_store_footer.artist_h, "offset", 0, 0) 
  294. 	vint_set_property(Music_store_footer.track_h, "offset", 0, 0) 
  295. 	 
  296. 	vint_set_property(Music_store_footer.artist_h, "alpha", 1) 
  297. 	vint_set_property(Music_store_footer.track_h, "alpha", 1) 
  298. 	 
  299. 	delay(MENU_MARQUEE_DELAY) 
  300. 	if Music_store_footer.artist_twn ~= 0 and Music_store_footer.artist_twn ~= nil then 
  301. 		vint_set_property(Music_store_footer.artist_twn, "state", "waiting") 
  302. 		vint_set_property(Music_store_footer.artist_twn, "start_time", vint_get_time_index()) 
  303. 	end 
  304. 	 
  305. 	if Music_store_footer.track_twn ~= 0 and Music_store_footer.track_twn ~= nil then 
  306. 		vint_set_property(Music_store_footer.track_twn, "state", "waiting") 
  307. 		vint_set_property(Music_store_footer.track_twn, "start_time", vint_get_time_index()) 
  308. 	end 
  309. end 
  310.  
  311. function	music_store_release(menu_data) 
  312. 	-- Clean up the group when the menu is released 
  313. 	if menu_data.footer_height ~= 0 and menu_data.footer_height ~= nil and menu_data.footer ~= nil then 
  314. 		vint_set_property(menu_data.footer.footer_grp, "visible", false) 
  315. 		vint_object_destroy(menu_data.footer.footer_grp) 
  316. 	end 
  317. end 
  318.  
  319. ------------------------ 
  320. --	MENU FUNCTIONALITY -- 
  321. ------------------------ 
  322. function music_store_build_horz_menu() 
  323. 	Music_store_horz_menu.num_items = 0 
  324. 	--	Get all the genres for the top menu 
  325. 	vint_dataresponder_request("music_store_populate_genres", "music_store_add_genres", 0) 
  326. 	local unlockable = table_clone(Music_store_horz_menu[0]) 
  327. 	for i = 0, Music_store_horz_menu.num_items - 2 do 
  328. 		Music_store_horz_menu[i] = 	table_clone(Music_store_horz_menu[i + 1]) 
  329. 	end 
  330. 	 
  331. --	Music_store_horz_menu[Music_store_horz_menu.num_items - 1] = table_clone(unlockable) 
  332. --	DAD 7/30/08 - Remove unlockables altogether. TDL 254954 
  333. 	Music_store_horz_menu.num_items = Music_store_horz_menu.num_items - 1 
  334. 	 
  335. end 
  336.  
  337. function music_store_add_genres(display_name) 
  338. 	local new_table = table_clone(Music_store_menu_a) 
  339. 	 
  340. 	--	Set the genre 
  341. 	Music_store_horz_menu[Music_store_horz_menu.num_items] = { label = display_name, genre = Music_store_horz_menu.num_items,  sub_menu=new_table } 
  342. 	--	Increment the count 
  343. 	Music_store_horz_menu.num_items = Music_store_horz_menu.num_items + 1 
  344. end 
  345.  
  346. function music_store_sort_menu(menu_data) 
  347. 	 
  348. 	if Music_store_btns.x_button == nil then 
  349. 		return 
  350. 	end	 
  351. 	 
  352. 	-- Toggle what to sort by 
  353. 	if Music_store_sort_data.sort_by_artist == true then  
  354. 		Music_store_sort_data.sort_by_artist = false 
  355. 	else 
  356. 		Music_store_sort_data.sort_by_artist = true 
  357. 	end 
  358. 	 
  359. 	--	Store the name of the artist and track so that we can highlight the same track after sorting 
  360. 	Music_store_sort_data.sorted_artist = Music_store_menu[Music_store_menu.highlighted_item].artist_name 
  361. 	Music_store_sort_data.sorted_track  = Music_store_menu[Music_store_menu.highlighted_item].track_name 
  362. 	 
  363. 	Music_store_dont_preview = true 
  364. 	--	Rebuild the menu, sorted 
  365. 	music_store_rebuild_menu(menu_data) 
  366. end 
  367.  
  368. function music_store_rebuild_menu(menu_data)  
  369. 	local menu_to_use 
  370. 	local swapped 
  371.  
  372. 	--	Swap out the real menu with the a 3rd menu and store whether or not we've done that 
  373. 	if Music_store_sort_data.sorted_menu == false then 
  374. 		menu_to_use = Music_store_menu_c 
  375. 		swapped = true 
  376. 	else 
  377. 		menu_to_use = Music_store_horz_menu[Music_store_horz_menu.current_selection].sub_menu 
  378. 		swapped = false 
  379. 	end 
  380. 	 
  381. 	-- Show the sorted menu 
  382. 	menu_show(menu_to_use, MENU_TRANSITION_SWEEP_LEFT) 
  383. 	 
  384. 	--	Make sure we keep the fact it was sorted 
  385. 	Music_store_sort_data.sorted_menu = swapped 
  386. 	music_store_finalize_footer(menu_to_use) 
  387. end 
  388.  
  389. function music_store_build_menu(menu_data) 
  390. 	Music_store_menu = menu_data 
  391. 	Music_store_sort_data.sorted_menu = false 
  392. 	Music_store_menu.num_items = 0 
  393. 	 
  394. 	--	Build the menu 
  395. 	vint_dataresponder_request("music_store_populate_tracks", "music_store_add_tracks", 0, Music_store_horz_menu[Music_store_horz_menu.current_selection].genre, Music_store_sort_data.sort_by_artist) 
  396. 	 
  397. 	--	No footer if there are no tracks 
  398. 	if Music_store_menu.num_items == 0 then 
  399. 		Music_store_menu.num_items = 1 
  400. 		Music_store_menu[0] = { label = "STORE_MUSIC_NOT_UNLOCKED", type=MENU_ITEM_TYPE_SELECTABLE } 
  401. 		Music_store_menu.footer_height = 0 
  402. 		Music_store_btns.x_button = nil 
  403. 	else  
  404. 		Music_store_menu.footer_height = 40 
  405. 		 
  406. 		if Music_store_sort_data.sort_by_artist == false then 
  407. 			Music_store_btns.x_button = { label = "MP3_PLAYLIST_OPTIONS_SORT_ARTIST", enabled = btn_tips_default_x, } 
  408. 		else 
  409. 			Music_store_btns.x_button = { label = "MP3_PLAYLIST_OPTIONS_SORT_TITLE", enabled = btn_tips_default_x, } 
  410. 		end 
  411. 	end 
  412. 	 
  413. 	--	Update the header 
  414. 	menu_data.highlighted_item = 0 
  415. 	menu_data.header_label_str = Music_store_horz_menu[Music_store_horz_menu.current_selection].label 
  416.  
  417. 	-- Select the same track if we just sorted 
  418. 	if Music_store_sort_data.sorted_artist ~= 0 and Music_store_sort_data.sorted_artist ~= nil then 
  419. 		for i = 0, menu_data.num_items - 1 do 
  420. 			-- We found it, so highlight it, reset the stored artist/track and exit the loop 
  421. 			if menu_data[i].artist_name == Music_store_sort_data.sorted_artist and menu_data[i].track_name == Music_store_sort_data.sorted_track then 
  422. 				menu_data.highlighted_item = i 
  423. 				Music_store_sort_data.sorted_artist = nil 
  424. 				Music_store_sort_data.sorted_track_name = nil 
  425. 				i = menu_data.num_items 
  426. 			end 
  427. 		end 
  428. 	end 
  429.  
  430. 	-- Build the footer and correct the data 
  431. 	music_store_build_footer(menu_data) 
  432. 	music_store_update_footer(menu_data.highlighted_item) 
  433. 	 
  434. 	--	If we have a footer, that means its a real menu, and preview the track 
  435. 	if (Music_store_menu.footer_height ~= nil and Music_store_menu.footer_height ~= 0) or Music_store_menu[Music_store_menu.highlighted_item].id ~= nil then 
  436. 		if Music_store_dont_preview == true then 
  437. 			Music_store_dont_preview = false 
  438. 		else 
  439. 			music_store_preview_track(Music_store_menu[Music_store_menu.highlighted_item].id) 
  440. 		end 
  441. 	else  
  442. 		music_store_preview_track(-1) 
  443. 	end 
  444. end 
  445.  
  446. function music_store_add_tracks(artist_name, track_name, price) 
  447. 	local display_name 
  448. 	 
  449. 	--	Display the correct thing according to sort 
  450. 	if Music_store_sort_data.sort_by_artist == true then 
  451. 		display_name = artist_name 
  452. 	else 
  453. 		display_name = track_name 
  454. 	end 
  455. 	 
  456. 	Music_store_menu[Music_store_menu.num_items] = { label = display_name, type = MENU_ITEM_TYPE_SELECTABLE, on_select = music_store_purchase, on_nav = music_store_nav_item, price = price, id = Music_store_menu.num_items, artist_name=artist_name, track_name=track_name } 
  457. 	Music_store_menu.num_items = Music_store_menu.num_items + 1 
  458. end 
  459.  
  460. function music_store_purchase(menu_label, menu_data) 
  461. 	-- Confirm the purchase if we can afford it 
  462. 	if menu_store_get_player_cash() >= menu_data.price then 
  463. --		local body = "Do you wish to purchase " .. menu_data.artist_name .. " - " .. menu_data.track_name .. " for " .. format_cash(menu_data.price) .. "?" 
  464. 		local insertion_values = { [0] = menu_data.artist_name, [1] = menu_data.track_name, [2] = format_cash(menu_data.price) } 
  465. 		local body = vint_insert_values_in_string("MUSIC_STORE_PURCHASE_PROMPT", insertion_values) 
  466. 		local heading = "MENU_TITLE_CONFIRM" 
  467. 		dialog_box_confirmation(heading, body, "music_store_confirm_selection") 
  468. 		Music_store_current_selection = menu_data 
  469. 	else  
  470. 		dialog_box_message("MENU_TITLE_NOTICE", "HUD_SHOP_INSUFFICIENT_FUNDS") 
  471. 	end 
  472. end 
  473.  
  474. function music_store_confirm_selection(result, action) 
  475. 	if action ~= DIALOG_ACTION_CLOSE then 
  476. 		return 
  477. 	end 
  478. 	 
  479. 	-- If they want it, then buy it, and rebuild the menu to reflect that its no longer on the menu 
  480. 	if result == 0 then 
  481. 		award_style("music", Music_store_current_selection.price) 
  482. 		music_store_make_purchase(Music_store_current_selection.id) 
  483. 		music_store_rebuild_menu(Music_store_menu) 
  484. 		audio_play(Menu_sound_purchase) 
  485. 	end 
  486. end 
  487.  
  488. function music_store_nav_item(menu_data) 
  489. 	if Music_store_menu.footer_height ~= nil then 
  490. 		vint_set_property(Music_store_footer.artist_h, "offset", 0, 0) 
  491. 		vint_set_property(Music_store_footer.track_h, "offset", 0, 0) 
  492.  
  493. 		if Music_store_footer.artist_twn ~= nil then 
  494. 			vint_object_destroy(Music_store_footer.artist_twn) 
  495. 			Music_store_footer.artist_twn = nil 
  496. 		end 
  497. 		if Music_store_footer.artist_thread ~= nil then 
  498. 			thread_kill(Music_store_footer.artist_thread) 
  499. 			Music_store_footer.artist_thread = nil 
  500. 		end 
  501. 		 
  502. 		if Music_store_footer.track_twn ~= nil then 
  503. 			vint_object_destroy(Music_store_footer.track_twn) 
  504. 			Music_store_footer.track_twn = nil 
  505. 		end 
  506. 		if Music_store_footer.track_thread ~= nil then 
  507. 			thread_kill(Music_store_footer.track_thread) 
  508. 			Music_store_footer.track_thread = nil 
  509. 		end 
  510. 		 
  511. 		-- When traversing the menu, update the preview and footer when nav'ing 
  512. 		if (Music_store_menu.footer_height ~= nil and Music_store_menu.footer_height ~= 0) or Music_store_menu[Music_store_menu.highlighted_item].id ~= nil then 
  513. 			music_store_preview_track(Music_store_menu[Music_store_menu.highlighted_item].id) 
  514. 		end 
  515. 		 
  516. 		music_store_update_footer(Music_store_menu[Music_store_menu.highlighted_item].id) 
  517.  
  518. 		music_store_scroll_footer() 
  519. 	end 
  520. end 
  521.  
  522. --------------- 
  523. -- MENU DATA -- 
  524. --------------- 
  525. Music_store_btns = { 
  526. 	a_button = { label = "CONTROL_SELECT", enabled = btn_tips_default_a, }, 
  527. 	x_button = { label = "MP3_PLAYLIST_OPTIONS_SORT_TITLE", enabled = btn_tips_default_x, }, 
  528. 	b_button = { label = "CONTROL_RESUME", enabled = btn_tips_default_b, }, 
  529. } 
  530.  
  531. Music_store_menu_a = { 
  532. 	header_str 		= "NONE", 
  533. 	on_show 	  		= music_store_build_menu, 
  534. 	on_back 	  		= music_store_exit, 
  535. 	on_release 	  	= music_store_release, 
  536. 	on_nav			= music_store_nav_item, 
  537. 	on_alt_select 	= music_store_sort_menu, 
  538. 	on_post_show	= music_store_finalize_footer, 
  539. 	num_items  		= 0, 
  540. 	 
  541. 	btn_tips 		= Music_store_btns, 
  542. 	footer_height 	= 40, 
  543. } 
  544.  
  545. Music_store_menu_b = { 
  546. 	header_str 		= "NONE", 
  547. 	on_show 	  		= music_store_build_menu, 
  548. 	on_back 	  		= music_store_exit, 
  549. 	on_release 	  	= music_store_release, 
  550. 	on_nav			= music_store_nav_item, 
  551. 	on_alt_select 	= music_store_sort_menu, 
  552. 	on_post_show	= music_store_finalize_footer, 
  553. 	num_items  		= 0, 
  554.  
  555. 	btn_tips 		= Music_store_btns, 
  556. 	footer_height = 40, 
  557. } 
  558.  
  559. Music_store_menu_c = { 
  560. 	header_str 		= "NONE", 
  561. 	on_show 	  		= music_store_build_menu, 
  562. 	on_back 	  		= music_store_exit, 
  563. 	on_release 	  	= music_store_release, 
  564. 	on_nav			= music_store_nav_item, 
  565. 	on_alt_select 	= music_store_sort_menu, 
  566. 	on_post_show	= music_store_finalize_footer, 
  567. 	num_items  		= 0, 
  568. 	 
  569. 	btn_tips 		= Music_store_btns, 
  570. 	footer_height = 40, 
  571. } 
  572.  
  573.  
  574. Music_store_horz_menu = { 
  575. 	num_items = 0, 
  576. 	current_selection = 0, 
  577. 	 
  578. } 
  579.