./hud_touch_combo.lua

  1. --#####################################################################  
  2. --Touch Combo System 
  3. --##################################################################### 
  4.  
  5. -- show_mode 
  6. -- 0 = Show Right stick 
  7. -- 1 = Show Both sticks 
  8. -- 2 = Show Right stick, dim left stick. 
  9.  
  10. Sexy_time_tween = -1 
  11.  
  12. Hud_touch_combo_input_gamepad = true 
  13.  
  14. Hud_combo_elements = { 
  15. 	main_grp_h = -1, 
  16. 	left_grp_h = -1,  
  17. 	left_stick_h = -1, 
  18. 	left_stick_stick_h = -1, 
  19. 	keyboard_h = -1, 
  20. 	left_highlight = -1, 
  21. 	hud_left_stick_highlight = { 
  22. 		[1] = -1, 
  23. 		[2] = -1, 
  24. 		[3] = -1, 
  25. 		[4] = -1, 
  26. 	}, 
  27. 	right_grp_h = -1, 
  28. 	right_stick_h = -1, 
  29. 	right_highlight = -1, 
  30. 	target_dot_h = -1, 
  31. 	help_txt_grp_h = -1, 
  32. } 
  33.  
  34.  
  35. local TOUCH_COMBO_SHOW_MODE_RIGHT 			= 0	--Shows right side... 
  36. local TOUCH_COMBO_SHOW_MODE_LEFT				= 1	--Shows left side. 
  37. local TOUCH_COMBO_SHOW_MODE_RIGHT_MISTAKE	= 2	--When the user slips off the right stick they need to correct it. 
  38.  
  39. Hud_touch_combo_status = { 
  40. 	combo_active = false, 
  41. 	show_mode = -1, 
  42. 	help_text = "", 
  43. 	left_stick_x = 0.0, 
  44. 	left_stick_x = 0.0, 
  45. 	right_stick_x = 0.0, 
  46. 	right_stick_y = 0.0, 
  47. 	rumble_level = -1, 
  48. 	grp_x = 640, 
  49. 	grp_y = 360, 
  50. } 
  51.  
  52. --PC Keys. 
  53. Hud_sexy_key_w = 0 
  54. Hud_sexy_key_n = 0 
  55. Hud_sexy_key_e = 0 
  56. Hud_sexy_key_s = 0 
  57.  
  58. function hud_touch_combo_init() 
  59. 	 
  60. 	--Get our gamepad status, we use this to determine what graphics to show... 
  61. 	Hud_touch_combo_input_gamepad = game_is_active_input_gamepad() 
  62.  
  63. 	--Hide everything when we first boot up... 
  64. 	Hud_combo_elements.main_grp_h = vint_object_find("combo_grp") 
  65. 	vint_set_property(Hud_combo_elements.main_grp_h, "visible", false)  
  66. 	 
  67. 	--Store initial position of main group... 
  68. 	local x, y = vint_get_property(Hud_combo_elements.main_grp_h, "anchor") 
  69. 	Hud_touch_combo_status.grp_x = x 
  70. 	Hud_touch_combo_status.grp_y = y 
  71. 	 
  72. 	--base help text object... 
  73. 	Hud_combo_elements.help_txt_grp_h 				= vint_object_find("help_txt_grp") 					-- Base help text object 
  74. 	Hud_combo_elements.help_txt_h 					= vint_object_find("help_txt") 						-- Text object 
  75. 	Hud_combo_elements.help_txt_bg_h 				= vint_object_find("help_txt_bg") 					-- Right big glow 
  76. 	Hud_combo_elements.help_txt_fade_out_anim_h 	= vint_object_find("help_text_fade_out_anim") 	-- Right big glow 
  77. 	 
  78. 	--Keyboard mouse... 
  79. 	local keyboard_mouse_grp_h 				= vint_object_find("keyboard_mouse_grp") 
  80. 	Hud_combo_elements.keyboard_h 			= vint_object_find("keyboard_grp", 			keyboard_mouse_grp_h) 
  81. 	Hud_combo_elements.mouse_grp_h 			= vint_object_find("mouse_grp", 				keyboard_mouse_grp_h) 
  82. 	Hud_combo_elements.mouse_h 				= vint_object_find("mouse", 				keyboard_mouse_grp_h) 
  83. 	Hud_combo_elements.mouse_marker_big_h 	= vint_object_find("mouse_marker_big", 	keyboard_mouse_grp_h) 
  84. 	Hud_combo_elements.mouse_marker_h 		= vint_object_find("mouse_marker", 			keyboard_mouse_grp_h) 
  85. 	Hud_combo_elements.mouse_bg_h 			= vint_object_find("mouse_bg")					--Right Stick Circle... 
  86. 	 
  87. 	local stick_grp_h = vint_object_find("stick_grp") 
  88. 	 
  89. 	--hide type depending on what mode we are in... 
  90. 	if Hud_touch_combo_input_gamepad then 
  91. 		vint_set_property(keyboard_mouse_grp_h, "visible", false) 
  92. 		vint_set_property(stick_grp_h, "visible", true) 
  93. 	else 
  94. 		vint_set_property(keyboard_mouse_grp_h, "visible", true) 
  95. 		vint_set_property(stick_grp_h, "visible", false) 
  96. 	end 
  97. 	 
  98. 	--Left Stick Group 
  99. 	local h = vint_object_find("left_stick")																	 
  100. 	Hud_combo_elements.left_stick_h = vint_object_find("stick_l", h) 
  101. 	Hud_combo_elements.left_stick_hl_h = vint_object_find("stick_l_hl", h)	--Left Stick  
  102. 	Hud_combo_elements.left_circle_h = vint_object_find("l_bg", h) 
  103. 	 
  104. 	-- Fix the image. 
  105. 	local platform = game_get_platform() 
  106. 	if (platform == "PS3") then  
  107. 		 
  108. 		--Right Stick and highlight... 
  109. 		local stick_bmp_h = vint_object_find("stick_bmp", Hud_combo_elements.left_stick_h) 
  110. 		local stick_l_hl_h = vint_object_find("stick_l_hl", Hud_combo_elements.left_stick_h) 
  111. 		vint_set_property(stick_bmp_h, "image", "ui_hud_combo_thumb_ps3") 
  112. 		vint_set_property(stick_l_hl_h, "image", "ui_hud_combo_thumb_ps3") 
  113. 		 
  114. 		--Right stick text... 
  115. 		local stick_txt_h = vint_object_find("stick_txt", Hud_combo_elements.left_stick_h ) 
  116. 		vint_set_property(stick_txt_h, "text_tag", "L") 
  117. 	elseif (platform == "PS4") then	-- HVS_JRP[PRINCE] 3/18/2014 
  118. 		 
  119. 		--Right Stick and highlight... 
  120. 		local stick_bmp_h = vint_object_find("stick_bmp", Hud_combo_elements.left_stick_h) 
  121. 		local stick_l_hl_h = vint_object_find("stick_l_hl", Hud_combo_elements.left_stick_h) 
  122. 		vint_set_property(stick_bmp_h, "image", "ui_hud_combo_thumb_ps4") 
  123. 		vint_set_property(stick_l_hl_h, "image", "ui_hud_combo_thumb_ps4") 
  124. 		 
  125. 		--Right stick text... 
  126. 		local stick_txt_h = vint_object_find("stick_txt", Hud_combo_elements.left_stick_h ) 
  127. 		vint_set_property(stick_txt_h, "text_tag", "L") 
  128. 	end 
  129. 	 
  130. 	--Left stick arrows... 
  131. 	Hud_combo_elements.left_stick_stick_h 		= vint_object_find("left_stick_stick", h) 
  132.  
  133. 	Hud_combo_elements.hud_left_stick_highlight[1] = vint_object_find("combo_arrow_n", h)	--Left Highlight North 
  134. 	Hud_combo_elements.hud_left_stick_highlight[2] = vint_object_find("combo_arrow_s", h)	--Left Highlight South 
  135. 	Hud_combo_elements.hud_left_stick_highlight[3] = vint_object_find("combo_arrow_w", h)	--Left Highlight West 
  136. 	Hud_combo_elements.hud_left_stick_highlight[4] = vint_object_find("combo_arrow_e", h)	--Left Highlight East	 
  137. 	 
  138. 	--Right Stick... 
  139. 	local h = vint_object_find("right_stick") 
  140. 	Hud_combo_elements.right_grp_h = h															--Right Stick Group 
  141. 	Hud_combo_elements.right_stick_h = vint_object_find("stick_r", h)					--Right Stick  
  142. 	Hud_combo_elements.right_stick_hl_h = vint_object_find("stick_r_hl", h)			--Right Stick Highlight 
  143. 	Hud_combo_elements.right_circle_h = vint_object_find("r_bg", h)					--Right Stick Circle... 
  144.  
  145.  
  146. 	-- fix the image 
  147. 	if (platform == "PS3") then  
  148. 		--Left Stick and highlight... 
  149. 		local stick_bmp_h = vint_object_find("stick_bmp", Hud_combo_elements.right_stick_h )	 
  150. 		local stick_r_hl_h = vint_object_find("stick_r_hl", Hud_combo_elements.right_stick_h )		 
  151. 		vint_set_property(stick_bmp_h, 	"image", 	"ui_hud_combo_thumb_ps3") 
  152. 		vint_set_property(stick_r_hl_h, 	"image", 	"ui_hud_combo_thumb_ps3") 
  153. 		 
  154. 		local stick_txt_h = vint_object_find("stick_txt", Hud_combo_elements.right_stick_h )								--Left Stick  
  155. 		vint_set_property(stick_txt_h, "text_tag", "R") 
  156. 	elseif (platform == "PS4") then	-- HVS_JRP[PRINCE] 3/18/2014 
  157. 		--Left Stick and highlight... 
  158. 		local stick_bmp_h = vint_object_find("stick_bmp", Hud_combo_elements.right_stick_h )	 
  159. 		local stick_r_hl_h = vint_object_find("stick_r_hl", Hud_combo_elements.right_stick_h )		 
  160. 		vint_set_property(stick_bmp_h, 	"image", 	"ui_hud_combo_thumb_ps4") 
  161. 		vint_set_property(stick_r_hl_h, 	"image", 	"ui_hud_combo_thumb_ps4") 
  162. 		 
  163. 		local stick_txt_h = vint_object_find("stick_txt", Hud_combo_elements.right_stick_h )								--Left Stick  
  164. 		vint_set_property(stick_txt_h, "text_tag", "R") 
  165. 	end 
  166.  
  167. 	Hud_combo_elements.target_dot_h = vint_object_find("marker", h)	--Right marker 
  168. 	Hud_combo_elements.target_dot_big_h = vint_object_find("marker_big", h) --right big glow 
  169.  
  170. 	--animations, rumble 
  171. 	Hud_combo_elements.right_stick_rumble_light_anim_h = vint_object_find("combo_stick_shake_light_anim") 
  172. 	Hud_combo_elements.right_stick_rumble_heavy_anim_h = vint_object_find("combo_stick_shake_heavy_anim") 
  173. 	Hud_combo_elements.mouse_rumble_light_anim_h = vint_object_find("mouse_shake_light_anim")  
  174. 	Hud_combo_elements.mouse_rumble_heavy_anim_h = vint_object_find("mouse_shake_heavy_anim") 
  175. 	 
  176. 	 
  177. 	--stick blink 
  178. 	Hud_combo_elements.combo_stick_hl_l = vint_object_find("combo_stick_hl_l") 
  179. 	Hud_combo_elements.combo_stick_hl_r = vint_object_find("combo_stick_hl_r") 
  180. 	vint_set_property(Hud_combo_elements.combo_stick_hl_l, "is_paused", true) 
  181. 	vint_set_property(Hud_combo_elements.combo_stick_hl_r, "is_paused", true) 
  182. 	--fade in 
  183. 	Hud_combo_elements.combo_sticks_fade_in_anim_h = vint_object_find("combo_sticks_fade_in_anim") 
  184. 	vint_set_property(Hud_combo_elements.combo_sticks_fade_in_anim_h, "is_paused", true) 
  185. 	--fade out 
  186. 	Hud_combo_elements.combo_sticks_fade_out_anim_h = vint_object_find("combo_sticks_fade_out_anim") 
  187. 	vint_set_property(Hud_combo_elements.combo_sticks_fade_out_anim_h, "is_paused", true) 
  188. 		 
  189. 	--build keyboard for left side 
  190. 	if not Hud_touch_combo_input_gamepad then 
  191. 		--Hide left stick...		 
  192. 		local stick_txt_h = vint_object_find("stick_txt", Hud_combo_elements.right_stick_h ) 
  193. 		vint_set_property(stick_txt_h, "visible", false) 
  194. 		 
  195. 		--Create left side keyboard... 
  196. 		local keyboard_h = vint_object_find("keyboard_grp") 
  197. 		Hud_sexy_key_w = Vdo_qte_key:new("sexy_key_w", keyboard_h) 
  198. 		Hud_sexy_key_n = Vdo_qte_key:new("sexy_key_n", keyboard_h) 
  199. 		Hud_sexy_key_e = Vdo_qte_key:new("sexy_key_e", keyboard_h) 
  200. 		Hud_sexy_key_s = Vdo_qte_key:new("sexy_key_s", keyboard_h) 
  201. 		 
  202. 		Hud_sexy_key_w:show_arrows(true) 
  203. 		Hud_sexy_key_n:show_arrows(true) 
  204. 		Hud_sexy_key_s:show_arrows(true) 
  205. 		Hud_sexy_key_e:show_arrows(true) 
  206. 		 
  207. 		local up_action_name, down_action_name = get_get_key_names_for_axis_action("CAA_WALK_FORWARD_BACKWARD") 
  208. 		local right_action_name, left_action_name = get_get_key_names_for_axis_action("CAA_WALK_TURN_LEFT_RIGHT") 
  209. 		 
  210. 		 
  211. 		Hud_sexy_key_w:set_text(left_action_name) 
  212. 		Hud_sexy_key_n:set_text(up_action_name) 
  213. 		Hud_sexy_key_e:set_text(right_action_name) 
  214. 		Hud_sexy_key_s:set_text(down_action_name) 
  215. 		Hud_sexy_key_w:set_arrow_direction(3) 
  216. 		Hud_sexy_key_n:set_arrow_direction(1) 
  217. 		Hud_sexy_key_s:set_arrow_direction(2) 
  218. 		Hud_sexy_key_e:set_arrow_direction(4) 
  219. 	 
  220. 		local key_scale = vint_get_property(Hud_sexy_key_w.handle, "scale") 
  221. 		 
  222. 		--get width of each key 
  223. 		local w_width = Hud_sexy_key_w:get_width() * key_scale 
  224. 		local n_width = Hud_sexy_key_n:get_width() * key_scale 
  225. 		local e_width = Hud_sexy_key_e:get_width() * key_scale 
  226. 		local s_width = Hud_sexy_key_s:get_width() * key_scale 
  227.  
  228. 		--center north icon 
  229. 		local x, y = vint_get_property(Hud_sexy_key_n.handle, "anchor") 
  230. 		vint_set_property(Hud_sexy_key_n.handle, "anchor", -n_width * .5, y) 
  231. 		 
  232. 		--center south icon 
  233. 		local s_width_half = s_width * 0.5 
  234. 		local key_spacing = 10 
  235. 		local base_x, base_y = vint_get_property(Hud_sexy_key_s.handle, "anchor") 
  236. 		vint_set_property(Hud_sexy_key_s.handle, "anchor", -s_width_half, base_y) 
  237. 		 
  238. 		--west icon 
  239. 		local x, y = vint_get_property(Hud_sexy_key_w.handle, "anchor") 
  240. 		vint_set_property(Hud_sexy_key_w.handle, "anchor", - s_width_half - key_spacing - (w_width), base_y) 
  241. 		local start_x = x 
  242. 		 
  243. 		 
  244. 		--east icon 
  245. 		local x, y = vint_get_property(Hud_sexy_key_e.handle, "anchor") 
  246. 		vint_set_property(Hud_sexy_key_e.handle, "anchor",  s_width_half + key_spacing, base_y) 
  247. 		local end_x = s_width_half + key_spacing 
  248. 		 
  249. 		local total_width = e_width + end_x + abs(start_x) 
  250. 		local x, y = vint_get_property(keyboard_h, "anchor") 
  251. 		local base_width = 193 
  252. 		if total_width > base_width then 
  253. 			vint_set_property(keyboard_h, "anchor", x - ((total_width - base_width) * 0.5) - 20, y) 
  254. 		end 
  255. 		 
  256. 		-- Change right side to mouse... 
  257. 		--Left Stick and highlight... 
  258. 		local stick_bmp_h = vint_object_find("stick_bmp", Hud_combo_elements.right_stick_h )	 
  259. 		local stick_r_hl_h = vint_object_find("stick_r_hl", Hud_combo_elements.right_stick_h )		 
  260. 		--[[ 
  261. 		vint_set_property(stick_bmp_h, "image", "ui_qte_mouse_base") 
  262. 		vint_set_property(stick_r_hl_h, "image", "ui_qte_mouse_outline") 
  263. 		vint_set_property(stick_bmp_h, "scale", 0.4, 0.4) 
  264. 		vint_set_property(stick_r_hl_h, "scale", 0.4, 0.4) 
  265. 		 
  266. 		vint_set_property(stick_bmp_h, "auto_offset", "c") 
  267. 		vint_set_property(stick_r_hl_h, "auto_offset", "c") 
  268.  
  269. 		]] 
  270. 		vint_set_property(Hud_combo_elements.left_stick_stick_h, 	"visible", false) 
  271. 		vint_set_property(Hud_combo_elements.keyboard_h,  "visible", true) 
  272. 	end 
  273. 	-- Touch Combo HUD 
  274. 	vint_dataitem_add_subscription("touch_combo_info", "update", "hud_touch_combo_system_update") 
  275. 	vint_dataitem_add_subscription("sexy_time_move_list", "update", "hud_sexy_time_move_list_update") 
  276. end 
  277.  
  278. function hud_touch_combo_system_update(di_h) 
  279. 	local combo_active, show_mode, right_stick_x, right_stick_y, left_stick_x, left_stick_y, target_x, target_y, rumble_level, help_text = vint_dataitem_get(di_h) 
  280. 	 
  281. 	if combo_active ~= Hud_touch_combo_status.combo_active then 
  282. 		Hud_touch_combo_status.combo_active = combo_active 
  283. 		 
  284. 		if combo_active == true then  
  285. 			debug_print("vint", "*** sexy time fade in *** \n") 
  286. 			hud_touch_combo_fade_in() 
  287. 			vint_set_property(Hud_combo_elements.main_grp_h, "visible", true)                                  
  288. 			vint_set_property(Hud_combo_elements.target_dot_h, "visible", false) 
  289. 			vint_set_property(Hud_combo_elements.hud_left_stick_highlight[1], "visible", true) 
  290. 			vint_set_property(Hud_combo_elements.hud_left_stick_highlight[2], "visible", true) 
  291. 			vint_set_property(Hud_combo_elements.hud_left_stick_highlight[3], "visible", true) 
  292. 			vint_set_property(Hud_combo_elements.hud_left_stick_highlight[4], "visible", true) 
  293.  
  294. 			vint_set_property(Hud_combo_elements.help_txt_grp_h, "visible", true) -- redisplay the text when restarting the minigame. 
  295. 			vint_set_property(Hud_combo_elements.help_txt_grp_h, "alpha", 1) 
  296. 			lua_play_anim(Hud_combo_elements.help_txt_fade_out_anim_h) 
  297. 		else 
  298. 			debug_print("vint", "*** sexy time fade out *** \n") 
  299. 			hud_touch_combo_fade_out() 
  300. 			hud_touch_combo_rumble_none() 
  301. 			vint_set_property(Hud_combo_elements.main_grp_h, "anchor", Hud_touch_combo_status.grp_x, Hud_touch_combo_status.grp_y) 
  302. 			vint_set_property(Hud_combo_elements.target_dot_big_h, "visible", false) 
  303. 			vint_set_property(Hud_combo_elements.target_dot_h, "visible", false) 
  304. 			vint_set_property(Hud_combo_elements.left_stick_stick_h_h, "alpha", 1)  
  305. 			vint_set_property(Hud_combo_elements.right_grp_h, "alpha", 1)  
  306. 			vint_set_property(Hud_combo_elements.hud_left_stick_highlight[1], "visible", false) 
  307. 			vint_set_property(Hud_combo_elements.hud_left_stick_highlight[2], "visible", false) 
  308. 			vint_set_property(Hud_combo_elements.hud_left_stick_highlight[3], "visible", false) 
  309. 			vint_set_property(Hud_combo_elements.hud_left_stick_highlight[4], "visible", false) 
  310. 			vint_set_property(Hud_combo_elements.help_txt_grp_h, "visible", false) 
  311. 			 
  312. 			vint_set_property(Hud_combo_elements.mouse_marker_big_h, "visible", false) 
  313. 			 
  314. 			return 
  315. 		end 
  316. 	end 
  317.  
  318. 	 
  319. 	if combo_active then 
  320. 		--which stick should we show 
  321. 		hud_touch_combo_sticks_update(left_stick_x, left_stick_y, right_stick_x, right_stick_y, target_x, target_y) 
  322.  
  323. 		--Shift the group around if we are using the left stick... 
  324. 		if show_mode == TOUCH_COMBO_SHOW_MODE_LEFT then 
  325. 			local stick_grp_mult = 7 
  326. 			local new_x = Hud_touch_combo_status.grp_x + (stick_grp_mult * left_stick_x) 
  327. 			local new_y = Hud_touch_combo_status.grp_y + (stick_grp_mult * -left_stick_y) 
  328. 			vint_set_property(Hud_combo_elements.main_grp_h, "anchor", new_x, new_y)			 
  329. 		else 
  330. 			vint_set_property(Hud_combo_elements.main_grp_h, "anchor", Hud_touch_combo_status.grp_x, Hud_touch_combo_status.grp_y) 
  331. 		end 
  332. 		 
  333. 		 
  334. 		 
  335. 		--how much rumble do we have 
  336. 		if Hud_touch_combo_status.rumble_level ~= rumble_level then	 
  337. 			--note: i look for rumble 0 farther down 
  338. 			if rumble_level == 1 then 
  339. 				--cancel the heavy stuff 
  340. 				vint_set_property(Hud_combo_elements.right_stick_rumble_heavy_anim_h, "is_paused", true) 
  341. 				vint_set_property(Hud_combo_elements.mouse_rumble_heavy_aanim_h, "is_paused", true) 
  342. 				--play the light stuff 
  343. 				hud_touch_combo_rumble_light() 
  344. 			elseif rumble_level == 2 then 
  345. 				--cancel the light stuff 
  346. 				vint_set_property(Hud_combo_elements.right_stick_rumble_light_anim_h, "is_paused", true) 
  347. 				vint_set_property(Hud_combo_elements.mouse_rumble_light_anim_h, "is_paused", true) 
  348. 				--play the heavy stuff 
  349. 				hud_touch_combo_rumble_heavy() 
  350. 			end 
  351. 		end 
  352. 		 
  353. 		--find mode, turn off the correct shit 
  354. 		if show_mode ~= Hud_touch_combo_status.show_mode then 
  355. 			if show_mode == TOUCH_COMBO_SHOW_MODE_RIGHT then 
  356. 				-- Show the Right Side, Dim Left. 
  357. 				 
  358. 				--Stick Version.. 
  359. 				vint_set_property(Hud_combo_elements.left_stick_stick_h_h, "alpha", .25)				 
  360. 				vint_set_property(Hud_combo_elements.right_grp_h, "alpha", 1)  
  361. 				vint_set_property(Hud_combo_elements.target_dot_h, "visible", false) 
  362. 				vint_set_property(Hud_combo_elements.target_dot_big_h, "visible", true) 
  363. 				 
  364. 				--Keybaord Version 
  365. 				vint_set_property(Hud_combo_elements.keyboard_h, "alpha", 0) 
  366. 				vint_set_property(Hud_combo_elements.mouse_marker_big_h, "visible", true) 
  367. 				vint_set_property(Hud_combo_elements.mouse_marker_big_h, "alpha", 0) 
  368. 				 
  369. 				hud_touch_combo_blink_right() 
  370. 				 
  371. 			elseif show_mode == TOUCH_COMBO_SHOW_MODE_LEFT then  
  372. 				--show the left stick but dim the right... 
  373. 				 
  374. 				--Stick Version 
  375. 				vint_set_property(Hud_combo_elements.left_stick_stick_h_h, "alpha", 1)  
  376. 				vint_set_property(Hud_combo_elements.right_grp_h, "alpha", 0.25)  
  377. 				vint_set_property(Hud_combo_elements.target_dot_h, "visible", true) 
  378. 				vint_set_property(Hud_combo_elements.target_dot_big_h, "visible", false) 
  379. 				 
  380. 				--Keyboard Version 
  381. 				vint_set_property(Hud_combo_elements.keyboard_h, "alpha", 1) 
  382. 				vint_set_property(Hud_combo_elements.mouse_marker_big_h, "visible", false) 
  383. 				 
  384. 				hud_touch_combo_blink_left() 
  385. 			elseif show_mode == TOUCH_COMBO_SHOW_MODE_RIGHT_MISTAKE then 
  386. 			 
  387. 				--show only the right stick 
  388. 				vint_set_property(Hud_combo_elements.left_stick_stick_h_h, "alpha", 0)  
  389. 				vint_set_property(Hud_combo_elements.keyboard_h, "alpha", 0) 
  390. 				 
  391. 				vint_set_property(Hud_combo_elements.right_grp_h, "alpha", 1)  
  392. 				hud_touch_combo_blink_right() 
  393. 			end 
  394. 		end 
  395. 		 
  396. 		--hide the small dot, or the big dot... 
  397. 		if show_mode == TOUCH_COMBO_SHOW_MODE_RIGHT then 
  398. 			vint_set_property(Hud_combo_elements.target_dot_h, "visible", true) 
  399. 			vint_set_property(Hud_combo_elements.target_dot_big_h, "visible", true) 
  400. 			vint_set_property(Hud_combo_elements.mouse_marker_big_h, "visible", true) 
  401. 			vint_set_property(Hud_combo_elements.mouse_marker_h, "visible", true) 
  402. 				 
  403. 		else 
  404. 			vint_set_property(Hud_combo_elements.target_dot_h, "visible", true) 
  405. 			vint_set_property(Hud_combo_elements.target_dot_big_h, "visible", false) 
  406. 		end	 
  407. 		 
  408. 		if rumble_level == 0 then 
  409. 			hud_touch_combo_rumble_none()	 
  410. 		end 
  411. 		 
  412. 		Hud_touch_combo_status.rumble_level = rumble_level 
  413. 		Hud_touch_combo_status.show_mode = show_mode 
  414. 	end 
  415. 	 
  416. 	 
  417. 	--Update help text 
  418. 	if Hud_touch_combo_status.help_text ~= help_text or help_text == "" then 
  419. 	 
  420. 		if help_text == "" then 
  421. 			vint_set_property(Hud_combo_elements.help_txt_fade_out_anim_h, "is_paused", true) 
  422. 			vint_set_property(Hud_combo_elements.help_txt_grp_h, "alpha", 0) 
  423. 		else  
  424. 			--Play fade out anim... fades out in seven seconds 
  425. 			vint_set_property(Hud_combo_elements.help_txt_grp_h, "alpha", 1) 
  426. 			lua_play_anim(Hud_combo_elements.help_txt_fade_out_anim_h) 
  427. 		end 
  428. 		 
  429. 		--Update text field 
  430. 		vint_set_property(Hud_combo_elements.help_txt_h, "text_tag", help_text) 
  431. 		 
  432. 		--Update background of text 
  433. 		local width, height = element_get_actual_size(Hud_combo_elements.help_txt_h) 
  434. 		local base_width, base_height = element_get_actual_size(Hud_combo_elements.help_txt_bg_h ) 
  435. 		element_set_actual_size(Hud_combo_elements.help_txt_bg_h , width + 15, base_height) 
  436. 			 
  437. 		Hud_touch_combo_status.help_text = help_text		 
  438. 	end 
  439. 	 
  440. 	 
  441. end 
  442.  
  443. function hud_touch_combo_blink_left() 
  444. 	--blink left 
  445. 	lua_play_anim(Hud_combo_elements.combo_stick_hl_l, 0) 
  446. 	vint_set_property(Hud_combo_elements.combo_stick_hl_r, "is_paused", true) 
  447. 	vint_set_property(Hud_combo_elements.right_stick_hl_h, "alpha", 0) 
  448. end 
  449.  
  450. function hud_touch_combo_blink_right() 
  451. 	--blink right 
  452. 	lua_play_anim(Hud_combo_elements.combo_stick_hl_r, 0) 
  453. 	vint_set_property(Hud_combo_elements.combo_stick_hl_l, "is_paused", true) 
  454. 	vint_set_property(Hud_combo_elements.right_stick_hl_h, "alpha", 0) 
  455. end 
  456.  
  457. function hud_touch_combo_rumble_light() 
  458. 	lua_play_anim(Hud_combo_elements.right_stick_rumble_light_anim_h, 0) 
  459. 	lua_play_anim(Hud_combo_elements.mouse_rumble_light_anim_h, 0) 
  460. end 
  461.  
  462. function hud_touch_combo_rumble_heavy() 
  463. 	lua_play_anim(Hud_combo_elements.right_stick_rumble_heavy_anim_h, 0) 
  464. 	lua_play_anim(Hud_combo_elements.mouse_rumble_heavy_anim_h, 0) 
  465. end 
  466.  
  467. function hud_touch_combo_rumble_none() 
  468. 	vint_set_property(Hud_combo_elements.target_dot_big_h, "alpha", 0) 
  469. 	vint_set_property(Hud_combo_elements.target_dot_big_h, "visible", false) 
  470. 	vint_set_property(Hud_combo_elements.right_stick_rumble_light_anim_h, "is_paused", true) 
  471. 	vint_set_property(Hud_combo_elements.right_stick_rumble_heavy_anim_h, "is_paused", true) 
  472. 	vint_set_property(Hud_combo_elements.mouse_rumble_light_anim_h, "is_paused", true) 
  473. 	vint_set_property(Hud_combo_elements.mouse_rumble_heavy_anim_h, "is_paused", true) 
  474. 	vint_set_property(Hud_combo_elements.right_circle_h, 	"scale", 1, 1) 
  475. 	vint_set_property(Hud_combo_elements.mouse_bg_h, 		"scale", 1.5, 1.5) 
  476. 	 
  477. 	--Keyboard Version 
  478. 	vint_set_property(Hud_combo_elements.mouse_marker_big_h, "alpha", 0) 
  479. 	vint_set_property(Hud_combo_elements.mouse_marker_big_h, "visible", false)	 
  480. end 
  481.  
  482. function hud_touch_combo_fade_out() 
  483. 	lua_play_anim(Hud_combo_elements.combo_sticks_fade_out_anim_h, 0) 
  484. end 
  485.  
  486. function hud_touch_combo_fade_in() 
  487. 	lua_play_anim(Hud_combo_elements.combo_sticks_fade_in_anim_h, 0) 
  488. end 
  489.  
  490. function hud_sexy_time_move_list_update(di_h) 
  491. 	-- get the data. 
  492. 	local sexy_time_direction = vint_dataitem_get(di_h) 
  493. 	 
  494. 	hud_sexy_time_tween_cleanup() 
  495. 	if sexy_time_direction ~= -1 then 
  496. 		hud_sexy_time_flash_current_movement(sexy_time_direction) 
  497. 	end 
  498. end 
  499.  
  500. function hud_sexy_time_create_tween(name, target_h, target_prop, duration) 
  501. 	local tween_h = vint_object_create(name, "tween", vint_object_find("root_animation")) 
  502. 	vint_set_property(tween_h, "duration", duration) 
  503. 	vint_set_property(tween_h, "target_handle", target_h) 
  504. 	vint_set_property(tween_h, "target_property", target_prop) 
  505. 	vint_set_property(tween_h, "max_loops", 0)  -- doing a lot so we don't run out of this stuff. 
  506. 	vint_set_property(tween_h, "loop_mode", 2) 
  507. 	vint_set_property(tween_h, "algorithm", 0) 
  508. 	vint_set_property(tween_h, "start_time",	vint_get_time_index() ) 
  509. 	vint_set_property(tween_h, "state", 1) 
  510. 	return tween_h 
  511. end 
  512.  
  513. function hud_sexy_time_tween_cleanup() 
  514.  
  515. 	if Sexy_time_tween ~= -1 then 
  516. 	 
  517. 		-- this is a new tween.  Stop the old one. 
  518. 		local target_handle = vint_get_property(Sexy_time_tween, "target_handle") 
  519. 		--vint_set_property(target_handle, "tint", 1,0,1) 
  520. 		vint_object_destroy(Sexy_time_tween) 
  521. 		vint_set_property(target_handle, "alpha", 0) 
  522. 		Sexy_time_tween = -1 
  523. 	end 
  524. end 
  525.  
  526. ------------------------------------------------------------------------------- 
  527. -- Updates positions on sticks and mouse stuff... 
  528. -- 
  529. function hud_touch_combo_sticks_update(left_stick_x, left_stick_y, right_stick_x, right_stick_y, target_x, target_y) 
  530. 	--Gamepad values... 
  531. 	local stick_radius = 15 
  532. 	local mouse_radius = 45 
  533. 	 
  534. 	if left_stick_x ~= Hud_touch_combo_status.left_stick_x  or  left_stick_y ~= Hud_touch_combo_status.left_stick_y then  
  535. 		vint_set_property(Hud_combo_elements.left_stick_h, "anchor", stick_radius * left_stick_x, stick_radius * -left_stick_y)			 
  536. 	end 
  537. 			 
  538. 	if right_stick_x ~= Hud_touch_combo_status.right_stick_x  or  right_stick_y ~= Hud_touch_combo_status.right_stick_y then  
  539. 		vint_set_property(Hud_combo_elements.right_stick_h, "anchor", stick_radius * right_stick_x, stick_radius * -right_stick_y) 
  540. 		vint_set_property(Hud_combo_elements.mouse_h, "anchor", mouse_radius * right_stick_x, mouse_radius * -right_stick_y) 
  541. 	end 
  542.  
  543. 	if target_x ~= Hud_touch_combo_status.target_x  or  target_y ~= Hud_touch_combo_status.target_y then  
  544. 		if Hud_touch_combo_input_gamepad then 
  545. 			vint_set_property(Hud_combo_elements.target_dot_h, "anchor", stick_radius * target_x, stick_radius * -target_y) 
  546. 		end 
  547. 	end 
  548.  
  549. 	--Specific mouse targeting stuff... 
  550. 	if not Hud_touch_combo_input_gamepad then 
  551. 		--Get magnitudes for comparing... 
  552. 		local max_mag 		= magnitude(0, 0, target_x,		target_y) 
  553. 		local current_mag = magnitude(right_stick_x, right_stick_y, target_x, target_y) 
  554. 		 
  555. 		local marker_x, marker_y = 0, 0 
  556. 		local scale = .8 
  557. 		local mag_percent = 1 
  558. 		if current_mag < max_mag then 
  559. 			local mag_inverse_percent =   1 - (current_mag / max_mag) 
  560. 			local mag_percent = (current_mag / max_mag) 
  561. 			scale = scale - (mag_inverse_percent * .5)   -- .5 to 1... 
  562.  
  563. 			marker_x = (target_x * mouse_radius) 	- (target_x * mouse_radius * mag_percent)  
  564. 			marker_y = (-target_y * mouse_radius) 	- (-target_y * mouse_radius * mag_percent)  
  565. 		end 
  566.  
  567. 		vint_set_property(Hud_combo_elements.mouse_marker_h, "anchor", marker_x, marker_y) 
  568. 		vint_set_property(Hud_combo_elements.mouse_marker_h, "scale",  scale, scale) 
  569. 	end 
  570. 	 
  571. 	--Store values to globals...	 
  572. 	Hud_touch_combo_status.left_stick_x = left_stick_x  
  573. 	Hud_touch_combo_status.left_stick_y = left_stick_y 
  574.  
  575. 	Hud_touch_combo_status.right_stick_x = right_stick_x  
  576. 	Hud_touch_combo_status.right_stick_y = right_stick_y	 
  577. 			 
  578. 	Hud_touch_combo_status.target_x = target_x  
  579. 	Hud_touch_combo_status.target_y = target_y 
  580. end 
  581.  
  582.  
  583. Sexy_time_tweens = {} 
  584.  
  585.  
  586.  
  587.  
  588. function hud_sexy_time_flash_current_movement(current_direction) 
  589. 	 
  590. 	 
  591. 	local current_item = 1 
  592. 	local continue_processing = true 
  593. 	local item_h 
  594. 	local tween_h 
  595. 	 
  596. 	if Hud_touch_combo_input_gamepad then 
  597. 		if Sexy_time_tween ~= -1 then 				-- this is a new tween.  Stop the old one. 
  598. 			vint_object_destroy(Sexy_time_tween) 
  599. 			Sexy_time_tween = -1 
  600. 		end 
  601. 		 
  602. 		local time_between_flashes = .25 
  603. 		local flash_duration = .25 
  604. 		 
  605. 		--Create Tween 
  606. 		item_h = Hud_combo_elements.hud_left_stick_highlight[current_direction]		 
  607. 		tween_h = hud_sexy_time_create_tween("tween" .. current_item, item_h , "alpha", flash_duration) 
  608.  
  609. 		vint_set_property(tween_h, "start_value", .1) 
  610. 		vint_set_property(tween_h, "end_value", 1) 
  611. 		 
  612. 		Sexy_time_tween = tween_h 
  613. 	else 
  614. 		--reset mash... 
  615. 		Hud_sexy_key_w:mash(-1) 
  616. 		Hud_sexy_key_n:mash(-1) 
  617. 		Hud_sexy_key_e:mash(-1) 
  618. 		Hud_sexy_key_s:mash(-1) 
  619. 				 
  620. 		--Highlight item to press... 
  621. 		if current_direction == 1 then 
  622. 			Hud_sexy_key_n:mash(1) 
  623. 		elseif  current_direction == 2 then 
  624. 			Hud_sexy_key_s:mash(1) 
  625. 		elseif current_direction == 3 then 
  626. 			Hud_sexy_key_w:mash(1) 
  627. 		elseif current_direction == 4 then 
  628. 			Hud_sexy_key_e:mash(1) 
  629. 		end 
  630. 	end 
  631. end 
  632.  
  633. -- calculate the magnitude of a line 
  634. function magnitude(startx,starty,endx,endy) 
  635.  
  636. 	local x = endx - startx 
  637. 	local y = endy - starty 
  638.  
  639.     return sqrt( x * x + y * y ) 
  640. end