local XBOX_LIVE_INDEX = 1
local SYSTEM_LINK_INDEX = 2
local COOP_OPTIONS_INDEX = 3
local WHORED_SINGLE_INDEX = 1
local ID_XBOX_LIVE = 1
local ID_SYSTEM_LINK = 2
local ID_WHORED_SINGLE = 3
local ID_COOP_OPTIONS = 4
local Xbox_live_button = {
type = TYPE_BUTTON,
label = "MAINMENU_ONLINE_GAME",
id = ID_XBOX_LIVE,
}
local System_link_button = {
type = TYPE_BUTTON,
label = "MULTI_GAMETYPE_1",
id = ID_SYSTEM_LINK,
}
local Whored_single_button = {
type = TYPE_BUTTON,
label = "MAINMENU_SINGLEPLAYER",
id = ID_WHORED_SINGLE,
}
local Coop_options_button = {
type = TYPE_BUTTON,
label = "COOP_OPTIONS",
id = ID_COOP_OPTIONS,
}
local Data = { }
local Input_tracker
local Mouse_input_tracker
local Screen_width = 495
local Tween_done = true
local Online_check_thread = -1
---------------------------------------------------------------------------
-- Initialize Pause Options Menu.
---------------------------------------------------------------------------
function main_menu_coop_top_init()
-- Subscribe to the button presses we need
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "main_menu_coop_top_button_a", 50)
Input_tracker:add_input("back", "main_menu_coop_top_button_b", 50)
Input_tracker:add_input("nav_up", "main_menu_coop_top_nav", 50)
Input_tracker:add_input("nav_down", "main_menu_coop_top_nav", 50)
Input_tracker:add_input("nav_left", "main_menu_coop_top_nav", 50)
Input_tracker:add_input("nav_right", "main_menu_coop_top_nav", 50)
Input_tracker:subscribe(false)
main_menu_coop_top_set_menu()
--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()
if Whored_mode_active then
Screen_width = 700
end
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, Input_tracker, Screen_back_out_anim, Screen_out_anim)
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_coop_top", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("main_menu_coop_top", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
--menu_common_set_mouse_tracker(Mouse_input_tracker)
end
end
function main_menu_coop_top_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
List:enable_toggle_input(false)
end
function main_menu_coop_top_set_menu()
local header_str
Data = { }
--Get Platform specific data...
if Whored_mode_active == true then
XBOX_LIVE_INDEX = WHORED_SINGLE_INDEX + 1
SYSTEM_LINK_INDEX = WHORED_SINGLE_INDEX + 2
COOP_OPTIONS_INDEX = WHORED_SINGLE_INDEX + 3
Data[WHORED_SINGLE_INDEX] = Whored_single_button
header_str = "MAINMENU_WHORED"
else
header_str = "MAINMENU_COOP"
end
Data[XBOX_LIVE_INDEX] = Xbox_live_button
Data[SYSTEM_LINK_INDEX] = System_link_button
Data[COOP_OPTIONS_INDEX] = Coop_options_button
--Initialize Header
Header_obj:set_text(header_str, Screen_width)
end
function main_menu_coop_top_nav(event, acceleration)
if Tween_done == true then
if event == "nav_up" then
-- Move highlight up
List:move_cursor(-1)
elseif event == "nav_down" then
-- Move highlight down
List:move_cursor(1)
elseif event == "nav_left" then
-- Move highlight left
List:move_slider(-1)
elseif event == "nav_right" then
-- Move highlight right
List:move_slider(1)
end
end
end
function mm_coop_top_check_live()
main_menu_supress_profile_change(true)
online_and_privilege_validator_begin(true, true, true, true, false)
while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do
thread_yield()
end
main_menu_supress_profile_change(false)
List:highlight_show(true)
if Online_validator_result ~= ONLINE_VALIDATOR_PASSED then
Input_tracker:subscribe(true)
return
end
if Whored_mode_active then
game_check_coop_dlc("main_menu_coop_top_dlc_check_live")
else
main_menu_coop_top_dlc_check_live(true, false)
end
Online_check_thread = -1
end
function mm_coop_top_check_lan()
main_menu_supress_profile_change(true)
online_and_privilege_validator_begin(true, false, false, false, false)
while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do
thread_yield()
end
main_menu_supress_profile_change(false)
List:highlight_show(true)
if Online_validator_result ~= ONLINE_VALIDATOR_PASSED then
Input_tracker:subscribe(true)
return
end
if Whored_mode_active then
game_check_coop_dlc("main_menu_coop_top_dlc_check_lan")
else
main_menu_coop_top_dlc_check_lan(true, false)
end
Online_check_thread = -1
end
function mm_coop_top_redeem_check()
main_menu_supress_profile_change(true)
online_and_privilege_validator_begin(true, true, true, false, false)
while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do
thread_yield()
end
main_menu_supress_profile_change(false)
List:highlight_show(true)
if Online_validator_result ~= ONLINE_VALIDATOR_PASSED then
Input_tracker:subscribe(true)
return
end
main_menu_redeem_code()
Input_tracker:subscribe(true)
Online_check_thread = -1
end
function mm_coop_top_dlc_cb(result, action)
if game_get_platform() == "PC" then
if result == 0 then
Enter_dlc_menu = true
main_menu_coop_top_button_b()
end
else
if result == 0 then
Input_tracker:subscribe(false)
Online_check_thread = thread_new("mm_coop_top_redeem_check")
elseif result == 1 then
Enter_dlc_menu = true
main_menu_coop_top_button_b()
end
end
end
function main_menu_coop_top_dlc_dialog()
local options
if game_get_platform() == "PC" then
options = { [0] = "GO_DLC_STORE", [1] = "CONTROL_CANCEL" }
else
options = { [0] = "REDEEM_CODE", [1] = "GO_DLC_STORE", [2] = "CONTROL_CANCEL" }
end
dialog_box_open("DIALOG_COOP_DLC_TITLE", "DLC_COOP_DLC_MAIN_BODY", options, "mm_coop_top_dlc_cb",
0, DIALOG_PRIORITY_ACTION, false, nil, false, false)
end
function main_menu_coop_top_dlc_check_live(has_dlc, cancelled)
Input_tracker:subscribe(true)
if has_dlc then
main_menu_check_open_nat()
Main_menu_coop_is_xbox_live = true
main_menu_set_coop_menu_type(true)
menu_common_stack_add(List:get_selection())
menu_common_transition_push("main_menu_coop")
elseif not cancelled then
main_menu_coop_top_dlc_dialog()
end
end
function main_menu_coop_top_dlc_check_lan(has_dlc, cancelled)
if has_dlc then
Main_menu_coop_is_xbox_live = false
main_menu_set_coop_menu_type(false)
menu_common_stack_add(List:get_selection())
menu_common_transition_push("main_menu_coop")
elseif not cancelled then
main_menu_coop_top_dlc_dialog()
end
Input_tracker:subscribe(true)
end
function main_menu_coop_top_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()
if current_id == ID_XBOX_LIVE then
if Whored_mode_active then
Input_tracker:subscribe(false)
Online_check_thread = thread_new("mm_coop_top_check_live")
else
Online_check_thread = thread_new("mm_coop_top_check_live")
end
return
elseif current_id == ID_SYSTEM_LINK then
if game_is_connected_to_network() == false then
dialog_box_message("MENU_TITLE_WARNING", "NO_NETWORK_CONNECTION")
return
end
Online_check_thread = thread_new("mm_coop_top_check_lan")
return
elseif current_id == ID_WHORED_SINGLE then
game_UI_audio_play("UI_Main_Menu_Select")
-- Nuke all button subscriptions
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
main_menu_horde_start()
return
elseif current_id == ID_COOP_OPTIONS then
--Add current selection to the stack to store the selected position on the menu
menu_common_stack_add(List:get_selection())
menu_common_transition_push("pause_co_op_menu")
return -- Make sure we don't try to push the coop menu
end
--Add current selection to the stack to store the selected position on the menu
menu_common_stack_add(List:get_selection())
menu_common_transition_push("main_menu_coop")
end
end
function main_menu_coop_top_button_b(event, acceleration)
if Tween_done == true then
--pass off the input to the list
List:button_b()
--Remove current menu from the stack
menu_common_stack_remove()
--Pop Screen off the list
menu_common_transition_pop(1)
First_time = true
bg_saints_slide_out()
end
end
function main_menu_coop_top_mouse_click(event, target_handle)
local hint_index = Menu_hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
main_menu_coop_top_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_top_button_a()
end
end
function main_menu_coop_top_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