local EASY_INDEX = 1
local MEDIUM_INDEX = 2
local HARD_INDEX = 3
local ID_EASY = 1
local ID_MEDIUM = 2
local ID_HARD = 3
local Data = {
[EASY_INDEX] = {
type = TYPE_BUTTON,
label = "DLT_CASUAL",
id = ID_EASY,
},
[MEDIUM_INDEX] = {
type = TYPE_BUTTON,
label = "DLT_NORMAL",
id = ID_MEDIUM,
},
[HARD_INDEX] = {
type = TYPE_BUTTON,
label = "DLT_HARDCORE",
id = ID_HARD,
},
}
local Main_menu_new_game_doc_handle = -1
local Screen_width
if vint_is_std_res() then
Screen_width = 750
else
Screen_width = 840
end
local Input_tracker
local Mouse_input_tracker
local Tween_done = true
local Device_selected = false
local Slide_out = true
---------------------------------------------------------------------------
-- Initialize Pause Options Menu.
---------------------------------------------------------------------------
function main_menu_new_game_init()
Main_menu_new_game_doc_handle = vint_document_find("main_menu_new_game")
-- Subscribe to the button presses we need
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "main_menu_new_game_button_a", 50)
Input_tracker:add_input("back", "main_menu_new_game_button_b", 50)
Input_tracker:add_input("nav_up", "main_menu_new_game_nav", 50)
Input_tracker:add_input("nav_down", "main_menu_new_game_nav", 50)
Input_tracker:add_input("nav_left", "main_menu_new_game_nav", 50)
Input_tracker:add_input("nav_right", "main_menu_new_game_nav", 50)
Input_tracker:subscribe(false)
--Initialize Header
Header_obj:set_text("MAINMENU_NEW_GAME_DIFF_HDR", Screen_width)
--Setup Button Hints
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Menu_hint_bar:set_hints(hint_data)
List:draw_items(Data, get_current_difficulty() + 1, Screen_width)
menu_common_set_list_style(List, Header_obj, Screen_width)
local text_anim_in_h
if First_time then
text_anim_in_h = vint_object_find("text_slide_in_anim",0,Main_menu_new_game_doc_handle)
Screen_in_anim:play(0)
bg_saints_slide_in(Screen_width)
First_time = false
menu_common_set_screen_data(List, Header_obj, nil, Screen_back_out_anim, Screen_out_anim)
else
text_anim_in_h = vint_object_find("text_back_in_anim",0,Main_menu_new_game_doc_handle)
Slide_out = false
menu_common_set_screen_data(List, Header_obj, nil, Screen_back_out_anim, Screen_slide_out_anim)
end
lua_play_anim(text_anim_in_h,0,Main_menu_new_game_doc_handle)
main_menu_new_game_set_description()
-- 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_new_game", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("main_menu_new_game", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
--menu_common_set_mouse_tracker(Mouse_input_tracker)
end
end
function main_menu_new_game_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_new_game_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
main_menu_new_game_set_description()
end
end
function main_menu_new_game_set_description()
local id = List:get_id()
local text_h = vint_object_find("difficulty_text",0,Main_menu_new_game_doc_handle)
if id == ID_EASY then
vint_set_property(text_h, "text_tag", "DLT_DESC_CASUAL")
elseif id == ID_MEDIUM then
vint_set_property(text_h, "text_tag", "DLT_DESC_NORMAL")
elseif id == ID_HARD then
vint_set_property(text_h, "text_tag", "DLT_DESC_HARDCORE")
end
end
function main_menu_new_game_block_input()
Input_tracker:subscribe(false)
if game_get_platform() == "PC" then
Mouse_input_tracker:subscribe(false)
end
end
function main_menu_new_game_button_a(event, acceleration)
if Tween_done == true and Device_selected == true then
--Set the screen data to the list data
Data = List:return_data()
local current_id = List:get_id()
game_UI_audio_play("UI_Main_Menu_Select")
--Do something with the difficulty selection...
game_difficulty_select(current_id - 1) -- Difficulties indexed by 0
local has_seen_cal_screen = pause_menu_has_seen_display_cal_screen()
if has_seen_cal_screen then
Start_game_after_display = false
main_menu_new_game()
else
Start_game_after_display = true
push_screen("pause_options_display_cal")
end
end
end
function main_menu_new_game_button_b(event, acceleration)
if Tween_done == true and Device_selected == true then
--pass off the input to the list
List:button_b()
Input_tracker:subscribe(false)
if game_get_platform() == "PC" then
Mouse_input_tracker:subscribe(false)
end
--Remove current menu from the stack
menu_common_stack_remove()
--Pop Screen off the list
menu_common_transition_pop(1)
local text_anim_out_h
if not First_time then
if Slide_out then
text_anim_out_h = vint_object_find("text_slide_out_anim",0,Main_menu_new_game_doc_handle)
bg_saints_slide_out()
else
text_anim_out_h = vint_object_find("text_back_out_anim",0,Main_menu_new_game_doc_handle)
end
lua_play_anim(text_anim_out_h,0,Main_menu_new_game_doc_handle)
end
end
end
function main_menu_new_game_mouse_click(event, target_handle)
local hint_index = Menu_hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
main_menu_new_game_button_b()
end
local new_index = List:get_button_index(target_handle)
if new_index ~= 0 then
List:set_selection(new_index)
main_menu_new_game_button_a()
end
end
function main_menu_new_game_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)
main_menu_new_game_set_description()
end
end
function device_selected()
Device_selected = true
Input_tracker:subscribe(true)
if game_get_platform() == "PC" then
Mouse_input_tracker:subscribe(true)
end
end