--#####################################################################
--Touch Combo System
--#####################################################################
-- show_mode
-- 0 = Show Right stick
-- 1 = Show Both sticks
-- 2 = Show Right stick, dim left stick.
Sexy_time_tween = -1
Hud_touch_combo_input_gamepad = true
Hud_combo_elements = {
main_grp_h = -1,
left_grp_h = -1,
left_stick_h = -1,
left_stick_stick_h = -1,
keyboard_h = -1,
left_highlight = -1,
hud_left_stick_highlight = {
[1] = -1,
[2] = -1,
[3] = -1,
[4] = -1,
},
right_grp_h = -1,
right_stick_h = -1,
right_highlight = -1,
target_dot_h = -1,
help_txt_grp_h = -1,
}
local TOUCH_COMBO_SHOW_MODE_RIGHT = 0 --Shows right side...
local TOUCH_COMBO_SHOW_MODE_LEFT = 1 --Shows left side.
local TOUCH_COMBO_SHOW_MODE_RIGHT_MISTAKE = 2 --When the user slips off the right stick they need to correct it.
Hud_touch_combo_status = {
combo_active = false,
show_mode = -1,
help_text = "",
left_stick_x = 0.0,
left_stick_x = 0.0,
right_stick_x = 0.0,
right_stick_y = 0.0,
rumble_level = -1,
grp_x = 640,
grp_y = 360,
}
--PC Keys.
Hud_sexy_key_w = 0
Hud_sexy_key_n = 0
Hud_sexy_key_e = 0
Hud_sexy_key_s = 0
function hud_touch_combo_init()
--Get our gamepad status, we use this to determine what graphics to show...
Hud_touch_combo_input_gamepad = game_is_active_input_gamepad()
--Hide everything when we first boot up...
Hud_combo_elements.main_grp_h = vint_object_find("combo_grp")
vint_set_property(Hud_combo_elements.main_grp_h, "visible", false)
--Store initial position of main group...
local x, y = vint_get_property(Hud_combo_elements.main_grp_h, "anchor")
Hud_touch_combo_status.grp_x = x
Hud_touch_combo_status.grp_y = y
--base help text object...
Hud_combo_elements.help_txt_grp_h = vint_object_find("help_txt_grp") -- Base help text object
Hud_combo_elements.help_txt_h = vint_object_find("help_txt") -- Text object
Hud_combo_elements.help_txt_bg_h = vint_object_find("help_txt_bg") -- Right big glow
Hud_combo_elements.help_txt_fade_out_anim_h = vint_object_find("help_text_fade_out_anim") -- Right big glow
--Keyboard mouse...
local keyboard_mouse_grp_h = vint_object_find("keyboard_mouse_grp")
Hud_combo_elements.keyboard_h = vint_object_find("keyboard_grp", keyboard_mouse_grp_h)
Hud_combo_elements.mouse_grp_h = vint_object_find("mouse_grp", keyboard_mouse_grp_h)
Hud_combo_elements.mouse_h = vint_object_find("mouse", keyboard_mouse_grp_h)
Hud_combo_elements.mouse_marker_big_h = vint_object_find("mouse_marker_big", keyboard_mouse_grp_h)
Hud_combo_elements.mouse_marker_h = vint_object_find("mouse_marker", keyboard_mouse_grp_h)
Hud_combo_elements.mouse_bg_h = vint_object_find("mouse_bg") --Right Stick Circle...
local stick_grp_h = vint_object_find("stick_grp")
--hide type depending on what mode we are in...
if Hud_touch_combo_input_gamepad then
vint_set_property(keyboard_mouse_grp_h, "visible", false)
vint_set_property(stick_grp_h, "visible", true)
else
vint_set_property(keyboard_mouse_grp_h, "visible", true)
vint_set_property(stick_grp_h, "visible", false)
end
--Left Stick Group
local h = vint_object_find("left_stick")
Hud_combo_elements.left_stick_h = vint_object_find("stick_l", h)
Hud_combo_elements.left_stick_hl_h = vint_object_find("stick_l_hl", h) --Left Stick
Hud_combo_elements.left_circle_h = vint_object_find("l_bg", h)
-- Fix the image.
local platform = game_get_platform()
if (platform == "PS3") then
--Right Stick and highlight...
local stick_bmp_h = vint_object_find("stick_bmp", Hud_combo_elements.left_stick_h)
local stick_l_hl_h = vint_object_find("stick_l_hl", Hud_combo_elements.left_stick_h)
vint_set_property(stick_bmp_h, "image", "ui_hud_combo_thumb_ps3")
vint_set_property(stick_l_hl_h, "image", "ui_hud_combo_thumb_ps3")
--Right stick text...
local stick_txt_h = vint_object_find("stick_txt", Hud_combo_elements.left_stick_h )
vint_set_property(stick_txt_h, "text_tag", "L")
elseif (platform == "PS4") then -- HVS_JRP[PRINCE] 3/18/2014
--Right Stick and highlight...
local stick_bmp_h = vint_object_find("stick_bmp", Hud_combo_elements.left_stick_h)
local stick_l_hl_h = vint_object_find("stick_l_hl", Hud_combo_elements.left_stick_h)
vint_set_property(stick_bmp_h, "image", "ui_hud_combo_thumb_ps4")
vint_set_property(stick_l_hl_h, "image", "ui_hud_combo_thumb_ps4")
--Right stick text...
local stick_txt_h = vint_object_find("stick_txt", Hud_combo_elements.left_stick_h )
vint_set_property(stick_txt_h, "text_tag", "L")
end
--Left stick arrows...
Hud_combo_elements.left_stick_stick_h = vint_object_find("left_stick_stick", h)
Hud_combo_elements.hud_left_stick_highlight[1] = vint_object_find("combo_arrow_n", h) --Left Highlight North
Hud_combo_elements.hud_left_stick_highlight[2] = vint_object_find("combo_arrow_s", h) --Left Highlight South
Hud_combo_elements.hud_left_stick_highlight[3] = vint_object_find("combo_arrow_w", h) --Left Highlight West
Hud_combo_elements.hud_left_stick_highlight[4] = vint_object_find("combo_arrow_e", h) --Left Highlight East
--Right Stick...
local h = vint_object_find("right_stick")
Hud_combo_elements.right_grp_h = h --Right Stick Group
Hud_combo_elements.right_stick_h = vint_object_find("stick_r", h) --Right Stick
Hud_combo_elements.right_stick_hl_h = vint_object_find("stick_r_hl", h) --Right Stick Highlight
Hud_combo_elements.right_circle_h = vint_object_find("r_bg", h) --Right Stick Circle...
-- fix the image
if (platform == "PS3") then
--Left Stick and highlight...
local stick_bmp_h = vint_object_find("stick_bmp", Hud_combo_elements.right_stick_h )
local stick_r_hl_h = vint_object_find("stick_r_hl", Hud_combo_elements.right_stick_h )
vint_set_property(stick_bmp_h, "image", "ui_hud_combo_thumb_ps3")
vint_set_property(stick_r_hl_h, "image", "ui_hud_combo_thumb_ps3")
local stick_txt_h = vint_object_find("stick_txt", Hud_combo_elements.right_stick_h ) --Left Stick
vint_set_property(stick_txt_h, "text_tag", "R")
elseif (platform == "PS4") then -- HVS_JRP[PRINCE] 3/18/2014
--Left Stick and highlight...
local stick_bmp_h = vint_object_find("stick_bmp", Hud_combo_elements.right_stick_h )
local stick_r_hl_h = vint_object_find("stick_r_hl", Hud_combo_elements.right_stick_h )
vint_set_property(stick_bmp_h, "image", "ui_hud_combo_thumb_ps4")
vint_set_property(stick_r_hl_h, "image", "ui_hud_combo_thumb_ps4")
local stick_txt_h = vint_object_find("stick_txt", Hud_combo_elements.right_stick_h ) --Left Stick
vint_set_property(stick_txt_h, "text_tag", "R")
end
Hud_combo_elements.target_dot_h = vint_object_find("marker", h) --Right marker
Hud_combo_elements.target_dot_big_h = vint_object_find("marker_big", h) --right big glow
--animations, rumble
Hud_combo_elements.right_stick_rumble_light_anim_h = vint_object_find("combo_stick_shake_light_anim")
Hud_combo_elements.right_stick_rumble_heavy_anim_h = vint_object_find("combo_stick_shake_heavy_anim")
Hud_combo_elements.mouse_rumble_light_anim_h = vint_object_find("mouse_shake_light_anim")
Hud_combo_elements.mouse_rumble_heavy_anim_h = vint_object_find("mouse_shake_heavy_anim")
--stick blink
Hud_combo_elements.combo_stick_hl_l = vint_object_find("combo_stick_hl_l")
Hud_combo_elements.combo_stick_hl_r = vint_object_find("combo_stick_hl_r")
vint_set_property(Hud_combo_elements.combo_stick_hl_l, "is_paused", true)
vint_set_property(Hud_combo_elements.combo_stick_hl_r, "is_paused", true)
--fade in
Hud_combo_elements.combo_sticks_fade_in_anim_h = vint_object_find("combo_sticks_fade_in_anim")
vint_set_property(Hud_combo_elements.combo_sticks_fade_in_anim_h, "is_paused", true)
--fade out
Hud_combo_elements.combo_sticks_fade_out_anim_h = vint_object_find("combo_sticks_fade_out_anim")
vint_set_property(Hud_combo_elements.combo_sticks_fade_out_anim_h, "is_paused", true)
--build keyboard for left side
if not Hud_touch_combo_input_gamepad then
--Hide left stick...
local stick_txt_h = vint_object_find("stick_txt", Hud_combo_elements.right_stick_h )
vint_set_property(stick_txt_h, "visible", false)
--Create left side keyboard...
local keyboard_h = vint_object_find("keyboard_grp")
Hud_sexy_key_w = Vdo_qte_key:new("sexy_key_w", keyboard_h)
Hud_sexy_key_n = Vdo_qte_key:new("sexy_key_n", keyboard_h)
Hud_sexy_key_e = Vdo_qte_key:new("sexy_key_e", keyboard_h)
Hud_sexy_key_s = Vdo_qte_key:new("sexy_key_s", keyboard_h)
Hud_sexy_key_w:show_arrows(true)
Hud_sexy_key_n:show_arrows(true)
Hud_sexy_key_s:show_arrows(true)
Hud_sexy_key_e:show_arrows(true)
local up_action_name, down_action_name = get_get_key_names_for_axis_action("CAA_WALK_FORWARD_BACKWARD")
local right_action_name, left_action_name = get_get_key_names_for_axis_action("CAA_WALK_TURN_LEFT_RIGHT")
Hud_sexy_key_w:set_text(left_action_name)
Hud_sexy_key_n:set_text(up_action_name)
Hud_sexy_key_e:set_text(right_action_name)
Hud_sexy_key_s:set_text(down_action_name)
Hud_sexy_key_w:set_arrow_direction(3)
Hud_sexy_key_n:set_arrow_direction(1)
Hud_sexy_key_s:set_arrow_direction(2)
Hud_sexy_key_e:set_arrow_direction(4)
local key_scale = vint_get_property(Hud_sexy_key_w.handle, "scale")
--get width of each key
local w_width = Hud_sexy_key_w:get_width() * key_scale
local n_width = Hud_sexy_key_n:get_width() * key_scale
local e_width = Hud_sexy_key_e:get_width() * key_scale
local s_width = Hud_sexy_key_s:get_width() * key_scale
--center north icon
local x, y = vint_get_property(Hud_sexy_key_n.handle, "anchor")
vint_set_property(Hud_sexy_key_n.handle, "anchor", -n_width * .5, y)
--center south icon
local s_width_half = s_width * 0.5
local key_spacing = 10
local base_x, base_y = vint_get_property(Hud_sexy_key_s.handle, "anchor")
vint_set_property(Hud_sexy_key_s.handle, "anchor", -s_width_half, base_y)
--west icon
local x, y = vint_get_property(Hud_sexy_key_w.handle, "anchor")
vint_set_property(Hud_sexy_key_w.handle, "anchor", - s_width_half - key_spacing - (w_width), base_y)
local start_x = x
--east icon
local x, y = vint_get_property(Hud_sexy_key_e.handle, "anchor")
vint_set_property(Hud_sexy_key_e.handle, "anchor", s_width_half + key_spacing, base_y)
local end_x = s_width_half + key_spacing
local total_width = e_width + end_x + abs(start_x)
local x, y = vint_get_property(keyboard_h, "anchor")
local base_width = 193
if total_width > base_width then
vint_set_property(keyboard_h, "anchor", x - ((total_width - base_width) * 0.5) - 20, y)
end
-- Change right side to mouse...
--Left Stick and highlight...
local stick_bmp_h = vint_object_find("stick_bmp", Hud_combo_elements.right_stick_h )
local stick_r_hl_h = vint_object_find("stick_r_hl", Hud_combo_elements.right_stick_h )
--[[
vint_set_property(stick_bmp_h, "image", "ui_qte_mouse_base")
vint_set_property(stick_r_hl_h, "image", "ui_qte_mouse_outline")
vint_set_property(stick_bmp_h, "scale", 0.4, 0.4)
vint_set_property(stick_r_hl_h, "scale", 0.4, 0.4)
vint_set_property(stick_bmp_h, "auto_offset", "c")
vint_set_property(stick_r_hl_h, "auto_offset", "c")
]]
vint_set_property(Hud_combo_elements.left_stick_stick_h, "visible", false)
vint_set_property(Hud_combo_elements.keyboard_h, "visible", true)
end
-- Touch Combo HUD
vint_dataitem_add_subscription("touch_combo_info", "update", "hud_touch_combo_system_update")
vint_dataitem_add_subscription("sexy_time_move_list", "update", "hud_sexy_time_move_list_update")
end
function hud_touch_combo_system_update(di_h)
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)
if combo_active ~= Hud_touch_combo_status.combo_active then
Hud_touch_combo_status.combo_active = combo_active
if combo_active == true then
debug_print("vint", "*** sexy time fade in *** \n")
hud_touch_combo_fade_in()
vint_set_property(Hud_combo_elements.main_grp_h, "visible", true)
vint_set_property(Hud_combo_elements.target_dot_h, "visible", false)
vint_set_property(Hud_combo_elements.hud_left_stick_highlight[1], "visible", true)
vint_set_property(Hud_combo_elements.hud_left_stick_highlight[2], "visible", true)
vint_set_property(Hud_combo_elements.hud_left_stick_highlight[3], "visible", true)
vint_set_property(Hud_combo_elements.hud_left_stick_highlight[4], "visible", true)
vint_set_property(Hud_combo_elements.help_txt_grp_h, "visible", true) -- redisplay the text when restarting the minigame.
vint_set_property(Hud_combo_elements.help_txt_grp_h, "alpha", 1)
lua_play_anim(Hud_combo_elements.help_txt_fade_out_anim_h)
else
debug_print("vint", "*** sexy time fade out *** \n")
hud_touch_combo_fade_out()
hud_touch_combo_rumble_none()
vint_set_property(Hud_combo_elements.main_grp_h, "anchor", Hud_touch_combo_status.grp_x, Hud_touch_combo_status.grp_y)
vint_set_property(Hud_combo_elements.target_dot_big_h, "visible", false)
vint_set_property(Hud_combo_elements.target_dot_h, "visible", false)
vint_set_property(Hud_combo_elements.left_stick_stick_h_h, "alpha", 1)
vint_set_property(Hud_combo_elements.right_grp_h, "alpha", 1)
vint_set_property(Hud_combo_elements.hud_left_stick_highlight[1], "visible", false)
vint_set_property(Hud_combo_elements.hud_left_stick_highlight[2], "visible", false)
vint_set_property(Hud_combo_elements.hud_left_stick_highlight[3], "visible", false)
vint_set_property(Hud_combo_elements.hud_left_stick_highlight[4], "visible", false)
vint_set_property(Hud_combo_elements.help_txt_grp_h, "visible", false)
vint_set_property(Hud_combo_elements.mouse_marker_big_h, "visible", false)
return
end
end
if combo_active then
--which stick should we show
hud_touch_combo_sticks_update(left_stick_x, left_stick_y, right_stick_x, right_stick_y, target_x, target_y)
--Shift the group around if we are using the left stick...
if show_mode == TOUCH_COMBO_SHOW_MODE_LEFT then
local stick_grp_mult = 7
local new_x = Hud_touch_combo_status.grp_x + (stick_grp_mult * left_stick_x)
local new_y = Hud_touch_combo_status.grp_y + (stick_grp_mult * -left_stick_y)
vint_set_property(Hud_combo_elements.main_grp_h, "anchor", new_x, new_y)
else
vint_set_property(Hud_combo_elements.main_grp_h, "anchor", Hud_touch_combo_status.grp_x, Hud_touch_combo_status.grp_y)
end
--how much rumble do we have
if Hud_touch_combo_status.rumble_level ~= rumble_level then
--note: i look for rumble 0 farther down
if rumble_level == 1 then
--cancel the heavy stuff
vint_set_property(Hud_combo_elements.right_stick_rumble_heavy_anim_h, "is_paused", true)
vint_set_property(Hud_combo_elements.mouse_rumble_heavy_aanim_h, "is_paused", true)
--play the light stuff
hud_touch_combo_rumble_light()
elseif rumble_level == 2 then
--cancel the light stuff
vint_set_property(Hud_combo_elements.right_stick_rumble_light_anim_h, "is_paused", true)
vint_set_property(Hud_combo_elements.mouse_rumble_light_anim_h, "is_paused", true)
--play the heavy stuff
hud_touch_combo_rumble_heavy()
end
end
--find mode, turn off the correct shit
if show_mode ~= Hud_touch_combo_status.show_mode then
if show_mode == TOUCH_COMBO_SHOW_MODE_RIGHT then
-- Show the Right Side, Dim Left.
--Stick Version..
vint_set_property(Hud_combo_elements.left_stick_stick_h_h, "alpha", .25)
vint_set_property(Hud_combo_elements.right_grp_h, "alpha", 1)
vint_set_property(Hud_combo_elements.target_dot_h, "visible", false)
vint_set_property(Hud_combo_elements.target_dot_big_h, "visible", true)
--Keybaord Version
vint_set_property(Hud_combo_elements.keyboard_h, "alpha", 0)
vint_set_property(Hud_combo_elements.mouse_marker_big_h, "visible", true)
vint_set_property(Hud_combo_elements.mouse_marker_big_h, "alpha", 0)
hud_touch_combo_blink_right()
elseif show_mode == TOUCH_COMBO_SHOW_MODE_LEFT then
--show the left stick but dim the right...
--Stick Version
vint_set_property(Hud_combo_elements.left_stick_stick_h_h, "alpha", 1)
vint_set_property(Hud_combo_elements.right_grp_h, "alpha", 0.25)
vint_set_property(Hud_combo_elements.target_dot_h, "visible", true)
vint_set_property(Hud_combo_elements.target_dot_big_h, "visible", false)
--Keyboard Version
vint_set_property(Hud_combo_elements.keyboard_h, "alpha", 1)
vint_set_property(Hud_combo_elements.mouse_marker_big_h, "visible", false)
hud_touch_combo_blink_left()
elseif show_mode == TOUCH_COMBO_SHOW_MODE_RIGHT_MISTAKE then
--show only the right stick
vint_set_property(Hud_combo_elements.left_stick_stick_h_h, "alpha", 0)
vint_set_property(Hud_combo_elements.keyboard_h, "alpha", 0)
vint_set_property(Hud_combo_elements.right_grp_h, "alpha", 1)
hud_touch_combo_blink_right()
end
end
--hide the small dot, or the big dot...
if show_mode == TOUCH_COMBO_SHOW_MODE_RIGHT then
vint_set_property(Hud_combo_elements.target_dot_h, "visible", true)
vint_set_property(Hud_combo_elements.target_dot_big_h, "visible", true)
vint_set_property(Hud_combo_elements.mouse_marker_big_h, "visible", true)
vint_set_property(Hud_combo_elements.mouse_marker_h, "visible", true)
else
vint_set_property(Hud_combo_elements.target_dot_h, "visible", true)
vint_set_property(Hud_combo_elements.target_dot_big_h, "visible", false)
end
if rumble_level == 0 then
hud_touch_combo_rumble_none()
end
Hud_touch_combo_status.rumble_level = rumble_level
Hud_touch_combo_status.show_mode = show_mode
end
--Update help text
if Hud_touch_combo_status.help_text ~= help_text or help_text == "" then
if help_text == "" then
vint_set_property(Hud_combo_elements.help_txt_fade_out_anim_h, "is_paused", true)
vint_set_property(Hud_combo_elements.help_txt_grp_h, "alpha", 0)
else
--Play fade out anim... fades out in seven seconds
vint_set_property(Hud_combo_elements.help_txt_grp_h, "alpha", 1)
lua_play_anim(Hud_combo_elements.help_txt_fade_out_anim_h)
end
--Update text field
vint_set_property(Hud_combo_elements.help_txt_h, "text_tag", help_text)
--Update background of text
local width, height = element_get_actual_size(Hud_combo_elements.help_txt_h)
local base_width, base_height = element_get_actual_size(Hud_combo_elements.help_txt_bg_h )
element_set_actual_size(Hud_combo_elements.help_txt_bg_h , width + 15, base_height)
Hud_touch_combo_status.help_text = help_text
end
end
function hud_touch_combo_blink_left()
--blink left
lua_play_anim(Hud_combo_elements.combo_stick_hl_l, 0)
vint_set_property(Hud_combo_elements.combo_stick_hl_r, "is_paused", true)
vint_set_property(Hud_combo_elements.right_stick_hl_h, "alpha", 0)
end
function hud_touch_combo_blink_right()
--blink right
lua_play_anim(Hud_combo_elements.combo_stick_hl_r, 0)
vint_set_property(Hud_combo_elements.combo_stick_hl_l, "is_paused", true)
vint_set_property(Hud_combo_elements.right_stick_hl_h, "alpha", 0)
end
function hud_touch_combo_rumble_light()
lua_play_anim(Hud_combo_elements.right_stick_rumble_light_anim_h, 0)
lua_play_anim(Hud_combo_elements.mouse_rumble_light_anim_h, 0)
end
function hud_touch_combo_rumble_heavy()
lua_play_anim(Hud_combo_elements.right_stick_rumble_heavy_anim_h, 0)
lua_play_anim(Hud_combo_elements.mouse_rumble_heavy_anim_h, 0)
end
function hud_touch_combo_rumble_none()
vint_set_property(Hud_combo_elements.target_dot_big_h, "alpha", 0)
vint_set_property(Hud_combo_elements.target_dot_big_h, "visible", false)
vint_set_property(Hud_combo_elements.right_stick_rumble_light_anim_h, "is_paused", true)
vint_set_property(Hud_combo_elements.right_stick_rumble_heavy_anim_h, "is_paused", true)
vint_set_property(Hud_combo_elements.mouse_rumble_light_anim_h, "is_paused", true)
vint_set_property(Hud_combo_elements.mouse_rumble_heavy_anim_h, "is_paused", true)
vint_set_property(Hud_combo_elements.right_circle_h, "scale", 1, 1)
vint_set_property(Hud_combo_elements.mouse_bg_h, "scale", 1.5, 1.5)
--Keyboard Version
vint_set_property(Hud_combo_elements.mouse_marker_big_h, "alpha", 0)
vint_set_property(Hud_combo_elements.mouse_marker_big_h, "visible", false)
end
function hud_touch_combo_fade_out()
lua_play_anim(Hud_combo_elements.combo_sticks_fade_out_anim_h, 0)
end
function hud_touch_combo_fade_in()
lua_play_anim(Hud_combo_elements.combo_sticks_fade_in_anim_h, 0)
end
function hud_sexy_time_move_list_update(di_h)
-- get the data.
local sexy_time_direction = vint_dataitem_get(di_h)
hud_sexy_time_tween_cleanup()
if sexy_time_direction ~= -1 then
hud_sexy_time_flash_current_movement(sexy_time_direction)
end
end
function hud_sexy_time_create_tween(name, target_h, target_prop, duration)
local tween_h = vint_object_create(name, "tween", vint_object_find("root_animation"))
vint_set_property(tween_h, "duration", duration)
vint_set_property(tween_h, "target_handle", target_h)
vint_set_property(tween_h, "target_property", target_prop)
vint_set_property(tween_h, "max_loops", 0) -- doing a lot so we don't run out of this stuff.
vint_set_property(tween_h, "loop_mode", 2)
vint_set_property(tween_h, "algorithm", 0)
vint_set_property(tween_h, "start_time", vint_get_time_index() )
vint_set_property(tween_h, "state", 1)
return tween_h
end
function hud_sexy_time_tween_cleanup()
if Sexy_time_tween ~= -1 then
-- this is a new tween. Stop the old one.
local target_handle = vint_get_property(Sexy_time_tween, "target_handle")
--vint_set_property(target_handle, "tint", 1,0,1)
vint_object_destroy(Sexy_time_tween)
vint_set_property(target_handle, "alpha", 0)
Sexy_time_tween = -1
end
end
-------------------------------------------------------------------------------
-- Updates positions on sticks and mouse stuff...
--
function hud_touch_combo_sticks_update(left_stick_x, left_stick_y, right_stick_x, right_stick_y, target_x, target_y)
--Gamepad values...
local stick_radius = 15
local mouse_radius = 45
if left_stick_x ~= Hud_touch_combo_status.left_stick_x or left_stick_y ~= Hud_touch_combo_status.left_stick_y then
vint_set_property(Hud_combo_elements.left_stick_h, "anchor", stick_radius * left_stick_x, stick_radius * -left_stick_y)
end
if right_stick_x ~= Hud_touch_combo_status.right_stick_x or right_stick_y ~= Hud_touch_combo_status.right_stick_y then
vint_set_property(Hud_combo_elements.right_stick_h, "anchor", stick_radius * right_stick_x, stick_radius * -right_stick_y)
vint_set_property(Hud_combo_elements.mouse_h, "anchor", mouse_radius * right_stick_x, mouse_radius * -right_stick_y)
end
if target_x ~= Hud_touch_combo_status.target_x or target_y ~= Hud_touch_combo_status.target_y then
if Hud_touch_combo_input_gamepad then
vint_set_property(Hud_combo_elements.target_dot_h, "anchor", stick_radius * target_x, stick_radius * -target_y)
end
end
--Specific mouse targeting stuff...
if not Hud_touch_combo_input_gamepad then
--Get magnitudes for comparing...
local max_mag = magnitude(0, 0, target_x, target_y)
local current_mag = magnitude(right_stick_x, right_stick_y, target_x, target_y)
local marker_x, marker_y = 0, 0
local scale = .8
local mag_percent = 1
if current_mag < max_mag then
local mag_inverse_percent = 1 - (current_mag / max_mag)
local mag_percent = (current_mag / max_mag)
scale = scale - (mag_inverse_percent * .5) -- .5 to 1...
marker_x = (target_x * mouse_radius) - (target_x * mouse_radius * mag_percent)
marker_y = (-target_y * mouse_radius) - (-target_y * mouse_radius * mag_percent)
end
vint_set_property(Hud_combo_elements.mouse_marker_h, "anchor", marker_x, marker_y)
vint_set_property(Hud_combo_elements.mouse_marker_h, "scale", scale, scale)
end
--Store values to globals...
Hud_touch_combo_status.left_stick_x = left_stick_x
Hud_touch_combo_status.left_stick_y = left_stick_y
Hud_touch_combo_status.right_stick_x = right_stick_x
Hud_touch_combo_status.right_stick_y = right_stick_y
Hud_touch_combo_status.target_x = target_x
Hud_touch_combo_status.target_y = target_y
end
Sexy_time_tweens = {}
function hud_sexy_time_flash_current_movement(current_direction)
local current_item = 1
local continue_processing = true
local item_h
local tween_h
if Hud_touch_combo_input_gamepad then
if Sexy_time_tween ~= -1 then -- this is a new tween. Stop the old one.
vint_object_destroy(Sexy_time_tween)
Sexy_time_tween = -1
end
local time_between_flashes = .25
local flash_duration = .25
--Create Tween
item_h = Hud_combo_elements.hud_left_stick_highlight[current_direction]
tween_h = hud_sexy_time_create_tween("tween" .. current_item, item_h , "alpha", flash_duration)
vint_set_property(tween_h, "start_value", .1)
vint_set_property(tween_h, "end_value", 1)
Sexy_time_tween = tween_h
else
--reset mash...
Hud_sexy_key_w:mash(-1)
Hud_sexy_key_n:mash(-1)
Hud_sexy_key_e:mash(-1)
Hud_sexy_key_s:mash(-1)
--Highlight item to press...
if current_direction == 1 then
Hud_sexy_key_n:mash(1)
elseif current_direction == 2 then
Hud_sexy_key_s:mash(1)
elseif current_direction == 3 then
Hud_sexy_key_w:mash(1)
elseif current_direction == 4 then
Hud_sexy_key_e:mash(1)
end
end
end
-- calculate the magnitude of a line
function magnitude(startx,starty,endx,endy)
local x = endx - startx
local y = endy - starty
return sqrt( x * x + y * y )
end