sr2lua/vehicle_cust.lua

  1. --------------------------- 
  2. -- VEHICLE CUSTOMIZATION -- 
  3. --------------------------- 
  4. -- "global" variables 
  5. Vehicle_cust_menu			 		= { } 
  6. Vehicle_cust_footer 				= { } 
  7.  
  8. Vehicle_cust_title_to_use		  	= "" 
  9. Vehicle_cust_menu_type			  	= 0 
  10.  
  11. Vehicle_cust_show_slot			  	= -1 
  12. Vehicle_cust_color_slot			  	= -1 
  13. Vehicle_cust_show_region			= false 
  14.  
  15. Vehicle_cust_style_to_award			= 0 
  16. Vehicle_cust_category_selected  	= 0 
  17. Vehicle_cust_palette_choice	  		= 0 
  18. Vehicle_cust_rim_family			 	= 0 
  19. Vehicle_cust_rim_index				= 0 
  20. Vehicle_cust_component_selected		= -1 
  21. Vehicle_cust_chosen_axle			= 0 
  22. Vehicle_cust_current_peg	  		= "" 
  23. Vehicle_cust_rebuild_wheel_menu		= true 
  24.  
  25. Vehicle_cust_color_menu				= { } 
  26.  
  27. Vehicle_cust_wheel_price			= 0 
  28. Vehicle_cust_rim_price				= 0 
  29. Vehicle_cust_tire_price				= 0 
  30. Vehicle_cust_hubcap_price			= 0 
  31.  
  32. Vehicle_cust_slider_values 			= { rim_size = -1, wheel_size = -1, wheel_width = -1 } 
  33.  
  34. VEHICLE_CUST_SLIDER_COST			= 100 
  35.  
  36. VEHICLE_CUST_RIM_PEG				= "ui_veh_r_0"  
  37. VEHICLE_CUST_TIRE_PEG 				= "ui_veh_tires" 
  38. VEHICLE_CUST_HUBCAP_PEG				= "ui_veh_h_01" 
  39. VEHICLE_CUST_SPINNER_PEG			= "ui_veh_s_0" 
  40.  
  41. VEHICLE_CUST_DOC_HANDLE 		  	= vint_document_find("vehicle_cust") 
  42.  
  43. VEHICLE_COMPONENT_LINE_CHECK_COLOR 	= {["R"] = 0.27, ["G"] = 0.47, ["B"] = 0.09} 			 
  44. VEHICLE_COMPONENT_LINE				= 2001 
  45.  
  46. Vehicle_just_upgrade				= false 
  47. Vehicle_upgrade_sound				= audio_get_audio_id("SYS_VEH_UPGRADE")		-- Any item is purchased 
  48.  
  49. Vehicle_cust_rim_sizes = { 
  50. 	num_rim_sizes = 5, 
  51. 	median_rim_size = 2, 
  52. 	 
  53. 	[0] = "VCUST_EXTRA_HIGH_PROFILE", 
  54. 	[1] = "VCUST_HIGH_PROFILE", 
  55. 	[2] = "VCUST_NORMAL_PROFILE", 
  56. 	[3] = "VCUST_LOW_PROFILE",  
  57. 	[4] = "VCUST_EXTRA_LOW_PROFILE", 
  58. } 
  59.  
  60.  
  61.  
  62. ---------------------- 
  63. --	SYSTEM FUNCTIONS -- 
  64. ---------------------- 
  65. --[ INITIALIZE AND SHUTDOWN ]-- 
  66. ------------------------------- 
  67. --	Initialize the menu 
  68. function vehicle_cust_init() 
  69.  
  70. 	--Event Tracking 
  71. 	event_tracking_interface_enter("Vehicle Customization") 
  72. 	 
  73. 	peg_load("ui_veh_paint") 
  74. 	peg_load("ui_veh_glass") 
  75.  
  76. 	menu_set_custom_control_callbacks(Vehicle_menu_controls) 
  77. 	 
  78. 	if vcust_using_lightset() == true then 
  79. 		interface_effect_begin("store", 1, 2, true) 
  80. 	end 
  81. 	 
  82. 	menu_store_init(true) 
  83. 	 
  84. 	vehicle_cust_build_horz_menu() 
  85. 	 
  86. 	menu_init() 
  87. 	menu_horz_init(Vehicle_cust_horz_menu) 
  88. 	 
  89. end 
  90.  
  91. -- Shutdown and cleanup the menu 
  92. function vehicle_cust_cleanup() 
  93. 	style_cluster_cleanup() 
  94. 	peg_unload("ui_veh_paint") 
  95. 	peg_unload("ui_veh_glass") 
  96. 	if Vehicle_cust_current_peg ~= "" then 
  97. 		peg_unload(Vehicle_cust_current_peg) 
  98. 	end 
  99.  
  100. 	if vcust_using_lightset() == true then 
  101. 		interface_effect_end(2) 
  102. 	end 
  103.  
  104. end 
  105.  
  106. --[ EXIT ]-- 
  107. ------------ 
  108. function vehicle_cust_exit(menu_data) 
  109. 	local body = "VCUST_EXIT_PROMPT" 
  110. 	local heading = "MENU_TITLE_WARNING" 
  111.  
  112. 	dialog_box_confirmation(heading, body, "vehicle_cust_exit_confirm") 
  113. end 
  114.  
  115. function vehicle_cust_exit_confirm(result, action) 
  116. 	if action ~= DIALOG_ACTION_CLOSE then 
  117. 		return 
  118. 	end 
  119. 	 
  120. 	if result == 0 then 
  121. 		menu_close(vehicle_cust_exit_final) 
  122. 	end 
  123. end 
  124. function vehicle_cust_exit_final() 
  125. 	vint_document_unload(VEHICLE_CUST_DOC_HANDLE)	 
  126. end 
  127.  
  128. ------------------- 
  129. -- CHECKBOX LINE -- 
  130. ------------------- 
  131. function vehicle_component_line_on_show(menu_label, menu_data) 
  132. 	local control = menu_label.control 
  133.  
  134. 	if control ~= nil then 
  135. 		if control.type ~= VEHICLE_COMPONENT_LINE then 
  136. 			menu_release_control(control) 
  137. 			control = nil 
  138. 		end 
  139. 	end 
  140.  
  141. 	if control == nil then 
  142. 		local control_h = vint_object_clone(vint_object_find("pm_objective_text_line"), Menu_option_labels.control_parent) 
  143. 		control = { grp_h = control_h, type = VEHICLE_COMPONENT_LINE, is_highlighted = false } 
  144. 		menu_label.original_anchor = { } 
  145. 		menu_label.original_anchor.x, menu_label.original_anchor.y  = vint_get_property(vint_object_find("pm_objective_text_line_label"), "anchor") 
  146. 	end 
  147.  
  148. 	menu_label.control = control 
  149. 	 
  150. 	--	Hide the O.G. Label 
  151. 	vint_set_property(menu_label.label_h, "visible", false) 
  152. 	 
  153. 	--	Show the new control 
  154. 	vint_set_property(control.grp_h, "visible", true) 
  155. 	vint_set_property(control.grp_h, "anchor", menu_label.anchor_x, menu_label.anchor_y) 
  156. 	vint_set_property(control.grp_h, "depth", menu_label.depth) 
  157. 	 
  158. 	--	Set the color and text_tag 
  159. 	menu_label.real_label_h = vint_object_find("pm_objective_text_line_label", control.grp_h) 
  160. 	vint_set_property(menu_label.real_label_h, "text_tag", menu_data.label) 
  161. 	vint_set_property(menu_label.real_label_h, "tint", 0.364, 0.368, 0.376) 
  162. 	vint_set_property(menu_label.real_label_h, "visible", true) 
  163. 	menu_label.checkbox_h = vint_object_find("pm_objective_checkbox", control.grp_h) 
  164. 	menu_label.check_h = vint_object_find("pm_objective_checkmark", control.grp_h) 
  165. 	vint_set_property(menu_label.checkbox_h, "tint", 0.364, 0.368, 0.376) 
  166. 	vint_set_property(menu_label.check_h, "tint", VEHICLE_COMPONENT_LINE_CHECK_COLOR.R, VEHICLE_COMPONENT_LINE_CHECK_COLOR.G, VEHICLE_COMPONENT_LINE_CHECK_COLOR.B) 
  167. 		 
  168. 	vint_set_property(menu_label.real_label_h, "anchor", menu_label.original_anchor.x, menu_label.original_anchor.y) 
  169. 	vint_set_property(menu_label.checkbox_h, "visible", true) 
  170. 	if menu_data.checked == true then 
  171. 		vint_set_property(menu_label.real_label_h, "alpha", 0.6) 
  172. 		vint_set_property(menu_label.checkbox_h, "alpha", 0.6) 
  173. 		vint_set_property(menu_label.check_h, "visible", true) 
  174. 		vint_set_property(menu_label.check_h, "alpha", 0.6) 
  175.  
  176. 	else 
  177. 		vint_set_property(menu_label.real_label_h, "alpha", 1.0) 
  178. 		vint_set_property(menu_label.check_h, "visible", false) 
  179. 	end 
  180. end 
  181.  
  182. function vehicle_update_custom_scrollbar() 
  183. 	local data_idx  = Menu_active.highlighted_item 
  184. 	local label_idx = Menu_active.highlighted_item - Menu_active.first_vis_item 
  185. 	 
  186. 	if label_idx  >= Menu_option_labels.max_rows then 
  187. 		return 
  188. 	end 
  189. 	local anchor_x, anchor_y = vint_get_property(Menu_option_labels[label_idx].real_label_h, "anchor") 
  190. 	local hl_bar_label_h = vint_object_find("menu_sel_bar_label", Menu_option_labels.hl_bar) 
  191. 	vint_set_property(Menu_option_labels.hl_bar, "anchor", anchor_x + 5, Menu_option_labels[label_idx].anchor_y + 1) 
  192. 	 
  193. 	vint_set_property(hl_bar_label_h, "text_tag", Menu_active[data_idx].label) 
  194. 	vehicle_component_line_resize_select_bar() 
  195. end 
  196.  
  197. function vehicle_component_line_resize_select_bar() 
  198. 	local width = Menu_active.menu_width - (element_get_actual_size(Menu_option_labels[0].checkbox_h) + 5) 
  199. 	local bg_h 
  200. 	local frame_h = Menu_option_labels.frame 
  201. 	local sel_bar_width = width 
  202. 	 
  203. 	if Menu_option_labels.scroll_bar_visible == true then 
  204. 		sel_bar_width = sel_bar_width - 40 
  205. 	end 
  206.  
  207. 	--Floor the selection bar width 
  208. 	sel_bar_width = floor(sel_bar_width) 
  209. 	 
  210. 	bg_h = vint_object_find("menu_sel_bar_w", frame_h) 
  211. 	vint_set_property(bg_h, "source_se", sel_bar_width, 36) 
  212. 	 
  213. 	bg_h = vint_object_find("menu_sel_bar_w_hl", frame_h) 
  214. 	vint_set_property(bg_h, "source_se", sel_bar_width, 36) 
  215. 	 
  216. 	bg_h = vint_object_find("menu_sel_bar_e", frame_h) 
  217. 	local menu_bar_e_anchor_x, menu_bar_e_anchor_y = vint_get_property(bg_h, "anchor") 
  218. 	menu_bar_e_anchor_x = sel_bar_width + 4 
  219. 	vint_set_property(bg_h, "anchor", menu_bar_e_anchor_x, menu_bar_e_anchor_y) 
  220. 	 
  221. 	local bg_h = vint_object_find("menu_sel_bar_e_hl", frame_h) 
  222. 	vint_set_property(bg_h, "anchor", menu_bar_e_anchor_x, menu_bar_e_anchor_y) 
  223. 	 
  224. 	vint_set_property(Menu_option_labels.hl_clip, "offset", 12, -15) 
  225. 	vint_set_property(Menu_option_labels.hl_clip, "clip_size", width - 17, MENU_ITEM_HEIGHT) 
  226. end 
  227.  
  228. function vehicle_component_line_nav_up(menu_label, menu_data) 
  229. 	local idx = Menu_active.highlighted_item  
  230. 	 
  231. 	if idx - 1 >= 0 then 
  232. 		Menu_active.highlighted_item = Menu_active.highlighted_item - 1 
  233. 	else  
  234. 		Menu_active.highlighted_item = Menu_active.num_items - 1 
  235. 	end 
  236. 	 
  237. 	audio_play(Menu_sound_item_nav) 
  238. 	vehicle_update_custom_control() 
  239. 	 
  240. 	if Menu_active.on_nav ~= nil then 
  241. 		Menu_active.on_nav(Menu_active) 
  242. 	end 
  243. end 
  244.  
  245. function vehicle_component_line_nav_down(menu_label, menu_data) 
  246. 	local idx = Menu_active.highlighted_item  
  247. 	 
  248. 	if idx + 1 < Menu_active.num_items then 
  249. 		Menu_active.highlighted_item = Menu_active.highlighted_item + 1 
  250. 	else 
  251. 		Menu_active.highlighted_item = 0 
  252. 	end 
  253. 	 
  254. 	audio_play(Menu_sound_item_nav) 
  255. 	vehicle_update_custom_control() 
  256. 	 
  257. 	if Menu_active.on_nav ~= nil then 
  258. 		Menu_active.on_nav(Menu_active) 
  259. 	end 
  260. end 
  261.  
  262. function vehicle_update_custom_control() 
  263. 	local h, ch, item, label_w, control 
  264.  
  265. 	-- check to see if we need to scroll 
  266. 	local first_vis_item = 0 
  267. 	local prev_first_vis_item = Menu_active.first_vis_item 
  268.  
  269. 	if Menu_active.num_items > Menu_option_labels.max_rows then 
  270. 		local half_max = floor(Menu_option_labels.max_rows / 2) 
  271. 		first_vis_item = limit(Menu_active.highlighted_item - half_max, 0, Menu_active.num_items - Menu_option_labels.max_rows) 
  272. 	end 
  273. 	Menu_active.first_vis_item = first_vis_item 
  274. 		 
  275. 	local idx = Menu_active 
  276. 	-- set the labels and hide unused 
  277. 	for i = 0, Menu_option_labels.max_rows - 1 do 
  278. 		if Menu_active.first_vis_item < 0 then 
  279. 			Menu_active.first_vis_item = 0 
  280. 		end 
  281. 		 
  282. 		item = Menu_active.first_vis_item + i 
  283. 		if item < Menu_active.num_items then 
  284. 			local item_type = Menu_active[item].type 
  285. 			 
  286. 			-- update control 
  287. 			local cb = Menu_control_callbacks[item_type] 
  288. 			if cb ~= nil then 
  289. 				if cb.on_show ~= nil then 
  290. 					cb.on_show(Menu_option_labels[i], Menu_active[item]) 
  291. 				end 
  292. 			end 
  293. 		else 
  294. 			if Menu_option_labels[i].control ~= nil then 
  295. 				h = Menu_option_labels[i].control.grp_h 
  296. 				vint_set_property(Menu_option_labels[i].stripe_h, "visible", false) 
  297. 				vint_set_property(h, "visible", false) 
  298. 			end 
  299. 		end 
  300. 	end 
  301.  
  302. 	-- update scroll bar 
  303. 	if Menu_option_labels.scroll_bar_visible == true then 
  304. 		menu_scroll_bar_set_thumb_pos(Menu_active.first_vis_item / (Menu_active.num_items - Menu_option_labels.max_rows)) 
  305. 	end 
  306. 	 
  307. 	vehicle_update_custom_scrollbar() 
  308. 	vehicle_component_line_update_checkbox(Menu_active) 
  309. end 
  310.  
  311.  
  312. function vehicle_component_line_on_release(control) 
  313. 	if control.grp_h ~= nil then 
  314. 		vint_object_destroy(control.grp_h) 
  315. 		control.grp_h = nil 
  316. 	end 
  317. end 
  318.  
  319. function vehicle_component_line_get_width(menu_data) 
  320.  
  321. 	local grp_h = vint_object_find("pm_objective_text_line") 
  322. 	local label_h =  vint_object_find("pm_objective_text_line_label", grp_h) 
  323. 	local checkbox_h = vint_object_find("pm_objective_checkbox", grp_h) 
  324. 	 
  325. 	vint_set_property(label_h, "text_tag", menu_data.label) 
  326. 	 
  327. 	--Check its width 
  328. 	local min_width = element_get_actual_size(label_h)	 
  329. 	min_width = min_width + element_get_actual_size(checkbox_h) 
  330. 	 
  331. 	return min_width + 5 
  332. end 
  333.  
  334. function vehicle_component_line_get_height(menu_label, menu_data) 
  335.  
  336. end 
  337.  
  338. function vehicle_component_line_update_checkbox(menu_data) 
  339. 	for i = 0, Menu_option_labels.max_rows - 1 do 
  340. 		if Menu_active.first_vis_item < 0 then 
  341. 			Menu_active.first_vis_item = 0 
  342. 		end 
  343. 		 
  344. 		local item = Menu_active.first_vis_item + i 
  345. 		if item < Menu_active.num_items then 
  346. 			if menu_data[item].owned == false then 
  347. 				vint_set_property(Menu_option_labels[i].checkbox_h, "visible", false) 
  348. 			else 
  349. 				vint_set_property(Menu_option_labels[i].checkbox_h, "visible", true) 
  350. 			end 
  351. 			 
  352. 			if menu_data[item].equipped == true then 
  353. 				vint_set_property(Menu_option_labels[i].check_h, "visible", true) 
  354. 			else 
  355. 				vint_set_property(Menu_option_labels[i].check_h, "visible", false) 
  356. 			end 
  357. 		end 
  358. 	end 
  359. end 
  360.  
  361. ------------ 
  362. --	FOOTER -- 
  363. ------------ 
  364. function vehicle_cust_adjust_footer_positions() 
  365. 	if Menu_active == 0 then 
  366. 		return 
  367. 	end 
  368. 	 
  369. 	if Menu_active.footer_height ~= 0 then 
  370. 		vint_set_property(Vehicle_cust_footer.label_h, "scale", 1.0, 1.0) 
  371. 		vint_set_property(Vehicle_cust_footer.price_h, "scale", 1.0, 1.0) 
  372. 		local text_x, text_y = vint_get_property(Vehicle_cust_footer.label_h, "anchor") 
  373. 		local text_width, text_height = element_get_actual_size(Vehicle_cust_footer.label_h) 
  374. 		local price_anchor_x = vint_get_property(Vehicle_cust_footer.price_h, "anchor") 
  375. 		local price_width, price_height = element_get_actual_size(Vehicle_cust_footer.price_h) 
  376. 		 
  377. 		 
  378. 		if price_width > text_width then 
  379. 			local size_of_text = Menu_active.menu_width - (text_x + text_width) - 30 
  380. 			local text_scale = (size_of_text / price_width) 
  381. 				 
  382. 			if price_width >= size_of_text then 
  383. 				vint_set_property(Vehicle_cust_footer.price_h, "scale", text_scale, text_scale) 
  384. 			end 
  385. 		else 
  386. 			local size_of_text = Menu_active.menu_width - price_width - 30 
  387. 			local text_scale  = (size_of_text / (text_x + text_width)) 
  388. 		 
  389. 			if text_x + text_width >= size_of_text then 
  390. 				vint_set_property(Vehicle_cust_footer.label_h, "scale", text_scale, text_scale) 
  391. 			end 
  392. 		end 
  393. 	end 
  394. end 
  395.  
  396. function vehicle_cust_build_footer(menu_data) 
  397. 	local grp = vint_object_clone(vint_object_find("style_footer"), Menu_option_labels.control_parent) 
  398. 	vint_set_property(grp, "visible", true) 
  399.  
  400. 	if menu_data.footer ~= nil and menu_data.footer.footer_grp ~= nil and menu_data.footer.footer_grp ~= 0 then 
  401. 		vint_object_destroy(menu_data.footer.footer_grp) 
  402. 	end 
  403.  
  404. 	menu_data.footer = { } 
  405. 	menu_data.footer.footer_grp = grp 
  406. 	 
  407. 	Vehicle_cust_footer.label_h = vint_object_find("price_label", grp) 
  408. 	Vehicle_cust_footer.price_h = vint_object_find("price_amount", grp) 
  409. 	Vehicle_cust_footer.style_h = vint_object_find("style_amount", grp) 
  410. 	 
  411. 	vint_set_property(Vehicle_cust_footer.label_h , "visible", true) 
  412. 	vint_set_property(Vehicle_cust_footer.price_h , "visible", true) 
  413. 	vint_set_property(Vehicle_cust_footer.style_h, "visible", true) 
  414.  
  415. end 
  416.  
  417. function vehicle_cust_build_footer_color(menu_data, swatch) 
  418. 	vehicle_cust_build_footer(menu_data) 
  419. 	 
  420. 	vint_set_property(Vehicle_cust_footer.label_h, "visible", true) 
  421. 	vint_set_property(Vehicle_cust_footer.price_h , "visible", false) 
  422. 	vint_set_property(Vehicle_cust_footer.style_h, "visible", false) 
  423. 	 
  424. 	if swatch ~= nil then 
  425. 		vehicle_cust_update_footer_color(swatch) 
  426. 	end 
  427. end 
  428.  
  429. function vehicle_cust_update_footer_color(swatch) 
  430. 	vint_set_property(Vehicle_cust_footer.label_h, "visible", false) 
  431. 	if swatch.label ~= nil and swatch.label ~= 0 then  
  432. 		 
  433. 		vint_set_property(Vehicle_cust_footer.label_h, "visible", true) 
  434. 		vint_set_property(Vehicle_cust_footer.label_h, "text_tag", swatch.label)			 
  435. 		 
  436. 		if swatch.price == nil then 
  437. 			vint_set_property(Vehicle_cust_footer.price_h , "visible", false) 
  438. 			return 
  439. 		end 
  440.  
  441. 		if swatch.price == 0 then 
  442. 			swatch.owned = true 
  443. 		end 
  444. 		 
  445. 		vint_set_property(Vehicle_cust_footer.price_h , "visible", true) 
  446. 		 
  447. 		if swatch.owned == true then 
  448. 			vint_set_property(Vehicle_cust_footer.price_h, "text_tag", "STORE_ITEM_OWNED") 
  449. 		else 
  450. 			vint_set_property(Vehicle_cust_footer.price_h, "text_tag", "$" .. format_cash(swatch.price)) 
  451. 		end 
  452. 		 
  453. 		if Style_cluster_player_cash < swatch.price and swatch.owned ~= true then 
  454. 			vint_set_property(Vehicle_cust_footer.price_h, "tint",  MENU_FOOTER_CASH_BROKE_COLOR.R, MENU_FOOTER_CASH_BROKE_COLOR.G, MENU_FOOTER_CASH_BROKE_COLOR.B) 
  455. 		else 
  456. 			vint_set_property(Vehicle_cust_footer.price_h, "tint",  MENU_FOOTER_CASH_NORMAL_COLOR.R, MENU_FOOTER_CASH_NORMAL_COLOR.G, MENU_FOOTER_CASH_NORMAL_COLOR.B) 
  457. 		end 
  458. 	else 
  459. 		vint_set_property(Vehicle_cust_footer.label_h, "text_tag_crc", swatch.label_crc) 
  460. 	end 
  461. 	 
  462. 	vehicle_cust_adjust_footer_positions() 
  463. end 
  464.  
  465. function vehicle_cust_update_footer_component(display_name, price, owned) 
  466. 	 
  467. 	vint_set_property(Vehicle_cust_footer.label_h, "text_tag", display_name) 
  468. 	 
  469. 	if price == 0 then 
  470. 		owned = true 
  471. 	end 
  472. 	 
  473. 	if owned == true then 
  474. 		vint_set_property(Vehicle_cust_footer.price_h, "text_tag", "STORE_ITEM_OWNED") 
  475. 		vint_set_property(Vehicle_cust_footer.style_h, "visible", false) 
  476. 	else 
  477. 		vint_set_property(Vehicle_cust_footer.price_h, "text_tag", "$" .. format_cash(price)) 
  478. 		vint_set_property(Vehicle_cust_footer.style_h, "visible", true) 
  479. 		 
  480. 		--Insert style values into style string 
  481. 		local style = { [0] = award_style("veh_comp", price, true) } 
  482. 		local style_string = vint_insert_values_in_string("STORE_ITEM_STYLE_AWARD", style) 
  483. 		vint_set_property(Vehicle_cust_footer.style_h, "text_tag", style_string) 
  484. 	end 
  485. 	 
  486. 	if Style_cluster_player_cash < price and owned ~= true then 
  487. 		vint_set_property(Vehicle_cust_footer.price_h, "tint",  MENU_FOOTER_CASH_BROKE_COLOR.R, MENU_FOOTER_CASH_BROKE_COLOR.G, MENU_FOOTER_CASH_BROKE_COLOR.B) 
  488. 	else 
  489. 		vint_set_property(Vehicle_cust_footer.price_h, "tint",  MENU_FOOTER_CASH_NORMAL_COLOR.R, MENU_FOOTER_CASH_NORMAL_COLOR.G, MENU_FOOTER_CASH_NORMAL_COLOR.B) 
  490. 	end 
  491. 	 
  492. 	vehicle_cust_adjust_footer_positions() 
  493. end 
  494.  
  495. function vehicle_cust_update_footer_wheels(label) 
  496. 	Vehicle_cust_wheel_price = Vehicle_cust_rim_price + Vehicle_cust_tire_price + Vehicle_cust_hubcap_price 
  497. 	if rim_size_text_slider.original_val ~= rim_size_text_slider.cur_value then 
  498. 		Vehicle_cust_wheel_price = Vehicle_cust_wheel_price + 100 
  499. 	end 
  500. 	 
  501. 	if wheel_size_text_slider.original_val ~= wheel_size_text_slider.cur_value then 
  502. 		Vehicle_cust_wheel_price = Vehicle_cust_wheel_price + 100 
  503. 	end 
  504. 	 
  505. 	if wheel_width_text_slider.original_val ~= wheel_width_text_slider.cur_value then 
  506. 		Vehicle_cust_wheel_price = Vehicle_cust_wheel_price + 100 
  507. 	end 
  508. 	 
  509. 	vint_set_property(Vehicle_cust_footer.label_h, "text_tag", label)	--	Should use text_tag_crc 
  510. 	 
  511. 	 
  512. 	vint_set_property(Vehicle_cust_footer.price_h, "text_tag", "$" .. format_cash(Vehicle_cust_wheel_price)) 
  513. 	 
  514. 	--Style Insert 
  515. 	local style = { [0] = award_style("veh_comp", Vehicle_cust_wheel_price, true) } 
  516. 	local style_string = vint_insert_values_in_string("STORE_ITEM_STYLE_AWARD", style) 
  517. 	vint_set_property(Vehicle_cust_footer.style_h, "text_tag", style_string) 
  518. 	 
  519. 	if Style_cluster_player_cash < Vehicle_cust_wheel_price then 
  520. 		vint_set_property(Vehicle_cust_footer.price_h, "tint",  MENU_FOOTER_CASH_BROKE_COLOR.R, MENU_FOOTER_CASH_BROKE_COLOR.G, MENU_FOOTER_CASH_BROKE_COLOR.B) 
  521. 	else 
  522. 		vint_set_property(Vehicle_cust_footer.price_h, "tint",  MENU_FOOTER_CASH_NORMAL_COLOR.R, MENU_FOOTER_CASH_NORMAL_COLOR.G, MENU_FOOTER_CASH_NORMAL_COLOR.B) 
  523. 	end 
  524.  
  525. 	vehicle_cust_adjust_footer_positions() 
  526. end 
  527.  
  528. function vehicle_cust_color_select_release(menu_data) 
  529. 	vcust_revert_color() 
  530. 	vehicle_cust_release(menu_data) 
  531. end 
  532.  
  533. function vehicle_cust_release(menu_data) 
  534. 	if menu_data.footer ~= nil then 
  535. 		vint_set_property(menu_data.footer.footer_grp, "visible", false) 
  536. 		vint_object_destroy(menu_data.footer.footer_grp) 
  537. 	end 
  538. 	 
  539. 	if menu_data[0].type == MENU_ITEM_TYPE_GRID then 
  540. 		menu_grid_release(menu_data[0]) 
  541. 	end 
  542. end 
  543.  
  544. function vehicle_cust_finalize_footer(menu_data) 
  545. 	vint_set_property(Vehicle_cust_footer.price_h, "anchor", menu_data.menu_width - 20, 0) 
  546. 	vehicle_cust_adjust_footer_positions() 
  547. end 
  548.  
  549. ------------------------ 
  550. --	MENU FUNCTIONALITY -- 
  551. ------------------------ 
  552. -- Creation of Menus 
  553. ------------------------ 
  554. -------------------------- 
  555. ---[ Horizontal Menu ]--- 
  556. function vehicle_cust_build_horz_menu() 
  557. 	-- New menu, clear out all items 
  558. 	Vehicle_cust_horz_menu.num_items = 0 
  559. 	-- Make the request to build the menu 
  560. 	vint_dataresponder_request("vcust_populate_menu", "vehicle_cust_populate_horz_menu", 0, 0) -- 0 = VCUST_INTF_POPULATE_HORZ_MENU 
  561. end 
  562.  
  563. function vehicle_cust_populate_horz_menu(display_name, index) 
  564. 	local sub_menu 
  565. 	--	 Alternate the menu so that changing menus erases the footer correctly 
  566. 	sub_menu = table_clone(Vehicle_cust_menu_a) 
  567.  
  568. 	-- Add the item 
  569. 	Vehicle_cust_horz_menu[Vehicle_cust_horz_menu.num_items] = { label = display_name, sub_menu = sub_menu, id = index } 
  570. 	-- Increase the count 
  571. 	Vehicle_cust_horz_menu.num_items = Vehicle_cust_horz_menu.num_items + 1 
  572. end 
  573.  
  574. -- Update the Current Menu selection 
  575. function vehicle_cust_nav_horz_menu() 
  576. 	vcust_change_top_level_menu(0, Vehicle_cust_horz_menu[Vehicle_cust_horz_menu.current_selection].id) 
  577. 	 
  578. 	Vehicle_cust_horz_menu[Vehicle_cust_horz_menu.current_selection].sub_menu.btn_tips = Vehicle_cust_btns_top 
  579. end 
  580.  
  581. ---------------------- 
  582. ---[ Generic Menu ]--- 
  583. function vehicle_cust_build_menu(menu_data) 
  584. 	 
  585. 	--	If we get back here, we need to rebuild the wheel menu next time we go in 
  586. 	Vehicle_cust_rebuild_wheel_menu = true 
  587. 	Vehicle_cust_color_menu = Vehicle_cust_menu 
  588. 	Vehicle_cust_menu = menu_data 
  589. 	Vehicle_cust_menu.btn_tips = Vehicle_cust_btns_top 
  590. 	-- New menu, clear out all items 
  591. 	Vehicle_cust_menu.num_items = 0 
  592. 	-- Make the request to build the menu 
  593. 	if Vehicle_cust_show_slot == -1 then 
  594. 		Vehicle_cust_menu.on_nav = nil 
  595. 		Vehicle_cust_menu.on_post_show = nil 
  596. 		Vehicle_cust_menu.footer_height = nil 
  597. 		 
  598. 		-- Build region menu 
  599. 		if Vehicle_cust_show_region == true then 
  600. 			Vehicle_cust_show_region = false 
  601. 			Vehicle_cust_menu.on_back = nil 
  602. 			Vehicle_cust_menu.header_label_str = "VCUST_REGION_TITLE" 
  603. 			vint_dataresponder_request("vcust_populate_menu", "vehicle_cust_populate_menu", 0, 4) -- 4 = VCUST_INTF_POPULATE_COLOR_REGION 
  604. 			Vehicle_cust_menu.btn_tips = Vehicle_cust_btns 
  605. 		else 
  606. 			Vehicle_cust_menu.on_back = vehicle_cust_exit 
  607. 			Vehicle_cust_menu.header_label_str = Vehicle_cust_horz_menu[Vehicle_cust_horz_menu.current_selection].label 
  608. 			vint_dataresponder_request("vcust_populate_menu", "vehicle_cust_populate_menu", 0, 1) -- 1 = VCUST_INTF_POPULATE_CURRENT_MENU 
  609. 			local component = Vehicle_cust_horz_menu[Vehicle_cust_horz_menu.current_selection].sub_menu 
  610. 			local hl_item = 0 
  611. 			if component.highlighted_item ~= nil then 
  612. 				hl_item = component.highlighted_item 
  613. 			end 
  614. 			 
  615. 			vcust_adjust_camera_angle(component[hl_item].id) 
  616. 		end 
  617. 		 
  618. 	else  
  619. 		Vehicle_cust_menu.header_label_str = Vehicle_cust_title_to_use 
  620. 		Vehicle_cust_menu.on_nav = vehicle_cust_nav_component 
  621. 		Vehicle_cust_menu.on_post_show = vehicle_cust_finalize_component 
  622. 		Vehicle_cust_menu.footer_height = 40 
  623. 		vehicle_cust_build_footer(Vehicle_cust_menu) 
  624. 		Vehicle_cust_menu.highlighted_item = 0 
  625. 		vint_dataresponder_request("vcust_populate_menu", "vehicle_cust_populate_menu", 0, 2, Vehicle_cust_show_slot) -- 2 = VCUST_INTF_POPULATE_COMPONENT_MENU 
  626. 		 
  627. 		local component = Vehicle_cust_menu[Vehicle_cust_menu.highlighted_item] 
  628. 		vehicle_cust_update_footer_component(component.label, component.price, component.owned) 
  629. 		vcust_preview_component(0, component.id) 
  630. --		vcust_adjust_camera_angle(component.id) 
  631. 		Vehicle_cust_menu.btn_tips = Vehicle_cust_btns 
  632. 		btn_tips_update() 
  633. 	end 
  634. 	Vehicle_cust_show_slot = -1 -- Reset it so we don't get stuck in perma-slot menu 
  635. 	 
  636. 	--	No footer if there are no options in there 
  637. 	if Vehicle_cust_menu.num_items == 0 then 
  638. 		Vehicle_cust_menu.num_items = 1 
  639. 		Vehicle_cust_menu.on_post_show = nil 
  640. 		Vehicle_cust_menu[0] = { label = "STORE_NO_ITEMS_IN_CATEGORY", type=MENU_ITEM_TYPE_SELECTABLE } 
  641. 		Vehicle_cust_menu.footer_height = nil 
  642. 	end 
  643.  
  644. end 
  645.  
  646. function vehicle_cust_populate_menu(display_name, cat_type, id, price, current) 
  647. 	-- Add the item 
  648. 	Vehicle_cust_menu[Vehicle_cust_menu.num_items] =  
  649. 		{ label = display_name, type=MENU_ITEM_TYPE_SUB_MENU, sub_menu = Vehicle_cust_menu_c, id = id, price = price, equipped = current } 
  650. 	if price == 0 then 
  651. 		Vehicle_cust_menu[Vehicle_cust_menu.num_items].owned = true 
  652. 	else 
  653. 		Vehicle_cust_menu[Vehicle_cust_menu.num_items].owned = false 
  654. 	end 
  655. 	 
  656. 	if cat_type > -1 and cat_type < Vehicle_cust_menu_ops.num_ops then 
  657. 		Vehicle_cust_menu[Vehicle_cust_menu.num_items].on_select = Vehicle_cust_menu_ops[cat_type].on_select 
  658. 		Vehicle_cust_menu[Vehicle_cust_menu.num_items].type = Vehicle_cust_menu_ops[cat_type].type 
  659. 		Vehicle_cust_menu[Vehicle_cust_menu.num_items].sub_menu = Vehicle_cust_menu_ops[cat_type].sub_menu 
  660. 		if Vehicle_cust_menu_ops[cat_type].on_nav ~= nil then 
  661. 			Vehicle_cust_menu.on_nav = Vehicle_cust_menu_ops[cat_type].on_nav 
  662. 		end 
  663.  
  664. 	else 
  665. 		debug_print("vint", "Vehicle Customization - Invalid Category type: " .. cat_type .. "\n") 
  666. 	end 
  667. 	 
  668. 	if current == true then 
  669. 		Vehicle_cust_menu.highlighted_item = Vehicle_cust_menu.num_items 
  670. 	end 
  671. 	 
  672. 	-- Increase the count 
  673. 	Vehicle_cust_menu.num_items = Vehicle_cust_menu.num_items + 1 
  674. end 
  675.  
  676. -- Selection / Navigation 
  677. function vehicle_cust_select_category(menu_label, menu_data)		--	Category selection 
  678. 	Vehicle_cust_show_slot = -1 
  679. 	vcust_make_menu_selection(0, Vehicle_cust_category_selected)	-- 0 = category 
  680. end 
  681.  
  682. function vehicle_cust_select_advanced_region(menu_label, menu_data)			-- Special case for Palette menu 
  683. 	Vehicle_cust_color_slot = menu_data.id 
  684. end 
  685.  
  686. function vehicle_cust_select_region(menu_label, menu_data) 
  687. 	Vehicle_cust_color_slot = menu_data.id 
  688. 	vcust_select_paint_slot(Vehicle_cust_color_slot)					--	Build the paint slots 
  689. 	Vehicle_cust_region_menu.on_show = vehicle_cust_build_menu 
  690. 	Vehicle_cust_show_region = true 
  691. end 
  692.  
  693. -- Update the current menu slot 
  694. function vehicle_cust_select_slot(menu_label, menu_data) 
  695. 	Vehicle_cust_show_slot = menu_data.id 
  696. 	Vehicle_cust_title_to_use = menu_data.label 
  697. --	vcust_adjust_camera_angle(Vehicle_cust_show_slot) 
  698. 	Vehicle_cust_menu_c.on_show = vehicle_cust_build_menu 
  699. end 
  700.  
  701. function vehicle_cust_nav_slot(menu_data) 
  702. 	vcust_adjust_camera_angle(menu_data[menu_data.highlighted_item].id) 
  703. end 
  704.  
  705. function vehicle_cust_nav_component(menu_data) 
  706. 	vcust_preview_component(0, menu_data[menu_data.highlighted_item].id) 
  707. 	vehicle_cust_update_footer_component(menu_data[menu_data.highlighted_item].label, menu_data[menu_data.highlighted_item].price, menu_data[menu_data.highlighted_item].owned) 
  708. end 
  709.  
  710. function vehicle_cust_finalize_component(menu_data) 
  711. 	vehicle_component_line_update_checkbox(menu_data) 
  712. 	vehicle_update_custom_scrollbar() 
  713. 	vehicle_cust_finalize_footer(menu_data) 
  714. end 
  715.  
  716. -- Possibly make a purchase 
  717. function vehicle_cust_select_component(menu_label, menu_data) 
  718. 	-- Confirm the purchase if we can afford it 
  719. 	if Style_cluster_player_cash >= menu_data.price and menu_data.price ~= 0 and menu_data.owned ~= true then 
  720. 		Vehicle_cust_component_selected = menu_data 
  721. 		-- local body = "Do you wish to purchase " .. menu_data.label .. " for $" .. format_cash(menu_data.price) .. "?" 
  722. 		local insert = { [0] = menu_data.label, [1] = format_cash(menu_data.price) } 
  723. 		local body = vint_insert_values_in_string("VCUST_PURCHASE_PROMPT", insert) 
  724. 		local heading = "MENU_TITLE_CONFIRM" 
  725. 		dialog_box_confirmation(heading, body, "vehicle_cust_component_confirm") 
  726. 	elseif menu_data.price ~= 0 and menu_data.owned ~= true then 
  727. 		dialog_box_message("MENU_TITLE_NOTICE", "HUD_SHOP_INSUFFICIENT_FUNDS") 
  728. 	else  
  729. 		Vehicle_cust_component_selected = menu_data 
  730. 		Vehicle_just_upgrade = true 
  731. 		vehicle_cust_component_confirm(0, DIALOG_ACTION_CLOSE) 
  732. 	end 
  733. end 
  734.  
  735. -- Make the purchase for realz 
  736. function vehicle_cust_component_confirm(result, action) 
  737. 	if action ~= DIALOG_ACTION_CLOSE then 
  738. 		return 
  739. 	end 
  740. 	 
  741. 	if result == 0 then 
  742. 		if vcust_show_nos_hydraulic_warning() == true then 
  743. 			dialog_box_confirmation("MENU_TITLE_CONFIRM", "VCUST_PERFORMANCE_WARNING", "vehicle_cust_component_confirm2") 
  744. 		else 
  745. 			vehicle_cust_component_confirm2(0, DIALOG_ACTION_CLOSE) 
  746. 		end 
  747. 	end 
  748. end 
  749.  
  750. function vehicle_cust_component_confirm2(result, action) 
  751. 	if action ~= DIALOG_ACTION_CLOSE then 
  752. 		return 
  753. 	end 
  754. 	 
  755. 	if result == 0 then 
  756. 		if Vehicle_cust_component_selected.price ~= 0 then 
  757. 			award_style("veh_comp", Vehicle_cust_component_selected.price) 
  758. 		end 
  759. 		Vehicle_cust_component_selected.owned = true 
  760. 		vcust_purchase_component()		--	Stop previewing the component, keep it and deduct cash 
  761. 		if Vehicle_just_upgrade	== true then 
  762. 			audio_play(Vehicle_upgrade_sound) 
  763. 			Vehicle_just_upgrade = false 
  764. 		else 
  765. 			audio_play(Menu_sound_purchase) 
  766. 		end 
  767. 		menu_show(Menu_active.parent_menu, MENU_TRANSITION_SWEEP_RIGHT) 
  768. 	end 
  769. end 
  770.  
  771. ------------------------------ 
  772. ----[ Color Palette Menu ]---- 
  773. function vehicle_cust_build_palette(menu_data) 
  774. 	Vehicle_cust_menu = menu_data 
  775. 	 
  776. 	local menu_item = menu_data[0] 
  777. 	menu_item.swatches = { num_swatches = 0 } 
  778. 	menu_item.cur_idx = 0 
  779. 		 
  780. 	-- Make the request to build the menu 
  781. 	vint_dataresponder_request("vcust_populate_palette_menu", "vehicle_cust_populate_palette_menu", 0, Vehicle_cust_color_slot) 
  782. 	local master_swatch = vint_object_find("swatch_paint", nil, MENU_BASE_DOC_HANDLE) 
  783. 	menu_grid_show(menu_data, menu_item, master_swatch, true)	 
  784. 	 
  785. 	-- update/build footer 
  786. 	vehicle_cust_build_footer_color(menu_data, menu_item.swatches[menu_item.cur_idx]) 
  787. 	local idx = menu_item.cur_row * menu_item.num_cols + menu_item.cur_col 
  788. 	if idx < menu_item.swatches.num_swatches then 
  789. 		vehicle_cust_update_footer_color(menu_item.swatches[idx])	 
  790. 	end 
  791. end 
  792.  
  793. function vehicle_cust_populate_palette_menu(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) 
  794. 	local swatches = Vehicle_cust_color_palette[0].swatches 
  795. 	swatches[swatches.num_swatches] = { 
  796. 		label = display_name, 
  797. 		base_r = base_r, base_g = base_g, base_b = base_b, 								-- Base paint color, used on base 
  798. 		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 
  799. 		spec_alpha = spec_alpha, 																	-- Specular alpha, used on spec 
  800. 		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 
  801. 		fres_con = fres_con, 																		-- Fresnel 'alpha' (contrast), used on fres 
  802. 		refl = refl, 																					-- Reflection color 
  803. 		is_glass = is_glass, 
  804. 	} 
  805. 	 
  806. 	if current == true then 
  807. 		Vehicle_cust_color_palette[0].cur_idx = swatches.num_swatches 
  808. 	end 
  809.  
  810. 	swatches.num_swatches = swatches.num_swatches + 1 
  811. 	--[[ 
  812. 	debug_print("vint", "display_name " .. vint_debug_decode_wide_string(display_name) .. "\n") 
  813. 	debug_print("vint", "spec_alpha " .. var_to_string(spec_alpha).. "\n") 
  814. 	debug_print("vint", "spec_col_r " .. var_to_string(spec_col_r).. "\n") 
  815. 	debug_print("vint", "fres_con " .. var_to_string(fres_con).. "\n") 
  816. 	debug_print("vint", "fres_col_r " .. var_to_string(fres_col_r).. "\n") 
  817. 	debug_print("vint", "refl " .. var_to_string(refl) .."\n\n\n")	 
  818. 	 
  819. 	]] 
  820. end 
  821.  
  822. function vehicle_cust_return_palette() 
  823. 	Vehicle_cust_show_region = true 
  824. 	menu_show(Menu_active.parent_menu, MENU_TRANSITION_SWEEP_RIGHT) 
  825. 	audio_play(Menu_sound_back) 
  826. end 
  827.  
  828. function vehicle_cust_update_palette_swatch(swatch) 
  829. 	local icon_h = vint_object_find("icon", swatch.swatch_h) 
  830. 	vint_set_property(icon_h, "visible", true) 
  831. 	vint_set_property(swatch.swatch_h, "visible", true) 
  832. 	 
  833. 	local base_h = vint_object_find("base", icon_h) 
  834. 	local fres_h = vint_object_find("fres", icon_h) 
  835. 	local irr_h  = vint_object_find("irr", icon_h) 
  836. 	local refl_h = vint_object_find("refl", icon_h) 
  837. 	local sky_h  = vint_object_find("sky", icon_h) 
  838. 	local spec_h = vint_object_find("spec", icon_h) 
  839.  
  840. 	--turn off the sky, it blows out the interior color... we turn this on later 
  841. 	vint_set_property(sky_h, "visible", false) 
  842. 	 
  843. 	-- If there's no Fresnel, then hide irridescence. 
  844. 	if swatch.fres_con == 0 then 
  845. 		vint_set_property(irr_h, "visible", false) 
  846. 	end 
  847.  
  848. 	local base_adj = 1.2 
  849. 	local refl_adj = .7 
  850. 	local glass_adj = .5 
  851. 	-- Setup the colors 
  852. 	vint_set_property(base_h, "tint", swatch.base_r * base_adj, swatch.base_g * base_adj, swatch.base_b * base_adj) 
  853. 	if swatch.is_glass == true then 
  854. 		vint_set_property(icon_h, "scale", 0.86, 0.86) 
  855. 		vint_set_property(icon_h, "anchor", -1, -1) 
  856. 		--base, make this dark 
  857. 		vint_set_property(base_h, "image", "ui_menu_veh_glass")  -- dark 
  858. 		vint_set_property(base_h, "alpha", 0.4) 
  859. 		vint_set_property(base_h, "tint", 0, 0, 0) 
  860. 		vint_set_property(base_h, "anchor", 3, 3) 
  861. 		--make the irr channel be the tinted color of glass 
  862. 		vint_set_property(irr_h, "image", "ui_menu_veh_glass")  --normal 
  863. 		vint_set_property(irr_h, "alpha", 1) 
  864. 		vint_set_property(irr_h, "tint", swatch.base_r * base_adj, swatch.base_g * base_adj, swatch.base_b * base_adj) 
  865. 		--make reflection turn on, be normal color to simulate real reflection 
  866. 		vint_set_property(refl_h, "image", "ui_menu_veh_glass") 
  867. 		vint_set_property(refl_h, "alpha", 0.62) 
  868. 		vint_set_property(refl_h, "tint", 1, 1, 1) 
  869. 		--turn off other shit 
  870. 		vint_set_property(fres_h, "visible", false) 
  871. 		vint_set_property(sky_h, "visible", false) 
  872. 		vint_set_property(spec_h, "visible", false) 
  873. 		return 
  874. 	end 
  875. 	 
  876. 	if swatch.is_glass == false then 
  877. 		--reset swatch back from glass to default 
  878. 		vint_set_property(icon_h, "scale", 1, 1) 
  879. 		vint_set_property(refl_h, "alpha", .2) 
  880. 		vint_set_property(icon_h, "anchor", 0, -3) 
  881. 		vint_set_property(base_h, "anchor", 0, 0) 
  882. 		 
  883. 	end 
  884.  
  885. 	vint_set_property(sky_h, "tint", .65 + (swatch.base_r * .55), .65 + (swatch.base_g * .55), .65 + (swatch.base_b * .55)) 
  886. 	vint_set_property(spec_h, "tint", swatch.spec_col_r, swatch.spec_col_g, swatch.spec_col_b) 
  887. 	vint_set_property(irr_h, "tint", swatch.fres_col_r, swatch.fres_col_g, swatch.fres_col_b) 
  888. 	vint_set_property(fres_h, "tint", swatch.fres_col_r, swatch.fres_col_g,  swatch.fres_col_b) 
  889. 	vint_set_property(refl_h, "tint", swatch.base_r * refl_adj, swatch.base_g * refl_adj, swatch.base_b * refl_adj) 
  890. 	 
  891. 	--Setup the alphas 
  892. 	vint_set_property(spec_h, "alpha", swatch.spec_alpha * 0.8) 
  893. 	 
  894. 	-- Interior/glass 
  895. 	if swatch.refl ~= nil then 
  896. 		vint_set_property(sky_h, "visible", true) 
  897. 		vint_set_property(refl_h, "alpha", swatch.refl) 
  898. 		vint_set_property(sky_h, "alpha", swatch.refl * 0.25) 
  899. 		vint_set_property(fres_h, "alpha", swatch.fres_con * 0.56) 
  900. 	end 
  901. 	 
  902. 	 
  903. 	if swatch.fres_con ~= nil then 
  904. 		if swatch.fres_con > 1 or swatch.fres_con == 0.75 then 
  905. 			local fres_adj = (swatch.fres_col_r + swatch.fres_col_g +  swatch.fres_col_b) /3 
  906. 			vint_set_property(refl_h, "alpha", swatch.fres_con * 1.1) 
  907. 			vint_set_property(sky_h, "alpha", fres_adj * 0.55) 
  908. 			vint_set_property(fres_h, "alpha", swatch.fres_con * 0.56) 
  909. 			vint_set_property(refl_h, "tint", swatch.fres_col_r * refl_adj, swatch.fres_col_g * refl_adj, swatch.fres_col_b * refl_adj) 
  910. 		else 
  911. 			-- opaque 
  912. 			if swatch.fres_con == 0 and swatch.spec_alpha < .21  and swatch.spec_alpha > .2 and swatch.refl < 16 then 
  913. 				vint_set_property(refl_h, "alpha", 0) 
  914. 				vint_set_property(sky_h, "alpha", 0) 
  915. 				vint_set_property(fres_h, "alpha", 0) 
  916. 				vint_set_property(spec_h, "alpha", 0) 
  917. 				vint_set_property(irr_h, "alpha", 0) 
  918. 			end 
  919. 			 
  920. 			-- matte  
  921. 			if swatch.fres_con == 0 and swatch.spec_alpha < .21  and swatch.spec_alpha > .2 and swatch.refl < 13 and swatch.refl > 12 then 
  922. 				vint_set_property(refl_h, "alpha", 0) 
  923. 				vint_set_property(sky_h, "alpha", 0) 
  924. 				vint_set_property(fres_h, "alpha", 0) 
  925. 				vint_set_property(irr_h, "alpha", 0) 
  926. 			end 
  927. 		end 
  928. 	end 
  929. 	 
  930. end 
  931.  
  932. -- Menu Navigation / Selection 
  933. function vehicle_cust_nav_new_palette(menu_label, menu_data) 
  934. 	local swatches = menu_data.swatches 
  935. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  936. 	 
  937. 	if idx < swatches.num_swatches then 
  938. 		vehicle_cust_update_footer_color(swatches[idx])	 
  939. 	end 
  940. end 
  941.  
  942. --------------------------- 
  943. ----[ Color Grid Menu ]---- 
  944. function vehicle_cust_build_color_grid(menu_data) 
  945. 	Vehicle_cust_menu = menu_data 
  946. 	 
  947. 	local menu_item = menu_data[0] 
  948. 	menu_item.swatches = { num_swatches = 0 } 
  949. 	menu_item.cur_idx = 0 
  950. 	 
  951. 	-- Make the request to build the menu 
  952. 	vint_dataresponder_request("vcust_populate_color_grid", "vehicle_cust_populate_color_grid", 0, Vehicle_cust_color_slot, Vehicle_cust_palette_choice) 
  953. 	local master_swatch = vint_object_find("swatch_paint", nil, MENU_BASE_DOC_HANDLE) 
  954. 	 
  955. 	menu_grid_show(menu_data, menu_item, master_swatch, true)	 
  956. 	vehicle_cust_build_footer_color(menu_data, menu_item.swatches[menu_item.cur_idx]) 
  957. 	local idx = menu_item.cur_row * menu_item.num_cols + menu_item.cur_col 
  958. 	if idx < menu_item.swatches.num_swatches then 
  959. 		vehicle_cust_update_footer_color(menu_item.swatches[idx])	 
  960. 	end 
  961. 	 
  962. 	Vehicle_cust_menu.btn_tips = Vehicle_cust_btns 
  963. 	btn_tips_update() 
  964. end 
  965.  
  966. function vehicle_cust_populate_color_grid(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) 
  967. 	local swatches = Vehicle_cust_color_select_menu[0].swatches 
  968. 	swatches[swatches.num_swatches] = { 
  969. 		label = display_name, 
  970. 		base_r = base_r, base_g = base_g, base_b = base_b, 								-- Base paint color, used on base 
  971. 		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 
  972. 		spec_alpha = spec_alpha, 																	-- Specular alpha, used on spec 
  973. 		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 
  974. 		fres_con = fres_con, 																		-- Fresnel 'alpha' (contrast), used on fres 
  975. 		refl = refl, 																					-- Reflection color 
  976. 		price = price, 
  977. 		owned = current, 
  978. 		is_glass = is_glass,																			-- Glass or Interior or normal 
  979. 	} 
  980. 	if current == true then 
  981. 		Vehicle_cust_color_select_menu[0].cur_idx = swatches.num_swatches 
  982. 	end 
  983.  
  984. 	swatches.num_swatches = swatches.num_swatches + 1 
  985.  
  986. end 
  987.  
  988. function vehicle_cust_update_color_grid(swatch) 
  989. 	local icon_h = vint_object_find("icon", swatch.swatch_h) 
  990. 	 
  991. 	vint_set_property(icon_h, "visible", true) 
  992. 	vint_set_property(swatch.swatch_h, "visible", true) 
  993. 	 
  994. 	local base_h = vint_object_find("base", icon_h) 
  995. 	local fres_h = vint_object_find("fres", icon_h) 
  996. 	local irr_h  = vint_object_find("irr", icon_h) 
  997. 	local refl_h = vint_object_find("refl", icon_h) 
  998. 	local sky_h  = vint_object_find("sky", icon_h) 
  999. 	local spec_h = vint_object_find("spec", icon_h) 
  1000. 	 
  1001. 	local base_adj = 1.5 
  1002. 	 
  1003. 	-- Setup the colors 
  1004. 	vint_set_property(base_h, "tint", swatch.base_r * base_adj, swatch.base_g * base_adj, swatch.base_b * base_adj) 
  1005. 	 
  1006. 	if swatch.is_glass == true then 
  1007. 		vint_set_property(base_h, "image", "ui_bms_veh_glass") 
  1008. 		vint_set_property(fres_h, "visible", false) 
  1009. 		vint_set_property(irr_h, "visible", false) 
  1010. 		vint_set_property(refl_h, "visible", false) 
  1011. 		vint_set_property(sky_h, "visible", false) 
  1012. 		vint_set_property(spec_h, "visible", false) 
  1013. 		return 
  1014. 	end 
  1015. 	vint_set_property(spec_h, "tint", swatch.spec_col_r, swatch.spec_col_g, swatch.spec_col_b) 
  1016. 	vint_set_property(irr_h, "tint", swatch.spec_col_r, swatch.spec_col_g, swatch.spec_col_b) 
  1017. 	vint_set_property(fres_h, "tint", swatch.fres_col_r, swatch.fres_col_g, swatch.fres_col_b) 
  1018. --	vint_set_property(sky_h, "tint", swatch.fres_col_r, swatch.fres_col_g, swatch.fres_col_b) 
  1019. 	vint_set_property(refl_h, "tint", swatch.fres_col_r, swatch.fres_col_g, swatch.fres_col_b) 
  1020. 	 
  1021. 	--Setup the alphas 
  1022. 	vint_set_property(spec_h, "alpha", swatch.spec_alpha * 0.8) 
  1023. 	vint_set_property(refl_h, "alpha", swatch.refl) 
  1024. 	vint_set_property(sky_h, "alpha",  swatch.refl * 0.2) 
  1025. 	vint_set_property(fres_h, "alpha", swatch.fres_con * 0.5) 
  1026. 	if swatch.fres_con == 0 then 
  1027. 		vint_set_property(irr_h, "visible", false) 
  1028. 	end 
  1029. end 
  1030.  
  1031. -- Selection / Navigation 
  1032. function vehicle_cust_nav_new_color(menu_label, menu_data) 
  1033. 	local swatches = menu_data.swatches 
  1034. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  1035. 	 
  1036. 	if idx < swatches.num_swatches then 
  1037. 		vehicle_cust_update_footer_color(swatches[idx])	 
  1038. 		vcust_preview_color(idx) 
  1039. 	end 
  1040. end 
  1041.  
  1042. Vehicle_cust_color_swatch_to_purchase = { } 
  1043. function vehicle_cust_select_color(menu_label, menu_data) 
  1044. 	local swatches = menu_data.swatches 
  1045. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  1046. 	 
  1047. 	if idx < swatches.num_swatches then 
  1048. 		Vehicle_cust_color_swatch_to_purchase = swatches[idx] 
  1049. 		if Vehicle_cust_color_swatch_to_purchase.price == 0 or Vehicle_cust_color_swatch_to_purchase.owned == true then 
  1050. 			menu_show(Vehicle_cust_color_menu, MENU_TRANSITION_SWEEP_LEFT) 
  1051. 		elseif Style_cluster_player_cash >= Vehicle_cust_color_swatch_to_purchase.price then -- Confirm the purchase if we can afford it	 
  1052. --			local body = "Do you wish to purchase " .. Vehicle_cust_color_swatch_to_purchase.label .. " for $" .. format_cash(Vehicle_cust_color_swatch_to_purchase.price) .. "?" 
  1053. 			local insert = { [0] = Vehicle_cust_color_swatch_to_purchase.label, [1] = format_cash(Vehicle_cust_color_swatch_to_purchase.price) } 
  1054. 			local body = vint_insert_values_in_string("VCUST_PURCHASE_PROMPT", insert) 
  1055. 			local heading = "MENU_TITLE_CONFIRM" 
  1056. 			dialog_box_confirmation(heading, body, "vehicle_cust_color_confirm") 
  1057. 		else 
  1058. 			dialog_box_message("MENU_TITLE_NOTICE", "HUD_SHOP_INSUFFICIENT_FUNDS") 
  1059. 		end 
  1060. 	end 
  1061. end 
  1062.  
  1063. function vehicle_cust_color_confirm(result, action) 
  1064. 	if action ~= DIALOG_ACTION_CLOSE then 
  1065. 		return 
  1066. 	end 
  1067. 	 
  1068. 	if result == 0 then 
  1069. 		if Vehicle_cust_color_swatch_to_purchase.price ~= 0 then 
  1070. 			award_style("veh_comp", Vehicle_cust_color_swatch_to_purchase.price) 
  1071. 		end 
  1072. 		 
  1073. 		vcust_purchase_paint(Vehicle_cust_color_swatch_to_purchase.price)	--	Purchase the currently previewed color 
  1074. 		audio_play(Menu_sound_purchase) 
  1075. 		menu_show(Vehicle_cust_color_menu, MENU_TRANSITION_SWEEP_LEFT) 
  1076. 	end 
  1077. end 
  1078.  
  1079. function vcehicle_cust_revert_color() 
  1080. 	vcust_revert_color(); 
  1081. 	menu_show(Menu_active.parent_menu, MENU_TRANSITION_SWEEP_RIGHT) 
  1082. 	audio_play(Menu_sound_back) 
  1083. end 
  1084.  
  1085. function vehicle_cust_select_color_grid(menu_label, menu_data) 
  1086. 	local swatches = menu_data.swatches 
  1087. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  1088. 	 
  1089. 	if idx < swatches.num_swatches then 
  1090. 		Vehicle_cust_palette_choice = idx 
  1091. 	end 
  1092. 	 
  1093. 	Vehicle_cust_color_select_menu.parent_menu = Menu_active 
  1094. 	menu_show(Vehicle_cust_color_select_menu, MENU_TRANSITION_SWEEP_LEFT) 
  1095. end 
  1096.  
  1097. ---------------------- 
  1098. ----[ Wheel Menu ]---- 
  1099. ---------------------- 
  1100. function vehicle_cust_select_axle(menu_label, menu_data) 
  1101. 	Vehicle_cust_wheel_menu.header_label_str = menu_data.label 
  1102. 	Vehicle_cust_chosen_axle = Vehicle_cust_axle_menu.highlighted_item - 1   -- -1 = both, 0 = front, 1 = rear 
  1103. end 
  1104.  
  1105. function vehicle_cust_revert_wheels() 
  1106. 	vcust_revert_wheels() 
  1107. 	menu_show(Menu_active.parent_menu, MENU_TRANSITION_SWEEP_RIGHT) 
  1108. 	audio_play(Menu_sound_back) 
  1109. end 
  1110.  
  1111. function vehicle_cust_reset_wheels() 
  1112. 	Vehicle_cust_rebuild_wheel_menu = true 
  1113. 	Vehicle_cust_slider_values.rim_size = -1 
  1114. 	Vehicle_cust_slider_values.wheel_size = -1 
  1115. 	Vehicle_cust_slider_values.wheel_width = -1 
  1116. end 
  1117.  
  1118. function vehicle_cust_build_wheel_menu(menu_data) 
  1119. 	Vehicle_cust_menu = menu_data 
  1120. 	vint_dataresponder_request("vcust_populate_wheel_menu", "vehicle_cust_populate_wheel_menu", 0, 7, Vehicle_cust_rebuild_wheel_menu, Vehicle_cust_chosen_axle) -- 7 = VCUST_INTF_POPULATE_WHEEL_MENU 
  1121. 	Vehicle_cust_rebuild_wheel_menu = false 
  1122. 	 
  1123. 	vehicle_cust_build_footer(menu_data) 
  1124. 	vehicle_cust_update_footer_wheels(Vehicle_cust_menu.header_label_str) 
  1125. 	Vehicle_cust_menu.btn_tips = Vehicle_cust_btns 
  1126. end 
  1127.  
  1128. function vehicle_cust_populate_wheel_menu(rim_display_name, tire_index, hubcap_index, spinner_index, current_rim_family, rim_size, 
  1129. 														wheel_size_min, wheel_size_max, wheel_size,  
  1130. 														wheel_width_min, wheel_width_max, wheel_width) 
  1131. 	Vehicle_cust_menu.num_items = 8													 
  1132. 	Vehicle_cust_rim_family = current_rim_family 
  1133. 	Vehicle_cust_rim_index = current_rim_family 
  1134. 	--	Rim Display 
  1135. 	Vehicle_cust_menu[0].info_text_str = rim_display_name 
  1136.  
  1137. 	--	Tire tread display 
  1138. 	local insert_values = { [0] = tire_index + 1, } 
  1139. 	Vehicle_cust_menu[1].info_text_str = vint_insert_values_in_string("VCUST_TIRE_TREAD_NUMBER", insert_values) 
  1140.  
  1141. 	--	Hubcap Display 
  1142. 	Vehicle_cust_menu[2].disabled = false 
  1143. 	if hubcap_index == -2 or hubcap_index == -1 then 
  1144. 		if hubcap_index == -2 then 
  1145. 			Vehicle_cust_menu[2].disabled = true 
  1146. 			Vehicle_cust_menu[2].info_text_str = "STORE_NOT_AVAILABLE" 
  1147. 		else 
  1148. 			Vehicle_cust_menu[2].info_text_str = "COMPONENT_NONE" 
  1149. 		end 
  1150. 	else  
  1151. 		local insert_values = { [0] = hubcap_index + 1, } 
  1152. 		Vehicle_cust_menu[2].info_text_str = vint_insert_values_in_string("VCUST_HUBCAP_NUMBER" , insert_values) 
  1153. 	end 
  1154.  
  1155. 	-- Spinner Display 
  1156. 	Vehicle_cust_menu[3].disabled = false 
  1157. 	if spinner_index == -2 or spinner_index == -1 then 
  1158. 		if spinner_index == -2 then 
  1159. 			Vehicle_cust_menu[3].disabled = true 
  1160. 			Vehicle_cust_menu[3].info_text_str = "STORE_NOT_AVAILABLE" 
  1161. 		else 
  1162. 			Vehicle_cust_menu[3].info_text_str = "COMPONENT_NONE" 
  1163. 		end 
  1164. 	else 
  1165. 		local insert_values = { [0] = spinner_index + 1, } 
  1166. 		Vehicle_cust_menu[3].info_text_str = vint_insert_values_in_string("VCUST_SPINNER_NUMBER", insert_values) 
  1167. 	end 
  1168.  
  1169. 	--	Rim Size display 
  1170. 	local idx = 4 
  1171. 	if rim_size == -10 then 
  1172. 		Vehicle_cust_menu.num_items = Vehicle_cust_menu.num_items - 1 
  1173. 		rim_size_text_slider.cur_value = 0 
  1174. 		rim_size_text_slider.original_val = 0 
  1175. 	else 
  1176. 		rim_size_text_slider.num_values = 5 
  1177. 		rim_size_text_slider.cur_value = rim_size 
  1178. 		rim_size_text_slider.original_val = rim_size_text_slider.cur_value 
  1179. 		for i = 0, rim_size_text_slider.num_values - 1 do		 
  1180. 			rim_size_text_slider[i] = { label = Vehicle_cust_rim_sizes[i] } 
  1181. 		end 
  1182.  
  1183. 		idx = idx + 1 
  1184. 	end  
  1185. 	 
  1186. 	--	Wheel Size Display 
  1187. 	 
  1188. 	if wheel_size_min == wheel_size_max then 
  1189. 		Vehicle_cust_menu.num_items = Vehicle_cust_menu.num_items - 1 
  1190. 		wheel_size_text_slider.cur_value = 0 
  1191. 		wheel_size_text_slider.original_val = 0 
  1192. 	else 
  1193. 		Vehicle_cust_menu[idx] = { label="VCUST_WHEEL_SIZE_OPTION", type=MENU_ITEM_TYPE_TEXT_SLIDER, text_slider_values = wheel_size_text_slider, on_value_update = vehicle_cust_wheel_size_update } 
  1194. 		 
  1195. 		wheel_size_text_slider.num_values = (wheel_size_max - wheel_size_min) + 1 
  1196. 		wheel_size_text_slider.cur_value = wheel_size - wheel_size_min 
  1197. 		wheel_size_text_slider.original_val = wheel_size_text_slider.cur_value  
  1198. 		Vehicle_cust_menu[idx].wheel_size_min = wheel_size_min 
  1199. 		 
  1200. 		local count = 0 
  1201. 		for i = wheel_size_min, wheel_size_max do 
  1202. 			wheel_size_text_slider[count] = { label = i } 
  1203. 			count = count + 1 
  1204. 		end 
  1205. 		 
  1206. 		idx = idx + 1 
  1207. 	end 
  1208. 	 
  1209. 	--	Wheel Width display 
  1210. 	if wheel_width_min == wheel_width_max then 
  1211. 		Vehicle_cust_menu.num_items = Vehicle_cust_menu.num_items - 1 
  1212. 		wheel_width_text_slider.cur_value = 0 
  1213. 		wheel_width_text_slider.original_val = 0 
  1214. 	else 
  1215. 		Vehicle_cust_menu[idx] = { label="VCUST_WHEEL_WIDTH_OPTION", type=MENU_ITEM_TYPE_TEXT_SLIDER,  text_slider_values = wheel_width_text_slider, on_value_update = vehicle_cust_wheel_width_update}  -- on_select 
  1216. 		 
  1217. 		wheel_width_text_slider.num_values = (wheel_width_max - wheel_width_min) + 1 
  1218. 		wheel_width_text_slider.cur_value = wheel_width - wheel_width_min 
  1219. 		wheel_width_text_slider.original_val = wheel_width_text_slider.cur_value  
  1220. 		Vehicle_cust_menu[idx].wheel_width_min = wheel_width_min 
  1221. 		 
  1222. 		local count = 0 
  1223. 		for i = wheel_width_min, wheel_width_max do 
  1224. 			wheel_width_text_slider[count] = { label = i } 
  1225. 			count = count + 1 
  1226. 		end 
  1227. 		 
  1228. 		idx = idx + 1 
  1229. 	end 
  1230. 	 
  1231. 	Vehicle_cust_menu[idx] = { label="VCUST_PURCHASE_OPTION", type=MENU_ITEM_TYPE_SELECTABLE, on_select = vehicle_cust_purchase_wheels } 
  1232. 	  
  1233. end 
  1234.  
  1235. ---------------------------------- 
  1236. -- Wheel/Rim Size Slider Functions 
  1237. function vehicle_cust_rim_profile_update(menu_label, menu_data) 
  1238. 	vcust_preview_rim_sizing(menu_data.text_slider_values.cur_value) 
  1239. 	vehicle_cust_update_footer_wheels(Vehicle_cust_wheel_menu.header_label_str) 
  1240. end 
  1241.  
  1242. function vehicle_cust_wheel_size_update(menu_label, menu_data) 
  1243. 	vcust_preview_wheel_sizing(menu_data.text_slider_values.cur_value + menu_data.wheel_size_min, -1) 
  1244. 	vehicle_cust_update_footer_wheels(Vehicle_cust_wheel_menu.header_label_str) 
  1245. end 
  1246.  
  1247. function vehicle_cust_wheel_width_update(menu_label, menu_data) 
  1248. 	vcust_preview_wheel_sizing(-1, menu_data.text_slider_values.cur_value  + menu_data.wheel_width_min) 
  1249. 	vehicle_cust_update_footer_wheels(Vehicle_cust_wheel_menu.header_label_str) 
  1250. end 
  1251.  
  1252. ----------------------- 
  1253. -- Create Rim menu 
  1254. function vehicle_cust_build_rim_menu(menu_data) 
  1255. 	Vehicle_cust_menu = menu_data 
  1256. 	-- New menu, clear out all items 
  1257. 	Vehicle_cust_menu.num_items = 0	 
  1258. 	Vehicle_cust_menu.header_label_str = "VCUST_RIM_FAMILY_TITLE" 
  1259. 	vint_dataresponder_request("vcust_populate_wheel_menu", "vehicle_cust_populate_rim_menu", 0, 8) -- 8 = VCUST_INTF_POPULATE_RIM_FAMILY_MENU 
  1260. 	Vehicle_cust_menu.btn_tips = Vehicle_cust_btns 
  1261. end 
  1262.  
  1263. function vehicle_cust_populate_rim_menu(display_name, current, id) 
  1264. 	Vehicle_cust_menu[Vehicle_cust_menu.num_items] = { label = display_name, type=MENU_ITEM_TYPE_SELECTABLE, on_select=vehicle_cust_get_rim_grid, id = id } 
  1265. 	if current == 1 then 
  1266. 		Vehicle_cust_menu.highlighted_item = Vehicle_cust_menu.num_items 
  1267. 	end 
  1268. 	Vehicle_cust_menu.num_items = Vehicle_cust_menu.num_items + 1 
  1269. end 
  1270.  
  1271. function vehicle_cust_build_rim_grid(menu_data) 
  1272. 	menu_data.header_label_str = Vehicle_cust_menu[Vehicle_cust_menu.highlighted_item].label 
  1273. 	 
  1274. 	Vehicle_cust_menu = menu_data 
  1275. 	Vehicle_cust_menu.num_items = 1 
  1276. 	Vehicle_cust_menu.on_back = vehicle_cust_revert_rims 
  1277. 	Vehicle_cust_menu.on_post_show = vehicle_cust_finalize_footer 
  1278. 	 
  1279. 	-- Create the grid 
  1280. 	Vehicle_cust_menu[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = vehicle_cust_preview_wheel_changes, on_nav = vehicle_cust_nav_new_rim, 
  1281. 									 row_height = MENU_SWATCH_DEFAULT_ROW_HEIGHT, num_cols = 4, col_width = MENU_SWATCH_DEFAULT_COL_WIDTH, highlight_scale = 1, unhighlight_scale = 0.7} 
  1282. 	Vehicle_cust_menu[0].item_type = "rim" 
  1283. 	 
  1284. 	--	Initilaize the swatches 
  1285. 	local menu_item = Vehicle_cust_menu[0] 
  1286. 	menu_item.swatches = { } 
  1287. 	menu_item.swatches = { num_swatches = 0 } 
  1288. 	menu_item.cur_idx = 0 
  1289.  
  1290. 	-- Make the request to build the menu 
  1291. 	vint_dataresponder_request("vcust_populate_wheel_grid_menu", "vehicle_cust_populate_rim_grid", 0, 9, Vehicle_cust_rim_index) -- 9 = VCUST_INTF_POPULATE_RIM_MENU 
  1292. 	 
  1293. 	-- Show the current rim 
  1294. 	vcust_preview_component(2, 0, Vehicle_cust_rim_index, menu_item.cur_idx) 
  1295. 	 
  1296. 	local idx = menu_item.cur_idx 
  1297. 	menu_grid_show(menu_data, menu_item)	 
  1298. 			 
  1299. 	vehicle_cust_build_footer(menu_data) 
  1300. 	 
  1301. 	local insert_values = { [0] = idx + 1, } 
  1302. 	local rim_name = vint_insert_values_in_string("VCUST_RIM_NUMBER", insert_values) 
  1303. 	vehicle_cust_update_footer_component(rim_name, menu_item.swatches[idx].price, menu_item.swatches[idx].owned) 
  1304. 	Vehicle_cust_menu.btn_tips = Vehicle_cust_btns 
  1305. end 
  1306.  
  1307. function vehicle_cust_populate_rim_grid(display_name, image_crc, price, current) 
  1308. 	local swatches = Vehicle_cust_menu[0].swatches 
  1309. 	swatches[swatches.num_swatches] = {	label = display_name, swatch_crc = image_crc, price = price, owned = false } 
  1310. 	 
  1311. 	if price == 0 then 
  1312. 		swatches[swatches.num_swatches].owned = true 
  1313. 	end 
  1314. 	 
  1315. 	if current == true then 
  1316. 		Vehicle_cust_menu[0].cur_idx = swatches.num_swatches 
  1317. 	end 
  1318. 	 
  1319. 	swatches.num_swatches = swatches.num_swatches + 1 
  1320. end 
  1321.  
  1322. ----------------------- 
  1323. -- Create Tires Menu 
  1324. function vehicle_cust_build_tire_menu(menu_data) 
  1325. 	Vehicle_cust_menu = menu_data 
  1326. 	 
  1327. 	-- New menu, clear out all items 
  1328. 	Vehicle_cust_menu.num_items = 1 
  1329. 	Vehicle_cust_menu.header_label_crc = nil 
  1330. 	Vehicle_cust_menu.header_label_str = "VCUST_TIRES_TITLE" 
  1331. 	Vehicle_cust_menu.on_back = vehicle_cust_revert_tires 
  1332. 	Vehicle_cust_menu.on_post_show = vehicle_cust_finalize_footer 
  1333. 	Vehicle_cust_menu.footer_height = 40 
  1334. 	 
  1335. 	-- Create the grid 
  1336. 	Vehicle_cust_menu[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = vehicle_cust_preview_wheel_changes, on_nav = vehicle_cust_nav_new_tire, 
  1337. 									  row_height = MENU_SWATCH_DEFAULT_ROW_HEIGHT, num_cols = 4, col_width = MENU_SWATCH_DEFAULT_COL_WIDTH, highlight_scale = 1, unhighlight_scale = 0.7} 
  1338. 	Vehicle_cust_menu[0].item_type = "tire" 
  1339. 	 
  1340. 	--	Initilaize the swatches 
  1341. 	local menu_item = Vehicle_cust_menu[0] 
  1342. 	menu_item.swatches = { } 
  1343. 	menu_item.swatches = { num_swatches = 0 } 
  1344. 	menu_item.cur_idx = 0 
  1345.  
  1346. 	-- Make the request to build the menu 
  1347. 	vint_dataresponder_request("vcust_populate_wheel_grid_menu", "vehicle_cust_populate_tire_menu", 0, 10) -- 10 = VCUST_INTF_POPULATE_TIRE_MENU 
  1348.  
  1349. 	local idx = menu_item.cur_idx 
  1350. 	menu_grid_show(menu_data, menu_item)	 
  1351. 	 
  1352. 	vehicle_cust_build_footer(menu_data) 
  1353. 	 
  1354. 	local insert_values = { [0] = idx + 1, } 
  1355. 	local tire_name = vint_insert_values_in_string("VCUST_TIRE_TREAD_NUMBER", insert_values) 
  1356. 	vehicle_cust_update_footer_component(tire_name, menu_item.swatches[idx].price, menu_item.swatches[idx].owned) 
  1357. 	Vehicle_cust_menu.btn_tips = Vehicle_cust_btns 
  1358. end 
  1359.  
  1360. function vehicle_cust_populate_tire_menu(display_name, image_crc, price, current) 
  1361. 	local swatches = Vehicle_cust_menu[0].swatches 
  1362. 	swatches[swatches.num_swatches] = {	label = display_name, swatch_crc = image_crc, price = price, owned = false } 
  1363. 	 
  1364. 	if price == 0 then 
  1365. 		swatches[swatches.num_swatches].owned = true 
  1366. 	end 
  1367. 	 
  1368. 	if current == true then 
  1369. 		Vehicle_cust_menu[0].cur_idx = swatches.num_swatches 
  1370. 	end 
  1371. 	swatches.num_swatches = swatches.num_swatches + 1 
  1372. end 
  1373.  
  1374. ----------------------- 
  1375. -- Create Hubcap Menu 
  1376. function vehicle_cust_build_hubcap_menu(menu_data) 
  1377. 	Vehicle_cust_menu = menu_data 
  1378. 	-- New menu, clear out all items 
  1379. 	Vehicle_cust_menu.num_items = 1 
  1380. 	Vehicle_cust_menu.header_label_crc = nil 
  1381. 	Vehicle_cust_menu.header_label_str = "VCUST_HUBCAPS_TITLE" 
  1382. 	Vehicle_cust_menu.on_back = vehicle_cust_revert_hubcaps 
  1383. 	Vehicle_cust_menu.on_post_show = vehicle_cust_finalize_footer 
  1384. 	Vehicle_cust_menu.footer_height = 40 
  1385. 	 
  1386. 	-- Create the grid 
  1387. 	Vehicle_cust_menu[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = vehicle_cust_preview_wheel_changes, on_nav = vehicle_cust_nav_new_hubcap, 
  1388. 									 row_height = MENU_SWATCH_DEFAULT_ROW_HEIGHT, num_cols = 4, col_width = MENU_SWATCH_DEFAULT_COL_WIDTH, highlight_scale = 1, unhighlight_scale = 0.7} 
  1389. 	Vehicle_cust_menu[0].item_type = "hubcap" 
  1390. 	 
  1391. 	--	Initilaize the swatches 
  1392. 	local menu_item = Vehicle_cust_menu[0] 
  1393. 	menu_item.swatches = { } 
  1394. 	menu_item.swatches = { num_swatches = 0 } 
  1395. 	menu_item.cur_idx = 0 
  1396.  
  1397. 	-- Make the request to build the menu 
  1398. 	vint_dataresponder_request("vcust_populate_wheel_grid_menu", "vehicle_cust_populate_hubcap_menu", 0, 11) -- 11 = VCUST_INTF_POPULATE_HUBCAP_MENU 
  1399.  
  1400. 	local idx = menu_item.cur_idx 
  1401. 	menu_grid_show(menu_data, menu_item)	 
  1402. 	vehicle_cust_build_footer(menu_data) 
  1403. 	vehicle_cust_update_footer_component(menu_item.swatches[idx].label, menu_item.swatches[idx].price, menu_item.swatches[idx].owned)	 
  1404. 	 
  1405. 	Vehicle_cust_menu.btn_tips = Vehicle_cust_btns 
  1406. 	btn_tips_update() 
  1407. end 
  1408.  
  1409. function vehicle_cust_populate_hubcap_menu(display_name, image_crc, price, current) 
  1410. 	local swatches = Vehicle_cust_menu[0].swatches 
  1411. 	 
  1412. 	swatches[swatches.num_swatches]	= { price = price, owned = false } 
  1413. 	 
  1414. 	if price == 0 then 
  1415. 		swatches[swatches.num_swatches].owned = true 
  1416. 	end 
  1417. 	 
  1418. 	if image_crc == 0 then 
  1419. 		swatches[swatches.num_swatches].swatch_str = "ui_menu_none" 
  1420. 		swatches[swatches.num_swatches].label = "COMPONENT_NONE" 
  1421. 	else  
  1422. 		swatches[swatches.num_swatches].swatch_crc = image_crc 
  1423. 		 
  1424. 		local insert_values = {  } 
  1425. 		if swatches[0].swatch_str == "ui_menu_none" then 
  1426. 			insert_values[0] = swatches.num_swatches 
  1427. 		else 
  1428. 			insert_values[0] = swatches.num_swatches + 1 
  1429. 		end 
  1430.  
  1431. 		swatches[swatches.num_swatches].label = vint_insert_values_in_string("VCUST_HUBCAP_NUMBER", insert_values) 
  1432. 	end 
  1433. 	 
  1434. 	if current == true then 
  1435. 		Vehicle_cust_menu[0].cur_idx = swatches.num_swatches 
  1436. 	end 
  1437. 	 
  1438. 	swatches.num_swatches = swatches.num_swatches + 1 
  1439. end 
  1440.  
  1441. ----------------------- 
  1442. -- Create Spinners Menu 
  1443. function vehicle_cust_build_spinners_menu(menu_data) 
  1444. 	Vehicle_cust_menu = menu_data 
  1445. 	-- New menu, clear out all items 
  1446. 	Vehicle_cust_menu.num_items = 1 
  1447. 	Vehicle_cust_menu.header_label_crc = nil 
  1448. 	Vehicle_cust_menu.header_label_str = "VCUST_SPINNERS_TITLE" 
  1449. 	Vehicle_cust_menu.on_back = vehicle_cust_revert_spinners 
  1450. 	Vehicle_cust_menu.on_post_show = vehicle_cust_finalize_footer 
  1451. 	Vehicle_cust_menu.footer_height = 40 
  1452.  
  1453. 	-- Create the grid 
  1454. 	Vehicle_cust_menu[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = vehicle_cust_preview_wheel_changes, on_nav = vehicle_cust_nav_new_spinner, 
  1455. 									 row_height = MENU_SWATCH_DEFAULT_ROW_HEIGHT, num_cols = 4, col_width = MENU_SWATCH_DEFAULT_COL_WIDTH, highlight_scale = 1, unhighlight_scale = 0.7} 
  1456. 	Vehicle_cust_menu[0].item_type = "hubcap" -- Although these are spinners, you can't have both hubcaps and spinners 
  1457. 	 
  1458. 	--	Initilaize the swatches 
  1459. 	local menu_item = Vehicle_cust_menu[0] 
  1460. 	menu_item.swatches = { } 
  1461. 	menu_item.swatches = { num_swatches = 0 } 
  1462. 	menu_item.cur_idx = 0 
  1463.  
  1464. 	-- Make the request to build the menu 
  1465. 	vint_dataresponder_request("vcust_populate_wheel_grid_menu", "vehicle_cust_populate_spinners_menu", 0, 12) -- 12 = VCUST_INTF_POPULATE_SPINNERS_MENU 
  1466. 	 
  1467. 	local idx = menu_item.cur_idx 
  1468. 	menu_grid_show(menu_data, menu_item)	 
  1469. 	 
  1470. 	vehicle_cust_build_footer(menu_data) 
  1471. 	vehicle_cust_update_footer_component(menu_item.swatches[idx].label, menu_item.swatches[idx].price, menu_item.swatches[idx].owned)	 
  1472. 	Vehicle_cust_menu.btn_tips = Vehicle_cust_btns 
  1473. end 
  1474.  
  1475. function vehicle_cust_populate_spinners_menu(display_name, image_crc, price, current) 
  1476. 	local swatches = Vehicle_cust_menu[0].swatches 
  1477. 	 
  1478. 	swatches[swatches.num_swatches]	= { price = price, owned = false } 
  1479. 	 
  1480. 	if price == 0 then  
  1481. 		swatches[swatches.num_swatches].owned = true 
  1482. 	end 
  1483. 	 
  1484. 	if image_crc == 0 then 
  1485. 		swatches[swatches.num_swatches].swatch_str = "ui_menu_none" 
  1486. 		swatches[swatches.num_swatches].label = "COMPONENT_NONE" 
  1487. 	else 
  1488. 		 
  1489. 		swatches[swatches.num_swatches].swatch_crc = image_crc 
  1490. 		local insert_values = { } 
  1491. 		if swatches[0].label == "COMPONENT_NONE" then 
  1492. 			insert_values[0] = swatches.num_swatches 
  1493. 		else 
  1494. 			insert_values[0] = swatches.num_swatches + 1 
  1495. 		end 
  1496. 		 
  1497. 		swatches[swatches.num_swatches].label = vint_insert_values_in_string("VCUST_SPINNER_NUMBER", insert_values) 
  1498. 	end 
  1499. 	 
  1500. 	if current == true then 
  1501. 		Vehicle_cust_menu[0].cur_idx = swatches.num_swatches 
  1502. 	end 
  1503. 	 
  1504. 	 
  1505. 	 
  1506. 	swatches.num_swatches = swatches.num_swatches + 1 
  1507. end 
  1508.  
  1509. ---------------------------- 
  1510. -- Preview Wheels as a whole 
  1511. function vehicle_cust_preview_wheel_changes(menu_label, menu_data) 
  1512. 	local swatches = menu_data.swatches 
  1513. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  1514. 	if idx < swatches.num_swatches then 
  1515. 		if menu_data.item_type == "rim" then 
  1516. 			Vehicle_cust_rim_price = swatches[idx].price 
  1517. 		elseif menu_data.item_type == "tire" then 
  1518. 			Vehicle_cust_tire_price = swatches[idx].price 
  1519. 		elseif menu_data.item_type == "hubcap" then 
  1520. 			Vehicle_cust_hubcap_price = swatches[idx].price 
  1521. 		end 
  1522. 	end 
  1523. 	menu_show(Vehicle_cust_wheel_menu, MENU_TRANSITION_SWEEP_RIGHT) 
  1524. end 
  1525.  
  1526. ------------------------------- 
  1527. -- Purchase the wheels for real 
  1528. function vehicle_cust_purchase_wheels(menu_label, menu_data) 
  1529. 	if Vehicle_cust_wheel_price == 0 then 
  1530. 		vcust_purchase_wheels(Vehicle_cust_wheel_price) 
  1531. 		menu_show(Vehicle_cust_axle_menu.parent_menu, MENU_TRANSITION_SWEEP_LEFT) 
  1532. 	elseif Style_cluster_player_cash >= Vehicle_cust_wheel_price then -- Confirm the purchase if we can afford it	 
  1533. 		Vehicle_cust_style_to_award = Vehicle_cust_wheel_price 
  1534.  
  1535. 		local insert = { [0] = format_cash(Vehicle_cust_wheel_price) } 
  1536. 		local body = vint_insert_values_in_string("VCUST_PURCHASE_WHEELS_PROMPT", insert) 
  1537. 		local heading = "MENU_TITLE_CONFIRM" 
  1538. 		dialog_box_confirmation(heading, body, "vehicle_cust_purchase_wheels_confirm") 
  1539. 	else 
  1540. 		dialog_box_message("MENU_TITLE_NOTICE", "HUD_SHOP_INSUFFICIENT_FUNDS") 
  1541. 	end 
  1542. end 
  1543.  
  1544.  
  1545. -- Make the purchase for realz 
  1546. function vehicle_cust_purchase_wheels_confirm(result, action) 
  1547. 	if action ~= DIALOG_ACTION_CLOSE then 
  1548. 		return 
  1549. 	end 
  1550. 	 
  1551. 	if result == 0 then 
  1552. 		if Vehicle_cust_style_to_award ~= 0 then 
  1553. 			award_style("veh_comp", Vehicle_cust_style_to_award) 
  1554. 		end 
  1555. 				 
  1556. 		Vehicle_cust_rim_price = 0 
  1557. 		Vehicle_cust_tire_price	= 0 
  1558. 		Vehicle_cust_hubcap_price = 0 
  1559.  
  1560. 		vcust_purchase_wheels(Vehicle_cust_wheel_price) 
  1561. 		audio_play(Menu_sound_purchase) 
  1562. 		menu_show(Vehicle_cust_axle_menu.parent_menu, MENU_TRANSITION_SWEEP_LEFT) 
  1563. 	end 
  1564. end 
  1565.  
  1566. ----------------------- 
  1567. -- Get/Show each menu 
  1568. function vehicle_cust_get_rims(menu_label, menu_data) 
  1569. 	Vehicle_cust_menu_c.parent_menu = Menu_active 
  1570. 	Vehicle_cust_menu_c.on_show = vehicle_cust_build_rim_menu 
  1571. 	Vehicle_cust_menu_c.on_nav = nil 
  1572. 	Vehicle_cust_menu_c.on_post_show = nil 
  1573. 	Vehicle_cust_menu_c.footer_height = 0 
  1574. 	 
  1575. 	menu_show(Vehicle_cust_menu_c, MENU_TRANSITION_SWEEP_LEFT) 
  1576. end 
  1577.   
  1578. function vehicle_cust_get_rim_grid(menu_label, menu_data) 
  1579. 	Vehicle_cust_menu_d.parent_menu = Vehicle_cust_menu_c 
  1580. 	Vehicle_cust_menu_d.on_show = vehicle_cust_build_rim_grid 
  1581. 	Vehicle_cust_menu_d.footer_height = 40 
  1582. 	Vehicle_cust_menu_d.on_nav = nil 
  1583. 	 
  1584. 	Vehicle_cust_rim_family =	menu_data.id 
  1585. 	Vehicle_cust_rim_index = Vehicle_cust_menu.highlighted_item 
  1586. 	if Vehicle_cust_current_peg ~= "" then 
  1587. 		peg_unload(Vehicle_cust_current_peg) 
  1588. 		Vehicle_cust_current_peg = "" 
  1589. 	end 
  1590. 	Vehicle_cust_current_peg = VEHICLE_CUST_RIM_PEG .. Vehicle_cust_rim_family + 1 
  1591. 	peg_load(Vehicle_cust_current_peg) 
  1592. 	menu_show(Vehicle_cust_menu_d, MENU_TRANSITION_SWEEP_LEFT) 
  1593. end 
  1594.  
  1595. function vehicle_cust_get_tires(menu_label, menu_data) 
  1596. 	Vehicle_cust_menu_d.parent_menu = Menu_active 
  1597. 	Vehicle_cust_menu_d.on_show = vehicle_cust_build_tire_menu 
  1598. 	Vehicle_cust_menu_d.on_nav = vehicle_cust_nav_new_tire 
  1599. 		 
  1600. 	if Vehicle_cust_current_peg ~= "" then 
  1601. 		peg_unload(Vehicle_cust_current_peg) 
  1602. 		Vehicle_cust_current_peg = "" 
  1603. 	end 
  1604. 	Vehicle_cust_current_peg = VEHICLE_CUST_TIRE_PEG  
  1605. 	peg_load(Vehicle_cust_current_peg) 
  1606.  
  1607. 	menu_show(Vehicle_cust_menu_d, MENU_TRANSITION_SWEEP_LEFT) 
  1608. end 
  1609.  
  1610. function vehicle_cust_get_hubcaps(menu_label, menu_data) 
  1611. 	Vehicle_cust_menu_d.parent_menu = Menu_active 
  1612. 	Vehicle_cust_menu_d.on_show = vehicle_cust_build_hubcap_menu 
  1613. 	Vehicle_cust_menu_d.on_nav = vehicle_cust_nav_new_hubcap 
  1614. 	 
  1615. 	if Vehicle_cust_current_peg ~= "" then 
  1616. 		peg_unload(Vehicle_cust_current_peg) 
  1617. 		Vehicle_cust_current_peg = "" 
  1618. 	end 
  1619. 	Vehicle_cust_current_peg = VEHICLE_CUST_HUBCAP_PEG 
  1620. 	peg_load(Vehicle_cust_current_peg) 
  1621.  
  1622. 	menu_show(Vehicle_cust_menu_d, MENU_TRANSITION_SWEEP_LEFT) 
  1623. end 
  1624.  
  1625. function vehicle_cust_get_spinners(menu_label, menu_data) 
  1626. 	Vehicle_cust_menu_d.parent_menu = Menu_active 
  1627. 	Vehicle_cust_menu_d.on_show = vehicle_cust_build_spinners_menu 
  1628. 	Vehicle_cust_menu_d.on_nav = vehicle_cust_nav_new_spinner 
  1629. 	 
  1630. 	if Vehicle_cust_current_peg ~= "" then 
  1631. 		peg_unload(Vehicle_cust_current_peg) 
  1632. 		Vehicle_cust_current_peg = "" 
  1633. 	end 
  1634. 	 
  1635. 	Vehicle_cust_current_peg = VEHICLE_CUST_SPINNER_PEG .. Vehicle_cust_rim_family + 1 
  1636. 	peg_load(Vehicle_cust_current_peg) 
  1637.  
  1638. 	menu_show(Vehicle_cust_menu_d, MENU_TRANSITION_SWEEP_LEFT) 
  1639. end 
  1640.  
  1641. ----------------------- 
  1642. -- Preview wheel choices 
  1643. function vehicle_cust_nav_new_rim(menu_label, menu_data) 
  1644. 	local swatches = menu_data.swatches 
  1645. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  1646. 	if idx < swatches.num_swatches then 
  1647. 		local insert_values = { [0] = idx + 1, } 
  1648. 		local rim_name = vint_insert_values_in_string("VCUST_RIM_NUMBER", insert_values) 
  1649. 		vehicle_cust_update_footer_component(rim_name, swatches[idx].price, swatches[idx].owned) 
  1650. 		vcust_preview_component(2, 0, Vehicle_cust_rim_index, idx) 
  1651. 	end	 
  1652. end 
  1653.  
  1654. function vehicle_cust_nav_new_tire(menu_label, menu_data) 
  1655. 	local swatches = menu_data.swatches 
  1656. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  1657. 	if idx < swatches.num_swatches then 
  1658. 		vcust_preview_component(2, 1, idx) 
  1659. 		local insert_values = { [0] = idx + 1, } 
  1660. 		local tire_name = vint_insert_values_in_string("VCUST_TIRE_TREAD_NUMBER", insert_values) 
  1661. 		vehicle_cust_update_footer_component(tire_name, swatches[idx].price, swatches[idx].owned)	 
  1662. 	end 
  1663. end 
  1664.  
  1665. function vehicle_cust_nav_new_hubcap(menu_label, menu_data) 
  1666. 	local swatches = menu_data.swatches 
  1667. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  1668. 	if idx < swatches.num_swatches then 
  1669. 		vcust_preview_component(2, 2, idx) 
  1670. 		vehicle_cust_update_footer_component(swatches[idx].label, swatches[idx].price, swatches[idx].owned)	 
  1671. 	end 
  1672. end 
  1673.  
  1674. function vehicle_cust_nav_new_spinner(menu_label, menu_data) 
  1675. 	local swatches = menu_data.swatches 
  1676. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  1677. 	if idx < swatches.num_swatches then 
  1678. 		vcust_preview_component(2, 3, idx) 
  1679. 		vehicle_cust_update_footer_component(swatches[idx].label, swatches[idx].price, swatches[idx].owned)	 
  1680. 	end 
  1681. end 
  1682.  
  1683. ----------------------- 
  1684. -- Revert wheel choices 
  1685. function vehicle_cust_revert_rims(menu_data) 
  1686. 	vcust_revert_wheel_choice(0) 
  1687. 	menu_show(Menu_active.parent_menu, MENU_TRANSITION_SWEEP_RIGHT) 
  1688. 	audio_play(Menu_sound_back) 
  1689. end 
  1690.  
  1691. function vehicle_cust_revert_tires(menu_data) 
  1692. 	vcust_revert_wheel_choice(1) 
  1693. 	menu_show(Menu_active.parent_menu, MENU_TRANSITION_SWEEP_RIGHT) 
  1694. 	audio_play(Menu_sound_back) 
  1695. end 
  1696.  
  1697. function vehicle_cust_revert_hubcaps(menu_data) 
  1698. 	vcust_revert_wheel_choice(2) 
  1699. 	menu_show(Menu_active.parent_menu, MENU_TRANSITION_SWEEP_RIGHT) 
  1700. 	audio_play(Menu_sound_back) 
  1701. end	 
  1702.  
  1703. function vehicle_cust_revert_spinners(menu_data) 
  1704. 	vcust_revert_wheel_choice(3) 
  1705. 	menu_show(Menu_active.parent_menu, MENU_TRANSITION_SWEEP_RIGHT) 
  1706. 	audio_play(Menu_sound_back) 
  1707. end 
  1708.  
  1709. --------------- 
  1710. -- MENU DATA -- 
  1711. --------------- 
  1712. Vehicle_cust_btns = { 
  1713. 	a_button 	= 	{ label = "CONTROL_SELECT", 	enabled = btn_tips_default_a, }, 
  1714. 	b_button 	= 	{ label = "MENU_BACK", 		enabled = btn_tips_default_a, }, 
  1715. 	right_stick =  	{ label = "CONTROL_ZOOM_AND_ROTATE", 	enabled = true }, 
  1716. } 
  1717.  
  1718. Vehicle_cust_btns_top = { 
  1719. 	a_button 	= 	{ label = "CONTROL_SELECT", 	enabled = btn_tips_default_a, }, 
  1720. 	b_button 	= 	{ label = "CONTROL_RESUME", 	enabled = btn_tips_default_a, }, 
  1721. 	right_stick =  	{ label = "CONTROL_ZOOM_AND_ROTATE", 	enabled = true }, 
  1722. } 
  1723. -------[ Menus ]------- 
  1724. Vehicle_cust_menu_a = { 
  1725. 	on_show = vehicle_cust_build_menu, 
  1726. 	on_back = vehicle_cust_exit, 
  1727. } 
  1728.  
  1729. Vehicle_cust_menu_b = { 
  1730. 	on_show = vehicle_cust_build_menu, 
  1731. 	on_back = vehicle_cust_exit, 
  1732. } 
  1733.  
  1734. Vehicle_cust_menu_c = { 
  1735. 	on_release = vehicle_cust_release, 
  1736.  
  1737. } 
  1738.  
  1739. Vehicle_cust_menu_d = { 
  1740. 	on_release = vehicle_cust_release, 
  1741. } 
  1742.  
  1743. Vehicle_cust_region_menu = { 
  1744. 	on_release = vehicle_cust_release, 
  1745. 	 
  1746. } 
  1747. ----[ Wheel Menus ]---- 
  1748. rim_size_text_slider	=	{ num_values = 0, cur_value = 0, } 
  1749. wheel_size_text_slider	= 	{ num_values = 0, cur_value = 0, } 
  1750. wheel_width_text_slider	=	{ num_values = 0, cur_value = 0, } 
  1751.  
  1752.  
  1753. Vehicle_cust_wheel_menu = { 
  1754. 	header_label_str = "VCUST_WHEELS_TITLE", 
  1755. 	on_show = vehicle_cust_build_wheel_menu, 
  1756. 	on_back = vehicle_cust_revert_wheels, 
  1757. 	on_release = vehicle_cust_release, 
  1758. 	on_post_show = vehicle_cust_finalize_footer, 
  1759. 	 
  1760. 	num_items = 8, 
  1761. 	[0] = { label="VCUST_RIM_STYLE_OPTION", type=MENU_ITEM_TYPE_INFO_BOX, on_select = vehicle_cust_get_rims, info_text_str = "temp" }, 
  1762. 	[1] = { label="VCUST_TIRE_TREAD_OPTION", type=MENU_ITEM_TYPE_INFO_BOX, on_select = vehicle_cust_get_tires, info_text_str = "temp" }, 
  1763. 	[2] = { label="VCUST_HUBCAP_OPTION", type=MENU_ITEM_TYPE_INFO_BOX, on_select = vehicle_cust_get_hubcaps, info_text_str = "temp" }, 
  1764. 	[3] = { label="VCUST_SPINNER_OPTION", type=MENU_ITEM_TYPE_INFO_BOX, on_select = vehicle_cust_get_spinners, info_text_str = "temp" }, 
  1765. 	[4] = { label="VCUST_RIM_SIZE_OPTION", type=MENU_ITEM_TYPE_TEXT_SLIDER, text_slider_values = rim_size_text_slider, on_value_update = vehicle_cust_rim_profile_update},  
  1766. 	[5] = { label="VCUST_WHEEL_SIZE_OPTION", type=MENU_ITEM_TYPE_TEXT_SLIDER, text_slider_values = wheel_size_text_slider, on_value_update = vehicle_cust_wheel_size_update}, -- on_select 
  1767. 	[6] = { label="VCUST_WHEEL_WIDTH_OPTION", type=MENU_ITEM_TYPE_TEXT_SLIDER, text_slider_values = wheel_width_text_slider, on_value_update = vehicle_cust_wheel_width_update}, -- on_select 
  1768. 	[7] = { label="VCUST_PURCHASE_OPTION", type=MENU_ITEM_TYPE_SELECTABLE, on_select = vehicle_cust_purchase_wheels }, 
  1769. 	 
  1770. 	footer_height = 40, 
  1771. } 
  1772.  
  1773. Vehicle_cust_axle_menu = { 
  1774. 	header_label_str = "VCUST_AXLES_TITLE", 
  1775. 	num_items = 3, 
  1776. 	on_show = vehicle_cust_reset_wheels, 
  1777. 	 
  1778. 	[0] = { label="VCUST_BOTH_AXLES_OPTION", type=MENU_ITEM_TYPE_SUB_MENU, sub_menu = Vehicle_cust_wheel_menu, on_select = vehicle_cust_select_axle }, 
  1779. 	[1] = { label="VCUST_FRONT_AXLE_OPTION", type=MENU_ITEM_TYPE_SUB_MENU, sub_menu = Vehicle_cust_wheel_menu, on_select = vehicle_cust_select_axle }, 
  1780. 	[2] = { label="VCUST_REAR_AXLE_OPTION" , type=MENU_ITEM_TYPE_SUB_MENU, sub_menu = Vehicle_cust_wheel_menu, on_select = vehicle_cust_select_axle }, 
  1781. 	 
  1782. 	btn_tips = Vehicle_cust_btns, 
  1783. } 
  1784.  
  1785. ----[ Color Menus ]---- 
  1786. Vehicle_cust_color_palette = { 
  1787. 	header_label_str = "VCUST_COLOR_PALETTE_TITLE", 
  1788. 	on_show = vehicle_cust_build_palette, 
  1789. 	on_back = vehicle_cust_return_palette, 
  1790. 	on_post_show = vehicle_cust_finalize_footer, 
  1791. 	on_release = vehicle_cust_release,  
  1792. 	num_items = 1, 
  1793. 	[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = vehicle_cust_select_color_grid, on_nav = vehicle_cust_nav_new_palette, 
  1794. 		update_swatch=vehicle_cust_update_palette_swatch, row_height = 50, num_cols = 6, col_width = 64, highlight_scale = 1, unhighlight_scale = 0.77}, 
  1795.  
  1796. 	footer_height = 40, 
  1797. 	btn_tips = Vehicle_cust_btns, 
  1798. } 
  1799.  
  1800. Vehicle_cust_color_select_menu = { 
  1801. 	header_label_str = "VCUST_COLOR_GRID_TITLE", 
  1802. 	on_show = vehicle_cust_build_color_grid, 
  1803. 	on_back = vcehicle_cust_revert_color, 
  1804. 	on_release = vehicle_cust_color_select_release,  
  1805. 	on_post_show = vehicle_cust_finalize_footer, 
  1806. 	 
  1807. 	num_items = 1, 
  1808. 	[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = vehicle_cust_select_color, on_nav = vehicle_cust_nav_new_color, 
  1809. 		update_swatch=vehicle_cust_update_palette_swatch, row_height = 56, num_cols = 6, col_width = 59, highlight_scale = 1, unhighlight_scale = 0.7}, 
  1810.  
  1811. 	footer_height = 40, 
  1812. 	btn_tips = Vehicle_cust_btns, 
  1813. } 
  1814.  
  1815. -----[ Horizontal Menu ]------ 
  1816. Vehicle_cust_horz_menu = { 
  1817. 	current_selection = 0, 
  1818. 	num_items = 0, 
  1819. 	on_nav = vehicle_cust_nav_horz_menu, 
  1820. } 
  1821.  
  1822. -----[ Specifics ]----- 
  1823. Vehicle_cust_menu_ops = { 
  1824. 	num_ops = 7, 
  1825. 	--	VCUST_INTF_TYPE_CATEGORY 
  1826. 	[0] = { on_select = vehicle_cust_select_category, type = MENU_ITEM_TYPE_SUB_MENU , sub_menu = Vehicle_cust_menu_c }, 
  1827. 	-- VCUST_INTF_TYPE_SLOT 
  1828. 	[1] = { on_nav = vehicle_cust_nav_slot, on_select = vehicle_cust_select_slot, type = MENU_ITEM_TYPE_SUB_MENU, sub_menu = Vehicle_cust_menu_c }, 
  1829. 	-- VCUST_INTF_TYPE_COMPONENT 
  1830. 	[2] = { on_select = vehicle_cust_select_component , type = VEHICLE_COMPONENT_LINE, sub_menu = Vehicle_cust_menu_c }, 
  1831. 	-- VCUST_INTF_TYPE_COLOR_REGION 
  1832. 	[3] = { on_nav = vehicle_cust_nav_slot, on_select = vehicle_cust_select_region, type = MENU_ITEM_TYPE_SUB_MENU , sub_menu = Vehicle_cust_region_menu },	 
  1833. 	-- VCUST_INTF_TYPE_COLOR_PALETTE 
  1834. 	[4] = { on_select = vehicle_cust_select_advanced_region, type = MENU_ITEM_TYPE_SUB_MENU , sub_menu = Vehicle_cust_color_palette },	 
  1835. 	--	VCUST_INTF_TYPE_COLOR_GRID 
  1836. 	[5] = { on_select = nil, type = MENU_ITEM_TYPE_SUB_MENU , sub_menu = Vehicle_cust_color_select_menu},	 
  1837. 	-- VCUST_INTF_TYPE_WHEEL 
  1838. 	[6] = { on_select = nil, type = MENU_ITEM_TYPE_SUB_MENU, sub_menu = Vehicle_cust_axle_menu}, 
  1839. 		 
  1840. } 
  1841.  
  1842. Vehicle_menu_controls = { 
  1843. 	[VEHICLE_COMPONENT_LINE] = { 
  1844. 		on_show 		=	vehicle_component_line_on_show, 
  1845. 		on_select 		=	menu_control_on_select, 
  1846. 		on_nav_up		=	vehicle_component_line_nav_up, 
  1847. 		on_nav_down		=	vehicle_component_line_nav_down, 
  1848. 		on_release		=  vehicle_component_line_on_release, 
  1849. 		get_width		=	vehicle_component_line_get_width, 
  1850. --		get_height	=	vehicle_component_line_get_height, 	 
  1851. 	}, 
  1852. }