local SCALE_FONT_STORE_TATTOO_LIST = 0.8
Store_tattoo_doc_handle = -1
-- Used to determine which of three colors player is currently picking, and the index in the color grid is currently chosen.
local Color_grid_idx = 1
local Color_slot_chosen = 0
local Color_grid_data = {}
-- Mouse input-related variables
local Game_platform
local Hint_bar_mouse_input_tracker
local MENU_TIER = 1
local COLOR_TIER = 2
local Current_tier = MENU_TIER
local Store_tattoo_in_anim
local Player_creation_bg_anim
-- Hint bar and store header vdo's.
local Not_popup_grp
local Store_tattoo_building_menu
local Store_tattoo_current_area
local Store_tattoo_current_item
local Store_tattoo_current_color
local Store_tattoo_current_alpha
local Store_tattoo_current_price
local Store_tattoo_current_respect
local Store_tattoo_reverted = {}
local Store_tattoo_nav_thread = -1
local Store_tattoo_init_camera_moved = false
local STORE_CHARACTER_HAIR_AREA_BEGIN = 0
local STORE_CHARACTER_HAIR_AREA_HEAD = 0
local STORE_CHARACTER_HAIR_AREA_END = 0
local Store_character_hair_values = {
[STORE_CHARACTER_HAIR_AREA_HEAD] = { name = "head", style = -1, primary = -1, secondary = -1 },
}
function store_tattoo_composite_alpha_done()
-- Disable mouse input for active_list and hint_bar
store_tattoo_enable_mouse(false)
store_tattoo_purchase()
end
function store_tattoo_composite_alpha_change(menu_data)
Store_tattoo_current_alpha = menu_data.current_value
pcr_change_composite(Store_tattoo_current_area, Store_tattoo_current_item, Store_tattoo_current_color, Store_tattoo_current_alpha)
end
function store_tattoo_composite_show_alpha_menu()
Active_list:set_visible(true)
-- Get data to populate the megalist
local New_menu_data = {
[1] = { label = "CUST_OPACITY_SLIDER", type = TYPE_SLIDER, on_select = nil,
on_value_update = store_tattoo_composite_alpha_change, min = 0, max = 1, step = 0.05, current_value = Store_tattoo_current_alpha },
[2] = { label = "STORE_PURCHASE_ITEM", label_crc = nil, type = TYPE_BUTTON, on_select = store_tattoo_composite_alpha_done, },
}
store_common_push_menu(New_menu_data)
end
function store_tattoo_color_grid_show(menu_data)
Active_list:set_visible(false)
-- display the grid
Store_common_color_grid:draw_items(Color_grid_data, Color_grid_idx, 9, 7, 53.5, 53.5, 15, nil, 1.1, true, true, -7, true)
Store_common_color_grid:set_visible(true)
Store_common_color_grid:nav_enable(true, "store_tattoo_color_select", "store_tattoo_color_grid_nav")
Color_grid_data.alpha_select = menu_data.alpha_select
-- Disable the mouse for the active list when showing the color grid
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:subscribe(false)
end
Current_tier = COLOR_TIER
end
function store_tattoo_color_grid_nav(event, value)
store_tattoo_grid_nav(event, value)
-- set the color and preview the item
local idx = Store_common_color_grid:return_selected_index()
Store_tattoo_current_color = Color_grid_data[idx].index
if Store_tattoo_nav_thread ~= -1 then
thread_kill(Store_tattoo_nav_thread)
Store_tattoo_nav_thread = -1
end
Store_tattoo_nav_thread = thread_new("store_tattoo_item_delayed_set")
end
function store_tattoo_add_color(color_index, label_crc, label_str, red, green, blue, max_colors, is_current)
local grid_idx = #Color_grid_data + 1
Color_grid_data[grid_idx] = {
icon = "ui_menu_veh_pnt_base",
label = label_str,
label_crc = label_crc,
color = {red = red, green = green, blue = blue},
index = color_index,
}
if is_current == true then
Color_grid_idx = grid_idx
Store_tattoo_current_color = Color_grid_data[grid_idx].index
end
end
function store_tattoo_purchase()
store_tattoo_enable_mouse(false)
-- Are we short on cash?
if Store_tattoo_current_price ~= nil and Store_tattoo_current_price > Store_common_player_cash then
Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1)
Store_common_popup:set_title("MENU_TITLE_NOTICE")
Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")
Store_common_popup:nav_enable(true, "store_tattoo_fail_msg", "store_tattoo_popup_nav")
Not_popup_grp:set_alpha(.5)
return
end
-- Make sure they want to buy this
Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)
Store_common_popup:set_title("STORE_TITLE_PURCHASING")
Store_common_popup:set_text("STORE_TEXT_CONFIRM_PURCHASE_BLANK")
Store_common_popup:nav_enable(true, "store_tattoo_item_purchase_final", "store_tattoo_popup_nav")
Not_popup_grp:set_alpha(.5)
end
function store_tattoo_color_select(event)
Store_common_color_grid:nav_enable(false, nil, nil)
Store_common_color_grid:set_visible(false)
Active_list:set_visible(true)
Current_tier = MENU_TIER
-- Did the player select a color?
if not (event == "select" or event == "mouse_click") then
game_UI_audio_play("UI_Main_Menu_Nav_Back")
store_tattoo_enable_mouse(true)
else
game_UI_audio_play("UI_Main_Menu_Select")
if Color_grid_data.alpha_select then
store_tattoo_composite_show_alpha_menu()
else
-- Disable mouse input for active_list and hint_bar
store_tattoo_enable_mouse(false)
store_tattoo_purchase()
end
end
end
-- Finalize or cancel a purchase based on the result of the confirmation question.
--
function store_tattoo_item_purchase_final(event)
Store_common_popup:nav_enable(false, nil, nil)
Not_popup_grp:set_alpha(1)
-- Re-enable the mouse for disabled elements
store_tattoo_enable_mouse(true)
-- The user hit the B button and are cancelling the purchase
-- This is redundant to selecting "No" in the list
if event == "back" then
game_UI_audio_play("UI_Main_Menu_Nav_Back")
return
end
game_UI_audio_play("UI_Main_Menu_Select")
-- Did we select yes? This assumes yes is the first item
if Store_common_popup:get_selected_data() ~= 1 then
return
end
-- award respect and actually purchase the item
if Store_tattoo_current_respect ~= nil then
game_award_respect(Store_tattoo_current_respect, nil, nil, true)
end
if Store_tattoo_current_price ~= nil then
pcr_purchase_tattoo(Store_tattoo_current_price)
end
Store_tattoo_reverted = {}
ui_audio_post_event("tattoo_purchase")
store_tattoo_header_revert()
store_common_back_menu()
store_common_back_menu()
-- do this so holding down the button doesn't cause repeated actions
Input_tracker:subscribe(false)
Input_tracker:subscribe(true)
end
function store_tattoo_fail_msg(event)
Store_common_popup:nav_enable(false, nil, nil)
game_UI_audio_play("UI_Main_Menu_Select")
Not_popup_grp:set_alpha(1)
-- Re-enable the mouse for active_list and hint_bar
store_tattoo_enable_mouse(true)
end
function store_tattoo_popup_nav(event, value)
if event == "mouse_move" then
vint_set_mouse_cursor("")
end
if event == "nav_up" then
Store_common_popup.list:move_cursor(-1)
elseif event == "nav_down" then
Store_common_popup.list:move_cursor(1)
elseif event == "mouse_move" then
-- value contains the target_handle in this case
local new_index = Store_common_popup.list:get_button_index(value)
if new_index ~= 0 then
Store_common_popup.list:set_selection(new_index)
Store_common_popup.list:move_cursor(0, true)
end
else
--do nothing
end
end
function store_tattoo_item_set(menu_data)
if menu_data.tattoo_item ~= -1 then
if menu_data.colorized then
store_tattoo_color_grid_show(menu_data)
else
if menu_data.alpha_select then
store_tattoo_composite_show_alpha_menu()
else
store_tattoo_purchase()
end
end
else
store_common_back_menu()
end
end
function store_tattoo_item_revert()
-- If a set operation hasn't been enacted yet, we need to cancel it first.
if Store_tattoo_nav_thread ~= -1 then
thread_kill(Store_tattoo_nav_thread)
Store_tattoo_nav_thread = -1
end
for index, revert_item in pairs(Store_tattoo_reverted) do
pcr_change_composite(revert_item.area, revert_item.index, revert_item.color, revert_item.alpha)
end
Store_tattoo_reverted = {}
store_tattoo_header_revert()
end
function store_tattoo_item_delayed_set()
delay(0.4)
pcr_change_composite(Store_tattoo_current_area, Store_tattoo_current_item, Store_tattoo_current_color)
Store_tattoo_nav_thread = -1
end
function store_tattoo_item_nav(menu_data)
if Store_tattoo_nav_thread ~= -1 then
thread_kill(Store_tattoo_nav_thread)
Store_tattoo_nav_thread = -1
end
Store_tattoo_current_price = menu_data.price
Store_tattoo_current_respect = menu_data.respect
Store_header:set_price(menu_data.price)
Store_header:set_respect(menu_data.respect)
Store_tattoo_current_item = menu_data.tattoo_item
Store_tattoo_nav_thread = thread_new("store_tattoo_item_delayed_set")
end
function store_tattoo_item_add(tattoo_index, name_crc, name_str, current, colorized, alpha_select, price, respect)
local item = {
type = TYPE_BUTTON, tattoo_item = tattoo_index, label = name_str, label_crc = name_crc, on_nav = store_tattoo_item_nav, price = price, respect = respect,
on_select = store_tattoo_item_set, on_cancel = store_tattoo_item_revert, colorized = colorized, alpha_select = alpha_select,
}
if item.price == 0 then
item.price = nil
end
if item.respect == 0 then
item.respect = nil
end
local menu_idx = #Store_tattoo_building_menu + 1
if current == true then
Store_tattoo_building_menu.start_index = menu_idx
Store_tattoo_current_item = tattoo_index
Store_tattoo_current_price = price
Store_tattoo_current_respect = respect
Store_header:set_price(price)
Store_header:set_respect(respect)
end
Store_tattoo_building_menu[menu_idx] = item
end
function store_tattoo_menu_build(menu_data)
Store_tattoo_reverted = {}
if menu_data.tattoo_area ~= nil then
Store_tattoo_current_area = menu_data.tattoo_area
else
return
end
-- We need to store values to restore in case player cancels/reverts. We do this for the
-- current tattoo area, and any areas that this one "replaces" (overlaps). We then clear
-- out any "replaced" tatttoos.
local index, color, alpha = pcr_get_composite_info(Store_tattoo_current_area)
local revert_item = { area = Store_tattoo_current_area, index = index, color = color, alpha = alpha }
Store_tattoo_reverted[#Store_tattoo_reverted + 1] = revert_item
-- SEH 6/22/2011 - FrankM said we shouldn't replace other tattoo slots; they should be allowed to overlap
-- if menu_data.replace ~= nil then
-- for key, area in pairs(menu_data.replace) do
-- local index, color = pcr_get_composite_info(area)
-- local revert_item = { area = area, index = index, color = color, alpha = alpha }
-- Store_tattoo_reverted[#Store_tattoo_reverted + 1] = revert_item
-- pcr_change_composite(area, -1, 0)
-- end
-- end
-- Get the colors for the palette.
-- We need to do this now, because we need to find and save off the current tattoo the player has in case they revert.
Color_grid_data = {}
Color_grid_idx = 1
Store_tattoo_current_color = -1
pcr_report_composite_colors(Store_tattoo_current_area, true, "store_tattoo_add_color")
Store_tattoo_building_menu = menu_data.sub_menu
Store_tattoo_current_item = -1
Store_tattoo_current_alpha = 1
local item = {
label = "CUST_ITEM_NOTHING", type = TYPE_BUTTON, tattoo_item = -1, on_nav = store_tattoo_item_nav,
on_select = store_tattoo_item_set, on_cancel = store_tattoo_item_revert,
}
local menu_idx = #Store_tattoo_building_menu + 1
Store_tattoo_building_menu[menu_idx] = item
pcr_report_composite_items(Store_tattoo_current_area, "store_tattoo_item_add")
end
-- Main menu
--------------------------------------------
function store_tattoo_exit_final(event)
Store_common_popup:nav_enable(false, nil, nil)
-- The user hit the B button and is exiting
-- This is redundant to selecting "No" in the list
if event == "back" then
game_UI_audio_play("UI_Main_Menu_Nav_Back")
Not_popup_grp:set_alpha(1)
store_tattoo_enable_mouse(true)
return
end
game_UI_audio_play("UI_Main_Menu_Select")
-- Did we select yes? This assumes yes is the first item
if Store_common_popup:get_selected_data() ~= 1 then
Not_popup_grp:set_alpha(1)
store_tattoo_enable_mouse(true)
return
end
ui_audio_post_event("UI_Store_Exit")
store_lock_controls()
Not_popup_grp:set_alpha(0)
-- exit the interface
local anim_out = Vdo_anim_object:new("tattoo_bg_anim_out", 0, Store_tattoo_doc_handle)
anim_out:play(0)
pop_screen()
end
-- Player has requested to leave the store. Get confirmation before doing so.
--
function store_tattoo_exit(menu_data)
local body = "STORE_EXIT_WARNING_BODY"
local heading = "MENU_TITLE_WARNING"
Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)
Store_common_popup:set_title(heading)
Store_common_popup:set_text(body)
Store_common_popup:nav_enable(true, "store_tattoo_exit_final", "store_tattoo_popup_nav")
Not_popup_grp:set_alpha(.5)
-- Disable mouse input for other items while the popup is up
store_tattoo_enable_mouse(false)
end
-- We have returned to the top level menu. Currently restores camera position and
-- makes sure the thread for preset updates is killed.
--
function store_tattoo_return_main(menu_data)
store_set_camera_pos("body")
end
function store_tattoo_set_start_camera()
if Store_tattoo_init_camera_moved == false then
store_set_camera_pos("body")
store_start_lighting_change()
Store_tattoo_init_camera_moved = true
end
end
local Store_tattoo_head = {
{ label = "CUST_TATTOO_HEAD_TOP", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo head", camera = "head top", },
{ label = "CUST_TATTOO_NECK", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo neck", camera = "neck", },
}
local Store_tattoo_upper_body = {
{ label = "CUST_TATTOO_ENTIRE_BACK", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo entire back", camera = "entire back",
replace = { "tattoo upper back", "tattoo lower back" }, },
{ label = "CUST_TATTOO_UPPER_BACK", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo upper back", camera = "upper back",
replace = { "tattoo entire back" }, },
{ label = "CUST_TATTOO_LOWER_BACK", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo lower back", camera = "lower back",
replace = { "tattoo entire back" }, },
{ label = "CUST_TATTOO_ENTIRE_CHEST", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo entire chest", camera = "entire chest",
replace = { "tattoo upper chest", "tattoo lower chest" }, },
{ label = "CUST_TATTOO_UPPER_CHEST", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo upper chest", camera = "upper chest",
replace = { "tattoo entire chest" }, },
{ label = "CUST_TATTOO_LOWER_CHEST", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo lower chest", camera = "lower chest",
replace = { "tattoo entire chest" }, },
}
local Store_tattoo_arms = {
{ label = "CUST_TATTOO_ENTIRE_ARM_RIGHT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo entire arm right", camera = "entire arm right",
replace = { "tattoo upper arm right", "tattoo lower arm right", "tattoo hand right" }, },
{ label = "CUST_TATTOO_UPPER_ARM_RIGHT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo upper arm right", camera = "upper arm right",
replace = { "tattoo entire arm right" }, },
{ label = "CUST_TATTOO_LOWER_ARM_RIGHT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo lower arm right", camera = "lower arm right",
replace = { "tattoo entire arm right" }, },
{ label = "CUST_TATTOO_HAND_RIGHT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo hand right", camera = "hand left",
replace = { "tattoo entire arm right" }, },
{ label = "CUST_TATTOO_ENTIRE_ARM_LEFT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo entire arm left", camera = "entire arm left",
replace = { "tattoo upper arm left", "tattoo lower arm left", "tattoo hand left" }, },
{ label = "CUST_TATTOO_UPPER_ARM_LEFT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo upper arm left", camera = "upper arm left",
replace = { "tattoo entire arm left" }, },
{ label = "CUST_TATTOO_LOWER_ARM_LEFT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo lower arm left", camera = "lower arm left",
replace = { "tattoo entire arm left" }, },
{ label = "CUST_TATTOO_HAND_LEFT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo hand left", camera = "hand left",
replace = { "tattoo entire arm left" }, },
}
local Store_tattoo_legs = {
{ label = "CUST_TATTOO_ENTIRE_LEG_RIGHT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo leg right", camera = "entire leg right", },
{ label = "CUST_TATTOO_ENTIRE_LEG_LEFT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo leg left", camera = "entire leg left", },
}
local Store_tattoo_main_menu = {
on_enter = store_tattoo_return_main,
{ label = "CUST_TATTOO_HEAD", type = TYPE_BUTTON, sub_menu = Store_tattoo_head },
{ label = "CUST_TATTOO_UPPER_BODY", type = TYPE_BUTTON, sub_menu = Store_tattoo_upper_body },
{ label = "CUST_TATTOO_ARMS", type = TYPE_BUTTON, sub_menu = Store_tattoo_arms },
{ label = "CUST_TATTOO_LEGS", type = TYPE_BUTTON, sub_menu = Store_tattoo_legs },
{ label = "STORE_EXIT", type = TYPE_BUTTON, on_select = store_tattoo_exit }
}
---------------------------------------------------------------------------
-- Initialize Tattoo Store
---------------------------------------------------------------------------
function store_tattoo_init()
Store_common_current_highlight_color = COLOR_PLAYER_CREATION_PRIMARY
-- Find doc handle
Store_tattoo_doc_handle = vint_document_find("store_tattoo")
-- Set up some callbacks for the common store script
Store_common_populate_list_cb = store_tattoo_populate_list
Store_common_exit_cb = store_tattoo_exit
store_lock_controls()
-- Save the platform and set up the hint_bar mouse input
Game_platform = game_get_platform()
if Game_platform == "PC" then
Hint_bar_mouse_input_tracker = Vdo_input_tracker:new()
end
--Setup Button Hints
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Store_common_hint_bar:set_hints(hint_data)
Store_common_hint_bar:set_visible(true)
local hint_rotate_data = {
{CTRL_BUTTON_RS, "STORE_ZOOM_ROTATE"},
}
Store_common_rotate_hint:set_hints(hint_rotate_data)
Store_common_rotate_hint:enable_text_shadow(true)
Store_common_rotate_hint:set_visible(true)
if game_get_platform() == "PC" then
Store_common_rotate_hint:set_visible(false)
end
Store_header:set_visible(true)
-- Everything that is not in the popup so we can fade it when the popup is active
Not_popup_grp = Vdo_base_object:new("not_popup_grp", 0, Store_common_doc_handle)
-- Setup purchase popup
Store_common_popup:set_visible(false)
Store_common_popup:set_size(STORE_COMMON_LIST_SIZE, (LIST_BUTTON_HEIGHT * 5) + (LIST_BUTTON_SPACE * 5))
-- Setup Color grid
Store_common_color_grid:set_visible(false)
Store_common_color_grid:set_ui_screen("store_tattoo")
-- Populate the areas and draw the first menu
Menu_data = Store_tattoo_main_menu
-- Pass the table data to the megalist vdo.
store_tattoo_populate_list(Menu_data, 1)
-- Hide background animations
--local player_creation_grp = Vdo_base_object:new("player_creation_grp", 0, Store_tattoo_doc_handle)
--player_creation_grp:set_visible(false)
local color_primary, color_secondary, color_tertiary
-- Change colors for player creation
color_primary = COLOR_PLAYER_CREATION_PRIMARY
color_secondary = COLOR_PLAYER_CREATION_SECONDARY
color_tertiary = COLOR_PLAYER_CREATION_TERTIARY
-- Set background animations
Store_tattoo_in_anim = Vdo_anim_object:new("store_common_in_anim", 0, Store_common_doc_handle)
local anim_in = Vdo_anim_object:new("tattoo_bg_anim_in", 0, Store_tattoo_doc_handle)
local tattoo_bg_anim = Vdo_anim_object:new("tattoo_bg_anim", 0, Store_tattoo_doc_handle)
local skull_anim = Vdo_anim_object:new("skull_anim", 0, Store_tattoo_doc_handle)
local rustys_anim = Vdo_anim_object:new("rustys_anim", 0, Store_tattoo_doc_handle)
local needle_anim = Vdo_anim_object:new("needle_anim", 0, Store_tattoo_doc_handle)
local end_event_twn = Vdo_tween_object:new("end_event_twn", Store_tattoo_in_anim.handle)
local twn_h = vint_object_find("new_tween10", anim_in.handle)
vint_set_property(twn_h, "end_event", "store_tattoo_bg_anim_done")
end_event_twn:set_end_event("store_unlock_controls")
vint_apply_start_values(Store_tattoo_in_anim.handle)
vint_apply_start_values(skull_anim.handle)
vint_apply_start_values(rustys_anim.handle)
vint_apply_start_values(needle_anim.handle)
-- Start animations now
Store_tattoo_in_anim:play(0)
anim_in:play(0)
tattoo_bg_anim:play(0)
skull_anim:play(0)
rustys_anim:play(0)
needle_anim:play(0)
ui_audio_post_event("enter_rustys_needle")
--Player_creation_bg_anim:play(0)
-- Set colors
Store_header:set_color(color_primary, color_secondary, color_tertiary)
Active_list:set_highlight_color(color_primary, color_secondary, color_tertiary)
Store_common_color_grid:set_highlight_color(color_primary, color_secondary, color_tertiary)
Store_common_popup:set_color(color_primary, color_secondary, color_tertiary)
-- SEH: not hiding hair now, but we may want to add this back, at least for tattoos on the head.
-- save hair settings, then remove hair
--store_tattoo_hair_save_current()
--pcr_change_hair(STORE_CHARACTER_HAIR_AREA_HEAD, -1, 1, 1)
character_enable_mouse_drag(true)
end
function store_lock_controls()
Input_tracker:subscribe(false)
store_tattoo_enable_mouse(false)
end
function store_unlock_controls()
Input_tracker:subscribe(true)
store_tattoo_enable_mouse(true)
end
---------------------------------------------------------------------------
-- Cleanup Tattoo Store
---------------------------------------------------------------------------
function store_tattoo_cleanup()
-- revert any pending changes
store_tattoo_item_revert()
-- Nuke all button subscriptions
Input_tracker:subscribe(false)
store_tattoo_enable_mouse(false)
character_enable_mouse_drag(false)
-- 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.
store_common_cleanup_current_store()
end
-- Populate the active megalist menu, and hide the previous menu
--
-- list_data: this table contains the data to populate the megalist
-- current_index: the current index in the menu that's selected
--
function store_tattoo_populate_list(list_data, current_index)
Active_list:draw_items(list_data, current_index, STORE_COMMON_LIST_SIZE, 12, SCALE_FONT_STORE_TATTOO_LIST)
Active_list:set_visible(true)
-- Update the hint bar
store_tattoo_set_hints(list_data)
-- Add mouse inputs for active_list
if Game_platform == "PC" then
Mouse_input_tracker:remove_all()
Active_list:set_store("store_tattoo")
Active_list:add_mouse_inputs("store_common", Mouse_input_tracker)
store_tattoo_enable_mouse(true)
end
end
-- Sets up the hint buttons
--
function store_tattoo_set_hints(list_data)
-- build hint data
local hint_data = {}
local hint_count = 0
-- If all the items in the menu are sliders (no submenus) then add an "accept" hint
-- restore all to original values
local has_buttons = false
for i = 1, #list_data do
if list_data[i].type == TYPE_BUTTON then
has_buttons = true
end
end
if has_buttons == false then
hint_count = hint_count + 1
hint_data[hint_count] = {CTRL_MENU_BUTTON_A, "PAUSE_MENU_ACCEPT"}
end
-- add back choice
-- Are we on the main screen?
local back_hint
if store_common_stack_get_menu() ~= nil then
back_hint = {CTRL_MENU_BUTTON_B, "MENU_BACK"}
else
back_hint = {CTRL_MENU_BUTTON_B, "STORE_EXIT"}
end
hint_count = hint_count + 1
hint_data[hint_count] = back_hint
Store_common_hint_bar:set_hints(hint_data)
-- Add mouse input subscriptions
if Game_platform == "PC" then
Hint_bar_mouse_input_tracker:remove_all()
Store_common_hint_bar:add_mouse_inputs("store_tattoo", Hint_bar_mouse_input_tracker)
Hint_bar_mouse_input_tracker:subscribe(true)
end
local hint_rotate_data = {
{CTRL_BUTTON_RS, "STORE_ZOOM_ROTATE"},
}
Store_common_rotate_hint:set_hints(hint_rotate_data)
if game_get_platform() == "PC" then
Store_common_rotate_hint:set_visible(false)
end
end
-- Handle navigating grid
function store_tattoo_grid_nav(event, value)
if event == "nav_up" then
Store_common_color_grid:move_cursor(-2)
elseif event == "nav_down" then
Store_common_color_grid:move_cursor(2)
elseif event == "nav_left" then
Store_common_color_grid:move_cursor(-1)
elseif event == "nav_right" then
Store_common_color_grid:move_cursor(1)
elseif event == "mouse_move" then
-- value contains the target_handle in this case
local new_index = Store_common_color_grid:get_data_index(value)
if new_index ~= 0 then
Store_common_color_grid:set_selection(new_index)
Store_common_color_grid:move_cursor(0, false, true)
end
else
--do nothing
end
end
function store_tattoo_header_revert(menu_data)
Store_header:set_price(nil)
Store_header:set_respect(nil)
end
-- Save off the player's current hair settings into the table Store_character_hair_values
--
function store_tattoo_hair_save_current()
for i = STORE_CHARACTER_HAIR_AREA_BEGIN, STORE_CHARACTER_HAIR_AREA_END do
if i == STORE_CHARACTER_HAIR_AREA_HEAD then
Store_character_hair_values[i].style, Store_character_hair_values[i].primary, Store_character_hair_values[i].secondary = pcr_get_hair_info(i)
end
-- SEH -- work around?
if Store_character_hair_values[i].style == -2 then
Store_character_hair_values[i].style = -1
end
end
end
-- Restore hair settings from current saved values
--
function store_character_hair_revert_to_saved()
for i = STORE_CHARACTER_HAIR_AREA_BEGIN, STORE_CHARACTER_HAIR_AREA_END do
if i == STORE_CHARACTER_HAIR_AREA_HEAD then
pcr_change_hair(i, Store_character_hair_values[i].style, Store_character_hair_values[i].primary, Store_character_hair_values[i].secondary)
end
end
end
function store_tattoo_bg_anim_done()
store_common_bg_anim_complete()
end
-- =====================================
-- Mouse Specific Functions
-- =====================================
function store_tattoo_enable_mouse(enable)
if Game_platform == "PC" and enable ~= nil then
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:subscribe(enable)
end
if Hint_bar_mouse_input_tracker ~= nil then
Hint_bar_mouse_input_tracker:subscribe(enable)
end
end
end
function store_tattoo_mouse_click(event, target_handle)
local hint_index = Store_common_hint_bar:get_hint_index(target_handle)
if hint_index ~= 0 then
if Store_common_hint_bar.hint_data[hint_index][1] == CTRL_MENU_BUTTON_B then
if Current_tier == MENU_TIER then
store_common_button_b()
elseif Current_tier == COLOR_TIER then
store_tattoo_color_select("back")
end
elseif Store_common_hint_bar.hint_data[hint_index][1] == CTRL_MENU_BUTTON_A then
store_common_button_a()
else
-- Should never get here (figure out what caused it and add case for it)
store_common_button_b()
end
end
end
function store_tattoo_mouse_move(event, target_handle)
vint_set_mouse_cursor("")
store_common_mouse_zoom(0.0)
Store_common_hint_bar:set_highlight(0)
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)
end
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)
Active_list:move_cursor(0, true)
-- If the item has a callback for navigation, do it (such as putting clothes on)
local data_item = Active_list:return_selected_data()
if data_item.on_nav ~= nil then
data_item.on_nav(data_item)
end
return
end
end
function store_tattoo_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines)
if scroll_lines ~= 0 then
if Store_common_color_grid.bg.handle == target_handle then
Store_common_color_grid:scroll_list(scroll_lines * -1)
end
end
end
function store_tattoo_mouse_drag(event, target_handle, mouse_x, mouse_y)
if Store_common_color_grid.scrollbar.tab.handle == target_handle then
local new_start_index = Store_common_color_grid.scrollbar:drag_scrolltab(mouse_y, Store_common_color_grid.rows - (Store_common_color_grid.max_height - 1))
Store_common_color_grid:scroll_list(0, new_start_index)
end
end
function store_tattoo_mouse_drag_release(event, target_handle, mouse_x, mouse_y)
if Store_common_color_grid.scrollbar.tab.handle == target_handle then
local start_row = Store_common_color_grid:get_visible_rows()
Store_common_color_grid.scrollbar:release_scrolltab(start_row, Store_common_color_grid.rows - (Store_common_color_grid.max_height - 1))
Store_common_color_grid:update_mouse_inputs()
end
end