./store_vehicle.lua

  1. -- REMAINING PC ISSUES 
  2. -- Rim style grid only responds to first mouse move before stopping 
  3. -- Rim size toggle doesn't respond to mouse 
  4. -- Canceling COLOR GRID purchase also doubles the header text (not PC specific) 
  5. -- First tire tread disappears after mousing off first time 
  6. -- Wheel width and size don't slide quite correctly (approx. double the actual mouse movement) 
  7. -- Lots of stuff with Garage probably doesn't work 
  8.  
  9. local Store_logo1 
  10. local Store_logo2 
  11. local Not_popup_grp 
  12. local Reward_image 
  13. local Triangle_select 
  14. local Vehicle_stats 
  15. local Empty_garage 
  16.  
  17. local Vehicle_stats_data = {} 
  18.  
  19. local SCALE_FONT_STORE_VEHICLE_LIST = 0.8 
  20. local MODE_VCUST 		= 0 
  21. local MODE_GARAGE 	= 1 
  22.  
  23. local Color_grid_data				= {} 
  24. local Old_vehicle_grid_index 		= -1 				-- For navigating a grid with the mouse 
  25. local Old_vehicle_grid_category 	= -1 			-- For navigating a grid with the mouse 
  26.  
  27. local Store_vehicle_curr_cat_tbl 
  28. local Store_vehicle_curr_feat_tbl 
  29.  
  30. local Store_vehicle_building_menu 
  31.  
  32. local STORE_VEHICLE_POPULATE_AREAS 				= 0 
  33. local STORE_VEHICLE_POPULATE_CURRENT_MENU 	= 1 
  34. local STORE_VEHICLE_POPULATE_COMPONENT_MENU	= 2 
  35.  
  36. local STORE_VEHICLE_POPULATE_COLOR_REGION		= 4 
  37.  
  38. local Store_vehicle_show_slot 					= -1 
  39. local Store_vehicle_show_region 					= false 
  40.  
  41. local Vehicle_just_upgrade							= false 
  42. local Store_vehicle_component_selected 
  43.  
  44. local Store_vehicle_chosen_axle					= -1 
  45.  
  46. local Store_vehicle_rebuild_wheel_menu			= true 
  47.  
  48. local Returning_to_crib 							= false 
  49.  
  50. local Store_vehicle_wheel_price	= { 
  51. 	rim = 0, 
  52. 	tire = 0, 
  53. 	size = 0, 
  54. } 
  55.  
  56. local Store_vehicle_wheel_respect = { 
  57. 	rim = 0, 
  58. 	tire = 0, 
  59. 	size = 0, 
  60. } 
  61.  
  62. local Store_vehicle_wheel_base_price = 100 
  63. local Store_vehicle_wheel_base_respect = 5 
  64.  
  65. local Store_vehicle_color_slot					= -1 
  66. local Store_vehicle_color_selection				= 0 
  67. local Store_vehicle_color_price					= 0 
  68. local Store_vehicle_color_respect				= 0 
  69. local Store_vehicle_current_logo					= -1 
  70.  
  71. local Store_vehicle_select_palette_first		= false 
  72.  
  73. local Store_vehicle_purchase_item				= nil 
  74.  
  75. local Store_vehicle_current_rim_id				= 0 
  76. local Store_vehicle_current_cat_id				= 0 
  77.  
  78. local Rim_jobs_grp									= 0 
  79.  
  80. local Store_vehicle_is_garage 					= false 
  81. local Garage_leave_with_car 						= false 
  82. local Garage_select_choices 						= {} 
  83.  
  84. -- flag to indicate how many menus we need to back up later 
  85. local Store_vehicle_region_menu_bypassed 		= false 
  86.  
  87. local Store_vehicle_multiple_palettes			= false 
  88.  
  89. Store_vehicle_doc_handle							= -1 
  90.  
  91. STORE_VEHICLE_TYPE_CATEGORY						= 0 
  92. STORE_VEHICLE_TYPE_SLOT								= 1 
  93. STORE_VEHICLE_TYPE_COMPONENT						= 2 
  94. STORE_VEHICLE_TYPE_COLOR_REGION					= 3 
  95. STORE_VEHICLE_TYPE_COLOR_PALETTE					= 4 
  96. STORE_VEHICLE_TYPE_COLOR_GRID						= 5 
  97. STORE_VEHICLE_TYPE_WHEEL							= 6 
  98. STORE_VEHICLE_TYPE_PERFORMANCE					= 7 
  99. STORE_VEHICLE_TYPE_PERFORMANCE_SLOT				= 8 
  100.  
  101. local STORE_VEHICLE_UNDERGLOW_COLOR				= -2 
  102.  
  103. VEHICLE_CUST_RIM_PEG					= "ui_bms_veh_rims" 
  104. VEHICLE_CUST_TIRE_PEG 				= "ui_bms_veh_tires" 
  105. VEHICLE_CUST_SPINNER_PEG			= "ui_bms_veh_s_0" 
  106. VEHICLE_CUST_GLASS_PEG				= "ui_bms_veh_glass" 
  107.  
  108. COLOR_STORE_VEHICLE_PRIMARY = {R=150/255, G=150/255, B=150/255} 
  109.  
  110. local Store_vehicle_spinner_cat = {} 
  111.  
  112. Store_vehicle_rim_sizes = { 
  113. 	median_rim_size = 3, 
  114. 	 
  115. 	[1] = "VCUST_EXTRA_HIGH_PROFILE", 
  116. 	[2] = "VCUST_HIGH_PROFILE", 
  117. 	[3] = "VCUST_NORMAL_PROFILE", 
  118. 	[4] = "VCUST_LOW_PROFILE", 
  119. 	[5] = "VCUST_EXTRA_LOW_PROFILE", 
  120. } 
  121.  
  122. local BRAND_LEXANI = 3 
  123. local BRAND_ASANTI = 4 
  124. local BRAND_RBP = 5 
  125.  
  126. local Store_vehicle_brand_data = { 
  127. 	[BRAND_LEXANI]	= "ui_bms_store_lexani_logo", 
  128. 	[BRAND_ASANTI]	= "ui_bms_store_asanti_logo", 
  129. 	[BRAND_RBP]		= "ui_bms_store_rbp_logo", 
  130. } 
  131.  
  132. local Store_vehicle_loaded_from_crib = false 
  133. local Store_vehicle_begin_from_garage = false 
  134.  
  135. -- Mouse input-related variables 
  136. local Game_platform 
  137. local Hint_bar_mouse_input_tracker 
  138.  
  139. -- Menu Tiers 
  140. local MENU_TIER		= 1 
  141. local COLOR_TIER		= 2 
  142. local PALETTE_TIER	= 3 
  143. local TIRE_TIER		= 4 
  144. local RIM_TIER			= 5 
  145. local Current_tier = MENU_TIER 
  146.  
  147. -- Defines for specially handled finish/palettes 
  148. -- 
  149. STORE_VEHICLE_HERO_MATTE							= 0 
  150. STORE_VEHICLE_HERO_GLOSS							= 1 
  151. STORE_VEHICLE_IRIDESCENT							= 2 
  152. STORE_VEHICLE_PEARLESCENT							= 3 
  153. STORE_VEHICLE_CANDY									= 4 
  154.  
  155. local GARAGE_SELECT_REPAIR							= 1 
  156. local GARAGE_SELECT_CUSTOMIZE						= 2 
  157. local GARAGE_SELECT_RETRIEVE						= 3 
  158. local GARAGE_SELECT_DELETE							= 4 
  159. local GARAGE_SELECT_CRIB							= 5 
  160. local GARAGE_SELECT_CANCEL							= 6 
  161.  
  162. local GVT_INVALID			= -1 
  163. local GVT_CARS				= 0 
  164. local GVT_HELICOPTERS	= 1 
  165. local GVT_AIRPLANES		= 2 
  166. local GVT_WATERCRAFT		= 3 
  167.  
  168. local Screen_cover_count = 0 
  169.  
  170. ---------------------- 
  171. function store_vehicle_crib_exit() 
  172. 	store_vehicle_do_return_to_crib() 
  173. end 
  174.  
  175. function store_vehicle_return_to_crib() 
  176. 	-- lock input during animation 
  177. 	store_lock_controls() 
  178. 	 
  179. 	Store_common_spinner:set_visible(false) 
  180. 	local vehicle_logo_h = vint_object_find("vehicle_logo", 0, Store_vehicle_doc_handle) 
  181. 	vint_set_property(vehicle_logo_h, "visible", false) 
  182. 	-- make background so car is covered up 
  183. 	bg_saints_set_background(false) 
  184. 	local back_out_anim = Vdo_anim_object:new("store_crib_out_anim", 0, Store_common_doc_handle) 
  185. 	local back_out_end_twn = Vdo_tween_object:new("common_anchor_out_twn", back_out_anim.handle) 
  186. 	back_out_end_twn:set_end_event("store_vehicle_crib_exit") 
  187. 	back_out_anim:play(0) 
  188. 	 
  189. 	Returning_to_crib = true; 
  190. end 
  191.  
  192. function store_vehicle_clear_header() 
  193. 	Store_header:enable_price_respect(false) 
  194. 	store_vehicle_set_description(nil) 
  195. end 
  196.  
  197. function store_vehicle_nav_slot(menu_data) 
  198. 	vcust_adjust_camera_angle( menu_data.id ) 
  199. 	 
  200. 	-- local hint_rotate_data = { 
  201. 		-- {CTRL_BUTTON_RS, "STORE_ZOOM"}, 
  202. 	-- } 
  203. 	-- Store_common_rotate_hint:set_hints(hint_rotate_data) 
  204. 	Store_common_rotate_hint:set_visible(false) 
  205. end 
  206.  
  207. function store_vehicle_nav_component(menu_data) 
  208. 	local item = Menu_data[Active_list:get_selection()] 
  209. 	vcust_preview_component(0, item.id) 
  210. 	 
  211. 	-- Update the store header price and respect values	 
  212. 	local price = item.price 
  213. 	local respect = item.style 
  214. 	 
  215. 	if price > 0 then 
  216. 		Store_header:set_price(price) 
  217. 		Store_header:enable_price_respect(true) 
  218. 	else 
  219. 		-- Passing nil to hide price 
  220. 		--Store_header:set_price(nil) 
  221. 		store_vehicle_clear_header() 
  222. 	end	 
  223. 	 
  224. 	if item.style > 0 then 
  225. 		Store_header:set_respect(item.style)	 
  226. 		Store_header:enable_price_respect(true)		 
  227. 	else 
  228. 		store_vehicle_clear_header()	 
  229. 	end 
  230. end 
  231.  
  232. -- Remove any preview for items we didn't select 
  233. function store_vehicle_revert_component(menu_data) 
  234. 	vcust_preview_component(0, Menu_data[Menu_data.start_index].id) 
  235. 	store_vehicle_clear_header() 
  236. end 
  237.  
  238. -- Garage select options 
  239. function store_vehicle_garage_vehicle_select() 
  240. 	-- disable popup until garage vehicle is loaded 
  241. 	if garage_vehicle_load_pending() then 
  242. 		return 
  243. 	end 
  244. 	 
  245. 	Garage_select_choices = {} 
  246. 	 
  247. 	-- can always retrieve 
  248. 	Garage_select_choices[#Garage_select_choices + 1] =  
  249. 	{ 
  250. 		type = TYPE_BUTTON, 
  251. 		select_type = GARAGE_SELECT_RETRIEVE, 
  252. 		label = "GARAGE_RETRIEVE_VEHICLE", 
  253. 		id = #Garage_select_choices + 1 
  254. 	} 
  255. 	 
  256. 	local repair_cost = garage_get_repair_cost() 
  257. 	if repair_cost > 0 then  
  258. 		local insert_values = { [0] = repair_cost } 
  259. 		local tag = vint_insert_values_in_string("GARAGE_REPAIR_VEHICLE", insert_values) 
  260. 			 
  261. 		Garage_select_choices[#Garage_select_choices + 1] =  
  262. 		{ 
  263. 			type = TYPE_BUTTON, 
  264. 			select_type = GARAGE_SELECT_REPAIR, 
  265. 			label = tag, 
  266. 			id = #Garage_select_choices + 1 
  267. 		} 
  268. 	end 
  269.  
  270. 	local customize = garage_can_customize() 
  271. 	if customize then 
  272. 		Garage_select_choices[#Garage_select_choices + 1] =  
  273. 		{ 
  274. 			type = TYPE_BUTTON, 
  275. 			select_type = GARAGE_SELECT_CUSTOMIZE, 
  276. 			label = "GARAGE_CUSTOMIZE_VEHICLE", 
  277. 			id = #Garage_select_choices + 1 
  278. 		} 
  279. 	end 
  280. 	 
  281. 	local delete = garage_can_delete()	 
  282. 	if delete then  
  283. 		Garage_select_choices[#Garage_select_choices + 1] =  
  284. 		{ 
  285. 			type = TYPE_BUTTON, 
  286. 			select_type = GARAGE_SELECT_DELETE, 
  287. 			label = "GARAGE_REMOVE_VEHICLE", 
  288. 			id = #Garage_select_choices + 1 
  289. 		} 
  290. 	end 
  291. 	 
  292. 	Garage_select_choices[#Garage_select_choices + 1] =  
  293. 	{ 
  294. 		type = TYPE_BUTTON, 
  295. 		select_type = GARAGE_SELECT_CANCEL, 
  296. 		label = "CONTROL_CANCEL", 
  297. 		id = #Garage_select_choices + 1 
  298. 	} 
  299. 	 
  300. 	local allow_crib = Store_vehicle_loaded_from_crib 
  301. 	--[[if allow_crib then 
  302. 		Garage_select_choices[#Garage_select_choices + 1] =  
  303. 		{ 
  304. 			type = TYPE_BUTTON, 
  305. 			select_type = GARAGE_SELECT_CRIB, 
  306. 			label = "VCUST_RETURN_TO_CRIB", 
  307. 			id = #Garage_select_choices + 1 
  308. 		}	 
  309. 	end--]] 
  310. 	 
  311. 	Store_common_popup:populate_list(Garage_select_choices, 1, STORE_COMMON_LIST_SIZE, #Garage_select_choices)	 
  312. 	Store_common_popup:set_title("GARAGE_VEHICLE_OPTION") 
  313. 	Store_common_popup:set_text("")		 
  314. 	Store_common_popup:nav_enable(true, "store_garage_select", "store_vehicle_popup_nav") 
  315.  
  316. 	Not_popup_grp:set_alpha(.5) 
  317. 	Active_list:set_visible(false) 
  318. 	 
  319. 	if store_vehicle_selection_should_lock_controls() then 
  320. 		store_lock_controls() 
  321. 		--store_vehicle_enable_controls(false) 
  322. 	end 
  323. 	 
  324. 	-- Disable mouse input for active_list and hint_bar 
  325. 	store_vehicle_enable_mouse(false) 
  326. end 
  327.  
  328. -- Possibly make a purchase 
  329. function store_vehicle_select_component(menu_data) 
  330. 	-- Confirm the purchase if we can afford it 
  331. 	if Store_common_player_cash >= menu_data.price and menu_data.price ~= 0 and menu_data.owned ~= true then 
  332. 		Store_vehicle_component_selected = menu_data 
  333. 		local insert = { [0] = menu_data.label, [1] = format_cash(menu_data.price) } 
  334. 		local body = vint_insert_values_in_string("VCUST_PURCHASE_PROMPT", insert) 
  335. 		local heading = "MENU_TITLE_CONFIRM" 
  336. 		Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  337. 		Store_common_popup:set_title(heading) 
  338. 		Store_common_popup:set_text(body)		 
  339. 		Store_common_popup:nav_enable(true, "store_vehicle_component_confirm", "store_vehicle_popup_nav") 
  340. 		Not_popup_grp:set_alpha(.5)	 
  341. 		Active_list:set_visible(false) 
  342. 		 
  343. 		-- Disable mouse input for active_list and hint_bar 
  344. 		store_vehicle_enable_mouse(false) 
  345. 	elseif menu_data.price ~= 0 and menu_data.owned ~= true then 
  346. 		Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  347. 		Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  348. 		Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")		 
  349. 		Store_common_popup:nav_enable(true, "store_vehicle_fail_msg", "store_vehicle_popup_nav") 
  350. 		Not_popup_grp:set_alpha(.5) 
  351. 		Active_list:set_visible(false) 
  352.  
  353. 		-- Disable mouse input for active_list and hint_bar 
  354. 		store_vehicle_enable_mouse(false)		 
  355. 	else  
  356. 		Store_vehicle_component_selected = menu_data 
  357. 		Vehicle_just_upgrade = true 
  358. 		-- just populate list because next function assumes we made a choice in the dialog box 
  359. 		--Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  360. 		--store_vehicle_component_confirm("accept") 
  361. 		store_vehicle_component_confirm_final() 
  362. 	end 
  363. end 
  364.  
  365. function store_garage_repair_confirm(event) 
  366. 	-- only used in the case of insufficient funds 
  367. 	--"STORE_TITLE_INSUFFICIENT_FUNDS", "GARAGE_TEXT_INSUFFICIENT_FUNDS" 
  368. 	Store_common_popup:nav_enable(false, nil, nil) 
  369. 	Not_popup_grp:set_alpha(1) 
  370. 	Active_list:set_visible(true) 
  371. 	 
  372. 	-- The user hit the B button and is exiting 
  373. 	-- This is redundant to selecting "No" in the list 
  374. 	if event == "back" then 
  375. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  376. 		return 
  377. 	end 
  378. 	 
  379. 	game_UI_audio_play("UI_Main_Menu_Select") 
  380. end 
  381.  
  382. function store_garage_customize_repair_confirm(event) 
  383. 	Store_common_popup:nav_enable(false, nil, nil) 
  384. 	Not_popup_grp:set_alpha(1) 
  385. 	Active_list:set_visible(true) 
  386. 	 
  387. 	-- The user hit the B button and is exiting 
  388. 	-- This is redundant to selecting "No" in the list 
  389. 	if event == "back" then 
  390. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  391. 		return 
  392. 	end 
  393. 	 
  394. 	game_UI_audio_play("UI_Main_Menu_Select") 
  395. 	 
  396. 	if Store_common_popup:get_selected_data() ~= 1 then 
  397. 		return 
  398. 	end 
  399. 	 
  400. 	if Store_common_player_cash < garage_get_repair_cost() then 
  401. 		-- INSUFFICIENT FUNDS MESSAGE BOX 
  402. 		Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  403. 		Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  404. 		Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")		 
  405. 		Store_common_popup:nav_enable(true, "store_garage_repair_confirm", "store_vehicle_popup_nav") 
  406. 		Not_popup_grp:set_alpha(.5)	 
  407. 		Active_list:set_visible(false) 
  408.  
  409. 		-- Disable mouse input for active_list and hint_bar 
  410. 		store_vehicle_enable_mouse(false)	 
  411. 		return 
  412. 	end 
  413. 	 
  414. 	garage_repair_vehicle() 
  415. 	store_vehicle_switch_mode() 
  416. end 
  417.  
  418. function store_garage_destroy_confirm(event) 
  419. 	Store_common_popup:nav_enable(false, nil, nil) 
  420. 	Not_popup_grp:set_alpha(1) 
  421. 	Active_list:set_visible(true) 
  422. 	 
  423. 	-- Re-enable mouse input? 
  424. 	 
  425. 	-- The user hit the B button and is exiting 
  426. 	-- This is redundant to selecting "No" in the list 
  427. 	if event == "back" then 
  428. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  429. 		store_unlock_controls() 
  430. 		return 
  431. 	end 
  432. 	 
  433. 	game_UI_audio_play("UI_Main_Menu_Select") 
  434. 	 
  435. 	-- Did we select yes?  This assumes yes is the first item 
  436. 	if Store_common_popup:get_selected_data() == 1 then 
  437. 		-- determine start index of repopulated list 
  438. 		local cur_sel =  Active_list:get_selection() 
  439. 		local size = #Menu_data 
  440. 		local next_sel = cur_sel 
  441. 		if cur_sel == size then  
  442. 			next_sel = 1 
  443. 		end 
  444. 		 
  445. 		-- delete active garage vehicle		 
  446. 		garage_remove_vehicle() 
  447. 		garage_build_areas() 
  448. 		store_vehicle_populate_list(Menu_data, next_sel) 
  449. 		garage_preview_vehicle(Menu_data[next_sel].id)		 
  450. 	else 
  451. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  452. 		store_unlock_controls() 
  453. 	end 
  454. end 
  455.  
  456. function store_garage_select(event) 
  457. 	Store_common_popup:nav_enable(false, nil, nil) 
  458. 	Not_popup_grp:set_alpha(1) 
  459. 	Active_list:set_visible(true) 
  460. 	 
  461. 	-- The user hit the B button and is exiting 
  462. 	-- This is redundant to selecting "No" in the list 
  463. 	if event == "back" then 
  464. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  465. 		Active_list:set_visible(true) 
  466. 		store_unlock_controls() 
  467. 		return 
  468. 	end 
  469. 	 
  470. 	game_UI_audio_play("UI_Main_Menu_Select") 
  471. 	 
  472. 	local choice_index = Store_common_popup:get_selected_data() 
  473. 	local select_type = Garage_select_choices[choice_index].select_type 
  474. 	 
  475. 	if select_type == GARAGE_SELECT_CANCEL then 
  476. 		Active_list:set_visible(true) 
  477. 		store_unlock_controls() 
  478. 		return 
  479. 	 
  480. 	elseif select_type == GARAGE_SELECT_REPAIR then  
  481. 		-- do repair 
  482. 		if Store_common_player_cash >= garage_get_repair_cost() then 
  483. 			garage_repair_vehicle() 
  484. 		else 
  485. 			-- INSUFFICIENT FUNDS MESSAGE BOX 
  486. 			Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  487. 			Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  488. 			Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")		 
  489. 			Store_common_popup:nav_enable(true, "store_garage_repair_confirm", "store_vehicle_popup_nav") 
  490. 			Not_popup_grp:set_alpha(.5) 
  491. 			Active_list:set_visible(false) 
  492.  
  493. 			-- Disable mouse input for active_list and hint_bar 
  494. 			store_vehicle_enable_mouse(false)				 
  495. 		end 
  496. 	end 
  497. 	 
  498. 	if select_type == GARAGE_SELECT_CUSTOMIZE then 
  499. 		local repair_cost = garage_get_repair_cost() 
  500. 		if repair_cost == 0 then 
  501. 			-- do customize 
  502. 			store_vehicle_switch_mode() 
  503. 		else 
  504. 			local insert_values = { [0] = repair_cost } 
  505. 			local tag = vint_insert_values_in_string("GARAGE_REPAIR_VEHICLE", insert_values) 
  506. 			local customize_choices = { 
  507. 				[1] = { 
  508. 					type = TYPE_BUTTON, 
  509. 					label = tag, 
  510. 					id = 1, 
  511. 				}, 
  512. 				[2] = { 
  513. 					type = TYPE_BUTTON, 
  514. 					label = "CONTROL_CANCEL", 
  515. 					id = 2, 
  516. 				}, 
  517. 			} 
  518. 			 
  519. 			-- NEED FULL REPAIR MESSAGE BOX 
  520. 			Store_common_popup:populate_list(customize_choices, 1, STORE_COMMON_LIST_SIZE, 2) 
  521. 			Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  522. 			Store_common_popup:set_text("GARAGE_REPAIR_BEFORE_CUSTOMIZATION")		 
  523. 			Store_common_popup:nav_enable(true, "store_garage_customize_repair_confirm", "store_vehicle_popup_nav") 
  524. 			Not_popup_grp:set_alpha(.5)	 
  525. 			Active_list:set_visible(false) 
  526.  
  527. 			-- Disable mouse input for active_list and hint_bar 
  528. 			store_vehicle_enable_mouse(false) 
  529. 		end 
  530. 	end 
  531. 	 
  532. 	if select_type == GARAGE_SELECT_RETRIEVE then 
  533. 		-- do retrieve 
  534. 		store_vehicle_retrieve_car_and_exit() 
  535. 	end 
  536. 	 
  537. 	if select_type == GARAGE_SELECT_DELETE then 
  538. 		-- DESTROY CONFIRMATION MESSAGE BOX 
  539. 		Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2) 
  540. 		Store_common_popup:set_title("MENU_TITLE_WARNING") 
  541. 		Store_common_popup:set_text("GARAGE_REMOVE_PROMPT")	 
  542. 		Store_common_popup:nav_enable(true, "store_garage_destroy_confirm", "store_vehicle_popup_nav") 
  543. 		Not_popup_grp:set_alpha(.5)	 
  544. 		Active_list:set_visible(false) 
  545. 		 
  546. 		-- Disable mouse input for active_list and hint_bar 
  547. 		store_vehicle_enable_mouse(false) 
  548. 	end 
  549. 	 
  550. 	if select_type == GARAGE_SELECT_CRIB then 
  551. 		store_vehicle_return_to_crib() 
  552. 	end 
  553. end 
  554.  
  555.  
  556. -- Make the purchase for realz 
  557. function store_vehicle_component_confirm(event) 
  558. 	Store_common_popup:nav_enable(false, nil, nil) 
  559. 	Not_popup_grp:set_alpha(1) 
  560. 	Active_list:set_visible(true) 
  561. 	store_vehicle_enable_mouse(true) 
  562. 	 
  563. 	-- The user hit the B button and is exiting 
  564. 	-- This is redundant to selecting "No" in the list 
  565. 	if event == "back" then 
  566. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  567. 		return 
  568. 	end 
  569. 	 
  570. 	-- Did we select yes?  This assumes yes is the first item 
  571. 	if Store_common_popup:get_selected_data() ~= 1 then	 
  572. 		return 
  573. 	end 
  574. 	 
  575. 	if vcust_show_nos_hydraulic_warning() == true then 
  576. 		Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  577. 		Store_common_popup:set_title("MENU_TITLE_CONFIRM") 
  578. 		Store_common_popup:set_text("VCUST_PERFORMANCE_WARNING")		 
  579. 		Store_common_popup:nav_enable(true, "store_vehicle_component_confirm2", "store_vehicle_popup_nav") 
  580. 		Not_popup_grp:set_alpha(.5)	 
  581. 		Active_list:set_visible(false) 
  582.  
  583. 		-- Disable mouse input for active_list and hint_bar 
  584. 		store_vehicle_enable_mouse(false) 
  585. 	else 
  586. 		store_vehicle_component_confirm2("accept") 
  587. 	end 
  588. end 
  589.  
  590. function store_vehicle_component_confirm2(event) 
  591. 	Store_common_popup:nav_enable(false, nil, nil) 
  592. 	Not_popup_grp:set_alpha(1) 
  593. 	Active_list:set_visible(true) 
  594. 	 
  595. 	-- Re-enable the mouse for disabled elements 
  596. 	store_vehicle_enable_mouse(true) 
  597.  
  598. 	-- The user hit the B button and is exiting 
  599. 	-- This is redundant to selecting "No" in the list 
  600. 	if event == "back" then 
  601. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  602. 		return 
  603. 	end 
  604. 	 
  605. 	-- Did we select yes?  This assumes yes is the first item 
  606. 	if Store_common_popup:get_selected_data() ~= 1 then 
  607. 		return 
  608. 	end 
  609. 	 
  610. 	if Store_vehicle_component_selected.price ~= 0 then 
  611. 		game_award_respect(Store_vehicle_component_selected.style) 
  612. 		 
  613. 		ui_audio_post_event("vehicle_purchase") 
  614. 		 
  615. 		if Vehicle_just_upgrade	== true then 
  616. 			Vehicle_just_upgrade = false 
  617. 		end 
  618. 	end 
  619. 	 
  620. 	Store_vehicle_component_selected.owned = true 
  621. 	 
  622. 	store_vehicle_component_confirm_final() 
  623. 	 
  624. end 
  625.  
  626. function store_vehicle_component_confirm_final() 
  627. 	--	Stop previewing the component, keep it and deduct cash 
  628. 	vcust_purchase_component()		 
  629. 	 
  630. 	-- Clear out the on_back function, so we don't revert this choice when backing out of menu 
  631. 	Menu_data[Active_list:get_selection()].on_back = nil 
  632. 	 
  633. 	-- make sure to clear header of old price data. 
  634. 	store_vehicle_clear_header()	 
  635. 	 
  636. 	-- back out of menu 
  637. 	store_common_button_b() 
  638. end 
  639.  
  640. function store_vehicle_fail_msg(event) 
  641. 	Store_common_popup:nav_enable(false, nil, nil) 
  642. 	Not_popup_grp:set_alpha(1) 
  643. 	game_UI_audio_play("UI_Main_Menu_Select")	 
  644. 	 
  645. 	-- Re-enable the mouse for active_list and hint_bar 
  646. 	if Current_tier ~= PALETTE_TIER and Current_tier ~= COLOR_TIER then 
  647. 		store_vehicle_enable_mouse(true) 
  648. 		Active_list:set_visible(true) 
  649. 	else 
  650. 		Active_list:set_visible(false) 
  651. 		 
  652. 		-- Re-enable the mouse 
  653. 		if Store_vehicle_select_palette_first then 
  654. 			Store_common_color_grid:nav_enable(true, "store_vehicle_trim_color_selected", "store_vehicle_trim_color_grid_nav") 
  655. 		else 
  656. 			if Store_vehicle_multiple_palettes == false then 
  657. 				store_vehicle_return_to_color_grid() 
  658. 			else 
  659. 				Store_common_color_grid:nav_enable(true, "store_vehicle_palette_selected", "store_vehicle_palette_grid_nav") 
  660. 			end 
  661. 		end 
  662. 		if Hint_bar_mouse_input_tracker ~= nil then 
  663. 			Hint_bar_mouse_input_tracker:subscribe(true) 
  664. 		end 
  665. 		 
  666. 	end 
  667. end 
  668.  
  669. ---[ Generic Menu ]--- 
  670. function store_vehicle_build_menu(menu_data) 
  671. 	Store_vehicle_show_slot = Menu_data[Active_list:get_selection()].id 
  672. 	 
  673. 	--	If we get back here, we need to rebuild the wheel menu next time we go in 
  674. 	Store_vehicle_rebuild_wheel_menu = true 
  675. 	 
  676. 	Store_vehicle_building_menu = menu_data.sub_menu 
  677. 	 
  678. 	Store_vehicle_building_menu.start_index = 1 
  679.  
  680. 	-- Make the request to build the menu 
  681. 	if Store_vehicle_show_slot == -1 or Store_vehicle_show_region == true then 
  682. 		 
  683. 		-- Build region menu 
  684. 		if Store_vehicle_show_region == true then 
  685. 			Store_vehicle_show_region = false 
  686. 			vint_dataresponder_request("vcust_populate_menu", "store_vehicle_populate_menu", 0, STORE_VEHICLE_POPULATE_COLOR_REGION) 
  687. 			 
  688. 			-- If we only have 1 color region, just skip this menu and go on 
  689. 			if #Store_vehicle_building_menu == 1 then 
  690. 				local item = Store_vehicle_building_menu[1] 
  691. 				menu_data.sub_menu = {} 
  692. 				 
  693. 				if Store_vehicle_select_palette_first then 
  694. 					store_vehicle_populate_trim_palette_menu(item) 
  695. 				else  
  696. 					store_vehicle_populate_color_grid(item) 
  697. 				end 
  698. 			end 
  699. 			 
  700. 			-- flag to indicate how many menus we need to back up later 
  701. 			Store_vehicle_region_menu_bypassed = (#Store_vehicle_building_menu == 1) 
  702. 		else 
  703. 			vint_dataresponder_request("vcust_populate_menu", "store_vehicle_populate_menu", 0, STORE_VEHICLE_POPULATE_CURRENT_MENU) 
  704. 		end 
  705. 		 
  706. 	else  
  707. 		vint_dataresponder_request("vcust_populate_menu", "store_vehicle_populate_items_menu", 0, STORE_VEHICLE_POPULATE_COMPONENT_MENU, Store_vehicle_show_slot) 
  708. 		 
  709. 		local component =  Store_vehicle_building_menu[Store_vehicle_building_menu.start_index] 
  710. 		vcust_preview_component(0, component.id) 
  711. 	end 
  712. 	Store_vehicle_show_slot = -1 -- Reset it so we don't get stuck in perma-slot menu 
  713. 	 
  714. 	if #Store_vehicle_building_menu == 0 then 
  715. 		local item = { label = "STORE_NO_ITEMS_IN_CATEGORY", type = TYPE_BUTTON } 
  716. 		Store_vehicle_building_menu[1] = item 
  717. 	end 
  718. end 
  719.  
  720. function store_vehicle_populate_items_menu(display_name, cat_type, id, price, current, level, desc, respect) 
  721. 	-- Add the item 
  722. 	local item = { label = display_name, type = TYPE_BUTTON, sub_menu = nil, id = id, price = price,  
  723. 						equipped = current, on_select = store_vehicle_select_component, on_nav = store_vehicle_nav_component,  
  724. 						on_back = store_vehicle_revert_component } 
  725. 	if price == 0 then 
  726. 		item.owned = true 
  727. 		item.style = 0 
  728. 	elseif price == nil then 
  729. 		-- Don't show checkbox for items that can't be purchased 
  730. 		item.owned = nil 
  731. 		item.style = 0 
  732. 	else 
  733. 		item.owned = false 
  734. 		item.style = respect 
  735. 	end 
  736. 	 
  737. 	local menu_idx = #Store_vehicle_building_menu + 1 
  738. 	Store_vehicle_building_menu[menu_idx] = item 
  739. 	 
  740. 	-- is this the currently owned item? 
  741. 	if current == true then 
  742. 		Store_vehicle_building_menu.start_index = menu_idx		 
  743. 	end	 
  744. end 
  745.  
  746.  
  747. -- Wheel menus 
  748. ----------------------------------- 
  749.  
  750. function store_vehicle_rim_peg_loaded() 
  751. 	-- input_data, current_option, max_width, max_height, button_w, button_h, hint_button_offset, current_category, outline_scale, background_enabled, show_current_button_bool, grid_spacing, set_size 
  752. 	Store_common_color_grid:draw_items(Color_grid_data, 1, 5, 4, 82, 80, 30, nil, 1.1, true, false, nil, nil) 
  753. 	 
  754. 	-- Initialize grid navigation for mouse 
  755. 	Old_vehicle_grid_index = -1 
  756. 	Old_vehicle_grid_category = -1 
  757. 	 
  758. 	Store_common_color_grid:nav_enable(true, "store_vehicle_rim_selected", "store_vehicle_rim_grid_nav")	 
  759.  
  760. 	-- update price and respect 
  761. 	local item = Store_common_color_grid:return_selected_data()	 
  762. 	if item.price ~= nil and item.price > 0 then 
  763. 		Store_header:set_price(item.price) 
  764. 		Store_header:set_respect(item.style) 
  765. 		Store_header:enable_price_respect(true) 
  766. 	else 
  767. 		store_vehicle_clear_header() 
  768. 	end	 
  769. 	 
  770. 	Store_vehicle_wheel_price.rim = item.price 
  771. 	Store_vehicle_wheel_respect.rim = item.style 
  772. 	 
  773. 	Store_common_color_grid:set_visible(true)	 
  774. 	Active_list:set_visible(false) 
  775. 	 
  776. 	-- set the titles on top 
  777. 	Store_header:push_title(nil, "VCUST_RIM_FAMILY_TITLE") 
  778. 	 
  779. 	-- Disable the mouse for the active list when showing the color grid 
  780. 	if Mouse_input_tracker ~= 0 then 
  781. 		Mouse_input_tracker:subscribe(false) 
  782. 	end 
  783. 	Current_tier = RIM_TIER 
  784. end 
  785.  
  786. function store_vehicle_build_rim_menu(menu_data) 
  787. 	-- New menu, clear out all items 
  788. 	Color_grid_data = {} 
  789. 	 
  790. 	-- We need special tables for all the spinners, which will be the last category 
  791. 	Store_vehicle_spinner_cat = { category_name = "VCUST_SPINNERS_TITLE" } 
  792. 	 
  793. 	-- Fill all the categories 
  794. 	vint_dataresponder_request("vcust_populate_wheel_menu", "store_vehicle_populate_rim_category", 0, 8) -- 8 = VCUST_INTF_POPULATE_RIM_FAMILY_MENU 
  795. 	 
  796. 	-- place the spinner categories as the last two in the grid, as long as they contain entries 
  797. 	if #Store_vehicle_spinner_cat > 0 then 
  798. 		Color_grid_data[#Color_grid_data + 1] = Store_vehicle_spinner_cat 
  799. 	end 
  800. 	 
  801. 	-- Load peg and wait for callback 
  802. 	game_peg_load_with_cb("store_vehicle_rim_peg_loaded", 1, VEHICLE_CUST_RIM_PEG)	 
  803. end 
  804.  
  805. function store_vehicle_populate_rim_category(display_name, current, id) 
  806.  
  807. 	local category = { category_name = display_name } 
  808. 	local cat_index = #Color_grid_data + 1 
  809. 	Store_vehicle_current_rim_id	= 0 
  810. 	Color_grid_data[cat_index] = category 
  811. 	 
  812. 	-- Used to store the rim category for spinners, since they are put in a different category in the UI then the code needs 
  813. 	Store_vehicle_current_cat_id = id	 
  814. 	 
  815. 	Store_vehicle_building_menu = Color_grid_data[cat_index] 
  816. 	 
  817. 	-- Make the request to fill the category 
  818. 	vint_dataresponder_request("vcust_populate_wheel_grid_menu", "store_vehicle_populate_rim_grid", 0, 9, id) -- 9 = VCUST_INTF_POPULATE_RIM_MENU	 
  819. 	 
  820. 	-- Make the request to find spinners in this category 
  821. 	local prev_spinner_count = #Store_vehicle_spinner_cat 
  822. 	Store_vehicle_building_menu = Store_vehicle_spinner_cat 
  823. 	Store_vehicle_current_rim_id = 0 
  824. 	vint_dataresponder_request("vcust_populate_wheel_grid_menu", "store_vehicle_populate_rim_grid", 0, 12, id) -- 12 = VCUST_INTF_POPULATE_SPINNERS_MENU	 
  825. end 
  826.  
  827. function store_vehicle_populate_rim_grid(display_name, image_crc, price, current, respect) 
  828.  
  829. 	local item_index = #Store_vehicle_building_menu + 1 
  830.  
  831. 	if display_name == nil then 
  832. 		local insert_values = { [0] = item_index, } 
  833. 		display_name = vint_insert_values_in_string("VCUST_RIM_NUMBER", insert_values) 
  834. 	end 
  835.  
  836. 	local item = { label = display_name, type = TYPE_BUTTON, icon_crc = image_crc, price = price, category_id = Store_vehicle_current_cat_id, 
  837. 						id = 	item_index - 1, color = {red = 1, green = 1, blue = 1}, } 
  838.  
  839. 	Store_vehicle_current_rim_id	= Store_vehicle_current_rim_id + 1 
  840. 						 
  841. 	if price == 0 then 
  842. 		item.owned = true 
  843. 	else 
  844. 		item.owned = false 
  845. 		item.style = respect 
  846. 	end 
  847. 	 
  848. 	Store_vehicle_building_menu[item_index] = item 
  849. end 
  850.  
  851. function store_vehicle_rim_selected(event) 
  852. 	-- remove title 
  853. 	Store_header:pop_title()	 
  854. 	 
  855. 	-- Did the player make a selection? 
  856. 	if event == "select" or event == "mouse_click" then 
  857. 		local idx = Store_common_color_grid:return_selected_index() 
  858. 		if idx <= #Color_grid_data then 
  859. 		end 
  860. 		game_UI_audio_play("UI_Main_Menu_Select") 
  861. 	else 
  862. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  863. 	end	 
  864. 	 
  865. 	store_vehicle_swap_logo(nil, false) 
  866. 		 
  867. 	game_peg_unload(VEHICLE_CUST_RIM_PEG) 
  868. 	 
  869. 	store_vehicle_update_total_price() 
  870. 	Store_common_color_grid:nav_enable(false, nil, nil) 
  871. 	Store_common_color_grid:set_visible(false) 
  872. 	Active_list:set_visible(true) 
  873. 	 
  874. 	Current_tier = MENU_TIER 
  875. 	 
  876. 	store_vehicle_enable_mouse(true) 
  877. end 
  878.  
  879. function store_vehicle_build_tire_menu(menu_data) 
  880. 	-- make sure to load our pegs, starting in 1st category 
  881. 	game_peg_load_with_cb("store_vehicle_tire_peg_loaded", 1, VEHICLE_CUST_TIRE_PEG)	 
  882. end 
  883.  
  884. function store_vehicle_tire_peg_loaded() 
  885. 	-- New menu, clear out all items 
  886. 	Color_grid_data = {} 
  887. 	 
  888. 	vint_dataresponder_request("vcust_populate_wheel_grid_menu", "store_vehicle_populate_tire_menu", 0, 10) -- 10 = VCUST_INTF_POPULATE_TIRE_MENU 
  889.  
  890. 	local grid_rows = ceil(#Color_grid_data / 5) 
  891. 	 
  892. 	Store_common_color_grid:draw_items(Color_grid_data, 1, 5, grid_rows, 92, 80, 35, nil, 1.1, true, false) 
  893. 	 
  894. 	-- Initialize grid navigation for mouse 
  895. 	Old_vehicle_grid_index = -1 
  896. 	 
  897. 	Store_common_color_grid:nav_enable(true, "store_vehicle_tire_selected", "store_vehicle_tire_grid_nav")	 
  898.  
  899. 	-- update price and respect 
  900. 	local item = Store_common_color_grid:return_selected_data()	 
  901. 	if item.price ~= nil and item.price > 0 then 
  902. 		Store_header:set_price(item.price) 
  903. 		Store_header:set_respect(item.style) 
  904. 		Store_header:enable_price_respect(true) 
  905. 	else 
  906. 		store_vehicle_clear_header() 
  907. 	end	 
  908. 	 
  909. 	Store_vehicle_wheel_price.tire = item.price 
  910. 	Store_vehicle_wheel_respect.tire = item.style	 
  911. 	 
  912. 	Store_common_color_grid:set_visible(true)	 
  913. 	Active_list:set_visible(false) 
  914. 	 
  915. 	-- set the titles on top 
  916. 	Store_header:push_title(nil, "VCUST_TIRE_TREAD_OPTION")	 
  917. 	 
  918. 	-- Disable the mouse for the active list when showing the color grid 
  919. 	if Mouse_input_tracker ~= 0 then 
  920. 		Mouse_input_tracker:subscribe(false) 
  921. 	end 
  922. 	Current_tier = TIRE_TIER 
  923. end 
  924.  
  925. function store_vehicle_populate_tire_menu(display_name, image_crc, price, current, respect) 
  926. 	local item_index = #Color_grid_data + 1 
  927.  
  928. 	local insert_values = { [0] = item_index, } 
  929. 	local rim_name = vint_insert_values_in_string("VCUST_TIRE_TREAD_NUMBER", insert_values) 
  930.  
  931. 	local item = { label = rim_name, type = TYPE_BUTTON, icon_crc = image_crc, price = price, 
  932. 						id = 	item_index - 1, color = {red = 1, green = 1, blue = 1}, } 
  933.  
  934. 	if price == 0 then 
  935. 		item.owned = true 
  936. 	else 
  937. 		item.owned = false 
  938. 		item.style = respect 
  939. 	end 
  940. 	 
  941. 	Color_grid_data[item_index] = item 
  942. end 
  943.  
  944. function store_vehicle_tire_grid_nav(event, value) 
  945. 	store_vehicle_grid_nav(event, false, value) 
  946.  
  947. 	Store_header:enable_price_respect(true) 
  948. 	-- update price and respect 
  949. 	local item = Store_common_color_grid:return_selected_data()	 
  950. 	if item.price ~= nil and item.price > 0 then 
  951. 		Store_header:set_price(item.price) 
  952. 		Store_header:set_respect(item.style) 
  953. 		Store_header:enable_price_respect(true) 
  954. 	else 
  955. 		store_vehicle_clear_header() 
  956. 	end 
  957. 	 
  958. 	Store_vehicle_wheel_price.tire = item.price	 
  959. 	Store_vehicle_wheel_respect.tire = item.style 
  960. 	 
  961. 	-- preview the tire 
  962. 	local idx = Store_common_color_grid:return_selected_index() 
  963. 	vcust_preview_component(2, 1, idx - 1) 
  964. end 
  965.  
  966. function store_vehicle_tire_selected(event) 
  967. 	-- remove title 
  968. 	Store_header:pop_title()	 
  969. 	 
  970. 	-- Did the player make a selection? 
  971. 	if event == "select" or event == "mouse_click" then 
  972. 		local idx = Store_common_color_grid:return_selected_index() 
  973. 		if idx <= #Color_grid_data then 
  974. 		end 
  975. 		game_UI_audio_play("UI_Main_Menu_Select") 
  976. 	else 
  977. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  978. 	end	 
  979. 	 
  980. 	game_peg_unload(VEHICLE_CUST_TIRE_PEG)	 
  981. 	store_vehicle_update_total_price() 
  982. 	Store_common_color_grid:nav_enable(false, nil, nil) 
  983. 	Store_common_color_grid:set_visible(false) 
  984. 	Active_list:set_visible(true) 
  985. 	 
  986. 	-- Re-enable the mouse 
  987. 	if Mouse_input_tracker ~= 0 then 
  988. 		Mouse_input_tracker:subscribe(true) 
  989. 	end 
  990. 	Current_tier = MENU_TIER 
  991. end 
  992.  
  993. function store_vehicle_update_total_price() 
  994. 	local price = Store_vehicle_wheel_price.rim + Store_vehicle_wheel_price.tire + Store_vehicle_wheel_price.size 
  995. 	 
  996. 	if Store_vehicle_wheel_respect.rim == nil then 
  997. 		Store_vehicle_wheel_respect.rim = 0 
  998. 	end 
  999. 	if Store_vehicle_wheel_respect.tire == nil then 
  1000. 		Store_vehicle_wheel_respect.tire = 0 
  1001. 	end 
  1002. 	if Store_vehicle_wheel_respect.size == nil then 
  1003. 		Store_vehicle_wheel_respect.size = 0 
  1004. 	end 
  1005. 	 
  1006. 	local respect =  Store_vehicle_wheel_respect.rim + Store_vehicle_wheel_respect.tire + Store_vehicle_wheel_respect.size 
  1007. 	 
  1008. 	if price ~= nil and price > 0 then 
  1009. 		Store_header:set_price(price) 
  1010. 		Store_header:set_respect(respect) 
  1011. 		Store_header:enable_price_respect(true) 
  1012. 	else 
  1013. 		store_vehicle_clear_header() 
  1014. 	end 
  1015. 	 
  1016. 	return price, respect 
  1017. end 
  1018.  
  1019. function store_vehicle_purchase_wheels(menu_data) 
  1020. 	 
  1021. 	local price, respect = store_vehicle_update_total_price() 
  1022. 	 
  1023. 	-- Is it free? 
  1024. 	 
  1025. 	if price == 0 then 
  1026. 		vcust_purchase_wheels(price) 
  1027. 		return 
  1028. 	else 
  1029.  
  1030. 		-- Are we short on cash? 
  1031. 		if price > Store_common_player_cash then 
  1032. 			Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  1033. 			Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  1034. 			Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")		 
  1035. 			Store_common_popup:nav_enable(true, "store_vehicle_fail_msg", "store_vehicle_popup_nav") 
  1036. 			Not_popup_grp:set_alpha(.5)	 
  1037. 			Active_list:set_visible(false) 
  1038.  
  1039. 			-- Disable mouse input for active_list and hint_bar 
  1040. 			store_vehicle_enable_mouse(false) 
  1041. 			return 
  1042. 		end 
  1043. 		 
  1044. 		-- Make sure they want to buy this 
  1045. 		Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  1046. 		Store_common_popup:set_title("STORE_TITLE_PURCHASING") 
  1047. 		local insert = { [0] = format_cash(price) } 
  1048. 		local body = vint_insert_values_in_string("VCUST_PURCHASE_WHEELS_PROMPT", insert)		 
  1049. 		Store_common_popup:set_text(body)				 
  1050. 		Store_common_popup:nav_enable(true, "store_vehicle_purchase_wheels_final", "store_vehicle_popup_nav") 
  1051. 		Not_popup_grp:set_alpha(.5) 
  1052. 		Active_list:set_visible(false) 
  1053. 		 
  1054. 		-- Disable the mouse for active_list and hint_bar 
  1055. 		store_vehicle_enable_mouse(false) 
  1056. 	end 
  1057. end 
  1058.  
  1059. -- Make the purchase for realz 
  1060. function store_vehicle_purchase_wheels_final(event) 
  1061.  
  1062. 	Store_common_popup:nav_enable(false, nil, nil) 
  1063. 	Not_popup_grp:set_alpha(1) 
  1064. 	Active_list:set_visible(true) 
  1065.  
  1066. 	-- Re-enable the mouse 
  1067. 	store_vehicle_enable_mouse(true) 
  1068.  
  1069. 	-- The user hit the B button and are cancelling the purchase 
  1070. 	-- This is redundant to selecting "No" in the list 
  1071. 	if event == "back" then 
  1072. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  1073. 		return 
  1074. 	end 
  1075. 	 
  1076. 	game_UI_audio_play("UI_Main_Menu_Select")	 
  1077. 	 
  1078. 	-- Did we select yes?  This assumes yes is the first item 
  1079. 	if Store_common_popup:get_selected_data() ~= 1 then 
  1080. 		return 
  1081. 	end 
  1082.  
  1083. 	-- award respect and actually purchase the item 
  1084. 	local price, respect = store_vehicle_update_total_price() 
  1085. 	 
  1086. 	game_award_respect(respect) 
  1087. 	vcust_purchase_wheels(price) 
  1088. 	ui_audio_post_event("vehicle_purchase") 
  1089.  
  1090. 	-- back up a menu 
  1091. 	store_common_button_b() 
  1092. 	 
  1093. 	-- do this so holding down the button doesn't cause repeated actions 
  1094. 	store_lock_controls() 
  1095. 	store_unlock_controls() 
  1096. 	--Input_tracker:subscribe(false)		 
  1097. 	--Input_tracker:subscribe(true)	 
  1098. 	 
  1099. end 
  1100.  
  1101. function store_vehicle_select_axle(menu_data) 
  1102. 	-- subtract 2 now, since indexing starts at 1 
  1103. 	Store_vehicle_chosen_axle = Active_list:get_selection() - 2   -- -1 = both, 0 = front, 1 = rear 
  1104. end 
  1105.  
  1106. function store_vehicle_fill_wheel_menu(menu_data) 
  1107. 	Store_vehicle_building_menu = menu_data.sub_menu 
  1108. 	vint_dataresponder_request("vcust_populate_wheel_menu", "store_vehicle_populate_wheel_menu", 0, 7, true, Store_vehicle_chosen_axle) -- 7 = VCUST_INTF_POPULATE_WHEEL_MENU 
  1109. 	Store_vehicle_rebuild_wheel_menu = false 
  1110. end 
  1111.  
  1112. function store_vehicle_rim_size_update(menu_data) 
  1113. 	Store_vehicle_wheel_price.size = Store_vehicle_wheel_base_price 
  1114. 	Store_vehicle_wheel_respect.size = Store_vehicle_wheel_base_respect 
  1115. 	store_vehicle_update_total_price() 
  1116. 	vcust_preview_rim_sizing(menu_data.current_value - 1) 
  1117. end 
  1118.  
  1119. function store_vehicle_wheel_size_update(menu_data) 
  1120. 	Store_vehicle_wheel_price.size = Store_vehicle_wheel_base_price 
  1121. 	Store_vehicle_wheel_respect.size = Store_vehicle_wheel_base_respect 
  1122. 	store_vehicle_update_total_price() 
  1123. 	vcust_preview_wheel_sizing(menu_data.current_value, -1) 
  1124. end 
  1125.  
  1126. function store_vehicle_wheel_width_update(menu_data) 
  1127. 	Store_vehicle_wheel_price.size = Store_vehicle_wheel_base_price 
  1128. 	Store_vehicle_wheel_respect.size = Store_vehicle_wheel_base_respect 
  1129. 	store_vehicle_update_total_price() 
  1130. 	vcust_preview_wheel_sizing(-1, menu_data.current_value)	 
  1131. end 
  1132.  
  1133. -- Data responder callback.  This populates our wheel menu with the data specific to this vehicle. 
  1134. -- Called by the sub_menu_fill callback to populate our megalist submenu data. 
  1135. -- 
  1136. function store_vehicle_populate_wheel_menu(rim_display_name, tire_index, spinner_index, current_rim_family, rim_size, 
  1137. 														wheel_size_min, wheel_size_max, wheel_size,  
  1138. 														wheel_width_min, wheel_width_max, wheel_width, price, respect) 
  1139. 														 
  1140. 	local index = 1 
  1141. 	 
  1142. 	Store_vehicle_building_menu[index] = { label = "VCUST_RIM_STYLE_OPTION", 	type = TYPE_BUTTON, on_select = store_vehicle_build_rim_menu, on_cancel = vcust_revert_wheels} 
  1143. 	index = index + 1 
  1144. 	 
  1145. 	Store_vehicle_building_menu[index] = { label = "VCUST_TIRE_TREAD_OPTION", 	type = TYPE_BUTTON, on_select = store_vehicle_build_tire_menu, on_cancel = vcust_revert_wheels } 
  1146. 	index = index + 1	 
  1147. 		 
  1148. 	Store_vehicle_building_menu[index] = { label = "VCUST_RIM_SIZE_OPTION", 	type = TYPE_TOGGLE, on_value_update = store_vehicle_rim_size_update, 
  1149. 																	options = Store_vehicle_rim_sizes, on_cancel = vcust_revert_wheels } 
  1150. 																	 
  1151. 	local rim_size_index = rim_size + 1 
  1152. 	if rim_size_index < 1 or rim_size_index > #Store_vehicle_rim_sizes then 
  1153. 		rim_size_index = Store_vehicle_rim_sizes.median_rim_size 
  1154. 	end 
  1155. 	Store_vehicle_building_menu[index].current_value = rim_size_index 
  1156. 							 
  1157. 	index = index + 1 
  1158.  
  1159. 	local wheel_size_mapping = { [0] = 7, 9, 12, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 41, 45, 52 } 
  1160. 	 
  1161. 	if wheel_size_min ~= wheel_size_max then 
  1162. 		Store_vehicle_building_menu[index] = { label = "VCUST_WHEEL_SIZE_OPTION", type = TYPE_SLIDER,  
  1163. 																		min = wheel_size_min, max = wheel_size_max, step = 1, current_value = wheel_size,  
  1164. 																		on_value_update = store_vehicle_wheel_size_update, on_cancel = vcust_revert_wheels,  
  1165. 																		mapping = wheel_size_mapping } 
  1166. 		index = index + 1 
  1167. 	end 
  1168. 		 
  1169. 	if wheel_width_min ~= wheel_width_max then 
  1170. 		Store_vehicle_building_menu[index] = { label = "VCUST_WHEEL_WIDTH_OPTION", type = TYPE_SLIDER,  
  1171. 																		min = wheel_width_min, max = wheel_width_max, step = 1, current_value = wheel_width,  
  1172. 																		on_value_update = store_vehicle_wheel_width_update, disabled = false, on_cancel = vcust_revert_wheels} 
  1173. 		index = index + 1 
  1174. 	end 
  1175. 		 
  1176. 	Store_vehicle_building_menu[index] = { label = "VCUST_PURCHASE_OPTION",	type = TYPE_BUTTON, on_select = store_vehicle_purchase_wheels, on_cancel = vcust_revert_wheels } 
  1177. 	index = index + 1 
  1178. 	 
  1179. 	Store_vehicle_wheel_price.rim = 0 
  1180. 	Store_vehicle_wheel_price.tire = 0 
  1181. 	Store_vehicle_wheel_price.size = 0 
  1182. 	Store_vehicle_wheel_respect.rim = 0 
  1183. 	Store_vehicle_wheel_respect.tire = 0 
  1184. 	Store_vehicle_wheel_respect.size = 0 
  1185. 	 
  1186. 	Store_vehicle_wheel_base_price = price 
  1187. 	Store_vehicle_wheel_base_respect = respect 
  1188. 	 
  1189. end 
  1190.  
  1191. function store_vehicle_clear_rim_selections() 
  1192. 	store_vehicle_clear_header() 
  1193. 	Store_vehicle_wheel_price.rim = 0 
  1194. 	Store_vehicle_wheel_price.tire = 0 
  1195. 	Store_vehicle_wheel_price.size = 0 
  1196. end 
  1197.  
  1198. Store_vehicle_axle_menu = { 
  1199. 	on_enter = store_vehicle_clear_rim_selections, 
  1200. 	[1] = { label = "VCUST_BOTH_AXLES_OPTION", type = TYPE_BUTTON, on_sub_menu_fill = store_vehicle_fill_wheel_menu, on_select = store_vehicle_select_axle, vcamera = "Both_axle" }, 
  1201. 	[2] = { label = "VCUST_FRONT_AXLE_OPTION", type = TYPE_BUTTON, on_sub_menu_fill = store_vehicle_fill_wheel_menu, on_select = store_vehicle_select_axle, vcamera = "Front_axle" }, 
  1202. 	[3] = { label = "VCUST_REAR_AXLE_OPTION" , type = TYPE_BUTTON, on_sub_menu_fill = store_vehicle_fill_wheel_menu, on_select = store_vehicle_select_axle, vcamera = "Rear_axle" }, 
  1203. } 
  1204.  
  1205. -- Color menus 
  1206. ------------------------------------- 
  1207.  
  1208. function store_vehicle_select_region(menu_data) 
  1209. 	Store_vehicle_color_slot = menu_data.id 
  1210. 	vcust_select_paint_slot(Store_vehicle_color_slot)					--	Build the paint slots 
  1211. 	Store_vehicle_show_region = true 
  1212. 	store_vehicle_build_menu(menu_data) 
  1213. end 
  1214.  
  1215. function store_vehicle_palette_selected(event) 
  1216.  
  1217. 	-- Did the player make a selection? 
  1218. 	if event == "select" or event == "mouse_click" then 
  1219. 		local idx = Store_common_color_grid:return_selected_index() 
  1220. 		if idx <= #Color_grid_data then 
  1221. 		end 
  1222. 		 
  1223. 		Store_common_color_grid:nav_enable(false, nil, nil)	-- disable input going to grid control			 
  1224. 		store_vehicle_enable_mouse(false) 
  1225. 		 
  1226. 		-- Now we need to check for purchasing 
  1227. 		 
  1228. 		-- Are we short on cash? 
  1229. 		if Store_vehicle_color_price > Store_common_player_cash then 
  1230. 			Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  1231. 			Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  1232. 			Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")		 
  1233. 			Store_common_popup:nav_enable(true, "store_vehicle_fail_msg", "store_vehicle_popup_nav") 
  1234. 			Not_popup_grp:set_alpha(.5)	 
  1235. 			Active_list:set_visible(false) 
  1236.  
  1237. 			return 
  1238. 		end 
  1239. 		 
  1240. 		-- Make sure they want to buy this 
  1241. 		Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  1242. 		Store_common_popup:set_title("STORE_TITLE_PURCHASING") 
  1243. 		local insert = { [0] = Color_grid_data[idx].label, [1] = format_cash(Store_vehicle_color_price) } 
  1244. 		local body = vint_insert_values_in_string("VCUST_PURCHASE_PROMPT", insert)		 
  1245. 		Store_common_popup:set_text(body)				 
  1246. 		Store_common_popup:nav_enable(true, "store_vehicle_purchase_color_final", "store_vehicle_popup_nav") 
  1247. 		Not_popup_grp:set_alpha(.5) 
  1248. 		Active_list:set_visible(false) 
  1249. 		return 
  1250. 	end		 
  1251. 	 
  1252. 	Current_tier = MENU_TIER 
  1253. 	game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  1254. 	-- revert color choice 
  1255. 	vcust_revert_color() 
  1256. 	 
  1257. 	-- remove titles 
  1258. 	Store_header:pop_title()	 
  1259. 	Store_header:pop_title() 
  1260. 	game_peg_unload(VEHICLE_CUST_GLASS_PEG)	 
  1261. 	Store_common_color_grid:set_visible(false)	 
  1262. 	-- disable input going to grid control 
  1263. 	Store_common_color_grid:nav_enable(false, nil, nil)	-- disable input going to grid control			 
  1264. 		 
  1265. 	-- disable input going to grid control			 
  1266. 	Store_common_color_grid:nav_enable(false, nil, nil)	 
  1267. 	store_vehicle_enable_mouse(false) 
  1268. 	 
  1269. 	-- back up to color grid 
  1270. 	local temp_item = { id = Store_vehicle_color_slot } 
  1271. 	store_vehicle_populate_color_grid(temp_item, false, false, true) 
  1272.  
  1273. end 
  1274.  
  1275. function store_vehicle_purchase_color_final(event) 
  1276.  
  1277. 	Store_common_popup:nav_enable(false, nil, nil) 
  1278. 	Not_popup_grp:set_alpha(1) 
  1279. 	 
  1280. 	-- The user hit the B button and are cancelling the purchase 
  1281. 	-- This is redundant to selecting "No" in the list 
  1282. 	if event == "back" then 
  1283. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  1284.  
  1285. 		-- Re-enable the mouse 
  1286. 		if Store_vehicle_select_palette_first then 
  1287. 			Store_common_color_grid:nav_enable(true, "store_vehicle_trim_color_selected", "store_vehicle_trim_color_grid_nav") 
  1288. 		else 
  1289. 			Store_common_color_grid:nav_enable(true, "store_vehicle_palette_selected", "store_vehicle_palette_grid_nav") 
  1290. 		end 
  1291. 		if Hint_bar_mouse_input_tracker ~= nil then 
  1292. 			Hint_bar_mouse_input_tracker:subscribe(true) 
  1293. 		end 
  1294. 	 
  1295. 		-- was palette grid bypassed? 
  1296. 		if #Color_grid_data == 1 then 
  1297. 			store_vehicle_return_to_color_grid() 
  1298. 			-- work around for too many title headers showing up because of redrawing the grid 
  1299. 			Store_header:pop_title() 
  1300. 		end 
  1301. 		return 
  1302. 	end 
  1303. 	 
  1304. 	game_UI_audio_play("UI_Main_Menu_Select")	 
  1305. 	 
  1306. 	-- Did we select yes?  This assumes yes is the first item 
  1307. 	if Store_common_popup:get_selected_data() ~= 1 then 
  1308. 		-- Re-enable the mouse 
  1309. 		if Store_vehicle_select_palette_first then 
  1310. 			Store_common_color_grid:nav_enable(true, "store_vehicle_trim_color_selected", "store_vehicle_trim_color_grid_nav") 
  1311. 		else 
  1312. 			Store_common_color_grid:nav_enable(true, "store_vehicle_palette_selected", "store_vehicle_palette_grid_nav") 
  1313. 		end 
  1314. 		if Hint_bar_mouse_input_tracker ~= nil then 
  1315. 			Hint_bar_mouse_input_tracker:subscribe(true) 
  1316. 		end 
  1317. 		 
  1318. 		-- was palette grid bypassed? 
  1319. 		if #Color_grid_data == 1 then 
  1320. 			store_vehicle_return_to_color_grid() 
  1321. 			-- work around for too many title headers showing up because of redrawing the grid 
  1322. 			Store_header:pop_title()			 
  1323. 		end		 
  1324. 		return 
  1325. 	end 
  1326.  
  1327. 	Current_tier = MENU_TIER 
  1328. 	-- Re-enable the mouse 
  1329. 	store_vehicle_enable_mouse(true) 
  1330.  
  1331. 	-- award respect and actually purchase the item	 
  1332. 	game_award_respect(Store_vehicle_color_respect) 
  1333. 	vcust_purchase_paint(Store_vehicle_color_price) 
  1334. 	ui_audio_post_event("vehicle_purchase") 
  1335. 	 
  1336. 	game_peg_unload(VEHICLE_CUST_GLASS_PEG)	 
  1337. 	Store_common_color_grid:nav_enable(false, nil, nil) 
  1338. 	Store_common_color_grid:set_visible(false) 
  1339. 	 
  1340. 	store_vehicle_clear_header() 
  1341. 	Active_list:set_visible(true)		 
  1342. 	 
  1343. 	-- back out of region menu 
  1344. 	if Store_vehicle_region_menu_bypassed ~= true then 
  1345. 		store_common_button_b() 
  1346. 	end 
  1347. 	 
  1348. 	-- back up another menu if we showed the palette as a menu instead of a grid 
  1349. 	if Store_vehicle_select_palette_first == true then 
  1350. 		store_common_button_b() 
  1351. 	end 
  1352. 	 
  1353. 	-- reset titles 
  1354. 	while #Store_header.title_stack > 1 do 
  1355. 		Store_header:pop_title() 
  1356. 	end 
  1357. 	 
  1358. 	-- do this so holding down the button doesn't cause repeated actions 
  1359. 	store_lock_controls() 
  1360. 	store_unlock_controls() 
  1361. 	--Input_tracker:subscribe(false)		 
  1362. 	--Input_tracker:subscribe(true)	 
  1363. end 
  1364.  
  1365. function store_vehicle_return_to_color_grid() 
  1366. 	game_peg_unload(VEHICLE_CUST_GLASS_PEG)	 
  1367. 	Store_common_color_grid:set_visible(false)	 
  1368. 		 
  1369. 	-- disable input going to grid control			 
  1370. 	Store_common_color_grid:nav_enable(false, nil, nil)	 
  1371. 	store_vehicle_enable_mouse(false) 
  1372. 	 
  1373. 	-- back up to color grid 
  1374. 	local temp_item = { id = Store_vehicle_color_slot } 
  1375. 	store_vehicle_populate_color_grid(temp_item, false, false, true)	 
  1376. end 
  1377.  
  1378. function store_vehicle_populate_palette_grid(menu_data) 
  1379. 	-- New menu, clear out all items 
  1380. 	Color_grid_data = {} 
  1381.  
  1382. 	-- Populate all our possible finishes 
  1383. 	vint_dataresponder_request("vcust_populate_palette_menu", "store_vehicle_add_palette", 0, Store_vehicle_color_slot, false) 
  1384. 	 
  1385. 	-- if we only have 1 palette choice, then bypass the grid 
  1386. 	if Store_vehicle_multiple_palettes == false then 
  1387. 		 
  1388. 		--Store_common_color_grid:nav_enable(false, nil, nil)	-- disable input going to grid control			 
  1389. 		store_vehicle_enable_mouse(false) 
  1390. 		 
  1391. 		-- Now we need to check for purchasing 
  1392. 		 
  1393. 		-- Are we short on cash? 
  1394. 		if Store_vehicle_color_price > Store_common_player_cash then 
  1395. 			Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  1396. 			Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  1397. 			Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")		 
  1398. 			Store_common_popup:nav_enable(true, "store_vehicle_fail_msg", "store_vehicle_popup_nav") 
  1399. 			Not_popup_grp:set_alpha(.5) 
  1400. 			Active_list:set_visible(false) 
  1401.  
  1402. 			-- Re-enable the grid inside store_vehicle_fail_msg, not here (screws up mouse inputs if it's done here) 
  1403. 			return 
  1404. 		end 
  1405. 		 
  1406. 		-- Make sure they want to buy this 
  1407. 		Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  1408. 		Store_common_popup:set_title("STORE_TITLE_PURCHASING") 
  1409. 		local insert = { [0] = Color_grid_data[1].label, [1] = format_cash(Store_vehicle_color_price) } 
  1410. 		local body = vint_insert_values_in_string("VCUST_PURCHASE_PROMPT", insert)		 
  1411. 		Store_common_popup:set_text(body)				 
  1412. 		Store_common_popup:nav_enable(true, "store_vehicle_purchase_color_final", "store_vehicle_popup_nav") 
  1413. 		Not_popup_grp:set_alpha(.5) 
  1414. 		Active_list:set_visible(false) 
  1415. 		return 
  1416. 	else 
  1417. 		 
  1418. 		Store_common_color_grid:draw_items(Color_grid_data, 1, 9, 1, 53.5, 53.5, 15, nil, 1.1, true, true, -7, true) 
  1419. 	 
  1420. 		-- set the titles on top 
  1421. 		Store_header:push_title(nil, "VCUST_COLOR_PALETTE_TITLE")		 
  1422.  
  1423. 		store_vehicle_palette_grid_nav() 
  1424.  
  1425. 		-- Initialize grid navigation for mouse 
  1426. 		Old_vehicle_grid_index = -1 
  1427. 	 
  1428. 		Store_common_color_grid:nav_enable(true, "store_vehicle_palette_selected", "store_vehicle_palette_grid_nav")	 
  1429.  
  1430. 		Current_tier = PALETTE_TIER 
  1431. 	end 
  1432. end 
  1433.  
  1434.  
  1435. function store_vehicle_add_palette(display_name, current, base_r, base_g, base_b, spec_col_r, spec_col_g, spec_col_b, spec_alpha, fres_col_r, fres_col_g, fres_col_b, fres_con, refl, is_glass, palette_type, palette_id) 
  1436. 	 
  1437. 	local index = #Color_grid_data + 1	 
  1438. 	 
  1439. 	local item = { 
  1440. 		label = display_name, 
  1441. 		icon = "ui_menu_veh_pnt_base", 
  1442. 		color = { red = base_r, green = base_g, blue = base_b },		 
  1443. 		base_r = base_r, base_g = base_g, base_b = base_b, 								-- Base paint color, used on base 
  1444. 		spec_col_r = spec_col_r, spec_col_g = spec_col_g, spec_col_b = spec_col_b,	-- Specular color, used on spec and irr 
  1445. 		spec_alpha = spec_alpha, 																	-- Specular alpha, used on spec 
  1446. 		fres_col_r = fres_col_r, fres_col_g = fres_col_g, fres_col_b = fres_col_b, -- Fresnel color, used on fres, refl, sky 
  1447. 		fres_con = fres_con, 																		-- Fresnel 'alpha' (contrast), used on fres 
  1448. 		refl = refl, 																					-- Reflection color 
  1449. 		is_glass = is_glass, 
  1450. 		is_layered = true,																			-- Do we use the layered button for paint finishes? 
  1451. 		palette_type = palette_type, 
  1452. 		id = palette_id, 
  1453. 		type = TYPE_BUTTON,																			-- this function is only used for palettes that are rendered in a menu instead of a grid (rim, trim) 
  1454. 		on_nav = store_vehicle_trim_palette_menu_nav,										-- this function is only used for palettes that are rendered in a menu instead of a grid (rim, trim) 
  1455. 		on_select = store_vehicle_trim_palette_selected,									-- this function is only used for palettes that are rendered in a menu instead of a grid (rim, trim) 
  1456. 		on_cancel = store_vehicle_trim_palette_reverted,									-- this function is only used for palettes that are rendered in a menu instead of a grid (rim, trim) 
  1457. 	} 
  1458. 	 
  1459. 	Color_grid_data[index] = item	 
  1460. end 
  1461.  
  1462. function store_vehicle_color_selected(event) 
  1463. 	Store_common_color_grid:nav_enable(false, nil, nil)	 
  1464.  
  1465. 	-- Did the player make a selection? 
  1466. 	if event == "select" or event == "mouse_click" then 
  1467. 		game_UI_audio_play("UI_Main_Menu_Select") 
  1468. 		local idx = Store_common_color_grid:return_selected_index() 
  1469. 		if idx <= #Color_grid_data then 
  1470. 			Store_vehicle_color_selection = idx 
  1471. 			store_vehicle_populate_palette_grid() 
  1472. 			return 
  1473. 		end 
  1474. 	end 
  1475. 	 
  1476. 	game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  1477. 	 
  1478. 	-- restore original color 
  1479. 	vcust_revert_color() 
  1480. 	 
  1481. 	-- remove title 
  1482. 	Store_header:pop_title()		 
  1483. 	 
  1484. 	game_peg_unload(VEHICLE_CUST_GLASS_PEG)	 
  1485. 	 
  1486. 	Store_common_color_grid:set_visible(false) 
  1487. 	store_vehicle_clear_header() 
  1488. 	Active_list:set_visible(true) 
  1489. 	 
  1490. 	-- Enable the mouse for active_list and hint_bar 
  1491. 	store_vehicle_enable_mouse(true) 
  1492. 	Current_tier = MENU_TIER 
  1493. end 
  1494.  
  1495. -- This is the draw items call for the body paint 
  1496. function store_vehicle_color_grid_draw() 
  1497. 	 
  1498. 	local grid_rows = ceil(#Color_grid_data / 9) 
  1499. 		 
  1500. 	Store_common_color_grid:draw_items(Color_grid_data, Color_grid_data.current, 9, grid_rows, 53.5, 53.5, 15, nil, 1.1, true, true, -7, true) 
  1501. 	 
  1502. 	Store_header:enable_price_respect(not Store_vehicle_multiple_palettes) 
  1503. 	local index = Store_common_color_grid:return_selected_index()	 
  1504. 	Store_vehicle_color_price = Color_grid_data[index].price 
  1505. 	Store_vehicle_color_respect = Color_grid_data[index].style		 
  1506. 	Store_header:set_price(Store_vehicle_color_price) 
  1507. 	Store_header:set_respect(Store_vehicle_color_respect)		 
  1508. 	 
  1509. 	-- Initialize grid navigation for mouse 
  1510. 	Old_vehicle_grid_index = -1 
  1511. 	 
  1512. 	Store_common_color_grid:nav_enable(true, "store_vehicle_color_selected", "store_vehicle_color_grid_nav") 
  1513. 	-- do an initial nav to initialize header, etc. (pass in dummy movement value for navigation) 
  1514. 	store_vehicle_color_grid_nav("do_not_move") 
  1515. 	Store_common_color_grid:set_visible(true)	 
  1516. 	Active_list:set_visible(false) 
  1517. 	 
  1518. 	-- set the titles on top 
  1519. 	Store_header:push_title(nil, "VCUST_COLOR_GRID_TITLE")	 
  1520. 	 
  1521. 	-- Disable the mouse for the active list 
  1522. 	if Mouse_input_tracker ~= 0 then 
  1523. 		Mouse_input_tracker:subscribe(false) 
  1524. 	end 
  1525. 	Current_tier = COLOR_TIER 
  1526. end 
  1527.  
  1528. -- This function puts in a dataresponder request to get 1 palette of colors, which in turn will call a callback that requests all 
  1529. -- the colors in that palette.  We then use this list of colors to populate our grid.  The grid is initialized empty in this function. 
  1530. -- This function also triggers loading of the glass swatch peg. 
  1531. -- 
  1532. -- menu_data: standard table for the menu selection passed to all menu callbacks. 
  1533. -- save_original: optional boolean which is false if we are repopulating the color grid, but we do not want the C code to save 
  1534. -- our original color slot color as the "original" used for restoring if purchasing is cancelled. 
  1535. -- 
  1536. function store_vehicle_populate_color_grid(menu_data, save_original, show_layered, restore_current) 
  1537.  
  1538. 	Store_vehicle_color_slot = menu_data.id 
  1539.  
  1540. 	-- New menu, clear out all items 
  1541. 	Color_grid_data = {} 
  1542. 	Color_grid_data.show_layered = show_layered or false 
  1543. 	 
  1544. 	Store_vehicle_multiple_palettes = false 
  1545. 	 
  1546. 	if save_original == nil then 
  1547. 		save_original = true 
  1548. 	end 
  1549. 	 
  1550. 	vint_dataresponder_request("vcust_populate_palette_menu", "store_vehicle_get_palette_colors", 0, Store_vehicle_color_slot, save_original) 
  1551. 	 
  1552. 	if restore_current == true then 
  1553. 		Color_grid_data.current = Store_vehicle_color_selection 
  1554. 	end 
  1555. 	 
  1556. 	game_peg_load_with_cb("store_vehicle_color_grid_draw", 1, VEHICLE_CUST_GLASS_PEG) 
  1557. 	 
  1558. 	if Hint_bar_mouse_input_tracker ~= nil and Hint_bar_mouse_input_tracker ~= 0 then 
  1559. 		Hint_bar_mouse_input_tracker:subscribe(true) 
  1560. 	end 
  1561. end 
  1562.  
  1563. function store_vehicle_get_palette_colors(display_name, current, base_r, base_g, base_b, spec_col_r, spec_col_g, spec_col_b, spec_alpha, fres_col_r, fres_col_g, fres_col_b, fres_con, refl, is_glass) 
  1564. 	 
  1565. 	-- We're just collecting colors right now.  We only add colors for the first palette, but we still want to know if there's more than one palette, because if there's only one we skip the palette grid. 
  1566. 	if #Color_grid_data == 0 then 
  1567. 		vint_dataresponder_request("vcust_populate_color_grid", "store_vehicle_add_color", 0, Store_vehicle_color_slot) 
  1568. 	else 
  1569. 		Store_vehicle_multiple_palettes = true	 
  1570. 	end 
  1571. end 
  1572. 	 
  1573. function store_vehicle_add_color(display_name, current, base_r, base_g, base_b, spec_col_r, spec_col_g, spec_col_b, spec_alpha, fres_col_r, fres_col_g, fres_col_b, fres_con, refl, price, is_glass, respect, ui_col_r, ui_col_g, ui_col_b, refl_alpha) 
  1574. 	local index = #Color_grid_data + 1 
  1575.  
  1576. 	local item = { 
  1577. 		label = display_name, 
  1578. 		icon = "ui_menu_veh_pnt_base", 
  1579. 		color = { red = base_r, green = base_g, blue = base_b }, 
  1580. 		base_r = base_r, base_g = base_g, base_b = base_b, 								-- Base paint color, used on base 
  1581. 		spec_col_r = spec_col_r, spec_col_g = spec_col_g, spec_col_b = spec_col_b,	-- Specular color, used on spec and irr 
  1582. 		spec_alpha = spec_alpha, 																	-- Specular alpha, used on spec 
  1583. 		fres_col_r = fres_col_r, fres_col_g = fres_col_g, fres_col_b = fres_col_b, -- Fresnel color, used on fres, refl, sky 
  1584. 		fres_con = fres_con, 																		-- Fresnel 'alpha' (contrast), used on fres 
  1585. 		refl = refl, 																					-- Reflection color 
  1586. 		price = price, 
  1587. 		owned = current, 
  1588. 		is_glass = is_glass,																			-- Glass or Interior or normal 
  1589. 		is_layered = false, 
  1590. 		style = respect, 
  1591. 		refl_alpha = refl_alpha, 
  1592. 	} 
  1593. 	 
  1594. 	if is_glass == true then 
  1595. 		--item.icon = "ui_menu_veh_glass" 
  1596. 		if ui_col_r ~= nil then 
  1597. 			item.color = { red = ui_col_r, green = ui_col_g, blue = ui_col_b } 
  1598. 		end		 
  1599. 	end	 
  1600. 	 
  1601. 	if current == true then 
  1602. 		Color_grid_data.current = index 
  1603. 	end 
  1604.  
  1605. 	Color_grid_data[index] = item 
  1606.  
  1607. end 
  1608.  
  1609. function store_vehicle_populate_trim_palette_menu(menu_data) 
  1610.  
  1611. 	Store_vehicle_color_slot = menu_data.id 
  1612.  
  1613. 	-- New menu, clear out all items 
  1614. 	Color_grid_data = {} 
  1615.  
  1616. 	-- Populate all our possible finishes 
  1617. 	vint_dataresponder_request("vcust_populate_palette_menu", "store_vehicle_add_palette", 0, Store_vehicle_color_slot, true)	 
  1618. 		 
  1619. 	store_common_push_menu(Color_grid_data) 
  1620. 	 
  1621. 	-- Store_common_color_grid:draw_items(Color_grid_data, Color_grid_data.current, 9, 1, 53.5, 53.5, 15, nil, 1.1, true, true, -7, true) 
  1622. 	 
  1623. 	-- Store_common_color_grid:nav_enable(true, "store_vehicle_trim_palette_selected", "store_vehicle_trim_palette_menu_nav") 
  1624. 	-- -- do an initial nav to initialize header, etc. (pass in dummy movement value for navigation) 
  1625. 	-- --store_vehicle_color_grid_nav("do_not_move") 
  1626. 	-- Store_common_color_grid:set_visible(true)	 
  1627. 	-- Active_list:set_visible(false) 
  1628. 	 
  1629. 	-- set the titles on top 
  1630. 	--Store_header:push_title(nil, "VCUST_COLOR_PALETTE_TITLE")	 
  1631. 	 
  1632. 	-- -- Disable the mouse for the active list 
  1633. 	-- if Mouse_input_tracker ~= 0 then 
  1634. 		-- Mouse_input_tracker:subscribe(false) 
  1635. 	-- end 
  1636. 	-- Current_tier = PALETTE_TIER	 
  1637. end 
  1638.  
  1639. function store_vehicle_trim_palette_menu_nav(menu_data) 
  1640. 	vcust_preview_palette(0, menu_data.id, 0) 
  1641. end 
  1642.  
  1643. -- function store_vehicle_trim_palette_menu_nav(event, value) 
  1644.  
  1645. 	-- store_vehicle_grid_nav(event, false, value) 
  1646. 	 
  1647. 	-- -- slot is hardcoded to 0 
  1648. 	-- -- color is hardcoded to 0 
  1649. 	-- local item = Store_common_color_grid:return_selected_data() 
  1650. 	-- vcust_preview_palette(0, item.id, 0) 
  1651. -- end 
  1652.  
  1653.  
  1654. function store_vehicle_trim_palette_reverted(menu_data) 
  1655. 	-- revert color choice 
  1656. 	vcust_revert_color() 
  1657. end 
  1658.  
  1659. function store_vehicle_trim_palette_selected(menu_data) 
  1660.  
  1661. 	Store_common_color_grid:set_visible(true)	 
  1662. 	Active_list:set_visible(false) 
  1663. 	 
  1664. 	-- Disable the mouse for the active list 
  1665. 	if Mouse_input_tracker ~= 0 then 
  1666. 		Mouse_input_tracker:subscribe(false) 
  1667. 	end 
  1668.  
  1669. 	Store_vehicle_color_selection = Active_list:get_selection() - 1 
  1670. 	store_vehicle_populate_trim_color_grid() 
  1671. end 
  1672.  
  1673. -- function store_vehicle_trim_palette_selected(event) 
  1674.  
  1675. 	-- Store_common_color_grid:nav_enable(false, nil, nil)	 
  1676.  
  1677. 	-- -- Did the player make a selection? 
  1678. 	-- if event == "select" or event == "mouse_click" then 
  1679. 		-- local idx = Store_common_color_grid:return_selected_index() 
  1680. 		-- if idx <= #Color_grid_data then 
  1681. 			-- Store_vehicle_color_selection = idx - 1 
  1682. 			-- store_vehicle_populate_trim_color_grid() 
  1683. 			-- return 
  1684. 		-- end 
  1685. 	-- end 
  1686. 	 
  1687. 	-- -- restore original color 
  1688. 	-- vcust_revert_color() 
  1689. 	 
  1690. 	-- -- remove title 
  1691. 	-- Store_header:pop_title() 
  1692. 	 
  1693. 	-- Store_common_color_grid:set_visible(false) 
  1694. 	-- store_vehicle_clear_header() 
  1695. 	-- Active_list:set_visible(true) 
  1696. 	 
  1697. 	-- -- Enable the mouse for active_list and hint_bar 
  1698. 	-- store_vehicle_enable_mouse(true) 
  1699. 	-- Current_tier = MENU_TIER	 
  1700. -- end 
  1701.  
  1702. function store_vehicle_populate_trim_color_grid() 
  1703. 	-- New menu, clear out all items 
  1704. 	Color_grid_data = {} 
  1705.  
  1706. 	-- Populate all our possible colors 
  1707. 	vint_dataresponder_request("vcust_populate_color_grid", "store_vehicle_add_color", 0, Store_vehicle_color_slot, Store_vehicle_color_selection)	 
  1708. 	 
  1709. 	local grid_rows = ceil(#Color_grid_data / 9) 
  1710. 	 
  1711. 	Store_common_color_grid:draw_items(Color_grid_data, Color_grid_data.current, 9, grid_rows, 53.5, 53.5, 15, nil, 1.1, true, true, -7, true) 
  1712. 		 
  1713. 	-- set the titles on top 
  1714. 	Store_header:push_title(nil, "VCUST_COLOR_GRID_TITLE")		 
  1715.  
  1716. 	-- Initialize grid navigation for mouse 
  1717. 	Old_vehicle_grid_index = -1 
  1718. 	 
  1719. 	Store_common_color_grid:nav_enable(true, "store_vehicle_trim_color_selected", "store_vehicle_trim_color_grid_nav")	 
  1720.  
  1721. 	Current_tier = COLOR_TIER 
  1722. 	 
  1723. 	Store_header:enable_price_respect(true)	 
  1724. 	local index = Store_common_color_grid:return_selected_index()	 
  1725. 	Store_vehicle_color_price = Color_grid_data[index].price 
  1726. 	Store_vehicle_color_respect = Color_grid_data[index].style		 
  1727. 	Store_header:set_price(Store_vehicle_color_price) 
  1728. 	Store_header:set_respect(Store_vehicle_color_respect)		 
  1729. 	Store_header:enable_price_respect(true) 
  1730. end 
  1731.  
  1732. function store_vehicle_trim_color_grid_nav(event, value) 
  1733.  
  1734. 	store_vehicle_grid_nav(event, false, value) 
  1735. 	 
  1736. 	-- subtract 1 because grid indexing starts at 1 
  1737. 	local index = Store_common_color_grid:return_selected_index() 
  1738. 	vcust_preview_color(index - 1) 
  1739. 	 
  1740. 	Store_vehicle_color_price = Color_grid_data[index].price 
  1741. 	Store_vehicle_color_respect = Color_grid_data[index].style		 
  1742. 	Store_header:set_price(Store_vehicle_color_price) 
  1743. 	Store_header:set_respect(Store_vehicle_color_respect) 
  1744. 	Store_header:enable_price_respect(true) 
  1745. end 
  1746.  
  1747. function store_vehicle_trim_color_selected(event) 
  1748. 	-- Did the player make a selection? 
  1749. 	if event == "select" or event == "mouse_click" then 
  1750. 		local idx = Store_common_color_grid:return_selected_index() 
  1751. 		if idx <= #Color_grid_data then 
  1752. 		end 
  1753. 				 
  1754. 		-- Now we need to check for purchasing 
  1755. 		-- Disable mouse input for active_list and hint_bar 
  1756. 		store_vehicle_enable_mouse(false) 
  1757. 		Store_common_color_grid:nav_enable(false, nil, nil) 
  1758. 			 
  1759. 		-- Are we short on cash? 
  1760. 		if Store_vehicle_color_price > Store_common_player_cash then 
  1761. 			Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  1762. 			Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  1763. 			Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")		 
  1764. 			Store_common_popup:nav_enable(true, "store_vehicle_fail_msg", "store_vehicle_popup_nav") 
  1765. 			Not_popup_grp:set_alpha(.5)		 
  1766. 			Active_list:set_visible(false) 
  1767. 			return 
  1768. 		end 
  1769. 		 
  1770. 		-- Make sure they want to buy this 
  1771. 		Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  1772. 		Store_common_popup:set_title("STORE_TITLE_PURCHASING") 
  1773. 		local insert = { [0] = Color_grid_data[idx].label, [1] = format_cash(Store_vehicle_color_price) } 
  1774. 		local body = vint_insert_values_in_string("VCUST_PURCHASE_PROMPT", insert)		 
  1775. 		Store_common_popup:set_text(body)				 
  1776. 		Store_common_popup:nav_enable(true, "store_vehicle_purchase_color_final", "store_vehicle_popup_nav") 
  1777. 		Not_popup_grp:set_alpha(.5) 
  1778. 		Active_list:set_visible(false) 
  1779. 		return 
  1780. 	end		 
  1781. 	 
  1782. 	Current_tier = MENU_TIER 
  1783.  
  1784. 	-- going back to menu 
  1785. 	Store_common_color_grid:nav_enable(false, nil, nil) 
  1786. 	Active_list:set_visible(true) 
  1787. 	store_vehicle_populate_list(Menu_data, Active_list:get_selection()) 
  1788. 	 
  1789. 	Store_header:enable_price_respect(false)		 
  1790. 			 
  1791. 	-- revert color choice 
  1792. 	vcust_revert_color() 
  1793. 	 
  1794. 	-- remove titles 
  1795. 	Store_header:pop_title()	 
  1796. 	--Store_header:pop_title() 
  1797. 	Store_common_color_grid:set_visible(false)		 
  1798. end 
  1799.  
  1800. function store_vehicle_populate_underglow_grid() 
  1801. 	Store_vehicle_color_slot = STORE_VEHICLE_UNDERGLOW_COLOR 
  1802.  
  1803. 	-- New menu, clear out all items 
  1804. 	Color_grid_data = {} 
  1805. 	Color_grid_data.show_layered = false 
  1806. 	 
  1807. 	vint_dataresponder_request("vcust_populate_underglow_color", "store_vehicle_underglow_color_add", 0) 
  1808. 	 
  1809. 	if Hint_bar_mouse_input_tracker ~= nil and Hint_bar_mouse_input_tracker ~= 0 then 
  1810. 		Hint_bar_mouse_input_tracker:subscribe(true) 
  1811. 	end 
  1812. 		 
  1813. 	Store_common_color_grid:draw_items(Color_grid_data, Color_grid_data.current, 9, 7, 53.5, 53.5, 15, nil, 1.1, true, true, -7, true) 
  1814. 	 
  1815. 	Store_header:enable_price_respect(true) 
  1816. 	local index = Store_common_color_grid:return_selected_index() 
  1817. 	Store_vehicle_color_price = Color_grid_data[1].price 
  1818. 	Store_vehicle_color_respect = Color_grid_data[1].respect 
  1819. 	Store_header:set_price(Store_vehicle_color_price) 
  1820. 	Store_header:set_respect(Store_vehicle_color_respect)	 
  1821. 	 
  1822. 	-- Initialize grid navigation for mouse 
  1823. 	Old_vehicle_grid_index = -1 
  1824. 	 
  1825. 	Store_common_color_grid:nav_enable(true, "store_vehicle_underglow_color_selected", "store_vehicle_underglow_color_grid_nav") 
  1826. 	-- do an initial nav to initialize header, etc. (pass in dummy movement value for navigation) 
  1827. 	store_vehicle_underglow_color_grid_nav("do_not_move") 
  1828. 	Store_common_color_grid:set_visible(true)	 
  1829. 	Active_list:set_visible(false) 
  1830. 	 
  1831. 	-- set the titles on top 
  1832. 	Store_header:push_title(nil, "VCUST_COLOR_GRID_TITLE") 
  1833. 	 
  1834. 	-- Disable the mouse for the active list 
  1835. 	if Mouse_input_tracker ~= 0 then 
  1836. 		Mouse_input_tracker:subscribe(false) 
  1837. 	end 
  1838. 	Current_tier = COLOR_TIER	 
  1839. end 
  1840.  
  1841. function store_vehicle_underglow_color_add(display_name, current, price, respect, base_r, base_g, base_b) 
  1842. 	local index = #Color_grid_data + 1 
  1843.  
  1844. 	local item = { 
  1845. 		label = display_name, 
  1846. 		icon = "ui_menu_veh_pnt_base", 
  1847. 		color = { red = base_r, green = base_g, blue = base_b }, 
  1848. 		base_r = base_r, base_g = base_g, base_b = base_b, 								-- Base paint color, used on base 
  1849. 		price = price, 
  1850. 		owned = current, 
  1851. 		is_glass = false,																				-- Glass or Interior or normal 
  1852. 		is_layered = false, 
  1853. 		respect = respect, 
  1854. 	} 
  1855. 	 
  1856. 	if current == true then 
  1857. 		Color_grid_data.current = index 
  1858. 	end 
  1859.  
  1860. 	Color_grid_data[index] = item 
  1861. end 
  1862.  
  1863. function store_vehicle_underglow_color_grid_nav(event, value) 
  1864. 	store_vehicle_grid_nav(event, false, value) 
  1865. end 
  1866.  
  1867. function store_vehicle_underglow_color_selected(event) 
  1868. 	Store_common_color_grid:nav_enable(false, nil, nil)	 
  1869.  
  1870. 	-- Did the player make a selection? 
  1871. 	if event == "select" or event == "mouse_click" then 
  1872. 		game_UI_audio_play("UI_Main_Menu_Select") 
  1873. 		local idx = Store_common_color_grid:return_selected_index() 
  1874. 		if idx <= #Color_grid_data then 
  1875. 			Store_vehicle_color_selection = idx 
  1876. 			Store_vehicle_color_price = Color_grid_data[idx].price 
  1877.  
  1878. 			--Store_common_color_grid:nav_enable(false, nil, nil)	-- disable input going to grid control			 
  1879. 			store_vehicle_enable_mouse(false) 
  1880. 			 
  1881. 			-- Now we need to check for purchasing 
  1882. 			 
  1883. 			-- Are we short on cash? 
  1884. 			if Store_vehicle_color_price > Store_common_player_cash then 
  1885. 				Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  1886. 				Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  1887. 				Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")		 
  1888. 				Store_common_popup:nav_enable(true, "store_vehicle_underglow_fail_msg", "store_vehicle_popup_nav") 
  1889. 				Not_popup_grp:set_alpha(.5) 
  1890.  
  1891. 				-- Re-enable the grid inside store_vehicle_fail_msg, not here (screws up mouse inputs if it's done here) 
  1892. 				return 
  1893. 			end 
  1894. 			 
  1895. 			-- Make sure they want to buy this 
  1896. 			Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  1897. 			Store_common_popup:set_title("STORE_TITLE_PURCHASING") 
  1898. 			local insert = { [0] = Color_grid_data[idx].label, [1] = format_cash(Store_vehicle_color_price) } 
  1899. 			local body = vint_insert_values_in_string("VCUST_PURCHASE_PROMPT", insert)		 
  1900. 			Store_common_popup:set_text(body)				 
  1901. 			Store_common_popup:nav_enable(true, "store_vehicle_underglow_purchase_color_final", "store_vehicle_popup_nav") 
  1902. 			Not_popup_grp:set_alpha(.5) 
  1903. 			return 
  1904. 		end 
  1905. 	end 
  1906. 	 
  1907. 	game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  1908. 	 
  1909. 	-- remove title 
  1910. 	Store_header:pop_title()			 
  1911. 	 
  1912. 	Store_common_color_grid:set_visible(false) 
  1913. 	store_vehicle_clear_header() 
  1914. 	Active_list:set_visible(true) 
  1915. 	 
  1916. 	-- Enable the mouse for active_list and hint_bar 
  1917. 	store_vehicle_enable_mouse(true) 
  1918. 	Current_tier = MENU_TIER 
  1919. end 
  1920.  
  1921. function store_vehicle_underglow_fail_msg(event) 
  1922. 	Store_common_popup:nav_enable(false, nil, nil) 
  1923. 	Not_popup_grp:set_alpha(1) 
  1924. 	game_UI_audio_play("UI_Main_Menu_Select")	 
  1925. 	 
  1926. 	-- Re-enable the mouse for active_list and hint_bar 
  1927. 	if Current_tier ~= PALETTE_TIER and Current_tier ~= COLOR_TIER then 
  1928. 		store_vehicle_enable_mouse(true) 
  1929. 	else 
  1930. 		-- Re-enable the mouse 
  1931. 		Store_common_color_grid:nav_enable(true, "store_vehicle_underglow_color_selected", "store_vehicle_underglow_color_grid_nav") 
  1932. 		if Hint_bar_mouse_input_tracker ~= nil then 
  1933. 			Hint_bar_mouse_input_tracker:subscribe(true) 
  1934. 		end 
  1935. 		 
  1936. 	end 
  1937. end 
  1938.  
  1939. function store_vehicle_underglow_purchase_color_final(event) 
  1940.  
  1941. 	Store_common_popup:nav_enable(false, nil, nil) 
  1942. 	Not_popup_grp:set_alpha(1) 
  1943.  
  1944. 	-- The user hit the B button and are cancelling the purchase 
  1945. 	-- This is redundant to selecting "No" in the list 
  1946. 	if event == "back" then 
  1947. 		vcust_revert_color() 
  1948. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  1949.  
  1950. 		-- Re-enable the mouse 
  1951. 		Store_common_color_grid:nav_enable(true, "store_vehicle_underglow_color_selected", "store_vehicle_underglow_color_grid_nav") 
  1952. 		if Hint_bar_mouse_input_tracker ~= nil then 
  1953. 			Hint_bar_mouse_input_tracker:subscribe(true) 
  1954. 		end 
  1955. 		return 
  1956. 	end 
  1957. 	 
  1958. 	game_UI_audio_play("UI_Main_Menu_Select")	 
  1959. 	 
  1960. 	-- Did we select yes?  This assumes yes is the first item 
  1961. 	if Store_common_popup:get_selected_data() ~= 1 then 
  1962. 		vcust_revert_color() 
  1963. 		 
  1964. 		-- Re-enable the mouse 
  1965. 		Store_common_color_grid:nav_enable(true, "store_vehicle_underglow_color_selected", "store_vehicle_underglow_color_grid_nav") 
  1966. 		if Hint_bar_mouse_input_tracker ~= nil then 
  1967. 			Hint_bar_mouse_input_tracker:subscribe(true) 
  1968. 		end	 
  1969. 		return 
  1970. 	end 
  1971.  
  1972. 	Current_tier = MENU_TIER 
  1973. 	-- Re-enable the mouse 
  1974. 	store_vehicle_enable_mouse(true) 
  1975.  
  1976. 	-- award respect and actually purchase the item 
  1977. 	game_award_respect(Store_vehicle_color_respect) 
  1978. 	 
  1979. 	-- subtract 1 because grid indexing starts at 1 
  1980. 	local index = Store_common_color_grid:return_selected_index()	 
  1981. 	vcust_set_underglow(index - 1, Store_vehicle_color_price) 
  1982. 	 
  1983. 	ui_audio_post_event("vehicle_purchase") 
  1984. 	 
  1985. 	-- reset titles 
  1986. 	while #Store_header.title_stack > 1 do 
  1987. 		Store_header:pop_title() 
  1988. 	end 
  1989. 	 
  1990. 	Store_common_color_grid:nav_enable(false, nil, nil) 
  1991. 	Store_common_color_grid:set_visible(false) 
  1992. 	 
  1993. 	store_vehicle_clear_header() 
  1994. 	Active_list:set_visible(true)		 
  1995. 	 
  1996. 	-- do this so holding down the button doesn't cause repeated actions 
  1997. 	store_lock_controls() 
  1998. 	store_unlock_controls() 
  1999. end 
  2000.  
  2001. -- Performance upgrades 
  2002. -------------------------------------- 
  2003.  
  2004. function store_vehicle_purchase_upgrade(menu_data) 
  2005. 	-- Disable the mouse for active_list and hint_bar 
  2006. 	store_vehicle_enable_mouse(false) 
  2007. 	 
  2008. 	-- Are we short on cash? 
  2009. 	if menu_data.price > Store_common_player_cash then 
  2010. 		Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  2011. 		Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  2012. 		Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")		 
  2013. 		Store_common_popup:nav_enable(true, "store_vehicle_fail_msg", "store_vehicle_popup_nav") 
  2014. 		Not_popup_grp:set_alpha(.5)	 
  2015. 		Active_list:set_visible(false)		 
  2016. 		return 
  2017. 	end 
  2018. 	 
  2019. 	-- Make sure they want to buy this 
  2020. 	Store_vehicle_purchase_item = menu_data 
  2021. 	Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  2022. 	Store_common_popup:set_title("STORE_TITLE_PURCHASING") 
  2023. 	Store_common_popup:set_text("STORE_TEXT_CONFIRM_PURCHASE_BLANK")				 
  2024. 	Store_common_popup:nav_enable(true, "store_vehicle_purchase_upgrade_final", "store_vehicle_popup_nav") 
  2025. 	Not_popup_grp:set_alpha(.5) 
  2026. 	Active_list:set_visible(false) 
  2027. end 
  2028.  
  2029. -- LAS: This is already defined, commenting out, though it can likely be deleted 
  2030. --[[function store_vehicle_fail_msg(event) 
  2031. 	Store_common_popup:nav_enable(false, nil, nil) 
  2032. 	Not_popup_grp:set_alpha(1) 
  2033. 	 
  2034. 	game_UI_audio_play("UI_Main_Menu_Select") 
  2035. 	 
  2036. 	-- Re-enable the mouse 
  2037. 	store_vehicle_enable_mouse(true) 
  2038. end]] 
  2039.  
  2040. -- Finalize or cancel a purchase based on the result of the confirmation question. 
  2041. -- 
  2042. -- response: 	how did the user respond? 
  2043. -- action: 		indicates if the dialog box was closed or some other action. 
  2044. -- 
  2045. function store_vehicle_purchase_upgrade_final(event) 
  2046.  
  2047. 	Store_common_popup:nav_enable(false, nil, nil) 
  2048. 	Not_popup_grp:set_alpha(1) 
  2049. 	Active_list:set_visible(true) 
  2050. 	 
  2051. 	-- Re-enable the mouse 
  2052. 	store_vehicle_enable_mouse(true)	 
  2053.  
  2054. 	-- The user hit the B button and are cancelling the purchase 
  2055. 	-- This is redundant to selecting "No" in the list 
  2056. 	if event == "back" then 
  2057. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  2058. 		return 
  2059. 	end 
  2060. 	 
  2061. 	game_UI_audio_play("UI_Main_Menu_Select")	 
  2062. 	 
  2063. 	-- Did we select yes?  This assumes yes is the first item 
  2064. 	if Store_common_popup:get_selected_data() ~= 1 then 
  2065. 		return 
  2066. 	end 
  2067.  
  2068. 	-- award respect and actually purchase the item 
  2069. 	game_award_respect(Store_vehicle_purchase_item.style) 
  2070. 	vcust_purchase_performance_upgrade(Store_vehicle_purchase_item.id) 
  2071. 	ui_audio_post_event("vehicle_purchase") 
  2072. 	 
  2073. 	-- repopulate the menu 
  2074. 	Store_vehicle_building_menu = {} 
  2075. 	vint_dataresponder_request("vcust_populate_menu", "store_vehicle_populate_menu", 0, STORE_VEHICLE_POPULATE_CURRENT_MENU)	 
  2076. 	Menu_data = Store_vehicle_building_menu 
  2077. 	local index = Active_list:get_selection() 
  2078. 	store_vehicle_populate_list(Menu_data, index) 
  2079. 	store_vehicle_upgrade_nav(Menu_data[index]) 
  2080.  
  2081. 	-- do this so holding down the button doesn't cause repeated actions 
  2082. 	store_lock_controls() 
  2083. 	store_unlock_controls() 
  2084. 	--Input_tracker:subscribe(false)		 
  2085. 	--Input_tracker:subscribe(true)	 
  2086. end 
  2087.  
  2088. function store_vehicle_upgrade_enter(menu_data) 
  2089.  
  2090. 	debug_print("vint", "entered store_vehicle_upgrade_enter\n") 
  2091.  
  2092. 	local index = Active_list:get_selection() 
  2093. 	 
  2094. 	store_vehicle_upgrade_nav(menu_data[index]) 
  2095.  
  2096. 	-- repopulate the menu 
  2097. 	Store_vehicle_building_menu = {} 
  2098. 	vint_dataresponder_request("vcust_populate_menu", "store_vehicle_populate_menu", 0, STORE_VEHICLE_POPULATE_CURRENT_MENU)	 
  2099. 	Menu_data = Store_vehicle_building_menu 
  2100. 	local index = Active_list:get_selection() 
  2101. 	store_vehicle_populate_list(Menu_data, index) 
  2102. 	store_vehicle_upgrade_nav(Menu_data[index]) 
  2103. end 
  2104.  
  2105. function store_vehicle_upgrade_nav(menu_data) 
  2106.  
  2107. 	-- Update the store header price and respect values	 
  2108.  
  2109. 	if menu_data.price ~= nil and menu_data.price > 0 and menu_data.is_purchased == false then 
  2110. 		Store_header:enable_price_respect(true) 
  2111. 		Store_header:set_price(menu_data.price) 
  2112. 		Store_header:set_respect(menu_data.style)			 
  2113. 	else 
  2114. 		store_vehicle_clear_header()			 
  2115. 	end	 
  2116. 	 
  2117. 	store_vehicle_set_description(menu_data.desc) 
  2118. end 
  2119.  
  2120. function garage_preview(menu_data) 
  2121.  
  2122. 	-- clear out "new" status if it is true 
  2123. 	if menu_data.is_new then 
  2124. 		garage_clear_new(menu_data.id) 
  2125. 		 
  2126. 		--Remove our mouse inputs first... 
  2127. 		if Mouse_input_tracker ~= 0 then 
  2128. 			Mouse_input_tracker:remove_all() 
  2129. 		end 
  2130. 		 
  2131. 		--Get index from the list and then remove the flag... 
  2132. 		local index = Active_list:get_index_from_id(menu_data.id) 
  2133. 		Active_list:remove_new_flag(index) 
  2134. 		 
  2135. 		--Update cursor, 
  2136. 		Active_list:move_cursor(0) 
  2137. 		--Re add mouse inputs... 
  2138. 		if Mouse_input_tracker ~= 0 then 
  2139. 			Mouse_input_tracker:remove_all() 
  2140. 			Active_list:add_mouse_inputs("store_common", Mouse_input_tracker) 
  2141. 			Mouse_input_tracker:subscribe(true) 
  2142. 		end		 
  2143. 	end 
  2144.  
  2145. 	if #Menu_data == 1 then 
  2146. 		-- Can't go up or down if there's just one item. 
  2147. 		return 
  2148. 	end 
  2149.  
  2150. 	if Active_list:get_selection() ~= nil and Menu_data[Active_list:get_selection()] ~= nil then 
  2151. 		garage_preview_vehicle( Menu_data[Active_list:get_selection()].id ) 
  2152. 		--local rim_jobs_grp = vint_object_find("rim_jobs_grp", 0, Store_vehicle_doc_handle) 
  2153. 		--vint_set_property(rim_jobs_grp, "background", false) -- Changing cars, so hiding the transition 
  2154. 	end 
  2155. end 
  2156.  
  2157. -- This is called once the car is fully loaded in.  At this point, all component data is loaded. 
  2158. -- We'll update stats and also show the background as a background 
  2159. function garage_populate_performance_stats(di_h) 
  2160. 	local index, label, level, max_level = vint_dataitem_get(di_h) 
  2161.  
  2162. 	if index == 0 then 
  2163. 		-- 0 indicates that we are done 
  2164. 		--Vehicle_stats:set_visible(true) 
  2165. 		Vehicle_stats:draw_items(Vehicle_stats_data) 
  2166. 		Vehicle_stats_data = {} 
  2167. 		local rim_jobs_grp = vint_object_find("rim_jobs_grp", 0, Store_vehicle_doc_handle) 
  2168. 		vint_set_property(rim_jobs_grp, "background", true) 
  2169. 		bg_saints_set_background(true) 
  2170. 	else  
  2171. 		Vehicle_stats_data[index] = { 
  2172. 			label = label, 
  2173. 			max_level = max_level, 
  2174. 			level = level, 
  2175. 		} 
  2176. 	end 
  2177. 	 
  2178. end 
  2179.  
  2180. function garage_update_stat_visibility() 
  2181. 	if garage_get_garage_type == GVT_CARS then 
  2182. 		Vehicle_stats:set_visible(true) 
  2183. 	end 
  2184. end 
  2185.  
  2186. function garage_select(menu_data) 
  2187. 	store_vehicle_garage_vehicle_select() 
  2188. end 
  2189.  
  2190. function garage_populate_car_list(display_name, id, retrieval_cost, current, is_new, is_dlc) 
  2191. 	-- Add the item 
  2192. 	local item = { label = display_name, type = TYPE_BUTTON, id = id, price = retrieval_cost, is_new = is_new, is_dlc = is_dlc } 
  2193. 	local menu_idx = #Store_vehicle_building_menu + 1 
  2194. 	Store_vehicle_building_menu[menu_idx] = item 
  2195.  
  2196. 	item.on_nav = garage_preview 
  2197. 	item.on_select = garage_select 
  2198. 	 
  2199. 	-- is this the currently owned item? 
  2200. 	if current == true then 
  2201. 		Menu_data.start_index = menu_idx 
  2202. 		-- Do what we would when navigating to the currently highlighted item 
  2203. 		if item.on_nav ~= nil then 
  2204. 			item.on_nav(item) 
  2205. 		end 
  2206. 	end 
  2207. end 
  2208.  
  2209. -- populate the top level menu 
  2210. function garage_build_areas() 
  2211. 	Menu_data = {} 
  2212. 	Menu_data.on_enter = garage_nav_areas 
  2213. 	Store_vehicle_building_menu = Menu_data 
  2214. 	vint_dataresponder_request("garage_populate", "garage_populate_car_list", 0) 
  2215. 	if Menu_data.start_index == nil then 
  2216. 		Menu_data.start_index = 1 
  2217. 	end 
  2218. 	if #Menu_data == 0 then 
  2219. 		Empty_garage = true 
  2220. 	else 
  2221. 		garage_preview_vehicle(Menu_data[Menu_data.start_index].id) 
  2222. 		Empty_garage = false 
  2223. 	end 
  2224. 	 
  2225. 	-- TODO: May need to enable the mouse for active_list and hint_bar 
  2226. end 
  2227.  
  2228. -- Update the Current Menu selection 
  2229. function garage_nav_areas(menu_data) 
  2230. 	-- subtracting one because C code is 0-indexed 
  2231. 	--garage_change_top_level_menu(0, Active_list:get_selection() - 1) 
  2232. end 
  2233.  
  2234. -- Customization Top level menus 
  2235. -------------------------------------- 
  2236.  
  2237. function store_vehicle_populate_menu(display_name, cat_type, id, price, current, level, desc, respect, palette_first) 
  2238. 	-- Add the item 
  2239. 	local item = { label = display_name, type = TYPE_BUTTON, id = id } 
  2240.  
  2241. 	-- Fill in values specific to different menu types 
  2242. 	if cat_type == STORE_VEHICLE_TYPE_SLOT then 
  2243. 		item.on_nav = store_vehicle_nav_slot 
  2244. 		item.on_sub_menu_fill = store_vehicle_build_menu 
  2245. 	elseif cat_type == STORE_VEHICLE_TYPE_COMPONENT then 
  2246. 		item.on_sub_menu_fill = store_vehicle_build_menu 
  2247. 	elseif cat_type == STORE_VEHICLE_TYPE_COLOR_REGION then 
  2248. 		-- we handle underglow color in a completely different manner 
  2249. 		if item.id == STORE_VEHICLE_UNDERGLOW_COLOR then 
  2250. 			item.on_select = store_vehicle_populate_underglow_grid 
  2251. 		else 
  2252. 			item.on_sub_menu_fill = store_vehicle_select_region 
  2253. 		end 
  2254. 	elseif cat_type == STORE_VEHICLE_TYPE_COLOR_PALETTE then 
  2255. 		-- some color regions start with the palette/material grid, some start with the color grid 
  2256. 		Store_vehicle_select_palette_first = palette_first 
  2257. 		if palette_first then 
  2258. 			item.on_select = store_vehicle_populate_trim_palette_menu 
  2259. 		else 
  2260. 			item.on_select = store_vehicle_populate_color_grid 
  2261. 		end 
  2262. 	elseif cat_type == STORE_VEHICLE_TYPE_PERFORMANCE then 
  2263. 		item.on_nav = store_vehicle_upgrade_nav	 
  2264. 		item.max_level = 4 
  2265. 		item.desc = desc 
  2266. 		item.show_next_level = true 
  2267. 		-- do we already own the max level? 
  2268. 		if level == item.max_level then 
  2269. 			item.is_purchased = true 
  2270. 			item.level = level 
  2271. 			item.show_next_level = false 
  2272. 		else 
  2273. 			item.level = level 
  2274. 			item.price = price 
  2275. 			item.style = respect 
  2276. 			item.on_select = store_vehicle_purchase_upgrade 
  2277. 			item.is_purchased = false 
  2278. 		end 
  2279. 		Store_vehicle_building_menu.performance_menu = true 
  2280. 	elseif cat_type == STORE_VEHICLE_TYPE_PERFORMANCE_SLOT then 
  2281. 		item.on_nav = store_vehicle_upgrade_nav 
  2282. 		item.on_sub_menu_fill = store_vehicle_build_menu 
  2283. 		Store_vehicle_building_menu.on_enter = store_vehicle_upgrade_enter 
  2284. 		 
  2285. 		item.max_level = 1 
  2286. 		item.desc = desc 
  2287. 		item.show_next_level = false 
  2288. 		-- do we already own the max level? 
  2289. 		if level == item.max_level then 
  2290. 			item.level = level 
  2291. 			item.show_next_level = false 
  2292. 			item.is_purchased = true 
  2293. 		else  
  2294. 			item.level = level 
  2295. 			item.price = price 
  2296. 			item.style = respect 
  2297. 			item.is_purchased = false 
  2298. 		end		 
  2299. 	else 
  2300. 		debug_print("vint", "Vehicle Customization - Invalid Category type: " .. cat_type .. "\n") 
  2301. 	end 
  2302. 	 
  2303. 	local menu_idx = #Store_vehicle_building_menu + 1 
  2304. 	Store_vehicle_building_menu[menu_idx] = item 
  2305. 	 
  2306. 	-- is this the currently owned item? 
  2307. 	if current == true then 
  2308. 		Store_vehicle_building_menu.start_index = menu_idx				 
  2309. 	end	 
  2310. end 
  2311.  
  2312. -- populate the current sub menu 
  2313. function store_vehicle_build_current_menu(menu_data) 
  2314. 	Store_vehicle_building_menu = menu_data.sub_menu 
  2315. 	Store_vehicle_building_menu.start_index = 1 
  2316. 	vint_dataresponder_request("vcust_populate_menu", "store_vehicle_populate_menu", 0, STORE_VEHICLE_POPULATE_CURRENT_MENU) 
  2317. 	 
  2318. 	-- Do what we would when navigating to the currently highlighted item 
  2319. 	local i = Store_vehicle_building_menu[Store_vehicle_building_menu.start_index] 
  2320. 	if i.on_nav ~= nil then 
  2321. 		i.on_nav(i) 
  2322. 	end		 
  2323. end 
  2324.  
  2325. -- populate the top level menu 
  2326. function store_vehicle_build_areas() 
  2327. 	Menu_data = {} 
  2328. 	Menu_data.on_enter = store_vehicle_area_on_enter 
  2329. 	Store_vehicle_building_menu = Menu_data 
  2330. 	vint_dataresponder_request("vcust_populate_menu", "store_vehicle_add_area", 0, STORE_VEHICLE_POPULATE_AREAS) 
  2331. 	 
  2332. 	store_vehicle_clear_header() 
  2333. 	 
  2334. 	if #Menu_data ~= 0 then 
  2335. 		if  store_vehicle_allow_garage() then 
  2336. 			local item = { 
  2337. 				--label = "GARAGE_CRIB_NAME", type = TYPE_BUTTON, on_select = store_vehicle_switch_mode, disabled = true, 
  2338. 				label = "GARAGE_CRIB_NAME", type = TYPE_BUTTON, on_select = store_vehicle_switch_mode, 
  2339. 			}		 
  2340. 			Menu_data[#Menu_data + 1] = item 
  2341. 		end 
  2342. 		 
  2343. 		-- add exit store option 
  2344. 		local exit_item = { 
  2345. 			label = "MENU_RESUME_GAME", type = TYPE_BUTTON, on_select = store_vehicle_resume_game 
  2346. 		} 
  2347. 		Menu_data[#Menu_data + 1] = exit_item 
  2348. 		 
  2349. 		-- add return to crib option 
  2350. 		-- can't return to crib from customization, need to go back to garage first. 
  2351. 		--[[ 
  2352. 		if Store_vehicle_loaded_from_crib then 
  2353. 			local crib_exit_item = { 
  2354. 				label = "VCUST_RETURN_TO_CRIB", type = TYPE_BUTTON, on_select = store_vehicle_return_to_crib 
  2355. 			}		 
  2356. 			Menu_data[#Menu_data + 1] = crib_exit_item 
  2357. 		end 
  2358. 		]] 
  2359. 		 
  2360. 		store_vehicle_populate_list(Menu_data, 1) 
  2361. 	end 
  2362. end 
  2363.  
  2364. -- C code was just informed us that the swap to a customizable vehicle is complete.  If we couldn't populate the top level menu 
  2365. -- earlier, we do so now. 
  2366. -- 
  2367. function store_vehicle_signal_swap_complete() 
  2368. 	if #Menu_data == 0 then 
  2369. 		store_vehicle_build_areas() 
  2370. 	end 
  2371. end 
  2372.  
  2373. function store_vehicle_add_area(display_name, index, ignored, ignored2, is_wheel_menu) 
  2374. 	-- Add the item 
  2375. 	local item = { label = display_name, type = TYPE_BUTTON, id = index, on_nav = store_vehicle_nav_areas } 
  2376. 	 
  2377. 	if is_wheel_menu then 
  2378. 		item.sub_menu = Store_vehicle_axle_menu 
  2379. 	else 
  2380. 		item.on_sub_menu_fill = store_vehicle_build_current_menu 
  2381. 	end 
  2382. 	 
  2383. 	local menu_idx = #Store_vehicle_building_menu + 1 
  2384. 	Store_vehicle_building_menu[menu_idx] = item 
  2385. end 
  2386.  
  2387. function store_vehicle_area_on_enter(menu_data) 
  2388. 	-- reset camera back to standard view 
  2389. 	vcust_set_camera_pos("Standard")	 
  2390. 	 
  2391. 	store_vehicle_nav_areas(menu_data) 
  2392. end 
  2393.  
  2394. -- Update the Current Menu selection 
  2395. function store_vehicle_nav_areas(menu_data) 
  2396. 	-- subtracting one because C code is 0-indexed 
  2397. 	vcust_change_top_level_menu(0, Active_list:get_selection() - 1) 
  2398. 	 
  2399. 	-- When returning to the top level menu, we want to make sure to clear the header and performance descriptions. 
  2400. 	store_vehicle_clear_header() 
  2401. 	 
  2402. 	local hint_rotate_data = { 
  2403. 		{CTRL_BUTTON_RS, "STORE_ZOOM_ROTATE"}, 
  2404. 	} 
  2405. 	Store_common_rotate_hint:set_hints(hint_rotate_data) 
  2406. 	if Game_platform ~= "PC" then 
  2407. 		Store_common_rotate_hint:set_visible(true)		 
  2408. 	end 
  2409. end 
  2410.  
  2411. function store_vehicle_init() 
  2412.  
  2413. 	Store_common_current_highlight_color = COLOR_STORE_VEHICLE_PRIMARY 
  2414. 	 
  2415. 	store_lock_controls() 
  2416.  
  2417. 	Store_vehicle_loaded_from_crib = store_common_crib_is_loaded() 
  2418. 	 
  2419. 	-- If we're in the crib, we're only doing garage (not store). 
  2420. 	-- For initial load, check with C which mode we should be in. 
  2421. 	if store_vehicle_get_state() == MODE_VCUST and Store_vehicle_loaded_from_crib == false then 
  2422. 		Store_vehicle_is_garage = false 
  2423. 	else 
  2424. 		Store_vehicle_is_garage = true 
  2425. 	end 
  2426. 	 
  2427. 	Store_vehicle_begin_from_garage = Store_vehicle_is_garage 
  2428.  
  2429. 	-- unload the full screen map to pillage memory 
  2430. 	if Store_vehicle_loaded_from_crib == false then 
  2431. 		pause_map_dump() 
  2432. 	end 
  2433. 	 
  2434. 	Screen_cover_count = 0 
  2435.  
  2436. 	Store_vehicle_doc_handle = vint_document_find("store_vehicle") 
  2437.  
  2438. 	-- Set up some callbacks for the common store script 
  2439. 	Store_common_populate_list_cb = store_vehicle_populate_list 
  2440. 	Store_common_exit_cb				= store_vehicle_exit 
  2441. 	 
  2442. 	-- Declare stage objects 
  2443. 	Not_popup_grp = Vdo_base_object:new("not_popup_grp", 0, Store_common_doc_handle)	-- Everything that is not in the popup so we can fade it when the popup is active 
  2444. 	 
  2445. 	-- Setup purchase popup 
  2446. 	Store_common_popup:set_visible(false) 
  2447. 	Store_common_popup:set_size(STORE_COMMON_LIST_SIZE, (LIST_BUTTON_HEIGHT * 5) + (LIST_BUTTON_SPACE * 5))	 
  2448. 	--local popup_x,popup_y = Store_common_popup:get_anchor() 
  2449. 	--Store_common_popup:set_anchor(155,popup_y) 
  2450. 	 
  2451. 	-- MAYBE MOVE THIS TO store_vehicle_mode_set_init? 
  2452. 	-- Save the platform and set up the hint_bar mouse input 
  2453. 	Game_platform = game_get_platform() 
  2454. 	if Game_platform == "PC" then 
  2455. 		Hint_bar_mouse_input_tracker = Vdo_input_tracker:new() 
  2456. 	end 
  2457. 	 
  2458. 	--Setup Button Hints 
  2459. 	local hint_data = { 
  2460. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  2461. 		--{CTRL_BUTTON_X, "GARAGE_CRIB_NAME"}, 
  2462. 	} 
  2463. 	Store_common_hint_bar:set_hints(hint_data) 	 
  2464. 	Store_common_hint_bar:set_visible(true)			 
  2465. 	 
  2466. 	local hint_rotate_data = { 
  2467. 		{CTRL_BUTTON_RS, "STORE_ZOOM_ROTATE"}, 
  2468. 	} 
  2469. 	Store_common_rotate_hint:set_hints(hint_rotate_data) 	 
  2470. 	Store_common_rotate_hint:enable_text_shadow(true)	 
  2471. 	if Game_platform ~= "PC" then 
  2472. 		Store_common_rotate_hint:set_visible(true)		 
  2473. 	end 
  2474. 	 
  2475. 	Store_header:set_visible(true)	 
  2476. 		 
  2477. 	-- Setup Color grid 
  2478. 	Store_common_color_grid:set_visible(false) 
  2479. 	Store_common_color_grid:set_ui_screen("store_vehicle") 
  2480. 	local grid_x, grid_y = Store_common_color_grid:get_anchor() 
  2481. 	Store_common_color_grid:set_anchor(grid_x, STORE_COMMON_GRID_VEHICLE_Y) 
  2482. 	 
  2483. 	Rim_jobs_grp = Vdo_base_object:new("rim_jobs_grp", 0,Store_vehicle_doc_handle) 
  2484. 	Rim_jobs_grp:set_visible(false) 
  2485. 	 
  2486. 	local cell_mask = Vdo_base_object:new("cell_mask", 0, Store_common_doc_handle) 
  2487. 	cell_mask:set_visible(false) 
  2488. 	cell_mask:set_property("mask", false) 
  2489. 	 
  2490. 	local brand_logo = Vdo_base_object:new("brand_logo", 0, Store_vehicle_doc_handle) 
  2491. 	brand_logo:set_visible(false) 
  2492. 	 
  2493. 	if Store_vehicle_loaded_from_crib then 
  2494. 		bg_saints_set_type(BG_TYPE_DEFAULT, true, 1280, 0) 
  2495. 	elseif Store_vehicle_begin_from_garage then 
  2496. 		bg_saints_set_type(BG_TYPE_DEFAULT, false, 1280, 0) 
  2497. 		bg_saints_slide_in(1280, 0) 
  2498. 	else 
  2499. 		bg_saints_set_type(BG_TYPE_DEFAULT, true, 1280, 0) 
  2500. 	end 
  2501. 	 
  2502. 	if Store_vehicle_is_garage then 
  2503. 		local store_logo = Vdo_base_object:new("rj_logo", 0, Store_vehicle_doc_handle) 
  2504. 		store_logo:set_visible(false) 
  2505. 		bg_saints_show(true) 
  2506. 		vint_set_property(vint_object_find("vignette_grp_1",0,Store_vehicle_doc_handle),"visible",false) 
  2507. 		Store_header:reformat_and_resize(true) 
  2508. 		ui_audio_post_event("Enter_Garage") 
  2509. 	else 
  2510. 		bg_saints_show(false) 
  2511. 		if Store_vehicle_loaded_from_crib == false then 
  2512. 			ui_audio_post_event("enter_rim_jobs") 
  2513. 		end 
  2514. 	end 
  2515.  
  2516. 	store_vehicle_bg_is_loaded() 
  2517.  
  2518. 	Vehicle_stats = Vdo_item_stats:new("item_stats", 0, Store_vehicle_doc_handle) 
  2519. 	Vehicle_stats:set_visible(false) 
  2520. 	 
  2521. 	-- Make background so vehicle shows on top 
  2522. 	if Store_vehicle_loaded_from_crib == false then 
  2523. 		-- moved color switching to store_vehicle_mode_set_init() 
  2524. 	else 
  2525. 		 
  2526. 		-- crib specific stuff 
  2527. 		local store_main_grp = Vdo_base_object:new("store_main_grp", 0, Store_common_doc_handle) 
  2528. 		store_main_grp:set_anchor(0,0) 
  2529. 		 
  2530. 		Store_common_spinner:set_color(COLOR_SAINTS_PURPLE) 
  2531. 		 
  2532. 		-- animate in ui for vehicles (shared by all stores) 
  2533. 		local store_vehicle_in_anim = Vdo_anim_object:new("store_common_in_anim", 0, Store_common_doc_handle) 
  2534. 		local end_event_twn = Vdo_tween_object:new("end_event_twn", store_vehicle_in_anim.handle, Store_common_doc_handle) 
  2535. 		end_event_twn:set_end_event("store_unlock_controls") 
  2536. 		 
  2537. 		vint_apply_start_values(store_vehicle_in_anim.handle) 
  2538. 		store_vehicle_in_anim:play(0) 
  2539. 		 
  2540. 		-- make background so car is on top 
  2541. 		bg_saints_set_background(false) 
  2542. 	 
  2543. 		-- Hide vehicle store background since we use the saints background in crib 
  2544. 		local vehicle_bg_grp = Vdo_base_object:new("rj_bg", 0, Store_vehicle_doc_handle) 
  2545. 		vehicle_bg_grp:set_visible(false) 
  2546. 		vehicle_bg_grp = Vdo_base_object:new("dots_grp", 0, Store_vehicle_doc_handle) 
  2547. 		vehicle_bg_grp:set_visible(false)	 
  2548. 		vehicle_bg_grp = Vdo_base_object:new("vignette_grp_1", 0, Store_vehicle_doc_handle) 
  2549. 		vehicle_bg_grp:set_visible(false)			 
  2550. 	end 
  2551. 	 
  2552. 	-- This must come after we set highlight colors, or it will fail 
  2553. 	store_vehicle_mode_set_init()	 
  2554. 	 
  2555. 	-- subscribe to data items 
  2556. 	vint_datagroup_add_subscription("garage_performance_stats", "update", "garage_populate_performance_stats") 
  2557.  
  2558. 	character_enable_mouse_drag(true) 
  2559. end 
  2560.  
  2561. function store_vehicle_bg_is_loaded() 
  2562.  
  2563. 	if Store_vehicle_loaded_from_crib == false --[[and not Store_vehicle_is_garage]] then 
  2564. 		local rim_jobs_bg_anim = Vdo_anim_object:new("rim_jobs_bg_anim", 0, Store_vehicle_doc_handle)	 
  2565. 		local store_vehicle_in_anim = Vdo_anim_object:new("store_common_in_anim", 0, Store_common_doc_handle)	 
  2566. 		local rim_jobs_bg_twn = Vdo_tween_object:new("rim_jobs_bg_twn") 
  2567. 		local bg_end_event_twn = Vdo_tween_object:new("bg_end_event_twn", rim_jobs_bg_anim.handle) 
  2568. 		 
  2569. 		bg_end_event_twn:set_end_event("store_vehicle_screen_is_covered") 
  2570. 		rim_jobs_bg_twn:set_end_event("store_vehicle_loop_bg_anims")	 
  2571. 		 
  2572. 		vint_apply_start_values(rim_jobs_bg_anim.handle) 
  2573. 		vint_apply_start_values(store_vehicle_in_anim.handle) 
  2574.  
  2575. 		rim_jobs_bg_anim:play(0)	 
  2576. 		store_vehicle_in_anim:play(0) 
  2577.  
  2578. 		if Store_vehicle_is_garage == false then 
  2579. 			Rim_jobs_grp:set_visible(true) 
  2580. 		end 
  2581. 	end 
  2582. 	 
  2583. end 
  2584.  
  2585. function store_vehicle_screen_is_covered() 
  2586. 	Screen_cover_count = Screen_cover_count + 1 
  2587. 	 
  2588. 	if Screen_cover_count == 1 then 
  2589. 		store_unlock_controls() 
  2590. 	end 
  2591. 	if vcust_is_camera_tool_mode() == false then 
  2592. 		-- notify C code to begin vehicle swap 
  2593. 		store_vehicle_notify_screen_covered() 
  2594. 	end 
  2595. end 
  2596.  
  2597. function store_vehicle_loop_bg_anims(tween_handle) 
  2598. 	local animation = vint_object_parent(tween_handle) 
  2599. 	 
  2600. 	-- Loop bg anim starting at frame 40 
  2601. 	lua_play_anim(animation, -1.5) 
  2602. end 
  2603.  
  2604. --function store_vehicle_unlock_controls() 
  2605. --	Input_tracker:subscribe(true) 
  2606. --	store_vehicle_enable_mouse(true) 
  2607. --end 
  2608.  
  2609. function store_vehicle_cleanup() 
  2610. 	-- make sure all pegs are unloaded	 
  2611. 	game_peg_unload(VEHICLE_CUST_RIM_PEG) 
  2612. 	game_peg_unload(VEHICLE_CUST_GLASS_PEG) 
  2613. 	game_peg_unload(VEHICLE_CUST_TIRE_PEG) 
  2614. 	 
  2615. 	if Store_vehicle_current_logo ~= -1 then 
  2616. 		--unload vehicle logo 
  2617. 		game_peg_unload(Store_vehicle_current_logo) 
  2618. 	end 
  2619. 	 
  2620. 	-- reload the full screen map 
  2621. 	if Store_vehicle_loaded_from_crib == false then	 
  2622. 		pause_map_restore() 
  2623. 	end 
  2624.  
  2625. 	character_enable_mouse_drag(false) 
  2626. 	 
  2627. 	-- Some things need to be cleaned up right away when a store doc is unloading, particular disabled inputs which have 
  2628. 	-- callbacks to the script that is unloading. 
  2629. 	store_common_cleanup_current_store()	 
  2630. end 
  2631.  
  2632. function store_vehicle_exit_final(event) 
  2633. 	Store_common_popup:nav_enable(false, nil, nil) 
  2634. 	Not_popup_grp:set_alpha(0) 
  2635. 	Vehicle_stats:set_alpha(0) 
  2636. 	 
  2637. 	-- The user hit the B button and is exiting 
  2638. 	-- This is redundant to selecting "No" in the list 
  2639. 	if event == "back" then 
  2640. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  2641. 		Not_popup_grp:set_alpha(1) 
  2642. 		Vehicle_stats:set_alpha(1) 
  2643. 		Active_list:set_visible(true) 
  2644. 		store_vehicle_enable_mouse(true) 
  2645. 		return 
  2646. 	end 
  2647. 	 
  2648. 	game_UI_audio_play("UI_Main_Menu_Select")	 
  2649. 	 
  2650. 	-- Did we select yes?  This assumes yes is the first item 
  2651. 	if Store_common_popup:get_selected_data() ~= 1 then 
  2652. 		Not_popup_grp:set_alpha(1) 
  2653. 		Vehicle_stats:set_alpha(1) 
  2654. 		Active_list:set_visible(true) 
  2655. 		store_vehicle_enable_mouse(true) 
  2656. 		return 
  2657. 	end 
  2658. 	 
  2659. 	-- Exit customization to garage 
  2660. 	if Store_vehicle_begin_from_garage and Store_vehicle_is_garage == false and Garage_leave_with_car ~= true then 
  2661. 		Not_popup_grp:set_alpha(1) 
  2662. 		Vehicle_stats:set_alpha(1) 
  2663. 		store_vehicle_enable_mouse(true) 
  2664. 		Active_list:set_visible(true) 
  2665. 		 
  2666. 		store_vehicle_switch_mode()		 
  2667. 		return 
  2668. 	end 
  2669. 		 
  2670. 	bg_saints_show(false) 
  2671. 	 
  2672. 	store_vehicle_retrieve_car_and_exit() 
  2673. end 
  2674.  
  2675. function store_vehicle_no_vehicle_exit_final(event) 
  2676. 	Store_common_popup:nav_enable(false, nil, nil) 
  2677. 	Not_popup_grp:set_alpha(0) 
  2678. 	Vehicle_stats:set_alpha(0) 
  2679. 	 
  2680. 	-- The user hit the B button and is exiting 
  2681. 	-- This is redundant to selecting "No" in the list 
  2682. 	if event == "back" then 
  2683. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  2684. 		Not_popup_grp:set_alpha(1) 
  2685. 		Vehicle_stats:set_alpha(1) 
  2686. 		Active_list:set_visible(true) 
  2687. 		store_vehicle_enable_mouse(true) 
  2688. 		return 
  2689. 	end 
  2690. 	 
  2691. 	game_UI_audio_play("UI_Main_Menu_Select")	 
  2692. 	 
  2693. 	-- Did we select yes?  This assumes yes is the first item 
  2694. 	if Store_common_popup:get_selected_data() ~= 1 then 
  2695. 		Not_popup_grp:set_alpha(1) 
  2696. 		Vehicle_stats:set_alpha(1) 
  2697. 		Active_list:set_visible(true) 
  2698. 		store_vehicle_enable_mouse(true) 
  2699. 		return 
  2700. 	end 
  2701. 	 
  2702. 	-- Exit garage to customization 
  2703. 	if Store_vehicle_begin_from_garage == false and Store_vehicle_is_garage then 
  2704. 		Not_popup_grp:set_alpha(1) 
  2705. 		Vehicle_stats:set_alpha(1) 
  2706. 		Active_list:set_visible(true) 
  2707. 		store_vehicle_enable_mouse(true) 
  2708. 		 
  2709. 		--hide the vehicle logo 
  2710. 		local vehicle_logo_h = vint_object_find("vehicle_logo", 0, Store_vehicle_doc_handle) 
  2711. 		vint_set_property(vehicle_logo_h, "visible", false) 
  2712. 		 
  2713. 		-- if back to customize returns true, go ahead and call store_vehicle_switch_mode 
  2714. 		-- otherwise, wait for vehicle to load in garage, then game will call store_vehicle_switch_mode 
  2715. 		-- garage_back_to_customize 
  2716. 		garage_back_to_customize() 
  2717. 		--store_vehicle_switch_mode()		 
  2718. 		return 
  2719. 	end 
  2720. 	 
  2721. 	--hide the vehicle logo 
  2722. 	local vehicle_logo_h = vint_object_find("vehicle_logo", 0, Store_vehicle_doc_handle) 
  2723. 	vint_set_property(vehicle_logo_h, "visible", false) 
  2724.  
  2725. 	store_vehicle_no_vehicle_exit() 
  2726. end 
  2727.  
  2728. function store_vehicle_resume_game() 
  2729. 	store_vehicle_exit(nil,true) 
  2730. end 
  2731.  
  2732. function store_vehicle_exit(menu_data, leave_with_car) 
  2733. 	-- If a popup is active, don't try to exit (to crib or switch modes) 
  2734. 	if Store_common_popup:get_visible() then 
  2735. 		return 
  2736. 	end 
  2737. 	 
  2738. 	-- no confirmation needed if we're just going back to the crib menu 
  2739. 	if Store_vehicle_loaded_from_crib then 
  2740. 		if Store_vehicle_is_garage then 
  2741. 			store_lock_controls() 
  2742. 			store_vehicle_return_to_crib() 
  2743. 			return 
  2744. 		elseif leave_with_car ~= true then 
  2745. 			--return to crib garage 
  2746. 			store_vehicle_switch_mode() 
  2747. 			return 
  2748. 		end		 
  2749. 	end 
  2750. 	 
  2751. 	--[[if Store_vehicle_begin_from_garage then 
  2752. 		store_vehicle_switch_mode() 
  2753. 		return 
  2754. 	end 
  2755. 	 
  2756. 		--store_vehicle_enable_controls(false) 
  2757. 	end]] 
  2758. 	 
  2759. 	-- don't allow exit popup (ignore controls) if vehicle not fully streamed in 
  2760. 	if store_vehicle_selection_should_lock_controls() then 
  2761. 		return 
  2762. 	end 
  2763. 	 
  2764. 	local body 
  2765. 	local callback 
  2766. 	 
  2767. 	if Store_vehicle_is_garage then 
  2768. 		body = "VCUST_GARAGE_EXIT_PROMPT" 
  2769. 		callback = "store_vehicle_no_vehicle_exit_final" 
  2770. 	else 
  2771. 		body = "VCUST_EXIT_PROMPT" 
  2772. 		callback = "store_vehicle_exit_final" 
  2773. 	end 
  2774. 	 
  2775. 	local heading = "MENU_TITLE_WARNING" 
  2776. 	 
  2777. 	Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)	 
  2778. 	Store_common_popup:set_title(heading) 
  2779. 	Store_common_popup:set_text(body)		 
  2780. 	Store_common_popup:nav_enable(true, callback, "store_vehicle_popup_nav") 
  2781. 	Not_popup_grp:set_alpha(0.5)	 
  2782. 	Vehicle_stats:set_alpha(0.5) 
  2783. 	Active_list:set_visible(false) 
  2784. 	 
  2785. 	Garage_leave_with_car = leave_with_car 
  2786. 	 
  2787. 	-- Disable mouse input for other items while the popup is up 
  2788. 	store_vehicle_enable_mouse(false)	 
  2789. end 
  2790.  
  2791. function store_vehicle_set_description(text) 
  2792. 	local upgrade_desc = Vdo_base_object:new("upgrade_desc", 0, Store_common_doc_handle) 
  2793. 	 
  2794. 	if text ~= nil then 
  2795. 		upgrade_desc:set_color(COLOR_STORE_VEHICLE_PRIMARY.R, COLOR_STORE_VEHICLE_PRIMARY.G, COLOR_STORE_VEHICLE_PRIMARY.B) 
  2796. 		upgrade_desc:set_text(text) 
  2797. 		upgrade_desc:set_visible(true) 
  2798. 	else 
  2799. 		upgrade_desc:set_visible(false) 
  2800. 	end 
  2801. end 
  2802.  
  2803. function store_vehicle_popup_nav(event, value) 
  2804. 	 
  2805. 	if event == "mouse_move" then 
  2806. 		vint_set_mouse_cursor("") 
  2807. 		Store_common_hint_bar:set_highlight(0) 
  2808. 	end 
  2809.  
  2810. 	if event == "nav_up" then	 
  2811. 		Store_common_popup.list:move_cursor(-1)	 
  2812. 	elseif event == "nav_down" then 
  2813. 		Store_common_popup.list:move_cursor(1) 
  2814. 	elseif event == "mouse_move" then 
  2815. 		-- value contains the target_handle in this case 
  2816. 		local new_index = Store_common_popup.list:get_button_index(value) 
  2817. 		if new_index ~= 0 then 
  2818. 			Store_common_popup.list:set_selection(new_index) 
  2819. 			Store_common_popup.list:move_cursor(0, true) 
  2820. 		end 
  2821. 	else 
  2822. 		--do nothing 
  2823. 	end 
  2824. 		 
  2825. end 
  2826.  
  2827. -- Populate the active megalist menu 
  2828. -- 
  2829. -- list_data: 		this table contains the data to populate the megalist 
  2830. -- current_index: 	the current index in the menu that's selected 
  2831. -- 
  2832. function store_vehicle_populate_list(list_data, current_index) 
  2833. 	local max_list_size = 11 
  2834. 	--if Store_vehicle_is_garage then 
  2835. 	--	max_list_size = 9 
  2836. 	--end	 
  2837. 	local selected_index = current_index 
  2838. 	 
  2839. 	if list_data.performance_menu == true and Game_platform == "PC" then 
  2840. 		-- On PC and performance menu, we will first select the last item in the list built the inputs and then 
  2841. 		-- set the selection to the right index. This is to setup the inputs properly because this type of list is  
  2842. 		-- doublelined and not really supported by the mouse input tracker. This was an easy workaround. 
  2843. 		selected_index = #list_data 
  2844. 	end 
  2845. 	 
  2846. 	Active_list:draw_items(list_data, selected_index, STORE_COMMON_LIST_SIZE, max_list_size, .9) 
  2847. 	Active_list:set_visible(true) 
  2848. 	 
  2849. 	-- Add mouse inputs for active_list 
  2850. 	if Game_platform == "PC" then 
  2851. 		Mouse_input_tracker:remove_all() 
  2852. 		 
  2853. 		Active_list:set_store("store_vehicle") 
  2854. 		Active_list:add_mouse_inputs("store_common", Mouse_input_tracker) 
  2855. 		 
  2856. 		if list_data.performance_menu == true then 
  2857. 			Active_list:set_selection(current_index) 
  2858. 			Active_list:move_cursor(0, true) 
  2859. 		end 
  2860. 		store_vehicle_enable_mouse(true) 
  2861. 	end 
  2862. end 
  2863.  
  2864. function store_vehicle_rim_grid_nav(event, value) 
  2865. 	-- true is passed to indicate we don't want the grid list vdo to redraw; we want to wait for swatch loads 
  2866. 	local redraw_grid = store_vehicle_grid_nav(event, true, value) 
  2867.  
  2868. 	-- update price and respect 
  2869. 	local item = Store_common_color_grid:return_selected_data()	 
  2870. 	if item.price ~= nil and item.price > 0 then 
  2871. 		Store_header:set_price(item.price) 
  2872. 		Store_header:set_respect(item.style)		 
  2873. 	else 
  2874. 		store_vehicle_clear_header() 
  2875. 	end 
  2876. 	 
  2877. 	Store_vehicle_wheel_price.rim = item.price 
  2878. 	Store_vehicle_wheel_respect.rim = item.style 
  2879. 	 
  2880. 	-- preview the selected rim 
  2881. 	local cat_index = Store_common_color_grid:return_selected_cat()		 
  2882. 		 
  2883. 	-- spinners must store their original category individually, since they are grouped 
  2884. 	-- into different categories for the UI. 
  2885. 	if Color_grid_data[cat_index].category_name == "VCUST_SPINNERS_TITLE" then 
  2886. 		vcust_preview_component(2, 3, item.category_id, item.id)	 
  2887. 	else 
  2888. 		vcust_preview_component(2, 0, cat_index - 1, item.id) 
  2889. 	end 
  2890. 	 
  2891. 	-- show logo if rim is branded 
  2892. 	if Store_vehicle_brand_data[cat_index] ~= nil then 
  2893. 		store_vehicle_swap_logo(cat_index, true) 
  2894. 	else 
  2895. 		store_vehicle_swap_logo(nil, false) 
  2896. 	end 
  2897. 	 
  2898. 	if redraw_grid then 
  2899. 		Store_common_color_grid:draw_items(Store_common_color_grid.data, Store_common_color_grid.current_idx, Store_common_color_grid.max_width, Store_common_color_grid.max_height, Store_common_color_grid.button_w, Store_common_color_grid.button_h, Store_common_color_grid.hint_button_offset, Store_common_color_grid.current_cat, nil, true, false)	 
  2900. 		Store_common_color_grid:update_mouse_inputs() 
  2901. 	end 
  2902. end 
  2903.  
  2904. function store_vehicle_palette_grid_nav(event, value) 
  2905.  
  2906. 	store_vehicle_grid_nav(event, false, value) 
  2907. 	 
  2908. 	-- slot is hardcoded to 0 
  2909. 	-- subtract 1 because grid indexing starts at 1 
  2910. 	local item = Store_common_color_grid:return_selected_data() 
  2911. 	vcust_preview_palette(0, item.id, Store_vehicle_color_selection - 1) 
  2912. 	 
  2913. 	Store_header:enable_price_respect(true) 
  2914. 	local index = Store_common_color_grid:return_selected_index()	 
  2915. 	Store_header:set_price(Store_vehicle_color_price) 
  2916. 	Store_header:set_respect(Store_vehicle_color_respect)	 
  2917. end 
  2918.  
  2919. function store_vehicle_color_grid_nav(event, value) 
  2920.  
  2921. 	store_vehicle_grid_nav(event, false, value) 
  2922. 	 
  2923. 	-- subtract 1 because grid indexing starts at 1 
  2924. 	local index = Store_common_color_grid:return_selected_index() 
  2925. 	vcust_preview_color(index - 1) 
  2926. 	 
  2927. 	Store_vehicle_color_price = Color_grid_data[index].price 
  2928. 	Store_vehicle_color_respect = Color_grid_data[index].style 
  2929. end 
  2930.  
  2931. -- Handle navigating grid 
  2932. -- Returns true if the grid index changed 
  2933. function store_vehicle_grid_nav(event, do_not_redraw, value, rim_resubscribe) 
  2934.  
  2935. 	if event == "nav_up" then	 
  2936. 		Store_common_color_grid:move_cursor(-2, do_not_redraw)	 
  2937. 	elseif event == "nav_down" then 
  2938. 		Store_common_color_grid:move_cursor(2, do_not_redraw) 
  2939. 	elseif event == "nav_left" then 
  2940. 		Store_common_color_grid:move_cursor(-1, do_not_redraw) 
  2941. 	elseif event == "nav_right" then 
  2942. 		Store_common_color_grid:move_cursor(1, do_not_redraw) 
  2943. 	elseif event == "mouse_move" then 
  2944. 		-- value contains the target_handle in this case 
  2945. 		local new_index, new_category = Store_common_color_grid:get_data_index(value) 
  2946. 		if new_index ~= 0 and (Old_vehicle_grid_index ~= new_index or Old_vehicle_grid_category ~= new_category) then 
  2947. 			Store_common_color_grid:set_selection(new_index, new_category) 
  2948. 			Store_common_color_grid:move_cursor(0, do_not_redraw, false) 
  2949. 			 
  2950. 			-- Store the index/etc for the next comparison 
  2951. 			Old_vehicle_grid_index = new_index 
  2952. 			Old_vehicle_grid_category = new_category 
  2953. 		else 
  2954. 			return false 
  2955. 		end 
  2956. 	else 
  2957. 		--do nothing 
  2958. 		return false 
  2959. 	end 
  2960. 	return true 
  2961. end 
  2962.  
  2963. function store_vehicle_set_hints(mode_switch_enabled) 
  2964.  
  2965. 	local hint_data = { {CTRL_MENU_BUTTON_B, "MENU_BACK"} }	 
  2966. 	 
  2967. 	Store_common_hint_bar:set_hints(hint_data)  
  2968. 	 
  2969. 	-- Add mouse input subscriptions 
  2970. 	if Game_platform == "PC" then 
  2971. 		Hint_bar_mouse_input_tracker:remove_all() 
  2972. 		 
  2973. 		Store_common_hint_bar:add_mouse_inputs("store_vehicle", Hint_bar_mouse_input_tracker) 
  2974. 		Hint_bar_mouse_input_tracker:subscribe(true) 
  2975. 	end 
  2976. 	 
  2977. 	local hint_rotate_data = { 
  2978. 		{CTRL_BUTTON_RS, "STORE_ZOOM_ROTATE"}, 
  2979. 	} 
  2980. 	Store_common_rotate_hint:set_hints(hint_rotate_data) 	 
  2981.  
  2982. end 
  2983.  
  2984. function store_vehicle_mode_set_init() 
  2985. 	-- Reset our header 
  2986. 	Store_header:clear_titles() 
  2987. 	store_vehicle_clear_header()		 
  2988. 	 
  2989. 	-- Populate the areas and draw the first menu 
  2990. 	local store_vehicle_name 
  2991. 	if Store_vehicle_is_garage then 
  2992. 	 
  2993. 		-- set colors for garage 
  2994. 		Store_header:set_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY, COLOR_STORE_REWARDS_TERTIARY)			 
  2995. 		Active_list:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY)				 
  2996. 		Store_common_color_grid:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY, COLOR_STORE_REWARDS_TERTIARY)			 
  2997. 		Store_common_popup:set_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY, COLOR_STORE_REWARDS_TERTIARY)				 
  2998. 		Store_common_spinner:set_color(COLOR_SAINTS_PURPLE)	 
  2999. 	 
  3000. 		store_vehicle_name = "garage" 
  3001. 		Store_header:enable_price_respect(false) 
  3002. 		local title = "TUT_TITLE_CRIB_GARAGE" 
  3003. 		local vehicle_type = garage_get_garage_type() 
  3004. 		if vehicle_type == GVT_WATERCRAFT then  
  3005. 			title = "GARAGE_DOCK" 
  3006. 		elseif vehicle_type == GVT_AIRPLANES then  
  3007. 			title = "GARAGE_HANGAR" 
  3008. 		elseif vehicle_type == GVT_HELICOPTERS then  
  3009. 			title = "GARAGE_HELIPORT" 
  3010. 		end 
  3011. 		Store_header:push_title(nil, title) 
  3012.  
  3013. 		local rim_jobs_grp = vint_object_find("rim_jobs_grp", 0, Store_vehicle_doc_handle) 
  3014. 		vint_set_property(rim_jobs_grp, "background", false) -- car isn't loaded yet 
  3015. 		bg_saints_set_background(false) 
  3016. 	else 
  3017. 	 
  3018. 		-- set colors for vehicle store 
  3019. 		Store_header:set_color(COLOR_STORE_VEHICLE_PRIMARY, COLOR_STORE_VEHICLE_SECONDARY, COLOR_STORE_VEHICLE_TERTIARY) 
  3020. 		Active_list:set_highlight_color(COLOR_STORE_VEHICLE_PRIMARY, COLOR_STORE_VEHICLE_SECONDARY, COLOR_STORE_VEHICLE_TERTIARY) 
  3021. 		Store_common_color_grid:set_highlight_color(COLOR_STORE_VEHICLE_PRIMARY, COLOR_STORE_VEHICLE_SECONDARY, COLOR_STORE_VEHICLE_TERTIARY)		 
  3022. 		Store_common_popup:set_color(COLOR_STORE_VEHICLE_PRIMARY, COLOR_STORE_VEHICLE_SECONDARY, COLOR_STORE_VEHICLE_TERTIARY)		 
  3023. 		Store_common_spinner:set_color(COLOR_STORE_VEHICLE_PRIMARY)	 
  3024. 	 
  3025. 		store_vehicle_name = "DEBUG_CLOTHING_STORE" 
  3026. 		Store_header:enable_price_respect(true)		 
  3027.  
  3028. 		local rim_jobs_grp = vint_object_find("rim_jobs_grp", 0, Store_vehicle_doc_handle) 
  3029. 		vint_set_property(rim_jobs_grp, "background", true) 
  3030. 		bg_saints_set_background(true) 
  3031. 	end	 
  3032.  
  3033. 	-- reset our store stacks 
  3034. 	store_common_stack_clear_menu() 
  3035. 	store_common_stack_clear_id() 
  3036. 	store_common_stack_clear_index() 
  3037. 	 
  3038. 	Menu_data = { } 
  3039.  
  3040. 	if vcust_is_camera_tool_mode() == false then 
  3041. 		-- Subscribe to the button presses we need, Input_tracker is created in store_common.lua 
  3042. 		--Input_tracker:subscribe(true)	 
  3043. 	 
  3044. 		-- Populate the areas and draw the first menu 
  3045. 		if Store_vehicle_is_garage then 
  3046. 			garage_build_areas() 
  3047. 			 
  3048. 			-- SEH, removing for now because it's broken 
  3049. 			--[[if Store_vehicle_loaded_from_crib == false then 
  3050. 				 local item = { 
  3051. 					 label = "GARAGE_CUST_NAME", type = TYPE_BUTTON, on_select = store_vehicle_switch_mode, 
  3052. 				} 
  3053. 				Menu_data[#Menu_data + 1] = item 
  3054. 			end 
  3055. 			--]] 
  3056. 			 
  3057. 			--[[ Remove exit option for garage.  Exit is done using "back" 
  3058. 			-- add exit store option 
  3059. 			local exit_item = { 
  3060. 				label = "STORE_EXIT", type = TYPE_BUTTON, on_select = store_vehicle_exit 
  3061. 					 
  3062. 			Menu_data[#Menu_data + 1] = exit_item	 
  3063. 			--]]			 
  3064. 			 
  3065. 			-- don't display menu if it's empty 
  3066. 			if #Menu_data > 0 then 
  3067. 				store_vehicle_populate_list(Menu_data, 1)	 
  3068. 			end 
  3069. 		else 
  3070. 			store_vehicle_build_areas()			 
  3071. 		end 
  3072. 		 
  3073. 	else 
  3074. 		store_lock_controls() 
  3075. 		--Input_tracker:subscribe(false)	 
  3076. 	 
  3077. 		-- Fill in a fake menu with enough data to show the scrollbar 
  3078. 		for i = 1,20 do 
  3079. 			local dummy_item = { label = "GIBBERISH", type = TYPE_BUTTON } 
  3080. 			Menu_data[i] = dummy_item 
  3081. 		end 
  3082. 		store_vehicle_populate_list(Menu_data, 1)		 
  3083. 	end 
  3084. 	 
  3085. 	-- Update our hints 
  3086. 	store_vehicle_set_hints(Store_vehicle_loaded_from_crib == false and  
  3087. 			(Store_vehicle_is_garage == false or Empty_garage == false)) 
  3088. 	 
  3089. end 
  3090.  
  3091. function store_vehicle_switch_mode() 
  3092.  
  3093. 	local store_main_grp = Vdo_base_object:new("store_main_grp", 0, Store_common_doc_handle) 
  3094. 	 
  3095. 	-- reusing wardrobe animations for garage 
  3096. 	local store_to_garage_anim = Vdo_anim_object:new("store_to_wardrobe_anim",0, Store_common_doc_handle) 
  3097. 	local logo_to_garage_anim = Vdo_anim_object:new("logo_to_garage_anim",0, Store_vehicle_doc_handle) 
  3098. 	local garage_twn_1 = Vdo_tween_object:new("wardrobe_twn_1", store_to_garage_anim.handle) 
  3099. 	local garage_twn_2 = Vdo_tween_object:new("wardrobe_twn_2", store_to_garage_anim.handle) 
  3100. 	 
  3101. 	store_main_grp:set_property("background", true) 
  3102. 	 
  3103. 	if Store_vehicle_is_garage == true then 
  3104. 		Store_vehicle_is_garage = false 
  3105. 		garage_twn_1:set_end_event("store_vehicle_switch_to_store") 
  3106. 		 
  3107. 		if Store_vehicle_loaded_from_crib then 
  3108. 			--hide the crib logo 
  3109. 			vint_set_property(Crib_title,"visible",false) 
  3110. 		end 
  3111. 		 
  3112. 		--hide the vehicle logo 
  3113. 		local vehicle_logo_h = vint_object_find("vehicle_logo", 0, Store_vehicle_doc_handle) 
  3114. 		vint_set_property(vehicle_logo_h, "visible", false) 
  3115. 	 
  3116. 		--show the rim jobs bg 
  3117. 		Rim_jobs_grp:set_visible(true) 
  3118. 		local vehicle_bg_grp = Vdo_base_object:new("rj_bg", 0, Store_vehicle_doc_handle) 
  3119. 		vehicle_bg_grp:set_visible(true) 
  3120. 		vehicle_bg_grp = Vdo_base_object:new("dots_grp", 0, Store_vehicle_doc_handle) 
  3121. 		vehicle_bg_grp:set_visible(true)	 
  3122. 		vehicle_bg_grp = Vdo_base_object:new("vignette_grp_1", 0, Store_vehicle_doc_handle) 
  3123. 		vehicle_bg_grp:set_visible(true)	 
  3124. 		 
  3125. 		local rim_jobs_bg_anim = Vdo_anim_object:new("rim_jobs_bg_anim", 0, Store_vehicle_doc_handle)	 
  3126. 		local rim_jobs_bg_twn = Vdo_tween_object:new("rim_jobs_bg_twn") 
  3127. 		local bg_end_event_twn = Vdo_tween_object:new("bg_end_event_twn", rim_jobs_bg_anim.handle) 
  3128. 		 
  3129. 		bg_end_event_twn:set_end_event("store_vehicle_screen_is_covered") 
  3130. 		rim_jobs_bg_twn:set_end_event("store_vehicle_loop_bg_anims")	 
  3131. 		 
  3132. 		local rj_logo_h = vint_object_find("rj_logo", 0, Store_vehicle_doc_handle) 
  3133. 		vint_set_property(rj_logo_h, "anchor", 343, 94) 
  3134. 		 
  3135. 		vint_apply_start_values(rim_jobs_bg_anim.handle) 
  3136. 		 
  3137. 		rim_jobs_bg_anim:play(0)	 
  3138. 		 
  3139. 		store_vehicle_change_mode(MODE_VCUST) 
  3140. 	else 
  3141. 		Store_vehicle_is_garage = true 
  3142. 		bg_saints_show(true) 
  3143. 		store_vehicle_clear_header() 
  3144. 		garage_twn_1:set_end_event("store_vehicle_switch_to_garage") 
  3145. 		if Store_vehicle_loaded_from_crib then 
  3146. 			vint_set_property(Crib_title,"visible",false) 
  3147. 		end 
  3148. 		local anim_out = Vdo_anim_object:new("rim_jobs_anim_out", 0, Store_vehicle_doc_handle) 
  3149. 		local end_event_twn = Vdo_tween_object:new("rim_jobs_end_event", anim_out.handle) 
  3150. 		end_event_twn:set_end_event("store_vehicle_hide_custom_bg") 
  3151. 		anim_out:play(0) 
  3152. 		--[[elseif Store_vehicle_begin_from_garage then 
  3153. 			local anim_out = Vdo_anim_object:new("rim_jobs_anim_out", 0, Store_vehicle_doc_handle) 
  3154. 			local end_event_twn = Vdo_tween_object:new("rim_jobs_end_event", anim_out.handle) 
  3155. 			end_event_twn:set_end_event("store_vehicle_hide_custom_bg") 
  3156. 			anim_out:play(0) 
  3157. 		end]] 
  3158. 		store_vehicle_change_mode(MODE_GARAGE) 
  3159. 	end 
  3160. 	 
  3161. 	garage_twn_2:set_end_event("store_vehicle_switch_mode_complete")		 
  3162. 	 
  3163. 	store_to_garage_anim:play(0) 
  3164. 	logo_to_garage_anim:play(0) 
  3165. 	 
  3166. 	-- Lock controls until animation is done 
  3167. 	store_lock_controls() 
  3168. 	--Input_tracker:subscribe(false) 
  3169. 	--store_vehicle_enable_mouse(false) 
  3170. 	 
  3171. 	-- Set camera position back to whole body 
  3172. 	-- store_set_camera_pos("body") 
  3173. end 
  3174.  
  3175. function store_vehicle_hide_custom_bg() 
  3176. 	Rim_jobs_grp:set_visible(false) 
  3177. 	local store_megalist_grp_h = vint_object_find("store_megalist_grp",0,Store_common_doc_handle) 
  3178. 	vint_set_property(store_megalist_grp_h, "anchor", 0, 0) 
  3179. 	local vehicle_bg_grp = Vdo_base_object:new("vignette_grp_1", 0, Store_vehicle_doc_handle) 
  3180. 	vehicle_bg_grp:set_visible(false) 
  3181. end 
  3182.  
  3183. function store_vehicle_switch_mode_complete() 
  3184. 	local store_main_grp = Vdo_base_object:new("store_main_grp", 0, Store_common_doc_handle) 
  3185. 	 
  3186. 	--Vehicle_stats:set_property("background", false)		 
  3187. 	store_main_grp:set_property("background", false) 
  3188. 	 
  3189. 	store_unlock_controls() 
  3190. end 
  3191.  
  3192. function store_vehicle_switch_to_garage() 
  3193. 	local store_logo = Vdo_base_object:new("rj_logo", 0, Store_vehicle_doc_handle) 
  3194. 	local store_vehicle_move_list_anim = Vdo_anim_object:new("store_vehicle_move_list_anim", 0, Store_common_doc_handle) 
  3195. 	local store_vehicle_list_twn = Vdo_tween_object:new("store_vehicle_list_twn", store_vehicle_move_list_anim.handle) 
  3196. 	 
  3197. 	bg_saints_show(true) 
  3198. 	 
  3199. 	store_vehicle_list_twn:set_property("end_value", 0, 0) 
  3200. 	store_logo:set_visible(false) 
  3201. 	Store_header:reformat_and_resize(true) 
  3202. 	Vehicle_stats:set_visible(false) 
  3203.  
  3204. 	store_vehicle_move_list_anim:play(0) 
  3205. 	 
  3206. 	store_vehicle_mode_set_init() 
  3207. end 
  3208.  
  3209. function store_vehicle_switch_to_store() 
  3210. 	local store_logo = Vdo_base_object:new("rj_logo", 0, Store_vehicle_doc_handle) 
  3211. 	local store_vehicle_move_list_anim = Vdo_anim_object:new("store_vehicle_move_list_anim", 0, Store_common_doc_handle) 
  3212. 	local store_vehicle_list_twn = Vdo_tween_object:new("store_vehicle_list_twn", store_vehicle_move_list_anim.handle) 
  3213. 	 
  3214. 	store_vehicle_list_twn:set_property("end_value", 0, 0) 
  3215. 	 
  3216. 	store_logo:set_visible(true) 
  3217. 	Store_header:reformat_and_resize(false) 
  3218. 	Vehicle_stats:set_visible(false) 
  3219. 	 
  3220. 	store_vehicle_move_list_anim:play(0)	 
  3221. 	 
  3222. 	store_vehicle_mode_set_init() 
  3223. end 
  3224.  
  3225. function store_vehicle_play_exit_anim() 
  3226.  
  3227. 	if Store_vehicle_loaded_from_crib and Returning_to_crib then 
  3228. 		-- done immediately & bg_saints is full screen until after teleport return to crib 
  3229. 		store_unload_doc() 
  3230. 	else 
  3231. 		-- exit with vehicle or exit to garage desk 
  3232. 		--[[ 
  3233. 		local anim_out = Vdo_anim_object:new("rim_jobs_anim_out", 0, Store_vehicle_doc_handle) 
  3234. 		local end_event_twn = Vdo_tween_object:new("rim_jobs_end_event", anim_out.handle) 
  3235. 		 
  3236. 		end_event_twn:set_end_event("store_unload_doc") 
  3237. 		 
  3238. 		anim_out:play(0) 
  3239. 		store_common_play_anim_out()]] 
  3240. 	end 
  3241. end 
  3242.  
  3243. function store_unload_doc() 
  3244.  
  3245. 	vint_document_unload() 
  3246. 	 
  3247. end 
  3248.  
  3249. function store_vehicle_debug_hide_toggle() 
  3250. 	local grp = vint_object_find("non_bg_grp") 
  3251. 	local visible = vint_get_property(grp, "visible") 
  3252. 	vint_set_property(grp, "visible", not visible) 
  3253. 	Active_list:set_visible(not visible) 
  3254. 	Store_common_hint_bar:set_visible(not visible) 
  3255. 	Store_common_rotate_hint:set_visible(not visible) 
  3256. 	Store_header:set_visible(not visible)	 
  3257. end 
  3258.  
  3259. -- ===================================== 
  3260. --       Mouse Specific Functions 
  3261. -- ===================================== 
  3262. function store_vehicle_enable_mouse(enable) 
  3263. 	if Game_platform == "PC" and enable ~= nil then 
  3264. 		if Mouse_input_tracker ~= 0 then 
  3265. 			Mouse_input_tracker:subscribe(enable) 
  3266. 		end 
  3267. 		 
  3268. 		if Hint_bar_mouse_input_tracker ~= nil then 
  3269. 			Hint_bar_mouse_input_tracker:subscribe(enable) 
  3270. 		end 
  3271. 	end 
  3272. end 
  3273.  
  3274. function store_vehicle_mouse_click(event, target_handle) 
  3275. 	local hint_index = Store_common_hint_bar:get_hint_index(target_handle) 
  3276. 	if hint_index ~= 0 then 
  3277. 		if Current_tier == MENU_TIER then 
  3278. 		 
  3279. 		-- If a popup is active, don't try to exit (to crib or switch modes) 
  3280. 		if Store_common_popup:get_visible() then 
  3281. 			if Store_common_popup.callback_action ~= nil then 
  3282. 				--Hacky hack so we can easily go from a string to a function call. 
  3283. 				thread_new(Store_common_popup.callback_action, "back") 
  3284. 			end 
  3285. 		else 
  3286. 			store_common_button_b() 
  3287. 		end 
  3288. 		elseif Current_tier == COLOR_TIER then 
  3289. 			store_vehicle_color_selected("back") 
  3290. 		elseif Current_tier == PALETTE_TIER then 
  3291. 			store_vehicle_palette_selected("back") 
  3292. 		elseif Current_tier == TIRE_TIER then 
  3293. 			store_vehicle_tire_selected("back") 
  3294. 		elseif Current_tier == RIM_TIER then 
  3295. 			store_vehicle_rim_selected("back") 
  3296. 		end 
  3297. 	end 
  3298. end 
  3299.  
  3300. function store_vehicle_mouse_move(event, target_handle) 
  3301.  
  3302. 	vint_set_mouse_cursor("") 
  3303. 	store_common_mouse_zoom(0.0) 
  3304.  
  3305. 	Store_common_hint_bar:set_highlight(0) 
  3306. 	 
  3307. 	local hint_index = Store_common_hint_bar:get_hint_index(target_handle) 
  3308. 	if hint_index ~= 0 then 
  3309. 		Store_common_hint_bar:set_highlight(hint_index, Store_common_current_highlight_color) 
  3310. 	end 
  3311. 	 
  3312. 	local old_index = Active_list:get_selection() 
  3313. 	local new_index = Active_list:get_button_index(target_handle) 
  3314. 	if new_index ~= 0 and new_index ~= old_index then 
  3315. 		Active_list:set_selection(new_index) 
  3316. 		Active_list:move_cursor(0, true) 
  3317. 		 
  3318. 		-- If the item has a callback for navigation, do it (such as putting clothes on) 
  3319. 		local data_item = Active_list:return_selected_data() 
  3320. 		if data_item.on_nav ~= nil then 
  3321. 			data_item.on_nav(data_item) 
  3322. 		end 
  3323. 		return 
  3324. 	end 
  3325. end 
  3326.  
  3327. function store_vehicle_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines) 
  3328. 	if scroll_lines ~= 0 then 
  3329. 		if Store_common_color_grid.bg.handle == target_handle then 
  3330. 			Store_common_color_grid:scroll_list(scroll_lines * -1) 
  3331. 		end 
  3332. 	end 
  3333. end 
  3334.  
  3335. function store_vehicle_mouse_drag(event, target_handle, mouse_x, mouse_y) 
  3336. 	if Store_common_color_grid.scrollbar.tab.handle == target_handle then 
  3337. 		local new_start_index = Store_common_color_grid.scrollbar:drag_scrolltab(mouse_y, Store_common_color_grid.rows - (Store_common_color_grid.max_height - 1)) 
  3338. 		Store_common_color_grid:scroll_list(0, new_start_index) 
  3339. 	end 
  3340. end 
  3341.  
  3342. function store_vehicle_mouse_drag_release(event, target_handle, mouse_x, mouse_y) 
  3343. 	if Store_common_color_grid.scrollbar.tab.handle == target_handle then 
  3344. 		local start_row = Store_common_color_grid:get_visible_rows() 
  3345. 		Store_common_color_grid.scrollbar:release_scrolltab(start_row, Store_common_color_grid.rows - (Store_common_color_grid.max_height - 1)) 
  3346. 		Store_common_color_grid:update_mouse_inputs() 
  3347. 	end 
  3348. end 
  3349.  
  3350. function store_vehicle_background_hide_vehicle(hide) 
  3351. 		local rim_jobs_grp = vint_object_find("rim_jobs_grp", 0, Store_vehicle_doc_handle) 
  3352. 		local visible = not hide 
  3353. 		vint_set_property(rim_jobs_grp, "background", visible) 
  3354. 		bg_saints_set_background(visible) 
  3355. end 
  3356.  
  3357. function store_lock_controls() 
  3358. 	Input_tracker:subscribe(false) 
  3359. 	store_vehicle_enable_mouse(false) 
  3360. end 
  3361.  
  3362. function store_unlock_controls() 
  3363. 	Input_tracker:subscribe(true) 
  3364. 	store_vehicle_enable_mouse(true) 
  3365. end 
  3366.  
  3367. function garage_vehicle_load_completed(vehicle_logo_name) 
  3368. 	if store_vehicle_get_state() == MODE_VCUST then 
  3369. 		ui_audio_post_event("rim_job_camera_zoom") 
  3370. 	end 
  3371. 	 
  3372. 	local vehicle_logo_h = vint_object_find("vehicle_logo", 0, Store_vehicle_doc_handle) 
  3373. 	-- Display a new vehicle logo 
  3374. 	if store_vehicle_get_state() == MODE_GARAGE then 
  3375. 		if Store_vehicle_current_logo ~= vehicle_logo_name then 
  3376. 			if vehicle_logo_name == "__unloaded" or vehicle_logo_name == 0 or vehicle_logo_name == "" then 
  3377. 				vint_set_property(vehicle_logo_h, "visible", false) 
  3378. 			else	 
  3379. 				game_peg_unload(Store_vehicle_current_logo) 
  3380. 				Store_vehicle_current_logo = vehicle_logo_name			 
  3381. 				-- Load vehicle logo peg 
  3382. 				game_peg_load_with_cb("garage_set_vehicle_logo", 1, vehicle_logo_name) 
  3383. 			end 
  3384. 		else 
  3385. 			vint_set_property(vehicle_logo_h, "visible", true) 
  3386. 		end 
  3387. 	else 
  3388. 		vint_set_property(vehicle_logo_h, "visible", false) 
  3389. 	end 
  3390. 	 
  3391. 	 
  3392. 	Store_common_spinner:set_visible(false) 
  3393. 	store_unlock_controls() 
  3394. end 
  3395.  
  3396. function garage_set_vehicle_logo() 
  3397. 	local vehicle_logo_h = vint_object_find("vehicle_logo", 0, Store_vehicle_doc_handle) 
  3398. 	vint_set_property(vehicle_logo_h, "image", Store_vehicle_current_logo) 
  3399. 	vint_set_property(vehicle_logo_h, "visible", true) 
  3400. end 
  3401.  
  3402. function garage_vehicle_load_begin() 
  3403. 	Store_common_spinner:set_visible(true) 
  3404. 	local vehicle_logo_h = vint_object_find("vehicle_logo", 0, Store_vehicle_doc_handle) 
  3405. 	vint_set_property(vehicle_logo_h, "visible", false) 
  3406. end 
  3407.  
  3408. function store_vehicle_swap_logo(brand_id, show_brand)	 
  3409. 	local rim_jobs_logo = Vdo_base_object:new("rj_logo", 0, Store_vehicle_doc_handle) 
  3410. 	local brand_logo = Vdo_base_object:new("brand_logo", 0, Store_vehicle_doc_handle) 
  3411. 	 
  3412. 	if show_brand == true then 
  3413. 		--Hide store logo 
  3414. 		rim_jobs_logo:set_visible(false) 
  3415. 		 
  3416. 		--Set and show brand logo 
  3417. 		brand_logo:set_image(Store_vehicle_brand_data[brand_id]) 
  3418. 		brand_logo:set_visible(true) 
  3419. 	else 
  3420. 		--Show store logo 
  3421. 		rim_jobs_logo:set_visible(true) 
  3422. 		 
  3423. 		--Hide brand logo 
  3424. 		brand_logo:set_visible(false)	 
  3425. 	end 
  3426. end 
  3427.  
  3428. function store_vehicle_exit_begin_bg_clear() 
  3429. 	-- start transitioning out background for non-crib exit 
  3430. 	local anim_out = Vdo_anim_object:new("rim_jobs_anim_out", 0, Store_vehicle_doc_handle) 
  3431. 	local end_event_twn = Vdo_tween_object:new("rim_jobs_end_event", anim_out.handle) 
  3432. 	 
  3433. 	ui_audio_post_event("UI_Store_Exit") 
  3434. 	 
  3435. 	bg_saints_slide_out(1300) 
  3436. 	 
  3437. 	end_event_twn:set_end_event("store_unload_doc") 
  3438. 	 
  3439. 	anim_out:play(0) 
  3440. 	store_common_play_anim_out() 
  3441.  
  3442. 	-- call store_vehicle_exit_bg_cleared() when this is complete 
  3443. end 
  3444.