./store_dlc.lua

  1. ---------------------------------------------------------------------------  
  2. -- DLC Store  
  3. -- Gets loaded from the main menu 
  4. -- Includes store_common for most of its megalist operations. 
  5. ------------------------------------------------------------------------ 
  6. local Store_dlc_doc_handle = 0 
  7. local Screen_width = 840 
  8. local STORE_DLC_LIST_SIZE = 745 
  9.  
  10. --Global/Local VDO objects 
  11. Store_dlc_scrollbox = {}--Scrollbox on this screen... 
  12.  
  13. Dlc_category_names = { 
  14. 	[1] = "DLC_FEATURE", 
  15. 	[2] = "DLC_GAMEPLAY", 
  16. 	[4] = "DLC_MISSION",  
  17. 	[8] = "DLC_PREVIEW", 
  18. } 
  19.  
  20. local Header_obj = -1 
  21. local Input_tracker 
  22. local Hint_bar 
  23. Store_dlc_list = -1 
  24.  
  25. local DLC_store_browsing_ready = false 
  26. local DLC_season_pass_installed = false 
  27. local DLC_season_pass_category_index = -1 
  28. local DLC_season_pass_category_added = false 
  29.  
  30. local Hint_bar_rotate 
  31. local Store_logo 
  32. local Store_popup 
  33. local Color_grid 
  34. local Color_grid_grp 
  35. local Not_popup_grp 
  36. local Reward_image 
  37.  
  38. local DLC_CATEGORY_LIST = 1 
  39. local DLC_ITEM_LIST = 2 
  40.  
  41. ---------------------------------------------------------------------------  
  42. -- Initialize DLC Store 
  43. --------------------------------------------------------------------------- 
  44. function store_dlc_init() 
  45. 	Store_dlc_doc_handle = vint_document_find("store_dlc") 
  46. 	ui_audio_post_event("UI_Hub_Menu_Forward") 
  47. 	if vint_is_std_res() then 
  48. 		Screen_width = 750 
  49. 	else 
  50. 		Screen_width = 840 
  51. 	end 
  52. 	 
  53. 	--set header 
  54. 	Header_obj = Vdo_pause_header:new("header",0,Store_dlc_doc_handle) 
  55. 	Header_obj:set_text("MAINMENU_DOWNLOADS", Screen_width) 
  56. 	 
  57. 	--Initialize scrollbox 
  58. 	Store_dlc_scrollbox = Vdo_scrollbox:new("scrollbox", 0, Store_dlc_doc_handle, "store_dlc.lua", "Store_dlc_scrollbox") 
  59. 	--Store_dlc_scrollbox:set_size(580, 181) 
  60. 	Store_dlc_scrollbox:set_size(Screen_width - 260, 173) 
  61. 	Store_dlc_scrollbox:set_color(COLOR_STORE_REWARDS_PRIMARY) 
  62. 	 
  63. 	--Start bg saints loop 
  64. 	local bg_saints_loop_h = vint_object_find("bg_saints_loop") 
  65. 	lua_play_anim(bg_saints_loop_h) 
  66. 	 
  67. 	--Start spinner animation 
  68. 	local spinner_anim_h = vint_object_find("spinner_anim", 0, Store_dlc_doc_handle) 
  69. 	lua_play_anim(spinner_anim_h) 
  70.  
  71. 	--Setup Button Hints 
  72.  
  73. 	Hint_bar = Vdo_hint_bar:new("hint_bar", 0, Store_dlc_doc_handle) 
  74. 	local hint_data = { 
  75. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"},	 
  76. 		{CTRL_BUTTON_X, "REDEEM_CODE"},	 
  77. 	} 
  78. 	Hint_bar:set_hints(hint_data) 	 
  79. 	Hint_bar:set_visible(true) 
  80.  
  81. 	-- subscribe to common inputs 
  82. 	Input_tracker = Vdo_input_tracker:new() 
  83. 	Input_tracker:add_input("pause", 		"store_dlc_nav_do_nothing", 	50) 
  84. 	Input_tracker:add_input("map", 			"store_dlc_nav_do_nothing", 	50) 
  85. 	Input_tracker:add_input("select", 		"store_dlc_nav_button_a", 		50) 
  86. 	Input_tracker:add_input("back", 			"store_dlc_nav_button_b", 		50)	 
  87. 	Input_tracker:add_input("alt_select", 	"store_dlc_nav_button_x", 		50)	 
  88. 	Input_tracker:add_input("nav_up", 		"store_dlc_nav_up", 				50) 
  89. 	Input_tracker:add_input("nav_down", 	"store_dlc_nav_down", 			50) 
  90. 	Input_tracker:add_input("nav_left", 	"store_dlc_nav_left", 			50) 
  91. 	Input_tracker:add_input("nav_right", 	"store_dlc_nav_right", 			50) 
  92. 	Input_tracker:add_input("right_joy_y", "store_dlc_input_joy",	 		50, true) 
  93. 		 
  94. 	--Setup list for the store... 
  95. 	Store_dlc_list = Vdo_mega_list:new("list_1", 0, Store_dlc_doc_handle, "store_dlc.lua", "Store_dlc_list") 
  96. 	Store_dlc_list:set_properties(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY, 5, .8, Screen_width, false, false) 
  97. 	Store_dlc_list:set_visible(false) 
  98. 	 
  99. 	store_dlc_item_show(false) 
  100. 	 
  101. 	--set text on the logo... 
  102. 	store_dlc_set_logo() 
  103. end 
  104.  
  105. function store_dlc_cleanup() 
  106.  
  107. 	--cleanup scrollbar... 
  108. 	--Store_dlc_scrollbox:destroy() 
  109. 	Input_tracker:subscribe(false) 
  110. end 
  111.  
  112. ------------------------------------------------------------------------------- 
  113. -- Navigation 
  114. ------------------------------------------------------------------------------- 
  115. function store_dlc_nav_do_nothing() 
  116. end 
  117.  
  118. function store_dlc_nav_button_a() 
  119. 	if Store_dlc_list:list_is_playing() == false then 
  120. 		--Set the screen data to the list data 
  121. 		local data = Store_dlc_list:return_data() 
  122. 		local current_index = Store_dlc_list:get_selection() 
  123. 		 
  124. 		--get select function from the dataset... 
  125. 		if data.on_select ~= nil then 
  126. 			--Execute select function 
  127. 			data.on_select(current_index) 
  128. 		end 
  129. 	end 
  130. end 
  131.  
  132. function store_dlc_nav_button_b() 
  133. 	if Store_dlc_list:list_is_playing() == false then 
  134. 		--Set the screen data to the list data 
  135. 		local data = Store_dlc_list:return_data() 
  136. 		 
  137. 		--get back function from the dataset... 
  138. 		if data.on_back ~= nil then 
  139. 			--Execute back function 
  140. 			data.on_back() 
  141. 		end 
  142. 	end 
  143. end 
  144.  
  145. function store_dlc_nav_button_x() 
  146. 	main_menu_redeem_code() 
  147. end 
  148.  
  149. function store_dlc_nav_up() 
  150. 	Store_dlc_list:move_cursor(-1)	 
  151. 	 
  152. 	--Set the screen data to the list data 
  153. 	local data = Store_dlc_list:return_data() 
  154. 	local selected_index = Store_dlc_list:get_selection() 
  155. 	 
  156. 	--Get on nav function from the dataset... 
  157. 	if data.on_nav ~= nil then 
  158. 		--Execute back function 
  159. 		data.on_nav(selected_index) 
  160. 	end 
  161. end 
  162.  
  163. function store_dlc_nav_down() 
  164. 	Store_dlc_list:move_cursor(1) 
  165. 	 
  166. 	--Set the screen data to the list data 
  167. 	local data = Store_dlc_list:return_data() 
  168. 	local selected_index = Store_dlc_list:get_selection() 
  169. 	 
  170. 	--Get on nav function from the dataset... 
  171. 	if data.on_nav ~= nil then 
  172. 		--Execute on nav function 
  173. 		data.on_nav(selected_index) 
  174. 	end 
  175. end 
  176.  
  177. function store_dlc_nav_left() 
  178. end 
  179.  
  180. function store_dlc_nav_right() 
  181. end 
  182.  
  183. function store_dlc_input_enable() 
  184. 	if DLC_store_browsing_ready then 
  185. 		Input_tracker:subscribe(true) 
  186. 	end 
  187. end 
  188.  
  189. function store_dlc_input_disable() 
  190. 	Input_tracker:subscribe(false) 
  191. end 
  192.  
  193. -------------------------------------------------------------------------------- 
  194. -- Categories functions... 
  195. -------------------------------------------------------------------------------- 
  196.  
  197. function store_dlc_retrieve_data_do() 
  198. 	-- reset the categories data 
  199. 	Store_dlc_categories_data = { 
  200. 		current_index = 1, 
  201. 		on_show = store_dlc_categories_on_show, 
  202. 		on_select = store_dlc_categories_select, 
  203. 		on_back = store_dlc_exit, 
  204. 		list_type = DLC_CATEGORY_LIST, 
  205. 	} 
  206.  
  207. 	store_dlc_categories_add("DLC_STORE_CAT_ALL", "AWESOME_IMAGE", -1)	-- No category id 
  208. 	vint_dataresponder_request("dlc_store_populate", "store_dlc_category_item_add", 0)		 
  209. 	Input_tracker:subscribe(true) 
  210. end 
  211.  
  212. function store_dlc_retrieve_data() 
  213. 	Input_tracker:subscribe(false) 
  214. 	thread_new("store_dlc_retrieve_data_do") 
  215. end 
  216. ------------------------------------------------------------------------------- 
  217. -- Populate function for the main category menu... 
  218. -- 
  219. -- list_data: 		this table contains the data to populate the megalist 
  220. -- current_index: 	the current index in the menu that's selected 
  221. -- 
  222. function store_dlc_categories_add(title, desc, cat_id) 
  223. 	local name = title 
  224. 	local image_name = desc 
  225. 	local menu_idx = #Store_dlc_categories_data + 1 
  226.  
  227. 	local new_item = { 
  228. 		type = TYPE_BUTTON, 
  229. 		id = cat_id, 
  230. 		image = image_name, 
  231. 	} 
  232. 	 
  233. 	if game_get_platform() == "PS3" and title ~= "DLC_STORE_CAT_ALL" then 
  234. 		new_item.label = vint_insert_values_in_string("{0:text_tag_crc}", { [0] = name }) 
  235. 	else 
  236. 		new_item.label = name 
  237. 	end 
  238.  
  239. 	Store_dlc_categories_data[menu_idx] = new_item 
  240. 	Store_dlc_categories_data[menu_idx].menu = table_clone(Store_dlc_category_base_data) 
  241. 	Store_dlc_categories_data[menu_idx].menu.category_menu_index = menu_idx 
  242. 	 
  243. 	return menu_idx 
  244. end 
  245.  
  246. function store_dlc_categories_on_show() 
  247. 	--Hide item on right side... 
  248. 	store_dlc_item_show(false) 
  249. end 
  250.  
  251. function store_dlc_categories_select(current_idx)	 
  252. 	store_dlc_list_show(Store_dlc_categories_data[current_idx].menu, 1)	 
  253.  
  254. 	--call nav function to update category highlight... 
  255. 	Store_dlc_categories_data[current_idx].menu.on_nav() 
  256. end 
  257.  
  258. ------------------------------------------------------------------------------- 
  259. -- Category menu functions 
  260. ------------------------------------------------------------------------------- 
  261.  
  262. function store_dlc_category_on_show() 
  263. 	--Show item on right side... 
  264. 	store_dlc_item_show(true) 
  265. end 
  266.  
  267. ------------------------------------------------------------------------------- 
  268. -- Callback function when user presses back on category screen. 
  269. --  
  270. function store_dlc_category_on_back() 
  271. 	store_dlc_list_show(Store_dlc_categories_data, 1)	 
  272. end 
  273.  
  274. function store_dlc_image_downloaded(img_id) 
  275. 	--Update image... 
  276. 	local store_item_h = vint_object_find("store_item", 0, Store_dlc_doc_handle)	 
  277. 	local image_h = vint_object_find("store_item_image", store_item_h, Store_dlc_doc_handle) 
  278. 	 
  279. 	vint_set_property(image_h, "image", img_id) 
  280. 	store_dlc_show_spinner(false) 
  281. end 
  282.  
  283. function store_dlc_category_on_nav(current_idx) 
  284. 	--Get data from our currently selected item... 
  285. 	local data = Store_dlc_list:return_selected_data() 
  286. 	local title = data.title 
  287. 	local price = data.price 
  288. 	local image_name = data.image_name 
  289. 	local description = data.description 
  290. 	local is_owned = data.is_owned 
  291.  
  292. 	-- At the category selection level, items do not correspond to actual offers.  
  293. 	if (data.id == -1) then 
  294. 		return 
  295. 	end 
  296.  
  297. 	--Update Title 
  298. 	local store_item_h = vint_object_find("store_item", 0, Store_dlc_doc_handle)	 
  299. 	local title_h = vint_object_find("title", store_item_h, Store_dlc_doc_handle)	 
  300. 	vint_set_property(title_h, "text_tag", title) 
  301. 	 
  302. 	--Update Price 
  303. 	local price_h = vint_object_find("price", store_item_h, Store_dlc_doc_handle) 
  304.  
  305. 	if game_get_platform() == "XBOX360" or (game_get_platform() == "XBOX3") then 
  306.  
  307. 		-- Set the price 
  308. 		if data.is_installed then 
  309. 			-- The price of installed items is always denoted by the star symbol, even if 
  310. 			-- the user would need to purchase the content to install it. 
  311. 			price = "DLC_STORE_ITEM_INSTALLED" 
  312. 		elseif data.is_season_pass_owned then 
  313. 			price = "DLC_STORE_ITEM_SEASON_PASS" 
  314. 		elseif data.is_owned then 
  315. 			price = "DLC_STORE_ITEM_PURCHASED" 
  316. 		end 
  317. 		 
  318. 		-- Set the A-button hint 
  319. 		local hint_data = { 
  320. 			{CTRL_MENU_BUTTON_B, "MENU_BACK"},	 
  321. 			{CTRL_BUTTON_X, "REDEEM_CODE"},	 
  322. 		}		 
  323. 		if data.is_owned or store_dlc_is_offer_free(data.id) then 
  324. 			hint_data[3] = {CTRL_MENU_BUTTON_A, "DLC_STORE_HINT_DOWNLOAD"} 
  325. 		else 
  326. 			hint_data[3] = {CTRL_MENU_BUTTON_A, "DLC_STORE_HINT_PURCHASE"} 
  327. 		end 
  328. 		Hint_bar:set_hints(hint_data) 	 
  329. 		Hint_bar:set_visible(true) 
  330. 		 
  331. 	else 
  332. 		if is_owned then 
  333. 			price = "DLC_STORE_ITEM_PURCHASED" 
  334. 		end 
  335. 	end 
  336. 	 
  337. 	vint_set_property(price_h, "text_tag", price) 
  338.  
  339. 	--Update image... 
  340. 	store_dlc_show_spinner(true) 
  341. 	thread_new("store_dlc_queue_icon_delayed", data.id) 
  342. 	 
  343. 	--Update description 
  344. 	Store_dlc_scrollbox:set_text(data.description) 
  345. 	Store_dlc_scrollbox:reset() 
  346. 	 
  347. 		--Format our screen... 
  348. 	local data = { 
  349. 		{h = title_h, 					type = VINT_OBJECT_TEXT, space = 0}, 
  350. 		{h = price_h,					type = VINT_OBJECT_TEXT, space = 5}, 
  351. 		{h = Store_dlc_scrollbox.handle, 	type = VINT_OBJECT_INVALID, space = 0}, 
  352. 	} 
  353. 	vint_align_elements(data, true) 
  354. end 
  355.  
  356. ------------------------------------------------------------------------------- 
  357. -- Delay queuing up the icon by a single frame to prevent missing image. 
  358. -- 
  359. function store_dlc_queue_icon_delayed(id) 
  360. 	thread_yield() 
  361. 	store_dlc_queue_icon(id, "store_dlc_image_downloaded") 
  362. end 
  363.  
  364. ------------------------------------------------------------------------------- 
  365. -- Populate function for the sub category menu... 
  366. -- 
  367. -- list_data: 		this table contains the data to populate the megalist 
  368. -- current_index: 	the current index in the menu that's selected 
  369. -- 
  370. function store_dlc_category_item_add(name, trunc_name, description, price, category_id, item_id, is_owned, is_installed, is_season_pass_category, is_season_pass) 
  371. 	debug_print("vint", "price: " .. var_to_string(price) .. "\n")  
  372. 	 
  373. 	local is_season_pass_owned = is_season_pass_category and (not is_season_pass) 
  374. 	 
  375. 	if is_owned then 
  376. 		price = "[image:ui_text_star]" 
  377. 	else 
  378. 		if game_get_platform() == "XBOX360" or (game_get_platform() == "XBOX3") then 
  379. 			 
  380. 			if (is_installed or is_season_pass_owned) then 
  381. 				price = "[image:ui_text_star]" 
  382. 			else 
  383. 				--Convert to show microsoft points. 
  384. 				local values = {[0] = price} 
  385. 				price = vint_insert_values_in_string("{0}[image:ui_text_mpoints]", values) 
  386. 			end 
  387. 		end 
  388. 	end 
  389.  
  390. 	local new_item = { 
  391. 		type = TYPE_ROW, 
  392. 		id = item_id, 
  393. 		label_1 = trunc_name, 
  394. 		label = trunc_name, 
  395. 		title = name, 
  396. 		price = price, 
  397. 		description = description, 
  398. 		label_crc = nil, 
  399. 		image_name = "", 
  400. 		label_2 = price, 
  401. 		label_3 = "",  
  402. 		label_4 = "", 
  403. 		current_value = 1, 
  404. 		is_owned = is_owned, 
  405. 	}		 
  406.  
  407. 	if game_get_platform() == "XBOX360" or (game_get_platform() == "XBOX3") then 
  408. 		new_item.is_installed = is_installed 
  409. 		new_item.is_season_pass_category = is_season_pass_category 
  410. 		new_item.is_season_pass = is_season_pass 
  411. 		new_item.is_season_pass_owned = is_season_pass_owned	 
  412.  
  413. 		if (new_item.is_season_pass and is_installed) then 
  414. 			DLC_season_pass_installed	= true 
  415. 		end 
  416.  
  417. 	end 
  418.  
  419. 	local Category_adding_to = nil 
  420. 	for i = 1, #Store_dlc_categories_data do  
  421. 		if Store_dlc_categories_data[i].id == category_id then 
  422. 			Category_adding_to = Store_dlc_categories_data[i] 
  423. 		end 
  424. 	end 
  425. 	 
  426. 	if Category_adding_to == nil then 
  427. 		local idx = -1 
  428. 		if game_get_platform() == "XBOX360" or (game_get_platform() == "XBOX3") then 
  429. 			local name = Dlc_category_names[category_id] 
  430. 			if Dlc_category_names[category_id] ~= nil then 
  431. 				 idx = store_dlc_categories_add(Dlc_category_names[category_id], "AWESOME_IMAGE", category_id) 
  432. 			end 
  433. 		else 
  434. 			idx = store_dlc_categories_add(category_id, "AWESOME_IMAGE", category_id) 
  435. 		end 
  436. 		 
  437. 		if idx ~= -1 then 
  438. 			Category_adding_to = Store_dlc_categories_data[idx] 
  439. 		end 
  440. 	end 
  441. 	 
  442. 	-- Add it to its own category 
  443. 	if Category_adding_to ~= nil then 
  444. 		local menu_idx = #Category_adding_to.menu + 1 
  445. 		Category_adding_to.menu[menu_idx] = new_item 
  446. 	end 
  447. 	 
  448. 	-- Add it to all 
  449. 	local all_idx = #Store_dlc_categories_data[1].menu + 1 
  450. 	Store_dlc_categories_data[1].menu[all_idx] = new_item 
  451. 	 
  452. 	-- Add to the season pass category 
  453. 	if ((game_get_platform() == "XBOX360" or (game_get_platform() == "XBOX3")) and is_season_pass_category) then 
  454. 	 
  455. 		if (DLC_season_pass_category_added == false) then 
  456. 			DLC_season_pass_category_index = store_dlc_categories_add("DLC_STORE_SEASON_PASS_CATEGORY", "AWESOME_IMAGE", -2) 
  457. 			DLC_season_pass_category_added = true 
  458. 		end 
  459. 	 
  460. 		local sp_idx = #Store_dlc_categories_data[DLC_season_pass_category_index].menu + 1 
  461. 		Store_dlc_categories_data[DLC_season_pass_category_index].menu[sp_idx] = new_item 
  462. 	end 
  463. end 
  464.  
  465. function store_dlc_category_select_confirm(result, action) 
  466. 	 
  467. 	if result == 0 then 
  468. 		local id = Store_dlc_list:get_id() 
  469. 		store_dlc_make_purchase(id) 
  470. 	end 
  471.  
  472. end 
  473.  
  474. function store_dlc_category_select(index) 
  475. 	local id = Store_dlc_list:get_id() 
  476. 	local data = Store_dlc_list:return_selected_data() 
  477. 	 
  478. 	if (game_get_platform() == "XBOX360") or (game_get_platform() == "XBOX3") then 
  479. 		 
  480. 		-- TODO: check for season-pass requirement. 
  481. 		 
  482. 		-- Warn the user if they're about to purchase content that is installed and accessible. 
  483. 		local has_cost = ( (not data.is_owned) and (not store_dlc_is_offer_free(id)) ) 
  484. 		if data.is_installed and has_cost then 
  485. 			dialog_box_confirmation("MENU_TITLE_WARNING", "DLC_STORE_PURCHASE_INSTALLED_CONFIRM", "store_dlc_category_select_confirm", nil, nil, 1) 
  486. 			 
  487. 		elseif data.is_installed then 
  488.  
  489. 			-- Warn users if they're about to download content that is already installed and accessible. 
  490. 			dialog_box_confirmation("MENU_TITLE_WARNING", "DLC_STORE_DOWNLOAD_INSTALLED_CONFIRM", "store_dlc_category_select_confirm", nil, nil, 1) 
  491.  
  492. 		elseif (data.is_season_pass_owned and (not DLC_season_pass_installed)) then 
  493. 		 
  494. 			-- Warn users that the season pass content will not function properly until the season pass is installed. 
  495. 			dialog_box_confirmation("MENU_TITLE_WARNING", "DLC_STORE_SEASON_PASS_PREREQ_CONFIRM", "store_dlc_category_select_confirm", nil, nil, 1) 
  496. 			 
  497. 		else  
  498. 			store_dlc_make_purchase(id)			 
  499. 		end 
  500. 		 
  501. 	else 
  502. 		store_dlc_make_purchase(id) 
  503. 	end 
  504.  
  505. end 
  506.  
  507. --Input 
  508.  
  509. function store_dlc_input_joy(event, accelleration) 
  510. 	--do scrolling in the box... 
  511. 	Store_dlc_scrollbox:nav_smooth(accelleration) 
  512. end 
  513.  
  514.  
  515. ------------------------------------------------------------------------------- 
  516. -- Misc store functionality 
  517. ------------------------------------------------------------------------------- 
  518.  
  519. ------------------------------------------------------------------------------- 
  520. -- Shows/Hides the store item on the right side... 
  521. -- 
  522. function store_dlc_item_show(show_item) 
  523. 	local store_item_h = vint_object_find("store_item") 
  524. 	vint_set_property(store_item_h, "visible", show_item) 
  525. end 
  526.  
  527.  
  528. ------------------------------------------------------------------------------- 
  529. -- Store_dlc_list and populate functions 
  530. ------------------------------------------------------------------------------- 
  531.  
  532. ------------------------------------------------------------------------------- 
  533. -- Populate the megalist menu 
  534. -- list_data: 		this table contains the data to populate the megalist 
  535. -- current_index: 	the current index in the menu that's selected 
  536. -- 
  537. function store_dlc_list_show(list_data, current_index) 
  538.  
  539. 	if game_get_platform() == "XBOX360" or (game_get_platform() == "XBOX3") then 
  540. 		local hint_data = { 
  541. 			{CTRL_MENU_BUTTON_B, "MENU_BACK"},	 
  542. 			{CTRL_BUTTON_X, "REDEEM_CODE"},	 
  543. 		} 
  544. 		Hint_bar:set_hints(hint_data) 	 
  545. 		Hint_bar:set_visible(true) 
  546. 	end 
  547.  
  548. 	Store_dlc_list:draw_items(list_data, current_index, Screen_width) 
  549. 	local data = Store_dlc_list:return_data() 
  550. 	 
  551. 	--Callback for showing specific list... 
  552. 	if data.on_show ~= nil then 
  553. 		data.on_show() 
  554. 	end 
  555. end 
  556.  
  557. function store_dlc_exit(event) 
  558. 	-- exit the interface 
  559. 	store_dlc_input_disable() 
  560. 	store_dlc_exit_screen() 
  561. end 
  562.  
  563. function store_dlc_refresh() 
  564. 	DLC_store_browsing_ready = true 
  565.  
  566. 	local data = Store_dlc_list:return_data() 
  567. 	local cat_idx = -1 
  568. 	local selection = 1 
  569. 	DLC_season_pass_installed = false 
  570. 	DLC_season_pass_category_index = -1 
  571. 	DLC_season_pass_category_added = false 
  572. 	 
  573. 	if data ~= nil and data.list_type == DLC_ITEM_LIST then 
  574. 		cat_idx = data.category_menu_index 
  575. 	end 
  576. 	 
  577. 	if data ~= nil then 
  578. 		selection = Store_dlc_list:get_selection() 
  579. 	end 
  580. 			 
  581. 	store_dlc_retrieve_data() 
  582. 	 
  583. 	if (cat_idx == -1 or Store_dlc_categories_data[cat_idx] == nil) then 
  584. 		store_dlc_list_show(Store_dlc_categories_data, selection) 
  585. 	else 
  586. 		store_dlc_list_show(Store_dlc_categories_data[cat_idx].menu, selection) 
  587. 		if (game_get_platform() == "XBOX360" or (game_get_platform() == "XBOX3")) and data.on_nav ~= nil then 
  588. 			-- Rerun the selection callback to update hints and the items price in the 
  589. 			-- detail portion of the screen. 
  590. 			data.on_nav(selection) 
  591. 		end 
  592. 	end 
  593. 	 
  594. 	Store_dlc_list:set_visible(true)		 
  595. 	 
  596. 	store_dlc_input_enable() 
  597. end 
  598.  
  599. ------------------------------------------------------------------------------- 
  600. -- Arrange text on logo 
  601. -- 
  602. function store_dlc_set_logo() 
  603. 	-- Set playstation store logo 
  604. 	local ps3_store_logo_grp_h = vint_object_find("ps3_store_logo_grp") 
  605. 	 
  606. 	-- Set platform... 
  607. 	local platform = game_get_platform() 
  608. 	if platform == "PS3" then 
  609. 		vint_set_property(ps3_store_logo_grp_h, "visible", true) 
  610. 		local ps3_store_logo_bmp_h = vint_object_find("ps3_store_logo_bmp") 
  611. 		if vint_is_std_res() then 
  612. 			vint_set_property(ps3_store_logo_bmp_h, "image", "ui_dlc_store_ps3_store_sd") 
  613. 			vint_set_property(ps3_store_logo_bmp_h, "scale", 1, 1)	--reset scale... 
  614. 			local x, y = vint_get_property(ps3_store_logo_bmp_h, "anchor") 
  615. 			vint_set_property(ps3_store_logo_bmp_h, "anchor", x, y + 15) 
  616. 		else 
  617. 			vint_set_property(ps3_store_logo_bmp_h, "image", "ui_dlc_store_ps3_store_hd") 
  618. 		end 
  619. 	else 
  620. 		vint_set_property(ps3_store_logo_grp_h, "visible", false) 
  621. 	end 
  622. end 
  623.  
  624. ------------------------------------------------------------------------------- 
  625. -- Shows the spinner if visible when hidden we show the image 
  626. -- 
  627. function store_dlc_show_spinner(is_visible) 
  628. 	 
  629. 	local spinner_grp_h 			= vint_object_find("spinner_grp", 0, Store_dlc_doc_handle) 
  630. 	local spinner_anim_h 		= vint_object_find("spinner_anim", 0, Store_dlc_doc_handle) 
  631. 	local store_item_image_h 	= vint_object_find("store_item_image", 0, Store_dlc_doc_handle) 
  632. 	 
  633. 	if is_visible then 
  634. 		vint_set_property(spinner_grp_h, "visible", true) 
  635. 		vint_set_property(spinner_anim_h, "is_paused", false) 
  636. 		vint_set_property(store_item_image_h, "visible", false) 
  637. 	else 
  638. 		vint_set_property(spinner_grp_h, "visible", false) 
  639. 		vint_set_property(spinner_anim_h, "is_paused", true) 
  640. 		vint_set_property(store_item_image_h, "visible", true) 
  641. 	end 
  642. end 
  643.  
  644. ------------------------------------------------------------------------------- 
  645. -- Final exit for the dlc store...  
  646. function store_dlc_exit_screen() 
  647. 	pop_screen() 
  648. end 
  649.  
  650. --Data used in the DLC Store for categories 
  651. Store_dlc_categories_data = { } 
  652.  
  653. -- Base Data used in the DLC Store 
  654. Store_dlc_category_base_data = { 
  655. 	current_index = 1, 
  656. 	row_alignment = {ALIGN_LEFT, ALIGN_RIGHT}, 
  657. 	row_column_count = 2, 
  658. 	on_show = store_dlc_category_on_show, 
  659. 	on_select = store_dlc_category_select, 
  660. 	on_nav = store_dlc_category_on_nav, 
  661. 	on_back = store_dlc_category_on_back, 
  662. 	list_type = DLC_ITEM_LIST, 
  663. 	category_menu_index = 0, 
  664. }