local ID_TYPE_REWARDS_INVALID = -1
local ID_TYPE_REWARDS_RECEIVED = 1
local ID_TYPE_REWARDS_UNLOCKED = 2
local ID_REWARDS_RECEIVED = 3
local ID_REWARDS_UNLOCKED = 4
Rewards_list_doc_h = 0
local Rewards_list = {}
Rewards_list.row_alignment = {ALIGN_LEFT, ALIGN_RIGHT}
Rewards_list.row_column_count = 2
local Input_tracker
local Mouse_input_tracker
local List_offset = 25
local SL_LIST_MAX_BUTTONS = 7
local Spinner_obj = 0
local Screen_width
if vint_is_std_res() then
Screen_width = 750
else
Screen_width = 840
end
function main_sl_rewards_list_init()
Rewards_list_doc_h = vint_document_find("main_sl_rewards_list")
-- Subscribe to the button presses we need
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "main_sl_rewards_list_button_a", 50)
Input_tracker:add_input("back", "main_sl_rewards_list_button_b", 50)
Input_tracker:add_input("nav_up", "main_sl_rewards_list_nav_up", 50)
Input_tracker:add_input("nav_down", "main_sl_rewards_list_nav_down", 50)
Input_tracker:subscribe(false)
-- Jeff - column titles are slightly different for rewards unlocked / received.
--Initialize Spinner
Spinner_obj = Vdo_spinner:new("spinner")
local columns_grp_h = vint_object_find("columns_grp")
vint_set_property(columns_grp_h, "visible", false)
--Initialize Header
Header_obj:show_me(false)
local column_01_h = vint_object_find("column_01", 0, Rewards_list_doc_h)
local column_02_h = vint_object_find("column_02", 0, Rewards_list_doc_h)
if Silverlink_rewards_type == ID_TYPE_REWARDS_RECEIVED then
Header_mini_obj:set_text("SL_TITLE_REWARDS_RECEIVED")
vint_set_property(column_01_h, "text_tag", "SL_REWARD_REWARD")
vint_set_property(column_02_h, "text_tag", "SL_REWARD_UNLOCKED_FROM")
else
Header_mini_obj:set_text("SL_TITLE_REWARDS_UNLOCKED")
vint_set_property(column_01_h, "text_tag", "SL_REWARD_ACHIEVMENT")
vint_set_property(column_02_h, "text_tag", "SL_REWARD_UNLOCKED_IN")
end
Header_mini_obj:set_visible(true)
--set up the list in twns
local list_back_in = Vdo_tween_object:new("back_in_twn2", Screen_back_in_anim.handle)
local x, y = list_back_in:get_property("start_value")
local y_offset = y + List_offset
list_back_in:set_property("start_value", x, y_offset)
list_back_in:set_property("end_value", x, y_offset)
local list_back_out = Vdo_tween_object:new("back_out_twn3", Screen_back_out_anim.handle)
list_back_out:set_property("start_value", x, y_offset)
list_back_out:set_property("end_value", x, y_offset)
--set up the list out twns
local list_slide_out = Vdo_tween_object:new("screen_slide_out_twn2", Screen_slide_out_anim.handle)
list_slide_out:set_property("start_value", x, y_offset)
list_slide_out:set_property("end_value", x, y_offset)
local list_slide_in = Vdo_tween_object:new("screen_slide_in_twn2", Screen_slide_in_anim.handle)
list_slide_in:set_property("start_value", x, y_offset)
list_slide_in:set_property("end_value", x, y_offset)
--Setup Button Hints
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Menu_hint_bar:set_hints(hint_data)
--Store some locals to the pause menu common for screen processing.
menu_common_set_list_style(List, Header_obj, Screen_width)
bg_saints_show(true)
menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_slide_out_anim)
--Hide the list...
List:set_visible(false)
local info_text_h = vint_object_find("info_text", 0, Rewards_list_doc_h)
vint_set_property(info_text_h, "visible", false)
--TODO: Show spinner until silverlink_rweards_data_avail() is called from C++
vint_dataresponder_request("silverlink_rewards_populate", "main_sl_rewards_list_unlocked_populate", 0, Silverlink_rewards_type)
--Some stuff i'm not sure what it does yet (JMH- 4/30/2013)
if First_time then
Screen_in_anim:play(0)
bg_saints_slide_in(Screen_width)
First_time = false
end
-- 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_sl_rewards_list", Mouse_input_tracker)
Menu_hint_bar:add_mouse_inputs("main_sl_rewards_list", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
--fade screen in
local screen_in_anim_h = vint_object_find("screen_in")
lua_play_anim(screen_in_anim_h)
--Disable event listener for button updates...
vdo_mega_list_enable_listener(false)
end
function main_sl_rewards_list_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)
Header_obj:show_me(true)
Header_mini_obj:set_visible(false)
local x, y = List:get_anchor()
--set up the list in twns
local list_back_in = Vdo_tween_object:new("back_in_twn2", Screen_back_in_anim.handle)
local x, y = list_back_in:get_property("start_value")
local y_offset = y - List_offset
list_back_in:set_property("start_value", x, y_offset)
list_back_in:set_property("end_value", x, y_offset)
local list_back_out = Vdo_tween_object:new("back_out_twn3", Screen_back_out_anim.handle)
list_back_out:set_property("start_value", x, y_offset)
list_back_out:set_property("end_value", x, y_offset)
--set up the list out twns
local list_slide_out = Vdo_tween_object:new("screen_slide_out_twn2", Screen_slide_out_anim.handle)
list_slide_out:set_property("start_value", x, y_offset)
list_slide_out:set_property("end_value", x, y_offset)
local list_slide_in = Vdo_tween_object:new("screen_slide_in_twn2", Screen_slide_in_anim.handle)
list_slide_in:set_property("start_value", x, y_offset)
list_slide_in:set_property("end_value", x, y_offset)
--Restore event listening
vdo_mega_list_enable_listener(true)
end
function main_sl_rewards_list_nav_up(event, acceleration)
-- Move highlight up
List:move_cursor(-1)
--Make sure our button is gone...
List:highlight_set_button("")
end
function main_sl_rewards_list_nav_down(event, acceleration)
-- Move highlight down
List:move_cursor(1)
--Make sure our button is gone...
List:highlight_set_button("")
end
function main_sl_rewards_list_button_a(event, acceleration)
--DOES NOTHING
end
function main_sl_rewards_list_button_b(event, acceleration)
List:button_b()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
--fade screen out
local screen_out_anim_h = vint_object_find("screen_out", 0, Rewards_list_doc_h)
lua_play_anim(screen_out_anim_h, 0, Rewards_list_doc_h)
-- final pop...
--Remove current menu from the stack
menu_common_stack_remove()
--Pop Screen off the list
menu_common_transition_pop(1)
end
function main_sl_rewards_list_mouse_click(event, target_handle)
local hint_index = Menu_hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
main_sl_rewards_list_button_b()
end
--[[
local new_index = List:get_button_index(target_handle)
if new_index ~= 0 then
List:set_selection(new_index)
main_sl_rewards_list_button_a()
List:highlight_set_button("")
end
]]
end
function main_sl_rewards_list_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)
List:highlight_set_button("")
end
end
-------------------------------------------------------------------------------
-- Populate function for the rewards unlocked screen
-- @acheivment_name Name of Acheivment
-- @unlocked_in Game that award is unlocked in...
--
function main_sl_rewards_list_unlocked_populate(acheivment_name, unlocked_in)
local num_items = #Rewards_list + 1
Rewards_list[num_items] = {
type = TYPE_ROW,
--Info for displaying the Vdo_pause_row
label_1 = acheivment_name,
label_2 = unlocked_in
}
end
-- Calls form C
-- data_error - whether there was an error retrieving data
-- num_results - number of results (may be 0) to expect if no error
function silverlink_rewards_data_avail(success, num_results)
local error_message_string = ""
local info_text_h = vint_object_find("info_text", 0, Rewards_list_doc_h)
vint_set_property(info_text_h, "visible", false)
if success == true then
--Empty rewards list and retreive data because the data are here...
Rewards_list = {}
if num_results == 0 then
--No results...
if Silverlink_rewards_type == ID_TYPE_REWARDS_RECEIVED then
error_message_string = "SL_REWARDS_NONE_RECEIVED"
else
error_message_string = "SL_REWARDS_NONE_UNLOCKED"
end
else
--Set row columns for list...
Rewards_list.row_alignment = {ALIGN_LEFT, ALIGN_RIGHT}
Rewards_list.row_column_count = 2
--get data...
vint_dataresponder_request("silverlink_rewards_populate", "main_sl_rewards_list_unlocked_populate", 0, Silverlink_rewards_type + 2)
end
else
--problem retreiving data...
error_message_string = "SL_REWARDS_PROBLEM_RETREIVING_DATA"
end
--Hide Spinner
Spinner_obj:set_visible(false)
if error_message_string == "" then
--No errors...
--Refresh and show the list...
List:draw_items(Rewards_list, 1, Screen_width, SL_LIST_MAX_BUTTONS)
List:highlight_set_button("")
List:set_visible(true)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:remove_all()
Menu_hint_bar:add_mouse_inputs("main_sl_rewards_list", Mouse_input_tracker)
List:add_mouse_inputs("main_sl_rewards_list", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
--Show Columns or not...
local columns_grp_h = vint_object_find("columns_grp")
vint_set_property(columns_grp_h, "visible", true)
else
--error show error message...
vint_set_property(info_text_h, "text_tag", error_message_string)
vint_set_property(info_text_h, "visible", true)
--Hide the columns
local columns_grp_h = vint_object_find("columns_grp")
vint_set_property(columns_grp_h, "visible", false)
end
end