sr2lua/tutorial.lua

  1.  
  2.  
  3. Tutorial = {} 
  4. Tutorial_hud_doc = -1 
  5. Tutorial_hud_prunings = {} 
  6.  
  7. Tutorial_hud_anim_cleanup = {} 
  8. Tutorial_hud_anim_obj_count = 0 
  9.  
  10. function tutorial_init() 
  11.  
  12. 	--Find Objects 
  13. 	Tutorial.handles = {} 
  14. 	Tutorial.handles.window = vint_object_find("tutorial") 
  15. 	Tutorial.handles.bg = vint_object_find("background") 
  16. 	Tutorial.handles.safe_frame = vint_object_find("safe_frame") 
  17. 	vint_set_property(Tutorial.handles.safe_frame, "visible", false) 
  18. 	--Text Elements 
  19. 	Tutorial.handles.footer_grp = vint_object_find("footer_grp") 
  20. 	Tutorial.handles.header_text = vint_object_find("tutorial_header_text") 
  21. 	Tutorial.handles.body_text = vint_object_find("tutorial_body_text") 
  22. 	Tutorial.handles.footer_text = vint_object_find("tutorial_footer_text") 
  23. 	 
  24. 	--Frame Elements 
  25. 	Tutorial.handles.side_l = vint_object_find("tutorial_frame_brdr_l") 
  26. 	Tutorial.handles.side_r = vint_object_find("tutorial_frame_brdr_r") 
  27. 	Tutorial.handles.middle = vint_object_find("menu_frame_middle") 
  28. 	Tutorial.handles.bottom = vint_object_find("menu_bottom") 
  29. 	 
  30. 	 
  31. 	--Highlight stuff 
  32. 	Tutorial.handles.arrow = vint_object_find("arrow") 
  33. 	--Animations 
  34. 	vint_set_property(vint_object_find("pulse_glow_anim"), "is_paused", true) 
  35. 	 
  36. 	Tutorial_hud_doc = -1 
  37.  
  38. 	Tutorial_hud_prunings.num_elements = 0 
  39. 	 
  40. 	--Alignment Properties 
  41. 	Tutorial.alignment_settings = {} 
  42. 	Tutorial.alignment_settings["center"] = { x = 0, y = 0, offset="w", vdoc_name = "align_center" } 
  43. 	Tutorial.alignment_settings["notoriety"] = { x = 0, y = 0, offset="sw", vdoc_name = "loc_notoriety" } 
  44. 	Tutorial.alignment_settings["health"] = { x = 0, y = 0, offset="ne", vdoc_name = "loc_health" } 
  45. 	Tutorial.alignment_settings["follower"] = { x = 0, y = 0, offset="ne", vdoc_name = "loc_follower" } 
  46. 	Tutorial.alignment_settings["hud_txt"] = { x = 0, y = 0, offset="sw", vdoc_name = "loc_hud_txt" } 
  47. 	Tutorial.alignment_settings["radial"] = { x = 0, y = 0, offset="e", vdoc_name = "loc_radial" } 
  48. 	Tutorial.alignment_settings["diversion"] = { x = 0, y = 0, offset="ne", vdoc_name = "loc_div" } 
  49. 	 
  50. 	--Custom Popups/animations 
  51. 	--HUD_TEXT 
  52. 	vint_set_property(vint_object_find("help_txt_anim"), "is_paused", true) 
  53. 	vint_set_property(vint_object_find("case_hud_txt_grp"), "visible", false) 
  54. 	 
  55. 	--Diversions 
  56. 	vint_set_property(vint_object_find("diversion_anim"), "is_paused", true) 
  57. 	vint_set_property(vint_object_find("case_div_grp"), "visible", false) 
  58. 	 
  59. 	--Initialize Frame size 
  60. 	Tutorial.height = 0 
  61. 	Tutorial.windows = {} 
  62. 	Tutorial.windows.num_items = 0  
  63. 	Tutorial.windows.cur_idx = 0  
  64. 	Tutorial.scaler = vint_get_property(Tutorial.handles.window, "scale") 
  65.  
  66. 	--Set default tutorial stuff 
  67. 	tutorial_alignment_set("center") 
  68. 	 
  69. 	tutorial_frame_resize() 
  70. 	 
  71. 	--hide frame and background 
  72. 	vint_set_property(Tutorial.handles.window, "alpha", 0)  
  73. 	vint_set_property(Tutorial.handles.bg, "alpha", 0)  
  74. 	 
  75. end 
  76.  
  77. function tutorial_open() 
  78. 	Tutorial_hud_doc = vint_document_find("hud") 
  79. --	tutorial_input_subscribe() 
  80. 	 
  81. 	--Populate and show the tutorial window 
  82. 	vint_dataresponder_request("tutorial_responder", "tutorial_update", 0, 1) 
  83. end 
  84.  
  85. function tutorial_close() 
  86. 	tutorial_input_unsubscribe() 
  87. 	 
  88. 	--Fail safe tohide the misc cases 
  89. 	tutorial_case_hide() 
  90. 	 
  91. 	--hide frame and background 
  92. 	vint_set_property(Tutorial.handles.safe_frame, "visible", false) 
  93. end 
  94.  
  95. function tutorial_update(tutorial_ready, header_txt, body_txt, tutorial_type) 
  96. 	tutorial_input_unsubscribe() 
  97.  
  98. 	--	We don't have any tutorials left to display so exit. 
  99. 	if tutorial_ready == false then 
  100. 		tutorial_close() 
  101. 		return 
  102. 	end 
  103. 		 
  104. 	-- Update the window information 
  105. 	Tutorial.window = { 
  106. 		header_txt = header_txt, 
  107. 		body_txt = body_txt, 
  108. 		tutorial_type = tutorial_type, 
  109. 		footer_txt = "TUT_CONTINUE_MSG" 
  110. 	} 
  111. 	 
  112. 	-- If there are, show them. 
  113. 	tutorial_show() 
  114. end 
  115.  
  116. function tutorial_show() 
  117. 	--Make a new window 
  118. 	local tut = Tutorial.window 
  119. 	tutorial_input_subscribe() 
  120.  
  121.  
  122. 	vint_set_property(Tutorial.handles.safe_frame, "visible", true)	 
  123. 	tutorial_case_show() 
  124. 	tutorial_update_text(tut.header_txt, tut.body_txt, tut.footer_txt) 
  125. 	 
  126. 	local Tutorial_sound = audio_get_audio_id("SYS_HUD_CONF_SERIOUS") 
  127. 	audio_play(Tutorial_sound) 
  128. end 
  129.  
  130. function tutorial_update_text(header_txt, body_txt, footer_txt) 
  131. 	vint_set_property(Tutorial.handles.header_text, "text_tag", header_txt) 
  132. 	vint_set_property(Tutorial.handles.body_text, "text_tag", body_txt) 
  133. 	vint_set_property(Tutorial.handles.footer_text, "text_tag", footer_txt) 
  134. 	tutorial_frame_resize() 
  135. end 
  136.  
  137. function tutorial_frame_resize() 
  138. 	--Resize tutorial frame 
  139. 	--Update footer vint_get_property(Tutorial.handles.body_text, "screen_size", Tutorial.handles.body_text) --  
  140. 	local x, y = vint_get_property(Tutorial.handles.body_text, "anchor")  
  141. 	local width, height = element_get_actual_size(Tutorial.handles.body_text) 
  142. 	local footer_x, footer_y = vint_get_property(Tutorial.handles.footer_grp, "anchor")  
  143. 	local footer_y = y + height 
  144. 	vint_set_property(Tutorial.handles.footer_grp, "anchor", footer_x, footer_y) 
  145. 	 
  146. 	Tutorial.height = footer_y 
  147. 	 
  148. 	--Bottom of frame 
  149. 	x, y = vint_get_property(Tutorial.handles.bottom, "anchor") 
  150. 	local bottom_y = footer_y + 26 
  151. 	vint_set_property(Tutorial.handles.bottom, "anchor", x, bottom_y) 
  152. 	 
  153. 	--Background 
  154. 	local se_x, se_y 
  155. 	local source_y = footer_y + 35 
  156. 	 
  157. 	--Left Side of bg 
  158. 	se_x, se_y = vint_get_property(Tutorial.handles.side_l, "source_se") 
  159. 	vint_set_property(Tutorial.handles.side_l, "source_se", se_x, source_y ) 
  160. 	 
  161. 	--Right Side of BG 
  162. 	se_x, se_y = vint_get_property(Tutorial.handles.side_r, "source_se") 
  163. 	vint_set_property(Tutorial.handles.side_r, "source_se", se_x, source_y ) 
  164. 	vint_set_property(Tutorial.handles.side_r, "scale", -1, 1) 
  165. 	vint_set_property(Tutorial.handles.side_r, "offset", -17, 0) 
  166. 	 
  167. 	--Middle of BG 
  168. 	se_x, se_y = element_get_actual_size(Tutorial.handles.middle) 
  169. 	element_set_actual_size(Tutorial.handles.middle, se_x, source_y) 
  170. 	 
  171. 	--Reset Frame positioning relative to alignment 
  172. 	x = Tutorial.alignment.x 
  173. 	y = Tutorial.alignment.y 
  174. 	height = bottom_y * Tutorial.scaler --Bottom_y is our lowest point so lets use that as our base height 
  175. 	width = 528	* Tutorial.scaler			--Hardcode width for alignment 
  176. 	 
  177. 	if Tutorial.alignment.offset == "w" then 
  178. 		y = y - (height/2) 
  179. 		--West/Ceneter 
  180. 	elseif Tutorial.alignment.offset == "sw" then 
  181. 		--Southwest 
  182. 		y = y - height 
  183. 	elseif Tutorial.alignment.offset == "nw" then 
  184. 		--Northwest use same values 
  185. 	elseif Tutorial.alignment.offset == "ne" then 
  186. 		x = x - width 
  187. 		y = y 
  188. 	elseif Tutorial.alignment.offset == "e" then 
  189. 		x = x - width 
  190. 		y = y - (height/2) 
  191. 	end 
  192. 	vint_set_property(Tutorial.handles.window, "anchor", x, y) 
  193. end 
  194.  
  195. function tutorial_cleanup() 
  196. end 
  197.  
  198. function tutorial_alignment_set(alignment_string) 
  199. 	Tutorial.alignment = Tutorial.alignment_settings[alignment_string] 
  200. 	if Tutorial.alignment == nil then  
  201. 		debug_print("vint", "Alignment configuration doesn't exist for tutorial_alignment_set()\nUsing Default alignment 'Center'") 
  202. 		Tutorial.alignment = Tutorial.alignment_settings["center"] 
  203. 	else 
  204. 		local loc_x, loc_y = vint_get_property(vint_object_find(Tutorial.alignment.vdoc_name), "anchor" ) 
  205. 		Tutorial.alignment.x = loc_x 
  206. 		Tutorial.alignment.y = loc_y 
  207. 	end 
  208. end 
  209.  
  210. function tutorial_input_subscribe() 
  211. 	if Tutorial.input_subs ~= nil then 
  212. 		-- already good to go 
  213. 		return 
  214. 	end 
  215. 	 
  216. 	--	Subscribe to the input 
  217. 	Tutorial.input_subs = {	 
  218. 		vint_subscribe_to_input_event(nil, "pause",				"tutorial_input", 50), 
  219. 		vint_subscribe_to_input_event(nil, "all_unassigned",	"tutorial_input", 50), 
  220. 	} 
  221. end 
  222.  
  223. function tutorial_input(target, event, accelleration) 
  224. 	--close  
  225. 	if event == "pause" then 
  226.  
  227. 		tutorial_case_hide() 
  228. 	 
  229. 		-- Find out if there are any more tutorials 
  230. 		vint_dataresponder_request("tutorial_responder", "tutorial_update", 0) 
  231. 	end 
  232. end 
  233.  
  234. function tutorial_input_unsubscribe() 
  235. 	if Tutorial.input_subs == nil then 
  236. 		return 
  237. 	end 
  238. 	 
  239. 	--	Unsubscribe to input 
  240. 	for idx, val in Tutorial.input_subs do 
  241. 		vint_unsubscribe_to_input_event(val) 
  242. 	end 
  243. 	Tutorial.input_subs = nil 
  244. end 
  245.  
  246.  
  247. -------------------------------------- 
  248. ---SPECIAL CASES 
  249. -- 
  250. function tutorial_case_show() 
  251. 	if Tutorial_hud_doc == -1 then 
  252. 		--No hud loaded 
  253. 		return 
  254. 	end 
  255. 	 
  256. 	--Show highlight if needed 
  257. 	if Tutorial_special_cases[Tutorial.window.tutorial_type] ~= nil then 
  258. 		local tutorial_case = Tutorial_special_cases[Tutorial.window.tutorial_type] 
  259. 		--show thing 
  260. 		tutorial_case.show() 
  261. 		 
  262. 		--Reset alignment 
  263. 		tutorial_alignment_set(tutorial_case.align) 
  264. 		 
  265. 		if tutorial_case.arrow ~= nil then 
  266. 			--Align arrow to specific point 
  267. 			local arrow_ref_h =  vint_object_find(tutorial_case.arrow) 
  268. 			local arrow_x, arrow_y = vint_get_property(arrow_ref_h, "anchor") 
  269. 			vint_set_property(Tutorial.handles.arrow, "anchor", arrow_x, arrow_y) 
  270. 			 
  271. 			--Set rotation 
  272. 			local rotation 
  273. 			if tutorial_case.arrow_rotation == "w" then 
  274. 				rotation = -3.141592654 
  275. 			elseif tutorial_case.arrow_rotation == "e" then 
  276. 				rotation = 0 
  277. 			elseif tutorial_case.arrow_rotation == "s" then 
  278. 				rotation = 1.570796327 
  279. 			elseif tutorial_case.arrow_rotation == "n" then 
  280. 				rotation = -1.570796327 
  281. 			end 
  282. 			vint_set_property(Tutorial.handles.arrow, "rotation", rotation) 
  283. 			 
  284. 			--Show 
  285. 			vint_set_property(Tutorial.handles.arrow, "visible", true) 
  286. 		else 
  287. 			vint_set_property(Tutorial.handles.arrow, "visible", false) 
  288. 		end 
  289. 	else 
  290. 		vint_set_property(Tutorial.handles.arrow, "visible", false) 
  291. 		tutorial_alignment_set("center")	 
  292. 	end 
  293. end 
  294.  
  295. function tutorial_case_hide() 
  296. 	if Tutorial_hud_doc == -1 then 
  297. 		--No hud loaded 
  298. 		return 
  299. 	end 
  300. 	 
  301. 	--Clean up pruned objects 
  302. 	for i = 0, Tutorial_hud_prunings.num_elements - 1 do	 
  303. 		if Tutorial.window.tutorial_type ~= 74 then 
  304. 			--only reset the visibility if the item is not the radial menu 
  305. 			vint_set_property(Tutorial_hud_prunings[i].source_h, "visible", Tutorial_hud_prunings[i].source_object_visibility) 
  306. 		end 
  307. 		vint_object_destroy(Tutorial_hud_prunings[i].clone_h) 
  308. 	end 
  309. 	 
  310. 	--Reset Pruning numbers 
  311. 	Tutorial_hud_prunings = {} 
  312. 	Tutorial_hud_prunings.num_elements = 0 
  313. 	 
  314. 	 
  315. 	--Wipe out all tweens and cloned objects 
  316. 	for idx, val in Tutorial_hud_anim_cleanup do 
  317. 		debug_print("vint", "destroy: " .. val ..  "\n") 
  318. 		vint_object_destroy(val) 
  319. 	end 
  320. 	Tutorial_hud_anim_cleanup = {} 
  321. 	 
  322. 	 
  323. 	--Do any special hide functions if they exist 
  324. 	local tutorial_case = Tutorial_special_cases[Tutorial.window.tutorial_type] 
  325. 	if tutorial_case ~= nil then 
  326. 		if tutorial_case.hide ~= nil then 
  327. 			tutorial_case.hide() 
  328. 		end 
  329. 	end 
  330. 	 
  331. 	--Hide any misc shit... 
  332. 	local hud_txt_grp_h = vint_object_find("case_hud_txt_grp") 
  333. 	vint_set_property(hud_txt_grp_h, "visible", false) 
  334. end 
  335.  
  336. function tutorial_case_prune_hud(target_object_name, target_object_parent, new_parent_obj) 
  337. 	local source_object_h = vint_object_find(target_object_name, target_object_parent, Tutorial_hud_doc) 
  338. 	local clone_object_h = vint_object_clone(source_object_h) 
  339. 	vint_object_set_parent(clone_object_h, new_parent_obj) 
  340. 	 
  341. 	--original state 
  342. 	local source_object_visibility = vint_get_property(source_object_h, "visible") 
  343. 	 
  344. 	--Hide original part 
  345. 	vint_set_property(source_object_h, "visible", false) 
  346. 	 
  347. 	Tutorial_hud_prunings[Tutorial_hud_prunings.num_elements] = {clone_h = clone_object_h, source_h = source_object_h, source_object_visibility = source_object_visibility} 
  348. 	Tutorial_hud_prunings.num_elements = Tutorial_hud_prunings.num_elements + 1 
  349. 	return clone_object_h 
  350. end 
  351.  
  352. function tutorial_case_add_grp(target_object_name, target_object_parent, grp_parent) 
  353. 	local source_object_h = vint_object_find(target_object_name, target_object_parent, Tutorial_hud_doc) 
  354. 	local x, y = vint_get_property(source_object_h, "anchor") 
  355. 	local scale_x, scale_y = vint_get_property(source_object_h, "scale") 
  356. 	local new_grp_h = vint_object_create("new_grp", "group", grp_parent) 
  357. 	vint_set_property(new_grp_h, "anchor", x, y) 
  358. 	vint_set_property(new_grp_h, "scale", scale_x, scale_y) 
  359. 	return new_grp_h 
  360. end 
  361.  
  362. function tutorial_case_highlight_object(target_object_h, do_scale) 
  363. 	local anim_h = vint_object_find("pulse_glow_anim") 
  364. 	local clone_anim_h = vint_object_clone(anim_h) 
  365. 	local twn_1_h = vint_object_find("alpha_twn_1", clone_anim_h) 
  366. 	local twn_2_h = vint_object_find("scale_twn_1", clone_anim_h) 
  367.  
  368. 	--Clone target object and set it to alpha 
  369. 	local pulse_object_h = vint_object_clone(target_object_h) 
  370. 	 
  371. 	local x, y = vint_get_property(pulse_object_h, "anchor") 
  372. 	 
  373. 	vint_set_property(pulse_object_h, "anchor", x, y) 
  374. 	 
  375. 	vint_set_property(pulse_object_h, "render_mode", "additive_alpha")  
  376. 	vint_set_property(pulse_object_h, "depth", -1000)  
  377. 	 
  378. 	--retarget_animmams 
  379. 	vint_set_property(twn_1_h, "target_handle", pulse_object_h) 
  380. 	vint_set_property(twn_2_h, "target_handle", pulse_object_h) 
  381. 	 
  382. 	if do_scale == false or do_scale == nil then 
  383. 		 
  384. 		--Set pulse to bounce 
  385. 		vint_set_property(twn_1_h, "loop_mode", "bounce") 
  386. 		local t = vint_get_property(twn_1_h, "duration") 
  387. 		 
  388. 		--Delete scale tween 
  389. 		vint_object_destroy(twn_2_h) 
  390. 	end 
  391. 	 
  392. 	--Store anim 
  393. 	Tutorial_hud_anim_cleanup[Tutorial_hud_anim_obj_count] = clone_anim_h 
  394. 	Tutorial_hud_anim_obj_count = Tutorial_hud_anim_obj_count + 1 
  395. 	 
  396. 	--store pulsed object 
  397. 	Tutorial_hud_anim_cleanup[Tutorial_hud_anim_obj_count] = pulse_object_h 
  398. 	Tutorial_hud_anim_obj_count = Tutorial_hud_anim_obj_count + 1 
  399. 	 
  400. 	--Play anim 
  401. 	lua_play_anim(clone_anim_h, 0) 
  402. end 
  403.  
  404. function tutorial_case_gang_noto_show() 
  405. 	local gang_icon_grp = tutorial_case_add_grp("map_grp", nil, Tutorial.handles.safe_frame) 
  406. 	local icon_1_h = tutorial_case_prune_hud("gang_noto_icon_1", nil, gang_icon_grp) 
  407. 	local icon_2_h = tutorial_case_prune_hud("gang_noto_icon_2", nil, gang_icon_grp) 
  408. 	local icon_3_h = tutorial_case_prune_hud("gang_noto_icon_3", nil, gang_icon_grp) 
  409. 	local icon_4_h = tutorial_case_prune_hud("gang_noto_icon_4", nil, gang_icon_grp) 
  410. 	local icon_5_h = tutorial_case_prune_hud("gang_noto_icon_5", nil, gang_icon_grp) 
  411. 	 
  412. 	vint_set_property(icon_1_h, "image", "ui_hud_not_brotherhood") 
  413. 	vint_set_property(icon_2_h, "image", "ui_hud_not_brotherhood") 
  414. 	vint_set_property(icon_3_h, "image", "ui_hud_not_brotherhood") 
  415. 	vint_set_property(icon_4_h, "image", "ui_hud_not_brotherhood") 
  416. 	vint_set_property(icon_5_h, "image", "ui_hud_not_brotherhood") 
  417. 	vint_set_property(icon_1_h, "visible", true) 
  418. 	vint_set_property(icon_2_h, "visible", true) 
  419. 	vint_set_property(icon_3_h, "visible", true) 
  420. 	vint_set_property(icon_4_h, "visible", true) 
  421. 	vint_set_property(icon_5_h, "visible", true) 
  422. 	vint_set_property(icon_1_h, "alpha", 1) 
  423. 	vint_set_property(icon_2_h, "alpha", 1) 
  424. 	vint_set_property(icon_3_h, "alpha", 1) 
  425. 	vint_set_property(icon_4_h, "alpha", 1) 
  426. 	vint_set_property(icon_5_h, "alpha", 1) 
  427. 	 
  428. 	tutorial_case_highlight_object(icon_1_h, true) 
  429. 	tutorial_case_highlight_object(icon_2_h, true) 
  430. 	tutorial_case_highlight_object(icon_3_h, true) 
  431. 	tutorial_case_highlight_object(icon_4_h, true) 
  432. 	tutorial_case_highlight_object(icon_5_h, true) 
  433. end 
  434.  
  435. function tutorial_case_cop_noto_show() 
  436. 	debug_print("vint", "show_cop\n") 
  437. 	local gang_icon_grp = tutorial_case_add_grp("map_grp", nil, Tutorial.handles.safe_frame) 
  438. 	local icon_1_h = tutorial_case_prune_hud("police_noto_icon_1", nil, gang_icon_grp) 
  439. 	local icon_2_h = tutorial_case_prune_hud("police_noto_icon_2", nil, gang_icon_grp) 
  440. 	local icon_3_h = tutorial_case_prune_hud("police_noto_icon_3", nil, gang_icon_grp) 
  441. 	local icon_4_h = tutorial_case_prune_hud("police_noto_icon_4", nil, gang_icon_grp) 
  442. 	local icon_5_h = tutorial_case_prune_hud("police_noto_icon_5", nil, gang_icon_grp) 
  443. 	 
  444. 	vint_set_property(icon_1_h, "visible", true) 
  445. 	vint_set_property(icon_2_h, "visible", true) 
  446. 	vint_set_property(icon_3_h, "visible", true) 
  447. 	vint_set_property(icon_4_h, "visible", true) 
  448. 	vint_set_property(icon_5_h, "visible", true) 
  449. 	vint_set_property(icon_1_h, "alpha", 1) 
  450. 	vint_set_property(icon_2_h, "alpha", 1) 
  451. 	vint_set_property(icon_3_h, "alpha", 1) 
  452. 	vint_set_property(icon_4_h, "alpha", 1) 
  453. 	vint_set_property(icon_5_h, "alpha", 1) 
  454. 	 
  455. 	tutorial_case_highlight_object(icon_1_h, true) 
  456. 	tutorial_case_highlight_object(icon_2_h, true) 
  457. 	tutorial_case_highlight_object(icon_3_h, true) 
  458. 	tutorial_case_highlight_object(icon_4_h, true) 
  459. 	tutorial_case_highlight_object(icon_5_h, true) 
  460. end 
  461.  
  462. function tutorial_case_respect_show() 
  463. 	debug_print("vint", "show_cop\n") 
  464. 	local respect_grp = tutorial_case_add_grp("health_grp", nil, Tutorial.handles.safe_frame) 
  465. 	 
  466. 	local bar_bg_h = tutorial_case_prune_hud("respect_bar_bg", nil, respect_grp) 
  467. 	local bar_fill_1_h = tutorial_case_prune_hud("respect_bar_fill_0", nil, respect_grp) 
  468. 	local bar_fill_2_h = tutorial_case_prune_hud("respect_bar_fill_1", nil, respect_grp) 
  469. 	local respect_count_grp = tutorial_case_prune_hud("respect_count_grp", nil, respect_grp) 
  470. 	local respect_count_txt = vint_object_find("respect_count_txt",respect_count_grp) 
  471. 	 
  472. 	vint_set_property(bar_bg_h, "alpha", 1) 
  473. 	vint_set_property(bar_fill_1_h, "alpha", 1) 
  474. 	vint_set_property(bar_fill_2_h, "alpha", 1) 
  475. 	vint_set_property(respect_count_grp, "alpha", 1) 
  476. 	vint_set_property(bar_bg_h, "alpha", 1) 
  477. 	vint_set_property(bar_fill_1_h, "alpha", 1) 
  478. 	vint_set_property(bar_fill_2_h, "alpha", 1) 
  479. 	vint_set_property(respect_count_grp, "alpha", 1) 
  480. 	 
  481. 	--Set angles 
  482. 	vint_set_property(bar_bg_h, "start_angle", 0.491725) 
  483. 	vint_set_property(bar_bg_h, "end_angle", 3.1715) 
  484. 	 
  485. 	vint_set_property(bar_fill_1_h, "start_angle",  0.491725) 
  486. 	vint_set_property(bar_fill_1_h, "end_angle", 3.1365) 
  487. 	vint_set_property(bar_fill_1_h, "start_angle",  0.491725) 
  488. 	vint_set_property(bar_fill_1_h, "end_angle", 3.1365) 
  489. 	 
  490. 	vint_set_property(respect_count_grp, "rotation", 3.83172) 
  491. 	vint_set_property(respect_count_txt, "rotation",  2.44828) 
  492. 	vint_set_property(respect_count_txt, "text_tag", "x2") 
  493. 	vint_set_property(respect_count_txt, "visible", true) 
  494. 	 
  495. 	tutorial_case_highlight_object(bar_bg_h, false) 
  496. 	tutorial_case_highlight_object(bar_fill_1_h, false) 
  497. 	tutorial_case_highlight_object(bar_fill_2_h, false) 
  498. 	tutorial_case_highlight_object(respect_count_txt, true) 
  499. end 
  500.  
  501. function tutorial_case_health_show() 
  502. 	local health_grp = tutorial_case_add_grp("health_grp", nil, Tutorial.handles.safe_frame) 
  503. 	 
  504. 	local h_bar_bg_h 		= tutorial_case_prune_hud("health_bar_bg", nil, health_grp) 
  505. 	local h_bar_fill_1_h = tutorial_case_prune_hud("health_bar_fill_0", nil, health_grp) 
  506. 	local h_bar_fill_2_h = tutorial_case_prune_hud("health_bar_fill_2", nil, health_grp) 
  507. 	local s_bar_bg_h 		= tutorial_case_prune_hud("sprint_bar_bg", nil, health_grp) 
  508. 	local s_bar_fill_1_h = tutorial_case_prune_hud("sprint_bar_fill_0", nil, health_grp) 
  509. 	local s_bar_fill_2_h = tutorial_case_prune_hud("sprint_bar_fill_2", nil, health_grp) 
  510.  
  511. 	vint_set_property(h_bar_bg_h, "alpha", 1) 
  512. 	vint_set_property(h_bar_fill_1_h, "alpha", 1) 
  513. 	vint_set_property(h_bar_fill_2_h, "alpha", 1) 
  514. 	vint_set_property(s_bar_bg_h, "alpha", 1) 
  515. 	vint_set_property(s_bar_fill_1_h, "alpha", 1) 
  516. 	vint_set_property(s_bar_fill_2_h, "alpha", 1) 
  517. 	 
  518. 	 
  519. 	--Angles (Health) 
  520. 	vint_set_property(h_bar_bg_h, "start_angle", 3.1265) 
  521. 	vint_set_property(h_bar_bg_h, "end_angle", 6.298) 
  522. 	vint_set_property(h_bar_fill_1_h, "start_angle", 3.1715) 
  523. 	vint_set_property(h_bar_fill_1_h, "end_angle", 6.253) 
  524. 	vint_set_property(h_bar_fill_2_h, "start_angle", 3.1715) 
  525. 	vint_set_property(h_bar_fill_2_h, "end_angle", 6.253) 
  526. 	 
  527. 	--Angles (Sprint) 
  528. 	vint_set_property(s_bar_bg_h, "start_angle", 3.1265) 
  529. 	vint_set_property(s_bar_bg_h, "end_angle", 6.298) 
  530. 	vint_set_property(s_bar_fill_1_h, "start_angle", 3.1715) 
  531. 	vint_set_property(s_bar_fill_1_h, "end_angle", 6.253) 
  532. 	vint_set_property(s_bar_fill_2_h, "start_angle", 3.1715) 
  533. 	vint_set_property(s_bar_fill_2_h, "end_angle", 6.253) 
  534. 	 
  535. 	tutorial_case_highlight_object(h_bar_fill_1_h, false) 
  536. 	tutorial_case_highlight_object(h_bar_fill_2_h, false) 
  537. 	tutorial_case_highlight_object(s_bar_fill_1_h, false) 
  538. 	tutorial_case_highlight_object(s_bar_fill_2_h, true) 
  539. end 
  540.  
  541.  
  542. function tutorial_case_followers_show() 
  543. 	local followers_grp_h	 = tutorial_case_add_grp("followers", nil, Tutorial.handles.safe_frame) 
  544. 	local follower_h 			 = tutorial_case_prune_hud("follower_grp_1", nil, followers_grp_h) 
  545.  
  546. 	--Clone anim 
  547. 	local anim_h = vint_object_find("follow_anim_0", nil, Tutorial_hud_doc) 
  548. 	local anim_clone_h = vint_object_clone(anim_h) 
  549. 	 
  550. 	local tutorial_doc = vint_document_find("tutorial") 
  551. 	local root_anim = vint_object_find("root_animation", nil, tutorial_doc) 
  552. 	vint_object_set_parent(anim_clone_h, root_anim) 
  553. 	vint_set_property(anim_clone_h, "target_handle", follower_h) 
  554. 	lua_play_anim(anim_clone_h, 0) 
  555. 	 
  556. 	local health_fill_h = vint_object_find("follower_health_fill") 
  557. 	vint_set_property(health_fill_h, "start_angle", 1.57) 
  558. 	vint_set_property(health_fill_h, "end_angle", 3.147) 
  559. 	 
  560. 	--setup callback for after thing animates in 
  561. 	local twn_h = vint_object_find("follow_h_fill_alpha_tween_0") 
  562. 	vint_set_property(twn_h, "end_event", "tutorial_case_followers_show_2") 
  563. end 
  564.  
  565. function tutorial_case_followers_show_2() 
  566. 	local follower_h = vint_object_find("follower_grp_1") 
  567. 	tutorial_case_highlight_object(follower_h, true) 
  568. end 
  569.  
  570. function tutorial_case_map_show() 
  571. 	local game_map_h = tutorial_case_prune_hud("map_grp", nil, Tutorial.handles.safe_frame) 
  572. end 
  573.  
  574. function tutorial_case_hud_text_show() 
  575. 	local anim_h = vint_object_find("help_txt_anim") 
  576. 	local hud_txt_grp_h = vint_object_find("case_hud_txt_grp") 
  577. 	vint_set_property(hud_txt_grp_h, "visible", true) 
  578. 	 
  579. 	--set callback for looping 
  580. 	local cb_twn_h = vint_object_find("hlp_line_3_alpha_twn_2", anim_h ) 
  581. 	vint_set_property(cb_twn_h, "end_event", "tutorial_case_hud_text_show") 
  582. 	 
  583. 	--Set text for exploration... 
  584. 	local hlp_line_3_h = vint_object_find("hlp_line_3", hud_txt_grp_h) 
  585. 	vint_set_property(hlp_line_3_h, "text_tag", "TUT_DIVERSION_EXPLORATION_HOOD") 
  586. 	 
  587. 	lua_play_anim(anim_h, 0) 
  588.  
  589. end 
  590.  
  591. function tutorial_case_hud_text_hide() 
  592. 	local anim_h = vint_object_find("help_txt_anim") 
  593. 	local hud_txt_grp_h = vint_object_find("case_hud_txt_grp") 
  594. 	vint_set_property(anim_h, "is_paused", true) 
  595. 	vint_set_property(hud_txt_grp_h, "visible", false) 
  596. end 
  597.  
  598.  
  599. Tutorial_radial_case = {}	--Global Table to highlight parts of the radial menu 
  600.  
  601. function tutorial_case_radial_show() 
  602. 	--Update the stick text for the radial menu 
  603. 	vint_set_property(Hud_radial_menu.stick_text_h, "text_tag", get_control_stick_text()) 
  604. 	local radial_h = tutorial_case_prune_hud("radial_grp", nil, Tutorial.handles.safe_frame) 
  605. 	 
  606. 	--Hide popup text 
  607. 	local desc_h = vint_object_find("slot_description")  
  608. 	vint_set_property(desc_h, "visible", false) 
  609. 	 
  610. 	--Show base radial group because it may have been hidden 
  611. 	vint_set_property(radial_h, "visible", true) 
  612.  
  613. 	--Clone animation and Slot select anim 
  614. 	local slot_select_h = vint_object_find("slot_select", radial_h) 
  615. 	local anim_h = vint_object_find("radial_select_glow", nil, Tutorial_hud_doc) 
  616. 	local anim_clone_h = vint_object_clone(anim_h) 
  617. 	local tutorial_doc = vint_document_find("tutorial") 
  618. 	local root_anim = vint_object_find("root_animation", nil, tutorial_doc) 
  619. 	 
  620. 	vint_object_set_parent(anim_clone_h, root_anim) 
  621. 	vint_set_property(anim_clone_h, "target_handle", slot_select_h) 
  622. 	lua_play_anim(anim_clone_h, 0) 
  623. 	 
  624. 	--Set weapons... 
  625. 	local slot_icons = { 
  626. 		[0] = "ui_hud_inv_w_fist", 
  627. 		[1] = "ui_hud_inv_w_nitestick", 
  628. 		[2] = "ui_hud_inv_w_beretta", 
  629. 		[3] = "ui_hud_inv_w_tek9", 
  630. 		[4] = "ui_hud_inv_w_shotgun", 
  631. 		[5] = "ui_hud_inv_w_m32", 
  632. 		[6] = "ui_hud_inv_w_rpg", 
  633. 		[7] = "ui_hud_inv_w_grenade", 
  634. 	} 
  635.  
  636. 	local slot_bmp_1_h, slot_bmp_2_h, slot_h, dual_wield_h 
  637. 	 
  638. 	for i = 0, 7 do 
  639. 		local image_name = slot_icons[i] 
  640. 		local slot_h = vint_object_find("slot_" .. i, radial_h) 
  641. 		local dual_wield_h = vint_object_find("inv_dual_wield_tmp", slot_h) 
  642. 		local slot_bmp_1_h = vint_object_find("inv_icon_tmp", slot_h) 
  643. 		 
  644. 		if dual_wield_h ~= 0 then 
  645. 			--Dual weild for whatever reason! Cheats??	 
  646. 			local slot_bmp_1_h = vint_object_find("inv_icon_0", dual_wield_h) 
  647. 			local slot_bmp_2_h = vint_object_find("inv_icon_1", dual_wield_h) 
  648. 			vint_set_property(slot_bmp_1_h, "image", image_name) 
  649. 			vint_set_property(slot_bmp_1_h, "image", image_name) 
  650. 			vint_set_property(dual_wield_h, "anchor", 0,0) 
  651. 			vint_set_property(dual_wield_h, "scale", .75,.75) 
  652. 		elseif  slot_bmp_1_h ~= 0 then 
  653. 			--Single 
  654. 			vint_set_property(slot_bmp_1_h, "image", image_name) 
  655. 			vint_set_property(slot_bmp_1_h, "anchor", 0,0) 
  656. 			vint_set_property(slot_bmp_1_h, "scale", .75,.75) 
  657. 		else 
  658. 			--Need to build icon regardless 
  659. 			local inv_h = vint_object_find("inv_icon_tmp") 
  660. 			local item_element_h = vint_object_clone(inv_h, slot_h) 
  661. 			vint_set_property(item_element_h, "image", image_name) 
  662. 			vint_set_property(item_element_h, "anchor", 0,0) 
  663. 			vint_set_property(item_element_h, "scale", .75,.75) 
  664. 		end 
  665. 		Tutorial_radial_case[i] = slot_h 
  666. 	end 
  667. 	Tutorial_radial_case.num_positions = 8 
  668. 	Tutorial_radial_case.cur_idx = 8 
  669. 	Tutorial_radial_case.slot_select_h = slot_select_h 
  670. 	Tutorial_radial_case.stick_h = vint_object_find("stick_grp", radial_h)  
  671. 	 
  672. 	Tutorial_radial_case.stick_positions = { 
  673. 		[0] = {x = 0, y = -12}, 
  674. 		[1] = {x = 6, y = -6}, 
  675. 		[2] = {x = 12, y = 0}, 
  676. 		[3] = {x = 6, y = 6}, 
  677. 		[4] = {x = 0, y = 12}, 
  678. 		[5] = {x = -6, y = 6}, 
  679. 		[6] = {x = -12, y = 0}, 
  680. 		[7] = {x = -6, y = -6}, 
  681. 	} 
  682. 	 
  683. 	local anim_h = vint_object_find("radial_action_anim_1") 
  684. 	lua_play_anim(anim_h, 0) 
  685. 	 
  686. 	local twn_h  = vint_object_find("radial_action_twn_1") 
  687. 	vint_set_property(twn_h, "end_event", "tutorial_case_radial_loop_event") 
  688. 	tutorial_case_radial_loop_event() 
  689. end 
  690.  
  691. function tutorial_case_radial_loop_event() 
  692. 	if Tutorial_radial_case.cur_idx >= Tutorial_radial_case.num_positions then 
  693. 		Tutorial_radial_case.cur_idx = 0 
  694. 	end 
  695. 	 
  696. 	--Move Highlight 
  697. 	local target_slot_h = Tutorial_radial_case[Tutorial_radial_case.cur_idx] 
  698. 	local x, y = vint_get_property(target_slot_h, "anchor") 
  699. 	vint_set_property(Tutorial_radial_case.slot_select_h, "anchor", x, y) 
  700. 	 
  701. 	--Move Stick 
  702. 	x = Tutorial_radial_case.stick_positions[Tutorial_radial_case.cur_idx].x 
  703. 	y = Tutorial_radial_case.stick_positions[Tutorial_radial_case.cur_idx].y 
  704. 	vint_set_property(Tutorial_radial_case.stick_h, "anchor", x, y) 
  705. 	 
  706. 	--Increment Radial Position 
  707. 	Tutorial_radial_case.cur_idx = Tutorial_radial_case.cur_idx + 1 
  708. 	 
  709. 	--Retrigger Animation 
  710. 	local anim_h = vint_object_find("radial_action_anim_1") 
  711. 	lua_play_anim(anim_h, 0) 
  712. end 
  713.  
  714. function tutorial_case_radial_hide() 
  715. 	local anim_h = vint_object_find("radial_action_anim_1") 
  716. 	vint_set_property(anim_h, "is_paused", true) 
  717. end 
  718.  
  719. function tutorial_case_div_shoot_show() 
  720. 	local div_grp = vint_object_find("case_div_grp") 
  721. 	local div_stunt_text_h = vint_object_find("div_stunt", div_grp) 
  722. 	vint_set_property(div_stunt_text_h, "text_tag", "DIVERSION_COMBAT_TRICKS_GANG_KILL") 
  723. 	tutorial_case_div_start() 
  724. end 
  725.  
  726. function tutorial_case_div_driving_show() 
  727. local div_grp = vint_object_find("case_div_grp") 
  728. 	local div_stunt_text_h = vint_object_find("div_stunt", div_grp) 
  729. 	vint_set_property(div_stunt_text_h, "text_tag", "DIVERSION_STUNT_JUMPING") 
  730. 	tutorial_case_div_start() 
  731. end 
  732.  
  733. function tutorial_case_div_start() 
  734. 	 
  735. 	--Show Grp 
  736. 	local div_grp = vint_object_find("case_div_grp") 
  737. 	vint_set_property(div_grp, "visible", true) 
  738. 	 
  739. 	--Align stars to text 
  740. 	local div_stunt_text_h = vint_object_find("div_stunt", div_grp) 
  741. 	local stars_h = vint_object_find("stars", div_grp) 
  742. 	local width, height = element_get_actual_size(div_stunt_text_h) 
  743. 	 
  744. 	local x, y = vint_get_property(stars_h, "anchor") 
  745. 	vint_set_property(stars_h, "anchor", 0 - width - 10, y) 
  746. 	 
  747. 	--Play Animation 
  748. 	local anim_h = vint_object_find("diversion_anim") 
  749. 	lua_play_anim(anim_h, 0) 
  750. 	 
  751. 	--Callback for looping animation 
  752. 	local twn_h = vint_object_find("div_respect_count_alpha_twn_3") 
  753. 	vint_set_property(twn_h, "end_event", "tutorial_case_div_loop_event") 
  754. end 
  755.  
  756. function tutorial_case_div_hide() 
  757. 	local anim_h = vint_object_find("diversion_anim") 
  758. 	local div_grp = vint_object_find("case_div_grp") 
  759. 	vint_set_property(anim_h, "is_paused", true) 
  760. 	vint_set_property(div_grp, "visible", false) 
  761. end 
  762.  
  763. function tutorial_case_div_loop_event() 
  764. 	--Play Animation 
  765. 	local anim_h = vint_object_find("diversion_anim") 
  766. 	lua_play_anim(anim_h, 0) 
  767. end 
  768.  
  769.  
  770. Tutorial_special_cases = { 
  771. 	--Gang Notoriety 
  772. 	[2] = {show = tutorial_case_gang_noto_show, align = "notoriety", arrow = "arrow_gang", arrow_rotation = "w"}, 
  773. 	--Cop Notoriety 
  774. 	[3] = {show = tutorial_case_cop_noto_show, align = "notoriety", arrow = "arrow_cop", arrow_rotation = "w"}, 
  775. 	 
  776. 	--Combat Weapons(Radial Menu) 
  777. 	[74] = {show = tutorial_case_radial_show, hide = tutorial_case_radial_hide, align = "radial", arrow = "arrow_radial", arrow_rotation = "e"}, 
  778. 	 
  779. 	--Diversion Driving 
  780. 	[79] = {show = tutorial_case_div_driving_show, hide = tutorial_case_div_hide, align = "diversion", arrow = "arrow_div", arrow_rotation = "n"}, 
  781. 	 
  782. 	--Diverison Shooting 
  783. 	[80] = {show = tutorial_case_div_shoot_show, hide = tutorial_case_div_hide, align = "diversion", arrow = "arrow_div", arrow_rotation = "n"}, 
  784. 	 
  785. 	--Respect 
  786. 	[89] = {show = tutorial_case_respect_show, align = "health", arrow = "arrow_respect", arrow_rotation = "e"}, 
  787. 	 
  788. 	--Health/Sprint Meter 
  789. 	[90] = {show = tutorial_case_health_show, align = "health", arrow = "arrow_health", arrow_rotation = "e"}, 
  790. 	 
  791. 	--Map 
  792. 	[92] = {show = tutorial_case_map_show, align = "notoriety", arrow = "arrow_minimap", arrow_rotation = "w"}, 
  793. 	 
  794. 	--Followers 
  795. 	[93] = {show = tutorial_case_followers_show, align = "follower", arrow = "arrow_follower", arrow_rotation = "e"}, 
  796. 	 
  797. 	--Diversion Standard 
  798. 	[94] = {show = tutorial_case_div_driving_show, hide = tutorial_case_div_hide,  align = "diversion", arrow = "arrow_div", arrow_rotation = "n"}, 
  799. 	 
  800. 	--Hud Text 
  801. 	[95] = {show = tutorial_case_hud_text_show, hide = tutorial_case_hud_text_hide, align = "hud_txt", arrow = "arrow_hud_txt", arrow_rotation = "s"}, 
  802. }