sr2lua/pause_map.lua

  1. Pause_map_styles = { 
  2. 	colors = { 
  3. 		filter_select = {0.2980, 0.5843, 0.934}, 
  4. 		filter_deselect = {0.6314, 0.6549, 0.684}, 
  5. 		filter_disabled = {0.3882, 0.4078, 0.434}, 
  6. 	} 
  7. } 
  8.  
  9. Pause_map_icons_rectangle = { 
  10. 	["map_other_bookmark_a_1"] = true, 
  11. 	["map_other_bookmark_a_2"] = true, 
  12. 	["map_other_bookmark_a_3"] = true, 
  13. 	["map_other_bookmark_a_4"] = true, 
  14. 	["map_other_bookmark_a_5"] = true, 
  15. 	["map_other_bookmark_b_1"] = true, 
  16. 	["map_other_bookmark_b_2"] = true, 
  17. 	["map_other_bookmark_b_3"] = true, 
  18. 	["map_other_bookmark_b_4"] = true, 
  19. 	["map_other_bookmark_b_5"] = true, 
  20. 	["map_other_crib"] = true, 
  21. 	["map_other_crib_purchase"] = true, 
  22. 	["map_other_train"] = true, 
  23. 	["map_start_mission_3ss"] = true, 
  24. 	["map_start_mission_bh"] = true, 
  25. 	["map_start_mission_rn"] = true, 
  26.    ["map_start_mission_ss"] = true, 
  27. 	["map_start_mission_ul"] = true, 
  28. 	["map_other_hidden_mission"] = true, 
  29. } 
  30. Pause_map_icons_objective = { 
  31. 	["map_act_kill"] = true, 
  32. 	["map_act_kill_up"] = true, 
  33. 	["map_act_kill_down"] = true, 
  34. 	["map_act_location"] = true, 
  35. 	["map_act_location_up"] = true, 
  36. 	["map_act_location_down"] = true, 
  37. 	["map_act_protectacquire"] = true, 
  38. 	["map_act_protectacquire_up"] = true, 
  39. 	["map_act_protectacquire_down"] = true 
  40. } 
  41.  
  42.  
  43. Pause_map_elements = { 
  44. 	base = { 
  45. 		map_grp_h = -1, 
  46. 		map_h = -1, 
  47. 		cursor_h = -1, 
  48. 		info_h = -1 
  49. 	}, 
  50. 	 
  51. 	header = { 
  52. 		hood_text_h = -1, 
  53. 		district_text_h = -1, 
  54. 	}, 
  55. 	filters = { 
  56. 		activities_h = -1, 
  57. 		all_h = -1, 
  58. 		cribs_h = -1, 
  59. 		missions_h = -1, 
  60. 		none_h = -1, 
  61. 		stores_h = -1, 
  62. 		strongholds_h = -1, 
  63. 		text_h = -1, 
  64. 	}, 
  65. 	footer = { 
  66. 		alt_select_btn_h = -1, 
  67. 		alt_select_text_h = -1, 
  68. 		select_btn_h = -1, 
  69. 		select_text_h = -1, 
  70. 		back_btn_h = -1, 
  71. 		back_text_h = -1, 
  72. 		up_down_btn_h = -1, 
  73. 		up_down_text_h = -1, 
  74. 		left_right_btn_h = -1, 
  75. 		left_right_text_h = -1, 
  76. 		rb_btn_h = -1, 
  77. 		rb_text_h = -1, 		 
  78. 	}, 
  79. }		 
  80.  
  81. Pause_map_anims = {} 
  82.  
  83. Pause_map = { done = false, } 
  84.  
  85. Pause_map_filter_status = { 
  86. 	selected_index = 0, 
  87. 	total_filters = 7, 
  88. 	filters = {} 
  89. } 
  90.  
  91. Pause_map_cursor_status = { 
  92. 	x = -1, 
  93. 	y = -1, 
  94. 	gps_active = -1, 
  95. 	fade_mode = "in" 
  96. } 
  97.  
  98. Pause_map_highlight_status = { } 
  99.  
  100. Pause_map_subscriptions = { } 
  101.  
  102. Pause_map_underground = false 
  103.  
  104. -- assume not taxi unless told otherwise 
  105. Pause_map_taxi_mode = false 
  106.  
  107. Pause_map_swapping = false 
  108.  
  109. function pause_map_init() 
  110.  
  111. 	vint_set_property(vint_object_find("pause_map"), "map_mode", "pause_map") 
  112. 	 
  113. 	--Base Group 
  114. 	local h = vint_object_find("map_grp") 
  115. 	Pause_map_elements.base.map_grp_h = h 
  116. 	Pause_map_elements.base.map_h = vint_object_find("map", h) 
  117. 	Pause_map_elements.base.info_h = vint_object_find("info", h) 
  118. 	 
  119. 	--Map Elements 
  120. 	Pause_map_elements.base.cursor_h = vint_object_find("cursor", h) 
  121. 	 
  122. 	h = vint_object_find("map_frame") 
  123. 	 
  124. 	--Header Elements 
  125. 	Pause_map_elements.header.district_text_h = 	vint_object_find("district_text", h) 
  126. 	Pause_map_elements.header.hood_text_h 		=	vint_object_find("hood_text", h) 
  127. 	 
  128. 	--Filter Elements and initial values 
  129. 	local h = vint_object_find("filters") 
  130. 	 
  131. 	-- Hide the filters if we're playing a competitive online game 
  132. 	if mp_is_enabled() == true then 
  133. 		vint_set_property(h, "visible", false) 
  134. 	end 
  135. 	 
  136. 	Pause_map_filter_status.filters[0] = { bmp_h = vint_object_find("all", h), 			filter = "PFT_ALL", 			filter_str = "PAUSE_MAP_FILTER_ALL" } 
  137. 	Pause_map_filter_status.filters[1] = { bmp_h = vint_object_find("cribs", h), 			filter = "PFT_CRIBS", 			filter_str = "PAUSE_MAP_FILTER_CRIBS"  } 
  138. 	Pause_map_filter_status.filters[2] = { bmp_h = vint_object_find("stores", h), 		filter = "PFT_STORES", 		filter_str = "PAUSE_MAP_FILTER_STORES"  } 
  139. 	--Pause_map_filter_status.filters[2] = { bmp_h = vint_object_find("saves", h), 		filter = "PFT_SAVES", 		filter_str = "SAVES"  } 
  140. 	Pause_map_filter_status.filters[3] = { bmp_h = vint_object_find("activities", h), 	filter = "PFT_ACTIVITIES", 	filter_str = "PAUSE_MAP_FILTER_ACTIVITIES"  } 
  141. 	Pause_map_filter_status.filters[4] = { bmp_h = vint_object_find("strongholds", h), 	filter = "PFT_STRONGHOLDS", 	filter_str = "PAUSE_MAP_FILTER_STRONGHOLDS"  } 
  142. 	Pause_map_filter_status.filters[5] = { bmp_h = vint_object_find("missions", h), 		filter = "PFT_MISSIONS", 		filter_str = "PAUSE_MAP_FILTER_MISSIONS"  } 
  143. 	--Pause_map_filter_status.filters[6] = { bmp_h = vint_object_find("trains", h), 		filter = "PFT_TRAIN_STATIONS", 	filter_str = "TRAINS"  } 
  144. 	Pause_map_filter_status.filters[6] = { bmp_h = vint_object_find("none", h), 			filter = "PFT_NONE", 				filter_str = "PAUSE_MAP_FILTER_NONE"  } 
  145. 	 
  146. 	 
  147. 	--Pause_map_filter_status.filters[8] = { bmp_h = vint_object_find("none", h), 			filter = "PFT_FILTER_LOCKED", 			filter_str = "HIDE ALL"  } 
  148. 	Pause_map_elements.filters.text_h = vint_object_find("filter_text", h) 
  149. 	 
  150. 	--Footer Elements 
  151. 	local h = vint_object_find("button_tips") 
  152. 	Pause_map_elements.footer.button_tips = h 
  153. 	Pause_map_elements.footer.alt_select_btn_h 	= vint_object_find("alt_select_btn", h) 
  154. 	Pause_map_elements.footer.alt_select_text_h	= vint_object_find("alt_select_text", h) 
  155. 	Pause_map_elements.footer.select_btn_h			= vint_object_find("select_btn", h) 
  156. 	Pause_map_elements.footer.select_text_h 		= vint_object_find("select_text", h) 
  157. 	Pause_map_elements.footer.back_btn_h 			= vint_object_find("back_btn", h) 
  158. 	Pause_map_elements.footer.back_text_h 			= vint_object_find("back_text", h) 
  159. 	Pause_map_elements.footer.up_down_btn_h 		= vint_object_find("up_down_btn", h) 
  160. 	Pause_map_elements.footer.up_down_text_h 		= vint_object_find("up_down_text", h) 
  161. 	Pause_map_elements.footer.left_right_btn_h 	= vint_object_find("left_right_btn", h) 
  162. 	Pause_map_elements.footer.left_right_text_h 	= vint_object_find("left_right_text", h)                                                
  163.  
  164. 	--Display platform specific buttons 
  165. 	vint_set_property(Pause_map_elements.footer.alt_select_btn_h, "image", get_x_button()) 
  166. 	vint_set_property(Pause_map_elements.footer.select_btn_h, "image", get_a_button()) 
  167. 	vint_set_property(Pause_map_elements.footer.back_btn_h, "image", get_b_button()) 
  168. 	vint_set_property(Pause_map_elements.footer.left_right_btn_h, "image", get_dpad_lr_image()) 
  169. 	vint_set_property(Pause_map_elements.footer.up_down_btn_h, "image", get_dpad_ud_image()) 
  170. 	 
  171. 	--Hide info 
  172. 	vint_set_property(vint_object_find("info"), "visible", false) 
  173. 	 
  174. 	--Animation find and pause 
  175. 	h = vint_object_find("root_animation") 
  176. 	Pause_map_anims.map_open_h					= vint_object_find("map_open", h) 
  177. 	Pause_map_anims.map_close_h 				= vint_object_find("map_close", h) 
  178. 	Pause_map_anims.cursor_fade_anim_h 		= vint_object_find("cursor_fade_anim", h) 
  179. 	Pause_map_anims.cursor_fade_twn_h 		= vint_object_find("cursor_fade_twn", Pause_map_anims.cursor_fade_anim_h) 
  180. 	Pause_map_anims.highlight_anim_in_h		= vint_object_find("highlight_anim_in", h) 
  181. 	Pause_map_anims.highlight_anim_out_h	= vint_object_find("highlight_anim_out", h) 
  182. 	Pause_map_anims.info_bg_anim_h			= vint_object_find("info_bg_anim", h) 
  183. 	Pause_map_anims.icon_highlight_anim_h	= vint_object_find("icon_highlight_anim", h) 
  184. 	 
  185. 	vint_set_property(Pause_map_anims.map_open_h , "is_paused", true) 
  186. 	vint_set_property(Pause_map_anims.map_close_h , "is_paused", true) 
  187. 	vint_set_property(Pause_map_anims.cursor_fade_anim_h , "is_paused", true) 
  188. 	vint_set_property(Pause_map_anims.highlight_anim_in_h , "is_paused", true) 
  189. 	vint_set_property(Pause_map_anims.highlight_anim_out_h , "is_paused", true) 
  190. 	vint_set_property(Pause_map_anims.info_bg_anim_h , "is_paused", true) 
  191. 	 
  192. 	--Set transition in and out events after into/extros 
  193. 	local twn = vint_object_find("map_grp_anchor_twn_1", Pause_map_anims.map_open_h) 
  194. 	vint_set_property(twn, "end_event", "pause_map_trans_in_complete") 
  195. 	local twn = vint_object_find("map_grp_anchor_twn_1", Pause_map_anims.map_close_h) 
  196. 	vint_set_property(twn, "end_event", "pause_map_trans_out_complete") 
  197.  
  198. 	--Subscribe to data items 
  199. 	vint_dataitem_add_subscription("PAUSE_MAP_HIGHLIGHT1", "update", "pause_map_highlight_update") 
  200. 	vint_dataitem_add_subscription("PAUSE_MAP_HIGHLIGHT2", "update", "pause_map_highlight_update") 
  201. 	vint_dataitem_add_subscription("PAUSE_MAP_CURSOR", "update", "pause_map_cursor_update") 
  202.  
  203. 	--Initialize Map parts 
  204. 	pause_map_btn_tips_format() 
  205. 	pause_map_open() 
  206. 	 
  207. 	--Event Tracking 
  208. 	event_tracking_interface_enter("Pause Map") 
  209. 	 
  210. 	--If in coop or mp show no pause indicators 
  211. 	if mp_is_enabled() or coop_is_active() then 
  212. 		vint_set_property(vint_object_find("game_is_paused_text"), "visible", false) 
  213. 	end 
  214. end 
  215.  
  216. function pause_map_cleanup() 
  217. 	--Event Tracking(Exit Menu) 
  218. 	event_tracking_interface_exit() 
  219. end 
  220.  
  221. function pause_map_is_taxi_mode(tm) 
  222. 	Pause_map_taxi_mode = (tm == true) 
  223. 	pause_map_btn_tips_format() 
  224. end 
  225.  
  226.  
  227. ----------------------------------------------- 
  228. -- Opens pause map 
  229. ----------------------------------------------- 
  230. function pause_map_open() 
  231. 	--Play animation 
  232. 	lua_play_anim(Pause_map_anims.map_open_h, 0) 
  233. 	 
  234. 	--Play sound 
  235. 	local noise = audio_get_audio_id("SYS_MENU_OPEN") 
  236. 	audio_play(noise) 
  237. 	 
  238. 	--Block all input by subscribing to everything 
  239. 	Pause_map_subscriptions.all_unassigned = vint_subscribe_to_input_event(nil, "all_unassigned", "pause_map_input") 
  240. end 
  241.  
  242. ----------------------------------------------- 
  243. -- Closes pause map 
  244. ----------------------------------------------- 
  245. function pause_map_close() 
  246. 	--Unsubscribe from all the events 
  247. 	for idx, val in Pause_map_subscriptions do 
  248. 		vint_unsubscribe_to_input_event(val) 
  249. 	end 
  250. 	Pause_map_subscriptions.all_unassigned = vint_subscribe_to_input_event(nil, "all_unassigned", "pause_map_input") 
  251. 	lua_play_anim(Pause_map_anims.map_close_h, 0) 
  252. 	 
  253. 	if Pause_map_swapping == false then 
  254. 		pause_menu_release_camera() 
  255. 	end 
  256. 	 
  257. 	--Play sound 
  258. 	local noise = audio_get_audio_id("SYS_MENU_CLOSE") 
  259. 	audio_play(noise) 
  260. end 
  261.  
  262. ----------------------------------------------- 
  263. -- After all the map slides in, this sets up  
  264. -- subscrptions and shit 
  265. ----------------------------------------------- 
  266. function pause_map_trans_in_complete() 
  267.  
  268. --	debug_print("vint", "map is loaded\n\n") 
  269. 	 
  270. 	--Desubscribe to the blocked events 
  271. 	vint_unsubscribe_to_input_event(Pause_map_subscriptions.all_unassigned) 
  272. 	 
  273. 	--Subscribe to controls 
  274. 	 
  275. 	--DPAD (For Filters and switching maps) 
  276. 	Pause_map_subscriptions.left = vint_subscribe_to_input_event(nil, "dpad_left", "pause_map_input") 
  277. 	Pause_map_subscriptions.right = vint_subscribe_to_input_event(nil, "dpad_right", "pause_map_input") 
  278. 	 
  279. 	--Map Button (for closing the interface) 
  280. 	Pause_map_subscriptions.map = vint_subscribe_to_input_event(nil, "map", "pause_map_input") 
  281. 	Pause_map_subscriptions.back = vint_subscribe_to_input_event(nil, "pad_back", "pause_map_input") 
  282. 	 
  283. 	Pause_map_subscriptions.pause = vint_subscribe_to_input_event(nil, "pause", "pause_map_input") 
  284. 	--Initialize filters 
  285. 	pause_map_filter_init() 
  286. end 
  287. function pause_map_trans_out_complete() 
  288. 	vint_unsubscribe_to_input_event(Pause_map_subscriptions.all_unassigned) 
  289. 	if Pause_map_swapping == true then 
  290. 		pause_menu_swap_with_map(0) 
  291. 	end 
  292.  
  293. 	vint_document_unload(vint_document_find("pause_map"))	 
  294. end 
  295.  
  296. function pause_map_input(target, event, accelleration) 
  297. 	if event == "dpad_left" then 
  298. 		local new_index = Pause_map_filter_status.selected_index - 1 
  299. 		if new_index  < 0 then 
  300. 			new_index = Pause_map_filter_status.total_filters - 1 
  301. 		end 
  302. 		pause_map_filter_change(new_index, true) 
  303. 	elseif event == "dpad_right" then 
  304. 		local new_index = Pause_map_filter_status.selected_index + 1 
  305. 		if new_index  == Pause_map_filter_status.total_filters then 
  306. 			new_index = 0 
  307. 		end 
  308. 		pause_map_filter_change(new_index, true) 
  309. 	elseif event == "map" then 
  310. 		--Close the interface 
  311. 		pause_map_close() 
  312. 	elseif event == "pad_back" then 
  313. 		--Close the interface 
  314. 		pause_map_close() 
  315. 	elseif event == "pause" then 
  316. 		Pause_map_swapping = true 
  317. 		pause_map_close()		 
  318. 	end 
  319. end 
  320.  
  321. -------------------------------------------------- 
  322. --Pause Map Filters 
  323. -------------------------------------------------- 
  324. function pause_map_filter_init() 
  325. 	--Initialize pause menu filters 
  326. 	 
  327. 	--get current filter mode from the game 
  328. 	local current_mode = pause_map_filter() 
  329. 	local current_index = 0 
  330. 	 
  331. --	debug_print("vint", "current_mode: " .. current_mode .. "\n") 
  332. 	 
  333. 	if current_mode == "PFT_FILTER_LOCKED" then 
  334. 		pause_map_filter_lock(true)		 
  335. 		return 
  336. 	end 
  337. 	 
  338. 	for idx, val in Pause_map_filter_status.filters do 
  339. 		if val.filter == current_mode then 
  340. 			current_index = idx 
  341. 			break 
  342. 		end 
  343. 	end 
  344. 	 
  345. 	pause_map_filter_change(current_index, false) 
  346. end 
  347.  
  348. function pause_map_filter_change(index, set_game_filter) 
  349. 	local filter_previous = Pause_map_filter_status.filters[Pause_map_filter_status.selected_index] 
  350. 	local filter = Pause_map_filter_status.filters[index] 
  351. 	 
  352. 	--Highlight Icon 
  353. 	vint_set_property(filter.bmp_h, "tint", Pause_map_styles.colors.filter_select[1], Pause_map_styles.colors.filter_select[2], Pause_map_styles.colors.filter_select[3]) 
  354. 	vint_set_property(filter.bmp_h, "scale", 1.2, 1.2) 
  355. 	 
  356. 	--If the previous filter is not the current filter then reset the previous state state. 
  357. 	if filter_previous ~= filter then 
  358. 		--Deselect Old icon 
  359. 		vint_set_property(filter_previous.bmp_h, "tint", Pause_map_styles.colors.filter_deselect[1], Pause_map_styles.colors.filter_deselect[2], Pause_map_styles.colors.filter_deselect[3]) 
  360. 		vint_set_property(filter_previous.bmp_h, "scale", 1.0, 1.0) 
  361. 	end 
  362. 	 
  363. 	--Change Text 
  364. 	vint_set_property(Pause_map_elements.filters.text_h, "text_tag", Pause_map_filter_status.filters[index].filter_str) 
  365. 	 
  366. 	--Set the game side filter 
  367. 	if set_game_filter == true then 
  368. 		pause_map_filter(filter.filter) 
  369. 	end 
  370. 	 
  371. 	--Store selected index 
  372. 	Pause_map_filter_status.selected_index = index 
  373. end 
  374.  
  375. function pause_map_filter_lock(is_locked) 
  376. 	 
  377. 	if is_locked == true then 
  378. 		local filter  
  379. 		for idx, val in Pause_map_filter_status.filters do 
  380. 			filter = val 
  381. 			vint_set_property(filter.bmp_h, "tint", Pause_map_styles.colors.filter_disabled[1], Pause_map_styles.colors.filter_disabled[2], Pause_map_styles.colors.filter_disabled[3]) 
  382. 			vint_set_property(filter.bmp_h, "scale", 1.0, 1.0) 
  383. 		end 
  384. 		vint_set_property(Pause_map_elements.filters.text_h, "text_tag", "PAUSE_MAP_FILTER_LOCKED") 
  385. 		 
  386. 		--Unsubscribe to inputs 
  387. 		vint_unsubscribe_to_input_event(Pause_map_subscriptions.left) 
  388. 		vint_unsubscribe_to_input_event(Pause_map_subscriptions.right) 
  389. 	else 
  390. 		local filter  
  391. 		for idx, val in Pause_map_filter_status.filters do 
  392. 			vint_set_property(filter.bmp_h, "tint", Pause_map_styles.colors.filter_deselect[1], Pause_map_styles.colors.filter_deselect[2], Pause_map_styles.colors.filter_deselect[3]) 
  393. 			vint_set_property(filter.bmp_h, "scale", 1.0, 1.0) 
  394. 		end 
  395. 		pause_map_filter_change(Pause_map_filter_status.selected_index, true) 
  396. 	end 
  397. end 
  398.  
  399.  
  400. -------------------------------------------------- 
  401. --Pause Map Button Tips 
  402. -------------------------------------------------- 
  403. function pause_map_btn_tips_format() 
  404. 	local btn_padding = 0 
  405. 	local tip_padding = 8 
  406.  
  407. 	--hardcoding the formatting because it is fast... yay! 
  408. 	if mp_is_enabled() == true then 
  409. 		-- Only show the back button for multiplayer 
  410. 		vint_set_property(Pause_map_elements.footer.select_btn_h, "visible", false) 
  411. 		vint_set_property(Pause_map_elements.footer.select_text_h, "visible", false) 
  412. 		 
  413. 		vint_set_property(Pause_map_elements.footer.alt_select_btn_h, "visible", false) 
  414. 		vint_set_property(Pause_map_elements.footer.alt_select_text_h, "visible", false) 
  415. 		 
  416. 		vint_set_property(Pause_map_elements.footer.left_right_btn_h, "visible", false) 
  417. 		vint_set_property(Pause_map_elements.footer.left_right_text_h, "visible", false) 
  418. 		 
  419. 		vint_set_property(Pause_map_elements.footer.up_down_btn_h, "visible", false) 
  420. 		vint_set_property(Pause_map_elements.footer.up_down_text_h, "visible", false) 
  421. 		 
  422. 		local x, y = vint_get_property(Pause_map_elements.footer.select_btn_h, "anchor") 
  423. 		vint_set_property(Pause_map_elements.footer.back_btn_h, "anchor", x, y) 
  424. 		 
  425. 		x, y = vint_get_property(Pause_map_elements.footer.select_text_h, "anchor") 
  426. 		vint_set_property(Pause_map_elements.footer.back_text_h, "anchor", x, y) 
  427. 	else 
  428. 		-- Format the buttons for single player and coop 
  429. 		local elements = { 
  430. 			[0] = { 
  431. 				btn = Pause_map_elements.footer.select_btn_h, 
  432. 				txt = Pause_map_elements.footer.select_text_h 
  433. 			}, 
  434. 			[1] = { 
  435. 				btn = Pause_map_elements.footer.alt_select_btn_h, 
  436. 				txt = Pause_map_elements.footer.alt_select_text_h 
  437. 			}, 
  438. 			[2] = { 
  439. 				btn = Pause_map_elements.footer.back_btn_h, 
  440. 				txt = Pause_map_elements.footer.back_text_h 
  441. 			}, 
  442. 			[3] = { 
  443. 				btn = Pause_map_elements.footer.left_right_btn_h, 
  444. 				txt = Pause_map_elements.footer.left_right_text_h 
  445. 			}, 
  446. 			[4] = { 
  447. 				btn = Pause_map_elements.footer.up_down_btn_h, 
  448. 				txt = Pause_map_elements.footer.up_down_text_h 
  449. 			}, 
  450. 		} 
  451. 		 
  452. 		local w, show 
  453. 		local x, y = 0, 0 
  454. 		 
  455. 		local prev_element = nil 
  456. 		 
  457. 		for idx = 0, 4 do 
  458. 			local val = elements[idx] 
  459. 			if Pause_map_taxi_mode == true and idx == 1 then 
  460. 				show = false 
  461. 			elseif idx == 4 then 
  462. 				show = (Pause_map_underground == true) 
  463. 			elseif idx == 0 then 
  464. 				show = (Pause_map_underground ~= true) 
  465. 			else 
  466. 				show = true 
  467. 			end 
  468. 			 
  469. 			if show == true then 
  470. 				w = element_get_actual_size(val.btn) 
  471. 				w = w/2 
  472. 				if prev_element == nil then 
  473. 					x = vint_get_property(elements[0].btn, "anchor") 
  474. 				else 
  475. 					x = x + w 
  476. 				end 
  477. 				 
  478. 				-- place button 
  479. 				vint_set_property(val.btn, "anchor", x, y) 
  480.  
  481. 				-- place text 
  482. 				x = x + w + btn_padding 
  483. 				vint_set_property(val.txt, "anchor", x, y) 
  484.  
  485. 				-- find pos for next pass 
  486. 				w = element_get_actual_size(val.txt) 
  487. 				x = x + w + tip_padding 
  488. 				 
  489. 				-- unhide elements 
  490. 				vint_set_property(val.txt, "visible", true) 
  491. 				vint_set_property(val.btn, "visible", true) 
  492. 				prev_element = val 
  493. 			else 
  494. 				vint_set_property(val.txt, "visible", false) 
  495. 				vint_set_property(val.btn, "visible", false) 
  496. 			end 
  497. 		end 
  498. 		 
  499. 		--Resize button tips if they are too big... 	 
  500. 		--720 is the ~width of the cellphone frame 
  501. 		if x > 720 then 
  502. 			local scale = 720/x 
  503. 			vint_set_property(Pause_map_elements.footer.button_tips, "scale", scale, scale) 
  504. 		end 
  505. 	end 
  506. end 
  507.  
  508. -------------------------------------------------- 
  509. --Highlight Update 
  510. -------------------------------------------------- 
  511. function anim_out_complete(tween_h) 
  512. 	for idx, val in Pause_map_highlight_status do  
  513. 		if val.last_tween_out == tween_h then 
  514. 		 
  515. 			local status = Pause_map_highlight_status[idx] 
  516. 			vint_object_destroy(status.info_h) 
  517. 			vint_object_destroy(status.in_anim_h) 
  518. 			vint_object_destroy(status.out_anim_h) 
  519. 			vint_object_destroy(status.info_bg_anim_h) 
  520. 			vint_object_destroy(status.icon_highlight_anim_h) 
  521.  
  522. 			Pause_map_highlight_status[idx] = nil 
  523. 			break 
  524. 		end 
  525. 	end 
  526. end 
  527.  
  528. function anim_in_complete() 
  529. 	debug_print("vint", "anim_in_complete \n") 
  530. 	Pause_map.done = true 
  531. end 
  532.  
  533. function pause_map_highlight_update(di_h) 
  534. 	--[[ 
  535. 		VINT_PROP_TYPE_STRING,			// icon bitmap name 
  536. 		VINT_PROP_TYPE_STRING,			// text line 1 
  537. 		VINT_PROP_TYPE_STRING,			// text line 2 
  538. 		VINT_PROP_TYPE_STRING,			// text line 3 
  539. 		VINT_PROP_TYPE_VECTOR2F,		// position 
  540. 		VINT_PROP_TYPE_BOOL,				// is highlighted 
  541. 		VINT_PROP_TYPE_BOOL,				// is gps target 
  542. 	]] 
  543. 	 
  544. 	local icon_bmp_name, text_line_1, text_line_2, text_line_3, position_x, position_y, is_highlighted, is_gps_target = vint_dataitem_get(di_h) 
  545.  
  546. --	debug_print("vint", "icon_bmp_name: " .. 	var_to_string(icon_bmp_name)  .. "\n") 
  547. --	debug_print("vint", " di_h: " .. 	var_to_string(di_h)  .. "\n") 
  548. --	debug_print("vint", " text_line_1: " .. 	var_to_string(text_line_1) 	 .. "\n") 
  549. --	debug_print("vint", " text_line_2: " ..	 	var_to_string(text_line_2)  	 .. "\n") 
  550. --	debug_print("vint", " text_line_3: " .. 	var_to_string(text_line_3) 	 .. "\n") 
  551. --	debug_print("vint", "x: " .. 		var_to_string(position_x) 	 .. ", ") 
  552. --	debug_print("vint", "y: " .. 		var_to_string(position_y) 	 .. "\n") 
  553. --	debug_print("vint", " is_highlighted: " .. var_to_string(is_highlighted) .. "\n") 
  554. --	debug_print("vint", " is_gps_target: " .. 	var_to_string(is_gps_target)  .. "\n") 
  555.  
  556. 	--Exit if there is no icon 
  557. 	if icon_bmp_name == nil then 
  558. 		return 
  559. 	end 
  560. 	 
  561. 	local status = Pause_map_highlight_status[di_h] 
  562.  
  563. 	--Check to see if the highlight/info element has been created then initalize the element if it hasn't. 
  564. 	if status == nil then 
  565. 		 
  566. 		--Clone the object and find targets. 
  567. 		local info_h = vint_object_clone(Pause_map_elements.base.info_h) 
  568. 		local icon_h = vint_object_find("icon", info_h) 
  569. 		local icon_highlight_h = vint_object_find("icon_highlight", info_h) 
  570. 		local lock_h = vint_object_find("lock", info_h) 
  571. 		local text_grp_h = vint_object_find("text_grp", info_h) 
  572. 		local text_line_1_h = vint_object_find("line_1_txt", info_h) 
  573. 		local text_line_2_h = vint_object_find("line_2_txt", info_h) 
  574. 		local text_line_3_h = vint_object_find("line_3_txt", info_h) 
  575. 		 
  576. 		--Clone, Retarget, and Pause Animations 
  577. 		local in_anim_h = vint_object_clone(Pause_map_anims.highlight_anim_in_h) 
  578. 		local out_anim_h = vint_object_clone(Pause_map_anims.highlight_anim_out_h) 
  579. 		local info_bg_anim_h = vint_object_clone(Pause_map_anims.info_bg_anim_h) 
  580. 		local icon_highlight_anim_h = vint_object_clone(Pause_map_anims.icon_highlight_anim_h) 
  581. 		local last_tween_in = vint_object_find("bg_wrapper_alpha_twn_1", in_anim_h) 
  582. 		local last_tween_out = vint_object_find("bg_wrapper_alpha_twn_1", out_anim_h) 
  583. 		 
  584. 		vint_set_property(in_anim_h, "is_paused", true) 
  585. 		vint_set_property(out_anim_h, "is_paused", true) 
  586. 		vint_set_property(info_bg_anim_h, "is_paused", true) 
  587. 		vint_set_property(icon_highlight_anim_h, "is_paused", true) 
  588. 		vint_set_property(in_anim_h, "target_handle", info_h) 
  589. 		vint_set_property(out_anim_h, "target_handle", info_h) 
  590. 		vint_set_property(icon_highlight_anim_h, "target_handle", info_h) 
  591. 		 
  592. 		vint_set_property(info_bg_anim_h, "target_handle", vint_object_find("bg_wrapper", info_h)) 
  593. 		vint_set_property(last_tween_in, "end_event", "anim_in_complete") 
  594. 		vint_set_property(last_tween_out, "end_event", "anim_out_complete") 
  595.  
  596. 		Pause_map_highlight_status[di_h] = { 
  597. 			info_h = info_h, 
  598. 			in_anim_h = in_anim_h, 
  599. 			out_anim_h = out_anim_h, 
  600. 			info_bg_anim_h = info_bg_anim_h, 
  601. 			icon_highlight_anim_h = icon_highlight_anim_h, 
  602. 			icon_h = icon_h, 
  603. 			icon_highlight_h = icon_highlight_h, 
  604. 			lock_h = lock_h, 
  605. 			text_grp_h = text_grp_h, 
  606. 			text_line_1_h = text_line_1_h, 
  607. 			text_line_2_h = text_line_2_h, 
  608. 			text_line_3_h = text_line_3_h, 
  609. 			icon_bmp_name = -1, 
  610. 			text_line_1 = -1, 
  611. 			text_line_2 = -1, 
  612. 			text_line_3 = -1, 
  613. 			text_width = -1, 
  614. 			text_height = -1, 
  615. 			alignment = "left", 
  616. 			is_highlighted = -1, 
  617. 			is_gps_target = -1, 
  618. 			last_tween_in = last_tween_in, 
  619. 			last_tween_out = last_tween_out, 
  620. 		} 
  621. 		 
  622. 		status = Pause_map_highlight_status[di_h] 
  623. 	end 
  624. 	 
  625. 	--Create locals from the status table 
  626. 	local info_h = status.info_h 
  627. 	local icon_h = status.icon_h 
  628. 	local icon_highlight_h = status.icon_highlight_h 
  629. 	local lock_h = status.lock_h 
  630. 	local last_tween_in = status.last_tween_in 
  631. 	local text_line_1_h = status.text_line_1_h 
  632. 	local text_line_2_h = status.text_line_2_h 
  633. 	local text_line_3_h = status.text_line_3_h 
  634. 	 
  635. 	--Set Icon bitmap 
  636. 	if icon_bmp_name ~= status.icon_bmp_name then 
  637. 		vint_set_property(icon_h, "image", icon_bmp_name) 
  638. 		vint_set_property(icon_h, "alpha", 0) 
  639. 		vint_set_property(icon_highlight_h, "image", icon_bmp_name) 
  640. 		vint_set_property(icon_highlight_h, "alpha", 0) 
  641. 		status.icon_bmp_name = icon_bmp_name 
  642. 	end 
  643. 	 
  644. 	vint_set_property(info_h, "anchor", position_x, position_y)			--Set screen coordinate positions 
  645. 	vint_set_property(info_h, "visible", true)								--show item 
  646. 	 
  647. 	--Adjust angle of the lock on graphic based on the icon name 
  648. 	if Pause_map_icons_rectangle[icon_bmp_name] == true then 
  649. 		vint_set_property(lock_h, "rotation", 0) 
  650. 	else 
  651. 		vint_set_property(lock_h, "rotation", .78) 
  652. 	end 
  653. 	 
  654. 	--Update lines of text 
  655. 	--Initialize alignment variables 
  656. 	local reset_alignment = false 
  657. 	local alignment = status.alignment 
  658. 		 
  659. 	--If text tags equal nil then we need to set the string to "" 
  660. 	if text_line_1 == nil then 
  661. 		text_line_1 = "" 
  662. 	end 
  663. 	if text_line_2 == nil then 
  664. 		text_line_3 = "" 
  665. 	end 
  666. 	if text_line_3 == nil then 
  667. 		text_line_3 = "" 
  668. 	end 
  669. 		 
  670. 	if text_line_1 ~= status.text_line_1 or text_line_2 ~= status.text_line_2 or text_line_3 ~= status.text_line_3 then 
  671. 			 
  672. 		--Set text tags 
  673. 		vint_set_property(text_line_1_h, "text_tag", text_line_1) 
  674. 		vint_set_property(text_line_2_h, "text_tag", text_line_2) 
  675. 		vint_set_property(text_line_3_h, "text_tag", text_line_3) 
  676. 		 
  677. 		--Get Largest text width and height 
  678. 		local text_width = 0 
  679. 		local text_height = 0 
  680. 		local temp1_width = element_get_actual_size(text_line_1_h) 
  681. 		local temp2_width = element_get_actual_size(text_line_2_h) 
  682. 		local temp3_width = element_get_actual_size(text_line_3_h) 
  683. 		 
  684. 		if temp1_width > text_width then 
  685. 			text_width = temp1_width 
  686. 		end 
  687. 		if temp2_width > text_width then 
  688. 			text_width = temp2_width 
  689. 		end 
  690. 		if temp3_width > text_width then 
  691. 			text_width = temp3_width 
  692. 		end 
  693.  
  694. 		if text_width ~= status.text_width then 
  695. 			--Set the reset alignment if the text has changed widths 
  696. 			reset_alignment = true 
  697. 		end 
  698. 		 
  699. 		--Do text height based on the line count 
  700. 		if text_line_2 == nil then 
  701. 			text_height = 40 
  702. 		elseif text_line_3 == nil then 
  703. 			text_height = 60 
  704. 		end 
  705. 		 
  706. 		--Store values 
  707. 		status.text_width = text_width 
  708. 		status.text_height = text_height 
  709. 		status.text_line_1 = text_line_1 
  710. 		status.text_line_2 = text_line_2 
  711. 		status.text_line_3 = text_line_3 
  712. 	end 
  713. 	 
  714. 	if reset_alignment == true then 
  715. 		local text_offset = 40	--Aprox offset from the center point of the box 
  716. 		local map_obj_h = vint_object_find("pause_map")	--Get map object 
  717. 		local box_width = vint_get_property(map_obj_h, "scale")									--use scale instead of screensize because it is the actual size 
  718. 	 
  719. 		if position_x + status.text_width + text_offset > box_width then 
  720. 			alignment = "right" 
  721. 		end 
  722. 				 
  723. 		local target_anchor = floor(status.text_width + text_offset) 
  724. 		local target_c_scale = (target_anchor / 45.0000)  
  725. 		 
  726. 		--Apply sizing directions to both sides of the tween 
  727. 		local left_c_scale_twn_h = vint_object_find("left_c_scale_twn", status.info_bg_anim_h) 
  728. 		local right_c_scale_twn_h = vint_object_find("right_c_scale_twn", status.info_bg_anim_h) 
  729. 		local left_e_anchor_twn_h = vint_object_find("left_e_anchor_twn", status.info_bg_anim_h) 
  730. 		local right_w_anchor_twn_h = vint_object_find("right_w_anchor_twn", status.info_bg_anim_h) 
  731. 		 
  732. 		vint_set_property(left_c_scale_twn_h, "end_value", target_c_scale, 1 ) 
  733. 		vint_set_property(right_c_scale_twn_h, "end_value", target_c_scale, 1 ) 
  734. 		vint_set_property(left_e_anchor_twn_h, "end_value", target_anchor, 0) 
  735. 		vint_set_property(right_w_anchor_twn_h, "end_value", 0 - target_anchor, 0) 
  736. 		 
  737. 		if alignment == "right" then 
  738. 			--RIGHT ALIGNMENT 
  739. 			vint_set_property(status.text_grp_h, "anchor", -31, -30)			--Set text group anchor 
  740. 			vint_set_property(status.text_line_1_h, "auto_offset", "ne")	--Adjust Text Alignment 
  741. 			vint_set_property(status.text_line_2_h, "auto_offset", "ne")	--Adjust Text Alignment 
  742. 			vint_set_property(status.text_line_3_h, "auto_offset", "ne")	--Adjust Text Alignment 
  743. 			 
  744. 			vint_set_property(vint_object_find("bg_left", status.info_h), "visible", false)	--Hide left aligned bg 
  745. 			vint_set_property(vint_object_find("bg_right", status.info_h), "visible", true)	--Show right aligned bg 
  746. 			 
  747. 		else 
  748. 			--LEFT ALIGNMENT 
  749. 			vint_set_property(status.text_grp_h, "anchor", 25, -30)			--Set text group anchor 
  750. 			vint_set_property(status.text_line_1_h, "auto_offset", "nw")	--Adjust Text Alignment 
  751. 			vint_set_property(status.text_line_2_h, "auto_offset", "nw")	--Adjust Text Alignment 
  752. 			vint_set_property(status.text_line_3_h, "auto_offset", "nw")	--Adjust Text Alignment		 
  753. 			 
  754. 			vint_set_property(vint_object_find("bg_left", status.info_h), "visible", true)	--Show left aligned bg 
  755. 			vint_set_property(vint_object_find("bg_right", status.info_h), "visible", false)	--Hide left aligned bg 
  756. 		end 
  757. 		 
  758. 		if alignment ~= status.alignment then 
  759. 			status.alignment = alignment 
  760. 		end 
  761. 	end 
  762.  
  763. 	--If the highlighted item changes state the we need to change how it is displayed 
  764. 	if is_highlighted ~= status.is_highlighted then 
  765. 		 
  766. 		--1. Check if we need to fade in or fade out the info box 
  767. 		if is_highlighted == true then 
  768. 			--Reset elements 
  769. 			vint_set_property(vint_object_find("bg_wrapper",info_h), "alpha", 0) 
  770. 			vint_set_property(status.text_grp_h, "alpha", 0) 
  771. 			vint_set_property(status.out_anim_h, "is_paused", true)	--Pause the out animation 
  772. 			lua_play_anim(status.in_anim_h, 0)								--Play in animation 
  773. 			lua_play_anim(status.info_bg_anim_h, 0) 
  774. 			lua_play_anim(status.icon_highlight_anim_h, 0) 
  775. 			Pause_map.done = false 
  776. 		elseif is_highlighted == false then 
  777. 			--if the fade in tweens are done, then its ok to fade them out 
  778. 			if Pause_map.done == true then 
  779. 				vint_set_property(status.in_anim_h, "is_paused", true)	--Pause the in animation 
  780. 				local alpha = vint_get_property(status.text_grp_h, "alpha") 
  781. 				vint_set_property(vint_object_find("txt_grp_alpha_twn_1",status.out_anim_h), "start_value", alpha) 
  782. 				lua_play_anim(status.out_anim_h, 0)	 
  783. 			else 
  784. 				--if fade in tweens arent finished, just destroy them 
  785. 				vint_object_destroy(status.info_h) 
  786. 				vint_object_destroy(status.in_anim_h) 
  787. 				vint_object_destroy(status.out_anim_h) 
  788. 				vint_object_destroy(status.info_bg_anim_h) 
  789. 				vint_object_destroy(status.icon_highlight_anim_h) 
  790.  
  791. 				Pause_map_highlight_status[di_h] = nil				 
  792. 			end			 
  793. 		end 
  794. 		 
  795. 		status.is_highlighted = is_highlighted 
  796. 		 
  797. 		--2. Fade the cursor if highlight and cursor state have changed 
  798. 		local is_active = false 
  799. 		for idx, val in Pause_map_highlight_status do  
  800. 			if val.is_highlighted == true then 
  801. 				is_active = true 
  802. 				break 
  803. 			end 
  804. 		end 
  805. 		 
  806. 		if is_active == true then 
  807. 			if Pause_map_cursor_status.fade_mode == "in" then 
  808. 				--Fade out Cursor 
  809. 				local current_alpha = vint_get_property(Pause_map_elements.base.cursor_h, "alpha") 
  810. 				vint_set_property(Pause_map_anims.cursor_fade_twn_h, "start_value", current_alpha)  
  811. 				vint_set_property(Pause_map_anims.cursor_fade_twn_h, "end_value", 0)  
  812. 				lua_play_anim(Pause_map_anims.cursor_fade_anim_h, 0) 
  813. 				Pause_map_cursor_status.fade_mode = "out" 
  814. 			end 
  815. 		else 
  816. 			if Pause_map_cursor_status.fade_mode == "out" then 
  817. 				--Fade In Cursor 
  818. 				local current_alpha = vint_get_property(Pause_map_elements.base.cursor_h, "alpha") 
  819. 				vint_set_property(Pause_map_anims.cursor_fade_twn_h, "start_value", current_alpha)  
  820. 				vint_set_property(Pause_map_anims.cursor_fade_twn_h, "end_value", 1)  
  821. 				lua_play_anim(Pause_map_anims.cursor_fade_anim_h, 0) 
  822. 				Pause_map_cursor_status.fade_mode = "in" 
  823. 			end 
  824. 		end 
  825. 	end 
  826. 	 
  827. 	if is_gps_target == true then 
  828. 		vint_set_property(lock_h, "tint", 0,1,0) 
  829. 	else 
  830. 		vint_set_property(lock_h, "tint", 1,1,1) 
  831. 	end 
  832. 	 
  833. end 
  834.  
  835. function pause_map_cursor_update(di_h) 
  836. 	--[[ 
  837.       VINT_PROP_TYPE_VECTOR2F,	// cursor pos 
  838.       VINT_PROP_TYPE_BOOL,			// gps active 
  839.       VINT_PROP_TYPE_STRING,		// district name 
  840.       VINT_PROP_TYPE_STRING,		// hood name 
  841. 	]] 
  842. 	local cursor_x, cursor_y, gps_active, district_str, hood_str, is_underground = vint_dataitem_get(di_h) 
  843. 	 
  844. 	vint_set_property(Pause_map_elements.base.cursor_h, "anchor", cursor_x, cursor_y) 
  845. 	Pause_map_cursor_status.x = cursor_x 
  846. 	Pause_map_cursor_status.y = cursor_y 
  847.  
  848. 	--Update district/hood text 
  849. 	vint_set_property(Pause_map_elements.header.hood_text_h, "text_tag", district_str) 
  850. 	vint_set_property(Pause_map_elements.header.district_text_h, "text_tag", hood_str) 
  851. 	 
  852. 	--Update button tips 
  853. 	if gps_active ~= Pause_map_cursor_status.gps_active or is_underground ~= Pause_map_underground then 
  854. 		if gps_active == true then 
  855. 			--LOCALIZE: 
  856. 			vint_set_property(Pause_map_elements.footer.select_text_h, "text_tag", "PAUSE_MAP_WAYPOINT_REMOVE") 
  857. 		else 
  858. 			vint_set_property(Pause_map_elements.footer.select_text_h, "text_tag", "PAUSE_MAP_WAYPOINT_SET") 
  859. 		end 
  860. 		--Reformat button tips because the text has been updated 
  861. 		Pause_map_underground = is_underground 
  862. 		Pause_map_cursor_status.gps_active = gps_active 
  863. 		pause_map_btn_tips_format() 
  864. 	end	 
  865. end 
  866.  
  867. --[[ 
  868. Find_nearest_items_to_populate = { 
  869. 	[0] = {bmp_name = "map_store_food", "Fast Food" }, 
  870. 	[1] = {bmp_name = "map_store_clothing_low", "Clothing Store" }, 
  871. 	[2] = {bmp_name = "map_store_cardealer_low", "Auto Dealer" }, 
  872. 	[3] = {bmp_name = "map_store_music", "Music Store" }, 
  873. 	[4] = {bmp_name = "map_store_mechanic", "Mechanic" }, 
  874. 	[5] = {bmp_name = "map_store_jewelry", "Jewelry Store" }, 
  875. 	[6] = {bmp_name = "map_store_tattoo", "Tattoo" }, 
  876. 	[7] = {bmp_name = "map_store_gun", "Weapon Store" }, 
  877. 	[8] = {bmp_name = "map_store_forgive", "Forgive and Forget" }, 
  878. 	[9] = {bmp_name = "map_store_surgeon", "Plastic Surgeon" }, 
  879. } 
  880.  
  881. function pause_map_find_nearest_item_add(index, icon_bmp_name, title_str) 
  882.  
  883. end 
  884.  
  885. function pause_map_find_nearest_open() 
  886.  
  887. end 
  888.  
  889. function pause_map_find_nearest_close() 
  890.  
  891. end]]