--This interface is used in the Mission 21 Killbane Mask removal sequence.
local Input_tracker
local Mouse_input_tracker = 0
local Option_selected = -1
local KILLBANE_OPTION_REMOVE_MASK = 0
local KILLBANE_OPTION_LET_GO = 1
local Pressed_left_image = -1
local Pressed_right_image = -1
local Image_left_h = -1
local Image_right_h = -1
local Msn_killbane_gamepad_listener = -1
function msn_killbane_init()
local platform = game_get_platform()
local option1_text, option1_body, option2_text, option2_body = msn_killbane_get_option_text()
vint_set_property( vint_object_find( "text_left_title" ), "text_tag_crc", option1_text )
vint_set_property( vint_object_find( "text_left_body" ), "text_tag_crc", option1_body )
vint_set_property( vint_object_find( "text_right" ), "text_tag_crc", option2_text )
vint_set_property( vint_object_find( "text_right_body" ), "text_tag_crc", option2_body )
--Do input subscription...
Input_tracker = Vdo_input_tracker:new()
-- Button images
Image_left_h = vint_object_find("button_left_img")
Image_right_h = vint_object_find("button_right_img")
-- Different inputs for PC only (when gamepad is not active)
if game_is_active_input_gamepad() == false then
Input_tracker:add_input("key_left", "msn_killbane_nav", 50)
Input_tracker:add_input("key_right", "msn_killbane_nav", 50)
Input_tracker:add_input("nav_left", "msn_killbane_nav", 50)
Input_tracker:add_input("nav_right", "msn_killbane_nav", 50)
vint_set_property(Image_left_h, "image", "ui_pc_qte_arrow_off")
vint_set_property(Image_right_h, "image", "ui_pc_qte_arrow_off")
--Store to use for replacement later...
Pressed_left_image = "ui_pc_qte_arrow_on"
Pressed_right_image = "ui_pc_qte_arrow_on"
vint_set_property(Image_left_h, "scale", -1.0, 1.0)
else
Input_tracker:add_input("scroll_left", "msn_killbane_nav", 50)
Input_tracker:add_input("scroll_right", "msn_killbane_nav", 50)
if platform == "PS3" then
vint_set_property(Image_left_h, "image", "ui_qte_l1_up_ps3")
vint_set_property(Image_right_h, "image", "ui_qte_r1_up_ps3")
--Store to use for replacement later...
Pressed_left_image = "ui_qte_l1_down_ps3"
Pressed_right_image = "ui_qte_r1_down_ps3"
else
vint_set_property(Image_left_h, "image", "ui_qte_lt_up_xbox2")
vint_set_property(Image_right_h, "image", "ui_qte_rt_up_xbox2")
--Store to use for replacement later...
Pressed_left_image = "ui_qte_lt_down_xbox2"
Pressed_right_image = "ui_qte_rt_down_xbox2"
end
end
Input_tracker:subscribe(true)
if game_get_platform() == "PC" then
Mouse_input_tracker = Input_tracker:new()
msn_killbane_mouse_input_add()
Msn_killbane_gamepad_listener = vint_scriptevent_listen( "gamepad_active", "msn_killbane_update_gamepad_state" )
end
--Hide screen
local screen_grp_h = vint_object_find("screen_grp")
vint_set_property(screen_grp_h, "alpha", 0)
--Fade in screen
local anim_h = vint_object_find("fade_in_anim")
lua_play_anim(anim_h)
local anim_h = vint_object_find("fade_out_anim")
local twn_h = vint_object_find("fade_out_twn", anim_h)
vint_set_property(twn_h, "end_event", "msn_killbane_select")
-- hide this stuff if the game pauses
vint_dataitem_add_subscription("game_paused_item", "update", "msn_killbane_game_is_paused") --to check if game is paused...
end
function msn_killbane_cleanup()
Input_tracker:subscribe(false)
Input_tracker:remove_all()
if game_get_platform() == "PC" then
Mouse_input_tracker:subscribe(false)
Mouse_input_tracker:remove_all()
vint_scriptevent_stop_listening( Msn_killbane_gamepad_listener )
end
end
function msn_killbane_game_is_paused(di_h)
local is_paused = vint_dataitem_get(di_h)
local screen_grp_h = vint_object_find("screen_grp")
vint_set_property(screen_grp_h, "visible", is_paused == false)
end
-------------------------------------------------------------------------------
-- Input
-------------------------------------------------------------------------------
function msn_killbane_nav(event)
if Option_selected == -1 then
if event == "scroll_right" or event == "key_right" or event == "nav_right" then
Option_selected = KILLBANE_OPTION_REMOVE_MASK
vint_set_property(Image_right_h, "image", Pressed_right_image)
elseif event == "scroll_left" or event == "key_left" or event == "nav_left" then
Option_selected = KILLBANE_OPTION_LET_GO
vint_set_property(Image_left_h, "image", Pressed_left_image)
end
local anim_h = vint_object_find("fade_out_anim")
lua_play_anim(anim_h)
end
end
-------------------------------------------------------------------------------
-- Callback from fade out animation tells the game we are finished,
-- what option we've selected and pops screen...
-------------------------------------------------------------------------------
function msn_killbane_select()
--Tell game which option we've selected...
msn_killbane_selected_option(Option_selected)
--and Pop screen
pop_screen()
end
function msn_killbane_mouse_input_add()
Mouse_input_tracker:add_mouse_input("mouse_click", "msn_killbane_mouse_click", 50, Image_left_h)
Mouse_input_tracker:add_mouse_input("mouse_click", "msn_killbane_mouse_click", 50, Image_right_h)
Mouse_input_tracker:subscribe(true)
end
-------------------------------------------------------------------------------
-- Mouse inputs
function msn_killbane_mouse_click(event, target_handle, mouse_x, mouse_y)
if target_handle == Image_right_h then
msn_killbane_nav("key_right")
elseif target_handle == Image_left_h then
msn_killbane_nav("key_left")
end
end
function msn_killbane_mouse_move(event, target_handle)
end
--[[ ---------------------------------------------------------------------
-- Function - msn_killbane_update_gamepad_state
-- Description - Called by code anytime gamepad is plugged or unplugged.
-- Parameters - none
-- Returns - nil
]]-- ---------------------------------------------------------------------
function msn_killbane_update_gamepad_state()
Input_tracker:subscribe(false)
Input_tracker:remove_all()
if game_get_platform() == "PC" then
Mouse_input_tracker:subscribe(false)
Mouse_input_tracker:remove_all()
end
-- Different inputs for PC only (when gamepad is not active)
if game_is_active_input_gamepad() == false then
Input_tracker:add_input("key_left", "msn_killbane_nav", 50)
Input_tracker:add_input("key_right", "msn_killbane_nav", 50)
Input_tracker:add_input("nav_left", "msn_killbane_nav", 50)
Input_tracker:add_input("nav_right", "msn_killbane_nav", 50)
vint_set_property(Image_left_h, "image", "ui_pc_qte_arrow_off")
vint_set_property(Image_right_h, "image", "ui_pc_qte_arrow_off")
--Store to use for replacement later...
Pressed_left_image = "ui_pc_qte_arrow_on"
Pressed_right_image = "ui_pc_qte_arrow_on"
vint_set_property(Image_left_h, "scale", -1.0, 1.0)
else
Input_tracker:add_input("scroll_left", "msn_killbane_nav", 50)
Input_tracker:add_input("scroll_right", "msn_killbane_nav", 50)
vint_set_property(Image_left_h, "image", "ui_qte_lt_up_xbox2")
vint_set_property(Image_right_h, "image", "ui_qte_rt_up_xbox2")
--Store to use for replacement later...
Pressed_left_image = "ui_qte_lt_down_xbox2"
Pressed_right_image = "ui_qte_rt_down_xbox2"
vint_set_property(Image_left_h, "scale", 1.0, 1.0)
end
Input_tracker:subscribe(true)
if game_get_platform() == "PC" then
msn_killbane_mouse_input_add()
end
end