sr2lua/hud_btnmash.lua

  1. Hud_btnmash = {	 
  2.  
  3. 	handles = {}, 
  4. 	shock_thread = -1 
  5. } 
  6.  
  7.  
  8. function hud_btnmash_init() 
  9. 	--get the language 
  10. 	Hud_btnmash.handles.language = get_language() 
  11. 	 
  12. 	local language = Hud_btnmash.handles.language 
  13. 	 
  14. 	--get the platform 
  15. 	Hud_btnmash.handles.platform = get_platform() 
  16. 		 
  17. 	local platform = Hud_btnmash.handles.platform 
  18. 	 
  19. 	 
  20. 	if platform == "XBOX360" then 
  21. 		Hud_btnmash.handles.platform = "xbox2" 
  22. 	elseif platform == "PS3" then 
  23. 		Hud_btnmash.handles.platform = "ps3" 
  24. 	elseif platform == "PC" then 
  25. 		Hud_btnmash.handles.platform = "pc" 
  26. 	end 
  27. 		 
  28. 	 
  29. 	platform = Hud_btnmash.handles.platform	 
  30. 	 
  31. 	 
  32. 	--[[ 
  33. 	*********************** 
  34. 	ATTENTION MASS MEDIA 
  35. 	SIX AXIS DETECTION HERE 
  36. 	*********************** 
  37. 	]] 
  38. 	--write code to detect sixaxis option and make this variable true or false 
  39. 	Hud_btnmash.handles.sixaxis_h = false 
  40. 	 
  41. 	 
  42. 	 
  43. 	 
  44. 	--Load Pegs 
  45. 	peg_load("ui_btnmash_" .. platform) 
  46. 	peg_load("ui_btnmash_t_" .. language ) 
  47. 	 
  48. 	 
  49.  
  50. 	--meter 
  51. 	Hud_btnmash.handles.meter_grp_h = vint_object_find("meter_grp") 
  52. 	local h = Hud_btnmash.handles.meter_grp_h 
  53. 	Hud_btnmash.handles.meter_fill_1_h = vint_object_find("fill_1", h) 
  54. 	Hud_btnmash.handles.meter_fill_2_h = vint_object_find("fill_2", h) 
  55. 	Hud_btnmash.handles.meter_border_h = vint_object_find("border", h) 
  56. 	Hud_btnmash.handles.meter_grit_h = vint_object_find("grit", h) 
  57. 	vint_set_property(Hud_btnmash.handles.meter_fill_2_h, "alpha", 0) 
  58. 	vint_set_property(h, "visible", false) 
  59. 	 
  60. 	--status word 
  61. 	Hud_btnmash.handles.status_grp_h = vint_object_find("status_grp") 
  62. 	h = Hud_btnmash.handles.status_grp_h 
  63. 	Hud_btnmash.handles.status_1_h = vint_object_find("status_1", h) 
  64. 	Hud_btnmash.handles.status_2_h = vint_object_find("status_2", h) 
  65. 	vint_set_property(h, "visible", false) 
  66.  
  67. 	 
  68. 	--triggers left 
  69. 	Hud_btnmash.handles.trigger_l_grp_h = vint_object_find("trigger_l_grp") 
  70. 	h = Hud_btnmash.handles.trigger_l_grp_h 
  71. 	Hud_btnmash.handles.trigger_l_dn_h = vint_object_find("trg_l_dn", h) 
  72. 	Hud_btnmash.handles.trigger_l_up_h = vint_object_find("trg_l_up", h) 
  73. 	Hud_btnmash.handles.trigger_l2_up_h = vint_object_find("trg_l2_up", h) 
  74. 	Hud_btnmash.handles.trigger_l_lbl_h = vint_object_find("trg_l_lbl", h) 
  75. 	vint_set_property(h, "visible", false) 
  76. 	 
  77. 	--triggers right 
  78. 	Hud_btnmash.handles.trigger_r_grp_h = vint_object_find("trigger_r_grp") 
  79. 	h = Hud_btnmash.handles.trigger_r_grp_h 
  80. 	Hud_btnmash.handles.trigger_r_dn_h = vint_object_find("trg_r_dn", h) 
  81. 	Hud_btnmash.handles.trigger_r_up_h = vint_object_find("trg_r_up", h) 
  82. 	Hud_btnmash.handles.trigger_r2_up_h = vint_object_find("trg_r2_up", h) 
  83. 	Hud_btnmash.handles.trigger_r_lbl_h = vint_object_find("trg_r_lbl", h) 
  84. 	vint_set_property(h, "visible", false) 
  85. 	 
  86. 	--sticks 
  87. 	Hud_btnmash.handles.sticks_grp_h = vint_object_find("sticks_grp") 
  88. 	h = Hud_btnmash.handles.sticks_grp_h 
  89. 	Hud_btnmash.handles.sticks_l_base_h = vint_object_find("st_l_base", h) 
  90. 	Hud_btnmash.handles.sticks_l_pad_h = vint_object_find("st_l_pad", h) 
  91. 	Hud_btnmash.handles.sticks_l_lbl_h = vint_object_find("st_l_lbl", h) 
  92. 	Hud_btnmash.handles.sticks_r_base_h = vint_object_find("st_r_base", h) 
  93. 	Hud_btnmash.handles.sticks_r_pad_h = vint_object_find("st_r_pad", h) 
  94. 	Hud_btnmash.handles.sticks_r_lbl_h = vint_object_find("st_r_lbl", h) 
  95. 	vint_set_property(h, "visible", false) 
  96. 	 
  97. 	--giant buttons 1 
  98. 	Hud_btnmash.handles.giant_buttons_grp_1_h = vint_object_find("giant_buttons_grp_1") 
  99. 	h = Hud_btnmash.handles.giant_buttons_grp_1_h 
  100. 	Hud_btnmash.handles.btn_dn_1_h = vint_object_find("btn_1_dn", h) 
  101. 	Hud_btnmash.handles.btn_up_1_h = vint_object_find("btn_1_up", h) 
  102. 	vint_set_property(h, "visible", false) 
  103. 	 
  104. 	--giant buttons 2 
  105. 	Hud_btnmash.handles.giant_buttons_grp_2_h = vint_object_find("giant_buttons_grp_2") 
  106. 	h = Hud_btnmash.handles.giant_buttons_grp_2_h 
  107. 	Hud_btnmash.handles.btn_dn_2_h = vint_object_find("btn_2_dn", h) 
  108. 	Hud_btnmash.handles.btn_up_2_h = vint_object_find("btn_2_up", h) 
  109. 	vint_set_property(h, "visible", false) 
  110. 	 
  111. 	--sixaxis fb 
  112. 	Hud_btnmash.handles.sixaxis_fb_h = vint_object_find("sixaxis_fb") 
  113. 	h = Hud_btnmash.handles.sixaxis_fb_h 
  114. 	Hud_btnmash.handles.sixaxis_fb_back_h = vint_object_find("sixaxis_fb_back", h) 
  115. 	Hud_btnmash.handles.sixaxis_fb_fwd_h = vint_object_find("sixaxis_fb_fwd", h) 
  116. 	Hud_btnmash.handles.sixaxis_fb_center_h = vint_object_find("sixaxis_fb_center", h) 
  117. 	vint_set_property(h, "visible", false) 
  118. 	 
  119. 	--sixaxis lr 
  120. 	Hud_btnmash.handles.sixaxis_lr_h = vint_object_find("sixaxis_lr") 
  121. 	h = Hud_btnmash.handles.sixaxis_lr_h 
  122. 	Hud_btnmash.handles.sixaxis_lr_left_h = vint_object_find("sixaxis_lr_left", h) 
  123. 	Hud_btnmash.handles.sixaxis_lr_right_h = vint_object_find("sixaxis_lr_right", h) 
  124. 	Hud_btnmash.handles.sixaxis_lr_center_h = vint_object_find("sixaxis_lr_center", h) 
  125. 	vint_set_property(h, "visible", false) 
  126. 	 
  127. 	--btnmash_grp 
  128. 	Hud_btnmash.handles.btn_mash_h = vint_object_find("btn_mash") 
  129. 	vint_set_property(Hud_btnmash.handles.btn_mash_h, "alpha", 0) 
  130. 	 
  131. 	 
  132. 	--if not ps3, don't load the graphics 
  133. 	if Hud_btnmash.handles.platform == "xbox2" then 
  134. 		vint_set_property(Hud_btnmash.handles.sixaxis_lr_left_h, "image", "") 
  135. 		vint_set_property(Hud_btnmash.handles.sixaxis_lr_right_h, "image", "") 
  136. 		vint_set_property(Hud_btnmash.handles.sixaxis_lr_center_h, "image", "") 
  137. 		vint_set_property(Hud_btnmash.handles.sixaxis_fb_back_h, "image", "") 
  138. 		vint_set_property(Hud_btnmash.handles.sixaxis_fb_fwd_h, "image", "") 
  139. 		vint_set_property(Hud_btnmash.handles.sixaxis_fb_center_h, "image", "") 
  140. 	end 
  141. 	 
  142. 	--load the meter graphics 
  143. 	--[[ 
  144. 	vint_set_property(Hud_btnmash.handles.meter_border_h, "image", "ui_btnmash_meter_border_" .. platform  ) 
  145. 	vint_set_property(Hud_btnmash.handles.meter_fill_1_h, "image", "ui_btnmash_meter_fill_" .. platform  ) 
  146. 	vint_set_property(Hud_btnmash.handles.meter_fill_2_h, "image", "ui_btnmash_meter_fill_" .. platform  ) 
  147. 	vint_set_property(Hud_btnmash.handles.meter_grit_h, "image", "ui_btnmash_meter_grit_" .. platform  ) 
  148. 	]] 
  149. 	--Load platform specific images 
  150. 	vint_set_property(Hud_btnmash.handles.btn_dn_1_h, "image", "ui_btnmash_b1_dn_" .. platform ) 
  151. 	vint_set_property(Hud_btnmash.handles.btn_up_1_h, "image", "ui_btnmash_b1_up_" .. platform ) 
  152. 	vint_set_property(Hud_btnmash.handles.btn_dn_2_h, "image", "ui_btnmash_b2_dn_" .. platform  ) 
  153. 	vint_set_property(Hud_btnmash.handles.btn_up_2_h, "image", "ui_btnmash_b2_up_" .. platform  ) 
  154. 	vint_set_property(Hud_btnmash.handles.sticks_l_base_h, "image", "ui_btnmash_base_" .. platform  ) 
  155. 	vint_set_property(Hud_btnmash.handles.sticks_l_pad_h, "image", "ui_btnmash_stick_" .. platform  ) 
  156. 	if platform == "pc" then 
  157. 		vint_set_property(Hud_btnmash.handles.sticks_r_base_h, "image", "ui_btnmash_base_" .. platform ) 
  158. 		vint_set_property(Hud_btnmash.handles.sticks_r_pad_h, "image", "ui_btnmash_base_" .. platform  ) 
  159. 	else 
  160. 		vint_set_property(Hud_btnmash.handles.sticks_r_base_h, "image", "ui_btnmash_base_" .. platform ) 
  161. 		vint_set_property(Hud_btnmash.handles.sticks_r_pad_h, "image", "ui_btnmash_stick_" .. platform  ) 
  162. 	end 
  163. 	vint_set_property(Hud_btnmash.handles.trigger_l_dn_h, "image", "ui_btnmash_tr_dn_" .. platform  ) 
  164. 	vint_set_property(Hud_btnmash.handles.trigger_l_up_h, "image", "ui_btnmash_tr_up_" .. platform  ) 
  165.  
  166. 	vint_set_property(Hud_btnmash.handles.trigger_r_dn_h, "image", "ui_btnmash_tr_dn_" .. platform  ) 
  167. 	vint_set_property(Hud_btnmash.handles.trigger_r_up_h, "image", "ui_btnmash_tr_up_" .. platform  ) 
  168. 	 
  169. 	vint_set_property(Hud_btnmash.handles.trigger_r_dn_h, "scale", -1, 1 ) 
  170. 	vint_set_property(Hud_btnmash.handles.trigger_r_up_h, "scale", -1, 1 )	 
  171.  
  172. 	 
  173. 	 
  174. 	--LABELS 
  175. 	if platform == "ps3" then 
  176. 		vint_set_property(Hud_btnmash.handles.trigger_l_lbl_h, "text_tag", "L2"  ) 
  177. 		vint_set_property(Hud_btnmash.handles.trigger_r_lbl_h, "text_tag", "R2"  ) 
  178. 		vint_set_property(Hud_btnmash.handles.sticks_l_lbl_h, "text_tag", "L"  ) 
  179. 		vint_set_property(Hud_btnmash.handles.sticks_r_lbl_h, "text_tag", "R"  ) 
  180. 		vint_set_property(Hud_btnmash.handles.trigger_l2_up_h, "visible", true) 
  181. 		vint_set_property(Hud_btnmash.handles.trigger_r2_up_h, "visible", true) 
  182. 	elseif platform == "pc" then 
  183. 		vint_set_property(Hud_btnmash.handles.trigger_l_lbl_h, "text_tag", ""  ) 
  184. 		vint_set_property(Hud_btnmash.handles.trigger_r_lbl_h, "text_tag", ""  ) 
  185. 		vint_set_property(Hud_btnmash.handles.sticks_l_lbl_h, "text_tag", ""  ) 
  186. 		vint_set_property(Hud_btnmash.handles.sticks_r_lbl_h, "text_tag", ""  ) 
  187. 		vint_set_property(Hud_btnmash.handles.trigger_l2_up_h, "visible", false) 
  188. 		vint_set_property(Hud_btnmash.handles.trigger_r2_up_h, "visible", false) 
  189. 	else 
  190. 		vint_set_property(Hud_btnmash.handles.trigger_l_lbl_h, "text_tag", "LT"  ) 
  191. 		vint_set_property(Hud_btnmash.handles.trigger_r_lbl_h, "text_tag", "RT"  ) 
  192. 		vint_set_property(Hud_btnmash.handles.sticks_l_lbl_h, "text_tag", "LS"  ) 
  193. 		vint_set_property(Hud_btnmash.handles.sticks_r_lbl_h, "text_tag", "RS"  ) 
  194. 		vint_set_property(Hud_btnmash.handles.trigger_l2_up_h, "visible", false) 
  195. 		vint_set_property(Hud_btnmash.handles.trigger_r2_up_h, "visible", false) 
  196. 	end 
  197. 	 
  198.  
  199.  
  200. 	 
  201. 	 
  202. 	 
  203. 	--animations and the loops 
  204. 	local twn_h = 0 
  205. 	 
  206. 		--regular controls 
  207. 		Hud_btnmash.handles.lt_rt_alt_h = vint_object_find("lt_rt_alt")			--Find animation 
  208. 		twn_h = vint_object_find("alt_lt_2_dn", Hud_btnmash.handles.lt_rt_alt_h)				--Find tween inside anim 
  209. 		vint_set_property(twn_h, "end_event", "hud_btnmash_lt_rt_alt_loop")	--Set end event callback 
  210. 		vint_set_property(Hud_btnmash.handles.lt_rt_alt_h , "is_paused", true) 
  211. 		 
  212. 		Hud_btnmash.handles.lt_rt_tog_h = vint_object_find("lt_rt_tog")			--Find animation 
  213. 		twn_h = vint_object_find("tog_lt_2_dn", Hud_btnmash.handles.lt_rt_tog_h)				--Find tween inside anim 
  214. 		vint_set_property(twn_h, "end_event", "hud_btnmash_lt_rt_tog_loop")							--Set end event callback 
  215. 		vint_set_property(Hud_btnmash.handles.lt_rt_tog_h, "is_paused", true) 
  216. 		 
  217. 		Hud_btnmash.handles.lt_only_h = vint_object_find("lt_only")			--Find animation 
  218. 		local twn_h = vint_object_find("lt_2_dn", Hud_btnmash.handles.lt_only_h)				--Find tween inside anim 
  219. 		vint_set_property(twn_h, "end_event", "hud_btnmash_lt_only_loop") 
  220. 		vint_set_property(Hud_btnmash.handles.lt_only_h, "is_paused", true) 
  221. 		 
  222. 		Hud_btnmash.handles.rt_only_h = vint_object_find("rt_only")			--Find animation 
  223. 		twn_h = vint_object_find("rt_2_dn", Hud_btnmash.handles.rt_only_h)				--Find tween inside anim 
  224. 		vint_set_property(twn_h, "end_event", "hud_btnmash_rt_only_loop")		 
  225. 		vint_set_property(Hud_btnmash.handles.rt_only_h, "is_paused", true) 
  226. 		 
  227. 		Hud_btnmash.handles.giant_btn_1_anim_h = vint_object_find("giant_btn_1_anim")			--Find animation 
  228. 		twn_h = vint_object_find("btn_1_2_dn", Hud_btnmash.handles.giant_btn_1_anim_h)				--Find tween inside anim 
  229. 		vint_set_property(twn_h, "end_event", "hud_btnmash_giant_btn_1_loop")							--Set end event callback 
  230. 		vint_set_property(Hud_btnmash.handles.giant_btn_1_anim_h, "is_paused", true) 
  231. 		 
  232. 		Hud_btnmash.handles.giant_btn_2_anim_h = vint_object_find("giant_btn_2_anim")			--Find animation 
  233. 		twn_h = vint_object_find("btn_2_2_dn", Hud_btnmash.handles.giant_btn_2_anim_h)				--Find tween inside anim 
  234. 		vint_set_property(twn_h, "end_event", "hud_btnmash_giant_btn_2_loop")							--Set end event callback 
  235. 		vint_set_property(Hud_btnmash.handles.giant_btn_2_anim_h, "is_paused", true) 
  236. 		 
  237. 		Hud_btnmash.handles.status_anim_h = vint_object_find("status_anim")					--Find animation 
  238. 		twn_h = vint_object_find("status_alpha_dwn", Hud_btnmash.handles.status_anim_h)				--Find tween inside anim 
  239. 		vint_set_property(twn_h, "end_event", "hud_btnmash_status_anim_loop")						--Set end event callback 
  240. 		vint_set_property(Hud_btnmash.handles.status_anim_h , "is_paused", true) 
  241.  
  242. 		Hud_btnmash.handles.bar_flash_anim_h = vint_object_find("bar_flash_anim")					--Find animation 
  243. 		vint_set_property(Hud_btnmash.handles.bar_flash_anim_h, "is_paused", true) 
  244. 		 
  245. 		Hud_btnmash.handles.bar_blink_anim_h = vint_object_find("bar_blink_anim")					--Find animation 
  246. 		twn_h = vint_object_find("blink_2", Hud_btnmash.handles.bar_blink_anim_h)	 
  247. 		vint_set_property(twn_h, "end_event", "hud_btnmash_bar_blink_anim_loop")						--Set end event callback 
  248. 		vint_set_property(Hud_btnmash.handles.bar_blink_anim_h, "is_paused", true) 
  249. 		 
  250. 		Hud_btnmash.handles.sticks_alt_h = vint_object_find("sticks_alt")			--Find animation 
  251. 		twn_h = vint_object_find("alt_ls_2", Hud_btnmash.handles.sticks_alt_h)				--Find tween inside anim 
  252. 		vint_set_property(twn_h, "end_event", "hud_btnmash_sticks_alt_loop")							--Set end event callback 
  253. 		vint_set_property(Hud_btnmash.handles.sticks_alt_h, "is_paused", true) 
  254. 		 
  255. 		Hud_btnmash.handles.sticks_tog_h = vint_object_find("sticks_tog")			--Find animation 
  256. 		twn_h = vint_object_find("tog_ls_2", Hud_btnmash.handles.sticks_tog_h)				--Find tween inside anim 
  257. 		vint_set_property(twn_h, "end_event", "hud_btnmash_sticks_tog_loop")							--Set end event callback 
  258. 		vint_set_property(Hud_btnmash.handles.sticks_tog_h, "is_paused", true) 
  259.  
  260. 		Hud_btnmash.handles.btnmash_fade_in_h = vint_object_find("btnmash_fade_in")			--Find animation 
  261. 		vint_set_property(Hud_btnmash.handles.btnmash_fade_in_h, "is_paused", true) 
  262. 		 
  263. 		Hud_btnmash.handles.btnmash_fade_out_h = vint_object_find("btnmash_fade_out") 
  264. 		twn_h = vint_object_find("fade_out", Hud_btnmash.handles.btnmash_fade_out_h) 
  265. 		vint_set_property(twn_h, "end_event", "hud_btnmash_fade_out_end")	 
  266. 		vint_set_property(Hud_btnmash.handles.btnmash_fade_out_h, "is_paused", true) 
  267. 		 
  268. 		 
  269. 		 
  270. 		--SIXAXIS I FUGGIN LOVE YOU 
  271. 		--LR 
  272. 		Hud_btnmash.handles.sixaxis_lr_anim_h = vint_object_find("sixaxis_lr_anim")			--Find animation 
  273. 		twn_h = vint_object_find("sixaxis_lr_center_alpha_twn_4", Hud_btnmash.handles.sixaxis_lr_anim_h)				--Find tween inside anim 
  274. 		vint_set_property(twn_h, "end_event", "sixaxis_lr_anim_loop")							--Set end event callback 
  275. 		vint_set_property(Hud_btnmash.handles.sixaxis_lr_anim_h, "is_paused", true) 
  276. 		--FB 
  277. 		Hud_btnmash.handles.sixaxis_fb_anim_h = vint_object_find("sixaxis_fb_anim")			--Find animation 
  278. 		twn_h = vint_object_find("sixaxis_fb_center_alpha_twn_4", Hud_btnmash.handles.sixaxis_fb_anim_h)				--Find tween inside anim 
  279. 		vint_set_property(twn_h, "end_event", "sixaxis_fb_anim_loop")							--Set end event callback 
  280. 		vint_set_property(Hud_btnmash.handles.sixaxis_fb_anim_h, "is_paused", true) 
  281. 	 
  282. 	--subscription 
  283. 	vint_dataitem_add_subscription("button_mashing_minigame", "update", "hud_btnmash_update") 
  284. 	 
  285.  
  286. 	Hud_btnmash.handles.last_index = -1 
  287. 	 
  288. end 
  289.  
  290.  
  291. function sixaxis_lr_anim_loop() 
  292. 	lua_play_anim(Hud_btnmash.handles.sixaxis_lr_anim_h, 0) 
  293. end 
  294.  
  295. function sixaxis_fb_anim_loop() 
  296. 	lua_play_anim(Hud_btnmash.handles.sixaxis_fb_anim_h, 0) 
  297. end 
  298.  
  299. function hud_btnmash_fade_out_end() 
  300. 		 
  301. 		vint_set_property(Hud_btnmash.handles.meter_grp_h, "visible", false) 
  302. 		vint_set_property(Hud_btnmash.handles.status_grp_h, "visible", false) 
  303. 		vint_set_property(Hud_btnmash.handles.giant_buttons_grp_1_h, "visible", false) 
  304. 		vint_set_property(Hud_btnmash.handles.giant_buttons_grp_2_h, "visible", false) 
  305. 		vint_set_property(Hud_btnmash.handles.trigger_l_grp_h, "visible", false) 
  306. 		vint_set_property(Hud_btnmash.handles.trigger_r_grp_h, "visible", false) 
  307. 		vint_set_property(Hud_btnmash.handles.sticks_grp_h, "visible", false) 
  308.  
  309. end 
  310.  
  311. function hud_btnmash_fade_out_pause_all() 
  312. 		vint_set_property(Hud_btnmash.handles.lt_rt_alt_h , "is_paused", true) 
  313. 		vint_set_property(Hud_btnmash.handles.lt_rt_tog_h, "is_paused", true) 
  314. 		vint_set_property(Hud_btnmash.handles.lt_only_h, "is_paused", true) 
  315. 		vint_set_property(Hud_btnmash.handles.rt_only_h, "is_paused", true) 
  316. 		vint_set_property(Hud_btnmash.handles.giant_btn_1_anim_h, "is_paused", true) 
  317. 		vint_set_property(Hud_btnmash.handles.giant_btn_2_anim_h, "is_paused", true) 
  318. 		vint_set_property(Hud_btnmash.handles.status_anim_h , "is_paused", true) 
  319. 		vint_set_property(Hud_btnmash.handles.bar_flash_anim_h, "is_paused", true) 
  320. 		vint_set_property(Hud_btnmash.handles.bar_blink_anim_h, "is_paused", true) 
  321. 		vint_set_property(Hud_btnmash.handles.sticks_alt_h, "is_paused", true) 
  322. 		vint_set_property(Hud_btnmash.handles.sticks_tog_h, "is_paused", true) 
  323. 		vint_set_property(Hud_btnmash.handles.btnmash_fade_in_h, "is_paused", true) 
  324. 		vint_set_property(Hud_btnmash.handles.btnmash_fade_out_h, "is_paused", true) 
  325. 		vint_set_property(Hud_btnmash.handles.sixaxis_lr_anim_h , "is_paused", true) 
  326. 		vint_set_property(Hud_btnmash.handles.sixaxis_fb_anim_h , "is_paused", true) 
  327. 		 
  328. end 
  329.  
  330. function hud_btnmash_lt_rt_alt_loop() 
  331. 	vint_set_property(Hud_btnmash.handles.lt_only_h, "is_paused", true) 
  332. 	vint_set_property(Hud_btnmash.handles.rt_only_h, "is_paused", true) 
  333. 	vint_set_property(Hud_btnmash.handles.lt_rt_tog_h, "is_paused", true) 
  334. 	lua_play_anim(Hud_btnmash.handles.lt_rt_alt_h, 0) 
  335. end 
  336.  
  337. function hud_btnmash_lt_rt_tog_loop() 
  338. 	vint_set_property(Hud_btnmash.handles.lt_only_h, "is_paused", true) 
  339. 	vint_set_property(Hud_btnmash.handles.rt_only_h, "is_paused", true) 
  340. 	vint_set_property(Hud_btnmash.handles.lt_rt_alt_h, "is_paused", true)	 
  341. 	lua_play_anim(Hud_btnmash.handles.lt_rt_tog_h, 0) 
  342. end 
  343.  
  344. function hud_btnmash_lt_only_loop() 
  345. 	vint_set_property(Hud_btnmash.handles.rt_only_h, "is_paused", true) 
  346. 	vint_set_property(Hud_btnmash.handles.lt_rt_alt_h, "is_paused", true) 
  347. 	vint_set_property(Hud_btnmash.handles.lt_rt_tog_h, "is_paused", true) 
  348. 	lua_play_anim(Hud_btnmash.handles.lt_only_h, 0) 
  349. end 
  350.  
  351. function hud_btnmash_rt_only_loop() 
  352. 	vint_set_property(Hud_btnmash.handles.lt_only_h, "is_paused", true) 
  353. 	vint_set_property(Hud_btnmash.handles.lt_rt_alt_h, "is_paused", true) 
  354. 	vint_set_property(Hud_btnmash.handles.lt_rt_tog_h, "is_paused", true) 
  355. 	lua_play_anim(Hud_btnmash.handles.rt_only_h, 0) 
  356. end 
  357.  
  358. 			 
  359. function hud_btnmash_giant_btn_1_loop() 
  360. 	lua_play_anim(Hud_btnmash.handles.giant_btn_1_anim_h, 0) 
  361. end 
  362.  
  363. function hud_btnmash_giant_btn_2_loop() 
  364. 	lua_play_anim(Hud_btnmash.handles.giant_btn_2_anim_h, 0) 
  365. end 
  366.  
  367. function hud_btnmash_sticks_alt_loop() 
  368. 	lua_play_anim(Hud_btnmash.handles.sticks_alt_h, 0) 
  369. end 
  370.  
  371. function hud_btnmash_sticks_tog_loop() 
  372. 	lua_play_anim(Hud_btnmash.handles.sticks_tog_h, 0) 
  373. end 
  374.  
  375. function hud_btnmash_bar_blink_anim_loop() 
  376. 	lua_play_anim(Hud_btnmash.handles.bar_blink_anim_h, 0) 
  377. end 
  378.  
  379. function hud_btnmash_status_anim_loop() 
  380. 	lua_play_anim(Hud_btnmash.handles.status_anim_h, 0) 
  381. end 
  382.  
  383.  
  384.  
  385. function hud_btnmash_update(di_h, event) 
  386.  
  387. 	local pct_done, button_set_index, is_ps3, player_input_this_frame = vint_dataitem_get(di_h) 
  388.  
  389. 		 
  390. 	--language to local var 
  391. 	local language = Hud_btnmash.handles.language 
  392. 	 
  393. 	--stop blinking the bar if the player didnt shock the victim 
  394. 	if Hud_btnmash.handles.last_index == 5 and button_set_index ~= 5 then 
  395. 		lua_play_anim(Hud_btnmash.handles.bar_blink_anim_h, 0) 
  396. 		vint_set_property(Hud_btnmash.handles.bar_blink_anim_h, "is_paused", true) 
  397. 	end 
  398. 	 
  399. 	--shock shaking 
  400. 	if button_set_index == 5 then 
  401. 		local randrot = -0.05 + rand_float(0.00, 0.1) 
  402. 		local randsx = rand_int(90,120)/100 
  403. 		local randsy = rand_int(85,110)/100 
  404. 		local randalpha = rand_float(0.2, 0.6) 
  405. 		local randanchor = rand_int(0,8) 
  406. 		vint_set_property(Hud_btnmash.handles.status_grp_h, "scale", randsx, randsy) 
  407. 		vint_set_property(Hud_btnmash.handles.status_grp_h, "rotation", randrot) 
  408. 		vint_set_property(Hud_btnmash.handles.status_2_h, "alpha", randalpha) 
  409. 		vint_set_property(Hud_btnmash.handles.status_grp_h, "anchor", randanchor, randanchor + 15) 
  410. 	else 
  411. 		vint_set_property(Hud_btnmash.handles.status_grp_h, "scale", 1, 1) 
  412. 		vint_set_property(Hud_btnmash.handles.status_grp_h, "rotation", 0) 
  413. 		vint_set_property(Hud_btnmash.handles.status_grp_h, "anchor", 0, 15) 
  414. 	end 
  415. 	 
  416. 	 
  417. 	 
  418. 	if button_set_index ~= -1 then 
  419. 		--show meter 
  420. 		vint_set_property(Hud_btnmash.handles.meter_grp_h, "visible", true) 
  421. 		 
  422. 				 
  423. 		--override randomly generated health pct for SHOCK with 1 
  424. 		if button_set_index == 5 then 
  425. 			pct_done = 1 
  426. 		end 
  427. 		 
  428. 		--meter colors 
  429. 		if button_set_index >= 0 and button_set_index <= 4 then 
  430. 			--fight club colors 
  431. 			local color_low = {["r"]=0.8, ["g"]=0, ["b"]=0} 
  432. 			local color_high = {["r"]=0.92, ["g"]=0.85, ["b"]=0.01} 
  433. 			local color_mid = {["r"]=((color_high.r - color_low.r) * pct_done) + color_low.r, ["g"]=((color_high.g - color_low.g) * pct_done) + color_low.g ,  ["b"]=((color_high.b - color_low.b) * pct_done) + color_low.b} 
  434. 			vint_set_property(Hud_btnmash.handles.meter_fill_1_h, "tint", color_mid.r, color_mid.g, color_mid.b) 
  435. 			vint_set_property(Hud_btnmash.handles.meter_fill_2_h, "tint", color_mid.r, color_mid.g, color_mid.b) 
  436. 		elseif button_set_index == 7 then 
  437. 			--chest compressions 
  438. 			local color_low = {["r"]=0.70, ["g"]=0.55, ["b"]=0.06} 
  439. 			local color_high = {["r"]=0.93, ["g"]=0.86, ["b"]=0.23} 
  440. 			local color_mid = {["r"]=((color_high.r - color_low.r) * pct_done) + color_low.r, ["g"]=((color_high.g - color_low.g) * pct_done) + color_low.g ,  ["b"]=((color_high.b - color_low.b) * pct_done) + color_low.b}	 
  441. 			vint_set_property(Hud_btnmash.handles.meter_fill_1_h, "tint", color_mid.r, color_mid.g, color_mid.b) 
  442. 			vint_set_property(Hud_btnmash.handles.meter_fill_2_h, "tint", color_mid.r, color_mid.g, color_mid.b) 
  443. 		else 
  444. 			--shock paddles colors 
  445. 			local color_low = {["r"]=0.28, ["g"]=0.34, ["b"]=0.80} 
  446. 			local color_high = {["r"]=0.40, ["g"]=0.53, ["b"]=0.92} 
  447. 			local color_mid = {["r"]=((color_high.r - color_low.r) * pct_done) + color_low.r, ["g"]=((color_high.g - color_low.g) * pct_done) + color_low.g ,  ["b"]=((color_high.b - color_low.b) * pct_done) + color_low.b}	 
  448. 			vint_set_property(Hud_btnmash.handles.meter_fill_1_h, "tint", color_mid.r, color_mid.g, color_mid.b) 
  449. 			vint_set_property(Hud_btnmash.handles.meter_fill_2_h, "tint", color_mid.r, color_mid.g, color_mid.b) 
  450. 		end 
  451. 		 
  452. 		--flash bar on user input 
  453. 		if player_input_this_frame == true then 
  454. 			lua_play_anim(Hud_btnmash.handles.bar_flash_anim_h, 0) 
  455. 		end 
  456.  
  457. 		--if the buttons change, swap em out 
  458. 		if button_set_index ~= Hud_btnmash.handles.last_index then 
  459.  
  460. 			--fade in if btn_mash_grp is transparent 
  461. 			if vint_get_property(Hud_btnmash.handles.btn_mash_h, "alpha") == 0 then 
  462. 				lua_play_anim(Hud_btnmash.handles.btnmash_fade_in_h, 0) 
  463. 			end 
  464. 				 
  465. 			--button 1	 
  466. 			if button_set_index == 0 then	 
  467. 				if Hud_btnmash.handles.sixaxis_h == false then 
  468. 					vint_set_property(Hud_btnmash.handles.giant_buttons_grp_1_h, "visible", true) 
  469. 					hud_btnmash_giant_btn_1_loop() 
  470. 				end 
  471. 			else 
  472. 				vint_set_property(Hud_btnmash.handles.giant_buttons_grp_1_h, "visible", false) 
  473. 				 
  474. 			end 
  475. 			 
  476. 			--button 2 
  477. 			if button_set_index == 1 then 
  478. 				if Hud_btnmash.handles.sixaxis_h == false then 
  479. 					vint_set_property(Hud_btnmash.handles.giant_buttons_grp_2_h, "visible", true) 
  480. 					hud_btnmash_giant_btn_2_loop() 
  481. 				end 
  482. 			else 
  483. 				vint_set_property(Hud_btnmash.handles.giant_buttons_grp_2_h, "visible", false) 
  484. 			end 
  485.  
  486. 			--triggers 
  487. 			if button_set_index == 2 then 
  488. 				vint_set_property(Hud_btnmash.handles.status_grp_h, "visible", false)	 
  489. 				--left trigger 
  490. 				vint_set_property(Hud_btnmash.handles.trigger_l_grp_h, "visible", true) 
  491. 				vint_set_property(Hud_btnmash.handles.trigger_r_grp_h, "visible", true) 
  492. 				--do this shit 
  493. 				hud_btnmash_lt_only_loop() 
  494. 				--Hud_btnmash.handles.last_index = button_set_index	 
  495. 			elseif button_set_index == 3 then 
  496. 				vint_set_property(Hud_btnmash.handles.status_grp_h, "visible", false) 
  497. 				--right trigger 
  498. 				vint_set_property(Hud_btnmash.handles.trigger_l_grp_h, "visible", true) 
  499. 				vint_set_property(Hud_btnmash.handles.trigger_r_grp_h, "visible", true) 
  500. 				--do this shit 
  501. 				hud_btnmash_rt_only_loop()				 
  502. 				--Hud_btnmash.handles.last_index = button_set_index 
  503. 			elseif button_set_index == 4 then 
  504. 				vint_set_property(Hud_btnmash.handles.status_grp_h, "visible", false) 
  505. 				--both triggers, alt 
  506. 				vint_set_property(Hud_btnmash.handles.trigger_l_grp_h, "visible", true) 
  507. 				vint_set_property(Hud_btnmash.handles.trigger_r_grp_h, "visible", true)				 
  508. 				--do this shit 
  509. 				hud_btnmash_lt_rt_alt_loop() 
  510. 				--Hud_btnmash.handles.last_index = button_set_index 
  511. 			elseif button_set_index == 5 then 
  512. 				vint_set_property(Hud_btnmash.handles.status_grp_h, "visible", true) 
  513. 				--shock! 
  514. 				vint_set_property(Hud_btnmash.handles.status_1_h, "image", "ui_btnmash_t_" .. language .. "_shock") 
  515. 				vint_set_property(Hud_btnmash.handles.status_2_h, "image", "ui_btnmash_t_" .. language .. "_shock") 
  516. 				--both triggers, together 
  517. 				vint_set_property(Hud_btnmash.handles.trigger_l_grp_h, "visible", true) 
  518. 				vint_set_property(Hud_btnmash.handles.trigger_r_grp_h, "visible", true) 
  519. 				--do this shit 
  520. 				hud_btnmash_lt_rt_tog_loop() 
  521. 				hud_btnmash_bar_blink_anim_loop()			 
  522. 			else  
  523. 				vint_set_property(Hud_btnmash.handles.trigger_l_grp_h, "visible", false) 
  524. 				vint_set_property(Hud_btnmash.handles.trigger_r_grp_h, "visible", false)	 
  525. 			end 
  526. 			 
  527. 			--STICKS 
  528. 			if button_set_index == 6 then 
  529. 				--sticks, alternating 
  530. 				vint_set_property(Hud_btnmash.handles.status_1_h, "image", "ui_btnmash_t_" .. language .. "_charge") 
  531. 				vint_set_property(Hud_btnmash.handles.status_2_h, "image", "ui_btnmash_t_" .. language .. "_charge")	 
  532. 				hud_btnmash_status_anim_loop() 
  533. 				if Hud_btnmash.handles.sixaxis_h == false then	 
  534. 					vint_set_property(Hud_btnmash.handles.sticks_grp_h, "visible", true)	 
  535. 					hud_btnmash_sticks_alt_loop()								 
  536. 				end 
  537. 				 
  538. 			elseif button_set_index == 7 then 
  539. 				--sticks, together 
  540. 				vint_set_property(Hud_btnmash.handles.status_1_h, "image", "ui_btnmash_t_" .. language .. "_chest") 
  541. 				vint_set_property(Hud_btnmash.handles.status_2_h, "image", "ui_btnmash_t_" .. language .. "_chest")				 
  542. 				hud_btnmash_status_anim_loop() 
  543. 				if Hud_btnmash.handles.sixaxis_h == false then		 
  544. 					vint_set_property(Hud_btnmash.handles.sticks_grp_h, "visible", true)		 
  545. 					hud_btnmash_sticks_tog_loop()								 
  546. 				end 
  547. 			else 
  548. 				vint_set_property(Hud_btnmash.handles.sticks_grp_h, "visible", false) 
  549. 			end 
  550. 			 
  551. 			 
  552. 			--SIXAXIS 	 
  553. 			if button_set_index == 1 or button_set_index == 7  then 
  554. 				--if all this is true, then do the sixaxis fwd-back tilt 
  555. 				if Hud_btnmash.handles.sixaxis_h == true then 
  556. 					vint_set_property(Hud_btnmash.handles.sixaxis_fb_h, "visible", true) 
  557. 					sixaxis_fb_anim_loop() 
  558. 					Hud_btnmash.handles.last_index = button_set_index 
  559. 				end 
  560. 			else 
  561. 				vint_set_property(Hud_btnmash.handles.sixaxis_fb_h, "visible", false) 
  562. 			end 
  563. 				 
  564.  
  565. 			if button_set_index == 0 or button_set_index == 6 then 
  566. 				--if all this is true, then do the sixaxis left-right tilt 
  567. 				if Hud_btnmash.handles.sixaxis_h == true then 
  568. 					vint_set_property(Hud_btnmash.handles.sixaxis_lr_h, "visible", true) 
  569. 					sixaxis_lr_anim_loop() 
  570. 					Hud_btnmash.handles.last_index = button_set_index 
  571. 				end 
  572. 			else 
  573. 				vint_set_property(Hud_btnmash.handles.sixaxis_lr_h, "visible", false) 
  574. 			end			 
  575. 			 
  576. 			--STATUS TEXT 
  577. 			if button_set_index > 4 and button_set_index < 8 then 
  578. 				vint_set_property(Hud_btnmash.handles.status_grp_h, "visible", true) 
  579. 			else 
  580. 				vint_set_property(Hud_btnmash.handles.status_grp_h, "visible", false) 
  581. 			end 
  582. 			 
  583. 			Hud_btnmash.handles.last_index = button_set_index 
  584. 			 
  585. 		end 
  586. 			 
  587. 	else 
  588. 		hud_btnmash_fade_out_pause_all() 
  589. 		lua_play_anim(Hud_btnmash.handles.btnmash_fade_out_h, 0) 
  590. 		Hud_btnmash.handles.last_index = -1 
  591. 	end 
  592. 	 
  593. 		--update the pct_done bar 
  594. 		vint_set_property(Hud_btnmash.handles.meter_fill_1_h, "source_se", 288 * pct_done, 10) 
  595. 		vint_set_property(Hud_btnmash.handles.meter_fill_2_h, "source_se", 288 * pct_done, 10) 
  596. 		vint_set_property(Hud_btnmash.handles.meter_border_h, "source_se", (288 * pct_done) + 4, 14) 
  597. 		 
  598. 		 
  599. 	 
  600. end 
  601.  
  602.  
  603. function hud_btnmash_cleanup() 
  604. 	--Unload Pegs 
  605. 	vint_set_property(Hud_btnmash.handles.btn_mash_h, "visible", false) 
  606. 	peg_unload("ui_btnmash_" .. Hud_btnmash.handles.platform) 
  607. 	peg_unload("ui_btnmash_t_" .. Hud_btnmash.handles.language) 
  608. end 
  609.  
  610.