./vdo_pause_mega_list.lua

  1. local PAUSE_LIST_BUTTON_HEIGHT	 	= 32 
  2. local PAUSE_LIST_HIGHLIGHT_HEIGHT 	= 10 
  3. Vdo_pause_mega_list_tween_done = true 
  4.  
  5. local PAUSE_MEGA_LIST_ALIGN_LEFT = 0 
  6. local PAUSE_MEGA_LIST_ALIGN_CENTER = 1 
  7.  
  8. local PAUSE_MEGA_LIST_DEFAULT_WIDTH = 700 
  9.  
  10. function vdo_pause_mega_list_init() 
  11. 	local anim_h = vint_object_find("mega_list_in_anim") 
  12. 	vint_set_property(anim_h, "is_paused", true) 
  13. end 
  14.  
  15. function vdo_pause_mega_list_cleanup() 
  16. end 
  17.  
  18. function Vdo_pause_mega_list_scroll_done(tween_h, event_name) 
  19. 	-- remove this callback 
  20. 	remove_tween_end_callback( vint_object_find("toggle_group_anchor_tween") ) 
  21. 	Vdo_pause_mega_list_tween_done = true 
  22. end 
  23.  
  24. -- Inherited from Vdo_base_object 
  25. Vdo_pause_mega_list = Vdo_base_object:new_base() 
  26.  
  27.  
  28. -------------------------------------------------------------------------------- 
  29. -- Initializes Mega List7 
  30. -------------------------------------------------------------------------------- 
  31. function Vdo_pause_mega_list:init() 
  32.  
  33. 	self.anim_in_func_cb  			= -1			--Animation callback func... 
  34. 	self.anim_out_func_cb  			= -1			--Animation callback func... 
  35. 	self.drawn_at_least_once		= false		--Determines if we've drawn at least once. The menu MUST animate everytime you see it at first. 
  36. 	 
  37. 	-- Hide the initial button 
  38. 	vint_set_property(vint_object_find("base", self.handle), "visible", false) 
  39.  
  40. 	self.button_copy = Vdo_pause_button_toggle:new("base", self.handle) 
  41. 	self.button_copy_x, self.button_copy_y = self.button_copy:get_property("anchor") 
  42.  
  43. 	self.highlight = Vdo_pause_button_highlight:new("highlight", self.handle) 
  44. 	 
  45. 	--Animation that slide that scales all the objects in. 
  46. 	local mega_list_anim_in = Vdo_anim_object:new("mega_list_in_anim", self.handle) 
  47. 	mega_list_anim_in:stop() 
  48. 	 
  49. 	Vdo_pause_mega_list_tween_done = true 
  50. end 
  51.  
  52.  
  53. -------------------------------------------------------------------------------- 
  54. -- Deletes the internal data and destroys the button clones 
  55. -------------------------------------------------------------------------------- 
  56. function Vdo_pause_mega_list:cleanup() 
  57. 	if self.draw_called then 
  58. 		for i, button in pairs(self.buttons) do 
  59. 			button:object_destroy() 
  60. 		end 
  61. 		self.draw_called = false 
  62. 	end 
  63. end 
  64.  
  65. function Vdo_pause_mega_list:set_list_alignment(alignment) 
  66. 	if alignment == "center" then 
  67. 		alignment = PAUSE_MEGA_LIST_ALIGN_CENTER 
  68. 	elseif alignment == "left" then 
  69. 		alignment = PAUSE_MEGA_LIST_ALIGN_LEFT  
  70. 	else 
  71. 		alignment = PAUSE_MEGA_LIST_ALIGN_LEFT  
  72. 	end 
  73. 	self.alignment = alignment  
  74. end 
  75.  
  76. function Vdo_pause_mega_list:set_width(width) 
  77. 	self.width = width 
  78. end 
  79.  
  80. -------------------------------------------------------------------------------- 
  81. -- Draws the megalist for the first time. Usually called immediatly after the  
  82. -- initialization of the object. 
  83. --	 
  84. -- @param data					Data  
  85. -- @param current_options	Which option is set to highlight in the list 
  86. -- @param width				Size in pixels the width of the list 
  87. -- @param max_buttons		How many buttosn can appear in the list 
  88. -- @param alignment			aligns text to left or center... ("left", "center") 
  89. -- @param refresh				set to true if you do not want to animate 
  90. -------------------------------------------------------------------------------- 
  91. function Vdo_pause_mega_list:draw_items(data, current_option, width, max_buttons, alignment, refresh) 
  92.  
  93. 	--Defaults 
  94. 	max_buttons = max_buttons or 999 
  95.  
  96. 	-- Error Check 
  97. 	for idx, val in pairs(data) do 
  98. 		if type(val) ~= "table" then 
  99. 			debug_print("vint", "Vdo_pause_mega_list:draw_items was called with impropperly formatted parameters!\n") 
  100. 			return 
  101. 		end 
  102. 	end 
  103. 	 
  104. 	-- Nuke the shit out of whatever was previously here 
  105. 	self:cleanup() 
  106.  
  107. 	-- Set up handle for base button 
  108. 	local button_copy = self.button_copy 
  109. 	if button_copy.handle == 0 then 
  110. 		debug_print("vint", "Unable to find object \"base\"") 
  111. 		return 
  112. 	end 
  113. 	 
  114. 	--TODO: Put these at the top of the file... 
  115. 	-- Set up tables to manage handles and data for this object 
  116. 	self.draw_called = true 
  117. 	self.buttons = {} 
  118. 	self.data = data 
  119. 	self.open = false 
  120. 	self.old_slider_value = nil 
  121. 	self.max_buttons = 0 
  122. 	 
  123. 	-- Set initial cursor position 
  124. 	if current_option == nil then 
  125. 		current_option = 1 
  126. 	end 
  127. 	 
  128. 	 
  129. 	 
  130. 	if width ~= nil then 
  131. 		self.width = width 
  132. 	elseif self.width == nil or self.width == 0 then 
  133. 		self.width = PAUSE_MEGA_LIST_DEFAULT_WIDTH 
  134. 	end 
  135. 	self.slider_anchor_y = 0 
  136. 	self.toggle_anchor_y = 0 
  137. 	 
  138. 	-- Reassign our objects 
  139. 	self.group 			= Vdo_base_object:new("megalist_group", self.handle)	 
  140. 	 
  141. 	self.anims = {} 
  142. 	self.anims.mega_list_in = Vdo_anim_object:new("mega_list_in_anim", self.handle) 
  143. 	 
  144. 	--Set alignment... 
  145. 	if self.alignment == nil and alignment == nil then 
  146. 		self.alignment = PAUSE_MEGA_LIST_ALIGN_LEFT 
  147. 	elseif alignment ~= nil then 
  148. 		self:set_list_alignment(alignment) 
  149. 	end 
  150.  
  151. 	-- Save the number of buttons 
  152. 	self.num_buttons = #data 
  153. 	 
  154. 	for i = 1, self.num_buttons do 
  155. 		-- Assign the button copy to the table that manages data for this object 
  156. 		self.buttons[i] = Vdo_pause_button_toggle:clone(button_copy.handle) 
  157. 		local button = self.buttons[i] 
  158. 		 
  159. 		local val = data[i] 
  160. 		 
  161. 		--Set shadows if we have it... 
  162. 		if self.button_shadows ~= nil then 
  163. 			button:set_shadow(self.button_shadows) 
  164. 		end 
  165. 		 
  166. 		-- Set the button toggle text 
  167. 		button:set_label(val.label) 
  168. 	 
  169. 		local button_width = button:get_text_width() 
  170. 		 
  171. 		-- Move the button copy into the correct position 
  172. 		local new_y = self.button_copy_y + (PAUSE_LIST_BUTTON_HEIGHT  * (i - 1)) 
  173. 		 
  174. 		local x 
  175. 		if self.alignment == PAUSE_MEGA_LIST_ALIGN_CENTER then 
  176. 			--Center alignment... 
  177. 			x = self.button_copy_x - button_width/2 - 30 
  178. 		else 
  179. 			--Default left alignment... 
  180. 			x = self.button_copy_x 
  181. 		end 
  182. 		button:set_property("anchor", x, new_y) 
  183. 		 
  184. 		-- Make the button visible 
  185. 		button:set_property("visible", true) 
  186. 		 
  187. 		--Set color if we have it... 
  188. 		if self.button_unselected_color ~= nil and self.button_unselected_color ~= nil then 
  189. 			button:set_color(self.button_selected_color, self.button_unselected_color) 
  190. 		end 
  191. 				                  	 
  192. 		--Used for fading out the object... 
  193. 		local extra_obj_handle = -1 
  194. 		local x = 0 
  195. 		local y = 0 
  196. 		 
  197. 		--store the button toggle options 
  198. 		if val.type == TYPE_BUTTON then 
  199. 			-- Set the button toggle value 
  200. 			button:set_value("") 
  201. 			if val.disabled == true then 
  202. 				button:set_alpha(.5) 
  203. 			end 
  204. 		end 
  205. 		 
  206. 		if current_option == i then 
  207. 			button:set_highlight(true) 
  208. 		else 
  209. 			button:set_highlight(false) 
  210. 		end 
  211. 		 
  212. 	end 
  213. 	 
  214. 	--find largest button and then we will figure out the positions for everything... 
  215. 	local largest_button_width = 0 
  216. 	local current_button_width, current_button_height 
  217. 	for i = 1, self.num_buttons do 
  218. 		local button = self.buttons[i] 
  219. 		local button_x, button_y = button:get_anchor() 
  220. 		current_button_width = button_x + button:get_text_width() + 30 
  221. 		if current_button_width > largest_button_width then 
  222. 			largest_button_width = current_button_width 
  223. 		end 
  224. 	end 
  225.  
  226. 	--Tween the animations... 
  227. 	local anchor_tween = Vdo_tween_object:new("mg_anchor_twn", self.handle)			 
  228. 	for i = 1, self.num_buttons do 
  229. 		local button = self.buttons[i] 
  230. 		 
  231. 		-- clone tween and retarget animation 
  232. 		local time_offset = i * (3/30) 
  233. 		local anchor_tween_clone = Vdo_tween_object:clone(anchor_tween.handle) 
  234. 		anchor_tween_clone:set_property("target_handle", button.handle) 
  235. 	 
  236. 		if self.alignment == PAUSE_MEGA_LIST_ALIGN_CENTER then 
  237. 			--overload anchor tween clone with basic fade values.. 
  238. 			anchor_tween_clone:set_property("start_time", time_offset) 
  239. 			anchor_tween_clone:set_property("target_property", "alpha") 
  240. 			anchor_tween_clone:set_property("start_value", 0) 
  241. 			anchor_tween_clone:set_property("end_value", 1) 
  242. 		else 
  243. 			--Calculate positions... 
  244. 			local start_x, start_y = anchor_tween_clone:get_property("start_value") 
  245. 			local end_x, end_y = anchor_tween_clone:get_property("end_value") 
  246. 			local temp_x, temp_y = button:get_anchor() 
  247. 			end_x = temp_x 
  248. 			end_y = temp_y  
  249. 			anchor_tween_clone:set_property("start_time", time_offset) 
  250. 			anchor_tween_clone:set_property("start_value", start_x, end_y) 
  251. 			anchor_tween_clone:set_property("end_value",  end_x, end_y) 
  252. 		end 
  253. 		 
  254. 		--Final tween... so we can do some special stuff based on this... 
  255. 		if i == self.num_buttons then 
  256. 			--Set callback if we have one... 
  257. 			if self.anim_in_func_cb ~= -1 then 
  258. 				anchor_tween_clone:set_end_event(self.anim_in_func_cb) 
  259. 			end 
  260. 		end 
  261. 	end 
  262. 	 
  263. 	--Animate list 
  264. 	if refresh == false or self.drawn_at_least_once == false then 
  265. 		self.anims.mega_list_in:play(0) 
  266. 		self.drawn_at_least_once = true 
  267. 	else 
  268. 		self.anims.mega_list_in:play(-20) 
  269. 	end 
  270. 	 
  271. 	if current_option > self.num_buttons then 
  272. 		current_option = self.num_buttons 
  273. 	end 
  274. 	--set the cuurent button to the passed in variable for the current option 
  275. 	self.current_idx = current_option 
  276. 			 
  277. 	--set the size of the list 
  278. 	--self:set_size(width, max_buttons) 
  279. 	 
  280. 	--reset the y of the list group 
  281. 	local list_x, list_y =  self.group:get_property("anchor") 
  282. 	self.group:set_property("anchor",list_x,0) 
  283.  
  284. 	-- Draw the cursor 
  285. 	self:move_cursor(0) 
  286. end 
  287.  
  288. -------------------------------------------------------------------------------- 
  289. -- Sets the size of the mega list 
  290. -- @param width			Size in pixels the width of the list 
  291. -- @param max_buttons	How many buttosn can appear in the list 
  292. -------------------------------------------------------------------------------- 
  293. function Vdo_pause_mega_list:set_size(width, max_buttons) 
  294. 	if not self.draw_called then 
  295. 		debug_print("vint", "Vdo_pause_mega_list:set_size called with invalid document handle\n") 
  296. 		return 
  297. 	end 
  298. end 
  299.  
  300.  
  301.  
  302. function Vdo_pause_mega_list:move_cursor(direction, is_index_set) 
  303. 	if not self.draw_called then 
  304. 		debug_print("vint", "Vdo_pause_mega_list:move_cursor called with invalid document handle\n") 
  305. 		return 
  306. 	end 
  307. 	 
  308. 	is_index_set = is_index_set or false 
  309. 	 
  310. 	-- Play sound for cursor movement... 
  311. 	if direction ~= 0 then 
  312. 		if direction == 1 then 
  313. 			game_UI_audio_play("Ui_main_menu_nav_up") 
  314. 		else 
  315. 			game_UI_audio_play("Ui_main_menu_nav_down") 
  316. 		end 
  317. 	elseif is_index_set then 
  318. 		game_UI_audio_play("Ui_main_menu_nav_up") 
  319. 	end 
  320. 	 
  321. 	local highlight = self.highlight 
  322. 	--check to see if the toggle is open 
  323. 	if not self.open then 
  324. 		--check if we can process input 
  325. 		if Vdo_pause_mega_list_tween_done then 
  326. 			-- Clear out old highlight 
  327. 			for idx, button in pairs(self.buttons) do 
  328. 				button:set_highlight(false) 
  329. 			end 
  330.  
  331. 			--toggle is closed so navigate the list normally 
  332. 			--Increment the direction 
  333. 			self.current_idx = wrap_index(self.current_idx, direction, self.num_buttons) 
  334. 			 
  335. 			local total_buttons = #self.data 
  336. 			local total_height = ( total_buttons * PAUSE_LIST_BUTTON_HEIGHT  ) + ( PAUSE_LIST_HIGHLIGHT_HEIGHT ) 
  337.  
  338. 			local new_y = total_height + 0 
  339. 			local list_x, list_y =  self.group:get_property("anchor") 
  340. 			local scrolling = false 
  341. 			local visual_center = ( self.max_buttons * 0.5 ) 
  342. 			--get the value for the visual bottom 
  343. 			local visual_center_bottom = total_buttons - visual_center 
  344. 			--do we need to scroll? 
  345. 			if (-1 * total_height) <= 0 then 
  346. 				scrolling = true 
  347. 				--move the list 
  348. 				local end_y = 5 
  349. 				if direction == -1 then 
  350. 					--is the current button half way from the visible top 
  351. 					if self.current_idx > visual_center then 
  352. 						--the current button is greater than or equal to the visual middle 
  353. 						--is the current button half way from the visible bottom 
  354. 						if self.current_idx < visual_center_bottom then 
  355. 							--the current button is less than or equal to the visual bottom center 
  356. 							--MOVE THE Y UP 
  357. 							new_y = list_y + PAUSE_LIST_BUTTON_HEIGHT 
  358. 						else 
  359. 							new_y = end_y 
  360. 						end 
  361. 					end 
  362. 				else 
  363. 					--is the current button half way from the visible top 
  364. 					if self.current_idx > visual_center then 
  365. 						--the current button is greater than or equal to the visual middle 
  366. 						--is the current button half way from the visible bottom 
  367. 						if self.current_idx < visual_center_bottom then 
  368. 							--the current button is less than or equal to the visual bottom center 
  369. 							--MOVE THE Y DOWN 
  370. 							new_y = list_y - PAUSE_LIST_BUTTON_HEIGHT 
  371. 						else 
  372. 							new_y = end_y 
  373. 						end 
  374. 					end 
  375. 				end 
  376. 		 
  377. 				Vdo_pause_mega_list_tween_done = true 
  378. 			end 
  379. 		 
  380. 			-- Get current button 
  381. 			local current_idx = self.current_idx 
  382. 			local current_button = self.buttons[current_idx] 
  383. 			 
  384. 			local current_button_data = self.data[current_idx] 
  385. 			 
  386. 			-- Highlight current button 
  387. 			current_button:set_highlight(true) 
  388. 			current_button:set_property("depth", -10) 
  389. 			current_button:set_property("blur", 0) 
  390. 		 
  391. 			highlight:set_property( "depth",  -1) 
  392. 			--get the current highlighted button x and y 
  393. 			local button_x, button_y = current_button:get_property("anchor") 
  394. 			highlight:set_property( "anchor", button_x, button_y ) 
  395. 			highlight:set_width(current_button:get_text_width()) 
  396. 			 
  397. 			--if there is only one button don't animate highlight 
  398. 			if self.num_buttons > 1 then 
  399. 				highlight:set_highlight() 
  400. 			end 
  401. 			 
  402. 			 
  403. 			-- Highlighting a button... 
  404. 			if self.data[current_idx].type == TYPE_BUTTON then 
  405. 				--Default controls... 
  406. 				--Show A Button 
  407. 				highlight:show_button(CTRL_MENU_BUTTON_A) 
  408. 			end 
  409. 			 
  410. 			if current_button_data.disabled == true then 
  411. 				--hide icon and button 
  412. 				current_button:set_property("alpha", 0.5) 
  413. 				highlight:show_button("") 
  414. 			else 
  415. 				current_button:set_property("alpha", 1.0) 
  416. 			end 
  417. 		end 
  418. 	elseif self.data[self.current_idx].type == TYPE_TOGGLE then 
  419. 		--toggle is open so send the navigation off to the toggle list 
  420. 		self.toggle:move_cursor(direction) 
  421. 	end 
  422. end 
  423.  
  424. function Vdo_pause_mega_list:get_selection() 
  425. 	if not self.draw_called then 
  426. 		debug_print("vint", "Vdo_pause_mega_list:get_selection called with invalid document handle\n") 
  427. 		return 
  428. 	end 
  429. 	 
  430. 	if self.data[self.current_idx].disabled == true then 
  431. 		return -1 
  432. 	end 
  433.  
  434. 	return self.current_idx 
  435. end 
  436.  
  437.  
  438. -- Gets an optional ID value if one is saved 
  439. function Vdo_pause_mega_list:get_id() 
  440. 	if not self.draw_called then 
  441. 		debug_print("vint", "Vdo_pause_mega_list:get_toggle_selection called with invalid document handle\n") 
  442. 		return 
  443. 	end 
  444. 	 
  445. 	if self.data[self.current_idx].disabled == true then 
  446. 		return -1 
  447. 	end 
  448. 	 
  449. 	return self.data[self.current_idx].id 
  450. end 
  451.  
  452. function Vdo_pause_mega_list:button_a() 
  453. 	if not self.draw_called then 
  454. 		debug_print("vint", "Vdo_pause_mega_list:button_a called with invalid document handle\n") 
  455. 		return 
  456. 	end 
  457. 	 
  458.  
  459. 	 
  460. 	local current_idx = self.current_idx 
  461. 	local button_data = self.data[current_idx] 
  462. 	local button =  self.buttons[current_idx] 
  463. 	 
  464. 	if button_data.type == TYPE_BUTTON then 
  465. 		--Play sound... 
  466. 		game_UI_audio_play("UI_main_menu_select") 
  467. 	end 
  468.  
  469. 	--Callback for selecting the object... 
  470. 	if button_data.on_select then 
  471. 		button_data.on_select(button_data) 
  472. 	end 
  473. 	 
  474. 	--check if we can process input 
  475. 	if not Vdo_pause_mega_list_tween_done then 
  476. 		return 
  477. 	end 
  478. 	 
  479. 	local current_button = self.buttons[current_idx] 
  480. end 
  481.  
  482. function Vdo_pause_mega_list:button_b() 
  483. 	if not self.draw_called then 
  484. 		debug_print("vint", "Vdo_pause_mega_list:button_b called with invalid document handle\n") 
  485. 		return 
  486. 	end 
  487. 	 
  488. 	--play sound... 
  489. 	game_UI_audio_play("UI_main_menu_nav_back") 
  490. 	 
  491. 	local current_idx = self.current_idx 
  492. 	local current_button = self.buttons[current_idx] 
  493. end 
  494.  
  495.  
  496. function Vdo_pause_mega_list:return_data() 
  497. 	if not self.draw_called then 
  498. 		debug_print("vint", "Vdo_pause_mega_list:return_data called with invalid document handle\n") 
  499. 		return 
  500. 	end 
  501. 	 
  502. 	return self.data 
  503. end 
  504.  
  505. function Vdo_pause_mega_list:return_selected_data() 
  506. 	if not self.draw_called then 
  507. 		debug_print("vint", "Vdo_pause_mega_list:return_selected_data called with invalid document handle\n") 
  508. 		return 
  509. 	end 
  510. 	 
  511. 	return self.data[self.current_idx] 
  512. end 
  513.  
  514. function Vdo_pause_mega_list:return_state() 
  515. 	 
  516. 	if not self.draw_called then 
  517. 		debug_print("vint", "Vdo_pause_mega_list:return_state called with invalid document handle\n") 
  518. 		return 
  519. 	end 
  520. 	 
  521. 	return self.open 
  522. end 
  523.  
  524. function Vdo_pause_mega_list:enable(state) 
  525. 	if not self.draw_called then 
  526. 		debug_print("vint", "Vdo_pause_mega_list:enable called with invalid document handle\n") 
  527. 		return 
  528. 	end 
  529. 	 
  530. 	local current_idx = self.current_idx 
  531. 	 
  532. 	for idx, button in pairs(self.buttons) do 
  533. 		button:set_enabled(state) 
  534. 	end 
  535. 	 
  536. 	local current_button = self.buttons[current_idx] 
  537. 	 
  538. 	-- Highlight/unhighlight current button 
  539. 	current_button:set_highlight(state) 
  540. 	current_button:set_enabled(state)		 
  541. end 
  542.  
  543. function Vdo_pause_mega_list:show_bar(is_on) 
  544. 	self.highlight:show_bar(is_on) 
  545. end 
  546.  
  547. function Vdo_pause_mega_list:toggle_highlight(is_on) 
  548. 	if not self.draw_called then 
  549. 		debug_print("vint", "Vdo_pause_mega_list:toggle_highlight called with invalid document handle\n") 
  550. 		return 
  551. 	end 
  552. 	 
  553. 	local highlight = self.highlight 
  554. 	highlight:set_property("visible", is_on) 
  555. 	 
  556. 	local current_idx = self.current_idx 
  557. 	 
  558. 	for idx, button in pairs(self.buttons) do 
  559. 		button:set_highlight(false) 
  560. 	end 
  561. 	 
  562. 	self.buttons[current_idx]:set_highlight(is_on) 
  563. end 
  564.  
  565. -- Method to set callback for when the transition animation is complete... 
  566. function  Vdo_pause_mega_list:set_anim_in_cb(callback_func) 
  567. 	self.anim_in_func_cb = callback_func 
  568. end 
  569.  
  570. -- Method to set callback for when the out animation is complete... 
  571. function  Vdo_pause_mega_list:set_anim_out_cb(callback_func) 
  572. 	self.anim_out_func_cb = callback_func 
  573. end 
  574.  
  575. function Vdo_pause_mega_list:transition_out() 
  576. 	local anim_out = Vdo_anim_object:new("mega_list_out_anim", self.handle) 
  577. 	local twn_out = Vdo_tween_object:new("megalist_out_twn", anim_out.handle) 
  578. 	twn_out:set_end_event(self.anim_out_func_cb) 
  579. 	anim_out:play() 
  580. end 
  581.  
  582. function Vdo_pause_mega_list:refresh_values(data) 
  583. 	if not self.draw_called then 
  584. 		debug_print("vint", "Vdo_pause_mega_list:refresh_values called with invalid document handle\n") 
  585. 		return 
  586. 	end 
  587. 	 
  588. 	for idx, val in pairs(data) do 
  589. 		--store the button toggle options 
  590. 		if data[idx].type == TYPE_BUTTON then 
  591. 			-- Set the button toggle value 
  592. 			self.buttons[idx]:set_value("") 
  593. 		end 
  594. 	end 
  595. end 
  596.  
  597. function Vdo_pause_mega_list:return_size() 
  598. 	local total_height 
  599. 	for idx, val in pairs(self.data) do 
  600. 		total_height = idx * LIST_BUTTON_HEIGHT 
  601. 	end 
  602. 	return self.width,total_height 
  603. end 
  604.  
  605. function Vdo_pause_mega_list:set_highlight_color(color) 
  606. 	self.highlight:set_color(color) 
  607. end 
  608.  
  609. function Vdo_pause_mega_list:set_button_color(selected_color, unselected_color) 
  610. 	self.button_selected_color 	= selected_color 
  611. 	self.button_unselected_color 	= unselected_color 
  612. end 
  613.  
  614. function Vdo_pause_mega_list:set_shadows(has_shadows) 
  615. 	self.button_shadows = has_shadows 
  616. end 
  617.  
  618. -- Sets the new current index 
  619. -- 
  620. function Vdo_pause_mega_list:set_selection(new_index) 
  621. 	if self.data[self.current_idx].disabled == true then 
  622. 		return 
  623. 	end 
  624.  
  625. 	self.current_idx = new_index 
  626. end 
  627.  
  628. -- ===================================== 
  629. --       Mouse Specific Functions 
  630. -- ===================================== 
  631.  
  632. -- Returns the button's index in the list based on the target handle. Returns 0 if nothing was found 
  633. -- 
  634. function Vdo_pause_mega_list:get_button_index(target_handle) 
  635. 	if self.buttons == nil then 
  636. 		return 
  637. 	end 
  638. 		 
  639. 	for idx, button in pairs(self.buttons) do 
  640. 		if self.alignment == PAUSE_MEGA_LIST_ALIGN_CENTER then 
  641. 			if vint_object_find("toggle_text", button.handle) == target_handle then 
  642. 				return idx 
  643. 			end 
  644. 		else 
  645. 			if button.handle == target_handle then 
  646. 				return idx 
  647. 			end 
  648. 		end 
  649. 	end 
  650.  
  651. 	-- If no matching target handle was found, return an invalid index 
  652. 	return 0 
  653. end 
  654.  
  655. -- Adds mouse input subscriptions to the input tracker 
  656. -- 
  657. -- @param	func_prefix			Name of the screen that is currently using the hint bar 
  658. -- @param	input_tracker		The input tracker to hold the mouse inputs events 
  659. -- @param	priority				The priority of the input event 
  660. function Vdo_pause_mega_list:add_mouse_inputs(func_prefix, input_tracker, priority) 
  661. 	if (self.buttons == nil) or (func_prefix == nil) then 
  662. 		return 
  663. 	end 
  664. 	 
  665. 	-- Default priority value to 50 
  666. 	priority = priority or 50 
  667. 	 
  668. 	local mouse_click_function = func_prefix.."_mouse_click" 
  669. 	local mouse_move_function = func_prefix.."_mouse_move" 
  670. 	 
  671. 	for idx, button in pairs(self.buttons) do 
  672. 		if self.alignment == PAUSE_MEGA_LIST_ALIGN_CENTER then 
  673. 			input_tracker:add_mouse_input("mouse_click", mouse_click_function, priority, vint_object_find("toggle_text", self.buttons[idx].handle)) 
  674. 			input_tracker:add_mouse_input("mouse_move", mouse_move_function, priority, vint_object_find("toggle_text", self.buttons[idx].handle)) 
  675. 			 
  676. 		else 
  677. 			input_tracker:add_mouse_input("mouse_click", mouse_click_function, priority, self.buttons[idx].handle) 
  678. 			input_tracker:add_mouse_input("mouse_move", mouse_move_function, priority, self.buttons[idx].handle) 
  679. 		end 
  680. 	end 
  681. end