./msn_killbane.lua

  1. --This interface is used in the Mission 21 Killbane Mask removal sequence. 
  2.  
  3. local Input_tracker  
  4. local Mouse_input_tracker = 0 
  5. local Option_selected = -1 
  6.  
  7. local KILLBANE_OPTION_REMOVE_MASK = 0 
  8. local KILLBANE_OPTION_LET_GO = 1 
  9.  
  10. local Pressed_left_image = -1 
  11. local Pressed_right_image = -1 
  12. local Image_left_h 		= -1 
  13. local Image_right_h 		= -1 
  14.  
  15. local Msn_killbane_gamepad_listener = -1 
  16.  
  17. function msn_killbane_init() 
  18. 	local platform = game_get_platform() 
  19. 	 
  20. 	local option1_text, option1_body, option2_text, option2_body = msn_killbane_get_option_text() 
  21. 	 
  22. 	vint_set_property( vint_object_find( "text_left_title" ), "text_tag_crc", option1_text ) 
  23. 	vint_set_property( vint_object_find( "text_left_body" ), "text_tag_crc", option1_body ) 
  24. 	vint_set_property( vint_object_find( "text_right" ), "text_tag_crc", option2_text ) 
  25. 	vint_set_property( vint_object_find( "text_right_body" ), "text_tag_crc", option2_body ) 
  26.  
  27. 	--Do input subscription... 
  28. 	Input_tracker = Vdo_input_tracker:new() 
  29. 	-- Button images 
  30. 	Image_left_h = vint_object_find("button_left_img") 
  31. 	Image_right_h = vint_object_find("button_right_img") 
  32.  
  33. 	-- Different inputs for PC only (when gamepad is not active) 
  34. 	if game_is_active_input_gamepad() == false then 
  35. 		Input_tracker:add_input("key_left", "msn_killbane_nav", 50) 
  36. 		Input_tracker:add_input("key_right", "msn_killbane_nav", 50) 
  37. 		Input_tracker:add_input("nav_left", "msn_killbane_nav", 50) 
  38. 		Input_tracker:add_input("nav_right", "msn_killbane_nav", 50) 
  39. 		 
  40. 		vint_set_property(Image_left_h, "image", "ui_pc_qte_arrow_off") 
  41. 		vint_set_property(Image_right_h, "image", "ui_pc_qte_arrow_off") 
  42. 		 
  43. 		--Store to use for replacement later... 
  44. 		Pressed_left_image = "ui_pc_qte_arrow_on" 
  45. 		Pressed_right_image = "ui_pc_qte_arrow_on" 
  46. 		 
  47. 		vint_set_property(Image_left_h, "scale", -1.0, 1.0) 
  48. 	else 
  49. 		Input_tracker:add_input("scroll_left", "msn_killbane_nav", 50) 
  50. 		Input_tracker:add_input("scroll_right", "msn_killbane_nav", 50) 
  51. 	 
  52. 		if platform == "PS3" then 
  53. 			vint_set_property(Image_left_h, "image", "ui_qte_l1_up_ps3") 
  54. 			vint_set_property(Image_right_h, "image", "ui_qte_r1_up_ps3") 
  55.  
  56. 			--Store to use for replacement later... 
  57. 			Pressed_left_image = "ui_qte_l1_down_ps3" 
  58. 			Pressed_right_image = "ui_qte_r1_down_ps3" 
  59. 		else 
  60. 			vint_set_property(Image_left_h, "image", "ui_qte_lt_up_xbox2") 
  61. 			vint_set_property(Image_right_h, "image", "ui_qte_rt_up_xbox2") 
  62. 			 
  63. 			--Store to use for replacement later... 
  64. 			Pressed_left_image = "ui_qte_lt_down_xbox2" 
  65. 			Pressed_right_image = "ui_qte_rt_down_xbox2"		 
  66. 		end 
  67. 	end 
  68. 	 
  69. 	Input_tracker:subscribe(true) 
  70.  
  71. 	if game_get_platform() == "PC" then 
  72. 		Mouse_input_tracker = Input_tracker:new() 
  73. 		msn_killbane_mouse_input_add() 
  74. 		 
  75. 		Msn_killbane_gamepad_listener = vint_scriptevent_listen( "gamepad_active", "msn_killbane_update_gamepad_state" ) 
  76. 	end 
  77.  
  78. 	 
  79. 	--Hide screen 
  80. 	local screen_grp_h = vint_object_find("screen_grp") 
  81. 	vint_set_property(screen_grp_h, "alpha", 0) 
  82. 	 
  83. 	--Fade in screen 
  84. 	local anim_h = vint_object_find("fade_in_anim") 
  85. 	lua_play_anim(anim_h) 
  86. 	 
  87. 	local anim_h = vint_object_find("fade_out_anim") 
  88. 	local twn_h  = vint_object_find("fade_out_twn", anim_h) 
  89. 	vint_set_property(twn_h, "end_event", "msn_killbane_select") 
  90. 	 
  91. 	-- hide this stuff if the game pauses 
  92. 	vint_dataitem_add_subscription("game_paused_item", "update", "msn_killbane_game_is_paused")	--to check if game is paused... 
  93. end 
  94.  
  95. function msn_killbane_cleanup() 
  96. 	Input_tracker:subscribe(false) 
  97. 	Input_tracker:remove_all() 
  98. 	 
  99. 	if game_get_platform() == "PC" then 
  100. 		Mouse_input_tracker:subscribe(false) 
  101. 		Mouse_input_tracker:remove_all() 
  102. 		vint_scriptevent_stop_listening( Msn_killbane_gamepad_listener ) 
  103. 	end 
  104. end 
  105.  
  106. function msn_killbane_game_is_paused(di_h) 
  107. 	local is_paused = vint_dataitem_get(di_h) 
  108. 	 
  109. 	local screen_grp_h = vint_object_find("screen_grp") 
  110. 	vint_set_property(screen_grp_h, "visible", is_paused == false) 
  111. end 
  112.  
  113. ------------------------------------------------------------------------------- 
  114. -- Input 
  115. ------------------------------------------------------------------------------- 
  116. function msn_killbane_nav(event) 
  117. 	if Option_selected == -1 then 
  118. 		if event == "scroll_right" or event == "key_right" or event == "nav_right" then 
  119. 			Option_selected = KILLBANE_OPTION_REMOVE_MASK 
  120. 			vint_set_property(Image_right_h, "image", Pressed_right_image) 
  121. 		elseif event == "scroll_left" or event == "key_left" or event == "nav_left" then 
  122. 			Option_selected = KILLBANE_OPTION_LET_GO 
  123. 			vint_set_property(Image_left_h, "image", Pressed_left_image) 
  124. 		end 
  125. 		local anim_h = vint_object_find("fade_out_anim") 
  126. 		lua_play_anim(anim_h) 
  127. 	end 
  128. end 
  129.  
  130. ------------------------------------------------------------------------------- 
  131. -- Callback from fade out animation tells the game we are finished,  
  132. -- what option we've selected and pops screen... 
  133. ------------------------------------------------------------------------------- 
  134. function msn_killbane_select() 
  135. 	--Tell game which option we've selected... 
  136. 	msn_killbane_selected_option(Option_selected) 
  137. 	--and Pop screen 
  138. 	pop_screen() 
  139. end 
  140.  
  141.  
  142. function msn_killbane_mouse_input_add() 
  143. 	Mouse_input_tracker:add_mouse_input("mouse_click", "msn_killbane_mouse_click", 50, Image_left_h) 
  144. 	Mouse_input_tracker:add_mouse_input("mouse_click", "msn_killbane_mouse_click", 50, Image_right_h) 
  145. 	Mouse_input_tracker:subscribe(true) 
  146. end 
  147.  
  148. ------------------------------------------------------------------------------- 
  149. -- Mouse inputs 
  150. function msn_killbane_mouse_click(event, target_handle, mouse_x, mouse_y) 
  151. 	if target_handle == Image_right_h then 
  152. 		msn_killbane_nav("key_right") 
  153. 	elseif target_handle == Image_left_h then 
  154. 		msn_killbane_nav("key_left") 
  155. 	end 
  156. end 
  157.  
  158. function msn_killbane_mouse_move(event, target_handle) 
  159. end 
  160.  
  161. --[[ --------------------------------------------------------------------- 
  162. -- Function - msn_killbane_update_gamepad_state 
  163. -- Description - Called by code anytime gamepad is plugged or unplugged. 
  164. -- Parameters - none 
  165. -- Returns - nil 
  166. ]]-- --------------------------------------------------------------------- 
  167. function msn_killbane_update_gamepad_state() 
  168. 	 
  169. 	Input_tracker:subscribe(false) 
  170. 	Input_tracker:remove_all() 
  171. 	 
  172. 	if game_get_platform() == "PC" then 
  173. 		Mouse_input_tracker:subscribe(false) 
  174. 		Mouse_input_tracker:remove_all() 
  175. 	end 
  176. 	 
  177. 	-- Different inputs for PC only (when gamepad is not active) 
  178. 	if game_is_active_input_gamepad() == false then 
  179. 		Input_tracker:add_input("key_left", "msn_killbane_nav", 50) 
  180. 		Input_tracker:add_input("key_right", "msn_killbane_nav", 50) 
  181. 		Input_tracker:add_input("nav_left", "msn_killbane_nav", 50) 
  182. 		Input_tracker:add_input("nav_right", "msn_killbane_nav", 50) 
  183. 		 
  184. 		vint_set_property(Image_left_h, "image", "ui_pc_qte_arrow_off") 
  185. 		vint_set_property(Image_right_h, "image", "ui_pc_qte_arrow_off") 
  186. 		 
  187. 		--Store to use for replacement later... 
  188. 		Pressed_left_image = "ui_pc_qte_arrow_on" 
  189. 		Pressed_right_image = "ui_pc_qte_arrow_on" 
  190. 		 
  191. 		vint_set_property(Image_left_h, "scale", -1.0, 1.0) 
  192. 	else 
  193. 		Input_tracker:add_input("scroll_left", "msn_killbane_nav", 50) 
  194. 		Input_tracker:add_input("scroll_right", "msn_killbane_nav", 50) 
  195. 		 
  196. 		vint_set_property(Image_left_h, "image", "ui_qte_lt_up_xbox2") 
  197. 		vint_set_property(Image_right_h, "image", "ui_qte_rt_up_xbox2") 
  198. 		 
  199. 		--Store to use for replacement later... 
  200. 		Pressed_left_image = "ui_qte_lt_down_xbox2" 
  201. 		Pressed_right_image = "ui_qte_rt_down_xbox2" 
  202. 		vint_set_property(Image_left_h, "scale", 1.0, 1.0)		 
  203. 	end 
  204. 	 
  205. 	Input_tracker:subscribe(true) 
  206.  
  207. 	if game_get_platform() == "PC" then 
  208. 		msn_killbane_mouse_input_add() 
  209. 	end 
  210. end