TEST_TABLE = {
["monkey"] = { 1, 2, 3 },
[12] = 12,
}
TEST_TABLE2 = {
["FREAKY"] = TEST_TABLE,
[46] = TEST_TABLE,
}
TEST_TABLE["super_monkey"] = TEST_TABLE2
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
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
--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
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 var_to_string(var)
if type(var) == "table" then
return "{table}"
elseif var == nil then
return "nil"
elseif var == true then
return "true"
elseif var == false then
return "false"
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_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
----------------------------------------------------------------------------------------------
-- 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")
--
function format_time(time_in_seconds, show_ms, show_units)
-- 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 and minutes > 0 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 = vint_insert_values_in_string("FORMAT_TIME_MINS", insert_values)
return body
end
else
if show_units == false then
return neg_symbol .. seconds .. "."..milliseconds
else
local insert_values = {[0] = neg_symbol .. seconds .. "."..milliseconds}
local body = vint_insert_values_in_string("FORMAT_TIME_SECS", insert_values)
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 = vint_insert_values_in_string("FORMAT_TIME_MINS", insert_values)
return body
end
else
if show_units == false then
return neg_symbol .. seconds
else
local insert_values = {[0] = neg_symbol .. seconds}
local body = vint_insert_values_in_string("FORMAT_TIME_SECS", insert_values)
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
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()
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
else
text = "R"
end
else
if (platform == "XBOX360") or (platform == "PC") then
text = "LS"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
else
image = "ui_ctrl_ps3_btn_select"
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"
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"
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
-------------------------------------------------------------------------------
-- 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()
game_peg_unload("ui_map_world_city")
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
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
thread_yield()
if Online_validator_privilege_check_online and 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
-- 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()
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
if game_get_platform() ~= "PS3" then
dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN")
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 then
dialog_box_confirmation("CONTROL_SIGN_IN", "MUST_SIGN_IN_PROFILE_CONFIRM", "online_validator_profile_cb")
else
dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN")
Online_validator_result = ONLINE_VALIDATOR_NOT_SIGNED_IN
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 then
dialog_box_message("MENU_TITLE_WARNING", "NOT_LOGGED_IN")
Online_validator_result = ONLINE_VALIDATOR_NOT_ONLINE
online_validator_set_checking(false)
else
dialog_box_confirmation("CONTROL_SIGN_IN", "MUST_LOG_IN_CONFIRM", "online_validator_profile_cb")
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
-------------------------------------------------------------------------------
-- Test Function
-------------------------------------------------------------------------------
function test_interp_linear(time, start, delta)
return delta * time + start
end