-- These are for the 9 buttons on the cellphone.
ID_INVALID = -2
ID_MAIN = -1
ID_MAP = 0
ID_MISSIONS = 1
ID_POWERS = 2
ID_REWARDS = 3
--ID_MUSIC = 4
--ID_CAMERA = 5
--ID_PHONE = 6
--ID_CASH = 4
--ID_EXTRAS = 5
ID_STATS = 4
ID_TOMES = 5
Cell_foreground_doc = -1
Cell_background_doc = -1
Cell_foreground_h = 0
Cell_background_h = 0
-- HVS_TBT 5/19/2014 - Set these to be true by default, since we usually DO come from the main menu.
Pause_map_from_menu = true --Are we coming from the cell_menu_main or directly from game?
Rewards_from_menu = true --Are we coming from the cell_menu_main or directly from game?
Missions_from_menu = true --Are we coming from the cell_menu_main or directly from game?
Gps_has_been_set = false
local Tutorial_h
--Transtition Enums...
CELL_TRANSITION_INVALID = 0
CELL_TRANSITION_IN_PORTRAIT = 1 --set to portrait
CELL_TRANSITION_IN_LANDSCAPE = 2 --set to landscape
CELL_TRANSITION_OUT_PORTRAIT = 3 --transition out to portrait
CELL_TRANSITION_OUT_LANDSCAPE = 4 --transition out to landscape
CELL_STATE_INVALID = 0
CELL_STATE_START = 1
CELL_STATE_OUT = 2
CELL_STATE_PORTRAIT = 3
CELL_STATE_LANDSCAPE = 4
CELL_STATE_START_PORTRAIT = 5
CELL_STATE_START_LANDSCAPE = 6
CELL_STATE_OUT_PORTRAIT = 7
CELL_STATE_OUT_LANDSCAPE = 8
CELL_TYPE_LANDSCAPE = 1
CELL_TYPE_PORTRAIT = 2
local Cell_current_state = CELL_STATE_START
Cell_transition_cb_func = -1
--This is a seperate enum because the ID_* enums does not have every screen in the phone...
CELL_SCREEN_NONE = 0
CELL_SCREEN_MAIN = 1
CELL_SCREEN_MAP = 2
CELL_SCREEN_MISSIONS = 3
CELL_SCREEN_POWERS = 4
CELL_SCREEN_REWARDS = 5
CELL_SCREEN_MUSIC = 6
CELL_SCREEN_MUSIC_SUB = 7
CELL_SCREEN_PLAYLIST = 8
CELL_SCREEN_CAMERA = 9
CELL_SCREEN_PHONE = 10
CELL_SCREEN_EXTRAS = 11
CELL_SCREEN_CHEATS = 12
CELL_SCREEN_STATS = 13
CELL_SCREEN_CASH =14
CELL_SCREEN_POWERS_SUB =15
CELL_SCREEN_COLLECTIBLES = 16
-- Table is used to define screen types.
-- Allows us to store the type of screen it is, document name and target element.
-- This allows us to make any kind of transtion to a particular screen.
-- Screen type is either CELL_TYPE_LANDSCAPE (screens designed to be wide) or CELL_TYPE_PORTRAIT (screens in vertical orientation.
local Cell_menu_types = {
--Screen ID defined above Screen Type Document Name First element of the group
[CELL_SCREEN_NONE] = {nil, nil, nil}, --This is used so we can transition to nothing...
[CELL_SCREEN_MAIN] = {CELL_TYPE_LANDSCAPE, "cell_menu_main", "cell_menu_grp"},
[CELL_SCREEN_MAP] = {CELL_TYPE_LANDSCAPE, "pause_map", "map_all_grp"},
[CELL_SCREEN_MISSIONS] = {CELL_TYPE_LANDSCAPE, "cell_missions", "missions_grp"},
[CELL_SCREEN_POWERS] = {CELL_TYPE_LANDSCAPE, "powers_main", "screen_grp"},
[CELL_SCREEN_REWARDS] = {CELL_TYPE_LANDSCAPE, "cell_rewards", "rewards_base_grp"},
[CELL_SCREEN_MUSIC_SUB] = {CELL_TYPE_LANDSCAPE, "cell_music_sub", "cell_menu_grp"},
[CELL_SCREEN_MUSIC] = {CELL_TYPE_LANDSCAPE, "cell_music_menu", "station_group"},
[CELL_SCREEN_PLAYLIST] = {CELL_TYPE_LANDSCAPE, "cell_playlist", "playlist_grp"},
[CELL_SCREEN_CAMERA] = {CELL_TYPE_LANDSCAPE, "cell_camera", "camera_grp"},
[CELL_SCREEN_PHONE] = {CELL_TYPE_LANDSCAPE, "cell_phone", "phone_grp"},
[CELL_SCREEN_EXTRAS] = {CELL_TYPE_LANDSCAPE, "cell_extras", "cell_menu_grp"},
[CELL_SCREEN_CHEATS] = {CELL_TYPE_LANDSCAPE, "cell_cheats", "cheats_grp"},
[CELL_SCREEN_STATS] = {CELL_TYPE_LANDSCAPE, "cell_stats", "stats_grp"},
[CELL_SCREEN_CASH] = {CELL_TYPE_LANDSCAPE, "store_crib_cash", "cell_bonus_grp"},
[CELL_SCREEN_POWERS_SUB] = {CELL_TYPE_LANDSCAPE, "powers_sub", "powers_base_grp"},
[CELL_SCREEN_COLLECTIBLES] = {CELL_TYPE_LANDSCAPE, "col_main", "screen_grp"},
}
-- Positions, rotation and scale values for screens in HD
local Cell_states = {
[CELL_TYPE_PORTRAIT] = {
--[CELL_STATE_START_PORTRAIT] = {x = 1000, y = 1300, r = (45 * DEG_TO_RAD), s = 1.0},
--[CELL_STATE_START_LANDSCAPE] = {x = 1000, y = 1300, r = (-45 * DEG_TO_RAD), s = 1.5},
[CELL_STATE_START_PORTRAIT] = {x = 640, y = 360, r = (45 * DEG_TO_RAD), s = 1.0},
[CELL_STATE_START_LANDSCAPE] = {x = 640, y = 360, r = (-45 * DEG_TO_RAD), s = 1.0},
[CELL_STATE_PORTRAIT] = {x = 640, y = 360, r = (0 * DEG_TO_RAD), s = 1.0},
[CELL_STATE_LANDSCAPE] = {x = 640, y = 360, r = (-90 * DEG_TO_RAD), s = 1.0},
--[CELL_STATE_OUT_PORTRAIT] = {x = 1000, y = 1300, r = (45 * DEG_TO_RAD), s = 1.0},
--[CELL_STATE_OUT_LANDSCAPE] = {x = 1000, y = 1300, r = (-45 * DEG_TO_RAD), s = 1.5},
[CELL_STATE_OUT_PORTRAIT] = {x = 640, y = 360, r = (45 * DEG_TO_RAD), s = 0.01},
[CELL_STATE_OUT_LANDSCAPE] = {x = 640, y = 360, r = (-45 * DEG_TO_RAD), s = 0.02},
},
[CELL_TYPE_LANDSCAPE] = {
--[CELL_STATE_START_PORTRAIT] = {x = 1000, y = 1300, r = (135 * DEG_TO_RAD), s = .65},
--[CELL_STATE_START_LANDSCAPE] = {x = 1000, y = 1300, r = (45 * DEG_TO_RAD), s = 1.0},
[CELL_STATE_START_PORTRAIT] = {x = 640, y = 360, r = (135 * DEG_TO_RAD), s = 1.0},
[CELL_STATE_START_LANDSCAPE] = {x = 640, y = 360, r = (45 * DEG_TO_RAD), s = 1.0},
[CELL_STATE_PORTRAIT] = {x = 640, y = 360, r = (90 * DEG_TO_RAD), s = 1.0},
[CELL_STATE_LANDSCAPE] = {x = 640, y = 360, r = (0 * DEG_TO_RAD), s = 1.0},
--[CELL_STATE_OUT_PORTRAIT] = {x = 1000, y = 1300, r = (135 * DEG_TO_RAD), s = 1.0},
--[CELL_STATE_OUT_LANDSCAPE] = {x = 1000, y = 1300, r = (45 * DEG_TO_RAD), s = 1.5},
[CELL_STATE_OUT_PORTRAIT] = {x = 640, y = 360, r = (135 * DEG_TO_RAD), s = 0.01},
[CELL_STATE_OUT_LANDSCAPE] = {x = 640, y = 360, r = (45 * DEG_TO_RAD), s = 0.02},
},
}
--Initialize
function cell_foreground_init()
if vint_is_std_res() then
-- Positions, rotation and scale values for screens in SD
for idx, val in pairs(Cell_states) do
for idx2, val2 in pairs(val) do
if val2.x == 640 then
val2.x = 320
elseif val2.x == 1000 then
val2.x = 700
end
if val2.y == 360 then
val2.y = 240
elseif val2.y == 1300 then
val2.y = 900
end
val2.s = val2.s *.667 *.9
end
end
end
Cell_foreground_doc = vint_document_find("cell_foreground")
Cell_background_doc = vint_document_find("cell_background")
Cell_foreground_h = vint_object_find("screen_grp", 0, Cell_foreground_doc)
Cell_background_h = vint_object_find("screen_grp", 0, Cell_background_doc)
local top_icons_h = vint_object_find("top_icons", 0, Cell_foreground_doc)
--Hide all elements to start out with...
vint_set_property(Cell_foreground_h, "visible", false)
vint_set_property(Cell_background_h, "visible", false)
--Powers Tutorial
Tutorial_h = Vdo_gsi_lite:new("tutorial", 0, Cell_foreground_doc)
local intro_anim_h = vint_object_find("intro_anim", 0, Cell_background_doc)
local bg_loop = Vdo_anim_object:new("bg_loop", 0, Cell_background_doc)
--Play sound when HUB screen animation starts
local audio_twn_h = vint_object_find("audio_twn_hub_enter", intro_anim_h)
vint_set_property(audio_twn_h, "start_event", "cell_foreground_audio_hub_enter_cb")
vint_apply_start_values(intro_anim_h)
lua_play_anim(intro_anim_h)
bg_loop:play(0)
--Apply lut
--cell_foreground_lut_effect("lut_completion_screen")
end
--Cleanup
function cell_foreground_cleanup()
cell_foreground_lut_effect("none")
end
function cell_foreground_update_tutorial(tutorial)
if tutorial == "off" then
Tutorial_h:set_visible(false)
end
if pause_map_is_tutorial_mode() then
if tutorial == "access_map" then
if Gps_has_been_set == false then
Tutorial_h:update("MM_1_1_OBJ_GO_TO_MAP", "ui_target_icon_use")
end
elseif tutorial == "gps_weapon" then
Tutorial_h:update("MM_1_1_OBJ_SET_GPS", "ui_target_icon_location")
elseif tutorial == "exit_hub" then
Tutorial_h:update("POWERS_TUT_EXIT_HUB", "ui_target_icon_use")
end
end
if challenge_tutorial_mode_is_active() then
if tutorial == "open_menu" then
Tutorial_h:update("CHALLENGE_TUT_ENTER_MENU", "ui_target_icon_use")
elseif tutorial == "set_challenge" then
Tutorial_h:update("CHALLENGE_TUT_PICK_CHALLENGE", "ui_target_icon_use")
elseif tutorial == "pick_objective" then
Tutorial_h:update("CHALLENGE_TUT_PICK_OBJECTIVE", "ui_target_icon_use")
elseif tutorial == "exit_hub" then
Tutorial_h:update("POWERS_TUT_EXIT_HUB", "ui_target_icon_use")
end
end
if Powers_main_tutorial_enable then
if tutorial == "hub" then
--tell them to click on powers screen
Tutorial_h:update("POWERS_TUT_FIRST", "ui_target_icon_use")
elseif tutorial == "main" then
--tell them to buy sprint and jump
Tutorial_h:update("POWERS_TUT_SECOND", "ui_target_icon_use")
elseif tutorial == "final" then
Tutorial_h:set_visible(false)
dialog_box_message("MENU_TITLE_NOTICE", "POWERS_TUT_FINAL", true, true, "cell_foreground_exit_tutorial")
end
end
end
function cell_foreground_exit_tutorial()
pop_screen()
pop_screen()
pop_screen()
pop_screen()
end
--DELETE THIS..
function cell_foreground_set_state()
end
-------------------------------------------------------------------------------
-- Transitions the cellphone screen to next
--
-- @transition_type transition type... (CELL_TRANSITION_IN_LANDSCAPE)
-- @doc_name "document name"
-- @doc_name "base_name"
--
-- transition_type, "pause_map", "map_all_grp",
--cell_transition_screen(CELL_TYPE_LANDSCAPE, CELL_STATE_LANDSCAPE, "pause_map", "map_all_grp", pause_map_trans_in_complete)
function cell_transition_screen(target_state, screen1, screen2, callback_func)
local screen_1_data = Cell_menu_types[screen1]
local screen_2_data = Cell_menu_types[screen2]
local transition_screens = {
[1] = {screen_type = screen_1_data[1], doc_name = screen_1_data[2], base_name = screen_1_data[3]},
[2] = {screen_type = CELL_TYPE_LANDSCAPE, doc_name = "cell_foreground", base_name = "top_bar"},--"cell_frame_grp"},
[3] = {screen_type = CELL_TYPE_PORTRAIT, doc_name = "cell_background", base_name = "cell_bg_grp"},
[4] = {screen_type = screen_2_data[1], doc_name = screen_2_data[2], base_name = screen_2_data[3]}
}
if screen1 == nil or screen2 == nil then
--ABORT: attempt to do whack transition...
debug_print("vint", "No valid screen set for cell_transition_screen(). screen1 or screen2: " .. var_to_string(screen1) .. "\n")
return
end
--Special case for cell rewards... needs to have an extra document transition...
if screen1 == CELL_SCREEN_REWARDS or screen2 == CELL_SCREEN_REWARDS then
transition_screens[5] = {screen_type = CELL_TYPE_LANDSCAPE, doc_name = "store_common", base_name = "cell_rotate_grp"}
--Also needs to reset scale of store common because it gets overriden.
local store_common_doc_h = vint_document_find("store_common")
local h = vint_object_find("screen_grp", 0, store_common_doc_h)
vint_set_property(h, "scale", 1,1)
end
local twn_h
--This is used to ensure our callbacks context is called to the appropriate document.
local transition_callback_idx = 1
if screen1 == CELL_SCREEN_NONE then
-- If screen is none this means we are exiting the phone,
-- Our function callback should happen in the context of the screen we are exiting from...
transition_callback_idx = 2
--outro anim can be added here
end
for idx, screen in pairs(transition_screens) do
if screen.screen_type ~= nil then
--Screen transitions...
local doc_h = vint_document_find(screen.doc_name)
local target_h = vint_object_find(screen.base_name, 0, doc_h)
--Animation we use as the base(anchor, rotation, scale)
local anim_h = vint_object_find("transition_element_anim", 0, Cell_background_doc)
local anim_clone_h = vint_object_clone(anim_h)
local root_anim_h = vint_object_find("root_animation", 0, doc_h)
vint_object_set_parent(anim_clone_h, root_anim_h)
local anchor_twn_h = vint_object_find("anchor_twn", anim_clone_h)
local rotation_twn_h = vint_object_find("rotation_twn", anim_clone_h)
local scale_twn_h = vint_object_find("scale_twn", anim_clone_h)
--local alpha_twn_h = vint_object_find("alpha_twn", anim_clone_h)
local start_state = Cell_current_state --start state is the last state saved...
local end_state = target_state --end state is the target state...
-- Do some translations for the start and end states...
-- If our state is starting then we need to figure out what type we should transition from.
-- This is to keep the size ratios the same all the way through...
if start_state == CELL_STATE_START then
if end_state == CELL_STATE_PORTRAIT then
start_state = CELL_STATE_START_PORTRAIT
else
start_state = CELL_STATE_START_LANDSCAPE
end
end
--We do the same for when we are transitioning out...
if end_state == CELL_STATE_OUT then
if start_state == CELL_STATE_PORTRAIT then
end_state = CELL_STATE_OUT_PORTRAIT
else
end_state = CELL_STATE_OUT_LANDSCAPE
end
end
local start_data = table_clone(Cell_states[screen.screen_type][start_state])
local end_data = table_clone(Cell_states[screen.screen_type][end_state])
--Check to make sure we have valid states...
if start_data == nil or end_data == nil then
debug_print("vint", "invalid target_state: " .. var_to_string(target_state) .. "\n")
debug_print("vint", "invalid screen_type: " .. var_to_string(screen.screen_type) .. "\n")
return
end
--Set target handle of our cloned tweens.
vint_set_property(anchor_twn_h, "target_handle", target_h)
vint_set_property(rotation_twn_h,"target_handle", target_h)
vint_set_property(scale_twn_h, "target_handle", target_h)
--vint_set_property(alpha_twn_h, "target_handle", target_h)
--Set callback so we know we are completed and can cleanup the tweens.
--Additionally, the callback will call our sent in callback function.
if idx == transition_callback_idx then
-- only setup the action callback for the screen we are transitioning to...
-- this is to maintain vint context of the lua function call to that document.
vint_set_property(anchor_twn_h, "end_event", "cell_transition_action_cb")
else
--callback to make sure we cleanup the animation when we are finished.
vint_set_property(anchor_twn_h, "end_event", "cell_transition_delete_cb")
end
--Get and set properties based on our start/end data.
vint_set_property(anchor_twn_h, "start_value", start_data.x, start_data.y)
vint_set_property(anchor_twn_h, "end_value", end_data.x, end_data.y)
--REMOVED FOR SR4 and changed to zero, we don't need no rotation
--vint_set_property(rotation_twn_h, "start_value", start_data.r)
--vint_set_property(rotation_twn_h, "end_value", end_data.r)
vint_set_property(rotation_twn_h, "start_value", 0)
vint_set_property(rotation_twn_h, "end_value", 0)
vint_set_property(scale_twn_h, "start_value", start_data.s, start_data.s)
vint_set_property(scale_twn_h, "end_value", end_data.s, end_data.s)
--if end_state == CELL_STATE_OUT_PORTRAIT or end_state == CELL_STATE_OUT_LANDSCAPE then
--vint_set_property(anchor_twn_h, "algorithm", "ease_out_quart")
--vint_set_property(rotation_twn_h,"algorithm", "ease_out_quart")
vint_set_property(scale_twn_h, "algorithm", "ease_out_quart")
--end
-- Play animation...
vint_apply_start_values(anim_clone_h)
lua_play_anim(anim_clone_h, 0, doc_h)
--Play incomming screens transition animation
if idx == 1 then
--Pause out animation
local trans_out_anim_h = vint_object_find("trans_out_anim", 0, doc_h)
if trans_out_anim_h ~= 0 then
vint_set_property(trans_out_anim_h, "is_paused", true)
end
--Play in animation...
local trans_in_anim_h = vint_object_find("trans_in_anim", 0, doc_h)
if trans_in_anim_h ~= 0 then
lua_play_anim(trans_in_anim_h, 0, doc_h)
end
if screen1 == CELL_SCREEN_MAIN or screen1 == CELL_SCREEN_EXTRAS or screen1 == CELL_SCREEN_MUSIC_SUB then
--cell_menu_main_animate_in()
end
--cell_menu_animate_in()
end
if idx == 3 then
--local bg_rotate_h = vint_object_find("bg_rotate",0,Cell_background_doc)
--bg rotation over ride
if start_state ~= end_state then
if (start_state == CELL_STATE_LANDSCAPE or start_state == CELL_STATE_START_PORTRAIT) and end_state == CELL_STATE_PORTRAIT then
--vint_set_property(bg_rotate_h, "rotation", (-35 * DEG_TO_RAD))
elseif (start_state == CELL_STATE_PORTRAIT or start_state == CELL_STATE_START_LANDSCAPE) and end_state == CELL_STATE_LANDSCAPE then
--vint_set_property(bg_rotate_h, "rotation", (55 * DEG_TO_RAD))
end
end
end
--Play outgoing screens transition animation
if idx == 4 then
--Pause in animation
local trans_in_anim_h = vint_object_find("trans_in_anim", 0, doc_h)
if trans_in_anim_h ~= 0 then
vint_set_property(trans_in_anim_h, "is_paused", true)
end
--Play out animation
local trans_out_anim_h = vint_object_find("trans_out_anim", 0, doc_h)
if trans_out_anim_h ~= 0 then
lua_play_anim(trans_out_anim_h, 0, doc_h)
end
if screen2 == CELL_SCREEN_MAIN or screen2 == CELL_SCREEN_EXTRAS or screen2 == CELL_SCREEN_MUSIC_SUB then
--need to play hide top bar anim...
if start_state ~= end_state then
if screen.end_state == CELL_STATE_PORTRAIT then
--fade in header
cell_foreground_fade_in_header()
else
--fade out header
cell_foreground_fade_out_header()
end
end
end
end
end
end
--Store callback function to global
if callback_func ~= nil then
Cell_transition_cb_func = callback_func
else
Cell_transition_cb_func = -1
end
--Glitch the screen
glitch_cell()
--Update clusters
local cell_menu_main_doc_h = vint_document_find("cell_menu_main")
if cell_menu_main_doc_h ~= nil then
cell_menu_main_cluster_update()
end
--Store current state.
Cell_current_state = target_state
end
-------------------------------------------------------------------------------
-- Callback functions for tweens.
-- 1. Destroys its parent anim.
--
function cell_transition_delete_cb(tween_h)
vint_object_destroy(vint_object_parent(tween_h))
end
-- Callback functions for tweens.
-- 1. Destroys its parent anim.
-- 2. Does callback that was stored in the global from our last transition.
-- 3. Wipes the callback out so other tweens don't call it.
function cell_transition_action_cb(tween_h)
vint_object_destroy(vint_object_parent(tween_h))
--Do cell transition callback if it exists the reset it.
if Cell_transition_cb_func ~= -1 then
Cell_transition_cb_func()
Cell_transition_cb_func = -1
end
end
-------------------------------------------------------------------------------
-- Fades in the header(battery, power)
--
function cell_foreground_fade_in_header()
lua_play_anim(vint_object_find("in_header_anim", 0, Cell_foreground_doc), 0, Cell_foreground_doc)
end
-------------------------------------------------------------------------------
-- Fades out the header(battery, power)
--
function cell_foreground_fade_out_header()
lua_play_anim(vint_object_find("out_header_anim", 0, Cell_foreground_doc), 0, Cell_foreground_doc)
end
function cell_show_frame()
vint_set_property(Cell_foreground_h, "visible", true)
vint_set_property(Cell_background_h, "visible", true)
end
function cell_foreground_lut_effect(lut_table_string)
if lut_table_string ~= "none" then
local platform = game_get_platform()
local lut_platform_string = ""
if platform == "PS3" then
lut_platform_string = "_ps3"
elseif platform == "XBOX360" then
lut_platform_string = "_xbox2"
elseif platform == "XBOX3" then
lut_platform_string = "_xbox3"
elseif platform == "PS4" then
lut_platform_string = "_ps4"
elseif platform == "PC" then
lut_platform_string = "_pc"
end
completion_load_lut(lut_table_string .. lut_platform_string)
else
completion_load_lut(lut_table_string)
end
end
--Callback for HUB Enter audio cue
function cell_foreground_audio_hub_enter_cb()
ui_audio_post_event("UI_Hub_Enter")
end