ID_RADIO = 0
ID_MIXTAPE = 1
local Data = {
[ID_RADIO] = {
label = "MENU_RADIO",
icon = "ui_cell_icon_music"
},
[ID_MIXTAPE] = {
label = "MENU_PLAYLIST",
icon = "ui_cell_icon_mix",
can_wrap = false,
},
}
local Menu_extras
local Hint_bar
local Input_tracker
local Mouse_input_tracker
local cell_music_sub_doc_h = -1
function cell_music_sub_init()
-- Subscribe to the button presses we need
cell_music_sub_doc_h = vint_document_find("cell_music_sub")
--Build input tracker...
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("map", "cell_music_sub_button_map", 50)
Input_tracker:add_input("select", "cell_music_sub_button_a", 50)
Input_tracker:add_input("back", "cell_music_sub_button_b", 50)
Input_tracker:add_input("nav_up", "cell_music_sub_nav_up", 50)
Input_tracker:add_input("nav_down", "cell_music_sub_nav_down", 50)
Input_tracker:add_input("nav_left", "cell_music_sub_nav_left", 50)
Input_tracker:add_input("nav_right", "cell_music_sub_nav_right", 50)
--Build menu...
Menu_extras = Vdo_cell_menu:new("cell_menu")
Menu_extras:populate_menu(Data)
-- Setup Button Hints
Hint_bar = Vdo_hint_bar:new("hint_bar", 0, cell_music_sub_doc_h)
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Hint_bar:set_hints(hint_data)
if game_get_platform() == "PC" then
Hint_bar:set_visible(true)
Hint_bar:set_highlight(0)
Mouse_input_tracker = Vdo_input_tracker:new()
Hint_bar:add_mouse_inputs("cell_music_sub", Mouse_input_tracker)
Menu_extras:add_mouse_inputs("cell_music_sub", Mouse_input_tracker)
end
--Transition the screen in...
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MUSIC_SUB, CELL_SCREEN_MAIN, cell_music_sub_gained_focus)
end
function cell_music_sub_cleanup()
-- Nuke all button subscriptions
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function cell_music_sub_nav_up(event, acceleration)
Menu_extras:nav_up()
end
function cell_music_sub_nav_down(event, acceleration)
Menu_extras:nav_down()
end
function cell_music_sub_nav_left(event, acceleration)
Menu_extras:nav_left()
end
function cell_music_sub_nav_right(event, acceleration)
Menu_extras:nav_right()
end
function cell_music_sub_button_map(event, acceleration)
--Play menu back audio
ui_audio_post_event("UI_Hub_Menu_Back")
cell_music_sub_lock_controls()
cell_transition_screen(CELL_STATE_OUT, CELL_SCREEN_NONE, CELL_SCREEN_MUSIC_SUB, cell_music_sub_exit_to_game)
end
function cell_music_sub_button_b(event, acceleration)
--Play menu back audio
ui_audio_post_event("UI_Hub_Menu_Back")
cell_music_sub_lock_controls()
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_MUSIC_SUB, cell_music_sub_exit_to_main)
end
function cell_music_sub_exit_to_main()
pop_screen() --Extras
end
function cell_music_sub_exit_to_game()
pop_screen() --Extras
pop_screen() --Main
pop_screen() --frame
end
function cell_music_sub_button_a(event, acceleration)
--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_music_sub_handle_state(current_id)
end
function cell_music_sub_mouse_click(event, target_handle)
local hint_index = Hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
cell_music_sub_button_b()
end
-- If the target_handle matches a button, activate it
if Menu_extras:select_button(target_handle) == true then
cell_music_sub_button_a()
end
end
function cell_music_sub_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_music_sub_handle_state(state)
if state == ID_RADIO then
push_screen("cell_music_menu")
ui_audio_post_event("UI_Hub_Menu_Forward")
cell_music_sub_lock_controls()
elseif state == ID_MIXTAPE then
push_screen("cell_playlist")
ui_audio_post_event("UI_Hub_Menu_Forward")
cell_music_sub_lock_controls()
end
end
function cell_music_sub_unlock_controls()
Input_tracker:subscribe(true)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
end
function cell_music_sub_lock_controls()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function cell_music_sub_lost_focus()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function cell_music_sub_gained_focus()
Input_tracker:subscribe(true)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
--glitch
--glitch_cell()
end