--Document handle
Hud_qte_key_doc_h = 0
-- handles
Hud_qte_btn_1_grp_h = 0
Hud_qte_btn_1_h = 0
Hud_qte_btn_2_h = 0
Hud_qte_sticks_grp_h = 0
Hud_qte_stick_pad_h = 0
Hud_qte_stick_base_h = 0
Hud_qte_stick_arrow_h = 0
Hud_qte_stick_label_h = 0
Hud_qte_success_grp_h = 0
Hud_qte_kb_grp_h = 0
Hud_qte_kb_dir_grp_h = 0
Hud_qte_mouse_grp_h = 0
Hud_qte_btn_2_grp_h = 0
Hud_qte_btn_3_h = 0
Hud_qte_btn_4_h = 0
--QTE Vdo Objects
Hud_qte_kb_key = 0
Hud_qte_kb_dir_w = 0
Hud_qte_kb_dir_n = 0
Hud_qte_kb_dir_e = 0
Hud_qte_kb_dir_s = 0
-- button_index values
HUD_QTE_BTN_HIDDEN = -1
HUD_QTE_BTN_A = 0
HUD_QTE_BTN_B = 1
HUD_QTE_BTN_X = 2
HUD_QTE_BTN_Y = 3
HUD_QTE_BTN_LT = 4
HUD_QTE_BTN_RT = 5
HUD_QTE_STICK_UP = 6
HUD_QTE_STICK_DOWN = 7
HUD_QTE_STICK_RIGHT = 8
HUD_QTE_STICK_LEFT = 9
HUD_QTE_TOUCH_PAD_SWIPE_NONE = 0 --HVS_JRP[PRINCE] 4/22/2014
HUD_QTE_TOUCH_PAD_SWIPE_UP = 1 --HVS_JRP[PRINCE] 4/22/2014
HUD_QTE_TOUCH_PAD_SWIPE_DOWN = 2 --HVS_JRP[PRINCE] 4/22/2014
HUD_QTE_TOUCH_PAD_SWIPE_RIGHT = 3 --HVS_JRP[PRINCE] 4/22/2014
HUD_QTE_TOUCH_PAD_SWIPE_LEFT = 4 --HVS_JRP[PRINCE] 4/22/2014
-- button_animation values
HUD_QTE_ANIM_NONE = -1
HUD_QTE_ANIM_MASH_STANDARD = 0
HUD_QTE_ANIM_MASH_FAST = 1
HUD_QTE_ANIM_ALTERNATE_TRIGGERS = 2
HUD_QTE_INVALID_DIRECTION = -1
-- storage
Hud_qte_prev_btn = 0
Hud_qte_prev_anim = 0
--Mouse key inputs...
local MOUSE_KEY_INVALID = -1
local MOUSE_KEY_LEFT = 0
local MOUSE_KEY_MIDDLE = 1
local MOUSE_KEY_RIGHT = 2
local MOUSE_KEY_4 = 3
local MOUSE_KEY_5 = 4
local MOUSE_KEY_WHEEL_UP = 5
local MOUSE_KEY_WHEEL_DOWN = 6
--mouse highlights...
local Hud_qte_mouse_highlights = {
[MOUSE_KEY_LEFT] = "ui_qte_mouse_0",
[MOUSE_KEY_MIDDLE] = "ui_qte_mouse_2",
[MOUSE_KEY_RIGHT] = "ui_qte_mouse_1",
[MOUSE_KEY_4] = "ui_qte_mouse_base_highlight",
[MOUSE_KEY_5] = "ui_qte_mouse_base_highlight",
[MOUSE_KEY_WHEEL_UP] = "ui_qte_mouse_scroll_up",
[MOUSE_KEY_WHEEL_DOWN] = "ui_qte_mouse_scroll_down",
}
--mouse icons...
local Hud_qte_mouse_icons = {
[MOUSE_KEY_LEFT] = "ui_qte_mouse_fluer",
[MOUSE_KEY_MIDDLE] = "ui_qte_mouse_fluer",
[MOUSE_KEY_RIGHT] = "ui_qte_mouse_fluer",
[MOUSE_KEY_4] = "ui_qte_mouse_3",
[MOUSE_KEY_5] = "ui_qte_mouse_4",
[MOUSE_KEY_WHEEL_UP] = "ui_qte_mouse_fluer",
[MOUSE_KEY_WHEEL_DOWN] = "ui_qte_mouse_fluer",
}
--warden meter
local Hud_warden_meter = {
grp_h = -1,
saints_fill_img_h = -1,
saints_fill_grad_img_h = -1,
saints_grad_static_img_h = -1,
saints_line_img_h = -1,
saints_clip_h = -1,
warden_fill_img_h = -1,
warden_fill_grad_img_h = -1,
warden_grad_static_img_h = -1,
warden_line_img_h = -1,
warden_clip_h = -1,
saints_pulse_anim_h = -1,
saints_energy_anim_h = -1,
warden_pulse_anim_h = -1,
warden_energy_anim_h = -1,
warden_next_btn_anim_h = -1,
qte_btn_change_grp_h = -1,
is_playing = false,
}
Hud_qte_mouse_success_bitmaps = {}
Hud_qte_mouse_success_anims = {}
function hud_qte_init()
Hud_qte_key_doc_h = vint_document_find("hud_qte")
-- assign handles
Hud_qte_btn_1_grp_h = vint_object_find("btn_1_grp")
Hud_qte_btn_1_h = vint_object_find("btn_1")
Hud_qte_btn_2_h = vint_object_find("btn_2")
Hud_qte_btn_2_grp_h = vint_object_find("btn_2_grp")
Hud_qte_btn_3_h = vint_object_find("btn_3")
Hud_qte_btn_4_h = vint_object_find("btn_4")
Hud_qte_sticks_grp_h = vint_object_find("qte_sticks_grp")
Hud_qte_stick_pad_h = vint_object_find("stick_pad")
Hud_qte_stick_base_h = vint_object_find("stick_base_bmp")
Hud_qte_stick_arrow_h = vint_object_find("stick_arrow")
Hud_qte_stick_label_h = vint_object_find("stick_label")
Hud_qte_kb_grp_h = vint_object_find("qte_keyboard_grp")
Hud_qte_kb_key = Vdo_qte_key:new("qte_key", 0, Hud_qte_key_doc_h)
Hud_qte_mouse_grp_h = vint_object_find("qte_mouse_grp")
Hud_qte_success_grp_h = vint_object_find("qte_success_grp")
--Warden Meter
Hud_warden_meter.grp_h = vint_object_find("base_warden_grp")
Hud_warden_meter.saints_fill_img_h = vint_object_find("saints_fill_img")
Hud_warden_meter.saints_fill_grad_img_h = vint_object_find("saints_fill_grad_img")
Hud_warden_meter.saints_grad_static_img_h = vint_object_find("saints_grad_static_img")
Hud_warden_meter.saints_line_img_h = vint_object_find("saints_line_img")
Hud_warden_meter.saints_clip_h = vint_object_find("saints_clip")
Hud_warden_meter.warden_fill_img_h = vint_object_find("warden_fill_img")
Hud_warden_meter.warden_fill_grad_img_h = vint_object_find("warden_fill_grad_img")
Hud_warden_meter.warden_grad_static_img_h = vint_object_find("warden_grad_static_img")
Hud_warden_meter.warden_line_img_h = vint_object_find("warden_line_img")
Hud_warden_meter.warden_clip_h = vint_object_find("warden_clip")
Hud_warden_meter.saints_pulse_anim_h = vint_object_find("saints_pulse_anim")
Hud_warden_meter.saints_energy_anim_h = vint_object_find("saints_energy_anim")
Hud_warden_meter.warden_pulse_anim_h = vint_object_find("warden_pulse_anim")
Hud_warden_meter.warden_energy_anim_h = vint_object_find("warden_energy_anim")
Hud_warden_meter.warden_next_btn_anim_h = vint_object_find("warden_next_btn_anim")
Hud_warden_meter.qte_btn_change_grp_h = vint_object_find("qte_btn_change_grp")
Hud_warden_meter.is_playing = false
vint_set_property(Hud_warden_meter.grp_h, "is_visible", false)
vint_set_property(Hud_warden_meter.qte_btn_change_grp_h, "is_visible", false)
-- set animation loops for QTE's
local btn_1_off_standard_twn_h = vint_object_find("btn_1_off_standard")
local btn_1_off_fast_twn_h = vint_object_find("btn_1_off_fast")
local stick_pressed_twn_h = vint_object_find("stick_pressed_twn")
vint_set_property(btn_1_off_standard_twn_h, "end_event", "vint_anim_loop_callback")
vint_set_property(btn_1_off_fast_twn_h, "end_event", "vint_anim_loop_callback")
vint_set_property(stick_pressed_twn_h, "end_event", "vint_anim_loop_callback")
local btn_3_off_standard_twn_h = vint_object_find("btn_4_on_standard01")
vint_set_property(btn_3_off_standard_twn_h, "end_event", "vint_anim_loop_callback")
--Keyboard Direction Setup...
Hud_qte_kb_dir_grp_h = vint_object_find("qte_keyboard_dir_grp")
Hud_qte_kb_dir_n = Vdo_qte_key:new("key_dir_n", Hud_qte_kb_dir_grp_h)
Hud_qte_kb_dir_e = Vdo_qte_key:new("key_dir_e", Hud_qte_kb_dir_grp_h)
Hud_qte_kb_dir_s = Vdo_qte_key:new("key_dir_s", Hud_qte_kb_dir_grp_h)
Hud_qte_kb_dir_w = Vdo_qte_key:new("key_dir_w", Hud_qte_kb_dir_grp_h)
Hud_qte_kb_dir_n:show_arrows(true)
Hud_qte_kb_dir_e:show_arrows(true)
Hud_qte_kb_dir_s:show_arrows(true)
Hud_qte_kb_dir_w:show_arrows(true)
Hud_qte_kb_dir_n:set_arrow_direction(HUD_QTE_KEY_ARROW_N)
Hud_qte_kb_dir_e:set_arrow_direction(HUD_QTE_KEY_ARROW_E)
Hud_qte_kb_dir_s:set_arrow_direction(HUD_QTE_KEY_ARROW_S)
Hud_qte_kb_dir_w:set_arrow_direction(HUD_QTE_KEY_ARROW_W)
-- subscription
vint_dataitem_add_subscription("hud_qte", "update", "hud_qte_update")
vint_dataitem_add_subscription( "hud_warden_finisher", "update", "hud_qte_warden_update" )
end
-------------------------------------------------------------------------------
-- Update the warden meter
--
function hud_qte_warden_update(di_h)
local warden_is_visible, warden_power, play_next_btn_anim = vint_dataitem_get(di_h)
vint_set_property(Hud_warden_meter.grp_h, "visible", warden_is_visible)
local WARDEN_METER_MAX = 604
local warden_fill_width, warden_fill_height = element_get_actual_size(Hud_warden_meter.warden_fill_img_h)
local warden_clip_width, warden_clip_height = element_get_actual_size(Hud_warden_meter.warden_clip_h)
local line_img_width, line_img_height = element_get_actual_size(Hud_warden_meter.saints_line_img_h)
local new_warden_width = WARDEN_METER_MAX - (warden_power * WARDEN_METER_MAX)
--Set warden part
--Using 2px padding around fill and outline gradient/ 4px for line img
element_set_actual_size(Hud_warden_meter.warden_fill_img_h, new_warden_width - 2, warden_fill_height)
element_set_actual_size(Hud_warden_meter.warden_fill_grad_img_h, (new_warden_width - 2) * -1, warden_fill_height)
element_set_actual_size(Hud_warden_meter.warden_line_img_h, new_warden_width - 12, line_img_height)
element_set_actual_size(Hud_warden_meter.warden_clip_h, new_warden_width, warden_clip_height)
--Get updated fill width and reposition gradient end cap
warden_fill_width, warden_fill_height = element_get_actual_size(Hud_warden_meter.warden_fill_img_h)
local warden_grad_static_img_x, warden_grad_static_img_y = vint_get_property(Hud_warden_meter.warden_grad_static_img_h, "anchor")
vint_set_property(Hud_warden_meter.warden_grad_static_img_h, "anchor", WARDEN_METER_MAX - (warden_fill_width + 6), warden_grad_static_img_y)
--Set saints part
element_set_actual_size(Hud_warden_meter.saints_fill_img_h, WARDEN_METER_MAX - (new_warden_width + 4), warden_fill_height)
element_set_actual_size(Hud_warden_meter.saints_fill_grad_img_h, WARDEN_METER_MAX - (new_warden_width + 4), warden_fill_height)
element_set_actual_size(Hud_warden_meter.saints_line_img_h, WARDEN_METER_MAX - (new_warden_width + 12), line_img_height)
element_set_actual_size(Hud_warden_meter.saints_clip_h, WARDEN_METER_MAX - (new_warden_width + 2), warden_clip_height)
--Get updated fill width and reposition gradient end cap
local saints_fill_width, saints_fill_height = element_get_actual_size(Hud_warden_meter.saints_fill_img_h)
local saints_grad_static_img_x, saints_grad_static_img_y = vint_get_property(Hud_warden_meter.saints_grad_static_img_h, "anchor")
vint_set_property(Hud_warden_meter.saints_grad_static_img_h, "anchor", saints_fill_width + 2, saints_grad_static_img_y)
-- If we're already playing, don't play again
Hud_warden_meter.is_playing = not vint_get_property(Hud_warden_meter.saints_pulse_anim_h, "is_paused")
if Hud_warden_meter.is_playing == false then
lua_play_anim(Hud_warden_meter.saints_pulse_anim_h)
lua_play_anim(Hud_warden_meter.saints_energy_anim_h)
lua_play_anim(Hud_warden_meter.warden_pulse_anim_h)
lua_play_anim(Hud_warden_meter.warden_energy_anim_h)
end
-- Play the btn ring flash anim to signal the button change
if play_next_btn_anim then
-- Hide yellow button change animation if using keyboard
if game_is_active_input_gamepad() == true then
vint_set_property(Hud_warden_meter.qte_btn_change_grp_h, "visible", true)
else
vint_set_property(Hud_warden_meter.qte_btn_change_grp_h, "visible", false)
end
-- Tell code when the anim is done
local end_event_twn_h = vint_object_find("end_event_twn", Hud_warden_meter.warden_next_btn_anim_h)
vint_set_property(end_event_twn_h, "end_event", "warden_beatdown_button_anim_handler")
--Hide the ring
local hide_ring_twn_h = vint_object_find("hide_ring_twn", Hud_warden_meter.warden_next_btn_anim_h)
vint_set_property(hide_ring_twn_h, "end_event", "hud_qte_stop_next_btn_anim")
lua_play_anim(Hud_warden_meter.warden_next_btn_anim_h)
end
end
function warden_beatdown_button_anim_handler()
vint_scriptevent_post( "warden_beatdown_button_anim" )
end
function hud_qte_stop_next_btn_anim()
vint_set_property(Hud_warden_meter.qte_btn_change_grp_h, "visible", false)
end
-------------------------------------------------------------------------------
-- Update via Dataitem
-- button_index: HUD_QTE_BTN_HIDDEN, HUD_QTE_BTN_A, HUD_QTE_BTN_B, HUD_QTE_BTN_X, etc...
-- button_animation: HUD_QTE_ANIM_NONE, HUD_QTE_ANIM_MASH_STANDARD, HUD_QTE_ANIM_MASH_FAST, HUD_QTE_ANIM_ALTERNATE_TRIGGER, etc...
-- x: position on screen for qte button...
-- y: position on screen for qte button...
-- is_ps3: is this button for ps3?
-- kbm_name: name to display on the keyboard or mouse.
-- success: true or false, depending on if the user completed the qte
-- mouse_button_number: Button number of the mouse (MOUSE_KEY_INVALID, MOUSE_KEY_LEFT, MOUSE_KEY_MIDDLE, etc...)
-- kb_direction: Number indicating the direction(HUD_QTE_INVALID_DIRECTION, HUD_QTE_KEY_ARROW_N, HUD_QTE_KEY_ARROW_E, HUD_QTE_KEY_ARROW_S, HUD_QTE_KEY_ARROW_W)
--
--
function hud_qte_update(di_h, event)
local button_index, button_animation, x, y, is_ps3, kbm_name, success, mouse_button_number, kb_direction, alt_button_index,alt_button_animation,alt_x,alt_y = vint_dataitem_get(di_h)
--mouse_button_number = MOUSE_KEY_4
--kb_direction = -1
local mouse_scroll_down_bg_h = vint_object_find("mouse_scroll_down_bg")
local mouse_scroll_up_bg_h = vint_object_find("mouse_scroll_up_bg")
vint_set_property(mouse_scroll_down_bg_h, "visible", false)
vint_set_property(mouse_scroll_up_bg_h, "visible", false)
-- set button group position
vint_set_property(Hud_qte_btn_1_grp_h, "anchor", x, y)
vint_set_property(Hud_qte_sticks_grp_h, "anchor", x, y)
vint_set_property(Hud_qte_success_grp_h, "anchor", x, y)
vint_set_property(Hud_qte_kb_grp_h, "anchor", x, y - 40) --moving the key up so it does not interfere with subtitles...
vint_set_property(Hud_qte_mouse_grp_h, "anchor", x, y)
vint_set_property(Hud_qte_kb_dir_grp_h, "anchor", x, y)
vint_set_property(Hud_qte_btn_2_grp_h, "anchor", alt_x, alt_y)
-- determine button visibility
vint_set_property(Hud_qte_btn_1_h, "visible", false)
vint_set_property(Hud_qte_btn_2_h, "visible", false)
vint_set_property(Hud_qte_btn_3_h, "visible", false)
vint_set_property(Hud_qte_btn_4_h, "visible", false)
vint_set_property(Hud_qte_sticks_grp_h, "visible", false)
vint_set_property(Hud_qte_success_grp_h, "visible", false)
vint_set_property(Hud_qte_kb_grp_h, "visible", false)
vint_set_property(Hud_qte_mouse_grp_h, "visible", false)
vint_set_property(Hud_qte_kb_dir_grp_h, "visible", false)
update(button_index, button_animation, x, y, is_ps3, kbm_name, success, mouse_button_number, kb_direction, false,mouse_scroll_down_bg_h, mouse_scroll_up_bg_h)
update(alt_button_index, alt_button_animation, alt_x, alt_y, is_ps3, kbm_name, success, mouse_button_number, kb_direction, true, mouse_scroll_down_bg_h, mouse_scroll_up_bg_h)
if(button_index == HUD_QTE_BTN_HIDDEN) then
hud_qte_pause_all()
end
end
function update(button_index, button_animation, x, y, is_ps3, kbm_name, success, mouse_button_number, kb_direction, alt, mouse_scroll_down_bg_h,mouse_scroll_up_bg_h)
if (button_index ~= HUD_QTE_BTN_HIDDEN) then
if game_is_active_input_gamepad() == false then
--determine if mouse or key...
if mouse_button_number == -1 then
if kb_direction == -1 then
--Show the keyboard key...
vint_set_property(Hud_qte_kb_grp_h, "visible", true)
--Set text...
Hud_qte_kb_key:set_text(kbm_name)
--Trigger animation...
Hud_qte_kb_key:mash(button_animation)
--Center QTE
local width = Hud_qte_kb_key:get_width()
local x, y = vint_get_property(Hud_qte_kb_key.handle, "anchor")
vint_set_property(Hud_qte_kb_key.handle, "anchor", -width * .5, y)
--Play succes animation?
Hud_qte_kb_key:success(success)
else
vint_set_property(Hud_qte_kb_dir_grp_h, "visible", true)
--Keyboard with directionals...
Hud_qte_kb_dir_n:mash(HUD_QTE_ANIM_NONE)
Hud_qte_kb_dir_e:mash(HUD_QTE_ANIM_NONE)
Hud_qte_kb_dir_s:mash(HUD_QTE_ANIM_NONE)
Hud_qte_kb_dir_w:mash(HUD_QTE_ANIM_NONE)
--reset the text of all the keys...
Hud_qte_kb_dir_n:set_text("")
Hud_qte_kb_dir_e:set_text("")
Hud_qte_kb_dir_s:set_text("")
Hud_qte_kb_dir_w:set_text("")
local qte_key = 0
if kb_direction == HUD_QTE_KEY_ARROW_N then
qte_key = Hud_qte_kb_dir_n
elseif kb_direction == HUD_QTE_KEY_ARROW_E then
qte_key = Hud_qte_kb_dir_e
elseif kb_direction == HUD_QTE_KEY_ARROW_S then
qte_key = Hud_qte_kb_dir_s
elseif kb_direction == HUD_QTE_KEY_ARROW_W then
qte_key = Hud_qte_kb_dir_w
end
qte_key:set_text(kbm_name)
qte_key:set_arrow_direction(kb_direction)
qte_key:mash(HUD_QTE_ANIM_MASH_STANDARD)
qte_key:success(success)
--Grab the key scale because the keys are scaled...
local key_scale = vint_get_property(Hud_qte_kb_dir_w.handle, "scale")
--get width of each key * key_scale to get the actual screen width...
local w_width = Hud_qte_kb_dir_w:get_width() * key_scale
local n_width = Hud_qte_kb_dir_n:get_width() * key_scale
local e_width = Hud_qte_kb_dir_e:get_width() * key_scale
local s_width = Hud_qte_kb_dir_s:get_width() * key_scale
--Reposition all the keys so they line up...
--center north icon
local x, y = vint_get_property(Hud_qte_kb_dir_n.handle, "anchor")
vint_set_property(Hud_qte_kb_dir_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_qte_kb_dir_s.handle, "anchor")
vint_set_property(Hud_qte_kb_dir_s.handle, "anchor", -s_width_half, base_y)
--west icon
local x, y = vint_get_property(Hud_qte_kb_dir_w.handle, "anchor")
vint_set_property(Hud_qte_kb_dir_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_qte_kb_dir_e.handle, "anchor")
vint_set_property(Hud_qte_kb_dir_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(Hud_qte_kb_dir_grp_h, "anchor")
local base_width = 193
if total_width > base_width then
vint_set_property(Hud_qte_kb_dir_grp_h, "anchor", x - ((total_width - base_width) * 0.5) - 20, y)
end
end
else
--Show mouse
vint_set_property(Hud_qte_mouse_grp_h, "visible", true)
--Update buttons
local mouse_highlight_h = vint_object_find("mouse_highlight")
local mouse_icon_h = vint_object_find("mouse_icon")
local mouse_mash_standard_anim_h = vint_object_find("mouse_mash_standard_anim")
local mouse_icon_tint_twn_h = vint_object_find("mouse_icon_tint_twn", mouse_mash_standard_anim_h)
--add bg for scroll arrow
if mouse_button_number == MOUSE_KEY_WHEEL_UP then
vint_set_property(mouse_scroll_up_bg_h, "visible", true)
elseif mouse_button_number == MOUSE_KEY_WHEEL_DOWN then
vint_set_property(mouse_scroll_down_bg_h, "visible", true)
end
--animate tint of 4, 5 big nums on mouse body
if mouse_button_number == MOUSE_KEY_4 or mouse_button_number == MOUSE_KEY_5 then
vint_set_property(mouse_icon_tint_twn_h, "start_value", 192/255,0,1)
else
vint_set_property(mouse_icon_tint_twn_h, "start_value", 1,1,1)
end
local mouse_highlight = Hud_qte_mouse_highlights[mouse_button_number]
local mouse_icon = Hud_qte_mouse_icons[mouse_button_number]
vint_set_property(mouse_highlight_h, "image", mouse_highlight)
vint_set_property(mouse_icon_h, "image", mouse_icon)
if (button_animation == HUD_QTE_ANIM_NONE) then
hud_qte_pause_all()
vint_set_property(mouse_highlight_h, "alpha", 0)
elseif (button_animation == HUD_QTE_ANIM_MASH_STANDARD or button_animation == HUD_QTE_ANIM_MASH_FAST) then
lua_play_anim(mouse_mash_standard_anim_h)
end
local mouse_success_anim_h = vint_object_find("mouse_success_anim")
local mouse_success_h = vint_object_find("mouse_success")
vint_set_property(mouse_success_h, "alpha", 0)
if #Hud_qte_mouse_success_bitmaps ~= 0 then
for i = 1, #Hud_qte_mouse_success_bitmaps do
vint_object_destroy(Hud_qte_mouse_success_bitmaps[i])
vint_object_destroy(Hud_qte_mouse_success_anims[i])
end
Hud_qte_mouse_success_bitmaps = {}
Hud_qte_mouse_success_anims = {}
end
if success then
--create mouse success items
for i = 1, 4 do
Hud_qte_mouse_success_bitmaps[i] = vint_object_clone(mouse_success_h)
Hud_qte_mouse_success_anims[i] = vint_object_clone(mouse_success_anim_h)
vint_set_property(Hud_qte_mouse_success_anims[i], "target_handle", Hud_qte_mouse_success_bitmaps[i])
lua_play_anim(Hud_qte_mouse_success_anims[i], (i - 1) * .1)
end
vint_set_property(mouse_highlight_h, "visible", false)
else
vint_set_property(mouse_highlight_h, "visible", true)
end
end
else
--Show buttons if index is lower than the stick indexes...
if button_index < HUD_QTE_STICK_UP then
if alt then
vint_set_property(Hud_qte_btn_3_h, "visible", true)
else
vint_set_property(Hud_qte_btn_1_h, "visible", true)
end
-- if animation exists make second image visible
if (button_animation ~= HUD_QTE_ANIM_NONE) then
if alt then
vint_set_property(Hud_qte_btn_4_h, "visible", true)
else
vint_set_property(Hud_qte_btn_2_h, "visible", true)
end
end
end
--Adjust stuff if button_index is a stick...
if (button_index >= HUD_QTE_STICK_UP and button_index <= HUD_QTE_STICK_LEFT ) then
--Uses stick index so show stick and adjust settings accordingly...
vint_set_property(Hud_qte_sticks_grp_h, "visible", true)
local stick_pressed_twn_h = vint_object_find("stick_pressed_twn")
--Set Callback to playback anim...
vint_set_property(stick_pressed_twn_h, "end_event", "vint_anim_loop_callback")
lua_play_anim(vint_object_find("stick_direction"))
if (button_index == HUD_QTE_STICK_UP) then -- R2
-- Rotate arrow pointing up...
vint_set_property(Hud_qte_stick_arrow_h, "rotation", 0)
--Modify Tweens to move stick up...
vint_set_property(stick_pressed_twn_h, "start_value", 0, -15)
vint_set_property(stick_pressed_twn_h, "end_value", 0, -15)
elseif (button_index == HUD_QTE_STICK_DOWN) then
--Rotate arrow pointing down..
vint_set_property(Hud_qte_stick_arrow_h, "rotation", 3.147)
--Modify Tweens to move stick down...
vint_set_property(stick_pressed_twn_h, "start_value", 0, 15)
vint_set_property(stick_pressed_twn_h, "end_value", 0, 15)
elseif (button_index == HUD_QTE_STICK_RIGHT) then -- R2
-- Rotate arrow pointing right...
vint_set_property(Hud_qte_stick_arrow_h, "rotation", 90 * DEG_TO_RAD)
--Modify Tweens to move stick right...
vint_set_property(stick_pressed_twn_h, "start_value", 0, 0)
vint_set_property(stick_pressed_twn_h, "end_value", 15, 0)
elseif (button_index == HUD_QTE_STICK_LEFT) then
--Rotate arrow pointing left..
vint_set_property(Hud_qte_stick_arrow_h, "rotation", 270 * DEG_TO_RAD)
--Modify Tweens to move stick left...
vint_set_property(stick_pressed_twn_h, "start_value", 0, 0)
vint_set_property(stick_pressed_twn_h, "end_value", -15, 0)
end
end
-- Set button images
local platform = game_get_platform()
if (is_ps3 == true) then
-- use PS3 button images
if (button_index == HUD_QTE_BTN_A) then -- CROSS
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_cross_up_ps3")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_cross_down_ps3")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_qte_cross_up_ps3")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_qte_cross_down_ps3")
end
elseif (button_index == HUD_QTE_BTN_B) then -- CIRCLE
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_circle_up_ps3")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_circle_down_ps3")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_qte_circle_up_ps3")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_qte_circle_down_ps3")
end
elseif (button_index == HUD_QTE_BTN_X) then -- SQUARE
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_square_up_ps3")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_square_down_ps3")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_qte_square_up_ps3")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_qte_square_down_ps3")
end
elseif (button_index == HUD_QTE_BTN_Y) then -- TRIANGLE
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_triangle_up_ps3")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_triangle_down_ps3")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_qte_triangle_up_ps3")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_qte_triangle_down_ps3")
end
elseif (button_index == HUD_QTE_BTN_LT) then -- L1
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_l1_up_ps3")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_l1_down_ps3")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_qte_l1_up_ps3")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_qte_l1_down_ps3")
end
elseif (button_index == HUD_QTE_BTN_RT) then -- **CHANGING RT TO MAP TO R1 ON PS3 BECAUSE R1 IS USED FOR SHOOTING ON PS3**
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_r1_up_ps3")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_r1_down_ps3")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_qte_r1_up_ps3")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_qte_r1_down_ps3")
end
elseif (button_index >= HUD_QTE_STICK_UP and button_index <= HUD_QTE_STICK_LEFT ) then --Stick
vint_set_property(Hud_qte_stick_pad_h, "image", "ui_qte_stick_ps3")
vint_set_property(Hud_qte_stick_base_h, "image", "ui_qte_base_ps3")
vint_set_property(Hud_qte_stick_arrow_h, "image", "ui_qte_arrow_ps3")
vint_set_property(Hud_qte_stick_label_h, "text_tag", "L")
else
--If btn value isn't accounted for throw up a garbage texture to let us know in game
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_hud_not_police")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_hud_not_police")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_hud_not_police")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_hud_not_police")
end
end
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
-- use PS4 button images
if touch_pad_index == HUD_QTE_TOUCH_PAD_SWIPE_UP then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_swipe_up_ps4")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_swipe_up_ps4")
elseif touch_pad_index == HUD_QTE_TOUCH_PAD_SWIPE_DOWN then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_swipe_down_ps4")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_swipe_down_ps4")
elseif touch_pad_index == HUD_QTE_TOUCH_PAD_SWIPE_LEFT then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_swipe_left_ps4")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_swipe_left_ps4")
elseif touch_pad_index == HUD_QTE_TOUCH_PAD_SWIPE_RIGHT then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_swipe_right_ps4")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_swipe_right_ps4")
elseif (button_index == HUD_QTE_BTN_A) then -- CROSS
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_cross_up_ps4")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_cross_down_ps4")
elseif (button_index == HUD_QTE_BTN_B) then -- CIRCLE
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_circle_up_ps4")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_circle_down_ps4")
elseif (button_index == HUD_QTE_BTN_X) then -- SQUARE
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_square_up_ps4")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_square_down_ps4")
elseif (button_index == HUD_QTE_BTN_Y) then -- TRIANGLE
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_triangle_up_ps4")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_triangle_down_ps4")
--HVS_TBT 9/3/2014: UPDATED LT/RT ON PS4 ONLY
elseif (button_index == HUD_QTE_BTN_LT) then -- L1
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_l2_up_ps4")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_l2_down_ps4")
elseif (button_index == HUD_QTE_BTN_RT) then -- **CHANGING RT TO MAP TO R1 ON PS4 BECAUSE R1 IS USED FOR SHOOTING ON PS4**
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_r2_up_ps4")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_r2_down_ps4")
elseif (button_index >= HUD_QTE_STICK_UP and button_index <= HUD_QTE_STICK_LEFT ) then --Stick
vint_set_property(Hud_qte_stick_pad_h, "image", "ui_qte_stick_ps4")
vint_set_property(Hud_qte_stick_base_h, "image", "ui_qte_base_ps4")
vint_set_property(Hud_qte_stick_arrow_h, "image", "ui_qte_arrow_ps4")
vint_set_property(Hud_qte_stick_label_h, "text_tag", "L")
else
--If btn value isn't accounted for throw up a garbage texture to let us know in game
vint_set_property(Hud_qte_btn_1_h, "image", "ui_hud_not_police")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_hud_not_police")
end
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
-- use XBOX3 button images
if (button_index == HUD_QTE_BTN_A) then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_a_up_xbox3")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_a_down_xbox3")
elseif (button_index == HUD_QTE_BTN_B) then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_b_up_xbox3")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_b_down_xbox3")
elseif (button_index == HUD_QTE_BTN_X) then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_x_up_xbox3")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_x_down_xbox3")
elseif (button_index == HUD_QTE_BTN_Y) then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_y_up_xbox3")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_y_down_xbox3")
elseif (button_index == HUD_QTE_BTN_LT) then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_lt_up_xbox3")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_lt_down_xbox3")
elseif (button_index == HUD_QTE_BTN_RT) then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_rt_up_xbox3")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_rt_down_xbox3")
elseif (button_index >= HUD_QTE_STICK_UP and button_index <= HUD_QTE_STICK_LEFT ) then --Stick
vint_set_property(Hud_qte_stick_pad_h, "image", "ui_qte_stick_xbox3")
vint_set_property(Hud_qte_stick_base_h, "image", "ui_qte_base_xbox3")
vint_set_property(Hud_qte_stick_arrow_h, "image", "ui_qte_arrow_xbox3")
vint_set_property(Hud_qte_stick_label_h, "text_tag", "LS")
else
--If btn value isn't accounted for throw up a garbage texture to let us know in game
vint_set_property(Hud_qte_btn_1_h, "image", "ui_hud_not_police")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_hud_not_police")
end
else
-- use XBOX2 button images
if (button_index == HUD_QTE_BTN_A) then
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_a_up_xbox2")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_a_down_xbox2")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_qte_a_up_xbox2")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_qte_a_down_xbox2")
end
elseif (button_index == HUD_QTE_BTN_B) then
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_b_up_xbox2")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_b_down_xbox2")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_qte_b_up_xbox2")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_qte_b_down_xbox2")
end
elseif (button_index == HUD_QTE_BTN_X) then
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_x_up_xbox2")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_x_down_xbox2")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_qte_x_up_xbox2")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_qte_x_down_xbox2")
end
elseif (button_index == HUD_QTE_BTN_Y) then
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_y_up_xbox2")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_y_down_xbox2")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_qte_y_up_xbox2")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_qte_y_down_xbox2")
end
elseif (button_index == HUD_QTE_BTN_LT) then
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_lt_up_xbox2")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_lt_down_xbox2")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_qte_lt_up_xbox2")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_qte_lt_down_xbox2")
end
elseif (button_index == HUD_QTE_BTN_RT) then
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_qte_rt_up_xbox2")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_qte_rt_down_xbox2")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_qte_rt_up_xbox2")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_qte_rt_down_xbox2")
end
elseif (button_index >= HUD_QTE_STICK_UP and button_index <= HUD_QTE_STICK_LEFT ) then --Stick
vint_set_property(Hud_qte_stick_pad_h, "image", "ui_qte_stick_xbox2")
vint_set_property(Hud_qte_stick_base_h, "image", "ui_qte_base_xbox2")
vint_set_property(Hud_qte_stick_arrow_h, "image", "ui_qte_arrow_xbox2")
vint_set_property(Hud_qte_stick_label_h, "text_tag", "LS")
else
--If btn value isn't accounted for throw up a garbage texture to let us know in game
if not alt then
vint_set_property(Hud_qte_btn_1_h, "image", "ui_hud_not_police")
vint_set_property(Hud_qte_btn_2_h, "image", "ui_hud_not_police")
else
vint_set_property(Hud_qte_btn_3_h, "image", "ui_hud_not_police")
vint_set_property(Hud_qte_btn_4_h, "image", "ui_hud_not_police")
end
end
end
--adjust success graphic anchor for buttons
if (button_index >= HUD_QTE_BTN_A and button_index <= HUD_QTE_BTN_RT ) then
local button_width, button_height
if alt then
button_width, button_height = vint_get_property(Hud_qte_btn_3_h, "screen_size")--element_get_actual_size
else
button_width, button_height = vint_get_property(Hud_qte_btn_1_h, "screen_size")--element_get_actual_size
end
local qte_x, qte_y = vint_get_property(Hud_qte_success_grp_h, "anchor")
local new_y = qte_y - button_height * 0.5
vint_set_property(Hud_qte_success_grp_h, "anchor", qte_x, new_y)
end
-- Play mash anim...
if (button_animation == HUD_QTE_ANIM_NONE) and not alt then
hud_qte_pause_all()
elseif (button_animation == HUD_QTE_ANIM_NONE) and alt then
vint_set_property(vint_object_find("mash_standard_alt"),"is_paused", true)
elseif (button_animation == HUD_QTE_ANIM_MASH_STANDARD) then
if alt then
lua_play_anim(vint_object_find("mash_standard_alt"))
else
lua_play_anim(vint_object_find("mash_standard"))
end
elseif (button_animation == HUD_QTE_ANIM_MASH_FAST) then
lua_play_anim(vint_object_find("mash_fast"))
end
-- if the qte is successful play the animation
if success then
vint_set_property(Hud_qte_success_grp_h, "visible", true)
hud_qte_play_success_anim()
end
end
else
--Hide and pause everything
if alt then
vint_set_property(Hud_qte_btn_3_h, "visible", false)
vint_set_property(Hud_qte_btn_4_h, "visible", false)
else
vint_set_property(Hud_qte_btn_1_h, "visible", false)
vint_set_property(Hud_qte_btn_2_h, "visible", false)
vint_set_property(Hud_qte_sticks_grp_h, "visible", false)
vint_set_property(Hud_qte_success_grp_h, "visible", false)
vint_set_property(Hud_qte_kb_grp_h, "visible", false)
vint_set_property(Hud_qte_mouse_grp_h, "visible", false)
end
end
-- store current btn and anim
Hud_qte_prev_btn = button_index
Hud_qte_prev_anim = button_animation
debug_print("vint", "button_animation: " .. var_to_string(button_animation) .. "\n")
end
-- Pause all animations
function hud_qte_pause_all()
vint_set_property(vint_object_find("mash_standard"),"is_paused", true)
vint_set_property(vint_object_find("mash_standard_alt"),"is_paused", true)
vint_set_property(vint_object_find("mash_fast"),"is_paused", true)
vint_set_property(vint_object_find("stick_direction"),"is_paused", true)
vint_set_property(vint_object_find("success"),"is_paused", true)
vint_set_property(vint_object_find("mouse_mash_standard_anim"),"is_paused", true)
vint_set_property(vint_object_find("mouse_mash_fast_anima"),"is_paused", true)
Hud_qte_kb_key:mash(HUD_QTE_ANIM_NONE)
end
--Play "success" Animation
function hud_qte_play_success_anim()
lua_play_anim(vint_object_find("success"))
end