local Data = {
[ID_MAP] = {
label = "MENU_MAP",
icon = "ui_cell_icon_map"
},
[ID_MISSIONS] = {
label = "MENU_MISSIONS",
icon = "ui_cell_icon_missions"
},
[ID_SAINTSBOOK] = {
label = "MENU_SAINTS_BOOK",
icon = "ui_cell_icon_saintsbook",
can_wrap = false
},
[ID_REWARDS] = {
label = "MENU_UPGRADES",
icon = "ui_cell_icon_rewards"
},
[ID_MUSIC] = {
label = "MENU_MUSIC",
icon = "ui_cell_icon_music"
},
[ID_CAMERA] = {
label = "MENU_CAMERA",
icon = "ui_cell_icon_camera"
},
[ID_PHONE] = {
label = "MENU_PHONE",
icon = "ui_cell_icon_phone"
},
[ID_CASH] = {
label = "COMPLETION_CASH",
icon = "ui_cell_icon_cash",
},
[ID_EXTRAS] = {
label = "MENU_EXTRAS",
icon = "ui_cell_icon_extras"
},
}
local Menu
local Hint_bar
local Input_tracker
local Mouse_input_tracker
local Cell_menu_main_doc_h = -1
local New_item_idx = 0
local Current_idx = 0
local Found_homie = false
local Online_check_thread = -1
Cell_rewards_to_map = false
-- Used by a data responder to indicate there is at least one eligible homie to be called from the cell phone
function cell_phone_found_homie()
Found_homie = true
end
function populate_data_is_enabled()
Found_homie = false
-- Data request for homies in cell phone - if there are none, disable that screen
vint_dataresponder_request("cell_phone_pad_populate", "cell_phone_found_homie", 0, 0)
if Found_homie == false then
Data[ID_PHONE].is_enabled = false
end
-- cannot do missions in machina mode
if cell_machinima_is_recording() then
Data[ID_MISSIONS].is_enabled = false
end
-- camera allowed
if cell_allow_camera() == false then
Data[ID_CAMERA].is_enabled = false
end
if Data[ID_MISSIONS].new_items == 0 then
Data[ID_MISSIONS].is_enabled = false
end
-- non-release_final functionality to allow buttons on test levels
if cell_debug_all_enabled() then
return
end
if (game_get_in_progress_type() == 1) then -- 1 = Activities
Data[ID_PHONE].is_enabled = false
end
-- disable based on mission completion
if cell_is_mission_complete("m03") then
-- nothing locked
elseif cell_is_mission_complete("m02") then
-- lock saints book
Data[ID_SAINTSBOOK].is_enabled = false
else
-- lock map, missions, saints book, upgrades, music, and phone
Data[ID_MAP].is_enabled = false
Data[ID_MISSIONS].is_enabled = false
Data[ID_SAINTSBOOK].is_enabled = false
Data[ID_REWARDS].is_enabled = false
Data[ID_MUSIC].is_enabled = false
Data[ID_PHONE].is_enabled = false
Data[ID_CASH].is_enabled = false
end
--Verify that saintsbook is not enabled...
if sb_saintsbook_is_available() == false then
Data[ID_SAINTSBOOK].is_enabled = false
end
-- if the map is disabled for mission or some other state, don't allow it
if cell_is_map_disabled() then
Data[ID_MAP].is_enabled = false
end
end
function cell_menu_main_init()
-- Find our documents...
Cell_menu_main_doc_h = vint_document_find("cell_menu_main")
--Hide safe frame...
local safe_frame_h = vint_object_find("safe_frame", 0, Cell_menu_main_doc_h)
vint_set_property(safe_frame_h, "visible", false)
-- Setup input tracker.+
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("map", "cell_menu_main_button_b", 50)
Input_tracker:add_input("select", "cell_menu_main_button_a", 50)
Input_tracker:add_input("back", "cell_menu_main_button_b", 50)
Input_tracker:add_input("nav_up", "cell_menu_main_nav_up", 50)
Input_tracker:add_input("nav_down", "cell_menu_main_nav_down", 50)
Input_tracker:add_input("nav_left", "cell_menu_main_nav_left", 50)
Input_tracker:add_input("nav_right", "cell_menu_main_nav_right", 50)
-- Setup Button Hints
Hint_bar = Vdo_hint_bar:new("hint_bar", 0, Cell_menu_main_doc_h)
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Hint_bar:set_hints(hint_data)
game_UI_audio_play("UI_Cell_Activate")
vint_dataresponder_request("cell_menu_main_new_items", "cell_menu_main_set_new", 0)
vint_dataresponder_request("cell_menu_state_dr", "cell_menu_handle_state", 0)
-- Populate Data::is_enabled fields
-- Do this after above data responder requests, as new item count may determine button availability
populate_data_is_enabled()
Menu = Vdo_cell_menu:new("cell_menu")
Menu:populate_menu(Data)
if game_get_platform() == "PC" then
Hint_bar:set_visible(true)
Hint_bar:set_highlight(0)
Mouse_input_tracker = Vdo_input_tracker:new()
Menu:add_mouse_inputs("cell_menu_main", Mouse_input_tracker)
Hint_bar:add_mouse_inputs("cell_menu_main", Mouse_input_tracker)
Mouse_input_tracker:subscribe(false)
end
Cell_rewards_to_map = false
end
function cell_menu_main_cleanup()
if Online_check_thread ~= -1 then
thread_kill(Online_check_thread)
end
-- Nuke all button subscriptions
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function cell_menu_main_nav_up(event, acceleration)
Menu:nav_up()
end
function cell_menu_main_nav_down(event, acceleration)
Menu:nav_down()
end
function cell_menu_main_nav_left(event, acceleration)
Menu:nav_left()
end
function cell_menu_main_nav_right(event, acceleration)
Menu:nav_right()
end
function cell_menu_main_out(event, acceleration)
-- 2nd pop for cell_foreground doc
pop_screen()
pop_screen()
end
function cell_menu_main_button_b(event, acceleration)
cell_menu_main_lost_focus()
cell_transition_screen(CELL_STATE_OUT, CELL_SCREEN_NONE, CELL_SCREEN_MAIN, cell_menu_main_out)
game_UI_audio_play("UI_Cell_Close")
end
function cell_menu_main_button_a(event, acceleration)
--TODO: Check to see if tween is done before you move to next screen.
local current_id = Menu:get_id()
-- Pause_map_from_menu is initialized in cell_foreground
Pause_map_from_menu = true
Rewards_from_menu = true
Missions_from_menu = true
cell_menu_handle_state(current_id)
end
function cell_menu_main_mouse_click(event, target_handle)
local hint_index = Hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
cell_menu_main_button_b()
end
-- If the target_handle matches a button, activate it
if Menu:select_button(target_handle) == true then
cell_menu_main_button_a()
end
end
function cell_menu_main_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)
game_UI_audio_play("UI_Cell_Nav")
end
-- If the target_handle matches a button, highlight it and play a sound
if Menu:select_button(target_handle) == true then
game_UI_audio_play("UI_Cell_Nav")
end
end
function cell_menu_check_online_for_camera()
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
cell_menu_main_unlock_controls()
if Online_validator_result ~= ONLINE_VALIDATOR_PASSED then
return
end
if main_menu_check_user_content() == false then
dialog_box_message("MENU_TITLE_WARNING", "USER_CONTENT_PRIV_DENIED")
return
end
push_screen("cell_camera")
Online_check_thread = -1
end
function cell_menu_handle_state(state)
-- Don't push on a new screen if we've asked this one to close
if cell_is_closing() then
return
end
-- If we are in a different state than -1, then we need the phone to "load that application"
--Lose focus...
cell_menu_main_lost_focus()
Current_idx = state
if state == ID_MAP then
push_screen("pause_map")
game_UI_audio_play("UI_Cell_Select")
elseif state == ID_MISSIONS then
push_screen("cell_missions")
game_UI_audio_play("UI_Cell_Select")
elseif state == ID_SAINTSBOOK then
push_screen("cell_saintsbook")
game_UI_audio_play("UI_Cell_Select")
elseif state == ID_REWARDS then
push_screen("cell_rewards")
game_UI_audio_play("UI_Cell_Select")
elseif state == ID_MUSIC then
push_screen("cell_music_sub")
game_UI_audio_play("UI_Cell_Select")
elseif state == ID_CAMERA then
game_UI_audio_play("UI_Cell_Select")
Online_check_thread = thread_new("cell_menu_check_online_for_camera")
elseif state == ID_PHONE then
push_screen("cell_phone")
game_UI_audio_play("UI_Cell_Select")
elseif state == ID_EXTRAS then
push_screen("cell_extras")
game_UI_audio_play("UI_Cell_Select")
elseif state == ID_CASH then
push_screen("store_crib_cash")
--completion_load_lut("lut_default_xbox2")
game_UI_audio_play("UI_Cell_Select")
else
-- DEFAULT VIEW
--Hide safe frame...
local safe_frame_h = vint_object_find("safe_frame", 0, Cell_menu_main_doc_h)
vint_set_property(safe_frame_h, "visible", true)
-- Make the foreground and background show up with the frame
cell_show_frame()
--Transition to main screen
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_NONE, cell_menu_main_gained_focus)
end
end
function cell_menu_main_set_new(new_items)
if New_item_idx < 8 and New_item_idx ~= ID_CASH then
Data[New_item_idx].new_items = new_items
elseif New_item_idx == ID_CASH then
--dataresponer returns cash amount. If we have cash then show a 1.
if new_items > 0 then
Data[New_item_idx].new_items = 1
else
Data[New_item_idx].new_items = 0
end
end
New_item_idx = New_item_idx + 1
end
function cell_menu_main_unlock_controls()
Input_tracker:subscribe(true)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
end
function cell_menu_main_lock_controls()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function cell_menu_main_lost_focus()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function cell_menu_main_gained_focus()
cell_menu_main_unlock_controls()
--Refresh hints incase user switched between gamepad and keyboard/mouse
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Hint_bar:set_hints(hint_data)
vint_set_property(vint_object_find("safe_frame"), "visible", true)
New_item_idx = 0
vint_dataresponder_request("cell_menu_main_new_items", "cell_menu_main_set_new", 0)
Menu:populate_menu(Data, Current_idx)
end
function cell_menu_main_trans_to_pause_map()
--pop off screen
Cell_rewards_to_map = true
pop_screen()
push_screen("pause_map")
end