-- Offset of list and header from other store layouts
local REWARDS_OFFSET = 80
local REWARDS_LIST_WIDTH = 0
-- Hint bar and store header vdo's.
local Hint_bar
local Hint_bar_rotate
local Store_logo
local Store_popup
local Not_popup_grp
Cur_text_adv = 0
local Color_grid
local Color_grid_grp
local Col_title
local Reward_image
local Input_tracker
local Mouse_input_tracker
local Hint_bar_mouse_input_tracker
local Col_main_loading_img = nil
local Col_main_unload_img = nil
local Col_main_category_id = 0
local CATEGORY_AUDIO = 0
local CATEGORY_TEXT = 1
local CATEGORY_TOD = 2
local CATEGORY_XMAS_TEXT = 3
local CATEGORY_XMAS_LETTER = 4
local Col_main_category_name = nil
local Col_main_doc_handle = -1
local Col_main_building_menu = {}
local Col_main_img_update_thread = -1
local COLOR_COL_POPUP = {R = 255/255, G =255/255, B =255/255}
local Audio_images = {
[0] = "ui_reward_homie_asha", --// COLLECTIBLE_TYPE_AUDIO_LOG_ASHA,
[1] = "ui_reward_homie_ben_king", --// COLLECTIBLE_TYPE_AUDIO_LOG_BEN_KING,
[2] = "ui_reward_homie_cyrus", -- // COLLECTIBLE_TYPE_AUDIO_LOG_CYRUS,
[3] = "ui_reward_homie_gat", --// COLLECTIBLE_TYPE_AUDIO_LOG_DJ_VETERAN_CHILD,
[4] = "ui_reward_homie_julius", -- // COLLECTIBLE_TYPE_AUDIO_LOG_JULIUS,
[5] = "ui_reward_homie_kinzie", -- // COLLECTIBLE_TYPE_AUDIO_LOG_KINZIE,
[6] = "ui_reward_homie_maero", -- // COLLECTIBLE_TYPE_AUDIO_LOG_MAERO,
[7] = "ui_reward_homie_matt_miller", -- // COLLECTIBLE_TYPE_AUDIO_LOG_MATT_MILLER,
[8] = "ui_reward_homie_pierce", -- // COLLECTIBLE_TYPE_AUDIO_LOG_PIERCE,
[9] = "ui_reward_homie_shaundi_sr2", -- // COLLECTIBLE_TYPE_AUDIO_LOG_SHAUNDI_SR2,
[10] = "ui_reward_homie_shaundi", -- // COLLECTIBLE_TYPE_AUDIO_LOG_SHAUNDI_SR3,
[11] = "ui_reward_homie_tanya", -- // COLLECTIBLE_TYPE_AUDIO_LOG_TANYA,
[12] = "ui_reward_homie_keith_david", -- // COLLECTIBLE_TYPE_AUDIO_LOG_VICE_PRESIDENT,
}
local Text_images = {
[0] = "ui_col_txt_adv_title",
[1] = "ui_col_xmas_txt_adv_title", --xmas text
[2] = "ui_col_xmas_letter_title", --letters to santa
}
---------------------------------------------------------------------------
-- Initialize Rewards Store
---------------------------------------------------------------------------
function col_main_init()
pause_map_dump()
Col_main_doc_handle = vint_document_find("col_main")
-- Set up some callbacks for the common store script
Store_common_populate_list_cb = col_main_populate_list
Store_common_exit_cb = col_main_exit
-- Subscribe to the button presses we need
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("nav_up", "col_main_nav_up", 50)
Input_tracker:add_input("nav_down", "col_main_nav_down", 50)
Input_tracker:add_input("back", "col_main_button_b", 50)
Input_tracker:add_input("select", "col_main_button_a", 50)
vint_set_glitch_percent( 0 )
--Set Title
Col_title = Vdo_cell_title:new("col_title", 0, Col_main_doc_handle)
Col_title:set_text("COL_MAIN_TITLE")
Col_title:set_icon("ui_cell_icon_tomes")
Col_title:play_dots_anim()
--Setup Button Hints
Hint_bar = Vdo_hint_bar:new("hint_bar", 0, Col_main_doc_handle)
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
{CTRL_MENU_BUTTON_A, "MENU_TITLE_CONFIRM"}
}
Hint_bar:set_hints(hint_data)
Hint_bar:set_visible(true)
Active_list = Vdo_mega_list:new("tomes_list", 0, Col_main_doc_handle, "col_main.lua", "Active_list")
Active_list:set_highlight_color(COLOR_CHEATS_PRIMARY, COLOR_CHEATS_SECONDARY)
-- HVS_JPM hack this list into the correct position
--Active_list:set_property("anchor", 186, 275)
Store_logo = Vdo_base_object:new("store_logo_img", 0, Store_common_doc_handle)
Store_logo:set_visible(false)
--Popup
Store_popup = Vdo_store_popup:new("store_popup", 0, Store_common_doc_handle)
Store_popup:set_visible(false)
Store_popup:set_color(COLOR_COL_POPUP, COLOR_STORE_REWARDS_SECONDARY, COLOR_STORE_REWARDS_TERTIARY)
Store_popup:set_size(STORE_COMMON_LIST_SIZE, (LIST_BUTTON_HEIGHT * 5) + (LIST_BUTTON_SPACE * 5))
-- Everything that is not in the popup so we can fade it when the popup is active
Not_popup_grp = Vdo_base_object:new("not_popup_grp", 0, Store_common_doc_handle)
Color_grid_grp = Vdo_base_object:new("color_grid_grp", 0, Store_common_doc_handle)
Color_grid_grp:set_visible(false)
-- Needs to be done after the list is drawn/populated
--Active_list:set_highlight_color(1, 1)
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_COLLECTIBLES, CELL_SCREEN_MAIN, col_main_unlock_controls)
local screen_grp = Vdo_base_object:new("screen_grp", 0, Col_main_doc_handle)
screen_grp:set_visible(true)
-- Pass the table data to the megalist vdo.
--vint_dataresponder_request("col_main_category_dr", "col_main_add_category", 0)
--col_main_add_category("COL_CAT_AUDIO", nil, nil, false)
-- HVS_JPM we only have the Audio Tomes
--[[
col_main_add_category("COL_CAT_TEXT", nil, nil, false)
if game_unlockable_is_unlocked( "ship_tod" ) and game_get_is_coop_client() == false then
col_main_add_category("COL_CAT_TOD", nil, nil, false)
end
if game_is_dlc_available("DLC2") then
col_main_add_category("COL_CAT_XMAS_TEXT", nil, nil, false)
col_main_add_category("COL_CAT_XMAS_LETTER", nil, nil, false)
end
--]]
col_main_populate_audio_tomes()
col_main_populate_list(Menu_data, 1)
-- Add this on_enter callback so the category menu gets refreshed when returning from a submenu
--Menu_data.on_enter = col_main_category_menu_update
-- For the rewards store, we don't want the bg to render behind the player, so change this property.
-- Perhaps these can be organized so it's easier to do this.
--local grp1_h = vint_object_find("lets_pretend_bg_grp", 0, Store_common_doc_handle)
--vint_set_property(grp1_h, "background", false)
--vint_set_property(grp1_h, "visible", false)
-- Animate phone in
--local col_main_anim_in_h = vint_object_find("col_main_anim_in", 0, Store_common_doc_handle)
--lua_play_anim(col_main_anim_in_h, 0, Store_common_doc_handle)
-- Tint store green
--local store_common_grp_h = vint_object_find("cell_rotate_grp", 0, Store_common_doc_handle)
--vint_set_property(store_common_grp_h, "saturation", 0)
--vint_set_property(store_common_grp_h, "tint", COLOR_COL_CELL_ROTATE.R, COLOR_COL_CELL_ROTATE.G, COLOR_COL_CELL_ROTATE.B)
-- Initialize reward image...
Reward_image = Vdo_bitmap_viewer:new("reward_image", 0, Col_main_doc_handle)
-- Hide description
Reward_image:set_description(" ", nil)
Reward_image:set_visible(false)
-- Mouse input
if game_get_platform() == "PC" then
Hint_bar:set_highlight(0)
Mouse_input_tracker = Vdo_input_tracker:new()
Active_list:add_mouse_inputs("col_main", Mouse_input_tracker)
Mouse_input_tracker:subscribe(false)
Hint_bar_mouse_input_tracker = Vdo_input_tracker:new()
Hint_bar:add_mouse_inputs("col_main", Hint_bar_mouse_input_tracker)
Hint_bar_mouse_input_tracker:subscribe(true)
end
--TODO: Transition the screen in...
--local pulse_anim_h = vint_object_find("pulse_anim", 0, Col_main_doc_handle)
--lua_play_anim(pulse_anim_h)
col_main_unlock_controls()
col_main_on_enter_draw_tome_img()
end
-- Cleanup
function col_main_cleanup()
-- Nuke all button subscriptions
Input_tracker:subscribe(false)
col_main_enable_mouse(false)
local current_image = Reward_image:get_image()
if current_image ~= nil then
game_peg_unload(current_image)
end
if Col_main_unload_img ~= nil then
game_peg_unload(Col_main_unload_img)
end
if Col_main_loading_img ~= nil then
game_peg_unload(Col_main_loading_img)
end
vint_scriptevent_post("audio_log_play", -1, -1)
pause_map_restore()
end
-------------------------------------------------------------------------------
-- Controls Unlock
--
function col_main_unlock_controls()
Input_tracker:subscribe(true)
col_main_enable_mouse(true)
end
-------------------------------------------------------------------------------
-- Controls Lock
--
function col_main_lock_controls()
Input_tracker:subscribe(false)
col_main_enable_mouse(false)
end
-- Populate the active megalist menu, and hide the previous menu
--
-- list_data: this table contains the data to populate the megalist
-- current_index: the current index in the menu that's selected
--
function col_main_populate_list(list_data, current_index)
Active_list:draw_items(list_data, current_index, STORE_COMMON_LIST_SIZE, 9, .8, false, false)
Active_list:set_visible(true)
col_main_mouse_update()
--[[
if game_get_platform() == "PC" then
Mouse_input_tracker:remove_all()
Active_list:set_store("col_main")
Active_list:add_mouse_inputs("store_common", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
--]]
end
-- Called in a thread to delay the image updating.
-- This is done for 2 reasons: to slow down rapid scrolling updates done too quickly,
-- and because the streaming system didn't always co-operate with the images being released
-- from the callback context that was executed when another stream load completed.
--
function col_main_image_update()
delay(0.2)
game_peg_unload(Col_main_unload_img)
game_peg_load_with_cb("col_main_show_image", 1, Col_main_loading_img)
Col_main_img_update_thread = -1
end
function col_main_tome_image_update()
delay(0.2)
game_peg_unload(Col_main_unload_img)
game_peg_load_with_cb("col_main_show_tome_image", 1, Col_main_loading_img)
Col_main_img_update_thread = -1
end
-- Callback for when an image is done loading.
-- SEH: It might make sense to roll this into vdo_bitmap_viewer...
--
function col_main_show_image()
local index = Active_list:get_selection()
local new_image
if Col_main_category_id == CATEGORY_AUDIO then
local homie = Menu_data[index].homie
new_image = Audio_images[homie]
elseif Col_main_category_id == CATEGORY_TEXT then
local id = Menu_data[index].id
new_image = Text_images[0]
elseif Col_main_category_id == CATEGORY_XMAS_TEXT then
local id = Menu_data[index].id
new_image = Text_images[1]
elseif Col_main_category_id == CATEGORY_XMAS_LETTER then
local id = Menu_data[index].id
new_image = Text_images[2]
end
local img_scale_x = 1
local img_scale_y = 1
if Col_main_loading_img == new_image then
Reward_image:set_image(new_image, Menu_data[index].is_locked, Menu_data[index].is_purchased, Menu_data[index].level, Menu_data[index].level_required, img_scale_x, img_scale_y)
Reward_image:set_description(nil, Menu_data[index].description)
Reward_image:set_visible(true)
Col_main_loading_img = nil
else
-- a new image was picked while we were loading - load this now, and unload the one we just loaded
if new_image ~= nil then
Col_main_unload_img = Col_main_loading_img
Col_main_loading_img = new_image
Col_main_img_update_thread = thread_new("col_main_image_update")
else
game_peg_unload(Col_main_loading_img)
Col_main_loading_img = nil
end
end
end
function col_main_show_tome_image()
local index = Active_list:get_selection()
local new_image
new_image = "ui_col_tome"
local img_scale_x = 1
local img_scale_y = 1
if Col_main_loading_img == new_image then
Reward_image:set_image(new_image, Menu_data[index].is_locked, Menu_data[index].is_purchased, Menu_data[index].level, Menu_data[index].level_required, img_scale_x, img_scale_y)
Reward_image:set_description(nil, Menu_data[index].description)
Reward_image:set_visible(not Menu_data[index].is_locked)
Col_main_loading_img = nil
else
-- a new image was picked while we were loading - load this now, and unload the one we just loaded
if new_image ~= nil then
Col_main_unload_img = Col_main_loading_img
Col_main_loading_img = new_image
Col_main_img_update_thread = thread_new("col_main_tome_image_update")
else
game_peg_unload(Col_main_loading_img)
Col_main_loading_img = nil
end
end
end
-- Update reward image based on which reward is highlighted
--
-- index of the reward in the table
--
function col_main_item_nav(menu_data)
Reward_image:set_visible(false)
if Col_main_loading_img == nil then
local new_image
if Col_main_category_id == CATEGORY_AUDIO then
local homie = menu_data.homie
new_image = Audio_images[homie]
elseif Col_main_category_id == CATEGORY_TEXT then
local id = menu_data.id
new_image = Text_images[0]
elseif Col_main_category_id == CATEGORY_XMAS_TEXT then
local id = menu_data.id
new_image = Text_images[1]
elseif Col_main_category_id == CATEGORY_XMAS_LETTER then
local id = menu_data.id
new_image = Text_images[2]
end
local current_image = Reward_image:get_image()
if current_image ~= nil then
game_peg_unload(current_image)
end
if new_image ~= nil then
-- must set Col_main_loading_img before calling game_peg_load_with_cb(), which could fire the callback right away
Col_main_loading_img = new_image
game_peg_load_with_cb("col_main_show_image", 1, new_image)
end
end
-- if this unlockable was marked as "new", then clear the flag since the player highlighted it
if menu_data.is_new then
vint_dataresponder_post("col_main_reward_dr", "Clear_new", menu_data.id)
--Get index from the list and then remove the flag...
local index = Active_list:get_index_from_id(menu_data.id)
if index ~= -1 then
Active_list:remove_new_flag(index)
end
--Update cursor,
Active_list:move_cursor(0)
--Re add mouse inputs...
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:remove_all()
Active_list:add_mouse_inputs("store_common", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
end
function col_main_tome_item_nav(menu_data)
Reward_image:set_visible(false)
if Col_main_loading_img == nil then
local new_image
new_image = "ui_col_tome"
local current_image = Reward_image:get_image()
if current_image ~= nil then
game_peg_unload(current_image)
end
if new_image ~= nil then
-- must set Col_main_loading_img before calling game_peg_load_with_cb(), which could fire the callback right away
Col_main_loading_img = new_image
game_peg_load_with_cb("col_main_show_tome_image", 1, new_image)
end
end
if menu_data.is_locked then
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Hint_bar:set_hints(hint_data)
else
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
{CTRL_MENU_BUTTON_A, "MENU_AUDIO_PLAY_TOME"}
}
Hint_bar:set_hints(hint_data)
end
if game_get_platform() == "PC" then
Hint_bar:set_highlight(0)
Hint_bar_mouse_input_tracker:remove_all()
Hint_bar_mouse_input_tracker = Vdo_input_tracker:new()
Hint_bar:add_mouse_inputs("col_main", Hint_bar_mouse_input_tracker)
Hint_bar_mouse_input_tracker:subscribe(true)
end
-- if this unlockable was marked as "new", then clear the flag since the player highlighted it
if menu_data.is_new then
vint_dataresponder_post("col_main_reward_dr", "Clear_new", menu_data.id)
--Get index from the list and then remove the flag...
local index = Active_list:get_index_from_id(menu_data.id)
if index ~= -1 then
Active_list:remove_new_flag(index)
end
--Update cursor,
Active_list:move_cursor(0)
--Re add mouse inputs...
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:remove_all()
Active_list:add_mouse_inputs("store_common", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
end
-- Update category image based on which category is highlighted
--
-- index of the category in the table
--
function col_main_category_nav(menu_data)
--Col_main_category_id = menu_data.id
Col_main_category_id = menu_data.cat_id
Col_main_category_name = menu_data.label
Reward_image:set_visible(false)
end
function col_main_purchase_select(menu_data)
if menu_data.is_locked == true or menu_data.is_purchased == true then
return
end
-- give reward and take money here
local current_index = Active_list:get_selection()
if Col_main_category_id == CATEGORY_AUDIO then
local homie = menu_data.homie
local index = menu_data.id
vint_scriptevent_post("audio_log_play", -1, -1)
vint_scriptevent_post("audio_log_play", homie, index)
elseif Col_main_category_id == CATEGORY_TEXT then
Cur_text_adv = current_index
push_screen("col_text_adventure")
Input_tracker:subscribe(false)
col_main_enable_mouse(false)
elseif Col_main_category_id == CATEGORY_TOD then
vint_scriptevent_post("player_set_tod", menu_data.id)
ui_audio_post_event("ui_tod_toggle")
store_common_button_b()
elseif Col_main_category_id == CATEGORY_XMAS_TEXT then
Cur_text_adv = current_index + 10 --Text Adv 11-18
push_screen("col_text_adventure")
Input_tracker:subscribe(false)
elseif Col_main_category_id == CATEGORY_XMAS_LETTER then
if menu_data.id == 9 then
Cur_text_adv = menu_data.id + 1 + 20 --Special case for the last letter
else
Cur_text_adv = current_index + 20 --Letters 21-29
end
push_screen("col_text_adventure")
Input_tracker:subscribe(false)
end
-- Save off index before we refresh the list
Menu_data.start_index = current_index
end
function col_main_tome_select(menu_data)
if menu_data.is_locked == true then
return
end
local current_index = Active_list:get_selection()
local homie = menu_data.homie
local index = menu_data.id
vint_scriptevent_post("audio_log_play", -1, -1)
vint_scriptevent_post("audio_log_play", homie, index)
-- Save off index before we refresh the list
Menu_data.start_index = current_index
end
function col_main_popup_nav(event, value)
if event == "nav_up" then
Store_popup.list:move_cursor(-1)
elseif event == "nav_down" then
Store_popup.list:move_cursor(1)
elseif event == "mouse_move" then
-- value contains the target_handle in this case
local new_index = Store_popup.list:get_button_index(value)
if new_index ~= 0 then
Store_popup.list:set_selection(new_index)
Store_popup.list:move_cursor(0, true)
end
else
--do nothing
end
end
function col_main_fail_msg(event)
Store_popup:nav_enable(false, nil, nil)
Not_popup_grp:set_alpha(1)
Active_list:set_visible(true)
col_main_enable_mouse(true)
end
function col_main_add_category(name, image_name, is_new, disabled)
local menu_idx = #Menu_data + 1
local cat_id
if name == "COL_CAT_AUDIO" then
cat_id = CATEGORY_AUDIO
elseif name == "COL_CAT_TEXT" then
cat_id = CATEGORY_TEXT
elseif name == "COL_CAT_TOD" then
cat_id = CATEGORY_TOD
elseif name == "COL_CAT_XMAS_TEXT" then
cat_id = CATEGORY_XMAS_TEXT
elseif name == "COL_CAT_XMAS_LETTER" then
cat_id = CATEGORY_XMAS_LETTER
end
local new_item = {
type = TYPE_BUTTON,
id = menu_idx - 1,
cat_id = cat_id,
label = name,
label_crc = nil,
image = image_name,
on_nav = col_main_category_nav,
on_sub_menu_fill = col_main_populate_rewards,
is_new = is_new,
disabled = disabled,
}
Menu_data[menu_idx] = new_item
end
-- This is called after the sub menu is generated for a selected category, and we now need to update
-- the image and description for the first award available. Must be called in on_enter(), because
-- the script asssumes Menu_data has already been set to the new sub menu we entered.
--
function col_main_on_enter_draw_image()
col_main_item_nav(Menu_data[1])
end
function col_main_on_enter_draw_tome_img()
col_main_tome_item_nav(Menu_data[1])
end
function col_main_populate_rewards(menu_data)
Col_main_building_menu = menu_data.sub_menu
local category
if Col_main_category_id == CATEGORY_AUDIO then
category = "audio_logs"
elseif Col_main_category_id == CATEGORY_TEXT then
category = "text_adventures"
elseif Col_main_category_id == CATEGORY_TOD then
category = "tod"
elseif Col_main_category_id == CATEGORY_XMAS_TEXT then
category = "xmas_text_adventures"
elseif Col_main_category_id == CATEGORY_XMAS_LETTER then
category = "xmas_letters"
end
vint_dataresponder_request("collections_main_dr", "col_main_add_reward", 0, category)
if #Col_main_building_menu > 0 then
if Col_main_category_id == CATEGORY_AUDIO then
Col_title:set_text("COL_CAT_AUDIO")
elseif Col_main_category_id == CATEGORY_TEXT then
Col_title:set_text("COL_CAT_TEXT")
elseif Col_main_category_id == CATEGORY_TOD then
Col_title:set_text("COL_CAT_TOD")
elseif Col_main_category_id == CATEGORY_XMAS_TEXT then
Col_title:set_text("COL_CAT_XMAS_TEXT")
elseif Col_main_category_id == CATEGORY_XMAS_LETTER then
Col_title:set_text("COL_CAT_XMAS_LETTER")
end
else
Store_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1)
Store_popup:set_title("MENU_TITLE_NOTICE")
Store_popup:set_text("COL_MAIN_NONE")
Store_popup:nav_enable(true, "col_main_fail_msg", "col_main_popup_nav")
Not_popup_grp:set_alpha(.5)
Active_list:set_visible(false)
end
Col_main_building_menu.on_enter = col_main_on_enter_draw_image
end
-- HVS_JPM new function used to only populate this menu with audio tomes
function col_main_populate_audio_tomes()
local category = "audio_logs"
vint_dataresponder_request("collections_main_dr", "col_main_add_audio_tome", 0, category)
Menu_data.on_enter = col_main_on_enter_draw_tome_img
end
function col_main_add_audio_tome(collected, id, name, desc_crc)
local menu_idx = #Menu_data + 1
local new_item = {
type = TYPE_BUTTON,
homie = 0,
id = id,
label = name,
label_crc = nil,
image = nil,
description = desc_crc,
is_locked = not collected,
is_purchased = collected,
level_required = 1,
-- Display of level and max_level disabled for now
level = nil,
max_level = nil,
on_nav = nil,--col_main_tome_item_nav,
on_select = nil, --col_main_tome_select,
on_back = nil,
--trumps = trumps, -- CRC for the name of the prerequisite
--is_new = is_new,
}
Menu_data[menu_idx] = new_item
end
function col_main_add_reward(homie, id, name, desc_crc)
local menu_idx = #Col_main_building_menu + 1
local new_item = {
type = TYPE_BUTTON,
homie = homie,
id = id,
label = name,
label_crc = nil,
image = nil,
description = desc_crc,
is_locked = false,
is_purchased = false,
level_required = 1,
-- Display of level and max_level disabled for now
level = nil,
max_level = nil,
on_nav = col_main_item_nav,
on_select = col_main_purchase_select,
on_back = col_main_revert_header,
--trumps = trumps, -- CRC for the name of the prerequisite
--is_new = is_new,
}
Col_main_building_menu[menu_idx] = new_item
end
function col_main_revert_header(menu_data)
-- kill update thread
if Col_main_img_update_thread ~= -1 then
thread_kill(Col_main_img_update_thread)
Col_main_img_update_thread = -1
end
Col_title:set_text("COL_MAIN_TITLE")
-- Hide description
Reward_image:set_description(" ", nil)
Reward_image:set_visible(false)
local current_image = Reward_image:get_image()
if current_image ~= nil then
game_peg_unload(current_image)
end
if Col_main_unload_img ~= nil then
game_peg_unload(Col_main_unload_img)
end
if Col_main_loading_img ~= nil then
game_peg_unload(Col_main_loading_img)
Col_main_loading_img = nil
end
end
function col_main_exit(event)
-- exit the interface
col_main_lock_controls()
-- Animate reward screen out
local anim_out_h = vint_object_find("col_main_anim_out", 0, Store_common_doc_handle)
lua_play_anim(anim_out_h)
pop_screen()
end
--HVS_TBT 6/27/2014 added missing *_unload() func
function col_main_unload()
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_COLLECTIBLES, nil)
end
-- After the completion screen from a purchase, refresh the list of rewards.
function col_main_gained_focus()
local index = Active_list:get_selection()
Menu_data = {}
Col_main_building_menu = Menu_data
local category
if Col_main_category_id == CATEGORY_AUDIO then
Col_title:set_text("COL_CAT_AUDIO")
category = "audio_logs"
elseif Col_main_category_id == CATEGORY_TEXT then
Col_title:set_text("COL_CAT_TEXT")
category = "text_adventures"
elseif Col_main_category_id == CATEGORY_TOD then
Col_title:set_text("COL_CAT_TOD")
category = "tod"
elseif Col_main_category_id == CATEGORY_XMAS_TEXT then
Col_title:set_text("COL_CAT_XMAS_TEXT")
category = "xmas_text_adventures"
elseif Col_main_category_id == CATEGORY_XMAS_LETTER then
Col_title:set_text("COL_CAT_XMAS_LETTER")
category = "xmas_letters"
end
vint_dataresponder_request("collections_main_dr", "col_main_add_reward", 0, category)
-- May need to update image and description if list was shifted
col_main_item_nav(Col_main_building_menu[index])
col_main_populate_list(Menu_data, index)
if game_get_platform() == "PC" then
Hint_bar:set_highlight(0)
Hint_bar_mouse_input_tracker:remove_all()
Hint_bar_mouse_input_tracker = Vdo_input_tracker:new()
Hint_bar:add_mouse_inputs("col_main", Hint_bar_mouse_input_tracker)
Hint_bar_mouse_input_tracker:subscribe(true)
end
Input_tracker:subscribe(true)
end
-- When returning to the category menu from submenu, this gets called to repopulate the data,
-- since we need to determine which categories still have new rewards.
--
function col_main_category_menu_update(menu_data)
local index = Active_list:get_selection()
Menu_data = {}
Col_main_building_menu = Menu_data
--vint_dataresponder_request("col_main_category_dr", "col_main_add_category", 0)
col_main_add_category("COL_CAT_AUDIO", nil, nil, false)
-- HVS_JPM, we only want the first category
--[[
col_main_add_category("COL_CAT_TEXT", nil, nil, false)
if game_unlockable_is_unlocked( "ship_tod" ) and game_get_is_coop_client() == false then
col_main_add_category("COL_CAT_TOD", nil, nil, false)
end
if game_is_dlc_available("DLC2") then
col_main_add_category("COL_CAT_XMAS_TEXT", nil, nil, false)
col_main_add_category("COL_CAT_XMAS_LETTER", nil, nil, false)
end
--]]
Menu_data = Col_main_building_menu
Menu_data.on_enter = col_main_category_menu_update
col_main_populate_list(Menu_data, index)
end
function col_main_nav_up(event, acceleration)
Active_list:move_cursor(-1)
local data_item = Active_list:return_selected_data()
col_main_tome_item_nav(data_item)
end
function col_main_nav_down(event, acceleration)
Active_list:move_cursor(1)
local data_item = Active_list:return_selected_data()
col_main_tome_item_nav(data_item)
end
function col_main_button_a()
local current_index = Active_list:get_selection()
local data_item = Active_list:return_selected_data()
if data_item.is_locked == true then
return
end
local homie = data_item.homie
local index = data_item.id
vint_scriptevent_post("audio_log_play", -1, -1)
vint_scriptevent_post("audio_log_play", homie, index)
end
function col_main_button_b()
col_main_lock_controls()
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_COLLECTIBLES, col_main_exit_to_extras)
end
function col_main_exit_to_extras()
pop_screen()
end
-- =====================================
-- Mouse Specific Functions
-- =====================================
function col_main_mouse_update()
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:remove_all()
Active_list:add_mouse_inputs("col_main", Mouse_input_tracker)
Hint_bar:add_mouse_inputs("col_main", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
function col_main_enable_mouse(enable)
if game_get_platform() == "PC" and enable ~= nil then
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:subscribe(enable)
end
if Hint_bar_mouse_input_tracker ~= nil then
Hint_bar_mouse_input_tracker:subscribe(enable)
end
end
end
-- Mouse inputs
function col_main_mouse_click(event, target_handle, mouse_x, mouse_y)
local hint_index = Hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
col_main_button_b()
elseif hint_index == 2 then
col_main_button_a()
end
local new_index = Active_list:get_button_index(target_handle)
if new_index ~= 0 then
Active_list:set_selection(new_index)
col_main_button_a()
end
end
function col_main_mouse_move(event, target_handle)
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 old_index = Active_list:get_selection()
local new_index = Active_list:get_button_index(target_handle)
if new_index ~= 0 and new_index ~= old_index then
Active_list:set_selection(new_index)
Active_list:move_cursor(0, true)
-- If the item has a callback for navigation, do it
local data_item = Active_list:return_selected_data()
col_main_tome_item_nav(data_item)
end
end
function col_main_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines)
if Active_list:list_is_playing() == false then
if scroll_lines ~= 0 then
if Active_list:get_scroll_region_handle() == target_handle then
Active_list:scroll_list(scroll_lines * -1)
Active_list:update_mouse_inputs("col_main", Mouse_input_tracker)
end
end
end
end
function col_main_mouse_drag(event, target_handle, mouse_x, mouse_y)
if Active_list:list_is_playing() == false then
if Active_list.scrollbar.tab_grp.handle == target_handle then
local new_start_index = Active_list.scrollbar:drag_scrolltab(mouse_y, Active_list.num_buttons - (Active_list.max_buttons - 1))
Active_list:scroll_list(0, new_start_index)
end
end
end
function col_main_mouse_drag_release(event, target_handle, mouse_x, mouse_y)
if Active_list:list_is_playing() == false then
if Active_list.scrollbar.tab_grp.handle == target_handle then
local start_index = Active_list:get_visible_indices()
Active_list.scrollbar:release_scrolltab(start_index, Active_list.num_buttons - (Active_list.max_buttons - 1))
col_main_mouse_update()
end
end
end