sr2lua/hud_gsi.lua

  1. --######################################## 
  2. --GSI  
  3. --######################################## 
  4. Hud_gsi = { 
  5. 	status = { 
  6. 		config_index = -1, 
  7. 		config = -1, 
  8. 		indicator_count = 0, 
  9. 		grid_spacing = 10, 
  10. 		text_ind_spacing = 5, --Additional width for text only indicators 
  11. 		line_height = -1,		--Height of each indicator status line 
  12. 		box_height_offset = -1, --An offset for the height of the box (Changes per font) 
  13. 		state = -1, 
  14. 		clip_offset = 0, 
  15. 		diversion_level = -1, 
  16. 		fade_in_time = 1.5, 
  17. 		formatted = false, 
  18. 		queue_format = false, 
  19. 		debug_mode = false, 
  20. 		is_fading_out = false, 
  21. 	}, 
  22. 	indicators = { 
  23. 	}, 
  24. 	grid = { 
  25. 	},  
  26. 	elements = { 
  27. 		gsi_grp_h = -1, 
  28. 		icon_h = -1, 
  29. 		header_grp_h = -1, 
  30. 		indicators_grp_h = -1, 
  31. 		clip_h = -1, 
  32. 		title_text_h = -1, 
  33. 		level_text_h = -1, 
  34. 		level_div_text_h = -1, 
  35. 		x_y_ind_h = -1, 
  36. 		timer_h = -1, 
  37. 		info_h = -1, 
  38. 		meter_h = -1, 
  39. 	}, 
  40. 	header = { 
  41. 		width = -1, 
  42. 		height = -1, 
  43. 	}, 
  44. 	anims = { 
  45. 		x_y_in_anim = -1, 
  46. 		gsi_anim_in = -1, 
  47. 		gsi_anim_out = -1, 
  48. 		gsi_box_anim = -1, 
  49. 		gsi_level_change_anim = -1, 
  50. 	} 
  51. } 
  52.  
  53. Hud_gsi_skins = { 
  54. 	meter = { 
  55. 		["Default"] = 			{ tint = {0.89, 0.749, 0.05}	},		--Default: Yellow			 
  56. 		["Health"] = 			{ tint = {0.75, 0 , 0} 			},		--Description: Health 
  57.       ["Damage"] = 			{ tint = {0.89, 0.749, 0.05}	}, 	--Description: Yellow 
  58.       ["Radioactivity"] =  { tint = {0, 1, 0.25} 			},		--Description: NEON Greeen 
  59.       ["Media"] =				{ tint = {0, .5, 1 } 			},		--Description: Blue 
  60.       ["Taunt"] = 			{ tint = {0.89, 0.749, 0.05} 	},		--Description: Yellow 
  61.       ["Fear"] = 				{ tint = {0.89, 0.749, 0.05}	}, 	--Description: Yellow 
  62.       ["Pleasure"] = 		{ tint = {1, 0, .5}				}, 	--Description: Pink (Escort) 
  63.       ["Footage"] = 			{ tint = {0, .5, 1} 				}, 	--Description: Blue (Escort) 
  64. 		["Mayhem"] =			{ tint = {0.89, 0.749, 0.05}	},		--Descirption: Mayhem has special properties where it grabs the colors from hud_mayhem.lua 
  65. 		["Fight_Club"] =		{ tint = {0.75, 0 , 0} 	},				--Descirption: Fight club is basically a red bar but requires special update functionality because the label changes all the time. 
  66. 		["Nitrous"] =			{ tint = {0, .5, 1 } 			},		--Description: Blue 
  67.     
  68. 	} 
  69. } 
  70. Hud_gsi_meter_flash_data = {} 
  71.  
  72. Hud_gsi_audio = { 
  73. 	count_pos = audio_get_audio_id("SYS_HUD_CNTDWN_POS"), 
  74. 	count_neg = audio_get_audio_id("SYS_HUD_CNTDWN_NEG"), 
  75. 	end_pos = audio_get_audio_id("SYS_HUD_CNTDWN_ENDPOS"), 
  76. 	end_neg = audio_get_audio_id("SYS_HUD_CNTDWN_ENDNEG"), 
  77. 	div_complete = audio_get_audio_id("SYS_HUD_DIVERSION_COMPLETE"), 
  78. 	trail_blazing = audio_get_audio_id("SYS_RACE_CHECKPOINT"), 
  79. } 
  80.  
  81. --Order of creation is timer, x/y, meter, info 
  82. --GSI Indicator Indexes, increment these if there is more than one 
  83. HUD_GSI_TIMER = 0 
  84. HUD_GSI_XY = 1 
  85. HUD_GSI_METER = 5 
  86. HUD_GSI_INFO = 9 
  87.  
  88. --Config Indexes 
  89. HUD_GSI_CONFIG_COL = 1		--Column Number 
  90. HUD_GSI_CONFIG_ROW = 2		--Row Number 
  91. HUD_GSI_CONFIG_SKIN = 3		--Skin Type (Indicator Specific) 
  92.  
  93. --TODO: Write up behavors of skin types 
  94. --TODO: Make sure all the elements don't update their positions/widths every update. The meter has this functionality, it just needs to be adapted for the others. 
  95. -- 
  96. HUD_GSI_CONFIG_MISSION = 1000 
  97. HUD_GSI_CONFIG_RACING1 = 130 
  98. HUD_GSI_CONFIG_RACING2 = 131 
  99.  
  100. Hud_gsi.configs = { 
  101. 	--Insurance Fraud 
  102. 		--Row, Column, Indicator Handle, Indicator Type, Skin 
  103. 	[0] = {  
  104. 		[HUD_GSI_TIMER] = {0, 0,	"negative", }, 
  105. 		[HUD_GSI_XY] = 	{0, 1,	"Cash", 		}, 
  106. 		[HUD_GSI_METER] = 	{1, 0, 	"Cash", 			}, 
  107. 	},                            
  108. 	--Mayhem 
  109. 	[1] = {  
  110. 		[HUD_GSI_TIMER] = {0, 0,	"negative",	}, 
  111. 		[HUD_GSI_XY] = 	{0, 1,	"Cash", 		}, 
  112. 		[HUD_GSI_INFO] = 	{1, 0,	"Mayhem"	, 	}, 
  113. 		[HUD_GSI_METER] = {1, 1,	"Mayhem", 	}, 
  114. 	}, 
  115. 	--Fight Club 
  116. 	[10] = { 
  117. 		[HUD_GSI_XY] = {0, 0,		"", 	}, 
  118. 	}, 
  119. 	--FireTruck 
  120. 	[20] = {   
  121. 		[HUD_GSI_TIMER] = {0, 0,	"negative",	}, 
  122. 		[HUD_GSI_INFO]  =	{0, 1,	"normal",	}, 
  123. 	}, 
  124. 	-- Survival, Drive By 
  125. 	[30] = { 
  126. 		[HUD_GSI_TIMER] = {0, 0, 	"negative", }, 
  127. 		[HUD_GSI_INFO] = {0, 1, 	"",			}, 
  128. 	}, 
  129. 	--Taxi, Hostage 
  130. 	[35] = { 
  131. 		[HUD_GSI_TIMER] = {0, 0, 	"negative", }, 
  132. 		[HUD_GSI_INFO] = {0, 1, 	"Cash",			}, 
  133. 	}, 
  134. 	--Ambulance 
  135. 	[40] = {  
  136. 		[HUD_GSI_TIMER] = {0, 0, 	"negative",		}, 
  137. 		[HUD_GSI_XY] = 	{0, 1,	"", 				}, 
  138. 	}, 
  139. 	--Tow Truck, Flashing, Streaking, Snatch 
  140. 	[50] = { 
  141. 		[HUD_GSI_TIMER] = {0, 0, 	"negative",	}, 
  142. 		[HUD_GSI_XY] = 	{0, 1,	"normal", 		}, 
  143. 	}, 
  144. 	--Heli's alternate 
  145. 	[51] = { 
  146. 		[HUD_GSI_XY] = 	{0, 0,	"normal", 		}, 
  147. 	}, 
  148. 	--Heli's Car and XY 
  149. 	[52] = { 
  150. 		[HUD_GSI_XY] = 	{0, 0,	"normal", 		}, 
  151. 		[HUD_GSI_METER] = 	{1, 0,	"Default", 		}, 
  152. 	}, 
  153. 	--Heli for hire (Standard) 
  154. 	[53] = { 
  155. 		[HUD_GSI_TIMER] = {0, 0, 	"negative",	}, 
  156. 		[HUD_GSI_XY] = 	{0, 1,	"normal", 		}, 
  157. 	}, 
  158. 	--Pushback 
  159. 	[55] = { 
  160. 		[HUD_GSI_XY] = 	{0, 0,	"normal", }, 
  161. 	}, 
  162. 	--Fuzz 
  163. 	[60] = { 
  164. 		[HUD_GSI_TIMER]		= {0, 0,	"negative",	}, 
  165. 		[HUD_GSI_METER]		= {0, 1,	"Footage",	}, 
  166. 		[HUD_GSI_METER + 1]	= {1, 0,	"Default",	}, 
  167. 	}, 
  168. 	--Trail Blazing 
  169. 	[70] = { 
  170. 		[HUD_GSI_TIMER] = {0, 0,	"negative",	}, 
  171. 		[HUD_GSI_XY] = {0, 1, "normal", }, 
  172. 		[HUD_GSI_INFO] = {1, 0,	"TrailBlazing"	}, 
  173. 	}, 
  174. 	--Sewage 
  175. 	[80] = { 
  176. 		[HUD_GSI_XY] 		= {0, 0, "Cash_Flash_Disabled",	}, 
  177. 		[HUD_GSI_METER]	= {1, 0,	"Default", 		}, 
  178. 	}, 
  179. 	-- Ho-ing 
  180. 	[100] = { 
  181. 		[HUD_GSI_METER] 		= {0, 0, "Pleasure",			}, 
  182. 	}, 
  183. 	-- Drug Trafficking, 	 
  184. 	[110] = { 
  185. 	--	[HUD_GSI_TIMER] = {0, 0, 	"negative", }, 
  186. 		[HUD_GSI_XY] = 	{0, 0,	"",	}, 
  187. 	}, 
  188. 	--Demo Derby 
  189. 	[112] = { 
  190. 		[HUD_GSI_METER] = {0, 0, 	"Nitrous", }, 
  191. 		[HUD_GSI_XY] = 	{1, 0,	"Cash",	}, 
  192. 	}, 
  193. 	--Piracy 
  194. 	[115] = { 
  195. 		[HUD_GSI_TIMER] = {0, 0, 	"negative", }, 
  196. 	}, 
  197. 	--Crowd Control 
  198. 	[120] = { 
  199. 		[HUD_GSI_TIMER] = {0, 0, 	"negative",	}, 
  200. 		[HUD_GSI_XY] = {0, 1, 	"Cash",	}, 
  201. 		[HUD_GSI_METER] = {1, 0, 	"",			}, 
  202. 	}, 
  203. 	--Racing Solo 
  204. 	[130] = { 
  205. 		[HUD_GSI_TIMER]	= {0, 0, "negative",		}, 
  206. 		[HUD_GSI_XY] 		= {1, 0, "",				}, 
  207. 	}, 
  208. 	--Racing Competitive 
  209. 	[131] = { 
  210. 		[HUD_GSI_INFO] = 	{ 0, 0, 	"", 	}, 
  211. 		[HUD_GSI_XY]	=	{ 1, 0, 	"",	}, 
  212. 	}, 
  213. 	--Racing Co-op Competitive with AI 
  214. 	[132] = { 
  215. 		[HUD_GSI_XY] = { 0, 0, "", }, 
  216. 	}, 
  217. 	-- Escort 
  218. 	[140] = { 
  219. 		[HUD_GSI_METER] 		= {0, 0, "Pleasure",			}, 
  220. 		[HUD_GSI_METER + 1]	= {1, 0, "Footage",			}, 
  221. 	}, 
  222. 	-- Guardian_angel 
  223. 	[150] = { 
  224. 		[HUD_GSI_TIMER] 	= {0, 0, "Pleasure",			}, 
  225. 	}, 
  226. 	 
  227. 	--	Coop Diversions 
  228. 	[160] = { 
  229. 		[HUD_GSI_INFO] = { 0, 0, "", }, 
  230. 		[HUD_GSI_TIMER] = { 0, 1, "negative", }, 
  231. 		[HUD_GSI_INFO + 1] = { 1, 0, "", }, 
  232. 	}, 
  233.  
  234. 	----------------------------- 
  235. 	-- Strong Arm HUDS start here 
  236. 	----------------------------- 
  237. 	 
  238. 	-- SA Insurance Fraud, Racing 
  239. 	[200] = { 
  240. 		[HUD_GSI_TIMER]	= { 0, 0, "negative",	}, 
  241. 	}, 
  242. 	 
  243. 	-- SA Mayhem 
  244. 	[210] = { 
  245. 		[HUD_GSI_INFO] = 	{0, 0,	"Mayhem"	, 	}, 
  246. 		[HUD_GSI_METER] = {0, 1,	"Mayhem", 	}, 
  247. 		[HUD_GSI_TIMER] = {1, 0,	"negative",	}, 
  248. 	}, 
  249. 	 
  250. 	[1000] = { 
  251. 		--Mission HUD!? OMG WHAT IS THIS? 
  252. 	}, 
  253. } 
  254.  
  255. --legacy  
  256.  
  257. function hud_gsi_init() 
  258. 	 
  259. 	--debug_print("vint", "hud_gsi_init()\n") 
  260. 	--GSI 
  261. 	local h = vint_object_find("gsi_grp") 
  262. 	Hud_gsi.elements.gsi_grp_h = h	 
  263. 	Hud_gsi.elements.title_text_h = vint_object_find("title_txt", h) 
  264. 	Hud_gsi.elements.level_text_h = vint_object_find("level_txt", h)  
  265. 	Hud_gsi.elements.level_div_text_h = vint_object_find("level_div_txt", h) 
  266. 	Hud_gsi.elements.header_grp_h = vint_object_find("header_grp", h) 
  267. 	 
  268. 	Hud_gsi.elements.clip_h = vint_object_find("standard_clip", h) 
  269. 	Hud_gsi.elements.icon_h = vint_object_find("icon", h)  
  270. 	Hud_gsi.elements.indicators_grp_h = vint_object_find("indicators_grp", h)  
  271. 	 
  272. 	--GSI Elements 
  273. 	Hud_gsi.elements.xy_h 	= vint_object_find("xy_grp", h)  
  274. 	Hud_gsi.elements.timer_h = vint_object_find("timer_grp", h)  
  275. 	Hud_gsi.elements.info_h = vint_object_find("info_grp", h)  
  276. 	Hud_gsi.elements.meter_h = vint_object_find("meter_grp", h)  
  277. 	 
  278. 	Hud_gsi.elements.standard_grp_h = vint_object_find("standard_grp", h) 
  279. 	Hud_gsi.elements.standard_box_h = vint_object_find("standard_box", h) 
  280. 	 
  281. 	--GSI Standard Frame 
  282. 	Hud_gsi.elements.frame_standard = {} 
  283. 	Hud_gsi.elements.frame_standard.nw = vint_object_find("bg_nw", Hud_gsi.elements.standard_grp_h) 
  284. 	Hud_gsi.elements.frame_standard.n = vint_object_find("bg_n", Hud_gsi.elements.standard_grp_h) 
  285. 	Hud_gsi.elements.frame_standard.ne = vint_object_find("bg_ne", Hud_gsi.elements.standard_grp_h) 
  286. 	Hud_gsi.elements.frame_standard.e = vint_object_find("bg_e", Hud_gsi.elements.standard_grp_h) 
  287. 	Hud_gsi.elements.frame_standard.se = vint_object_find("bg_se", Hud_gsi.elements.standard_grp_h) 
  288. 	Hud_gsi.elements.frame_standard.s = vint_object_find("bg_s", Hud_gsi.elements.standard_grp_h) 
  289. 	Hud_gsi.elements.frame_standard.sw = vint_object_find("bg_sw", Hud_gsi.elements.standard_grp_h) 
  290. 	Hud_gsi.elements.frame_standard.w = vint_object_find("bg_w", Hud_gsi.elements.standard_grp_h) 
  291. 	Hud_gsi.elements.frame_standard.c = vint_object_find("bg_c", Hud_gsi.elements.standard_grp_h) 
  292. 	Hud_gsi.elements.frame_standard.ghost_c = vint_object_find("bg_c_ghost", Hud_gsi.elements.standard_grp_h) 
  293. 	 
  294. 	--GSI Animations 
  295. 	Hud_gsi.anims.x_y_in_anim = vint_object_find("gsi_xy_anim_in") 
  296. 	Hud_gsi.anims.gsi_anim_in = vint_object_find("gsi_anim_in") 
  297. 	Hud_gsi.anims.gsi_anim_out = vint_object_find("gsi_anim_out") 
  298. 	Hud_gsi.anims.gsi_box_anim = vint_object_find("gsi_box_anim")  
  299. 	Hud_gsi.anims.gsi_level_change_anim = vint_object_find("gsi_level_change")  
  300. 	Hud_gsi.anims.gsi_fill_pulse = vint_object_find("gsi_fill_pulse") 
  301. 	Hud_gsi.anims.gsi_fade_in_twn = vint_object_find("gsi_grp_alpha_twn_1", Hud_gsi.anims.gsi_anim_in) 
  302. 	Hud_gsi.anims.gsi_fade_out_twn = vint_object_find("gsi_grp_alpha_twn_1", Hud_gsi.anims.gsi_anim_out) 
  303. 	 
  304. 	vint_set_property(Hud_gsi.anims.gsi_fade_out_twn, "end_event", "hud_gsi_close_final") 
  305.  
  306. 	--Pause Animations 
  307. 	vint_set_property(Hud_gsi.anims.x_y_in_anim, "is_paused", true) 
  308. 	vint_set_property(Hud_gsi.anims.gsi_anim_in, "is_paused", true) 
  309. 	vint_set_property(Hud_gsi.anims.gsi_anim_out, "is_paused", true) 
  310. 	vint_set_property(Hud_gsi.anims.gsi_box_anim, "is_paused", true) 
  311. 	vint_set_property(Hud_gsi.anims.gsi_level_change_anim, "is_paused", true) 
  312. 	vint_set_property(Hud_gsi.anims.gsi_fill_pulse, "is_paused", true) 
  313. 	 
  314. 	--Hide elements 
  315. 	vint_set_property(Hud_gsi.elements.standard_grp_h , "alpha", 0) 
  316. 	vint_set_property(Hud_gsi.elements.clip_h, "alpha", 0) 
  317. 	vint_set_property(Hud_gsi.elements.level_text_h, "alpha", 0) 
  318. 	vint_set_property(Hud_gsi.elements.icon_h, "alpha", 0) 
  319. 	vint_set_property(Hud_gsi.elements.standard_box_h , "alpha", 0) 
  320. 	 
  321. 	--Persistant GSI 
  322. 	Hud_gsi_persistant.handles = {} 
  323. 	Hud_gsi_persistant.handles.grp = vint_object_find("persistant_grp") 
  324. 	Hud_gsi_persistant.handles.poloroid_bmp = vint_object_find("poloroid_bmp", Hud_gsi_persistant.handles.grp ) 
  325. 	Hud_gsi_persistant.handles.poloroid_bmp = vint_object_find("poloroid_bmp", Hud_gsi_persistant.handles.grp ) 
  326. 	Hud_gsi_persistant.handles.poloroid_title_txt = vint_object_find("poloroid_title_txt", Hud_gsi_persistant.handles.grp) 
  327. 	Hud_gsi_persistant.handles.poloroid_line_1_txt = vint_object_find("poloroid_line_1_txt", Hud_gsi_persistant.handles.grp) 
  328. 	Hud_gsi_persistant.handles.poloroid_line_2_txt = vint_object_find("poloroid_line_2_txt", Hud_gsi_persistant.handles.grp) 
  329. 	 
  330. 	--GSI Persistant Frame 
  331. 	Hud_gsi_persistant.handles.frame = {} 
  332. 	Hud_gsi_persistant.handles.frame.nw = vint_object_find("bg_nw", Hud_gsi_persistant.handles.grp ) 
  333. 	Hud_gsi_persistant.handles.frame.n = vint_object_find("bg_n", Hud_gsi_persistant.handles.grp) 
  334. 	Hud_gsi_persistant.handles.frame.ne = vint_object_find("bg_ne", Hud_gsi_persistant.handles.grp) 
  335. 	Hud_gsi_persistant.handles.frame.e = vint_object_find("bg_e", Hud_gsi_persistant.handles.grp) 
  336. 	Hud_gsi_persistant.handles.frame.se = vint_object_find("bg_se", Hud_gsi_persistant.handles.grp) 
  337. 	Hud_gsi_persistant.handles.frame.s = vint_object_find("bg_s", Hud_gsi_persistant.handles.grp) 
  338. 	Hud_gsi_persistant.handles.frame.sw = vint_object_find("bg_sw", Hud_gsi_persistant.handles.grp) 
  339. 	Hud_gsi_persistant.handles.frame.w = vint_object_find("bg_w", Hud_gsi_persistant.handles.grp) 
  340. 	Hud_gsi_persistant.handles.frame.c = vint_object_find("bg_c", Hud_gsi_persistant.handles.grp) 
  341. 	Hud_gsi_persistant.handles.frame.ghost_c = vint_object_find("bg_c_ghost", Hud_gsi_persistant.handles.grp)	 
  342. 	 
  343. 	local language = get_language() 
  344. 	local line_width, line_height = element_get_actual_size(vint_object_find("label_txt",Hud_gsi.elements.timer_h)) 
  345. 	local box_height_offset = -15 
  346. 	if language == "SK" or language == "JP" or language == "CH" then 
  347. 		line_height = line_height - 8 
  348. 		box_height_offset = -8 
  349. 	else 
  350. 		--Standard font 
  351. 		line_height = line_height - 8 
  352. 	end 
  353. 	 
  354. 	Hud_gsi.status.box_height_offset = box_height_offset 
  355. 	Hud_gsi.status.line_height = line_height 
  356. 	 
  357. 	--Hide persistant GSI 
  358. 	vint_set_property(Hud_gsi_persistant.handles.grp, "visible", false) 
  359. 	 
  360. 	--Init fade fade out status 
  361. 	Hud_gsi.status.is_fading_out = false 
  362. 	 
  363. 	--Subscribe to events 
  364. 	vint_datagroup_add_subscription("sr2_local_player_gameplay_indicator_status", "insert", "hud_gsi_update") 
  365. 	vint_datagroup_add_subscription("sr2_local_player_gameplay_indicator_status", "update", "hud_gsi_update") 
  366.  
  367. 		--Subscribe to events 
  368. 	vint_dataitem_add_subscription("persistent_gsi", "insert",  "hud_gsi_persistant_update") 
  369. end 
  370.  
  371. function hud_gsi_update(di_h) 
  372. 	 
  373. 	local data_type, param1, param2, param3, param4, param5, param6, param7, param8, param9  = vint_dataitem_get(di_h) 
  374. 	 
  375. 	if Hud_gsi.status.debug_mode == true then 
  376. 		debug_print("vint", "GSI Update: " .. var_to_string(data_type).. "\n") 
  377. 	end 
  378. 	 
  379. 	if data_type == "configuration" then 
  380. 		--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  381. 		--Debug Start 
  382. 		--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  383. 		if Hud_gsi.status.debug_mode == true then	 
  384. 			debug_print("vint", " gsi state: " .. var_to_string(param1) .. "\n") 
  385. 			debug_print("vint", " configuration: " .. var_to_string(param2) .. "\n") 
  386. 			debug_print("vint", " icon_bitmap_name: " .. var_to_string(param3) .. "\n") 
  387. 			debug_print("vint", " gameplay_title crc: " .. var_to_string(param4) .. "\n") 
  388. 			debug_print("vint", " gameplay_title string: " .. var_to_string(param5) .. "\n") 
  389. 			debug_print("vint", " diversion_level: " .. var_to_string(param6) .. "\n") 
  390. 			debug_print("vint", " visible: " .. var_to_string(param7) .. "\n") 
  391. 			debug_print("vint", " is_diversion: " .. var_to_string(param8) .. "\n") 
  392. 			debug_print("vint", " indicator_count: " .. var_to_string(param9) .. "\n\n") 
  393. 		end 
  394. 		--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  395. 		 
  396. 		local gsi_state				= param1	--1 = initializing, 2 = running, 3 = end 
  397. 		local config 					= param2	--Configuration # 
  398. 		local icon_bmp_name			= param3	--Icon Bitmap Name 
  399. 		local gameplay_title_crc	= param4	--Title CRC ( 
  400. 		local diversion_level		= param6	--Diversion Level # string 
  401. 		local visible					= param7 --Visible 
  402. 		local is_diversion 			= param8	--Is it a diversion? 
  403. 		local indicator_count		= param9	--Indicator Count (ONLY FOR MISSIONS) 
  404.  
  405. 		--Increment diversions because the levels are indexed by 0 
  406. 		--DAD: We made the diversions pass in the right values. 
  407. --		if is_diversion == true then 
  408. --			diversion_level = diversion_level + 1 
  409. --		end 
  410. 		 
  411. 		--Update Diversion Level 
  412. 		if diversion_level ~= Hud_gsi.status.diversion_level then 
  413. 		 
  414. 			--Create Diversion level string 
  415. 			local level_str = "" 
  416. 			if diversion_level ~= nil and diversion_level ~= 0 then 
  417. 				level_str = "LVL" .. diversion_level 
  418. 			else  
  419. 				level_str = "" 
  420. 			end 
  421. 		 
  422. 			if icon_bmp_name == nil or icon_bmp_name == "" then 
  423. 				--No icon so use the Use Diversion Style Text 
  424. 				vint_set_property(Hud_gsi.elements.level_div_text_h, "visible", true) 
  425. 				vint_set_property(Hud_gsi.elements.level_div_text_h, "text_tag", level_str) 
  426. 				vint_set_property(Hud_gsi.elements.level_text_h, "visible", false) 
  427. 				 
  428. 				if gsi_state == 2 then 
  429. 					--Since the level can expand to 2 digits, Recalculate header and queue a format request 
  430. 					--Only do this if the gsi is already running. 
  431. 					local test_x, test_y = vint_get_property(Hud_gsi.elements.level_div_text_h, "anchor") 
  432. 					local test_w, test_h = element_get_actual_size(Hud_gsi.elements.level_div_text_h) 
  433. 					Hud_gsi.header.width = test_x + test_w 
  434. 					hud_gsi_queue_format() 
  435. 				end 
  436. 			else 
  437. 				--Use Standard Text 
  438. 				vint_set_property(Hud_gsi.elements.level_text_h, "visible", true)	  
  439. 				vint_set_property(Hud_gsi.elements.level_text_h, "text_tag", level_str) 
  440. 				vint_set_property(Hud_gsi.elements.level_div_text_h, "text_tag", "") 
  441. 				vint_set_property(Hud_gsi.elements.level_div_text_h, "visible", false) 
  442. 				 
  443. 				--Play Level fade in Animation for activity level text 
  444. 				vint_set_property(Hud_gsi.elements.level_text_h, "alpha", 0) 
  445. 				lua_play_anim(Hud_gsi.anims.gsi_level_change_anim, Hud_gsi.status.fade_in_time) 
  446. 			end 
  447. 			 
  448. 			 
  449. 			Hud_gsi.status.diversion_level = diversion_level	 
  450. 		end 
  451. 		 
  452. 		if config == HUD_GSI_CONFIG_RACING1 or config == HUD_GSI_CONFIG_RACING2 then 
  453. 			--Reset text strings for levels during races 
  454. 			vint_set_property(Hud_gsi.elements.level_text_h, "text_tag", "") 
  455. 			vint_set_property(Hud_gsi.elements.level_div_text_h, "text_tag", "") 
  456. 		end 
  457. 		 
  458. 		if gsi_state ~= Hud_gsi.status.state or gsi_state == 4 then 
  459. 		 
  460. 			if gsi_state == 1 or (Hud_gsi.status.formatted == false and Hud_gsi.status.state == -1 and gsi_state ~= 3) or (gsi_state == 4 and config == HUD_GSI_CONFIG_MISSION and Hud_gsi.status.formatted == false ) then 
  461. 				 
  462. 				--Make sure we set the flag to unformatted. 
  463. 				Hud_gsi.status.formatted = false 
  464. 				 
  465. 				--Start out with a fresh number of indicators 
  466. 				local number_of_indicators = 0	 
  467. 				 
  468. 				--Update Title 
  469. 				hud_gsi_update_header(icon_bmp_name, gameplay_title_crc, diversion_level, is_diversion) 
  470. 				 
  471. 				if config ~= HUD_GSI_CONFIG_MISSION then 
  472. 					--Use pre-configuration settings 
  473. 					 
  474. 					--Update configuration layout 
  475. 					hud_gsi_update_config(config) 
  476. 							 
  477. 					--Show the GSI 
  478. 					vint_set_property(Hud_gsi.elements.standard_grp_h, "alpha", 1)  
  479. 					 
  480. 					--Get number of indicators used in configuration 
  481. 					for idx, val in Hud_gsi.status.config do 
  482. 						number_of_indicators = number_of_indicators + 1 
  483. 					end 
  484.  
  485. 				else 
  486. 					--Use Mission config  
  487. 					 
  488. 					--Clear Indicator Objects 
  489. 					for idx, val in Hud_gsi.indicators do 
  490. 						vint_object_destroy(val.elements.grp_h) 
  491. 					end 
  492. 					 
  493. 					--Clear Indicator tables, grid and meter flash data 
  494. 					Hud_gsi.indicators = {} 
  495. 					Hud_gsi.grid = {} 
  496. 					Hud_gsi_meter_flash_data = {} 
  497. 					 
  498. 					--Use Mission Configuration, then you have to wait until the indicators are setup here. 
  499. 					Hud_gsi.status.config_index = HUD_GSI_CONFIG_MISSION 
  500. 					Hud_gsi.status.config = Hud_gsi.configs[HUD_GSI_CONFIG_MISSION] 
  501. 					 
  502. 					--Missions get the number of active indicators needed to populate the setup 
  503. 					number_of_indicators = indicator_count 
  504. 					 
  505. 					if number_of_indicators > 2 then 
  506. 						debug_print("", "MISSION GSI ERROR!!! The mission is trying to use more than two indicators at once\n") 
  507. 					end 
  508. 					 
  509. 				end	 
  510. 				 
  511. 				--Store status data into files 
  512. 				Hud_gsi.status.indicator_count = number_of_indicators 
  513. 		 
  514. 			elseif gsi_state == 3 then 
  515. 			 
  516. 				--Set the flag to unformatted. 
  517. 				Hud_gsi.status.formatted = false 
  518. 				 
  519. 				--Reset the diversion level 
  520. 				Hud_gsi.status.diversion_level = -1 
  521. 				 
  522. 				--GSI state should now close 
  523. 				hud_gsi_close() 
  524. 	 
  525. 			elseif gsi_state == 4 and config == HUD_GSI_CONFIG_MISSION then 
  526. 				 
  527. 				--This is used if the hud needs to change configuration midway through a mission 
  528. 				 
  529. 				--Since we are killing the old format, set the flag to unformatted. 
  530. 				Hud_gsi.status.formatted = false 
  531. 				 
  532. 				--Update Title if its changed... 
  533. 				hud_gsi_update_header(icon_bmp_name, gameplay_title_crc, diversion_level, is_diversion) 
  534. 				 
  535. 				--Clear Indicator Objects 
  536. 				for idx, val in Hud_gsi.indicators do 
  537. 					vint_object_destroy(val.elements.grp_h) 
  538. 				end 
  539. 				 
  540. 				--Clear Indicator tables and grid 
  541. 				Hud_gsi.indicators = {} 
  542. 				Hud_gsi.grid = {} 
  543. 				Hud_gsi_meter_flash_data = {} 
  544. 				 
  545. 				--Use Mission Configuration, you have to wait until the indicators are setup here. 
  546. 				Hud_gsi.status.config_index = HUD_GSI_CONFIG_MISSION 
  547. 				Hud_gsi.status.config = Hud_gsi.configs[HUD_GSI_CONFIG_MISSION] 
  548. 				 
  549. 				--Store status data into files 
  550. 				Hud_gsi.status.indicator_count = indicator_count 
  551. 				 
  552. 			end 
  553. 			Hud_gsi.status.state = gsi_state 
  554. 		end 
  555. 		 
  556. 		if visible == nil then 
  557. 			visible = true 
  558. 		end 
  559. 		 
  560. 		--TODO: Delete this line if you want to hide the gsi 
  561. 		visible = true 
  562. 		 
  563. 		vint_set_property(Hud_gsi.elements.gsi_grp_h, "visible", visible) 
  564. 	 
  565. 	elseif data_type == nil then 
  566. 		--No specified data_type so don't do anything. 
  567. 	else 
  568. 		 
  569. 		--These are used for every indicator 
  570. 		local ind_index			=	param1	--Element Index 
  571. 		local visible				= 	param2	--Is Element Visible? 
  572. 		local label_crc			=	param3	--Label CRC 
  573. 		 
  574. 		--Error checking 
  575. 		if Hud_gsi.status.config == -1 then 
  576. 			debug_print("vint", "GSI: No configurations were created, so we do not update shit.\n") 
  577. 			return 
  578. 		end 
  579.  
  580. 		--Use Mission Configuration, you have to wait until the indicators are setup here.			 
  581. 		if Hud_gsi.status.config[ind_index] == nil and Hud_gsi.status.config ~= Hud_gsi.configs[HUD_GSI_CONFIG_MISSION] then 
  582. 			debug_print("vint", "GSI: Indicator not supported in current configuration. [element_type = " .. var_to_string(ind_index) .. " ]\n") 
  583. 			return 
  584. 		end 
  585. 		 
  586. 		--Get skin from the configuration index 
  587. 		local skin 
  588. 		if Hud_gsi.status.config ~= Hud_gsi.configs[HUD_GSI_CONFIG_MISSION] then 
  589. 			skin = Hud_gsi.status.config[ind_index][HUD_GSI_CONFIG_SKIN] 
  590. 		else 
  591. 			skin = "" 
  592. 		end 
  593. 		 
  594. 		--TIMER 
  595. 		if	data_type == "timer" then 
  596. 		 
  597. 			--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  598. 			--Debug Start 
  599. 			--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  600. 			if Hud_gsi.status.debug_mode == true then 
  601. 				debug_print("vint", " timer index: " .. param1 .. "\n") 
  602. 				debug_print("vint", " visible: " .. var_to_string(param2) .. "\n") 
  603. 				debug_print("vint", " description crc: " .. var_to_string(param3) .. "\n") 
  604. 				debug_print("vint", " description: " .. var_to_string(param4) .. "\n") 
  605. 				debug_print("vint", " seconds left: " .. var_to_string(param5) .. " is a positive timer: " .. var_to_string(param6) .. "\n\n") 
  606. 			end 
  607. 			--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  608. 			 
  609. 			--Get specific indicator parameters 
  610. 			local seconds				=	param5	--Time: seconds left  
  611. 			local is_positive_timer	=	param6	--Is it a positive timer? 
  612. 			 
  613. 			--Check if indicator has been created	 
  614. 			if Hud_gsi.indicators[ind_index] == nil then 
  615. 				--need to create the indicator	 
  616. 				hud_gsi_create_timer(ind_index, skin, visible) 
  617. 			end 
  618. 			 
  619. 			--Update Timer 
  620. 			hud_gsi_update_timer(ind_index, visible, skin, label_crc, seconds) 
  621.  
  622. 		--X OF Y INDICATOR 
  623. 		elseif data_type == "x_of_y_indicator" then 
  624. 		 
  625. 			--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  626. 			--Debug Start 
  627. 			--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  628. 			if Hud_gsi.status.debug_mode == true then 
  629. 				debug_print("vint", " x_of_y_indicator index: " .. param1 .. "\n") 
  630. 				debug_print("vint", " visible: " .. var_to_string(param2)  .. "\n") 
  631. 				debug_print("vint", " description crc: " .. var_to_string(param3) .. "\n") 
  632. 				debug_print("vint", " description str: " .. var_to_string(param4)  .. "\n") 
  633. 				debug_print("vint", " current amount: " .. var_to_string(param5) .. " target amount: " .. var_to_string(param6) .. " is it money? " .. var_to_string(param7) .. "\n\n") 
  634. 			end 
  635. 			--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  636. 							 
  637. 			--Get specific indicator parameters 
  638. 			local x_value	=	param5	--Time: seconds left  
  639. 			local y_value	=	param6	--Is it a positive timer? 
  640. 			local is_cash	=	param7	--Is the indicator cash 
  641.  
  642. 			--If skin is left blank then  
  643. 			if skin == "" then 
  644. 				if is_cash == true then 
  645. 					skin = "cash" 
  646. 				else  
  647. 					skin = "default" 
  648. 				end 
  649. 			end 
  650.  
  651. 			--Check if indicator has been created 
  652. 			if Hud_gsi.indicators[ind_index] == nil then 
  653. 				--need to create the indicator 
  654. 				hud_gsi_create_xy(ind_index, skin) 
  655. 			end 
  656. 			 
  657. 			--Update Indicator 
  658. 			hud_gsi_update_xy(ind_index, visible, skin, label_crc, x_value, y_value) 
  659. 		 
  660. 		--METER 
  661. 		elseif data_type == "meter" then 
  662. 		 
  663. 			--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  664. 			--Debug Start 
  665. 			--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  666. 			if Hud_gsi.status.debug_mode == true then 
  667. 				debug_print("vint", " meter index: " .. param1 .. "\n") 
  668. 				debug_print("vint", " visible: " .. var_to_string(param2) .. "\n") 
  669. 				debug_print("vint", " description crc: " .. var_to_string(param3) .. "\n") 
  670. 				debug_print("vint", " description: " .. var_to_string(param4) .. "\n") 
  671. 				debug_print("vint", " current amount: " .. var_to_string(param5) .. "\n\n") 
  672. 			end 
  673. 			--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  674. 			 
  675. 			--Get specific indicator parameters 
  676. 			local meter_pct	=	param5	--Meter Percentage 
  677. 			local skin = param6				--Skin 
  678. 			local is_flashing = param7		--Is the meter flashing!? oooohhh 
  679. 			 
  680. 			--override skin if not a mission 
  681. 			if Hud_gsi.status.config_index ~= HUD_GSI_CONFIG_MISSION then 
  682. 				--Get specific indicator parameters 
  683. 				skin = Hud_gsi.status.config[ind_index][HUD_GSI_CONFIG_SKIN] 
  684. 			end 
  685. 		 
  686. 			--Check if indicator has been created 
  687. 			if Hud_gsi.indicators[ind_index] == nil then 
  688. 				--need to create the indicator 
  689. 				hud_gsi_create_meter(ind_index, skin) 
  690. 			end 
  691. 			 
  692. 			--Update Indicator 
  693. 			hud_gsi_update_meter(ind_index, visible, skin, label_crc, meter_pct, is_flashing) 
  694. 			 
  695. 		--INFORMATION INDICATOR 
  696. 		elseif data_type == "information_indicator" then 
  697. 		 
  698. 			--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  699. 			--Debug Start 
  700. 			--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  701. 			if Hud_gsi.status.debug_mode == true then 
  702. 				debug_print("vint", " information_indicator index: " .. param1 .. "\n") 
  703. 				debug_print("vint", " visible: " .. var_to_string(param2) .. "\n") 
  704. 				debug_print("vint", " description crc: " .. param3 .. "\n") 
  705. 				debug_print("vint", " description: " .. var_to_string(param4) .. "\n") 
  706. 				debug_print("vint", " information crc: " .. param5 .. "\n") 
  707. 				debug_print("vint", " information: " .. var_to_string(param6) .. "\n\n") 
  708. 			end 
  709. 			--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  710.  
  711. 			local info_crc = param5 
  712. 			local info_value = param6 
  713. 			 
  714. 			--Check if indicator has been created 
  715. 			if Hud_gsi.indicators[ind_index] == nil then 
  716. 				--need to create the indicator 
  717. 				hud_gsi_create_info(ind_index, skin) 
  718. 			end 
  719. 			 
  720. 			--Update Indicator 
  721. 			hud_gsi_update_info(ind_index, visible, skin, label_crc, info_crc, info_value) 
  722. 		end 
  723. 	end 
  724. 		 
  725. 	--Check if the gsi has been re-formatted 
  726. 	if Hud_gsi.status.formatted == false and Hud_gsi.status.state ~= 3 then 
  727. 		local indicators_created = 0 
  728. 		for i, val in Hud_gsi.indicators do 
  729. 			indicators_created = indicators_created + 1 
  730. 		end 
  731. 		 
  732. 		--If we have all the data then format it! 
  733. 		if indicators_created == Hud_gsi.status.indicator_count then 
  734. 			if Hud_gsi.status.config_index == HUD_GSI_CONFIG_MISSION then 
  735. 				--Mission config doesn't exist until this is run 
  736. 				hud_gsi_update_config(HUD_GSI_CONFIG_MISSION) 
  737. 			end 
  738. 			 
  739. 			--If we are in state 4, it means to do a partial refresh. Otherwise play the opening animation. 
  740. 			if Hud_gsi.status.state == 4 then 
  741. 				local width, height = hud_gsi_update_layout() 
  742. 				hud_gsi_frame_animate(width, height, 0, Hud_gsi.elements.frame_standard) 
  743. 			else 
  744. 				--Open up GSI 
  745. 				hud_gsi_open() 
  746. 			end 
  747. 			 
  748. 			--We should now be formatted so set the flag to true 
  749. 			Hud_gsi.status.formatted = true 
  750. 		end 
  751. 	end 
  752. 	 
  753. 	--Process the GSI 
  754. 	hud_gsi_process() 
  755. 	 
  756. end 
  757.  
  758. --[[ 
  759. 	Resets the configuration and clears out old config 
  760. ]] 
  761. function hud_gsi_update_config(config_index) 
  762.  
  763. 	local config = Hud_gsi.configs[config_index] 
  764.  
  765. 	if config == nil then 
  766. 		debug_print("vint", "Failed to update config. Config index doesn't exist\n") 
  767. 		return false 
  768. 	end 
  769. 	 
  770. 	if config_index ~= Hud_gsi.status.config_index or config_index == HUD_GSI_CONFIG_MISSION then 
  771.  
  772. 		if config_index ~= HUD_GSI_CONFIG_MISSION then 
  773. 			--Standard Configuration	 
  774. 			 
  775. 			--Clear out all old indicator elements 
  776. 			for idx, val in Hud_gsi.indicators do 
  777. 				vint_object_destroy(val.elements.grp_h) 
  778. 			end 
  779. 			 
  780. 			--Clear indicator tables and grid 
  781. 			Hud_gsi.indicators = {} 
  782. 			Hud_gsi.grid = {} 
  783. 			Hud_gsi_meter_flash_data = {} 
  784. 			 
  785. 			--Build the new config 
  786. 			for idx, val in config do 
  787. 				local col = val[HUD_GSI_CONFIG_COL] 
  788. 				local row = val[HUD_GSI_CONFIG_ROW] 
  789. 				local indicator_index = idx 
  790. 				 
  791. 				--Add item to grid 
  792. 				hud_gsi_grid_item_add(row, col, indicator_index) 
  793. 			end 
  794. 		else 
  795. 			--Mission Configuration 
  796. 			 
  797. 			--Oh shit this is all fucking crazy 
  798. 			local indicator_mess = {}		--Indicator mess will be a table full of indicator indexes and indicator priorities 
  799. 			local indicator_counter = 0 
  800. 			local indicator_priority = 1 
  801. 			 
  802. 			--Prioritie defines 
  803. 			local priority_timer = 1 
  804. 			local priority_xy 	= 2 
  805. 			local priority_info 	= 3 
  806. 			local priority_meter = 4 
  807. 			 
  808. 			--first sort through the items to see what we have and build priority for them 
  809. 			 
  810. 			 
  811. 			for idx, val in Hud_gsi.indicators do 
  812. 				 
  813. 				--Calculate priority 
  814. 				if idx == HUD_GSI_TIMER then 
  815. 					indicator_priority = priority_timer 
  816. 				elseif idx < HUD_GSI_METER then 
  817. 					indicator_priority = priority_meter 
  818. 				elseif idx < HUD_GSI_INFO then 
  819. 					indicator_priority = priority_info 
  820. 				else 
  821. 					--other... for now this is X/Y 
  822. 					indicator_priority = priority_xy 
  823. 				end 
  824.  
  825. 				indicator_mess[indicator_counter] = {["index"] = Hud_gsi.indicators[idx].data.index,	["priority"] = indicator_priority}  
  826. 				indicator_counter = indicator_counter + 1 
  827. 			end 
  828. 			 
  829. 			--Assign priorities to the items 
  830. 			local temp_indicator_storage 
  831. 			local flag = false 
  832. 			while flag == false do 
  833. 			 
  834. 				flag = true 
  835. 				 
  836. 				for i = 0, Hud_gsi.status.indicator_count - 2 do 
  837.  
  838. 					if indicator_mess[i].priority > indicator_mess[i + 1].priority then 
  839. 						--swap indexes if the priority is greater 
  840. 						temp_indicator_storage = indicator_mess[i] 
  841. 						indicator_mess[i] = indicator_mess[i + 1] 
  842. 						indicator_mess[i + 1] = temp_indicator_storage   
  843. 						flag = false 
  844. 						break 
  845. 					end 
  846. 				end 
  847. 			end 
  848. 			 
  849. 			--Place items into the grid 
  850. 			local col = 0 
  851. 			local row = 0 
  852. 			local indicator_index = 0 
  853. 			local loop_index = 0 
  854. 			local indicator_placement = Hud_gsi.status.indicator_count 
  855. 			local end_loop = false 
  856. 			 
  857. 			--Add Grid Items 
  858. 			if indicator_counter ~= 0 then 
  859. 				--First Indicator 
  860. 				for i = 0, indicator_counter - 1 do 
  861. 					if i >= 2 then 
  862. 						--no more than two indicators allowd 
  863. 						break 
  864. 					end 
  865. 					if indicator_mess[i].index ~= nil then 
  866. 						hud_gsi_grid_item_add(0, i, indicator_mess[i].index) 
  867. 					end 
  868. 				end 
  869. 			end 
  870. 		end 
  871. 		Hud_gsi.status.config_index = config_index 
  872. 		Hud_gsi.status.config = config 
  873. 	end 
  874. end 
  875.  
  876. function hud_gsi_grid_item_add(col, row, idx) 
  877. 	if Hud_gsi.grid[row] == nil then 
  878. 		Hud_gsi.grid[row] = {} 
  879. 	end 
  880. 	Hud_gsi.grid[row][col] = idx 
  881. end 
  882.  
  883. function hud_gsi_open() 
  884. 	debug_print("vint", "hud_gsi_open()\n") 
  885. 	 
  886. 	--Enable fade in tween ... 
  887. 	vint_set_property(Hud_gsi.anims.gsi_fade_in_twn , "state", "paused") 
  888. 	 
  889. 	--Animation doesn't play for a second so we need to hide some shit. Boosh. 
  890. 	vint_set_property(Hud_gsi.elements.clip_h, "alpha", 0) 
  891. 	vint_set_property(Hud_gsi.elements.icon_h, "alpha", 0) 
  892. 	vint_set_property(Hud_gsi.elements.standard_box_h , "alpha", 0) 
  893. 	lua_play_anim(Hud_gsi.anims.gsi_anim_in, Hud_gsi.status.fade_in_time) 
  894. 	 
  895. 	local width, height = hud_gsi_update_layout() 
  896.  
  897. 	--Set initial values for GSI frame to animate in from 
  898. 	hud_gsi_frame_resize(20, height, Hud_gsi.elements.frame_standard) 
  899. 	 
  900. 	--Animate GSI Frame 
  901. 	hud_gsi_frame_animate(width, height, Hud_gsi.status.fade_in_time, Hud_gsi.elements.frame_standard) 
  902. end 
  903.  
  904. function hud_gsi_update_layout() 
  905. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  906. 		--Debug Start 
  907. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  908. 	if Hud_gsi.status.debug_mode == true then 
  909. 		debug_print("vint", "Updating Layout. hud_gsi_update_layout()\n") 
  910. 	end 
  911. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  912. 	 
  913. 	for row = 0, 10 do 
  914. 		if Hud_gsi.grid[row] == nil then 
  915. 			break 
  916. 		end 
  917. 		for col = 0, 10 do 
  918. 			if Hud_gsi.grid[row][col] == nil then 
  919. 				break 
  920. 			end 
  921. 			local indicator_index = Hud_gsi.grid[row][col] 
  922. 			local indicator_obj = Hud_gsi.indicators[indicator_index] 
  923.  
  924. 			if indicator_obj == nil then 
  925. 				break 
  926. 			end 
  927.  
  928. 			--Do processing for layout 
  929. 			if row == 0 and col == 0 then 
  930. 				--First Element (Incredible) place it at 0,0 
  931. 				vint_set_property(indicator_obj.elements.grp_h, "anchor", 0, 0) 
  932. 			end 
  933. 			 
  934. 			if row == 0 and col == 1 then 
  935. 				--Line 1, Item 2 
  936. 				local prev_indicator_index = Hud_gsi.grid[0][0] 
  937. 				local prev_indicator_obj = Hud_gsi.indicators[prev_indicator_index] 
  938. 				local p_x, p_y = vint_get_property(prev_indicator_obj.elements.grp_h, "anchor") 
  939. 				local p_w = prev_indicator_obj.elements.width  
  940. 				local object_offset = 0 
  941.  
  942. 				local x = p_x + p_w + Hud_gsi.status.grid_spacing + object_offset 
  943. 				 
  944. 				vint_set_property(indicator_obj.elements.grp_h, "anchor", x, p_y) 
  945. 			end 
  946. 			 
  947. 			if row == 1 and col == 0 then 
  948. 				--Line 2, Item 1 
  949. 				local prev_indicator_index = Hud_gsi.grid[0][0] 
  950. 				local prev_indicator_obj = Hud_gsi.indicators[prev_indicator_index] 
  951. 				local p_x, p_y = vint_get_property(prev_indicator_obj.elements.grp_h, "anchor") 
  952. 				local p_h = Hud_gsi.status.line_height 
  953. 				local y = p_h 	 
  954. 				vint_set_property(indicator_obj.elements.grp_h, "anchor", p_x, y) 
  955. 			end 
  956. 			 
  957. 			if row == 1 and col == 1 then 
  958. 				--Line 2, Item 2 
  959. 				local prev_indicator_index = Hud_gsi.grid[1][0] 
  960. 				local prev_indicator_obj = Hud_gsi.indicators[prev_indicator_index] 
  961. 				local p_x, p_y = vint_get_property(prev_indicator_obj.elements.grp_h, "anchor") 
  962. 				local p_w = prev_indicator_obj.elements.width  
  963. 				local object_offset = 0 
  964.  
  965. 				local x = p_x + p_w + Hud_gsi.status.grid_spacing + object_offset 
  966. 				vint_set_property(indicator_obj.elements.grp_h, "anchor", x, p_y) 
  967. 			end 
  968. 		end 
  969. 	end 
  970. 	 
  971. 	--Check if both rows have meters in them... 
  972. 	--We need to get them aligned if so... 
  973. 	if Hud_gsi.grid[0] ~= nil and Hud_gsi.grid[1] ~= nil then 
  974. 		if Hud_gsi.grid[0][0] == HUD_GSI_METER and Hud_gsi.grid[1][0] == HUD_GSI_METER + 1 then 
  975. 			local meter_1_obj = Hud_gsi.indicators[HUD_GSI_METER] 
  976. 			local meter_2_obj = Hud_gsi.indicators[HUD_GSI_METER + 1] 
  977. 			hud_gsi_update_meter_alignment(meter_1_obj, meter_2_obj) 
  978. 		end 
  979. 	end 
  980.  
  981. 	--Calculate size of box 
  982. 	--Calculate largest width 
  983. 	local header_width, header_height = element_get_actual_size(Hud_gsi.elements.header_grp_h) 
  984. 		 
  985. 	--Calculate how many lines we have in the grid 
  986. 	local number_of_lines_in_grid = 0 
  987. 	 
  988. 	for idx, val in Hud_gsi.grid do 
  989. 		number_of_lines_in_grid = number_of_lines_in_grid + 1 
  990. 	end 
  991. 	 
  992. 	--See how many lines are visible within that configuration 
  993. 	local number_of_lines_visible_in_grid = 0 
  994. 	local line_found = false 
  995. 	local current_line_width = 0 
  996. 	local largest_line_width = 0 
  997. 	 
  998. 	if number_of_lines_in_grid > 0 then 
  999. 		for outer_idx, outer_val in Hud_gsi.grid do 
  1000. 			line_found = false 
  1001. 			current_line_width = 0 
  1002. 			for inner_idx, inner_val in outer_val do 
  1003. 				--is the indicator visible? 
  1004. 				 
  1005. 				if Hud_gsi == nil or Hud_gsi.indicators == nil or Hud_gsi.indicators[inner_val] == nil or Hud_gsi.indicators[inner_val].elements == nil then 
  1006. 					break 
  1007. 				end 
  1008.  
  1009. 				if Hud_gsi.indicators[inner_val].elements.visible == true then 
  1010. 					if line_found == false then 
  1011. 						number_of_lines_visible_in_grid = number_of_lines_visible_in_grid + 1 
  1012. 						line_found = true 
  1013. 					end 
  1014. 					current_line_width = Hud_gsi.indicators[inner_val].elements.width + current_line_width 
  1015. 				end 
  1016. 			end 
  1017. 			if current_line_width > largest_line_width then 
  1018. 				largest_line_width = current_line_width 
  1019. 			end 
  1020. 		end 
  1021. 	end 
  1022. 	 
  1023. 	local indicator_height = number_of_lines_visible_in_grid * Hud_gsi.status.line_height 
  1024. 	local indicator_width = largest_line_width 
  1025. 	 
  1026. 	--Finalize width and height values for the header and indicator 
  1027. 	local width = 0 
  1028. 	local height = 0 
  1029. 	if indicator_width > Hud_gsi.header.width then 
  1030. 		width = indicator_width + 5 
  1031. 	else 
  1032. 		width = Hud_gsi.header.width  
  1033. 	end 
  1034. 	 
  1035. 	width = width + Hud_gsi.status.clip_offset - 8 
  1036. 	height = indicator_height + Hud_gsi.header.height + Hud_gsi.status.box_height_offset 
  1037. 	 
  1038. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1039. 	--Debug Start 
  1040. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1041. 	if Hud_gsi.status.debug_mode == true then	 
  1042. 		show_bounds(Hud_gsi.elements.header_grp_h) 
  1043. 		show_bounds(Hud_gsi.elements.indicators_grp_h) 
  1044. 	end 
  1045. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1046. 	 
  1047. 	return width, height 
  1048. end 
  1049.  
  1050. Hud_gsi_twns = {} 
  1051.  
  1052. function hud_gsi_frame_update(param1, event) 
  1053.  
  1054. 	local active_frame  
  1055.  
  1056. 	if event == "per_frame_event" then 
  1057. 		--Callback was from tween 
  1058. 		--If the callback was from a tween the parameter is a number.. and we always want to use the standard frame in that case 
  1059. 		active_frame = Hud_gsi.elements.frame_standard 
  1060. 	else  
  1061. 		-- calling_not_from_tween, so we should use the specified parameter 
  1062. 		active_frame = param1 
  1063. 	end 
  1064. 	 
  1065. 	--setup limits	 
  1066. 	local source_se_x, source_se_y, anchor_x, anchor_y, c_anchor_y, c_anchor_x, target_x, target_y 
  1067. 	 
  1068. 	--Get ghost frame values and floor them 
  1069. 	local width, height = vint_get_property(active_frame.ghost_c, "source_se") 
  1070. 	width = floor(width) 
  1071. 	height = floor(height) 
  1072. 	 
  1073. 	--North 
  1074. 	source_se_x, source_se_y = vint_get_property(active_frame.n,"source_se") 
  1075. 	vint_set_property(active_frame.n, "source_se", width, source_se_y) 
  1076. 	 
  1077. 	--West 
  1078. 	source_se_x, source_se_y = vint_get_property(active_frame.w,"source_se") 
  1079. 	vint_set_property(active_frame.w, "source_se", source_se_x, height) 
  1080. 	 
  1081. 	--Center 
  1082. 	vint_set_property(active_frame.c, "source_se", width, height) 
  1083. 	c_anchor_y, c_anchor_x = vint_get_property(active_frame.c, "anchor") 
  1084. 	 
  1085. 	target_x = c_anchor_x + width - 1 
  1086. 	target_y = c_anchor_y + height + 1 
  1087. 	 
  1088. 	--North East 
  1089. 	anchor_x, anchor_y = vint_get_property(active_frame.ne, "anchor") 
  1090. 	vint_set_property(active_frame.ne, "anchor", target_x , anchor_y) 
  1091. 		 
  1092. 	--East 
  1093. 	anchor_x, anchor_y = vint_get_property(active_frame.e, "anchor") 
  1094. 	source_se_x, source_se_y = vint_get_property(active_frame.e, "source_se") 
  1095. 	vint_set_property(active_frame.e, "anchor", target_x , anchor_y) 
  1096. 	vint_set_property(active_frame.e, "source_se", source_se_x, height) 
  1097. 	 
  1098. 	--South West 
  1099. 	anchor_x, anchor_y = vint_get_property(active_frame.sw, "anchor") 
  1100. 	vint_set_property(active_frame.sw, "anchor", anchor_x, target_y) 
  1101. 	 
  1102. 	--South  
  1103. 	anchor_x, anchor_y = vint_get_property(active_frame.s, "anchor") 
  1104. 	vint_set_property(active_frame.s, "anchor", anchor_x, target_y) 
  1105. 	source_se_x, source_se_y = vint_get_property(active_frame.s, "source_se") 
  1106. 	vint_set_property(active_frame.s, "source_se", width, source_se_y) 
  1107. 	 
  1108. 	--South East 
  1109. 	vint_set_property(active_frame.se, "anchor", target_x, target_y)	 
  1110. 	 
  1111. 	--Only resize the clip if we are changing the standard frame 
  1112. 	if active_frame == Hud_gsi.elements.frame_standard then 
  1113. 		--Set Clip 
  1114. 		vint_set_property(Hud_gsi.elements.clip_h, "clip_size",  width + 15 - Hud_gsi.status.clip_offset, height + 15) 
  1115. 	end 
  1116. end 
  1117.  
  1118. function hud_gsi_frame_animate(width, height, delay, active_frame) 
  1119. 	width = floor(width) 
  1120. 	height = floor(height) 
  1121.  
  1122. 	--Tween ghost part and set callback to update the actual parts 
  1123. 	local twn_h = vint_object_find("bg_twn_1", Hud_gsi.anims.gsi_box_anim) 
  1124. 	local c_width, c_height = vint_get_property(active_frame.ghost_c, "source_se") 
  1125. 	vint_set_property(twn_h, "start_value", c_width, c_height) 
  1126. 	vint_set_property(twn_h, "end_value", width, height)	 
  1127. 	vint_set_property(twn_h, "per_frame_event", "hud_gsi_frame_update") 
  1128. 	vint_set_property(twn_h, "target_handle", active_frame.ghost_c) 
  1129. 	lua_play_anim(Hud_gsi.anims.gsi_box_anim, delay) 
  1130. end 
  1131.  
  1132.  
  1133. function hud_gsi_frame_resize(width, height, active_frame) 
  1134. 	--Floor Width/Height	 
  1135. 	width = floor(width) 
  1136. 	height = floor(height) 
  1137. 	--Set base size and update the frame 
  1138. 	vint_set_property(active_frame.ghost_c, "source_se", width, height) 
  1139. 	hud_gsi_frame_update(active_frame) 
  1140. end 
  1141.  
  1142. function hud_gsi_close() 
  1143. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1144. 	--Debug Start 
  1145. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1146. 	if Hud_gsi.status.debug_mode == true then	 
  1147. 		debug_print("vint", "hud_gsi_close()\n") 
  1148. 	end 
  1149. 	 
  1150. 	Hud_gsi.status.is_fading_out = true 
  1151. 	 
  1152. 	--Disable fade in tween in case we are fading in... 
  1153. 	vint_set_property(Hud_gsi.anims.gsi_fade_in_twn , "state", "disabled") 
  1154. 	 
  1155. 	--Fade out from current alpha state 
  1156. 	local alpha_val = vint_get_property(Hud_gsi.elements.standard_grp_h, "alpha") 
  1157. 	vint_set_property(Hud_gsi.anims.gsi_fade_out_twn, "start_value", alpha_val) 
  1158. 	 
  1159. 	lua_play_anim(Hud_gsi.anims.gsi_anim_out, 0) 
  1160. 	 
  1161. 	--close complete 
  1162. 	 
  1163. 	--Reset diversion level tag 
  1164. 	vint_set_property(Hud_gsi.elements.level_div_text_h, "text_tag", "") 
  1165. end 
  1166.  
  1167. function hud_gsi_close_final() 
  1168.  
  1169. 	--Reset fade out status 
  1170. 	Hud_gsi.status.is_fading_out = false 
  1171. 	--if the persistant hud is active we need to show it now. 
  1172. 	if Hud_gsi_persistant.status > 0 then 
  1173. 		hud_gsi_persistant_show() 
  1174. 	end 
  1175.  
  1176. end 
  1177.  
  1178. function hud_gsi_update_header(icon_bmp_name, title_crc, level, is_diversion) 
  1179. 	 
  1180. 	local clip_offset = 0 
  1181.  
  1182. 	if icon_bmp_name == nil or icon_bmp_name == "" then 
  1183. 		--No icon so it must be a diversion 
  1184. 		 
  1185. 		--Hide placeholder icon 
  1186. 		vint_set_property(Hud_gsi.elements.icon_h, "visible", false) 
  1187. 		 
  1188. 		debug_print("vint", "Hud_gsi.elements.icon_h: should be invisible\n") 
  1189. 		 
  1190. 		--Set group offset 
  1191. 		clip_offset = 15 
  1192. 		local clip_x, clip_y = vint_get_property(Hud_gsi.elements.clip_h, "anchor") 
  1193. 		vint_set_property(Hud_gsi.elements.clip_h, "anchor", clip_offset, clip_y) 
  1194. 		 
  1195. 	else 
  1196. 		--Ok, so there is an icon... format it so. 
  1197. 		 
  1198. 		--Set bitmap Name of icon 
  1199. 		vint_set_property(Hud_gsi.elements.icon_h, "image", icon_bmp_name) 
  1200. 		vint_set_property(Hud_gsi.elements.icon_h, "visible", true) 
  1201. 		 
  1202. 		--Set group offset 
  1203. 		clip_offset = 50 
  1204. 		local clip_x, clip_y = vint_get_property(Hud_gsi.elements.clip_h, "anchor") 
  1205. 		vint_set_property(Hud_gsi.elements.clip_h, "anchor", clip_offset, clip_y) 
  1206. 	end 
  1207. 		 
  1208. 	--Set Title with crc 
  1209. 	vint_set_property(Hud_gsi.elements.title_text_h, "text_tag_crc", title_crc) 
  1210. 	 
  1211. 	--Adjust positions 
  1212. 	local title_w, title_h = element_get_actual_size(Hud_gsi.elements.title_text_h) 
  1213. 	local title_x, title_y = vint_get_property(Hud_gsi.elements.title_text_h, "anchor") 
  1214. 	local target_x = title_w + title_x + 5 
  1215. 	vint_set_property(Hud_gsi.elements.level_div_text_h, "anchor", target_x, title_y) 
  1216. 	 
  1217. 	local test_x, test_y = vint_get_property(Hud_gsi.elements.level_div_text_h, "anchor") 
  1218. 	local test_w, test_h = element_get_actual_size(Hud_gsi.elements.level_div_text_h) 
  1219.  
  1220. 	Hud_gsi.status.clip_offset = clip_offset 
  1221. 	 
  1222. 	--Use default title height if no title specified 
  1223. 	if title_crc == 0 then 
  1224. 		title_h = 36.8 
  1225. 	end 
  1226. 	 
  1227. 	Hud_gsi.header.width = test_x + test_w 
  1228. 	Hud_gsi.header.height =	title_h 
  1229. 	Hud_gsi.header.icon_bmp_name = icon_bmp_name 
  1230. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1231. 	--Debug Start 
  1232. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1233. 	if Hud_gsi.status.debug_mode == true then 
  1234. 		show_bounds(Hud_gsi.elements.title_text_h) 
  1235. 		debug_print("vint", "GSI Header Update:\n") 
  1236. 		debug_print("vint", " Hud_gsi.header.height: " .. Hud_gsi.header.height .. "\n") 
  1237. 		debug_print("vint", " title_crc: " .. var_to_string(title_crc) .. "\n\n") 
  1238. 	end 
  1239. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1240. 	 
  1241. end 
  1242.  
  1243.  
  1244. function hud_gsi_create_info(index, skin) 
  1245. 	--[[ 
  1246. 	index, 		=	Index of Indicator 
  1247. 	skin, 	=	What type of x/y indicator ("default" == default display) 
  1248. 	]] 
  1249. 	 
  1250. 	--Error Checking 
  1251. 	if Hud_gsi.indicators[index] ~= nil then 
  1252. 		debug_print("vint", "Failed to create INFO indicator with index: " .. index .. "\n") 
  1253. 		return 
  1254. 	end 
  1255. 	 
  1256. 	--Duplicate groups into the indicators grp and store handles to parts 
  1257. 	local info_grp_h = vint_object_clone(Hud_gsi.elements.info_h, Hud_gsi.elements.indicators_grp_h) 
  1258. 	local label_h = vint_object_find("label_txt", info_grp_h) 
  1259. 	local info_h = vint_object_find("info_txt", info_grp_h) 
  1260. 	 
  1261. 	--Setup default table for object 
  1262. 	local ind_obj = { 
  1263. 		data = { 
  1264. 			index = index, 
  1265. 			info_value = "XXXX: IS AWESOME", 
  1266. 			label = 0, 
  1267. 			init = false, 
  1268. 		}, 
  1269. 		elements = { 
  1270. 			skin = skin, 
  1271. 			grp_h = info_grp_h, 
  1272. 			label_h = label_h, 
  1273. 			info_h = info_h, 
  1274. 			label_padding = 9, 
  1275. 			visible = -1, 
  1276. 			width = -1, 
  1277. 			height = -1, 
  1278. 		} 
  1279. 	} 
  1280. 	Hud_gsi.indicators[index] = ind_obj  
  1281. end 
  1282.  
  1283. function hud_gsi_update_info(index, visible, skin, label_crc, info_crc, info_value) 
  1284. 	--[[ 
  1285. 	index, 			some index to refer to the timer indicator 
  1286. 	]] 
  1287. 	local ind_obj = Hud_gsi.indicators[index] 
  1288.  
  1289. 	 
  1290. 	--Make sure we have found a correct index, otherwise abort! 
  1291. 	if ind_obj == nil then 
  1292. 		return nil 
  1293. 	end 
  1294. 	 
  1295. 	--Check if everything is formatted during change? 
  1296. 	 
  1297. 	--Hide the indicator if it is not visible 
  1298. 	if visible ~= ind_obj.elements.visible then 
  1299. 		if visible == true then 
  1300. 			vint_set_property(ind_obj.elements.grp_h, "visible", true) 
  1301. 			ind_obj.elements.visible = visible 
  1302. 		else 
  1303. 			vint_set_property(ind_obj.elements.grp_h, "visible", false) 
  1304. 			ind_obj.elements.visible = visible 
  1305. 		end 
  1306. 		 
  1307. 		--If the hud is already formatted, queue format process 
  1308. 		if Hud_gsi.status.formatted == true then 
  1309. 			hud_gsi_queue_format() 
  1310. 		end 
  1311. 	end 
  1312. 	 
  1313. 	--Set label with crc 
  1314. 	if label_crc == 0 or label_crc == nil then 
  1315. 		--No crc or Invalid crc 
  1316. 		vint_set_property(ind_obj.elements.label_h, "text_tag", "") 
  1317. 	else 
  1318. 		vint_set_property(ind_obj.elements.label_h, "text_tag_crc", label_crc) 
  1319. 	end 
  1320. 	 
  1321. 	--Store off local vars from the indicator object 
  1322. 	local info_h = ind_obj.elements.info_h 
  1323. 	local label_h = ind_obj.elements.label_h 
  1324. 	 
  1325. 	--Set Info Part 
  1326. 	if info_crc == 0 and info_value == nil then 
  1327. 		--no string 
  1328. 		vint_set_property(info_h, "text_tag", "") 
  1329. 	elseif info_crc == 0 then 
  1330. 		--Use string 
  1331. 		 
  1332. 		--Skin processing 
  1333. 		if skin == "Cash" then 
  1334. 			--format the cash 
  1335. 			info_value = "$" .. format_cash(tonumber(info_value)) 
  1336. 		elseif skin == "TrailBlazing" then 
  1337. 			--Trailblazing specific 
  1338. 			local insertion_text 	= { [0] = info_value } 
  1339. 			info_value = vint_insert_values_in_string("HUD_AMT_SECS_B", insertion_text) 
  1340. 			--Tint the bonus yellow 
  1341. 			vint_set_property(info_h, "tint", Hud_gsi_skins.meter["Default"].tint[1], Hud_gsi_skins.meter["Default"].tint[2], Hud_gsi_skins.meter["Default"].tint[3]) 
  1342. 		end 
  1343. 		 
  1344. 		vint_set_property(info_h, "text_tag", info_value) 
  1345. 	else 
  1346. 		--use crc 
  1347. 		vint_set_property(info_h,"text_tag_crc", info_crc) 
  1348. 	end 
  1349. 	 
  1350. 	--If info indicator is using Mayhem skin update its color 
  1351. 	if skin == "Mayhem" then 
  1352. 		if info_value ~= "0" then 
  1353. 			vint_set_property(info_h, "tint", Hud_mayhem_world_cash_status.color_r, Hud_mayhem_world_cash_status.color_g, Hud_mayhem_world_cash_status.color_b) 
  1354. 		else 
  1355. 			--reset color 
  1356. 			vint_set_property(info_h, "tint", Hud_gsi_skins.meter["Mayhem"].tint[1], Hud_gsi_skins.meter["Mayhem"].tint[2], Hud_gsi_skins.meter["Mayhem"].tint[3]) 
  1357. 		end 
  1358. 	end 
  1359. 	 
  1360. 	 
  1361. 	--Repostion Elements and Calculate width/height 
  1362. 	local label_width, label_height = element_get_actual_size(label_h) 
  1363. 	local info_width, info_height = element_get_actual_size(info_h) 
  1364. 	 
  1365. 	local label_padding = ind_obj.elements.label_padding 
  1366. 	if label_width == 0 then 
  1367. 		--If the label doesn't exist then we don't need any padding 
  1368. 		label_padding = 0  
  1369. 	end 
  1370. 	 
  1371. 	--Left Aligned Only? 
  1372. 	local info_x = label_padding + label_width 
  1373. 	local info_y = 0		 
  1374. 	vint_set_property(info_h, "anchor", info_x, info_y) 
  1375.  
  1376. 	--Override width for mayhem only. 
  1377. 	if skin == "Mayhem" then 
  1378. 		info_width = 30 
  1379. 	end 
  1380. 	 
  1381. 	--Queue frame resize if shit is dirty 
  1382. 	if label_crc ~= ind_obj.data.label_crc  then 
  1383. 		hud_gsi_queue_format() 
  1384. 	end 
  1385. 	 
  1386. 	--Add spacing to width 
  1387. 	local width = info_x + info_width + Hud_gsi.status.text_ind_spacing 
  1388. 	 
  1389. 	local width_dif = abs(ind_obj.elements.width - width) 
  1390. 	 
  1391. 	if width_dif > 3 then 
  1392. 		hud_gsi_queue_format() 
  1393. 	end 
  1394. 	 
  1395. 	ind_obj.elements.width = width 
  1396. 	ind_obj.elements.height = label_height 
  1397. 	 
  1398. 	---Store Values 
  1399. 	ind_obj.data.label_crc = label_crc 
  1400. 	ind_obj.data.info_value = info_value 
  1401. 	 
  1402. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1403. 	--Debug Start 
  1404. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1405. 	if Hud_gsi.status.debug_mode == true then 
  1406. 		show_bounds(ind_obj.elements.grp_h) 
  1407. 	end 
  1408. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1409. end 
  1410.  
  1411. function hud_gsi_create_timer(index, skin, visible) 
  1412. 	--[[ 
  1413. 		index, 		=	Index of Indicator 
  1414. 		skin, 	=	What type of x/y indicator ("positive" == Positive Countdown, "negative" == Negative Countdown) 
  1415. 	]] 
  1416. 	--Error Checking 
  1417. 	if Hud_gsi.indicators[index] ~= nil then 
  1418. 		debug_print("vint", "Failed to create XY indicator with index: " .. index .. "\n") 
  1419. 		return 
  1420. 	end 
  1421. 	 
  1422. 	if skin ~= "positive" and skin ~= "negative" then 
  1423. 		skin = "negative" 
  1424. 		 
  1425. 	end 
  1426. 	 
  1427. 	if visible == false and Hud_gsi.status.config_index == HUD_GSI_CONFIG_MISSION then 
  1428. 		debug_print("vint", "timer is invisible... do not create timer if the timer is not visible and in mission mode\n") 
  1429. 		return 
  1430. 	end 
  1431. 	 
  1432. 	--Duplicate group into the indicators grp and store handles to parts 
  1433. 	local timer_grp_h = vint_object_clone(Hud_gsi.elements.timer_h, Hud_gsi.elements.indicators_grp_h) 
  1434. 	local timer_h = vint_object_find("timer_txt", timer_grp_h) 
  1435. 	local label_h = vint_object_find("label_txt", timer_grp_h) 
  1436. 		 
  1437. 	local default_time = "00:00" 
  1438. 	 
  1439. 	--Get width/height 
  1440. 	vint_set_property(timer_h, "text_tag", default_time) 
  1441. 	local width, height = element_get_actual_size(timer_h) 
  1442. 	 
  1443. 	--Setup default table for object 
  1444. 	local ind_obj = {  
  1445. 		data = { 
  1446. 			index = index, 
  1447. 			timer_value = 0, 
  1448. 			label_crc = 0, 
  1449. 			init = false, 
  1450. 		}, 
  1451. 		elements = { 
  1452. 			grp_h = timer_grp_h, 
  1453. 			label_h = label_h, 
  1454. 			timer_h = timer_h, 
  1455. 			skin = skin, 
  1456. 			label_padding = 9, 
  1457. 			visible = -1, 
  1458. 			width = width, 
  1459. 			height = height, 
  1460. 		} 
  1461. 	} 
  1462. 	Hud_gsi.indicators[index] = ind_obj  
  1463. end 
  1464.  
  1465. function hud_gsi_update_timer(index, visible, skin, label_crc, timer_value) 
  1466. 	local ind_obj = Hud_gsi.indicators[index] 
  1467. 	 
  1468. 	--Make sure we have found a correct index, otherwise abort! 
  1469. 	if ind_obj == nil then 
  1470. 		return nil 
  1471. 	end 
  1472. 	 
  1473. 	--Hide the indicator if it is not visible	 
  1474. 	if visible ~= ind_obj.elements.visible then 
  1475. 		if visible == true then 
  1476. 			vint_set_property(ind_obj.elements.grp_h, "visible", true) 
  1477. 			ind_obj.elements.visible = visible 
  1478. 		else 
  1479. 			vint_set_property(ind_obj.elements.grp_h, "visible", false) 
  1480. 			ind_obj.elements.visible = visible 
  1481. 		end 
  1482. 		 
  1483. 		--If the hud is already formatted, queue format process 
  1484. 		if Hud_gsi.status.formatted == true then 
  1485. 			hud_gsi_queue_format() 
  1486. 		end 
  1487. 	end 
  1488. 	 
  1489. 	--Set label with crc 
  1490. 	if label_crc == 0 or label_crc == nil then 
  1491. 		--No crc or Invalid crc 
  1492. 		vint_set_property(ind_obj.elements.label_h, "text_tag", "") 
  1493. 	else 
  1494. 		vint_set_property(ind_obj.elements.label_h, "text_tag_crc", label_crc) 
  1495. 	end 
  1496.  
  1497. 	--Error Check for timer value 
  1498. 	if timer_value == nil then 
  1499. 		timer_value = 0 
  1500. 	end 
  1501. 	 
  1502. 	--Store local handles to indicator elements 
  1503. 	local timer_h = ind_obj.elements.timer_h 
  1504. 	local label_h = ind_obj.elements.label_h 
  1505. 	 
  1506. 	---Format the time 
  1507. 	local minutes = floor(timer_value / 60) 
  1508. 	local seconds =  mod(timer_value, 60) 
  1509. 	--Pad the seconds for the timer 
  1510. 	if seconds < 10 then 
  1511. 		seconds = "0" .. seconds 
  1512. 	end 
  1513.  
  1514. 	local time_formatted = minutes .. ":" .. seconds 
  1515.  
  1516. 	--Output the time to the text field 
  1517. 	vint_set_property(timer_h, "text_tag", time_formatted) 
  1518. 	 
  1519. 	--Repostion Elements and Calculate width/height 
  1520. 	local label_width, label_height = element_get_actual_size(label_h) 
  1521. 	local timer_width, timer_height = element_get_actual_size(timer_h) 
  1522. 	 
  1523. 	local label_padding = ind_obj.elements.label_padding 
  1524. 	if label_width == 0 then 
  1525. 		--If the label doesn't exist then we don't need any padding 
  1526. 		label_padding = 0  
  1527. 	end 
  1528. 	 
  1529. 	local timer_x = label_padding + label_width 
  1530. 	local timer_y = 0	 
  1531. 	 
  1532. 	vint_set_property(timer_h, "anchor", timer_x, timer_y ) 
  1533. 	 
  1534. 	local is_positive_timer = false 
  1535. 	if skin == "positive" then 
  1536. 		is_positive_timer = true 
  1537. 	end 
  1538. 	 
  1539. 	 
  1540. 	--Resize Frame if shit is dirty 
  1541. 	if label_crc ~= ind_obj.data.label_crc  then 
  1542. 		hud_gsi_queue_format() 
  1543. 	end 
  1544. 	 
  1545. 	ind_obj.elements.width = timer_x + timer_width + Hud_gsi.status.text_ind_spacing 
  1546. 	ind_obj.elements.height = timer_height 
  1547. 	 
  1548. 	--do some extra sound processing 
  1549. 	hud_gsi_update_timer_sound(timer_value, ind_obj.data.timer_value, is_positive_timer) 
  1550. 	 
  1551. 	ind_obj.data.label_crc = label_crc 
  1552. 	ind_obj.data.timer_value = timer_value 
  1553. 	 
  1554. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1555. 	--Debug Start 
  1556. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1557. 	if Hud_gsi.status.debug_mode == true then 
  1558. 		show_bounds(ind_obj.elements.grp_h) 
  1559. 	end 
  1560. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1561. end 
  1562.  
  1563. function hud_gsi_create_xy(index, skin) 
  1564. 	--[[ 
  1565. 		index, 		=	Index of Indicator 
  1566. 		skin, 	=	What type of x/y indicator (nil == nothing special, "cash" == cash display) 
  1567. 	]] 
  1568. 	 
  1569. 	--Error Checking 
  1570. 	if Hud_gsi.indicators[index] ~= nil then 
  1571. 		debug_print("vint", "Failed to create XY indicator with index: " .. index .. "\n") 
  1572. 		return 
  1573. 	end 
  1574. 	 
  1575. 	--Duplicate groups into the indicators grp 
  1576. 	local xy_grp_h = vint_object_clone(Hud_gsi.elements.xy_h, Hud_gsi.elements.indicators_grp_h) 
  1577. 	local label_h = vint_object_find("label_txt", xy_grp_h) 
  1578. 	local x_h = vint_object_find("x_txt", xy_grp_h) 
  1579. 	local y_h = vint_object_find("y_txt", xy_grp_h) 
  1580. 	local slash_h = vint_object_find("slash_txt", xy_grp_h) 
  1581.  
  1582. 	--Setup default table for object 
  1583. 	local ind_obj = { 
  1584. 		data = { 
  1585. 			index = index, 
  1586. 			x_value = 200, 
  1587. 			y_value = 200, 
  1588. 			label = 0, 
  1589. 			init = false, 
  1590. 		}, 
  1591. 		elements = { 
  1592. 			grp_h = xy_grp_h,  
  1593. 			label_h = label_h, 
  1594. 			x_h = x_h, 
  1595. 			y_h = y_h, 
  1596. 			slash_h = slash_h, 
  1597. 			skin = skin, 
  1598. 			label_padding = 9, 
  1599. 			slash_padding = 2, 
  1600. 			visible = -1, 
  1601. 			width = -1, 
  1602. 			height = -1, 
  1603. 		} 
  1604. 	}  
  1605. 	Hud_gsi.indicators[index] = ind_obj  
  1606. end 
  1607.  
  1608. function hud_gsi_update_xy(index, visible, skin, label_crc, x_value, y_value) 
  1609. 	local ind_obj = Hud_gsi.indicators[index] 
  1610. 	 
  1611. 	--Make sure we have found a correct index, otherwise abort! 
  1612. 	if ind_obj == nil then 
  1613. 		return nil 
  1614. 	end 
  1615. 	 
  1616. 	--Hide the indicator if it is not visible 
  1617. 	if visible ~= ind_obj.elements.visible then 
  1618. 		if visible == true then 
  1619. 			vint_set_property(ind_obj.elements.grp_h, "visible", true) 
  1620. 			ind_obj.elements.visible = visible 
  1621. 		else 
  1622. 			vint_set_property(ind_obj.elements.grp_h, "visible", false) 
  1623. 			ind_obj.elements.visible = visible 
  1624. 		end 
  1625. 		 
  1626. 		--If the hud is already formatted, queue format process 
  1627. 		if Hud_gsi.status.formatted == true then 
  1628. 			hud_gsi_queue_format() 
  1629. 		end 
  1630. 	end 
  1631. 	 
  1632. 	 
  1633. 	--Set label with crc 
  1634. 	if label_crc == 0 or label_crc == nil then 
  1635. 		--No crc or Invalid crc 
  1636. 		vint_set_property(ind_obj.elements.label_h, "text_tag", "") 
  1637. 	else 
  1638. 		vint_set_property(ind_obj.elements.label_h, "text_tag_crc", label_crc) 
  1639. 	end 
  1640. 	 
  1641. 	 
  1642. 	--Store off local vars from the indicator object 
  1643. 	local x_h = ind_obj.elements.x_h 
  1644. 	local y_h = ind_obj.elements.y_h 
  1645. 	local slash_h = ind_obj.elements.slash_h 
  1646. 	local label_h = ind_obj.elements.label_h 
  1647. 	 
  1648. 	--Maybe play sound only if our value is greater than 0 
  1649. 	if x_value > 0 then  
  1650. 		--Play sound if we are in a certain configuration? 
  1651. 		if Hud_gsi.status.config_index == 70 then 
  1652. 			--Trail blazing 
  1653. 			audio_play(Hud_gsi_audio.trail_blazing)	 
  1654. 		elseif Hud_gsi.status.config_index >= 51 and Hud_gsi.status.config_index <= 53 then 
  1655. 			--Heli Assault 
  1656. 			audio_play(Hud_gsi_audio.div_complete) 
  1657. 		end 
  1658. 	end 
  1659. 	 
  1660. 	--Apply any special formatting to the text 
  1661. 	local x_value_text, y_value_text 
  1662. 	 
  1663. 	if ind_obj.elements.skin == "Cash" or ind_obj.elements.skin == "Cash_Flash_Disabled" then 
  1664. 		x_value_text = "$" .. format_cash(x_value) 
  1665. 		y_value_text = "$" .. format_cash(y_value) 
  1666. 	else 
  1667. 		x_value_text = x_value 
  1668. 		y_value_text = y_value 
  1669. 	end 
  1670. 			 
  1671. 	--Set Text Fields 
  1672. 	vint_set_property(ind_obj.elements.x_h,"text_tag", x_value_text) 
  1673. 	vint_set_property(ind_obj.elements.y_h,"text_tag", y_value_text) 
  1674. 	 
  1675. 	--Reposition elements 
  1676. 	local slash_padding = ind_obj.elements.slash_padding 
  1677. 	local label_padding = ind_obj.elements.label_padding 
  1678.  
  1679. 	--Get Sizes first 
  1680. 	local label_x, label_y = vint_get_property(label_h, "anchor") 
  1681. 	local label_width, label_height = element_get_actual_size(label_h) 
  1682. 	local x_width, x_height = element_get_actual_size(x_h) 
  1683. 	local slash_width, slash_height = element_get_actual_size(slash_h) 
  1684. 	local y_width, y_height = element_get_actual_size(y_h) 
  1685.  
  1686. 	 
  1687. 	local slash_anchor_x 
  1688. 	if x_width > y_width then 
  1689. 		slash_anchor_x = label_x + label_width + label_padding + x_width 
  1690. 	else 
  1691. 		slash_anchor_x = label_x + label_width + label_padding + y_width 
  1692. 	end 
  1693. 	 
  1694. 	--Set Positions 
  1695. 	local x_anchor_x = slash_anchor_x - slash_padding - x_width 
  1696. 	local y_anchor_x = slash_anchor_x + slash_width + slash_padding 
  1697. 	 
  1698. 	vint_set_property(x_h, "anchor", x_anchor_x, label_y) 
  1699. 	vint_set_property(slash_h, "anchor", slash_anchor_x, label_y) 
  1700. 	vint_set_property(y_h, "anchor", y_anchor_x, label_y) 
  1701. 		 
  1702. 	--Play animations 
  1703. 	if x_value ~= Hud_gsi.indicators[index].data.x_value and skin ~= "Cash_Flash_Disabled" then 
  1704. 		--Make the new number bounce in... 
  1705. 		 
  1706. 		--Clone Number 
  1707. 		local x_clone_h = vint_object_clone(x_h) 
  1708. 		 
  1709. 		vint_set_property(x_clone_h, "render_mode", "additive_alpha") 
  1710. 		vint_set_property(x_clone_h, "depth", -1000) 
  1711. 		local x_clone_x, x_clone_y = vint_get_property(x_h, "anchor") 
  1712. 		local x_width, x_height = element_get_actual_size(x_h) 
  1713. 		 
  1714. 		local x_clone_x_offset = x_width * .5 
  1715. 		local x_clone_y_offset = x_height * .5  
  1716. 	 
  1717. 		x_clone_x = x_clone_x + x_clone_x_offset 
  1718. 		x_clone_y = x_clone_y + x_clone_y_offset 
  1719. 		 
  1720. 		vint_set_property(x_clone_h, "anchor", x_clone_x, x_clone_y) 
  1721. 		vint_set_property(x_clone_h, "auto_offset", "c") 
  1722.  
  1723. 		--Clone Tween 
  1724. 		local anim_h = vint_object_clone(Hud_gsi.anims.x_y_in_anim) 
  1725. 		local twn1 = vint_object_find("gsi_xy_alpha", anim_h) 
  1726. 		local twn2 = vint_object_find("gsi_xy_scale", anim_h) 
  1727.  
  1728. 		--retarget tweens 
  1729. 		vint_set_property(twn1, "target_handle", x_clone_h) 
  1730. 		vint_set_property(twn2, "target_handle", x_clone_h) 
  1731. 		 
  1732. 		--store tweens for cleanup and set callback 
  1733. 		hud_gsi_tween_prepare_cleanup(twn1, anim_h) 
  1734. 		hud_gsi_tween_prepare_cleanup(twn1, x_clone_h) 
  1735. 		vint_set_property(twn1, "end_event", "hud_gsi_tween_cleanup") 
  1736. 		 
  1737. 		--play anim 
  1738. 		lua_play_anim(anim_h, 0) 
  1739. 	end 
  1740.  
  1741. 	--Store values into the data set 
  1742. 	ind_obj.data.label_crc = label_crc 
  1743.  
  1744. 	ind_obj.data.x_value = x_value 
  1745. 	ind_obj.data.y_value = y_value 
  1746. 	 
  1747. 	 
  1748. 	--Calculate Width 
  1749. 	local width = y_anchor_x + y_width + Hud_gsi.status.text_ind_spacing 
  1750. 	 
  1751. 	local width_dif = abs(ind_obj.elements.width - width) 
  1752. 	 
  1753. 	if width_dif > 3 then 
  1754. 		hud_gsi_queue_format() 
  1755. 	end 
  1756. 	 
  1757. 	--Element Set 
  1758. 	ind_obj.elements.width = width 
  1759. 	ind_obj.elements.height = x_height 
  1760. 	 
  1761. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1762. 	--Debug Start 
  1763. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1764. 	if Hud_gsi.status.debug_mode == true then 
  1765. 		show_bounds(ind_obj.elements.grp_h) 
  1766. 		show_bounds(ind_obj.elements.x_h) 
  1767. 		show_bounds(ind_obj.elements.y_h) 
  1768. 		show_bounds(ind_obj.elements.slash_h) 
  1769. 	end 
  1770. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1771. end 
  1772.  
  1773. function hud_gsi_create_meter(index, skin) 
  1774. 	--[[ 
  1775. 	index, 		=	Index of Indicator 
  1776. 	skin, 	=	What type of x/y indicator ("default" == default display) 
  1777. 	]] 
  1778. 	 
  1779. 	--Error Checking 
  1780. 	if Hud_gsi.indicators[index] ~= nil then 
  1781. 		debug_print("vint", "Failed to create meter indicator with index: " .. index .. "\n") 
  1782. 		return 
  1783. 	end 
  1784. 	 
  1785. 	--Setup skin 
  1786. 	local meter_skin = Hud_gsi_skins.meter[skin] 
  1787. 	 
  1788. 	if meter_skin == nil then 
  1789. 		--No skin use default 
  1790. 		meter_skin = Hud_gsi_skins.meter["Default"] 
  1791. 	end 
  1792. 	 
  1793. 	local tint = meter_skin.tint 
  1794. 	 
  1795. 	--Duplicate groups into the indicators grp and store handles to parts 
  1796. 	local meter_grp_h = vint_object_clone(Hud_gsi.elements.meter_h, Hud_gsi.elements.indicators_grp_h) 
  1797. 	local label_h = vint_object_find("label_txt", meter_grp_h) 
  1798. 	local meter_fill_h = vint_object_find("fill", meter_grp_h) 
  1799. 	local meter_fill_2_h = vint_object_find("fill_2", meter_grp_h) 
  1800. 	local meter_bg_h = vint_object_find("bg", meter_grp_h) 
  1801. 	 
  1802. 	--Clone the pulsing animation and retarget the tweens 
  1803. 	local meter_pulse_anim_h = vint_object_clone(Hud_gsi.anims.gsi_fill_pulse) 
  1804. 	vint_set_property(meter_pulse_anim_h, "is_paused", true) 
  1805. 	local scale_twn = vint_object_find("fill_2_scale_twn_1", meter_pulse_anim_h) 
  1806. 	vint_set_property(vint_object_find("fill_2_alpha_twn_1", meter_pulse_anim_h), "target_handle", meter_fill_2_h) 
  1807. 	vint_set_property(scale_twn, "target_handle", meter_fill_2_h) 
  1808. 	vint_set_property(scale_twn, "end_event", "hud_gsi_meter_flash_loop") 
  1809.  
  1810. 	--Store to global for animation special properties 
  1811. 	Hud_gsi_meter_flash_data[scale_twn] = { 
  1812. 		fill_h = meter_fill_h, 
  1813. 		fill_2_h = meter_fill_2_h, 
  1814. 		anim_h = meter_pulse_anim_h, 
  1815. 		BAR_WIDTH_MAX = 172 
  1816. 	} 
  1817. 	 
  1818. 	--Set width of meter 
  1819. 	local meter_filled = vint_get_property(meter_bg_h, "source_se") 
  1820. 	local meter_empty = 0 
  1821. 	 
  1822. 	--Tint Meter 
  1823. 	vint_set_property(meter_fill_h, "tint", tint[1], tint[2], tint[3]) 
  1824. 	vint_set_property(meter_fill_2_h, "tint", tint[1], tint[2], tint[3]) 
  1825.  
  1826. 	--Setup default table for object 
  1827. 	local ind_obj = { 
  1828. 		data = { 
  1829. 			index = index, 
  1830. 			meter_pct = 1, 
  1831. 			meter_filled = meter_filled, 
  1832. 			meter_empty = meter_empty, 
  1833. 			tint = tint, 
  1834. 			is_flashing = false, 
  1835. 			label = 0, 
  1836. 			init = false, 
  1837. 		}, 
  1838. 		elements = { 
  1839. 			skin = skin, 
  1840. 			grp_h = meter_grp_h, 
  1841. 			label_h = label_h, 
  1842. 			meter_fill_h = meter_fill_h, 
  1843. 			meter_fill_2_h = meter_fill_2_h, 
  1844. 			meter_pulse_anim_h = meter_pulse_anim_h, 
  1845. 			meter_bg_h = meter_bg_h, 
  1846. 			label_padding = 9, 
  1847. 			visible = -1, 
  1848. 			width = 100, 
  1849. 			height = 10, 
  1850. 		} 
  1851. 	} 
  1852. 	Hud_gsi.indicators[index] = ind_obj  
  1853. end 
  1854.  
  1855. function hud_gsi_update_meter(index, visible, skin, label_crc, meter_pct, is_flashing) 
  1856. 	--[[ 
  1857. 	index, 			some index to refer to the timer indicator 
  1858. 	info_string, 	string representing the the string to use in the indicator 
  1859. 	]] 
  1860. 	local ind_obj = Hud_gsi.indicators[index] 
  1861. 	 
  1862. 	--Make sure we have found a correct index, otherwise abort! 
  1863. 	if ind_obj == nil then 
  1864. 		return nil 
  1865. 	end 
  1866.  
  1867. 	--Hide the indicator if it is not visible 
  1868. 	if visible ~= ind_obj.elements.visible then 
  1869. 		if visible == true then 
  1870. 			vint_set_property(ind_obj.elements.grp_h, "visible", true) 
  1871. 			ind_obj.elements.visible = visible 
  1872. 		else 
  1873. 			vint_set_property(ind_obj.elements.grp_h, "visible", false) 
  1874. 			ind_obj.elements.visible = visible 
  1875. 		end 
  1876. 		 
  1877. 		--If the hud is already formatted, queue format process 
  1878. 		if Hud_gsi.status.formatted == true then 
  1879. 			hud_gsi_queue_format() 
  1880. 		end 
  1881. 	end 
  1882. 	 
  1883. 	--Set label with crc 
  1884. 	if label_crc == 0 or label_crc == nil then 
  1885. 		--No crc or Invalid crc 
  1886. 		vint_set_property(ind_obj.elements.label_h, "text_tag", "") 
  1887. 	else 
  1888. 		vint_set_property(ind_obj.elements.label_h, "text_tag_crc", label_crc) 
  1889. 	end 
  1890. 	 
  1891. 	--If meter is using mayhem skin update its color 
  1892. 	--Tint Meter 
  1893. 	if skin == "Mayhem" then 
  1894. 		vint_set_property(ind_obj.elements.meter_fill_h, "tint", Hud_mayhem_world_cash_status.color_r, Hud_mayhem_world_cash_status.color_g, Hud_mayhem_world_cash_status.color_b) 
  1895. 		vint_set_property(ind_obj.elements.meter_fill_2_h, "tint", Hud_mayhem_world_cash_status.color_r, Hud_mayhem_world_cash_status.color_g, Hud_mayhem_world_cash_status.color_b) 
  1896. 	end 
  1897. 	 
  1898. 	--Store off local vars from the indicator object 
  1899. 	local label_h = ind_obj.elements.label_h 
  1900. 	local info_h = ind_obj.elements.info_h 
  1901. 	local meter_fill_h = ind_obj.elements.meter_fill_h 
  1902. 	local meter_fill_2_h = ind_obj.elements.meter_fill_2_h 
  1903. 	local meter_bg_h = ind_obj.elements.meter_bg_h 
  1904. 	 
  1905. 	--Calculate meter width and set it 
  1906. 	local fill_width, fill_height = vint_get_property(ind_obj.elements.meter_fill_h, "source_se") 
  1907. 	fill_width = ind_obj.data.meter_filled * meter_pct -- overwrite fill width multiplied by percentage 
  1908. 	vint_set_property(ind_obj.elements.meter_fill_h, "source_se", fill_width, fill_height) 
  1909. 	vint_set_property(ind_obj.elements.meter_fill_2_h , "source_se", fill_width, fill_height) 
  1910.  
  1911. 	if skin == "Fight_Club"	then 
  1912. 		if label_crc ~= ind_obj.data.label_crc then 
  1913. 			--If the hud is already formatted, queue format process because we have changed width 
  1914. 			ind_obj.data.init = false 
  1915. 		end 
  1916. 	end 
  1917. 	 
  1918. 	--Only re-align if this is the first time the element has been updated 
  1919. 	if ind_obj.data.init == false then 
  1920. 		--Repostion Elements and Calculate width/height 
  1921. 		local label_width, label_height = element_get_actual_size(label_h) 
  1922. 		 
  1923. 		local label_padding = ind_obj.elements.label_padding 
  1924. 		if label_width == 0 then 
  1925. 			--If the label doesn't exist then we don't need any padding 
  1926. 			label_padding = 0  
  1927. 		end 
  1928. 		 
  1929. 		local meter_width, meter_height = element_get_actual_size(meter_fill_h) 
  1930. 		local meter_x, meter_y = vint_get_property(meter_bg_h, "anchor") 
  1931. 		meter_x = label_padding + label_width 
  1932. 		 
  1933. 		vint_set_property(meter_fill_h, "anchor", meter_x + 1, meter_y + 3) 
  1934. 		vint_set_property(meter_fill_2_h, "anchor", meter_x + 1, meter_y + 3) 
  1935. 		vint_set_property(meter_bg_h, "anchor", meter_x, meter_y ) 
  1936. 		 
  1937. 		if skin == "Fight_Club"	then 
  1938. 			local width, height = hud_gsi_update_layout() 
  1939. 			hud_gsi_frame_resize(width, height, Hud_gsi.elements.frame_standard) 
  1940. 		end 
  1941. 		 
  1942. 		ind_obj.elements.width = meter_x + meter_width 
  1943. 		ind_obj.elements.height = label_height 
  1944. 		 
  1945. 		ind_obj.data.init = true 
  1946. 	end 
  1947. 	 
  1948. 	if is_flashing == true then 
  1949. 		vint_set_property(ind_obj.elements.meter_pulse_anim_h, "is_paused", false) 
  1950. 		vint_set_property(meter_fill_2_h, "visible", true) 
  1951. 	elseif is_flashing == false then 
  1952. 		vint_set_property(ind_obj.elements.meter_pulse_anim_h, "is_paused", true)		 
  1953. 		vint_set_property(meter_fill_2_h, "visible", false) 
  1954. 	end 
  1955. 	 
  1956. 	--Store Values 
  1957. 	ind_obj.data.label_crc = label_crc 
  1958. 	ind_obj.data.meter_pct = meter_pct 
  1959. 	ind_obj.data.is_flashing = is_flashing 
  1960. 	 
  1961. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1962. 	--Debug Start 
  1963. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1964. 	if Hud_gsi.status.debug_mode == true then 
  1965. 		show_bounds(ind_obj.elements.grp_h) 
  1966. 	end 
  1967. 	--@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  1968. end 
  1969.  
  1970. function hud_gsi_meter_flash_loop(tween_h) 
  1971. 	local flash_data = Hud_gsi_meter_flash_data[tween_h]  
  1972. 	 
  1973. 	if flash_data == nil then 
  1974. 		vint_set_property(tween_h, "end_event", nil) 
  1975. 		return 
  1976. 	end 
  1977. 	lua_play_anim(flash_data.anim_h ) 
  1978. end 
  1979.  
  1980.  
  1981. function hud_gsi_update_meter_alignment(meter_1_obj, meter_2_obj) 
  1982. 	 
  1983. 	--This function assumes that both meters exist and formats them so they align with each other 
  1984. 	 
  1985. 	if meter_1_obj == nil or meter_2_obj == nil then 
  1986. 		--No valid objects homie... 
  1987. 		return 
  1988. 	end 
  1989. 	 
  1990. 	local meter_1_label_width, meter_1_label_height = element_get_actual_size(meter_1_obj.elements.label_h) 
  1991. 	local meter_2_label_width, meter_2_label_height = element_get_actual_size(meter_2_obj.elements.label_h) 
  1992. 	 
  1993. 	local largest_label_width = 0  
  1994. 	local meter_with_smallest_label_obj = nil 
  1995. 	 
  1996. 	--compare widths and assign it to the largest label width 
  1997. 	if meter_1_label_width > meter_2_label_width then 
  1998. 		largest_label_width = meter_1_label_width 
  1999. 		meter_with_smallest_label_obj = meter_2_obj 
  2000. 	else 
  2001. 		largest_label_width = meter_2_label_width 
  2002. 		meter_with_smallest_label_obj = meter_1_obj 
  2003. 	end 
  2004. 	 
  2005. 	--Now we now which object to adjust and what to adjust it too. 
  2006. 	local grp_h = meter_with_smallest_label_obj.elements.grp_h 
  2007. 	local meter_fill_h = meter_with_smallest_label_obj.elements.meter_fill_h 
  2008. 	local meter_bg_h = meter_with_smallest_label_obj.elements.meter_bg_h 
  2009. 	local label_padding = meter_with_smallest_label_obj.elements.label_padding 
  2010. 	local meter_x, meter_y = vint_get_property(meter_bg_h, "anchor") 
  2011. 	local meter_width, meter_height = element_get_actual_size(meter_fill_h) 
  2012. 	meter_x = label_padding + largest_label_width 
  2013. 	 
  2014. 	vint_set_property(meter_fill_h, "anchor", meter_x + 1, meter_y + 3) 
  2015. 	vint_set_property(meter_bg_h, "anchor", meter_x, meter_y ) 
  2016.  
  2017. 	--We Only need to reset the width of the object because the height didn't change 
  2018. 	meter_with_smallest_label_obj.elements.width = meter_x + meter_width 
  2019.  
  2020. end 
  2021.  
  2022. Hud_gsi_tween_objects = {} 
  2023. --Tween object cleanup 
  2024. function hud_gsi_tween_prepare_cleanup(tween_h, obj_h) 
  2025. 	if Hud_gsi_tween_objects[tween_h] == nil then 
  2026. 		Hud_gsi_tween_objects[tween_h] = {} 
  2027. 	end 
  2028. 	Hud_gsi_tween_objects[tween_h][obj_h] = obj_h 
  2029. end 
  2030.  
  2031. function hud_gsi_tween_cleanup(tween_h) 
  2032. 	for index, value in Hud_gsi_tween_objects do 
  2033. 		if index == tween_h then 
  2034. 			--This is the one to clean up so do it 
  2035. 			--Clean Up items 
  2036. 			for ix, vx in value do 
  2037. 				vint_object_destroy(vx) 
  2038. 			end 
  2039. 			Hud_gsi_tween_objects[index] = nil 
  2040. 		end 
  2041. 	end 
  2042. end 
  2043.  
  2044. --Does processing to verify that the hud always maintains its proper format. 
  2045. function hud_gsi_process() 
  2046. 	if Hud_gsi.status.queue_format == true then 
  2047. 		--We can't format anything if we don't have all the indicators 
  2048. 		local indicators_created = 0 
  2049. 		for i, val in Hud_gsi.indicators do 
  2050. 			indicators_created = indicators_created + 1 
  2051. 		end 
  2052. 		 
  2053. 		--If we have all the indicators created, we can format 
  2054. 		if indicators_created == Hud_gsi.status.indicator_count then 
  2055. 			local width, height = hud_gsi_update_layout() 
  2056. 			hud_gsi_frame_animate(width, height, 0, Hud_gsi.elements.frame_standard) 
  2057. 		end 
  2058. 		 
  2059. 		--Reset the format 
  2060. 		Hud_gsi.status.queue_format = false 
  2061. 	end 
  2062. end 
  2063.  
  2064. function hud_gsi_queue_format() 
  2065. 	Hud_gsi.status.queue_format = true 
  2066. end 
  2067.  
  2068. Hud_gsi_persistant = { 
  2069. 	is_active = false, 
  2070. 	loaded_peg = -1, 
  2071. } 
  2072.  
  2073. function hud_gsi_persistant_update(di_h) 
  2074. 	--Updates teh persistent gsi 
  2075. 	local status, title, peg_name, image_name, line_1, line_2 = vint_dataitem_get(di_h) 
  2076. 	 
  2077. 	if Hud_gsi.status.debug_mode == true then 
  2078. 		debug_print("vint", "hud_gsi_persistant_update(di_h)\n") 
  2079. 		debug_print("vint", " status: " .. var_to_string(status) .. "\n") 
  2080. 		debug_print("vint", " title: " .. var_to_string(title) .. "\n") 
  2081. 		debug_print("vint", " peg_name: " .. var_to_string(peg_name) .. "\n") 
  2082. 		debug_print("vint", " image_name: " .. var_to_string(image_name) .. "\n") 
  2083. 		debug_print("vint", " line_1: " .. var_to_string(line_1) .. "\n") 
  2084. 		debug_print("vint", " line_2: " .. var_to_string(line_2) .. "\n\n") 
  2085. 	end 
  2086. 	--[[ 
  2087. 	status = 0 off 
  2088. 	status = 1 on 
  2089. 	status = 2 refresh 
  2090. ]]	 
  2091. 	--update active state 
  2092. 	if status > 0 then 
  2093. 		 
  2094. 		--Load peg 
  2095. 		if Hud_gsi_persistant.loaded_peg ~= -1 then 
  2096. 			--unload old peg 
  2097. 			peg_unload(Hud_gsi_persistant.loaded_peg) 
  2098. 		end 
  2099. 		 
  2100. 		--load new peg 
  2101. 		Hud_gsi_persistant.loaded_peg = peg_name 
  2102. 		peg_load(peg_name) 
  2103. 		 
  2104. 		--Set image 
  2105. 		vint_set_property(Hud_gsi_persistant.handles.poloroid_bmp, "image", image_name) 
  2106. 		 
  2107. 		--Set Text 
  2108. 		vint_set_property(Hud_gsi_persistant.handles.poloroid_title_txt, "text_tag", title) 
  2109. 		vint_set_property(Hud_gsi_persistant.handles.poloroid_line_1_txt, "text_tag", line_1) 
  2110. 		vint_set_property(Hud_gsi_persistant.handles.poloroid_line_2_txt, "text_tag", line_2) 
  2111. 		 
  2112. 		if Hud_gsi.status.is_fading_out == false then 
  2113. 			--Show display 
  2114. 			hud_gsi_persistant_show() 
  2115. 		end 
  2116. 		 
  2117. 	else 
  2118. 		hud_gsi_persistant_hide() 
  2119. 	end 
  2120. 	 
  2121. 	Hud_gsi_persistant.status = status 
  2122. end 
  2123.  
  2124.  
  2125. function hud_gsi_persistant_show() 
  2126. 	--Pops the GSI into the poloroid mode 
  2127. 	 
  2128. 	--Hide normal gsi elements 
  2129. 	vint_set_property(Hud_gsi.elements.standard_grp_h, "visible", false) 
  2130.  
  2131. 	--Show persistant elements 
  2132. 	vint_set_property(Hud_gsi_persistant.handles.grp, "visible", true) 
  2133. 	 
  2134. 	--Resize box 
  2135. 	hud_gsi_persistant_resize() 
  2136. 	 
  2137. 	--Show box 
  2138. 	vint_set_property(Hud_gsi.elements.box_grp_h, "alpha", 1) 
  2139. end 
  2140.  
  2141. function hud_gsi_persistant_resize() 
  2142. 	 
  2143. 	local width = 0  
  2144. 	local height = 0 
  2145. 	local line_height = 0 
  2146.  
  2147. 	local temp_width, temp_height = element_get_actual_size(Hud_gsi_persistant.handles.poloroid_title_txt) 
  2148. 	 
  2149. 	--Store header height 
  2150. 	local header_height = temp_height	 
  2151. 	 
  2152. 	--Header width test 
  2153. 	if temp_width > width then 
  2154. 		width = temp_width 
  2155. 	end 
  2156. 	 
  2157. 	--Line 1 Test 
  2158. 	temp_width, temp_height = element_get_actual_size(Hud_gsi_persistant.handles.poloroid_line_1_txt) 
  2159. 	if temp_width > width then 
  2160. 		width = temp_width 
  2161. 	end 
  2162.  
  2163. 	--Line 2 Test 
  2164. 	temp_width, temp_height = element_get_actual_size(Hud_gsi_persistant.handles.poloroid_line_2_txt) 
  2165. 	if temp_width > width then 
  2166. 		width = temp_width 
  2167. 	end 
  2168.  
  2169. 	local x, y = vint_get_property(Hud_gsi_persistant.handles.poloroid_line_2_txt, "anchor") 
  2170. 	width = width + x - 8 
  2171.  
  2172. 	--Calculate height with some magic numbers (indicator height) + header_height 
  2173. 	height = (2 * Hud_gsi.status.line_height) + header_height - Hud_gsi.status.box_height_offset - 10 
  2174.  
  2175. 	hud_gsi_frame_resize(width, height, Hud_gsi_persistant.handles.frame) 
  2176. end 
  2177.  
  2178.  
  2179. function hud_gsi_persistant_hide() 
  2180. 	--Show normal gsi elements 
  2181. 	vint_set_property(Hud_gsi.elements.standard_grp_h, "visible", true) 
  2182.  
  2183. 	--Hide persistant elements 
  2184. 	vint_set_property(Hud_gsi_persistant.handles.grp, "visible", false) 
  2185. end 
  2186.  
  2187.  
  2188. ---------------------------------------------------------------- 
  2189. --Countdown process 
  2190. ---------------------------------------------------------------- 
  2191.  
  2192. function hud_gsi_update_timer_sound(cur_time, prev_time, is_positive_timer) 
  2193. --[[	if cur_time ~= prev_time then 
  2194. 		local play_sound = false 
  2195. 		local play_second_sound = false 
  2196. 		if cur_time <= 15 and  cur_time > 10 then 
  2197. 			--2 seconds 
  2198. 			play_sound = true 
  2199. 		elseif cur_time <= 10 and cur_time > 5 then 
  2200. 			--1 second 
  2201. 			play_sound = true 
  2202. 		elseif cur_time <= 5 and cur_time > 0 then 
  2203. 			--0.5 seconds 
  2204. 			play_sound = true 
  2205. 			play_second_sound = true 
  2206. 		elseif cur_time == 0 then 
  2207. 			--Play final sound 
  2208. 			if is_positive_timer then 
  2209. 				audio_play(Hud_gsi_audio.end_pos) 
  2210. 			else 
  2211. 				audio_play(Hud_gsi_audio.end_neg) 
  2212. 			end 
  2213. 		end 
  2214. 		if play_sound == true then 
  2215. 			if is_positive_timer then 
  2216. 				audio_play(Hud_gsi_audio.count_pos) 
  2217. 				if play_second_sound == true then 
  2218. 					hud_gsi_sound_play_delay(Hud_gsi_audio.count_pos, .5) 
  2219. 				end 
  2220. 			else 
  2221. 				audio_play(Hud_gsi_audio.count_neg) 
  2222. 				if play_second_sound == true then 
  2223. 					hud_gsi_sound_play_delay(Hud_gsi_audio.count_neg, .5) 
  2224. 				end 
  2225. 			end 
  2226. 		end 
  2227. 	end 
  2228. 	 
  2229. 	]]-- 
  2230. end 
  2231.  
  2232.  
  2233. -------------------------------------------- 
  2234. --sound delay stuff 
  2235. function hud_gsi_sound_play_delay(sound_id, offset) 
  2236. 	thread_new("hud_gsi_sound_play_thread", sound_id, offset) 
  2237. end 
  2238.  
  2239. function hud_gsi_sound_play_thread(sound_id, offset) 
  2240. 	local is_pause_menu_open  
  2241. 	--Check if pause menu is open 
  2242. 	local pause_doc = vint_document_find("pause_menu") 
  2243. 	if pause_doc == 0 then 
  2244. 		delay(offset) 
  2245. 		audio_play(sound_id) 
  2246. 	end 
  2247. end 
  2248.  
  2249.  
  2250. --[[ 
  2251. ######################################################################### 
  2252. TEST FUNCTIONS 
  2253. ######################################################################### 
  2254. ]] 
  2255.  
  2256. --Used to show the bounding box of an object. (NOTE: Does not work for offsets that are not 0,0) 
  2257. Bounds_util_data = {} 
  2258. function show_bounds(element_handle) 
  2259. 	local h 
  2260. 	if Bounds_util_data[element_handle] == nil then 
  2261. 		h = vint_object_create("bounds_util", "bitmap", element_handle) 
  2262. 		vint_set_property(h, "image", "ui_blank") 
  2263. 		vint_set_property(h, "tint", rand_float(.3,1),rand_float(.3,1),rand_float(.3,1)) 
  2264. 		vint_set_property(h, "alpha", .5) 
  2265. 		vint_set_property(h, "depth", -5000) 
  2266. 		Bounds_util_data[element_handle] = h 
  2267. 	else 
  2268. 		h = Bounds_util_data[element_handle] 
  2269. 	end 
  2270. 	vint_set_property(h, "anchor", 0,0) 
  2271. 	local element_height, element_width = vint_get_property(element_handle,"screen_size") 
  2272. 	vint_set_property(h, "screen_size", element_height, element_width) 
  2273. end 
  2274.  
  2275.  
  2276.