local Main_menu_silverlink_doc_h = 0
local ID_CONNECT = 1
local ID_CREATE_ACCOUNT = 2
local ID_LOST_PASSWORD = 3
local ID_ABOUT_SILVERLINK = 4
local ID_REWARDS = 5
local ID_SETTINGS = 6
--If the user is logged out
local Menu_logged_out = {
[1] = {
type = TYPE_BUTTON,
label = "SL_MENU_CONNECT",
id = ID_CONNECT,
},
[2] = {
type = TYPE_BUTTON,
label = "SL_MENU_CREATE_ACCOUNT",
id = ID_CREATE_ACCOUNT,
},
[3] = {
type = TYPE_BUTTON,
label = "SL_MENU_LOST_PASSWORD",
id = ID_LOST_PASSWORD,
},
[4] = {
type = TYPE_BUTTON,
label = "SL_MENU_ABOUT_SILVERLINK",
id = ID_ABOUT_SILVERLINK,
}
}
--If the user is logged out
local Menu_logged_in = {
[1] = {
type = TYPE_BUTTON,
label = "SL_MENU_SILVERLINK_REWARDS",
id = ID_REWARDS,
},
[2] = {
type = TYPE_BUTTON,
label = "SL_MENU_SETTINGS",
id = ID_SETTINGS,
},
[3] = {
type = TYPE_BUTTON,
label = "SL_MENU_ABOUT_SILVERLINK",
id = ID_ABOUT_SILVERLINK,
}
}
local Input_tracker
local Mouse_input_tracker
local Screen_width
if vint_is_std_res() then
Screen_width = 750
else
Screen_width = 840
end
---------------------------------------------------------------------------
-- Initialize Pause Options Menu.
---------------------------------------------------------------------------
function main_menu_silverlink_init()
Main_menu_silverlink_doc_h = vint_document_find("main_menu_silverlink")
-- Subscribe to the button presses we need
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "main_menu_silverlink_button_a", 50)
Input_tracker:add_input("back", "main_menu_silverlink_button_b", 50)
Input_tracker:add_input("nav_up", "main_menu_silverlink_nav_up", 50)
Input_tracker:add_input("nav_down", "main_menu_silverlink_nav_down", 50)
Input_tracker:add_input("nav_left", "main_menu_silverlink_nav_left", 50)
Input_tracker:add_input("nav_right", "main_menu_silverlink_nav_right", 50)
Input_tracker:subscribe(false)
--Initialize Header
Header_obj:show_me(false)
--Header_mini_obj:set_text("SILVER LINK 2")
--Header_mini_obj:set_visible(true)
--Setup Button Hints
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Menu_hint_bar:set_hints(hint_data)
--Check to see if we are connected or disconnected... base menu display based on that...
local am_i_logged_in = silverlink_is_connected()
local data
if am_i_logged_in then
data = Menu_logged_in
main_menu_silverlink_update_login(true)
else
data = Menu_logged_out
main_menu_silverlink_update_login(false)
end
--Get the selection option from when the menu was last loaded
local last_option_selected = menu_common_stack_get_index(data)
List:set_visible(true)
List:draw_items(data, last_option_selected, Screen_width)
--Store some locals to the pause menu common for screen processing.
menu_common_set_list_style(List, Header_obj, Screen_width)
bg_saints_show(true)
menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_slide_out_anim)
--Show the silverlink logo
if In_silverlink_menu == false then
main_menu_silverlink_logo_show(true)
main_menu_silverlink_logo_is_visible(true)
In_silverlink_menu = true
end
--Show silverlink Login
main_menu_silverlink_login_show(true)
--Some stuff i'm not sure what it does yet (JMH- 4/30/2013)
if First_time then
Screen_in_anim:play(0)
bg_saints_slide_in(Screen_width)
First_time = false
end
-- Add mouse inputs for the PC
if game_get_platform() == "PC" then
Menu_hint_bar:set_highlight(0)
Mouse_input_tracker = Vdo_input_tracker:new()
List:add_mouse_inputs("main_menu_silverlink", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("main_menu_silverlink", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
--menu_common_set_mouse_tracker(Mouse_input_tracker)
end
end
function main_menu_silverlink_cleanup()
-- Nuke all button subscriptions
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
List:enable_toggle_input(false)
Header_obj:show_me(true)
Header_mini_obj:set_visible(false)
end
function main_menu_silverlink_nav_up(event, acceleration)
-- Move highlight up
List:move_cursor(-1)
end
function main_menu_silverlink_nav_down(event, acceleration)
-- Move highlight down
List:move_cursor(1)
end
function main_menu_silverlink_nav_left(event, acceleration)
-- Move highlight left
List:move_slider(-1)
end
function main_menu_silverlink_nav_right(event, acceleration)
-- Move highlight right
List:move_slider(1)
end
function main_menu_silverlink_button_a(event, acceleration)
local current_id = List:get_id()
--Add current selection to the stack to store the selected position on the menu
menu_common_stack_add(current_id)
--pass off the input to the list
List:button_a()
if current_id == ID_CONNECT then
silverlink_dlg_connect()
elseif current_id == ID_CREATE_ACCOUNT then
silverlink_dlg_create_account()
elseif current_id == ID_LOST_PASSWORD then
silverlink_dlg_lost_password()
elseif current_id == ID_ABOUT_SILVERLINK then
menu_common_transition_push("main_sl_about")
--Hide silverlink Login
main_menu_silverlink_login_show(false)
elseif current_id == ID_REWARDS then
menu_common_transition_push("main_sl_rewards")
--Hide silverlink Login
main_menu_silverlink_login_show(false)
elseif current_id == ID_SETTINGS then
menu_common_transition_push("main_sl_settings")
--Hide silverlink Login
main_menu_silverlink_login_show(false)
end
end
function main_menu_silverlink_button_b(event, acceleration)
List:button_b()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
-- final pop...
--Remove current menu from the stack
menu_common_stack_remove()
--Pop Screen off the list
menu_common_transition_pop(1)
--Hide the silverlink logo
main_menu_silverlink_logo_show(false)
--Hide silverlink Login
main_menu_silverlink_login_show(false)
In_silverlink_menu = false
bg_saints_slide_out()
end
function main_menu_silverlink_mouse_click(event, target_handle)
local hint_index = Menu_hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
main_menu_silverlink_button_b()
end
local new_index = List:get_button_index(target_handle)
if new_index ~= 0 then
List:set_selection(new_index)
main_menu_silverlink_button_a()
end
end
function main_menu_silverlink_mouse_move(event, target_handle)
Menu_hint_bar:set_highlight(0)
local hint_index = Menu_hint_bar:get_hint_index(target_handle)
if hint_index ~= 0 then
Menu_hint_bar:set_highlight(hint_index)
end
local new_index = List:get_button_index(target_handle)
if new_index ~= 0 then
List:set_selection(new_index)
List:move_cursor(0, true)
end
end
-------------------------------------------------------------------------------
-- When silverlink is connceted...
-- (This is called From C++)
--
function silverlink_connection_changed()
--Changes menu to a connected screen
local am_i_logged_in = silverlink_is_connected()
local data
if am_i_logged_in then
data = Menu_logged_in
main_menu_silverlink_update_login(true)
else
data = Menu_logged_out
main_menu_silverlink_update_login(false)
end
List:set_visible(true)
List:draw_items(data, 1, Screen_width)
end
-------------------------------------------------------------------------------
-- When all dialogs are closed...
-- (This is called From C++)
--
function silverlink_all_dialogs_closed()
--All dialogs closed now lets show the cursor...
List:move_cursor(0)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:remove_all()
Menu_hint_bar:add_mouse_inputs("main_menu_silverlink", Mouse_input_tracker)
List:add_mouse_inputs("main_menu_silverlink", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end