./vint_lib.lua

  1. function test_error_me() 
  2. 	X = 5 
  3. end 
  4.  
  5. GAME_BUILD_DATE = "0000-00-00 20:00:00" 
  6.  
  7. -- legacy for menu_base... 
  8. --MENU_NUM_SLIDER_ACCEL_REPEAT =	0.08 
  9. --MENU_NUM_SLIDER_ACCEL_FACTOR =	15 
  10. --MENU_NUM_SLIDER_ACCEL_LIMIT =		1000 
  11.  
  12. FEET_PER_METER = 3.2808399 
  13.  
  14. -- HUD Elements -- 
  15. HUD_ELEM_GSI 						= 0 
  16. HUD_ELEM_MINIMAP 					= 1 
  17. HUD_ELEM_RETICLE 					= 2 
  18. HUD_ELEM_HIT_INDICATORS 		= 3 
  19. HUD_ELEM_WEAPONS 					= 4 
  20. HUD_ELEM_CASH_RESPECT_HOMEY 	= 5 
  21. HUD_ELEM_WEAPON_SWAP_MESSAGE 	= 6 
  22. HUD_ELEM_RADIO_STATION 			= 7 
  23. HUD_ELEM_VEHICLE_NAME 			= 8 
  24. HUD_ELEM_DIVERSIONS 				= 9 
  25. HUD_ELEM_MESSAGES 				= 10 
  26. HUD_ELEM_TUTORIAL_HELP 			= 11 
  27. HUD_ELEM_AMMO_PICKUP				= 12 
  28. HUD_ELEM_COLLECTION				= 13 
  29. HUD_ELEM_SUPER_REWARD			= 14 
  30. HUD_ELEM_MECH						= 15 
  31.  
  32. -- Must be explicitly hidden 
  33. HUD_ELEM_SCREEN_FX 				= 16 
  34. HUD_ELEM_SUBTITLES 				= 17 
  35. HUD_ELEM_OI 						= 18 
  36. HUD_ELEM_RADIAL					= 19 
  37.  
  38. HUD_ALL_ELEM 						= 20 
  39.  
  40. -- HUD Fade Levels -- 
  41. HUD_FADE_HIDDEN = 0 
  42. HUD_FADE_TRANSPARENT = 1 
  43. HUD_FADE_VISIBLE = 2 
  44. HUD_FADE_NO_CHANGE = 3 
  45.  
  46. local MY_HUD_STATE = -1 
  47. function hud_hide_test_1() 
  48. 	MY_HUD_STATE = ui_hud_display_create_state() 
  49. 	ui_hud_display_set_element(MY_HUD_STATE, HUD_ELEM_RADIAL, HUD_FADE_HIDDEN) 
  50. 	ui_hud_display_commit_state(MY_HUD_STATE) 
  51. end 
  52.  
  53. function hud_hide_test_2() 
  54. 	ui_hud_display_remove_state(MY_HUD_STATE) 
  55. 	MY_HUD_STATE = -1 
  56. end 
  57.  
  58. Pcr_open_plastic_surgeon = false 
  59.  
  60. -- some docs need to know what menu mode we are doing 
  61. -- set this from C before loading menu docs 
  62. Menu_mode_current = "" 
  63.  
  64. --Main Menu Globals... 
  65. Main_menu_controller_is_selected = false			-- Determines if we've got a controller selected for the game, used by main menu... 
  66. Main_menu_gameboot_complete = false				--Determines if we've already loaded the main menu(we use this to determine to show loading and press start or not). 
  67. Menu_swap_in_progress = false 
  68.  
  69. --LEGACY DELETE THIS when unreferenced by the main menu... 
  70. Main_menu_controller_selected = false			-- Determines if we've got a controller selected for the game, used by main menu... LEGACY 
  71.  
  72. Main_menu_can_has_input = false 
  73.  
  74. Hud_msg_back_is_coop_join = false				-- is the currently displayed back message item a coop quest share 
  75.  
  76.  --stored here so we know how to properly restart the clothing store 
  77. Clothing_store_name = "DEBUG_CLOTHING_STORE" 
  78. Clothing_store_display_name = 0 
  79. Clothing_store_original_name = "DEBUG_CLOTHING_STORE" 
  80. Clothing_store_original_display_name = 0 
  81. Menu_swap_interface_unload_handle = 0 
  82. Menu_swap_interface_reload_name = 0 
  83. Menu_swap_callback_function = 0 
  84. Menu_swap_hud_hidden = false; 
  85.  
  86. INVALID_NUM_FRAMES = -1 
  87. Num_frames_from_switch = INVALID_NUM_FRAMES 
  88.  
  89. Pause_menu_save_for_server_drop = false 
  90.  
  91. Credits_format = "default" 
  92.  
  93. DIALOG_OPEN_SOUND 		= "SYS_HUD_HELPTEXT" 
  94. DIALOG_SERIOUS_SOUND	= "SYS_HUD_CONF_SERIOUS" 
  95. Menu_sound_item_nav		= "SYS_MENU_CLICK_UD"		-- Current menu item changes 
  96. Menu_sound_value_nav	= "SYS_MENU_CLICK_LR"		-- Value of current item changes 
  97. Menu_sound_select		= "UI_Main_Menu_Select"			-- Current item selected 
  98. Menu_sound_scroll		= "SYS_MENU_TRIGGER_LR"		-- Horizontal menu changes 
  99. Menu_sound_back			= "SYS_MENU_BACK"			-- Current menu changes to previous 
  100. Menu_sound_open			= "SYS_MENU_OPEN"			-- Menu system is opened 
  101. Menu_sound_close		= "SYS_MENU_CLOSE"			-- Menu system is closed 
  102. Menu_sound_warning		= "SYS_MENU_OPEN"			-- Warning dialog opens 
  103. Menu_sound_purchase		= "SYS_MENU_PURCHASE"		-- Any item is purchased 
  104. Menu_sound_confirm		= "SYS_HUD_CONF_SERIOUS"	-- Confirmation/warning dialog opens 
  105. Menu_sound_reward		= "SYS_HUD_CONF_REWARD"		-- Reward notification dialog 
  106.  
  107.  
  108.  
  109. --Tween States 
  110. VINT_TWEEN_STATE_WAITING 	= 0 
  111. VINT_TWEEN_STATE_RUNNING	= 1 
  112. VINT_TWEEN_STATE_PAUSED		= 2 
  113. VINT_TWEEN_STATE_DISABLED	= 3 
  114. VINT_TWEEN_STATE_FINISHED	= 4 
  115.  
  116. Screen_center_x = 640 
  117. Screen_center_y = 360 
  118.  
  119. Safe_frame_e	= 0 
  120. Safe_frame_w	= 0 
  121. Safe_frame_n	= 0 
  122. Safe_frame_s	= 0 
  123.  
  124. VINT_OBJECT_INVALID 	= -1 
  125. VINT_OBJECT_GROUP 	= 0 
  126. VINT_OBJECT_BITMAP 	= 1 
  127. VINT_OBJECT_TEXT 		= 2 
  128.  
  129. function vint_lib_init_constants() 
  130. 	if vint_is_std_res() then 
  131. 		Screen_center_x = 320 
  132. 		Screen_center_y = 240 
  133. 	else 
  134. 		Screen_center_x = 640 
  135. 		Screen_center_y = 360 
  136. 	end 
  137. 	 
  138. 	--Get safe frame... 
  139. 	Safe_frame_w, Safe_frame_n, Safe_frame_e, Safe_frame_s = vint_get_safe_frame() 
  140. end 
  141.  
  142. function vint_menu_swap_thread() 
  143. 	while true do 
  144. 		if Menu_swap_interface_reload_name ~= 0 then 
  145. 			if Menu_swap_hud_hidden == false then 
  146. 				game_hud_hide(true); 
  147. 				Menu_swap_hud_hidden = true 
  148. 			end 
  149. 			if Num_frames_from_switch ~= INVALID_NUM_FRAMES then 
  150. 				Num_frames_from_switch = Num_frames_from_switch + 1 
  151. 			end 
  152. 			if Num_frames_from_switch > 2 then 
  153. 				if Menu_swap_interface_reload_name ~= 0 then 
  154. 					vint_document_load(Menu_swap_interface_reload_name) 
  155. 					Menu_swap_interface_reload_name = 0 
  156. 					Num_frames_from_switch = INVALID_NUM_FRAMES 
  157. 					Menu_swap_in_progress = false 
  158. 					if Menu_swap_callback_function ~= 0 then 
  159. 						Menu_swap_callback_function() 
  160. 						Menu_swap_callback_function = 0 
  161. 					end 
  162. 				end 
  163. 			end 
  164. 		end 
  165. 		thread_yield() 
  166. 	end 
  167. end 
  168.  
  169. function vint_menu_swap_invalidate() 
  170. 	Menu_swap_interface_reload_name = 0 
  171. 	Num_frames_from_switch = INVALID_NUM_FRAMES 
  172. 	Clothing_store_name = "DEBUG_CLOTHING_STORE" 
  173. 	Clothing_store_display_name = 0 
  174. 	Clothing_store_original_name = "DEBUG_CLOTHING_STORE" 
  175. 	Clothing_store_original_display_name = 0 
  176. 	Menu_swap_interface_unload_handle = 0 
  177. 	Menu_swap_interface_reload_name = 0 
  178. 	Menu_swap_in_progress = false 
  179. 	game_hud_hide(false); 
  180. 	Menu_swap_hud_hidden = false 
  181. end 
  182.  
  183. function vint_menu_swap_unload() 
  184. 	vint_document_unload(Menu_swap_interface_unload_handle) 
  185. 	Num_frames_from_switch = 0 
  186. end 
  187.  
  188. function argument_unwrapper(arguments, start) 
  189. 	if start < arguments.n then 
  190. 		return arguments[start + 1], argument_unwrapper(arguments, start + 1) 
  191. 	end	 
  192. end 
  193.  
  194. function vint_dataresponder_request(data_responder_name, callback_function_name, max_records_to_return, ...) 
  195. 	vint_internal_dataresponder_request(data_responder_name, callback_function_name, max_records_to_return, argument_unwrapper(arg, 0)) 
  196. 	while(vint_dataresponder_finished(data_responder_name) ~= true) do 
  197. 		thread_yield() 
  198. 		vint_internal_dataresponder_request(data_responder_name, callback_function_name, max_records_to_return, argument_unwrapper(arg, 0)) 
  199. 	end 
  200. end 
  201.  
  202. --[[ 
  203. ######################################################################### 
  204. UTILITY FUNCTIONS  
  205. ######################################################################### 
  206. ]] 
  207.  
  208. function set_text_tag(text_element_h, text_crc, text_string) 
  209. 	--Set Label 
  210. 	if text_crc == 0 and text_string == nil then 
  211. 		--no string 
  212. 		vint_set_property(text_element_h,"text_tag", "") 
  213. 	elseif text_crc == 0 then 
  214. 		--use string 
  215. 		vint_set_property(text_element_h, "text_tag", text_string) 
  216. 	elseif text_crc == nil then 
  217. 		--Label crc invalid 
  218. 		vint_set_property(text_element_h,"text_tag", "") 
  219. 	else 
  220. 		--use crc 
  221. 		vint_set_property(text_element_h, "text_tag_crc",text_crc) 
  222. 	end 
  223. end 
  224.  
  225. --Easy Start Anim 
  226. function lua_play_anim(anim_h, start_time_offset, doc) 
  227. 	if start_time_offset == nil then 
  228. 		start_time_offset = 0 
  229. 	end 
  230. 	 
  231. 	local start_time = vint_get_time_index(doc) + start_time_offset 
  232. 	 
  233. 	vint_set_property(anim_h, "is_paused", false) 
  234. 	vint_set_property(anim_h, "start_time", start_time) 
  235. end 
  236.  
  237. --Easy Play tween method 
  238. function lua_play_tween(tween_handle, target_handle, start_time_offset) 
  239. 	vint_set_property(tween_handle, "target_handle",	target_handle) 
  240. 	vint_set_property(tween_handle, "start_time",		vint_get_time_index() + start_time_offset) 
  241. 	vint_set_property(tween_handle, "state",				"running") 
  242. end 
  243.  
  244. function lua_reverse_anim(anim_h) 
  245.  
  246. 	--Find largest duration... 
  247. 	local tween_h = vint_object_first_child(anim_h) 
  248. 	local max_anim_length = 0 
  249. 	 
  250. 	while tween_h ~= 0 and tween_h ~= nil do 
  251. 		local tween_start_time	= vint_get_property(tween_h, "start_time") 
  252. 		local tween_duration 	= vint_get_property(tween_h, "duration") 
  253. 		local anim_length = tween_start_time + tween_duration 
  254. 		max_anim_length = max(max_anim_length, anim_length)		 
  255. 		tween_h = vint_object_next_sibling(tween_h) 
  256. 	end 
  257. 	 
  258. 	--loop through and swap times... 
  259. 	local tween_h = vint_object_first_child(anim_h) 
  260. 	while tween_h ~= 0 and tween_h ~= nil do 
  261. 		--find out what these tweens are... 
  262. 		local property_name = vint_get_property(tween_h, "target_property")	 
  263. 		 
  264. 		--Swap values 
  265. 		if property_name == "anchor" or property_name == "offset" or property_name == "source_nw" or property_name == "source_ne" or property_name == "scale" then 
  266. 			--Vector type properties 
  267. 			local start_value_x, start_value_y 	= vint_get_property(tween_h, "start_value") 
  268. 			local end_value_x, end_value_y 	= vint_get_property(tween_h, "end_value") 
  269. 			vint_set_property(tween_h, "end_value",	 start_value_x, start_value_y) 
  270. 			vint_set_property(tween_h, "start_value", end_value_x, end_value_y) 
  271. 		elseif property_name == "alpha" or property_name == "rotation" then 
  272. 			--Single value properties 
  273. 			local start_value	= vint_get_property(tween_h, "start_value") 
  274. 			local end_value	= vint_get_property(tween_h, "end_value") 
  275. 			vint_set_property(tween_h, "start_value", end_value) 
  276. 			vint_set_property(tween_h, "end_value", 	start_value) 
  277. 		elseif property_name == "tint" then 
  278. 			--Tint 
  279. 			local start_value_r, start_value_g, start_value_b 	= vint_get_property(tween_h, "start_value") 
  280. 			local end_value_r, end_value_g, end_value_b	= vint_get_property(tween_h, "end_value") 
  281. 			vint_set_property(tween_h, "end_value",	 	start_value_r, start_value_g, start_value_b) 
  282. 			vint_set_property(tween_h, "start_value", 	end_value_r, end_value_g, end_value_b) 
  283. 		end 
  284. 		 
  285. 		--Change tween start time 
  286. 		local tween_start_time			= vint_get_property(tween_h, "start_time") 
  287. 		local tween_duration				= vint_get_property(tween_h, "duration") 
  288. 		local new_tween_start_time  	= max_anim_length - tween_start_time - tween_duration 
  289. 		vint_set_property(tween_h, "start_time", new_tween_start_time) 
  290. 		tween_h = vint_object_next_sibling(tween_h) 
  291. 	end 
  292. end 
  293.  
  294. function var_to_string(var) 
  295. 	local t = type(var)  
  296. 	if t == "table" then 
  297. 		return "{table}" 
  298. 	elseif var == nil then 
  299. 		return "nil" 
  300. 	elseif var == true then 
  301. 		return "true" 
  302. 	elseif var == false then 
  303. 		return "false" 
  304. 	elseif t == "number" then 
  305. 		return "" .. var 
  306. 	else 
  307. 		return var 
  308. 	end 
  309. end 
  310.  
  311. --Sets actual size of the element. This is independant of the parent scaler values. 
  312. function element_set_actual_size(element_h, width, height) 
  313. 	local current_width, current_height = vint_get_property(element_h, "unscaled_size") 
  314. 	if current_width == nil or current_height == nil then 
  315. 		debug_print("vint", "Can't set actual size, element handle: " .. element_h .. " does not exist.\n") 
  316. 		return false 
  317. 	end 
  318. 	if width == nil or width == nil then 
  319. 		debug_print("vint", "Can't set actual size, element handle: " .. element_h .. " does not exist.\n") 
  320. 		return false 
  321. 	end 
  322. 	 
  323. 	local scale_x = width/current_width 
  324. 	local scale_y = height/current_height 
  325. 	vint_set_property(element_h, "scale", scale_x, scale_y) 
  326. 	return true 
  327. end 
  328.  
  329. --Returns actual size of the element, indpendant from the parent scaler values. 
  330. function element_get_actual_size(element_h) 
  331. 	local width, height = vint_get_property(element_h, "unscaled_size") 
  332. 	local scale_x, scale_y = vint_get_property(element_h, "scale") 
  333. 	if width == nil or width == nil or scale_x == nil or scale_y == nil then 
  334. 		debug_print("vint", "Can't get actual size, element handle: " .. element_h .. " does not exist.\n") 
  335. 		return 0, 0 
  336. 	end 
  337. 	 
  338. 	width = width * scale_x 
  339. 	height = height * scale_y 
  340. 	return width, height 
  341. end 
  342.  
  343. function element_get_scale_from_size(element_h, width, height) 
  344. 	local current_width, current_height = vint_get_property(element_h, "unscaled_size") 
  345. 	if current_width == nil or current_height == nil then 
  346. 		debug_print("vint", "Can't set actual size, element handle: " .. element_h .. " does not exist.\n") 
  347. 		return 0, 0 
  348. 	end 
  349. 	local scale_x = width/current_width 
  350. 	local scale_y = height/current_height 
  351. 	return scale_x, scale_y 
  352. end 
  353.  
  354. ------------------------------------------------------------------------------- 
  355. -- Returns the size of the first level elements within a group. 
  356. -- Notes: (ONLY 1 Deep, does not recurse), (Does not work on Vdos) 
  357. --  
  358. -- 
  359. function group_get_actual_size(group_h) 
  360. 	if group_h == 0 or group_h == nil then 
  361. 		debug_print("vint", "Not a valid group handle. Found data type: " .. type(group_h) .. "\n") 
  362. 	end 
  363.  
  364. 	local a_x, a_y, b_x, b_y 
  365.  
  366. 	local child_h = vint_object_first_child(group_h) 
  367. 	while true do 
  368.  
  369. 		local x, y = vint_get_property(child_h, "anchor") 
  370. 		local width, height = element_get_actual_size(child_h) 
  371. 		 
  372. 		local c_x = x 
  373. 		local c_y = y 
  374. 		local d_x = x + width 
  375. 		local d_y = y + height 
  376. 		 
  377. 		if a_x == nil then 
  378. 			a_x = x 
  379. 			a_y = y 
  380. 			b_x = x 
  381. 			b_y = y 
  382. 		end 
  383. 		 
  384. 		a_x = min(c_x, a_x) 
  385. 		a_y = min(c_y, a_y) 
  386. 		b_x = max(d_x, b_x) 
  387. 		b_y = max(d_y, b_y) 
  388.  
  389. 		child_h = vint_object_next_sibling(child_h) 
  390. 		if child_h == nil or child_h == 0 then 
  391. 			break 
  392. 		end 
  393. 	end 
  394. 	 
  395. 	local width 	= b_x - a_x 
  396. 	local height 	= b_y - a_y  
  397. 	 
  398. 	return width, height 
  399. end 
  400.  
  401. ------------------------------------------------------------------------------- 
  402. -- Align elements in vertical direction... 
  403. --		 local data = { 
  404. --				{	h = handle, 
  405. --					type = VINT_OBJECT_GROUP 
  406. --					space = 10,}, 
  407. --				{	h = handle, 
  408. --					type = VINT_OBJECT_GROUP 
  409. --					space = 10,}, 
  410. --			} 
  411. -- @returns width and height of all the elements 
  412. ------------------------------------------------------------------------------- 
  413. ------------------------------------------------------------------------------- 
  414. -- Align elements in vertical direction... 
  415. --		 local data = { 
  416. --				{	h = handle, 
  417. --					type = VINT_OBJECT_GROUP 
  418. --					space = 10,}, 
  419. --				{	h = handle, 
  420. --					type = VINT_OBJECT_GROUP 
  421. --					space = 10,}, 
  422. --			} 
  423. -- @returns width and height of all the elements 
  424. ------------------------------------------------------------------------------- 
  425. function vint_align_elements(data) 
  426. 	local x, y, width, height 
  427. 	local space = 0  
  428. 	local prev_x 		= 0 
  429. 	local prev_y 		= 0 
  430. 	local prev_width 	= 0 
  431. 	local prev_height = 0 
  432. 	local start_x, start_y  
  433. 	for idx, element in pairs(data) do 
  434. 		x, y = vint_get_property(element.h, "anchor") 
  435. 		if idx < 2 then 
  436. 			--first element will start their positions from original spot. 
  437. 			start_x = x 
  438. 			prev_x = x 
  439. 			start_y = y 
  440. 			prev_y = y 
  441. 			--skip spacing of first element. 
  442. 			space = 0 
  443. 		else 
  444. 			--elements after 1 will use the spacing variable... 
  445. 			space = element.space 
  446. 		end 
  447. 		if element.type == VINT_OBJECT_GROUP then 
  448. 			width, height = group_get_actual_size(element.h) 
  449. 		elseif element.type == VINT_OBJECT_INVALID then 
  450. 			width = 0 
  451. 			height = 0 
  452. 		else 
  453. 			width, height = element_get_actual_size(element.h) 
  454. 		end 
  455. 		 
  456. 		y = prev_y + prev_height + space 
  457. 		vint_set_property(element.h, "anchor", x, y) 
  458. 		prev_x = x 
  459. 		prev_y = y 
  460. 		prev_width 	= width 
  461. 		prev_height = height 
  462. 	end 
  463. 	width 	= x + width - start_x  
  464. 	height 	= y + height - start_y 
  465. 	return width, height 
  466. end 
  467.  
  468. ------------------------------------------------------------------------------- 
  469. -- A debug function that does a debug_print of values of a dataitem paired with strings. 
  470. -- Outputs to the console window the dataitem handle along with the paired values 
  471. -- for the strings entered. 
  472. -- 
  473. -- @param di_h		The dataitem that you would like to print. 
  474. -- @param ...		Arguments each item in dataitem 
  475.  
  476. -- Example: dataitem_to_debug(di_h, "icon_bmp_name", "coord_x", "coord_y") 
  477. ------------------------------------------------------------------------------- 
  478. function dataitem_to_debug(di_h, ...) 
  479. 	local data = {} 
  480. 	data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15], data[16], data[17], data[18], data[19], data[20], data[21], data[22], data[23], data[24] = vint_dataitem_get(di_h)  
  481. 	 
  482. 	local return_string = "\n" 
  483. 	 
  484. 	debug_print("vint", "DATAITEM: di_h\n") 
  485. 	 
  486. 	for idx, val in pairs(arg) do 
  487. 		if type(idx) ~= "string" then 
  488. 			if idx > 25 then 
  489. 				debug_print("vint", "Too much data for this debug function dataitem_to_debug(). Increase number of arguments on the dataitem get.\n") 
  490. 				return 
  491. 			end 
  492. 			 
  493. 			if idx > 0 then  
  494. 				--Print... dataitem_name, and value... 
  495. 				if idx == arg.n then 
  496. 					--Last string in list... do a double return. 
  497. 					return_string = "\n\n" 
  498. 				end 
  499. 				debug_print("vint", "  " .. val .. ":\t\t" .. var_to_string(data[idx]) .. return_string) 
  500. 			end 
  501. 		end		 
  502. 	end 
  503. end 
  504.  
  505. --------------------------------------------------------------- 
  506. --  Returns scaled value if game is in standard def 
  507. -- 
  508. -- @param value          - Value to scale for std def 
  509. -- @param operator       - Determines which operator 
  510. --                         to perform on value 
  511. --                              
  512. --                       0 = multiply (default) 
  513. --                       1 = divide 
  514. --------------------------------------------------------------- 
  515. function vint_to_std_res(value, operator) 
  516. 	if vint_is_std_res() then  
  517.       if operator == nil or operator == 0 then 
  518. 			value = value * SCALE_STD_RES 
  519. 		elseif operator == 1 then 
  520. 			value = value / SCALE_STD_RES 
  521. 		end 
  522.     return value 
  523. 	end 
  524. 	return value 
  525. end	 
  526.  
  527. -- Support for hud monkey business 
  528. Hud_has_focus = true 
  529.  
  530. -- Math stuffs 
  531. PI = 3.1415 
  532. PI2 = 6.283 
  533.  
  534. --======================================= 
  535. --MP Utilities 
  536. --======================================= 
  537. MP_gameplay_mode_names = { 
  538. 	"Pre-game lobby", 
  539. 	"Gangsta Brawl", 
  540. 	"Team Gangsta Brawl", 
  541. 	"Braveheart", 
  542. 	"Multiplayer Creation", 
  543. 	"Multiplayer Customization", 
  544. 	"Multiplayer Game Results", 
  545. 	"Multiplayer Scoreboard", 
  546. 	"Multiplayer Tutorial", 
  547. } 
  548.  
  549. function mp_is_enabled() 
  550. 	--Get some multiplayer Data 
  551. 	local gp_mode = game_get_pending_game_play_mode() 
  552. 	for i, m in pairs( MP_gameplay_mode_names ) do 
  553. 		if gp_mode == m then 
  554. 			--found a match 
  555. 			return true 
  556. 		end 
  557. 	end 
  558. 	 
  559. 	gp_mode = game_get_game_play_mode() 
  560. 	for i, m in pairs( MP_gameplay_mode_names ) do 
  561. 		if gp_mode == m then 
  562. 			--found a match 
  563. 			return true 
  564. 		end 
  565. 	end 
  566. 	return false 
  567. end 
  568.  
  569. function ui_play_pain_audio() 
  570. 	audio_object_post_event("Play_Gat_Vending_Pain", nil, nil, nil, false) 
  571. end 
  572.  
  573. function ui_audio_post_event( event_name ) 
  574. 	audio_object_post_event(event_name, nil, nil, nil, false) 
  575. end 
  576.  
  577. --####################################### 
  578. --Audio Delay 
  579. --####################################### 
  580. function audio_play_delayed(sound_id, offset) 
  581. 	thread_new("audio_play_delayed_thread", sound_id, offset) 
  582. end 
  583.  
  584. function audio_play_delayed_thread(sound_id, offset) 
  585. 	delay(offset) 
  586. 	game_audio_play(sound_id) 
  587. end 
  588.  
  589. function format_cash(cash) 
  590. 	return game_format_int_to_string(cash) 
  591. end 
  592.  
  593. function format_cash_add_padding(c) 
  594. 	if c < 10 then 
  595. 		return "00" .. c 
  596. 	elseif c < 100 then 
  597. 		return "0" .. c 
  598. 	else  
  599. 		return c 
  600. 	end 
  601. end 
  602.  
  603. function format_distance(distance_in_meters) 
  604.  
  605. 	local distance_in_feet 
  606. 	local distance_str 
  607. 	 
  608. 	if game_use_imperial_units() then 
  609. 	 
  610. 		distance_in_feet = distance_in_meters * FEET_PER_METER		 
  611. 		distance_str = floor(distance_in_feet).." ft" 
  612. 		 
  613. 		return distance_str 
  614. 	 
  615. 	else 
  616. 		 
  617. 		distance_str = floor(distance_in_meters).." m" 
  618. 	 
  619. 		return distance_str 
  620. 	 
  621. 	end 
  622.  
  623. end 
  624.  
  625. ------------------------------------------------------------------------------- 
  626. -- Formats seconds into clock format 
  627. -- @param	time_in_seconds	time in seconds 
  628. -- @param	show_ms				whether or not you want to show ms (00:00 or 00:00.00) 
  629. -- 
  630. function format_clock(time_in_seconds, show_ms) 
  631. 	 
  632. 	local neg_symbol = "" 
  633. 	 
  634. 	if time_in_seconds < 0 then 
  635. 		time_in_seconds = abs(time_in_seconds) 
  636. 		neg_symbol  = "-" 
  637. 	end 
  638.  
  639. 	-- Format the time 
  640. 	local minutes = floor(time_in_seconds / 60) 
  641. 	local milliseconds =  (time_in_seconds * 1000) % 1000 
  642. 	local seconds = floor(time_in_seconds) % 60 
  643. 	 
  644. 	seconds = abs(seconds) -- Negative time is handled earlier, this should always be positive. 
  645. 	 
  646. 	-- Pad the seconds for the timer 
  647. 	if seconds < 10 and minutes > 0 then 
  648. 		seconds = "0" .. seconds 
  649. 	end 
  650. 	 
  651. 	if show_ms == true then 
  652. 		-- Only show one decimal place 
  653. 		milliseconds = milliseconds * .01 
  654. 	 
  655. 		milliseconds = floor(milliseconds)	 
  656. 	 
  657. 		if minutes > 0 then 
  658. 			return neg_symbol .. minutes .. ":" .. seconds .. "." .. milliseconds 
  659. 		else 
  660. 			return neg_symbol .. seconds .. "." .. milliseconds 
  661. 		end 
  662. 	else 
  663. 		if minutes > 0 then 
  664. 			return neg_symbol .. minutes .. ":" .. seconds  
  665. 		else 
  666. 			return neg_symbol .. seconds 
  667. 		end 
  668. 	end 
  669. end 
  670.  
  671.  
  672. ---------------------------------------------------------------------------------------------- 
  673. -- Function format_time() 
  674. -- 
  675. -- Formats seconds into time format 00:00 min or 00:00.00 min 
  676. -- 
  677. -- @param	time_in_seconds	time in seconds 
  678. -- @param	show_ms				whether or not you want to show ms 
  679. -- @param	show_units			whether or not you want to show units of time ("mins" or "secs") 
  680. -- @param	units_in_caps		show units in ALL CAPS 
  681. -- @param	show_colon			show colon for time under 1 min (ex: ":33" vs "33") 
  682. -- 
  683. ---------------------------------------------------------------------------------------------- 
  684. function format_time(time_in_seconds, show_ms, show_units, units_in_caps, show_colon) 
  685. 	 
  686. 	-- since show_units is a new addition and the default behavior is to show units 
  687. 	-- defaulting nil to true 
  688. 	if show_units == nil then 
  689. 		show_units = true 
  690. 	end 
  691. 	 
  692. 	local neg_symbol = "" 
  693. 	 
  694. 	if time_in_seconds < 0 then 
  695. 		time_in_seconds = abs(time_in_seconds) 
  696. 		neg_symbol  = "-" 
  697. 	end 
  698.  
  699. 	-- Format the time 
  700. 	local minutes = floor(time_in_seconds / 60) 
  701. 	local milliseconds =  (time_in_seconds * 1000) % 1000 
  702. 	local seconds = floor(time_in_seconds) % 60 
  703. 	 
  704. 	seconds = abs(seconds) -- Negative time is handled earlier, this should always be positive. 
  705. 	 
  706. 	-- Pad the seconds for the timer 
  707. 	if seconds < 10 then 
  708. 		seconds = "0" .. seconds 
  709. 	end 
  710. 	 
  711. 	if show_ms == true then 
  712. 	 
  713. 		-- Only show one decimal place 
  714. 		milliseconds = milliseconds * .01 
  715. 	 
  716. 		milliseconds = floor(milliseconds)	 
  717. 	 
  718. 		--localize "secs" and "mins" then return string 
  719. 		if minutes > 0 then 
  720. 			if show_units == false then 
  721. 				return neg_symbol .. minutes .. ":" .. seconds .. ".".. milliseconds 
  722. 			else 
  723. 				local insert_values = {[0] = neg_symbol .. minutes .. ":" .. seconds .. ".".. milliseconds} 
  724. 				 
  725. 				local body 
  726. 				if units_in_caps == true then 
  727. 					body = vint_insert_values_in_string("FORMAT_TIME_MINS_CAPS", insert_values) 
  728. 				else 
  729. 					body = vint_insert_values_in_string("FORMAT_TIME_MINS", insert_values) 
  730. 				end 
  731. 				 
  732. 				return body 
  733. 			end 
  734. 		else 
  735. 			if show_units == false then 
  736. 				if show_colon == true then 
  737. 					return neg_symbol .. ":" .. seconds .. "."..milliseconds 
  738. 				else 
  739. 					return neg_symbol .. seconds .. "."..milliseconds 
  740. 				end 
  741. 			else 
  742. 				local insert_values 
  743. 				if show_colon == true then 
  744. 					insert_values = {[0] = neg_symbol .. ":" .. seconds .. "."..milliseconds} 
  745. 				else 
  746. 					insert_values = {[0] = neg_symbol .. seconds .. "."..milliseconds} 
  747. 				end 
  748. 				 
  749. 				local body 
  750. 				if units_in_caps == true then 
  751. 					body = vint_insert_values_in_string("FORMAT_TIME_SECS_CAPS", insert_values) 
  752. 				else 
  753. 					body = vint_insert_values_in_string("FORMAT_TIME_SECS", insert_values) 
  754. 				end 
  755. 				 
  756. 				return body		 
  757. 			end	 
  758. 		end 
  759. 	else 
  760. 		if minutes > 0 then 
  761. 			if show_units == false then 
  762. 				return neg_symbol .. minutes .. ":" .. seconds 
  763. 			else 
  764. 				local insert_values = {[0] = neg_symbol .. minutes .. ":" .. seconds} 
  765. 				 
  766. 				local body 
  767. 				if units_in_caps == true then 
  768. 					body = vint_insert_values_in_string("FORMAT_TIME_MINS_CAPS", insert_values) 
  769. 				else 
  770. 					body = vint_insert_values_in_string("FORMAT_TIME_MINS", insert_values) 
  771. 				end 
  772. 				 
  773. 				return body	 
  774. 			end			 
  775. 		else 
  776. 			if show_units == false then 
  777. 				if show_colon == true then 
  778. 					return neg_symbol .. ":" .. seconds 
  779. 				else 
  780. 					return neg_symbol .. seconds 
  781. 				end 
  782. 			else 
  783. 				local insert_values 
  784. 				if show_colon == true then 
  785. 					insert_values = {[0] = neg_symbol .. ":" .. seconds} 
  786. 				else 
  787. 					insert_values = {[0] = neg_symbol .. seconds} 
  788. 				end 
  789. 				 
  790. 				local body 
  791. 				if units_in_caps == true then 
  792. 					body = vint_insert_values_in_string("FORMAT_TIME_SECS_CAPS", insert_values) 
  793. 				else 
  794. 					body = vint_insert_values_in_string("FORMAT_TIME_SECS", insert_values) 
  795. 				end 
  796. 				 
  797. 				return body			 
  798. 			end 
  799. 		end 
  800. 	end 
  801. end 
  802.  
  803.  
  804. ---------------------------------------------------------------------------------------------------- 
  805. -- Button remapping... 
  806. ---------------------------------------------------------------------------------------------------- 
  807. --Map buttons for globals on ui init 
  808. CTRL_MENU_BUTTON_A = -1 
  809. CTRL_GAMEPLAY_BUTTON_A = -1 
  810. CTRL_MENU_BUTTON_B = -1 
  811. CTRL_GAMEPLAY_BUTTON_B = -1 
  812. CTRL_BUTTON_X = -1 
  813. CTRL_BUTTON_Y = -1 
  814.  
  815. CTRL_BUTTON_LB = -1 
  816. CTRL_BUTTON_LT = -1 
  817. CTRL_BUTTON_RB = -1 
  818. CTRL_BUTTON_RT = -1 
  819.  
  820. CTRL_BUTTON_LS = -1 
  821. CTRL_BUTTON_LS_PRESS = -1 
  822. CTRL_BUTTON_RS = -1 
  823. CTRL_BUTTON_RS_PRESS = -1 
  824.  
  825. CTRL_BUTTON_DPAD = -1 
  826. CTRL_BUTTON_DPAD_UP = -1 
  827. CTRL_BUTTON_DPAD_DOWN = -1 
  828. CTRL_BUTTON_DPAD_LEFT = -1 
  829. CTRL_BUTTON_DPAD_RIGHT = -1 
  830.  
  831. CTRL_BUTTON_DPAD_UP_DOWN = -1 
  832. CTRL_BUTTON_DPAD_LEFT_RIGHT = -1 
  833.  
  834. CTRL_MENU_BUTTON_BACK = -1 
  835. CTRL_BUTTON_START = -1 
  836.  
  837. CTRL_BUTTON_MOUSE_SCROLL = -1 
  838.  
  839. function vint_lib_init_buttons() 
  840. 	--Map buttons for globals on ui init 
  841. 	-- 
  842. 	-- SEH 8/15/2011: PS3 can swap the meaning of the accept and cancel buttons for menus, but we don't want to 
  843. 	-- swap them for gameplay.  Making separate variables to handle this.  Ideally, for SR4, the other buttons will 
  844. 	-- get renamed to be more consistent, or how this is handled will be changed. 
  845. 	-- 
  846. 	CTRL_MENU_BUTTON_A = get_a_button(false) 
  847. 	CTRL_GAMEPLAY_BUTTON_A = get_a_button(true) 
  848. 	CTRL_MENU_BUTTON_B = get_b_button(false) 
  849. 	CTRL_GAMEPLAY_BUTTON_B = get_b_button(true)	 
  850. 	CTRL_BUTTON_X = get_x_button() 
  851. 	CTRL_BUTTON_Y = get_y_button() 
  852.  
  853. 	CTRL_BUTTON_LB = get_lb_button() 
  854. 	CTRL_BUTTON_LT = get_lt_button() 
  855. 	CTRL_BUTTON_RB = get_rb_button() 
  856. 	CTRL_BUTTON_RT = get_rt_button() 
  857.  
  858. 	CTRL_BUTTON_LS 		= get_left_stick() 
  859. 	CTRL_BUTTON_LS_PRESS = get_ls_press_image() 
  860. 	CTRL_BUTTON_RS 		= get_right_stick() 
  861. 	CTRL_BUTTON_RS_PRESS = get_rs_press_image() 
  862.  
  863. 	CTRL_BUTTON_DPAD = get_dpad_image() 
  864. 	CTRL_BUTTON_DPAD_UP = get_dpad_up_image() 
  865. 	CTRL_BUTTON_DPAD_DOWN = get_dpad_down_image() 
  866. 	CTRL_BUTTON_DPAD_LEFT = get_dpad_left_image() 
  867. 	CTRL_BUTTON_DPAD_RIGHT = get_dpad_right_image() 
  868. 	CTRL_BUTTON_DPAD_UP_DOWN = get_dpad_ud_image() 
  869.    CTRL_BUTTON_DPAD_LEFT_RIGHT = get_dpad_lr_image() 
  870. 	 
  871. 	CTRL_MENU_BUTTON_BACK =  get_back_image() 
  872. 	CTRL_BUTTON_START = get_start_image() 
  873. 	 
  874. 	CTRL_BUTTON_MOUSE_SCROLL = get_mouse_scroll_image() 
  875. end 
  876.  
  877. -- this is now unofficially get_confirm_button! 
  878. function get_a_button(for_gameplay) 
  879. 	local button 
  880. 	local platform = game_get_platform() 
  881. 	if (platform == "XBOX360") or (platform == "PC") then 
  882. 		button = "ui_ctrl_360_btn_a" 
  883. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  884. 		button = "ui_ctrl_xbox3_btn_a" 
  885. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  886. 		local button_swap = game_get_ps3_button_swap() and for_gameplay == false 
  887. 		if button_swap == true then 
  888. 			button = "ui_ctrl_ps4_btn_circle" 
  889. 		else  
  890. 			button = "ui_ctrl_ps4_btn_cross" 
  891. 		end 
  892. 	else 
  893. 		local button_swap = game_get_ps3_button_swap() and for_gameplay == false 
  894. 		if button_swap == true then 
  895. 			button = "ui_ctrl_ps3_btn_circle" 
  896. 		else  
  897. 		-- old standard 
  898. 			button = "ui_ctrl_ps3_btn_cross" 
  899. 		end 
  900. 	end 
  901. 	 
  902. 	return button 
  903. end 
  904.  
  905. function get_x_button() 
  906. 	local button 
  907. 	local platform = game_get_platform() 
  908. 	if (platform == "XBOX360") or (platform == "PC") then 
  909. 		button = "ui_ctrl_360_btn_x" 
  910. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  911. 		button = "ui_ctrl_xbox3_btn_x" 
  912. 	elseif platform == "PS4" then		-- HVS_JRP[PRINCE] 3/18/2014 
  913. 		button = "ui_ctrl_ps4_btn_square" 
  914. 	else 
  915. 		button = "ui_ctrl_ps3_btn_square" 
  916. 	end 
  917. 	return button 
  918. end 
  919.  
  920. -- this is now unofficially get_back_button! 
  921. function get_b_button(for_gameplay) 
  922. 	local button 
  923. 	local platform = game_get_platform() 
  924. 	if (platform == "XBOX360") or (platform == "PC") then 
  925. 		button = "ui_ctrl_360_btn_b" 
  926. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  927. 		button = "ui_ctrl_xbox3_btn_b" 
  928. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  929. 		local button_swap = game_get_ps3_button_swap() and for_gameplay == false 
  930. 		if button_swap == true then 
  931. 			button = "ui_ctrl_ps4_btn_cross" 
  932. 		else  
  933. 			button = "ui_ctrl_ps4_btn_circle" 
  934. 		end 
  935. 	else 
  936. 		local button_swap = game_get_ps3_button_swap() and for_gameplay == false 
  937. 		if button_swap == true then 
  938. 			button = "ui_ctrl_ps3_btn_cross" 
  939. 		else  
  940. 			button = "ui_ctrl_ps3_btn_circle" 
  941. 		end 
  942. 	end 
  943. 	return button 
  944. end 
  945.  
  946. function get_y_button() 
  947. 	local button 
  948. 	local platform = game_get_platform() 
  949. 	if (platform == "XBOX360") or (platform == "PC") then 
  950. 		button = "ui_ctrl_360_btn_y" 
  951. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  952. 		button = "ui_ctrl_xbox3_btn_y" 
  953. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  954. 		button = "ui_ctrl_ps4_btn_triangle" 
  955. 	else 
  956. 		button = "ui_ctrl_ps3_btn_triangle" 
  957. 	end 
  958. 	return button 
  959. end 
  960.  
  961. function get_right_stick() 
  962. 	local button 
  963. 	local platform = game_get_platform() 
  964. 	if (platform == "XBOX360") or (platform == "PC") then 
  965. 		button = "ui_ctrl_360_btn_rs" 
  966. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  967. 		button = "ui_ctrl_xbox3_btn_rs" 
  968. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  969. 		button = "ui_ctrl_ps4_btn_r" 
  970. 	else 
  971. 		button = "ui_ctrl_ps3_btn_r" 
  972. 	end 
  973. 	return button 
  974. end 
  975.  
  976. function get_left_stick() 
  977. 	local button 
  978. 	local platform = game_get_platform() 
  979. 	if (platform == "XBOX360") or (platform == "PC") then 
  980. 		button = "ui_ctrl_360_btn_ls" 
  981. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  982. 		button = "ui_ctrl_xbox3_btn_ls" 
  983. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  984. 		button = "ui_ctrl_ps4_btn_l" 
  985. 	else 
  986. 		button = "ui_ctrl_ps3_btn_l" 
  987. 	end 
  988. 	return button 
  989. end 
  990.  
  991. function get_lt_button() 
  992. 	local button 
  993. 	local platform = game_get_platform() 
  994. 	if (platform == "XBOX360") or (platform == "PC") then 
  995. 		button = "ui_ctrl_360_btn_lt" 
  996. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  997. 		button = "ui_ctrl_xbox3_btn_lt" 
  998. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  999. 		button = "ui_ctrl_ps4_btn_l2" --HVS_TBT 8/27/2014 
  1000. 	else 
  1001. 		button = "ui_ctrl_ps3_btn_l1" 
  1002. 	end 
  1003. 	return button 
  1004. end 
  1005.  
  1006. function get_rt_button() 
  1007. 	local button 
  1008. 	local platform = game_get_platform() 
  1009. 	if (platform == "XBOX360") or (platform == "PC") then 
  1010. 		button = "ui_ctrl_360_btn_rt" 
  1011. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1012. 		button = "ui_ctrl_xbox3_btn_rt" 
  1013. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1014. 		button = "ui_ctrl_ps4_btn_r2" --HVS_TBT 8/27/2014 
  1015. 	else 
  1016. 		button = "ui_ctrl_ps3_btn_r1" 
  1017. 	end 
  1018. 	return button 
  1019. end 
  1020.  
  1021. function get_lb_button() 
  1022. 	local button 
  1023. 	local platform = game_get_platform() 
  1024. 	if (platform == "XBOX360") or (platform == "PC") then 
  1025. 		button = "ui_ctrl_360_btn_lb" 
  1026. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1027. 		button = "ui_ctrl_xbox3_btn_lb" 
  1028. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1029. 		button = "ui_ctrl_ps4_btn_l1" --HVS_TBT 8/27/2014 
  1030. 	else 
  1031. 		button = "ui_ctrl_ps3_btn_l2" 
  1032. 	end 
  1033. 	return button 
  1034. end 
  1035.  
  1036. function get_rb_button() 
  1037. 	local button 
  1038. 	local platform = game_get_platform() 
  1039. 	if (platform == "XBOX360") or (platform == "PC") then 
  1040. 		button = "ui_ctrl_360_btn_rb" 
  1041. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1042. 		button = "ui_ctrl_xbox3_btn_rb" 
  1043. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1044. 		button = "ui_ctrl_ps4_btn_r1" --HVS_TBT 8/27/2014 
  1045. 	else 
  1046. 		button = "ui_ctrl_ps3_btn_r2" 
  1047. 	end 
  1048. 	return button 
  1049. end 
  1050.  
  1051. function get_left_right() 
  1052. 	local button 
  1053. 	local platform = game_get_platform() 
  1054. 	if (platform == "XBOX360") or (platform == "PC") then 
  1055. 		button = "ui_ctrl_360_dpad_lr" 
  1056. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1057. 		button = "ui_ctrl_xbox3_dpad_lr" 
  1058. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1059. 		button = "ui_ctrl_ps4_dapd_lr" 
  1060. 	else 
  1061. 		button = "ui_ctrl_ps3_dapd_lr" 
  1062. 	end 
  1063. 	return button 
  1064. end 
  1065.  
  1066. function get_up_down() 
  1067. 	local button 
  1068. 	local platform = game_get_platform() 
  1069. 	if (platform == "XBOX360") or (platform == "PC") then 
  1070. 		button = "ui_ctrl_360_dpad_ud" 
  1071. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1072. 		button = "ui_ctrl_xbox3_dpad_ud" 
  1073. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1074. 		button = "ui_ctrl_ps4_dpad_ud" 
  1075. 	else 
  1076. 		button = "ui_ctrl_ps3_dpad_ud" 
  1077. 	end 
  1078. 	return button 
  1079. end 
  1080.  
  1081. function get_left_trigger() 
  1082. 	local button 
  1083. 	local platform = game_get_platform() 
  1084. 	if (platform == "XBOX360") or (platform == "PC") then 
  1085. 		button = "ui_ctrl_360_btn_lt" 
  1086. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1087. 		button = "ui_ctrl_xbox3_btn_lt" 
  1088. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1089. 		button = "ui_ctrl_ps4_btn_l2" 
  1090. 	else 
  1091. 		button = "ui_ctrl_ps3_btn_l2" 
  1092. 	end 
  1093. 	return button 
  1094. end 
  1095.  
  1096. function get_right_trigger() 
  1097. 	local button 
  1098. 	local platform = game_get_platform() 
  1099. 	if (platform == "XBOX360") or (platform == "PC") then 
  1100. 		button = "ui_ctrl_360_btn_rt" 
  1101. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1102. 		button = "ui_ctrl_xbox3_btn_rt" 
  1103. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1104. 		button = "ui_ctrl_ps4_btn_r2" 
  1105. 	else 
  1106. 		button = "ui_ctrl_ps3_btn_r2" 
  1107. 	end 
  1108. 	return button 
  1109. end 
  1110.  
  1111. function get_control_stick_base() 
  1112. 	local image 
  1113. 	local platform = game_get_platform() 
  1114. 	if (platform == "XBOX360") or (platform == "PC") then 
  1115. 		image = "ui_hud_radial_stick_base_xbox2" 
  1116. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1117. 		image = "ui_hud_radial_stick_base_xbox3" 
  1118. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1119. 		image = "ui_hud_radial_stick_base_ps4" 
  1120. 	else 
  1121. 		image = "ui_hud_radial_stick_base_ps3" 
  1122. 	end 
  1123. 	return image 
  1124. end 
  1125.  
  1126. function get_control_stick_thumb() 
  1127. 	local image 
  1128. 	local platform = game_get_platform() 
  1129. 	if (platform == "XBOX360") or (platform == "PC") then 
  1130. 		image = "ui_hud_radial_stick_thumb_xbox2" 
  1131. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1132. 		image = "ui_hud_radial_stick_thumb_xbox3" 
  1133. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1134. 		image = "ui_hud_radial_stick_thumb_ps4" 
  1135. 	else 
  1136. 		image = "ui_hud_radial_stick_thumb_ps3" 
  1137. 	end 
  1138. 	return image 
  1139. end 
  1140.  
  1141. function get_control_stick_text() 
  1142. 	local text 
  1143. 	local platform = game_get_platform() 
  1144. 	 
  1145. 	if pause_menu_is_using_southpaw_control_scheme() == true and game_is_local_player_in_vehicle() == false then 
  1146. 		if (platform == "XBOX360") or (platform == "PC") then 
  1147. 			text = "RS" 
  1148. 		elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1149. 			text = "RS" 
  1150. 		elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1151. 			text = "R" 
  1152. 		else 
  1153. 			text = "R" 
  1154. 		end	 
  1155. 	elseif pause_menu_is_using_vehicle_southpaw_control_scheme() == true and game_is_local_player_in_vehicle() == true then 
  1156. 		if (platform == "XBOX360") or (platform == "PC") then 
  1157. 			text = "RS" 
  1158. 		elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1159. 			text = "RS" 
  1160. 		elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1161. 			text = "R" 
  1162. 		else 
  1163. 			text = "R" 
  1164. 		end 
  1165. 	else  
  1166. 		if (platform == "XBOX360") or (platform == "PC") then 
  1167. 			text = "LS" 
  1168. 		elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1169. 			text = "LS" 
  1170. 		elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1171. 			text = "L" 
  1172. 		else 
  1173. 			text = "L" 
  1174. 		end	 
  1175. 	end  
  1176. 	return text 
  1177. end 
  1178.  
  1179. function get_dpad_image() 
  1180. 	local image 
  1181. 	local platform = game_get_platform() 
  1182. 	if (platform == "XBOX360") or (platform == "PC") then 
  1183. 		image = "ui_hud_radial_dpad_xbox2" 
  1184. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1185. 		image = "ui_hud_radial_dpad_xbox3" 
  1186. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1187. 		image = "ui_hud_radial_dpad_ps4" 
  1188. 	else 
  1189. 		image = "ui_hud_radial_dpad_ps3" 
  1190. 	end 
  1191. 	return image 
  1192. end 
  1193.  
  1194. function get_dpad_lr_image() 
  1195. 	local image 
  1196. 	local platform = game_get_platform() 
  1197. 	if (platform == "XBOX360") or (platform == "PC") then 
  1198. 		image = "ui_ctrl_360_dpad_lr" 
  1199. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1200. 		image = "ui_ctrl_xbox3_dpad_lr" 
  1201. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1202. 		image = "ui_ctrl_ps4_dpad_lr" 
  1203. 	else 
  1204. 		image = "ui_ctrl_ps3_dpad_lr" 
  1205. 	end 
  1206. 	return image 
  1207. end 
  1208.  
  1209. function get_dpad_ud_image() 
  1210. 	local image 
  1211. 	local platform = game_get_platform() 
  1212. 	if (platform == "XBOX360") or (platform == "PC") then 
  1213. 		image = "ui_ctrl_360_dpad_ud" 
  1214. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1215. 		image = "ui_ctrl_xbox3_dpad_ud" 
  1216. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1217. 		image = "ui_ctrl_ps4_dpad_ud" 
  1218. 	else 
  1219. 		image = "ui_ctrl_ps3_dpad_ud" 
  1220. 	end 
  1221. 	return image 
  1222. end 
  1223.  
  1224. function get_dpad_image() 
  1225. 	local image 
  1226. 	local platform = game_get_platform() 
  1227. 	if (platform == "XBOX360") or (platform == "PC") then 
  1228. 		image = "ui_ctrl_360_dpad_n" 
  1229. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1230. 		image = "ui_ctrl_xbox3_dpad_n" 
  1231. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1232. 		image = "ui_ctrl_ps4_dpad_n" 
  1233. 	else 
  1234. 		image = "ui_ctrl_ps3_dpad_n" 
  1235. 	end 
  1236. 	return image 
  1237. end 
  1238.  
  1239. function get_dpad_up_image() 
  1240. 	local image 
  1241. 	local platform = game_get_platform() 
  1242. 	if (platform == "XBOX360") or (platform == "PC") then 
  1243. 		image = "ui_ctrl_360_dpad_u" 
  1244. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1245. 		image = "ui_ctrl_xbox3_dpad_u" 
  1246. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1247. 		image = "ui_ctrl_ps4_dpad_u" 
  1248. 	else 
  1249. 		image = "ui_ctrl_ps3_dpad_u" 
  1250. 	end 
  1251. 	return image 
  1252. end 
  1253.  
  1254. function get_dpad_down_image() 
  1255. 	local image 
  1256. 	local platform = game_get_platform() 
  1257. 	if (platform == "XBOX360") or (platform == "PC") then 
  1258. 		image = "ui_ctrl_360_dpad_d" 
  1259. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1260. 		image = "ui_ctrl_xbox3_dpad_d" 
  1261. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1262. 		image = "ui_ctrl_ps4_dpad_d" 
  1263. 	else 
  1264. 		image = "ui_ctrl_ps3_dpad_d" 
  1265. 	end 
  1266. 	return image 
  1267. end 
  1268.  
  1269. function get_dpad_left_image() 
  1270. 	local image 
  1271. 	local platform = game_get_platform() 
  1272. 	if (platform == "XBOX360") or (platform == "PC") then 
  1273. 		image = "ui_ctrl_360_dpad_l" 
  1274. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1275. 		image = "ui_ctrl_xbox3_dpad_l" 
  1276. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1277. 		image = "ui_ctrl_ps4_dpad_l" 
  1278. 	else 
  1279. 		image = "ui_ctrl_ps3_dpad_l" 
  1280. 	end 
  1281. 	return image 
  1282. end 
  1283.  
  1284. function get_dpad_right_image() 
  1285. 	local image 
  1286. 	local platform = game_get_platform() 
  1287. 	if (platform == "XBOX360") or (platform == "PC") then 
  1288. 		image = "ui_ctrl_360_dpad_r" 
  1289. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1290. 		image = "ui_ctrl_xbox3_dpad_r" 
  1291. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1292. 		image = "ui_ctrl_ps4_dpad_r" 
  1293. 	else 
  1294. 		image = "ui_ctrl_ps3_dpad_r" 
  1295. 	end 
  1296. 	return image 
  1297. end 
  1298.  
  1299. function get_ls_press_image() 
  1300. 	local image 
  1301. 	local platform = game_get_platform() 
  1302. 	if (platform == "XBOX360") or (platform == "PC") then 
  1303. 		image = "ui_ctrl_360_btn_ls_press" 
  1304. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1305. 		image = "ui_ctrl_xbox3_btn_ls_press" 
  1306. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1307. 		image = "ui_ctrl_ps4_btn_l3" 
  1308. 	else 
  1309. 		image = "ui_ctrl_ps3_btn_l3" 
  1310. 	end 
  1311. 	return image 
  1312. end 
  1313.  
  1314. function get_rs_press_image() 
  1315. 	local image 
  1316. 	local platform = game_get_platform() 
  1317. 	if (platform == "XBOX360") or (platform == "PC") then 
  1318. 		image = "ui_ctrl_360_btn_rs_press" 
  1319. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1320. 		image = "ui_ctrl_xbox3_btn_rs_press" 
  1321. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1322. 		image = "ui_ctrl_ps4_btn_r3" 
  1323. 	else 
  1324. 		image = "ui_ctrl_ps3_btn_r3" 
  1325. 	end 
  1326. 	return image 
  1327. end 
  1328.  
  1329.  
  1330. function get_start_image() 
  1331. 	local image 
  1332. 	local platform = game_get_platform() 
  1333. 	if (platform == "XBOX360") or (platform == "PC") then 
  1334. 		image = "ui_ctrl_360_btn_start" 
  1335. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1336. 		image = "ui_ctrl_xbox3_btn_start" 
  1337. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1338. 		image = "ui_ctrl_ps4_btn_start" 
  1339. 	else 
  1340. 		image = "ui_ctrl_ps3_btn_start" 
  1341. 	end 
  1342. 	return image 
  1343. end 
  1344.  
  1345. function get_back_image() 
  1346. 	local image 
  1347. 	local platform = game_get_platform() 
  1348. 	if (platform == "XBOX360") or (platform == "PC") then 
  1349. 		image = "ui_ctrl_360_btn_back" 
  1350. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1351. 		image = "ui_ctrl_xbox3_btn_back" 
  1352. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1353. 		image = "ui_ctrl_ps4_btn_select" 
  1354. 	else 
  1355. 		image = "ui_ctrl_ps3_btn_select" 
  1356. 	end 
  1357. 	return image 
  1358. end 
  1359.  
  1360. function get_mouse_scroll_image() 
  1361. 	local image 
  1362. 	local platform = game_get_platform() 
  1363. 	if platform == "PC" then 
  1364. 		image = "ui_pc_icon_options" 
  1365. 	elseif platform == "XBOX360" then 
  1366. 		image = "ui_ctrl_360_btn_rs" 
  1367. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1368. 		image = "ui_ctrl_xbox3_btn_back" 
  1369. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1370. 		image = "ui_ctrl_ps4_btn_r" 
  1371. 	else 
  1372. 		image = "ui_ctrl_ps3_btn_r" 
  1373. 	end 
  1374. 	return image 
  1375. end 
  1376.  
  1377. function get_actual_a_button() 
  1378. 	local button 
  1379. 	local platform = game_get_platform() 
  1380. 	if (platform == "XBOX360") or (platform == "PC") then 
  1381. 		button = "ui_ctrl_360_btn_a" 
  1382. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1383. 		button = "ui_ctrl_xbox3_btn_a" 
  1384. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1385. 		button = "ui_ctrl_ps4_btn_cross" 
  1386. 	else 
  1387. 		button = "ui_ctrl_ps3_btn_cross" 
  1388. 	end 
  1389. 	 
  1390. 	return button 
  1391. end 
  1392.  
  1393. function get_actual_b_button() 
  1394. 	local button 
  1395. 	local platform = game_get_platform() 
  1396. 	if (platform == "XBOX360") or (platform == "PC") then 
  1397. 		button = "ui_ctrl_360_btn_b" 
  1398. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1399. 		button = "ui_ctrl_xbox3_btn_b" 
  1400. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1401. 		button = "ui_ctrl_ps4_btn_circle" 
  1402. 	else 
  1403. 		button = "ui_ctrl_ps3_btn_circle" 
  1404. 	end 
  1405. 	return button 
  1406. end 
  1407.  
  1408. function table_clone(src) 
  1409. 	local dst = { } 
  1410.  
  1411. 	if src == nil then 
  1412. 		return nil 
  1413. 	end 
  1414. 	 
  1415. 	for k, v in pairs(src) do 
  1416. --		if type(v) == "table" then 
  1417. --			dst[k] = table_clone(v) 
  1418. --		else 
  1419. 			dst[k] = v 
  1420. --		end 
  1421. 	end 
  1422. 	 
  1423. 	return dst 
  1424. end 
  1425.  
  1426. --[[ --------------------------------------------------------------------- 
  1427. -- Function - table_clear 
  1428. -- Description - Properly clears a table and cleans up its used memory 
  1429. -- Parameters -  
  1430. -- 		table_to_clear - table, The table to be cleared 
  1431. -- 		recursive_clean - bool, If true, clears out 2D tables if any are found 
  1432. -- Returns - nil 
  1433. ]]-- --------------------------------------------------------------------- 
  1434.  
  1435. function table_clear(table_to_clear, recursive_clean) 
  1436. 	 
  1437. 	if( type(recursive_clean) ~= "boolean" ) then 
  1438. 		--debug_print("vint", "vint_lib.lua :::: table_clear :::: type(recursive_clean) = " .. var_to_string(type(recursive_clean)) .. "\n") 
  1439. 		recursive_clean = false 
  1440. 	end 
  1441. 	 
  1442. 	if(table_to_clear ~= nil) then 
  1443. 		for x, table_item in pairs(table_to_clear) do 
  1444. 			--debug_print("vint", "vint_lib.lua :::: table_clear :::: x = " .. var_to_string(x) .. "\n") 
  1445. 			--debug_print("vint", "vint_lib.lua :::: table_clear :::: table_item = " .. var_to_string(table_item) .. "\n") 
  1446. 			 
  1447. 			if( recursive_clean )then 
  1448. 				if( type(table_item) == "table" )then 
  1449. 					--debug_print("vint", "vint_lib.lua :::: table_clear :::: FOUND 2D TABLE!\n\n") 
  1450. 					table_clear(table_item, true) 
  1451. 				end 
  1452. 			end 
  1453. 			 
  1454. 			--debug_print("vint", "vint_lib.lua :::: table_clear :::: CLEARING table_item = " .. var_to_string(table_item) .. ", x = " .. var_to_string(x) .."\n\n") 
  1455. 			table_to_clear[x] = nil	 
  1456. 		end 
  1457. 	end 
  1458. 	 
  1459. 	return 
  1460. end 
  1461.  
  1462. ------------------------------------------------------------------------------- 
  1463. -- Prints all the key value pairs for a table. (Does not do deep tables) 
  1464. -- 
  1465. function lua_debug_table(table) 
  1466. 	for key, val in pairs(table) do 
  1467. 		debug_print("vint", "key: " .. var_to_string(key) .. "| val: " .. var_to_string(val) .. "\n") 
  1468. 	end 
  1469. end 
  1470.  
  1471. --Limits value between low and high 
  1472. function limit(value, low, high) 
  1473. 	if value < low then 
  1474. 		value = low 
  1475. 	elseif value > high then 
  1476. 		value = high 
  1477. 	end 
  1478. 	 
  1479. 	return value 
  1480. end 
  1481.  
  1482. -- Helper function for list options that wraps indexes 
  1483. -- 
  1484. -- current_idx: current value 
  1485. -- direction: value to add/subtract 
  1486. -- max_idx: maximum index value 
  1487. -- min_idx: (optional) minimum index value, defaults to 1 
  1488. function wrap_index(current_idx, direction, max_idx, min_idx) 
  1489. 	min_idx = min_idx or 1 
  1490.  
  1491. 	local idx0 = (current_idx + direction - min_idx)	-- Base 0 
  1492. 	local base = max_idx - min_idx + 1 
  1493. 	 
  1494. 	return (idx0 % base) + min_idx 
  1495. end 
  1496.  
  1497.  
  1498. -- Helper function to hide children objects... 
  1499. -- 
  1500. -- object_h: object with children underneath to hide... 
  1501. function vint_hide_children(object_h) 
  1502. 	local h = vint_object_first_child(object_h) 
  1503. 	while true do  
  1504. 		if h == nil then 
  1505. 			break 
  1506. 		end 
  1507. 		vint_set_property(h, "visible", false) 
  1508. 		h = vint_object_next_sibling(h) 
  1509. 	end 
  1510. end 
  1511.  
  1512.  
  1513. -- Simple Callback function to loop animations from tweens... 
  1514. -- usage: vint_set_property(twn_h, "end_event", "vint_anim_loop_callback") 
  1515. -- This will cause the animation to continue to loop... 
  1516. function vint_anim_loop_callback(tween_h, event) 
  1517. 	local anim_h = vint_object_parent(tween_h) 
  1518. 	lua_play_anim(anim_h) 
  1519. end 
  1520.  
  1521. -- Helper function to dump pause map to get more memory in certain screens 
  1522. -- 
  1523. function pause_map_dump( wait ) 
  1524. 	local peg_name = "ui_map_world_city" 
  1525. 	game_peg_unload( peg_name ) 
  1526. 	 
  1527. 	if wait == true then 
  1528. 		while game_peg_is_loaded( peg_name ) do 
  1529. 			thread_yield() 
  1530. 		end 
  1531. 	end 
  1532. end 
  1533.  
  1534. function game_peg_unload_wait( peg_name ) 
  1535. 	game_peg_unload( peg_name ) 
  1536.  
  1537. 	while game_peg_is_loaded( peg_name ) do 
  1538. 		thread_yield() 
  1539. 	end 
  1540. end 
  1541.  
  1542. -- unload one or more pegs and wait for them to unload 
  1543. --  peg list (table, strings) - list of peg names to unload 
  1544. function game_peg_list_unload_wait( peg_list ) 
  1545. 	for k, v in pairs( peg_list ) do 
  1546. 		game_peg_unload( v ) 
  1547. 	end 
  1548.  
  1549. 	local all_unloaded 
  1550. 	 
  1551. 	repeat 
  1552. 		thread_yield() 
  1553. 		all_unloaded = true 
  1554. 		 
  1555. 		for k, v in pairs( peg_list ) do 
  1556. 			if game_peg_is_loaded( v ) then 
  1557. 				all_unloaded = false 
  1558. 				break 
  1559. 			end 
  1560. 		end 
  1561. 	until all_unloaded == true 
  1562. end 
  1563.  
  1564. function do_nothing() 
  1565. end 
  1566.  
  1567. -- Helper function to reload pause map 
  1568. -- 
  1569. function pause_map_restore() 
  1570. 	if (game_is_going_to_main_menu() == false) and (game_is_debug_reloading_level() == false) then 
  1571. 		game_peg_load_with_cb("do_nothing", 1, "ui_map_world_city")	 
  1572. 	end 
  1573. end 
  1574.  
  1575. -- Returns the widest element... useful for finding the longest string or element in a field... 
  1576. --  
  1577. --	@param	data	= { element_1_h, element_2_h, element_3_h }	(these are handles to elements you want to evaluate) 
  1578. -- 
  1579. -- @return largest_element_h		handle to largest element. 
  1580. -- @return largest_width			width of largest element... 
  1581. function find_widest_text_element(data) 
  1582. 	local width, height 
  1583. 	local largest_width = 0 
  1584. 	local largest_element_h = 0 
  1585. 	for idx, val in pairs(data) do 
  1586. 		width, height = element_get_actual_size(val) 
  1587. 		if width > largest_width then 
  1588. 			largest_width = width 
  1589. 			largest_element_h = val 
  1590. 		end 
  1591. 	end 
  1592. 	return largest_element_h, floor(largest_width) 
  1593. end 
  1594.  
  1595. ------------------------------------------------------------------------------- 
  1596. -- Debug prints all objects in the document tree 
  1597. -- @param vint_doc_name string for vint document e.g. "hud" 
  1598. --  
  1599. function vint_debug_safe_frame(vint_doc_name) 
  1600. 	local doc_h = vint_document_find(vint_doc_name) 
  1601. 	if doc_h == 0 or doc_h == nil then 
  1602. 		debug_print("vint", "vint_debug_safe_frame() " .. var_to_string(vint_doc_name) .. " was not found...\n") 
  1603. 		return 
  1604. 	end 
  1605.  
  1606. 	local safe_frame_h = vint_object_find("safe_frame", 0, doc_h) 
  1607. 	vint_debug_safe_frame_objects(safe_frame_h, 0) 
  1608. end 
  1609.  
  1610. ------------------------------------------------------------------------------- 
  1611. -- Debug prints all objects below the element sent in, 
  1612. -- @param vint_doc_name string for vint document e.g. "hud" 
  1613. --  
  1614. function vint_debug_safe_frame_objects(object_h, depth) 
  1615. 	if depth == nil then 
  1616. 		depth = 0 
  1617. 	end 
  1618. 	if object_h ~= nil and object_h ~= 0 then 
  1619. 		local depth_str = "" 
  1620. 		for i = 1, depth do 
  1621. 			depth_str = depth_str .. "   " 
  1622. 		end 
  1623. 		 
  1624. 		--Name, object 
  1625. 		local name = vint_object_get_name_from_handle(object_h) 
  1626. 		local debug_str = depth_str .."Name: " .. name 
  1627. 		debug_str = debug_str .. "(" ..  var_to_string(object_h) ..  ")\n" 
  1628. 		 
  1629. 		--Print it... 
  1630. 		debug_print("vint", debug_str) 
  1631. 	end 
  1632. 	 
  1633. 	local child_h = vint_object_first_child(object_h) 
  1634. 	if child_h ~= 0 and child_h ~= nil then 
  1635. 		vint_debug_safe_frame_objects(child_h, depth + 1) 
  1636. 	end 
  1637. 	 
  1638. 	local next_sibling_h = vint_object_next_sibling(object_h)  
  1639. 	if next_sibling_h ~= 0 and next_sibling_h ~= nil then 
  1640. 		vint_debug_safe_frame_objects(next_sibling_h, depth) 
  1641. 	end 
  1642. end 
  1643.  
  1644. ------------------------------------------------------------------------------- 
  1645. -- Online and Privilege  
  1646. ------------------------------------------------------------------------------- 
  1647. ONLINE_VALIDATOR_PASSED 				= 0 
  1648. ONLINE_VALIDATOR_NO_ONLINE_PRIV		= 1 
  1649. ONLINE_VALIDATOR_NOT_SIGNED_IN		= 2 
  1650. ONLINE_VALIDATOR_NOT_ONLINE			= 3 
  1651. ONLINE_VALIDATOR_NO_ETHERNET			= 4 
  1652. ONLINE_VALIDATOR_IN_PROGRESS			= 5 
  1653.  
  1654. Online_validator_result = ONLINE_VALIDATOR_PASSED 
  1655. Online_validator_privilege_check_service = false 
  1656. Online_validator_privilege_check_online = false 
  1657. Online_validator_privilege_check_chat = false 
  1658. Online_validator_privilege_fail_on_chat = false 
  1659.  
  1660. Powers_main_tutorial_enable = false 
  1661.  
  1662. function online_validator_check_privs() 
  1663. 	-- We need to wait a frame for PS3 to process the new multi login, otherwise the privileges are not up to date 
  1664. 	delay( 1 ) 
  1665.  
  1666. 	if Online_validator_privilege_check_online then 
  1667. 		if game_get_platform() == "PS4" then 
  1668. 			if main_menu_check_needs_patch() == true then 
  1669. 				Online_validator_result = ONLINE_VALIDATOR_NO_ONLINE_PRIV 
  1670. 				online_validator_set_checking(false) 
  1671. 				return 
  1672. 			elseif main_menu_check_online_privilege() == false then 
  1673. 				dialog_box_message("MENU_TITLE_WARNING", "MAIN_MENU_PRIVILEGE_DENIED") 
  1674. 				Online_validator_result = ONLINE_VALIDATOR_NO_ONLINE_PRIV 
  1675. 				online_validator_set_checking(false) 
  1676. 				return 
  1677. 			elseif main_menu_check_playstation_plus() == false then 
  1678. 				-- HVS_TJW, this isn't neat, but it shows the correct message when the router is unplugged 
  1679. 				-- this is only necessary because the Sony network connection state doesn't properly update in this instance 
  1680. 				if main_menu_check_presence() == false then 
  1681. 					dialog_box_message("MENU_TITLE_WARNING", "NO_NETWORK_CONNECTION") 
  1682. 					Online_validator_result = ONLINE_VALIDATOR_NO_ETHERNET 
  1683. 				else 
  1684. 					-- HVS_EC  Since we always display the "Join PS Plus" system message, this message is redundant. 
  1685. 					-- dialog_box_message("MENU_TITLE_WARNING", "NO_PLAYSTATION_PLUS_MESSAGE") 
  1686. 					Online_validator_result = ONLINE_VALIDATOR_NO_ONLINE_PRIV 
  1687. 				end 
  1688. 				online_validator_set_checking(false) 
  1689. 				return 
  1690. 			end 
  1691. 		elseif main_menu_check_online_privilege() == false then 
  1692. 		dialog_box_message("MENU_TITLE_WARNING", "MAIN_MENU_PRIVILEGE_DENIED") 
  1693. 		Online_validator_result = ONLINE_VALIDATOR_NO_ONLINE_PRIV 
  1694. 		online_validator_set_checking(false) 
  1695. 		return 
  1696. 	end 
  1697. 	end 
  1698. 	 
  1699. 	-- Chat most likely doesn't need a return code. It's just a warning 
  1700. 	-- also, we don't call it if it's already been shown for this login 
  1701. 	if Online_validator_privilege_check_chat and main_menu_check_chat_priv() == false then 
  1702. 		if Online_validator_privilege_fail_on_chat then 
  1703. 			Online_validator_result = ONLINE_VALIDATOR_NO_ONLINE_PRIV 
  1704. 			dialog_box_message("MENU_TITLE_WARNING", "USER_CONTENT_PRIV_DENIED") 
  1705. 			return 
  1706. 		else 
  1707. 			main_menu_maybe_show_voice_dialog() 
  1708. 			while(main_menu_wait_for_voice_dialog() == true) do 
  1709. 				thread_yield() 
  1710. 			end 
  1711. 		end 
  1712. 	end 
  1713. 	 
  1714. 	Online_validator_result = ONLINE_VALIDATOR_PASSED 
  1715. 	online_validator_set_checking(false) 
  1716. end 
  1717.  
  1718. function online_validator_sign_in_cb(result) 
  1719. 	main_menu_supress_profile_change(false) 
  1720. 	if game_is_signed_in() == false or  
  1721. 		(Online_validator_privilege_check_service and game_is_connected_to_service() == false) then 
  1722. 		local platform = game_get_platform() 
  1723. 		if platform ~= "PS3" then 
  1724. 			if platform == "XBOX3" then 
  1725. 				dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN_X3") 
  1726. 			else 
  1727. 				dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN") 
  1728. 			end 
  1729. 		end 
  1730. 		Online_validator_result = ONLINE_VALIDATOR_NOT_ONLINE 
  1731. 		online_validator_set_checking(false) 
  1732. 	else  
  1733. 		thread_new("online_validator_check_privs") 
  1734. 	end 
  1735. end 
  1736.  
  1737. function online_validator_profile_cb(result, action) 
  1738. 	if result == 0 then 
  1739. 		main_menu_supress_profile_change(true) 
  1740. 		game_sign_into_network(true, "online_validator_sign_in_cb") 
  1741. 	else 
  1742. 		Online_validator_result = ONLINE_VALIDATOR_NOT_SIGNED_IN 
  1743. 		online_validator_set_checking(false) 
  1744. 	end 
  1745. end 
  1746.  
  1747. function online_and_privilege_validator_begin(can_sign_in, check_service, check_online_priv, check_chat_priv, in_game, fail_on_chat) 
  1748. 	Online_validator_result = ONLINE_VALIDATOR_IN_PROGRESS  
  1749.  
  1750. 	Online_validator_privilege_check_service = check_service or false 
  1751. 	Online_validator_privilege_check_online = check_online_priv or false 
  1752. 	Online_validator_privilege_check_chat = check_chat_priv or false 
  1753. 	 
  1754. 	-- DAD - 9/14/11 - This is hacked in last minute, this should get cleaned up later 
  1755. 	Online_validator_privilege_fail_on_chat = fail_on_chat or false 
  1756. 	 
  1757. 	if game_is_connected_to_network() == false then 
  1758. 		dialog_box_message("MENU_TITLE_WARNING", "NO_NETWORK_CONNECTION") 
  1759. 		Online_validator_result = ONLINE_VALIDATOR_NO_ETHERNET 
  1760. 		return 
  1761. 	end 
  1762.  
  1763. 	online_validator_set_checking(true) 
  1764. 	 
  1765. 	--see if we're on a profile 
  1766. 	if game_is_signed_in() == false then 
  1767. 		if can_sign_in or not (game_get_platform() == "PS4") then			-- HVS_JRS 7/23/2014 PS4 signin is external to game 
  1768. 			dialog_box_confirmation("CONTROL_SIGN_IN", "MUST_SIGN_IN_PROFILE_CONFIRM", "online_validator_profile_cb") 
  1769. 		else 
  1770. 			local platform = game_get_platform() 
  1771.  
  1772. 			if main_menu_check_presence() == false then						-- HVS_JRS 11/18/2014 show no network connection if sceNpGetGamePresenceStatus() fails (PS4 only) 
  1773. 				debug_print("mp","Showing NO_NETWORK_CONNECTION instead of NOT_LOGGED_IN\n") 
  1774. 				dialog_box_message("MENU_TITLE_WARNING", "NO_NETWORK_CONNECTION") 
  1775. 				Online_validator_result = ONLINE_VALIDATOR_NO_ETHERNET 
  1776. 			else 
  1777. 				if platform == "XBOX3" then 
  1778. 					dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN_X3") 
  1779. 				else 
  1780. 					dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN") 
  1781. 				end 
  1782. 				Online_validator_result = ONLINE_VALIDATOR_NOT_SIGNED_IN 
  1783. 			end 
  1784. 			online_validator_set_checking(false) 
  1785. 		end 
  1786. 		return 
  1787. 	end 
  1788.  
  1789. 	-- See if we're connected to PSN or XBL 
  1790. 	if check_service == true and game_is_connected_to_service() == false then 
  1791. 		if game_get_platform() == "PC" then 
  1792. 			Online_validator_result = ONLINE_VALIDATOR_NOT_SIGNED_IN 
  1793. 			game_sign_into_network(true, "online_validator_sign_in_cb") 
  1794. 		elseif game_get_platform() == "PS3" then 
  1795. 			game_sign_into_network(true, "online_validator_sign_in_cb") 
  1796. 		else 
  1797. 			-- According to TCR/TRC, PS3 doesn't want a sign in prompt before hand, MS does. 
  1798. 			if in_game or (game_get_platform() == "PS4") then			-- HVS_JRS 7/14/2014 PS4 signin is external to game 
  1799. 				if main_menu_check_presence() == false then				-- HVS_JRS 11/18/2014 show no network connection if sceNpGetGamePresenceStatus() fails (PS4 only) 
  1800. 					debug_print("mp","Showing NO_NETWORK_CONNECTION instead of NOT_LOGGED_IN\n") 
  1801. 					dialog_box_message("MENU_TITLE_WARNING", "NO_NETWORK_CONNECTION") 
  1802. 					Online_validator_result = ONLINE_VALIDATOR_NO_ETHERNET 
  1803. 				else 
  1804. 					dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN") 
  1805. 					Online_validator_result = ONLINE_VALIDATOR_NOT_ONLINE 
  1806. 				end 
  1807. 				online_validator_set_checking(false) 
  1808. 			else 
  1809. 				if game_get_platform() == "XBOX3" then 
  1810. 					dialog_box_confirmation("CONTROL_SIGN_IN", "MUST_LOG_IN_CONFIRM_X3", "online_validator_profile_cb") 
  1811. 				else 
  1812. 					dialog_box_confirmation("CONTROL_SIGN_IN", "MUST_LOG_IN_CONFIRM", "online_validator_profile_cb") 
  1813. 				end 
  1814. 			end 
  1815. 		end 
  1816. 		return 
  1817. 	end 
  1818. 		 
  1819. 	online_validator_check_privs() 
  1820. 	 
  1821. 	if Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS then 
  1822. 		Online_validator_result = ONLINE_VALIDATOR_PASSED 
  1823. 	end 
  1824. 	online_validator_set_checking(false) 
  1825. end 
  1826.  
  1827. --Resize text thats too wide 
  1828. function resize_text_element(element_h, max_width) 
  1829. 	vint_set_property(element_h, "scale", 1, 1) 
  1830. 	local text_width, text_height = element_get_actual_size(element_h)	 
  1831. 	 
  1832. 	if text_width > max_width then 
  1833. 		local text_scale = max_width/text_width 
  1834. 		vint_set_property(element_h, "scale", text_scale, text_scale) 
  1835. 	end 
  1836. end 
  1837.  
  1838. function vint_debug_print(name, value)  
  1839. 	debug_print("vint", name .."::::" .. var_to_string(value) .. "\n") 
  1840. end 
  1841. 	 
  1842.  
  1843. --Glitch screen, hub style 
  1844. function glitch_cell() 
  1845. 	vint_set_glitch_preset("hub") 
  1846. 	vint_spike_glitch( 200, 0 ) 
  1847. end 
  1848.  
  1849. ------------------------------------------------------------------------------- 
  1850. -- Test Function 
  1851. ------------------------------------------------------------------------------- 
  1852. function test_interp_linear(time, start, delta) 
  1853. 	return delta * time + start 
  1854. end 
  1855.  
  1856.