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