./store_gang.lua

  1.  
  2. SCALE_FONT_STORE_GANG_LIST = 0.8 
  3.  
  4. Store_gang_doc_handle = -1 
  5.  
  6. -- Hint bar and store header vdo's. 
  7. local Store_logo1 
  8. local Store_logo2 
  9. local Not_popup_grp 
  10. local Reward_image 
  11.  
  12. -- We used this as a reference to the current submenu we are building. 
  13. local Store_gang_building_menu = {} 
  14.  
  15. -- Keeps track of the text tag crc for the category the player chose. 
  16. local Store_gang_category_label_crc = 0 
  17.  
  18. -- Slot id (0-3) that is currently the "front" character.  Entering interface starts at 0. 
  19. local Store_gang_current_slot = 0 
  20.  
  21. local Store_gang_slot_info = {} 
  22.  
  23. -- Similar to character slots, but for vehicles.  Entering interface starts at 0. 
  24. local Store_gang_current_vehicle_slot = 0 
  25.  
  26. local Store_gang_loaded_from_crib = false 
  27.  
  28. local Hint_bar_mouse_input_tracker 
  29. local Game_platform 
  30.  
  31. local Store_gang_input_allowed = false 
  32.  
  33. ---------------------------------------------------------------------------  
  34. -- Initialize Gang Store (Customization) 
  35. --------------------------------------------------------------------------- 
  36. function store_gang_init() 
  37.  
  38. 	Store_common_current_highlight_color = COLOR_STORE_REWARDS_PRIMARY 
  39.  
  40. 	Game_platform = game_get_platform() 
  41.  
  42. 	Store_gang_loaded_from_crib = store_common_crib_is_loaded() 
  43.  
  44. 	Store_gang_doc_handle = vint_document_find("store_gang") 
  45. 	 
  46. 	-- Set up some callbacks for the common store script 
  47. 	Store_common_allow_input_cb	= store_gang_allow_input 
  48. 	Store_common_populate_list_cb = store_gang_populate_list 
  49. 	Store_common_exit_cb				= store_gang_exit 
  50.  
  51. 	-- Subscribe to the button presses we need, Input_tracker is created in store_common.lua 
  52. 	Input_tracker:subscribe(false) 
  53.  
  54. 	--Setup Button Hints 
  55. 	local hint_data = { 
  56. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"},	 
  57. 	} 
  58. 	Store_common_hint_bar:set_hints(hint_data)  
  59. 	Store_common_hint_bar:set_visible(true)	 
  60. 	 
  61. 	if game_is_active_input_gamepad() then 
  62. 		local hint_rotate_data = { 
  63. 			{CTRL_BUTTON_RS, "CONTROL_ROTATE"}, 
  64. 		} 
  65. 		Store_common_rotate_hint:set_hints(hint_rotate_data) 	 
  66. 		Store_common_rotate_hint:set_visible(true) 
  67. 	end 
  68. 	character_enable_mouse_drag(true) 
  69.  
  70. 	-- Initialize mouse input trackers and create mouse tracker for the hint bar 
  71. 	if Game_platform == "PC" then 
  72. 		Mouse_input_tracker:subscribe(false) 
  73. 		 
  74. 		Hint_bar_mouse_input_tracker = Vdo_input_tracker:new() 
  75. 		Store_common_hint_bar:add_mouse_inputs("store_gang", Hint_bar_mouse_input_tracker) 
  76. 		Hint_bar_mouse_input_tracker:subscribe(true) 
  77. 	end 
  78. 	 
  79. 	-- Set Store Header colors 
  80. 	Store_header:set_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY, COLOR_STORE_REWARDS_TERTIARY) 
  81. 	Store_header:set_visible(true) 
  82. 	 
  83. 	Store_header:push_title(nil, "GANG_CUSTOMIZATION") 
  84.  
  85. 	Active_list:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY)			 
  86. 		 
  87. 	-- Everything that is not in the popup so we can fade it when the popup is active 
  88. 	Not_popup_grp = Vdo_base_object:new("not_popup_grp", 0, Store_common_doc_handle) 
  89. 	 
  90. 	-- Setup purchase popup 
  91. 	Store_common_popup:set_visible(false) 
  92. 	Store_common_popup:set_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY, COLOR_STORE_REWARDS_TERTIARY) 
  93. 	Store_common_popup:set_size(STORE_COMMON_LIST_SIZE, (LIST_BUTTON_HEIGHT * 5) + (LIST_BUTTON_SPACE * 5)) 
  94. 	 
  95. 	-- Setup Color grid 
  96. 	Store_common_color_grid:set_visible(false) 
  97. 	 
  98. 	if Store_gang_loaded_from_crib then 
  99. 		-- crib specific stuff 
  100. 		local store_main_grp = Vdo_base_object:new("store_main_grp", 0, Store_common_doc_handle) 
  101. 		store_main_grp:set_anchor(0,0) 
  102. 		 
  103. 		bg_saints_set_type(BG_TYPE_CENTER,true,1280) 
  104. 		bg_saints_set_background(false) 
  105. 		 
  106. 		-- animate in ui for gang customization (shared by all stores) 
  107. 		local store_gang_in_anim = Vdo_anim_object:new("store_common_in_anim", 0, Store_common_doc_handle) 
  108. 		local end_event_twn = Vdo_tween_object:new("end_event_twn", store_gang_in_anim.handle, Store_common_doc_handle) 
  109. 		end_event_twn:set_end_event("store_unlock_controls") 
  110. 		 
  111. 		local twn_h = vint_object_find("store_megalist_grp_twn",store_gang_in_anim.handle,Store_common_doc_handle) 
  112. 		vint_set_property(twn_h,"start_event","store_gang_bg_anim_done") 
  113. 		 
  114. 		bg_saints_show(true) 
  115. 		 
  116. 		vint_apply_start_values(store_gang_in_anim.handle) 
  117. 		store_gang_in_anim:play(0) 
  118. 		 
  119. 	end 
  120. 	 
  121. 	-- Pass the table data to the megalist vdo. 
  122. 	Menu_data = Store_gang_top_menu 
  123. 	 
  124. 	-- Pass the table data to the megalist vdo. 
  125. 	store_gang_populate_list(Menu_data, 1)	 
  126. 	 
  127. 	-- acquire information about the 4 gang character slots 
  128. 	store_gang_slot_populate() 
  129. 	 
  130. 	vint_dataitem_add_subscription("store_gang_current_object_is_loaded", "update", "store_gang_load_status_update")	 
  131.  
  132. end 
  133.  
  134. -- Cleanup function called on document unload. 
  135. -- 
  136. function store_gang_cleanup() 
  137.  
  138. 	if Store_gang_loaded_from_crib == false then 
  139. 		bg_saints_show(false) 
  140.  
  141. 		-- Nuke all button subscriptions 
  142. 		Input_tracker:subscribe(false) 
  143. 		store_gang_enable_mouse(false) 
  144. 	end 
  145. 	 
  146. 	character_enable_mouse_drag(false) 
  147. 	 
  148. 	-- Some things need to be cleaned up right away when a store doc is unloading, particular disabled inputs which have 
  149. 	-- callbacks to the script that is unloading. 
  150. 	store_common_cleanup_current_store()	 
  151. end 
  152.  
  153. function store_lock_controls() 
  154. 	Input_tracker:subscribe(false) 
  155. 	store_gang_enable_mouse(false) 
  156. end 
  157.  
  158. function store_unlock_controls() 
  159. 	Input_tracker:subscribe(true) 
  160. 	store_gang_enable_mouse(true) 
  161. end 
  162.  
  163. function store_gang_slot_populate() 
  164.  
  165. 	Store_gang_slot_info = {} 
  166. 	vint_dataresponder_request("store_gang_slot_dr", "store_gang_slot_add", 0)		 
  167. end 
  168.  
  169. -- Called by data responder to add a new slot to the table 
  170. -- 
  171. function store_gang_slot_add(is_random, display_name_crc) 
  172. 	local menu_idx = #Store_gang_slot_info + 1 
  173.  
  174. 	local new_item = { 
  175. 		id = menu_idx - 1, 
  176. 		type = TYPE_BUTTON, 
  177. 		is_random = is_random, 
  178. 		label_crc = display_name_crc, 
  179. 	}		 
  180. 	 
  181. 	Store_gang_slot_info[menu_idx] = new_item 
  182. end 
  183.  
  184. function store_gang_slot_menu_enter() 
  185. 	-- We want left/right movement to rotate characters instead of moving sliders in this interface 
  186. 	Input_tracker:remove_input("nav_left") 
  187. 	Input_tracker:remove_input("nav_right") 
  188. 	Input_tracker:add_input("nav_left", "store_common_nav_up", 50) 
  189. 	Input_tracker:add_input("nav_right", "store_common_nav_down", 50)	 
  190. 	 
  191. 	-- update labels (gang selections may have been updated in a submenu). 
  192. 	for i = 1, #Menu_data do 
  193. 		local values 
  194. 		values = {[0] = i, [1] = Store_gang_slot_info[i].label_crc}	 
  195. 		Menu_data[i].label = vint_insert_values_in_string("GANG_CUST_SLOT", values) 
  196. 	end	 
  197. 	 
  198. 	local index = Active_list:get_selection() 
  199. 	 
  200. 	store_gang_populate_list(Menu_data, index) 
  201. 	 
  202. 	-- check for random 
  203. 	store_gang_handle_random() 
  204. 	 
  205. 	--store_gang_show_question_marks(true) 
  206. end 
  207.  
  208. function store_gang_rotate_characters() 
  209. 	-- We want left/right movement to rotate characters instead of moving sliders in this interface 
  210. 	Input_tracker:remove_input("nav_left") 
  211. 	Input_tracker:remove_input("nav_right") 
  212. 	Input_tracker:add_input("nav_left", "store_common_nav_left", 50) 
  213. 	Input_tracker:add_input("nav_right", "store_common_nav_right", 50) 
  214. 	 
  215. 	-- hide random text 
  216. 	local crib_random_grp = Vdo_base_object:new("crib_random_grp", 0, Store_common_doc_handle) 
  217. 	crib_random_grp:set_visible(false)		 
  218. end 
  219.  
  220. function store_gang_slot_menu_leave() 
  221. 	store_gang_rotate_characters() 
  222. 	 
  223. 	--store_gang_show_question_marks(false) 
  224. end 
  225.  
  226. -- Player is navigating to a new gang character slot.  We need to call C to rotate the players and set new slot 
  227. -- 
  228. function store_gang_slot_nav(menu_data) 
  229. 	vint_dataresponder_post("store_gang_character_dr", "Set_slot", menu_data.id) 
  230. 	Store_gang_current_slot = menu_data.id 
  231. 	store_gang_handle_random() 
  232. end 
  233.  
  234. function store_gang_handle_random() 
  235. 	-- if slot is random than display text for which category 
  236. 	local crib_random_grp = Vdo_base_object:new("crib_random_grp", 0, Store_common_doc_handle) 
  237. 	local crib_random_text = Vdo_base_object:new("crib_random_txt", 0, Store_common_doc_handle) 
  238. 	local crib_random_anim_out = Vdo_anim_object:new("crib_random_anim_out", 0, Store_common_doc_handle) 
  239. 	local end_event_twn = Vdo_tween_object:new("random_out_end_event", crib_random_anim_out.handle) 
  240. 	 
  241. 	end_event_twn:set_end_event("store_gang_random_anim_complete") 
  242. 	crib_random_anim_out:play(0)	 
  243. end 
  244.  
  245. function store_gang_random_anim_complete() 
  246. 	local crib_random_anim_in = Vdo_anim_object:new("crib_random_anim_in", 0, Store_common_doc_handle) 
  247. 	local crib_random_grp = Vdo_base_object:new("crib_random_grp", 0, Store_common_doc_handle) 
  248. 	local crib_random_text = Vdo_base_object:new("crib_random_txt", 0, Store_common_doc_handle) 
  249. 	 
  250. 	if Store_gang_slot_info[Store_gang_current_slot + 1].is_random == true then 
  251. 		local values, tag 
  252. 		values = {[0] = "GANG_CUST_RANDOM", [1] = Store_gang_slot_info[Store_gang_current_slot + 1].label_crc}	 
  253. 		tag = vint_insert_values_in_string("{0}  {1:text_tag_crc}", values)		 
  254. 		crib_random_text:set_text(tag) 
  255. 		crib_random_grp:set_visible(true)		 
  256. 		crib_random_anim_in:play(0)				 
  257. 	else 
  258. 		crib_random_grp:set_visible(false) 
  259. 	end	 
  260. end 
  261.  
  262. -- Player has chosen a gang character slot, and now we need to populate the submenu with the gang categories. 
  263. -- 
  264. function store_gang_category_populate(menu_data) 
  265. 	-- change our input for left/right back to default 
  266. 	store_gang_rotate_characters() 
  267. 	 
  268. 	Store_gang_building_menu = menu_data.sub_menu 
  269. 	Store_gang_building_menu.start_index = 1	 
  270. 	vint_dataresponder_request("store_gang_category_dr", "store_gang_category_add", 0)		 
  271. end 
  272.  
  273. -- Called by data responder to add a new category to the menu. 
  274. -- 
  275. function store_gang_category_add(id, display_name_crc, is_current) 
  276. 	local menu_idx = #Store_gang_building_menu + 1 
  277.  
  278. 	local new_item = { 
  279. 		id = id, 
  280. 		type = TYPE_BUTTON, 
  281. 		label = nil, 
  282. 		label_crc = display_name_crc, 
  283. 		on_sub_menu_fill = store_gang_character_populate, 
  284. 	}		 
  285.  
  286. 	Store_gang_building_menu[menu_idx] = new_item 
  287. 	 
  288. 	if is_current == true then 
  289. 		Store_gang_building_menu.start_index = menu_idx 
  290. 	end		 
  291. end 
  292.  
  293. -- The player has chosen a category; now we need to find the available characters in that category. 
  294. -- 
  295. -- menu_data: standard table with the contents of the menu entry chosen. 
  296. -- 
  297. function store_gang_character_populate(menu_data) 
  298. 	Store_gang_category_label_crc = menu_data.label_crc 
  299. 	Store_gang_building_menu = menu_data.sub_menu 
  300. 	Store_gang_building_menu.start_index = 1 
  301. 	vint_dataresponder_request("store_gang_character_dr", "store_gang_character_add", 0, menu_data.id) 
  302. 	store_gang_show_question_marks(true) 
  303. 	store_gang_character_nav(Store_gang_building_menu[Store_gang_building_menu.start_index]) 
  304. end 
  305.  
  306. -- When leaving the character style selection menu, we're going to stop showing question marks 
  307. -- 
  308. function store_gang_character_back(menu_data) 
  309. 	store_gang_show_question_marks(false) 
  310. end 
  311.  
  312. -- Called by data responder to add a new character to the menu. 
  313. -- 
  314. function store_gang_character_add(id, is_current, is_random) 
  315. 	local menu_idx = #Store_gang_building_menu + 1 
  316.  
  317. 	local menu_label 
  318. 	local insert_values = { [0] = Store_gang_category_label_crc, [1] = menu_idx } 
  319. 	 
  320. 	if is_random then 
  321. 		menu_label = "GANG_CUST_RANDOM" 
  322. 	else 
  323. 		menu_label = vint_insert_values_in_string("{0:text_tag_crc} {1}", insert_values) 
  324. 	end 
  325. 	 
  326. 	local new_item = { 
  327. 		type = TYPE_BUTTON, 
  328. 		id = id, 
  329. 		label = menu_label, 
  330. 		label_crc = nil, 
  331. 		--is_locked = is_locked, 
  332. 		on_nav = store_gang_character_nav, 
  333. 		on_select = store_gang_character_update, 
  334. 		on_cancel = store_gang_character_revert, 
  335. 		on_back	 = store_gang_character_back, 
  336. 		is_random = is_random 
  337. 	}		 
  338.  
  339. 	Store_gang_building_menu[menu_idx] = new_item 
  340. 	 
  341. 	if is_current == true then 
  342. 		Store_gang_building_menu.start_index = menu_idx 
  343. 	end	 
  344. end 
  345.  
  346. -- Called when the player navigates the character list, and we spawn in the characters to show. 
  347. -- 
  348. function store_gang_character_nav(menu_data) 
  349. 	vint_dataresponder_post("store_gang_character_dr", "Load", menu_data.id) 
  350. 	store_gang_slot_populate() 
  351. end 
  352. 	 
  353. -- Called when the player hits accept to keep the character 
  354. --	 
  355. function store_gang_character_update(menu_data) 
  356. 	vint_dataresponder_post("store_gang_character_dr", "Update_char", menu_data.id) 
  357. 	 
  358. 	-- update our gang character slot info table 
  359. 	store_gang_slot_populate()	 
  360. 	 
  361. 	-- go back up 2 menus 
  362. 	store_common_back_menu() 
  363. 	store_common_back_menu() 
  364. end	 
  365. 	 
  366. -- Called when the player hits cancel to revert the character 
  367. --	 
  368. function store_gang_character_revert(menu_data) 
  369. 	vint_dataresponder_post("store_gang_character_dr", "Revert_char", menu_data.id) 
  370. 	store_gang_slot_populate()	 
  371. end		 
  372. 	 
  373. -- Player has chosen to see gang sign menu, and now we need to populate the submenu. 
  374. -- 
  375. function store_gang_sign_populate(menu_data) 
  376. 	 
  377. 	Store_gang_building_menu = menu_data.sub_menu 
  378. 	vint_dataresponder_request("store_gang_sign_dr", "store_gang_sign_add", 0)		 
  379. 	 
  380. 	--[[local hint_rotate_data = { 
  381. 		{CTRL_BUTTON_RS, "STORE_ZOOM"}, 
  382. 	} 
  383. 	Store_common_rotate_hint:set_hints(hint_rotate_data)]]-- 
  384. 	Store_common_rotate_hint:set_visible(false) 
  385. 	 
  386. 	character_enable_mouse_drag(false) 
  387. end 
  388.  
  389. -- Called by data responder to add a new gang sign to the menu. 
  390. -- 
  391. function store_gang_sign_add(sign_type, display_name, is_current) 
  392. 	local menu_idx = #Store_gang_building_menu + 1 
  393.  
  394. 	local new_item = { 
  395. 		id = menu_idx - 1, 
  396. 		type = TYPE_BUTTON, 
  397. 		label = display_name, 
  398. 		label_crc = nil, 
  399. 		on_nav = store_gang_sign_nav, 
  400. 		on_select = store_gang_sign_select, 
  401. 		on_cancel = store_gang_sign_revert, 
  402. 		on_back = store_gang_sign_on_back 
  403. 	}		 
  404.  
  405. 	Store_gang_building_menu[menu_idx] = new_item 
  406. 	 
  407. 	if is_current == true then 
  408. 		Store_gang_building_menu.start_index = menu_idx 
  409. 	end	 
  410. end	 
  411. 	 
  412. -- Called when navigating over a gang sign 
  413. -- 
  414. function store_gang_sign_nav(menu_data) 
  415. 	gang_customization_select_gang_sign(0, menu_data.id) 
  416. end 
  417. 	 
  418. 	 
  419. -- Called when selecting a gang sign 
  420. -- 
  421. function store_gang_sign_select(menu_data) 
  422. 	gang_customization_confirm_gang_sign(menu_data.id) 
  423. 	store_common_back_menu()	 
  424. end 
  425.  
  426. -- Called when reverting from a gang sign 
  427. -- 
  428. function store_gang_sign_revert(menu_data) 
  429. 	gang_customization_revert_gang_sign() 
  430. end 
  431. 	 
  432. -- Called when navigating to a different vehicle slot 
  433. -- 
  434. function store_gang_vehicle_slot_nav(menu_data) 
  435. 	vint_dataresponder_post("store_gang_vehicle_dr", "Set_slot", menu_data.id) 
  436. 	Store_gang_current_vehicle_slot = menu_data.id 
  437. end 
  438. 	 
  439. -- Called when we need to request the available vehicles list. 
  440. -- 
  441. function store_gang_vehicle_populate(menu_data) 
  442. 	Store_gang_building_menu = menu_data.sub_menu 
  443. 	vint_dataresponder_request("store_gang_vehicle_dr", "store_gang_vehicle_add", 0, menu_data.id)	 
  444. end 
  445.  
  446. -- Called by data responder to add a new vehicle to the menu. 
  447. -- 
  448. function store_gang_vehicle_add(name, is_current) 
  449. 	local menu_idx = #Store_gang_building_menu + 1 
  450. 	 
  451. 	local new_item = { 
  452. 		type = TYPE_BUTTON, 
  453. 		id = menu_idx - 1, 
  454. 		label = name, 
  455. 		label_crc = nil, 
  456. 		--is_locked = is_locked, 
  457. 		on_nav = store_gang_vehicle_nav, 
  458. 		on_select = store_gang_vehicle_update, 
  459. 		on_cancel = store_gang_vehicle_revert, 
  460. 	}		 
  461.  
  462. 	Store_gang_building_menu[menu_idx] = new_item 
  463. 	 
  464. 	if is_current == true then 
  465. 		Store_gang_building_menu.start_index = menu_idx 
  466. 	end	 
  467. end 
  468. 	 
  469. -- Called when the player navigates the vehicle list, and we spawn in the vehicle to show. 
  470. -- 
  471. function store_gang_vehicle_nav(menu_data) 
  472. 	gang_customization_select_vehicle(menu_data.id, Store_gang_current_vehicle_slot) 
  473. end 
  474. 	 
  475. -- Called when the player hits accept to keep the vehicle 
  476. --	 
  477. function store_gang_vehicle_update(menu_data) 
  478. 	gang_customization_confirm_vehicle(Store_gang_current_vehicle_slot) 
  479. 	store_common_back_menu() 
  480. end	 
  481. 	 
  482. -- Called when the player hits cancel to revert the vehicle 
  483. --	 
  484. function store_gang_vehicle_revert(menu_data) 
  485. 	gang_customization_revert_vehicle(Store_gang_current_vehicle_slot) 
  486. end		 
  487. 	 
  488. -- Called when player requests exiting store. 
  489. -- 
  490. function store_gang_exit() 
  491.  
  492. 	-- no confirmation needed if we're just going back to the crib menu 
  493. 	if Store_gang_loaded_from_crib then 
  494. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  495. 		-- lock input during animation 
  496. 		store_lock_controls() 
  497. 		-- make background so player is covered up 
  498. 		bg_saints_set_background(false) 
  499. 		local back_out_anim = Vdo_anim_object:new("store_crib_out_anim", 0, Store_common_doc_handle) 
  500. 		local back_out_end_twn = Vdo_tween_object:new("common_anchor_out_twn", back_out_anim.handle) 
  501. 		back_out_end_twn:set_end_event("store_gang_crib_exit") 
  502. 		back_out_anim:play(0) 
  503. 						 
  504. 		-- notify C code to reset camera (end customization camera_mode, customization near clip) 
  505. 		store_gang_begin_exit() 
  506.  
  507. 	else 
  508. 		Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  509. 		Store_common_popup:set_title("MENU_TITLE_WARNING") 
  510. 		Store_common_popup:set_text("STORE_EXIT_WARNING_BODY")		 
  511. 		Store_common_popup:nav_enable(true, "store_gang_exit_final", "store_gang_popup_nav") 
  512. 		Not_popup_grp:set_alpha(.5) 
  513. 		 
  514. 		store_gang_enable_mouse(false) 
  515. 	end 
  516. end 
  517.  
  518. function store_gang_crib_exit() 
  519. 	pop_screen() 
  520. end 
  521. -- Called when player has responded to store exit confirmation dialog. 
  522. -- 
  523. -- event: input response from the player 
  524. -- 
  525. function store_gang_exit_final(event) 
  526. 	Store_common_popup:nav_enable(false, nil, nil) 
  527. 		 
  528. 	-- The user hit the B button and is exiting 
  529. 	-- This is redundant to selecting "No" in the list 
  530. 	if event == "back" then 
  531. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  532. 		Not_popup_grp:set_alpha(1) 
  533. 		store_gang_enable_mouse(true) 
  534. 		return 
  535. 	end 
  536. 	 
  537. 	game_UI_audio_play("UI_Main_Menu_Select") 
  538. 	 
  539. 	-- Did we select yes?  This assumes yes is the first item 
  540. 	if Store_common_popup:get_selected_data() ~= 1 then 
  541. 		Not_popup_grp:set_alpha(1) 
  542. 		store_gang_enable_mouse(true) 
  543. 		return 
  544. 	end 
  545. 	 
  546. 	Not_popup_grp:set_alpha(0) 
  547. 	-- exit the interface 
  548. 	pop_screen() 
  549. end 
  550.  
  551. -- Populate the active megalist menu, and hide the previous menu 
  552. -- 
  553. -- list_data: 		this table contains the data to populate the megalist 
  554. -- current_index: 	the current index in the menu that's selected 
  555. -- 
  556. function store_gang_populate_list(list_data, current_index) 
  557. 	Active_list:draw_items(list_data, current_index, STORE_COMMON_LIST_SIZE, 10, SCALE_FONT_STORE_GANG_LIST)	 
  558. 	Active_list:set_visible(true) 
  559. 	 
  560. 	if Game_platform == "PC" then 
  561. 		Mouse_input_tracker:remove_all() 
  562. 		 
  563. 		Active_list:set_store("store_gang") 
  564. 		Active_list:add_mouse_inputs("store_common", Mouse_input_tracker) 
  565. 		Mouse_input_tracker:subscribe(true) 
  566. 	end 
  567. end 
  568.  
  569. -- Clears the price and respect values from the store header. 
  570. -- 
  571. function store_gang_header_revert(menu_data) 
  572. 	Store_header:set_price(nil) 
  573. 	Store_header:set_respect(nil) 
  574. end 
  575.  
  576. -- Handles navigation of any popups 
  577. function store_gang_popup_nav(event, value) 
  578. 	 
  579. 	if event == "mouse_move" then 
  580. 		vint_set_mouse_cursor("") 
  581. 	end 
  582. 	 
  583. 	if event == "nav_up" then	 
  584. 		Store_common_popup.list:move_cursor(-1)	 
  585. 	elseif event == "nav_down" then 
  586. 		Store_common_popup.list:move_cursor(1) 
  587. 	elseif event == "mouse_move" then 
  588. 		-- value contains the target_handle in this case 
  589. 		local new_index = Store_common_popup.list:get_button_index(value) 
  590. 		if new_index ~= 0 then 
  591. 			Store_common_popup.list:set_selection(new_index) 
  592. 			Store_common_popup.list:move_cursor(0, true) 
  593. 		end 
  594. 		 
  595. 	else 
  596. 		--do nothing 
  597. 	end 
  598. end 
  599.  
  600. function store_gang_style_menu_select(menu_data) 
  601.  
  602. 	local slot_menu = { 
  603. 		on_enter = store_gang_slot_menu_enter, 
  604. 		on_back = store_gang_slot_menu_leave, 
  605. 		[1] = { type = TYPE_BUTTON, id = 0, on_nav = store_gang_slot_nav, on_sub_menu_fill = store_gang_category_populate, on_back = store_gang_slot_menu_leave}, 
  606. 		[2] = { type = TYPE_BUTTON, id = 1, on_nav = store_gang_slot_nav, on_sub_menu_fill = store_gang_category_populate, on_back = store_gang_slot_menu_leave}, 
  607. 		[3] = { type = TYPE_BUTTON, id = 2, on_nav = store_gang_slot_nav, on_sub_menu_fill = store_gang_category_populate, on_back = store_gang_slot_menu_leave}, 
  608. 		[4] = { type = TYPE_BUTTON, id = 3, on_nav = store_gang_slot_nav, on_sub_menu_fill = store_gang_category_populate, on_back = store_gang_slot_menu_leave} 
  609. 	} 
  610.  
  611. 	menu_data.sub_menu = slot_menu 
  612. 	 
  613. 	-- set starting choice according to current slot 
  614. 	menu_data.sub_menu.start_index = Store_gang_current_slot	+ 1 
  615. 	 
  616. 	character_enable_mouse_drag(true) 
  617.  
  618. end 
  619.  
  620. function store_gang_vehicle_slot_menu_enter(menu_data) 
  621. 	vint_dataresponder_post("store_gang_vehicle_dr", "Set_slot", 0) 
  622. 	Store_gang_current_vehicle_slot = 0 
  623. 	Store_common_rotate_hint:set_visible(false) 
  624. 	character_enable_mouse_drag(false) 
  625. end 
  626.  
  627. function store_gang_vehicle_slot_menu_leave(menu_data) 
  628. 	vint_dataresponder_post("store_gang_vehicle_dr", "Set_slot", -1) 
  629. 	if game_is_active_input_gamepad() then 
  630. 		Store_common_rotate_hint:set_visible(true) 
  631. 	end 
  632. 	character_enable_mouse_drag(true) 
  633. end 
  634.  
  635. -- While vehicles or gang characters are loading and visible on the screen, we need to set the background property to false. 
  636. -- 
  637. function store_gang_load_status_update(di_h) 
  638. 	--[[ 
  639. 		is_loaded = is the current preview target loaded? 
  640. 	]]-- 
  641. 	local is_loaded = vint_dataitem_get(di_h) 
  642. 	-- make character show if a character is loaded... 
  643. 	bg_saints_set_background(is_loaded) 
  644. 	Store_gang_input_allowed = is_loaded 
  645. end 
  646.  
  647. function store_gang_allow_input() 
  648. 	return Store_gang_input_allowed 
  649. end 
  650.  
  651. function store_gang_bg_anim_done(twn_h, event_name) 
  652. 	vint_set_property(twn_h,"start_event",nil) 
  653. 	store_gang_bg_covered() 
  654. 	store_common_bg_anim_complete() 
  655. 	--debug_print("vint","GANG BG DONE") 
  656. end 
  657.  
  658. function store_gang_sign_on_back() 
  659. 	character_enable_mouse_drag(true) 
  660. 	 
  661. 	if game_is_active_input_gamepad() then 
  662. 		local hint_rotate_data = { 
  663. 			{CTRL_BUTTON_RS, "CONTROL_ROTATE"}, 
  664. 		} 
  665. 		Store_common_rotate_hint:set_hints(hint_rotate_data) 
  666. 		Store_common_rotate_hint:set_visible(true) 
  667. 	else 
  668. 		Store_common_rotate_hint:set_visible(false) 
  669. 	end 
  670. end 
  671.  
  672. Store_gang_gang_menu = { 
  673. 	[1] = { label = "GANG_CUST_GANG_STYLE_OPT", type = TYPE_BUTTON, on_sub_menu_fill = store_gang_style_menu_select }, 
  674. 	[2] = { label = "GANG_CUST_GANG_SIGN_OPT", type = TYPE_BUTTON, on_sub_menu_fill = store_gang_sign_populate } 
  675. } 
  676.  
  677. Store_gang_vehicle_menu = { 
  678. 	[1] = { label = "GANG_CUST_SLOT_1", type = TYPE_BUTTON, id = 0, on_nav = store_gang_vehicle_slot_nav, on_sub_menu_fill = store_gang_vehicle_populate, }, 
  679. 	[2] = { label = "GANG_CUST_SLOT_2", type = TYPE_BUTTON, id = 1, on_nav = store_gang_vehicle_slot_nav, on_sub_menu_fill = store_gang_vehicle_populate, }, 
  680. 	[3] = { label = "GANG_CUST_SLOT_3", type = TYPE_BUTTON, id = 2, on_nav = store_gang_vehicle_slot_nav, on_sub_menu_fill = store_gang_vehicle_populate, }, 
  681. } 
  682.  
  683. Store_gang_top_menu = { 
  684. 	[1] = { label = "GANG_CUST_GANG_TITLE", type = TYPE_BUTTON, sub_menu = Store_gang_gang_menu, on_nav = store_gang_vehicle_slot_menu_leave }, 
  685. 	[2] = { label = "GANG_CUST_VEHICLE_TITLE", type = TYPE_BUTTON, sub_menu = Store_gang_vehicle_menu, on_nav = store_gang_vehicle_slot_menu_enter }  
  686. } 
  687.  
  688.  
  689. -- ===================================== 
  690. --       Mouse Specific Functions 
  691. -- ===================================== 
  692.  
  693. function store_gang_enable_mouse(enable) 
  694. 	if Game_platform == "PC" and enable ~= nil then 
  695. 		if Mouse_input_tracker ~= 0 then 
  696. 			Mouse_input_tracker:subscribe(enable) 
  697. 		end 
  698. 		 
  699. 		if Hint_bar_mouse_input_tracker ~= nil then 
  700. 			Hint_bar_mouse_input_tracker:subscribe(enable) 
  701. 		end 
  702. 	end 
  703. end 
  704.  
  705. function store_gang_mouse_click(event, target_handle) 
  706. 	local hint_index = Store_common_hint_bar:get_hint_index(target_handle) 
  707. 	if hint_index ~= 0 then 
  708. 		store_common_button_b() 
  709. 	end 
  710. end 
  711.  
  712. function store_gang_mouse_move(event, target_handle) 
  713.  
  714. 	vint_set_mouse_cursor("") 
  715.  
  716. 	-- Reset all highlights 
  717. 	Store_common_hint_bar:set_highlight(0) 
  718. 	 
  719. 	-- Check if the mouse is over the hint bar buttons 
  720. 	local hint_index = Store_common_hint_bar:get_hint_index(target_handle) 
  721. 	if hint_index ~= 0 then 
  722. 		Store_common_hint_bar:set_highlight(hint_index, Store_common_current_highlight_color) 
  723. 		return 
  724. 	end 
  725. 	 
  726. 	-- Check if the mouse is over a button on the mega list 
  727. 	local old_index = Active_list:get_selection() 
  728. 	local new_index = Active_list:get_button_index(target_handle) 
  729. 	if new_index ~= 0 and new_index ~= old_index then 
  730. 		Active_list:set_selection(new_index) 
  731. 		Active_list:move_cursor(0, true) 
  732. 		 
  733. 		-- If the item has a callback for navigation, do it (such as putting clothes on) 
  734. 		local data_item = Active_list:return_selected_data() 
  735. 		if data_item.on_nav ~= nil then 
  736. 			data_item.on_nav(data_item) 
  737. 		end 
  738. 		return 
  739. 	end 
  740. end 
  741.  
  742. function store_gang_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines) 
  743. end 
  744.  
  745. function store_gang_mouse_drag(event, target_handle, mouse_x, mouse_y) 
  746. end 
  747.  
  748. function store_gang_mouse_drag_release(event, target_handle, mouse_x, mouse_y) 
  749. end 
  750.