./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") or (platform == "XBOX3") 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 or button_index == BUTTON_MASH_X or button_index == BUTTON_MASH_Y then 
  242. 				if qte_use_touch_pad() then	--HVS_JRP[PRINCE] 4/22/2014 
  243. 					vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_swipe_left_ps4") 
  244. 					vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_swipe_right_ps4")													 
  245. 				elseif			(button_index == BUTTON_MASH_A) then -- CROSS 
  246. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_cross_up_ps3") 
  247. 				vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_cross_down_ps3")													 
  248. 			elseif	(button_index == BUTTON_MASH_X) then -- SQUARE 
  249. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_square_up_ps3") 
  250. 				vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_square_down_ps3") 
  251. 			elseif	(button_index == BUTTON_MASH_Y) then -- TRIANGLE 
  252. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_triangle_up_ps3") 
  253. 				vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_triangle_down_ps3") 
  254. 				end 
  255. 			elseif	(button_index >= BUTTON_MASH_ROTATE_LS_LEFT and button_index <= BUTTON_MASH_ROTATE_RS_RIGHT ) then --Stick		 
  256. 				 
  257. 				vint_set_property(Hud_btnmash_stick_ls_pad_h, 		"image", "ui_qte_stick_ps3") 
  258. 				vint_set_property(Hud_btnmash_stick_ls_base_bmp_h, "image", "ui_qte_base_ps3") 
  259.  
  260. 				vint_set_property(Hud_btnmash_stick_rs_pad_h, 		"image", "ui_qte_stick_ps3") 
  261. 				vint_set_property(Hud_btnmash_stick_rs_base_bmp_h, "image", "ui_qte_base_ps3") 
  262. 				 
  263. 				vint_set_property(Hud_btnmash_stick_ls_label_h, "text_tag", "L") 
  264. 				vint_set_property(Hud_btnmash_stick_rs_label_h, "text_tag", "R") 
  265. 			else 
  266. 				--If btn value isn't accounted for throw up a garbage texture to let us know in game 
  267. 				vint_set_property(Hud_qte_btn_1_h, "image", "ui_hud_not_police") 
  268. 				vint_set_property(Hud_qte_btn_2_h, "image", "ui_hud_not_police")			 
  269. 			end					 
  270. 		else	 
  271. 			-- use XBOX2 button images 
  272. 			if			(button_index == BUTTON_MASH_A) then  
  273. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_a_up_xbox2") 
  274. 				vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_a_down_xbox2")													 
  275. 			elseif	(button_index == BUTTON_MASH_X) then  
  276. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_x_up_xbox2") 
  277. 				vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_x_down_xbox2") 
  278. 			elseif	(button_index == BUTTON_MASH_Y) then  
  279. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_qte_y_up_xbox2") 
  280. 				vint_set_property(Hud_btnmash_btn_2_h, "image", "ui_qte_y_down_xbox2")	 
  281. 			elseif	(button_index >= BUTTON_MASH_ROTATE_LS_LEFT and button_index <= BUTTON_MASH_ROTATE_RS_RIGHT ) then --Stick 
  282. 			 
  283. 				vint_set_property(Hud_btnmash_stick_ls_pad_h, 		"image", "ui_qte_stick_xbox2") 
  284. 				vint_set_property(Hud_btnmash_stick_ls_base_bmp_h, "image", "ui_qte_base_xbox2") 
  285.  
  286. 				vint_set_property(Hud_btnmash_stick_rs_pad_h, 		"image", "ui_qte_stick_xbox2") 
  287. 				vint_set_property(Hud_btnmash_stick_rs_base_bmp_h, "image", "ui_qte_base_xbox2") 
  288. 				 
  289. 				vint_set_property(Hud_btnmash_stick_ls_label_h, "text_tag", "LS") 
  290. 				vint_set_property(Hud_btnmash_stick_rs_label_h, "text_tag", "RS") 
  291. 			else 
  292. 				--If btn value isn't accounted for throw up a garbage texture to let us know in game 
  293. 				vint_set_property(Hud_btnmash_btn_1_h, "image", "ui_hud_not_police") 
  294. 				vint_set_property(Hud_qte_btn_2_h, "image", "ui_hud_not_police")			 
  295. 			end			 
  296. 		end 
  297. 		 
  298. 		--Now modify the screen and play the appropriate action. 
  299. 		 
  300. 		--Pause all playing animations.. 
  301. 		vint_set_property(Hud_btn_mash_btn_mash_anim_h, "is_paused", true) 
  302. 		vint_set_property(Hud_btn_mash_ls_rotate_left_anim_h, "is_paused", true) 
  303. 		vint_set_property(Hud_btn_mash_ls_rotate_right_anim_h, "is_paused", true) 
  304. 		vint_set_property(Hud_btn_mash_rs_rotate_left_anim_h, "is_paused", true) 
  305. 		vint_set_property(Hud_btn_mash_rs_rotate_right_anim_h, "is_paused", true) 
  306. 		vint_set_property(Hud_btn_mash_btn_mash_anim_h, "is_paused", true) 
  307. 		vint_set_property(Hud_btn_mash_mouse_left_anim_h, "is_paused", true) 
  308. 		vint_set_property(Hud_btn_mash_mouse_right_anim_h, "is_paused", true) 
  309. 		Hud_btnmash_pc_key:mash(-1) 
  310. 		  
  311. 		if button_index >= BUTTON_MASH_A and button_index <= BUTTON_MASH_Y then 
  312. 			--Button Mashing 
  313. 			 
  314. 			--Hide sticks, show button 
  315. 			vint_set_property(Hud_btnmash_stick_rs_grp_h, "visible", false) 
  316. 			vint_set_property(Hud_btnmash_stick_ls_grp_h, "visible", false) 
  317. 			vint_set_property(Hud_btnmash_mouse_grp_h, "visible", false) 
  318. 			 
  319. 			if game_is_active_input_gamepad() then 
  320. 				vint_set_property(Hud_btnmash_btn_grp_h, "visible", true) 
  321. 				vint_set_property(Hud_btnmash_key_grp_h, "visible", false) 
  322. 			else 
  323. 				vint_set_property(Hud_btnmash_btn_grp_h, "visible", false) 
  324. 				vint_set_property(Hud_btnmash_key_grp_h, "visible", true) 
  325. 			end 
  326. 			--Play button mash anim 
  327. 			lua_play_anim(Hud_btn_mash_btn_mash_anim_h) 
  328. 			Hud_btnmash_pc_key:mash(HUD_QTE_ANIM_MASH_STANDARD) 
  329. 			 
  330. 		elseif button_index >= BUTTON_MASH_ROTATE_LS_LEFT and button_index <= BUTTON_MASH_ROTATE_RS_RIGHT then 
  331. 			--Stick movements 
  332. 			 
  333. 			--Show sticks, hide button 
  334. 			if game_is_active_input_gamepad() then 
  335. 				vint_set_property(Hud_btnmash_stick_rs_grp_h, 	"visible", true) 
  336. 				vint_set_property(Hud_btnmash_stick_ls_grp_h, 	"visible", true) 
  337. 				vint_set_property(Hud_btnmash_mouse_grp_h, 		"visible", false) 
  338. 			else 
  339. 				vint_set_property(Hud_btnmash_stick_rs_grp_h, 	"visible", false) 
  340. 				vint_set_property(Hud_btnmash_stick_ls_grp_h, 	"visible", false) 
  341. 				vint_set_property(Hud_btnmash_mouse_grp_h, 		"visible", true) 
  342. 			end 
  343. 				 
  344. 			vint_set_property(Hud_btnmash_btn_grp_h, "visible", false) 
  345. 			vint_set_property(Hud_btnmash_key_grp_h, "visible", false) 
  346. 		 
  347. 			local stick_ls_rotate_h		 	= vint_object_find("stick_ls_rotate") 
  348. 			local stick_ls_unrotate_h	 	= vint_object_find("stick_ls_unrotate") 
  349. 			local stick_rs_rotate_h 		= vint_object_find("stick_rs_rotate") 
  350. 			local stick_rs_unrotate_h 		= vint_object_find("stick_rs_unrotate") 
  351. 			 
  352. 			--Default left stick is active... 
  353. 			local stick_grp_h 					= Hud_btnmash_stick_ls_grp_h 
  354. 			local stick_rotate_h           	= stick_ls_rotate_h 
  355. 			local stick_unrotate_h           = stick_ls_unrotate_h 
  356. 			local dim_stick_grp_h 				= Hud_btnmash_stick_rs_grp_h 
  357. 			local dim_stick_rotate_h 			= stick_rs_rotate_h 
  358. 			local dim_stick_unrotate_h       = stick_rs_unrotate_h 
  359.  
  360. 			if button_index >= BUTTON_MASH_ROTATE_RS_LEFT and button_index <= BUTTON_MASH_ROTATE_RS_RIGHT then 
  361. 				--Right stick is active... 
  362. 				stick_grp_h 					= Hud_btnmash_stick_rs_grp_h 
  363. 				stick_rotate_h          	= stick_rs_rotate_h 
  364. 				stick_unrotate_h           = stick_rs_unrotate_h 
  365. 				dim_stick_grp_h 				= Hud_btnmash_stick_ls_grp_h 
  366. 				dim_stick_rotate_h 			= stick_ls_rotate_h 
  367. 				dim_stick_unrotate_h       = stick_ls_unrotate_h 
  368. 			end 
  369.  
  370. 			--Dim stick, center and unrotate... 
  371. 			vint_set_property(dim_stick_grp_h, "tint", HUD_BTNMASH_COLOR_DIM[1], HUD_BTNMASH_COLOR_DIM[2], HUD_BTNMASH_COLOR_DIM[3]) 
  372. 			vint_set_property(dim_stick_unrotate_h, "anchor", 0, 0) 
  373. 			vint_set_property(dim_stick_unrotate_h, "rotation", 0) 
  374. 			vint_set_property(dim_stick_rotate_h, 	"rotation", 0) 
  375. 			 
  376. 			--Reset normal stick anchor of unrotated item and tint... 
  377. 			vint_set_property(stick_unrotate_h, "anchor", 0, HUD_BTNMASH_STICK_OFFSET) 
  378. 			vint_set_property(stick_grp_h, "tint", 255, 255, 255) 
  379. 		 
  380. 			--Play animation on appropraite stick... 
  381. 			if button_index == BUTTON_MASH_ROTATE_LS_LEFT then 
  382. 				lua_play_anim(Hud_btn_mash_ls_rotate_left_anim_h) 
  383. 				lua_play_anim(Hud_btn_mash_mouse_left_anim_h) 
  384. 			elseif button_index == BUTTON_MASH_ROTATE_LS_RIGHT then 
  385. 				lua_play_anim(Hud_btn_mash_ls_rotate_right_anim_h) 
  386. 				lua_play_anim(Hud_btn_mash_mouse_right_anim_h) 
  387. 			elseif button_index == BUTTON_MASH_ROTATE_RS_LEFT then 
  388. 				lua_play_anim(Hud_btn_mash_rs_rotate_left_anim_h) 
  389. 				lua_play_anim(Hud_btn_mash_mouse_left_anim_h) 
  390. 			elseif button_index == BUTTON_MASH_ROTATE_RS_RIGHT then 
  391. 				lua_play_anim(Hud_btn_mash_rs_rotate_right_anim_h) 
  392. 				lua_play_anim(Hud_btn_mash_mouse_right_anim_h) 
  393. 			end	 
  394. 		end 
  395. 		Hud_btnmash_button_index = button_index 
  396. 	end	 
  397.  
  398. 	--Update help text 
  399. 	if Hud_btnmash_help_txt ~= help_txt then 
  400. 		if help_txt == "" then  
  401. 			vint_set_property(Hud_btnmash_help_txt_grp_h, "visible", false) 
  402. 		else  
  403. 			vint_set_property(Hud_btnmash_help_txt_grp_h, "visible", true) 
  404. 		end 
  405. 		 
  406. 		--Update text field 
  407. 		vint_set_property(Hud_btnmash_help_txt_h, "text_tag", help_txt) 
  408. 		 
  409. 		--Update background of text 
  410. 		local width, height = element_get_actual_size(Hud_btnmash_help_txt_h) 
  411. 		local base_width, base_height = element_get_actual_size(Hud_btnmash_help_txt_bg_h) 
  412. 		element_set_actual_size(Hud_btnmash_help_txt_bg_h, width + 15, base_height) 
  413.  
  414. 		Hud_btnmash_help_txt = help_txt		 
  415. 	end 
  416. 	 
  417. 	--Update Meter 
  418. 	if Hud_btnmash_meter_pct ~= meter_pct then 
  419. 		local meter_x_scale = Hud_btnmash_meter_base_width * meter_pct 
  420. 		vint_set_property(Hud_btnmash_meter_fill_h, "scale", meter_x_scale, Hud_btnmash_meter_base_height) 
  421. 		Hud_btnmash_meter_pct = meter_pct 
  422. 	end 
  423. 	 
  424.  
  425. 	--Update Timer 
  426. 	if Hud_btnmash_timer_value ~= timer_value then 
  427. 		if timer_value >= 0 then 
  428. 			vint_set_property(Hud_btnmash_timer_grp_h, "visible", true)  
  429. 			local time_formatted = format_clock(timer_value, true) 
  430. 			vint_set_property(Hud_btnmash_timer_txt_h, "text_tag", ":" .. time_formatted) 
  431. 		else 
  432. 			vint_set_property(Hud_btnmash_timer_grp_h, "visible", false)  
  433. 		end 
  434. 		Hud_btnmash_timer_value = timer_value 
  435. 	end 
  436. 	 
  437. 	 
  438. 	--Play animation to switch the the appropriate state... 
  439. 	-- Also hide groups using Alpha that don't belong in the state... 
  440. 	if Hud_btnmash_state ~= state then 
  441. 		--Always pause all animations... 
  442. 		vint_set_property(Hud_btn_mash_fade_in_anim_h, 		"is_paused", true) 
  443. 		vint_set_property(Hud_btn_mash_success_anim_h, 		"is_paused", true) 
  444. 		vint_set_property(Hud_btn_mash_fail_anim_h, 			"is_paused", true) 
  445. 		vint_set_property(Hud_btn_mash_fade_out_anim_h, 	"is_paused", true) 
  446. 		 
  447. 		if state == HUD_BTNMASH_STATE_UPDATE then 
  448. 			-- fade in 
  449. 			lua_play_anim(Hud_btn_mash_fade_in_anim_h) 
  450. 			vint_set_property(Hud_btnmash_fail_grp_h, "alpha", 0) 
  451. 			vint_set_property(Hud_btnmash_win_grp_h, "alpha", 0) 
  452. 		elseif state == HUD_BTNMASH_STATE_SUCCESS then 
  453. 			--Success 
  454. 			lua_play_anim(Hud_btn_mash_success_anim_h) 
  455. 			vint_set_property(Hud_btnmash_fail_grp_h, "alpha", 0) 
  456. 		elseif state == HUD_BTNMASH_STATE_FAIL then 
  457. 			--FAIL 
  458. 			lua_play_anim(Hud_btn_mash_fail_anim_h) 
  459. 			vint_set_property(Hud_btnmash_fail_grp_h, "alpha", 0) 
  460. 		elseif state == HUD_BTNMASH_STATE_HIDE then 
  461. 			--Hide immediatly... 
  462. 			vint_set_property(Hud_btnmash_btn_mash_grp_h, "alpha", 0)    
  463. 			vint_set_property(Hud_btnmash_fail_grp_h, "alpha", 0) 
  464. 			vint_set_property(Hud_btnmash_win_grp_h, "alpha", 0) 
  465. 	 	end	 
  466. 		 				 
  467. 		Hud_btnmash_state = state 
  468. 	end 
  469. end 
  470.  
  471. function hud_btnmash_complete() 
  472. 	-- Tell C++ here that we have finished. and can start another one. 
  473. 	-- This will get called eventually if any of the states change from UPDATE  to SUCCESS, FAIL, or HIDE. Via tween callback... 
  474. 	Hud_btnmash_state = HUD_BTNMASH_STATE_HIDDEN 
  475. 	 
  476. 	autil_mashing_minigame_faded_out() 
  477. end