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 data = {
{h = vint_object_find("web_title_txt"), type = VINT_OBJECT_TEXT, space = 0},
{h = vint_object_find("web_desc_txt"), type = VINT_OBJECT_TEXT, space = 0},
}
local width, height = vint_align_elements(data, true)
local web_info_bg_h = vint_object_find("web_info_bg")
local bg_width, bg_height = element_get_actual_size(web_info_bg_h)
height = height + 15 --(add padding for height)
element_set_actual_size(web_info_bg_h, bg_width, height)
local web_info_grp_h = vint_object_find("web_info_grp")
local x, y = vint_get_property(web_info_grp_h, "anchor")
local bottom_y = 370 --bottom of the screen
y = bottom_y - height --subtract up to place...
vint_set_property(web_info_grp_h, "anchor", x, y)
--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 + ((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_icon_vdo = Vdo_hint_button:new( "camera_hint_icon" )
camera_hint_icon_vdo:set_button( CTRL_BUTTON_DPAD_DOWN, game_get_key_name_for_action( "CBA_GAC_TAKE_SCREENSHOT" ), false, false)
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 )
--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, 364, 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)
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 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
function cell_camera_button_b(event, acceleration)
cell_camera_lock_controls()
game_UI_audio_play("UI_Cell_Nav_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)
game_UI_audio_play("UI_Cell_Close")
--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