local NEW_GAME_INDEX = 1
local LOAD_GAME_INDEX = 2
local ID_NEW_GAME = 1
local ID_LOAD_GAME = 2
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 Data
local Anims = {}
local Input_tracker
local Mouse_input_tracker
local Tween_done = true
local Screen_width
if vint_is_std_res() then
Screen_width = 750
else
Screen_width = 840
end
---------------------------------------------------------------------------
-- Initialize Pause Options Menu.
---------------------------------------------------------------------------
function main_menu_campaign_init()
-- Subscribe to the button presses we need
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "main_menu_campaign_button_a", 50)
Input_tracker:add_input("back", "main_menu_campaign_button_b", 50)
Input_tracker:add_input("nav_up", "main_menu_campaign_nav_up", 50)
Input_tracker:add_input("nav_down", "main_menu_campaign_nav_down", 50)
Input_tracker:add_input("nav_left", "main_menu_campaign_nav_left", 50)
Input_tracker:add_input("nav_right", "main_menu_campaign_nav_right", 50)
Input_tracker:subscribe(false)
local header_str = "MAINMENU_CAMPAIGN"
Data = { }
Data[NEW_GAME_INDEX] = New_game_button
if game_is_demo() == false then
Data[LOAD_GAME_INDEX] = Load_game_button
end
--Initialize Header
Header_obj:set_text(header_str, Screen_width)
--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()
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(495)
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_campaign", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("main_menu_campaign", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
--menu_common_set_mouse_tracker(Mouse_input_tracker)
end
end
function main_menu_campaign_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_campaign_nav_up(event, acceleration)
-- Move highlight up
List:move_cursor(-1)
end
function main_menu_campaign_nav_down(event, acceleration)
-- Move highlight down
List:move_cursor(1)
end
function main_menu_campaign_nav_left(event, acceleration)
-- Move highlight left
List:move_slider(-1)
end
function main_menu_campaign_nav_right(event, acceleration)
-- Move highlight right
List:move_slider(1)
end
function main_menu_campaign_button_a(event, acceleration)
-- HVS_ARF - HS# 10810 See explanation in multi_core_platform.h
-- PS3 is in a different menu then the other platforms when this error can happen
local platform = game_get_platform()
if platform == "PS3" then
if save_system_has_accepted_game_invite() then
return
end
end
if Tween_done == true then
--Set the screen data to the list data
Data = List:return_data()
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)
if current_id == ID_NEW_GAME then
menu_common_transition_push("main_menu_new_game")
return
elseif current_id == ID_LOAD_GAME then
menu_common_transition_push("pause_save_game")
return
end
end
end
function main_menu_campaign_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)
bg_saints_slide_out()
end
end
function main_menu_campaign_mouse_click(event, target_handle)
local hint_index = Menu_hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
main_menu_campaign_button_b()
end
local new_index = List:get_button_index(target_handle)
if new_index ~= 0 then
List:set_selection(new_index)
main_menu_campaign_button_a()
end
end
function main_menu_campaign_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