./cte_outro_ending.lua

  1. -- HVS_BDF 3/07/14 
  2. -- This is the script file that manages the logic for the cte_outro_ending.vint_doc. 
  3. -- This is a rough protoype and can certainly be better engineered! 
  4. -- This code is not sacred, so re-engineer as you see fit. 
  5. -- The magic frame numbers below are found in:  
  6. --		X:\Art\Cinematics\Storybook_Pages\Reference\Documents_Bink\Outro_Bink_Frames.xlsx 
  7. -- We may want to consider using keyframes instead of raw frame values (check with Amber). 
  8. -- If we do decide to go with keyframes, make sure you modify vint_game_system_init() in 
  9. --	vint_game_main.cpp; see my comments there for more information. 
  10.  
  11.  
  12. local Ending_Text = { 
  13. 	[1] = { 
  14. 		label = "OUTRO_ENDING_DESC_HEAVEN", 
  15. 	}, 
  16. 	[2] = { 
  17. 		label = "OUTRO_ENDING_DESC_HELL", 
  18. 	}, 
  19. 	[3] = { 
  20. 		label = "OUTRO_ENDING_DESC_NEW_PLANET", 
  21. 	}, 
  22. 	[4] = { 
  23. 		label = "OUTRO_ENDING_DESC_NEW_EARTH", 
  24. 	}, 
  25. 	[5] = { 
  26. 		label = "OUTRO_ENDING_DESC_COSMIC_KNWLGE", 
  27. 	}, 
  28. } 
  29.  
  30. local Ending_Cutscenes = { "bink_alt_heaven", "bink_alt_hell" , "bink_alt_new_planet" , "bink_alt_new_earth" , "bink_alt_cosmic" } 
  31. STORE_COMMON_LIST_SIZE = 435		--vint_to_std_res(428, -378) 
  32.  
  33. Yes_no_choices = { 
  34. 	[1] = { 
  35. 		type = TYPE_BUTTON, 
  36. 		label = "PAUSE_MENU_ACCEPT", 
  37. 		id = 1, 
  38. 	}, 
  39. 	[2] = { 
  40. 		type = TYPE_BUTTON, 
  41. 		label = "CONTROL_CANCEL", 
  42. 		id = 2, 
  43. 		audio_object_post_event( "Play_Page_Turns" ) 
  44. 	}, 
  45. } 
  46.  
  47. -- Globals 
  48. Cte_outro_ending_doc_handle = -1 
  49. local Input_tracker = -1 
  50. local Mouse_input_tracker = -1 
  51. local Video1_h = -1						-- the handle to the vint_element_video 
  52. local Video1_str = "SB_Outro_UI.bk2"	-- the filename of the video 
  53. local Num_pages = 5						-- how many pages in the book 
  54. local Current_page = -1					-- the current page the player is looking at 
  55. local Start_frame = 1					-- the frame of the video to initialize with 
  56. local Initial_frame_event_num = 3602	-- the frame of the video to initialize with 
  57. local initial_bink_portion = false		-- are we still in the first part of the bink 
  58. local final_bink_portion = false 
  59. local final_bink_frame = -1 
  60.  
  61. local leftArrowBase_h = -1 
  62. local leftArrowHighlight_h = -1 
  63.  
  64. local rightArrowBase_h = -1 
  65. local rightArrowHighlight_h = -1 
  66.  
  67. local text_area_h = -1 
  68. local text_ending_desc = -1 
  69. local text_hint = -1 
  70. local text_coop_desc = -1 
  71.  
  72. local confirm_box = -1 
  73.  
  74. -- Debugging 
  75. local Debug_text_h = -1				-- the handle to a text element, useful for debugging 
  76.  
  77. local p5_to_4_frame_start = -1 
  78. local p5_to_4_frame_event = -1 
  79. local p4_to_3_frame_start = -1 
  80. local p4_to_3_frame_event = -1 
  81. local p3_to_2_frame_start = -1 
  82. local p3_to_2_frame_event = -1 
  83. local p2_to_1_frame_start = -1 
  84. local p2_to_1_frame_event = -1 
  85.  
  86. local p1_to_2_frame_start = -1 
  87. local p1_to_2_frame_event = -1 
  88. local p2_to_3_frame_start = -1 
  89. local p2_to_3_frame_event = -1 
  90. local p3_to_4_frame_start = -1 
  91. local p3_to_4_frame_event = -1 
  92. local p4_to_5_frame_start = -1 
  93. local p4_to_5_frame_event = -1 
  94.  
  95. local select_page_5_start = -1 
  96. local select_page_5_event = -1 
  97. local select_page_4_start = -1 
  98. local select_page_4_event = -1 
  99. local select_page_3_start = -1 
  100. local select_page_3_event = -1 
  101. local select_page_2_start = -1 
  102. local select_page_2_event = -1 
  103. local select_page_1_start = -1 
  104. local select_page_1_event = -1 
  105.  
  106. local UI_METHOD = false; 
  107.  
  108. -- Standard initialization 
  109. function cte_outro_ending_init() 
  110. 	-- Get the doc handle; this should be done before anything else! 
  111. 	Cte_outro_ending_doc_handle = vint_document_find("cte_outro_ending") 
  112.  
  113. 	-- Get the handle to our debug text field 
  114. 	Debug_text_h = vint_object_find( "text1", 0, Cte_outro_ending_doc_handle ) 
  115.  
  116. 	-- turn off debug text field 
  117. 	vint_set_property( Debug_text_h, "visible", false ) 
  118.  
  119. 	-- get arrow handles 
  120. 	leftArrowBase_h = vint_object_find("ui_sb_arrow_idle_left", 0, Cte_outro_ending_doc_handle) 
  121. 	leftArrowHighlight_h = vint_object_find("ui_sb_arrow_selected_left", 0, Cte_outro_ending_doc_handle) 
  122.  
  123. 	rightArrowBase_h = vint_object_find("ui_sb_arrow_idle_right", 0, Cte_outro_ending_doc_handle) 
  124. 	rightArrowHighlight_h = vint_object_find("ui_sb_arrow_selected_right", 0, Cte_outro_ending_doc_handle) 
  125.  
  126. 	-- turn off arrows 
  127. 	vint_set_property( leftArrowBase_h, "visible", false ) 
  128. 	vint_set_property( leftArrowHighlight_h, "visible", false ) 
  129. 	vint_set_property( rightArrowBase_h, "visible", false ) 
  130. 	vint_set_property( rightArrowHighlight_h, "visible", false ) 
  131.  
  132. 	-- get confirm box handle 
  133. 	confirm_box = Vdo_store_popup:new("vdo_store_popup", 0, Cte_outro_ending_doc_handle)--vint_object_find("vdo_store_popup", 0, Cte_outro_ending_doc_handle) 
  134. 	confirm_box:set_visible(false) 
  135. 	confirm_box:set_size(STORE_COMMON_LIST_SIZE, (LIST_BUTTON_HEIGHT * 5) + (LIST_BUTTON_SPACE * 5)) 
  136. 	 
  137. 	-- get our ending description and vignettes 
  138. 	text_area_h = vint_object_find("text_area", 0, Cte_outro_ending_doc_handle) 
  139. 	text_ending_desc = vint_object_find("text_ending_desc", 0, Cte_outro_ending_doc_handle) 
  140. 	text_coop_desc = vint_object_find("text_coop_desc", 0, Cte_outro_ending_doc_handle) 
  141.  
  142. 	local data = { 
  143. 		{CTRL_MENU_BUTTON_A, "OUTRO_ENDING_SELECT"}, 
  144. 	} 
  145.  
  146. 	text_hint = Vdo_hint_bar:new("vdo_hint_button", 0, Cte_outro_ending_doc_handle) -- vint_object_find("vdo_hint_button", 0, Cte_outro_ending_doc_handle) 
  147. 	text_hint:set_hints(data) 
  148. 	text_hint:set_highlight(1, COLOR_CHEATS_SECONDARY) 
  149.  
  150. 	-- turn off desc and vignettes 
  151. 	vint_set_property( text_area_h, "visible", false ) 
  152. 	vint_set_property( text_coop_desc, "visible", false ) 
  153. 	vint_set_property( text_coop_desc, "text_tag", "OUTRO_ENDING_WAITING" ) 
  154. 	text_hint:set_visible(false) 
  155.  
  156. 	local jane_austin_buff = 3602 --1402 
  157.  
  158. 	if not UI_METHOD then 
  159. 		p5_to_4_frame_start = 0 + jane_austin_buff 
  160. 		p5_to_4_frame_event = 74 + jane_austin_buff 
  161. 		p4_to_3_frame_start = 75 + jane_austin_buff 
  162. 		p4_to_3_frame_event = 148 + jane_austin_buff 
  163. 		p3_to_2_frame_start = 149 + jane_austin_buff 
  164. 		p3_to_2_frame_event = 222 + jane_austin_buff 
  165. 		p2_to_1_frame_start = 223 + jane_austin_buff 
  166. 		p2_to_1_frame_event = 296 + jane_austin_buff 
  167.  
  168. 		p1_to_2_frame_start = 297 + jane_austin_buff 
  169. 		p1_to_2_frame_event = 370 + jane_austin_buff 
  170. 		p2_to_3_frame_start = 371 + jane_austin_buff 
  171. 		p2_to_3_frame_event = 444 + jane_austin_buff 
  172. 		p3_to_4_frame_start = 445 + jane_austin_buff 
  173. 		p3_to_4_frame_event = 518 + jane_austin_buff 
  174. 		p4_to_5_frame_start = 519 + jane_austin_buff 
  175. 		p4_to_5_frame_event = 590 + jane_austin_buff 
  176.  
  177. 		Initial_frame_event_num = 2 + jane_austin_buff 
  178.  
  179. 		select_page_5_start = 593 + jane_austin_buff 
  180. 		select_page_5_event = 1970 + jane_austin_buff 
  181. 		select_page_4_start = 1972 + jane_austin_buff 
  182. 		select_page_4_event = 3596 + jane_austin_buff 
  183. 		select_page_3_start = 3598 + jane_austin_buff 
  184. 		select_page_3_event = 5147 + jane_austin_buff 
  185. 		select_page_2_start = 5149 + jane_austin_buff 
  186. 		select_page_2_event = 6818 + jane_austin_buff 
  187. 		select_page_1_start = 6820 + jane_austin_buff 
  188. 		select_page_1_event = 7946 + jane_austin_buff 
  189. 	else 
  190. 		p5_to_4_frame_start = 3602 
  191. 		p5_to_4_frame_event = 3676 
  192. 		p4_to_3_frame_start = 3676 
  193. 		p4_to_3_frame_event = 3750 
  194. 		p3_to_2_frame_start = 3750 
  195. 		p3_to_2_frame_event = 3824 
  196. 		p2_to_1_frame_start = 3824 
  197. 		p2_to_1_frame_event = 3898 
  198.  
  199. 		p1_to_2_frame_start = 3898 
  200. 		p1_to_2_frame_event = 3972 
  201. 		p2_to_3_frame_start = 3972 
  202. 		p2_to_3_frame_event = 4046 
  203. 		p3_to_4_frame_start = 4046 
  204. 		p3_to_4_frame_event = 4120 
  205. 		p4_to_5_frame_start = 4120 
  206. 		p4_to_5_frame_event = 4194 
  207.  
  208. 		select_page_5_start = 4194 
  209. 		select_page_5_event = 5571 
  210. 		select_page_4_start = 5573 
  211. 		select_page_4_event = 7197 
  212. 		select_page_3_start = 7199 
  213. 		select_page_3_event = 8748 
  214. 		select_page_2_start = 8750 
  215. 		select_page_2_event = 10419 
  216. 		select_page_1_start = 10421 
  217. 		select_page_1_event = 11549 
  218. 	end 
  219.  
  220. end 
  221.  
  222.  
  223. -- Initialize the video element 
  224. function cte_outro_ending_init_video() 
  225. 	 
  226. 	if UI_METHOD then 
  227. 	-------------------------------------------------- 
  228. 	--												-- 
  229. 	--					** UI Method **				-- 
  230. 	--												-- 
  231. 	-------------------------------------------------- 
  232. 	 
  233. 		Video1_h = vint_object_find( "new_video1", 0, Cte_outro_ending_doc_handle ) 
  234. 	 
  235. 		-- Initialize some of the video element props; this could be done in the vint_doc instead 
  236. 		vint_set_property( Video1_h, "vid_name", Video1_str ) 
  237. 		vint_set_property( Video1_h, "visible", false ) 
  238. 		vint_set_property( Video1_h, "is_looped", false ) 
  239. 		vint_set_property( Video1_h, "frame_event_num", Initial_frame_event_num ) 
  240. 		vint_set_property( Video1_h, "frame_event", "pause_video" ) 
  241. 	 
  242. 		-- Start the video 
  243. 		--cte_outro_start_video() 
  244. 	 
  245.  
  246. 	-------------------------------------------------- 
  247. 	--												-- 
  248. 	--				**End UI Method **				-- 
  249. 	--												-- 
  250. 	-------------------------------------------------- 
  251. 	else 
  252. 	-------------------------------------------------- 
  253. 	--												-- 
  254. 	--			** In Cutscene Method **			-- 
  255. 	--												-- 
  256. 	-------------------------------------------------- 
  257. 	 
  258. 		local cutscene_bink_handle = get_cutscene_bink_handle() 
  259. 	 
  260. 		--video_player_vint_goto_frame(cutscene_bink_handle, 1) 
  261. 		video_player_vint_goto_nearest_keyframe(cutscene_bink_handle, 3602)			-- these frame numbers are approximate 
  262. 		video_player_vint_update_lua_frame_event_num(cutscene_bink_handle, 3602)	-- these frame numbers are approximate 
  263. 		video_player_vint_update_lua_frame_event(cutscene_bink_handle, "pause_video") 
  264. 	 
  265. 		-- Resume playing the video 
  266. 		video_player_vint_pause(cutscene_bink_handle, false) 
  267. 	-------------------------------------------------- 
  268. 	--												-- 
  269. 	--			**End Cutscene Method **			-- 
  270. 	--												-- 
  271. 	-------------------------------------------------- 
  272. 	end 
  273. end 
  274.  
  275.  
  276. -- Initialize the Input Tracker 
  277. function cte_outro_ending_init_input() 
  278. 	Input_tracker = Vdo_input_tracker:new() 
  279. 	 
  280. 	Input_tracker:add_input("select", "cte_outro_ending_handle_input", 50) 
  281. 	Input_tracker:add_input("nav_left", "cte_outro_ending_handle_input", 50) 
  282. 	Input_tracker:add_input("nav_right", "cte_outro_ending_handle_input", 50) 
  283. 	 
  284. 	Input_tracker:subscribe( true ) 
  285.  
  286. 	-- Create the mouse's input tracker 
  287. 	if game_get_platform() == "PC" then 
  288. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  289. 		 
  290. 		--leftArrowBase_h:add_mouse_inputs("cte_outro_ending", Mouse_input_tracker, false) 
  291. 		--rightArrowBase_h:add_mouse_inputs("cte_outro_ending", Mouse_input_tracker, false) 
  292.  
  293. 		Mouse_input_tracker:add_mouse_input("mouse_click", "cte_outro_mouse_click_left", 0, leftArrowBase_h) 
  294. 		Mouse_input_tracker:add_mouse_input("mouse_click", "cte_outro_mouse_click_right", 0, rightArrowBase_h) 
  295. 		--Mouse_input_tracker:add_mouse_input("mouse_click", "cte_outro_mouse_click_select", 0, text_area_h) 
  296.  
  297. 		text_hint:add_mouse_inputs("cte_outro", Mouse_input_tracker); 
  298.  
  299. 		Mouse_input_tracker:subscribe(true) 
  300. 	end 
  301. end 
  302.  
  303. function cte_outro_mouse_click_left(event, target_handle) 
  304. 	cte_outro_ending_handle_input( "nav_left" ) 
  305. end  
  306.  
  307. function cte_outro_mouse_click_right(event, target_handle) 
  308. 	cte_outro_ending_handle_input( "nav_right" ) 
  309. 	 
  310. end 
  311.  
  312. function cte_outro_mouse_click_select(event, target_handle) 
  313. 	cte_outro_ending_handle_input( "select" ) 
  314. end 
  315.  
  316. function cte_outro_mouse_click(event, target_handle)  
  317. 	cte_outro_ending_handle_input( "select" ) 
  318. end 
  319.  
  320. function cte_outro_mouse_move(event, target_handle) 
  321. 	text_hint:set_highlight(0) 
  322. 	local hint_index = text_hint:get_hint_index(target_handle) 
  323. 	if hint_index ~= 0 then 
  324. 		text_hint:set_highlight(hint_index) 
  325. 	end 
  326. end 
  327.  
  328. -- Input handler 
  329. function cte_outro_ending_handle_input( event ) 
  330. 	-- Ignore input processing while the video is playing 
  331. 	local cutscene_bink_handle = get_cutscene_bink_handle() 
  332.  
  333. 	local is_cutscene_pause = false 
  334. 	if UI_METHOD then 
  335. 		is_cutscene_pause = vint_get_property(Video1_h, "is_paused") 
  336. 	else 
  337. 		is_cutscene_pause = video_player_vint_is_paused(cutscene_bink_handle) 
  338. 	end 
  339.  
  340. 	if ( is_cutscene_pause == false ) then 
  341. 		 
  342. 		if (initial_bink_portion and event == "select") then 
  343. 			-- skip to the selection portion without hearing the explanation 
  344. 			initial_bink_portion = false; 
  345. 			--vint_set_property( Video1_h, "frame", Initial_frame_event_num ) 
  346. 		end 
  347.  
  348. 		if (final_bink_portion and event == "select") then 
  349. 			-- skip to credits 
  350. 			final_bink_portion = false; 
  351.  
  352.  
  353. 			if UI_METHOD then 
  354. 			-------------------------------------------------- 
  355. 			--												-- 
  356. 			--					** UI Method **				-- 
  357. 			--												-- 
  358. 			-------------------------------------------------- 
  359.  
  360. 				-- Jump to the new frame and set the new callback frame 
  361. 				--vint_set_property( Video1_h, "frame", final_bink_frame ) 
  362.  
  363. 			-------------------------------------------------- 
  364. 			--												-- 
  365. 			--				**End UI Method **				-- 
  366. 			--												-- 
  367. 			-------------------------------------------------- 
  368. 			else 
  369. 			-------------------------------------------------- 
  370. 			--												-- 
  371. 			--			** In Cutscene Method **			-- 
  372. 			--												-- 
  373. 			-------------------------------------------------- 
  374.  
  375. 				--local cutscene_bink_handle = get_cutscene_bink_handle() 
  376.  
  377. 				-- Jump to the new frame and set the new callback frame 
  378. 				--video_player_vint_goto_frame(cutscene_bink_handle, final_bink_frame) 
  379.  
  380. 			-------------------------------------------------- 
  381. 			--												-- 
  382. 			--			**End Cutscene Method **			-- 
  383. 			--												-- 
  384. 			-------------------------------------------------- 
  385. 			end 
  386.  
  387. 			 
  388. 		end 
  389. 		-- Possibly play some "no-no" sound effect 
  390. 		-- ui_audio_post_event( "UI_Hub_Navigate" ) 
  391. 		return 
  392. 	end 
  393.  
  394. 	-- Check which event and redirect accordingly 
  395. 	if event == "select" then 
  396. 		cte_outro_ending_confirm_select() 
  397. 	else 
  398. 		cte_outro_ending_nav( event ) 
  399. 	end 
  400. end 
  401.  
  402.  
  403. -- Navigation handler 
  404. function cte_outro_ending_nav( event ) 
  405. 	local frame_num = 0 
  406. 	local frame_event_num = -1 
  407.  
  408. 	--vint_set_property(leftArrowBase_h, "visible", false) 
  409. 	--vint_set_property(rightArrowBase_h, "visible", false) 
  410.  
  411. 	local is_client = outro_is_client() 
  412. 	if not is_client then 
  413. 		outro_send_multiplayer_nav_event(event); 
  414. 	end  
  415.  
  416. 	if event == "nav_left" and Current_page > 1 then 
  417. 		set_debug_text( "Page left!" ) 
  418. 		audio_object_post_event( "Play_Page_Turns" ) 
  419.  
  420. 		vint_set_property(text_area_h, "visible", false) 
  421. 		vint_set_property( text_coop_desc, "visible", false ) 
  422. 		text_hint:set_visible(false) 
  423.  
  424. 		--vint_set_property(leftArrowHighlight_h, "visible", true) 
  425. 		local left_arrow_animation = vint_object_find( "Arrow_Left_Selected", 0, Cte_outro_ending_doc_handle  ) 
  426. 		lua_play_anim( left_arrow_animation, 0 ) 
  427.  
  428. 		if ( Current_page == 5 ) then 
  429. 			frame_num = p5_to_4_frame_start 
  430. 			frame_event_num = p5_to_4_frame_event 
  431. 		elseif ( Current_page == 4 ) then 
  432. 			frame_num = p4_to_3_frame_start 
  433. 			frame_event_num = p4_to_3_frame_event 
  434. 		elseif ( Current_page == 3 ) then 
  435. 			frame_num = p3_to_2_frame_start 
  436. 			frame_event_num = p3_to_2_frame_event 
  437. 		elseif ( Current_page == 2 ) then 
  438. 			frame_num = p2_to_1_frame_start 
  439. 			frame_event_num = p2_to_1_frame_event 
  440. 		end 
  441. 		-- Update the page tracker 
  442. 		Current_page = Current_page - 1 
  443.  
  444. 	elseif event == "nav_right" and Current_page < Num_pages then 
  445. 		set_debug_text( "Page right!" ) 
  446. 		audio_object_post_event( "Play_Page_Turns" ) 
  447.  
  448. 		vint_set_property(text_area_h, "visible", false) 
  449. 		text_hint:set_visible(false) 
  450.  
  451. 		--vint_set_property(rightArrowHighlight_h, "visible", true) 
  452. 		local right_arrow_animation = vint_object_find( "Arrow_Right_Selected", 0, Cte_outro_ending_doc_handle  ) 
  453. 		lua_play_anim( right_arrow_animation, 0 ) 
  454.  
  455. 		if ( Current_page == 1 ) then 
  456. 			frame_num = p1_to_2_frame_start 
  457. 			frame_event_num = p1_to_2_frame_event 
  458. 		elseif ( Current_page == 2 ) then 
  459. 			frame_num = p2_to_3_frame_start 
  460. 			frame_event_num = p2_to_3_frame_event 
  461. 		elseif ( Current_page == 3 ) then 
  462. 			frame_num = p3_to_4_frame_start 
  463. 			frame_event_num = p3_to_4_frame_event 
  464. 		elseif ( Current_page == 4 ) then 
  465. 			frame_num = p4_to_5_frame_start 
  466. 			frame_event_num = p4_to_5_frame_event 
  467. 		end 
  468. 		-- Update the page tracker 
  469. 		Current_page = Current_page + 1 
  470. 	else 
  471. 		-- Possibly play some "no-no" sound effect 
  472. 		ui_audio_post_event("UI_Hub_Navigate") 
  473. 		return 
  474. 	end 
  475.  
  476. 	if UI_METHOD then 
  477. 	-------------------------------------------------- 
  478. 	--												-- 
  479. 	--					** UI Method **				-- 
  480. 	--												-- 
  481. 	-------------------------------------------------- 
  482. 	 
  483. 		-- Jump to the new frame and set the new callback frame 
  484. 		vint_set_property( Video1_h, "frame", frame_num ) 
  485. 		vint_set_property( Video1_h, "frame_event_num", frame_event_num ) 
  486.  
  487. 		-- Resume playing the video 
  488. 		vint_set_property( Video1_h, "is_paused", false ) 
  489.  
  490. 	-------------------------------------------------- 
  491. 	--												-- 
  492. 	--				**End UI Method **				-- 
  493. 	--												-- 
  494. 	-------------------------------------------------- 
  495. 	else 
  496. 	-------------------------------------------------- 
  497. 	--												-- 
  498. 	--			** In Cutscene Method **			-- 
  499. 	--												-- 
  500. 	-------------------------------------------------- 
  501. 	 
  502. 		local cutscene_bink_handle = get_cutscene_bink_handle() 
  503. 		-- Jump to the new frame and set the new callback frame 
  504. 		--video_player_vint_goto_frame(cutscene_bink_handle, frame_num) 
  505. 		video_player_vint_goto_nearest_keyframe(cutscene_bink_handle, frame_num) 
  506. 		video_player_vint_update_lua_frame_event_num(cutscene_bink_handle, frame_event_num) 
  507. 	 
  508. 		-- Resume playing the video 
  509. 		video_player_vint_pause(cutscene_bink_handle, false) 
  510. 	 
  511. 	-------------------------------------------------- 
  512. 	--												-- 
  513. 	--			**End Cutscene Method **			-- 
  514. 	--												-- 
  515. 	-------------------------------------------------- 
  516. 	end 
  517. 	-- SFX 
  518. 	ui_audio_post_event("UI_Hub_Navigate") 
  519. end 
  520.  
  521.  
  522. function cte_outro_ending_confirm_select() 
  523. 	--Valid purchase 
  524. 	confirm_box:set_visible(true) 
  525. 	confirm_box:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)				 
  526. 	confirm_box:set_title("MENU_TITLE_CONFIRM")		 
  527. 	confirm_box:set_text("OUTRO_ENDING_CONFIRM")		 
  528. 	confirm_box:nav_enable(true, "cte_outro_confirm", "cte_outro_popup_nav")	 
  529. 	cte_outro_enable_mouse(false) 
  530. 	game_UI_audio_play("UI_HUD_HELP") 
  531. end 
  532.  
  533. function cte_outro_confirm(event) 
  534. 	cte_outro_enable_mouse(true) 
  535.  
  536. 	confirm_box:nav_enable(false, nil, nil) 
  537. 	 
  538. 	-- The user hit the B button and are cancelling the purchase 
  539. 	-- This is the same as selecting "No" in the list 
  540. 	if event == "back" or confirm_box:get_selected_data() ~= 1 then 
  541. 		 
  542. 		confirm_box:set_visible(false) 
  543. 		 
  544. 		return 
  545. 	end 
  546.  
  547. 	cte_outro_ending_select() 
  548. 	finished_outro_selection() 
  549. end 
  550.  
  551. -- Handles navigation of any popups 
  552. function cte_outro_popup_nav(event, value) 
  553. 	if event == "nav_up" then	 
  554. 		confirm_box.list:move_cursor(-1)	 
  555. 	elseif event == "nav_down" then 
  556. 		confirm_box.list:move_cursor(1) 
  557. 	elseif event == "mouse_move" then 
  558. 		-- value contains the target_handle in this case 
  559. 		local new_index = confirm_box.list:get_button_index(value) 
  560. 		if new_index ~= 0 then 
  561. 			confirm_box.list:set_selection(new_index) 
  562. 			confirm_box.list:move_cursor(0, true) 
  563. 		end 
  564. 	else 
  565. 		--do nothing 
  566. 	end 
  567. end 
  568.  
  569. -- Selection handler 
  570. -- Stubbed in for now... 
  571. function cte_outro_ending_select(page_num) 
  572. 	set_debug_text( "Select!" ) 
  573.  
  574. 	--Input_tracker:remove_all() 
  575.  
  576. 	local is_client = outro_is_client() 
  577. 	if not is_client then 
  578. 		outro_send_multiplayer_select_event(Current_page); 
  579. 	end  
  580.  
  581. 	outro_did_selection() 
  582.  
  583. 	vint_set_property(text_area_h, "visible", false) 
  584. 	text_hint:set_visible(false) 
  585. 	vint_set_property(leftArrowBase_h, "visible", false) 
  586. 	vint_set_property(rightArrowBase_h, "visible", false) 
  587. 	vint_set_property( text_coop_desc, "visible", false ) 
  588. 	 
  589. 	if page_num ~= nil then 
  590. 		Current_page = page_num 
  591. 	end 
  592.  
  593.  
  594. 		local cutscene_bink_handle = get_cutscene_bink_handle() 
  595.  
  596. 	video_player_vint_set_next_video(Ending_Cutscenes[Current_page]) 
  597. 	--video_player_vint_stop_video(cutscene_bink_handle) 
  598.  
  599. 	finished_outro_selection() 
  600.  
  601. 	if not is_client then 
  602. 	--Input_tracker:add_input("select", "cte_outro_ending_handle_input", 1) 
  603. 		Input_tracker:remove_all() 
  604. 		Input_tracker:subscribe( false ) 
  605. 		cte_outro_enable_mouse(false) 
  606. 	end 
  607. end 
  608.  
  609.  
  610. -- Standard cleanup 
  611. function cte_outro_ending_cleanup() 
  612.  
  613. 	text_hint:cleanup() 
  614. 	confirm_box:cleanup() 
  615. 	-- Nuke all button subscriptions 
  616. 	if Input_tracker ~= -1 then 
  617. 		Input_tracker:remove_all() 
  618. 		Input_tracker:subscribe( false ) 
  619. 	end 
  620.  
  621. 	if Mouse_input_tracker ~= -1 then 
  622. 		Mouse_input_tracker:remove_all() 
  623. 		Mouse_input_tracker:subscribe( false ) 
  624. 	end 
  625.  
  626. 	-- Stop the video 
  627. 	--vint_set_property( Video1_h, "is_stopped", true ) 
  628. end 
  629.  
  630. function cte_outro_start_video() 
  631.  
  632. 	-- Setup the video element 
  633. 	cte_outro_ending_init_video() 
  634.  
  635. 	-- The video is currently authored such that the player starts 
  636. 	-- interacting with the Storybook from the last page. 
  637. 	Current_page = Num_pages 
  638. 	initial_bink_portion = true; 
  639.  
  640. 	if not UI_METHOD then 
  641. 		--pause_video() 
  642. 	end 
  643. 	 
  644. 	if UI_METHOD then 
  645. 	-------------------------------------------------- 
  646. 	--												-- 
  647. 	--					** UI Method **				-- 
  648. 	--												-- 
  649. 	-------------------------------------------------- 
  650.  
  651. 		vint_set_property( Video1_h, "is_paused", false ) 
  652. 		vint_set_property( Video1_h, "frame", Start_frame ) 
  653. 		vint_set_property( Video1_h, "visible", true ) 
  654.  
  655. 	-------------------------------------------------- 
  656. 	--												-- 
  657. 	--				**End UI Method **				-- 
  658. 	--												-- 
  659. 	-------------------------------------------------- 
  660. 	end 
  661.  
  662. 	-- Setup input tracker 
  663. 	local is_client = outro_is_client() 
  664. 	if not is_client then 
  665. 		cte_outro_ending_init_input() 
  666. 	end 
  667. end 
  668.  
  669.  
  670. -- Pause the video 
  671. -- This is the primary callback function 
  672. function pause_video() 
  673. 	set_debug_text( "Paused" ) 
  674.  
  675. 	if UI_METHOD then 
  676. 	-------------------------------------------------- 
  677. 	--												-- 
  678. 	--					** UI Method **				-- 
  679. 	--												-- 
  680. 	-------------------------------------------------- 
  681.  
  682. 		-- Pause the video 
  683. 		vint_set_property( Video1_h, "is_paused", true ) 
  684.  
  685. 		-- Invalidate the frame_event_num so we don't accidentally trigger the callback function (this) 
  686. 		vint_set_property( Video1_h, "frame_event_num", -1 ) 
  687.  
  688. 		--]] 
  689. 	-------------------------------------------------- 
  690. 	--												-- 
  691. 	--				**End UI Method **				-- 
  692. 	--												-- 
  693. 	-------------------------------------------------- 
  694. 	else 
  695. 	-------------------------------------------------- 
  696. 	--												-- 
  697. 	--			** In Cutscene Method **			-- 
  698. 	--												-- 
  699. 	-------------------------------------------------- 
  700.  
  701. 		local cutscene_bink_handle = get_cutscene_bink_handle() 
  702.  
  703. 		-- Pause the video 
  704. 		video_player_vint_pause(cutscene_bink_handle, true) 
  705. 				audio_object_post_event( "Play_SRG_end_selection_music_lp" ) 
  706.  
  707. 		-- Invalidate the frame_event_num so we don't accidentally trigger the callback function (this) 
  708. 		video_player_vint_update_lua_frame_event_num(cutscene_bink_handle, -1) 
  709.  
  710. 	-------------------------------------------------- 
  711. 	--												-- 
  712. 	--			**End Cutscene Method **			-- 
  713. 	--												-- 
  714. 	-------------------------------------------------- 
  715. 	end 
  716.  
  717. 	local is_client = outro_is_client() 
  718. 	if not is_client then 
  719. 		vint_set_property(leftArrowBase_h, "visible", false) 
  720. 		vint_set_property(rightArrowBase_h, "visible", false) 
  721. 		vint_set_property(leftArrowHighlight_h, "visible", true) 
  722. 		vint_set_property(rightArrowHighlight_h, "visible", true) 
  723.  
  724. 		if ( Current_page ~= 5 ) then 
  725. 			vint_set_property(rightArrowBase_h, "visible", true) 
  726. 			local right_fade_animation = vint_object_find( "Arrow_Right_Fade_In", 0, Cte_outro_ending_doc_handle  ) 
  727. 			lua_play_anim( right_fade_animation, 0, Cte_outro_ending_doc_handle ) 
  728. 			--vint_set_property(rightArrowBase_h, "visible", true) 
  729. 		end  
  730.  
  731. 		if ( Current_page ~= 1 ) then 
  732. 			vint_set_property(leftArrowBase_h, "visible", true) 
  733. 			local left_fade_animation = vint_object_find( "Arrow_Left_Fade_In", 0, Cte_outro_ending_doc_handle  ) 
  734. 			lua_play_anim( left_fade_animation, 0, Cte_outro_ending_doc_handle ) 
  735. 			--vint_set_property(leftArrowBase_h, "visible", true) 
  736. 		end 
  737.  
  738. 		text_hint:set_visible(true) 
  739. 		--text_ending_desc:set_text(Ending_Text[Current_page].label) 
  740. 	else 
  741. 		vint_set_property( text_coop_desc, "visible", true ) 
  742. 	end 
  743.  
  744. 	-- set up text 
  745. 	vint_set_property(text_area_h, "visible", true) 
  746. 	vint_set_property(text_ending_desc, "text_tag", Ending_Text[Current_page].label) 
  747. end 
  748.  
  749. -- Close out this menu and roll credits 
  750.  
  751. function roll_credits() 
  752. 	set_debug_text( "Roll Credits" ) 
  753.  
  754. 	finished_outro_selection(); 
  755.  
  756. 	if UI_METHOD then 
  757. 	-------------------------------------------------- 
  758. 	--												-- 
  759. 	--					** UI Method **				-- 
  760. 	--												-- 
  761. 	-------------------------------------------------- 
  762.  
  763. 		-- Pause the video 
  764. 		vint_set_property( Video1_h, "is_paused", true ) 
  765.  
  766. 		-- Invalidate the frame_event_num so we don't accidentally trigger the callback function (this) 
  767. 		vint_set_property( Video1_h, "frame_event_num", -1 ) 
  768.  
  769. 	 
  770. 	-------------------------------------------------- 
  771. 	--												-- 
  772. 	--				**End UI Method **				-- 
  773. 	--												-- 
  774. 	-------------------------------------------------- 
  775. 	else 
  776. 	-------------------------------------------------- 
  777. 	--												-- 
  778. 	--			** In Cutscene Method **			-- 
  779. 	--												-- 
  780. 	-------------------------------------------------- 
  781.  
  782. 		local cutscene_bink_handle = get_cutscene_bink_handle() 
  783.  
  784. 		-- Pause the video 
  785. 		video_player_vint_pause(cutscene_bink_handle, true) 
  786.  
  787. 		-- Invalidate the frame_event_num so we don't accidentally trigger the callback function (this) 
  788. 		video_player_vint_update_lua_frame_event_num(cutscene_bink_handle, -1) 
  789.  
  790. 	-------------------------------------------------- 
  791. 	--												-- 
  792. 	--			**End Cutscene Method **			-- 
  793. 	--												-- 
  794. 	-------------------------------------------------- 
  795. 	end 
  796.  
  797. end 
  798.  
  799. -- Print some debug text to the screen 
  800. function set_debug_text( text ) 
  801. 	vint_set_property( Debug_text_h, "text_tag", text ) 
  802. end 
  803.  
  804. function cte_outro_enable_mouse(enable) 
  805. 	if game_get_platform() == "PC" and enable ~= nil then 
  806. 		if Mouse_input_tracker ~= 0 then 
  807. 			Mouse_input_tracker:subscribe(enable) 
  808. 		end 
  809. 		 
  810. 	end 
  811. end 
  812.