--TODO invert all items.
-- highlight_grp
-- Uninvert the folllowing
-- icon
-- icon_highlight
-- line_1_txt
-- line_2_txt
-- line_3_txt
-- line_4_txt
-- hint_bar_highlight
---- Need to add functionality to invert this one..
local Entered_with_gamepad = false
local PAUSE_MAP_COLOR_ZOOM_SELECTED = {R = 220/255, G = 220/255, B = 220/255}
local PAUSE_MAP_COLOR_ZOOM_UNSELECTED = {R = 170/255, G = 170/255, B = 170/255}
-- Info is on left side of icon...
local PAUSE_MAP_HIGHLIGHT_TEXT_X_OFFSET_LEFT = 8
local PAUSE_MAP_HIGHLIGHT_HINTS_X_OFFSET_LEFT = 17
-- Info is on right side of icon...
local PAUSE_MAP_HIGHLIGHT_TEXT_X_OFFSET_RIGHT = 27
local PAUSE_MAP_HIGHLIGHT_HINTS_X_OFFSET_RIGHT = 35
--Invert scale for std definition... this needs to match the scale of the screen set in cell_forground.lua for standard definition.
-- it is used because coordinates are sent to pause_map.lua in screen space and not translated scale.
local PAUSE_MAP_CURSOR_STD_RES_SCALE = 1.67
local X_FUNC_NO_OP = 0
local X_FUNC_PLACE_BOOKMARK = 1
local X_FUNC_REMOVE_BOOKMARK = 2
local X_FUNC_TAXI = 3
local INTERFACE_EVENT_ADD_GPS = 0
local INTERFACE_EVENT_REMOVE_GPS = 1
local INTERFACE_EVENT_ADD_BOOKMARK = 2
local INTERFACE_EVENT_REMOVE_BOOKMARK = 3
--Icons that are oriented horizontally.
Pause_map_icons_rectangle = {
["map_other_bookmark_a_1"] = true,
["map_other_bookmark_a_2"] = true,
["map_other_bookmark_a_3"] = true,
["map_other_bookmark_a_4"] = true,
["map_other_bookmark_a_5"] = true,
["map_other_bookmark_b_1"] = true,
["map_other_bookmark_b_2"] = true,
["map_other_bookmark_b_3"] = true,
["map_other_bookmark_b_4"] = true,
["map_other_bookmark_b_5"] = true,
["map_other_crib"] = true,
["map_other_crib_4sale"] = true,
["map_other_crib_purchase"] = true,
["map_other_train"] = true,
["map_start_mission_3ss"] = true,
["map_start_mission_bh"] = true,
["map_start_mission_rn"] = true,
["map_start_mission_ss"] = true,
["map_start_mission_ul"] = true,
["map_other_hidden_mission"] = true,
["map_store_property"] = true,
["map_store_property_owned"] = true,
["map_other_collect_drug"] = true,
["map_other_collect_money"] = true,
["map_other_collect_photoop"] = true,
["map_other_collect_sexdoll"] = true,
}
local PAUSE_MAP_GREEN = {R = 136/255, G = 211/255, B = 24/255}
local PAUSE_MAP_BLUE = {R = 25/255, G = 159/255, B = 229/255}
local PAUSE_MAP_YELLOW = {R = 245/255, G = 228/255, B = 68/255}
local PAUSE_MAP_GREY = {R = 170/255, G = 170/255, B = 170/255}
local PAUSE_MAP_PINK = {R = 204/255, G = 73/255, B = 143/255}
local PAUSE_MAP_BROWN = {R = 153/255, G = 69/255, B = 011/255}
PAUSE_MAP_ICON_COLORS = {
--Activities
["map_start_bonusderby"] = PAUSE_MAP_BLUE,
["map_start_chopshop"] = PAUSE_MAP_BLUE,
["map_start_cleansweep"] = PAUSE_MAP_BLUE,
["map_start_crowdcontrol"] = PAUSE_MAP_BLUE,
["map_start_demoderby"] = PAUSE_MAP_BLUE,
["map_start_drugtrafficking"] = PAUSE_MAP_BLUE,
["map_start_escort"] = PAUSE_MAP_BLUE,
["map_start_fightclub"] = PAUSE_MAP_BLUE,
["map_start_fuzz"] = PAUSE_MAP_BLUE,
["map_start_guardianangel"] = PAUSE_MAP_BLUE,
["map_start_heliassault"] = PAUSE_MAP_BLUE,
["map_start_hitman"] = PAUSE_MAP_BLUE,
["map_start_humantorch"] = PAUSE_MAP_BLUE,
["map_start_insfraud"] = PAUSE_MAP_BLUE,
["map_start_mayhem"] = PAUSE_MAP_BLUE,
["map_start_piracy"] = PAUSE_MAP_BLUE,
["map_start_racing"] = PAUSE_MAP_BLUE,
["map_start_snatch"] = PAUSE_MAP_BLUE,
["map_start_taxi"] = PAUSE_MAP_BLUE,
["map_start_flashpoint"] = PAUSE_MAP_PINK,
--Stores
["map_store_cardealer_high"] = PAUSE_MAP_GREEN,
["map_store_cardealer_low"] = PAUSE_MAP_GREEN,
["map_store_clothing"] = PAUSE_MAP_GREEN,
["map_store_food"] = PAUSE_MAP_GREEN,
["map_store_forgive"] = PAUSE_MAP_GREEN,
["map_store_gun"] = PAUSE_MAP_GREEN,
["map_store_jewelry"] = PAUSE_MAP_GREEN,
["map_store_liqour"] = PAUSE_MAP_GREEN,
["map_store_mechanic"] = PAUSE_MAP_GREEN,
["map_store_music"] = PAUSE_MAP_GREEN,
["map_store_surgeon"] = PAUSE_MAP_GREEN,
["map_store_tattoo"] = PAUSE_MAP_GREEN,
["map_store_property"] = PAUSE_MAP_BROWN,
--
["map_store_cardealer_high_4sale"] = PAUSE_MAP_GREEN,
["map_store_cardealer_low_4sale"] = PAUSE_MAP_GREEN,
["map_store_clothing_4sale"] = PAUSE_MAP_GREEN,
["map_store_food_4sale"] = PAUSE_MAP_GREEN,
["map_store_forgive_4sale"] = PAUSE_MAP_GREEN,
["map_store_gun_4sale"] = PAUSE_MAP_GREEN,
["map_store_jewelry_4sale"] = PAUSE_MAP_GREEN,
["map_store_liqour_4sale"] = PAUSE_MAP_GREEN,
["map_store_mechanic_4sale"] = PAUSE_MAP_GREEN,
["map_store_music_4sale"] = PAUSE_MAP_GREEN,
["map_store_surgeon_4sale"] = PAUSE_MAP_GREEN,
["map_store_tattoo_4sale"] = PAUSE_MAP_GREEN,
["map_store_property_4sale"] = PAUSE_MAP_BROWN,
--Other
--Bookmarks
["map_other_bookmark_a_1"] = PAUSE_MAP_GREY,
["map_other_bookmark_a_2"] = PAUSE_MAP_GREY,
["map_other_bookmark_a_3"] = PAUSE_MAP_GREY,
["map_other_bookmark_a_4"] = PAUSE_MAP_GREY,
["map_other_bookmark_a_5"] = PAUSE_MAP_GREY,
["map_other_bookmark_b_1"] = PAUSE_MAP_GREY,
["map_other_bookmark_b_2"] = PAUSE_MAP_GREY,
["map_other_bookmark_b_3"] = PAUSE_MAP_GREY,
["map_other_bookmark_b_4"] = PAUSE_MAP_GREY,
["map_other_bookmark_b_5"] = PAUSE_MAP_GREY,
--Collectables
["map_other_collect_drug"] = PAUSE_MAP_GREY,
["map_other_collect_money"] = PAUSE_MAP_GREY,
["map_other_collect_photoop"] = PAUSE_MAP_GREY,
["map_other_collect_sexdoll"] = PAUSE_MAP_GREY,
--Randoms
["map_other_crib"] = PAUSE_MAP_YELLOW,
["map_other_crib_4sale"] = PAUSE_MAP_YELLOW,
["map_other_crib_purchase"] = PAUSE_MAP_YELLOW,
["map_other_hidden_act"] = PAUSE_MAP_BLUE,
["map_other_hidden_crib"] = PAUSE_MAP_YELLOW,
["map_other_hidden_mission"] = PAUSE_MAP_GREY,
["map_other_hidden_property"] = PAUSE_MAP_BROWN,
["map_other_hidden_store"] = PAUSE_MAP_GREEN,
["map_other_property"] = PAUSE_MAP_GREEN,
["map_other_property_owned"] = PAUSE_MAP_GREEN,
--[[
map_start_mission_3ss
map_start_mission_bh
map_start_mission_rn
map_start_mission_ss
map_start_mission_ul
]]
}
PAUSE_MAP_ICON_SMALL = {
["map_other_hidden_act"] = true,
["map_other_hidden_crib"] = true,
["map_other_hidden_mission"] = true,
["map_other_hidden_store"] = true,
["map_other_hidden_property"] = true,
}
Pause_map_elements = {
base = {
map_grp_h = -1,
map_h = -1,
cursor_h = -1,
info_h = -1
},
filters = {
activities_h = -1,
all_h = -1,
collectibles = -1,
cribs_h = -1,
flashpoints = -1,
missions_h = -1,
none_h = -1,
stores_h = -1,
strongholds_h = -1,
text_h = -1,
},
}
Pause_map_anims = {}
Pause_map = { done = false, }
Map_mask_handle = 0
Filter_list_handle = 0
Hint_bar_bg = 0
Cursor_tool_handle = 0
Pause_map_gamepad_monitor_thread_handle = 0
Pause_map_cursor_status = {
x = -1,
y = -1,
gps_active = false,
x_func = -1,
fade_mode = "in"
}
Pause_map_filter = -1
Pause_map_filter_locked = false
Pause_map_highlight_status = { }
Pause_map_stag_popup = {} --Popup for stag mode...
Pause_map_stag_popup_x = 0
Pause_map_stag_popup_y = 0
Yes_no_choices = {
[1] = {
type = TYPE_BUTTON,
label = "PAUSE_MENU_ACCEPT",
id = 1,
},
[2] = {
type = TYPE_BUTTON,
label = "CONTROL_CANCEL",
id = 2,
},
}
--Default all special modes to false.
Pause_map_tutorial_mode = false
Pause_map_taxi_mode = false
Pause_map_stag_mode = false
Pause_map_underground = false
Pause_map_swapping = false
Pause_map_exit_phone = false
--Local globals...
local Input_tracker --Keeps track on input mapping...
local Mouse_input_tracker = 0
local Filter_mouse_input_tracker = 0
local Hint_bar --Hintbar for main screen.
local PC_hint_bar
local PC_zoom_in
local PC_zoom_out
local Pause_map_control_meter --Control meter
local Pause_map_district_overlays = {} --Table for the district overlays on the map.(LUCHADORES, 25%)
local Pause_map_district_overlays_count = 0
local Main_hint_data_set_gps = {CTRL_MENU_BUTTON_A, "MENU_SET_GPS"}
local Main_hint_data_back = {CTRL_MENU_BUTTON_B, "MENU_BACK"}
local Main_hint_data_back_map = {CTRL_MENU_BUTTON_BACK, "MENU_RESUME_GAME"}
local Main_hint_data_add_bookmark = {CTRL_BUTTON_X, "ADD_BOOKMARK", "B"}
local Main_hint_data_remove_gps = {CTRL_MENU_BUTTON_A, "MENU_REMOVE_GPS"}
local Main_hint_data_remove_bookmark = {CTRL_BUTTON_X, "REMOVE_BOOKMARK", "B"}
local Main_hint_data_taxi = {CTRL_BUTTON_X, "CELL_TAXI_CAB" }
local Main_hint_data_set_gps_rmb = {HINT_BUTTON_RMB_OVERRIDE, "MENU_SET_GPS"}
local Main_hint_data_remove_gps_rmb = {HINT_BUTTON_RMB_OVERRIDE, "MENU_REMOVE_GPS"}
-- Only used for initialization
local Main_hint_data_waypoint_off = {
Main_hint_data_set_gps,
Main_hint_data_back_map,
Main_hint_data_back,
Main_hint_data_add_bookmark,
}
-- Only used for initialization
local Main_hint_data_waypoint_off_pc = {
Main_hint_data_set_gps_rmb,
Main_hint_data_add_bookmark,
}
local Pause_map_hints_stag = {{CTRL_MENU_BUTTON_A, "PAUSE_MAP_STAG_TAKEOVER_HINT"}}
function pause_map_init()
Entered_with_gamepad = game_is_active_input_gamepad()
local pause_map_doc_h = vint_document_find("pause_map")
Map_mask_handle = vint_object_find("map_mask", 0, pause_map_doc_h)
Filter_list_handle = vint_object_find("filter_list", 0, pause_map_doc_h)
Hint_bar_bg = vint_object_find("hint_bar_bg", 0, pause_map_doc_h)
Cursor_tool_handle = vint_object_find("cursor_tool", 0, pause_map_doc_h)
Pause_map_filter = Vdo_cell_filter:new("filter_list")
Pause_map_filter:set_use_icons(true)
Pause_map_control_meter = Vdo_city_control:new("control_meter")
--Set callback for filter changing, the function that is passed here
--tells the game to change the map filter.
Pause_map_filter:filter_callback_set(game_pause_map_filter)
vint_set_property(vint_object_find("pause_map"), "map_mode", "pause_map")
--Set transition in and out events after into/extros
local h = vint_object_find("root_animation")
-- Check if we come from phone or open the map cold
-- Pause_map_from_menu is initialized in cell_foreground
-- and set in cell_menu_main
local map_alpha_out_twn_h = vint_object_find("map_alpha_out_twn")
vint_set_property(map_alpha_out_twn_h, "end_event", "pause_map_hide_c_map")
--Transition elements from our screen in...
--lua_play_anim(map_open_phone_anim_h, 0)
--Make sure our cellphone frame is in view, sometimes we could come straight into this menu...
cell_show_frame()
--Transition screen in...
if Cell_rewards_to_map then
cell_transition_screen(CELL_STATE_LANDSCAPE, CELL_SCREEN_MAP, CELL_SCREEN_NONE, pause_map_trans_in_complete)
elseif Pause_map_from_menu then
cell_transition_screen(CELL_STATE_LANDSCAPE, CELL_SCREEN_MAP, CELL_SCREEN_MAIN, pause_map_trans_in_complete)
else
--fade out header from the foreground...
cell_foreground_fade_out_header()
cell_transition_screen(CELL_STATE_LANDSCAPE, CELL_SCREEN_MAP, CELL_SCREEN_NONE, pause_map_trans_in_complete)
end
--hintbar...
local hint_bar_element_name = "hint_bar"
if game_get_platform() == "PC" then
hint_bar_element_name = "pc_hint_bar"
end
Hint_bar = Vdo_hint_bar:new(hint_bar_element_name)
Hint_bar:enable_mini_mode(true)
--Setup button hints
if game_get_platform() == "PC" then
pause_map_update_button_hints(Main_hint_data_waypoint_off_pc)
else
pause_map_update_button_hints(Main_hint_data_waypoint_off)
end
--Setup Cursor to data_item
vint_dataitem_add_subscription("PAUSE_MAP_CURSOR", "update", "pause_map_cursor_update")
--TODO: Cleanup the following
--Map Elements
local h = vint_object_find("map_grp")
Pause_map_elements.base.cursor_h = vint_object_find("cursor", h)
h = vint_object_find("highlight_grp")
vint_set_property(h, "visible", false)
h = vint_object_find("map_frame")
--Hide info
vint_set_property(vint_object_find("info"), "visible", false)
--Hide original filter
vint_set_property(vint_object_find("filter_type_grp"), "visible", false)
--hide map overlays
vint_set_property(vint_object_find("hood_overlay_grp"), "visible", false)
--Animation find and pause
h = vint_object_find("root_animation")
Pause_map_anims.cursor_fade_anim_h = vint_object_find("cursor_fade_anim", h)
Pause_map_anims.cursor_fade_twn_h = vint_object_find("cursor_fade_twn", Pause_map_anims.cursor_fade_anim_h)
Pause_map_anims.highlight_anim_in_h = vint_object_find("highlight_anim_in", h)
Pause_map_anims.highlight_anim_out_h = vint_object_find("highlight_anim_out", h)
Pause_map_anims.icon_highlight_anim_h = vint_object_find("icon_highlight_anim", h)
--Subscribe to data items
vint_dataitem_add_subscription("PAUSE_MAP_HIGHLIGHT1", "update", "pause_map_highlight_update")
vint_dataitem_add_subscription("PAUSE_MAP_HIGHLIGHT2", "update", "pause_map_highlight_update")
vint_datagroup_add_subscription("map_filter", "update", "pause_map_filters_populate")
vint_datagroup_add_subscription("map_district_names", "update", "pause_map_district_overlay_update")
--Set cash on interface
local cash_txt_h = vint_object_find("cash_value_txt")
vint_set_property(cash_txt_h, "text_tag", "$" .. format_cash(Hud_player_status.cash) .. "\n")
--Set income per day
local income_per_day = get_world_income_dollars()
local income_value_txt_h = vint_object_find("income_value_txt")
vint_set_property(income_value_txt_h, "text_tag", "$" .. format_cash(income_per_day) .. "\n")
Pause_map_stag_mode = pause_map_is_stag_mode()
local stag_grp_h = vint_object_find("stag_grp")
local stag_filter_h = vint_object_find("stag_filter")
Pause_map_tutorial_mode = pause_map_is_tutorial_mode()
local stag_popup_overlay_grp_h = vint_object_find("stag_popup_overlay_grp")
vint_set_property(stag_popup_overlay_grp_h, "visible", false)
if Pause_map_stag_mode == true then
--update help
local stag_grp_h = vint_object_find("stag_grp")
vint_set_property(stag_grp_h, "visible", true)
vint_set_property(stag_filter_h, "visible", true)
-- Move normal map group down to make room for stag group...
local map_info_grp_h = vint_object_find("map_info_grp")
local x, y = vint_get_property(map_info_grp_h, "anchor")
y = 110 --positions the other stuff right below the stag block...
vint_set_property(map_info_grp_h, "anchor", x, y )
--Align instructions for localized text, this spaces our text out properly.
local stag_title_txt_h = vint_object_find("stag_title_txt")
local stag_instructions_txt_h = vint_object_find("stag_instructions_txt")
local align_text_table = {
{h = stag_title_txt_h, type = VINT_OBJECT_TEXT, space = 0},
{h = stag_instructions_txt_h, type = VINT_OBJECT_TEXT, space = 2}
}
local width, height = vint_align_elements(align_text_table)
-- now align group to center, text is center aligned in the document.
-- so current y position minus half the height of our text. Aligns perfectly with the stag logo.
local stag_text_grp_h = vint_object_find("stag_text_grp")
local x, y = vint_get_property(stag_text_grp_h, "anchor")
y = y - (height * .5)
vint_set_property(stag_text_grp_h, "anchor", x, y )
--setup popup...
Pause_map_stag_popup = Vdo_store_popup:new("stag_popup")
Pause_map_stag_popup:set_color({R = 204/255, G = 89/255, B = 10/255}) -- Stag color referenced from our document...
Pause_map_stag_popup:set_size(840, 400)
Pause_map_stag_popup:set_menu_option_text_scale(.9)
Pause_map_stag_popup:populate_list(Yes_no_choices, 2, 840, 2)
Pause_map_stag_popup:set_title("PAUSE_MAP_STAG_POPUP_TITLE")
Pause_map_stag_popup_x, Pause_map_stag_popup_y = Pause_map_stag_popup:get_anchor()
else
--hide any stag related stuff...
vint_set_property(stag_grp_h, "visible", false)
vint_set_property(stag_filter_h, "visible", false)
end
--Lock tutorials
if Pause_map_tutorial_mode == true then
pause_map_tutorial_mode_enable(true)
pause_map_filter_lock(true)
else
pause_map_tutorial_mode_enable(false)
end
-- PC-specific elements
if game_get_platform() == "PC" then
PC_hint_bar = Vdo_hint_bar:new("hint_bar")
else
PC_hint_bar = Vdo_hint_bar:new("pc_hint_bar")
end
PC_zoom_in = Vdo_base_object:new("zoom_in_bmp", 0, pause_map_doc_h)
PC_zoom_out = Vdo_base_object:new("zoom_out_bmp", 0, pause_map_doc_h)
if game_get_platform() == "PC" then
if Pause_map_stag_mode == false then
local hint_data = { Main_hint_data_back, Main_hint_data_back_map }
PC_hint_bar:enable_mini_mode(true)
PC_hint_bar:enable_text_shadow(true)
PC_hint_bar:set_hints(hint_data, false, false) --Entered_with_gamepad, not Entered_with_gamepad)
local width, height = PC_hint_bar:get_size()
width = floor(width)
height = floor(height)
local bg_width, bg_height = element_get_actual_size(Hint_bar_bg, width, height)
local hint_background_padding = 35 -- Additional padding needed for background height
element_set_actual_size(Hint_bar_bg, width + 35, bg_height)
else
PC_hint_bar:set_visible(false)
vint_set_property(Hint_bar_bg, "visible", false)
end
Pause_map_gamepad_monitor_thread_handle = thread_new("pause_map_gamepad_monitor_thread")
else
-- Hide the elements on console
PC_hint_bar:set_visible(false)
PC_zoom_in:set_visible(false)
PC_zoom_out:set_visible(false)
end
end
function pause_map_cleanup()
--Event Tracking(Exit Menu)
game_event_tracking_interface_exit()
if Pause_map_gamepad_monitor_thread_handle ~= 0 then
thread_kill(Pause_map_gamepad_monitor_thread_handle)
end
vint_set_mouse_cursor("")
end
function pause_map_is_taxi_mode(tm)
Pause_map_taxi_mode = (tm == true)
--pause_map_btn_tips_format() -- Can cause a crash if called during finish init
end
--This gets called after diaglog confirming takeover of hood
function pause_map_stag_exit()
--close cell phone
Pause_map_exit_phone = true
pause_map_close()
vint_dataresponder_post("cell_menu_state_dr", "Set", ID_MAIN) --Load cell phone next time
--set up delayed reward screen (cash and respect only)
if Pause_map_stag_mode then
pause_map_stag_takeover_do_reward()
end
end
-- This gets called from code when the 'A' button is pressed in STAG takeover mode
-- and the cursor is over a valid hood
function pause_map_stag_completion()
--A button is pressed bring up poopup...
local stag_popup_overlay_grp_h = vint_object_find("stag_popup_overlay_grp")
vint_set_property(stag_popup_overlay_grp_h, "visible", true)
local insert_string = "PAUSE_MAP_STAG_POPUP_BODY"
if Completion_is_client() then
insert_string = "PAUSE_MAP_STAG_POPUP_BODY_CLIENT"
end
local percent_hood_owned = {[0] = floor(100 * pause_map_stag_current_district_control())}
local percent_string = vint_insert_values_in_string(insert_string, percent_hood_owned)
Pause_map_stag_popup:set_text(percent_string)
--Reset Position because of new text...
local width, height = Pause_map_stag_popup:get_size()
Pause_map_stag_popup:set_anchor(Pause_map_stag_popup_x, Pause_map_stag_popup_y- height)
Pause_map_stag_popup:nav_enable(true, "pause_map_stag_popup_select", "pause_map_stag_popup_nav")
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:subscribe(false)
end
if Filter_mouse_input_tracker ~= 0 then
Filter_mouse_input_tracker:subscribe(false)
end
vint_set_mouse_cursor("")
game_UI_audio_play("UI_Main_Menu_Select")
end
-----------------------------------------------
-- Closes pause map
-----------------------------------------------
function pause_map_close()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:subscribe(false)
end
if Filter_mouse_input_tracker ~= 0 then
Filter_mouse_input_tracker:subscribe(false)
end
if Pause_map_exit_phone then
-- game_UI_audio_play("UI_Cell_Close")
cell_transition_screen(CELL_STATE_OUT, CELL_SCREEN_NONE, CELL_SCREEN_MAP, pause_map_trans_out_complete)
else
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_MAP, pause_map_trans_out_complete)
game_UI_audio_play("UI_Cell_Nav_Back")
end
end
-----------------------------------------------
-- After all the map slides in, this sets up
-- subscrptions and shit
-----------------------------------------------
function pause_map_trans_in_complete()
-- Track Input
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("dpad_up", "pause_map_filter_nav", 50)
Input_tracker:add_input("dpad_down", "pause_map_filter_nav", 50)
Input_tracker:add_input("map", "pause_map_input", 50)
Input_tracker:add_input("back", "pause_map_input", 50)
Input_tracker:add_input("select", "pause_map_input_button_a", 50)
if game_get_platform() == "PC" then
Input_tracker:add_input("scancode", "pause_map_filter_nav", 50, false, 59) -- F1 key
Input_tracker:add_input("scancode", "pause_map_input_button_x", 50, false, 48)
Input_tracker:add_input("gamepad_x", "pause_map_input_button_x", 50)
else
Input_tracker:add_input("alt_select", "pause_map_input_button_x", 50)
end
Input_tracker:subscribe(true)
if game_get_platform() == "PC" then
local filter_list_visible = vint_get_property(Filter_list_handle, "visible")
if Pause_map_stag_mode == false or filter_list_visible then
Filter_mouse_input_tracker = Vdo_input_tracker:new()
Pause_map_filter:add_mouse_inputs("pause_map", Filter_mouse_input_tracker)
Filter_mouse_input_tracker:subscribe(true)
end
Mouse_input_tracker = Vdo_input_tracker:new()
if Pause_map_stag_mode == false or filter_list_visible then
Mouse_input_tracker:add_mouse_input("mouse_click", "pause_map_mouse_move", 50, Filter_list_handle)
Mouse_input_tracker:add_mouse_input("mouse_move", "pause_map_mouse_move", 50, Filter_list_handle)
vint_set_property(Filter_list_handle, "mouse_depth", -4000)
end
Mouse_input_tracker:add_mouse_input("mouse_right_click", "pause_map_mouse_right_click", 50, Map_mask_handle)
Mouse_input_tracker:add_mouse_input("mouse_middle_click", "pause_map_mouse_middle_click", 50, Map_mask_handle)
Mouse_input_tracker:add_mouse_input("mouse_move", "pause_map_mouse_move", 50, Map_mask_handle)
Mouse_input_tracker:add_mouse_input("mouse_click", "pause_map_mouse_move", 50, Map_mask_handle)
Mouse_input_tracker:add_mouse_input("mouse_drag", "pause_map_mouse_drag", 50, Map_mask_handle)
Mouse_input_tracker:add_mouse_input("mouse_drag_release", "pause_map_mouse_drag_release", 50, Map_mask_handle)
-- Zoom buttons
Mouse_input_tracker:add_mouse_input("mouse_move", "pause_map_mouse_move", 50, PC_zoom_in.handle)
Mouse_input_tracker:add_mouse_input("mouse_click", "pause_map_mouse_click", 50, PC_zoom_in.handle)
Mouse_input_tracker:add_mouse_input("mouse_move", "pause_map_mouse_move", 50, PC_zoom_out.handle)
Mouse_input_tracker:add_mouse_input("mouse_click", "pause_map_mouse_click", 50, PC_zoom_out.handle)
--Mouse_input_tracker:add_mouse_input("mouse_click", "pause_map_mouse_click", 50, Hint_bar_bg)
--vint_set_property(Hint_bar_bg, "mouse_depth", -4004)
PC_hint_bar:add_mouse_inputs("pause_map", Mouse_input_tracker)
--vint_set_property(PC_hint_bar.handle, "mouse_depth", -4003)
Mouse_input_tracker:subscribe(true)
end
end
function pause_map_trans_out_complete()
pop_screen();
if Pause_map_exit_phone == true then
pop_screen(); -- exit the phone completely
pop_screen(); -- pop off the cell phone fore/background
end
end
function pause_map_input(event, accelleration)
if Pause_map_stag_mode then
--cannot exit during stag mode...
return
end
if event == "map" then
--Close the interface
Pause_map_exit_phone = true
pause_map_close()
vint_dataresponder_post("cell_menu_state_dr", "Set", ID_MAP) --come back to the map next time
elseif event == "back" then
Pause_map_exit_phone = false
pause_map_close()
vint_dataresponder_post("cell_menu_state_dr", "Set", ID_MAIN) --Load cell phone next time
end
end
-------------------------------------------------------------------------------
-- Adds a filter to the list. Should be called via data responder.
--
-- @param filter_type String indicating filter type
-- @param filter_name String of actual filter name
-- @param x X# of icons for the filter left to complete
-- @param y Y# of icons total for the filter
-------------------------------------------------------------------------------
function pause_map_filters_populate(di_h)
local filter_type, filter_name, x, y = vint_dataitem_get(di_h)
-- If we get PFT_ALL (always the first item), then we need to rebuild the list
if filter_type == "PFT_ALL" then
if Filter_mouse_input_tracker ~= 0 then
Filter_mouse_input_tracker:subscribe(false)
Filter_mouse_input_tracker:remove_all()
end
Pause_map_filter:clear()
end
-- Add item to list...
Pause_map_filter:add(filter_type, filter_name, x, y)
if filter_type == "PFT_NONE" then
--Last Item in list... now update...
local current_mode = game_pause_map_filter()
if current_mode == "PFT_FILTER_LOCKED" then
pause_map_filter_lock(true)
--Hide the filters...
Pause_map_filter:set_visible(false)
--Hide player info...
vint_set_property(vint_object_find("player_info_grp"), "visible", false)
return
end
if Pause_map_stag_mode then
--Stag filter change
Pause_map_filter:change_filter_by_type("PFT_ALL", false)
pause_map_filter_lock(true)
Pause_map_filter:set_visible(false)
--Hide player info...
vint_set_property(vint_object_find("player_info_grp"), "visible", false)
else
--Change filter
Pause_map_filter:change_filter_by_type(current_mode, false)
end
--List is completed...
pause_map_adjust_layout()
if Filter_mouse_input_tracker ~= 0 then
Pause_map_filter:add_mouse_inputs("pause_map", Filter_mouse_input_tracker)
Filter_mouse_input_tracker:subscribe(true)
end
end
end
-------------------------------------------------------------------------------
-- Navigating for filters
-- This is a callback setup via input tracker for changing filters.
-------------------------------------------------------------------------------
function pause_map_filter_nav(event, accelleration)
if Pause_map_filter_locked == true then
--do not nav the filters...
return
end
--Check event type and move cursor...
if event == "dpad_up" then
Pause_map_filter:move_cursor(-1)
elseif event == "dpad_down" or event == "scancode" then
Pause_map_filter:move_cursor(1)
end
game_UI_audio_play("UI_Cell_Nav")
end
function pause_map_input_button_a()
pause_map_set_gps()
end
function pause_map_input_button_x()
pause_map_add_bookmark()
end
-------------------------------------------------------------------------------
-- Turns screen into a locked mode where the user can't interact with filters
-- at all.
-- @param is_locked (Bool) Determines if the screen should be locked or not
-------------------------------------------------------------------------------
function pause_map_filter_lock(is_locked)
Pause_map_filter_locked = is_locked
--Hide the filters...
Pause_map_filter:set_visible(is_locked)
end
function pause_map_adjust_layout()
--Hood width
local district_name_txt_h = vint_object_find("district_name_txt")
local hood_name_txt_h = vint_object_find("hood_name_txt")
local data = {
district_name_txt_h,
hood_name_txt_h,
}
local widest_element_h, hood_width = find_widest_text_element(data)
local widest_element_x, widest_element_y = 0, 0
if widest_element_h ~= 0 then
widest_element_x, widest_element_y = vint_get_property(widest_element_h, "anchor")
end
hood_width = hood_width + widest_element_x
--Cash Width
local cash_label_txt_h = vint_object_find("cash_label_txt")
local income_label_txt_h = vint_object_find("income_label_txt")
local data = {
cash_label_txt_h,
income_label_txt_h,
}
local widest_element_h, cash_width = find_widest_text_element(data)
local income_value_txt_h = vint_object_find("income_value_txt")
local cash_value_txt_h = vint_object_find("cash_value_txt")
local data = {
income_value_txt_h,
cash_value_txt_h,
}
local widest_element_h, cash_value_width = find_widest_text_element(data)
local cash_label_x, cash_label_y = vint_get_property(cash_label_txt_h, "anchor")
local income_x, income_y = vint_get_property(income_value_txt_h, "anchor")
local cash_x, cash_y = vint_get_property(cash_value_txt_h, "anchor")
local player_cash_width = cash_label_x + cash_width + cash_value_width + 10
--Get Filter Width...
local filter_element_width = Pause_map_filter:adjust_layout()
local bg_width = 290
--Hood Info
bg_width = max(bg_width, hood_width)
if Pause_map_stag_mode then
bg_width = max(bg_width, 300) --Stag bg width hardcode.
end
if not Pause_map_stag_mode then
--Filter width...
bg_width = max(bg_width, filter_element_width)
--Player Cash width
bg_width = max(bg_width, player_cash_width)
end
--Reset Width of filters...
Pause_map_filter:adjust_layout(bg_width)
--Reset width of cash values.
local player_info_bg_h = vint_object_find("player_info_bg")
vint_set_property(income_value_txt_h, "anchor", bg_width, income_y)
vint_set_property(cash_value_txt_h, "anchor", bg_width, cash_y)
--pad out the width for our backgrounds
bg_width = bg_width + 10
--filter padding...
local filter_bg_h = vint_object_find("filter_bg")
local hood_info_bg_h = vint_object_find("hood_info_bg")
local width, height = element_get_actual_size(filter_bg_h)
element_set_actual_size(filter_bg_h, bg_width, height)
width, height = element_get_actual_size(hood_info_bg_h)
element_set_actual_size(hood_info_bg_h, bg_width, height)
local stag_bg_h = vint_object_find("stag_bg")
width, height = element_get_actual_size(stag_bg_h)
element_set_actual_size(stag_bg_h, bg_width, height)
local player_info_bg_width, player_info_bg_height = element_get_actual_size(player_info_bg_h)
element_set_actual_size(player_info_bg_h, bg_width, player_info_bg_height)
end
--------------------------------------------------
--Highlight Update
--------------------------------------------------
function anim_out_complete(tween_h)
for idx, val in pairs(Pause_map_highlight_status) do
if val.last_tween_out == tween_h then
local status = Pause_map_highlight_status[idx]
vint_object_destroy(status.info_h)
vint_object_destroy(status.in_anim_h)
vint_object_destroy(status.out_anim_h)
vint_object_destroy(status.icon_highlight_anim_h)
Pause_map_highlight_status[idx] = nil
break
end
end
end
function anim_in_complete()
debug_print("vint", "anim_in_complete \n")
Pause_map.done = true
end
-------------------------------------------------------------------------------
-- Updates the highlight on the pause map... this is done via 2 dataitems that
-- Swap
-- DATAITEM: PAUSE_MAP_HIGHLIGHT1, PAUSE_MAP_HIGHLIGHT2
-- @param icon_bmp_name,
-- @param text_line_1 -- First line
-- @param text_line_2 -- Second Line
-- @param text_line_3 -- Third Line (Left)
-- @param text_line_4 -- Fourth Line (Right)
-- @param is_highlighted -- Is Highlighted? (Are we over the icon or off)
-- @param is_gps_target -- Is the thing a gps target?
-- @param is_mad_icon -- Is the thing a mad icon?
-- @param is_store_icon -- Is the thing a store icon?
-- @param is_crib_icon -- Is the thing a crib icon?
-- @param taxi_available -- Is there a taxi available?
-------------------------------------------------------------------------------
function pause_map_highlight_update(di_h)
-- Get dataitem...
local icon_bmp_name, overlay_bmp_name, text_line_1, text_line_2, text_line_3, text_line_4, is_highlighted, is_gps_target, is_mad_icon, is_store_icon, is_crib_icon, taxi_available = vint_dataitem_get(di_h)
--dataitem_to_debug(di_h, "icon_bmp_name", "text_line_1", "text_line_2", "text_line_3", "text_line_4", "is_highlighted", "is_gps_target", "taxi_available")
--Exit if there is no icon
if icon_bmp_name == nil then
return
end
local status = Pause_map_highlight_status[di_h]
--Check to see if the highlight/info element has been created then initalize the element if it hasn't.
if status == nil then
--Clone the object and find targets.
local info_h = vint_object_clone(vint_object_find("highlight_grp"))
local icon_h = vint_object_find("icon", info_h)
local icon_highlight_h = vint_object_find("icon_highlight", info_h)
local icon_overlay_h = vint_object_find("icon_overlay", info_h)
local lock_h = vint_object_find("lock", info_h)
local text_grp_h = vint_object_find("text_grp", info_h)
local text_line_1_h = vint_object_find("line_1_txt", info_h)
local text_line_2_h = vint_object_find("line_2_txt", info_h)
local text_line_3_h = vint_object_find("line_3_txt", info_h)
local text_line_4_h = vint_object_find("line_4_txt", info_h)
--Clone, Retarget, and Pause Animations
local in_anim_h = vint_object_clone(Pause_map_anims.highlight_anim_in_h)
local out_anim_h = vint_object_clone(Pause_map_anims.highlight_anim_out_h)
local icon_highlight_anim_h = vint_object_clone(Pause_map_anims.icon_highlight_anim_h)
vint_set_property(in_anim_h, "is_paused", true)
vint_set_property(out_anim_h, "is_paused", true)
vint_set_property(icon_highlight_anim_h, "is_paused", true)
vint_set_property(in_anim_h, "target_handle", info_h)
vint_set_property(out_anim_h, "target_handle", info_h)
vint_set_property(icon_highlight_anim_h, "target_handle", info_h)
local hint_bar = Vdo_hint_bar:new("hint_bar_highlight", info_h)
hint_bar:enable_mini_mode(true) --Make hintbar mini!
Pause_map_highlight_status[di_h] = {
info_h = info_h,
in_anim_h = in_anim_h,
out_anim_h = out_anim_h,
hint_bar = hint_bar,
icon_highlight_anim_h = icon_highlight_anim_h,
icon_h = icon_h,
icon_highlight_h = icon_highlight_h,
icon_overlay_h = icon_overlay_h,
lock_h = lock_h,
text_grp_h = text_grp_h,
text_line_1_h = text_line_1_h,
text_line_2_h = text_line_2_h,
text_line_3_h = text_line_3_h,
text_line_4_h = text_line_4_h,
icon_bmp_name = -1,
overlay_bmp_name = -1,
text_line_1 = -1,
text_line_2 = -1,
text_line_3 = -1,
text_line_4 = -1,
text_width = -1,
text_height = -1,
alignment = "left",
is_highlighted = -1,
is_gps_target = -1,
}
status = Pause_map_highlight_status[di_h]
end
--Create locals from the status table
local info_h = status.info_h
local icon_h = status.icon_h
local icon_highlight_h = status.icon_highlight_h
local icon_overlay_h = status.icon_overlay_h
local text_grp_h = status.text_grp_h
local lock_h = status.lock_h
local text_line_1_h = status.text_line_1_h
local text_line_2_h = status.text_line_2_h
local text_line_3_h = status.text_line_3_h
local text_line_4_h = status.text_line_4_h
--Set Icon bitmap
if icon_bmp_name ~= status.icon_bmp_name or overlay_bmp_name ~= status.overlay_bmp_name then
vint_set_property(icon_h, "image", icon_bmp_name)
vint_set_property(icon_h, "alpha", 0)
vint_set_property(icon_highlight_h, "image", icon_bmp_name)
vint_set_property(icon_highlight_h, "alpha", 0)
--Set overlay image (e.g. 4sale)
vint_set_property(icon_overlay_h, "image", overlay_bmp_name)
vint_set_property(icon_overlay_h, "alpha", 0)
status.icon_bmp_name = icon_bmp_name
status.overlay_bmp_name = overlay_bmp_name
end
--Determine if we are going to show the overlay image...
if status.overlay_bmp_name ~= "" then
vint_set_property(icon_overlay_h, "visible", true)
else
vint_set_property(icon_overlay_h, "visible", false)
end
--vint_set_property(info_h, "anchor", position_x, position_y) --Set screen coordinate positions
vint_set_property(info_h, "visible", true) --show item
--Adjust angle of the lock on graphic based on the icon name
if Pause_map_icons_rectangle[icon_bmp_name] == true then
vint_set_property(lock_h, "rotation", 0)
else
vint_set_property(lock_h, "rotation", .78)
end
-- Re-Scale the lock icon that goes around the icon in the tween...
local in_twn_h = vint_object_find("lock_scale_twn", status.in_anim_h)
local out_twn_h = vint_object_find("lock_scale_twn", status.out_anim_h)
if PAUSE_MAP_ICON_SMALL[icon_bmp_name] == true then
vint_set_property(in_twn_h, "end_value", .75, .75)
vint_set_property(out_twn_h, "start_value", .75, .75)
else
vint_set_property(in_twn_h, "end_value", 1.0, 1.0)
vint_set_property(out_twn_h, "start_value", 1.0, 1.0)
end
--Set color of highlight bar
local cursor_line_h = vint_object_find("cursor_line_bg", info_h)
local color = PAUSE_MAP_ICON_COLORS[icon_bmp_name]
if color then
vint_set_property(cursor_line_h, "tint", color.R, color.G, color.B)
else
vint_set_property(cursor_line_h, "tint", PAUSE_MAP_GREY.R, PAUSE_MAP_GREY.G, PAUSE_MAP_GREY.B)
end
-- Hintbar
local hint_data
if taxi_available then
hint_data = {
{CTRL_MENU_BUTTON_A, "MENU_GPS"},
{CTRL_BUTTON_X, "CELL_TAXI_CAB"}
}
else
if game_get_platform() == "PC" then
hint_data = {
{HINT_BUTTON_RMB_OVERRIDE, "MENU_GPS"}
}
else
hint_data = {
{CTRL_MENU_BUTTON_A, "MENU_GPS"}
}
end
end
if Pause_map_stag_mode then
hint_data = nil
local hint_bar_highlight_bg_h = vint_object_find("hint_bar_highlight_bg", info_h)
vint_set_property(hint_bar_highlight_bg_h, "visible", false)
end
status.hint_bar:set_hints(hint_data, false, false)--Entered_with_gamepad, not Entered_with_gamepad)
--Set text tags
vint_set_property(text_line_1_h, "text_tag", text_line_1)
vint_set_property(text_line_2_h, "text_tag", text_line_2)
vint_set_property(text_line_3_h, "text_tag", text_line_3)
vint_set_property(text_line_4_h, "text_tag", text_line_4)
--Now update boxes... We will calculate vertical size first for each box...
local box_height_new = 55 --Fullsize
local hint_y_offset = 15
--If text tags equal nil then we need to set the string to ""
if text_line_4 == nil or text_line_4 == "" then
text_line_4 = ""
end
if text_line_3 == nil or text_line_3 == "" then
text_line_3 = ""
box_height_new = 30
end
if text_line_2 == nil or text_line_2 == "" then
text_line_2 = ""
box_height_new = 1
box_height_new = 1
hint_y_offset = 15
end
if text_line_1 == nil or text_line_1 == "" then
text_line_1 = ""
box_height_new = 1
hint_y_offset = 0
end
--Get the largets width of the text... so we know what to do...
if text_line_1 ~= status.text_line_1 or text_line_2 ~= status.text_line_2 or text_line_3 ~= status.text_line_3 or text_line_4 ~= status.text_line_4 then
--Get Largest text width and height
local text_width = 0
local text_height = 0
local temp1_width, temp1_height = element_get_actual_size(text_line_1_h)
local temp2_width, temp2_height = element_get_actual_size(text_line_2_h)
local temp3_width, temp3_height = element_get_actual_size(text_line_3_h)
local temp4_width, temp4_height = element_get_actual_size(text_line_4_h)
local temp3_x, temp3_y = vint_get_property(text_line_1_h, "anchor")
local temp4_x, temp4_y = vint_get_property(text_line_4_h, "anchor")
local temp4_width = temp4_width + temp4_x - temp3_x
local hintbar_width, hintbar_height = status.hint_bar:get_size()
text_width = max(temp1_width, text_width)
text_width = max(temp2_width, text_width)
text_width = max(temp3_width, text_width)
text_width = max(temp4_width, text_width)
text_width = max(hintbar_width, text_width)
text_width = text_width + 40
--Resize boxes...
local box_h = vint_object_find("cursor_bg", info_h)
local hint_bar_highlight_bg_h = vint_object_find("hint_bar_highlight_bg", info_h)
local hint_bar_bg_width, hint_bar_bg_height = element_get_actual_size(hint_bar_highlight_bg_h)
local box_width, box_height = element_get_actual_size(box_h)
local cursor_line_width, cursor_line_height = element_get_actual_size(cursor_line_h)
-- Colored box (No that is not racist)
element_set_actual_size(cursor_line_h, text_width, cursor_line_height)
-- Backgorund for descripton text...
element_set_actual_size(box_h, text_width, box_height_new)
--Hintbar...
local hint_grp_h = vint_object_find("highlight_hint_grp", info_h)
local x, y = vint_get_property(hint_grp_h, "anchor")
vint_set_property(hint_grp_h, "anchor", x, box_height_new + hint_y_offset)
element_set_actual_size(hint_bar_highlight_bg_h, text_width, hint_bar_bg_height )
--Invert highlight or not?'
local invert = false
local right_side_of_box = Pause_map_cursor_status.x + text_width
if right_side_of_box > 900 then
invert = true
end
if invert then
--Move group elements... (Boxes)
local x, y = vint_get_property(hint_grp_h, "anchor")
vint_set_property(hint_grp_h, "anchor", -text_width, y)
local x, y = vint_get_property(text_grp_h, "anchor")
vint_set_property(text_grp_h, "anchor", -text_width, y)
--Move insides of boxes
local hint_bar_highlight_h = vint_object_find("hint_bar_highlight", hint_grp_h)
local x, y = vint_get_property(hint_bar_highlight_h, "anchor")
vint_set_property(hint_bar_highlight_h, "anchor", PAUSE_MAP_HIGHLIGHT_HINTS_X_OFFSET_LEFT, y)
local text_items_grp_h = vint_object_find("text_items_grp", text_grp_h)
local x, y = vint_get_property(text_items_grp_h, "anchor")
vint_set_property(text_items_grp_h, "anchor", PAUSE_MAP_HIGHLIGHT_TEXT_X_OFFSET_LEFT, y)
else
--Move group elements... (Boxes)
local x, y = vint_get_property(hint_grp_h, "anchor")
vint_set_property(hint_grp_h, "anchor", 0, y)
local x, y = vint_get_property(text_grp_h, "anchor")
vint_set_property(text_grp_h, "anchor", 0, y)
--Move insides of boxes
local hint_bar_highlight_h = vint_object_find("hint_bar_highlight", hint_grp_h)
local x, y = vint_get_property(hint_bar_highlight_h, "anchor")
vint_set_property(hint_bar_highlight_h, "anchor", PAUSE_MAP_HIGHLIGHT_HINTS_X_OFFSET_RIGHT, y)
local text_items_grp_h = vint_object_find("text_items_grp", text_grp_h)
local x, y = vint_get_property(text_items_grp_h, "anchor")
vint_set_property(text_items_grp_h, "anchor", PAUSE_MAP_HIGHLIGHT_TEXT_X_OFFSET_RIGHT, y)
end
--Store values
status.text_width = text_width
status.text_height = text_height
status.text_line_1 = text_line_1
status.text_line_2 = text_line_2
status.text_line_3 = text_line_3
status.text_line_4 = text_line_4
end
--If the highlighted item changes state the we need to change how it is displayed
if is_highlighted ~= status.is_highlighted then
--1. Check if we need to fade in or fade out the info box
if is_highlighted == true then
--Reset elements
vint_set_property(vint_object_find("bg_wrapper",info_h), "alpha", 0)
vint_set_property(status.text_grp_h, "alpha", 0)
vint_set_property(status.out_anim_h, "is_paused", true) --Pause the out animation
lua_play_anim(status.in_anim_h, 0) --Play in animation
lua_play_anim(status.icon_highlight_anim_h, 0)
Pause_map.done = false
elseif is_highlighted == false then
--if the fade in tweens are done, then its ok to fade them out
if Pause_map.done == true then
vint_set_property(status.in_anim_h, "is_paused", true) --Pause the in animation
local alpha = vint_get_property(status.text_grp_h, "alpha")
vint_set_property(vint_object_find("txt_grp_alpha_twn_1",status.out_anim_h), "start_value", alpha)
lua_play_anim(status.out_anim_h, 0)
else
--if fade in tweens arent finished, just destroy them
vint_object_destroy(status.info_h)
vint_object_destroy(status.in_anim_h)
vint_object_destroy(status.out_anim_h)
vint_object_destroy(status.icon_highlight_anim_h)
Pause_map_highlight_status[di_h] = nil
end
end
status.is_highlighted = is_highlighted
--2. Fade the cursor if highlight and cursor state have changed
local is_active = false
for idx, val in pairs(Pause_map_highlight_status) do
if val.is_highlighted == true then
is_active = true
break
end
end
if is_active == true then
if Pause_map_cursor_status.fade_mode == "in" then
--Fade out Cursor
local current_alpha = vint_get_property(Pause_map_elements.base.cursor_h, "alpha")
vint_set_property(Pause_map_anims.cursor_fade_twn_h, "start_value", current_alpha)
vint_set_property(Pause_map_anims.cursor_fade_twn_h, "end_value", 0)
lua_play_anim(Pause_map_anims.cursor_fade_anim_h, 0)
Pause_map_cursor_status.fade_mode = "out"
end
else
if Pause_map_cursor_status.fade_mode == "out" then
--Fade In Cursor
local current_alpha = vint_get_property(Pause_map_elements.base.cursor_h, "alpha")
vint_set_property(Pause_map_anims.cursor_fade_twn_h, "start_value", current_alpha)
vint_set_property(Pause_map_anims.cursor_fade_twn_h, "end_value", 1)
lua_play_anim(Pause_map_anims.cursor_fade_anim_h, 0)
Pause_map_cursor_status.fade_mode = "in"
end
end
end
-- This functionality causes inconsistant results... taking it out (JMH 7/29/2011)
-- if is_gps_target == true then
-- vint_set_property(lock_h, "tint", 0,1,0)
-- else
-- vint_set_property(lock_h, "tint", 1,1,1)
-- end
if is_highlighted == true and is_mad_icon == true then
game_UI_audio_play("UI_Cell_Hover_MAD")
elseif is_highlighted == true and is_store_icon == true then
game_UI_audio_play("UI_Cell_Hover_Store")
elseif is_highlighted == true and is_crib_icon == true then
game_UI_audio_play("UI_Cell_Hover_MAD")
end
end
-------------------------------------------------------------------------------
-- Updates the pause map cursor and other navigational style elements via Dataitem.
--
-- DATAITEM:
-- @param cursor_x Position of the cursor, relative to the upper left of the pause_map object.
-- @param cursor_y Position of the cursor, relative to the upper left of the pause_map object.
-- @param highlight_icon_x Position of the highlighted icon, relative to the upper left of the pause_map object.
-- @param highlight_icon_y Position of the highlighted icon, relative to the upper left of the pause_map object.
-- @param gps_active Is the GPS Active?
-- @param district_str --District name
-- @param hood_str --Hood Name
-- @param control_pct --control percentage for the district
-------------------------------------------------------------------------------
function pause_map_cursor_update(di_h)
--Get data from dataitem...
local cursor_x, cursor_y, highlight_icon_x, highlight_icon_y, gps_active, x_func, district_str, hood_str, control_pct = vint_dataitem_get(di_h)
--Translate cursor position...
if vint_is_std_res() then
cursor_x = cursor_x * PAUSE_MAP_CURSOR_STD_RES_SCALE
cursor_y = cursor_y * PAUSE_MAP_CURSOR_STD_RES_SCALE
highlight_icon_x = highlight_icon_x * PAUSE_MAP_CURSOR_STD_RES_SCALE
highlight_icon_y = highlight_icon_y * PAUSE_MAP_CURSOR_STD_RES_SCALE
end
-- NOTE: when no icon is highlighted, highlight_icon_x, highlight_icon_y is 0,0
--Update the cursor position on the screen...
local cursor_h = vint_object_find("cursor")
vint_set_property(cursor_h, "anchor", cursor_x, cursor_y)
Pause_map_cursor_status.x = cursor_x
Pause_map_cursor_status.y = cursor_y
--Offset icon from the cursor, because the location could be at a different spot.
if highlight_icon_x ~= 0 or highlight_icon_y ~=0 then
for idx, val in pairs(Pause_map_highlight_status) do
if val.info_h ~= nil then
local x = highlight_icon_x - cursor_x
local y = highlight_icon_y - cursor_y
vint_set_property(val.info_h, "anchor", x, y)
end
end
end
--Update button tips depending on if the GPS is active or not...
if gps_active ~= Pause_map_cursor_status.gps_active or x_func ~= Pause_map_cursor_status.x_func then
local main_hint_bar = { }
if game_get_platform() == "PC" then
if gps_active == true then
main_hint_bar[#main_hint_bar + 1] = Main_hint_data_remove_gps_rmb
else
main_hint_bar[#main_hint_bar + 1] = Main_hint_data_set_gps_rmb
end
else
if gps_active == true then
main_hint_bar[#main_hint_bar + 1] = Main_hint_data_remove_gps
else
main_hint_bar[#main_hint_bar + 1] = Main_hint_data_set_gps
end
end
if game_get_platform() ~= "PC" then
main_hint_bar[#main_hint_bar + 1] = Main_hint_data_back
main_hint_bar[#main_hint_bar + 1] = Main_hint_data_back_map
end
if Pause_map_tutorial_mode == false then
--book mark only available in normal mode...
if x_func == X_FUNC_PLACE_BOOKMARK then
main_hint_bar[#main_hint_bar + 1] = Main_hint_data_add_bookmark
elseif x_func == X_FUNC_TAXI then
main_hint_bar[#main_hint_bar + 1] = Main_hint_data_taxi
elseif x_func == X_FUNC_REMOVE_BOOKMARK then
main_hint_bar[#main_hint_bar + 1] = Main_hint_data_remove_bookmark
end
end
if Pause_map_stag_mode == true then
pause_map_update_button_hints(Pause_map_hints_stag)
else
pause_map_update_button_hints(main_hint_bar)
end
Pause_map_cursor_status.gps_active = gps_active
Pause_map_cursor_status.x_func = x_func
end
--Update Contact information...
local district_name_txt_h = vint_object_find("district_name_txt")
local hood_name_txt_h = vint_object_find("hood_name_txt")
local hood_info_grp_h = vint_object_find("hood_info_grp")
--Set District Name
vint_set_property(district_name_txt_h, "text_tag", district_str)
--Set hood name...
vint_set_property(hood_name_txt_h, "text_tag", hood_str)
--Update control pct...
if district_str == "" then
Pause_map_control_meter:set_visible(false)
else
Pause_map_control_meter:set_visible(true)
Pause_map_control_meter:update(control_pct, false)
end
pause_map_adjust_layout()
end
-------------------------------------------------------------------------------
-- Updates the pause map cursor and other navigational style elements via Datagroup.
--
-- DATAGROUP:
-- @param district_str String of the district name.
-- @param district_pct This is the percentage the player has control of the district...
-- @param position_x Position of the item, relative to the upper left of the pause_map object.
-- @param position_y Position of the item, relative to the upper left of the pause_map object.
-- @param scale Scale of the item in relation to the map...
-- @param is_visible Is the overlay visible, this is flagged to false if the overlay should be hidden...
-------------------------------------------------------------------------------
function pause_map_district_overlay_update(di_h)
--Check to see if we havn't updated this item before... if we havn't we need to clone a group for it...
if Pause_map_district_overlays[di_h] == nil then
--Clone overlay item...
local grp_h = vint_object_find("hood_overlay_grp")
grp_h = vint_object_clone(grp_h)
vint_set_property(grp_h, "visible", true)
vint_set_property(grp_h, "alpha", 0)
local anim_h = vint_object_find("hood_overlay_fade_anim")
anim_h = vint_object_clone(anim_h)
vint_set_property(anim_h, "target_handle", grp_h)
--Store it to a table...
Pause_map_district_overlays[di_h] = {
grp_h = grp_h,
anim_h = anim_h,
is_visible = -1
}
Pause_map_district_overlays_count = Pause_map_district_overlays_count + 1
end
--Update the overlay...
--Find overlay we stored in the table...
local grp_h = Pause_map_district_overlays[di_h].grp_h
--Get data out of dataitem
local district_str, district_pct, position_x, position_y, scale, is_visible = vint_dataitem_get(di_h)
--Update visibility...
if is_visible ~= Pause_map_district_overlays[di_h].is_visible then
local target_alpha = 1.0
if is_visible == false then
--Going to fade out...
target_alpha = 0
end
--Find animation to fade in or out...
local anim_h = Pause_map_district_overlays[di_h].anim_h
--Set properties for tween to current alpha of the object and the target value...
local hood_overlay_fade_twn_h = vint_object_find("hood_overlay_fade_twn", anim_h)
local current_alpha = vint_get_property(grp_h, "alpha")
vint_set_property(hood_overlay_fade_twn_h, "start_value", current_alpha)
vint_set_property(hood_overlay_fade_twn_h, "end_value", target_alpha)
--Play the animation...
lua_play_anim(anim_h)
--Store to global...
Pause_map_district_overlays[di_h].is_visible = is_visible
end
--Update text...
local hood_overlay_district_txt_h = vint_object_find("hood_overlay_district_txt", grp_h)
local hood_overlay_pct_txt_h = vint_object_find("hood_overlay_pct_txt", grp_h)
vint_set_property(hood_overlay_district_txt_h, "text_tag", district_str)
local district_pct_string = floor((district_pct * 100) + .5) .. "%%"
vint_set_property(hood_overlay_pct_txt_h, "text_tag", district_pct_string)
if vint_is_std_res() then
position_x = position_x * PAUSE_MAP_CURSOR_STD_RES_SCALE
position_y = position_y * PAUSE_MAP_CURSOR_STD_RES_SCALE
end
--Update position
vint_set_property(grp_h, "anchor", position_x, position_y)
local target_scale = 3.5 * scale
--Update the scale
vint_set_property(grp_h, "scale", target_scale, target_scale)
end
-------------------------------------------------------------------------------
-- Updates main button hints. This is essentially a wrapper for our button hints
-- It allows us to draw a nifty little background behind the hints that is
-- Custom to the phone.
--
-- @param hint_data Table representing button hints..
-------------------------------------------------------------------------------
function pause_map_update_button_hints(hint_data)
Hint_bar:set_hints(hint_data, false, false) --Entered_with_gamepad, not Entered_with_gamepad)
if game_get_platform() ~= "PC" then
local width, height = Hint_bar:get_size()
width = floor(width)
height = floor(height)
local bg_width, bg_height = element_get_actual_size(Hint_bar_bg, width, height)
local hint_background_padding = 35 -- Additional padding needed for background height
element_set_actual_size(Hint_bar_bg, width + 35, bg_height)
end
end
-------------------------------------------------------------------------------
-- Flips an element in the horizontal direction...
-- @param h handle to element
-- @param x_flip (bool)Do we flip the item or not? horizontal
-- @param y_flip (bool)Do we flip the item or not? vertical
-- @param override (bool)true if we don't care if the item was flipped initially.
-------------------------------------------------------------------------------
function pause_map_flip_element(h, x_flip, y_flip, override)
local scale_x, scale_y = vint_get_property(h, "scale")
if override == true then
scale_x = abs(scale_x)
scale_y = abs(scale_y)
end
local x_direction = 1
local y_direction = 1
if x_flip == true then
x_direction = -1
end
if y_flip == true then
y_direction = -1
end
scale_x = scale_x * x_direction
scale_y = scale_y * y_direction
vint_set_property(h, "scale", scale_x, scale_y)
end
function pause_map_hide_c_map()
local h = vint_object_find("pause_map")
vint_set_property(h, "visible", false)
vint_object_destroy(h)
end
function pause_map_interface_event(event)
--supported events:
--INTERFACE_EVENT_ADD_GPS
--INTERFACE_EVENT_REMOVE_GPS
--INTERFACE_EVENT_ADD_BOOKMARK
--INTERFACE_EVENT_REMOVE_BOOKMARK
--for now just use the same sound for all
if event == INTERFACE_EVENT_ADD_GPS then
if Pause_map_tutorial_mode == true then
pause_map_tutorial_mode_change_text("M03_OBJ_GO_TO_WEAPON_STORE")
end
elseif event == INTERFACE_EVENT_REMOVE_GPS then
if Pause_map_tutorial_mode == true then
pause_map_tutorial_mode_change_text("M03_OBJ_SET_GPS")
end
end
game_UI_audio_play("UI_Cell_Nav")
end
function pause_map_stag_popup_select(event, target_handle)
--User wanted to go back...
if event == "back" or Pause_map_stag_popup:get_selected_data() == 2 then
-- The user hit the B button and cancelled the change
Pause_map_stag_popup:nav_enable(false, nil, nil)
game_UI_audio_play("UI_Main_Menu_Nav_Back")
local stag_popup_overlay_grp_h = vint_object_find("stag_popup_overlay_grp")
vint_set_property(stag_popup_overlay_grp_h, "visible", false)
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:subscribe(true)
end
if Filter_mouse_input_tracker ~= 0 then
Filter_mouse_input_tracker:subscribe(true)
end
return
end
-- Did we select yes? Now exit to via stag exit...
if Pause_map_stag_popup:get_selected_data() == 1 then
Pause_map_stag_popup:nav_enable(false, nil, nil)
game_UI_audio_play("UI_Main_Menu_Select")
pause_map_stag_exit()
return
end
end
function pause_map_stag_popup_nav(event, value)
if event == "nav_up" then
Pause_map_stag_popup.list:move_cursor(-1)
elseif event == "nav_down" then
Pause_map_stag_popup.list:move_cursor(1)
elseif event == "mouse_move" then
-- value contains the target_handle in this case
local new_index = Pause_map_stag_popup.list:get_button_index(value)
if new_index ~= 0 then
Pause_map_stag_popup.list:set_selection(new_index)
Pause_map_stag_popup.list:move_cursor(0, true)
end
else
--do nothing
end
end
-------------------------------------------------------------------------------
-- Enables or disables tutorial mode dialog.
--
function pause_map_tutorial_mode_enable(enabled)
local tutorial_overlay_grp_h = vint_object_find("tutorial_overlay_grp")
vint_set_property(tutorial_overlay_grp_h, "visible", enabled)
if enabled then
pause_map_tutorial_mode_change_text("M03_OBJ_SET_GPS")
local map_info_grp_h = vint_object_find("map_info_grp")
vint_set_property(map_info_grp_h, "visible", false)
end
end
-------------------------------------------------------------------------------
-- Modifies the text field in the fake map GSI
--
function pause_map_tutorial_mode_change_text(text_tag)
local doc_h = vint_document_find("pause_map")
local tutorial_overlay_grp_h = vint_object_find("tutorial_overlay_grp", 0, doc_h)
local obj_txt_h = vint_object_find("obj_txt", tutorial_overlay_grp_h, doc_h)
vint_set_property(obj_txt_h, "text_tag", text_tag)
--resize bg to account for localized strings...
local gsi_bg_h = vint_object_find("gsi_bg", tutorial_overlay_grp_h, doc_h)
local obj_img_h = vint_object_find("obj_img", tutorial_overlay_grp_h, doc_h)
local obj_txt_h = vint_object_find("obj_txt", tutorial_overlay_grp_h, doc_h)
local x, y = vint_get_property(obj_txt_h, "anchor")
local bg_width, bg_height = element_get_actual_size(gsi_bg_h)
local text_width, text_height = element_get_actual_size(obj_txt_h)
local width = text_width + x + 10
element_set_actual_size(gsi_bg_h, width, bg_height)
end
function pause_map_mouse_move(event, target_handle, x, y, lines_to_scroll, current_target_handle)
if target_handle == Map_mask_handle then
vint_set_mouse_cursor("Ui_cursor_hand_open")
else
vint_set_mouse_cursor("")
end
local hint_index = PC_hint_bar:get_hint_index(target_handle)
if hint_index ~= 0 then
PC_hint_bar:set_highlight(hint_index)
else
PC_hint_bar:set_highlight(0)
end
-- Zoom in/out highlighting
vint_set_property(PC_zoom_in.handle, "tint", PAUSE_MAP_COLOR_ZOOM_UNSELECTED.R, PAUSE_MAP_COLOR_ZOOM_UNSELECTED.G, PAUSE_MAP_COLOR_ZOOM_UNSELECTED.B)
vint_set_property(PC_zoom_out.handle, "tint", PAUSE_MAP_COLOR_ZOOM_UNSELECTED.R, PAUSE_MAP_COLOR_ZOOM_UNSELECTED.G, PAUSE_MAP_COLOR_ZOOM_UNSELECTED.B)
if target_handle == PC_zoom_in.handle then
vint_set_property(PC_zoom_in.handle, "tint", PAUSE_MAP_COLOR_ZOOM_SELECTED.R, PAUSE_MAP_COLOR_ZOOM_SELECTED.G, PAUSE_MAP_COLOR_ZOOM_SELECTED.B)
end
if target_handle == PC_zoom_out.handle then
vint_set_property(PC_zoom_out.handle, "tint", PAUSE_MAP_COLOR_ZOOM_SELECTED.R, PAUSE_MAP_COLOR_ZOOM_SELECTED.G, PAUSE_MAP_COLOR_ZOOM_SELECTED.B)
end
end
function pause_map_mouse_click(event, target_handle, x, y, lines_to_scroll, current_target_handle)
local hint_index = PC_hint_bar:get_hint_index(target_handle)
if hint_index == 1 then
pause_map_input("back")
elseif hint_index == 2 then
pause_map_input("map")
end
local filter_target_idx = Pause_map_filter:get_filter_index(current_target_handle)
if filter_target_idx >= 0 then
Pause_map_filter:change_filter(filter_target_idx, true)
end
if target_handle == PC_zoom_in.handle then
pause_map_zoom(true)
end
if target_handle == PC_zoom_out.handle then
pause_map_zoom(false)
end
end
function pause_map_mouse_right_click(event, target_handle, x, y, lines_to_scroll, current_target_handle)
if target_handle == Map_mask_handle then
pause_map_set_gps()
end
end
function pause_map_mouse_middle_click(event, target_handle, x, y, lines_to_scroll, current_target_handle)
if target_handle == Map_mask_handle then
pause_map_add_bookmark()
end
end
function pause_map_mouse_drag(event, target_handle, x, y, lines_to_scroll, current_target_handle)
if target_handle == Map_mask_handle then
vint_set_mouse_cursor("Ui_cursor_hand_closed")
pause_map_drag_map()
--vint_set_property(Cursor_tool_handle, "visible", false)
end
end
function pause_map_mouse_drag_release(event, target_handle, x, y, lines_to_scroll, current_target_handle)
if current_target_handle ~= Map_mask_handle then
vint_set_mouse_cursor("")
elseif target_handle == Map_mask_handle then
vint_set_mouse_cursor("Ui_cursor_hand_open")
end
--vint_set_property(Cursor_tool_handle, "visible", true)
end
function pause_map_gamepad_monitor_thread()
while true do
vint_set_property(Cursor_tool_handle, "visible", game_is_active_input_gamepad())
delay(0.5)
end
end
-- This is required because we're using Vdo_store_popup
--
function store_common_do_nothing()
end