local Data = { }
local Clip_select_doc_handle
local Input_tracker
local Mouse_input_tracker
local Tween_done = true
local Num_clips = 0
local Current_clip = 1
function vint_clip_select_get_num_clips(clips)
Num_clips = clips
end
local Screen_width = 700
function vint_clip_select_get_clip_data(clip_name, clip_info)
local t = {
type = TYPE_BUTTON,
label = clip_name,
tool_tip_text = clip_info
}
Data[Current_clip] = t
Current_clip = Current_clip + 1
end
function vint_clip_select_get_clips(clip_name, clip_description)
Data[#Data+1] = {
type = TYPE_BUTTON,
label = clip_name,
tool_tip_text = clip_description
}
end
function options_clip_select_update_build_list()
Data = {}
vint_dataresponder_request("vint_clip_select_get_clips_responder", "vint_clip_select_get_clips", 0)
-- Remove subscriptions
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:remove_all()
end
-- Initialize and draw list object
List:draw_items(Data, 1, Screen_width - 15, 10)
-- Re-add subscriptions
if Mouse_input_tracker ~= nil then
List:add_mouse_inputs("pause_options_clip_select", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_options_clip_select", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
function pause_options_clip_select_init()
options_clip_select_update_build_list()
Clip_select_doc_handle = vint_document_find("pause_options_clip_select")
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "options_clip_select_button_a", 50)
Input_tracker:add_input("back", "options_clip_select_button_b", 50)
if In_pause_menu then
Input_tracker:add_input("pause", "options_clip_select_button_start", 50)
end
Input_tracker:add_input("nav_up", "options_clip_select_nav_up", 50)
Input_tracker:add_input("nav_down", "options_clip_select_nav_down", 50)
Input_tracker:subscribe(false)
--Set Button hints
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Menu_hint_bar:set_hints(hint_data)
--Initialize Header
Header_obj:set_text("MENU_OPTIONS_CLIP_SELECT")
if First_time then
Screen_in_anim:play(0)
bg_saints_slide_in(Screen_width)
First_time = false
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_slide_out_anim)
Menu_hint_bar:set_highlight(0)
Mouse_input_tracker = Vdo_input_tracker:new()
List:add_mouse_inputs("pause_options_clip_select", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_options_clip_select", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
pause_options_clip_select_set_tool_tip(Data[1].tool_tip_text) --("X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X") -- Use this to figure out the correct anchor for In_pause_menu
end
function pause_options_clip_select_set_tool_tip(new_tip_text)
local tool_tip_h = vint_object_find("tool_tip_text", 0, Clip_select_doc_handle)
vint_set_property(tool_tip_h, "text_tag", new_tip_text)
end
function pause_options_clip_select_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 options_clip_select_nav_up(event, acceleration)
-- Move highlight up
List:move_cursor(-1)
options_clip_select_update_mouse_inputs()
-- Set the tool_tip_text
local current_idx = List:get_selection()
local menu_item = Data[current_idx]
pause_options_clip_select_set_tool_tip(menu_item.tool_tip_text)
end
function options_clip_select_nav_down(event, acceleration)
-- Move highlight down
List:move_cursor(1)
options_clip_select_update_mouse_inputs()
-- Set the tool_tip_text
local current_idx = List:get_selection()
local menu_item = Data[current_idx]
pause_options_clip_select_set_tool_tip(menu_item.tool_tip_text)
end
function options_clip_select_button_b(event, acceleration)
--back up a screen
--game_difficulty_select(Data[DIFFICULTY_INDEX].current_value - 1) -- Difficulties indexed by 0
pause_menu_accept_options()
List:button_b()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
List:enable_toggle_input(false)
--Remove current menu from the stack
menu_common_stack_remove()
menu_common_transition_pop(1)
end
-- Defines for clip options
local OPTION_EDIT = 0
local OPTION_CLONE = 1
local OPTION_DELETE = 2
local OPTION_CANCEL = 3
local DELETE_CANCEL = 0
local DELETE_CONFIRM = 1
function options_clip_select_button_a(event, acceleration)
-- Display the options for editing a clip in a dialog box
local options = {
[OPTION_EDIT] = "PC_CA_EDIT_EXPORT",
[OPTION_CLONE] = "PC_CA_CLONE",
[OPTION_DELETE] = "PC_CA_DELETE",
[OPTION_CANCEL] = "PC_CA_CANCEL",
}
local cur_selection = List:get_selection()
dialog_box_open(Data[cur_selection].label, "PC_CLIP_ACTIONS", options, "options_clip_select_dialog_cb", 0, DIALOG_PRIORITY_ACTION)
end
function options_clip_select_dialog_cb(result, action)
-- TODO: Make these options work (or remove them, particularly CLONE)
if result == OPTION_EDIT then
game_machinima_playback_enter(Data[List:get_selection()].label)
elseif result == OPTION_CLONE then
game_vkeyboard_input("SAVE_CLIP", "SAVE_CLIP_NAME", 64, "SAVE_CLIP", "options_clip_select_copy_cb", true)
elseif result == OPTION_DELETE then
dialog_box_confirmation(Data[List:get_selection()].label, "PC_CLIP_DELETE_CONFIRM", "options_clip_delete_cb", nil, nil, 1)
elseif result == OPTION_CANCEL then
end
end
function options_clip_select_copy_cb(success)
if success == true then
if game_machinima_clip_exists("VKEYBOARD_RESULTS") == true then
dialog_box_confirmation(Data[List:get_selection()].label, "PC_CLIP_OVERWRITE_CONFIRM", "options_clip_overwrite_cb", nil, nil, 1)
else
game_machinima_copy_clip(Data[List:get_selection()].label, "VKEYBOARD_RESULTS")
options_clip_select_update_build_list()
end
end
end
function options_clip_overwrite_cb(result, action)
if result == 0 then
game_machinima_overwrite_clip(Data[List:get_selection()].label, "VKEYBOARD_RESULTS")
options_clip_select_update_build_list()
end
end
function options_clip_delete_cb(result, action)
if result == 0 then
game_machinima_delete_clip(Data[List:get_selection()].label)
options_clip_select_update_build_list()
end
end
function options_clip_select_button_start(event, acceleration)
menu_common_transition_pop(3) -- options_clip_select, pause_menu_top, menu_common
end
-- Mouse inputs
function pause_options_clip_select_mouse_click(event, target_handle, mouse_x, mouse_y)
local hint_index = Menu_hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
options_clip_select_button_b()
end
local new_index = List:get_button_index(target_handle)
if new_index ~= 0 then
options_clip_select_button_a()
end
end
function pause_options_clip_select_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)
-- Set the tool_tip_text
local menu_item = Data[new_index]
pause_options_clip_select_set_tool_tip(menu_item.tool_tip_text)
end
end
function options_clip_select_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines)
if scroll_lines ~= 0 then
if List:get_scroll_region_handle() == target_handle then
List:scroll_list(scroll_lines * -1)
options_clip_select_update_mouse_inputs()
end
end
end
function options_clip_select_mouse_drag(event, target_handle, mouse_x, mouse_y)
if List.scrollbar.tab_grp.handle == target_handle then
local new_start_index = List.scrollbar:drag_scrolltab(mouse_y, List.num_buttons - (List.max_buttons - 1))
List:scroll_list(0, new_start_index)
end
end
-- Updates the mouse inputs for the list and snaps the scrolltab to the closest notch based on the visible index
--
function options_clip_select_mouse_drag_release(event, target_handle, mouse_x, mouse_y)
if List.scrollbar.tab_grp.handle == target_handle then
local start_index = List:get_visible_indices()
List.scrollbar:release_scrolltab(start_index, List.num_buttons - (List.max_buttons - 1))
options_clip_select_update_mouse_inputs()
end
end
function options_clip_select_update_mouse_inputs()
List:update_mouse_inputs("pause_options_clip_select", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("pause_options_clip_select", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end