function test_error_me()
X = 5
end
GAME_BUILD_DATE = "0000-00-00 20:00:00"
-- legacy for menu_base...
--MENU_NUM_SLIDER_ACCEL_REPEAT = 0.08
--MENU_NUM_SLIDER_ACCEL_FACTOR = 15
--MENU_NUM_SLIDER_ACCEL_LIMIT = 1000
FEET_PER_METER = 3.2808399
-- HUD Elements --
HUD_ELEM_GSI = 0
HUD_ELEM_MINIMAP = 1
HUD_ELEM_RETICLE = 2
HUD_ELEM_HIT_INDICATORS = 3
HUD_ELEM_WEAPONS = 4
HUD_ELEM_CASH_RESPECT_HOMEY = 5
HUD_ELEM_WEAPON_SWAP_MESSAGE = 6
HUD_ELEM_RADIO_STATION = 7
HUD_ELEM_VEHICLE_NAME = 8
HUD_ELEM_DIVERSIONS = 9
HUD_ELEM_MESSAGES = 10
HUD_ELEM_TUTORIAL_HELP = 11
HUD_ELEM_AMMO_PICKUP = 12
HUD_ELEM_COLLECTION = 13
HUD_ELEM_SUPER_REWARD = 14
HUD_ELEM_MECH = 15
-- Must be explicitly hidden
HUD_ELEM_SCREEN_FX = 16
HUD_ELEM_SUBTITLES = 17
HUD_ELEM_OI = 18
HUD_ELEM_RADIAL = 19
HUD_ALL_ELEM = 20
-- HUD Fade Levels --
HUD_FADE_HIDDEN = 0
HUD_FADE_TRANSPARENT = 1
HUD_FADE_VISIBLE = 2
HUD_FADE_NO_CHANGE = 3
local MY_HUD_STATE = -1
function hud_hide_test_1()
MY_HUD_STATE = ui_hud_display_create_state()
ui_hud_display_set_element(MY_HUD_STATE, HUD_ELEM_RADIAL, HUD_FADE_HIDDEN)
ui_hud_display_commit_state(MY_HUD_STATE)
end
function hud_hide_test_2()
ui_hud_display_remove_state(MY_HUD_STATE)
MY_HUD_STATE = -1
end
Pcr_open_plastic_surgeon = false
-- some docs need to know what menu mode we are doing
-- set this from C before loading menu docs
Menu_mode_current = ""
--Main Menu Globals...
Main_menu_controller_is_selected = false -- Determines if we've got a controller selected for the game, used by main menu...
Main_menu_gameboot_complete = false --Determines if we've already loaded the main menu(we use this to determine to show loading and press start or not).
Menu_swap_in_progress = false
--LEGACY DELETE THIS when unreferenced by the main menu...
Main_menu_controller_selected = false -- Determines if we've got a controller selected for the game, used by main menu... LEGACY
Main_menu_can_has_input = false
Hud_msg_back_is_coop_join = false -- is the currently displayed back message item a coop quest share
--stored here so we know how to properly restart the clothing store
Clothing_store_name = "DEBUG_CLOTHING_STORE"
Clothing_store_display_name = 0
Clothing_store_original_name = "DEBUG_CLOTHING_STORE"
Clothing_store_original_display_name = 0
Menu_swap_interface_unload_handle = 0
Menu_swap_interface_reload_name = 0
Menu_swap_callback_function = 0
Menu_swap_hud_hidden = false;
INVALID_NUM_FRAMES = -1
Num_frames_from_switch = INVALID_NUM_FRAMES
Pause_menu_save_for_server_drop = false
Credits_format = "default"
DIALOG_OPEN_SOUND = "SYS_HUD_HELPTEXT"
DIALOG_SERIOUS_SOUND = "SYS_HUD_CONF_SERIOUS"
Menu_sound_item_nav = "SYS_MENU_CLICK_UD" -- Current menu item changes
Menu_sound_value_nav = "SYS_MENU_CLICK_LR" -- Value of current item changes
Menu_sound_select = "UI_Main_Menu_Select" -- Current item selected
Menu_sound_scroll = "SYS_MENU_TRIGGER_LR" -- Horizontal menu changes
Menu_sound_back = "SYS_MENU_BACK" -- Current menu changes to previous
Menu_sound_open = "SYS_MENU_OPEN" -- Menu system is opened
Menu_sound_close = "SYS_MENU_CLOSE" -- Menu system is closed
Menu_sound_warning = "SYS_MENU_OPEN" -- Warning dialog opens
Menu_sound_purchase = "SYS_MENU_PURCHASE" -- Any item is purchased
Menu_sound_confirm = "SYS_HUD_CONF_SERIOUS" -- Confirmation/warning dialog opens
Menu_sound_reward = "SYS_HUD_CONF_REWARD" -- Reward notification dialog
--Tween States
VINT_TWEEN_STATE_WAITING = 0
VINT_TWEEN_STATE_RUNNING = 1
VINT_TWEEN_STATE_PAUSED = 2
VINT_TWEEN_STATE_DISABLED = 3
VINT_TWEEN_STATE_FINISHED = 4
Screen_center_x = 640
Screen_center_y = 360
Safe_frame_e = 0
Safe_frame_w = 0
Safe_frame_n = 0
Safe_frame_s = 0
VINT_OBJECT_INVALID = -1
VINT_OBJECT_GROUP = 0
VINT_OBJECT_BITMAP = 1
VINT_OBJECT_TEXT = 2
function vint_lib_init_constants()
if vint_is_std_res() then
Screen_center_x = 320
Screen_center_y = 240
else
Screen_center_x = 640
Screen_center_y = 360
end
--Get safe frame...
Safe_frame_w, Safe_frame_n, Safe_frame_e, Safe_frame_s = vint_get_safe_frame()
end
function vint_menu_swap_thread()
while true do
if Menu_swap_interface_reload_name ~= 0 then
if Menu_swap_hud_hidden == false then
game_hud_hide(true);
Menu_swap_hud_hidden = true
end
if Num_frames_from_switch ~= INVALID_NUM_FRAMES then
Num_frames_from_switch = Num_frames_from_switch + 1
end
if Num_frames_from_switch > 2 then
if Menu_swap_interface_reload_name ~= 0 then
vint_document_load(Menu_swap_interface_reload_name)
Menu_swap_interface_reload_name = 0
Num_frames_from_switch = INVALID_NUM_FRAMES
Menu_swap_in_progress = false
if Menu_swap_callback_function ~= 0 then
Menu_swap_callback_function()
Menu_swap_callback_function = 0
end
end
end
end
thread_yield()
end
end
function vint_menu_swap_invalidate()
Menu_swap_interface_reload_name = 0
Num_frames_from_switch = INVALID_NUM_FRAMES
Clothing_store_name = "DEBUG_CLOTHING_STORE"
Clothing_store_display_name = 0
Clothing_store_original_name = "DEBUG_CLOTHING_STORE"
Clothing_store_original_display_name = 0
Menu_swap_interface_unload_handle = 0
Menu_swap_interface_reload_name = 0
Menu_swap_in_progress = false
game_hud_hide(false);
Menu_swap_hud_hidden = false
end
function vint_menu_swap_unload()
vint_document_unload(Menu_swap_interface_unload_handle)
Num_frames_from_switch = 0
end
function argument_unwrapper(arguments, start)
if start < arguments.n then
return arguments[start + 1], argument_unwrapper(arguments, start + 1)
end
end
function vint_dataresponder_request(data_responder_name, callback_function_name, max_records_to_return, ...)
vint_internal_dataresponder_request(data_responder_name, callback_function_name, max_records_to_return, argument_unwrapper(arg, 0))
while(vint_dataresponder_finished(data_responder_name) ~= true) do
thread_yield()
vint_internal_dataresponder_request(data_responder_name, callback_function_name, max_records_to_return, argument_unwrapper(arg, 0))
end
end
--[[
#########################################################################
UTILITY FUNCTIONS
#########################################################################
]]
function set_text_tag(text_element_h, text_crc, text_string)
--Set Label
if text_crc == 0 and text_string == nil then
--no string
vint_set_property(text_element_h,"text_tag", "")
elseif text_crc == 0 then
--use string
vint_set_property(text_element_h, "text_tag", text_string)
elseif text_crc == nil then
--Label crc invalid
vint_set_property(text_element_h,"text_tag", "")
else
--use crc
vint_set_property(text_element_h, "text_tag_crc",text_crc)
end
end
--Easy Start Anim
function lua_play_anim(anim_h, start_time_offset, doc)
if start_time_offset == nil then
start_time_offset = 0
end
local start_time = vint_get_time_index(doc) + start_time_offset
vint_set_property(anim_h, "is_paused", false)
vint_set_property(anim_h, "start_time", start_time)
end
--Easy Play tween method
function lua_play_tween(tween_handle, target_handle, start_time_offset)
vint_set_property(tween_handle, "target_handle", target_handle)
vint_set_property(tween_handle, "start_time", vint_get_time_index() + start_time_offset)
vint_set_property(tween_handle, "state", "running")
end
function lua_reverse_anim(anim_h)
--Find largest duration...
local tween_h = vint_object_first_child(anim_h)
local max_anim_length = 0
while tween_h ~= 0 and tween_h ~= nil do
local tween_start_time = vint_get_property(tween_h, "start_time")
local tween_duration = vint_get_property(tween_h, "duration")
local anim_length = tween_start_time + tween_duration
max_anim_length = max(max_anim_length, anim_length)
tween_h = vint_object_next_sibling(tween_h)
end
--loop through and swap times...
local tween_h = vint_object_first_child(anim_h)
while tween_h ~= 0 and tween_h ~= nil do
--find out what these tweens are...
local property_name = vint_get_property(tween_h, "target_property")
--Swap values
if property_name == "anchor" or property_name == "offset" or property_name == "source_nw" or property_name == "source_ne" or property_name == "scale" then
--Vector type properties
local start_value_x, start_value_y = vint_get_property(tween_h, "start_value")
local end_value_x, end_value_y = vint_get_property(tween_h, "end_value")
vint_set_property(tween_h, "end_value", start_value_x, start_value_y)
vint_set_property(tween_h, "start_value", end_value_x, end_value_y)
elseif property_name == "alpha" or property_name == "rotation" then
--Single value properties
local start_value = vint_get_property(tween_h, "start_value")
local end_value = vint_get_property(tween_h, "end_value")
vint_set_property(tween_h, "start_value", end_value)
vint_set_property(tween_h, "end_value", start_value)
elseif property_name == "tint" then
--Tint
local start_value_r, start_value_g, start_value_b = vint_get_property(tween_h, "start_value")
local end_value_r, end_value_g, end_value_b = vint_get_property(tween_h, "end_value")
vint_set_property(tween_h, "end_value", start_value_r, start_value_g, start_value_b)
vint_set_property(tween_h, "start_value", end_value_r, end_value_g, end_value_b)
end
--Change tween start time
local tween_start_time = vint_get_property(tween_h, "start_time")
local tween_duration = vint_get_property(tween_h, "duration")
local new_tween_start_time = max_anim_length - tween_start_time - tween_duration
vint_set_property(tween_h, "start_time", new_tween_start_time)
tween_h = vint_object_next_sibling(tween_h)
end
end
function var_to_string(var)
local t = type(var)
if t == "table" then
return "{table}"
elseif var == nil then
return "nil"
elseif var == true then
return "true"
elseif var == false then
return "false"
elseif t == "number" then
return "" .. var
else
return var
end
end
--Sets actual size of the element. This is independant of the parent scaler values.
function element_set_actual_size(element_h, width, height)
local current_width, current_height = vint_get_property(element_h, "unscaled_size")
if current_width == nil or current_height == nil then
debug_print("vint", "Can't set actual size, element handle: " .. element_h .. " does not exist.\n")
return false
end
if width == nil or width == nil then
debug_print("vint", "Can't set actual size, element handle: " .. element_h .. " does not exist.\n")
return false
end
local scale_x = width/current_width
local scale_y = height/current_height
vint_set_property(element_h, "scale", scale_x, scale_y)
return true
end
--Returns actual size of the element, indpendant from the parent scaler values.
function element_get_actual_size(element_h)
local width, height = vint_get_property(element_h, "unscaled_size")
local scale_x, scale_y = vint_get_property(element_h, "scale")
if width == nil or width == nil or scale_x == nil or scale_y == nil then
debug_print("vint", "Can't get actual size, element handle: " .. element_h .. " does not exist.\n")
return 0, 0
end
width = width * scale_x
height = height * scale_y
return width, height
end
function element_get_scale_from_size(element_h, width, height)
local current_width, current_height = vint_get_property(element_h, "unscaled_size")
if current_width == nil or current_height == nil then
debug_print("vint", "Can't set actual size, element handle: " .. element_h .. " does not exist.\n")
return 0, 0
end
local scale_x = width/current_width
local scale_y = height/current_height
return scale_x, scale_y
end
-------------------------------------------------------------------------------
-- Returns the size of the first level elements within a group.
-- Notes: (ONLY 1 Deep, does not recurse), (Does not work on Vdos)
--
--
function group_get_actual_size(group_h)
if group_h == 0 or group_h == nil then
debug_print("vint", "Not a valid group handle. Found data type: " .. type(group_h) .. "\n")
end
local a_x, a_y, b_x, b_y
local child_h = vint_object_first_child(group_h)
while true do
local x, y = vint_get_property(child_h, "anchor")
local width, height = element_get_actual_size(child_h)
local c_x = x
local c_y = y
local d_x = x + width
local d_y = y + height
if a_x == nil then
a_x = x
a_y = y
b_x = x
b_y = y
end
a_x = min(c_x, a_x)
a_y = min(c_y, a_y)
b_x = max(d_x, b_x)
b_y = max(d_y, b_y)
child_h = vint_object_next_sibling(child_h)
if child_h == nil or child_h == 0 then
break
end
end
local width = b_x - a_x
local height = b_y - a_y
return width, height
end
-------------------------------------------------------------------------------
-- Align elements in vertical direction...
-- local data = {
-- { h = handle,
-- type = VINT_OBJECT_GROUP
-- space = 10,},
-- { h = handle,
-- type = VINT_OBJECT_GROUP
-- space = 10,},
-- }
-- @returns width and height of all the elements
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Align elements in vertical direction...
-- local data = {
-- { h = handle,
-- type = VINT_OBJECT_GROUP
-- space = 10,},
-- { h = handle,
-- type = VINT_OBJECT_GROUP
-- space = 10,},
-- }
-- @returns width and height of all the elements
-------------------------------------------------------------------------------
function vint_align_elements(data)
local x, y, width, height
local space = 0
local prev_x = 0
local prev_y = 0
local prev_width = 0
local prev_height = 0
local start_x, start_y
for idx, element in pairs(data) do
x, y = vint_get_property(element.h, "anchor")
if idx < 2 then
--first element will start their positions from original spot.
start_x = x
prev_x = x
start_y = y
prev_y = y
--skip spacing of first element.
space = 0
else
--elements after 1 will use the spacing variable...
space = element.space
end
if element.type == VINT_OBJECT_GROUP then
width, height = group_get_actual_size(element.h)
elseif element.type == VINT_OBJECT_INVALID then
width = 0
height = 0
else
width, height = element_get_actual_size(element.h)
end
y = prev_y + prev_height + space
vint_set_property(element.h, "anchor", x, y)
prev_x = x
prev_y = y
prev_width = width
prev_height = height
end
width = x + width - start_x
height = y + height - start_y
return width, height
end
-------------------------------------------------------------------------------
-- A debug function that does a debug_print of values of a dataitem paired with strings.
-- Outputs to the console window the dataitem handle along with the paired values
-- for the strings entered.
--
-- @param di_h The dataitem that you would like to print.
-- @param ... Arguments each item in dataitem
-- Example: dataitem_to_debug(di_h, "icon_bmp_name", "coord_x", "coord_y")
-------------------------------------------------------------------------------
function dataitem_to_debug(di_h, ...)
local data = {}
data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15], data[16], data[17], data[18], data[19], data[20], data[21], data[22], data[23], data[24] = vint_dataitem_get(di_h)
local return_string = "\n"
debug_print("vint", "DATAITEM: di_h\n")
for idx, val in pairs(arg) do
if type(idx) ~= "string" then
if idx > 25 then
debug_print("vint", "Too much data for this debug function dataitem_to_debug(). Increase number of arguments on the dataitem get.\n")
return
end
if idx > 0 then
--Print... dataitem_name, and value...
if idx == arg.n then
--Last string in list... do a double return.
return_string = "\n\n"
end
debug_print("vint", " " .. val .. ":\t\t" .. var_to_string(data[idx]) .. return_string)
end
end
end
end
---------------------------------------------------------------
-- Returns scaled value if game is in standard def
--
-- @param value - Value to scale for std def
-- @param operator - Determines which operator
-- to perform on value
--
-- 0 = multiply (default)
-- 1 = divide
---------------------------------------------------------------
function vint_to_std_res(value, operator)
if vint_is_std_res() then
if operator == nil or operator == 0 then
value = value * SCALE_STD_RES
elseif operator == 1 then
value = value / SCALE_STD_RES
end
return value
end
return value
end
-- Support for hud monkey business
Hud_has_focus = true
-- Math stuffs
PI = 3.1415
PI2 = 6.283
--=======================================
--MP Utilities
--=======================================
MP_gameplay_mode_names = {
"Pre-game lobby",
"Gangsta Brawl",
"Team Gangsta Brawl",
"Braveheart",
"Multiplayer Creation",
"Multiplayer Customization",
"Multiplayer Game Results",
"Multiplayer Scoreboard",
"Multiplayer Tutorial",
}
function mp_is_enabled()
--Get some multiplayer Data
local gp_mode = game_get_pending_game_play_mode()
for i, m in pairs( MP_gameplay_mode_names ) do
if gp_mode == m then
--found a match
return true
end
end
gp_mode = game_get_game_play_mode()
for i, m in pairs( MP_gameplay_mode_names ) do
if gp_mode == m then
--found a match
return true
end
end
return false
end
function ui_play_pain_audio()
audio_object_post_event("Play_Gat_Vending_Pain", nil, nil, nil, false)
end
function ui_audio_post_event( event_name )
audio_object_post_event(event_name, nil, nil, nil, false)
end
--#######################################
--Audio Delay
--#######################################
function audio_play_delayed(sound_id, offset)
thread_new("audio_play_delayed_thread", sound_id, offset)
end
function audio_play_delayed_thread(sound_id, offset)
delay(offset)
game_audio_play(sound_id)
end
function format_cash(cash)
return game_format_int_to_string(cash)
end
function format_cash_add_padding(c)
if c < 10 then
return "00" .. c
elseif c < 100 then
return "0" .. c
else
return c
end
end
function format_distance(distance_in_meters)
local distance_in_feet
local distance_str
if game_use_imperial_units() then
distance_in_feet = distance_in_meters * FEET_PER_METER
distance_str = floor(distance_in_feet).." ft"
return distance_str
else
distance_str = floor(distance_in_meters).." m"
return distance_str
end
end
-------------------------------------------------------------------------------
-- Formats seconds into clock format
-- @param time_in_seconds time in seconds
-- @param show_ms whether or not you want to show ms (00:00 or 00:00.00)
--
function format_clock(time_in_seconds, show_ms)
local neg_symbol = ""
if time_in_seconds < 0 then
time_in_seconds = abs(time_in_seconds)
neg_symbol = "-"
end
-- Format the time
local minutes = floor(time_in_seconds / 60)
local milliseconds = (time_in_seconds * 1000) % 1000
local seconds = floor(time_in_seconds) % 60
seconds = abs(seconds) -- Negative time is handled earlier, this should always be positive.
-- Pad the seconds for the timer
if seconds < 10 and minutes > 0 then
seconds = "0" .. seconds
end
if show_ms == true then
-- Only show one decimal place
milliseconds = milliseconds * .01
milliseconds = floor(milliseconds)
if minutes > 0 then
return neg_symbol .. minutes .. ":" .. seconds .. "." .. milliseconds
else
return neg_symbol .. seconds .. "." .. milliseconds
end
else
if minutes > 0 then
return neg_symbol .. minutes .. ":" .. seconds
else
return neg_symbol .. seconds
end
end
end
----------------------------------------------------------------------------------------------
-- Function format_time()
--
-- Formats seconds into time format 00:00 min or 00:00.00 min
--
-- @param time_in_seconds time in seconds
-- @param show_ms whether or not you want to show ms
-- @param show_units whether or not you want to show units of time ("mins" or "secs")
-- @param units_in_caps show units in ALL CAPS
-- @param show_colon show colon for time under 1 min (ex: ":33" vs "33")
--
----------------------------------------------------------------------------------------------
function format_time(time_in_seconds, show_ms, show_units, units_in_caps, show_colon)
-- since show_units is a new addition and the default behavior is to show units
-- defaulting nil to true
if show_units == nil then
show_units = true
end
local neg_symbol = ""
if time_in_seconds < 0 then
time_in_seconds = abs(time_in_seconds)
neg_symbol = "-"
end
-- Format the time
local minutes = floor(time_in_seconds / 60)
local milliseconds = (time_in_seconds * 1000) % 1000
local seconds = floor(time_in_seconds) % 60
seconds = abs(seconds) -- Negative time is handled earlier, this should always be positive.
-- Pad the seconds for the timer
if seconds < 10 then
seconds = "0" .. seconds
end
if show_ms == true then
-- Only show one decimal place
milliseconds = milliseconds * .01
milliseconds = floor(milliseconds)
--localize "secs" and "mins" then return string
if minutes > 0 then
if show_units == false then
return neg_symbol .. minutes .. ":" .. seconds .. ".".. milliseconds
else
local insert_values = {[0] = neg_symbol .. minutes .. ":" .. seconds .. ".".. milliseconds}
local body
if units_in_caps == true then
body = vint_insert_values_in_string("FORMAT_TIME_MINS_CAPS", insert_values)
else
body = vint_insert_values_in_string("FORMAT_TIME_MINS", insert_values)
end
return body
end
else
if show_units == false then
if show_colon == true then
return neg_symbol .. ":" .. seconds .. "."..milliseconds
else
return neg_symbol .. seconds .. "."..milliseconds
end
else
local insert_values
if show_colon == true then
insert_values = {[0] = neg_symbol .. ":" .. seconds .. "."..milliseconds}
else
insert_values = {[0] = neg_symbol .. seconds .. "."..milliseconds}
end
local body
if units_in_caps == true then
body = vint_insert_values_in_string("FORMAT_TIME_SECS_CAPS", insert_values)
else
body = vint_insert_values_in_string("FORMAT_TIME_SECS", insert_values)
end
return body
end
end
else
if minutes > 0 then
if show_units == false then
return neg_symbol .. minutes .. ":" .. seconds
else
local insert_values = {[0] = neg_symbol .. minutes .. ":" .. seconds}
local body
if units_in_caps == true then
body = vint_insert_values_in_string("FORMAT_TIME_MINS_CAPS", insert_values)
else
body = vint_insert_values_in_string("FORMAT_TIME_MINS", insert_values)
end
return body
end
else
if show_units == false then
if show_colon == true then
return neg_symbol .. ":" .. seconds
else
return neg_symbol .. seconds
end
else
local insert_values
if show_colon == true then
insert_values = {[0] = neg_symbol .. ":" .. seconds}
else
insert_values = {[0] = neg_symbol .. seconds}
end
local body
if units_in_caps == true then
body = vint_insert_values_in_string("FORMAT_TIME_SECS_CAPS", insert_values)
else
body = vint_insert_values_in_string("FORMAT_TIME_SECS", insert_values)
end
return body
end
end
end
end
----------------------------------------------------------------------------------------------------
-- Button remapping...
----------------------------------------------------------------------------------------------------
--Map buttons for globals on ui init
CTRL_MENU_BUTTON_A = -1
CTRL_GAMEPLAY_BUTTON_A = -1
CTRL_MENU_BUTTON_B = -1
CTRL_GAMEPLAY_BUTTON_B = -1
CTRL_BUTTON_X = -1
CTRL_BUTTON_Y = -1
CTRL_BUTTON_LB = -1
CTRL_BUTTON_LT = -1
CTRL_BUTTON_RB = -1
CTRL_BUTTON_RT = -1
CTRL_BUTTON_LS = -1
CTRL_BUTTON_LS_PRESS = -1
CTRL_BUTTON_RS = -1
CTRL_BUTTON_RS_PRESS = -1
CTRL_BUTTON_DPAD = -1
CTRL_BUTTON_DPAD_UP = -1
CTRL_BUTTON_DPAD_DOWN = -1
CTRL_BUTTON_DPAD_LEFT = -1
CTRL_BUTTON_DPAD_RIGHT = -1
CTRL_BUTTON_DPAD_UP_DOWN = -1
CTRL_BUTTON_DPAD_LEFT_RIGHT = -1
CTRL_MENU_BUTTON_BACK = -1
CTRL_BUTTON_START = -1
CTRL_BUTTON_MOUSE_SCROLL = -1
function vint_lib_init_buttons()
--Map buttons for globals on ui init
--
-- SEH 8/15/2011: PS3 can swap the meaning of the accept and cancel buttons for menus, but we don't want to
-- swap them for gameplay. Making separate variables to handle this. Ideally, for SR4, the other buttons will
-- get renamed to be more consistent, or how this is handled will be changed.
--
CTRL_MENU_BUTTON_A = get_a_button(false)
CTRL_GAMEPLAY_BUTTON_A = get_a_button(true)
CTRL_MENU_BUTTON_B = get_b_button(false)
CTRL_GAMEPLAY_BUTTON_B = get_b_button(true)
CTRL_BUTTON_X = get_x_button()
CTRL_BUTTON_Y = get_y_button()
CTRL_BUTTON_LB = get_lb_button()
CTRL_BUTTON_LT = get_lt_button()
CTRL_BUTTON_RB = get_rb_button()
CTRL_BUTTON_RT = get_rt_button()
CTRL_BUTTON_LS = get_left_stick()
CTRL_BUTTON_LS_PRESS = get_ls_press_image()
CTRL_BUTTON_RS = get_right_stick()
CTRL_BUTTON_RS_PRESS = get_rs_press_image()
CTRL_BUTTON_DPAD = get_dpad_image()
CTRL_BUTTON_DPAD_UP = get_dpad_up_image()
CTRL_BUTTON_DPAD_DOWN = get_dpad_down_image()
CTRL_BUTTON_DPAD_LEFT = get_dpad_left_image()
CTRL_BUTTON_DPAD_RIGHT = get_dpad_right_image()
CTRL_BUTTON_DPAD_UP_DOWN = get_dpad_ud_image()
CTRL_BUTTON_DPAD_LEFT_RIGHT = get_dpad_lr_image()
CTRL_MENU_BUTTON_BACK = get_back_image()
CTRL_BUTTON_START = get_start_image()
CTRL_BUTTON_MOUSE_SCROLL = get_mouse_scroll_image()
end
-- this is now unofficially get_confirm_button!
function get_a_button(for_gameplay)
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_a"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_a"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
local button_swap = game_get_ps3_button_swap() and for_gameplay == false
if button_swap == true then
button = "ui_ctrl_ps4_btn_circle"
else
button = "ui_ctrl_ps4_btn_cross"
end
else
local button_swap = game_get_ps3_button_swap() and for_gameplay == false
if button_swap == true then
button = "ui_ctrl_ps3_btn_circle"
else
-- old standard
button = "ui_ctrl_ps3_btn_cross"
end
end
return button
end
function get_x_button()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_x"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_x"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_btn_square"
else
button = "ui_ctrl_ps3_btn_square"
end
return button
end
-- this is now unofficially get_back_button!
function get_b_button(for_gameplay)
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_b"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_b"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
local button_swap = game_get_ps3_button_swap() and for_gameplay == false
if button_swap == true then
button = "ui_ctrl_ps4_btn_cross"
else
button = "ui_ctrl_ps4_btn_circle"
end
else
local button_swap = game_get_ps3_button_swap() and for_gameplay == false
if button_swap == true then
button = "ui_ctrl_ps3_btn_cross"
else
button = "ui_ctrl_ps3_btn_circle"
end
end
return button
end
function get_y_button()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_y"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_y"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_btn_triangle"
else
button = "ui_ctrl_ps3_btn_triangle"
end
return button
end
function get_right_stick()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_rs"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_rs"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_btn_r"
else
button = "ui_ctrl_ps3_btn_r"
end
return button
end
function get_left_stick()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_ls"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_ls"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_btn_l"
else
button = "ui_ctrl_ps3_btn_l"
end
return button
end
function get_lt_button()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_lt"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_lt"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_btn_l2" --HVS_TBT 8/27/2014
else
button = "ui_ctrl_ps3_btn_l1"
end
return button
end
function get_rt_button()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_rt"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_rt"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_btn_r2" --HVS_TBT 8/27/2014
else
button = "ui_ctrl_ps3_btn_r1"
end
return button
end
function get_lb_button()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_lb"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_lb"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_btn_l1" --HVS_TBT 8/27/2014
else
button = "ui_ctrl_ps3_btn_l2"
end
return button
end
function get_rb_button()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_rb"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_rb"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_btn_r1" --HVS_TBT 8/27/2014
else
button = "ui_ctrl_ps3_btn_r2"
end
return button
end
function get_left_right()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_dpad_lr"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_dpad_lr"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_dapd_lr"
else
button = "ui_ctrl_ps3_dapd_lr"
end
return button
end
function get_up_down()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_dpad_ud"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_dpad_ud"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_dpad_ud"
else
button = "ui_ctrl_ps3_dpad_ud"
end
return button
end
function get_left_trigger()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_lt"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_lt"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_btn_l2"
else
button = "ui_ctrl_ps3_btn_l2"
end
return button
end
function get_right_trigger()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_rt"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_rt"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_btn_r2"
else
button = "ui_ctrl_ps3_btn_r2"
end
return button
end
function get_control_stick_base()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_hud_radial_stick_base_xbox2"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_hud_radial_stick_base_xbox3"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_hud_radial_stick_base_ps4"
else
image = "ui_hud_radial_stick_base_ps3"
end
return image
end
function get_control_stick_thumb()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_hud_radial_stick_thumb_xbox2"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_hud_radial_stick_thumb_xbox3"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_hud_radial_stick_thumb_ps4"
else
image = "ui_hud_radial_stick_thumb_ps3"
end
return image
end
function get_control_stick_text()
local text
local platform = game_get_platform()
if pause_menu_is_using_southpaw_control_scheme() == true and game_is_local_player_in_vehicle() == false then
if (platform == "XBOX360") or (platform == "PC") then
text = "RS"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
text = "RS"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
text = "R"
else
text = "R"
end
elseif pause_menu_is_using_vehicle_southpaw_control_scheme() == true and game_is_local_player_in_vehicle() == true then
if (platform == "XBOX360") or (platform == "PC") then
text = "RS"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
text = "RS"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
text = "R"
else
text = "R"
end
else
if (platform == "XBOX360") or (platform == "PC") then
text = "LS"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
text = "LS"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
text = "L"
else
text = "L"
end
end
return text
end
function get_dpad_image()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_hud_radial_dpad_xbox2"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_hud_radial_dpad_xbox3"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_hud_radial_dpad_ps4"
else
image = "ui_hud_radial_dpad_ps3"
end
return image
end
function get_dpad_lr_image()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_ctrl_360_dpad_lr"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_xbox3_dpad_lr"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_ps4_dpad_lr"
else
image = "ui_ctrl_ps3_dpad_lr"
end
return image
end
function get_dpad_ud_image()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_ctrl_360_dpad_ud"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_xbox3_dpad_ud"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_ps4_dpad_ud"
else
image = "ui_ctrl_ps3_dpad_ud"
end
return image
end
function get_dpad_image()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_ctrl_360_dpad_n"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_xbox3_dpad_n"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_ps4_dpad_n"
else
image = "ui_ctrl_ps3_dpad_n"
end
return image
end
function get_dpad_up_image()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_ctrl_360_dpad_u"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_xbox3_dpad_u"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_ps4_dpad_u"
else
image = "ui_ctrl_ps3_dpad_u"
end
return image
end
function get_dpad_down_image()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_ctrl_360_dpad_d"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_xbox3_dpad_d"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_ps4_dpad_d"
else
image = "ui_ctrl_ps3_dpad_d"
end
return image
end
function get_dpad_left_image()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_ctrl_360_dpad_l"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_xbox3_dpad_l"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_ps4_dpad_l"
else
image = "ui_ctrl_ps3_dpad_l"
end
return image
end
function get_dpad_right_image()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_ctrl_360_dpad_r"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_xbox3_dpad_r"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_ps4_dpad_r"
else
image = "ui_ctrl_ps3_dpad_r"
end
return image
end
function get_ls_press_image()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_ctrl_360_btn_ls_press"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_xbox3_btn_ls_press"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_ps4_btn_l3"
else
image = "ui_ctrl_ps3_btn_l3"
end
return image
end
function get_rs_press_image()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_ctrl_360_btn_rs_press"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_xbox3_btn_rs_press"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_ps4_btn_r3"
else
image = "ui_ctrl_ps3_btn_r3"
end
return image
end
function get_start_image()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_ctrl_360_btn_start"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_xbox3_btn_start"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_ps4_btn_start"
else
image = "ui_ctrl_ps3_btn_start"
end
return image
end
function get_back_image()
local image
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
image = "ui_ctrl_360_btn_back"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_xbox3_btn_back"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_ps4_btn_select"
else
image = "ui_ctrl_ps3_btn_select"
end
return image
end
function get_mouse_scroll_image()
local image
local platform = game_get_platform()
if platform == "PC" then
image = "ui_pc_icon_options"
elseif platform == "XBOX360" then
image = "ui_ctrl_360_btn_rs"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_xbox3_btn_back"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
image = "ui_ctrl_ps4_btn_r"
else
image = "ui_ctrl_ps3_btn_r"
end
return image
end
function get_actual_a_button()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_a"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_a"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_btn_cross"
else
button = "ui_ctrl_ps3_btn_cross"
end
return button
end
function get_actual_b_button()
local button
local platform = game_get_platform()
if (platform == "XBOX360") or (platform == "PC") then
button = "ui_ctrl_360_btn_b"
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_xbox3_btn_b"
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
button = "ui_ctrl_ps4_btn_circle"
else
button = "ui_ctrl_ps3_btn_circle"
end
return button
end
function table_clone(src)
local dst = { }
if src == nil then
return nil
end
for k, v in pairs(src) do
-- if type(v) == "table" then
-- dst[k] = table_clone(v)
-- else
dst[k] = v
-- end
end
return dst
end
--[[ ---------------------------------------------------------------------
-- Function - table_clear
-- Description - Properly clears a table and cleans up its used memory
-- Parameters -
-- table_to_clear - table, The table to be cleared
-- recursive_clean - bool, If true, clears out 2D tables if any are found
-- Returns - nil
]]-- ---------------------------------------------------------------------
function table_clear(table_to_clear, recursive_clean)
if( type(recursive_clean) ~= "boolean" ) then
--debug_print("vint", "vint_lib.lua :::: table_clear :::: type(recursive_clean) = " .. var_to_string(type(recursive_clean)) .. "\n")
recursive_clean = false
end
if(table_to_clear ~= nil) then
for x, table_item in pairs(table_to_clear) do
--debug_print("vint", "vint_lib.lua :::: table_clear :::: x = " .. var_to_string(x) .. "\n")
--debug_print("vint", "vint_lib.lua :::: table_clear :::: table_item = " .. var_to_string(table_item) .. "\n")
if( recursive_clean )then
if( type(table_item) == "table" )then
--debug_print("vint", "vint_lib.lua :::: table_clear :::: FOUND 2D TABLE!\n\n")
table_clear(table_item, true)
end
end
--debug_print("vint", "vint_lib.lua :::: table_clear :::: CLEARING table_item = " .. var_to_string(table_item) .. ", x = " .. var_to_string(x) .."\n\n")
table_to_clear[x] = nil
end
end
return
end
-------------------------------------------------------------------------------
-- Prints all the key value pairs for a table. (Does not do deep tables)
--
function lua_debug_table(table)
for key, val in pairs(table) do
debug_print("vint", "key: " .. var_to_string(key) .. "| val: " .. var_to_string(val) .. "\n")
end
end
--Limits value between low and high
function limit(value, low, high)
if value < low then
value = low
elseif value > high then
value = high
end
return value
end
-- Helper function for list options that wraps indexes
--
-- current_idx: current value
-- direction: value to add/subtract
-- max_idx: maximum index value
-- min_idx: (optional) minimum index value, defaults to 1
function wrap_index(current_idx, direction, max_idx, min_idx)
min_idx = min_idx or 1
local idx0 = (current_idx + direction - min_idx) -- Base 0
local base = max_idx - min_idx + 1
return (idx0 % base) + min_idx
end
-- Helper function to hide children objects...
--
-- object_h: object with children underneath to hide...
function vint_hide_children(object_h)
local h = vint_object_first_child(object_h)
while true do
if h == nil then
break
end
vint_set_property(h, "visible", false)
h = vint_object_next_sibling(h)
end
end
-- Simple Callback function to loop animations from tweens...
-- usage: vint_set_property(twn_h, "end_event", "vint_anim_loop_callback")
-- This will cause the animation to continue to loop...
function vint_anim_loop_callback(tween_h, event)
local anim_h = vint_object_parent(tween_h)
lua_play_anim(anim_h)
end
-- Helper function to dump pause map to get more memory in certain screens
--
function pause_map_dump( wait )
local peg_name = "ui_map_world_city"
game_peg_unload( peg_name )
if wait == true then
while game_peg_is_loaded( peg_name ) do
thread_yield()
end
end
end
function game_peg_unload_wait( peg_name )
game_peg_unload( peg_name )
while game_peg_is_loaded( peg_name ) do
thread_yield()
end
end
-- unload one or more pegs and wait for them to unload
-- peg list (table, strings) - list of peg names to unload
function game_peg_list_unload_wait( peg_list )
for k, v in pairs( peg_list ) do
game_peg_unload( v )
end
local all_unloaded
repeat
thread_yield()
all_unloaded = true
for k, v in pairs( peg_list ) do
if game_peg_is_loaded( v ) then
all_unloaded = false
break
end
end
until all_unloaded == true
end
function do_nothing()
end
-- Helper function to reload pause map
--
function pause_map_restore()
if (game_is_going_to_main_menu() == false) and (game_is_debug_reloading_level() == false) then
game_peg_load_with_cb("do_nothing", 1, "ui_map_world_city")
end
end
-- Returns the widest element... useful for finding the longest string or element in a field...
--
-- @param data = { element_1_h, element_2_h, element_3_h } (these are handles to elements you want to evaluate)
--
-- @return largest_element_h handle to largest element.
-- @return largest_width width of largest element...
function find_widest_text_element(data)
local width, height
local largest_width = 0
local largest_element_h = 0
for idx, val in pairs(data) do
width, height = element_get_actual_size(val)
if width > largest_width then
largest_width = width
largest_element_h = val
end
end
return largest_element_h, floor(largest_width)
end
-------------------------------------------------------------------------------
-- Debug prints all objects in the document tree
-- @param vint_doc_name string for vint document e.g. "hud"
--
function vint_debug_safe_frame(vint_doc_name)
local doc_h = vint_document_find(vint_doc_name)
if doc_h == 0 or doc_h == nil then
debug_print("vint", "vint_debug_safe_frame() " .. var_to_string(vint_doc_name) .. " was not found...\n")
return
end
local safe_frame_h = vint_object_find("safe_frame", 0, doc_h)
vint_debug_safe_frame_objects(safe_frame_h, 0)
end
-------------------------------------------------------------------------------
-- Debug prints all objects below the element sent in,
-- @param vint_doc_name string for vint document e.g. "hud"
--
function vint_debug_safe_frame_objects(object_h, depth)
if depth == nil then
depth = 0
end
if object_h ~= nil and object_h ~= 0 then
local depth_str = ""
for i = 1, depth do
depth_str = depth_str .. " "
end
--Name, object
local name = vint_object_get_name_from_handle(object_h)
local debug_str = depth_str .."Name: " .. name
debug_str = debug_str .. "(" .. var_to_string(object_h) .. ")\n"
--Print it...
debug_print("vint", debug_str)
end
local child_h = vint_object_first_child(object_h)
if child_h ~= 0 and child_h ~= nil then
vint_debug_safe_frame_objects(child_h, depth + 1)
end
local next_sibling_h = vint_object_next_sibling(object_h)
if next_sibling_h ~= 0 and next_sibling_h ~= nil then
vint_debug_safe_frame_objects(next_sibling_h, depth)
end
end
-------------------------------------------------------------------------------
-- Online and Privilege
-------------------------------------------------------------------------------
ONLINE_VALIDATOR_PASSED = 0
ONLINE_VALIDATOR_NO_ONLINE_PRIV = 1
ONLINE_VALIDATOR_NOT_SIGNED_IN = 2
ONLINE_VALIDATOR_NOT_ONLINE = 3
ONLINE_VALIDATOR_NO_ETHERNET = 4
ONLINE_VALIDATOR_IN_PROGRESS = 5
Online_validator_result = ONLINE_VALIDATOR_PASSED
Online_validator_privilege_check_service = false
Online_validator_privilege_check_online = false
Online_validator_privilege_check_chat = false
Online_validator_privilege_fail_on_chat = false
Powers_main_tutorial_enable = false
function online_validator_check_privs()
-- We need to wait a frame for PS3 to process the new multi login, otherwise the privileges are not up to date
delay( 1 )
if Online_validator_privilege_check_online then
if game_get_platform() == "PS4" then
if main_menu_check_needs_patch() == true then
Online_validator_result = ONLINE_VALIDATOR_NO_ONLINE_PRIV
online_validator_set_checking(false)
return
elseif main_menu_check_online_privilege() == false then
dialog_box_message("MENU_TITLE_WARNING", "MAIN_MENU_PRIVILEGE_DENIED")
Online_validator_result = ONLINE_VALIDATOR_NO_ONLINE_PRIV
online_validator_set_checking(false)
return
elseif main_menu_check_playstation_plus() == false then
-- HVS_TJW, this isn't neat, but it shows the correct message when the router is unplugged
-- this is only necessary because the Sony network connection state doesn't properly update in this instance
if main_menu_check_presence() == false then
dialog_box_message("MENU_TITLE_WARNING", "NO_NETWORK_CONNECTION")
Online_validator_result = ONLINE_VALIDATOR_NO_ETHERNET
else
-- HVS_EC Since we always display the "Join PS Plus" system message, this message is redundant.
-- dialog_box_message("MENU_TITLE_WARNING", "NO_PLAYSTATION_PLUS_MESSAGE")
Online_validator_result = ONLINE_VALIDATOR_NO_ONLINE_PRIV
end
online_validator_set_checking(false)
return
end
elseif main_menu_check_online_privilege() == false then
dialog_box_message("MENU_TITLE_WARNING", "MAIN_MENU_PRIVILEGE_DENIED")
Online_validator_result = ONLINE_VALIDATOR_NO_ONLINE_PRIV
online_validator_set_checking(false)
return
end
end
-- Chat most likely doesn't need a return code. It's just a warning
-- also, we don't call it if it's already been shown for this login
if Online_validator_privilege_check_chat and main_menu_check_chat_priv() == false then
if Online_validator_privilege_fail_on_chat then
Online_validator_result = ONLINE_VALIDATOR_NO_ONLINE_PRIV
dialog_box_message("MENU_TITLE_WARNING", "USER_CONTENT_PRIV_DENIED")
return
else
main_menu_maybe_show_voice_dialog()
while(main_menu_wait_for_voice_dialog() == true) do
thread_yield()
end
end
end
Online_validator_result = ONLINE_VALIDATOR_PASSED
online_validator_set_checking(false)
end
function online_validator_sign_in_cb(result)
main_menu_supress_profile_change(false)
if game_is_signed_in() == false or
(Online_validator_privilege_check_service and game_is_connected_to_service() == false) then
local platform = game_get_platform()
if platform ~= "PS3" then
if platform == "XBOX3" then
dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN_X3")
else
dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN")
end
end
Online_validator_result = ONLINE_VALIDATOR_NOT_ONLINE
online_validator_set_checking(false)
else
thread_new("online_validator_check_privs")
end
end
function online_validator_profile_cb(result, action)
if result == 0 then
main_menu_supress_profile_change(true)
game_sign_into_network(true, "online_validator_sign_in_cb")
else
Online_validator_result = ONLINE_VALIDATOR_NOT_SIGNED_IN
online_validator_set_checking(false)
end
end
function online_and_privilege_validator_begin(can_sign_in, check_service, check_online_priv, check_chat_priv, in_game, fail_on_chat)
Online_validator_result = ONLINE_VALIDATOR_IN_PROGRESS
Online_validator_privilege_check_service = check_service or false
Online_validator_privilege_check_online = check_online_priv or false
Online_validator_privilege_check_chat = check_chat_priv or false
-- DAD - 9/14/11 - This is hacked in last minute, this should get cleaned up later
Online_validator_privilege_fail_on_chat = fail_on_chat or false
if game_is_connected_to_network() == false then
dialog_box_message("MENU_TITLE_WARNING", "NO_NETWORK_CONNECTION")
Online_validator_result = ONLINE_VALIDATOR_NO_ETHERNET
return
end
online_validator_set_checking(true)
--see if we're on a profile
if game_is_signed_in() == false then
if can_sign_in or not (game_get_platform() == "PS4") then -- HVS_JRS 7/23/2014 PS4 signin is external to game
dialog_box_confirmation("CONTROL_SIGN_IN", "MUST_SIGN_IN_PROFILE_CONFIRM", "online_validator_profile_cb")
else
local platform = game_get_platform()
if main_menu_check_presence() == false then -- HVS_JRS 11/18/2014 show no network connection if sceNpGetGamePresenceStatus() fails (PS4 only)
debug_print("mp","Showing NO_NETWORK_CONNECTION instead of NOT_LOGGED_IN\n")
dialog_box_message("MENU_TITLE_WARNING", "NO_NETWORK_CONNECTION")
Online_validator_result = ONLINE_VALIDATOR_NO_ETHERNET
else
if platform == "XBOX3" then
dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN_X3")
else
dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN")
end
Online_validator_result = ONLINE_VALIDATOR_NOT_SIGNED_IN
end
online_validator_set_checking(false)
end
return
end
-- See if we're connected to PSN or XBL
if check_service == true and game_is_connected_to_service() == false then
if game_get_platform() == "PC" then
Online_validator_result = ONLINE_VALIDATOR_NOT_SIGNED_IN
game_sign_into_network(true, "online_validator_sign_in_cb")
elseif game_get_platform() == "PS3" then
game_sign_into_network(true, "online_validator_sign_in_cb")
else
-- According to TCR/TRC, PS3 doesn't want a sign in prompt before hand, MS does.
if in_game or (game_get_platform() == "PS4") then -- HVS_JRS 7/14/2014 PS4 signin is external to game
if main_menu_check_presence() == false then -- HVS_JRS 11/18/2014 show no network connection if sceNpGetGamePresenceStatus() fails (PS4 only)
debug_print("mp","Showing NO_NETWORK_CONNECTION instead of NOT_LOGGED_IN\n")
dialog_box_message("MENU_TITLE_WARNING", "NO_NETWORK_CONNECTION")
Online_validator_result = ONLINE_VALIDATOR_NO_ETHERNET
else
dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN")
Online_validator_result = ONLINE_VALIDATOR_NOT_ONLINE
end
online_validator_set_checking(false)
else
if game_get_platform() == "XBOX3" then
dialog_box_confirmation("CONTROL_SIGN_IN", "MUST_LOG_IN_CONFIRM_X3", "online_validator_profile_cb")
else
dialog_box_confirmation("CONTROL_SIGN_IN", "MUST_LOG_IN_CONFIRM", "online_validator_profile_cb")
end
end
end
return
end
online_validator_check_privs()
if Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS then
Online_validator_result = ONLINE_VALIDATOR_PASSED
end
online_validator_set_checking(false)
end
--Resize text thats too wide
function 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)
if text_width > max_width then
local text_scale = max_width/text_width
vint_set_property(element_h, "scale", text_scale, text_scale)
end
end
function vint_debug_print(name, value)
debug_print("vint", name .."::::" .. var_to_string(value) .. "\n")
end
--Glitch screen, hub style
function glitch_cell()
vint_set_glitch_preset("hub")
vint_spike_glitch( 200, 0 )
end
-------------------------------------------------------------------------------
-- Test Function
-------------------------------------------------------------------------------
function test_interp_linear(time, start, delta)
return delta * time + start
end