-- Global variables
local Active_list
local Cinema_clip_manager_doc_handle = -1
local Input_tracker
local Mouse_input_tracker
local Hint_bar
-- Fake enumerations for clips
local CLIP1 = 1
local CLIP2 = 2
local CLIP3 = 3
local CLIP4 = 4
-- Fake data for clips, to be replaced by data from the game (eventually)
local Data = {
[CLIP1] = {
type = TYPE_BUTTON,
label = "CLIP_1",
id = CLIP1,
clip_date = "!!11/15/11",
location = "!!STEELPORT ACADEMY",
edited = false,
exported = false,
clip_image = "ui_pc_arrow",
},
[CLIP2] = {
type = TYPE_BUTTON,
label = "CLIP_2",
id = CLIP2,
clip_date = "!!11/14/11",
location = "!!NEW BARANEC",
edited = true,
exported = false,
clip_image = "ui_homie_gat",
},
[CLIP3] = {
type = TYPE_BUTTON,
label = "CLIP_3",
id = CLIP3,
clip_date = "!!11/13/11",
location = "!!PHILIPS TOWER",
edited = true,
exported = true,
clip_image = "ui_homie_pierce",
},
[CLIP4] = {
type = TYPE_BUTTON,
label = "CLIP_4",
id = CLIP4,
clip_date = "!!11/13/11",
location = "!!HARRISBURG",
edited = false,
exported = true,
clip_image = "ui_homie_shaundi",
},
}
function cinema_clip_manager_init()
Cinema_clip_manager_doc_handle = vint_document_find("cinema_clip_manager")
-- Init the visual elements
Active_list = Vdo_mega_list:new("active_list", 0, Cinema_clip_manager_doc_handle)
Active_list:set_highlight_color(COLOR_SAINTS_PURPLE)
Hint_bar = Vdo_hint_bar:new("hint_bar", 0, Cinema_clip_manager_doc_handle)
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Hint_bar:set_hints(hint_data)
Hint_bar:set_highlight(0) -- Mouse-specific
cinema_clip_manager_populate_list(Data)
cinema_clip_manager_clip_info_update()
-- Keyboard/gamepad controls
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "cinema_clip_manager_nav_a", 50)
Input_tracker:add_input("back", "cinema_clip_manager_nav_b", 50)
Input_tracker:add_input("nav_up", "cinema_clip_manager_nav_up", 50)
Input_tracker:add_input("nav_down", "cinema_clip_manager_nav_down", 50)
--Input_tracker:add_input("nav_left", "cinema_clip_manager_nav_left", 50)
--Input_tracker:add_input("nav_right", "cinema_clip_manager_nav_right", 50)
Input_tracker:subscribe(true)
-- Mouse controls
if game_get_platform() == "PC" then
Mouse_input_tracker = Vdo_input_tracker:new()
Active_list:add_mouse_inputs("cinema_clip_manager", Mouse_input_tracker)
Hint_bar:add_mouse_inputs("cinema_clip_manager", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
function cinema_clip_manager_cleanup()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function cinema_clip_manager_populate_list(data)
Active_list:draw_items(data, 1, 660)
end
-- Defines for clip options
local OPTION_EDIT = 0
local OPTION_CLONE = 1
local OPTION_DELETE = 2
local OPTION_CANCEL = 3
function cinema_clip_manager_nav_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 = Active_list:get_selection()
dialog_box_open("PC_CLIP_ACTIONS", Data[cur_selection].label, options, "cinema_clip_manager_cb", 0, DIALOG_PRIORITY_ACTION)
-- TODO: Remove this if dialog box takes focus from Mouse_input_tracker like it does for Input_tracker
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
end
function cinema_clip_manager_cb(result, action)
if result == OPTION_EDIT then
-- TODO: Remove this if dialog box takes focus from Mouse_input_tracker like it does for Input_tracker
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
elseif result == OPTION_CLONE then
-- TODO: Remove this if dialog box takes focus from Mouse_input_tracker like it does for Input_tracker
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
elseif result == OPTION_DELETE then
-- TODO: Remove this if dialog box takes focus from Mouse_input_tracker like it does for Input_tracker
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
elseif result == OPTION_CANCEL then
-- TODO: Remove this if dialog box takes focus from Mouse_input_tracker like it does for Input_tracker
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
end
end
function cinema_clip_manager_nav_b(event, acceleration)
-- Close the screen
pop_screen()
end
function cinema_clip_manager_nav_up(event, acceleration)
-- Move highlight up
Active_list:move_cursor(-1)
cinema_clip_manager_clip_info_update()
end
function cinema_clip_manager_nav_down(event, acceleration)
-- Move highlight down
Active_list:move_cursor(1)
cinema_clip_manager_clip_info_update()
end
function cinema_clip_manager_nav_left(event, acceleration)
-- Move highlight left
Active_list:move_slider(-1)
end
function cinema_clip_manager_nav_right(event, acceleration)
-- Move highlight right
Active_list:move_slider(1)
end
-- Mouse events (auto-generated by add_mouse_inputs)
function cinema_clip_manager_mouse_click(event, target_handle)
-- First check if the target_handle is in the hint bar
local hint_index = Hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
cinema_clip_manager_nav_b()
end
local new_index = Active_list:get_button_index(target_handle)
if new_index ~= 0 then
-- Enter an option if the target_handle is in the Active_list
Active_list:set_selection(new_index)
cinema_clip_manager_nav_a()
end
end
function cinema_clip_manager_mouse_move(event, target_handle)
-- Reset highlight for hint bar
Hint_bar:set_highlight(0)
local hint_index = Hint_bar:get_hint_index(target_handle)
if hint_index ~= 0 then
Hint_bar:set_highlight(hint_index)
end
local new_index = Active_list:get_button_index(target_handle)
if new_index ~= 0 then
-- Set the button as the new selected highlight
Active_list:set_selection(new_index)
Active_list:move_cursor(0, true)
end
end
function cinema_clip_manager_clip_info_update()
local cur_selection = Active_list:get_selection()
-- Get the vint handles for the objects needed
local date_txt_h = vint_object_find("date_txt", 0, Cinema_clip_manager_doc_handle)
local location_txt_h = vint_object_find("location_txt", 0, Cinema_clip_manager_doc_handle)
local edited_txt_h = vint_object_find("edited_txt", 0, Cinema_clip_manager_doc_handle)
local exported_txt_h = vint_object_find("exported_txt", 0, Cinema_clip_manager_doc_handle)
local clip_image_h = vint_object_find("clip_img", 0, Cinema_clip_manager_doc_handle)
-- Set the date and location
vint_set_property(date_txt_h, "text_tag", Data[cur_selection].clip_date)
vint_set_property(location_txt_h, "text_tag", Data[cur_selection].location)
-- Set the edited and exported text
if Data[cur_selection].edited then
vint_set_property(edited_txt_h, "text_tag", "OPTION_YES")
else
vint_set_property(edited_txt_h, "text_tag", "OPTION_NO")
end
if Data[cur_selection].exported then
vint_set_property(exported_txt_h, "text_tag", "OPTION_YES")
else
vint_set_property(exported_txt_h, "text_tag", "OPTION_NO")
end
-- Set the image (Re-enable this once we're saving/loading the data)
-- Make sure it scales correctly too (if it's blank by default, etc)
-- vint_set_property(clip_image, "image", Data[cur_selection].clip_image)
end