local Input_tracker
local Mouse_input_tracker
local Hint_bar
local Camera_menu_data = {
[1] = { label = "CELL_CAMERA_MODE_TITLE", type = TYPE_TOGGLE, id = 1, current_value = 1, options = {"CELL_CAMERA_MODE_ENABLED", "CELL_CAMERA_MODE_DISABLED"} },
}
Camera_list = 0
Cell_camera_doc_handle = -1
local CHEATS_LIST_WIDTH
function cell_camera_init()
--Get our document handle...
Cell_camera_doc_handle = vint_document_find("cell_camera")
--Ask c++ if our camera is enabled...
local camera_enabled = cell_camera_is_enabled()
--Set our menu to reflect game data...
if camera_enabled == true then
Camera_menu_data[1].current_value = 1
else
Camera_menu_data[1].current_value = 2
end
--Format our screen...
--Align web info...
local how_to_txt_h = vint_object_find("how_to_txt", 0, Cell_camera_doc_handle)
resize_text_element(how_to_txt_h, 380)
local web_title_txt_h = vint_object_find("web_title_txt" ,0, Cell_camera_doc_handle)
resize_text_element(web_title_txt_h, 380)
local web_info_grp_h = vint_object_find("web_info_grp")
local x, y = vint_get_property(web_info_grp_h, "anchor")
--Set up title
local cell_title_h = Vdo_cell_title:new("cell_title", 0, Cell_camera_doc_handle)
cell_title_h:set_text("MENU_CAMERA")
--cell_title_h:set_icon("ui_cell_icon_camera")
cell_title_h:play_dots_anim()
--Align description/how to...
local description_1_txt_h = vint_object_find("description_1_txt")
local description_x, description_y = vint_get_property(description_1_txt_h, "anchor")
local description_width, description_height = element_get_actual_size(description_1_txt_h)
local camera_hint_grp_h = vint_object_find("camera_hint_grp")
local camera_hint_x, camera_hint_y = vint_get_property(camera_hint_grp_h, "anchor")
local camera_hint_y = description_y + description_height + 110 --+ ((y - (description_y + description_height))*.4)
--vint_set_property(camera_hint_grp_h, "anchor", camera_hint_x, camera_hint_y)
--set control image...
local camera_hint_text = vint_object_find("camera_hint_txt", 0, Cell_camera_doc_handle)
local camera_hint_icon_vdo = Vdo_hint_button:new( "camera_hint_icon" )
camera_hint_icon_vdo:set_button( CTRL_MENU_BUTTON_BACK, game_get_key_name_for_action( "CBA_GAC_TAKE_SCREENSHOT" ), false, false)
if game_get_platform() == "PC" and game_is_active_input_gamepad() ~= true then
local hint_icon_w,hint_icon_h = camera_hint_icon_vdo:get_property( "screen_size" )
local adjusted_hint_x = hint_icon_w * 0.5
camera_hint_icon_vdo:set_property( "anchor", adjusted_hint_x, 0 )
local camera_hint_icon_bmp_h = vint_object_find( "camera_hint_icon_bmp" )
vint_set_property( camera_hint_icon_bmp_h, "anchor", hint_icon_w + 6, 0 )
vint_set_property(camera_hint_text, "visible", false)
else
local hint_text_w, hint_text_h = element_get_actual_size(camera_hint_text)
local hint_icon_w,hint_icon_h = camera_hint_icon_vdo:get_actual_size()
local adjusted_hint_x = hint_icon_w * 0.5
camera_hint_icon_vdo:set_property( "anchor", hint_text_w + 20 + adjusted_hint_x, 0 )
local camera_hint_icon_bmp_h = vint_object_find( "camera_hint_icon_bmp" )
vint_set_property( camera_hint_icon_bmp_h, "anchor", hint_text_w + 20 + hint_icon_w + 20, 0 )
vint_set_property(camera_hint_text, "visible", true)
end
--Build our megalist...
Camera_list = Vdo_mega_list:new("camera_list", 0, Cell_camera_doc_handle, "cell_camera.lua", "Camera_list")
Camera_list:set_properties(COLOR_CHEATS_PRIMARY, COLOR_CHEATS_SECONDARY, 10, .8, 410, false, false)
Camera_list:draw_items(Camera_menu_data, 1)
-- Subscribe to the button presses we need
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("map", "cell_camera_button_map", 50)
Input_tracker:add_input("back", "cell_camera_button_b", 50)
Input_tracker:add_input("nav_up", "cell_camera_nav", 50)
Input_tracker:add_input("nav_down", "cell_camera_nav", 50)
Input_tracker:add_input("nav_left", "cell_camera_nav_left_right", 50)
Input_tracker:add_input("nav_right", "cell_camera_nav_left_right", 50)
Input_tracker:subscribe(true)
--[[
local action_hint_data = {
{CTRL_BUTTON_DPAD_DOWN, "CELL_CAMERA_MODE_TAKE_SNAPSHOT"},
}
local action_hint_bar = Vdo_hint_bar:new("action_hint")
action_hint_bar:set_hints(action_hint_data)
]]
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Hint_bar = Vdo_hint_bar:new("hint_bar")
Hint_bar:set_hints(hint_data)
if game_get_platform() == "PC" then
Hint_bar:set_highlight(0)
Mouse_input_tracker = Vdo_input_tracker:new()
Camera_list:add_mouse_inputs("cell_camera", Mouse_input_tracker)
Hint_bar:add_mouse_inputs("cell_camera", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
--Transition the screen in...
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_CAMERA, CELL_SCREEN_MAIN, nil)
--glitch
--glitch_cell()
end
function cell_camera_nav(event)
if event == "nav_up" then
Camera_list:move_cursor(-1)
elseif event == "nav_down" then
Camera_list:move_cursor(1)
end
end
function cell_camera_nav_left_right(event)
if Camera_list:list_is_playing() == false then
Input_tracker:subscribe(false)
if game_get_platform() == "PC" then
Mouse_input_tracker:subscribe(false)
end
--online_and_privilege_validator_begin(can_sign_in = false, check_service = true, check_online_priv = true, check_chat_priv = false, in_game = true, fail_on_chat = nil)
online_and_privilege_validator_begin(false, true, true, false, true) -- Check we're signed in and we have content permissions
while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do
thread_yield()
end
Input_tracker:subscribe(true)
if game_get_platform() == "PC" then
Mouse_input_tracker:subscribe(true)
end
if Online_validator_result ~= ONLINE_VALIDATOR_PASSED then
return
end
if game_get_platform() == "XBOX360" then
if main_menu_xbox_get_age_group() == "unknown" then
dialog_box_message( "MENU_TITLE_NOTICE", "NO_NETWORK_CONNECTION" )
return
end
if main_menu_xbox_get_age_group() ~= "adult" then
dialog_box_message( "MENU_TITLE_NOTICE", "PLATFORM_XBOX_COMMUNITY_AGE_RESTRICTED" )
return
end
end
if game_get_platform() == "XBOX3" then
if main_menu_xbox_get_age_group() == "unknown" then
dialog_box_message( "MENU_TITLE_NOTICE", "NO_NETWORK_CONNECTION" )
return
end
if main_menu_xbox_get_age_group() ~= "adult" then
dialog_box_message( "MENU_TITLE_NOTICE", "PLATFORM_XBOX_COMMUNITY_AGE_RESTRICTED" )
return
end
end
if main_menu_check_social_privilege() == false then
dialog_box_message("MENU_TITLE_WARNING", "USER_CONTENT_PRIV_DENIED")
return
end
if event == "nav_left" then
Camera_list:move_slider(1)
elseif event == "nav_right" then
Camera_list:move_slider(-1)
end
local toggle_selection = Camera_list:get_toggle_selection()
if toggle_selection == 1 then
--enabled
cell_camera_enable(true)
elseif toggle_selection == 2 then
--disabled
cell_camera_enable(false)
end
end
end
function cell_camera_button_b(event, acceleration)
cell_camera_lock_controls()
ui_audio_post_event("UI_Hub_Menu_Back")
--Transition the screen in...
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_CAMERA, cell_camera_exit_to_main)
end
function cell_camera_button_map(event, acceleration)
--Exit phone...
cell_camera_lock_controls()
vint_dataresponder_post("cell_menu_state_dr", "Set", ID_MAIN)
ui_audio_post_event("UI_Hub_Menu_Back")
--Transition the screen in...
cell_transition_screen(CELL_STATE_OUT, CELL_SCREEN_NONE, CELL_SCREEN_CAMERA, cell_camera_exit_to_game)
end
function cell_camera_exit_to_main()
pop_screen()
end
function cell_camera_exit_to_game()
pop_screen() --camera
pop_screen() --main menu
pop_screen() --cellphone frame
end
-------------------------------------------------------------------------------
-- Controls Unlock
--
function cell_camera_unlock_controls()
Input_tracker:subscribe(true)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
end
-------------------------------------------------------------------------------
-- Controls Lock
--
function cell_camera_lock_controls()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
-- Mouse inputs
function cell_camera_mouse_click(event, target_handle, mouse_x, mouse_y)
local hint_index = Hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
cell_camera_button_b()
end
local new_index = Camera_list:get_button_index(target_handle)
if new_index ~= 0 then
Camera_list:set_selection(new_index)
cell_camera_nav_left_right("nav_right")
end
if Camera_list:is_left_arrow(target_handle) then
cell_camera_nav_left_right("nav_left")
end
end
function cell_camera_mouse_move(event, target_handle)
Hint_bar:set_highlight(0)
local hint_index = Hint_bar:get_hint_index(target_handle)
if hint_index ~= 0 then
Hint_bar:set_highlight(hint_index)
end
local new_index = Camera_list:get_button_index(target_handle)
if new_index ~= 0 then
Camera_list:set_selection(new_index)
Camera_list:move_cursor(0, true)
end
end