STORE_CLOTHING_INVALID_INDEX = -1
SCALE_FONT_STORE_CLOTHING_LIST = 0.8
STORE_CLOTHING_CATEGORY_MAX = 150
STORE_CLOTHING_TOTAL_MAX = 2048
BRAND_NONE = -1
BRAND_ASTRO = 0
BRAND_CROOKS = 1
BRAND_HEYDEY = 2
BRAND_JOYSTICK = 3
BRAND_RIPPLE = 4
BRAND_SOTA = 5
Store_clothing_doc_handle = -1
local CRIB = 0
local LETS_PRETEND = 1
local NOBODY_LOVES_ME = 2
local LEATHER_AND_LACE = 3
local PLANET_SAINTS = 4
local IMPRESSIONS = 5
local Store_clothing_data = {
[CRIB] = { pegs = { }, color = COLOR_STORE_REWARDS_PRIMARY, logo_grp = "store_title_grp"},
[LETS_PRETEND] = { pegs = { "ui_bms_store_lets_pretend" }, color = COLOR_STORE_LETS_PRETEND_PRIMARY, logo_grp = "store_logo_grp"},
[NOBODY_LOVES_ME] = { pegs = { "ui_bms_store_nobody" }, color = COLOR_STORE_NOBODY_PRIMARY, logo_grp = "nobody_logo_grp"},
[LEATHER_AND_LACE] = { pegs = { "ui_bms_store_lace" }, color = COLOR_STORE_LACE_PRIMARY, logo_grp = "lace_logo_grp"},
[PLANET_SAINTS] = { pegs = { "ui_bms_store_planet" }, color = COLOR_STORE_PLANET_PRIMARY, logo_grp = "planet_logo_grp"},
[IMPRESSIONS] = { pegs = { "ui_bms_store_impressions" }, color = COLOR_STORE_IMPRESSIONS_PRIMARY, logo_grp = "impressions_logo_grp"},
}
local Store_clothing_brand_data = {
[BRAND_ASTRO] = { logo = "ui_store_brand_astro"},
[BRAND_CROOKS] = { logo = "ui_store_brand_crooks"},
[BRAND_HEYDEY] = { logo = "ui_store_brand_heyday"}, --the targa is spelled heyday
[BRAND_JOYSTICK] = { logo = "ui_store_brand_joystick"},
[BRAND_RIPPLE] = { logo = "ui_store_brand_ripple"},
[BRAND_SOTA] = { logo = "ui_store_brand_sota"},
}
local Store_index = LETS_PRETEND
local Next_anim_to_play = 0
local Online_check_thread = -1
-- These tables hold our menu and toggle data that get populated into the vdo's.
local Toggle_data = {}
local Wear_opt_data = {}
local Style_variant_data = {}
Color_grid_data = {}
-- 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
-- Save off current clothing color index if player cancels change
local Color_prev_color = 0
-- Hint bar and store header vdo's.
local Store_logo_grp
local Store_logo1
local Store_logo2
local Not_popup_grp
local Reward_image
STORE_CLOTHING_PENDING_NONE = -1
STORE_CLOTHING_PENDING_ITEM = 1
STORE_CLOTHING_PENDING_STORE_OUTFIT = 2
STORE_CLOTHING_PENDING_OWNED_OUTFIT = 3
-- Variables for background updating threads.
local Store_clothing_item_update_thread = -1
local Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_NONE
local Store_clothing_outfit_id = -1
local Store_clothing_outfit_finalize = false
-- Keeps tracking of the area and category that we've currently selected
local Store_clothing_area = -1
local Store_clothing_category = -1
local Store_clothing_brands_loaded = false
-- This table holds a ton of information for the currently selected clothing item.
Store_clothing_item_info = {
colors = { [0] = { }, [1] = { }, [2] = { } }
}
-- Determines if we're in "store" or "wardrobe" mode.
local Store_clothing_is_wardrobe = false
local Store_clothing_loaded_from_crib = false
-- Menu Tiers
local MENU_TIER = 1
local COLOR_TIER = 2
local Current_tier = MENU_TIER
local Game_platform
Hint_bar_mouse_input_tracker = -1
---------------------------------------------------------------------------
-- Initialize Clothing Store
---------------------------------------------------------------------------
function store_clothing_init()
Store_clothing_doc_handle = vint_document_find("store_clothing")
-- Save boolean if we're coming from the crib
Store_clothing_loaded_from_crib = store_common_crib_is_loaded()
if Store_clothing_loaded_from_crib == false then
pause_map_dump()
end
thread_new("store_clothing_pause_map_delay")
-- These should either be globals, or just use vint_set_property to mark these visible false, rather than Vdo_base_object:new here
local lets_pretend_bg_grp = Vdo_base_object:new("lets_pretend_bg_grp", 0, Store_clothing_doc_handle)
local nobody_grp = Vdo_base_object:new("nobody_grp", 0, Store_clothing_doc_handle)
local lace_grp = Vdo_base_object:new("lace_grp", 0, Store_clothing_doc_handle)
local planet_grp = Vdo_base_object:new("planet_grp", 0, Store_clothing_doc_handle)
local impressions_grp = Vdo_base_object:new("impressions_grp", 0, Store_clothing_doc_handle)
local brand_logo = Vdo_base_object:new("brand_logo_img", 0, Store_clothing_doc_handle)
lets_pretend_bg_grp:set_visible(false)
nobody_grp:set_visible(false)
lace_grp:set_visible(false)
planet_grp:set_visible(false)
impressions_grp:set_visible(false)
brand_logo:set_visible(false)
--set the index so we know what peg to load
Store_index = store_clothing_get_store_id()
--Override return if we're coming from the crib doc
if Store_clothing_loaded_from_crib then
Store_index = CRIB
end
-- We don't need to animate in the background or load pegs or change colors if we're coming from the crib interface.
local pegs = Store_clothing_data[Store_index].pegs
local peg_count = #Store_clothing_data[Store_index].pegs
if Store_index == CRIB then
store_clothing_set_store()
else
game_peg_load_with_cb("store_clothing_set_store", 1, pegs[1])
end
character_enable_mouse_drag(true)
end
-- Lock input until streaming is done, to prevent issues with backing out of menus before a previewed item appears at it doesn't get reverted.
--
function store_clothing_allow_input(event)
local allow = pcu_is_streaming_done() or (event ~= "back" and event ~= "select")
return allow
end
function store_clothing_set_store()
Game_platform = game_get_platform()
-- If we're in the crib, we're only doing wardrobe (not store).
Store_clothing_is_wardrobe = Store_clothing_loaded_from_crib
-- Set up some callbacks for the common store script
Store_common_populate_list_cb = store_clothing_populate_list
Store_common_exit_cb = store_clothing_exit
Store_common_allow_input_cb = store_clothing_allow_input
-- Subscribe to the button presses we need, Input_tracker is created in store_common.lua
Input_tracker:subscribe(false)
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Store_common_hint_bar:set_hints(hint_data)
Store_common_hint_bar:set_visible(true)
if game_is_active_input_gamepad() then
local hint_rotate_data = {
{CTRL_BUTTON_RS, "STORE_ZOOM_ROTATE"},
}
Store_common_rotate_hint:set_hints(hint_rotate_data)
if Game_platform ~= "PC" then
Store_common_rotate_hint:set_visible(true)
end
end
if Game_platform == "PC" then
Mouse_input_tracker:subscribe(false)
Hint_bar_mouse_input_tracker = Vdo_input_tracker:new()
Store_common_rotate_hint:set_visible(false)
end
Store_header:set_visible(true)
Store_logo_grp = Vdo_base_object:new("store_logo_grp", 0, Store_clothing_doc_handle)
Store_logo1 = Vdo_base_object:new("store_logo_img_1", 0, Store_clothing_doc_handle)
Store_logo2 = Vdo_base_object:new("store_logo_img_2", 0, Store_clothing_doc_handle)
-- 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_clothing")
-- Start up the background update thread.
if Store_clothing_item_update_thread == -1 then
Store_clothing_item_update_thread = thread_new("store_clothing_item_preview_update")
end
-- SEH
Active_list:set_highlight_color(Store_clothing_data[Store_index].color)
Store_common_current_highlight_color = Store_clothing_data[Store_index].color
if Store_clothing_loaded_from_crib then
Store_common_current_highlight_color = COLOR_STORE_REWARDS_PRIMARY
end
-- Do all our main initialization based on which mode (store or wardrobe) we're in
store_clothing_mode_set_init()
-- make background so player is on top
bg_saints_set_background(false)
local lets_pretend_bg_grp = Vdo_base_object:new("lets_pretend_bg_grp", 0, Store_clothing_doc_handle)
local nobody_grp = Vdo_base_object:new("nobody_grp", 0, Store_clothing_doc_handle)
local lace_grp = Vdo_base_object:new("lace_grp", 0, Store_clothing_doc_handle)
local planet_grp = Vdo_base_object:new("planet_grp", 0, Store_clothing_doc_handle)
local impressions_grp = Vdo_base_object:new("impressions_grp", 0, Store_clothing_doc_handle)
-- animate in ui for clothing store (shared by all stores)
local store_clothing_in_anim = Vdo_anim_object:new("store_common_in_anim", 0, Store_common_doc_handle)
local end_event_twn = Vdo_tween_object:new("end_event_twn", store_clothing_in_anim.handle, Store_common_doc_handle)
end_event_twn:set_end_event("store_unlock_controls")
-- offset if we are in the crib
if Store_clothing_is_wardrobe then
local cloth_screen_grp_twn = vint_object_find("cloth_screen_grp_twn",0,Store_common_doc_handle)
local twn_x,twn_y = vint_get_property(cloth_screen_grp_twn,"end_value")
vint_set_property(cloth_screen_grp_twn, "end_value", Store_common_screen_grp_x, twn_y)
local store_main_grp = Vdo_base_object:new("store_main_grp", 0, Store_common_doc_handle)
store_main_grp:set_anchor(0,0)
end
vint_apply_start_values(store_clothing_in_anim.handle)
store_clothing_in_anim:play(0)
-- Set Store Header colors
Store_header:set_color(Store_clothing_data[Store_index].color, COLOR_STORE_CLOTHING_SECONDARY, COLOR_STORE_CLOTHING_TERTIARY)
-- Needs to be done after the list is drawn/populated
--Active_list:set_highlight_color(Store_clothing_data[Store_index].color)
Store_common_color_grid:set_highlight_color(Store_clothing_data[Store_index].color)
Store_common_popup:set_color(Store_clothing_data[Store_index].color, COLOR_STORE_CLOTHING_SECONDARY, COLOR_STORE_CLOTHING_TERTIARY)
local clothing_bg_grp = Vdo_base_object:new("screen_grp", 0, Store_clothing_doc_handle)
clothing_bg_grp:set_visible(true)
if Store_index == CRIB then
bg_saints_set_type(BG_TYPE_CENTER,true,1280)
bg_saints_set_background(false)
--hack just to get an animation for the rendering callback
local planet_bg_anim_in = Vdo_anim_object:new("planet_bg_anim_in", 0, Store_clothing_doc_handle)
local planet_bg_twn = Vdo_tween_object:new("new_tween67", planet_bg_anim_in.handle, Store_clothing_doc_handle)
vint_apply_start_values(planet_bg_anim_in.handle)
planet_bg_anim_in:play(0)
planet_bg_twn:set_end_event("store_clothing_bg_anim_done")
--store_unlock_controls()
-- SEH: 6/28/11: commenting out because we do need this visible for the "brand logo"- and it doesn't appear to be necessary.
-- Hide clothing store background since we use the saints background in crib
--local clothing_bg_grp = Vdo_base_object:new("screen_grp", 0, Store_clothing_doc_handle)
--clothing_bg_grp:set_visible(false)
elseif Store_index == LETS_PRETEND then
--Set background animations to running
local lets_pretend_logo_anim = Vdo_anim_object:new("lets_pretend_logo_anim", 0, Store_clothing_doc_handle)
local bg_animation1 = Vdo_anim_object:new("rainbow1_anim", 0, Store_clothing_doc_handle)
local bg_animation2 = Vdo_anim_object:new("rainbow2_anim", 0, Store_clothing_doc_handle)
local bg_animation3 = Vdo_anim_object:new("lets_pretend_bg_anim_in", 0, Store_clothing_doc_handle)
local bg_twn = Vdo_tween_object:new("rainbow_end_event_twn", bg_animation1.handle, Store_clothing_doc_handle)
local bg_twn2 = Vdo_tween_object:new("rainbow_end_event_twn", bg_animation2.handle, Store_clothing_doc_handle)
local bg_twn4 = Vdo_tween_object:new("desaturate_twn", bg_animation3.handle, Store_clothing_doc_handle)
vint_apply_start_values(lets_pretend_logo_anim.handle)
vint_apply_start_values(bg_animation1.handle)
vint_apply_start_values(bg_animation2.handle)
vint_apply_start_values(bg_animation3.handle)
lets_pretend_logo_anim:play(0)
bg_animation1:play(0)
bg_animation2:play(0)
bg_animation3:play(0)
ui_audio_post_event("enter_lets_pretend")
bg_twn:set_end_event("store_loop_bg_anims")
bg_twn2:set_end_event("store_loop_bg_anims")
bg_twn4:set_end_event("store_clothing_bg_anim_done")
lets_pretend_bg_grp:set_visible(true)
elseif Store_index == NOBODY_LOVES_ME then
local nobody_logo_anim = Vdo_anim_object:new("nobody_logo_anim", 0, Store_clothing_doc_handle)
local nobody_bg_anim_in = Vdo_anim_object:new("nobody_bg_anim_in", 0, Store_clothing_doc_handle)
--tell next anim to play
local end_event_twn = Vdo_tween_object:new("end_event_twn", nobody_bg_anim_in.handle)
end_event_twn:set_end_event("store_clothing_loop_nobody_bg")
local twn = Vdo_tween_object:new("new_tween68", nobody_bg_anim_in.handle, Store_clothing_doc_handle)
vint_apply_start_values(nobody_logo_anim.handle)
vint_apply_start_values(nobody_bg_anim_in.handle)
nobody_bg_anim_in:play(0)
nobody_logo_anim:play(0)
ui_audio_post_event("enter_nobody_loves_me")
twn:set_end_event("store_clothing_bg_anim_done")
nobody_grp:set_visible(true)
elseif Store_index == LEATHER_AND_LACE then
local lace_logo_anim = Vdo_anim_object:new("lace_logo_anim", 0, Store_clothing_doc_handle)
local lace_bg_anim = Vdo_anim_object:new("lace_bg_anim", 0, Store_clothing_doc_handle)
local lace_bg_anim_in = Vdo_anim_object:new("lace_bg_anim_in", 0, Store_clothing_doc_handle)
local lace_bg_twn = Vdo_tween_object:new("new_tween21", lace_bg_anim_in.handle, Store_clothing_doc_handle)
vint_apply_start_values(lace_bg_anim_in.handle)
vint_apply_start_values(lace_logo_anim.handle)
lace_bg_anim_in:play(0)
lace_logo_anim:play(0)
lace_bg_anim:play(0)
ui_audio_post_event("enter_leatherlace")
lace_bg_twn:set_end_event("store_clothing_bg_anim_done")
lace_grp:set_visible(true)
elseif Store_index == PLANET_SAINTS then
local planet_logo_anim = Vdo_anim_object:new("planet_logo_anim", 0, Store_clothing_doc_handle)
local planet_bg_anim = Vdo_anim_object:new("planet_bg_anim", 0, Store_clothing_doc_handle)
local planet_bg_anim_in = Vdo_anim_object:new("planet_bg_anim_in", 0, Store_clothing_doc_handle)
local planet_bg_twn = Vdo_tween_object:new("new_tween67", planet_bg_anim_in.handle, Store_clothing_doc_handle)
--tween loops in vinny
vint_apply_start_values(planet_logo_anim.handle)
vint_apply_start_values(planet_bg_anim.handle)
vint_apply_start_values(planet_bg_anim_in.handle)
planet_bg_anim_in:play(0)
planet_logo_anim:play(0)
planet_bg_anim:play(0)
ui_audio_post_event("enter_planet_saints")
planet_bg_twn:set_end_event("store_clothing_bg_anim_done")
planet_grp:set_visible(true)
elseif Store_index == IMPRESSIONS then
local impressions_logo_anim = Vdo_anim_object:new("impressions_logo_anim", 0, Store_clothing_doc_handle)
local impressions_bg_anim = Vdo_anim_object:new("impressions_bg_anim", 0, Store_clothing_doc_handle)
local impressions_bg_anim_in = Vdo_anim_object:new("impressions_bg_anim_in", 0, Store_clothing_doc_handle)
vint_apply_start_values(impressions_logo_anim.handle)
vint_apply_start_values(impressions_bg_anim_in.handle)
vint_apply_start_values(impressions_bg_anim.handle)
--tween loops in vinny
impressions_bg_anim_in:play(0)
impressions_logo_anim:play(0)
impressions_bg_anim:play(0)
impressions_grp:set_visible(true)
end
end
function store_clothing_pause_map_delay()
delay(2)
store_clothing_brand_load_peg()
end
function store_clothing_brand_load_peg()
--Load peg for clothing store brand logos (used in ALL stores)
game_peg_load_with_cb("store_clothing_brand_loaded", 1, "ui_bms_store_brands")
end
function store_clothing_brand_loaded()
Store_clothing_brands_loaded = true
end
function store_clothing_brand_swap_logo(brand_id, show_brand)
if Store_clothing_brands_loaded == false then
return
end
local doc_handle = Store_clothing_doc_handle
-- For the crib wardrobe, the logo is actually stored in the crib doc
if Store_index == CRIB then
doc_handle = Store_crib_doc_handle
end
local store_logo_grp = Vdo_base_object:new(Store_clothing_data[Store_index].logo_grp, 0, doc_handle)
local brand_logo = Vdo_base_object:new("brand_logo_img", 0, Store_clothing_doc_handle)
if show_brand == true then
--Hide store logo
store_logo_grp:set_visible(false)
--Set and show brand logo
brand_logo:set_image(Store_clothing_brand_data[brand_id].logo)
brand_logo:set_visible(true)
else
--Show store logo
store_logo_grp:set_visible(true)
--Hide brand logo
brand_logo:set_visible(false)
end
end
function store_clothing_loop_nobody_bg(tween_h)
--loop background anim
local nobody_bg_anim = Vdo_anim_object:new("nobody_bg_anim", 0, Store_clothing_doc_handle)
local twn_h = vint_object_find("end_event_twn", nobody_bg_anim.handle)
nobody_bg_anim:play(0)
vint_set_property(twn_h, "end_event", "vint_anim_loop_callback")
end
function store_unlock_controls()
bg_saints_set_background(true)
Input_tracker:subscribe(true)
store_clothing_enable_mouse(true)
end
function store_loop_bg_anims(tween_handle)
local animation = vint_object_parent(tween_handle)
lua_play_anim(animation)
end
-- Cleanup function called on document unload.
--
function store_clothing_cleanup()
-- Remove anything that hasn't been purchased.
pcu_clear_preview_slot()
-- kill update thread
if Store_clothing_item_update_thread ~= -1 then
thread_kill(Store_clothing_item_update_thread)
Store_clothing_item_update_thread = -1
end
-- Nuke all button subscriptions
Input_tracker:subscribe(false)
store_clothing_enable_mouse(false)
local store_clothing_in_anim = Vdo_anim_object:new("store_clothing_in_anim", 0, Store_common_doc_handle)
local end_event_twn = Vdo_tween_object:new("end_event_twn", store_clothing_in_anim.handle, Store_common_doc_handle)
end_event_twn:set_end_event(nil)
-- unload all pegs
for key, peg_name in pairs(Store_clothing_data[Store_index].pegs) do
game_peg_unload(peg_name)
end
game_peg_unload("ui_bms_store_brands")
if Store_clothing_loaded_from_crib == false then
pause_map_restore()
end
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()
if Online_check_thread ~= -1 then
thread_kill(Online_check_thread)
end
end
function store_clothing_exit()
-- no confirmation needed if we're just going back to the crib menu
if Store_clothing_loaded_from_crib then
game_UI_audio_play("UI_Main_Menu_Nav_Back")
-- lock input during animation
Input_tracker:subscribe(false)
store_clothing_enable_mouse(false)
-- make background so player is covered up
bg_saints_set_background(false)
local back_out_anim = Vdo_anim_object:new("store_crib_out_anim", 0, Store_common_doc_handle)
local back_out_end_twn = Vdo_tween_object:new("common_anchor_out_twn", back_out_anim.handle)
back_out_end_twn:set_end_event("store_clothing_crib_exit")
back_out_anim:play(0)
else
-- if we're in the wardrobe from a store, just go back to the store
if Store_clothing_is_wardrobe then
store_clothing_switch_mode()
return
end
Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)
Store_common_popup:set_title("MENU_TITLE_WARNING")
Store_common_popup:set_text("STORE_EXIT_WARNING_BODY")
Store_common_popup:nav_enable(true, "store_clothing_exit_final", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
store_clothing_enable_mouse(false)
end
end
function store_clothing_crib_exit(tween_h, event)
-- called when we slide out to the crib
pop_screen()
end
function store_clothing_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_logo_grp:set_alpha(1)
Active_list:set_visible(true)
store_clothing_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_logo_grp:set_alpha(1)
Active_list:set_visible(true)
store_clothing_enable_mouse(true)
return
end
ui_audio_post_event("UI_Store_Exit")
Input_tracker:subscribe(false)
store_clothing_enable_mouse(false)
Not_popup_grp:set_alpha(0)
Store_logo_grp:set_alpha(0)
-- exit the interface
pop_screen()
end
-- Called when this interface becomes the top one on the stack again.
--
function store_clothing_gained_focus()
Input_tracker:subscribe(true)
store_clothing_enable_mouse(true)
if Game_platform ~= "PC" then
Store_common_rotate_hint:set_visible(true)
end
Store_common_hint_bar:set_visible(true)
character_enable_mouse_drag(true)
-- Reinitialize state
store_clothing_mode_set_init()
-- Set up some callbacks for the common store script
Store_common_populate_list_cb = store_clothing_populate_list
Store_common_exit_cb = store_clothing_exit
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_clothing_populate_list(list_data, current_index)
Active_list:draw_items(list_data, current_index, STORE_COMMON_LIST_SIZE, 12, SCALE_FONT_STORE_CLOTHING_LIST)
Active_list:set_visible(true)
if Game_platform == "PC" then
Mouse_input_tracker:remove_all()
Active_list:set_store("store_clothing")
Active_list:add_mouse_inputs("store_common", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
-- Callback from C code that adds areas to Menu_data table.
--
-- area_index: unique ID for the area.
-- label_crc: crc for the name to display. nil if string is used instead.
-- label_str: string for the name to display. nil if crc is used instead.
-- has_new_items: does this category have items that haven't been viewed in the wardrobe?
--
function store_clothing_area_add(area_index, label_crc, label_str, has_new_items)
local menu_idx = #Menu_data + 1
local new_item = {
type = TYPE_BUTTON,
id = area_index,
label = nil,
label_crc = nil,
on_nav = store_clothing_area_nav,
on_sub_menu_fill = store_clothing_category_get_all,
is_new = has_new_items,
}
Menu_data[menu_idx] = new_item
-- Set the name of the menu choice, may be from crc or string itself
if label_crc ~= nil and label_crc ~= 0 then
new_item.label_crc = label_crc
else
new_item.label = label_str
end
end
function store_clothing_category_get_all(menu_data)
Store_common_sub_menu = {}
pcu_get_categories_in_area(Store_clothing_area, "store_clothing_category_add")
Store_clothing_category = Store_common_sub_menu[1].id
pcu_set_active_category(Store_clothing_category, Store_clothing_area)
-- If there is only one category in this area, just go on into the category menu!
if #Store_common_sub_menu == 1 then
local new_menu_data = {}
new_menu_data.id = Store_clothing_category
Store_common_sub_menu = {}
store_clothing_item_get_list(new_menu_data)
else
Store_common_sub_menu.on_enter = store_clothing_category_menu_update
end
end
-- Refresh the clothing category menu when we return to it, since the "new" highlights may have been updated by browsing
--
function store_clothing_category_menu_update(menu_data)
local index = Active_list:get_selection()
Menu_data = {}
Store_common_sub_menu = {}
pcu_set_active_category(Store_clothing_category, Store_clothing_area)
pcu_get_categories_in_area(Store_clothing_area, "store_clothing_category_add")
Menu_data = Store_common_sub_menu
Store_common_sub_menu = {}
Menu_data.on_enter = store_clothing_category_menu_update
store_clothing_populate_list(Menu_data, index)
end
-- Callback from C code that adds categories to Menu_data table.
--
-- area_index: unique ID for the category.
-- label_crc: crc for the name to display. nil if string is used instead.
-- label_str: string for the name to display. nil if crc is used instead.
-- has_new_items: this category contains items that haven't been viewed in the UI before.
--
function store_clothing_category_add(cat_index, label_crc, label_str, has_new_items)
local menu_idx = #Store_common_sub_menu + 1
local new_item = {
type = TYPE_BUTTON,
id = cat_index,
label = nil,
label_crc = nil,
on_nav = store_clothing_category_nav,
on_sub_menu_fill = store_clothing_item_get_list,
is_new = has_new_items,
}
Store_common_sub_menu[menu_idx] = new_item
-- Set the name of the menu choice, may be from crc or string itself
if label_crc ~= nil and label_crc ~= 0 then
new_item.label_crc = label_crc
else
new_item.label = label_str
end
end
function store_clothing_item_get_list(menu_data)
-- disable switching modes here
store_clothing_set_hints(false)
-- force a garbage collection
vint_force_lua_gc()
Store_common_sub_menu = {
default_on_nav = store_clothing_item_nav,
default_on_sub_menu_fill = store_clothing_item_details,
default_on_back = store_clothing_item_revert
}
pcu_get_items_in_category(menu_data.id, "store_clothing_item_add")
if #Store_common_sub_menu == 0 then
-- Don't think this should ever happen, if stores are set up correctly, but just in case.
Store_common_sub_menu[1] = {
type = TYPE_BUTTON,
id = -1,
label = "HAIR_CAT_NONE",
label_crc = nil,
is_owned = true,
price = 0,
style = 0,
is_outfit = false,
on_select = store_clothing_item_remove,
}
end
local index = Store_common_sub_menu.start_index or 1
store_clothing_item_nav(Store_common_sub_menu[index])
end
function store_clothing_outfit_none(menu_data)
store_clothing_item_revert(menu_data)
store_common_button_b()
end
-- The player chose "none" for the item to wear. Set player to wear nothing and go back up a menu.
--
function store_clothing_item_remove(menu_data)
store_clothing_header_revert()
pcu_wear_current_clothing()
-- back out of menu
store_common_back_menu()
end
-- Callback from C code that adds clothing items to Menu_data table.
--
-- item_id: unique id for the clothing item.
-- label_crc: crc for the name to display. nil if string is used instead.
-- label_str: string for the name to display. nil if crc is used instead.
-- is_outfit: true if this is an outfit.
-- price: price of the item
-- style: how much style the item adds.
-- inc_wardrobe_instance: instance of the wardrobe item (to distinguish duplicate items)
-- is_available: true if the item is available for purchase.
-- variant_num: id indicating which variant this is
-- variant_lbl: string for the variant text to display. nil if crc is used instead.
-- variant_lbl_crc: crc for the variant text to display. nil if string is used instead.
-- is_current: true if we're in the wardrobe and this item is currently worn.
--
function store_clothing_item_add(item_id, label_crc, label_str, is_outfit, price, style, inc_wardrobe_instance, is_available, is_reward, is_unusable_dlc, is_new, is_dlc, variant_num, variant_lbl_crc, variant_lbl, is_current, brand_id, disable_removal)
local menu_idx = #Store_common_sub_menu + 1
--debug_print("vint", "adding brand " .. brand_id .. "\n")
-- We only want to add a "none" choice if this isn't an outfits menu, and (obviously) we haven't added it
-- to the top of the list yet.
if menu_idx == 1 and is_outfit == false and disable_removal ~= true then
-- first choice is to remove items of this type
Store_common_sub_menu[1] = {
id = -1,
label = "HAIR_CAT_NONE",
label_crc = nil,
is_owned = true,
price = 0,
style = 0,
is_outfit = false,
on_select = store_clothing_item_remove,
is_new = false,
is_dlc = false,
}
menu_idx = 2
end
local new_item = {
id = item_id,
label = nil,
label_crc = nil,
--is_owned = false,
variant_num = variant_num,
is_outfit = is_outfit,
wardrobe_instance = inc_wardrobe_instance,
disabled = is_unusable_dlc,
--is_reward = is_reward,
--is_unusable_dlc = is_unusable_dlc,
brand_id = brand_id,
is_new = is_new,
is_dlc = is_dlc,
-- on_nav = store_clothing_item_nav,
-- on_sub_menu_fill = store_clothing_item_details,
-- on_back = store_clothing_item_revert,
}
if Store_clothing_is_wardrobe == false then
new_item.price = price
new_item.style = style
end
if variant_lbl_crc == nil and variant_lbl == nil then
--Set the name of the menu choice, may be from crc or string itself
if label_crc ~= nil and label_crc ~= 0 then
new_item.label_crc = label_crc
else
new_item.label = label_str
end
else
-- Set the name of the menu choice, may be from crc or string itself
if variant_lbl_crc ~= nil and variant_lbl_crc ~= 0 then
new_item.label_crc = variant_lbl_crc
else
new_item.label = variant_lbl
end
end
-- if is_available ~= false then
-- if pcu_is_item_owned(item_id, nil) == true then
-- -- We own all of this item's styles, so you can't actually select details
-- new_item.is_owned = true
-- end
-- end
Store_common_sub_menu[menu_idx] = new_item
if is_current == true then
Store_common_sub_menu.start_index = menu_idx
end
end
function store_clothing_header_revert(menu_data)
Store_header:set_price(nil)
Store_header:set_respect(nil)
end
-- Trigger background item updates when navigating among different clothing items in the menu.
--
-- id: unique id of the selected clothing item.
-- variant_id: unique id of the variant for this item.
--
function store_clothing_item_nav(menu_data)
--debug_print("vint", "brand is " .. menu_data.brand_id .. "\n")
if menu_data.is_outfit == false then
Store_clothing_outfit_id = -1
local id = menu_data.id
local variant_id = menu_data.variant_num
if Store_clothing_is_wardrobe == false then
store_clothing_item_get_defaults(id)
else
if id == -1 then
Store_clothing_item_info.item_index = -1
else
store_clothing_get_owned_item_info(menu_data.id, menu_data.wardrobe_instance)
Store_clothing_item_info.wardrobe_instance = menu_data.wardrobe_instance --store the instance of the current item incase we need to discard
end
end
if variant_id then
Store_clothing_item_info.variant_index = variant_id
end
Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_ITEM
local brand_id = menu_data.brand_id
if brand_id == nil or brand_id == BRAND_NONE then
-- Swap back to store logo
store_clothing_brand_swap_logo(brand_id, false)
else
-- Swap back to store logo
store_clothing_brand_swap_logo(brand_id, true)
end
-- clear out "new" status if it is true
if menu_data.is_new then
pcu_clear_item_new(menu_data.id, menu_data.wardrobe_instance)
--Remove our mouse inputs first...
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:remove_all()
end
--Get index from the list and then remove the flag...
local index = 1
local data = Active_list:return_data()
for data_index = 1, #data do
if menu_data.id == data[data_index].id then
if menu_data.wardrobe_instance == data[data_index].wardrobe_instance then
--Match!!
index = data_index
break
end
end
end
--Remove the new flag from our active list...
Active_list:remove_new_flag(index)
--Update cursor,
Active_list:move_cursor(0)
--Re add mouse inputs...
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:remove_all()
Active_list:add_mouse_inputs("store_common", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
else
Store_clothing_item_info.item_price = menu_data.price
Store_clothing_item_info.item_style = menu_data.style
Store_clothing_outfit_id = menu_data.id
Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_STORE_OUTFIT
end
if Store_clothing_is_wardrobe == false then
-- Update the store header price and respect values
Store_header:set_price(Store_clothing_item_info.item_price)
Store_header:set_respect(Store_clothing_item_info.item_style)
end
end
-- Player hit back on clothing item instead of buying it; revert preview.
--
function store_clothing_item_revert(menu_data)
-- This will cancel the delayed preview of an item
Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_NONE
store_clothing_header_revert()
if menu_data.is_outfit then
pcu_set_active_category(Store_clothing_category, Store_clothing_area)
else
pcu_clear_preview_slot()
end
-- We want to re-enable mode switching at this point
store_clothing_set_hints(Store_clothing_loaded_from_crib == false)
-- Swap logo back
store_clothing_brand_swap_logo(nil, false)
end
function store_clothing_area_nav(menu_data)
local id = Active_list:get_id()
Store_clothing_area = id
end
function store_clothing_category_nav(menu_data)
local id = Active_list:get_id()
pcu_clear_preview_slot()
Store_clothing_category = id
pcu_set_active_category(Store_clothing_category, Store_clothing_area)
end
function store_clothing_wear_option_nav(menu_data)
Store_clothing_item_info.wear_option_index = Wear_opt_data[Active_list:get_toggle_selection()]
store_clothing_item_preview(true)
end
function store_clothing_style_nav(menu_data)
Store_clothing_item_info.variant_index = Style_variant_data[Active_list:get_toggle_selection()]
store_clothing_item_preview(true)
end
-- Calls into C code to get the default setttings for a given item.
--
-- item_index: unique ID into for the item to get info on.
--
function store_clothing_item_get_defaults(item_index)
local t = Store_clothing_item_info
if item_index >= 0 then
t.slot_index, t.item_index, t.item_name_crc, t.item_name_str,
t.num_variants, t.variant_index, t.variant_name_crc, t.variant_name_str,
t.colors.num_colors,
t.colors[0].index, t.colors[0].red, t.colors[0].green, t.colors[0].blue,
t.colors[1].index, t.colors[1].red, t.colors[1].green, t.colors[1].blue,
t.colors[2].index, t.colors[2].red, t.colors[2].green, t.colors[2].blue,
t.num_wear_options, t.wear_option_index, t.wear_option_name_crc, t.wear_option_name_str,
t.num_logos, t.logo_index, t.logo_name_crc, t.logo_name_str, t.logo_color_index, t.logo_color_red, t.logo_color_green, t.logo_color_blue,
t.item_style, t.item_price,
t.player_style_level, t.player_style_percent
= pcu_get_item_defaults(item_index)
else
t.item_index = -1
t.item_price = nil
t.item_style = nil
end
end
function store_clothing_get_owned_item_info(item_index, wardrobe_instance) -- like get item defaults, but called when browsing the inventory
local t = Store_clothing_item_info
if wardrobe_instance == nil then
wardrobe_instance = -1 --this should never occur, but incase it does, this will make it assert instead of crash
end
if item_index >= 0 then
t.slot_index, t.item_index, t.item_name_crc, t.item_name_str,
t.num_variants, t.variant_index, t.variant_name_crc, t.variant_name_str,
t.colors.num_colors,
t.colors[0].index, t.colors[0].red, t.colors[0].green, t.colors[0].blue,
t.colors[1].index, t.colors[1].red, t.colors[1].green, t.colors[1].blue,
t.colors[2].index, t.colors[2].red, t.colors[2].green, t.colors[2].blue,
t.num_wear_options, t.wear_option_index, t.wear_option_name_crc, t.wear_option_name_str,
t.num_logos, t.logo_index, t.logo_name_crc, t.logo_name_str, t.logo_color_index, t.logo_color_red, t.logo_color_green, t.logo_color_blue
= pcu_get_owned_item_info(item_index, wardrobe_instance)
else
t.item_index = -1
t.item_price = nil
t.item_style = nil
end
end
-- Calls into C code to get the settingsf for the given slot.
--
-- slot: ID for the slot to get the info on.
--
function store_clothing_item_get_slot_info(slot)
local t = Store_clothing_item_info
local temp_logo_storage_color_index = t.logo_color_index
local temp_logo_storage_color_red = t.logo_color_red
local temp_logo_storage_color_green = t.logo_color_green
local temp_logo_storage_color_blue = t.logo_color_blue
t.slot_index, t.item_index, t.item_name_crc, t.item_name_str,
t.num_variants, t.variant_index, t.variant_name_crc, t.variant_name_str,
t.colors.num_colors,
t.colors[0].index, t.colors[0].red, t.colors[0].green, t.colors[0].blue,
t.colors[1].index, t.colors[1].red, t.colors[1].green, t.colors[1].blue,
t.colors[2].index, t.colors[2].red, t.colors[2].green, t.colors[2].blue,
t.num_wear_options, t.wear_option_index, t.wear_option_name_crc, t.wear_option_name_str,
t.num_logos, t.logo_index, t.logo_name_crc, t.logo_name_str, t.logo_color_index, t.logo_color_red, t.logo_color_green, t.logo_color_blue,
t.item_style, t.item_price,
t.player_style_level, t.player_style_percent
= pcu_get_slot_info(slot)
--do this to prevent logo color from being wiped when previewing the "no logo" logo
if t.logo_index == STORE_CLOTHING_INVALID_INDEX then
t.logo_color_index = temp_logo_storage_color_index
t.logo_color_red = temp_logo_storage_color_red
t.logo_color_green = temp_logo_storage_color_green
t.logo_color_blue = temp_logo_storage_color_blue
end
end
-- Build the menu for the detailed actions possible for the selected item.
--
function store_clothing_item_details(menu_data)
Store_common_sub_menu = {}
local new_menu = Store_common_sub_menu
local menu_idx = 0
if Store_clothing_outfit_id == -1 then
-- get info on the item
store_clothing_item_preview(true)
local item = Store_clothing_item_info
-- color selections
if Store_clothing_is_wardrobe == false and item.colors.num_colors ~= nil and item.colors.num_colors > 0 then
local c = item.colors
for i = 0, c.num_colors - 1 do
local color_label
if i == 0 then
color_label = "STORE_PRIMARY_COLOR"
elseif i == 1 then
color_label = "STORE_SECONDARY_COLOR"
elseif i == 2 then
color_label = "STORE_TERTIARY_COLOR"
else
color_label = "STORE_DETAIL_COLOR"
end
menu_idx = menu_idx + 1
local new_item = {
type = TYPE_TOGGLE_COLOR,
id = i,
label = color_label,
label_crc = nil,
color = c[i],
on_select = store_clothing_color_select,
}
new_menu[menu_idx] = new_item
end
end
-- style (variant) selections
if Store_clothing_is_wardrobe == false and item.num_variants > 1 then
-- get our variants to populate the toggle
Toggle_data = {}
Style_variant_data = {}
pcu_get_variants(item.slot_index, "store_clothing_style_add")
menu_idx = menu_idx + 1
local new_item = {
type = TYPE_TOGGLE,
label = "MENU_STYLE",
options = Toggle_data,
current_value = 1,
on_nav = store_clothing_style_nav,
}
new_menu[menu_idx] = new_item
end
-- wear option selections
if item.num_wear_options > 1 then
-- get our wear options to populate the toggle
Toggle_data = {}
Wear_opt_data = {}
pcu_get_wear_options(item.slot_index, "store_clothing_wear_option_add")
menu_idx = menu_idx + 1
local new_item = {
type = TYPE_TOGGLE,
label = "CUST_MENU_WEAR_OPTION",
options = Toggle_data,
current_value = 1,
on_nav = store_clothing_wear_option_nav,
}
new_menu[menu_idx] = new_item
end
end
-- add the purchase item choice
menu_idx = menu_idx + 1
if Store_clothing_is_wardrobe == false then
local new_item = {
type = TYPE_BUTTON,
label = "STORE_PURCHASE_ITEM",
label_crc = nil,
on_select = store_clothing_item_purchase
}
new_menu[menu_idx] = new_item
else
local new_item = {
type = TYPE_BUTTON,
label = "CUST_ITEM_WEAR",
label_crc = nil,
on_select = store_clothing_item_wear
}
new_menu[menu_idx] = new_item
menu_idx = menu_idx + 1
new_item = {
type = TYPE_BUTTON,
label = "STORE_DISCARD_ITEM",
label_crc = nil,
on_select = store_clothing_item_discard
}
new_menu[menu_idx] = new_item
end
end
-- When in the wardrobe, the player can select to wear an item. This updates the slots and leaves menu.
--
function store_clothing_item_wear()
if pcu_is_streaming_done() and Store_clothing_waiting_update_value == STORE_CLOTHING_PENDING_NONE then
pcu_wear_current_clothing()
store_common_back_menu()
store_common_back_menu()
end
end
-- When in the wardrobe, the player can select to discard an item. This brings up a warning dialog before doing so.
--
function store_clothing_item_discard()
store_clothing_enable_mouse(false)
if pcu_is_current_item_worn(Store_clothing_item_info.slot_index, Store_clothing_item_info.wardrobe_instance) then
if pcu_is_underwear_category(Store_clothing_category) then
Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1)
Store_common_popup:set_title("STORE_UNDERWEAR_WARNING")
Store_common_popup:set_text("STORE_UNDERWEAR_SUB_WARNING")
Store_common_popup:nav_enable(true, "store_clothing_fail_msg", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
else
if pcu_is_bra_category(Store_clothing_category) and pcu_bra_required() then
Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1)
Store_common_popup:set_title("STORE_BRA_WARNING")
Store_common_popup:set_text("STORE_BRA_SUB_WARNING")
Store_common_popup:nav_enable(true, "store_clothing_fail_msg", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
else
Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)
Store_common_popup:set_title("STORE_TITLE_DISCARD")
Store_common_popup:set_text("STORE_TEXT_DISCARD")
Store_common_popup:nav_enable(true, "store_clothing_item_discard_confirm_1", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
end
end
else
Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)
Store_common_popup:set_title("STORE_TITLE_DISCARD")
Store_common_popup:set_text("STORE_TEXT_DISCARD")
Store_common_popup:nav_enable(true, "store_clothing_item_discard_confirm_1", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
end
end
function store_clothing_item_discard_confirm_1(event)
Store_common_popup:nav_enable(false, nil, nil)
Not_popup_grp:set_alpha(1)
Store_logo_grp:set_alpha(1)
Active_list:set_visible(true)
store_clothing_enable_mouse(true)
-- The user hit the B button and are cancelling the discard
-- 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
-- do this so holding down the button doesn't cause repeated actions
Input_tracker:subscribe(false)
Input_tracker:subscribe(true)
if pcu_is_item_needed_for_outfit(Store_clothing_item_info.slot_index) then
Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)
Store_common_popup:set_title("STORE_TITLE_DISCARD_OUTFIT_WARNING")
Store_common_popup:set_text("STORE_TEXT_DISCARD_OUTFIT_WARNING")
Store_common_popup:nav_enable(true, "store_clothing_item_discard_confirm_2", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
store_clothing_enable_mouse(false)
else
pcu_discard_slot(Store_clothing_item_info.slot_index, Store_clothing_item_info.wardrobe_instance)
store_common_back_menu()
store_common_back_menu()
end
end
function store_clothing_item_discard_confirm_2(event)
Store_common_popup:nav_enable(false, nil, nil)
Not_popup_grp:set_alpha(1)
Store_logo_grp:set_alpha(1)
Active_list:set_visible(true)
store_clothing_enable_mouse(true)
-- The user hit the B button and are cancelling the discard
-- 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
-- do this so holding down the button doesn't cause repeated actions
Input_tracker:subscribe(false)
Input_tracker:subscribe(true)
pcu_discard_slot(Store_clothing_item_info.slot_index, Store_clothing_item_info.wardrobe_instance)
store_common_back_menu()
store_common_back_menu()
end
function store_clothing_item_purchase(menu_data)
local item = Store_clothing_item_info
store_clothing_enable_mouse(false)
-- Have we reached the category item limit?
local num_owned = pcu_get_num_items_category(Store_clothing_category, Store_clothing_outfit_id)
if num_owned >= STORE_CLOTHING_CATEGORY_MAX 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("CUST_MENU_CATEGORY_LIMIT_REACHED")
Store_common_popup:nav_enable(true, "store_clothing_fail_msg", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
return
end
-- Have we reached the total item limit?
num_owned = pcu_get_num_items_owned(Store_clothing_outfit_id)
if num_owned >= STORE_CLOTHING_TOTAL_MAX 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("CUST_MENU_TOTAL_LIMIT_REACHED")
Store_common_popup:nav_enable(true, "store_clothing_fail_msg", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
return
end
-- Are we short on cash?
if item.item_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_clothing_fail_msg", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
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_clothing_item_purchase_final", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
end
function store_clothing_color_select(menu_data)
Active_list:set_visible(false)
-- get the colors for the palette
Color_grid_data = {}
Color_slot_chosen = menu_data.id
Color_grid_idx = 1
pcu_report_item_colors("store_clothing_color_add", Store_clothing_item_info.item_index)
-- 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_clothing_color_selected", "store_clothing_color_nav")
Color_prev_color = Color_grid_idx
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:subscribe(false)
end
Current_tier = COLOR_TIER
end
-- Callback to get a wear option from C and add it to our wear option toggle.
--
-- option_index: indicates which wear option this is for
-- name_crc: crc to use for the toggle choice name. nil if string is used.
-- name_str: string to use for the toggle choice name. nil if crc is used.
--
function store_clothing_wear_option_add(option_index, name_crc, name_str)
local toggle_idx = #Toggle_data + 1
if name_crc ~= nil then
Toggle_data[toggle_idx] = name_crc
else
Toggle_data[toggle_idx] = name_str
end
Wear_opt_data[toggle_idx] = option_index
end
-- Callback to get a style option from C and add it to our style toggle.
--
-- option_index: indicates which style options this is for
-- name_crc: crc to use for the toggle choice name. nil if string is used.
-- name_str: string to use for the toggle choice name. nil if crc is used.
--
function store_clothing_style_add(option_index, name_crc, name_str)
local toggle_idx = #Toggle_data + 1
if name_crc ~= nil then
Toggle_data[toggle_idx] = name_crc
else
Toggle_data[toggle_idx] = name_str
end
Style_variant_data[toggle_idx] = option_index
end
-- Callback to get a color option from C and add it to our color grid.
--
-- color_index: indicates which color this is for
-- label_crc: crc to use for the toggle choice name. nil if string is used.
-- label_str: string to use for the toggle choice name. nil if crc is used.
-- red: r value.
-- green: g value.
-- blue: b value.
--
function store_clothing_color_add(color_index, label_crc, label_str, red, green, blue)
local grid_idx = #Color_grid_data + 1
Color_grid_data[grid_idx] = {
icon = "ui_menu_veh_pnt_base",
label_crc = label_crc,
label = label_str,
color = {red = red, green = green, blue = blue},
index = color_index,
}
if color_index == Store_clothing_item_info.colors[Color_slot_chosen].index then
Color_grid_idx = grid_idx
end
end
function store_clothing_color_selected(event)
--Did the player select a color?
if event == "select" or event == "mouse_click" then
game_UI_audio_play("UI_Main_Menu_Select")
else
game_UI_audio_play("UI_Main_Menu_Nav_Back")
-- restore previous color
Store_clothing_item_info.colors[Color_slot_chosen].index = Color_grid_data[Color_prev_color].index
Store_clothing_item_info.colors[Color_slot_chosen].red = Color_grid_data[Color_prev_color].color.red
Store_clothing_item_info.colors[Color_slot_chosen].green = Color_grid_data[Color_prev_color].color.green
Store_clothing_item_info.colors[Color_slot_chosen].blue = Color_grid_data[Color_prev_color].color.blue
store_clothing_item_preview(true)
end
store_clothing_populate_list(Menu_data, Active_list:get_selection())
Store_common_color_grid:nav_enable(false, nil, nil)
Store_common_color_grid:cleanup()
Color_grid_data = {}
Store_common_color_grid:set_visible(false)
Store_common_color_grid:cleanup()
Active_list:set_visible(true)
store_clothing_enable_mouse(true)
Current_tier = MENU_TIER
end
function store_clothing_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)
Store_logo_grp:set_alpha(1)
Active_list:set_visible(true)
store_clothing_enable_mouse(true)
end
-- Finalize or cancel a purchase based on the result of the confirmation question.
--
-- response: how did the user respond?
-- action: indicates if the dialog box was closed or some other action.
--
function store_clothing_item_purchase_final(event)
Store_common_popup:nav_enable(false, nil, nil)
Not_popup_grp:set_alpha(1)
Store_logo_grp:set_alpha(1)
Active_list:set_visible(true)
store_clothing_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
game_award_respect(Store_clothing_item_info.item_style, nil, nil, true)
-- is this an outfit or an item?
if Store_clothing_outfit_id == -1 then
pcu_purchase_slot(Store_clothing_item_info.slot_index)
else
pcu_purchase_outfit(Store_clothing_outfit_id)
end
ui_audio_post_event("clothing_purchase")
-- Go back up 2 menus
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_clothing_popup_nav(event, value)
vint_set_mouse_cursor("")
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_clothing_color_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
-- set the color and preview the item
local idx = Store_common_color_grid:return_selected_index()
Store_clothing_item_info.colors[Color_slot_chosen].index = Color_grid_data[idx].index
Store_clothing_item_info.colors[Color_slot_chosen].red = Color_grid_data[idx].color.red
Store_clothing_item_info.colors[Color_slot_chosen].green = Color_grid_data[idx].color.green
Store_clothing_item_info.colors[Color_slot_chosen].blue = Color_grid_data[idx].color.blue
store_clothing_item_preview(true)
end
-- Kick off previewing an item
--
-- get_specific_variant: currently unused.
--
function store_clothing_item_preview(get_specific_variant)
Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_ITEM -- this needs to not be = -1 so we know to update
end
-- Background thread that updates the item that is previewed.
--
function store_clothing_item_preview_update() --this thread should be always running in the background when suits are being previewed
debug_print("vint", "outfit update thread started\n")
while true do
if pcu_is_streaming_done() then
delay(0.2)
if Store_clothing_waiting_update_value ~= STORE_CLOTHING_PENDING_NONE then
-- clothing items
if Store_clothing_waiting_update_value == STORE_CLOTHING_PENDING_ITEM then
local t = Store_clothing_item_info
debug_print("vint", "updating single item with logo "..var_to_string(t.logo_index).."\n")
--if t.slot_index ~= STORE_CLOTHING_INVALID_INDEX then --makes sure the item is initialized before trying to preview it
if t.item_index < 0 or t.wear_option_index < 0 then
pcu_set_slots_empty(Store_clothing_category)
else
pcu_set_slot_info(t.slot_index, t.item_index, t.variant_index, t.colors.num_colors, t.colors[0].index,
t.colors[1].index, t.colors[2].index, t.wear_option_index, t.logo_index, t.logo_color_index, true)
end
--end
-- This appears to be necessary to make sure Preview_slot global in C is updated.
if t.slot_index ~= nil then
store_clothing_item_get_slot_info(t.slot_index)
end
end
-- outfits (in store)
if Store_clothing_waiting_update_value == STORE_CLOTHING_PENDING_STORE_OUTFIT then
debug_print("vint", "updating store outfit\n")
pcu_wear_store_outfit(Store_clothing_outfit_id)
end
-- outfits (in wardrobe)
if Store_clothing_waiting_update_value == STORE_CLOTHING_PENDING_OWNED_OUTFIT then
debug_print("vint", "updating owned outfit\n")
pcu_wear_outfit(Store_clothing_outfit_id, Store_clothing_outfit_finalize)
end
Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_NONE
end
end
thread_yield()
end
end
-- Callback that's called when asynchronous image loading is complete
--
function store_clothing_set_logo()
Store_logo1:set_image("ui_store_logo_lets_pretend")
Store_logo2:set_image("ui_store_logo_lets_pretend")
for i = 1, 4 do
local r_h = Vdo_base_object:new("rainbow"..i, 0, Store_clothing_doc_handle)
r_h:set_image("ui_store_lets_pretend_rainbow")
r_h = Vdo_base_object:new("rainbow"..i.."_1", 0, Store_clothing_doc_handle)
r_h:set_image("ui_store_lets_pretend_rainbow")
end
end
-- Sets up the hint buttons - will change between store/wardrobe.
--
function store_clothing_set_hints(mode_switch_enabled)
local hint_data = { {CTRL_MENU_BUTTON_B, "MENU_BACK"} }
Store_common_hint_bar:set_hints(hint_data)
if Game_platform == "PC" then
Hint_bar_mouse_input_tracker:remove_all()
Store_common_hint_bar:add_mouse_inputs("store_clothing", 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)
end
-- When returning to the top level menu, we may need to restore items that were removed
-- because they obscure other slots.
--
function store_clothing_restore_items(menu_data)
pcu_clear_obscured_slots()
store_set_camera_pos("body")
end
function store_clothing_wardrobe_outfit_menu_fill(menu_data)
local store_clothing_wardrobe_outfit_menu = {
on_enter = store_clothing_outfit_enter,
[1] = { label = "CUST_ITEM_VIEW_OUTFITS", type = TYPE_BUTTON, on_sub_menu_fill = store_clothing_outfit_get_all, outfit_cb = store_clothing_outfit_select },
[2] = { label = "CUST_ITEM_CREATE_OUTFIT", type = TYPE_BUTTON, on_select = store_clothing_outfit_create },
[3] = { label = "CUST_ITEM_DELETE_OUTFIT", type = TYPE_BUTTON, on_sub_menu_fill = store_clothing_outfit_get_all, outfit_cb = store_clothing_outfit_delete },
[4] = { label = "CUST_ITEM_REMOVE_CLOTHING", type = TYPE_BUTTON, on_select = store_clothing_remove_clothing },
}
Store_common_sub_menu = store_clothing_wardrobe_outfit_menu
end
function store_clothing_mode_set_init()
-- Update our hints
store_clothing_set_hints(Store_clothing_loaded_from_crib == false)
-- Reset our header
Store_header:clear_titles()
Store_header:set_price(nil)
Store_header:set_respect(nil)
-- Populate the areas and draw the first menu
local store_clothing_name
if Store_clothing_is_wardrobe then
store_clothing_name = "wardrobe"
Store_header:enable_price_respect(false)
Store_header:push_title(nil, "MENU_SWAP_WARDROBE")
else
store_clothing_name = "DEBUG_CLOTHING_STORE"
--Store_header:enable_price_respect(true)
end
-- reset our store stacks
store_common_stack_clear_menu()
store_common_stack_clear_id()
store_common_stack_clear_index()
Menu_data = {}
pcu_get_areas(store_clothing_name, "store_clothing_area_add")
Menu_data.on_enter = store_clothing_area_menu_update
-- if we're in the wardrobe, add the outfit menu
if Store_clothing_is_wardrobe then
local item = {
label = "CUST_ICON_OUTFITS", type = TYPE_BUTTON, on_sub_menu_fill = store_clothing_wardrobe_outfit_menu_fill
}
Menu_data[#Menu_data + 1] = item
if Store_clothing_loaded_from_crib == false then
item = {
label = "MENU_BACK", type = TYPE_BUTTON, on_select = store_clothing_switch_mode
}
Menu_data[#Menu_data + 1] = item
end
else
local item = {
label = "MENU_SWAP_WARDROBE", type = TYPE_BUTTON, on_select = store_clothing_switch_mode
}
Menu_data[#Menu_data + 1] = item
-- Option to switch to the online character gallery
local item = {
label = "STORE_CHARACTER_GALLERY", type = TYPE_BUTTON, on_select = store_clothing_load_gallery,
}
Menu_data[#Menu_data + 1] = item
-- add exit store option
local exit_item = {
label = "STORE_EXIT", type = TYPE_BUTTON, on_select = store_clothing_exit
}
Menu_data[#Menu_data + 1] = exit_item
end
-- Set current area to first menu choice
Store_clothing_area = Menu_data[1].id
-- Pass the table data to the megalist vdo.
store_clothing_populate_list(Menu_data, 1)
end
-- Refresh the clothing area menu when we return to it, since the "new" highlights may have been updated by browsing
--
function store_clothing_area_menu_update(menu_data)
local store_clothing_name
if Store_clothing_is_wardrobe then
store_clothing_name = "wardrobe"
else
store_clothing_name = "DEBUG_CLOTHING_STORE"
end
local index = Active_list:get_selection()
Menu_data = {}
pcu_get_areas(store_clothing_name, "store_clothing_area_add")
Menu_data.on_enter = store_clothing_area_menu_update
-- if we're in the wardrobe, add the outfit menu
if Store_clothing_is_wardrobe then
local item = {
label = "CUST_ICON_OUTFITS", type = TYPE_BUTTON, on_sub_menu_fill = store_clothing_wardrobe_outfit_menu_fill
}
Menu_data[#Menu_data + 1] = item
if Store_clothing_loaded_from_crib == false then
item = {
label = "MENU_BACK", type = TYPE_BUTTON, on_select = store_clothing_switch_mode
}
Menu_data[#Menu_data + 1] = item
end
else
local item = {
label = "MENU_SWAP_WARDROBE", type = TYPE_BUTTON, on_select = store_clothing_switch_mode
}
Menu_data[#Menu_data + 1] = item
-- Option to switch to the online character gallery
local item = {
label = "STORE_CHARACTER_GALLERY", type = TYPE_BUTTON, on_select = store_clothing_load_gallery,
}
Menu_data[#Menu_data + 1] = item
-- add exit store option
local exit_item = {
label = "STORE_EXIT", type = TYPE_BUTTON, on_select = store_clothing_exit
}
Menu_data[#Menu_data + 1] = exit_item
end
store_clothing_populate_list(Menu_data, index)
-- Force removed clothing to be returned
store_clothing_restore_items()
end
-- Load the online character gallery.
--
function store_clothing_load_gallery()
Online_check_thread = thread_new("store_clothing_check_online_for_gallery")
end
function store_clothing_check_online_for_gallery()
online_and_privilege_validator_begin(false, true, true, true, true, true) -- Check we're signed in and we have content permissions
while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do
thread_yield()
end
Input_tracker:subscribe(true)
if Online_validator_result ~= ONLINE_VALIDATOR_PASSED then
return
end
if main_menu_check_user_content() == false then
dialog_box_message("MENU_TITLE_WARNING", "USER_CONTENT_PRIV_DENIED")
return
end
push_screen("store_gallery")
Online_check_thread = -1
end
-- Switch between store and wardrobe modes.
--
function store_clothing_switch_mode()
local store_main_grp = Vdo_base_object:new("store_main_grp", 0, Store_common_doc_handle)
local store_to_wardrobe_anim = Vdo_anim_object:new("store_to_wardrobe_anim",0, Store_common_doc_handle)
local wardrobe_twn_1 = Vdo_tween_object:new("wardrobe_twn_1", store_to_wardrobe_anim.handle)
local wardrobe_twn_2 = Vdo_tween_object:new("wardrobe_twn_2", store_to_wardrobe_anim.handle)
store_main_grp:set_property("background", true)
--bg_saints_set_background(true)
if Store_clothing_is_wardrobe == true then
Store_clothing_is_wardrobe = false
wardrobe_twn_1:set_end_event("store_clothing_switch_to_store")
else
Store_clothing_is_wardrobe = true
wardrobe_twn_1:set_end_event("store_clothing_switch_to_wardrobe")
end
wardrobe_twn_2:set_end_event("store_clothing_switch_mode_complete")
store_to_wardrobe_anim:play(0)
-- Lock controls until animation is done
Input_tracker:subscribe(false)
store_clothing_enable_mouse(false)
-- Set camera position back to whole body
store_set_camera_pos("body")
end
function store_clothing_switch_mode_complete()
local store_main_grp = Vdo_base_object:new("store_main_grp", 0, Store_common_doc_handle)
store_main_grp:set_property("background", false)
bg_saints_set_background(false)
store_unlock_controls()
end
function store_clothing_switch_to_wardrobe()
local store_logo_grp = Vdo_base_object:new("store_logo_grp", 0, Store_common_doc_handle)
store_logo_grp:set_visible(false)
Store_header:reformat_and_resize(true)
store_clothing_mode_set_init()
end
function store_clothing_switch_to_store()
local store_logo_grp = Vdo_base_object:new("store_logo_grp", 0, Store_common_doc_handle)
store_logo_grp:set_visible(true)
Store_header:reformat_and_resize(false)
store_clothing_mode_set_init()
end
-- Acquire all the outfits the player has into a sub menu.
--
function store_clothing_outfit_get_all(menu_data)
-- disable switching modes here
store_clothing_set_hints(false)
Store_common_sub_menu = {}
Store_common_sub_menu.cb = menu_data.outfit_cb
pcu_report_outfits("store_clothing_outfit_add")
if #Store_common_sub_menu == 0 then
local new_item = { label = "NO_OUTFITS_DISPLAY_NAME", type = TYPE_BUTTON, on_select = store_common_back_menu }
Store_common_sub_menu[1] = new_item
else
store_clothing_outfit_nav(Store_common_sub_menu[1])
end
end
-- Callback to add 1 outfit to the menu
--
function store_clothing_outfit_add(outfit_idx)
local menu_idx = #Store_common_sub_menu + 1
local item = { label = "{OUTFIT_NAME_"..outfit_idx.."}", type = TYPE_BUTTON, outfit_index = outfit_idx, on_select = Store_common_sub_menu.cb,
on_nav = store_clothing_outfit_nav, on_cancel = store_clothing_outfit_revert }
Store_common_sub_menu[menu_idx] = item
end
-- Called when navigating over a different outfit.
--
function store_clothing_outfit_nav(menu_data)
Store_clothing_outfit_id = menu_data.outfit_index
Store_clothing_outfit_finalize = false
Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_OWNED_OUTFIT
end
-- Called when player backs out of outfit preview with back button.
--
function store_clothing_outfit_revert(menu_data)
pcu_category_nav_clear_slot(Store_clothing_area)
end
-- Handles when the player selects an outfit to preview
--
function store_clothing_outfit_select()
if (pcu_is_streaming_done()) then
Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)
Store_common_popup:set_title("WEAR_OUTFIT_TITLE")
Store_common_popup:set_text("CONFIRM_WEAR_OUTFIT")
Store_common_popup:nav_enable(true, "store_clothing_outfit_select_confirm", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
store_clothing_enable_mouse(false)
end
end
-- Confirmation for dialog to wear outfit.
--
function store_clothing_outfit_select_confirm(event)
Store_common_popup:nav_enable(false, nil, nil)
Not_popup_grp:set_alpha(1)
Store_logo_grp:set_alpha(1)
Active_list:set_visible(true)
store_clothing_enable_mouse(true)
-- 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")
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
Store_clothing_outfit_finalize = true
Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_OWNED_OUTFIT
store_common_back_menu()
end
-- Create an outfit from the player's current clothes.
--
function store_clothing_outfit_create()
local success, reason_title, reason_body
success, reason_title, reason_body = pcu_can_create_outfit()
if success == true then
-- disable switching modes here
store_clothing_set_hints(false)
game_vkeyboard_input("OUTFIT_NAME_TAG", "OUTFIT_NAME_ENTRY_DIALOG", 16, "OUTFIT_NAME_TAG", "store_clothing_outfit_name_cb", true)
else
Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1)
Store_common_popup:set_title(reason_title)
Store_common_popup:set_text(reason_body)
Store_common_popup:nav_enable(true, "store_clothing_fail_msg", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
store_clothing_enable_mouse(false)
end
end
-- Callback from virtual keyboard.
--
function store_clothing_outfit_name_cb(success)
if success == true then
pcu_create_outfit("VKEYBOARD_RESULTS")
end
-- enable switching modes here
store_clothing_set_hints(Store_clothing_loaded_from_crib == false)
end
-- Pulls up dialog to confirm if we are going to delete an outfit.
--
function store_clothing_outfit_delete(menu_data)
Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)
Store_common_popup:set_title("CUST_ITEM_DELETE_OUTFIT")
Store_common_popup:set_text("CONFIRM_DELETE_OUTFIT")
Store_common_popup:nav_enable(true, "store_clothing_outfit_delete_confirm", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
store_clothing_enable_mouse(false)
end
-- Confirmation for dialog to delete outfit.
--
function store_clothing_outfit_delete_confirm(event)
Store_common_popup:nav_enable(false, nil, nil)
Not_popup_grp:set_alpha(1)
Store_logo_grp:set_alpha(1)
Active_list:set_visible(true)
store_clothing_enable_mouse(true)
-- 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")
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
pcu_delete_outfit(Store_clothing_outfit_id)
pcu_clear_preview_slot()
store_common_back_menu()
end
function store_clothing_remove_clothing()
Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)
Store_common_popup:set_title("CUST_DIALOG_DISROBE_TITLE")
Store_common_popup:set_text("CUST_DIALOG_DISROBE_BODY")
Store_common_popup:nav_enable(true, "clothing_store_remove_clothing_confirm", "store_clothing_popup_nav")
Not_popup_grp:set_alpha(.5)
Store_logo_grp:set_alpha(.5)
Active_list:set_visible(false)
store_clothing_enable_mouse(false)
end
function clothing_store_remove_clothing_confirm(event)
Store_common_popup:nav_enable(false, nil, nil)
Not_popup_grp:set_alpha(1)
Store_logo_grp:set_alpha(1)
Active_list:set_visible(true)
store_clothing_enable_mouse(true)
-- 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")
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
pcu_remove_clothing()
end
function store_clothing_outfit_enter(menu_data)
-- enable switching modes here
store_clothing_set_hints(Store_clothing_loaded_from_crib == false)
end
function store_clothing_play_exit_anim()
--[[if Store_clothing_loaded_from_crib == false then
local anim_out = Vdo_anim_object:new("lets_pretend_bg_anim_out", 0, Store_clothing_doc_handle)
local end_event_twn = Vdo_tween_object:new("anim_out_end_event", anim_out.handle)
end_event_twn:set_end_event("store_unload_doc")
anim_out:play(0)
store_common_play_anim_out()
else
store_unload_doc()
end]]--
local anim_out
local end_event_twn
if Store_index == CRIB then
store_unload_doc()
elseif Store_index == LETS_PRETEND then
--Find exit anim
--Find end event twn
--set end event to "store_unload_doc"
--Play anim
anim_out = Vdo_anim_object:new("lets_pretend_bg_anim_out", 0, Store_clothing_doc_handle)
end_event_twn = Vdo_tween_object:new("anim_out_end_event", anim_out.handle)
end_event_twn:set_end_event("store_unload_doc")
anim_out:play(0)
store_common_play_anim_out()
elseif Store_index == NOBODY_LOVES_ME then
anim_out = Vdo_anim_object:new("nobody_bg_anim_out", 0, Store_clothing_doc_handle)
end_event_twn = Vdo_tween_object:new("end_event_twn", anim_out.handle)
end_event_twn:set_end_event("store_unload_doc")
anim_out:play(0)
store_common_play_anim_out()
elseif Store_index == LEATHER_AND_LACE then
--must stop other bg anim from playing before fade out
anim_out = Vdo_anim_object:new("lace_bg_anim_out", 0, Store_clothing_doc_handle)
end_event_twn = Vdo_tween_object:new("end_event_twn", anim_out.handle)
end_event_twn:set_end_event("store_unload_doc")
anim_out:play(0)
store_common_play_anim_out()
elseif Store_index == PLANET_SAINTS then
anim_out = Vdo_anim_object:new("planet_bg_anim_out", 0, Store_clothing_doc_handle)
end_event_twn = Vdo_tween_object:new("end_event_twn", anim_out.handle)
end_event_twn:set_end_event("store_unload_doc")
anim_out:play(0)
store_common_play_anim_out()
elseif Store_index == IMPRESSIONS then
anim_out = Vdo_anim_object:new("impressions_bg_anim_out", 0, Store_clothing_doc_handle)
end_event_twn = Vdo_tween_object:new("end_event_twn", anim_out.handle)
end_event_twn:set_end_event("store_unload_doc")
anim_out:play(0)
store_common_play_anim_out()
else
store_unload_doc()
end
end
function store_unload_doc()
vint_document_unload()
end
function store_clothing_bg_anim_done()
store_common_bg_anim_complete()
end
-- =====================================
-- Mouse Specific Functions
-- =====================================
function store_clothing_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 ~= -1 then
Hint_bar_mouse_input_tracker:subscribe(enable)
end
end
end
function store_clothing_mouse_click(event, target_handle)
local hint_index = Store_common_hint_bar:get_hint_index(target_handle)
if hint_index ~= 0 then
if Current_tier == MENU_TIER then
store_common_button_b()
elseif Current_tier == COLOR_TIER then
store_clothing_color_selected("back")
end
end
end
function store_clothing_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)
elseif Menu_data.default_on_nav ~= nil then
Menu_data.default_on_nav(data_item)
end
return
end
end
function store_clothing_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_clothing_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_clothing_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