local HUD_COLLECTION_FLASHPOINT = 0
local HUD_COLLECTION_HOTSPOT = 1
local HUD_COLLECTION_ALTER = 2
local HUD_COLLECTION_COMMENTARY = 3
local HUD_COLLECTION_EXTRACTION = 4
local HUD_COLLECTION_COLLECTIBLE_GENERIC = 5
local HUD_COLLECTION_HITMAN = 6
local HUD_COLLECTION_CHOP_SHOP = 7
local HUD_COLLECTION_REVENGE = 8
local HUD_COLLECTION_STUNT_JUMP = 9
local HUD_COLLECTION_BARNSTORMING = 10
local HUD_COLLECTION_SURVIVAL = 11
local HUD_COLLECTION_SECRET = 12
local HUD_COLLECTION_STAG = 13
local HUD_COLLECTION_COLLECTIBLE_ORB = 14
local HUD_COLLECTION_ACTIVITY_TIER_BRONZE = 15
local HUD_COLLECTION_ACTIVITY_TIER_SILVER = 16
local HUD_COLLECTION_ACTIVITY_TIER_GOLD = 17
local HUD_COLLECTION_UNLOCKABLE = 18
local HUD_COLLECTION_MISC_OBJECTIVE = 19
local HUD_COLLECTION_QUEST = 20
local HUD_COLLECTION_SILVERLINK = 21
local HUD_COLLECTION_SEVEN_DEADLY_SINS = 22
local STATS_INVALID = -1
local DT_NONE = -1
local DT_CHOP_SHOP = 1
local DT_BARNSTORMING = 4
local DT_EXPLORATION = 3
local DT_FLASHPOINT = 7
local DT_HOTSPOT = 8
local DT_EXTRACTION = 9
local DT_HITMAN = 13
local DT_SURVIVAL = 19
local DT_REVENGE = 16
local DT_ALTAR = 4
local DT_COMMENTARY = 5
local Hud_collection_types = {
[HUD_COLLECTION_FLASHPOINT] = {
audio = "ui_hud_gang_flash_complete",
d_type = DT_FLASHPOINT,
},
[HUD_COLLECTION_HOTSPOT] = {
audio = "ui_hud_generic_div_complete",
d_type = DT_HOTSPOT,
},
[HUD_COLLECTION_ALTER] = {
audio = "ui_hud_generic_div_complete",
d_type = DT_ALTAR,
},
[HUD_COLLECTION_COMMENTARY] = {
audio = "ui_hud_generic_div_complete",
d_type = DT_COMMENTARY,
},
[HUD_COLLECTION_EXTRACTION] = {
audio = "ui_hud_generic_div_complete",
d_type = DT_EXTRACTION,
},
[HUD_COLLECTION_COLLECTIBLE_GENERIC] = {
audio = "ui_hud_generic_div_complete",
d_type = DT_NONE,
},
[HUD_COLLECTION_HITMAN] = {
audio = "ui_hud_hitman_complete",
d_type = DT_HITMAN,
},
[HUD_COLLECTION_CHOP_SHOP] = {
audio = "ui_hud_chop_shop_complete",
d_type = DT_CHOP_SHOP,
},
[HUD_COLLECTION_REVENGE] = {
audio = "ui_hud_revenge_complete",
d_type = DT_REVENGE,
},
[HUD_COLLECTION_STUNT_JUMP] = {
d_type = DT_NONE,
},
[HUD_COLLECTION_BARNSTORMING] = {
d_type = DT_BARNSTORMING,
},
[HUD_COLLECTION_SURVIVAL] = {
audio = "ui_hud_survival_complete",
d_type = DT_SURVIVAL,
},
[HUD_COLLECTION_SECRET] = {
d_type = DT_EXPLORATION,
},
[HUD_COLLECTION_STAG] = {
audio = "ui_hud_generic_div_complete",
d_type = DT_NONE,
},
[HUD_COLLECTION_COLLECTIBLE_ORB] = {
audio = "ui_hud_generic_div_complete",
d_type = DT_NONE,
},
[HUD_COLLECTION_ACTIVITY_TIER_BRONZE] = {
audio = "UI_Activity_Complete_Bronze",
d_type = DT_NONE,
},
[HUD_COLLECTION_ACTIVITY_TIER_SILVER] = {
audio = "UI_Activity_Complete_Silver",
d_type = DT_NONE,
},
[HUD_COLLECTION_ACTIVITY_TIER_GOLD] = {
audio = "UI_Activity_Complete_Gold",
d_type = DT_NONE,
},
[HUD_COLLECTION_UNLOCKABLE] = {
audio = "ui_hud_generic_div_complete",
d_type = DT_NONE,
},
[HUD_COLLECTION_MISC_OBJECTIVE] = {
audio = "ui_hud_generic_div_complete",
d_type = DT_NONE,
},
[HUD_COLLECTION_QUEST] = {
audio = "ui_hud_generic_div_complete",
d_type = DT_NONE,
},
[HUD_COLLECTION_SILVERLINK] = {
audio = "ui_hud_generic_div_complete",
d_type = DT_NONE,
},
[HUD_COLLECTION_SEVEN_DEADLY_SINS] = {
audio = "ui_hud_generic_div_complete",
d_type = DT_NONE,
},
}
local Hud_collection_anims = {}
local Hud_collection_data = {}
Hud_collection_is_active = false
local Current_collection_index = 0
local Num_collection_data = 0
local Queued_collection_data = { }
local Hud_collection_control_meter = 0 --Control meter object...
local Hud_collection_respect_meter = 0 --Respect meter object...
local Hud_collection_cash_h = 0 --Cash Display...
local Hud_collection_bonus_grp_h = 0 --Bonus Display...
local Hud_collection_bonus_txt_h = 0 --Bonus text...
local Hud_collection_bonus_bmp_h = 0 --Bonus bitmap
local Collection_title_grp_h
local Title_x, Title_y
local HUD_COLLECTION_ICON_WIDTH = 64
local HUD_COLLECTION_CONTROL_WIDTH = 84
local HUD_COLLECTION_RESPECT_WIDTH = 84
local HUD_COLLECTION_BONUS_WIDTH = 80
local HUD_COLLECTION_MAX_WIDTH = 818
local HUD_COLLECTION_HEADER_MAX_WIDTH = 495
local HUD_COLLECTION_ICON_DEFAULT_X = 27
local HUD_COLLECTION_ICON_DEFAULT_Y = 109
local HUD_COLLECTION_TITLE_DEFAULT_X = 63
local HUD_COLLECTION_TITLE_DEFAULT_Y = 100
local HUD_COLLECTION_ICON_TIER_X = 50
local HUD_COLLECTION_TITLE_TIER_X = 120
local HUD_COLLECTION_TIER_WIDTH = 405
-------------------------------------------------------------------------------
-- This is included with hud.vint_doc
-------------------------------------------------------------------------------
function hud_collection_init()
vint_dataitem_add_subscription("game_paused_item", "update", "hud_collection_game_is_paused") --to check if game is paused...
local h = vint_object_find("collection_grp")
vint_set_property(h, "visible", false)
--Animations stored to globals
Hud_collection_anims.in_anim_h = vint_object_find("collection_in_anim")
Hud_collection_anims.in_deadly_h = vint_object_find("collection_in_deadly")
Hud_collection_anims.district_anim_h = vint_object_find("collection_district_anim")
Hud_collection_anims.respect_anim_h = vint_object_find("collection_respect_anim")
Hud_collection_anims.bonus_anim_h = vint_object_find("collection_bonus_anim")
Hud_collection_anims.cash_anim_h = vint_object_find("collection_cash_anim")
Hud_collection_anims.complete_anim_h = vint_object_find("collection_complete_anim")
Hud_collection_anims.complete_deadly_h = vint_object_find("collection_complete_deadly")
-- Setup callbacks to tweens....
local control_twn_h = vint_object_find("collection_control_twn")
local respect_twn_h = vint_object_find("collection_respect_twn")
local cash_twn_h = vint_object_find("collection_cash_twn")
local collection_start_fade_out_twn_h = vint_object_find("cbg_start_event_twn")
local collection_end_fade_out_twn_h = vint_object_find("cbg_end_event_twn")
local collection_meter_in_twn_h = vint_object_find("collection_meter_in_twn")
vint_set_property(control_twn_h, "end_event", "hud_collection_start_control")
vint_set_property(respect_twn_h, "start_event", "hud_collection_show_respect")
vint_set_property(respect_twn_h, "end_event", "hud_collection_start_respect")
vint_set_property(cash_twn_h, "start_event", "hud_collection_start_cash")
vint_set_property(collection_start_fade_out_twn_h, "start_event", "hud_collection_audio_out") --audio play out...
vint_set_property(collection_end_fade_out_twn_h, "end_event", "hud_collection_finished")
vint_set_property(collection_meter_in_twn_h, "end_event", "hud_collection_animate_meter")
--Initialize control meter.
Hud_collection_control_meter = Vdo_city_control:new("collection_control_meter")
--Initialize respect meter.
Hud_collection_respect_meter = Vdo_city_control:new("collection_respect_meter")
Hud_collection_respect_meter:change_to_respect()
Hud_collection_cash_h = vint_object_find("collection_cash_txt")
Hud_collection_bonus_grp_h = vint_object_find("collection_bonus_group")
Hud_collection_bonus_txt_h = vint_object_find("collection_bonus_text")
Hud_collection_bonus_bmp_h = vint_object_find("collection_bonus_image")
Collection_title_grp_h = vint_object_find("collection_title_grp")
Title_x, Title_y = vint_get_property(Collection_title_grp_h, "anchor")
end
-------------------------------------------------------------
-- Fills in the data object for populating the screen...
-------------------------------------------------------------
-- VINT_PROP_TYPE_INT, // Collection type
-- VINT_PROP_TYPE_UINT, // Title of the Collection message ("Gang Operation", "Hitman", "Chopshop")
-- VINT_PROP_TYPE_UINT, // Subtitle (Destroyed, Completed, Found)
-- VINT_PROP_TYPE_INT, // How many items the player has left in district or game
-- VINT_PROP_TYPE_INT, // Total items in district or game
--
-- // if the following are nil then we omit their display...
-- VINT_PROP_TYPE_FLOAT, // Cash Reward
-- VINT_PROP_TYPE_INT, // Respect Reward
-- VINT_PROP_TYPE_INT, // Respect Bonus - for display purposes only - do not send back to game_award_respect
-- VINT_PROP_TYPE_FLOAT, // District percentage before...
-- VINT_PROP_TYPE_FLOAT, // District percentage after...
-- VINT_PROP_TYPE_STRING, // DISTRICT name
-- VINT_PROP_TYPE_BOOL, // Whether the rewards should be saved on mission failure/restart
-- VINT_PROP_TYPE_BOOL, // whether to award cash / respect
function hud_collection_update(collection_type, title, sub_title, items_left, items_total, cash_reward, respect_reward, respect_bonus, district_pct_old, district_pct_new, district_name, save_in_mission, no_reward, bonus_reward, bonus_text, bonus_image)
--determine what kind of collection type we are and do some shit based on that...
local collection_type = collection_type
if title == 0 then
--No data... Abort Collection screen.
return
end
local gained_pct = district_pct_new - district_pct_old
--Queue up any data into memory...
Queued_collection_data[Num_collection_data] = {
collection_type = collection_type,
title = title,
sub_title = sub_title,
items_left = items_left,
items_total = items_total,
cash_reward = cash_reward,
respect_reward = respect_reward,
respect_bonus = respect_bonus,
district_pct_old = district_pct_old,
district_pct_new = district_pct_new,
district_name = district_name,
save_in_mission = save_in_mission,
no_reward = no_reward,
bonus_reward = bonus_reward, --number, send 0 or nil for no reward
bonus_text = bonus_text, --text to display of bonus amount, x5 or +2
bonus_image = bonus_image, -- image to display either a homie head or the fluer
}
Num_collection_data = Num_collection_data + 1
if Num_collection_data == 1 then
hud_collection_start()
end
-- skip the current orb banner if this is an orb banner
if collection_type == HUD_COLLECTION_COLLECTIBLE_ORB then
local current_displayed = Queued_collection_data[ Current_collection_index ]
if current_displayed ~= nil and current_displayed.collection_type == HUD_COLLECTION_COLLECTIBLE_ORB then
hud_collection_finished()
return
end
end
end
function hud_collection_start()
Hud_collection_is_active = true
Hud_collection_data = Queued_collection_data[Current_collection_index]
Current_collection_index = Current_collection_index + 1
--Determine what rewards to display...
Hud_collection_data.has_district = true
Hud_collection_data.has_respect = true
Hud_collection_data.has_cash = true
Hud_collection_data.has_bonus = true
if Hud_collection_data.district_pct_old == Hud_collection_data.district_pct_new then
--No district
Hud_collection_data.has_district = false
end
if Hud_collection_data.respect_reward == 0 then
--No cash reward...
Hud_collection_data.has_respect = false
end
if Hud_collection_data.cash_reward == 0 then
--No cash reward...
Hud_collection_data.has_cash = false
end
if Hud_collection_data.bonus_reward == 0 or Hud_collection_data.bonus_reward == nil then
--No bonus reward...
Hud_collection_data.has_bonus = false
end
--award the stuff for real...
if Hud_collection_data.has_respect and Hud_collection_data.no_reward ~= true then
game_award_respect(Hud_collection_data.respect_reward, STATS_INVALID, Hud_collection_types[Hud_collection_data.collection_type].d_type, Hud_collection_data.save_in_mission)
end
if Hud_collection_data.has_cash and Hud_collection_data.no_reward ~= true then
game_award_cash(Hud_collection_data.cash_reward, Hud_collection_types[Hud_collection_data.collection_type].d_type, Hud_collection_data.save_in_mission)
end
--All reward elements start out hidden...
Hud_collection_control_meter:set_alpha( 0 )
Hud_collection_respect_meter:set_alpha( 0 )
vint_set_property( Hud_collection_cash_h, "alpha", 0 )
vint_set_property( Hud_collection_bonus_grp_h, "alpha", 0 )
--pause any animations that might be playing from the last collection
vint_set_property(Hud_collection_anims.district_anim_h, "is_paused", true)
vint_set_property(Hud_collection_anims.respect_anim_h, "is_paused", true)
vint_set_property(Hud_collection_anims.bonus_anim_h, "is_paused", true)
vint_set_property(Hud_collection_anims.cash_anim_h, "is_paused", true)
--set the icon
local collect_icon_h = vint_object_find( "collect_icon" )
if Hud_collection_data.collection_type == HUD_COLLECTION_COLLECTIBLE_ORB then
vint_set_property( collect_icon_h, "image", "ui_hud_unlock_orb" )
elseif Hud_collection_data.collection_type == HUD_COLLECTION_SILVERLINK then
vint_set_property( collect_icon_h, "image", "ui_mainmenu_silverlink" )
elseif Hud_collection_data.collection_type == HUD_COLLECTION_COMMENTARY and Hud_collection_data.bonus_image ~= "" and Hud_collection_data.bonus_image ~= nil then
vint_set_property( collect_icon_h, "image", Hud_collection_data.bonus_image)
else
vint_set_property( collect_icon_h, "image", "ui_hud_collect_saints" )
end
--Initialize Control meter...
Hud_collection_control_meter:update(Hud_collection_data.district_pct_old, false)
--Do update of text items...
local header_txt_h = vint_object_find( "collection_header_txt" )
local insert_values = { [0] = Hud_collection_data.title, [1] = Hud_collection_data.items_left, [2] = Hud_collection_data.items_total}
local text_string
if Hud_collection_data.collection_type == HUD_COLLECTION_STAG then
text_string = Hud_collection_data.title
elseif Hud_collection_data.collection_type == HUD_COLLECTION_REVENGE then
if Hud_collection_data.items_total <= 0 then
text_string = vint_insert_values_in_string("{0} {1}", insert_values)
else
text_string = vint_insert_values_in_string("{0} {1}/{2}", insert_values)
end
elseif Hud_collection_data.items_total <= 0 then
text_string = Hud_collection_data.title
elseif Hud_collection_data.collection_type == HUD_COLLECTION_COLLECTIBLE_ORB then
text_string = Hud_collection_data.title
elseif Hud_collection_data.collection_type == HUD_COLLECTION_HITMAN then
text_string = Hud_collection_data.title
elseif Hud_collection_data.collection_type == HUD_COLLECTION_CHOP_SHOP then
text_string = Hud_collection_data.title
else
text_string = vint_insert_values_in_string("{0} {1}/{2}", insert_values)
end
vint_set_property(header_txt_h, "text_tag", text_string)
local sub_txt_h = vint_object_find( "collection_sub_txt" )
vint_set_property(sub_txt_h, "text_tag", Hud_collection_data.sub_title)
vint_set_property( sub_txt_h, "visible", true )
--center large text vertically in no small text
if text_string == "" or text_string == nil then
vint_set_property( sub_txt_h, "anchor", 0, -6)
else
vint_set_property( sub_txt_h, "anchor", 0, 6)
end
--Set cash total...
vint_set_property(Hud_collection_cash_h, "text_tag", "{GAME_CASH}" .. format_cash(Hud_collection_data.cash_reward))
--set the bonus group
vint_set_property(Hud_collection_bonus_txt_h, "text_tag", Hud_collection_data.bonus_text)
vint_set_property(Hud_collection_bonus_bmp_h, "image", Hud_collection_data.bonus_image)
--calculate widths of headers and cash
local header_width, header_height = element_get_actual_size( header_txt_h )
local header_sub_width, header_sub_height = element_get_actual_size( sub_txt_h )
--set up collection meter
local meter_grp_h = vint_object_find( "collection_meter_grp" )
local meter_h = vint_object_find( "collection_meter" )
local meter_twn_h = vint_object_find( "collection_meter_twn" )
local meter_max = 200
vint_set_property( meter_grp_h, "visible", false )
--Need to scale but by how much?
local new_header_width = max( header_width, header_sub_width )
local scale = 1.0
local max_width = HUD_COLLECTION_HEADER_MAX_WIDTH
if header_width > header_sub_width then
if header_width > max_width then
scale = max_width / header_width
new_header_width = header_width * scale
end
else
if header_sub_width > max_width then
scale = max_width / header_sub_width
new_header_width = header_sub_width * scale
end
end
--Apply scale to whole text group...
vint_set_property(Collection_title_grp_h, "scale", scale, scale)
local pos_y = 102 --Start position for reward elements...
local start_time = 1.5 --start offset for first reward...
local start_time_spacing = 1.2 --Time between rewards..
local header_width_min = 0 -- min size of element
local HUD_COLLECTION_TEXT_SPACING = 15
--positions
local x, y = Hud_collection_control_meter:get_anchor()
x = Title_x + new_header_width + HUD_COLLECTION_TEXT_SPACING
--Positions for elements...
local control_x = 0
local respect_x = 0
local bonus_x = 0
local cash_x = 0
--Start times for elements...
local control_start_time = 0
local respect_start_time = 0
local bonus_start_time = 0
local cash_start_time = 0
local complete_start_time = 0
local HUD_COLLECTION_ITEM_SPACING = 10
--Determine what we have and then calculate each item based on that...
if Hud_collection_data.has_district then
local half_width = (HUD_COLLECTION_CONTROL_WIDTH *.5)
control_x = x + half_width
x = x + HUD_COLLECTION_CONTROL_WIDTH + HUD_COLLECTION_ITEM_SPACING
control_start_time = start_time
start_time = start_time + start_time_spacing
end
if Hud_collection_data.has_respect then
local half_width = (HUD_COLLECTION_RESPECT_WIDTH *.5)
respect_x = x + half_width
x = x + HUD_COLLECTION_RESPECT_WIDTH + HUD_COLLECTION_ITEM_SPACING
respect_start_time = start_time
start_time = start_time + start_time_spacing
end
if Hud_collection_data.has_bonus then
local half_width = (HUD_COLLECTION_BONUS_WIDTH *.5)
bonus_x = x + half_width
x = x + HUD_COLLECTION_BONUS_WIDTH + HUD_COLLECTION_ITEM_SPACING
bonus_start_time = start_time
start_time = start_time + start_time_spacing
end
if Hud_collection_data.has_cash then
local cash_width, cash_height = element_get_actual_size(Hud_collection_cash_h)
local half_width = (cash_width *.5)
cash_x = x + half_width
x = x + cash_width + HUD_COLLECTION_ITEM_SPACING
cash_start_time = start_time
end
--Activity Tier Banners: These require custom spacing
--Tint and reposition the icon and title text group to fit the activity medal images
--Items we need to tint
local cbg_right_h = vint_object_find("cbg_right")
local cbg_left_h = vint_object_find("cbg_left")
local collect_icon_glow_h = vint_object_find("collect_icon_glow")
--Tint everything to default in case we are not bronze, silver, or gold
local bg_tint_r, bg_tint_g, bg_tint_b = COLOR_HUD_COLLECTION_DEFAULT.R, COLOR_HUD_COLLECTION_DEFAULT.G, COLOR_HUD_COLLECTION_DEFAULT.B
local txt_tint_r, txt_tint_g, txt_tint_b = COLOR_HUD_COLLECTION_DEFAULT.R, COLOR_HUD_COLLECTION_DEFAULT.G, COLOR_HUD_COLLECTION_DEFAULT.B
if Hud_collection_data.collection_type == HUD_COLLECTION_ACTIVITY_TIER_BRONZE then
--Tint bronze
bg_tint_r, bg_tint_g, bg_tint_b = COLOR_HUD_COLLECTION_BRONZE_BG.R, COLOR_HUD_COLLECTION_BRONZE_BG.G, COLOR_HUD_COLLECTION_BRONZE_BG.B
txt_tint_r, txt_tint_g, txt_tint_b = COLOR_HUD_COLLECTION_BRONZE_TEXT.R, COLOR_HUD_COLLECTION_BRONZE_TEXT.G, COLOR_HUD_COLLECTION_BRONZE_TEXT.B
--Change image to bronze medal
vint_set_property(collect_icon_h, "image", "ui_hud_tier_bronze")
elseif Hud_collection_data.collection_type == HUD_COLLECTION_ACTIVITY_TIER_SILVER then
--Tint silver
bg_tint_r, bg_tint_g, bg_tint_b = COLOR_HUD_COLLECTION_SILVER_BG.R, COLOR_HUD_COLLECTION_SILVER_BG.G, COLOR_HUD_COLLECTION_SILVER_BG.B
txt_tint_r, txt_tint_g, txt_tint_b = COLOR_HUD_COLLECTION_SILVER_TEXT.R, COLOR_HUD_COLLECTION_SILVER_TEXT.G, COLOR_HUD_COLLECTION_SILVER_TEXT.B
--Change image to silver medal
vint_set_property(collect_icon_h, "image", "ui_hud_tier_silver")
elseif Hud_collection_data.collection_type == HUD_COLLECTION_ACTIVITY_TIER_GOLD then
--Tint gold
bg_tint_r, bg_tint_g, bg_tint_b = COLOR_HUD_COLLECTION_GOLD_BG.R, COLOR_HUD_COLLECTION_GOLD_BG.G, COLOR_HUD_COLLECTION_GOLD_BG.B
txt_tint_r, txt_tint_g, txt_tint_b = COLOR_HUD_COLLECTION_GOLD_BG.R, COLOR_HUD_COLLECTION_GOLD_BG.G, COLOR_HUD_COLLECTION_GOLD_BG.B
--Change image to gold medal
vint_set_property(collect_icon_h, "image", "ui_hud_tier_gold")
end
local collection_deadly_h = vint_object_find("collection_bg_deadly");
if Hud_collection_data.collection_type == HUD_COLLECTION_SEVEN_DEADLY_SINS then
vint_set_property(collection_deadly_h, "visible", true)
else
vint_set_property(collection_deadly_h, "visible", false)
end
--If we are a medal reposition the image and text group
if Hud_collection_data.collection_type == HUD_COLLECTION_ACTIVITY_TIER_BRONZE or Hud_collection_data.collection_type == HUD_COLLECTION_ACTIVITY_TIER_SILVER or Hud_collection_data.collection_type == HUD_COLLECTION_ACTIVITY_TIER_GOLD then
--Reposition medal and text
vint_set_property(collect_icon_h, "anchor", HUD_COLLECTION_ICON_TIER_X, HUD_COLLECTION_ICON_DEFAULT_Y)
vint_set_property(collect_icon_glow_h, "anchor", HUD_COLLECTION_ICON_TIER_X, HUD_COLLECTION_ICON_DEFAULT_Y)
--Update anchor twn with new position
local twn_h = vint_object_find("collection_title_anchor_twn")
vint_set_property(twn_h, "end_value", HUD_COLLECTION_TITLE_TIER_X, HUD_COLLECTION_TITLE_DEFAULT_Y)
--Set the width of the banner
x = HUD_COLLECTION_TIER_WIDTH
elseif Hud_collection_data.collection_type == HUD_COLLECTION_SILVERLINK then
--Accomodate for larger silverlink logo... add values to the x positions...
vint_set_property(collect_icon_h, "anchor", HUD_COLLECTION_TITLE_DEFAULT_X+5, HUD_COLLECTION_ICON_DEFAULT_Y)
vint_set_property(collect_icon_glow_h, "anchor", HUD_COLLECTION_TITLE_DEFAULT_X+5, HUD_COLLECTION_ICON_DEFAULT_Y)
local twn_h = vint_object_find("collection_title_anchor_twn")
vint_set_property(twn_h, "end_value", HUD_COLLECTION_TITLE_TIER_X+35, HUD_COLLECTION_TITLE_DEFAULT_Y)
--Add 75 Pixels to width width of the banner, this accomodates for larger silverlink logo...
x = x + 75
else
--Not a medal, set to default positions
vint_set_property(collect_icon_h, "anchor", HUD_COLLECTION_ICON_DEFAULT_X, HUD_COLLECTION_ICON_DEFAULT_Y)
vint_set_property(collect_icon_glow_h, "anchor", HUD_COLLECTION_ICON_DEFAULT_X, HUD_COLLECTION_ICON_DEFAULT_Y)
local twn_h = vint_object_find("collection_title_anchor_twn")
vint_set_property(twn_h, "end_value", HUD_COLLECTION_TITLE_DEFAULT_X, HUD_COLLECTION_TITLE_DEFAULT_Y)
end
--Tint sides, text, and glow image
vint_set_property(cbg_right_h, "tint", bg_tint_r, bg_tint_g, bg_tint_b)
vint_set_property(cbg_left_h, "tint", bg_tint_r, bg_tint_g, bg_tint_b)
vint_set_property(sub_txt_h, "tint", txt_tint_r, txt_tint_g, txt_tint_b)
vint_set_property(collect_icon_glow_h, "tint", bg_tint_r, bg_tint_g, bg_tint_b)
local total_width = x --total width of the element is x....
complete_start_time = start_time + 3 --Delay close out animation by 3 seconds...
--Set positions...
Hud_collection_control_meter:set_anchor(control_x, y)
Hud_collection_respect_meter:set_anchor(respect_x, y)
vint_set_property(Hud_collection_bonus_grp_h, "anchor", bonus_x, y)
vint_set_property(Hud_collection_cash_h, "anchor", cash_x, y)
local collection_elements_grp_h = vint_object_find("collection_elements_grp")
local collection_x, collection_y = vint_get_property(collection_elements_grp_h, "anchor")
collection_x = 640 - (total_width * 0.5)
vint_set_property(collection_elements_grp_h, "anchor", collection_x, collection_y)
vint_set_property(collection_elements_grp_h, "alpha", 1.0)
--Unhide
local h = vint_object_find("collection_grp")
vint_set_property(h, "visible", true)
--set the background width
local cbg_width = (total_width + 35.0)
local cbg_anchor_y = 51.0
--set the background animate in end values since the size of the banner is dynamic
local cbg_main_scale_twn_h = vint_object_find("cbg_main_scale_twn")
vint_set_property(cbg_main_scale_twn_h, "end_value", (cbg_width / 16), 6.0)
local cbg_left_anchor_twn_h = vint_object_find("cbg_left_anchor_twn")
vint_set_property(cbg_left_anchor_twn_h, "end_value", 640 - (cbg_width * 0.5), cbg_anchor_y)
local cbg_right_anchor_twn_h = vint_object_find("cbg_right_anchor_twn")
vint_set_property(cbg_right_anchor_twn_h, "end_value", 640 + (cbg_width * 0.5), cbg_anchor_y)
if Hud_collection_data.collection_type == HUD_COLLECTION_SEVEN_DEADLY_SINS then
-- left side
local deadly_left_endcap_h = vint_object_find("cap_left_deadly");
vint_set_property(deadly_left_endcap_h, "alpha", 1)
local deadly_left_bar_anchor_twn_h = vint_object_find("deadly_left_anchor_twn")
vint_set_property(deadly_left_bar_anchor_twn_h, "end_value", 640 - (cbg_width * 0.5), cbg_anchor_y)
local deadly_left_cap_anchor_twn_h = vint_object_find("cap_left_anchor_twn")
vint_set_property(deadly_left_cap_anchor_twn_h, "end_value", 640 - (cbg_width * 0.5), cbg_anchor_y)
local deadly_left_corners_anchor_twn_h = vint_object_find("corner_left_anchor_twn")
vint_set_property(deadly_left_corners_anchor_twn_h, "end_value", 640 - (cbg_width * 0.5), cbg_anchor_y)
-- right side
local deadly_right_endcap_h = vint_object_find("cap_right_deadly");
vint_set_property(deadly_right_endcap_h, "alpha", 1)
local deadly_right_bar_anchor_twn_h = vint_object_find("deadly_right_anchor_twn")
vint_set_property(deadly_right_bar_anchor_twn_h, "end_value", 640 + (cbg_width * 0.5), cbg_anchor_y)
local deadly_right_cap_anchor_twn_h = vint_object_find("cap_right_anchor_twn")
vint_set_property(deadly_right_cap_anchor_twn_h, "end_value", 640 + (cbg_width * 0.5), cbg_anchor_y)
local deadly_right_corners_anchor_twn_h = vint_object_find("corner_right_anchor_twn")
vint_set_property(deadly_right_corners_anchor_twn_h, "end_value", 640 + (cbg_width * 0.5), cbg_anchor_y)
end
--set the start values of the animate out to match
cbg_main_scale_twn_h = vint_object_find("cbg_main_scale_out_twn")
vint_set_property(cbg_main_scale_twn_h, "start_value", (cbg_width / 16), 6.0)
cbg_left_anchor_twn_h = vint_object_find("cbg_left_anchor_out_twn")
vint_set_property(cbg_left_anchor_twn_h, "start_value", 640 - (cbg_width * 0.5), cbg_anchor_y)
cbg_right_anchor_twn_h = vint_object_find("cbg_right_anchor_out_twn")
vint_set_property(cbg_right_anchor_twn_h, "start_value", 640 + (cbg_width * 0.5), cbg_anchor_y)
if Hud_collection_data.collection_type == HUD_COLLECTION_SEVEN_DEADLY_SINS then
-- left side
local deadly_left_bar_anchor_twn_h = vint_object_find("deadly_left_anchor_out_twn")
vint_set_property(deadly_left_bar_anchor_twn_h, "start_value", 640 - (cbg_width * 0.5), cbg_anchor_y)
local deadly_left_cap_anchor_twn_h = vint_object_find("cap_left_anchor_out_twn")
vint_set_property(deadly_left_cap_anchor_twn_h, "start_value", 640 - (cbg_width * 0.5), cbg_anchor_y)
local deadly_left_corners_anchor_twn_h = vint_object_find("corner_left_anchor_out_twn")
vint_set_property(deadly_left_corners_anchor_twn_h, "start_value", 640 - (cbg_width * 0.5), cbg_anchor_y)
-- right side
local deadly_right_bar_anchor_twn_h = vint_object_find("deadly_right_anchor_out_twn")
vint_set_property(deadly_right_bar_anchor_twn_h, "start_value", 640 + (cbg_width * 0.5), cbg_anchor_y)
local deadly_right_cap_anchor_twn_h = vint_object_find("cap_right_anchor_out_twn")
vint_set_property(deadly_right_cap_anchor_twn_h, "start_value", 640 + (cbg_width * 0.5), cbg_anchor_y)
local deadly_right_corners_anchor_twn_h = vint_object_find("corner_right_anchor_out_twn")
vint_set_property(deadly_right_corners_anchor_twn_h, "start_value", 640 + (cbg_width * 0.5), cbg_anchor_y)
end
--Playback animations at different times...
-- Play back main animation....
lua_play_anim(Hud_collection_anims.in_anim_h, 0)
vint_apply_start_values( Hud_collection_anims.in_anim_h )
if Hud_collection_data.collection_type == HUD_COLLECTION_SEVEN_DEADLY_SINS then
lua_play_anim(Hud_collection_anims.in_deadly_h, 0)
vint_apply_start_values( Hud_collection_anims.in_deadly_h )
end
game_set_refraction_situation("screen_collection")
ui_audio_post_event("ui_generic_band_anim_in")
--Play back animations... but only if they are needed... this is to prevent bad callbacks...
if Hud_collection_data.has_district then
lua_play_anim(Hud_collection_anims.district_anim_h, control_start_time)
end
if Hud_collection_data.has_respect then
lua_play_anim(Hud_collection_anims.respect_anim_h, respect_start_time)
end
if Hud_collection_data.has_bonus then
lua_play_anim(Hud_collection_anims.bonus_anim_h, bonus_start_time)
end
if Hud_collection_data.has_cash then
lua_play_anim(Hud_collection_anims.cash_anim_h, cash_start_time)
end
--This animation closes it out...
lua_play_anim(Hud_collection_anims.complete_anim_h, complete_start_time)
if Hud_collection_data.collection_type == HUD_COLLECTION_SEVEN_DEADLY_SINS then
lua_play_anim(Hud_collection_anims.complete_deadly_h, complete_start_time)
end
if Hud_super_reward.is_active ~= nil and Hud_super_reward.is_active == true then
vint_set_property(Hud_super_reward.move_grp, "anchor", 0, 110)
else
vint_set_property(Hud_super_reward.move_grp, "anchor", 0,0)
end
--Get audio string from collection type...
local audio = Hud_collection_types[Hud_collection_data.collection_type].audio
if audio ~= nil then
--Play event...
audio_object_post_event(audio, nil, nil, nil, false)
end
end
function hud_collection_audio_out()
ui_audio_post_event("ui_generic_band_anim_out")
end
function hud_collection_finished()
--pause looping bg animation..
--award the stuff for real...
-- if Hud_collection_data.has_respect and Hud_collection_data.no_reward ~= true then
-- game_award_respect(Hud_collection_data.respect_reward, STATS_INVALID, Hud_collection_types[Hud_collection_data.collection_type].d_type, Hud_collection_data.save_in_mission)
-- end
-- if Hud_collection_data.has_cash and Hud_collection_data.no_reward ~= true then
-- game_award_cash(Hud_collection_data.cash_reward, Hud_collection_types[Hud_collection_data.collection_type].d_type, Hud_collection_data.save_in_mission)
-- end
if Current_collection_index == Num_collection_data then
Num_collection_data = 0
Current_collection_index = 0
Queued_collection_data = { }
Hud_collection_is_active = false
hud_collection_done()
--only save after last collection is done...
game_autosave()
else
hud_collection_start()
end
end
function hud_collection_animate_meter()
local meter_anim_h = vint_object_find( "collection_meter_anim" )
lua_play_anim( meter_anim_h, 0 )
end
-------------------------------------------------------------
-- Starts control meter fill/update (done via callback)
-------------------------------------------------------------
function hud_collection_start_control()
Hud_collection_control_meter:update(Hud_collection_data.district_pct_new, true)
end
-------------------------------------------------------------
-- Makes respect meter visible....(done via callback)
-------------------------------------------------------------
function hud_collection_show_respect()
--Query respect meter for current values...
local respect_total, respect_pct, respect_level = Hud_respect:get_data()
local final_respect_reward = Hud_collection_data.respect_reward + Hud_collection_data.respect_bonus
--Initialize meter...
Hud_collection_respect_meter:update_respect(final_respect_reward, respect_pct, respect_level, false)
end
-------------------------------------------------------------
-- Starts respect meter fill/update (done via callback)
-------------------------------------------------------------
function hud_collection_start_respect()
-- Query for the new values...
local respect_total_new, respect_pct_new, respect_level_new = Hud_respect:get_data()
local final_respect_reward = Hud_collection_data.respect_reward + Hud_collection_data.respect_bonus
--Start animationg the meter...
Hud_collection_respect_meter:update_respect(final_respect_reward, respect_pct_new, respect_level_new, true)
end
-------------------------------------------------------------
-- Starts cash count/update (done via callback)
-------------------------------------------------------------
function hud_collection_start_cash()
hud_collection_animate_cash()
end
-----------------------------------------
--Cash count...
-----------------------------------------
function hud_collection_animate_cash()
thread_new("hud_collection_anim_cash_thread")
end
function hud_collection_anim_cash_thread()
--init stuff
local start_cash = 0
local cash_this_frame = -1
local is_complete = false
--get the variables from the global
local cash = Hud_collection_data.cash_reward
local amt_min = 100
local amt_max = 5000
local time_min = 300
local time_max = 2999
local init_time = floor(vint_get_time_index() * 1000)
local cur_time = init_time
local time_to_count = floor(time_min + ((time_max - time_min) * (cash / amt_max)))
if time_to_count > time_max then
time_to_count = time_max
end
--init sound IDs
local activity_cash_count = 0
local activity_cash_hit = 0
while is_complete == false do
cur_time = floor(vint_get_time_index() * 1000) - init_time
--set my values
cash_this_frame = cash * (cur_time / time_to_count)
vint_set_property(Hud_collection_cash_h, "text_tag", "{GAME_CASH}" .. format_cash(cash_this_frame))
if cur_time >= time_to_count then
--game_audio_stop(activity_cash_count)
--activity_cash_hit = game_audio_play(Completion_audio.cash_hit)
vint_set_property(Hud_collection_cash_h, "text_tag", "{GAME_CASH}" .. format_cash(cash))
is_complete = true
end
thread_yield()
end
end
-------------------------------------------------------------------------------
-- Pausing support for hud collection...
--
function hud_collection_game_is_paused(di_h)
local is_paused = vint_dataitem_get(di_h)
if Hud_collection_is_active then
if is_paused == true then
--Stop anims
vint_set_property(Hud_collection_anims.complete_anim_h, "is_paused", true)
vint_set_property(Hud_collection_anims.complete_deadly_h, "is_paused", true)
else
--Play all anims
vint_set_property(Hud_collection_anims.complete_anim_h, "is_paused", false)
vint_set_property(Hud_collection_anims.complete_deadly_h, "is_paused", false)
end
end
end