--Lists
Mission_list = -1
Objective_list = -1
--Doc handle
local Cell_missions_doc_h = -1
local just_swapped = false
--Input trackers
local Input_tracker_left = -1
local Input_tracker_right = -1
local Active_input = -1
local Hint_bar_mouse_input_tracker = -1
local Mouse_input_tracker = -1
--Challenges and complete quests index in quests list
local Challenges_index = -1
local Completed_quests_index = -1
local Quests_index = -1
--Which platform are we?
local Game_platform = false
--Used to load challenges images
local Cell_missions_peg_load_thread_h = -1
local Challenge_tutorial_pending_clear = false
--List indices
local Curr_mission_index = -1
local Curr_objective_index = -1
--Used for quest info
local Hint_bar = -1
local Arrow_img_h = -1
local Arrow_x = -1
local Arrow_y = -1
local Challenges_grp_h = -1
local Challenges_overview_grp_h = -1
local Summary_grp_h = -1
--HVS_RCK - Current left-side quest
local Current_left_quest = -1
--Screen title
local Cell_missions_title_h = -1
--Flags for switch to challenges and completed quests states
local Challenges_is_active = true
local Completed_quests_is_active = false
local In_mission = false
local Objective_is_valid = true
--Data tables
local Objective_data = {}
local Challenges_data = {}
local Completed_quests_data = {}
local Crit_path_quest_data = {}
local Full_challenge_list = {}
Mission_data = {}
--Temp data tables
local Cell_missions_completed_objective_temp = {}
local Cell_missions_uncompleted_objective_temp = {}
local Cell_missions_rewards_temp = {}
local Cell_missions_challenges_temp = {
{ -- Activities
category = {},
label_name = "CHALLENGE_HEADER_ACTIVITY"
},
{ -- Diversions
category = {},
label_name = "CHALLENGE_HEADER_DIVERSIONS"
},
{ -- Arcane Powers
category = {},
label_name = "CHALLENGE_HEADER_ARCANE"
},
{ -- Weapons
category = {},
label_name = "CHALLENGE_HEADER_WEAPONS"
},
{ -- Enemies
category = {},
label_name = "CHALLENGE_HEADER_ENEMIES"
},
{ -- Misc
category = {},
label_name = "CHALLENGE_HEADER_MISC"
},
}
--Constants
local MISSION_LIST_WIDTH = 400
local OBJECTIVE_LIST_WIDTH = 465
local OBJECT_LIST_MAX_BUTTONS = 7
local OBJECT_LIST_MAX_BUTTONS_COMPLETED = 10
local MISSION_LIST_MAX_BUTTONS = 13
local INPUT_LEFT = 0
local INPUT_RIGHT = 1
local LIST_ALPHA_ACTIVE = 1
local LIST_ALPHA_INACTIVE = .5
local ARROW_OFFSET = 37.5
local REWARD_TYPE_ACHIEVEMENT = 0
local REWARD_TYPE_UNLOCKABLE = 1
local OBJECTIVE_TYPE_MISSION = 0
local OBJECTIVE_TYPE_ACTIVITY = 1
local OBJECTIVE_TYPE_RIFT = 2
local OBJECTIVE_TYPE_COLLECTIBLE = 3
local GAMEPLAY_TYPE_MISSION = 0
-- These are from mission_info.h
local MT_MISSION_NONE = -1
local MT_MISSION = 0
local MT_ACTIVITY = 1
local MT_SILENT = 2
local MT_DIVERSION_ACTIVE = 3
-- challenge overview junk
local Cell_mission_chal_ov_total = 0
local Cell_mission_chal_ov_completed = 0
local Cell_mission_chal_ov_milestone_goal = 0
local Cell_mission_chal_ov_progress = 0
local Cell_mission_chal_ov_cash_reward = 0
local Cell_mission_chal_ov_respect_reward = 0
local Cell_mission_chal_ov_unlockable_reward = 0
--Hints data
local Mission_list_hints_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
{CTRL_MENU_BUTTON_A, "MENU_SELECT"},
}
local Clear_objective_hints_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
{CTRL_MENU_BUTTON_A, "MENU_SELECT"},
{CTRL_BUTTON_X, "MENU_CLEAR_OBJECTIVE"},
}
local Objective_list_hints_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
{CTRL_MENU_BUTTON_A, "MENU_START_OBJECTIVE"},
{CTRL_BUTTON_X, "MENU_CLEAR_OBJECTIVE"},
}
local Challenges_hints_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
{CTRL_MENU_BUTTON_A, "MENU_SELECT"},
{CTRL_BUTTON_X, "MENU_CLEAR_OBJECTIVE"},
}
local Completed_quests_hints_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
local In_mission_hints_data = {
{CTRL_MENU_BUTTON_A, "MENU_SELECT"},
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
{CTRL_BUTTON_X, "HUD_CANCEL_MISSION"},
}
--In a quest, but no mission is active (hotspots, flashpoints, survival)
local No_mission_hints_data = {
{CTRL_MENU_BUTTON_A, "MENU_SELECT"},
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
--Data example
--[[ [1] = {
id = "m01",
label = "THE POWER OF LOVE",
type = TYPE_BUTTON,
summary = 3515151786,
contact_img = "ui_homie_35_donnie",
icon_name = "ui_homie_35_donnie",
contact_name = "DONNIE",
reward_cache = 2000,
reward_power = 1000,
units_type = "ORBS",
units_collected = 20,
units_total = 100,
objective_data = {
[1] = {
label = "OBJECTIVES",
type = TYPE_HEADER,
},
[2] = {
label = "HACK LET'S PRETEND",
type = TYPE_BUTTON,
},
[3] = {
label = "INSURANCE FRAUD",
type = TYPE_BUTTON,
},
[4] = {
label = "",
type = TYPE_LINE_BREAK,
},
[5] = {
label = "COMPLETED",
type = TYPE_HEADER,
},
[6] = {
label = "HELI ASSAULT",
type = TYPE_BUTTON,
completed = true,
},
},
},
[2] = {
id = "m02",
label = "BOATS 'N HOES",
type = TYPE_BUTTON,
summary = 3515151786,
contact_img = "ui_homie_35_julius",
contact_name = "JULIUS",
reward_cache = 2500,
reward_power = 1500,
objective_data = {
[1] = {
label = "OBJECTIVES",
type = TYPE_HEADER,
},
[2] = {
label = "BLAZIN",
type = TYPE_BUTTON,
},
[3] = {
label = "",
type = TYPE_LINE_BREAK,
},
[4] = {
label = "REWARDS",
type = TYPE_HEADER,
},
[5] = {
label = "WRAITH",
type = TYPE_BUTTON,
},
},
},
} ]]
function cell_missions_init()
vint_force_lua_gc() --Force Garbage Collection
pause_map_dump()
Cell_missions_doc_h = vint_document_find("cell_missions")
Mission_list = Vdo_mega_list:new("mission_list", 0, Cell_missions_doc_h, "cell_missions.lua", "Mission_list")
Objective_list = Vdo_mega_list:new("objective_list", 0, Cell_missions_doc_h, "cell_missions.lua", "Objective_list")
Input_tracker_left = Vdo_input_tracker:new()
Input_tracker_left:add_input("map", "cell_missions_exit_to_game", 50)
Input_tracker_left:add_input("select", "cell_missions_nav_a", 50)
Input_tracker_left:add_input("back", "cell_missions_nav_b", 50)
Input_tracker_left:add_input("alt_select", "cell_missions_nav_x", 50)
Input_tracker_left:add_input("nav_up", "cell_missions_nav_list", 50)
Input_tracker_left:add_input("nav_down", "cell_missions_nav_list", 50)
Input_tracker_left:add_input("nav_left", "cell_missions_nav_left", 50)
Input_tracker_left:add_input("nav_right", "cell_missions_nav_right", 50)
if game_get_platform() == "PC" then
Input_tracker_left:add_input("alt_joy_up", "cell_missions_scroll_left", 50)
Input_tracker_left:add_input("alt_joy_down", "cell_missions_scroll_left", 50)
end
Input_tracker_left:add_input("all_unassigned", "cell_missions_nav_do_nothing", 50)
Input_tracker_left:subscribe(false)
Input_tracker_right = Vdo_input_tracker:new()
Input_tracker_right:add_input("map", "cell_missions_exit_to_game", 50)
Input_tracker_right:add_input("select", "cell_missions_nav_a", 50)
Input_tracker_right:add_input("back", "cell_missions_nav_b", 50)
Input_tracker_right:add_input("alt_select", "cell_missions_nav_x", 50)
Input_tracker_right:add_input("nav_up", "cell_missions_nav_list", 50)
Input_tracker_right:add_input("nav_down", "cell_missions_nav_list", 50)
Input_tracker_right:add_input("nav_left", "cell_missions_nav_left", 50)
Input_tracker_right:add_input("nav_right", "cell_missions_nav_right", 50)
Input_tracker_right:add_input("all_unassigned", "cell_missions_nav_do_nothing", 50)
Input_tracker_right:subscribe(false)
Mouse_input_tracker = Vdo_input_tracker:new()
Hint_bar_mouse_input_tracker = Vdo_input_tracker:new()
Hint_bar = Vdo_hint_bar:new("cell_hint_bar", 0, Cell_missions_doc_h)
Game_platform = game_get_platform()
--Setup hints for PC
if Game_platform == "PC" then
Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000)
Hint_bar_mouse_input_tracker:subscribe(true)
end
--Set up title
Cell_missions_title_h = Vdo_cell_title:new("cell_title", 0, Cell_missions_doc_h)
Cell_missions_title_h:set_text("MENU_MISSIONS")
Cell_missions_title_h:set_icon("ui_cell_icon_missions")
Cell_missions_title_h:play_dots_anim()
--Set left as active input intially
--Controls unlocked after sceen animates in
Active_input = INPUT_LEFT
--Hide the screen until peg is loaded
local screen_grp_h = vint_object_find("screen_grp", 0, Cell_missions_doc_h)
vint_set_property(screen_grp_h, "alpha", 0)
--Setup initial alpha and color of lists
Mission_list:set_alpha(LIST_ALPHA_ACTIVE)
Objective_list:set_alpha(LIST_ALPHA_INACTIVE)
Mission_list:set_highlight_color(COLOR_SAINTS_PURPLE)
Objective_list:set_highlight_color(COLOR_LIST_LOST_FOCUS)
--Store off arrow position and color arrow
Arrow_img_h = vint_object_find("arrow_img", 0, Cell_missions_doc_h)
Arrow_x, Arrow_y = vint_get_property(Arrow_img_h, "anchor")
vint_set_property(Arrow_img_h, "tint", COLOR_SAINTS_PURPLE.R, COLOR_SAINTS_PURPLE.G, COLOR_SAINTS_PURPLE.B)
--Find summary grp for when we need it
Summary_grp_h = vint_object_find("summary_grp", 0, Cell_missions_doc_h)
--Hide challenges grp until we need it
Challenges_grp_h = vint_object_find("challenges_grp", 0, Cell_missions_doc_h)
vint_set_property(Challenges_grp_h, "visible", false)
--Hide challenges overview grp until needed
Challenges_overview_grp_h = vint_object_find("challenges_overview_grp", 0, Cell_missions_doc_h)
vint_set_property(Challenges_overview_grp_h, "visible", false)
--Make sure background is visible in case we enter directly from HUD to quest log
cell_show_frame()
--Get quest data from code
cell_missions_quests_update()
--Draw the quest list
cell_missions_update(Mission_data, nil, true)
--Update challenges
cell_missions_challenges_update(2, false)
--Hide A button
Objective_list:highlight_set_button("")
Objective_list:stop_marquee()
--Load challenges peg
Cell_missions_peg_load_thread_h = thread_new("cell_missions_peg_load")
-- grab challenges data
vint_dataresponder_request( "saintsbook_categories", "cell_missions_chal_overview_update", 0, 4 )
--HVS_RCK - Switch to Challenges immediately. We're not going to show anything else.
Challenges_is_active = true
--Update screen title
Cell_missions_title_h:set_text("QUEST_LOG_CHALLENGES", 320)
--Save off challenges index for when we return
Challenges_index = Curr_mission_index
--Update challenges and redraw list
cell_missions_challenges_update(2, true)
--Call the nav function clear the first quest's new status
cell_missions_nav_list(0)
if Game_platform == "PC" then
Hint_bar_mouse_input_tracker:remove_all()
end
Hint_bar:set_hints(Mission_list_hints_data)
if Game_platform == "PC" then
Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000)
Hint_bar_mouse_input_tracker:subscribe(true)
end
cell_foreground_update_tutorial("set_challenge")
end
--Cleanup, kill threads, unload pegs, reload pause map
function cell_missions_cleanup()
game_peg_unload("ui_bms_sb_challenges")
pause_map_restore()
thread_kill(Cell_missions_peg_load_thread_h)
Cell_missions_peg_load_thread_h = -1
Input_tracker_left:remove_all()
Input_tracker_left:subscribe(false)
Input_tracker_right:remove_all()
Input_tracker_right:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:remove_all()
Mouse_input_tracker:subscribe(false)
Hint_bar_mouse_input_tracker:remove_all()
Hint_bar_mouse_input_tracker:subscribe(false)
end
Hint_bar:cleanup()
table_clear(Objective_data, true)
table_clear(Challenges_data, true)
table_clear(Completed_quests_data, true)
table_clear(Crit_path_quest_data, true)
table_clear(Mission_data, true)
table_clear(Cell_missions_completed_objective_temp, true)
table_clear(Cell_missions_uncompleted_objective_temp, true)
table_clear(Cell_missions_rewards_temp, true)
table_clear(Cell_missions_challenges_temp, true)
table_clear(Full_challenge_list, true)
end
--Load challenges peg
function cell_missions_peg_load()
pause_map_dump( true )
game_peg_load_with_cb("cell_missions_peg_load_complete", 1, "ui_bms_sb_challenges")
end
--Everything is loaded, transition screen in
function cell_missions_peg_load_complete()
--Transition screen in and unlock controls
if Missions_from_menu then
--Transition the screen in...
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MISSIONS, CELL_SCREEN_MAIN, cell_missions_unlock_controls)
else
--Transition the screen in...
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MISSIONS, CELL_SCREEN_NONE, cell_missions_unlock_controls)
end
end
------------------------------------------------------------------------------------------------
-- Function cell_missions_update()
--
-- @param data -- List data
-- @param index -- Current index
-- @param draw_list -- Determines if the Mission list should redraw or not
--
-- Quest Log Modes:
--
-- 1. In a mission with an active objective
-- -Hide everything expect Quest Title and Active Objective.
-- -The user can only back out or exit mission from this state.
--
-- 2. In a mission with NO active objective
-- -Show the quest log, when the user trys to start an objective-
-- -throw up a popup that says you can't start an objective right now.
--
-- 3. Not in a mission
-- -Show the quest log as normal.
--
------------------------------------------------------------------------------------------------
function cell_missions_update(data, index, draw_list)
--Find active quest
local active_quest_index = nil
for i=1, #data do
if data[i].quest_pinned == true then
active_quest_index = i
end
end
local valid_quest_index = nil
for i=1, #data do
if data[i].type ~= TYPE_HEADER then
valid_quest_index = i
break
end
end
--Challenges is always second to last
Challenges_index = #Mission_data - 1
--If no index specified, go to active quest
if index == nil then
index = active_quest_index or valid_quest_index
end
--Store off mission index
Curr_mission_index = index
--Completed quests is always last
--Completed_quests_index = #Mission_data
--Store off current mission
local curr_mission = data[Curr_mission_index]
local in_mission_grp_h = vint_object_find("in_mission_grp", 0, Cell_missions_doc_h)
vint_set_property(in_mission_grp_h, "visible", false)
--HVS_JPM fix for HS 6605 - not sure how current mission is becoming null here, but if it is, we should just early out
if curr_mission == nil then
return
end
--Loop through objective data to find active objective and first available objective
local active_objective_index = nil
local available_objective_index = -1
for i=1, #curr_mission.objective_data do
local curr_objective = curr_mission.objective_data[i]
if curr_objective.quest_pinned == true then
active_objective_index = i
end
if curr_objective.completed == false and available_objective_index == -1 then
available_objective_index = i
end
end
--Figure out what state we're in
--Are we in a mission?
In_mission = not cell_missions_can_start_objective()
local quest_log_grp_h = vint_object_find("quest_log_grp", 0, Cell_missions_doc_h)
vint_set_property(quest_log_grp_h, "visible", false)
if In_mission then
-- HVS_JPM we don't need to do this for SRGAT because we don't have missions per say. Fixes HS 9581
--[[
--Do we have an active objective
if active_quest_index ~= nil then
--We're in a mission with a valid objective, go to in mission state
vint_set_property(in_mission_grp_h, "visible", true)
vint_set_property(quest_log_grp_h, "visible", false)
if Game_platform == "PC" then --Hint bar is about to be reset, remove old input
Hint_bar_mouse_input_tracker:remove_all()
end
local gameplay_type = game_get_in_progress_type()
if game_get_in_progress_type() == -1 then
Hint_bar:set_hints(No_mission_hints_data)
else
if gameplay_type == MT_MISSION then
In_mission_hints_data[2][2] = "HUD_CANCEL_MISSION"
elseif gameplay_type == MT_ACTIVITY then
In_mission_hints_data[2][2] = "HUD_CANCEL_ACTIVITY"
elseif gameplay_type == MT_DIVERSION_ACTIVE then
In_mission_hints_data[2][2] = "HUD_CANCEL_DIVERSION"
end
Hint_bar:set_hints(In_mission_hints_data)
end
if Game_platform == "PC" then --Hint bar has been reset so resubscribe mouse input
Hint_bar:set_highlight(0)
Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000)
Hint_bar_mouse_input_tracker:subscribe(true)
end
--In mission text fields
local quest_title_txt_h = vint_object_find("quest_title_txt", 0 , Cell_missions_doc_h)
local objective_title_txt_h = vint_object_find("objective_title_txt", 0 , Cell_missions_doc_h)
vint_set_property(quest_title_txt_h, "text_tag_crc", curr_mission.label_crc)
vint_set_property(objective_title_txt_h, "text_tag_crc", curr_mission.objective_data[active_objective_index].label_crc)
return
else
--]]
--Set flag to deny objective start if/when it is selected
Objective_is_valid = false
--end
else
--Set flag to allow objectives to start
Objective_is_valid = true
end
--Show Quest Log as normal
vint_set_property(in_mission_grp_h, "visible", false)
vint_set_property(quest_log_grp_h, "visible", true)
if Game_platform == "PC" then --Hint bar is about to be reset, remove old input
Hint_bar_mouse_input_tracker:remove_all()
end
Hint_bar:set_hints(Mission_list_hints_data)
if Game_platform == "PC" then --Hint bar has been reset so resubscribe mouse input
Hint_bar:set_highlight(0)
Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000)
Hint_bar_mouse_input_tracker:subscribe(true)
end
--Update summary info on right side
cell_missions_summary_update(curr_mission)
--Skip redrawing the list if not required to save framerate
if draw_list == true then
--Remove all inputs before drawing the list...
if Game_platform == "PC" then
Mouse_input_tracker:remove_all()
end
--Draw missions list
Mission_list:draw_items(data, index, MISSION_LIST_WIDTH, MISSION_LIST_MAX_BUTTONS, .7, true, false)
--Update mouse inputs because we've redrawn the list
if Game_platform == "PC" then
Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
if curr_mission.is_quest then
Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
end
Mouse_input_tracker:subscribe(true)
end
end
--Hide challenges grp until challenges are called
vint_set_property(Challenges_grp_h, "visible", false)
--We're not in challenges or completed quests so we are an active mission
if Challenges_is_active == false and Completed_quests_is_active == false then
if curr_mission.is_challenges ~= true and curr_mission.is_completed_quests ~= true then
--Update objectives list
cell_missions_objective_update(curr_mission.objective_data, available_objective_index)
Objective_list:set_visible(true)
vint_set_property(Summary_grp_h, "visible", true)
end
if curr_mission.is_challenges == true and Challenges_is_active == false then
--Switch to challenges mode
Objective_list:set_visible(false)
vint_set_property(Summary_grp_h, "visible", false)
--Update info for challenges overview
cell_missions_challenges_overview_update()
--Show Challenges overview group
vint_set_property(Challenges_overview_grp_h, "visible", true)
else
--Hide Challenges overview group
vint_set_property(Challenges_overview_grp_h, "visible", false)
end
if curr_mission.is_completed_quests == true then
--Switch to completed missions mode
Objective_list:set_visible(false)
vint_set_property(Summary_grp_h, "visible", false)
end
end
--Handle completed quests mode
if Completed_quests_is_active == true then
vint_set_property(Summary_grp_h, "visible", true)
Mission_list:highlight_set_button("")
Objective_list:set_visible(true)
cell_missions_objective_update(curr_mission.objective_data, 1)
end
end
--Update objectives list
function cell_missions_objective_update(data, index)
--Save off Objective data
Objective_data = data
if Game_platform == "PC" then
Mouse_input_tracker:remove_all()
end
--Draw objectives list
if Completed_quests_is_active then
Objective_list:draw_items(data, index, OBJECTIVE_LIST_WIDTH, OBJECT_LIST_MAX_BUTTONS_COMPLETED, .7, true, false)
else
Objective_list:draw_items(data, index, OBJECTIVE_LIST_WIDTH, OBJECT_LIST_MAX_BUTTONS, .7, true, false)
end
--If objective list is active update mouse inputs
if Game_platform == "PC" then
Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
--If list is inactive or the highlighted option is a reward don't show A button
if Active_input == INPUT_LEFT then
Objective_list:highlight_set_button("")
Objective_list:stop_marquee()
end
end
-------------------------------------------------------------------------------
-- Function cell_missions_quests_update()
--
-- Get all quest data. Add objectives to quest data. Filter out any host only
-- quests. Add headers for each section and store everything
-- back in Mission_data.
--
-- Quest sections:
-- PRIMARY QUESTS
-- SIDE QUESTS
-- HOST ONLY QUESTS
-- EXTRAS
--
-------------------------------------------------------------------------------
function cell_missions_quests_update()
Crit_path_quest_data = {}
-- Get the quest list
vint_dataresponder_request( "cell_missions_list_items_dr", "cell_missions_quest_populate", 0 )
-- now get the objectives for each quest
cell_missions_objectives_add(Mission_data)
cell_missions_objectives_add(Crit_path_quest_data)
-- and challenges list
for k, category in pairs(Cell_missions_challenges_temp) do
Cell_missions_challenges_temp[k].category = { }
Cell_missions_challenges_temp[k].category[ #Cell_missions_challenges_temp[k].category + 1 ] = {
name = 0,
label = Cell_missions_challenges_temp[k].label_name,
type = TYPE_HEADER,
summary = 0,
contact_img = "ui_homie_gat",
contact_name = nil,
reward_cache = 0,
reward_power = 0,
reward_label = nil,
icon_name = nil,
complete_pct = 0,
units_collected = 0,
units_total = 1,
}
end
--vint_dataresponder_request( "cell_missions_list_items_dr", "cell_missions_quest_populate", 0 )
vint_dataresponder_request( "saintsbook_categories", "cell_missions_challenges_populate", 0, 3 )
-- Loop through mission data to check for any host only objectives
local host_only_quests_data ={}
local temp_quest_data = {}
-- HVS_RCK 10/20/14 - All of our quests as client come from the host. There's no need for this.
-- Filters out host only quests from side quests data
-- for k, quest in pairs(Mission_data) do
-- local host_only_count = 0
-- for k2, objective in pairs(quest.objective_data) do
-- -- Determine which objectives are host only
-- if objective.host_only == true then
-- host_only_count = host_only_count + 1
-- end
-- end
-- -- If all objectives are host only (minus the header) then add it to the host only quest data
-- -- and remove it from the side quests data. We compress the list later when we append all the sections.
-- if host_only_count == #quest.objective_data - 1 then
-- host_only_quests_data[#host_only_quests_data + 1] = table_clone( Mission_data[ k ] )
-- Mission_data[ k ] = nil
-- end
-- end
-- Appends a table to a table
-- Compresses the list (if it's sparse)
local function append(a,b)
for k, v in pairs(b) do
a[ #a + 1 ] = v
end
end
-- Sort the list by crit and non-crit path quests
local has_crit_path_quests = #Crit_path_quest_data > 0
local has_optional_quests = #Mission_data > 0
-- Append crit path quests
-- if has_crit_path_quests then
-- --Add a header for primary quests
-- temp_quest_data[ #temp_quest_data + 1 ] = {
-- label = "QUEST_LOG_PRIMARY_QUESTS",
-- type = TYPE_HEADER,
-- summary = 0,
-- contact_img = "ui_homie_gat",
-- contact_name = nil,
-- reward_cache = 0,
-- reward_power = 0,
-- objective_data = { },
-- quest_complete = false,
-- is_challenges = true,
-- is_completed_quests = false,
-- equipped = false,
-- quest_pinned = false,
-- is_new = false,
-- }
-- append(temp_quest_data, Crit_path_quest_data)
-- end
Quests_index = #temp_quest_data
--Add a header for side quests
--HVS_RCK - Use this header for both players.
temp_quest_data[ #temp_quest_data + 1 ] = {
label = "QUEST_LOG_SIDE_QUESTS",
type = TYPE_HEADER,
summary = 0,
contact_img = "ui_homie_gat",
contact_name = nil,
reward_cache = 0,
reward_power = 0,
objective_data = { },
quest_complete = false,
is_challenges = true,
is_completed_quests = false,
equipped = false,
quest_pinned = false,
is_new = false,
}
-- Append side quests : If we're host only. Client will have their own list built from host quests below
if has_optional_quests == true then
append(temp_quest_data, Mission_data)
end
-- Append all host only quest, obviously if we are host we don't want to do this (but just be sure)
if #host_only_quests_data > 0 and game_get_is_coop_client() == true then
--Add a header with host's gamertag for host only quests
-- temp_quest_data[ #temp_quest_data + 1 ] = {
-- label = "QUEST_LOG_HOST_QUESTS",
-- type = TYPE_HEADER,
-- summary = 0,
-- contact_img = "ui_homie_gat",
-- contact_name = nil,
-- reward_cache = 0,
-- reward_power = 0,
-- objective_data = { },
-- quest_complete = false,
-- is_challenges = true,
-- is_completed_quests = false,
-- equipped = false,
-- quest_pinned = false,
-- is_new = false,
-- }
append(temp_quest_data, host_only_quests_data)
end
Mission_data = temp_quest_data
-- Adding "Challenges" and "Completed Missions" to the bottom of the list
-- is_challenges = is the "Challenges" option in the list
-- is_completed_quests = is the "Completed Missions" option in the list
local has_challenges = #Cell_missions_challenges_temp > 0
local has_completed_quests = #Completed_quests_data > 0
-- If we have either, show the header for this section
-- if has_challenges or has_completed_quests then
-- Mission_data[ #Mission_data + 1 ] = {
-- id = "m01",
-- label = "QUEST_LOG_EXTRAS",
-- type = TYPE_HEADER,
-- summary = 0,
-- contact_img = "ui_homie_gat",
-- contact_name = nil,
-- reward_cache = 0,
-- reward_power = 0,
-- objective_data = { },
-- quest_complete = false,
-- is_challenges = true,
-- is_completed_quests = false,
-- equipped = false,
-- quest_pinned = false,
-- is_new = false,
-- }
-- end
-- If we have challenges show the option
-- if has_challenges then
-- Mission_data[ #Mission_data + 1 ] = {
-- id = "m01",
-- label = "QUEST_LOG_CHALLENGES",
-- type = TYPE_BUTTON,
-- summary = 0,
-- contact_img = "ui_homie_gat",
-- contact_name = nil,
-- reward_cache = 0,
-- reward_power = 0,
-- objective_data = { },
-- quest_complete = false,
-- is_challenges = true,
-- is_completed_quests = false,
-- equipped = false,
-- quest_pinned = false,
-- is_new = false,
-- }
-- end
-- If we have completed quests show the option on the list
if has_completed_quests then
--get objectives for each completed quest
cell_missions_objectives_add(Completed_quests_data)
Mission_data[ #Mission_data + 1 ] = {
id = "m01",
label = "QUEST_LOG_COMPLETED_QUESTS",
type = TYPE_BUTTON,
summary = 0,
contact_img = "ui_homie_gat",
contact_name = nil,
reward_cache = 0,
reward_power = 0,
objective_data = { },
quest_complete = false,
is_challenges = false,
is_completed_quests = true,
equipped = false,
is_new = false,
}
Completed_quests_index = #Mission_data
end
end
-----------------------------------------------------------------------------------------------
-- Function cell_missions_quest_populate
--
-- @param id -- quest id
-- @param display_name -- quest name
-- @param summary -- quest summary text
-- @param contact_img -- homie head contact image
-- @param contact name -- homie contact name
-- @param cache_reward -- amount of cache rewarded for quest
-- @param power_reward -- amount of power rewarded for quest
-- @param num_avail_objectives -- how many available objectives
-- @param num_complted_objectives -- how many completed objectives
-- @param is_new -- is a new quest
-- @param is_active -- is the quest active?
-- @param remote_objective -- remote player's active objective
--
-----------------------------------------------------------------------------------------------
function cell_missions_quest_populate( id, display_name, summary, contact_img, contact_name, cache_reward, power_reward, num_avail_objectives, num_completed_objectives, is_new, is_active, is_crit_path, complete, remote_objective, is_dlc2)
local temp_data = {
id = id,
label_crc = display_name,
type = TYPE_BUTTON,
summary = summary,
contact_img = contact_img,
contact_name = contact_name,
reward_cache = cache_reward,
reward_power = power_reward,
equipped = false,
quest_pinned = is_active,
objective_data = { },
quest_complete = complete,
is_new = is_new,
is_crit_path = is_crit_path,
remote_objective = remote_objective,
is_completed_quests = false,
is_dlc2 = is_dlc2, -- This uses the second icon as opposed to other instances where we set the first icon to the dlc fleur -Rossi 8/7/13
is_quest = true,
}
if temp_data.quest_complete then
--Safety check, if the quest is complete then it shouldn't be new
temp_data.is_new = false
Completed_quests_data[ #Completed_quests_data + 1 ] = temp_data
elseif temp_data.is_crit_path then
Crit_path_quest_data[ #Crit_path_quest_data + 1 ] = temp_data
else
Mission_data[ #Mission_data + 1 ] = temp_data
end
end
-------------------------------------------------------------------------------
--Adds objective data to quest data
--
function cell_missions_objectives_add(data)
for k, v in pairs( data ) do
-- get the objectives in two lists, completed and uncompleted
vint_dataresponder_request( "cell_missions_list_items_dr", "cell_missions_objective_populate", 0, "objectives", v.id )
vint_dataresponder_request( "cell_missions_list_items_dr", "cell_missions_reward_populate", 0, "rewards", v.id )
-- merge them with headers and whatnot
v.objective_data = { }
v.objective_data[ 1 ] = { label = "QUEST_LOG_OBJECTIVES", type = TYPE_HEADER, }
for k2, v2 in pairs( Cell_missions_uncompleted_objective_temp ) do
v.objective_data[ #v.objective_data + 1 ] = v2
end
-- Adding completed objectives
if #Cell_missions_completed_objective_temp > 0 then
--v.objective_data[ #v.objective_data + 1 ] = { label = "", type = TYPE_LINE_BREAK, }
v.objective_data[ #v.objective_data + 1 ] = { label = "COMPLETED", type = TYPE_HEADER, }
for k2, v2 in pairs( Cell_missions_completed_objective_temp ) do
v.objective_data[ #v.objective_data + 1 ] = v2
end
end
--If we have a reward then place it in the quest data
if #Cell_missions_rewards_temp > 0 then
v.reward_label = Cell_missions_rewards_temp[1].label
end
-------------------------------------------------------------------------
-- Removing rewards from the objectives list. Replaced with a static
-- rewards section at the bottom of the screen.
-------------------------------------------------------------------------
--[[if #Cell_missions_rewards_temp > 0 then
--v.objective_data[ #v.objective_data + 1 ] = { label = "", type = TYPE_LINE_BREAK, }
v.objective_data[ #v.objective_data + 1 ] = { label = "MENU_REWARDS", type = TYPE_HEADER, }
for k2, v2 in pairs( Cell_missions_rewards_temp ) do
v.objective_data[ #v.objective_data + 1 ] = v2
end
end]]
--------------------------------------------------------------------------
Cell_missions_uncompleted_objective_temp = { }
Cell_missions_completed_objective_temp = { }
Cell_missions_rewards_temp = { }
end
end
-----------------------------------------------------------------------------------------------
-- Function cell_missions_objective_populate
--
-- @param id -- objective id
-- @param display_name -- objective name
-- @param completed -- is objective complete?
-- @param icon name -- an icon to show gameplay type (same as on pause map)
-- @param objective_type -- corresponds to the following enums:
--OBJECTIVE_TYPE_MISSION = 0
--OBJECTIVE_TYPE_ACTIVITY = 1
--OBJECTIVE_TYPE_RIFT = 2
--OBJECTIVE_TYPE_COLLECTIBLE = 3
--JAM 2/7/13: Not sure if we need this
-- @param is_active -- is this objective active?
-- @param host_only --only the host can start this objective (always false in SP and host)
-- @param remote_objective --remote player's objective
--
-----------------------------------------------------------------------------------------------
function cell_missions_objective_populate( id, display_name, completed, icon_name, objective_type, is_active, host_only, remote_objective )
Cell_missions_uncompleted_objective_temp[ #Cell_missions_uncompleted_objective_temp + 1 ] = {
name = id,
label_crc = display_name,
completed = completed,
obj_complete = completed,
type = TYPE_BUTTON,
objective_type = objective_type,
equipped = false,
quest_pinned = is_active,
disabled = completed,
host_only = host_only,
remote_objective = remote_objective,
}
end
-----------------------------------------------------------------------------------------------
-- Function cell_missions_reward_populate
--
-- Populates a temp table with available rewards from a quest
--
-- @param reward_type -- corresponds to the following enums:
--REWARD_TYPE_ACHIEVEMENT = 0
--REWARD_TYPE_UNLOCKABLE = 1
-- @param display_name -- reward name
--
-----------------------------------------------------------------------------------------------
function cell_missions_reward_populate( reward_type, display_name )
Cell_missions_rewards_temp[ #Cell_missions_rewards_temp + 1 ] = {
reward_type = reward_type,
label = display_name,
type = TYPE_BUTTON,
}
end
-- Updates quest list with list of challenges
function cell_missions_challenges_update(index, draw_list)
for k, category in pairs(Cell_missions_challenges_temp) do
Cell_missions_challenges_temp[k].category = { }
Cell_missions_challenges_temp[k].category[ #Cell_missions_challenges_temp[k].category + 1 ] = {
name = 0,
label = Cell_missions_challenges_temp[k].label_name,
type = TYPE_HEADER,
summary = 0,
contact_img = "ui_homie_gat",
contact_name = nil,
reward_cache = 0,
reward_power = 0,
reward_label = nil,
icon_name = nil,
complete_pct = 0,
units_collected = 0,
units_total = 1,
}
end
-- get the challenges data
vint_dataresponder_request( "saintsbook_categories", "cell_missions_challenges_populate", 0, 3 )
--vint_dataresponder_request( "cell_missions_list_items_dr", "cell_missions_quest_populate", 0 )
-- update list with challenges
--Remove all inputs before drawing the list...
local function append(a,b)
for k, v in pairs(b) do
if v.equipped == true then
if v.name ~= Curr_tracked_challenge_id then
v.equipped = false
end
end
if v.name == Curr_tracked_challenge_id then
v.equipped = true
end
a[ #a + 1 ] = v
end
end
--table_clear(Full_challenge_list, true)
local has_optional_quests = #Mission_data > 0
if has_optional_quests then
-- --Add a header for side quests
-- Full_challenge_list[ #Full_challenge_list + 1 ] = {
-- label = "QUEST_LOG_SIDE_QUESTS",
-- type = TYPE_HEADER,
-- summary = 0,
-- contact_img = "ui_homie_gat",
-- contact_name = nil,
-- reward_cache = 0,
-- reward_power = 0,
-- objective_data = { },
-- quest_complete = false,
-- is_challenges = true,
-- is_completed_quests = false,
-- equipped = false,
-- quest_pinned = false,
-- is_new = false,
-- }
Full_challenge_list = table_clone(Mission_data)
else
Full_challenge_list = {}
end
--Full_challenge_list = Cell_missions_challenges_temp[1].category
for k, category in pairs(Cell_missions_challenges_temp) do
append(Full_challenge_list, category.category)
end
if draw_list == true then
if Game_platform == "PC" then
Mouse_input_tracker:subscribe(false)
Mouse_input_tracker:remove_all()
end
--Draw missions list
Mission_list:draw_items(Full_challenge_list, index, MISSION_LIST_WIDTH, MISSION_LIST_MAX_BUTTONS, .7, true, false)
--Update mouse inputs because we've redrawn the list
if Game_platform == "PC" then
Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
--Show summary and challenge grp
vint_set_property(Summary_grp_h, "visible", true)
vint_set_property(Challenges_grp_h, "visible", true)
--Hide Challenges overview group
vint_set_property(Challenges_overview_grp_h, "visible", false)
--Hide the A button
--Mission_list:highlight_set_button("")
--Get current challenge
local curr_challenge = Full_challenge_list[index]
Curr_mission_index = index
--Update summary info on right side
cell_missions_summary_update(curr_challenge)
--Update challenge widget
local chal_unit_title_txt_h = vint_object_find("chal_unit_title_txt", 0, Cell_missions_doc_h)
local chal_unit_txt_h = vint_object_find("chal_unit_txt", 0, Cell_missions_doc_h)
local chal_icon_img_h = vint_object_find("chal_icon_img", 0, Cell_missions_doc_h)
vint_set_property(chal_unit_title_txt_h, "text_tag_crc", curr_challenge.units_type)
vint_set_property(chal_unit_txt_h, "text_tag", var_to_string(curr_challenge.units_collected).."/"..var_to_string(curr_challenge.units_total))
--Set image if there is one
vint_debug_print("challenge icon", curr_challenge.icon_name)
if curr_challenge.icon_name ~= nil then
vint_set_property(chal_icon_img_h, "image", curr_challenge.icon_name)
vint_set_property(chal_icon_img_h, "visible", true)
else
vint_set_property(chal_icon_img_h, "visible", false)
end
--Update meter
local chal_meter_clip_h = vint_object_find("chal_meter_clip", 0, Cell_missions_doc_h)
if curr_challenge.is_quest == false then
local METER_FULL_PCT = 340
local chal_meter_width, chal_meter_height = vint_get_property(chal_meter_clip_h, "clip_size")
local new_width = METER_FULL_PCT * curr_challenge.complete_pct
if curr_challenge.complete_pct ~= 1 then --if 1 then set it to full
local increment = METER_FULL_PCT/49
for i = 0, METER_FULL_PCT, increment do
if new_width >= i and new_width < (i + increment) then
new_width = i
end
end
end
vint_set_property(Challenges_grp_h, "visible", true)
vint_set_property(chal_unit_title_txt_h, "visible", true)
vint_set_property(chal_unit_txt_h, "visible", true)
vint_set_property(chal_meter_clip_h, "visible", true)
vint_set_property(chal_meter_clip_h, "clip_size", new_width, chal_meter_height)
Objective_list:set_visible(false)
if Game_platform == "PC" then
Mouse_input_tracker:subscribe(false)
Mouse_input_tracker:remove_all()
Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
else
vint_set_property(Challenges_grp_h, "visible", false)
vint_set_property(chal_meter_clip_h, "visible", false)
vint_set_property(chal_unit_title_txt_h, "visible", false)
vint_set_property(chal_unit_txt_h, "visible", false)
Objective_list:set_visible(true)
if curr_challenge.is_completed_quests == false and curr_challenge.objective_data[1] then
cell_missions_objective_update(curr_challenge.objective_data, 1)
end
end
if curr_challenge.is_new then
Mission_list:remove_new_flag(index)
if curr_challenge.is_quest then
vint_scriptevent_post("quest_log_clear_new", "quest", curr_challenge.id)
else
vint_scriptevent_post("quest_log_clear_new", "challenge", curr_challenge.name)
end
--Remove our mouse inputs first...
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:remove_all()
end
curr_challenge.is_new = false
--Update mouse inputs because we've redrawn the list
if Game_platform == "PC" then
Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
if curr_challenge.is_quest then
Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
end
Mouse_input_tracker:subscribe(true)
end
end
--if Mission_data[Curr_mission_index].is_completed_quests == true then
if Curr_mission_index == Completed_quests_index then
--Switch to completed missions mode
Objective_list:set_visible(false)
vint_set_property(Summary_grp_h, "visible", false)
end
end
-----------------------------------------------------------------------------------------------
-- Function cell_missions_chal_overview_update()
--
-- Stores challenge overview data in globals so we only have to call them once.
--
-- @param total_challenges --total number of challenges
-- @param completed_challenges --number of completed challenges
-- @param milestone_goal --number of challenges needed to reach next milestone
-- @param progress --progress towards the milestone
-- @param cash --cash reward for meeting the milestone
-- @param respect --respect reward for meeting the milestone
-- @param unlockable --unlockable reward for meeting the milestone
--
-----------------------------------------------------------------------------------------------
function cell_missions_chal_overview_update( total_challenges, completed_challenges, milestone_goal, progress, cash, respect, unlockable )
Cell_mission_chal_ov_total = total_challenges
Cell_mission_chal_ov_completed = completed_challenges
Cell_mission_chal_ov_milestone_goal = milestone_goal
Cell_mission_chal_ov_progress = progress
Cell_mission_chal_ov_cash_reward = cash
Cell_mission_chal_ov_respect_reward = respect
Cell_mission_chal_ov_unlockable_reward = unlockable
end
-----------------------------------------------------------------------------------------------
-- Function cell_missions_challenges_overview_update
--
-- Updates the challenges overview section on the right side of the screen
-- when the user has "challenges" highlighted in the quest list
--
-- Params used:
-- Total challenges
-- Completed challenges
-- Current milestone
-- Progress towards current milestone
-- Rewards for current milestone
-- Cash
-- Respect
-- Unlockable
--
-----------------------------------------------------------------------------------------------
function cell_missions_challenges_overview_update()
-- Find all challenge overview elements
local challenges_title_txt_h = vint_object_find("challenges_title_txt", 0, Cell_missions_doc_h)
local progress_txt_h = vint_object_find("progress_txt", 0, Cell_missions_doc_h)
local progress_value_txt_h = vint_object_find("progress_value_txt", 0, Cell_missions_doc_h)
local completed_txt_h = vint_object_find("completed_txt", 0, Cell_missions_doc_h)
local goal_txt_h = vint_object_find("goal_txt", 0, Cell_missions_doc_h)
local goal_label_txt_h = vint_object_find("goal_label_txt", 0, Cell_missions_doc_h)
local goal_meter_fill_img_h = vint_object_find("goal_meter_fill_img", 0, Cell_missions_doc_h)
local goal_meter_grp_h = vint_object_find("goal_meter_grp", 0, Cell_missions_doc_h)
-- Set localization tags
vint_set_property(challenges_title_txt_h, "text_tag", "QUEST_LOG_CHALLENGES_OVERVIEW")
vint_set_property(progress_txt_h, "text_tag", "QUEST_LOG_TOTAL_PROGRESS")
vint_set_property(completed_txt_h, "text_tag", "ACTIVITY_COMPLETED")
vint_set_property(goal_txt_h, "text_tag", "QUEST_LOG_CURRENT_GOAL")
-- Set challenges x/y
local color = "[format][color:#9300C5]"
local insert_values = {[0] = color, [1] = Cell_mission_chal_ov_completed, [2] = Cell_mission_chal_ov_total}
local body = vint_insert_values_in_string("QUEST_LOG_CHALLENGES_X_Y", insert_values)
vint_set_property(progress_value_txt_h, "text_tag", body)
-- Set challlenge milestone info
local insert_values = {[0] = Cell_mission_chal_ov_milestone_goal}
local body
-- For 1 Challenge
if Cell_mission_chal_ov_milestone_goal == 1 then
body = vint_insert_values_in_string("QUEST_LOG_COMPLETE_CHALLENGE", insert_values)
else
-- For more than 1 Challenge
body = vint_insert_values_in_string("QUEST_LOG_COMPLETE_CHALLENGES", insert_values)
end
vint_set_property(goal_label_txt_h, "text_tag", body)
-- Reposition completed text
local progress_width, progress_height = element_get_actual_size(progress_value_txt_h)
local progress_x, progress_y = vint_get_property(progress_value_txt_h, "anchor")
local completed_x, completed_y = vint_get_property(completed_txt_h, "anchor")
vint_set_property(completed_txt_h, "anchor", progress_x + progress_width + 5, completed_y)
--Set reward info
local reward_data = {
is_crit_path = false,
reward_label = Cell_mission_chal_ov_unlockable_reward,
reward_cache = Cell_mission_chal_ov_cash_reward,
reward_power = Cell_mission_chal_ov_respect_reward,
}
cell_missions_reward_update(reward_data, true)
--Update meter
local GOAL_FULL_PCT = 340
local goal_clip_h = vint_object_find("goal_clip", 0, Cell_missions_doc_h)
local goal_meter_width, goal_meter_height = vint_get_property(goal_clip_h, "clip_size")
local new_width = GOAL_FULL_PCT * Cell_mission_chal_ov_progress
if Cell_mission_chal_ov_progress ~= 1 then --if 1 then set it to full
local increment = GOAL_FULL_PCT/49
for i = 0, GOAL_FULL_PCT, increment do
if new_width >= i and new_width < (i + increment) then
new_width = i
end
end
end
vint_set_property(goal_clip_h, "clip_size", new_width, goal_meter_height)
end
-----------------------------------------------------------------------------------------------
-- Function cell_missions_summary_update
--
-- Updates the quest/challenge summary text, header, and icon on the right side of the screen
--
-- @param summary_data -- summary data for highlighted menu item
--
-----------------------------------------------------------------------------------------------
function cell_missions_summary_update(summary_data)
--Hide rewards if we're in completed quests mode
if summary_data.is_completed_quests ~= true and Completed_quests_is_active ~= true then
cell_missions_reward_update(summary_data, true)
else
cell_missions_reward_update(summary_data, false)
end
--Find summary elements
local contact_img_h = vint_object_find("contact_img", 0, Cell_missions_doc_h)
local contact_name_txt_h = vint_object_find("contact_name_txt", 0, Cell_missions_doc_h)
local summary_txt_h = vint_object_find("summary_txt", 0, Cell_missions_doc_h)
--Set text fields
vint_set_property(contact_img_h, "image", summary_data.contact_img)
vint_set_property(contact_name_txt_h, "text_tag", summary_data.contact_name)
vint_set_property(summary_txt_h, "text_tag_crc", summary_data.summary)
--Move arrow with megalist highlight
vint_set_property(Arrow_img_h, "anchor", Arrow_x, Arrow_y + ((Curr_mission_index - 1) * ARROW_OFFSET))
--Set size of speech bubble
local bubble_top_img_h = vint_object_find("bubble_top_img", 0, Cell_missions_doc_h)
local bubble_bot_img_h = vint_object_find("bubble_bot_img", 0, Cell_missions_doc_h)
local bubble_left_img_h = vint_object_find("bubble_left_img", 0, Cell_missions_doc_h)
local bubble_right_img_h = vint_object_find("bubble_right_img", 0, Cell_missions_doc_h)
local bubble_side_width, bubble_side_height = element_get_actual_size(bubble_left_img_h)
local summary_width, summary_height = element_get_actual_size(summary_txt_h)
local bubble_left_x, bubble_left_y = vint_get_property(bubble_left_img_h, "anchor")
local bubble_bot_x, bubble_bot_y = vint_get_property(bubble_bot_img_h, "anchor")
element_set_actual_size(bubble_left_img_h, bubble_side_width, summary_height)
element_set_actual_size(bubble_right_img_h, bubble_side_width, summary_height)
vint_set_property(bubble_bot_img_h, "anchor", bubble_bot_x, bubble_left_y + summary_height - 1) --TODO: inset the graphic to remove the -1
end
-----------------------------------------------------------------------------------------------
-- Function cell_missions_reward_update
--
-- Updates the reward section of a quest
--
-- @param reward_data -- reward data for a quest
-- @param show_rewards -- toggles rewards group visibility
--
-----------------------------------------------------------------------------------------------
function cell_missions_reward_update(reward_data, show_rewards)
--Hide rewards for crith path quest
if reward_data.is_crit_path == true then
show_rewards = false
end
--Show/hide the reward grp
local reward_grp_h = vint_object_find("reward_grp", 0 , Cell_missions_doc_h)
vint_set_property(reward_grp_h, "visible", show_rewards)
--No rewards to update, return early
if show_rewards == false then
return
end
--Find the reward elements
local reward_label_txt_h = vint_object_find("reward_label_txt", 0, Cell_missions_doc_h)
local reward_txt_h = vint_object_find("reward_txt", 0, Cell_missions_doc_h)
local cache_txt_h = vint_object_find("cache_txt", 0 , Cell_missions_doc_h)
local power_txt_h = vint_object_find("power_txt", 0 , Cell_missions_doc_h)
--Do we have a reward?
if reward_data.reward_label ~= nil and reward_data.reward_label ~= 0 then
if type(reward_data.reward_label) == "string" then
vint_set_property(reward_txt_h, "text_tag", reward_data.reward_label)
else
vint_set_property(reward_txt_h, "text_tag_crc", reward_data.reward_label)
end
--Shrink text to make sure it fits
resize_text_element(reward_txt_h, 445)
vint_set_property(reward_txt_h, "visible", true)
else
vint_set_property(reward_txt_h, "visible", false)
end
--Set text fields
vint_set_property(reward_label_txt_h, "text_tag", "MENU_REWARDS_TOTAL")
vint_set_property(cache_txt_h, "text_tag", "{GAME_CASH}"..format_cash(reward_data.reward_cache))
vint_set_property(power_txt_h, "text_tag", var_to_string(reward_data.reward_power))
--Resize and position reward box
local REWARD_TEXT_PADDING = 5
local LINE_HEIGHT = 2
local power_img_h = vint_object_find("power_img", 0, Cell_missions_doc_h)
local power_img_width, power_img_height = element_get_actual_size(power_img_h)
local power_txt_x, power_txt_y = vint_get_property(power_txt_h, "anchor")
local power_txt_width, power_txt_height = element_get_actual_size(power_txt_h)
local box_grp_h = vint_object_find("box_grp", 0, Cell_missions_doc_h)
local top_img_h = vint_object_find("top_img", 0, Cell_missions_doc_h)
local cache_box_grp_h = vint_object_find("cache_box_grp", 0, Cell_missions_doc_h)
local box_x, box_y = vint_get_property(box_grp_h, "anchor")
local cache_box_x, cache_box_y = vint_get_property(cache_box_grp_h, "anchor")
local top_img_with, top_img_height = element_get_actual_size(top_img_h)
--Position cache and power text
vint_set_property(power_img_h, "anchor", power_txt_x - power_txt_width, power_txt_y)
vint_set_property(cache_txt_h, "anchor", power_txt_x - power_txt_width - REWARD_TEXT_PADDING - power_img_width - REWARD_TEXT_PADDING, power_txt_y)
local cache_x, cache_y = vint_get_property(cache_txt_h, "anchor")
local cache_width, cache_height = element_get_actual_size(cache_txt_h)
local new_top_img_width = cache_x - cache_width - box_x - REWARD_TEXT_PADDING
--Resize outer box
element_set_actual_size(top_img_h, new_top_img_width - REWARD_TEXT_PADDING, LINE_HEIGHT)
vint_set_property(cache_box_grp_h, "anchor", new_top_img_width, cache_box_y)
local cache_top_img_h = vint_object_find("cache_top_img", 0, Cell_missions_doc_h)
local cache_bot_img_h = vint_object_find("cache_bot_img", 0, Cell_missions_doc_h)
local cache_right_img_h = vint_object_find("cache_right_img", 0, Cell_missions_doc_h)
local bot_img_h = vint_object_find("bot_img", 0, Cell_missions_doc_h)
local bot_width, bot_height = element_get_actual_size(bot_img_h)
local new_cache_box_width = bot_width - new_top_img_width
--Rock the cache box
element_set_actual_size(cache_top_img_h, new_cache_box_width, LINE_HEIGHT)
element_set_actual_size(cache_bot_img_h, new_cache_box_width, LINE_HEIGHT)
vint_set_property(cache_right_img_h, "anchor", new_cache_box_width, 0)
end
-----------------------------------------------------------------------------------------------
-- Function cell_missions_challenges_populate
--
-- Populates challenges data
--
-- @param id -- challenge id
-- @param display_name -- challenge name
-- @param summary -- challenge summary text
-- @param contact_img -- homie head contact image
-- @param contact name -- homie contact name
-- @param cache_reward -- amount of cache rewarded for challenge
-- @param power_reward -- amount of power rewarded for challenge
-- @param icon_name -- challenge icon
-- @param units_collected -- number of units collected
-- @param units_total -- max number of units available to collect
-- @param units_type -- type of units
-- @param reward_label -- string for reward
--
-----------------------------------------------------------------------------------------------
function cell_missions_challenges_populate(id, display_name, summary, contact_img, contact_name, cache_reward, power_reward, icon_name, units_collected, units_total, units_type, reward_label, completed, type_index, is_new)
local type_category = Cell_missions_challenges_temp[type_index].category
local is_equipped = false
if id == Curr_tracked_challenge_id then
is_equipped = true
end
type_category[ #type_category + 1 ] = {
name = id,
label_crc = display_name,
type = TYPE_BUTTON,
summary = summary,
contact_img = contact_img,
contact_name = contact_name,
reward_cache = cache_reward,
reward_power = power_reward,
reward_label = reward_label,
icon_name = icon_name,
complete_pct = units_collected / units_total,
units_collected = units_collected,
units_total = units_total,
units_type = units_type,
equipped = is_equipped,
is_new = is_new,
is_quest = false,
}
end
-- Exit back to hub menu
function cell_missions_exit_to_menu()
if Challenge_tutorial_pending_clear then
challenge_tutorial_set_active(false)
hud_prompt_clear_all()
end
--Play menu back audio
ui_audio_post_event("UI_Hub_Menu_Back")
--Set HUB state to main menu
vint_dataresponder_post("cell_menu_state_dr", "Set", ID_MAIN)
pop_screen() --missions
end
--Exit back to game
function cell_missions_exit_to_game(play_audio)
if Challenge_tutorial_pending_clear then
challenge_tutorial_set_active(false)
hud_prompt_clear_all()
end
--Don't play back out audio if starting a new objective
if play_audio ~= false then
--Play menu back audio
ui_audio_post_event("UI_Hub_Menu_Back")
end
--Store off HUB state so we can return to missions next time
vint_dataresponder_post("cell_menu_state_dr", "Set", ID_MISSIONS)
pop_screen() --missions
pop_screen() --main menu
pop_screen() --cellphone frame
end
--Unlock input
function cell_missions_unlock_controls()
if Active_input == INPUT_LEFT then
Input_tracker_left:subscribe(true)
Input_tracker_right:subscribe(false)
else
Input_tracker_left:subscribe(false)
Input_tracker_right:subscribe(true)
end
end
--Lock input
function cell_missions_lock_controls()
Input_tracker_left:subscribe(false)
Input_tracker_right:subscribe(false)
end
--Swap input trackers, set which input is active
function cell_missions_nav_swap(objective)
--We're in a mission, disabling controls
if In_mission == true and Objective_is_valid == true then
return
end
if Active_input == INPUT_LEFT then
--Going left to right
--Switch input subscriptions
Input_tracker_left:subscribe(false)
Input_tracker_right:subscribe(true)
--Alpha out quests list and turn on objectives list
Mission_list:set_alpha(LIST_ALPHA_INACTIVE)
Objective_list:set_alpha(LIST_ALPHA_ACTIVE)
--Set active highlight to purple and inactive to grey
Mission_list:set_highlight_color(COLOR_LIST_LOST_FOCUS)
Objective_list:set_highlight_color(COLOR_SAINTS_PURPLE)
vint_set_property(Arrow_img_h, "tint", COLOR_LIST_LOST_FOCUS.R, COLOR_LIST_LOST_FOCUS.G, COLOR_LIST_LOST_FOCUS.B)
vint_set_property(Arrow_img_h, "alpha", LIST_ALPHA_INACTIVE)
--Hide the A button
Mission_list:highlight_set_button("")
--Stop marquee for long quest titles
Mission_list:stop_marquee()
--Adding a move cursor so that marqueeing will restart
Objective_list:move_cursor(0)
local objective_idx = Objective_list:get_selection()
local current_objective = objective.objective_data[objective_idx]
Current_left_quest = objective
cell_missions_objective_update(objective.objective_data, 1)
--If in completed quests or challenges hide A button for objectives
if Completed_quests_is_active == true or Challenges_is_active == true then
Objective_list:highlight_set_button("")
else
Objective_list:highlight_set_button(CTRL_MENU_BUTTON_A)
end
--Switch active input
Active_input = INPUT_RIGHT
if Current_left_quest.id == challenge_get_challenge_tut_id() then
cell_foreground_update_tutorial("pick_objective")
end
ui_audio_post_event("ui_quest_forward")
else
--Going right to left
--Switch input subscriptions
Input_tracker_left:subscribe(true)
Input_tracker_right:subscribe(false)
--Alpha out objectives list and turn on quest list
Mission_list:set_alpha(LIST_ALPHA_ACTIVE)
Objective_list:set_alpha(LIST_ALPHA_INACTIVE)
--Set active highlight to purple and inactive to grey
Mission_list:set_highlight_color(COLOR_SAINTS_PURPLE)
Objective_list:set_highlight_color(COLOR_LIST_LOST_FOCUS)
vint_set_property(Arrow_img_h, "tint", COLOR_SAINTS_PURPLE.R, COLOR_SAINTS_PURPLE.G, COLOR_SAINTS_PURPLE.B)
vint_set_property(Arrow_img_h, "alpha", LIST_ALPHA_ACTIVE)
--Stop marquee for long objective titles
Objective_list:stop_marquee()
--Adding a move cursor so that marqueeing will restart
Mission_list:move_cursor(0)
--Show A button for quests and hide for objectives
Mission_list:highlight_set_button(CTRL_MENU_BUTTON_A)
Objective_list:highlight_set_button("")
if Completed_quests_is_active == true or Challenges_is_active == true then
Mission_list:highlight_set_button("")
end
--Switch active input
Active_input = INPUT_LEFT
just_swapped = true
if not Challenge_tutorial_pending_clear then
cell_foreground_update_tutorial("set_challenge")
end
ui_audio_post_event("ui_quest_back")
end
local mission_index = Mission_list:get_selection()
--Determine which hints to show
cell_missions_hints_update(mission_index)
--On PC we have to refresh mouse inputs when inputs are swapped
if game_is_active_input_gamepad() == false then
--Get current mission index
Curr_mission_index = Mission_list:get_selection()
Mission_list:move_cursor(0)
--Get current objective index
Curr_objective_index = Objective_list:get_selection()
Objective_list:move_cursor(0)
--Update lists to refresh mouse inputs
--cell_missions_nav_list()
end
vint_debug_print("Active_input", Active_input)
end
--Handle events for A button
function cell_missions_nav_a()
--We're in a mission, you can't use the A button
if In_mission == true and Objective_is_valid == true then
return
end
if Active_input == INPUT_LEFT then
if Mission_list:list_is_playing() == false then
--Do nothing for completed quest. All you can do is scroll the list on the left.
--Don't need to check anything in Mission_data
if Completed_quests_is_active == true then
return
end
if Challenges_is_active == true and Full_challenge_list[Curr_mission_index].is_quest == false then
if Curr_tracked_challenge_id ~= Full_challenge_list[Curr_mission_index].name then
Challenge_tracker_enabled = true
Curr_tracked_challenge = Full_challenge_list[Curr_mission_index]
Curr_tracked_challenge_id = Curr_tracked_challenge.name
Curr_tracked_challenge.equipped = true
ui_hud_set_current_challenge(Curr_tracked_challenge.name) -- HVS_RCK - For some reason "name" is the id number of the challenge
local METER_FULL_PCT = 140
local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE)
vint_set_property(challenges_bar_h, "visible", true)
local chal_meter_title = vint_object_find("chal_unit_title_txt", 0, HUD_DOC_HANDLE)
vint_set_property(chal_meter_title, "text_tag_crc", Curr_tracked_challenge.label_crc)
local chal_meter_unit_type = vint_object_find("chal_unit_txt", 0, HUD_DOC_HANDLE)
local base_units_string = "{0}/{1}"
local values = {[0] = Curr_tracked_challenge.units_collected, [1] = Curr_tracked_challenge.units_total}
local units_tag = vint_insert_values_in_string(base_units_string, values)
vint_set_property(chal_meter_unit_type, "text_tag", units_tag)
local chal_meter_clip_h = vint_object_find("chal_meter_bar_clip", 0, HUD_DOC_HANDLE)
local chal_meter_width, chal_meter_height = vint_get_property(chal_meter_clip_h, "clip_size")
local new_width = METER_FULL_PCT * Curr_tracked_challenge.complete_pct
--Update challenge widget
local chal_icon_img_h = vint_object_find("chal_icon_sm", 0, HUD_DOC_HANDLE)
local chal_background_h = vint_object_find("challenge_backer", 0, HUD_DOC_HANDLE)
local chal_background_width, chal_background_height = vint_get_property(chal_background_h, "screen_size")
local chal_text_width, chal_text_height = vint_get_property(chal_meter_title, "screen_size")
local new_backer_width = chal_text_width + 10
if new_backer_width < 150 then
new_backer_width = 150
end
vint_set_property(chal_background_h, "screen_size", new_backer_width, chal_background_height)
--Set image if there is one
--vint_debug_print("challenge icon", Curr_tracked_challenge.icon_name)
-- if Curr_tracked_challenge.icon_name ~= nil then
-- vint_set_property(chal_icon_img_h, "image", Curr_tracked_challenge.icon_name)
-- vint_set_property(chal_icon_img_h, "visible", true)
-- else
vint_set_property(chal_icon_img_h, "visible", false)
--end
if Curr_tracked_challenge.complete_pct ~= 1 then --if 1 then set it to full
local increment = METER_FULL_PCT/20
for i = 0, METER_FULL_PCT, increment do
if new_width >= i and new_width < (i + increment) then
new_width = i
end
end
end
vint_set_property(chal_meter_clip_h, "clip_size", new_width, chal_meter_height)
else
Challenge_tracker_enabled = false
Curr_tracked_challenge.equipped = false
ui_hud_set_current_challenge(-1)
Curr_tracked_challenge_id = -1
local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE)
vint_set_property(challenges_bar_h, "visible", false)
end
-- HVS_RCK - I hate this, but it seems to be the only way to get this crap to turn off the "equipped" on the previous challenge. Thanks, Lua.
for k, challenge in pairs(Full_challenge_list) do
if challenge.name == Curr_tracked_challenge_id then
challenge.equipped = true
else
challenge.equipped = false
end
end
--local first_category = Cell_missions_challenges_temp[1].category
if Game_platform == "PC" then
Mouse_input_tracker:subscribe(false)
Mouse_input_tracker:remove_all()
end
--Draw missions list
Mission_list:draw_items(Full_challenge_list, Curr_mission_index, MISSION_LIST_WIDTH, MISSION_LIST_MAX_BUTTONS, .7, true, false)
--Update mouse inputs because we've redrawn the list
if Game_platform == "PC" then
Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
--Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
cell_missions_hints_update()
--You can't select anything in the challenges screen
return
end
--If Challenges are selected in quest list update list on left to display challenges
-- if Mission_data[Curr_mission_index].is_challenges == true then
-- Challenges_is_active = true
-- --Update screen title
-- Cell_missions_title_h:set_text("QUEST_LOG_CHALLENGES", 320)
-- --Save off challenges index for when we return
-- Challenges_index = Curr_mission_index
-- --Update challenges and redraw list
-- cell_missions_challenges_update(2, true)
-- if Game_platform == "PC" then
-- Hint_bar_mouse_input_tracker:remove_all()
-- end
-- Hint_bar:set_hints(Challenges_hints_data)
-- if Game_platform == "PC" then
-- Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000)
-- Hint_bar_mouse_input_tracker:subscribe(true)
-- end
-- return
-- end
--If Completed quests are selected in quest list update list on left to display completed quests
if Mission_data[Curr_mission_index].is_completed_quests == true then
Completed_quests_is_active = true
--Save off completed quests index for when we return
Completed_quests_index = Curr_mission_index
cell_missions_update(Completed_quests_data, 1, true)
cell_missions_hints_update()
return
end
local mission_index = Mission_list:get_selection()
cell_missions_nav_swap(Full_challenge_list[mission_index])
end
else
if Objective_list:list_is_playing() == false then
--Are we on an active objective?
local curr_mission = Mission_data[ Curr_mission_index ]
local objective_idx = Objective_list:get_selection()
local curr_objective = Objective_data[objective_idx]
if curr_objective.reward_type == nil and curr_objective.completed ~= true and Completed_quests_is_active ~= true then
--Are we able to start the objective?
if cell_missions_objective_locked_by_contact( curr_objective.name ) == true then
--Homie is unavailable message
dialog_box_message( "MENU_TITLE_NOTICE", "MENU_OBJ_HOMIE_LOCKED_BODY", true, true )
elseif cell_missions_objective_mystery_locked( curr_objective.name ) == true then
--We have the quest unlocked, but not all components. Drained & Tutorials. Do the rally event first.
--Until then, show ???? and "NOT AVAILABLE" for log menu and on selection
dialog_box_message( "MENU_TITLE_NOTICE", "SRG_OBJECTIVE_NOT_AVAILABLE", true, true )
elseif cell_missions_client_objective_locked_by_host_progress( curr_objective.name ) == true then
--Host has not progressed far enough to unlock this gameplay message
dialog_box_message( "MENU_TITLE_NOTICE", "MENU_OBJ_HOST_LOCK_BODY", true, true )
elseif cell_missions_host_should_wait_for_client( curr_objective.name ) == true then
--We're still waiting on the client to join the game
--Too late to add new text, but this existing hud message should be the right thing to reuse
--from the mission trigger use messages
dialog_box_message( "MENU_TITLE_NOTICE", "HUD_WAIT_FOR_PARTNER_TO_JOIN", true, true )
elseif Objective_is_valid == true then
--This flag is determined by checking for active objectives sent by code
--Are we already pinned? If so, don't restart the mission.
if curr_objective.quest_pinned == true then
cell_missions_exit_to_game(true)
return
end
--Pin objective and quest
Current_left_quest.quest_pinned = true
Current_left_quest.objective_data[ objective_idx ].quest_pinned = true
if Current_left_quest.id == challenge_get_challenge_tut_id() then
cell_foreground_update_tutorial("exit_hub")
Challenge_tutorial_pending_clear = true
end
--Hide any quest complete animations playing in the hud
local hud_msg_doc_h = vint_document_find("hud_msg")
if hud_msg_doc_h ~= nil then
hud_msg_quest_hide()
end
--Exit screen
cell_missions_exit_to_game(false)
--Popping the screen before calling additional script seems weird, but according to SEH the function executes fully before the screen is allowed to pop.
--Launch gameplay
vint_scriptevent_post( "set_active_objective", Current_left_quest.objective_data[ objective_idx ].name )
else
--Display a dialog box explaining why we can't start an objective at this time
dialog_box_message("MENU_TITLE_NOTICE", "QUEST_NEW_OBJECTIVE_DENY")
end
end
end
end
end
--Handle events for B button
function cell_missions_nav_b()
if Active_input == INPUT_RIGHT then
--If in objectives list swap back to quests list
if Objective_list:list_is_playing() == false then
cell_missions_nav_swap()
end
else
--If in Challenges, redraw quest list
--HVS_RCK - Challenges IS the new quests menu. Backing out takes us all the way out of quests.
-- if Challenges_is_active == true then
-- Challenges_is_active = false
-- --Set screen title back to "QUESTS"
-- Cell_missions_title_h:set_text("MENU_MISSIONS")
-- cell_missions_update(Mission_data, Challenges_index, true)
-- if Game_platform == "PC" then
-- Hint_bar_mouse_input_tracker:remove_all()
-- Hint_bar:set_hints(Mission_list_hints_data)
-- Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000)
-- Hint_bar_mouse_input_tracker:subscribe(true)
-- else
-- Hint_bar:set_hints(Mission_list_hints_data)
-- end
-- return
-- end
if Completed_quests_is_active == true then
Completed_quests_is_active = false
Hint_bar:set_hints(Mission_list_hints_data)
--Update challenges and redraw list
cell_missions_challenges_update(2, true)
return
end
if not Challenge_tutorial_pending_clear then
cell_foreground_update_tutorial("open_menu")
end
--Exit game
cell_missions_lock_controls()
--Transition the menu in
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_MISSIONS, cell_missions_exit_to_menu)
end
end
-- HVS_TBT 5/19/2014: added missing *_unload function
function cell_missions_unload()
--Play menu back audio
ui_audio_post_event("UI_Hub_Menu_Back")
--Set HUB state to main menu
vint_dataresponder_post("cell_menu_state_dr", "Set", ID_MAIN)
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_MISSIONS, nil)
end
-------------------------------------------------------------------------------
-- Function cell_missions_nav_x()
--
-- If we're in a mission (X) is used to retry/exit the mission.
--
-- If not in a mission, but an objective is active the (X) button is used to
-- clear/unpin pinned that quest and objective.
--
-------------------------------------------------------------------------------
function cell_missions_nav_x()
if Active_input == INPUT_LEFT then
if Mission_list:list_is_playing() == false and Curr_tracked_challenge_id == Full_challenge_list[Curr_mission_index].name then
Challenge_tracker_enabled = false
Curr_tracked_challenge.equipped = false
ui_hud_set_current_challenge(-1)
Curr_tracked_challenge_id = -1
local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE)
vint_set_property(challenges_bar_h, "visible", false)
-- HVS_RCK - I hate this, but it seems to be the only way to get this crap to turn off the "equipped" on the previous challenge. Thanks, Lua.
for k, challenge in pairs(Full_challenge_list) do
if challenge.name == Curr_tracked_challenge_id then
challenge.equipped = true
else
challenge.equipped = false
end
end
--local first_category = Cell_missions_challenges_temp[1].category
if Game_platform == "PC" then
Mouse_input_tracker:subscribe(false)
Mouse_input_tracker:remove_all()
end
--Draw missions list
Mission_list:draw_items(Full_challenge_list, Curr_mission_index, MISSION_LIST_WIDTH, MISSION_LIST_MAX_BUTTONS, .7, true, false)
--Update mouse inputs because we've redrawn the list
if Game_platform == "PC" then
Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
--Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
cell_missions_hints_update()
--You can't select anything in the challenges screen
return
end
elseif Active_input == INPUT_RIGHT then
--We're in a mission, you can't use the A button
if In_mission == true and Objective_is_valid == true then
return
end
local objective_idx = Objective_list:get_selection()
local current_quest = Mission_data[ Curr_mission_index ]
local current_objective = Mission_data[ Curr_mission_index ].objective_data[ objective_idx ]
if current_objective.quest_pinned == true then
--Unpin objective and quest
current_quest.quest_pinned = false
current_objective.quest_pinned = false
--Tell code to clear objective
vint_scriptevent_post( "set_active_objective", "" )
--refresh objective list
cell_missions_objective_update(current_quest.objective_data, objective_idx)
if Game_platform == "PC" then
Mouse_input_tracker:subscribe(false)
Mouse_input_tracker:remove_all()
end
Mission_list:set_highlight_color(COLOR_SAINTS_PURPLE)
--Draw missions list
Mission_list:draw_items(Full_challenge_list, Curr_mission_index, MISSION_LIST_WIDTH, MISSION_LIST_MAX_BUTTONS, .7, true, false)
--Update mouse inputs because we've redrawn the list
if Game_platform == "PC" then
Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
cell_missions_nav_swap()
end
end
end
-- Determines which state we're in and which hints to show
function cell_missions_hints_update(mission_index)
if Game_platform == "PC" then
Hint_bar_mouse_input_tracker:remove_all()
end
if ( Completed_quests_is_active ) then
Hint_bar:set_hints(Completed_quests_hints_data)
elseif Active_input == INPUT_LEFT then
if Mission_list:list_is_playing() == false then
if Curr_tracked_challenge_id == Full_challenge_list[Curr_mission_index].name then
Hint_bar:set_hints(Challenges_hints_data)
else
Hint_bar:set_hints(Mission_list_hints_data)
end
else
Hint_bar:set_hints(Mission_list_hints_data) --Challenges_hints_data
end
else
local mission_idx = Curr_mission_index
if mission_index ~= nil then
mission_idx = mission_index
end
local objective_idx = Objective_list:get_selection()
local current_quest = Mission_data[ mission_idx ]
local current_objective = Mission_data[ mission_idx ].objective_data[ objective_idx ]
if current_objective.quest_pinned == true then
Hint_bar:set_hints(Challenges_hints_data)
else
Hint_bar:set_hints(Mission_list_hints_data)
end
end
if Game_platform == "PC" then
Hint_bar:set_highlight(0)
Hint_bar:add_mouse_inputs("cell_missions", Hint_bar_mouse_input_tracker, 1000)
Hint_bar_mouse_input_tracker:subscribe(true)
end
end
-------------------------------------------------------------------------------
-- Handles navigating the lists
--
function cell_missions_nav_list(event)
--If in a mission return early
if In_mission == true and Objective_is_valid == true then
return
end
--What direction did we move?
local direction = 0
if event == "nav_up" then
direction = -1
elseif event == "nav_down" then
direction = 1
end
if Active_input == INPUT_LEFT then
--Clear the new flag for the quest we moved from
if Challenges_is_active == false and Completed_quests_is_active == false then
local prev_quest = Mission_data[Curr_mission_index]
if prev_quest.is_new == true then
--Remove all inputs before drawing the list...
if Game_platform == "PC" then
Mouse_input_tracker:remove_all()
end
--Remove new flag from the list and post it to the game.
Mission_list:remove_new_flag(Curr_mission_index)
vint_scriptevent_post("quest_log_clear_new", "quest", prev_quest.id)
prev_quest.is_new = false
--Update mouse inputs because we've redrawn the list
if Game_platform == "PC" then
Mission_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
--Objective_list:add_mouse_inputs("cell_missions", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
end
if direction ~= 0 or Mission_list.data[Curr_mission_index].disabled == true or event == "mouse_move" or just_swapped == true then
--Move cursor for quests list
Mission_list:move_cursor(direction)
--Get new index
Curr_mission_index = Mission_list:get_selection()
end
just_swapped = false
if Completed_quests_is_active == true then
--Update list to completed quests
cell_missions_update(Completed_quests_data, Curr_mission_index, false)
elseif Challenges_is_active == true then
--Update list to challenges
cell_missions_challenges_update(Curr_mission_index, false)
else
--Update mission details
cell_missions_update(Mission_data, Curr_mission_index, false)
end
else
local orig_idx = Objective_list:get_selection()
local orig_objective = Current_left_quest.objective_data[orig_idx]
--HVS_RCK[KING] 8/29/14 - If we're on a disabled objective, we don't have one available. Don't allow us to scroll.
if not orig_objective.disabled then
--Move the objective list cursor
Objective_list:move_cursor(direction)
local objective_idx = Objective_list:get_selection()
--Determine which data to use - complete quests or mission data
local current_quest
if Completed_quests_is_active == true then
current_quest = Completed_quests_data[Curr_mission_index]
else
current_quest = Mission_data[Curr_mission_index]
end
local current_objective = Current_left_quest.objective_data[objective_idx]
--Make sure we're not a reward and the id is valid - if so, clear the "new" flag
if current_objective.reward_type ~= 1 and current_objective.id ~= nil and current_objective.is_new == true then
Objective_list:remove_new_flag(objective_idx)
vint_scriptevent_post("quest_log_clear_new", "objective", current_objective.id)
end
--Get new index
Curr_objective_index = Objective_list:get_selection()
--Update objectives
cell_missions_objective_update(Current_left_quest.objective_data, Curr_objective_index)
end
end
cell_missions_hints_update()
end
function cell_missions_scroll_left(event)
--What direction did we move?
local direction = 0
if event == "alt_joy_up" then
direction = -1
elseif event == "alt_joy_down" then
direction = 1
end
--scroll lines are inverted for some reason
local scroll_lines = direction
if Active_input == INPUT_LEFT and Mission_list:list_is_playing() == false then
if scroll_lines ~= 0 then
Mission_list:scroll_list(scroll_lines)
if game_get_platform() == "PC" then
Mission_list:update_mouse_inputs("cell_missions", Mouse_input_tracker, 50)
end
--Get the new selection index
Curr_mission_index = Mission_list:get_selection()
--Update both lists with new data
cell_missions_nav_list()
end
end
if Active_input == INPUT_RIGHT and Objective_list:list_is_playing() == false then
if scroll_lines ~= 0 then
Objective_list:scroll_list(scroll_lines)
if game_get_platform() == "PC" then
Objective_list:update_mouse_inputs("cell_missions", Mouse_input_tracker, 50)
end
--Get the new selection index
--Curr_objective_index = Objective_list:get_selection()
--Update both lists with new data
cell_missions_nav_list()
end
end
end
--Handle input for moving left
function cell_missions_nav_left()
if Active_input == INPUT_RIGHT then
cell_missions_nav_swap()
end
end
--Handle input for moving right
function cell_missions_nav_right()
if Active_input == INPUT_LEFT then
if Challenges_is_active == false and Mission_data[Curr_mission_index].is_challenges ~= true and Mission_data[Curr_mission_index].is_completed_quests ~= true and Completed_quests_is_active == false then
cell_missions_nav_swap()
end
end
end
--Used as empty callback
function cell_missions_nav_do_nothing()
end
--------------------------------------------------------------------------------------
-- PC INPUTS
--------------------------------------------------------------------------------------
function cell_missions_mouse_move(event, target_handle)
if Mission_list:list_is_playing() == false then
--Select mission
local new_index = Mission_list:get_button_index(target_handle)
if new_index ~= 0 then
if Active_input == INPUT_LEFT then
--Update list highlight
Mission_list:set_selection(new_index)
--Update both lists with new data
cell_missions_nav_list("mouse_move")
end
end
end
if Objective_list:list_is_playing() == false then
--Select Objective
local new_index = Objective_list:get_button_index(target_handle)
if new_index ~= 0 then
if Active_input == INPUT_RIGHT then
--Update list highlight
Objective_list:set_selection(new_index)
--Update both lists with new data
cell_missions_nav_list("mouse_move")
end
end
end
--Reset hints every move
Hint_bar:set_highlight(0)
--Handle selecting hints
local hint_index = Hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
Hint_bar:set_highlight(1, COLOR_SAINTS_PURPLE)
elseif hint_index == 2 then
Hint_bar:set_highlight(2, COLOR_SAINTS_PURPLE)
elseif hint_index == 3 then
Hint_bar:set_highlight(3, COLOR_SAINTS_PURPLE)
end
end
function cell_missions_mouse_click(event, target_handle, mouse_x, mouse_y)
--If active input is on the right and we want to navigate to the left.
if Active_input == INPUT_RIGHT and Mission_list:list_is_playing() == false then
--Find which button is selected and check if it's valid.
local new_index = Mission_list:get_button_index(target_handle)
if new_index ~= 0 then
--Swap nav to the left side...
cell_missions_nav_swap()
--Update list highlight
Mission_list:set_selection(new_index)
--Update the list
Mission_list:move_cursor(0, true)
--Update both lists with new data
cell_missions_nav_list()
--Do not process the click as a button press and return
return
end
end
--If active input is on the left and we want to navigate to the right.
if Active_input == INPUT_LEFT and Objective_list:list_is_playing() == false and Challenges_is_active == false and Completed_quests_is_active == false and Mission_data[Curr_mission_index].is_challenges == false and Mission_data[Curr_mission_index].is_completed_quests == false then
--Find which button is selected and check if it's valid.
local new_index = Objective_list:get_button_index(target_handle)
if new_index ~= 0 then
--Swap nav to the right side...
cell_missions_nav_swap()
--Update list highlight
Objective_list:set_selection(new_index)
--Update the list
Objective_list:move_cursor(0, true)
--Do not process the click as a button press and return
return
end
end
local focus_change = false
--If left has focus and we clicked a button
if Active_input == INPUT_LEFT and Mission_list:list_is_playing() == false then
--Find which button is selected and check if its valid.
local new_index = Mission_list:get_button_index(target_handle)
if new_index ~= 0 then
--Update list highlight
Mission_list:set_selection(new_index)
--Update the list
Mission_list:move_cursor(0, true)
--Process the input
cell_missions_nav_a()
end
new_index = Objective_list:get_button_index(target_handle)
if new_index ~= 0 then
--Process the input
cell_missions_nav_a()
focus_change = true
end
end
--If right has focus and we clicked a button
if Active_input == INPUT_RIGHT and Objective_list:list_is_playing() == false and focus_change == false then
--Find which button is selected and check if its valid.
local new_index = Objective_list:get_button_index(target_handle)
if new_index ~= 0 then
--Update list highlight
Objective_list:set_selection(new_index)
--Update the list
Objective_list:move_cursor(0, true)
--Process the input
cell_missions_nav_a()
end
end
--Update hints
local hint_index = Hint_bar:get_hint_index(target_handle)
if In_mission then
if hint_index == 1 then
cell_missions_nav_b()
elseif hint_index == 2 then
cell_missions_nav_x()
end
return
end
if hint_index ~= nil then
if hint_index == 1 then
cell_missions_nav_b()
elseif hint_index == 2 then
cell_missions_nav_a()
elseif hint_index == 3 then
cell_missions_nav_x()
end
end
end
function cell_missions_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines)
--scroll lines are inverted for some reason
scroll_lines = scroll_lines * -1
if Active_input == INPUT_LEFT and Mission_list:list_is_playing() == false then
if scroll_lines ~= 0 then
Mission_list:scroll_list(scroll_lines)
Mission_list:update_mouse_inputs("cell_missions", Mouse_input_tracker, 50)
--Get the new selection index
Curr_mission_index = Mission_list:get_selection()
--Update both lists with new data
cell_missions_nav_list()
end
end
if Active_input == INPUT_RIGHT and Objective_list:list_is_playing() == false then
if scroll_lines ~= 0 then
Objective_list:scroll_list(scroll_lines)
Objective_list:update_mouse_inputs("cell_missions", Mouse_input_tracker, 50)
--Get the new selection index
--Curr_objective_index = Objective_list:get_selection()
--Update both lists with new data
cell_missions_nav_list()
end
end
end
function cell_missions_mouse_drag(event, target_handle, mouse_x, mouse_y, scroll_lines)
--Max items is number of buttons in the list minus the max buttons that can be displayed.
if Active_input == INPUT_LEFT and Mission_list:list_is_playing() == false then
local scrollbar = Mission_list.scrollbar
if scrollbar.tab_grp.handle == target_handle then
local max_items = Mission_list.num_buttons - (Mission_list.max_buttons - 1)
--Get new start index from scroll tab
local new_start_index = scrollbar:drag_scrolltab(mouse_y, max_items)
--Scroll Mission list
Mission_list:scroll_list(0, new_start_index)
end
end
if Active_input == INPUT_RIGHT and Objective_list:list_is_playing() == false then
local scrollbar = Objective_list.scrollbar
if scrollbar.tab_grp.handle == target_handle then
local max_items = Objective_list.num_buttons - (Objective_list.max_buttons - 1)
--Get new start index from scroll tab
local new_start_index = scrollbar:drag_scrolltab(mouse_y, max_items)
--Scroll Mission list
Objective_list:scroll_list(0, new_start_index)
end
end
end
function cell_missions_mouse_drag_release(event, target_handle, mouse_x, mouse_y)
if Active_input == INPUT_LEFT and Mission_list:list_is_playing() == false then
local scrollbar = Mission_list.scrollbar
if scrollbar.tab_grp.handle == target_handle then
local start_index, end_index = Mission_list:get_visible_indices()
--Max items is number of buttons in the list minus the max buttons that can be displayed.
local max_items = Mission_list.num_buttons - (Mission_list.max_buttons - 1)
--Set scrolltab position...
scrollbar:release_scrolltab(start_index, max_items)
Mission_list:update_mouse_inputs("cell_missions", Mouse_input_tracker, 50)
end
end
if Active_input == INPUT_RIGHT and Objective_list:list_is_playing() == false then
local scrollbar = Objective_list.scrollbar
if scrollbar.tab_grp.handle == target_handle then
local start_index, end_index = Objective_list:get_visible_indices()
--Max items is number of buttons in the list minus the max buttons that can be displayed.
local max_items = Objective_list.num_buttons - (Objective_list.max_buttons - 1)
vint_debug_print("start_index", start_index)
--Set scrolltab position...
scrollbar:release_scrolltab(start_index, max_items)
vint_debug_print("Objective_list current selection", Objective_list:get_selection())
--Objective_list:update_mouse_inputs("cell_missions", Mouse_input_tracker, 50)
end
end
end
-- C is telling you to get out now
function cell_mission_force_exit()
cell_missions_nav_b()
end
--------------------------------------------------------------------------------------
-- END PC INPUTS
--------------------------------------------------------------------------------------