Team_assign_doc_handle = -1
local BEN = 1
local SHAUNDI_2 = 2
local SHAUNDI_3 = 3
local PIERCE = 4
local LIN = 5
local DISTRACTION = 1
local INFILTRATION = 2
local COMMANDER = 3
local COMBAT = 4
local Input_tracker
local Hint_bar = -1
local Character_grp_h = -1
local Character_bio_h = -1
local Character_name_h = -1
local Head_h = -1
local Character_bg_h = -1
local Mission_grp_h = -1
local Mission_bio_h = -1
local Mission_name_h = -1
local Mission_bg_h = -1
local Character_bounce_anim_h = -1
local CHARACTER_DATA = {
[BEN] = {head = "ui_homie_35_ben", name = "M22_2_TEAM_BEN_NAME", bio = "M22_2_TEAM_BEN_BIO"}, --SR1 Ben King
[SHAUNDI_2] = {head = "ui_homie_35_shaundi", name = "M22_2_TEAM_SHAUNDI_2_NAME", bio = "M22_2_TEAM_SHAUNDI_2_BIO"}, --SR2 Shaundi
[SHAUNDI_3] = {head = "ui_homie_shaundi", name = "M22_2_TEAM_SHAUNDI_3_NAME", bio = "M22_2_TEAM_SHAUNDI_3_BIO"}, --SR3 Shaundi
[PIERCE] = {head = "ui_homie_pierce", name = "M22_2_TEAM_PIERCE_NAME", bio = "M22_2_TEAM_PIERCE_BIO"}, --SR3 Pierce
[LIN] = {head = "ui_homie_35_lin", name = "M22_2_TEAM_LIN_NAME", bio = "M22_2_TEAM_LIN_BIO"}, --SR1 Lin
}
local MISSION_DATA = {
[DISTRACTION] = {name = "M22_2_TEAM_DISTRACTION_NAME", bio = "M22_2_TEAM_DISTRACTION_BIO"},
[INFILTRATION] = {name = "M22_2_TEAM_INFILTRATION_NAME", bio = "M22_2_TEAM_INFILTRATION_BIO"},
[COMMANDER] = {name = "M22_2_TEAM_COMMANDER_NAME", bio = "M22_2_TEAM_COMMANDER_BIO"},
[COMBAT] = {name = "M22_2_TEAM_COMBAT_NAME", bio = "M22_2_TEAM_COMBAT_BIO"},
}
function team_assign_init()
Team_assign_doc_handle = vint_document_find("team_assign")
vint_dataitem_add_subscription("team_assign_update", "update", "team_assign_update")
Character_grp_h = vint_object_find("character_grp", 0, Team_assign_doc_handle)
Character_bio_h = vint_object_find("character_bio", 0, Team_assign_doc_handle)
Character_name_h = vint_object_find("character_name", 0, Team_assign_doc_handle)
Head_h = vint_object_find("head", 0, Team_assign_doc_handle)
Character_bg_h = vint_object_find("character_bg", 0, Team_assign_doc_handle)
Mission_grp_h = vint_object_find("mission_grp", 0, Team_assign_doc_handle)
Mission_bio_h = vint_object_find("mission_bio", 0, Team_assign_doc_handle)
Mission_name_h = vint_object_find("mission_name", 0, Team_assign_doc_handle)
Mission_bg_h = vint_object_find("mission_bg", 0, Team_assign_doc_handle)
Character_bounce_anim_h = vint_object_find("character_bounce_anim")
lua_play_anim(Character_bounce_anim_h)
--hide character box
vint_set_property(Character_grp_h, "visible", false)
--hide mission box
vint_set_property(Mission_grp_h, "visible", false)
end
function team_assign_resize_text_element(element_h, max_width)
vint_set_property(element_h, "scale", 1, 1)
local text_width, text_height = element_get_actual_size(element_h)
debug_print("vint", "text_width: " .. text_width .. "\n")
if text_width > max_width then
local text_scale = max_width/text_width
debug_print("vint", "max width: " .. max_width .. "\n")
vint_set_property(element_h, "scale", text_scale, text_scale)
end
end
function team_assign_update(di_h)
local character, is_visible, mission = vint_dataitem_get(di_h)
--[[is_visible = true
character = 1
mission = 1]]
--Populate with data
if (mission > 0) then
vint_set_property(Mission_name_h, "text_tag", MISSION_DATA[mission].name)
--acount for long text
team_assign_resize_text_element(Mission_name_h, 297)
vint_set_property(Mission_bio_h, "text_tag", MISSION_DATA[mission].bio)
--show mission box
vint_set_property(Mission_grp_h, "visible", true)
else
--hide the mission box
vint_set_property(Mission_grp_h, "visible", false)
end
--arrange mission box
local mission_bg_width, mission_bg_height = element_get_actual_size(Mission_bg_h)
local mission_bio_width, mission_bio_height = element_get_actual_size(Mission_bio_h)
local mission_bg_new_height = mission_bio_height + 69
element_set_actual_size(Mission_bg_h, mission_bg_width, mission_bg_new_height)
if is_visible == true then
--Arrange character box to be below mission box
local character_grp_x, character_grp_y = vint_get_property(Character_grp_h, "anchor")
local mission_grp_x, mission_grp_y = vint_get_property(Mission_grp_h, "anchor")
local character_grp_new_y = mission_bg_new_height + mission_grp_y + 25 --25 is padding
vint_set_property(Character_grp_h, "anchor", character_grp_x, character_grp_new_y)
--Populate with data
vint_set_property(Head_h, "image", CHARACTER_DATA[character].head)
vint_set_property(Character_name_h, "text_tag", CHARACTER_DATA[character].name)
vint_set_property(Character_bio_h, "text_tag", CHARACTER_DATA[character].bio)
local insert_values = {[0] = CHARACTER_DATA[character].name}
local confirm_string = vint_insert_values_in_string("M22_2_TEAM_CONFIRM", insert_values)
local hint_data = {
{CTRL_BUTTON_Y, confirm_string},
}
Hint_bar = Vdo_hint_bar:new("hint_bar")
Hint_bar:set_hints(hint_data)
--Arrange character elements
local character_bg_width, character_bg_height = element_get_actual_size(Character_bg_h)
local character_bio_width, character_bio_height = element_get_actual_size(Character_bio_h)
local hint_bar_x, hint_bar_y = Hint_bar:get_property("anchor")
local hint_bar_new_y = 110 + character_bio_height --110 is the space from the top of the bio to the top of the box
Hint_bar:set_property("anchor",hint_bar_x,hint_bar_new_y)
local character_bg_new_height = hint_bar_new_y + 26
element_set_actual_size(Character_bg_h, character_bg_width, character_bg_new_height)
--show character box
vint_set_property(Character_grp_h, "visible", true)
else
--hide character box
vint_set_property(Character_grp_h, "visible", false)
end
end
function team_assign_cleanup()
end