./hud_msg.lua

  1. Hud_msg_doc = 0 
  2.  
  3. -- Has to match the enum in hud_message.h 
  4. HUD_REGION_DEBUG				= 0 
  5. HUD_REGION_HELP				= 1 
  6. HUD_REGION_DIVERSION			= 2 
  7. HUD_REGION_SUBTITLES			= 3 
  8. HUD_REGION_CUTSCENE_HELP	= 4 
  9. HUD_REGION_USE_MSGS 			= 5 
  10. HUD_REGION_NEW_GAMEPLAY		= 6 
  11. HUD_REGION_CRITICAL_TIMER	= 7 
  12. HUD_REGION_USE_MSGS_ALT		= 8 
  13. HUD_NUM_REGIONS				= 9 
  14.  
  15. HUD_MSG_DIR_UP			= 0 
  16. HUD_MSG_DIR_DOWN		= 1 
  17. HUD_MSG_DIR_CENTER	= 2 
  18.  
  19. Hud_msg_std_text 		= { scale = 0.6, wrap_width = 0, leading = -5} 
  20. Hud_msg_help_text		= { scale = 0.7, wrap_width = 390, leading = -5} 	 
  21. Hud_msg_subtitle_text	= { scale = 0.7, wrap_width = 0, leading = -5}	-- Needs to match subtitles.cpp 
  22.  
  23. -- HUD Message Icon Enum... action_message_icon in  
  24. -- 
  25. -- ...\src\game\interface\interface_enums.h  
  26. HUD_MSG_ICON_NONE = 0  
  27. HUD_MSG_ICON_Y = 1 
  28. HUD_MSG_ICON_X = 2 
  29. HUD_MSG_ICON_A = 3 
  30. HUD_MSG_ICON_BACK = 4 
  31. HUD_MSG_ICON_DPAD_LEFT = 5 
  32. HUD_MSG_ICON_DPAD_RIGHT = 6 
  33. HUD_MSG_ICON_DPAD_DOWN = 7 
  34. HUD_MSG_ICON_DPAD_UP = 8 
  35. HUD_MSG_ICON_SHOP = 9 
  36. HUD_MSG_ICON_MISSION = 10 
  37. HUD_MSG_ICON_HUMANSHIELD = 11 
  38. HUD_MSG_ICON_MECHANIC = 12 
  39. HUD_MSG_ICON_GARAGE = 13 
  40. HUD_MSG_ICON_CRIB = 14 
  41. HUD_MSG_ICON_LEFT_BUMPER = 15 
  42. HUD_MSG_ICON_RIGHT_BUMPER = 16 
  43.  
  44. -- Used to tell the HUB to go directly to the quest log 
  45. Hud_msg_new_quest_displayed = false 
  46.  
  47. --Alternate and standard use message indexes. 
  48. local HUD_MSG_INDEX_STANDARD 	= 0 
  49. local HUD_MSG_INDEX_ALT 		= 1 
  50.  
  51. Hud_msg_icons = { 
  52. 	[HUD_MSG_ICON_NONE] = { 
  53. 		bmp = "ui_blank", 
  54. 	}, 
  55. 	[HUD_MSG_ICON_SHOP] = { 
  56. 		bmp = "ui_hud_use_shopping", 
  57. 		color = {R = 201/255, G = 186/255, B = 44/255}, 
  58. 		x = -34, 
  59. 		y = -39,  
  60. 	}, 
  61. 	[HUD_MSG_ICON_Y] = { 
  62. 		bmp = CTRL_BUTTON_Y, 
  63. 	}, 
  64. 	[HUD_MSG_ICON_X] = { 
  65. 		bmp = CTRL_BUTTON_X, 
  66. 	},	 
  67. 	[HUD_MSG_ICON_A] = { 
  68. 		bmp = get_a_button(true), 
  69. 	},	 
  70. 	[HUD_MSG_ICON_DPAD_LEFT] = { 
  71. 		bmp = CTRL_BUTTON_DPAD_LEFT, 
  72. 	}, 
  73. 	[HUD_MSG_ICON_DPAD_RIGHT] = { 
  74. 		bmp = CTRL_BUTTON_DPAD_RIGHT, 
  75. 	},	 
  76. 	[HUD_MSG_ICON_DPAD_DOWN] = { 
  77. 		bmp = CTRL_BUTTON_DPAD_DOWN, 
  78. 	},	 
  79. 	[HUD_MSG_ICON_DPAD_UP] = { 
  80. 		bmp = CTRL_BUTTON_DPAD_UP, 
  81. 	},	 
  82. 	[HUD_MSG_ICON_BACK] = { 
  83. 		bmp = CTRL_MENU_BUTTON_BACK, 
  84. 	}, 
  85. 	[HUD_MSG_ICON_MISSION] = { 
  86. 		bmp = "ui_hud_icon_new_mission", 
  87. 	}, 
  88. 	[HUD_MSG_ICON_HUMANSHIELD] = { 
  89. 		bmp = "ui_hud_use_human_shield", 
  90. 		color = {R = 201/255, G = 186/255, B = 44/255}, 
  91. 		x = -30, 
  92. 		y = -55,  
  93. 	}, 
  94. 	[HUD_MSG_ICON_MECHANIC] = { 
  95. 		bmp = "ui_hud_use_wrench", 
  96. 		color = {R = 201/255, G = 186/255, B = 44/255}, 
  97. 		x = -34, 
  98. 		y = -39,  
  99. 	}, 
  100. 	[HUD_MSG_ICON_GARAGE] = { 
  101. 		bmp = "ui_hud_use_garage", 
  102. 		color = {R = 201/255, G = 186/255, B = 44/255}, 
  103. 		x = -34, 
  104. 		y = -39,  
  105. 	}, 
  106. 	[HUD_MSG_ICON_CRIB] = { 
  107. 		bmp = "ui_hud_use_crib", 
  108. 		color = {R = 201/255, G = 186/255, B = 44/255}, 
  109. 		x = -34, 
  110. 		y = -39,  
  111. 	}, 
  112. 	[HUD_MSG_ICON_LEFT_BUMPER] = { 
  113. 		bmp = CTRL_BUTTON_LB, 
  114. 	}, 
  115. 	[HUD_MSG_ICON_RIGHT_BUMPER] = { 
  116. 		bmp = CTRL_BUTTON_RB, 
  117. 	},	 
  118. } 
  119.  
  120. local Hud_msg_use_h 
  121. local Hud_msg_use_btn 
  122. local Hud_msg_use_alt_btn 
  123. local Hud_msg_use_btn_meter_grp_h 
  124. local Hud_msg_use_start_x = 0 
  125. local Hud_msg_use_start_y = 0 
  126. local Hud_msg_use_text_start_x = 0 
  127. local Hud_msg_use_text_start_y = 0 
  128. local Hud_msg_tiers_text_start_x = 0 
  129. local Hud_msg_tiers_text_start_y = 0 
  130.  
  131. local Hud_msg_new_gameplay_h 
  132. local Hud_msg_gameplay_btn 
  133. local Hud_msg_gameplay_start_x = 0 
  134. local Hud_msg_gameplay_start_y = 0 
  135.  
  136. local Hud_msg_use_alt_h 
  137. local Hud_use_msg_alt_fade_in_h  
  138. local Hud_use_msg_alt_fade_out_h  
  139.  
  140. local Hud_msg_critical = {} 
  141.  
  142. local Hud_msg_current_use_msg_id = 0 
  143. local Hud_msg_current_use_alt_msg_id = 0 
  144. local Hud_msg_current_critical_msg_id = 0 
  145. local Hud_msg_current_critical_msg_visible = false 
  146.  
  147. local Hud_msg_quest_anim_h = 0 
  148. local Hud_msg_quest_out_anim_h = 0 
  149. local Hud_msg_quest_new_only_h = 0 
  150. local Hud_msg_quest_out_new_only_h = 0 
  151. local Hud_msg_obj_anim_h = 0 
  152. local Hud_msg_coop_anim_h = 0 
  153. local Hud_msg_coop_out_anim_h = 0 
  154. local Hud_msg_base_anim_h = 0 
  155. local Hud_msg_base_out_anim_h = 0 
  156. local Hud_msg_quest_grp_h = 0 
  157.  
  158. local Hud_msg_voice_msg_h = 0 -- HVS_TJW 
  159.  
  160. local Hud_msg_objective_complete_listener_h = 0 
  161.  
  162. local HUD_QUEST_COMPLETE_MAX_WIDTH = 360 
  163.  
  164. local HUD_MSG_USE_ALT_OFFSET_VERTICAL = 33	--Offset of standard use message... 
  165.  
  166. Hud_msg_regions = { 
  167. 	[HUD_REGION_DEBUG]		= { 
  168. 		text_fmt = Hud_msg_std_text, 
  169. 		direction = HUD_MSG_DIR_CENTER,	max_msgs = 10, 
  170. 		anchor = "msg_debug_anchor", 
  171. 		msgs = { num_msgs = 0 } 
  172. 	}, 
  173. 	 
  174. 	[HUD_REGION_HELP]		= { 
  175. 		text_fmt = Hud_msg_help_text, 
  176. 		direction = HUD_MSG_DIR_DOWN, 
  177. 		max_msgs = 3, 
  178. 		anchor = "msg_help_anchor", 
  179. 		msgs = { num_msgs = 0 } 
  180. 	}, 
  181. 	 
  182. 	[HUD_REGION_DIVERSION]	= { 
  183. 		text_fmt = Hud_msg_std_text, 
  184. 		direction = HUD_MSG_DIR_UP, 
  185. 		max_msgs = 7, 
  186. 		anchor = "msg_diversion_anchor", 
  187. 		msgs = { num_msgs = 0 } 
  188. 	}, 
  189.  
  190. 	[HUD_REGION_SUBTITLES]	= { 
  191. 		text_fmt = Hud_msg_subtitle_text, 
  192. 		direction = HUD_MSG_DIR_CENTER, 
  193. 		max_msgs = 3, 
  194. 		anchor = "msg_subtitle_anchor", 
  195. 		msgs = { num_msgs = 0 } 
  196. 	}, 
  197.  
  198. 	[HUD_REGION_CUTSCENE_HELP]	= { 
  199. 		text_fmt = Hud_msg_help_text, 
  200. 		direction = HUD_MSG_DIR_CENTER, 
  201. 		max_msgs = 2, 
  202. 		anchor = "cs_help_anchor", 
  203. 		msgs = { num_msgs = 0 } 
  204. 	}, 
  205. 	[HUD_REGION_USE_MSGS]	= { 
  206. 		text_fmt = Hud_msg_help_text, 
  207. 		direction = HUD_MSG_DIR_DOWN, 
  208. 		max_msgs = 2, 
  209. 		anchor = "msg_help_anchor", 
  210. 		msgs = { num_msgs = 0 }, 
  211. 	}, 
  212. 	[HUD_REGION_NEW_GAMEPLAY]	= { 
  213. 		text_fmt = Hud_msg_help_text, 
  214. 		direction = HUD_MSG_DIR_DOWN, 
  215. 		max_msgs = 1, 
  216. 		anchor = "msg_help_anchor", 
  217. 		msgs = { num_msgs = 0 }, 
  218. 	}, 
  219. 	[HUD_REGION_CRITICAL_TIMER]	= { 
  220. 		text_fmt = Hud_msg_help_text, 
  221. 		direction = HUD_MSG_DIR_DOWN, 
  222. 		max_msgs = 1, 
  223. 		anchor = "msg_help_anchor", 
  224. 		msgs = { num_msgs = 0 }, 
  225. 	},	 
  226. 	[HUD_REGION_USE_MSGS_ALT]	= { 
  227. 		text_fmt = Hud_msg_help_text, 
  228. 		direction = HUD_MSG_DIR_DOWN, 
  229. 		max_msgs = 1, 
  230. 		anchor = "msg_help_anchor", 
  231. 		msgs = { num_msgs = 0 }, 
  232. 	},	 
  233. } 
  234.  
  235. -- all messages are stored here with the data item handle as index 
  236. Hud_msgs = { } 
  237.  
  238. function hud_msg_init() 
  239. 	Hud_msg_doc = vint_document_find("hud_msg") 
  240. 	 
  241. 	-- resolve the anchors out to handles 
  242. 	for i, v in pairs(Hud_msg_regions) do 
  243. 		v.anchor = vint_object_find(v.anchor) 
  244. 	end 
  245.  
  246. 	--Resize help region if we are in hd 
  247. 	if vint_is_std_res() == false then 
  248. 		--HD mode 
  249. 		Hud_msg_help_text.wrap_width = 635 
  250. 	end 
  251. 	 
  252. 	if game_get_language() == "JP" then 
  253. 		Hud_msg_subtitle_text.leading = -3 
  254. 	elseif game_get_language() == "SK" then 
  255. 		Hud_msg_subtitle_text.scale = 0.9 
  256. 		Hud_msg_subtitle_text.leading = -3 
  257. 	end 
  258. 	 
  259. 	--Store center for centering later... 
  260. 	Hud_msg_use_h = vint_object_find("use_msg") 
  261. 	Hud_msg_use_start_x, Hud_msg_use_start_y = vint_get_property(Hud_msg_use_h, "anchor") 
  262. 	local use_text_h = vint_object_find("use_text", Hud_msg_use_h) 
  263. 	Hud_msg_use_text_start_x, Hud_msg_use_text_start_y = vint_get_property(use_text_h, "anchor") 
  264. 	local tiers_text_h = vint_object_find("tiers_text", Hud_msg_use_h) 
  265. 	Hud_msg_tiers_text_start_x, Hud_msg_tiers_text_start_y = vint_get_property(tiers_text_h, "anchor") 
  266. 	 
  267. 	--Creates our alternate use message via script. 
  268. 	hud_msg_create_use_alt() 
  269. 	 
  270. 	--Store off the buttons for later use 
  271. 	Hud_msg_use_btn = Vdo_hint_button:new("use_btn", Hud_msg_use_h) 
  272. 	Hud_msg_use_alt_btn = Vdo_hint_button:new("use_btn", Hud_msg_use_alt_h) 
  273. 	Hud_msg_gameplay_btn = Vdo_hint_button:new("new_gameplay_btn") 
  274. 	 
  275. 	Hud_msg_use_btn_meter_grp_h = vint_object_find("use_btn_meter_grp") 
  276. 	vint_set_property(Hud_msg_use_btn_meter_grp_h, "visible", false) 
  277. 	 
  278. 	--Hide Use Message... 
  279. 	vint_set_property(Hud_msg_use_h, "alpha", 0) 
  280. 	vint_set_property(Hud_msg_use_alt_h, "alpha", 0) 
  281. 	 
  282. 	--Store center for centering later... 
  283. 	Hud_msg_new_gameplay_h = vint_object_find("new_gameplay_msg") 
  284. 	Hud_msg_gameplay_start_x, Hud_msg_gameplay_start_y = vint_get_property(Hud_msg_new_gameplay_h, "anchor") 
  285. 	 
  286. 	--Store voice chat message handle 
  287. 	Hud_msg_voice_msg_h = vint_object_find("coop_voice_msg") 
  288. 	 
  289. 	--Hide New Gameplay Message... 
  290. 	vint_set_property(Hud_msg_new_gameplay_h, "alpha", 0) 
  291. 	 
  292. 	--Critical Timer 
  293. 	Hud_msg_critical.grp_h 					= vint_object_find("critical_timer") 
  294. 	Hud_msg_critical.timer_grp_h 			= vint_object_find("timer_grp", Hud_msg_critical.grp_h) 
  295. 	Hud_msg_critical.timer_txt_h  		= vint_object_find("critical_time_txt", Hud_msg_critical.grp_h) 
  296. 	Hud_msg_critical.timer_bmp_h  		= vint_object_find("timer_bmp", Hud_msg_critical.grp_h) 
  297. 	Hud_msg_critical.timer_desc_txt_h 	= vint_object_find("critical_timer_desc_txt", Hud_msg_critical.grp_h) 
  298. 	Hud_msg_critical.critical_bg_h 		= vint_object_find("critical_bg", Hud_msg_critical.grp_h) 
  299. 	Hud_msg_critical.fade_in_anim_h 		= vint_object_find("critical_timer_fade_in")		  
  300. 	Hud_msg_critical.fade_out_anim_h 	= vint_object_find("critical_timer_fade_out")	  
  301.  
  302. 	--Store centering information for the timer. 
  303. 	Hud_msg_critical.timer_grp_x, Hud_msg_critical.timer_grp_y  	= vint_get_property(Hud_msg_critical.timer_grp_h, "anchor") 
  304. 	 
  305. 	--Hide Critical Timer... 
  306. 	vint_set_property(Hud_msg_critical.grp_h, "alpha", 0) 
  307. 	 
  308. 	--Hide quest grp 
  309. 	Hud_msg_quest_grp_h = vint_object_find("quest_update_grp", 0, Hud_msg_doc) 
  310. 	Hud_msg_quest_anim_h = vint_object_find("quest_update_anim", 0) 
  311. 	Hud_msg_quest_out_anim_h = vint_object_find("quest_update_out_anim", 0)	 
  312. 	Hud_msg_quest_new_only_h = vint_object_find("quest_update_solo", 0) 
  313. 	Hud_msg_quest_out_new_only_h = vint_object_find("quest_update_out_solo", 0) 
  314. 	 
  315. 	vint_set_property(Hud_msg_quest_grp_h, "visible", false) 
  316. 	 
  317. 	--Quest/Coop/Objective Animations... 
  318. 	Hud_msg_obj_anim_h = vint_object_find("objective_cmp_anim", 0)	 
  319. 	Hud_msg_base_anim_h = vint_object_find("quest_base_anim", 0)	 
  320. 	Hud_msg_base_out_anim_h = vint_object_find("quest_base_out_anim", 0)		 
  321. 	Hud_msg_coop_anim_h = vint_object_find("quest_coop_anim", 0)		 
  322. 	Hud_msg_coop_out_anim_h = vint_object_find("quest_coop_out_anim", 0)		 
  323. 	 
  324.  
  325. 	--Setup callback for Quest objective complete anim... 
  326. 	local objective_cmp_end_twn_h = vint_object_find("objective_cmp_end_twn", Hud_msg_obj_anim_h) 
  327. 	vint_set_property(objective_cmp_end_twn_h, "start_event", "hud_msg_quest_obj_fade_out")	 
  328. 	 
  329. 	--Setup callback for Quest complete anim... 
  330. 	--local quest_out_end_event_twn_h = vint_object_find("end_event", Hud_msg_quest_out_anim_h) 
  331. 	--vint_set_property(quest_out_end_event_twn_h, "start_event", "hud_msg_quest_hide") 
  332. 	 
  333. 	--Setup callback for Quest complete anim... 
  334. 	local quest_out_new_end_event_twn_h = vint_object_find("end_event", Hud_msg_quest_out_new_only_h) 
  335. 	vint_set_property(quest_out_new_end_event_twn_h, "start_event", "hud_msg_quest_new_hide") 
  336. 		 
  337. 	--Subscribe to data... 
  338. 	vint_datagroup_add_subscription("hud_messages", "insert", "hud_msg_new_message") 
  339. 	vint_datagroup_add_subscription("hud_messages", "update", "hud_msg_update_message") 
  340. 	vint_datagroup_add_subscription("hud_messages", "remove", "hud_msg_remove_message") 
  341. 	 
  342. 	-- quest objective listener 
  343. 	Hud_msg_objective_complete_listener_h = vint_scriptevent_listen( "quest_objective_complete", "hud_msg_update_quest" ) 
  344. end 
  345.  
  346. function hud_msg_cleanup() 
  347. 	vint_scriptevent_stop_listening( Hud_msg_objective_complete_listener_h ) 
  348. end 
  349.  
  350. function hud_msg_process() 
  351. 	for i, region in pairs(Hud_msg_regions) do 
  352. 		if region.is_dirty == true then 
  353. 			hud_msg_update_region(region, i) 
  354. 			region.is_dirty = false 
  355. 		end 
  356. 	end 
  357. end 
  358.  
  359. function hud_msg_update_region(region, region_index) 
  360. 	local pos_x, pos_y = 0, 0 
  361. 	local msgs_displayed = 0 
  362.  
  363. 	if region_index == HUD_REGION_USE_MSGS then 
  364. 		--Use messages... 
  365. 		for msg_i = 0, region.msgs.num_msgs - 1 do 
  366. 			if msgs_displayed >= region.max_msgs then 
  367. 			else 
  368. 				local msg = region.msgs[msg_i] 
  369. 				local msg_id = msg.di_h 
  370. 				hud_msg_update_use(msg) 
  371. 				if Hud_msg_current_use_msg_id ~= msg.di_h then					 
  372. 					--New message we should always fade in... 
  373. 					local h = vint_object_find("use_msg_fade_out", 0, Hud_msg_doc) 
  374. 					vint_set_property(h, "is_paused", true) 
  375. 					h = vint_object_find("use_msg_fade_in", 0, Hud_msg_doc) 
  376. 					lua_play_anim(h, 0, Hud_msg_doc) 
  377. 				end 
  378. 				if Hud_msg_current_use_msg_id == msg.di_h then 
  379. 					if msg.fade_time ~= 0 then 
  380. 						--old message with a fade time, lets fade out... 
  381. 						local h = vint_object_find("use_msg_fade_in", 0, Hud_msg_doc) 
  382. 						vint_set_property(h, "is_paused", true) 
  383. 						h = vint_object_find("use_msg_fade_out", 0, Hud_msg_doc) 
  384. 						lua_play_anim(h, 0, Hud_msg_doc) 
  385. 						msg_id = -1 
  386. 					end 
  387. 				end 
  388.  				Hud_msg_current_use_msg_id = msg_id 
  389. 			end 
  390. 			msgs_displayed = msgs_displayed + 1 
  391. 		end 
  392. 		if region.msgs.num_msgs == 0 and Hud_msg_current_use_msg_id ~= -1 then 
  393. 			--Fade out if there are no more messages left in the queue.. 
  394. 			local h = vint_object_find("use_msg_fade_in", 0, Hud_msg_doc) 
  395. 			vint_set_property(h, "is_paused", true) 
  396. 			h = vint_object_find("use_msg_fade_out", 0, Hud_msg_doc) 
  397. 			lua_play_anim(h, 0, Hud_msg_doc) 
  398. 			Hud_msg_current_use_msg_id = -1 
  399. 		end 
  400. 	elseif region_index == HUD_REGION_USE_MSGS_ALT then 
  401. 		--Use messages... 
  402. 		for msg_i = 0, region.msgs.num_msgs - 1 do 
  403. 			if msgs_displayed >= region.max_msgs then 
  404. 			else 
  405. 				local msg = region.msgs[msg_i] 
  406. 				local msg_id = msg.di_h 
  407. 				hud_msg_update_use_alt(msg) 
  408. 				if Hud_msg_current_use_alt_msg_id ~= msg.di_h then					 
  409. 					--New message we should always fade in... 
  410. 					vint_set_property(Hud_use_msg_alt_fade_out_h, "is_paused", true) 
  411. 					lua_play_anim(Hud_use_msg_alt_fade_in_h, 0, Hud_msg_doc) 
  412. 				end 
  413. 				if Hud_msg_current_use_alt_msg_id == msg.di_h then 
  414. 					if msg.fade_time ~= 0 then 
  415. 						--old message with a fade time, lets fade out... 
  416. 						vint_set_property(Hud_use_msg_alt_fade_in_h, "is_paused", true) 
  417. 						lua_play_anim(Hud_use_msg_alt_fade_out_h, 0, Hud_msg_doc) 
  418. 						msg_id = -1 
  419. 					end 
  420. 				end 
  421.  				Hud_msg_current_use_alt_msg_id = msg_id 
  422. 			end 
  423. 			msgs_displayed = msgs_displayed + 1 
  424. 		end 
  425. 		if region.msgs.num_msgs == 0 and Hud_msg_current_use_alt_msg_id ~= -1 then 
  426. 			--Fade out if there are no more messages left in the queue.. 
  427. 			vint_set_property(Hud_use_msg_alt_fade_in_h, "is_paused", true) 
  428. 			lua_play_anim(Hud_use_msg_alt_fade_out_h, 0, Hud_msg_doc) 
  429. 			Hud_msg_current_use_alt_msg_id = -1 
  430. 		end 
  431. 	elseif region_index == HUD_REGION_CRITICAL_TIMER then 
  432. 	 
  433. 		--Critical Timer messages... 
  434. 		for msg_i = 0, region.msgs.num_msgs - 1 do 
  435. 			if msgs_displayed < region.max_msgs then 
  436. 				local msg = region.msgs[msg_i] 
  437. 				local msg_id = msg.di_h 
  438. 				hud_msg_update_critical(msg) 
  439. 				if Hud_msg_current_critical_msg_id ~= msg.di_h and msg.di_h ~= -1 then 
  440. 					if Hud_msg_current_critical_msg_visible == false then 
  441. 						--New message we should always fade in... 
  442. 						vint_set_property(Hud_msg_critical.fade_out_anim_h, "is_paused", true) 
  443. 						lua_play_anim(Hud_msg_critical.fade_in_anim_h, 0, Hud_msg_doc) 
  444. 						Hud_msg_current_critical_msg_visible = true 
  445. 					end 
  446. 				end 
  447. 				if Hud_msg_current_critical_msg_id == msg.di_h then 
  448. 					if Hud_msg_current_critical_msg_visible == true then 
  449. 						if msg.fade_time ~= 0 then 
  450. 							--old message with a fade time, lets fade out... 
  451. 							vint_set_property(Hud_msg_critical.fade_in_anim_h, "is_paused", true) 
  452. 							lua_play_anim(Hud_msg_critical.fade_out_anim_h, 0, Hud_msg_doc) 
  453. 							Hud_msg_current_critical_msg_visible = false 
  454. 						end 
  455. 					end 
  456. 				end 
  457.  				Hud_msg_current_critical_msg_id = msg_id 
  458. 			end 
  459. 			msgs_displayed = msgs_displayed + 1 
  460. 		end 
  461. 			 
  462. 		if region.msgs.num_msgs == 0 and Hud_msg_current_critical_msg_id ~= -1 then 
  463. 			if Hud_msg_current_critical_msg_visible == true then 
  464. 				--Fade out if there are no more messages left in the queue.. 
  465. 				vint_set_property(Hud_msg_critical.fade_in_anim_h, "is_paused", true) 
  466. 				lua_play_anim(Hud_msg_critical.fade_out_anim_h, 0, Hud_msg_doc) 
  467. 				Hud_msg_current_critical_msg_id = -1 
  468. 				Hud_msg_current_critical_msg_visible = false 
  469. 			end 
  470. 		end 
  471. 	else 
  472. 		--Standard Help message... 
  473. 		for msg_i = 0, region.msgs.num_msgs - 1 do 
  474. 			local msg = region.msgs[msg_i] 
  475. 			local o = msg.text_obj_h 
  476. 			 
  477. 			if msgs_displayed >= region.max_msgs then 
  478. 				if o ~= 0 then 
  479. 					vint_object_destroy(o) 
  480. 				end 
  481. 				msg.text_obj_h = 0 
  482. 			else 
  483.  
  484. 				-- create a text item if needed 
  485. 				if o == 0 then 
  486. 					o = vint_object_create("hud_msg", "text", region.anchor) 
  487. 					if o == 0 then 
  488. 						debug_print("vint", "Problem: hud_msg cannot be created!\n") 
  489. 						return 
  490. 					end 
  491. 					vint_set_property(o, "text_tag", msg.text) 
  492. 					vint_set_property(o, "font", "thin_overlay") 
  493. 					vint_set_property(o, "text_scale", region.text_fmt.scale, region.text_fmt.scale) 
  494. 					vint_set_property(o, "tint", 0.862, 0.862, 0.862)	--(220,220,220) 
  495. 					vint_set_property(o, "leading", region.text_fmt.leading) 
  496. 					 
  497. 					local auto_offset, halign 
  498. 					if region.direction == HUD_MSG_DIR_CENTER then 
  499. 						auto_offset = "n" 
  500. 						halign = "center" 
  501. 					elseif region.direction == HUD_MSG_DIR_UP then 
  502. 						auto_offset = "sw" 
  503. 						halign = "left" 
  504. 					else	-- HUD_MSG_DIR_DOWN 
  505. 						auto_offset = "nw" 
  506. 						halign = "left" 
  507. 					end 
  508. 					 
  509. 					if region.text_fmt.wrap_width > 0 then 
  510. 						vint_set_property(o, "word_wrap", true) 
  511. 						vint_set_property(o, "wrap_width", region.text_fmt.wrap_width) 
  512. 					end 
  513. 					 
  514. 					vint_set_property(o, "auto_offset", auto_offset) 
  515. 					vint_set_property(o, "horz_align", halign) 
  516. 					vint_set_property(o, "shadow_enabled", true) 
  517. 					vint_set_property(o, "shadow_offset", 2, 2) 
  518. 					vint_set_property(o, "shadow_alpha", .6) 
  519. 					vint_set_property(o, "shadow_tint", 0,0,0) 
  520. 					 
  521. 					if msg.audio_id ~= -1 then 
  522. 						game_audio_play(msg.audio_id, msg.audio_type) 
  523. 					end 
  524. 				 
  525. 					msg.text_obj_h = o 
  526. 				end 
  527. 				 
  528. 				-- place the text 
  529. 				vint_set_property(o, "anchor", pos_x, pos_y) 
  530. 				 
  531. 				local w, h = vint_get_property(o, "unscaled_size") 
  532. 				 
  533. 				if h ~= nil then 
  534. 					-- figure position of next element 
  535. 					if region.direction == HUD_MSG_DIR_UP then 
  536. 						pos_y = pos_y - h 
  537. 					else	-- HUD_MSG_DIR_DOWN or HUD_MSG_DIR_CENTER 
  538. 						pos_y = pos_y + h 
  539. 					end 
  540. 				else 
  541. 					debug_print("vint", "Problem: hud_msg region has no height!\n") 
  542. 				end 
  543. 			end 
  544. 			 
  545. 			msgs_displayed = msgs_displayed + 1 
  546. 		end 
  547. 	end 
  548. end 
  549.  
  550.  
  551.  
  552. function hud_msg_new_message(di_h) 
  553. 	local region_index, priority, text, modifier, extra_text, fade_time, audio_type, audio_id, icon1, icon2, pc_key, timer_value, message_index = vint_dataitem_get(di_h) 
  554. 	 
  555. 	-- index is (so far) only used for use messages, 0 for normal or 1 for alternate 
  556. 	 
  557. 	--Fake the region index if its a use message and using the alternate message index... 
  558. 	if message_index == HUD_MSG_INDEX_ALT and region_index == HUD_REGION_USE_MSGS then 
  559. 		region_index = HUD_REGION_USE_MSGS_ALT 
  560. 	end 
  561. 	 
  562. 	local region = Hud_msg_regions[region_index] 
  563. 	 
  564. 	if region == nil then 
  565. 		debug_print("vint", "Message placed in invalid region, discarding. Region Index: " .. var_to_string(region_index) .."\n") 
  566. 		return 
  567. 	end 
  568. 	 
  569. 	-- initialize message 
  570. 	local msg = { 
  571. 		di_h = di_h, 
  572. 		fade_time = fade_time, 
  573. 		region_index = region_index, 
  574. 		priority = priority, 
  575. 		text = text, 
  576. 		modifier = modifier, 
  577. 		extra_text = extra_text, 
  578. 		audio_type = audio_type, 
  579. 		icon1 = icon1, 
  580. 		icon2 = icon2, 
  581. 		pc_key = pc_key, 
  582. 		audio_id = audio_id, 
  583. 		text_obj_h = 0, 
  584. 		timer_value = timer_value, 
  585. 		message_index = message_index, 
  586. 	} 
  587. 	 
  588. 	--Process special cases for special regions first... 
  589. 	if region_index == HUD_REGION_NEW_GAMEPLAY then 
  590. 		hud_msg_update_gameplay_msg(di_h) 
  591. 	else 
  592. 		--Standard region... 
  593. 		 
  594. 		-- insert in region list in priority order 
  595. 		local	insert_index = region.msgs.num_msgs 
  596. 		for i = 0, region.msgs.num_msgs - 1 do 
  597. 			local m = region.msgs[i] 
  598. 			if m.priority < priority then 
  599. 				insert_index = i 
  600. 				break 
  601. 			end 
  602. 		end 
  603.  
  604. 		-- shift the list down 
  605. 		for i = region.msgs.num_msgs, insert_index + 1, -1  do 
  606. 			region.msgs[i] = region.msgs[i - 1] 
  607. 		end 
  608. 		 
  609. 		-- insert new msg 
  610. 		region.msgs[insert_index] = msg 
  611. 		region.msgs.num_msgs = region.msgs.num_msgs + 1 
  612. 		Hud_msgs[di_h] = msg 
  613. 		region.is_dirty = true 
  614. 		 
  615.  
  616. 		--process fades differently for use messages... 
  617. 		if msg.region_index ~= HUD_REGION_USE_MSGS and msg.region_index ~= HUD_REGION_CRITICAL_TIMER and msg.region_index ~= HUD_REGION_USE_MSGS_ALT then 
  618. 			hud_msg_fade_process(msg, fade_time) 
  619. 		end 
  620. 	end 
  621. end 
  622.  
  623. function hud_msg_update_message(di_h) 
  624. 	local region_index, priority, text, modifier, extra_text, fade_time, audio_type, audio_id, icon1, icon2, pc_key, timer_value, message_index = vint_dataitem_get(di_h) 
  625. 	local msg = Hud_msgs[di_h] 
  626. 	 
  627. 	 
  628. 	--Fake the region index if its a use message and using the alternate message index... 
  629. 	if message_index == HUD_MSG_INDEX_ALT and region_index == HUD_REGION_USE_MSGS then 
  630. 		region_index = HUD_REGION_USE_MSGS_ALT 
  631. 	end 
  632. 	 
  633. 	if msg == nil then 
  634. 		-- we have no record of this data item 
  635. 		hud_msg_new_message(di_h) 
  636. 		return 
  637. 	end 
  638. 	 
  639. 	if region_index == HUD_REGION_NEW_GAMEPLAY then 
  640. 		hud_msg_update_gameplay_msg(di_h) 
  641. 	else 
  642. 		--Standard Msg Region... 
  643. 		local region = Hud_msg_regions[msg.region_index] 
  644. 		 
  645. 		-- update the text item if it's changed 
  646. 		if msg.text ~= text or msg.timer_value ~= timer_value then 
  647. 			msg.text = text 
  648. 			if msg.text_obj_h ~= 0 then 
  649. 				vint_set_property(msg.text_obj_h, "text_tag", text) 
  650. 			elseif msg.region_index == HUD_REGION_USE_MSGS or msg.region_index == HUD_REGION_CRITICAL_TIMER or msg.region_index == HUD_REGION_USE_MSGS_ALT then 
  651. 				-- the whole message has to be updated 
  652. 				-- find msg in region 
  653. 				local region = Hud_msg_regions[msg.region_index] 
  654. 				local msg_index = -1 
  655. 				for i = 0, region.msgs.num_msgs - 1 do 
  656. 					if di_h == region.msgs[i].di_h then 
  657. 						msg_index = i 
  658. 						break 
  659. 					end 
  660. 				end 
  661. 			 
  662. 				-- remove it 
  663. 				if msg_index > -1 then 
  664. 					for i = msg_index + 1, region.msgs.num_msgs - 1 do 
  665. 						region.msgs[i - 1] = region.msgs[i] 
  666. 					end 
  667. 				 
  668. 					region.msgs.num_msgs = region.msgs.num_msgs - 1 
  669. 					region.is_dirty = true 
  670. 				end 
  671. 				Hud_msgs[di_h] = nil 
  672. 				hud_msg_new_message(di_h) 
  673. 			end 
  674. 		end 
  675. 		 
  676. 		--Update fade time... 
  677. 		msg.fade_time = fade_time 
  678.  
  679. 		-- Use messages fade differently 
  680. 		if msg.region_index ~= HUD_REGION_USE_MSGS and msg.region_index ~= HUD_REGION_CRITICAL_TIMER and msg.region_index ~= HUD_REGION_USE_MSGS_ALT then 
  681. 			hud_msg_fade_process(msg, fade_time) 
  682. 		end 
  683. 		 
  684. 		region.is_dirty = true 
  685. 	end 
  686. end 
  687.  
  688. function hud_msg_remove_message(di_h) 
  689. 	 
  690. 	local region_index, priority, text, modifier, extra_text, fade_time, audio_type, audio_id, icon1, icon2, pc_key, unused_timer, message_index = vint_dataitem_get(di_h) 
  691.  
  692. 		--Fake the region index if its a use message and using the alternate message index... 
  693. 	if message_index == HUD_MSG_INDEX_ALT and region_index == HUD_REGION_USE_MSGS then 
  694. 		region_index = HUD_REGION_USE_MSGS_ALT 
  695. 	end 
  696. 	 
  697. 	if region_index == HUD_REGION_NEW_GAMEPLAY then 
  698. 		local h = vint_object_find("gameplay_msg_fade_out") 
  699. 		vint_set_property(h, "is_paused", true) 
  700. 		h = vint_object_find("gameplay_msg_fade_in") 
  701. 		vint_set_property(h, "is_paused", true) 
  702. 		vint_set_property(Hud_msg_new_gameplay_h, "alpha", 0) 
  703. 	else 
  704. 		local msg = Hud_msgs[di_h] 
  705. 		if msg ~= nil then 
  706. 			-- clean up any existing fade tween 
  707. 			if msg.fade_tween_h ~= nil then 
  708. 				vint_object_destroy(msg.fade_tween_h) 
  709. 			end 
  710.  
  711. 			-- destroy text object 
  712. 			if msg.text_obj_h ~= 0 then 
  713. 				vint_object_destroy(msg.text_obj_h) 
  714. 			end 
  715. 			 
  716. 			-- find msg in region 
  717. 			local region = Hud_msg_regions[msg.region_index] 
  718. 			local msg_index = -1 
  719. 			for i = 0, region.msgs.num_msgs - 1 do 
  720. 				if di_h == region.msgs[i].di_h then 
  721. 					msg_index = i 
  722. 					break 
  723. 				end 
  724. 			end 
  725. 			 
  726. 			-- remove it 
  727. 			if msg_index > -1 then 
  728. 				for i = msg_index + 1, region.msgs.num_msgs - 1 do 
  729. 					region.msgs[i - 1] = region.msgs[i] 
  730. 				end 
  731. 				 
  732. 				region.msgs.num_msgs = region.msgs.num_msgs - 1 
  733. 				region.is_dirty = true 
  734. 			end 
  735. 		end 
  736. 		 
  737. 		Hud_msgs[di_h] = nil 
  738. 	end 
  739. end 
  740.  
  741. function hud_msg_fade_process(msg, new_fade) 
  742. 	local is_fading = (msg.fade_time ~= nil and msg.fade_time ~= 0) 
  743. 	local should_be_fading = (new_fade > 0) 
  744. 	 
  745. 	if is_fading ~= should_be_fading then 
  746. 		-- clean up any existing tween 
  747. 		if msg.fade_tween_h ~= nil then 
  748. 			vint_object_destroy(msg.fade_tween_h) 
  749. 		end 
  750. 		 
  751. 		if should_be_fading == true then 
  752. 			-- start fading 
  753. 			local o = vint_object_create("msg_fade", "tween", vint_object_find("root_animation")) 
  754. 			vint_set_property(o, "target_handle", msg.text_obj_h) 
  755. 			vint_set_property(o, "target_property", "alpha") 
  756. 			vint_set_property(o, "duration", new_fade) 
  757. 			vint_set_property(o, "start_value", 1) 
  758. 			vint_set_property(o, "end_value", 0) 
  759. 			vint_set_property(o, "start_time", vint_get_time_index()) 
  760. 			msg.fade_tween_h = o 
  761. 		else 
  762. 			-- stop fading 
  763. 			vint_set_property(msg.text_obj_h, "alpha", 1) 
  764. 		end 
  765. 	end 
  766. 	 
  767. 	msg.fade_time = new_fade 
  768. end 
  769.  
  770. function hud_msg_hide_region(region, hide) 
  771. 	local region = Hud_msg_regions[region] 
  772. 	 
  773. 	if region ~= nil then 
  774. 		vint_set_property(region.anchor, "visible", hide == false) 
  775. 	end 
  776. end 
  777.  
  778. function hud_msg_update_use(msg) 
  779. 	--get data out of table... 
  780. 	local text = msg.text 
  781. 	local extra_text = msg.extra_text 
  782. 	local modifier = msg.modifier 
  783. 	local icon1 = msg.icon1 
  784. 	local icon2 = msg.icon2 
  785. 	local pc_key = msg.pc_key 
  786. 	 
  787. 	--pop in message 
  788. 	vint_set_property(Hud_msg_use_h, "visible", true) 
  789. 	vint_set_property(Hud_msg_use_h, "alpha", 1) 
  790. 	 
  791. 	local bg_h = vint_object_find("use_bg", Hud_msg_use_h) 
  792. 	local use_icon_h = vint_object_find("use_icon", Hud_msg_use_h) 
  793. 	local use_txt_h = vint_object_find("use_text", Hud_msg_use_h) 
  794. 	local use_mod_txt_h = vint_object_find("use_modifier_text", Hud_msg_use_h) 
  795. 	local use_mod_txt_bg_h = vint_object_find("use_modifier_bg", Hud_msg_use_h) 
  796. 	local tiers_txt_h = vint_object_find("tiers_text", Hud_msg_use_h) 
  797. 	 
  798. 	--Set text for use message... 
  799. 	vint_set_property(use_txt_h, "text_tag", text) 
  800. 	 
  801. 	--Set text for tiers message... 
  802. 	if extra_text ~= "" and extra_text ~= nil then 
  803. 		vint_set_property(tiers_txt_h, "text_tag", extra_text) 
  804. 	end 
  805. 	 
  806. 	--Add modifier button if needed... (HOLD) + message... 
  807. 	local mod_width = 0 
  808. 	if modifier ~= "" then 
  809. 		vint_set_property(use_mod_txt_h, "text_tag", modifier)	 
  810. 		vint_set_property(use_mod_txt_h, "visible", true)	 
  811. 		vint_set_property(use_mod_txt_bg_h, "visible", true)	 
  812. 		 
  813. 		--set backgorund size of left button... 
  814. 		local w, h = element_get_actual_size(use_mod_txt_h) 
  815. 		local bg_width, bg_height = element_get_actual_size(use_mod_txt_bg_h) 
  816. 		mod_width = w + 14 
  817. 		element_set_actual_size(use_mod_txt_bg_h, mod_width, bg_height) 
  818. 	else  
  819. 		--Hide modifier action... 
  820. 		vint_set_property(use_mod_txt_h, "visible", false)	 
  821. 		vint_set_property(use_mod_txt_bg_h, "visible", false)	 
  822. 	end 
  823. 	 
  824. 	--Icon1 is the button image... so set it.. 
  825. 	local button_width = 0 
  826. 	if icon1 ~= HUD_MSG_ICON_NONE then 
  827. 		local icon_bmp = Hud_msg_icons[icon1].bmp 
  828. 		Hud_msg_use_btn:set_button(icon_bmp, pc_key) 
  829. 		Hud_msg_use_btn:set_visible(true) 
  830. 		local h_w, h_h = Hud_msg_use_btn:get_size() 
  831. 		button_width = h_w 
  832. 		local button_x = (button_width * 0.5) + 5 
  833. 		Hud_msg_use_btn:set_anchor(button_x, 0) 
  834. 		vint_set_property(Hud_msg_use_btn_meter_grp_h, "anchor", button_x, 0) 
  835. 		local h_x,h_y = Hud_msg_use_btn:get_anchor() 
  836. 		vint_set_property(use_txt_h, "anchor", h_x + button_x, Hud_msg_use_text_start_y)--Hud_msg_use_text_start_x, Hud_msg_use_text_start_y) 
  837. 		vint_set_property(tiers_txt_h, "anchor", Hud_msg_tiers_text_start_x, Hud_msg_tiers_text_start_y) 
  838. 	else 
  839. 		Hud_msg_use_btn:set_visible(false) 
  840. 		--offset text from left... 
  841. 		vint_set_property(use_txt_h, "anchor", 8, Hud_msg_use_text_start_y) 
  842. 	end	 
  843. 		 
  844. 	--Target positions for centers... 
  845. 	local target_x = Hud_msg_use_start_x 
  846. 	local target_y = Hud_msg_use_start_y 
  847. 	 
  848. 	--Icon2 is the action image... 
  849. 	if icon2 ~= HUD_MSG_ICON_NONE then 
  850. 		local icon_bmp = Hud_msg_icons[icon2].bmp 
  851. 		local color = Hud_msg_icons[icon2].color 
  852. 		 
  853. 		--Set color if it is defined... 
  854. 		if color then 
  855. 			vint_set_property(use_icon_h, "tint", color.R, color.G, color.B) 
  856. 		else 
  857. 			--No specified color... 
  858. 			vint_set_property(use_icon_h, "tint", 1,1,1) 
  859. 		end 
  860. 		 
  861. 		vint_set_property(use_icon_h, "image", Hud_msg_icons[icon2].bmp) 
  862. 		vint_set_property(use_icon_h, "visible", true) 
  863. 		vint_set_property(bg_h, "visible", false) 
  864. 		vint_set_property(use_txt_h, "visible", false) 
  865. 		vint_set_property(tiers_txt_h, "visible", false) 
  866. 		 
  867. 		local w, h = element_get_actual_size(use_icon_h) 
  868. 		target_x = Hud_msg_use_start_x - w/2 - 10 
  869. 	else 
  870. 		vint_set_property(use_icon_h, "visible", false) 
  871. 		vint_set_property(use_txt_h, "visible", true) 
  872. 		vint_set_property(tiers_txt_h, "visible", true) 
  873. 		vint_set_property(bg_h, "visible", true) 
  874. 		 
  875. 		--Update background size and center to screen... 
  876. 		local h_w, h_h = element_get_actual_size(use_txt_h) 
  877. 		local w = button_width + h_w + 17 
  878. 				 
  879. 		--set background size of button... 
  880. 		local bg_width, bg_height = element_get_actual_size(bg_h) 
  881. 		element_set_actual_size(bg_h, w, bg_height) 
  882. 			 
  883. 		--Center object to screen... 
  884. 		local scale_x, scale_y = vint_get_property(Hud_msg_use_h, "scale")	-- get scale of the box so we can center it appropriatly.. 
  885. 		target_x = (Hud_msg_use_start_x - ((w - mod_width) / 2) * scale_x) 
  886. 	end 
  887. 	 
  888. 	if extra_text ~= nil and extra_text ~= "" then 
  889. 		vint_set_property(tiers_txt_h, "visible", true) 
  890. 	else 
  891. 		vint_set_property(tiers_txt_h, "visible", false) 
  892. 	end 
  893. 	 
  894. 	--Set Position... 
  895. 	vint_set_property(Hud_msg_use_h, "anchor", target_x, target_y)	 
  896. end 
  897.  
  898. function hud_msg_update_use_alt(msg) 
  899. 	--get data out of table... 
  900. 	local text = msg.text 
  901. 	local extra_text = msg.extra_text 
  902. 	local modifier = msg.modifier 
  903. 	local icon1 = msg.icon1 
  904. 	local icon2 = msg.icon2 
  905. 	local pc_key = msg.pc_key 
  906. 	 
  907. 	--pop in message 
  908. 	vint_set_property(Hud_msg_use_alt_h, "visible", true) 
  909. 	vint_set_property(Hud_msg_use_alt_h, "alpha", 1) 
  910. 	 
  911. 	local bg_h = vint_object_find("use_bg", Hud_msg_use_alt_h) 
  912. 	local use_icon_h = vint_object_find("use_icon", Hud_msg_use_alt_h) 
  913. 	local use_txt_h = vint_object_find("use_text", Hud_msg_use_alt_h) 
  914. 	local use_mod_txt_h = vint_object_find("use_modifier_text", Hud_msg_use_alt_h) 
  915. 	local use_mod_txt_bg_h = vint_object_find("use_modifier_bg", Hud_msg_use_alt_h) 
  916. 	local tiers_txt_h = vint_object_find("tiers_text", Hud_msg_use_alt_h) 
  917. 	 
  918. 	--Set text for use message... 
  919. 	vint_set_property(use_txt_h, "text_tag", text) 
  920. 	 
  921. 	--Set text for tiers message... 
  922. 	if extra_text ~= "" and extra_text ~= nil then 
  923. 		vint_set_property(tiers_txt_h, "text_tag", extra_text) 
  924. 	end 
  925. 	 
  926. 	--Add modifier button if needed... (HOLD) + message... 
  927. 	local mod_width = 0 
  928. 	if modifier ~= "" then 
  929. 		vint_set_property(use_mod_txt_h, "text_tag", modifier)	 
  930. 		vint_set_property(use_mod_txt_h, "visible", true)	 
  931. 		vint_set_property(use_mod_txt_bg_h, "visible", true)	 
  932. 		 
  933. 		--set backgorund size of left button... 
  934. 		local w, h = element_get_actual_size(use_mod_txt_h) 
  935. 		local bg_width, bg_height = element_get_actual_size(use_mod_txt_bg_h) 
  936. 		mod_width = w + 14 
  937. 		element_set_actual_size(use_mod_txt_bg_h, mod_width, bg_height) 
  938. 	else  
  939. 		--Hide modifier action... 
  940. 		vint_set_property(use_mod_txt_h, "visible", false)	 
  941. 		vint_set_property(use_mod_txt_bg_h, "visible", false)	 
  942. 	end 
  943. 	 
  944. 	--Icon1 is the button image... so set it.. 
  945. 	local button_width = 0 
  946. 	if icon1 ~= HUD_MSG_ICON_NONE then 
  947. 		local icon_bmp = Hud_msg_icons[icon1].bmp 
  948. 		Hud_msg_use_alt_btn:set_button(icon_bmp, pc_key) 
  949. 		Hud_msg_use_alt_btn:set_visible(true) 
  950. 		local h_w, h_h = Hud_msg_use_alt_btn:get_size() 
  951. 		button_width = h_w 
  952. 		local button_x = (button_width * 0.5) + 5 
  953. 		Hud_msg_use_alt_btn:set_anchor(button_x, 0) 
  954. 		vint_set_property(Hud_msg_use_btn_meter_grp_h, "anchor", button_x, 0) 
  955. 		local h_x,h_y = Hud_msg_use_alt_btn:get_anchor() 
  956. 		vint_set_property(use_txt_h, "anchor", h_x + button_x, Hud_msg_use_text_start_y)--Hud_msg_use_text_start_x, Hud_msg_use_text_start_y) 
  957. 		vint_set_property(tiers_txt_h, "anchor", Hud_msg_tiers_text_start_x, Hud_msg_tiers_text_start_y) 
  958. 	else 
  959. 		Hud_msg_use_alt_btn:set_visible(false) 
  960. 		--offset text from left... 
  961. 		vint_set_property(use_txt_h, "anchor", 8, Hud_msg_use_text_start_y) 
  962. 	end	 
  963. 		 
  964. 	--Target positions for centers... 
  965. 	local target_x = Hud_msg_use_start_x 
  966. 	local target_y = Hud_msg_use_start_y + vint_to_std_res(HUD_MSG_USE_ALT_OFFSET_VERTICAL) 
  967. 	 
  968. 	--Icon2 is the action image... 
  969. 	if icon2 ~= HUD_MSG_ICON_NONE then 
  970. 		local icon_bmp = Hud_msg_icons[icon2].bmp 
  971. 		local color = Hud_msg_icons[icon2].color 
  972. 		 
  973. 		--Set color if it is defined... 
  974. 		if color then 
  975. 			vint_set_property(use_icon_h, "tint", color.R, color.G, color.B) 
  976. 		else 
  977. 			--No specified color... 
  978. 			vint_set_property(use_icon_h, "tint", 1,1,1) 
  979. 		end 
  980. 		 
  981. 		vint_set_property(use_icon_h, "image", Hud_msg_icons[icon2].bmp) 
  982. 		vint_set_property(use_icon_h, "visible", true) 
  983. 		vint_set_property(bg_h, "visible", false) 
  984. 		vint_set_property(use_txt_h, "visible", false) 
  985. 		vint_set_property(tiers_txt_h, "visible", false) 
  986. 		 
  987. 		local w, h = element_get_actual_size(use_icon_h) 
  988. 		target_x = Hud_msg_use_start_x - w/2 - 10 
  989. 	else 
  990. 		vint_set_property(use_icon_h, "visible", false) 
  991. 		vint_set_property(use_txt_h, "visible", true) 
  992. 		vint_set_property(tiers_txt_h, "visible", true) 
  993. 		vint_set_property(bg_h, "visible", true) 
  994. 		 
  995. 		--Update background size and center to screen... 
  996. 		local h_w, h_h = element_get_actual_size(use_txt_h) 
  997. 		local w = button_width + h_w + 17 
  998. 				 
  999. 		--set background size of button... 
  1000. 		local bg_width, bg_height = element_get_actual_size(bg_h) 
  1001. 		element_set_actual_size(bg_h, w, bg_height) 
  1002. 			 
  1003. 		--Center object to screen... 
  1004. 		local scale_x, scale_y = vint_get_property(Hud_msg_use_alt_h, "scale")	-- get scale of the box so we can center it appropriatly.. 
  1005. 		target_x = (Hud_msg_use_start_x - ((w - mod_width) / 2) * scale_x) 
  1006. 	end 
  1007. 	 
  1008. 	if extra_text ~= nil and extra_text ~= "" then 
  1009. 		vint_set_property(tiers_txt_h, "visible", true) 
  1010. 	else 
  1011. 		vint_set_property(tiers_txt_h, "visible", false) 
  1012. 	end 
  1013. 	 
  1014. 	--Set Position... 
  1015. 	vint_set_property(Hud_msg_use_alt_h, "anchor", target_x, target_y)	 
  1016. end 
  1017.  
  1018. function hud_msg_update_critical(msg) 
  1019.  
  1020. 	--get data out of table... 
  1021. 	local text = msg.text 
  1022. 	local modifier = msg.modifier 
  1023. 	local timer_value = msg.timer_value 
  1024. 	 
  1025. 	local timer_grp_h 	= Hud_msg_critical.timer_grp_h 			 
  1026. 	local timer_txt_h 	= Hud_msg_critical.timer_txt_h  
  1027. 	local timer_bmp_h 	= Hud_msg_critical.timer_bmp_h	 
  1028. 	local timer_desc_txt = Hud_msg_critical.timer_desc_txt_h  		 
  1029. 	local critical_bg_h 	= Hud_msg_critical.critical_bg_h 
  1030.  
  1031. 	---Format the time 
  1032. 	local minutes = floor(timer_value / 60) 
  1033. 	local seconds =  timer_value % 60 
  1034. 	--Pad the seconds for the timer 
  1035. 	if seconds < 1 then 
  1036. 		-- Fixing a case where we had negative 0 
  1037. 		seconds = "00" 
  1038. 	elseif seconds < 10 then 
  1039. 		seconds = "0" .. seconds 
  1040. 	end 
  1041. 	 
  1042. 	local time_formatted 
  1043. 	if minutes < 1 then 
  1044. 		time_formatted = ":" .. seconds 
  1045. 	else 
  1046. 		time_formatted = minutes .. ":" .. seconds 
  1047. 	end 
  1048. 	 
  1049. 	--Set Text values... 
  1050. 	vint_set_property(timer_txt_h, "text_tag", time_formatted) 
  1051. 	vint_set_property(timer_desc_txt, "text_tag", text) 
  1052.  
  1053. 	--center timer with text 
  1054. 	local timer_width, timer_height = element_get_actual_size(timer_txt_h) 
  1055. 	local timer_bmp_width, timer_bmp_height = element_get_actual_size(timer_bmp_h) 
  1056. 	timer_width = timer_width + timer_bmp_width 
  1057. 	local x = - timer_width / 2 
  1058. 	vint_set_property(timer_grp_h, "anchor", x, Hud_msg_critical.timer_grp_y) 
  1059. 	 
  1060. 	--Update background size and center to screen... 
  1061. 	local timer_desc_width, timer_desc_height = element_get_actual_size(timer_desc_txt) 
  1062. 	local width = timer_desc_width + 20 
  1063. 	width = max(width, timer_width) 
  1064. 	local critical_bg_width, critical_bg_height = element_get_actual_size(critical_bg_h) 
  1065. 	element_set_actual_size(critical_bg_h, width, critical_bg_height) 
  1066. end 
  1067.  
  1068. function hud_msg_update_voice_msg(b_visible, b_active, s_name) 
  1069. 	--Update voice chat message 
  1070. 	local voice_msg = vint_object_find("voice_msg", Hud_msg_voice_msg_h) 
  1071. 	local voice_bg = vint_object_find("bg", Hud_msg_voice_msg_h) 
  1072. 	local voice_bg_msg = vint_object_find("party_msg", Hud_msg_voice_msg_h) 
  1073. 	vint_set_property(voice_msg, "text_tag", s_name) 
  1074. 	vint_set_property(voice_msg, "visible", b_visible) 
  1075. 	vint_set_property(voice_bg, "visible", b_visible) 
  1076. 	vint_set_property(voice_bg_msg, "text_tag", "VOICE_CHAT") 
  1077. 	vint_set_property(voice_bg_msg, "visible", b_visible) 
  1078. 	if b_active == true then 
  1079. 		vint_set_property(voice_msg, "tint", 255/255, 147/255, 42/255) 
  1080. 	else 
  1081. 		vint_set_property(voice_msg, "tint", 1, 1, 1) 
  1082. 	end 
  1083. end 
  1084.  
  1085. function hud_msg_update_gameplay_msg(di_h) 
  1086.  
  1087. 	local region_index, priority, text, modifier, fade_time, audio_type, audio_id, icon1, icon2, pc_key = vint_dataitem_get(di_h) 
  1088. 	 
  1089. 	if fade_time == 0 then 
  1090. 		local h = vint_object_find("gameplay_msg_fade_out") 
  1091. 		vint_set_property(h, "is_paused", true) 
  1092. 		lua_play_anim(vint_object_find("gameplay_msg_fade_in")) 
  1093. 	else  
  1094.  
  1095. 		lua_play_anim(vint_object_find("gameplay_msg_fade_out")) 
  1096. 	end 
  1097. 	 
  1098. 	local use_txt_h = vint_object_find("new_gameplay_txt", Hud_msg_new_gameplay_h) 
  1099. 	local use_bmp_h = vint_object_find("gameplay_icon", Hud_msg_new_gameplay_h) 
  1100.  
  1101. 	--Icon1 is the button image... so set it.. 
  1102. 	if icon1 ~= HUD_MSG_ICON_NONE then 
  1103. 		local icon_bmp = Hud_msg_icons[icon1].bmp 
  1104. 		Hud_msg_gameplay_btn:set_button(icon_bmp, pc_key) 
  1105. 	end 
  1106. 	 
  1107. 	if icon2 == HUD_MSG_ICON_NONE then 
  1108. 		vint_set_property(use_bmp_h, "visible", false) 
  1109. 	else 
  1110. 		local icon_data = Hud_msg_icons[icon2] 
  1111. 		vint_set_property(use_bmp_h, "image", icon_data.bmp) 
  1112. 		vint_set_property(use_bmp_h, "visible", true) 
  1113. 	end 
  1114.  
  1115. 	vint_set_property(use_txt_h, "text_tag", text) 
  1116. 	vint_set_property(use_txt_h, "visible", true) 
  1117. 	 
  1118. 	local button_x = 0 
  1119. 	local h_w, h_h = Hud_msg_gameplay_btn:get_size() 
  1120. 	local new_button_x = button_x + (h_w * 0.5) + 5 
  1121. 	 
  1122. 	--Update background size and center to screen... 
  1123. 	local w = 0 
  1124. 	local img_w, img_h = element_get_actual_size(use_bmp_h) 
  1125. 	w = w + h_w 
  1126. 	 
  1127. 	Hud_msg_gameplay_btn:set_anchor(new_button_x, 0) 
  1128. 	vint_set_property(use_bmp_h, "anchor", new_button_x + (h_w * 0.5) + (img_w * 0.5) + 3, 0) 
  1129. 	vint_set_property(use_txt_h, "anchor", new_button_x + (h_w * 0.5) + img_w + 5, 0) 
  1130. 	 
  1131. 	h_w, h_h = element_get_actual_size(use_txt_h) 
  1132. 	w = w + h_w + img_w + 20 
  1133. 	 
  1134. 	--set backgorund size of button... 
  1135. 	local bg_h = vint_object_find("new_gameplay_bg") 
  1136. 	local bg_width, bg_height = element_get_actual_size(bg_h) 
  1137. 	element_set_actual_size(bg_h, w, bg_height) 
  1138. 	 
  1139. 	--Center object to screen... 
  1140. 	local scale_x, scale_y = vint_get_property(Hud_msg_new_gameplay_h, "scale")	-- get scale of the box so we can center it appropriatly.. 
  1141. 	vint_set_property(Hud_msg_new_gameplay_h, "anchor", Hud_msg_gameplay_start_x - ((w / 2) * scale_x) , Hud_msg_gameplay_start_y) 
  1142. end 
  1143.  
  1144.  
  1145. -- Test functions 
  1146. function hud_msg_update_quest_test() 
  1147. 	vint_scriptevent_post( "quest_objective_complete" ,421421, 232, false, false, false) 
  1148. end 
  1149.  
  1150. function hud_msg_update_quest_test2() 
  1151. 	vint_scriptevent_post( "quest_objective_complete" ,421421, 232, false, false, true, true) 
  1152. end 
  1153.  
  1154. function hud_msg_update_quest_test3() 
  1155. 	vint_scriptevent_post( "quest_objective_complete" ,421421, 232, true, false, false) 
  1156. end 
  1157.  
  1158. function hud_msg_update_quest_test4() 
  1159. 	vint_scriptevent_post( "quest_objective_complete" ,421421, 232, false, false, true, false) 
  1160. end 
  1161.  
  1162. function hud_msg_update_quest(cmp_obj_crc, quest_title_crc, quest_completed, show_new_quest_only, coop_new_quest, coop_quest_is_available) 
  1163. 	local q_type 
  1164. 	 
  1165. 	if coop_new_quest == true then 
  1166. 		q_type = HUD_MSG_BACK_COOP_QUEST 
  1167. 	else 
  1168. 		q_type = HUD_MSG_BACK_QUEST_LOG 
  1169. 	end 
  1170.  
  1171. 	if q_type == HUD_MSG_BACK_QUEST_LOG and show_new_quest_only == false then 
  1172. 		return 
  1173. 	end 
  1174. 	 
  1175. 	hud_msg_back_add( q_type, { cmp_obj_crc, quest_title_crc, quest_completed, show_new_quest_only, coop_new_quest, coop_quest_is_available } ) 
  1176. end 
  1177.  
  1178. ------------------------------------------------------------------------------- 
  1179. -- Function hud_msg_update_quest() 
  1180. -- 
  1181. -- Displays unique banner on the hud for the following instances: 
  1182. --		1. Quest complete 
  1183. --		2. Objective complete 
  1184. --		3. Coop player started a quest 
  1185. -- 
  1186. -- @param cmp_obj_crc					--title of objective that was completed		 
  1187. -- @param quest_title_crc				--quest title 
  1188. -- @param quest_completed				--is the entire quest complete? 
  1189. -- @param show_new_quest_only			--only show the new quest available prompt 
  1190. -- @param coop_new_quest				--coop player started a new quest 
  1191. -- @param coop_quest_is_available	--local player can start the coop quest 
  1192. -- 
  1193. ------------------------------------------------------------------------------- 
  1194. function hud_msg_update_quest_do(cmp_obj_crc, quest_title_crc, quest_completed, show_new_quest_only, coop_new_quest, coop_quest_is_available) 
  1195.  
  1196. 	local complete_objective_txt_h = vint_object_find("complete_objective_txt", 0, Hud_msg_doc) 
  1197. 	local quest_title_txt_h = vint_object_find("quest_title_txt", Hud_msg_quest_grp_h, Hud_msg_doc) 
  1198. 	local quest_update_txt_h = vint_object_find("quest_update_txt", 0, Hud_msg_doc) 
  1199. 	local new_mission_txt_h = vint_object_find("new_mission_txt", 0, Hud_msg_doc) 
  1200. 	local quest_title_label_h = vint_object_find("objective_complete_txt", 0, Hud_msg_doc) 
  1201. 	local coop_grp_h = vint_object_find("coop_grp", 0, Hud_msg_doc) 
  1202. 	local coop_join_txt_h = vint_object_find("coop_join_txt", 0, Hud_msg_doc) 
  1203. 	local strike_img_h = vint_object_find("strike_img", 0, Hud_msg_doc) 
  1204. 	local coop_btn_back = Vdo_hint_button:new("coop_btn_back", 0, Hud_msg_doc) 
  1205. 	local press_back_txt_h = vint_object_find("press_back_txt", 0, Hud_msg_doc) 
  1206. 		 
  1207. 	-- Set coop join button to back button 
  1208. 	coop_btn_back:set_button(CTRL_MENU_BUTTON_BACK) 
  1209. 	 
  1210. 	-- Hide objective complete elmeents 
  1211. 	vint_set_property(complete_objective_txt_h, "visible", false) 
  1212. 	vint_set_property(strike_img_h, "alpha", 0) 
  1213. 	 
  1214. 	-- Hide QUEST COMPLETE/OBJECTIVE COMPLETE text until needed 
  1215. 	vint_set_property(quest_update_txt_h, "visible", false) 
  1216. 	 
  1217. 	-- Hide coop elements 
  1218. 	vint_set_property(coop_grp_h, "visible", false) 
  1219. 	vint_set_property(coop_join_txt_h, "visible", false) 
  1220. 	coop_btn_back:set_visible(false) 
  1221. 	coop_btn_back:set_alpha(0)	 
  1222. 	 
  1223. 	-- Localize and resize press text 
  1224. 	vint_set_property(press_back_txt_h, "text_tag" ,"QUEST_HUD_PRESS") 
  1225. 	resize_text_element(press_back_txt_h, 70)	 
  1226. 	 
  1227. 	-- Resize new msg bar based on new msg txt 
  1228. 	local new_msg_bar_h = vint_object_find("new_msg_bar_img", 0, Hud_msg_doc) 
  1229. 	local new_msg_txt_h = vint_object_find("new_msg_txt", 0, Hud_msg_doc) 
  1230. 	local new_msg_bar_width, new_msg_bar_height = element_get_actual_size(new_msg_bar_h) 
  1231. 	local new_msg_txt_width, new_msg_txt_height = element_get_actual_size(new_msg_txt_h) 
  1232. 	local new_msg_txt_x, new_msg_txt_y = vint_get_property(new_msg_txt_h, "anchor") 
  1233. 	local new_msg_bar_x, new_msg_bar_y = vint_get_property(new_msg_bar_h, "anchor") 
  1234. 			 
  1235. 	vint_set_property(new_msg_bar_h, "anchor", new_msg_txt_x + new_msg_txt_width, new_msg_bar_y) 
  1236. 	element_set_actual_size(new_msg_bar_h, 390 - new_msg_txt_width, new_msg_bar_height)	 
  1237. 	 
  1238. 	local new_msg_bar_scale_x, new_msg_bar_scale_y = vint_get_property(new_msg_bar_h, "scale")			 
  1239. 	local bar_anchor_twn_h = vint_object_find("bar_anchor_twn", Hud_msg_quest_anim_h) 
  1240. 	local bar_scale_out_twn_h = vint_object_find("bar_scale_out_twn", Hud_msg_quest_anim_h) 
  1241. 	local bar_scale_in_twn_h = vint_object_find("bar_scale_in_twn", Hud_msg_quest_anim_h) 
  1242. 				 
  1243. 	vint_set_property(bar_anchor_twn_h, "start_value", new_msg_txt_x + new_msg_txt_width + 10, new_msg_bar_y - 10) 
  1244. 	vint_set_property(bar_anchor_twn_h, "end_value", new_msg_txt_x + new_msg_txt_width + 10, new_msg_bar_y) 
  1245. 	vint_set_property(bar_scale_out_twn_h, "start_value", 0, new_msg_bar_scale_y) 
  1246. 	vint_set_property(bar_scale_out_twn_h, "end_value", new_msg_bar_scale_x, new_msg_bar_scale_y) 
  1247. 	vint_set_property(bar_scale_in_twn_h, "start_value", new_msg_bar_scale_x, new_msg_bar_scale_y) 
  1248. 	vint_set_property(bar_scale_in_twn_h, "end_value", 0, new_msg_bar_scale_y) 
  1249. 	 
  1250. 	--Reset end event for each message 
  1251. 	local end_event_twn_h = vint_object_find("coop_quest_end_event_twn", Hud_msg_base_anim_h)		 
  1252. 	vint_set_property(end_event_twn_h, "end_event", nil) 
  1253. 	 
  1254. 	if coop_new_quest == true then 
  1255. 	 
  1256. 		--COOP PLAYER STARTING A NEW QUEST 
  1257. 		 
  1258. 		local gamertag_txt_h = vint_object_find("gamertag_txt", 0, Hud_msg_doc) 
  1259. 		local coop_start_txt_h = vint_object_find("coop_start_txt", 0, Hud_msg_doc) 
  1260. 		 
  1261. 		--Set Gamertag text 
  1262. 		vint_set_property(gamertag_txt_h, "text_tag", "{PARTNER_NAME}") 
  1263. 		 
  1264. 		--Set "starting new quest" text 
  1265. 		vint_set_property(coop_start_txt_h, "text_tag", "QUEST_COOP_NEW_QUEST_START") 
  1266. 		 
  1267. 		--Set QUEST TITLE to "NOTICE" 
  1268. 		vint_set_property(quest_title_label_h, "text_tag", "MENU_TITLE_NOTICE")	 
  1269. 		 
  1270. 		--Set "(BACK) JOIN GAMERTAG'S QUEST" 
  1271. 		vint_set_property(coop_join_txt_h, "text_tag", "QUEST_COOP_QUEST_JOIN")		 
  1272. 					 
  1273. 		--Shrink text until it fits 
  1274. 		resize_text_element(gamertag_txt_h, 360)						 
  1275. 		resize_text_element(coop_start_txt_h, HUD_QUEST_COMPLETE_MAX_WIDTH)			 
  1276. 		resize_text_element(coop_join_txt_h, 350)				 
  1277. 		 
  1278. 		--Turn on quest group and play anim 
  1279. 		vint_set_property(Hud_msg_quest_grp_h, "visible", true) 
  1280. 		vint_set_property(coop_grp_h, "visible", true) 
  1281. 		 
  1282. 		if game_get_in_progress_type() ~= -1 then 
  1283. 			 
  1284. 			--In active gameplay 
  1285. 			--Play first part of animation then display a tutorial explaining why they can't join 
  1286. 			local end_event_twn_h = vint_object_find("coop_quest_end_event_twn", Hud_msg_base_anim_h)		 
  1287. 			vint_set_property(end_event_twn_h, "end_event", "hud_msg_quest_new_hide")			 
  1288.  
  1289. 			game_tutorial_start("coop_quest_busy") 			 
  1290. 		else 
  1291. 		 
  1292. 			-- It's available, play the full animation			 
  1293. 			vint_set_property(coop_join_txt_h, "visible", true)							 
  1294. 			coop_btn_back:set_visible(true)		 
  1295. 		end 
  1296.  
  1297. 		-- Play base anim and coop anim 
  1298. 		vint_set_property(Hud_msg_quest_grp_h, "visible", true) 
  1299. 		vint_set_property(Hud_msg_quest_grp_h, "alpha", 1)  
  1300.  
  1301. 		vint_apply_start_values(Hud_msg_coop_anim_h) 
  1302. 		vint_apply_start_values(Hud_msg_base_anim_h)		 
  1303. 		 
  1304. 		lua_play_anim(Hud_msg_coop_anim_h, 0)		 
  1305. 		lua_play_anim(Hud_msg_base_anim_h, 0) 
  1306. 		ui_audio_post_event("ui_objective_complete") 
  1307.  
  1308. 		-- Don't need to start any more anims, return early 
  1309. 		return 
  1310. 	end		 
  1311.  
  1312. 	-- Determine whether to show quest complete or objective complete	 
  1313. 	if show_new_quest_only == true then 
  1314. 	 
  1315. 		--QUEST COMPLETE 
  1316. 	 
  1317. 		--Set QUEST COMPLETE to localized text		 
  1318. 		vint_set_property(quest_update_txt_h, "text_tag", "QUEST_COMPLETE") 
  1319. 		 
  1320. 		--Set NEW QUEST to localized text 
  1321. 		vint_set_property(new_mission_txt_h, "text_tag", "QUEST_NEW") 
  1322. 		 
  1323. 		--Set QUEST TITLE to localized text		 
  1324. 		vint_set_property(quest_title_label_h, "text_tag", "QUEST_TITLE")	 
  1325. 		 
  1326. 		--Set current quest name 
  1327. 		vint_set_property(complete_objective_txt_h, "text_tag_crc", quest_title_crc)	 
  1328. 				 
  1329. 		--Shrink quest title until it fits		 
  1330. 		resize_text_element(quest_update_txt_h, 340)						 
  1331. 		resize_text_element(complete_objective_txt_h, HUD_QUEST_COMPLETE_MAX_WIDTH)	 
  1332. 		resize_text_element(new_mission_txt_h, 122)			 
  1333.  
  1334. 		--Set button hint to HUB menu button 
  1335. 		local btn_back = Vdo_hint_button:new("btn_back", 0, Hud_msg_doc) 
  1336. 		btn_back:set_button(CTRL_MENU_BUTTON_BACK) 
  1337. 		 
  1338. 		local quest_anim_is_paused = vint_get_property(Hud_msg_quest_new_only_h, "is_paused") 
  1339. 		 
  1340. 		--Turn on quest group and play anim 
  1341. 		 
  1342. 		 
  1343. 		-- Skip ahead to new quest tweens 
  1344. 		if show_new_quest_only then 
  1345. 			vint_set_property(Hud_msg_quest_grp_h, "visible", true) 
  1346. 			vint_set_property(Hud_msg_quest_grp_h, "alpha", 1) 
  1347. 			 
  1348. 			local hud_quest_new_grp_h = vint_object_find("new_mission_group", Hud_msg_quest_grp_h, Hud_msg_doc) 
  1349. 			vint_set_property(hud_quest_new_grp_h, "visible", true) 
  1350. 			vint_set_property(hud_quest_new_grp_h, "alpha", 1) 
  1351. 			 
  1352. 			local hud_quest_obj_grp_h = vint_object_find("complete_group", Hud_msg_quest_grp_h, Hud_msg_doc) 
  1353. 			vint_set_property(hud_quest_obj_grp_h, "visible", false) 
  1354. 			vint_set_property(hud_quest_obj_grp_h, "alpha", 0) 
  1355. 			 
  1356. 			vint_set_property(complete_objective_txt_h, "visible", false) 
  1357. 			vint_set_property(quest_update_txt_h, "visible", true) 
  1358.  
  1359. 			--Set the "map" button to open the quest log 
  1360. 			vint_apply_start_values(Hud_msg_quest_new_only_h) 
  1361. 			lua_play_anim(Hud_msg_quest_new_only_h, 0) 
  1362. 			 
  1363. 			Hud_msg_new_quest_displayed = true 
  1364. 		end 
  1365. 	end 
  1366. end 
  1367.  
  1368.  
  1369. ------------------------------------------------------------------------------- 
  1370. -- Fades out quest update (new quest message is displayed until code cancels it) 
  1371. -- (this is called via callback from code) 
  1372. -- 
  1373. function hud_msg_quest_fade_out() 
  1374. 	--Hud_msg_new_quest_displayed = false 
  1375. 	Hud_msg_back_current = -1 
  1376.  
  1377. 	lua_play_anim(Hud_msg_quest_out_new_only_h, 0, Hud_msg_doc) 
  1378. end 
  1379.  
  1380.  
  1381. ------------------------------------------------------------------------------- 
  1382. -- Fades out objective after objective text is displayed. 
  1383. -- (this is called via callback from tween) 
  1384. -- 
  1385. function hud_msg_quest_obj_fade_out() 
  1386. 	lua_play_anim(Hud_msg_base_out_anim_h, 0, Hud_msg_doc) 
  1387. end 
  1388.  
  1389. ------------------------------------------------------------------------------- 
  1390. -- Fades out the coop message after objective text is displayed. 
  1391. -- (this is called via callback from code) 
  1392. -- 
  1393. function hud_msg_quest_coop_fade_out() 
  1394. 	--Pause in anim 
  1395. 	vint_set_property(Hud_msg_coop_anim_h, "is_paused", true) 
  1396. 	 
  1397. 	--Play coop and base out anim 
  1398. 	lua_play_anim(Hud_msg_coop_out_anim_h, 0, Hud_msg_doc) 
  1399. 	lua_play_anim(Hud_msg_base_out_anim_h, 0, Hud_msg_doc) 
  1400. 	 
  1401. 	vint_set_property( Hud_msg_quest_grp_h, "visible", false ) 
  1402. end 
  1403.  
  1404.  
  1405. ------------------------------------------------------------------------------- 
  1406. -- Creates alternate use message by cloning the original use message and its animations. 
  1407. -- 
  1408. function hud_msg_create_use_alt() 
  1409.  
  1410. 	--Clone use message stuff 
  1411. 	Hud_msg_use_alt_h = vint_object_clone(Hud_msg_use_h) 
  1412. 	vint_set_property(Hud_msg_use_alt_h, "visible", true) 
  1413. 	vint_set_property(Hud_msg_use_alt_h, "alpha", 1) 
  1414. 	local x, y = vint_get_property(Hud_msg_use_alt_h, "anchor") 
  1415.  
  1416. 	--Delete Unused stuff out of the group 
  1417. 	local temp_h = vint_object_find("use_btn_meter_grp", Hud_msg_use_alt_h) 
  1418. 	vint_object_destroy(temp_h) 
  1419. 	 
  1420. 	temp_h = vint_object_find("tiers_text", Hud_msg_use_alt_h) 
  1421. 	vint_object_destroy(temp_h) 
  1422. 	 
  1423. 	temp_h = vint_object_find("tiers_text", Hud_msg_use_alt_h) 
  1424. 	vint_object_destroy(temp_h)	 
  1425. 	 
  1426. 	--temp_h = vint_object_find("use_icon", Hud_msg_use_alt_h) 
  1427. 	--vint_object_destroy(temp_h) 
  1428. 	 
  1429. 	--shift it so its right below 
  1430. 	vint_set_property(Hud_msg_use_alt_h, "anchor", x, y + HUD_MSG_USE_ALT_OFFSET_VERTICAL) 
  1431. 	 
  1432. 	--Clone animations and retarget... 
  1433. 	Hud_use_msg_alt_fade_in_h = vint_object_clone( vint_object_find("use_msg_fade_in") ) 
  1434. 	Hud_use_msg_alt_fade_out_h = vint_object_clone( vint_object_find("use_msg_fade_out") ) 
  1435. 	 
  1436. 	--Delete Unused fade in tweens 
  1437. 	temp_h = vint_object_find("use_icon_alpha_twn", Hud_use_msg_alt_fade_in_h) 
  1438. 	vint_object_destroy(temp_h) 
  1439. 	 
  1440. 	temp_h = vint_object_find("use_icon_anchor_twn", Hud_use_msg_alt_fade_in_h) 
  1441. 	vint_object_destroy(temp_h) 
  1442. 	 
  1443. 	--Retarget animations to base group... 
  1444. 	vint_set_property(Hud_use_msg_alt_fade_in_h, "target_handle", Hud_msg_use_alt_h) 
  1445. 	vint_set_property(Hud_use_msg_alt_fade_out_h, "target_handle", Hud_msg_use_alt_h) 
  1446. 	 
  1447. 	--vint_set_property(Hud_msg_use_alt_h, "visible", false) 
  1448. end 
  1449.  
  1450. function hud_msg_quest_hide(tween_handle, reset_input) 
  1451. 	 
  1452. 	--Anim is done, allow "map" button to return to original action 
  1453. 	Hud_msg_new_quest_displayed = false		 
  1454. 	 
  1455. 	--Stop anim so it's ready for next update	 
  1456. 	vint_set_property(Hud_msg_quest_anim_h, "is_paused", true) 
  1457. 	vint_set_property(Hud_msg_quest_grp_h, "visible", false) 
  1458. end 
  1459.  
  1460. function hud_msg_quest_new_hide(tween_handle, reset_input) 
  1461. 	Hud_msg_new_quest_displayed = false 
  1462. 	 
  1463. 	vint_set_property(Hud_msg_quest_new_only_h, "is_paused", true) 
  1464. 	vint_set_property(Hud_msg_quest_new_only_h, "visible", true) 
  1465. end  
  1466.  
  1467.  
  1468. ------------------------------------------------------------------------------- 
  1469. -- Fill the circle meter around the button hint 
  1470. -- 
  1471. function hud_msg_use_meter_update(meter_pct) 
  1472. 	if meter_pct ~= nil and meter_pct > 0 then 
  1473. 		local use_meter_fill_circle_h = vint_object_find("use_meter_fill_circle") 
  1474. 		vint_set_property(use_meter_fill_circle_h, "end_angle", meter_pct * 6.28) 
  1475. 		vint_set_property(Hud_msg_use_btn_meter_grp_h, "is_visible", true) 
  1476. 	else 
  1477. 		vint_set_property(Hud_msg_use_btn_meter_grp_h, "is_visible", false) 
  1478. 	end	 
  1479. end 
  1480.  
  1481. ------------------------------------------------------------------------------- 
  1482. -- Moves subtitle messages to top of screen 
  1483. -- 
  1484. function hud_msg_subtitle_top() 
  1485. 	local anchor_x,anchor_y = vint_get_property(Hud_msg_regions[HUD_REGION_SUBTITLES].anchor, "anchor") 
  1486. 	local scale_x,scale_y = vint_get_property(Hud_msg_regions[HUD_REGION_SUBTITLES].anchor, "scale") 
  1487. 	anchor_y = 94 * scale_x 
  1488. 	vint_set_property(Hud_msg_regions[HUD_REGION_SUBTITLES].anchor, "anchor", anchor_x, anchor_y) 
  1489. end 
  1490.  
  1491. ------------------------------------------------------------------------------- 
  1492. -- Moves subtitle messages to bottom of screen 
  1493. -- 
  1494. function hud_msg_subtitle_bottom() 
  1495. 	local anchor_x,anchor_y = vint_get_property(Hud_msg_regions[HUD_REGION_SUBTITLES].anchor, "anchor") 
  1496. 	local scale_x,scale_y = vint_get_property(Hud_msg_regions[HUD_REGION_SUBTITLES].anchor, "scale") 
  1497. 	anchor_y = 561 * scale_x 
  1498. 	vint_set_property(Hud_msg_regions[HUD_REGION_SUBTITLES].anchor, "anchor", anchor_x, anchor_y) 
  1499. end 
  1500.  
  1501. function hud_msg_back_nothing() 
  1502. end 
  1503.  
  1504. HUD_MSG_BACK_QUEST_LOG = 1 
  1505. HUD_MSG_BACK_COOP_QUEST = 2 
  1506. HUD_MSG_BACK_REWARDS = 3 
  1507.  
  1508. Hud_msg_back_things = { 
  1509. 	[ HUD_MSG_BACK_QUEST_LOG ]		= { start = hud_msg_update_quest_do, finish = hud_msg_quest_fade_out }, 
  1510. 	[ HUD_MSG_BACK_COOP_QUEST ]	= { start = hud_msg_update_quest_do, finish = hud_msg_quest_coop_fade_out }, 
  1511. 	[ HUD_MSG_BACK_REWARDS ]		= { start = hud_msg_back_nothing, finish = hud_msg_back_nothing }, 
  1512. } 
  1513.  
  1514. Hud_msg_back_queue = { } 
  1515. Hud_msg_back_current = -1 
  1516. Hud_msg_back_thread_handle = -1 
  1517. Hud_msg_back_is_delayed = false 
  1518.  
  1519. function hud_msg_back_add( q_type, params ) 
  1520. 	-- replace existing entry with this one on type match 
  1521. 	local key = nil 
  1522. 	for k,v in pairs( Hud_msg_back_queue ) do 
  1523. 		if v.q_type == q_type then 
  1524. 			key = k 
  1525. 			break 
  1526. 		end 
  1527. 	end 
  1528. 	 
  1529. 	if key == nil then 
  1530. 		key = #Hud_msg_back_queue + 1 
  1531. 	end 
  1532. 	 
  1533. 	Hud_msg_back_queue[ key ] = { q_type = q_type, params = params } 
  1534. 	 
  1535. 	-- start the thread if needed 
  1536. 	if Hud_msg_back_is_delayed == false and Hud_msg_back_thread_handle == -1 then 
  1537. 		Hud_msg_back_thread_handle = thread_new( "hud_msg_back_thread" ) 
  1538. 	end 
  1539. end 
  1540.  
  1541. function hud_msg_back_resume() 
  1542. 	if Hud_msg_back_is_delayed == false then 
  1543. 		return 
  1544. 	end 
  1545. 	 
  1546. 	Hud_msg_back_is_delayed = false 
  1547. 	 
  1548. 	if Hud_msg_back_thread_handle ~= -1 then 
  1549. 		thread_kill( Hud_msg_back_thread_handle ) 
  1550. 		Hud_msg_back_thread_handle = -1 
  1551. 	end 
  1552.  
  1553. 	if #Hud_msg_back_queue ~= 0 then 
  1554. 		Hud_msg_back_thread_handle = thread_new( "hud_msg_back_thread" ) 
  1555. 	end 
  1556. end 
  1557.  
  1558. function hud_msg_back_delay() 
  1559. 	if Hud_msg_back_is_delayed == true then 
  1560. 		return 
  1561. 	end 
  1562.  
  1563. 	if Hud_msg_back_thread_handle ~= -1 then 
  1564. 		thread_kill( Hud_msg_back_thread_handle ) 
  1565. 		Hud_msg_back_thread_handle = -1 
  1566. 	end 
  1567.  
  1568. 	--HVS_RCK 5/27/14 - There are currently no other messages that get added here to my knowledge. This is causing a problem where it continually re-adds the back_current that tells it to play the anim 
  1569. 	--					This causes the anim to play again every time you close the hub after jumping to challenges from the prompt. 
  1570. 	if Hud_msg_back_current ~= -1 then 
  1571. 		Hud_msg_back_things[ Hud_msg_back_current.q_type ].finish() 
  1572. 	end 
  1573.  
  1574. 	if Hud_msg_back_current ~= -1 then 
  1575. 		for i = #Hud_msg_back_queue, 1, -1 do 
  1576. 			Hud_msg_back_queue[ i + 1 ] = Hud_msg_back_queue[ i ] 
  1577. 		end 
  1578. 		 
  1579. 		Hud_msg_back_queue[ 1 ] = Hud_msg_back_current 
  1580. 		Hud_msg_back_current = -1 
  1581. 	 end 
  1582.  
  1583. 	Hud_msg_back_is_coop_join = false 
  1584. 	Hud_msg_back_current = -1 
  1585. 	Hud_msg_back_is_delayed = true 
  1586. end 
  1587.  
  1588. function hud_msg_back_thread() 
  1589. 	while #Hud_msg_back_queue > 0 do 
  1590. 		-- move the top item to the current global 
  1591. 		Hud_msg_back_current = Hud_msg_back_queue[ 1 ] 
  1592. 		Hud_msg_back_is_coop_join = ( Hud_msg_back_current.q_type == HUD_MSG_BACK_COOP_QUEST ) 
  1593. 		 
  1594. 		for i = 2, #Hud_msg_back_queue do 
  1595. 			Hud_msg_back_queue[ i - 1 ] = Hud_msg_back_queue[ i ] 
  1596. 		end 
  1597. 		 
  1598. 		Hud_msg_back_queue[ #Hud_msg_back_queue ] = nil 
  1599. 		 
  1600. 		Hud_msg_back_things[ Hud_msg_back_current.q_type ].start( unpack( Hud_msg_back_current.params ) ) 
  1601. 		 
  1602. 		-- minimum display time 
  1603. 		delay( 6 ) 
  1604. 		 
  1605. 		-- interrupt if something comes up 
  1606. 		-- local c = 17	-- 17 * 0.5 secs = 8.5 secs 
  1607. 		-- while #Hud_msg_back_queue == 0 and c > 0 do 
  1608. 			-- c = c - 1 
  1609. 			-- delay( 0.5 ) 
  1610. 		-- end 
  1611. 		 
  1612. 		Hud_msg_back_things[ Hud_msg_back_current.q_type ].finish() 
  1613. 		Hud_msg_back_is_coop_join = false 
  1614. 		Hud_msg_back_current = -1 
  1615. 		 
  1616. 		delay( 5 ) 
  1617. 	end 
  1618. 	 
  1619. 	Hud_msg_back_thread_handle = -1 
  1620. end