-- Globals
-- These are from mission_info.h
local MT_MISSION_NONE = -1
local MT_MISSION = 0
local MT_ACTIVITY = 1
local MT_SILENT = 2
local MT_DIVERSION_ACTIVE = 3
local ID_SAVE_GAME = 1
local ID_LOAD_GAME = 2
local ID_OPTIONS = 3
local ID_CO_OP = 4
local ID_QUIT_GAME = 5
local ID_CANCEL_MISSION = 8
--HVS_TBT 7/23/2014
local ID_HELP = 12
--HVS_TBT 7/30/2014
local ID_PAUSE_VOICE_TUT = 13
local Cleanup_from_b = false
local Quit_message_normal = "QUIT_GAME_TEXT_FULL"
local Quit_message
local Data
local Save_button = {
type = TYPE_BUTTON,
label = "SAVELOAD_SAVE_GAME",
id = ID_SAVE_GAME,
}
local Load_button = {
type = TYPE_BUTTON,
label = "SAVELOAD_LOAD_GAME",
id = ID_LOAD_GAME,
}
local Options_button = {
type = TYPE_BUTTON,
label = "PAUSE_MENU_OPTIONS",
id = ID_OPTIONS,
}
local Coop_button = {
type = TYPE_BUTTON,
label = "PAUSE_MENU_COOP",
id = ID_CO_OP,
}
--HVS_TBT 7/23/2014
local Help_button = {
type = TYPE_BUTTON,
label = "PAUSE_MENU_HELP",
id = ID_HELP
}
--HVS_TBT 7/30/2014
local Voice_tut_button = {
type = TYPE_BUTTON,
label = "PAUSE_VOICE_TUT",
id = ID_PAUSE_VOICE_TUT
}
local Quit_button = {
type = TYPE_BUTTON,
label = "HORDE_MODE_MENU_EXIT",
id = ID_QUIT_GAME,
}
local Cancel_button = {
type = TYPE_BUTTON,
id = ID_CANCEL_MISSION,
label = "HUD_CANCEL_MISSION",
}
local Anims = {}
local Input_tracker
local Mouse_input_tracker
local Online_check_thread = -1
local Screen_width
if vint_is_std_res() then
Screen_width = 750
else
Screen_width = 840
end
local Tween_done = true
local Checking_dlc = false
---------------------------------------------------------------------------
-- Initialize Pause Menu Top (First Level of Pause Menu)
---------------------------------------------------------------------------
function pause_menu_top_init()
-- Subscribe to the button presses we need
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "pause_menu_top_button_a", 50)
Input_tracker:add_input("pause", "pause_menu_top_button_b", 50)
Input_tracker:add_input("back", "pause_menu_top_button_b", 50)
Input_tracker:add_input("nav_up", "pause_menu_top_nav_up", 50)
Input_tracker:add_input("nav_down", "pause_menu_top_nav_down", 50)
Input_tracker:add_input("nav_left", "pause_menu_top_nav_left", 50)
Input_tracker:add_input("nav_right", "pause_menu_top_nav_right", 50)
Input_tracker:subscribe(false)
ui_audio_post_event("ui_pause")
--Initialize Header
Header_obj:set_text("SYSTEM_PAUSED", Screen_width) --("MENU_GAME_PAUSED")
-- Clear pause menu and build a new one
Data = {}
if game_machinima_is_recording() == false then
if game_is_prologue_complete(true) == true and vint_game_is_safe_to_save_game() == true then
Data[#Data+1] = Save_button
end
if vint_game_is_safe_to_load_game() == true then
Data[#Data+1] = Load_button
end
end
local gameplay_type = game_get_in_progress_type()
local cancel_button_tag = nil
--HVS_RCK - If you haven't completed the prologue, you can't exit/retry the mission. Specifying true means we include the flight tutorial
if not mission_is_active("mIntro") then
if gameplay_type == MT_MISSION then
cancel_button_tag = "HUD_CANCEL_MISSION"
elseif gameplay_type == MT_ACTIVITY then
cancel_button_tag = "HUD_CANCEL_ACTIVITY"
elseif gameplay_type == MT_DIVERSION_ACTIVE then
cancel_button_tag = "HUD_CANCEL_DIVERSION"
end
end
if cancel_button_tag then
Data[#Data+1] = Cancel_button
Cancel_button.label = cancel_button_tag
if pause_menu_cant_retry_because_host_in_creation() then
Cancel_button.disabled = true
end
end
Data[#Data+1] = Options_button
if game_get_is_host() == false and cancel_button_tag ~= nil then
Load_button.disabled = true
end
-- HVS_JBG - don't allow the client to load during the intro. They should load a character when joining, or can load after the intro is complete.
-- This should be fine because the player's abilities should be fixed during the intro anyway.
-- This addresses Hansoft #11006
if game_get_is_host() == false and mission_is_active("mIntro") then
Load_button.disabled = true
end
if game_machinima_is_recording() == false and game_is_demo() == false then
Data[#Data+1] = Coop_button
end
if game_record_mode_is_supported() then
--Data[#Data+1] = Casual_record_button
--[[if game_machinima_is_recording() == true then
Data[#Data+1] = Playback_button;
else
Data[#Data+1] = Record_button;
end]]
end
if game_get_platform() == "XBOX3" then
Data[#Data+1] = Help_button
end
if (game_get_platform() == "XBOX3" or game_get_platform() == "PS4") and hvs_voice_controls_active() then
Data[#Data+1] = Voice_tut_button
end
Data[#Data+1] = Quit_button
Quit_message = Quit_message_normal
--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)
--[[
--this HACK stinks, we should get the longest string width back and adjust for that
if game_get_language() == "DE" then
Screen_width = 680
end
]]
-- Initialize and draw list object
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, pause_menu_top_anim_in_done)
-- Add mouse input subscriptions 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("pause_menu_top", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_menu_top", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
if First_time then
local bg_anchor = 100
if vint_is_std_res() then
bg_anchor = 74
end
Screen_in_anim:play(0)
bg_saints_slide_in(Screen_width, bg_anchor)
bg_saints_dimmer_show(true) --Dim out the game...
First_time = false
end
vint_set_mouse_cursor("")
end
function pause_menu_top_force_save()
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)
Save_system_operation = SAVE_OPERATION_SAVE_GAME
Close_all_menu = true
menu_common_transition_push("pause_save_game")
Save_message_displayed = true
end
function pause_menu_top_gained_focus()
--Initialize Header
Header_obj:set_text("SYSTEM_PAUSED", Screen_width) --("MENU_GAME_PAUSED")
--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)
-- Remove subscriptions
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:remove_all()
end
-- Initialize and draw list object
List:draw_items(Data, last_option_selected, Screen_width)
-- Re-add subscriptions
if Mouse_input_tracker ~= nil then
List:add_mouse_inputs("pause_menu_top", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_menu_top", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
--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, pause_menu_top_anim_in_done)
end
function pause_menu_top_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 pause_menu_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)
if Cleanup_from_b ~= true then
ui_audio_post_event("ui_unpause")
end
end
function pause_menu_top_anim_in_done()
if Exit_after_closing == true then
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
else
Input_tracker:subscribe(true)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
end
--send them straight to save
if pause_menu_point_of_no_return() then
pause_menu_top_force_save()
end
pause_menu_common_top_finished_loading()
end
function pause_menu_top_nav_up(event, acceleration)
-- Move highlight up
List:move_cursor(-1)
end
function pause_menu_top_nav_down(event, acceleration)
-- Move highlight down
List:move_cursor(1)
end
function pause_menu_top_nav_left(event, acceleration)
-- Move highlight left
List:move_slider(-1)
end
function pause_menu_top_nav_right(event, acceleration)
-- Move highlight right
List:move_slider(1)
end
function pause_menu_save_callback(result, action)
menu_common_transition_push("pause_save_game")
end
function coop_dlc_checked(has_dlc, cancelled)
if has_dlc then
Input_tracker:subscribe(true)
menu_common_transition_push("pause_co_op_menu")
List:button_a()
return
end
if not cancelled then
dialog_box_message("DIALOG_COOP_DLC_TITLE", "DIALOG_COOP_DLC_BODY")
end
Input_tracker:subscribe(true)
end
function pause_menu_top_button_a(event, acceleration)
local package_chunk_movies = 1
if game_get_platform() == "XBOX3" then
package_chunk_movies = 2
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)
--pass off the input to the list
if current_id == ID_SAVE_GAME then
-- check if the game is autosaving
if game_is_autosaving() then
dialog_box_message("MENU_TITLE_NOTICE", "SAVELOAD_CANT_ENTER_AUTOSAVE")
else
Save_system_operation = SAVE_OPERATION_SAVE_GAME
List:button_a()
local progress_type = game_get_in_progress_type()
if Save_message_displayed == false and (progress_type == MT_MISSION or progress_type == MT_SILENT) then
dialog_box_message("MENU_TITLE_WARNING", "SAVELOAD_MISSION_WARNING", nil, nil, "pause_menu_save_callback")
elseif Save_message_displayed == false and (progress_type == MT_ACTIVITY or progress_type == MT_DIVERSION_ACTIVE) then
dialog_box_message("MENU_TITLE_WARNING", "SAVELOAD_ACTIVITY_WARNING", nil, nil, "pause_menu_save_callback")
else
menu_common_transition_push("pause_save_game")
end
Save_message_displayed = true
end
return
elseif current_id == ID_LOAD_GAME then
-- check if the game is autosaving
if game_is_autosaving() then
dialog_box_message("MENU_TITLE_NOTICE", "SAVELOAD_CANT_ENTER_AUTOSAVE")
elseif game_is_waiting_for_partner() then
dialog_box_message("MENU_TITLE_NOTICE", "SAVELOAD_CANT_ENTER_JOINING")
else
Save_system_operation = SAVE_OPERATION_LOAD_GAME
menu_common_transition_push("pause_save_game")
List:button_a()
end
return
elseif current_id == ID_OPTIONS then
menu_common_transition_push("pause_options_menu")
List:button_a()
return
elseif current_id == ID_CO_OP then
if game_get_platform() == "PS3" then
if not game_user_has_online_privilege() then
dialog_box_message( "MENU_TITLE_NOTICE", "PLATFORM_PS3_ONLINE_AGE_RESTRICTED" )
return
end
end
if package_chunk_loaded(package_chunk_movies) == false then
dialog_box_message( "GAME_INSTALL_INCOMPLETE_TITLE", "GAME_INSTALL_INCOMPLETE_LOAD" )
return
end
Input_tracker:subscribe(false)
game_check_coop_dlc("coop_dlc_checked")
return
elseif current_id == ID_CANCEL_MISSION then
game_cancel_mission()
return
elseif current_id == ID_QUIT_GAME then
dialog_box_destructive_confirmation("PAUSE_MENU_QUIT_TITLE", Quit_message,"pause_menu_top_confirm_quit")
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
return
elseif current_id == ID_PAUSE_VOICE_TUT then
pause_menu_show_voice_tut()
elseif current_id == ID_HELP then
hvs_xb1_voice_snap_help()
end
end
end
--HVS_TBT 8/15/2014: use proper transition to push voice tutorial
function pause_menu_show_voice_tut()
menu_common_transition_push("pause_voice_tut")
end
function pause_menu_top_confirm_quit(result, action)
-- if action == 1 then
-- return
-- end
if result == 0 then
-- Dialog box result YES
Input_tracker:subscribe(false)
pause_menu_quit_game_internal()
-- menu_common_transition_pop(2)
-- bg_saints_slide_out()
elseif result == 1 then
-- Dialog box result NO
-- Restore inputs to the pause menu
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
end
end
function record_mode_confirm(result, action)
--[[
if result == 0 then
-- Dialog box result YES
game_machinima_record()
menu_common_transition_pop(2)
elseif result == 1 then
-- Dialog box result NO
-- Restore inputs to the pause menu
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
end
]]
end
function playback_mode_confirm(result, action)
--[[
if result == 0 then
-- Dialog box result YES
game_machinima_playback_enter("machinima")
menu_common_transition_pop(2)
elseif result == 1 then
-- Dialog box result NO
-- Restore inputs to the pause menu
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
end
]]
end
function pause_menu_top_button_b(event, acceleration)
if Tween_done == true then
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
List:button_b()
menu_common_transition_pop(2)
bg_saints_slide_out()
Cleanup_from_b = true
ui_audio_post_event("ui_unpause")
end
end
function pause_menu_top_mouse_click(event, target_handle)
-- First check if the target_handle is in the hint bar
local hint_index = Menu_hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
pause_menu_top_button_b()
end
local new_index = List:get_button_index(target_handle)
if new_index ~= 0 then
-- Enter an option if the target_handle is in the List
List:set_selection(new_index)
pause_menu_top_button_a()
end
end
function pause_menu_top_mouse_move(event, target_handle)
-- Reset highlights
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
-- Set the button as the new selected highlight
List:set_selection(new_index)
List:move_cursor(0, true)
end
end