-- Get the handle to the doc which holds most of the store vint elements
Store_common_doc_handle = -1
Store_common_hint_bar = -1
Store_common_rotate_hint = -1
Store_common_popup = -1
Store_common_color_grid = -1
Store_common_spinner = -1
Store_common_bypass_animate = false
Store_common_current_highlight_color = COLOR_SAINTS_PURPLE
Store_header = {}
Input_tracker = {}
Menu_data = {}
Active_list = {}
Store_common_sub_menu = {}
Store_common_gsi = {}
Mouse_input_tracker = 0
Character_mouse_input_tracker = 0
Character_mouse_drag_region = 0
-- Width of the store menus.
--TODO MODIFY THESE FOR BOTH HD/SD (JMH 5/4/2011)
--STORE_COMMON_HEADER_SIZE = --vint_to_std_res(428,
STORE_COMMON_LIST_SIZE = 435 --vint_to_std_res(428, -378)
STORE_COMMON_LIST_NO_PRICE_Y = 247
STORE_COMMON_GRID_NO_PRICE_Y = 270
STORE_COMMON_GRID_VEHICLE_Y = 280
Store_common_allow_input_cb = 0
Store_common_populate_list_cb = 0
Store_common_exit_cb = 0
Store_common_gallery_download_only = false
Store_common_gallery_cancel = false
-- Current amount of cash player has
Store_common_player_cash = 0
-- Override input if someone presses both back and select together
Store_common_override_input = false
Yes_no_choices = {
[1] = {
type = TYPE_BUTTON,
label = "PAUSE_MENU_ACCEPT",
id = 1,
},
[2] = {
type = TYPE_BUTTON,
label = "CONTROL_CANCEL",
id = 2,
},
}
Ok_choice = {
[1] = {
type = TYPE_BUTTON,
label = "CONTROL_OKAY",
id = 1,
},
}
---------------------------------------------------------------------------
-- Stack tracking for the stores. ID's are unique numbers for categories,
-- items, etc. Indexes are the order in the menu that was selected.
---------------------------------------------------------------------------
Store_common_stack_id = {}
Store_common_stack_index = {}
Store_common_stack_menu = {}
function store_common_init()
Store_common_stack_id.current_stack = 0
Store_common_stack_index.current_stack = 0
-- Get the handle to the doc which holds most of the store vint elements
Store_common_doc_handle = vint_document_find("store_common")
Store_common_hint_bar = Vdo_hint_bar:new("hint_bar", 0, Store_common_doc_handle)
Store_common_rotate_hint = Vdo_hint_bar:new("hint_rotate", 0, Store_common_doc_handle)
Store_common_popup = Vdo_store_popup:new("store_popup", 0, Store_common_doc_handle)
Store_common_color_grid = Vdo_grid_list:new("color_grid", 0, Store_common_doc_handle)
Store_common_spinner = Vdo_spinner:new("store_spinner", 0, Store_common_doc_handle)
bg_saints_show(false)
local upgrade_desc = Vdo_base_object:new("upgrade_desc", 0, Store_common_doc_handle)
local crib_random_grp = Vdo_base_object:new("crib_random_grp", 0, Store_common_doc_handle)
-- Hide everything then turn on what we need in the individual stores
upgrade_desc:set_visible(false)
crib_random_grp:set_visible(false)
Store_common_hint_bar:enable_text_shadow(true)
Store_common_hint_bar:set_visible(false)
Store_common_rotate_hint:set_visible(false)
Store_common_popup:set_visible(false)
Store_common_color_grid:set_visible(false)
Store_common_spinner:set_visible(false)
Store_common_hint_bar:enable_text_shadow(true)
Store_common_rotate_hint:enable_text_shadow(true)
-- Initially, list_1 is the active list
Active_list = Vdo_mega_list:new("list_1", 0, Store_common_doc_handle, "store_common.lua", "Active_list")
Active_list:set_visible(false)
--Setup header
Store_header = Vdo_store_header:new("store_header", 0, Store_common_doc_handle)
-- Initialize the store header
Store_header:set_title()
Store_header:set_price(nil)
Store_header:set_respect(nil)
Store_header:set_visible(false)
Store_common_gsi = Vdo_gsi_lite:new("store_common_gsi", 0, Store_common_doc_handle)
-- set up data items for player status
vint_dataitem_add_subscription("sr2_local_player_respect", "update", "store_common_respect_update")
vint_dataitem_add_subscription("sr2_local_player_status_infrequent", "update", "store_common_cash_update")
-- subscribe to common inputs
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("pause", "store_common_pause", 50)
Input_tracker:add_input("map", "store_common_do_nothing", 50)
Input_tracker:add_input("back", "store_common_button_b", 50)
Input_tracker:add_input("select", "store_common_button_a", 50)
Input_tracker:add_input("nav_up", "store_common_nav_up", 50)
Input_tracker:add_input("nav_down", "store_common_nav_down", 50)
Input_tracker:add_input("nav_left", "store_common_nav_left", 50)
Input_tracker:add_input("nav_right", "store_common_nav_right", 50)
Active_list:set_input_tracker(Input_tracker)
Store_common_color_grid:set_input_tracker(Input_tracker)
-- Create the mouse's input tracker
if game_get_platform() == "PC" then
Mouse_input_tracker = Vdo_input_tracker:new()
Character_mouse_drag_region = vint_object_find("hidden_mouse_mask_bg", 0, Store_common_doc_handle)
if Character_mouse_drag_region ~= 0 then
Character_mouse_input_tracker = Vdo_input_tracker:new()
Character_mouse_input_tracker:add_mouse_input("mouse_click", "character_mouse_click", 50, Character_mouse_drag_region)
Character_mouse_input_tracker:add_mouse_input("mouse_scroll", "character_mouse_scroll", 50, Character_mouse_drag_region)
Character_mouse_input_tracker:add_mouse_input("mouse_move", "character_mouse_move", 50, Character_mouse_drag_region)
Character_mouse_input_tracker:add_mouse_input("mouse_drag", "character_mouse_drag", 50, Character_mouse_drag_region)
Character_mouse_input_tracker:add_mouse_input("mouse_drag_release", "character_mouse_drag_release", 50, Character_mouse_drag_region)
character_enable_mouse_drag(false)
end
end
end
function store_common_safe_frame_show()
local safe_frame = vint_object_find("safe_frame", 0, Store_common_doc_handle)
vint_set_property(safe_frame, "visible", true)
end
function store_common_cleanup()
Store_common_hint_bar:cleanup()
Store_common_rotate_hint:cleanup()
Store_common_popup:cleanup()
Store_common_color_grid:nav_enable(false, nil, nil)
Store_common_color_grid:cleanup()
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:subscribe(false)
end
if Character_mouse_input_tracker ~= 0 then
Character_mouse_input_tracker:subscribe(false)
vint_set_mouse_cursor("")
store_common_mouse_zoom(0.0)
end
end
-- Some things need to be cleaned up right away when a store doc is unloading, particular disabled inputs which have
-- callbacks to the script that is unloading.
--
function store_common_cleanup_current_store()
Store_common_popup:cleanup()
Store_common_color_grid:nav_enable(false, nil, nil)
Store_common_color_grid:cleanup()
end
---------------------------------------------------------------------------
-- Adds an element to the stack. Use when making a selection on the menu.
-- @param id ID of the current selected option
---------------------------------------------------------------------------
function store_common_stack_add_id(id)
Store_common_stack_id[Store_common_stack_id.current_stack + 1] = id
Store_common_stack_id.current_stack = Store_common_stack_id.current_stack + 1
end
---------------------------------------------------------------------------
-- Removes an element from the stack. Use when going back a menu.
---------------------------------------------------------------------------
function store_common_stack_remove_id()
--Nothing in menu stack return default selection
if Store_common_stack_id.current_stack == 0 then
return
end
--Remove value of current stack
Store_common_stack_id[Store_common_stack_id.current_stack] = nil
Store_common_stack_id.current_stack = Store_common_stack_id.current_stack - 1
end
---------------------------------------------------------------------------
-- Returns the current id for the current menu.
---------------------------------------------------------------------------
function store_common_stack_get_id()
--Nothing stored in the current stack then return default id
if Store_common_stack_id[Store_common_stack_id.current_stack] == nil then
return 0
end
--Return value of current stack
return Store_common_stack_id[Store_common_stack_id.current_stack]
end
---------------------------------------------------------------------------
-- Removes all elements from the stack. Use when starting from the top.
---------------------------------------------------------------------------
function store_common_stack_clear_id()
Store_common_stack_id.current_stack = 0
end
---------------------------------------------------------------------------
-- Adds an element to the stack. Use when making a selection on the menu.
-- @param index Index of the current selected option
---------------------------------------------------------------------------
function store_common_stack_add_index(index)
Store_common_stack_index[Store_common_stack_index.current_stack] = index
Store_common_stack_index.current_stack = Store_common_stack_index.current_stack + 1
end
---------------------------------------------------------------------------
-- Removes an element from the stack. Use when going back a menu.
---------------------------------------------------------------------------
function store_common_stack_remove_index()
--Nothing in menu stack return default selection
if Store_common_stack_index.current_stack == 0 then
return
end
--Remove value of current stack
Store_common_stack_index[Store_common_stack_index.current_stack] = nil
Store_common_stack_index.current_stack = Store_common_stack_index.current_stack - 1
end
---------------------------------------------------------------------------
-- Returns the current index for the current menu.
---------------------------------------------------------------------------
function store_common_stack_get_index()
--Nothing stored in the current stack then return default index
if Store_common_stack_index[Store_common_stack_index.current_stack] == nil then
return 1
end
--Return value of current stack
return Store_common_stack_index[Store_common_stack_index.current_stack]
end
---------------------------------------------------------------------------
-- Removes all elements from the stack. Use when starting from the top.
---------------------------------------------------------------------------
function store_common_stack_clear_index()
Store_common_stack_index.current_stack = 0
end
---------------------------------------------------------------------------
-- Adds an element to the stack. Use when making a selection on the menu.
-- @param menu - sub menu to store
---------------------------------------------------------------------------
function store_common_stack_add_menu(menu)
Store_common_stack_menu[#Store_common_stack_menu + 1] = menu
end
---------------------------------------------------------------------------
-- Removes an element from the stack. Use when going back a menu.
---------------------------------------------------------------------------
function store_common_stack_remove_menu()
--Nothing in menu stack return default selection
if #Store_common_stack_menu == 0 then
return
end
--Remove value of current stack
Store_common_stack_menu[#Store_common_stack_menu] = nil
end
---------------------------------------------------------------------------
-- Returns the current menu on the stack.
---------------------------------------------------------------------------
function store_common_stack_get_menu()
--Nothing stored in the current stack then return default menu
if #Store_common_stack_menu == 0 then
return nil
end
--Return value of current stack
return Store_common_stack_menu[#Store_common_stack_menu]
end
---------------------------------------------------------------------------
-- Removes all elements from the stack. Use when starting from the top.
---------------------------------------------------------------------------
function store_common_stack_clear_menu()
Store_common_stack_menu = {}
end
-- This function is called when the player respect data item is updated
--
-- di_h: data item handle
--
function store_common_respect_update(di_h)
--[[
respect_total = total respect earned
respect_needed = respect % to reach next level
respect_level = current respect level
show_upgrades = should we show the "upgrade ready" indication
]]--
local respect_total, respect_needed, respect_level, show_upgrades = vint_dataitem_get(di_h)
Store_header.respect_meter:update_respect(respect_total, respect_needed, respect_level)
end
-- This function is called when the player status data item is updated, used for cash
--
-- di_h: data item handle
--
function store_common_cash_update(di_h)
--[[
cash = player's cash
The rest are unused.
]]--
local cash = vint_dataitem_get(di_h)
Store_common_player_cash = cash
Store_header:set_cash(cash)
end
function store_common_pause(event)
dialog_open_pause_display()
end
function store_common_do_nothing(event)
end
-- If a store has registered an allow_input callback, call it and see if input is not allowed.
-- Returns true if input is allowed, false otherwise.
--
function store_common_allow_input(event)
if Store_common_allow_input_cb ~= 0 then
return Store_common_allow_input_cb(event)
else
return true
end
end
-- Pushes a new menu on the stack, but one that isn't a submenu of an existing menu item
--
function store_common_push_menu(menu_data)
local current_id = Active_list:get_id()
local current_index = Active_list:get_selection()
--Add current selection to the stack to store the selected position on the menu
store_common_stack_add_id(current_id)
store_common_stack_add_index(current_index)
-- Store off tables we need for backing out of the menu
store_common_stack_add_menu(Menu_data)
-- SEH, probably don't want this...
-- set the titles on top
local title = nil
local title_crc = nil
title_crc = Menu_data[Active_list:get_selection()].label_crc
if title_crc == nil then
title = Menu_data[Active_list:get_selection()].label
end
Store_header:push_title( title_crc, title )
-- Now move to the new sub menu
Menu_data = menu_data
-- populate the new list
if Store_common_populate_list_cb ~= 0 then
-- sub_menu_fill may have decided that our starting selection was something other than the first
local start_index = 1
if Menu_data.start_index ~= nil and Menu_data.start_index >= 1 and Menu_data.start_index <= #Menu_data then
start_index = Menu_data.start_index
end
Store_common_populate_list_cb(Menu_data, start_index)
end
-- Call on_enter function since we're entering the menu
if Menu_data.on_enter ~= nil then
Menu_data.on_enter(Menu_data)
end
-- do this so holding down the button doesn't cause repeated actions
--Input_tracker:subscribe(false)
--Input_tracker:subscribe(true)
end
-- Handle A/accept button action on a menu item.
--
function store_common_button_a(event)
if store_common_allow_input(event) == false or Store_common_override_input then
return
end
--Do NOT allow input until list is finish animating
if Active_list:list_is_playing() == false then
local current_id = Active_list:get_id()
local current_index = Active_list:get_selection()
-- If this is not a button choice (ie. it's a toggle or slider) then don't do normal menu processing
if Menu_data[current_index].type == TYPE_TOGGLE then
store_common_nav_right()
elseif Menu_data[current_index].type == TYPE_TOGGLE_COLOR then
game_UI_audio_play("UI_Main_Menu_Select")
else
if Menu_data[current_index].equiped ~= true or Menu_data[current_index].is_purchased ~= true then
game_UI_audio_play("UI_Main_Menu_Select")
end
end
if Menu_data[current_index].on_select ~= nil then
-- Save off a local to determine if we have a sub menu to enter, because the on_select callback could
-- change Menu_data! If the callback does this, this selection should never expect to have a sub menu.
local enter_sub_menu = true
if Menu_data[current_index].on_sub_menu_fill == nil and Menu_data[current_index].sub_menu == nil then
enter_sub_menu = false
end
Menu_data[current_index].on_select(Menu_data[current_index])
-- we're done, unless there is a sub menu
if enter_sub_menu == false then
return
end
end
Store_common_sub_menu = {}
-- submenu exists, but still needs to be generated
if Menu_data[current_index].on_sub_menu_fill ~= nil then
Menu_data[current_index].sub_menu = {}
Menu_data[current_index].on_sub_menu_fill(Menu_data[current_index])
else
if Menu_data.default_on_sub_menu_fill ~= nil then
Menu_data[current_index].sub_menu = {}
Menu_data.default_on_sub_menu_fill(Menu_data[current_index])
end
end
if (Menu_data[current_index].sub_menu == nil or #Menu_data[current_index].sub_menu <= 0) and #Store_common_sub_menu == 0 then
return
end
-- reposition camera based on settings for this item
if Menu_data[current_index].camera ~= nil then
store_set_camera_pos(Menu_data[current_index].camera)
end
-- Different C call for vehicle cameras
if Menu_data[current_index].vcamera ~= nil then
vcust_set_camera_pos(Menu_data[current_index].vcamera, true)
-- local hint_rotate_data = {
-- {CTRL_BUTTON_RS, "STORE_ZOOM"},
-- }
-- Store_common_rotate_hint:set_hints(hint_rotate_data)
Store_common_rotate_hint:set_visible(false)
end
--Add current selection to the stack to store the selected position on the menu
store_common_stack_add_id(current_id)
store_common_stack_add_index(current_index)
-- drill down further into our menu depth
-- set the titles on top
local title = nil
local title_crc = nil
title_crc = Menu_data[Active_list:get_selection()].label_crc
if title_crc == nil then
title = Menu_data[Active_list:get_selection()].label
end
Store_header:push_title( title_crc, title )
-- Store off tables we need for backing out of the menu
store_common_stack_add_menu(Menu_data)
-- Now move to the new sub menu
if #Store_common_sub_menu > 0 then
Menu_data = Store_common_sub_menu
else
Menu_data = Menu_data[current_index].sub_menu
end
-- populate the new list
if Store_common_populate_list_cb ~= 0 then
-- sub_menu_fill may have decided that our starting selection was something other than the first
local start_index = 1
if Menu_data.start_index ~= nil and Menu_data.start_index >= 1 and Menu_data.start_index <= #Menu_data then
start_index = Menu_data.start_index
end
Store_common_populate_list_cb(Menu_data, start_index)
end
-- Call on_enter function since we're entering the menu
if Menu_data.on_enter ~= nil then
Menu_data.on_enter(Menu_data)
end
Store_common_sub_menu = {}
end
end
-- Handle B/back button action on a menu item.
--
function store_common_button_b(event)
Store_common_override_input = true
if store_common_allow_input(event) == false then
Store_common_override_input = false
return
end
--used to bypass the animate when vechicle store needs to backout 2 times in a row, in function store_vehicle_purchase_color_final
local list_is_playing = Active_list:list_is_playing()
if Store_common_bypass_animate then
list_is_playing = false
end
Store_common_bypass_animate = false --set it back to false for next time
--Do NOT allow input until list is finish animating
if list_is_playing == false then
-- If we're at the top level, ask if player wants to leave store
if store_common_stack_get_menu() == nil and Store_common_exit_cb ~= 0 then
Store_common_exit_cb()
Store_common_override_input = false
return
end
--Removed check for open toggles since, we don't open them anymore and they are inline. JMH (4/27/2011)
-- get index of current selection
local index = Active_list:get_selection()
-- If player needs to confirm a cancel, do that callback. If it doesn't return true, then a confirm
-- isn't needed right now. If a confirm is needed, return since we can't back up now.
if Menu_data[index].on_cancel_confirm ~= nil then
local confirm_needed = Menu_data[index].on_cancel_confirm(Menu_data[index])
if confirm_needed == true then
Store_common_override_input = false
return
end
end
game_UI_audio_play("UI_Main_Menu_Nav_Back")
-- do on_cancel callback if we have one
if Menu_data[index].on_cancel ~= nil then
Menu_data[index].on_cancel(Menu_data[index])
end
store_common_back_menu()
else
Store_common_override_input = false
end
end
function store_common_back_menu()
--Remove current menu from the stack
store_common_stack_remove_id()
store_common_stack_remove_index()
-- do on_back callback if we have one
local index = Active_list:get_selection()
if Menu_data[index].on_back ~= nil then
Menu_data[index].on_back(Menu_data[index])
else
if Menu_data.default_on_back ~= nil then
Menu_data.default_on_back(Menu_data[index])
end
end
-- pop back up our menu depth
-- set the titles on top
Store_header:pop_title()
local current_id = store_common_stack_get_id()
local current_index = store_common_stack_get_index()
-- Retrieve the previous menu
Menu_data = store_common_stack_get_menu()
store_common_stack_remove_menu()
-- set the new active list with the new data
if Store_common_populate_list_cb ~= 0 then
Store_common_populate_list_cb(Menu_data, current_index)
end
-- Call on_enter function since we're entering the menu
if Menu_data.on_enter ~= nil then
Menu_data.on_enter(Menu_data)
end
-- do this so holding down the button doesn't cause repeated actions
--Input_tracker:subscribe(false)
--Input_tracker:subscribe(true)
Store_common_override_input = false
end
-- Common up/down navigation code
--
function store_common_nav_up_down(movement, do_not_redraw)
if store_common_allow_input(movement) == false then
return
end
--Do NOT allow input until list is finish animating
if Active_list:list_is_playing() == false then
-- Move highlight
Active_list:move_cursor(movement, do_not_redraw)
if Mouse_input_tracker ~= 0 then
Active_list:update_mouse_inputs("store_common", Mouse_input_tracker)
end
-- get a more convenient reference to the current item in the list
local data_item = Active_list:return_selected_data()
if data_item.on_nav ~= nil then
data_item.on_nav(data_item)
return
end
if Menu_data.default_on_nav ~= nil then
Menu_data.default_on_nav(data_item)
end
end
end
function store_common_nav_up()
-- Move highlight up
store_common_nav_up_down(-1)
end
function store_common_nav_down()
-- Move highlight down
store_common_nav_up_down(1)
end
-- Common left/right navigation code
--
function store_common_nav_left_right(movement)
if store_common_allow_input(movement) == false then
return
end
-- Move highlight
Active_list:move_slider(movement)
-- get a more convenient reference to the current item in the list
local data_item = Active_list:return_selected_data()
--local current_index = Active_list:get_selection()
if data_item.on_value_update ~= nil then
data_item.on_value_update(data_item)
return
end
end
-- Handle navigating left (sliders)
--
function store_common_nav_left(event, acceleration)
store_common_nav_left_right(-1)
end
-- Handle navigating right (sliders)
--
function store_common_nav_right(event, acceleration)
store_common_nav_left_right(1)
end
function store_common_mouse_click(event, target_handle, mouse_x, mouse_y)
if store_common_allow_input(event) == false then
return
end
local new_index = Active_list:get_button_index(target_handle)
if new_index ~= 0 then
local old_index = Active_list:get_selection()
Active_list:set_selection(new_index)
-- Check if the user clicked on the slider
local current_selection = Active_list:return_selected_data()
if current_selection.type == TYPE_SLIDER then
if Active_list:is_slider(target_handle) then
Active_list:move_slider(0, mouse_x)
-- get a more convenient reference to the current item in the list
local data_item = Active_list:return_selected_data()
if data_item.on_value_update ~= nil then
data_item.on_value_update(data_item)
end
end
else
if old_index ~= new_index then
-- get a more convenient reference to the current item in the list
local data_item = Active_list:return_selected_data()
if data_item.on_nav ~= nil then
data_item.on_nav(data_item)
else
if Menu_data.default_on_nav ~= nil then
Menu_data.default_on_nav(data_item)
end
end
end
store_common_button_a()
end
return
end
-- Check if the user clicked on the toggle/slider arrows
local current_selection = Active_list:return_selected_data()
if current_selection.type == TYPE_SLIDER or current_selection.type == TYPE_TOGGLE then
if Active_list:is_left_arrow(target_handle) then
store_common_nav_left()
elseif Active_list:is_right_arrow(target_handle) then
store_common_nav_right()
end
end
end
function store_common_mouse_down(event, target_handle)
end
-- Each store should have its own mouse_move function to handle the mouse_move events. This is here
-- as a backup case to work on the mega list at the very least.
--
function store_common_mouse_move(event, target_handle)
vint_set_mouse_cursor("")
store_common_mouse_zoom(0.0)
Store_common_hint_bar:set_highlight(0)
if store_common_allow_input(event) == false then
return
end
if Active_list:list_is_playing() == false then
local old_index = Active_list:get_selection()
local new_index = Active_list:get_button_index(target_handle)
if new_index ~= 0 and new_index ~= old_index then
Active_list:set_selection(new_index)
store_common_nav_up_down(0, true)
return
end
end
-- Check if the mouse is over the hint bar buttons
local hint_index = Store_common_hint_bar:get_hint_index(target_handle)
if hint_index ~= 0 then
Store_common_hint_bar:set_highlight(hint_index, Store_common_current_highlight_color)
return
end
end
function store_common_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines)
if target_handle == Character_mouse_drag_region then
store_common_mouse_zoom()
end
if Active_list:list_is_playing() == false then
if scroll_lines ~= 0 then
if Active_list:get_scroll_region_handle() == target_handle then
Active_list:scroll_list(scroll_lines * -1)
Active_list:update_mouse_inputs("store_common", Mouse_input_tracker)
end
end
end
end
function store_common_mouse_drag(event, target_handle, mouse_x, mouse_y)
if store_common_allow_input(event) == false then
return
end
if Active_list.scrollbar.tab_grp.handle == target_handle then
local new_start_index = Active_list.scrollbar:drag_scrolltab(mouse_y, Active_list.num_buttons - (Active_list.max_buttons - 1))
Active_list:scroll_list(0, new_start_index)
elseif Active_list:is_slider(target_handle) then
local updated = Active_list:move_slider(0, mouse_x)
-- Update if the slider changed
if updated then
local data_item = Active_list:return_selected_data()
if data_item.on_value_update ~= nil then
data_item.on_value_update(data_item)
end
end
end
end
-- Updates the mouse inputs for the list and snaps the scrolltab to the closest notch based on the visible index
--
function store_common_mouse_drag_release(event, target_handle, mouse_x, mouse_y)
if Active_list.scrollbar.tab_grp.handle == target_handle then
local start_index = Active_list:get_visible_indices()
Active_list.scrollbar:release_scrolltab(start_index, Active_list.num_buttons - (Active_list.max_buttons - 1))
Active_list:update_mouse_inputs("store_common", Mouse_input_tracker)
end
end
function store_common_crib_is_loaded()
return vint_document_find("store_crib") ~= 0
end
-- If store_common has just gained focus, it means we've left whatever store we were in.
-- Unload ourself.
--
function store_common_gained_focus()
pop_screen()
end
function store_common_play_anim_out()
local anim_out = Vdo_anim_object:new("store_common_anim_out", 0, Store_common_doc_handle)
anim_out:play(0)
end
function character_mouse_click(event, target_handle, mouse_x, mouse_y)
end
function character_mouse_down(event, target_handle)
if target_handle == Character_mouse_drag_region then
vint_set_mouse_cursor("Ui_cursor_hand_closed")
end
end
-- Each store should have its own mouse_move function to handle the mouse_move events. This is here
-- as a backup case to work on the mega list at the very least.
--
function character_mouse_move(event, target_handle)
Store_common_hint_bar:set_highlight(0)
if target_handle == Character_mouse_drag_region then
vint_set_mouse_cursor("Ui_cursor_hand_open")
else
vint_set_mouse_cursor("")
store_common_mouse_zoom(0.0)
end
end
function character_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines, current_highlighted_element)
if current_highlighted_element == Character_mouse_drag_region then
store_common_mouse_zoom()
else
store_common_mouse_zoom(0.0)
end
end
function character_mouse_drag(event, target_handle, mouse_x, mouse_y)
if target_handle == Character_mouse_drag_region then
vint_set_mouse_cursor("Ui_cursor_hand_closed")
store_common_rotate_mouse_drag()
end
end
-- Updates the mouse inputs for the list and snaps the scrolltab to the closest notch based on the visible index
--
function character_mouse_drag_release(event, target_handle, mouse_x, mouse_y, lines_to_scroll, current_highlighted_element)
if current_highlighted_element ~= Character_mouse_drag_region then
vint_set_mouse_cursor("")
store_common_mouse_zoom(0.0)
elseif target_handle == Character_mouse_drag_region then
vint_set_mouse_cursor("Ui_cursor_hand_open")
end
end
function character_enable_mouse_drag(enable)
if Character_mouse_input_tracker ~= 0 and Character_mouse_input_tracker ~= nil then
Character_mouse_input_tracker:subscribe(enable)
end
if enable == false then
vint_set_mouse_cursor("")
end
end
-- JM: Adding this for video capturing
function store_common_hide_controls()
Store_common_hint_bar:set_visible(false)
Store_common_hint_bar:set_alpha(0)
Store_common_rotate_hint:set_visible(false)
Store_common_rotate_hint:set_alpha(0)
end
--[[ ---------------------------------------------------------------------
-- Function - store_common_input_disable
-- Description - Disable input for store
-- Parameters - None
-- Returns - Nil
]]-- ---------------------------------------------------------------------
function store_common_input_disable()
Input_tracker:subscribe(false)
if game_get_platform() == "PC" then
Mouse_input_tracker:subscribe(false)
Character_mouse_input_tracker:subscribe(false)
end
end
--[[ ---------------------------------------------------------------------
-- Function - store_common_input_enable
-- Description - Enables input for store
-- Parameters - None
-- Returns - Nil
]]-- ---------------------------------------------------------------------
function store_common_input_enable()
Input_tracker:subscribe(true)
if game_get_platform() == "PC" then
Mouse_input_tracker:subscribe(true)
Character_mouse_input_tracker:subscribe(true)
end
end