./hud_btnmash.lua

  1.  
  2. --BUTTON MASH TYPES... 
  3. local BUTTON_MASH_HIDDEN						= -1 
  4. local BUTTON_MASH_A								= 0 
  5. local BUTTON_MASH_X								= 1 
  6. local BUTTON_MASH_Y 								= 2	 
  7. local BUTTON_MASH_ROTATE_LS_LEFT				= 3 
  8. local BUTTON_MASH_ROTATE_LS_RIGHT			= 4 
  9. local BUTTON_MASH_ROTATE_RS_LEFT				= 5 
  10. local BUTTON_MASH_ROTATE_RS_RIGHT			= 6 
  11.  
  12. --Button mashing states... 
  13. local HUD_BTNMASH_STATE_HIDDEN 		= -1	--used internally... 
  14. local HUD_BTNMASH_STATE_UPDATE 		= 1 
  15. local HUD_BTNMASH_STATE_SUCCESS 		= 2 
  16. local HUD_BTNMASH_STATE_FAIL 			= 3 
  17. local HUD_BTNMASH_STATE_HIDE	 		= 4 
  18.  
  19. Hud_btnmash_platform_is_ps3 = false 
  20. local HUD_BTNMASH_COLOR_DIM = {128/255, 128/255, 128/255} 
  21. local HUD_BTNMASH_STICK_OFFSET = -18 
  22.  
  23. ------------------------------------------------------------------------------- 
  24. --Handles 
  25. ------------------------------------------------------------------------------- 
  26. --Base groups 
  27. local Hud_btnmash_fail_grp_h 				= 0 
  28. local Hud_btnmash_win_grp_h 				= 0 
  29. local Hud_btnmash_btn_mash_grp_h 		= 0 
  30.  
  31. -- Left Stick 
  32. local Hud_btnmash_stick_ls_grp_h			= 0 
  33. local Hud_btnmash_stick_ls_base_bmp_h	= 0 
  34. local Hud_btnmash_stick_ls_pad_h			= 0 
  35. local Hud_btnmash_stick_ls_label_h		= 0 
  36.  
  37.  
  38. -- Right Stick 
  39. local Hud_btnmash_stick_rs_grp_h			= 0 
  40. local Hud_btnmash_stick_rs_base_bmp_h	= 0 
  41. local Hud_btnmash_stick_rs_pad_h			= 0 
  42. local Hud_btnmash_stick_rs_label_h		= 0 
  43.  
  44.  
  45. -- Button 
  46. local Hud_btnmash_btn_grp_h				= 0 
  47. local Hud_btnmash_btn_1_h					= 0 
  48. local Hud_btnmash_btn_2_h					= 0 
  49.  
  50. -- Mouse 
  51. local Hud_btnmash_mouse_grp_h				= 0 
  52.  
  53. -- Key 
  54. local Hud_btnmash_key_grp_h 				= 0 
  55. local Hud_btnmash_pc_key					= 0 
  56.  
  57. -- Meter 
  58. local Hud_btnmash_meter_grp_h 			= 0 
  59. local Hud_btnmash_meter_bg_h 				= 0 
  60. local Hud_btnmash_meter_fill_h 			= 0 
  61. local Hud_btnmash_meter_fill_bg_h 		= 0 
  62.  
  63. -- Timer 
  64. local Hud_btnmash_timer_grp_h				= 0 
  65. local Hud_btnmash_timer_txt_h				= 0 
  66. local Hud_btnmash_meter_fill_h			= 0 
  67. local Hud_btnmash_meter_fill_h			= 0 
  68.  
  69. -- Help Text 
  70. local Hud_btnmash_help_txt_grp_h			= 0 
  71. local Hud_btnmash_help_txt_h				= 0 
  72. local Hud_btnmash_help_txt_bg_h			= 0 
  73.  
  74. -- Mash/Rotate Animations 
  75. local Hud_btn_mash_btn_mash_anim_h 						= 0 
  76. local Hud_btn_mash_ls_rotate_left_anim_h 				= 0  
  77. local Hud_btn_mash_ls_rotate_right_anim_h				= 0 
  78. local Hud_btn_mash_rs_rotate_left_anim_h				= 0 
  79. local Hud_btn_mash_rs_rotate_right_anim_h				= 0 
  80. local Hud_btn_mash_btnmash_fade_in_anim_h				= 0 
  81. local Hud_btn_mash_btnmash_fade_out_anim_h			= 0 
  82. local Hud_btn_mash_mouse_left_anim_h					= 0 
  83. local Hud_btn_mash_mouse_right_anim_h		         = 0 
  84.  
  85.  
  86. --Fade/State Animations 
  87. local Hud_btn_mash_fade_in_anim_h 			= 0 
  88. local Hud_btn_mash_fade_out_anim_h			= 0 
  89. local Hud_btn_mash_fail_anim_h				= 0 
  90. local Hud_btn_mash_success_anim_h			= 0 
  91.  
  92. --Global State variables 
  93. local Hud_btnmash_button_index 	= -2 
  94. local Hud_btnmash_help_txt 		= -1 
  95. local Hud_btnmash_meter_pct 		= -1 
  96. local Hud_btnmash_timer_value 	= -1 
  97. local Hud_btnmash_state  			= -1 
  98.  
  99. --Scale base for the meter fill... 
  100. local Hud_btnmash_meter_base_width 	= 1  
  101. local Hud_btnmash_meter_base_height = 1 
  102.  
  103. ------------------------------------------------------------------------------- 
  104. -- Init  
  105. -- 
  106. function hud_btnmash_init() 
  107.  
  108. 	local hud_btnmash_doc_h = vint_document_find("hud_btnmash") 
  109. 	 
  110. 	--get the platform 
  111. 	local platform = game_get_platform() 
  112. 	if platform == "XBOX360" then 
  113. 		Hud_btnmash_platform_is_ps3 = false 
  114. 	elseif platform == "PS3" then 
  115. 		Hud_btnmash_platform_is_ps3 = true 
  116. 	end 
  117. 	 
  118. 	--Find handles to everything... 
  119. 	 
  120. 	--Base groups 
  121. 	Hud_btnmash_fail_grp_h 				= vint_object_find("fail_grp") 
  122. 	Hud_btnmash_win_grp_h 		      = vint_object_find("win_grp") 
  123. 	Hud_btnmash_btn_mash_grp_h       = vint_object_find("btn_mash_grp") 
  124. 	 
  125. 	--Left Stick 
  126. 	Hud_btnmash_stick_ls_grp_h			= vint_object_find("stick_ls_grp") 
  127. 	Hud_btnmash_stick_ls_pad_h			= vint_object_find("stick_ls_pad") 
  128. 	Hud_btnmash_stick_ls_label_h		= vint_object_find("stick_ls_label") 
  129. 	Hud_btnmash_stick_ls_base_bmp_h	= vint_object_find("stick_ls_base_bmp") 
  130.  
  131. 	--Right Stick 
  132. 	Hud_btnmash_stick_rs_grp_h			= vint_object_find("stick_rs_grp") 
  133. 	Hud_btnmash_stick_rs_pad_h			= vint_object_find("stick_rs_pad") 
  134. 	Hud_btnmash_stick_rs_label_h		= vint_object_find("stick_rs_label") 
  135. 	Hud_btnmash_stick_rs_base_bmp_h	= vint_object_find("stick_rs_base_bmp") 
  136.  
  137. 	-- Button 
  138. 	Hud_btnmash_btn_grp_h				= vint_object_find("btn_grp") 
  139. 	Hud_btnmash_btn_1_h					= vint_object_find("btn_1") 
  140. 	Hud_btnmash_btn_2_h					= vint_object_find("btn_2") 
  141. 	 
  142. 	-- Mouse and keyboard 
  143. 	Hud_btnmash_mouse_grp_h				= vint_object_find("mouse_rotate_grp") 
  144. 	Hud_btnmash_key_grp_h				= vint_object_find("key_grp") 
  145.  
  146. 	--Meter 
  147. 	Hud_btnmash_meter_grp_h 			= vint_object_find("meter_grp") 
  148. 	Hud_btnmash_meter_bg_h 				= vint_object_find("meter_bg") 
  149. 	Hud_btnmash_meter_fill_h 			= vint_object_find("meter_fill") 
  150. 	Hud_btnmash_meter_fill_bg_h 		= vint_object_find("meter_fill_bg") 
  151.  
  152. 	--Timer 
  153. 	Hud_btnmash_timer_grp_h				= vint_object_find("timer_grp") 
  154. 	Hud_btnmash_timer_txt_h				= vint_object_find("timer_txt") 
  155. 	Hud_btnmash_meter_fill_h			= vint_object_find("meter_fill") 
  156. 	Hud_btnmash_meter_fill_h			= vint_object_find("meter_fill") 
  157. 		 
  158. 	--Help Text 
  159. 	Hud_btnmash_help_txt_grp_h			= vint_object_find("help_txt_grp") 
  160. 	Hud_btnmash_help_txt_h				= vint_object_find("help_txt") 
  161. 	Hud_btnmash_help_txt_bg_h			= vint_object_find("help_txt_bg") 
  162.  
  163. 	--Animations 
  164. 	Hud_btn_mash_btn_mash_anim_h 				= vint_object_find("btn_mash_anim") 
  165. 	Hud_btn_mash_ls_rotate_left_anim_h 		= vint_object_find("ls_rotate_left_anim") 
  166. 	Hud_btn_mash_ls_rotate_right_anim_h		= vint_object_find("ls_rotate_right_anim") 
  167. 	Hud_btn_mash_rs_rotate_left_anim_h		= vint_object_find("rs_rotate_left_anim") 
  168. 	Hud_btn_mash_rs_rotate_right_anim_h		= vint_object_find("rs_rotate_right_anim") 
  169. 	Hud_btn_mash_mouse_left_anim_h			= vint_object_find("mouse_rotate_left_anim") 
  170. 	Hud_btn_mash_mouse_right_anim_h			= vint_object_find("mouse_rotate_right_anim") 
  171.  
  172. 	--State Animations 
  173. 	Hud_btn_mash_fade_in_anim_h				= vint_object_find("fade_in_anim") 
  174. 	Hud_btn_mash_fade_out_anim_h				= vint_object_find("fade_out_anim") 
  175. 	Hud_btn_mash_fail_anim_h					= vint_object_find("fail_anim") 
  176. 	Hud_btn_mash_success_anim_h				= vint_object_find("btn_mash_success_anim") 
  177. 	 
  178. 	 
  179. 	--These tweens get played when we are done, these are used to tell the game we are finished displaying the UI. 
  180. 	local success_end_twn_h = vint_object_find("success_end_twn") 
  181. 	local fail_end_twn_h = vint_object_find("fail_end_twn") 
  182. 	local fade_out_twn_h = vint_object_find("fade_out_twn") 
  183. 	 
  184. 	vint_set_property(success_end_twn_h, 	"end_event", "hud_btnmash_complete") 
  185. 	vint_set_property(fail_end_twn_h, 		"end_event", "hud_btnmash_complete") 
  186. 	vint_set_property(fade_out_twn_h, 		"end_event", "hud_btnmash_complete") 
  187. 	 
  188. 	--setup looping tweens for button mash (sticks loop normally) 
  189. 	local btn_1_off_standard_twn_h = vint_object_find("btn_1_off_standard", Hud_btn_mash_btn_mash_anim_h) 
  190. 	vint_set_property(btn_1_off_standard_twn_h, "end_event", "vint_anim_loop_callback") 
  191.  
  192. 	--Initialize QTE key 
  193. 	Hud_btnmash_pc_key = Vdo_qte_key:new("pc_key", 0, hud_btnmash_doc_h) 
  194. 	Hud_btnmash_pc_key:set_text(game_get_key_name_for_action("CBA_OFC_JUMP_CLIMB")) 
  195.  
  196. 	local width = Hud_btnmash_pc_key:get_width() 
  197. 	local x, y = vint_get_property(Hud_btnmash_pc_key.handle, "anchor") 
  198. 	vint_set_property(Hud_btnmash_pc_key.handle, "anchor", -(width * 0.5), y) 
  199. 	 
  200. 	--Initialize Meter Variables 
  201. 	Hud_btnmash_meter_base_width, Hud_btnmash_meter_base_height = vint_get_property(Hud_btnmash_meter_fill_bg_h, "scale") 
  202. 	 
  203. 	--localize text 
  204. 	local fail_txt_h = vint_object_find("fail_txt") 
  205. 	local win_txt_h = vint_object_find("win_txt") 
  206. 	vint_set_property(fail_txt_h, "text_tag", "FAILED!") 
  207. 	vint_set_property(win_txt_h, "text_tag", "SUCCESS!") 
  208. 	 
  209. 	vint_set_property(Hud_btnmash_fail_grp_h, "alpha", 0) 
  210. 	vint_set_property(Hud_btnmash_win_grp_h, "alpha", 0)		   
  211. 	vint_set_property(Hud_btnmash_btn_mash_grp_h, "alpha", 0)    
  212. 	 
  213. 	--subscription 
  214. 	vint_dataitem_add_subscription("button_mashing_minigame", "update", "hud_btnmash_update") 
  215. 	Hud_btnmash_button_index = -1 
  216. end 
  217.  
  218. ------------------------------------------------------------------------------- 
  219. -- Cleanup 
  220. -- 
  221. function hud_btnmash_cleanup() 
  222. end 
  223.  
  224. ------------------------------------------------------------------------------- 
  225. -- Dataitem update for button mashing. 
  226. -- button index 	- Button image to display from BUTTON MASH TYPES enums. 
  227. -- help_text 		- display string ID 
  228. -- meter_pct 		- percentage (0-1) complete 
  229. -- timer_value 	- time remaining in minigame. 
  230. -- state				- [1 = update, 2 = success, 3 = fail, 4 = hide] (Button mashing states) 
  231. -- 
  232. ------------------------------------------------------------------------------- 
  233. function hud_btnmash_update(di_h, event) 
  234.  
  235. 	local button_index, help_txt, meter_pct, timer_value, state  = vint_dataitem_get(di_h) 
  236.  
  237. 	if Hud_btnmash_button_index ~= button_index then 
  238. 		-- Set button images 
  239. 		if (Hud_btnmash_platform_is_ps3 == true) then		 
  240. 			-- use PS3 button images 
  241. 			if			(button_index == BUTTON_MASH_A) then -- CROSS 
  242. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_cross_up_ps3") 
  243. 				vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_cross_down_ps3")													 
  244. 			elseif	(button_index == BUTTON_MASH_X) then -- SQUARE 
  245. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_square_up_ps3") 
  246. 				vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_square_down_ps3") 
  247. 			elseif	(button_index == BUTTON_MASH_Y) then -- TRIANGLE 
  248. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_triangle_up_ps3") 
  249. 				vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_triangle_down_ps3") 
  250. 			elseif	(button_index >= BUTTON_MASH_ROTATE_LS_LEFT and button_index <= BUTTON_MASH_ROTATE_RS_RIGHT ) then --Stick		 
  251. 				 
  252. 				vint_set_property(Hud_btnmash_stick_ls_pad_h, 		"image", "ui_qte_stick_ps3") 
  253. 				vint_set_property(Hud_btnmash_stick_ls_base_bmp_h, "image", "ui_qte_base_ps3") 
  254.  
  255. 				vint_set_property(Hud_btnmash_stick_rs_pad_h, 		"image", "ui_qte_stick_ps3") 
  256. 				vint_set_property(Hud_btnmash_stick_rs_base_bmp_h, "image", "ui_qte_base_ps3") 
  257. 				 
  258. 				vint_set_property(Hud_btnmash_stick_ls_label_h, "text_tag", "L") 
  259. 				vint_set_property(Hud_btnmash_stick_rs_label_h, "text_tag", "R") 
  260. 			else 
  261. 				--If btn value isn't accounted for throw up a garbage texture to let us know in game 
  262. 				vint_set_property(Hud_qte_btn_1_h, "image", "ui_hud_not_police") 
  263. 				vint_set_property(Hud_qte_btn_2_h, "image", "ui_hud_not_police")			 
  264. 			end					 
  265. 		else	 
  266. 			-- use XBOX2 button images 
  267. 			if			(button_index == BUTTON_MASH_A) then  
  268. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_a_up_xbox2") 
  269. 				vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_a_down_xbox2")													 
  270. 			elseif	(button_index == BUTTON_MASH_X) then  
  271. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_x_up_xbox2") 
  272. 				vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_x_down_xbox2") 
  273. 			elseif	(button_index == BUTTON_MASH_Y) then  
  274. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_y_up_xbox2") 
  275. 				vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_y_down_xbox2")	 
  276. 			elseif	(button_index >= BUTTON_MASH_ROTATE_LS_LEFT and button_index <= BUTTON_MASH_ROTATE_RS_RIGHT ) then --Stick 
  277. 			 
  278. 				vint_set_property(Hud_btnmash_stick_ls_pad_h, 		"image", "ui_qte_stick_xbox2") 
  279. 				vint_set_property(Hud_btnmash_stick_ls_base_bmp_h, "image", "ui_qte_base_xbox2") 
  280.  
  281. 				vint_set_property(Hud_btnmash_stick_rs_pad_h, 		"image", "ui_qte_stick_xbox2") 
  282. 				vint_set_property(Hud_btnmash_stick_rs_base_bmp_h, "image", "ui_qte_base_xbox2") 
  283. 				 
  284. 				vint_set_property(Hud_btnmash_stick_ls_label_h, "text_tag", "LS") 
  285. 				vint_set_property(Hud_btnmash_stick_rs_label_h, "text_tag", "RS") 
  286. 			else 
  287. 				--If btn value isn't accounted for throw up a garbage texture to let us know in game 
  288. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_hud_not_police") 
  289. 				vint_set_property(Hud_qte_btn_2_h, "image", "ui_hud_not_police")			 
  290. 			end			 
  291. 		end 
  292. 		 
  293. 		--Now modify the screen and play the appropriate action. 
  294. 		 
  295. 		--Pause all playing animations.. 
  296. 		vint_set_property(Hud_btn_mash_btn_mash_anim_h, "is_paused", true) 
  297. 		vint_set_property(Hud_btn_mash_ls_rotate_left_anim_h, "is_paused", true) 
  298. 		vint_set_property(Hud_btn_mash_ls_rotate_right_anim_h, "is_paused", true) 
  299. 		vint_set_property(Hud_btn_mash_rs_rotate_left_anim_h, "is_paused", true) 
  300. 		vint_set_property(Hud_btn_mash_rs_rotate_right_anim_h, "is_paused", true) 
  301. 		vint_set_property(Hud_btn_mash_btn_mash_anim_h, "is_paused", true) 
  302. 		vint_set_property(Hud_btn_mash_mouse_left_anim_h, "is_paused", true) 
  303. 		vint_set_property(Hud_btn_mash_mouse_right_anim_h, "is_paused", true) 
  304. 		Hud_btnmash_pc_key:mash(-1) 
  305. 		  
  306. 		if button_index >= BUTTON_MASH_A and button_index <= BUTTON_MASH_Y then 
  307. 			--Button Mashing 
  308. 			 
  309. 			--Hide sticks, show button 
  310. 			vint_set_property(Hud_btnmash_stick_rs_grp_h, "visible", false) 
  311. 			vint_set_property(Hud_btnmash_stick_ls_grp_h, "visible", false) 
  312. 			vint_set_property(Hud_btnmash_mouse_grp_h, "visible", false) 
  313. 			 
  314. 			if game_is_active_input_gamepad() then 
  315. 				vint_set_property(Hud_btnmash_btn_grp_h, "visible", true) 
  316. 				vint_set_property(Hud_btnmash_key_grp_h, "visible", false) 
  317. 			else 
  318. 				vint_set_property(Hud_btnmash_btn_grp_h, "visible", false) 
  319. 				vint_set_property(Hud_btnmash_key_grp_h, "visible", true) 
  320. 			end 
  321. 			--Play button mash anim 
  322. 			lua_play_anim(Hud_btn_mash_btn_mash_anim_h) 
  323. 			Hud_btnmash_pc_key:mash(HUD_QTE_ANIM_MASH_STANDARD) 
  324. 			 
  325. 		elseif button_index >= BUTTON_MASH_ROTATE_LS_LEFT and button_index <= BUTTON_MASH_ROTATE_RS_RIGHT then 
  326. 			--Stick movements 
  327. 			 
  328. 			--Show sticks, hide button 
  329. 			if game_is_active_input_gamepad() then 
  330. 				vint_set_property(Hud_btnmash_stick_rs_grp_h, 	"visible", true) 
  331. 				vint_set_property(Hud_btnmash_stick_ls_grp_h, 	"visible", true) 
  332. 				vint_set_property(Hud_btnmash_mouse_grp_h, 		"visible", false) 
  333. 			else 
  334. 				vint_set_property(Hud_btnmash_stick_rs_grp_h, 	"visible", false) 
  335. 				vint_set_property(Hud_btnmash_stick_ls_grp_h, 	"visible", false) 
  336. 				vint_set_property(Hud_btnmash_mouse_grp_h, 		"visible", true) 
  337. 			end 
  338. 				 
  339. 			vint_set_property(Hud_btnmash_btn_grp_h, "visible", false) 
  340. 			vint_set_property(Hud_btnmash_key_grp_h, "visible", false) 
  341. 		 
  342. 			local stick_ls_rotate_h		 	= vint_object_find("stick_ls_rotate") 
  343. 			local stick_ls_unrotate_h	 	= vint_object_find("stick_ls_unrotate") 
  344. 			local stick_rs_rotate_h 		= vint_object_find("stick_rs_rotate") 
  345. 			local stick_rs_unrotate_h 		= vint_object_find("stick_rs_unrotate") 
  346. 			 
  347. 			--Default left stick is active... 
  348. 			local stick_grp_h 					= Hud_btnmash_stick_ls_grp_h 
  349. 			local stick_rotate_h           	= stick_ls_rotate_h 
  350. 			local stick_unrotate_h           = stick_ls_unrotate_h 
  351. 			local dim_stick_grp_h 				= Hud_btnmash_stick_rs_grp_h 
  352. 			local dim_stick_rotate_h 			= stick_rs_rotate_h 
  353. 			local dim_stick_unrotate_h       = stick_rs_unrotate_h 
  354.  
  355. 			if button_index >= BUTTON_MASH_ROTATE_RS_LEFT and button_index <= BUTTON_MASH_ROTATE_RS_RIGHT then 
  356. 				--Right stick is active... 
  357. 				stick_grp_h 					= Hud_btnmash_stick_rs_grp_h 
  358. 				stick_rotate_h          	= stick_rs_rotate_h 
  359. 				stick_unrotate_h           = stick_rs_unrotate_h 
  360. 				dim_stick_grp_h 				= Hud_btnmash_stick_ls_grp_h 
  361. 				dim_stick_rotate_h 			= stick_ls_rotate_h 
  362. 				dim_stick_unrotate_h       = stick_ls_unrotate_h 
  363. 			end 
  364.  
  365. 			--Dim stick, center and unrotate... 
  366. 			vint_set_property(dim_stick_grp_h, "tint", HUD_BTNMASH_COLOR_DIM[1], HUD_BTNMASH_COLOR_DIM[2], HUD_BTNMASH_COLOR_DIM[3]) 
  367. 			vint_set_property(dim_stick_unrotate_h, "anchor", 0, 0) 
  368. 			vint_set_property(dim_stick_unrotate_h, "rotation", 0) 
  369. 			vint_set_property(dim_stick_rotate_h, 	"rotation", 0) 
  370. 			 
  371. 			--Reset normal stick anchor of unrotated item and tint... 
  372. 			vint_set_property(stick_unrotate_h, "anchor", 0, HUD_BTNMASH_STICK_OFFSET) 
  373. 			vint_set_property(stick_grp_h, "tint", 255, 255, 255) 
  374. 		 
  375. 			--Play animation on appropraite stick... 
  376. 			if button_index == BUTTON_MASH_ROTATE_LS_LEFT then 
  377. 				lua_play_anim(Hud_btn_mash_ls_rotate_left_anim_h) 
  378. 				lua_play_anim(Hud_btn_mash_mouse_left_anim_h) 
  379. 			elseif button_index == BUTTON_MASH_ROTATE_LS_RIGHT then 
  380. 				lua_play_anim(Hud_btn_mash_ls_rotate_right_anim_h) 
  381. 				lua_play_anim(Hud_btn_mash_mouse_right_anim_h) 
  382. 			elseif button_index == BUTTON_MASH_ROTATE_RS_LEFT then 
  383. 				lua_play_anim(Hud_btn_mash_rs_rotate_left_anim_h) 
  384. 				lua_play_anim(Hud_btn_mash_mouse_left_anim_h) 
  385. 			elseif button_index == BUTTON_MASH_ROTATE_RS_RIGHT then 
  386. 				lua_play_anim(Hud_btn_mash_rs_rotate_right_anim_h) 
  387. 				lua_play_anim(Hud_btn_mash_mouse_right_anim_h) 
  388. 			end	 
  389. 		end 
  390. 		Hud_btnmash_button_index = button_index 
  391. 	end	 
  392.  
  393. 	--Update help text 
  394. 	if Hud_btnmash_help_txt ~= help_txt then 
  395. 		if help_txt == "" then  
  396. 			vint_set_property(Hud_btnmash_help_txt_grp_h, "visible", false) 
  397. 		else  
  398. 			vint_set_property(Hud_btnmash_help_txt_grp_h, "visible", true) 
  399. 		end 
  400. 		 
  401. 		--Update text field 
  402. 		vint_set_property(Hud_btnmash_help_txt_h, "text_tag", help_txt) 
  403. 		 
  404. 		--Update background of text 
  405. 		local width, height = element_get_actual_size(Hud_btnmash_help_txt_h) 
  406. 		local base_width, base_height = element_get_actual_size(Hud_btnmash_help_txt_bg_h) 
  407. 		element_set_actual_size(Hud_btnmash_help_txt_bg_h, width + 15, base_height) 
  408.  
  409. 		Hud_btnmash_help_txt = help_txt		 
  410. 	end 
  411. 	 
  412. 	--Update Meter 
  413. 	if Hud_btnmash_meter_pct ~= meter_pct then 
  414. 		local meter_x_scale = Hud_btnmash_meter_base_width * meter_pct 
  415. 		vint_set_property(Hud_btnmash_meter_fill_h, "scale", meter_x_scale, Hud_btnmash_meter_base_height) 
  416. 		Hud_btnmash_meter_pct = meter_pct 
  417. 	end 
  418. 	 
  419.  
  420. 	--Update Timer 
  421. 	if Hud_btnmash_timer_value ~= timer_value then 
  422. 		if timer_value >= 0 then 
  423. 			vint_set_property(Hud_btnmash_timer_grp_h, "visible", true)  
  424. 			local time_formatted = format_clock(timer_value, true) 
  425. 			vint_set_property(Hud_btnmash_timer_txt_h, "text_tag", ":" .. time_formatted) 
  426. 		else 
  427. 			vint_set_property(Hud_btnmash_timer_grp_h, "visible", false)  
  428. 		end 
  429. 		Hud_btnmash_timer_value = timer_value 
  430. 	end 
  431. 	 
  432. 	 
  433. 	--Play animation to switch the the appropriate state... 
  434. 	-- Also hide groups using Alpha that don't belong in the state... 
  435. 	if Hud_btnmash_state ~= state then 
  436. 		--Always pause all animations... 
  437. 		vint_set_property(Hud_btn_mash_fade_in_anim_h, 		"is_paused", true) 
  438. 		vint_set_property(Hud_btn_mash_success_anim_h, 		"is_paused", true) 
  439. 		vint_set_property(Hud_btn_mash_fail_anim_h, 			"is_paused", true) 
  440. 		vint_set_property(Hud_btn_mash_fade_out_anim_h, 	"is_paused", true) 
  441. 		 
  442. 		if state == HUD_BTNMASH_STATE_UPDATE then 
  443. 			-- fade in 
  444. 			lua_play_anim(Hud_btn_mash_fade_in_anim_h) 
  445. 			vint_set_property(Hud_btnmash_fail_grp_h, "alpha", 0) 
  446. 			vint_set_property(Hud_btnmash_win_grp_h, "alpha", 0) 
  447. 		elseif state == HUD_BTNMASH_STATE_SUCCESS then 
  448. 			--Success 
  449. 			lua_play_anim(Hud_btn_mash_success_anim_h) 
  450. 			vint_set_property(Hud_btnmash_fail_grp_h, "alpha", 0) 
  451. 		elseif state == HUD_BTNMASH_STATE_FAIL then 
  452. 			--FAIL 
  453. 			lua_play_anim(Hud_btn_mash_fail_anim_h) 
  454. 			vint_set_property(Hud_btnmash_fail_grp_h, "alpha", 0) 
  455. 		elseif state == HUD_BTNMASH_STATE_HIDE then 
  456. 			--Hide immediatly... 
  457. 			vint_set_property(Hud_btnmash_btn_mash_grp_h, "alpha", 0)    
  458. 			vint_set_property(Hud_btnmash_fail_grp_h, "alpha", 0) 
  459. 			vint_set_property(Hud_btnmash_win_grp_h, "alpha", 0) 
  460. 	 	end	 
  461. 		 				 
  462. 		Hud_btnmash_state = state 
  463. 	end 
  464. end 
  465.  
  466. function hud_btnmash_complete() 
  467. 	-- Tell C++ here that we have finished. and can start another one. 
  468. 	-- This will get called eventually if any of the states change from UPDATE  to SUCCESS, FAIL, or HIDE. Via tween callback... 
  469. 	Hud_btnmash_state = HUD_BTNMASH_STATE_HIDDEN 
  470. 	 
  471. 	autil_mashing_minigame_faded_out() 
  472. end