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