./hud_noto.lua

  1. ------------------------------------------------------------------------------- 
  2. -- This deals with the notoriety icons around the minimap. 
  3. --------------------------------------------------------------------------------- 
  4.  
  5. --Notoriety States 
  6. local NOTO_STATE_INITIALIZE	= -1 
  7. local NOTO_STATE_HIDDEN 		= 0 
  8. local NOTO_STATE_VISIBLE 		= 1 
  9. local NOTO_STATE_ADD				= 2 
  10. local NOTO_STATE_REMOVE			= 3 
  11. local NOTO_STATE_DECAYING		= 4 
  12. local NOTO_STATE_INCREASING	= 5 
  13.  
  14. ------------------------------------------------------------------------------- 
  15. -- Hud notoriety data. 
  16. --  
  17. Hud_noto_data = { 
  18. 	gangs = { 
  19. 		cur_team = 0, 
  20. 		cur_level = -1, 
  21. 		teams = { 
  22. 			["brotherhood"]	= 	{icon_image = "ui_hud_not_syndicate",	noto_level = -1}, 
  23. 			["ronin"]	= 			{icon_image = "ui_hud_not_syndicate",	noto_level = -1}, 
  24. 			["samedi"]	= 			{icon_image = "ui_hud_not_syndicate",	noto_level = -1}, 
  25. 		}, 
  26. 		icons = { 
  27. 			[1] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  28. 			[2] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  29. 			[3] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  30. 			[4] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  31. 			[5] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0} 
  32. 		}, 
  33. 	}, 
  34.  
  35. 	police = { 
  36. 		cur_team = 0, 
  37. 		cur_level = -1, 
  38. 		teams = { 
  39. 			["police"]	= {icon_image = "ui_hud_not_police", noto_level = -1}, 
  40. 		}, 
  41. 		icons = { 
  42. 			[1] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  43. 			[2] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  44. 			[3] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  45. 			[4] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  46. 			[5] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0} 
  47. 		}, 
  48. 	}, 
  49. } 
  50.  
  51. ------------------------------------------------------------------------------- 
  52. -- Initialize and subscribe to data. 
  53. --  
  54. function hud_noto_init() 
  55.  
  56. 	--find reference base icons 
  57. 	for i = 1, 5 do 
  58. 		local gang_icon_h = vint_object_find("gang_noto_icon_" .. i) 
  59. 		local police_icon_h = vint_object_find("police_noto_icon_" .. i) 
  60. 		Hud_noto_data.gangs.icons[i].icon_h = gang_icon_h 
  61. 		Hud_noto_data.police.icons[i].icon_h = police_icon_h 
  62. 	end 
  63.  
  64. 	--decay tweens must play at the same time. so we start the animation but disable the tweens and enable them as we go. 
  65. 	local decaying_anim_h = vint_object_find("noto_decaying_anim") 
  66. 	local noto_decaying_twn_h = vint_object_find("noto_decaying_twn", decaying_anim_h) 
  67. 	vint_set_property(noto_decaying_twn_h, "state", VINT_TWEEN_STATE_DISABLED) 
  68. 	lua_play_anim(decaying_anim_h) 
  69. 	 
  70. 	--Notoriety 
  71. 	vint_datagroup_add_subscription("sr2_notoriety", "update", "hud_noto_change") 
  72. 	vint_datagroup_add_subscription("sr2_notoriety", "insert", "hud_noto_change") 
  73. end 
  74.  
  75. ------------------------------------------------------------------------------- 
  76. -- Datagroup callback 
  77. --  
  78. function hud_noto_change(data_item_h, event_name) 
  79. 	local team_name, noto_level, noto_icon = vint_dataitem_get(data_item_h) 
  80. 	local noto_data, display_data, icon_data, meter_data, team_data 
  81.  
  82. 	-- find the interesting data for team 
  83. 	for key, noto_type in pairs(Hud_noto_data) do 
  84. 		if noto_type.teams[team_name] ~= nil then 
  85. 			noto_data = noto_type 
  86. 			display_data = noto_type.teams[team_name] 
  87. 			icon_data = noto_type.icons 
  88. 			break 
  89. 		end 
  90. 	end 
  91.  
  92. 	if noto_data == nil then 
  93. 		-- not an interesting team so outta here 
  94. 		return 
  95. 	end 
  96.  
  97. 	-- update the notoriety table 
  98. 	display_data.noto_level = noto_level 
  99.  
  100. 	-- find the team in this group with highest notoriety 
  101. 	noto_level = -1 
  102. 	team_name = nil 
  103. 	for key, value in pairs(noto_data.teams) do 
  104. 		if value.noto_level > noto_level then 
  105. 			team_name = key 
  106. 			noto_level = value.noto_level 
  107. 			team_data = value 
  108. 		end 
  109. 	end 
  110.  
  111. 	-- better safe then sorry 
  112. 	if team_name == nil then 
  113. 		return 
  114. 	end 
  115.  
  116. 	local base_new_noto = floor(noto_level) 
  117. 	local base_old_noto = floor(noto_data.cur_level) 
  118. 	local icon_h = 0 
  119.  
  120. 	-- new team, animate in all icons 
  121. 	if team_name ~= noto_data.cur_team then 
  122. 		--update current image 
  123. 		for i = 1, 5 do 
  124. 			--Set image of icon... 
  125. 			vint_set_property(noto_data.icons[i], "image", team_data.icon_image) 
  126. 		 
  127. 			--set the proper state for the icon... 
  128. 			if base_new_noto >= i then 
  129. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_ADD) 
  130. 			else 
  131. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_REMOVE) 
  132. 			end 
  133. 		end 
  134.  
  135. 		noto_data.cur_team = team_name 
  136. 		 
  137. 		--Make sure we are visible... 
  138. 		hud_player_notoriety_show() 
  139.  
  140. 	-- noto on the rise, animate in all new icons 
  141. 	elseif base_new_noto > base_old_noto then 
  142. 		for i = 1, 5 do 
  143. 			icon_h = noto_data.icons[i].icon_h 
  144. 			if base_new_noto >= i and base_old_noto < i then 
  145. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_ADD) 
  146. 			elseif base_new_noto < i then 
  147. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_REMOVE) 
  148. 			else 
  149. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_VISIBLE) 
  150. 			end 
  151. 		end 
  152. 		 
  153. 		--Make sure we are visible... 
  154. 		hud_player_notoriety_show() 
  155.  
  156. 	-- noto falling, animate the highest active icon 
  157. 	elseif base_new_noto < base_old_noto then 
  158. 		for i = 1, 5 do 
  159. 			if base_new_noto == i then 
  160. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_ADD) 
  161. 			elseif base_new_noto < i then 
  162. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_REMOVE) 
  163. 			end 
  164. 		end 
  165. 	end 
  166.  
  167. 	-- update meter 
  168. 	local part_new_noto = noto_level - base_new_noto 
  169. 	 
  170.  
  171. 	--determine if we are still, decaying or increasing 
  172. 	local noto_diff = noto_level - noto_data.cur_level 
  173. 	if base_new_noto == base_old_noto then 
  174.  
  175. 		if noto_diff < -0.001 then 
  176. 			--decaying... 
  177. 			for i = 1, 5 do 
  178. 				icon_h = noto_data.icons[i].icon_h 
  179. 				if base_new_noto == i then 
  180. 					hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_DECAYING) 
  181. 				end 
  182. 			end 
  183. 		elseif noto_diff > 0.001 then 
  184. 			--Increase... 
  185. 			for i = 1, 5 do 
  186. 				icon_h = noto_data.icons[i].icon_h 
  187. 				if base_new_noto == i then 
  188. 					hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_INCREASING) 
  189. 				end 
  190. 			end 
  191. 		elseif abs(noto_level) > 0.0001 then 
  192. 			--probably the same level again just make sure we are visible... 
  193. 			for i = 1, 5 do 
  194. 				icon_h = noto_data.icons[i].icon_h 
  195. 				if base_new_noto == i then 
  196. 					hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_VISIBLE) 
  197. 				end 
  198. 			end 
  199. 		end 
  200. 	end 
  201.  
  202. 	--store the current level to the notoriety type(gang or police) 
  203. 	noto_data.cur_level = noto_level 
  204. 	 
  205. 	--Process the states... 
  206. 	hud_noto_icon_process_state(noto_data) 
  207. 	 
  208. 	-- find lowest notoriety value 
  209. 	local lowest_noto_level = 0 
  210. 	local x_data = Hud_noto_data 
  211. 	for key, noto_type in pairs(Hud_noto_data) do 
  212. 		if noto_type.cur_level ~= -1 then 
  213. 			if noto_type.cur_level > lowest_noto_level then 
  214. 				lowest_noto_level = noto_type.cur_level 
  215. 			end		 
  216. 		end 
  217. 	end 
  218. 	 
  219. 	--hide notoriety if we are less than 1. 
  220. 	if lowest_noto_level < 1 then 
  221. 		hud_player_notoriety_hide() 
  222. 	end 
  223. end 
  224.  
  225. ------------------------------------------------------------------------------- 
  226. -- Icon set state 
  227. -- 
  228. function hud_noto_icon_set_state(icon, state) 
  229. 	if state == NOTO_STATE_ADD then 
  230. 		if icon.state == NOTO_STATE_VISIBLE then 
  231. 			--Don't try to re-add an icon. 
  232. 			icon.state = NOTO_STATE_VISIBLE 
  233. 		else 
  234. 			icon.state = NOTO_STATE_ADD 
  235. 		end 
  236. 	elseif state == NOTO_STATE_REMOVE then 
  237. 		if icon.state == NOTO_STATE_HIDDEN then 
  238. 			--Don't try to re-hide an icon 
  239. 			icon.state = NOTO_STATE_HIDDEN 
  240. 		else 
  241. 			icon.state = NOTO_STATE_REMOVE 
  242. 		end 
  243. 	elseif state == NOTO_STATE_VISIBLE then 
  244. 		if icon.state == NOTO_STATE_ADD then 
  245. 			--If the state is already adding, we just keep it that way instead of trying to force visible. 
  246. 			icon.state = NOTO_STATE_ADD 
  247. 		else 
  248. 			icon.state = NOTO_STATE_VISIBLE 
  249. 		end 
  250. 	elseif state == NOTO_STATE_INCREASING then 
  251. 		if icon.state == NOTO_STATE_ADD then 
  252. 			--can't change to increasing if we are currently adding. 
  253. 			icon.state = NOTO_STATE_ADD 
  254. 		else 
  255. 			icon.state = NOTO_STATE_INCREASING 
  256. 		end		 
  257. 	else 
  258. 		icon.state = state 
  259. 	end 
  260. end 
  261.  
  262. ------------------------------------------------------------------------------- 
  263. -- Silenetly resets the state. This happens after our ADD, REMOVE and PULSE 
  264. -- callbacks. This way we don't reprocess a hidden state. 
  265. -- 
  266. function hud_noto_icon_set_state_silent(icon, state) 
  267. 	icon.state = state 
  268. 	icon.state_prev = state 
  269. end 
  270.  
  271. ------------------------------------------------------------------------------- 
  272. -- Processes the state for the specific noto type. 
  273. -- noto_type			(gang or police) Hud_noto_data.gang or Hud_noto_data.police 
  274. -- process_icon_id 	if icon# is specified, we will only process that icon. 
  275. -- 
  276. function hud_noto_icon_process_state(noto_type) 
  277. 	-- Loop through our icons and change state... 
  278. 	for icon_id = 1, 5 do 
  279. 		local icon = noto_type.icons[icon_id] 
  280. 		local icon_h = icon.icon_h 
  281. 		if icon.state ~= icon.state_prev then 
  282. 			-- We need to change states now... 
  283. 			if icon.state == NOTO_STATE_ADD then 
  284. 				hud_noto_icon_add(icon_h, icon) 
  285. 			elseif icon.state == NOTO_STATE_DECAYING then 
  286. 				hud_noto_icon_decay(icon_h, icon) 
  287. 			elseif icon.state == NOTO_STATE_INCREASING then 
  288. 				hud_noto_icon_pulse(icon_h, icon) 
  289. 			elseif icon.state == NOTO_STATE_REMOVE then 
  290. 				hud_noto_icon_remove(icon_h, icon) 
  291. 			elseif icon.state == NOTO_STATE_VISIBLE then 
  292. 				hud_noto_icon_visible(icon_h, icon)	 
  293. 			elseif icon.state == NOTO_STATE_HIDDEN then 
  294. 				hud_noto_icon_hide(icon_h, icon) 
  295. 			end 
  296. 			icon.state_prev = icon.state 
  297. 		end 
  298. 	end 
  299. end 
  300.  
  301. ------------------------------------------------------------------------------- 
  302. -- Hides icons with animation... 
  303. --  
  304. function hud_noto_icon_remove(icon_h, icon) 
  305. 	vint_object_destroy(icon.bmp_clone_0) 
  306. 	vint_object_destroy(icon.bmp_clone_1) 
  307. 	vint_object_destroy(icon.anim_0) 
  308. 	vint_object_destroy(icon.anim_1) 
  309. 	vint_object_destroy(icon.anim_2) 
  310. 	vint_object_destroy(icon.anim_3) 
  311.  
  312. 	--ANIMATE: Fade Icon Away 
  313. 	local anim_3 = vint_object_find("noto_fade_out_anim") 
  314. 	local anim_clone_3 = vint_object_clone(anim_3) 
  315.  
  316. 	--Targets 
  317. 	local anim_3_alpha_tween = vint_object_find("noto_alpha_3", anim_clone_3) 
  318. 	vint_set_property(anim_3_alpha_tween, "target_handle",	icon_h) 
  319.  
  320. 	--Reset Tween value 
  321. 	local alpha_val = vint_get_property(icon_h, "alpha") 
  322. 	vint_set_property_typed("float", anim_3_alpha_tween, "start_value", alpha_val) 
  323.  
  324. 	--Callback 
  325. 	vint_set_property(anim_3_alpha_tween, "end_event",		"hud_noto_icon_hide_end") 
  326.  
  327. 	lua_play_anim(anim_clone_3, 0); 
  328.  
  329. 	icon.bmp_clone_0 = 0 
  330. 	icon.bmp_clone_1 = 0 
  331. 	icon.anim_0 = 0 
  332. 	icon.anim_1 = 0 
  333. 	icon.anim_2 = 0 
  334. 	icon.anim_3 = anim_clone_3 
  335. 	icon.tween_end = anim_3_alpha_tween 
  336. end 
  337.  
  338. function hud_noto_icon_hide_end(tween_h, event_name) 
  339. 	-- search for indicated tween and clean up 
  340. 	for k, noto_data in pairs(Hud_noto_data) do 
  341. 		for key, icon in pairs(noto_data.icons) do 
  342. 			if icon.tween_alpha_out == tween_h then 
  343. 				vint_object_destroy(icon.bmp_clone_0) 
  344. 				vint_object_destroy(icon.bmp_clone_1) 
  345. 				vint_object_destroy(icon.anim_0) 
  346. 				vint_object_destroy(icon.anim_1) 
  347. 				vint_object_destroy(icon.anim_2) 
  348. 				vint_object_destroy(icon.anim_3) 
  349. 				icon.bmp_clone_0 = 0 
  350. 				icon.bmp_clone_1 = 0 
  351. 				icon.anim_0 = 0 
  352. 				icon.anim_1 = 0 
  353. 				icon.anim_2 = 0 
  354. 				icon.anim_3 = 0 
  355. 				icon.tween_show = 0 
  356. 				 
  357. 				hud_noto_icon_set_state_silent(icon, NOTO_STATE_HIDDEN) 
  358. 				return 
  359. 			end 
  360. 		end 
  361. 	end 
  362. end 
  363.  
  364. ------------------------------------------------------------------------------- 
  365. -- Shows icons with animation... 
  366. --  
  367. function hud_noto_icon_add(icon_h, icon) 
  368. 	vint_set_property(icon_h, "visible", true) 
  369.  
  370. 	--Destroy all objects if there are any currently being animated 
  371. 	vint_object_destroy(icon.bmp_clone_0) 
  372. 	vint_object_destroy(icon.bmp_clone_1) 
  373. 	vint_object_destroy(icon.anim_0) 
  374. 	vint_object_destroy(icon.anim_1) 
  375. 	vint_object_destroy(icon.anim_2) 
  376. 	vint_object_destroy(icon.anim_3) 
  377.  
  378. 	--Create bitmap clones for animation 
  379. 	local bmp_clone_0 = vint_object_clone(icon_h) 
  380. 	local bmp_clone_1 = vint_object_clone(icon_h) 
  381. 	vint_set_property(bmp_clone_0, "depth",	-1) 
  382. 	vint_set_property(bmp_clone_1, "depth",	-2) 
  383.  
  384. 	--Clone the notoriety anim and adjust the childs targets 
  385.  
  386. 	--ANIMATION: Large to small 
  387. 	local anim_0 = vint_object_find("noto_add_down_anim") 
  388. 	local anim_clone_0 = vint_object_clone(anim_0) 
  389.  
  390. 	--Target Tweens 
  391. 	local anim_0_alpha_tween = vint_object_find("noto_alpha_0", anim_clone_0) 
  392. 	local anim_0_scale_tween = vint_object_find("noto_scale_0", anim_clone_0) 
  393. 	vint_set_property(anim_0_alpha_tween, "target_handle",	bmp_clone_0) 
  394. 	vint_set_property(anim_0_scale_tween, "target_handle",	bmp_clone_0) 
  395. 	 
  396. 	--ANIMATION: Small To Large 
  397. 	local anim_1 = vint_object_find("noto_add_up_anim"); 
  398. 	local anim_clone_1 = vint_object_clone(anim_1) 
  399.  
  400. 	--Target Tweens 
  401. 	local anim_1_alpha_tween = vint_object_find("noto_alpha_1", anim_clone_1) 
  402. 	local anim_1_scale_tween = vint_object_find("noto_scale_1", anim_clone_1) 
  403. 	vint_set_property(anim_1_alpha_tween, "target_handle",	bmp_clone_1) 
  404. 	vint_set_property(anim_1_scale_tween, "target_handle",	bmp_clone_1) 
  405. 	 
  406. 	--ANIMATION: BASIC FADE IN 
  407. 	local anim_2 = vint_object_find("noto_fade_in_anim") 
  408. 	local anim_clone_2 = vint_object_clone(anim_2) 
  409. 	 
  410. 	--Target Tweens 
  411. 	local anim_2_alpha_tween = vint_object_find("noto_alpha_2", anim_clone_2) 
  412. 	vint_set_property(anim_2_alpha_tween, "target_handle",	icon_h) 
  413. 	 
  414. 	--Reset Properties to current value 
  415. 	local alpha_val = vint_get_property(icon_h, "alpha") 
  416. 	vint_set_property_typed("float", anim_2_alpha_tween, "start_value", alpha_val) 
  417.  
  418. 	--Setup callback 
  419. 	vint_set_property(anim_0_scale_tween, "end_event",		"hud_noto_icon_add_end") 
  420. 	 
  421. 	--play anims 
  422. 	lua_play_anim(anim_clone_0, 0); 
  423. 	lua_play_anim(anim_clone_1, 0); 
  424. 	lua_play_anim(anim_clone_2, 0); 
  425.  
  426. 	icon.bmp_clone_0 = bmp_clone_0 
  427. 	icon.bmp_clone_1 = bmp_clone_1 
  428. 	icon.anim_0 = anim_clone_0 
  429. 	icon.anim_1 = anim_clone_1 
  430. 	icon.anim_2 = anim_clone_2 
  431. 	icon.anim_3 = 0 
  432. 	icon.tween_end = anim_0_scale_tween 
  433. end 
  434.  
  435. function hud_noto_icon_add_end(tween_h, event_name) 
  436. 	-- search for indicated tween and clean up 
  437. 	for k, noto_data in pairs(Hud_noto_data) do 
  438. 		for key, icon in pairs(noto_data.icons) do 
  439. 			if icon.tween_end == tween_h then 
  440.  
  441. 				vint_object_destroy(icon.bmp_clone_0) 
  442. 				vint_object_destroy(icon.bmp_clone_1) 
  443. 				vint_object_destroy(icon.anim_0) 
  444. 				vint_object_destroy(icon.anim_1) 
  445. 				vint_object_destroy(icon.anim_2) 
  446.  
  447. 				icon.bmp_clone_0 = 0 
  448. 				icon.bmp_clone_1 = 0 
  449. 				icon.anim_0 = 0 
  450. 				icon.anim_1 = 0 
  451. 				icon.anim_2 = 0 
  452. 				icon.tween_show = 0 
  453. 				 
  454. 				hud_noto_icon_set_state_silent(icon, NOTO_STATE_VISIBLE) 
  455. 				return 
  456. 			end 
  457. 		end 
  458. 	end 
  459. end 
  460.  
  461. ------------------------------------------------------------------------------- 
  462. -- Starts decaying looping animation on specific icon. 
  463. -- 
  464. function hud_noto_icon_decay(icon_h, icon) 
  465.  
  466. 	--make sure we aren't already playing an animation... 
  467. 	vint_object_destroy(icon.bmp_clone_0) 
  468. 	vint_object_destroy(icon.bmp_clone_1) 
  469. 	vint_object_destroy(icon.anim_0) 
  470. 	vint_object_destroy(icon.anim_1) 
  471. 	vint_object_destroy(icon.anim_2) 
  472. 	vint_object_destroy(icon.anim_3) 
  473.  
  474. 	vint_set_property(icon_h, "visible", true) 
  475.  
  476. 	--This one is a little bit different because we want the tweens to stay in sync... so we just clone the tween. 
  477. 	--Animation is already playing, cloning the tweens will keep them in sync. 
  478. 	local decaying_anim_h = vint_object_find("noto_decaying_anim") 
  479. 	local decay_twn_h = vint_object_find("noto_decaying_twn", decaying_anim_h) 
  480. 	local decay_clone_twn_h = vint_object_clone(decay_twn_h) 
  481. 	vint_set_property(decay_clone_twn_h, "state", VINT_TWEEN_STATE_RUNNING) 
  482. 	vint_set_property(decay_clone_twn_h, "target_handle",	icon_h) 
  483. 	 
  484. 	--Store options to globals... 
  485. 	icon.bmp_clone_0 = 0 
  486. 	icon.bmp_clone_1 = 0 
  487. 	icon.anim_0 = decay_clone_twn_h 
  488. 	icon.anim_1 = 0 
  489. 	icon.anim_2 = 0 
  490. 	icon.anim_3 = 0 
  491. 	icon.tween_end = 0 
  492. end 
  493.  
  494. ------------------------------------------------------------------------------- 
  495. -- Pleys pulse up animation on icon 
  496. -- 
  497. function hud_noto_icon_pulse(icon_h, icon) 
  498.  
  499. 	--make sure we aren't already playing an animation, nuke it... 
  500. 	vint_object_destroy(icon.bmp_clone_0) 
  501. 	vint_object_destroy(icon.bmp_clone_1) 
  502. 	vint_object_destroy(icon.anim_0) 
  503. 	vint_object_destroy(icon.anim_1) 
  504. 	vint_object_destroy(icon.anim_2) 
  505. 	vint_object_destroy(icon.anim_3) 
  506. 	 
  507. 	--make sure our notoriety icon is visible. 
  508. 	vint_set_property(icon_h, "visible", true) 
  509. 	vint_set_property(icon_h, "alpha", 1) 
  510.  
  511. 	--Create bitmap clones for animation 
  512. 	local bmp_clone_0 = vint_object_clone(icon_h) 
  513. 	vint_set_property(bmp_clone_0, "depth",	-1) 
  514.  
  515. 	--Clone the notoriety anim and adjust the childs targets 
  516.  
  517. 	--ANIMATION: Small To Large 
  518. 	local anim_0 = vint_object_find("noto_add_up_anim"); 
  519. 	local anim_clone_0 = vint_object_clone(anim_0) 
  520.  
  521. 	--Target Tweens 
  522. 	local anim_0_alpha_tween = vint_object_find("noto_alpha_1", anim_clone_0) 
  523. 	local anim_0_scale_tween = vint_object_find("noto_scale_1", anim_clone_0) 
  524. 	vint_set_property(anim_0_alpha_tween, "target_handle",	bmp_clone_0) 
  525. 	vint_set_property(anim_0_scale_tween, "target_handle",	bmp_clone_0) 
  526.  
  527. 	--Setup callback 
  528. 	vint_set_property(anim_0_scale_tween, "end_event",		"hud_noto_icon_pulse_end") 
  529. 	 
  530. 	--play anims 
  531. 	lua_play_anim(anim_clone_0, 0); 
  532.  
  533. 	icon.bmp_clone_0 = bmp_clone_0 
  534. 	icon.anim_0 = anim_clone_0 
  535. 	icon.tween_end = anim_0_scale_tween 
  536. end 
  537.  
  538. function hud_noto_icon_pulse_end(tween_h, event) 
  539. 	-- search for indicated tween and clean up 
  540. 	for k, noto_data in pairs(Hud_noto_data) do 
  541. 		for key, icon in pairs(noto_data.icons) do 
  542. 			if icon.tween_end == tween_h then 
  543. 				vint_object_destroy(icon.bmp_clone_0) 
  544. 				vint_object_destroy(icon.bmp_clone_1) 
  545. 				vint_object_destroy(icon.anim_0) 
  546. 				vint_object_destroy(icon.anim_1) 
  547. 				vint_object_destroy(icon.anim_2) 
  548.  
  549. 				icon.bmp_clone_0 = 0 
  550. 				icon.bmp_clone_1 = 0 
  551. 				icon.anim_0 = 0 
  552. 				icon.anim_1 = 0 
  553. 				icon.anim_2 = 0 
  554. 				icon.tween_show = 0 
  555. 				 
  556. 				hud_noto_icon_set_state_silent(icon, NOTO_STATE_VISIBLE) 
  557. 				return 
  558. 			end 
  559. 		end 
  560. 	end 
  561. end 
  562.  
  563. ------------------------------------------------------------------------------- 
  564. -- Force show icon... 
  565. -- 
  566. function hud_noto_icon_visible(icon_h, icon) 
  567. 	--make sure we aren't already playing an animation... 
  568. 	vint_object_destroy(icon.bmp_clone_0) 
  569. 	vint_object_destroy(icon.bmp_clone_1) 
  570. 	vint_object_destroy(icon.anim_0) 
  571. 	vint_object_destroy(icon.anim_1) 
  572. 	vint_object_destroy(icon.anim_2) 
  573. 	vint_object_destroy(icon.anim_3) 
  574.  
  575. 	vint_set_property(icon_h, "visible", true) 
  576. 	vint_set_property(icon_h, "alpha", 1) 
  577. end 
  578.  
  579. ------------------------------------------------------------------------------- 
  580. -- Force hide icon. 
  581. -- 
  582. function hud_noto_icon_hide(icon_h, icon) 
  583. 	--make sure we aren't already playing an animation... 
  584. 	vint_object_destroy(icon.bmp_clone_0) 
  585. 	vint_object_destroy(icon.bmp_clone_1) 
  586. 	vint_object_destroy(icon.anim_0) 
  587. 	vint_object_destroy(icon.anim_1) 
  588. 	vint_object_destroy(icon.anim_2) 
  589. 	vint_object_destroy(icon.anim_3) 
  590.  
  591. 	vint_set_property(icon_h, "visible", false) 
  592. 	vint_set_property(icon_h, "alpha", 0) 
  593. end 
  594.  
  595.  
  596.  
  597. ------------------------------------------------------------------------------- 
  598. -- Expand notoriety bars... 
  599. --  
  600. function hud_player_notoriety_show() 
  601. 	if Hud_notoriety.is_expanded ~= true then 
  602. 		vint_set_property(vint_object_find("map_noteriety_contract"), "is_paused", true) 
  603. 		lua_play_anim(vint_object_find("map_noteriety_expand")) 
  604. 		Hud_notoriety.is_expanded = true 
  605. 	end 
  606. end 
  607.  
  608.  
  609. ------------------------------------------------------------------------------- 
  610. -- Retract notoriety bars... 
  611. --  
  612. function hud_player_notoriety_hide() 
  613. 	if Hud_notoriety.is_expanded ~= false then 
  614. 		vint_set_property(vint_object_find("map_noteriety_expand"), "is_paused", true) 
  615. 		lua_play_anim(vint_object_find("map_noteriety_contract")) 
  616. 		Hud_notoriety.is_expanded = false 
  617. 	end 
  618. end