ID_CHEATS = 0
ID_STATS = 1
local Data = {
[ID_CHEATS] = {
label = "MENU_CHEATS",
icon = "ui_cell_icon_cheats"
},
[ID_STATS] = {
label = "MENU_STATS",
icon = "ui_cell_icon_stats",
can_wrap = false
},
}
local Menu_extras
local Hint_bar
local Input_tracker
local Mouse_input_tracker
local Cell_extras_doc_h = -1
function cell_extras_init()
-- Subscribe to the button presses we need
Cell_extras_doc_h = vint_document_find("cell_extras")
--Build input tracker...
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("map", "cell_extras_button_map", 50)
Input_tracker:add_input("select", "cell_extras_button_a", 50)
Input_tracker:add_input("back", "cell_extras_button_b", 50)
Input_tracker:add_input("nav_up", "cell_extras_nav_up", 50)
Input_tracker:add_input("nav_down", "cell_extras_nav_down", 50)
Input_tracker:add_input("nav_left", "cell_extras_nav_left", 50)
Input_tracker:add_input("nav_right", "cell_extras_nav_right", 50)
--Build menu...
Menu_extras = Vdo_cell_menu:new("cell_menu")
Menu_extras:populate_menu(Data)
if game_get_platform() == "PC" then
-- Setup Button Hints
Hint_bar = Vdo_hint_bar:new("hint_bar", 0, Cell_extras_doc_h)
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Hint_bar:set_hints(hint_data)
Hint_bar:set_visible(true)
Hint_bar:set_highlight(0)
Mouse_input_tracker = Vdo_input_tracker:new()
Menu_extras:add_mouse_inputs("cell_extras", Mouse_input_tracker)
Hint_bar:add_mouse_inputs("cell_extras", Mouse_input_tracker)
end
debug_print("vint", "double transition\n")
--Transition the screen in...
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_EXTRAS, CELL_SCREEN_MAIN, cell_extras_gained_focus)
end
function cell_extras_cleanup()
-- Nuke all button subscriptions
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function cell_extras_nav_up(event, acceleration)
Menu_extras:nav_up()
end
function cell_extras_nav_down(event, acceleration)
Menu_extras:nav_down()
end
function cell_extras_nav_left(event, acceleration)
Menu_extras:nav_left()
end
function cell_extras_nav_right(event, acceleration)
Menu_extras:nav_right()
end
function cell_extras_button_map(event, acceleration)
game_UI_audio_play("UI_Cell_Close")
cell_extras_lock_controls()
cell_transition_screen(CELL_STATE_OUT, CELL_SCREEN_NONE, CELL_SCREEN_EXTRAS, cell_extras_exit_to_game)
end
function cell_extras_button_b(event, acceleration)
game_UI_audio_play("UI_Cell_Nav_Back")
cell_extras_lock_controls()
Menu_extras:show_highlight(false)
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_EXTRAS, cell_extras_exit_to_main)
end
function cell_extras_exit_to_main()
pop_screen() --Extras
end
function cell_extras_exit_to_game()
pop_screen() --Extras
pop_screen() --Main
pop_screen() --frame
end
function cell_extras_button_a(event, acceleration)
cell_extras_lock_controls()
--TODO: Check to see if tween is done before you move to next screen.
--Get id and change state...
local current_id = Menu_extras:get_id()
cell_extras_handle_state(current_id)
end
function cell_extras_mouse_click(event, target_handle)
local hint_index = Hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
cell_extras_button_b()
end
-- If the target_handle matches a button, activate it
if Menu_extras:select_button(target_handle) == true then
cell_extras_button_a()
end
end
function cell_extras_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_extras:select_button(target_handle) == true then
game_UI_audio_play("UI_Cell_Nav")
end
end
function cell_extras_handle_state(state)
-- If we are in a different state than -1, then we need the phone to "load that application"
local safe_frame = vint_object_find("safe_frame")
vint_set_property(safe_frame, "visible", true)
if state == ID_STATS then
push_screen("cell_stats")
game_UI_audio_play("UI_Cell_Select")
elseif state == ID_CHEATS then
push_screen("cell_cheats")
game_UI_audio_play("UI_Cell_Select")
end
end
function cell_extras_unlock_controls()
Input_tracker:subscribe(true)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
end
function cell_extras_lock_controls()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function cell_extras_lost_focus()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function cell_extras_gained_focus()
Input_tracker:subscribe(true)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
end