local JOIN_FRIEND_INDEX = 1
local NEW_GAME_INDEX = 2
local LOAD_GAME_INDEX = 3
local MATCHMAKING_INDEX = 4
local ID_JOIN_FRIEND = 1
local ID_NEW_GAME = 2
local ID_LOAD_GAME = 3
local ID_MATCHMAKING = 4
local ID_CHECK_MESSAGES = 5
local Check_messages_button = {
type = TYPE_BUTTON,
label = "MAINMENU_CHECK_MESSAGES",
id = ID_CHECK_MESSAGES,
}
local Syslink_join_button = {
type = TYPE_BUTTON,
label = "MULTI_FIND_GAMES",
id = ID_JOIN_FRIEND,
}
local Live_join_button = {
type = TYPE_BUTTON,
label = "MULTI_JOIN_FRIEND",
id = ID_JOIN_FRIEND,
}
local New_game_button = {
type = TYPE_BUTTON,
label = "MAINMENU_NEW",
id = ID_NEW_GAME,
}
local Load_game_button = {
type = TYPE_BUTTON,
label = "SAVELOAD_LOAD_GAME",
id = ID_LOAD_GAME,
}
local Matchmaking_button = {
type = TYPE_BUTTON,
label = "MULTI_MATCHMAKING",
id = ID_MATCHMAKING,
}
local Data
local Anims = {}
local Input_tracker
local Mouse_input_tracker
local Should_lock = false
local Tween_done = true
---------------------------------------------------------------------------
-- Initialize Pause Options Menu.
---------------------------------------------------------------------------
function main_menu_coop_init()
-- Subscribe to the button presses we need
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "main_menu_coop_button_a", 50)
Input_tracker:add_input("back", "main_menu_coop_button_b", 50)
Input_tracker:add_input("nav_up", "main_menu_coop_nav_up", 50)
Input_tracker:add_input("nav_down", "main_menu_coop_nav_down", 50)
Input_tracker:add_input("nav_left", "main_menu_coop_nav_left", 50)
Input_tracker:add_input("nav_right", "main_menu_coop_nav_right", 50)
main_menu_coop_gained_focus()
end
function main_menu_coop_gained_focus()
Input_tracker:subscribe(false)
local screen_width = 600
local header_str = "MAINMENU_ONLINE_GAME"
local header_crumb = ""
Data = { }
-- DAD - 9/10/11 - reset the indices (PS3) (last minute hack)
JOIN_FRIEND_INDEX = 1
NEW_GAME_INDEX = 2
LOAD_GAME_INDEX = 3
MATCHMAKING_INDEX = 4
if game_get_platform() == "PS3" and Main_menu_coop_is_xbox_live then
JOIN_FRIEND_INDEX = JOIN_FRIEND_INDEX + 1
NEW_GAME_INDEX = JOIN_FRIEND_INDEX + 1
LOAD_GAME_INDEX = JOIN_FRIEND_INDEX + 2
MATCHMAKING_INDEX = JOIN_FRIEND_INDEX + 3
Data[1] = Check_messages_button
end
--Get menu specific data...
if Main_menu_coop_is_xbox_live then
-- Xbox live
Data[JOIN_FRIEND_INDEX] = Live_join_button
else
-- System link
Data[JOIN_FRIEND_INDEX] = Syslink_join_button
header_str = "MAINMENU_SYSLINK_TITLE"
end
Data[NEW_GAME_INDEX] = New_game_button
if Whored_mode_active == true then
if Main_menu_coop_is_xbox_live then
Data[NEW_GAME_INDEX].label = "MAINMENU_WHORED_COOP_OPTION"
else
Data[NEW_GAME_INDEX].label = "MAINMENU_WHORED_OPTION"
end
MATCHMAKING_INDEX = LOAD_GAME_INDEX
header_crumb = "MAINMENU_WHORED"
else
Data[LOAD_GAME_INDEX] = Load_game_button
end
if Main_menu_coop_is_xbox_live == true then
-- Xbox live
Data[MATCHMAKING_INDEX] = Matchmaking_button
end
--Initialize Header
Header_obj:set_text(header_str, screen_width)
Header_obj:set_crumb(header_crumb)
--Setup Button Hints
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Menu_hint_bar:set_hints(hint_data)
--Get the selection option from when the menu was last loaded
local last_option_selected = menu_common_stack_get_index(Data)
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)
menu_common_set_screen_data(List, Header_obj, nil, Screen_back_out_anim, Screen_slide_out_anim, anim_finished)
-- Add mouse inputs for the PC
if game_get_platform() == "PC" then
if Mouse_input_tracker == nil then
Mouse_input_tracker = Vdo_input_tracker:new()
end
List:add_mouse_inputs("main_menu_coop", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("main_menu_coop", Mouse_input_tracker)
Menu_hint_bar:set_highlight(0)
Mouse_input_tracker:subscribe(true)
--menu_common_set_mouse_tracker(Mouse_input_tracker)
end
end
function main_menu_coop_lost_focus()
-- 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)
end
function anim_finished()
if Should_lock == false then
main_menu_coop_lock_controls(false)
end
end
function main_menu_coop_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)
end
function main_menu_coop_nav_up(event, acceleration)
-- Move highlight up
List:move_cursor(-1)
end
function main_menu_coop_nav_down(event, acceleration)
-- Move highlight down
List:move_cursor(1)
end
function main_menu_coop_nav_left(event, acceleration)
-- Move highlight left
List:move_slider(-1)
end
function main_menu_coop_nav_right(event, acceleration)
-- Move highlight right
List:move_slider(1)
end
function main_menu_coop_button_a(event, acceleration)
if Tween_done == true then
--Set the screen data to the list data
Data = List:return_data()
local current_id = List:get_id()
--pass off the input to the list
--List:button_a()
--Add current selection to the stack to store the selected position on the menu
menu_common_stack_add(current_id)
if current_id == ID_JOIN_FRIEND then
if Main_menu_coop_is_xbox_live == true then
Coop_connect_operation = COOP_ONLINE_JOIN_LIST
else
Coop_connect_operation = COOP_SYSLINK_JOIN_LIST
end
menu_common_transition_push("pause_invite_friends")
return
elseif current_id == ID_NEW_GAME then
if Main_menu_coop_is_xbox_live then
game_coop_start_new_live()
else
game_coop_start_new_syslink()
end
if Whored_mode_active then
main_menu_horde_start()
else
menu_common_transition_push("main_menu_new_game")
end
return
elseif current_id == ID_LOAD_GAME then
Load_for_coop = true
menu_common_transition_push("pause_save_game")
return
elseif current_id == ID_MATCHMAKING then
main_menu_matchmaking(Whored_mode_active)
main_menu_coop_lock_controls(true)
elseif current_id == ID_CHECK_MESSAGES then
main_menu_check_messages()
end
end
end
function main_menu_coop_button_b(event, acceleration)
if Tween_done == true then
--pass off the input to the list
List:button_b()
main_menu_coop_lost_focus()
--Remove current menu from the stack
menu_common_stack_remove()
--Pop Screen off the list
menu_common_transition_pop(1)
--else
--back up a screen
--Anims.list_in:stop()
--Anims.list_out:play()
--Anims.list_out_tween = Vdo_tween_object:new("list_anchor_twn_2")
--Anims.list_out_tween:set_property("end_event", "ui_options_audio_anim_done")
--Tween_done = false
--end
end
end
function main_menu_coop_mouse_click(event, target_handle)
local hint_index = Menu_hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
main_menu_coop_button_b()
end
local new_index = List:get_button_index(target_handle)
if new_index ~= 0 then
List:set_selection(new_index)
main_menu_coop_button_a()
end
end
function main_menu_coop_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
function main_menu_coop_lock_controls(lock)
Should_lock = lock
if Should_lock then
debug_print("vint", "Coop input locked!\n")
else
debug_print("vint", "Coop input unlocked!\n")
end
-- Nuke all button subscriptions
Input_tracker:subscribe(not lock)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(not lock)
end
end