./store_clothing.lua

  1.  
  2. STORE_CLOTHING_INVALID_INDEX 	= -1 
  3. SCALE_FONT_STORE_CLOTHING_LIST = 0.8 
  4.  
  5. STORE_CLOTHING_CATEGORY_MAX = 150 
  6. STORE_CLOTHING_TOTAL_MAX	 = 2048 
  7.  
  8. BRAND_NONE		= -1 
  9. BRAND_ASTRO		= 0 
  10. BRAND_CROOKS	= 1 
  11. BRAND_HEYDEY	= 2 
  12. BRAND_JOYSTICK	= 3 
  13. BRAND_RIPPLE	= 4 
  14. BRAND_SOTA		= 5 
  15.  
  16. Store_clothing_doc_handle = -1 
  17.  
  18. local CRIB 				= 0 
  19. local LETS_PRETEND 		= 1 
  20. local NOBODY_LOVES_ME 	= 2 
  21. local LEATHER_AND_LACE  = 3 
  22. local PLANET_SAINTS		= 4 
  23. local IMPRESSIONS		= 5 
  24.  
  25. local Store_clothing_data = {								  
  26. 	[CRIB] 					= { pegs = { }, 										color = COLOR_STORE_REWARDS_PRIMARY,			logo_grp = "store_title_grp"}, 
  27. 	[LETS_PRETEND] 		= { pegs = { "ui_bms_store_lets_pretend" },	color = COLOR_STORE_LETS_PRETEND_PRIMARY, 	logo_grp = "store_logo_grp"}, 
  28. 	[NOBODY_LOVES_ME] 	= { pegs = { "ui_bms_store_nobody" }, 			color = COLOR_STORE_NOBODY_PRIMARY, 			logo_grp = "nobody_logo_grp"}, 
  29. 	[LEATHER_AND_LACE] 	= { pegs = { "ui_bms_store_lace" }, 			color = COLOR_STORE_LACE_PRIMARY,				logo_grp = "lace_logo_grp"}, 
  30. 	[PLANET_SAINTS] 		= { pegs = { "ui_bms_store_planet" }, 			color = COLOR_STORE_PLANET_PRIMARY, 			logo_grp = "planet_logo_grp"}, 
  31. 	[IMPRESSIONS] 			= { pegs = { "ui_bms_store_impressions" }, 	color = COLOR_STORE_IMPRESSIONS_PRIMARY, 		logo_grp = "impressions_logo_grp"}, 
  32. } 
  33.  
  34. local Store_clothing_brand_data = { 
  35. 	[BRAND_ASTRO]			= { logo = "ui_store_brand_astro"}, 
  36. 	[BRAND_CROOKS]			= { logo = "ui_store_brand_crooks"}, 
  37. 	[BRAND_HEYDEY]			= { logo = "ui_store_brand_heyday"}, --the targa is spelled heyday 
  38. 	[BRAND_JOYSTICK]		= { logo = "ui_store_brand_joystick"}, 
  39. 	[BRAND_RIPPLE]			= { logo = "ui_store_brand_ripple"}, 
  40. 	[BRAND_SOTA]			= { logo = "ui_store_brand_sota"}, 
  41. } 
  42.  
  43. local Store_index = LETS_PRETEND 
  44. local Next_anim_to_play = 0 
  45.  
  46. local Online_check_thread = -1 
  47.  
  48. -- These tables hold our menu and toggle data that get populated into the vdo's. 
  49. local Toggle_data 			= {} 
  50. local Wear_opt_data 		   = {} 
  51. local Style_variant_data 	= {} 
  52. Color_grid_data 				= {} 
  53.  
  54. -- Used to determine which of three colors player is currently picking, and the index in the color grid is currently chosen. 
  55. local Color_grid_idx			= 1 
  56. local Color_slot_chosen		= 0 
  57.  
  58. -- Save off current clothing color index if player cancels change 
  59. local Color_prev_color		= 0 
  60.  
  61. -- Hint bar and store header vdo's. 
  62.  
  63. local Store_logo_grp 
  64. local Store_logo1 
  65. local Store_logo2 
  66. local Not_popup_grp 
  67. local Reward_image 
  68.  
  69. STORE_CLOTHING_PENDING_NONE				= -1 
  70. STORE_CLOTHING_PENDING_ITEM				= 1 
  71. STORE_CLOTHING_PENDING_STORE_OUTFIT		= 2 
  72. STORE_CLOTHING_PENDING_OWNED_OUTFIT		= 3 
  73.  
  74. -- Variables for background updating threads. 
  75. local Store_clothing_item_update_thread 		= -1 
  76. local Store_clothing_waiting_update_value 	= STORE_CLOTHING_PENDING_NONE 
  77. local Store_clothing_outfit_id					= -1 
  78. local Store_clothing_outfit_finalize			= false 
  79.  
  80. -- Keeps tracking of the area and category that we've currently selected 
  81. local Store_clothing_area				= -1 
  82. local Store_clothing_category 		= -1 
  83.  
  84. local Store_clothing_brands_loaded  = false 
  85.  
  86. -- This table holds a ton of information for the currently selected clothing item. 
  87. Store_clothing_item_info = { 
  88. 	colors = { [0] = { }, [1] = { }, [2] = { } } 
  89. } 
  90.  
  91. -- Determines if we're in "store" or "wardrobe" mode. 
  92. local Store_clothing_is_wardrobe = false 
  93.  
  94. local Store_clothing_loaded_from_crib = false 
  95.  
  96. -- Menu Tiers 
  97. local MENU_TIER	= 1 
  98. local COLOR_TIER	= 2 
  99. local Current_tier = MENU_TIER 
  100.  
  101. local Game_platform 
  102. Hint_bar_mouse_input_tracker = -1 
  103.  
  104. ---------------------------------------------------------------------------  
  105. -- Initialize Clothing Store 
  106. --------------------------------------------------------------------------- 
  107. function store_clothing_init() 
  108.  
  109. 	Store_clothing_doc_handle = vint_document_find("store_clothing")	 
  110.  
  111. 	-- Save boolean if we're coming from the crib 
  112. 	Store_clothing_loaded_from_crib = store_common_crib_is_loaded()		 
  113. 		 
  114. 	if Store_clothing_loaded_from_crib == false then 
  115. 		pause_map_dump() 
  116. 	end 
  117. 	 
  118. 	thread_new("store_clothing_pause_map_delay") 
  119. 	 
  120. 	-- These should either be globals, or just use vint_set_property to mark these visible false, rather than Vdo_base_object:new here 
  121. 	local lets_pretend_bg_grp = Vdo_base_object:new("lets_pretend_bg_grp", 0, Store_clothing_doc_handle) 
  122. 	local nobody_grp = Vdo_base_object:new("nobody_grp", 0, Store_clothing_doc_handle) 
  123. 	local lace_grp = Vdo_base_object:new("lace_grp", 0, Store_clothing_doc_handle) 
  124. 	local planet_grp = Vdo_base_object:new("planet_grp", 0, Store_clothing_doc_handle) 
  125. 	local impressions_grp = Vdo_base_object:new("impressions_grp", 0, Store_clothing_doc_handle) 
  126. 	local brand_logo = Vdo_base_object:new("brand_logo_img", 0, Store_clothing_doc_handle) 
  127. 		 
  128. 	lets_pretend_bg_grp:set_visible(false) 
  129. 	nobody_grp:set_visible(false) 
  130. 	lace_grp:set_visible(false) 
  131. 	planet_grp:set_visible(false) 
  132. 	impressions_grp:set_visible(false) 
  133. 	brand_logo:set_visible(false) 
  134. 	 
  135. 	--set the index so we know what peg to load 
  136. 	Store_index = store_clothing_get_store_id() 
  137. 	 
  138. 	--Override return if we're coming from the crib doc 
  139. 	if Store_clothing_loaded_from_crib then 
  140. 		Store_index = CRIB 
  141. 	end 
  142. 	 
  143. 	-- We don't need to animate in the background or load pegs or change colors if we're coming from the crib interface. 
  144. 	local pegs = Store_clothing_data[Store_index].pegs 
  145. 	local peg_count = #Store_clothing_data[Store_index].pegs 
  146. 	 
  147. 	if Store_index == CRIB then 
  148. 		store_clothing_set_store() 
  149. 	else 
  150. 		game_peg_load_with_cb("store_clothing_set_store", 1, pegs[1]) 
  151. 	end 
  152. 	 
  153. 	character_enable_mouse_drag(true)		 
  154. end 
  155.  
  156. -- 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. 
  157. -- 
  158. function store_clothing_allow_input(event) 
  159. 	local allow = pcu_is_streaming_done() or (event ~= "back" and event ~= "select") 
  160. 	return allow 
  161. end	 
  162.  
  163. function store_clothing_set_store() 
  164.  
  165. 	Game_platform = game_get_platform() 
  166. 	 
  167. 	-- If we're in the crib, we're only doing wardrobe (not store). 
  168. 	Store_clothing_is_wardrobe = Store_clothing_loaded_from_crib 
  169. 	 
  170. 	-- Set up some callbacks for the common store script 
  171. 	Store_common_populate_list_cb = store_clothing_populate_list 
  172. 	Store_common_exit_cb				= store_clothing_exit 
  173. 	Store_common_allow_input_cb	= store_clothing_allow_input 
  174.  
  175. 	-- Subscribe to the button presses we need, Input_tracker is created in store_common.lua 
  176. 	Input_tracker:subscribe(false) 
  177.  
  178. 	local hint_data = {	 
  179. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"},			 
  180. 	} 
  181. 	Store_common_hint_bar:set_hints(hint_data)  
  182. 	Store_common_hint_bar:set_visible(true) 
  183.  
  184. 	if game_is_active_input_gamepad() then 
  185. 		local hint_rotate_data = { 
  186. 			{CTRL_BUTTON_RS, "STORE_ZOOM_ROTATE"}, 
  187. 		} 
  188. 		Store_common_rotate_hint:set_hints(hint_rotate_data) 
  189. 		if Game_platform ~= "PC" then 
  190. 			Store_common_rotate_hint:set_visible(true) 
  191. 		end 
  192. 	end 
  193. 	 
  194. 	if Game_platform == "PC" then 
  195. 		Mouse_input_tracker:subscribe(false) 
  196. 		 
  197. 		Hint_bar_mouse_input_tracker = Vdo_input_tracker:new() 
  198. 		Store_common_rotate_hint:set_visible(false) 
  199. 	end 
  200. 	 
  201. 	Store_header:set_visible(true) 
  202. 	 
  203. 	Store_logo_grp = Vdo_base_object:new("store_logo_grp", 0, Store_clothing_doc_handle) 
  204. 	Store_logo1 = Vdo_base_object:new("store_logo_img_1", 0, Store_clothing_doc_handle) 
  205. 	Store_logo2 = Vdo_base_object:new("store_logo_img_2", 0, Store_clothing_doc_handle) 
  206. 	 
  207. 	-- Everything that is not in the popup so we can fade it when the popup is active 
  208. 	Not_popup_grp = Vdo_base_object:new("not_popup_grp", 0, Store_common_doc_handle) 
  209. 	 
  210. 	-- Setup purchase popup 
  211. 	Store_common_popup:set_visible(false) 
  212. 	Store_common_popup:set_size(STORE_COMMON_LIST_SIZE, (LIST_BUTTON_HEIGHT * 5) + (LIST_BUTTON_SPACE * 5)) 
  213. 	 
  214. 	-- Setup Color grid 
  215. 	Store_common_color_grid:set_visible(false) 
  216. 	Store_common_color_grid:set_ui_screen("store_clothing") 
  217.  
  218. 	-- Start up the background update thread. 
  219. 	if Store_clothing_item_update_thread == -1 then 
  220. 		Store_clothing_item_update_thread = thread_new("store_clothing_item_preview_update") 
  221. 	end	 
  222. 	 
  223. 	-- SEH 
  224. 	Active_list:set_highlight_color(Store_clothing_data[Store_index].color)	 
  225. 	 
  226. 	Store_common_current_highlight_color = Store_clothing_data[Store_index].color 
  227. 	if Store_clothing_loaded_from_crib then 
  228. 		Store_common_current_highlight_color = COLOR_STORE_REWARDS_PRIMARY 
  229. 	end 
  230. 	 
  231. 	-- Do all our main initialization based on which mode (store or wardrobe) we're in 
  232. 	store_clothing_mode_set_init()	 
  233. 	 
  234. 	-- make background so player is on top 
  235. 	bg_saints_set_background(false) 
  236.  
  237. 	local lets_pretend_bg_grp = Vdo_base_object:new("lets_pretend_bg_grp", 0, Store_clothing_doc_handle) 
  238. 	local nobody_grp = Vdo_base_object:new("nobody_grp", 0, Store_clothing_doc_handle) 
  239. 	local lace_grp = Vdo_base_object:new("lace_grp", 0, Store_clothing_doc_handle) 
  240. 	local planet_grp = Vdo_base_object:new("planet_grp", 0, Store_clothing_doc_handle) 
  241. 	local impressions_grp = Vdo_base_object:new("impressions_grp", 0, Store_clothing_doc_handle) 
  242. 	 
  243. 	-- animate in ui for clothing store (shared by all stores) 
  244. 	local store_clothing_in_anim = Vdo_anim_object:new("store_common_in_anim", 0, Store_common_doc_handle) 
  245. 	local end_event_twn = Vdo_tween_object:new("end_event_twn", store_clothing_in_anim.handle, Store_common_doc_handle) 
  246. 	end_event_twn:set_end_event("store_unlock_controls") 
  247. 	 
  248. 	-- offset if we are in the crib 
  249. 	if Store_clothing_is_wardrobe then 
  250. 		local cloth_screen_grp_twn = vint_object_find("cloth_screen_grp_twn",0,Store_common_doc_handle) 
  251. 		local twn_x,twn_y = vint_get_property(cloth_screen_grp_twn,"end_value") 
  252. 		vint_set_property(cloth_screen_grp_twn, "end_value", Store_common_screen_grp_x, twn_y) 
  253. 		local store_main_grp = Vdo_base_object:new("store_main_grp", 0, Store_common_doc_handle) 
  254. 		store_main_grp:set_anchor(0,0) 
  255. 	end 
  256. 	 
  257. 	vint_apply_start_values(store_clothing_in_anim.handle) 
  258. 	store_clothing_in_anim:play(0) 
  259. 	 
  260. 	-- Set Store Header colors 
  261. 	Store_header:set_color(Store_clothing_data[Store_index].color, COLOR_STORE_CLOTHING_SECONDARY, COLOR_STORE_CLOTHING_TERTIARY)	 
  262.  
  263. 	-- Needs to be done after the list is drawn/populated 
  264. 	--Active_list:set_highlight_color(Store_clothing_data[Store_index].color) 
  265. 	Store_common_color_grid:set_highlight_color(Store_clothing_data[Store_index].color) 
  266. 	 
  267. 	Store_common_popup:set_color(Store_clothing_data[Store_index].color, COLOR_STORE_CLOTHING_SECONDARY, COLOR_STORE_CLOTHING_TERTIARY)		 
  268. 	 
  269. 	local clothing_bg_grp = Vdo_base_object:new("screen_grp", 0, Store_clothing_doc_handle) 
  270. 	clothing_bg_grp:set_visible(true) 
  271. 	 
  272. 	if Store_index == CRIB then 
  273. 		bg_saints_set_type(BG_TYPE_CENTER,true,1280) 
  274. 		bg_saints_set_background(false) 
  275. 		 
  276. 		--hack just to get an animation for the rendering callback 
  277. 		local planet_bg_anim_in = Vdo_anim_object:new("planet_bg_anim_in", 0, Store_clothing_doc_handle) 
  278. 		local planet_bg_twn = Vdo_tween_object:new("new_tween67", planet_bg_anim_in.handle, Store_clothing_doc_handle)		 
  279. 		 
  280. 		vint_apply_start_values(planet_bg_anim_in.handle) 
  281. 		 
  282. 		planet_bg_anim_in:play(0) 
  283. 		 
  284. 		planet_bg_twn:set_end_event("store_clothing_bg_anim_done") 
  285. 		 
  286. 		--store_unlock_controls() 
  287. 		 
  288. 		-- SEH: 6/28/11: commenting out because we do need this visible for the "brand logo"- and it doesn't appear to be necessary. 
  289. 		-- Hide clothing store background since we use the saints background in crib 
  290. 		--local clothing_bg_grp = Vdo_base_object:new("screen_grp", 0, Store_clothing_doc_handle) 
  291. 		--clothing_bg_grp:set_visible(false) 
  292. 		 
  293. 	elseif  Store_index == LETS_PRETEND then 
  294. 	 
  295. 		--Set background animations to running		 
  296. 		local lets_pretend_logo_anim = Vdo_anim_object:new("lets_pretend_logo_anim", 0, Store_clothing_doc_handle) 
  297. 		local bg_animation1 = Vdo_anim_object:new("rainbow1_anim", 0, Store_clothing_doc_handle) 
  298. 		local bg_animation2 = Vdo_anim_object:new("rainbow2_anim", 0, Store_clothing_doc_handle) 
  299. 		local bg_animation3 = Vdo_anim_object:new("lets_pretend_bg_anim_in", 0, Store_clothing_doc_handle) 
  300. 		local bg_twn = Vdo_tween_object:new("rainbow_end_event_twn", bg_animation1.handle, Store_clothing_doc_handle)		 
  301. 		local bg_twn2 = Vdo_tween_object:new("rainbow_end_event_twn", bg_animation2.handle, Store_clothing_doc_handle)			 
  302. 		local bg_twn4 = Vdo_tween_object:new("desaturate_twn", bg_animation3.handle, Store_clothing_doc_handle)		 
  303. 		 
  304. 		vint_apply_start_values(lets_pretend_logo_anim.handle) 
  305. 		vint_apply_start_values(bg_animation1.handle) 
  306. 		vint_apply_start_values(bg_animation2.handle) 
  307. 		vint_apply_start_values(bg_animation3.handle)			 
  308. 		 
  309. 		lets_pretend_logo_anim:play(0) 
  310. 		 
  311. 		bg_animation1:play(0) 
  312. 		bg_animation2:play(0) 
  313. 		bg_animation3:play(0) 
  314. 		 
  315. 		ui_audio_post_event("enter_lets_pretend") 
  316. 			 
  317. 		bg_twn:set_end_event("store_loop_bg_anims") 
  318. 		bg_twn2:set_end_event("store_loop_bg_anims") 
  319. 		bg_twn4:set_end_event("store_clothing_bg_anim_done") 
  320. 		 
  321. 		lets_pretend_bg_grp:set_visible(true) 
  322. 		 
  323. 	elseif Store_index == NOBODY_LOVES_ME then 
  324. 	 
  325. 		local nobody_logo_anim = Vdo_anim_object:new("nobody_logo_anim", 0, Store_clothing_doc_handle) 
  326. 		local nobody_bg_anim_in = Vdo_anim_object:new("nobody_bg_anim_in", 0, Store_clothing_doc_handle)		 
  327. 		 
  328. 		--tell next anim to play 
  329. 		local end_event_twn = Vdo_tween_object:new("end_event_twn", nobody_bg_anim_in.handle) 
  330. 		end_event_twn:set_end_event("store_clothing_loop_nobody_bg") 
  331. 		 
  332. 		local twn = Vdo_tween_object:new("new_tween68", nobody_bg_anim_in.handle, Store_clothing_doc_handle) 
  333. 					 
  334. 		vint_apply_start_values(nobody_logo_anim.handle) 
  335. 		vint_apply_start_values(nobody_bg_anim_in.handle) 
  336. 		 
  337. 		nobody_bg_anim_in:play(0) 
  338. 		nobody_logo_anim:play(0) 
  339. 		 
  340. 		ui_audio_post_event("enter_nobody_loves_me") 
  341. 		 
  342. 		twn:set_end_event("store_clothing_bg_anim_done") 
  343. 		 
  344. 		nobody_grp:set_visible(true)	 
  345. 		 
  346. 	elseif Store_index == LEATHER_AND_LACE then 
  347. 		 
  348. 		local lace_logo_anim = Vdo_anim_object:new("lace_logo_anim", 0, Store_clothing_doc_handle) 
  349. 		local lace_bg_anim = Vdo_anim_object:new("lace_bg_anim", 0, Store_clothing_doc_handle) 
  350. 		local lace_bg_anim_in = Vdo_anim_object:new("lace_bg_anim_in", 0, Store_clothing_doc_handle) 
  351. 		local lace_bg_twn = Vdo_tween_object:new("new_tween21", lace_bg_anim_in.handle, Store_clothing_doc_handle)		 
  352. 		 
  353. 		vint_apply_start_values(lace_bg_anim_in.handle) 
  354. 		vint_apply_start_values(lace_logo_anim.handle) 
  355. 		 
  356. 		 
  357. 		lace_bg_anim_in:play(0) 
  358. 		lace_logo_anim:play(0) 
  359. 		lace_bg_anim:play(0) 
  360. 		 
  361. 		ui_audio_post_event("enter_leatherlace") 
  362. 		 
  363. 		lace_bg_twn:set_end_event("store_clothing_bg_anim_done") 
  364. 		 
  365. 		lace_grp:set_visible(true) 
  366. 		 
  367. 	elseif Store_index == PLANET_SAINTS then 
  368. 		 
  369. 		local planet_logo_anim = Vdo_anim_object:new("planet_logo_anim", 0, Store_clothing_doc_handle) 
  370. 		local planet_bg_anim = Vdo_anim_object:new("planet_bg_anim", 0, Store_clothing_doc_handle) 
  371. 		local planet_bg_anim_in = Vdo_anim_object:new("planet_bg_anim_in", 0, Store_clothing_doc_handle) 
  372. 		local planet_bg_twn = Vdo_tween_object:new("new_tween67", planet_bg_anim_in.handle, Store_clothing_doc_handle)		 
  373. 		 
  374. 		--tween loops in vinny 
  375. 		vint_apply_start_values(planet_logo_anim.handle) 
  376. 		vint_apply_start_values(planet_bg_anim.handle) 
  377. 		vint_apply_start_values(planet_bg_anim_in.handle) 
  378. 		 
  379. 		planet_bg_anim_in:play(0) 
  380. 		planet_logo_anim:play(0) 
  381. 		planet_bg_anim:play(0) 
  382. 		 
  383. 		ui_audio_post_event("enter_planet_saints") 
  384. 		 
  385. 		planet_bg_twn:set_end_event("store_clothing_bg_anim_done") 
  386. 		 
  387. 		planet_grp:set_visible(true) 
  388. 		 
  389. 	elseif Store_index == IMPRESSIONS then 
  390. 		 
  391. 		local impressions_logo_anim = Vdo_anim_object:new("impressions_logo_anim", 0, Store_clothing_doc_handle) 
  392. 		local impressions_bg_anim = Vdo_anim_object:new("impressions_bg_anim", 0, Store_clothing_doc_handle) 
  393. 		local impressions_bg_anim_in = Vdo_anim_object:new("impressions_bg_anim_in", 0, Store_clothing_doc_handle) 
  394. 		 
  395. 		vint_apply_start_values(impressions_logo_anim.handle) 
  396. 		vint_apply_start_values(impressions_bg_anim_in.handle) 
  397. 		vint_apply_start_values(impressions_bg_anim.handle) 
  398. 		 
  399. 		--tween loops in vinny 
  400. 		impressions_bg_anim_in:play(0) 
  401. 		impressions_logo_anim:play(0) 
  402. 		impressions_bg_anim:play(0) 
  403. 		 
  404. 		impressions_grp:set_visible(true)	 
  405. 	end 
  406. end 
  407.  
  408. function store_clothing_pause_map_delay() 
  409. 	delay(2) 
  410. 	store_clothing_brand_load_peg() 
  411. end 
  412.  
  413. function store_clothing_brand_load_peg() 
  414. 	--Load peg for clothing store brand logos (used in ALL stores) 
  415. 	game_peg_load_with_cb("store_clothing_brand_loaded", 1, "ui_bms_store_brands") 
  416. end 
  417.  
  418. function store_clothing_brand_loaded() 
  419.  
  420. 	Store_clothing_brands_loaded = true 
  421.  
  422. end 
  423.  
  424. function store_clothing_brand_swap_logo(brand_id, show_brand) 
  425. 	 
  426. 	if Store_clothing_brands_loaded == false then 
  427. 		return 
  428. 	end 
  429. 	 
  430. 	local doc_handle = Store_clothing_doc_handle 
  431. 	 
  432. 	-- For the crib wardrobe, the logo is actually stored in the crib doc 
  433. 	if Store_index == CRIB then 
  434. 		doc_handle = Store_crib_doc_handle 
  435. 	end 
  436. 	 
  437. 	local store_logo_grp = Vdo_base_object:new(Store_clothing_data[Store_index].logo_grp, 0, doc_handle) 
  438. 	local brand_logo = Vdo_base_object:new("brand_logo_img", 0, Store_clothing_doc_handle) 
  439. 	 
  440. 	if show_brand == true then 
  441. 		--Hide store logo 
  442. 		store_logo_grp:set_visible(false) 
  443. 		 
  444. 		--Set and show brand logo 
  445. 		brand_logo:set_image(Store_clothing_brand_data[brand_id].logo) 
  446. 		brand_logo:set_visible(true) 
  447. 	else 
  448. 		--Show store logo 
  449. 		store_logo_grp:set_visible(true) 
  450. 		 
  451. 		--Hide brand logo 
  452. 		brand_logo:set_visible(false)	 
  453. 	end 
  454. end 
  455.  
  456. function store_clothing_loop_nobody_bg(tween_h) 
  457. 	--loop background anim 
  458. 	local nobody_bg_anim = Vdo_anim_object:new("nobody_bg_anim", 0, Store_clothing_doc_handle) 
  459. 	local twn_h = vint_object_find("end_event_twn", nobody_bg_anim.handle) 
  460. 	nobody_bg_anim:play(0) 
  461. 	vint_set_property(twn_h, "end_event", "vint_anim_loop_callback")	 
  462. 	 
  463. end	 
  464.  
  465. function store_unlock_controls() 
  466. 	bg_saints_set_background(true) 
  467. 	Input_tracker:subscribe(true) 
  468. 	store_clothing_enable_mouse(true) 
  469. end 
  470.  
  471. function store_loop_bg_anims(tween_handle) 
  472. 	local animation = vint_object_parent(tween_handle) 
  473. 	lua_play_anim(animation) 
  474. end 
  475.  
  476. -- Cleanup function called on document unload. 
  477. -- 
  478. function store_clothing_cleanup() 
  479. 	-- Remove anything that hasn't been purchased. 
  480. 	pcu_clear_preview_slot() 
  481.  
  482. 	-- kill update thread 
  483. 	if Store_clothing_item_update_thread ~= -1 then 
  484. 		thread_kill(Store_clothing_item_update_thread) 
  485. 		Store_clothing_item_update_thread = -1 
  486. 	end		 
  487.  
  488. 	-- Nuke all button subscriptions  
  489. 	Input_tracker:subscribe(false) 
  490. 	store_clothing_enable_mouse(false) 
  491. 	 
  492. 	local store_clothing_in_anim = Vdo_anim_object:new("store_clothing_in_anim", 0, Store_common_doc_handle) 
  493. 	local end_event_twn = Vdo_tween_object:new("end_event_twn", store_clothing_in_anim.handle, Store_common_doc_handle)	 
  494. 	end_event_twn:set_end_event(nil) 
  495.  
  496. 	-- unload all pegs 
  497. 	for key, peg_name in pairs(Store_clothing_data[Store_index].pegs) do 
  498. 		game_peg_unload(peg_name) 
  499. 	end	 
  500. 	 
  501. 	game_peg_unload("ui_bms_store_brands") 
  502. 	 
  503. 	if Store_clothing_loaded_from_crib == false then 
  504. 		pause_map_restore() 
  505. 	end 
  506. 	 
  507. 	character_enable_mouse_drag(false) 
  508. 	 
  509. 	-- Some things need to be cleaned up right away when a store doc is unloading, particular disabled inputs which have 
  510. 	-- callbacks to the script that is unloading. 
  511. 	store_common_cleanup_current_store()	 
  512. 	 
  513. 	if Online_check_thread ~= -1 then 
  514. 		thread_kill(Online_check_thread) 
  515. 	end	 
  516. end 
  517.  
  518. function store_clothing_exit() 
  519.  
  520. 	-- no confirmation needed if we're just going back to the crib menu 
  521. 	if Store_clothing_loaded_from_crib then 
  522. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  523. 		-- lock input during animation 
  524. 		Input_tracker:subscribe(false)	 
  525. 		store_clothing_enable_mouse(false) 
  526. 		-- make background so player is covered up 
  527. 		bg_saints_set_background(false) 
  528. 		local back_out_anim = Vdo_anim_object:new("store_crib_out_anim", 0, Store_common_doc_handle) 
  529. 		local back_out_end_twn = Vdo_tween_object:new("common_anchor_out_twn", back_out_anim.handle) 
  530. 		back_out_end_twn:set_end_event("store_clothing_crib_exit") 
  531. 		back_out_anim:play(0) 
  532. 	else 
  533. 		-- if we're in the wardrobe from a store, just go back to the store 
  534. 		if Store_clothing_is_wardrobe then 
  535. 			store_clothing_switch_mode() 
  536. 			return 
  537. 		end 
  538. 	 
  539. 		Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)	 
  540. 		Store_common_popup:set_title("MENU_TITLE_WARNING") 
  541. 		Store_common_popup:set_text("STORE_EXIT_WARNING_BODY") 
  542. 		 
  543. 		Store_common_popup:nav_enable(true, "store_clothing_exit_final", "store_clothing_popup_nav") 
  544. 		Not_popup_grp:set_alpha(.5) 
  545. 		Store_logo_grp:set_alpha(.5) 
  546. 		Active_list:set_visible(false) 
  547. 		store_clothing_enable_mouse(false) 
  548. 	end 
  549. end 
  550.  
  551. function store_clothing_crib_exit(tween_h, event) 
  552. 	-- called when we slide out to the crib 
  553. 	pop_screen() 
  554. end 
  555.  
  556. function store_clothing_exit_final(event) 
  557. 	Store_common_popup:nav_enable(false, nil, nil) 
  558. 		 
  559. 	-- The user hit the B button and is exiting 
  560. 	-- This is redundant to selecting "No" in the list 
  561. 	if event == "back" then 
  562. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  563. 		Not_popup_grp:set_alpha(1) 
  564. 		Store_logo_grp:set_alpha(1) 
  565. 		Active_list:set_visible(true) 
  566. 		store_clothing_enable_mouse(true) 
  567. 		return 
  568. 	end 
  569. 	 
  570. 	game_UI_audio_play("UI_Main_Menu_Select") 
  571. 	 
  572. 	-- Did we select yes?  This assumes yes is the first item 
  573. 	if Store_common_popup:get_selected_data() ~= 1 then 
  574. 		Not_popup_grp:set_alpha(1) 
  575. 		Store_logo_grp:set_alpha(1) 
  576. 		Active_list:set_visible(true) 
  577. 		store_clothing_enable_mouse(true) 
  578. 		return 
  579. 	end 
  580. 	 
  581. 	ui_audio_post_event("UI_Store_Exit") 
  582. 	 
  583. 	Input_tracker:subscribe(false) 
  584. 	store_clothing_enable_mouse(false) 
  585. 		 
  586. 	Not_popup_grp:set_alpha(0) 
  587. 	Store_logo_grp:set_alpha(0) 
  588. 	-- exit the interface 
  589. 	pop_screen() 
  590. end 
  591.  
  592. -- Called when this interface becomes the top one on the stack again. 
  593. -- 
  594. function store_clothing_gained_focus() 
  595.  
  596. 	Input_tracker:subscribe(true)	 
  597. 	store_clothing_enable_mouse(true) 
  598. 	if Game_platform ~= "PC" then 
  599. 		Store_common_rotate_hint:set_visible(true) 
  600. 	end 
  601. 	 
  602. 	Store_common_hint_bar:set_visible(true) 
  603. 	character_enable_mouse_drag(true) 
  604. 	 
  605. 	-- Reinitialize state 
  606. 	store_clothing_mode_set_init() 
  607. 	 
  608. 	-- Set up some callbacks for the common store script 
  609. 	Store_common_populate_list_cb = store_clothing_populate_list 
  610. 	Store_common_exit_cb				= store_clothing_exit	 
  611. end 
  612.  
  613. -- Populate the active megalist menu, and hide the previous menu 
  614. -- 
  615. -- list_data: 		this table contains the data to populate the megalist 
  616. -- current_index: 	the current index in the menu that's selected 
  617. -- 
  618. function store_clothing_populate_list(list_data, current_index) 
  619.  
  620. 	Active_list:draw_items(list_data, current_index, STORE_COMMON_LIST_SIZE, 12, SCALE_FONT_STORE_CLOTHING_LIST) 
  621. 	Active_list:set_visible(true) 
  622. 	 
  623. 	if Game_platform == "PC" then 
  624. 		Mouse_input_tracker:remove_all() 
  625. 		Active_list:set_store("store_clothing") 
  626. 		Active_list:add_mouse_inputs("store_common", Mouse_input_tracker) 
  627. 		Mouse_input_tracker:subscribe(true) 
  628. 	end 
  629. end 
  630.  
  631. -- Callback from C code that adds areas to Menu_data table. 
  632. -- 
  633. -- area_index: 	unique ID for the area. 
  634. -- label_crc: 	crc for the name to display.  nil if string is used instead. 
  635. -- label_str: 	string for the name to display.  nil if crc is used instead. 
  636. -- has_new_items: does this category have items that haven't been viewed in the wardrobe? 
  637. -- 
  638. function store_clothing_area_add(area_index, label_crc, label_str, has_new_items) 
  639. 	local menu_idx = #Menu_data + 1 
  640.  
  641. 	local new_item = { 
  642. 		type = TYPE_BUTTON, 
  643. 		id = area_index, 
  644. 		label = nil, 
  645. 		label_crc = nil, 
  646. 		on_nav = store_clothing_area_nav, 
  647. 		on_sub_menu_fill = store_clothing_category_get_all, 
  648. 		is_new = has_new_items, 
  649. 	}		 
  650.  
  651. 	Menu_data[menu_idx] = new_item 
  652. 	 
  653. 	-- Set the name of the menu choice, may be from crc or string itself 
  654. 	if label_crc ~= nil and label_crc ~= 0 then 
  655. 		new_item.label_crc = label_crc 
  656. 	else 
  657. 		new_item.label = label_str 
  658. 	end 
  659. 	 
  660. end 
  661.  
  662. function store_clothing_category_get_all(menu_data) 
  663. 	Store_common_sub_menu = {} 
  664. 	pcu_get_categories_in_area(Store_clothing_area, "store_clothing_category_add") 
  665. 	Store_clothing_category = Store_common_sub_menu[1].id 
  666. 	pcu_set_active_category(Store_clothing_category, Store_clothing_area)	 
  667. 	 
  668. 	-- If there is only one category in this area, just go on into the category menu! 
  669. 	if #Store_common_sub_menu == 1 then 
  670. 		local new_menu_data = {} 
  671. 		new_menu_data.id = Store_clothing_category 
  672. 		Store_common_sub_menu = {} 
  673. 		store_clothing_item_get_list(new_menu_data) 
  674. 	else 
  675. 		Store_common_sub_menu.on_enter = store_clothing_category_menu_update 
  676. 	end 
  677. end 
  678.  
  679. -- Refresh the clothing category menu when we return to it, since the "new" highlights may have been updated by browsing 
  680. -- 
  681. function store_clothing_category_menu_update(menu_data) 
  682. 	local index = Active_list:get_selection() 
  683. 	Menu_data = {} 
  684. 	Store_common_sub_menu = {} 
  685. 	pcu_set_active_category(Store_clothing_category, Store_clothing_area) 
  686. 	pcu_get_categories_in_area(Store_clothing_area, "store_clothing_category_add") 
  687. 	Menu_data = Store_common_sub_menu 
  688. 	Store_common_sub_menu = {} 
  689. 	Menu_data.on_enter = store_clothing_category_menu_update 
  690. 	store_clothing_populate_list(Menu_data, index) 
  691.  
  692. end 
  693.  
  694. -- Callback from C code that adds categories to Menu_data table. 
  695. -- 
  696. -- area_index: 	unique ID for the category. 
  697. -- label_crc: 	crc for the name to display.  nil if string is used instead. 
  698. -- label_str: 	string for the name to display.  nil if crc is used instead. 
  699. -- has_new_items: this category contains items that haven't been viewed in the UI before. 
  700. -- 
  701. function store_clothing_category_add(cat_index, label_crc, label_str, has_new_items) 
  702. 	local menu_idx = #Store_common_sub_menu + 1 
  703.  
  704. 	local new_item = { 
  705. 		type = TYPE_BUTTON, 
  706. 		id = cat_index, 
  707. 		label = nil, 
  708. 		label_crc = nil, 
  709. 		on_nav = store_clothing_category_nav, 
  710. 		on_sub_menu_fill = store_clothing_item_get_list, 
  711. 		is_new = has_new_items, 
  712. 	}		 
  713.  
  714. 	Store_common_sub_menu[menu_idx] = new_item 
  715. 	 
  716. 	-- Set the name of the menu choice, may be from crc or string itself 
  717. 	if label_crc ~= nil and label_crc ~= 0 then 
  718. 		new_item.label_crc = label_crc 
  719. 	else 
  720. 		new_item.label = label_str 
  721. 	end 
  722. 	 
  723. end 
  724.  
  725. function store_clothing_item_get_list(menu_data) 
  726.  
  727. 	-- disable switching modes here 
  728. 	store_clothing_set_hints(false) 
  729.  
  730. 	-- force a garbage collection 
  731. 	vint_force_lua_gc() 
  732. 	 
  733. 	Store_common_sub_menu = { 
  734. 		default_on_nav = store_clothing_item_nav, 
  735. 		default_on_sub_menu_fill = store_clothing_item_details, 
  736. 		default_on_back = store_clothing_item_revert 
  737. 	} 
  738. 	 
  739. 	pcu_get_items_in_category(menu_data.id, "store_clothing_item_add") 
  740. 	 
  741. 	if #Store_common_sub_menu == 0 then 
  742. 		-- Don't think this should ever happen, if stores are set up correctly, but just in case. 
  743. 		Store_common_sub_menu[1] = { 
  744. 			type = TYPE_BUTTON, 
  745. 			id = -1, 
  746. 			label = "HAIR_CAT_NONE", 
  747. 			label_crc = nil, 
  748. 			is_owned = true, 
  749. 			price = 0, 
  750. 			style = 0, 
  751. 			is_outfit = false, 
  752. 			on_select = store_clothing_item_remove, 
  753. 		}		 
  754. 	end 
  755. 	 
  756. 	local index = Store_common_sub_menu.start_index or 1 
  757. 	store_clothing_item_nav(Store_common_sub_menu[index]) 
  758. end 
  759.  
  760. function store_clothing_outfit_none(menu_data) 
  761. 	store_clothing_item_revert(menu_data) 
  762. 	store_common_button_b() 
  763. end 
  764.  
  765. -- The player chose "none" for the item to wear.  Set player to wear nothing and go back up a menu. 
  766. -- 
  767. function store_clothing_item_remove(menu_data) 
  768. 	store_clothing_header_revert() 
  769. 	pcu_wear_current_clothing() 
  770. 	 
  771. 	-- back out of menu 
  772. 	store_common_back_menu() 
  773. end 
  774.  
  775. -- Callback from C code that adds clothing items to Menu_data table. 
  776. -- 
  777. -- item_id: 	unique id for the clothing item. 
  778. -- label_crc: 	crc for the name to display.  nil if string is used instead. 
  779. -- label_str: 	string for the name to display.  nil if crc is used instead. 
  780. -- is_outfit: 	true if this is an outfit. 
  781. -- price: 		price of the item 
  782. -- style: 		how much style the item adds. 
  783. -- inc_wardrobe_instance: instance of the wardrobe item (to distinguish duplicate items) 
  784. -- is_available: true if the item is available for purchase. 
  785. -- variant_num: id indicating which variant this is 
  786. -- variant_lbl: string for the variant text to display.  nil if crc is used instead. 
  787. -- variant_lbl_crc: crc for the variant text to display.  nil if string is used instead. 
  788. -- is_current: true if we're in the wardrobe and this item is currently worn. 
  789. --	 
  790. 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) 
  791. 	local menu_idx = #Store_common_sub_menu + 1 
  792.  
  793. 	--debug_print("vint", "adding brand " .. brand_id .. "\n")	 
  794. 	 
  795. 	-- We only want to add a "none" choice if this isn't an outfits menu, and (obviously) we haven't added it 
  796. 	-- to the top of the list yet. 
  797. 	if menu_idx == 1 and is_outfit == false and disable_removal ~= true then 
  798. 	 
  799. 		-- first choice is to remove items of this type 
  800. 		Store_common_sub_menu[1] = { 
  801. 			id = -1, 
  802. 			label = "HAIR_CAT_NONE", 
  803. 			label_crc = nil, 
  804. 			is_owned = true, 
  805. 			price = 0, 
  806. 			style = 0, 
  807. 			is_outfit = false, 
  808. 			on_select = store_clothing_item_remove, 
  809. 			is_new = false, 
  810. 			is_dlc = false, 
  811. 		}	 
  812. 		menu_idx = 2 
  813. 	end 
  814. 	 
  815. 	local new_item = { 
  816. 		id = item_id, 
  817. 		label = nil, 
  818. 		label_crc = nil, 
  819. 		--is_owned = false, 
  820. 		variant_num = variant_num, 
  821. 		is_outfit = is_outfit,	 
  822. 		wardrobe_instance = inc_wardrobe_instance, 
  823. 		disabled = is_unusable_dlc, 
  824. 		--is_reward = is_reward, 
  825. 		--is_unusable_dlc = is_unusable_dlc, 
  826. 		brand_id = brand_id, 
  827. 		is_new = is_new, 
  828. 		is_dlc = is_dlc, 
  829. 		 
  830. 		-- on_nav = store_clothing_item_nav, 
  831. 		-- on_sub_menu_fill = store_clothing_item_details, 
  832. 		-- on_back = store_clothing_item_revert,		 
  833. 	}		 
  834. 	 
  835. 	if Store_clothing_is_wardrobe == false then 
  836. 		new_item.price = price 
  837. 		new_item.style = style 
  838. 	end 
  839. 	 
  840. 	if variant_lbl_crc == nil and variant_lbl == nil then 
  841. 		--Set the name of the menu choice, may be from crc or string itself 
  842. 		if label_crc ~= nil and label_crc ~= 0 then 
  843. 			new_item.label_crc = label_crc 
  844. 		else 
  845. 			new_item.label = label_str 
  846. 		end 
  847. 	else 
  848. 		-- Set the name of the menu choice, may be from crc or string itself 
  849. 		if variant_lbl_crc ~= nil and variant_lbl_crc ~= 0 then 
  850. 			new_item.label_crc = variant_lbl_crc 
  851. 		else 
  852. 			new_item.label = variant_lbl 
  853. 		end 
  854. 	end 
  855. 	 
  856. 	-- if is_available ~= false then 
  857. 		-- if pcu_is_item_owned(item_id, nil) == true then 
  858. 			-- -- We own all of this item's styles, so you can't actually select details 
  859. 			-- new_item.is_owned = true 
  860. 		-- end 
  861. 	-- end 
  862. 	 
  863. 	Store_common_sub_menu[menu_idx] = new_item	 
  864. 	 
  865. 	if is_current == true then 
  866. 		Store_common_sub_menu.start_index = menu_idx 
  867. 	end 
  868. end 
  869.  
  870. function store_clothing_header_revert(menu_data) 
  871. 	Store_header:set_price(nil) 
  872. 	Store_header:set_respect(nil) 
  873. end 
  874.  
  875. -- Trigger background item updates when navigating among different clothing items in the menu. 
  876. -- 
  877. -- id: unique id of the selected clothing item. 
  878. -- variant_id: unique id of the variant for this item. 
  879. -- 
  880. function store_clothing_item_nav(menu_data) 
  881.  
  882. 	--debug_print("vint", "brand is " .. menu_data.brand_id .. "\n") 
  883.  
  884. 	if menu_data.is_outfit == false then 
  885. 		Store_clothing_outfit_id = -1 
  886. 	 
  887. 		local id = menu_data.id 
  888. 		local variant_id = menu_data.variant_num	 
  889. 	 
  890. 		if Store_clothing_is_wardrobe == false then 
  891. 			store_clothing_item_get_defaults(id) 
  892. 		else 
  893. 			if id == -1 then 
  894. 				Store_clothing_item_info.item_index = -1 
  895. 			else 
  896. 				store_clothing_get_owned_item_info(menu_data.id, menu_data.wardrobe_instance) 
  897. 				Store_clothing_item_info.wardrobe_instance = menu_data.wardrobe_instance --store the instance of the current item incase we need to discard 
  898. 			end 
  899. 		end		 
  900. 		 
  901. 		if variant_id then 
  902. 			Store_clothing_item_info.variant_index = variant_id 
  903. 		end		 
  904. 		 
  905. 		Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_ITEM 
  906. 		 
  907. 		local brand_id = menu_data.brand_id 
  908. 		if brand_id == nil or brand_id == BRAND_NONE then 
  909. 			-- Swap back to store logo 
  910. 			store_clothing_brand_swap_logo(brand_id, false) 
  911. 		else 
  912. 			-- Swap back to store logo 
  913. 			store_clothing_brand_swap_logo(brand_id, true) 
  914. 		end 
  915. 		 
  916. 		-- clear out "new" status if it is true 
  917. 		if menu_data.is_new then 
  918. 			pcu_clear_item_new(menu_data.id, menu_data.wardrobe_instance) 
  919. 			 
  920. 			--Remove our mouse inputs first... 
  921. 			if Mouse_input_tracker ~= 0 then 
  922. 				Mouse_input_tracker:remove_all() 
  923. 			end 
  924. 			 
  925. 			--Get index from the list and then remove the flag... 
  926. 			local index = 1 
  927. 			local data = Active_list:return_data() 
  928. 			for data_index = 1, #data do 
  929. 				if menu_data.id == data[data_index].id then 
  930. 					if menu_data.wardrobe_instance == data[data_index].wardrobe_instance then 
  931. 						--Match!! 
  932. 						index = data_index 
  933. 						break 
  934. 					end 
  935. 				end 
  936. 			end 
  937. 			 
  938. 			--Remove the new flag from our active list... 
  939. 			Active_list:remove_new_flag(index) 
  940. 			 
  941. 			--Update cursor, 
  942. 			Active_list:move_cursor(0) 
  943. 			--Re add mouse inputs... 
  944. 			if Mouse_input_tracker ~= 0 then 
  945. 				Mouse_input_tracker:remove_all() 
  946. 				Active_list:add_mouse_inputs("store_common", Mouse_input_tracker) 
  947. 				Mouse_input_tracker:subscribe(true) 
  948. 			end	 
  949. 		end 
  950. 	else 
  951. 		Store_clothing_item_info.item_price = menu_data.price 
  952. 		Store_clothing_item_info.item_style = menu_data.style 
  953. 		Store_clothing_outfit_id = menu_data.id 
  954. 		Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_STORE_OUTFIT 
  955. 	end 
  956. 	 
  957. 	if Store_clothing_is_wardrobe == false then 
  958. 		-- Update the store header price and respect values 
  959. 		Store_header:set_price(Store_clothing_item_info.item_price) 
  960. 		Store_header:set_respect(Store_clothing_item_info.item_style)	 
  961. 	end 
  962. end 
  963.  
  964. -- Player hit back on clothing item instead of buying it; revert preview. 
  965. -- 
  966. function store_clothing_item_revert(menu_data) 
  967.  
  968. 	-- This will cancel the delayed preview of an item 
  969. 	Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_NONE 
  970. 	 
  971. 	store_clothing_header_revert() 
  972. 	 
  973. 	if menu_data.is_outfit then 
  974. 		pcu_set_active_category(Store_clothing_category, Store_clothing_area) 
  975. 	else 
  976. 		pcu_clear_preview_slot() 
  977. 	end 
  978. 	 
  979. 	-- We want to re-enable mode switching at this point 
  980. 	store_clothing_set_hints(Store_clothing_loaded_from_crib == false) 
  981. 	 
  982. 	-- Swap logo back 
  983. 	store_clothing_brand_swap_logo(nil, false) 
  984. end 
  985.  
  986. function store_clothing_area_nav(menu_data) 
  987. 	local id = Active_list:get_id() 
  988. 	Store_clothing_area = id	 
  989. end 
  990.  
  991. function store_clothing_category_nav(menu_data) 
  992. 	local id = Active_list:get_id() 
  993. 	pcu_clear_preview_slot() 
  994. 	Store_clothing_category = id 
  995. 	pcu_set_active_category(Store_clothing_category, Store_clothing_area)	 
  996. end 
  997.  
  998. function store_clothing_wear_option_nav(menu_data) 
  999. 	Store_clothing_item_info.wear_option_index = Wear_opt_data[Active_list:get_toggle_selection()] 
  1000. 	store_clothing_item_preview(true)	 
  1001. end 
  1002.  
  1003. function store_clothing_style_nav(menu_data) 
  1004. 	Store_clothing_item_info.variant_index = Style_variant_data[Active_list:get_toggle_selection()] 
  1005. 	store_clothing_item_preview(true) 
  1006. end 
  1007.  
  1008. -- Calls into C code to get the default setttings for a given item. 
  1009. -- 
  1010. -- item_index: unique ID into for the item to get info on. 
  1011. -- 
  1012. function store_clothing_item_get_defaults(item_index) 
  1013. 	local t = Store_clothing_item_info 
  1014. 	 
  1015. 	if item_index >= 0 then 
  1016. 		t.slot_index, t.item_index, t.item_name_crc, t.item_name_str, 
  1017. 		t.num_variants, t.variant_index, t.variant_name_crc, t.variant_name_str, 
  1018. 		t.colors.num_colors, 
  1019. 		t.colors[0].index, t.colors[0].red, t.colors[0].green, t.colors[0].blue, 
  1020. 		t.colors[1].index, t.colors[1].red, t.colors[1].green, t.colors[1].blue, 
  1021. 		t.colors[2].index, t.colors[2].red, t.colors[2].green, t.colors[2].blue, 
  1022. 		t.num_wear_options, t.wear_option_index, t.wear_option_name_crc, t.wear_option_name_str, 
  1023. 		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, 
  1024. 		t.item_style, t.item_price, 
  1025. 		t.player_style_level, t.player_style_percent 
  1026. 		= pcu_get_item_defaults(item_index) 
  1027. 	else 
  1028. 		t.item_index = -1 
  1029. 		t.item_price = nil 
  1030. 		t.item_style = nil 
  1031. 	end 
  1032. end 
  1033.  
  1034. function store_clothing_get_owned_item_info(item_index, wardrobe_instance)  -- like get item defaults, but called when browsing the inventory 
  1035. 	local t = Store_clothing_item_info 
  1036. 	if wardrobe_instance == nil then 
  1037. 		wardrobe_instance = -1  --this should never occur, but incase it does, this will make it assert instead of crash 
  1038. 	end 
  1039. 	if item_index >= 0 then 
  1040. 		t.slot_index, t.item_index, t.item_name_crc, t.item_name_str, 
  1041. 		t.num_variants, t.variant_index, t.variant_name_crc, t.variant_name_str, 
  1042. 		t.colors.num_colors, 
  1043. 		t.colors[0].index, t.colors[0].red, t.colors[0].green, t.colors[0].blue, 
  1044. 		t.colors[1].index, t.colors[1].red, t.colors[1].green, t.colors[1].blue, 
  1045. 		t.colors[2].index, t.colors[2].red, t.colors[2].green, t.colors[2].blue, 
  1046. 		t.num_wear_options, t.wear_option_index, t.wear_option_name_crc, t.wear_option_name_str, 
  1047. 		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 
  1048. 		= pcu_get_owned_item_info(item_index, wardrobe_instance) 
  1049. 	else 
  1050. 		t.item_index = -1 
  1051. 		t.item_price = nil 
  1052. 		t.item_style = nil		 
  1053. 	end 
  1054. end 
  1055.  
  1056. -- Calls into C code to get the settingsf for the given slot. 
  1057. -- 
  1058. -- slot: ID for the slot to get the info on. 
  1059. -- 
  1060. function store_clothing_item_get_slot_info(slot) 
  1061. 	local t = Store_clothing_item_info 
  1062. 	local temp_logo_storage_color_index = t.logo_color_index 
  1063. 	local temp_logo_storage_color_red = t.logo_color_red 
  1064. 	local temp_logo_storage_color_green = t.logo_color_green 
  1065. 	local temp_logo_storage_color_blue = t.logo_color_blue 
  1066. 	 
  1067. 	t.slot_index, t.item_index, t.item_name_crc, t.item_name_str, 
  1068. 	t.num_variants, t.variant_index, t.variant_name_crc, t.variant_name_str, 
  1069. 	t.colors.num_colors, 
  1070. 	t.colors[0].index, t.colors[0].red, t.colors[0].green, t.colors[0].blue, 
  1071. 	t.colors[1].index, t.colors[1].red, t.colors[1].green, t.colors[1].blue, 
  1072. 	t.colors[2].index, t.colors[2].red, t.colors[2].green, t.colors[2].blue, 
  1073. 	t.num_wear_options, t.wear_option_index, t.wear_option_name_crc, t.wear_option_name_str, 
  1074. 	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, 
  1075. 	t.item_style, t.item_price, 
  1076. 	t.player_style_level, t.player_style_percent 
  1077. 	= pcu_get_slot_info(slot) 
  1078. 	 
  1079. 	--do this to prevent logo color from being wiped when previewing the "no logo" logo 
  1080. 	if t.logo_index == STORE_CLOTHING_INVALID_INDEX then 
  1081. 		t.logo_color_index = temp_logo_storage_color_index 
  1082. 		t.logo_color_red = temp_logo_storage_color_red 
  1083. 		t.logo_color_green = temp_logo_storage_color_green  
  1084. 		t.logo_color_blue = temp_logo_storage_color_blue 
  1085. 	end 
  1086. end 
  1087.  
  1088. -- Build the menu for the detailed actions possible for the selected item. 
  1089. -- 
  1090. function store_clothing_item_details(menu_data) 
  1091.  
  1092. 	Store_common_sub_menu = {} 
  1093. 	 
  1094. 	local new_menu = Store_common_sub_menu 
  1095. 	local menu_idx = 0 
  1096. 	 
  1097. 	if Store_clothing_outfit_id == -1 then 
  1098. 	 
  1099. 		-- get info on the item 
  1100. 		store_clothing_item_preview(true) 
  1101. 		 
  1102. 		local item = Store_clothing_item_info 
  1103. 		 
  1104. 		-- color selections 
  1105. 		if Store_clothing_is_wardrobe == false and item.colors.num_colors ~= nil and item.colors.num_colors > 0 then 
  1106. 			local c = item.colors 
  1107. 			 
  1108. 			for i = 0, c.num_colors - 1 do 
  1109. 				local color_label 
  1110. 				if i == 0 then 
  1111. 					color_label = "STORE_PRIMARY_COLOR" 
  1112. 				elseif i == 1 then 
  1113. 					color_label = "STORE_SECONDARY_COLOR" 
  1114. 				elseif i == 2 then 
  1115. 					color_label = "STORE_TERTIARY_COLOR" 
  1116. 				else 
  1117. 					color_label = "STORE_DETAIL_COLOR" 
  1118. 				end 
  1119. 				 
  1120. 				menu_idx = menu_idx + 1 
  1121. 				local new_item = { 
  1122. 					type = TYPE_TOGGLE_COLOR, 
  1123. 					id = i, 
  1124. 					label = color_label, 
  1125. 					label_crc = nil, 
  1126. 					color = c[i], 
  1127. 					on_select = store_clothing_color_select, 
  1128. 				}	 
  1129. 				new_menu[menu_idx] = new_item		 
  1130. 			end 
  1131. 		end 
  1132.  
  1133. 		-- style (variant) selections 
  1134. 		if Store_clothing_is_wardrobe == false and item.num_variants > 1 then 
  1135. 			-- get our variants to populate the toggle 
  1136. 			Toggle_data = {} 
  1137. 			Style_variant_data = {} 
  1138. 			pcu_get_variants(item.slot_index, "store_clothing_style_add") 
  1139. 		 
  1140. 			menu_idx = menu_idx + 1 
  1141. 			local new_item = { 
  1142. 				type = TYPE_TOGGLE, 
  1143. 				label = "MENU_STYLE", 
  1144. 				options = Toggle_data, 
  1145. 				current_value = 1, 
  1146. 				on_nav = store_clothing_style_nav,		 
  1147. 			}	 
  1148. 			new_menu[menu_idx] = new_item	 
  1149. 		end	 
  1150. 		 
  1151. 		-- wear option selections 
  1152. 		if item.num_wear_options > 1 then 
  1153. 			-- get our wear options to populate the toggle 
  1154. 			Toggle_data = {} 
  1155. 			Wear_opt_data = {} 
  1156. 			pcu_get_wear_options(item.slot_index, "store_clothing_wear_option_add") 
  1157. 		 
  1158. 			menu_idx = menu_idx + 1 
  1159. 			local new_item = { 
  1160. 				type = TYPE_TOGGLE, 
  1161. 				label = "CUST_MENU_WEAR_OPTION", 
  1162. 				options = Toggle_data, 
  1163. 				current_value = 1, 
  1164. 				on_nav = store_clothing_wear_option_nav, 
  1165. 			}	 
  1166. 			new_menu[menu_idx] = new_item	 
  1167. 		end 
  1168. 	end 
  1169. 	 
  1170. 	-- add the purchase item choice 
  1171. 	menu_idx = menu_idx + 1 
  1172.  
  1173. 	if Store_clothing_is_wardrobe == false then 
  1174. 		local new_item	= { 
  1175. 			type = TYPE_BUTTON, 
  1176. 			label = "STORE_PURCHASE_ITEM", 
  1177. 			label_crc = nil,	 
  1178. 			on_select = store_clothing_item_purchase 
  1179. 		} 
  1180. 		 
  1181. 		new_menu[menu_idx] = new_item			 
  1182. 	else 
  1183. 		local new_item	= { 
  1184. 			type = TYPE_BUTTON, 
  1185. 			label = "CUST_ITEM_WEAR", 
  1186. 			label_crc = nil,	 
  1187. 			on_select = store_clothing_item_wear 
  1188. 		}		 
  1189. 		 
  1190. 		new_menu[menu_idx] = new_item	 
  1191. 		menu_idx = menu_idx + 1 
  1192. 		 
  1193. 		new_item	= { 
  1194. 			type = TYPE_BUTTON, 
  1195. 			label = "STORE_DISCARD_ITEM", 
  1196. 			label_crc = nil,	 
  1197. 			on_select = store_clothing_item_discard 
  1198. 		}		 
  1199. 		 
  1200. 		new_menu[menu_idx] = new_item				 
  1201. 	end 
  1202. end 
  1203.  
  1204. -- When in the wardrobe, the player can select to wear an item.  This updates the slots and leaves menu. 
  1205. -- 
  1206. function store_clothing_item_wear() 
  1207. 	if pcu_is_streaming_done() and Store_clothing_waiting_update_value == STORE_CLOTHING_PENDING_NONE then 
  1208. 		pcu_wear_current_clothing() 
  1209. 		store_common_back_menu() 
  1210. 		store_common_back_menu()		 
  1211. 	end 
  1212. end 
  1213.  
  1214. -- When in the wardrobe, the player can select to discard an item.  This brings up a warning dialog before doing so. 
  1215. -- 
  1216. function store_clothing_item_discard() 
  1217. 	store_clothing_enable_mouse(false) 
  1218.  
  1219. 	if pcu_is_current_item_worn(Store_clothing_item_info.slot_index, Store_clothing_item_info.wardrobe_instance) then 
  1220. 		if pcu_is_underwear_category(Store_clothing_category) then 
  1221. 			Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  1222. 			Store_common_popup:set_title("STORE_UNDERWEAR_WARNING") 
  1223. 			Store_common_popup:set_text("STORE_UNDERWEAR_SUB_WARNING")		 
  1224. 			Store_common_popup:nav_enable(true, "store_clothing_fail_msg", "store_clothing_popup_nav") 
  1225. 			Not_popup_grp:set_alpha(.5) 
  1226. 			Store_logo_grp:set_alpha(.5) 
  1227. 			Active_list:set_visible(false) 
  1228. 		else  
  1229. 			if pcu_is_bra_category(Store_clothing_category) and pcu_bra_required() then 
  1230. 				Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  1231. 				Store_common_popup:set_title("STORE_BRA_WARNING") 
  1232. 				Store_common_popup:set_text("STORE_BRA_SUB_WARNING")		 
  1233. 				Store_common_popup:nav_enable(true, "store_clothing_fail_msg", "store_clothing_popup_nav") 
  1234. 				Not_popup_grp:set_alpha(.5)	 
  1235. 				Store_logo_grp:set_alpha(.5) 
  1236. 				Active_list:set_visible(false) 
  1237. 			else 
  1238. 				Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)	 
  1239. 				Store_common_popup:set_title("STORE_TITLE_DISCARD") 
  1240. 				Store_common_popup:set_text("STORE_TEXT_DISCARD")				 
  1241. 				Store_common_popup:nav_enable(true, "store_clothing_item_discard_confirm_1", "store_clothing_popup_nav") 
  1242. 				Not_popup_grp:set_alpha(.5)	 
  1243. 				Store_logo_grp:set_alpha(.5) 
  1244. 				Active_list:set_visible(false)				 
  1245. 			end 
  1246. 		end 
  1247. 	else 
  1248. 		Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)	 
  1249. 		Store_common_popup:set_title("STORE_TITLE_DISCARD") 
  1250. 		Store_common_popup:set_text("STORE_TEXT_DISCARD")				 
  1251. 		Store_common_popup:nav_enable(true, "store_clothing_item_discard_confirm_1", "store_clothing_popup_nav") 
  1252. 		Not_popup_grp:set_alpha(.5)	 
  1253. 		Store_logo_grp:set_alpha(.5) 
  1254. 		Active_list:set_visible(false) 
  1255. 	end 
  1256. end 
  1257.  
  1258. function store_clothing_item_discard_confirm_1(event) 
  1259.  
  1260. 	Store_common_popup:nav_enable(false, nil, nil) 
  1261. 	Not_popup_grp:set_alpha(1) 
  1262. 	Store_logo_grp:set_alpha(1) 
  1263. 	Active_list:set_visible(true) 
  1264. 	store_clothing_enable_mouse(true) 
  1265.  
  1266. 	-- The user hit the B button and are cancelling the discard 
  1267. 	-- This is redundant to selecting "No" in the list 
  1268. 	if event == "back" then 
  1269. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  1270. 		return 
  1271. 	end 
  1272. 	 
  1273. 	game_UI_audio_play("UI_Main_Menu_Select") 
  1274. 	 
  1275. 	-- Did we select yes?  This assumes yes is the first item 
  1276. 	if Store_common_popup:get_selected_data() ~= 1 then 
  1277. 		return 
  1278. 	end	 
  1279. 	 
  1280. 	-- do this so holding down the button doesn't cause repeated actions 
  1281. 	Input_tracker:subscribe(false)		 
  1282. 	Input_tracker:subscribe(true)		 
  1283. 	 
  1284. 	if pcu_is_item_needed_for_outfit(Store_clothing_item_info.slot_index) then 
  1285. 		Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)	 
  1286. 		Store_common_popup:set_title("STORE_TITLE_DISCARD_OUTFIT_WARNING") 
  1287. 		Store_common_popup:set_text("STORE_TEXT_DISCARD_OUTFIT_WARNING")				 
  1288. 		Store_common_popup:nav_enable(true, "store_clothing_item_discard_confirm_2", "store_clothing_popup_nav") 
  1289. 		Not_popup_grp:set_alpha(.5)	 
  1290. 		Store_logo_grp:set_alpha(.5) 
  1291. 		Active_list:set_visible(false) 
  1292. 		store_clothing_enable_mouse(false) 
  1293. 	else 
  1294. 		pcu_discard_slot(Store_clothing_item_info.slot_index, Store_clothing_item_info.wardrobe_instance) 
  1295. 		store_common_back_menu() 
  1296. 		store_common_back_menu()		 
  1297. 	end 
  1298. end 
  1299.  
  1300. function store_clothing_item_discard_confirm_2(event) 
  1301. 	Store_common_popup:nav_enable(false, nil, nil) 
  1302. 	Not_popup_grp:set_alpha(1) 
  1303. 	Store_logo_grp:set_alpha(1) 
  1304. 	Active_list:set_visible(true) 
  1305. 	 
  1306. 	store_clothing_enable_mouse(true) 
  1307.  
  1308. 	-- The user hit the B button and are cancelling the discard 
  1309. 	-- This is redundant to selecting "No" in the list 
  1310. 	if event == "back" then 
  1311. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  1312. 		return 
  1313. 	end 
  1314. 	 
  1315. 	game_UI_audio_play("UI_Main_Menu_Select") 
  1316. 	 
  1317. 	-- Did we select yes?  This assumes yes is the first item 
  1318. 	if Store_common_popup:get_selected_data() ~= 1 then 
  1319. 		return 
  1320. 	end	 
  1321. 	 
  1322. 	-- do this so holding down the button doesn't cause repeated actions 
  1323. 	Input_tracker:subscribe(false)		 
  1324. 	Input_tracker:subscribe(true)	 
  1325. 	 
  1326. 	pcu_discard_slot(Store_clothing_item_info.slot_index, Store_clothing_item_info.wardrobe_instance) 
  1327. 	store_common_back_menu() 
  1328. 	store_common_back_menu()	 
  1329. end 
  1330.  
  1331.  
  1332. function store_clothing_item_purchase(menu_data) 
  1333. 	local item = Store_clothing_item_info 
  1334. 	store_clothing_enable_mouse(false) 
  1335. 	 
  1336. 	-- Have we reached the category item limit? 
  1337. 	local num_owned = pcu_get_num_items_category(Store_clothing_category, Store_clothing_outfit_id) 
  1338. 	if num_owned >= STORE_CLOTHING_CATEGORY_MAX then 
  1339. 		Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  1340. 		Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  1341. 		Store_common_popup:set_text("CUST_MENU_CATEGORY_LIMIT_REACHED")		 
  1342. 		Store_common_popup:nav_enable(true, "store_clothing_fail_msg", "store_clothing_popup_nav") 
  1343. 		Not_popup_grp:set_alpha(.5)	 
  1344. 		Store_logo_grp:set_alpha(.5)	 
  1345. 		Active_list:set_visible(false)		 
  1346. 		return 
  1347. 	end	 
  1348. 	 
  1349. 	-- Have we reached the total item limit?	 
  1350. 	num_owned = pcu_get_num_items_owned(Store_clothing_outfit_id) 
  1351. 	if num_owned >= STORE_CLOTHING_TOTAL_MAX then 
  1352. 		Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  1353. 		Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  1354. 		Store_common_popup:set_text("CUST_MENU_TOTAL_LIMIT_REACHED")		 
  1355. 		Store_common_popup:nav_enable(true, "store_clothing_fail_msg", "store_clothing_popup_nav") 
  1356. 		Not_popup_grp:set_alpha(.5)	 
  1357. 		Store_logo_grp:set_alpha(.5)	 
  1358. 		Active_list:set_visible(false)		 
  1359. 		return 
  1360. 	end		 
  1361. 	 
  1362. 	-- Are we short on cash? 
  1363. 	if item.item_price > Store_common_player_cash then 
  1364. 		Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  1365. 		Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  1366. 		Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")		 
  1367. 		Store_common_popup:nav_enable(true, "store_clothing_fail_msg", "store_clothing_popup_nav") 
  1368. 		Not_popup_grp:set_alpha(.5)	 
  1369. 		Store_logo_grp:set_alpha(.5)	 
  1370. 		Active_list:set_visible(false)		 
  1371. 		return 
  1372. 	end 
  1373. 	 
  1374. 	-- Make sure they want to buy this 
  1375. 	Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  1376. 	Store_common_popup:set_title("STORE_TITLE_PURCHASING") 
  1377. 	Store_common_popup:set_text("STORE_TEXT_CONFIRM_PURCHASE_BLANK")				 
  1378. 	Store_common_popup:nav_enable(true, "store_clothing_item_purchase_final", "store_clothing_popup_nav") 
  1379. 	Not_popup_grp:set_alpha(.5) 
  1380. 	Store_logo_grp:set_alpha(.5) 
  1381. 	Active_list:set_visible(false) 
  1382. end 
  1383.  
  1384. function store_clothing_color_select(menu_data) 
  1385. 	Active_list:set_visible(false) 
  1386. 	 
  1387. 	-- get the colors for the palette 
  1388. 	Color_grid_data = {} 
  1389. 	Color_slot_chosen = menu_data.id 
  1390. 	Color_grid_idx = 1 
  1391. 	pcu_report_item_colors("store_clothing_color_add", Store_clothing_item_info.item_index) 
  1392. 	 
  1393. 	-- display the grid 
  1394. 	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) 
  1395. 	Store_common_color_grid:set_visible(true) 
  1396. 	Store_common_color_grid:nav_enable(true, "store_clothing_color_selected", "store_clothing_color_nav")	 
  1397. 	Color_prev_color = Color_grid_idx 
  1398. 	 
  1399. 	if Mouse_input_tracker ~= 0 then 
  1400. 		Mouse_input_tracker:subscribe(false) 
  1401. 	end 
  1402. 	Current_tier = COLOR_TIER 
  1403. end 
  1404.  
  1405. -- Callback to get a wear option from C and add it to our wear option toggle. 
  1406. -- 
  1407. -- option_index: 	indicates which wear option this is for 
  1408. -- name_crc:		crc to use for the toggle choice name. nil if string is used. 
  1409. -- name_str:		string to use for the toggle choice name.  nil if crc is used. 
  1410. -- 
  1411. function store_clothing_wear_option_add(option_index, name_crc, name_str) 
  1412. 	local toggle_idx = #Toggle_data + 1 
  1413. 	if name_crc ~= nil then 
  1414. 		Toggle_data[toggle_idx] = name_crc 
  1415. 	else 
  1416. 		Toggle_data[toggle_idx] = name_str 
  1417. 	end 
  1418. 	Wear_opt_data[toggle_idx] = option_index 
  1419. end 
  1420.  
  1421. -- Callback to get a style option from C and add it to our style toggle. 
  1422. -- 
  1423. -- option_index: 	indicates which style options this is for 
  1424. -- name_crc:		crc to use for the toggle choice name. nil if string is used. 
  1425. -- name_str:		string to use for the toggle choice name.  nil if crc is used. 
  1426. -- 
  1427. function store_clothing_style_add(option_index, name_crc, name_str) 
  1428. 	local toggle_idx = #Toggle_data + 1 
  1429. 	if name_crc ~= nil then 
  1430. 		Toggle_data[toggle_idx] = name_crc 
  1431. 	else 
  1432. 		Toggle_data[toggle_idx] = name_str 
  1433. 	end 
  1434. 	Style_variant_data[toggle_idx] = option_index 
  1435. end 
  1436.  
  1437. -- Callback to get a color option from C and add it to our color grid. 
  1438. -- 
  1439. -- color_index: 	indicates which color this is for 
  1440. -- label_crc:		crc to use for the toggle choice name. nil if string is used. 
  1441. -- label_str:		string to use for the toggle choice name.  nil if crc is used. 
  1442. -- red:				r value. 
  1443. -- green:			g value. 
  1444. -- blue:			b value. 
  1445. -- 
  1446. function store_clothing_color_add(color_index, label_crc, label_str, red, green, blue) 
  1447. 	local grid_idx = #Color_grid_data + 1 
  1448. 	 
  1449. 	Color_grid_data[grid_idx] = { 
  1450. 		icon = "ui_menu_veh_pnt_base", 
  1451. 		label_crc = label_crc, 
  1452. 		label = label_str, 
  1453. 		color = {red = red, green = green, blue = blue}, 
  1454. 		index = color_index, 
  1455. 	} 
  1456. 	 
  1457. 	if color_index == Store_clothing_item_info.colors[Color_slot_chosen].index then 
  1458. 		Color_grid_idx = grid_idx 
  1459. 	end 
  1460. end 
  1461.  
  1462. function store_clothing_color_selected(event) 
  1463. 	 
  1464. 	--Did the player select a color? 
  1465. 	if event == "select" or event == "mouse_click" then 
  1466. 		game_UI_audio_play("UI_Main_Menu_Select")				 
  1467. 	else 
  1468. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  1469. 		-- restore previous color 
  1470. 		Store_clothing_item_info.colors[Color_slot_chosen].index = Color_grid_data[Color_prev_color].index 
  1471. 		Store_clothing_item_info.colors[Color_slot_chosen].red = Color_grid_data[Color_prev_color].color.red 
  1472. 		Store_clothing_item_info.colors[Color_slot_chosen].green = Color_grid_data[Color_prev_color].color.green 
  1473. 		Store_clothing_item_info.colors[Color_slot_chosen].blue = Color_grid_data[Color_prev_color].color.blue	 
  1474. 			 
  1475. 		store_clothing_item_preview(true)			 
  1476. 	end 
  1477. 	 
  1478. 	store_clothing_populate_list(Menu_data, Active_list:get_selection()) 
  1479. 	 
  1480. 	Store_common_color_grid:nav_enable(false, nil, nil) 
  1481. 	Store_common_color_grid:cleanup() 
  1482. 	Color_grid_data = {} 
  1483. 	 
  1484. 	Store_common_color_grid:set_visible(false) 
  1485. 	Store_common_color_grid:cleanup() 
  1486. 	Active_list:set_visible(true) 
  1487. 	 
  1488. 	store_clothing_enable_mouse(true) 
  1489. 	Current_tier = MENU_TIER 
  1490. end 
  1491.  
  1492. function store_clothing_fail_msg(event) 
  1493. 	Store_common_popup:nav_enable(false, nil, nil) 
  1494. 	game_UI_audio_play("UI_Main_Menu_Select") 
  1495. 	Not_popup_grp:set_alpha(1) 
  1496. 	Store_logo_grp:set_alpha(1) 
  1497. 	Active_list:set_visible(true) 
  1498. 	store_clothing_enable_mouse(true) 
  1499. end 
  1500.  
  1501.  
  1502. -- Finalize or cancel a purchase based on the result of the confirmation question. 
  1503. -- 
  1504. -- response: 	how did the user respond? 
  1505. -- action: 		indicates if the dialog box was closed or some other action. 
  1506. -- 
  1507. function store_clothing_item_purchase_final(event) 
  1508.  
  1509. 	Store_common_popup:nav_enable(false, nil, nil) 
  1510. 	Not_popup_grp:set_alpha(1) 
  1511. 	Store_logo_grp:set_alpha(1) 
  1512. 	Active_list:set_visible(true) 
  1513. 	 
  1514. 	store_clothing_enable_mouse(true) 
  1515. 	 
  1516. 	-- The user hit the B button and are cancelling the purchase 
  1517. 	-- This is redundant to selecting "No" in the list 
  1518. 	if event == "back" then 
  1519. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  1520. 		return 
  1521. 	end 
  1522. 	 
  1523. 	game_UI_audio_play("UI_Main_Menu_Select") 
  1524. 	 
  1525. 	-- Did we select yes?  This assumes yes is the first item 
  1526. 	if Store_common_popup:get_selected_data() ~= 1 then 
  1527. 		return 
  1528. 	end 
  1529.  
  1530. 	-- award respect and actually purchase the item 
  1531. 	game_award_respect(Store_clothing_item_info.item_style, nil, nil, true) 
  1532. 	 
  1533. 	-- is this an outfit or an item? 
  1534. 	if Store_clothing_outfit_id == -1 then 
  1535. 		pcu_purchase_slot(Store_clothing_item_info.slot_index) 
  1536. 	else 
  1537. 		pcu_purchase_outfit(Store_clothing_outfit_id) 
  1538. 	end 
  1539. 	 
  1540. 	ui_audio_post_event("clothing_purchase") 
  1541. 	 
  1542. 	-- Go back up 2 menus 
  1543. 	store_common_back_menu() 
  1544. 	store_common_back_menu() 
  1545. 	 
  1546. 	-- do this so holding down the button doesn't cause repeated actions 
  1547. 	Input_tracker:subscribe(false)		 
  1548. 	Input_tracker:subscribe(true)		 
  1549. end 
  1550.  
  1551. function store_clothing_popup_nav(event, value) 
  1552. 	 
  1553. 	vint_set_mouse_cursor("") 
  1554. 	 
  1555. 	if event == "nav_up" then	 
  1556. 		Store_common_popup.list:move_cursor(-1)	 
  1557. 	elseif event == "nav_down" then 
  1558. 		Store_common_popup.list:move_cursor(1) 
  1559. 	elseif event == "mouse_move" then 
  1560. 		-- value contains the target_handle in this case 
  1561. 		local new_index = Store_common_popup.list:get_button_index(value) 
  1562. 		if new_index ~= 0 then 
  1563. 			Store_common_popup.list:set_selection(new_index) 
  1564. 			Store_common_popup.list:move_cursor(0, true) 
  1565. 		end 
  1566. 	else 
  1567. 		--do nothing 
  1568. 	end	 
  1569. end 
  1570.  
  1571. function store_clothing_color_nav(event, value) 
  1572. 	 
  1573. 	if event == "nav_up" then	 
  1574. 		Store_common_color_grid:move_cursor(-2)	 
  1575. 	elseif event == "nav_down" then 
  1576. 		Store_common_color_grid:move_cursor(2) 
  1577. 	elseif event == "nav_left" then 
  1578. 		Store_common_color_grid:move_cursor(-1) 
  1579. 	elseif event == "nav_right" then 
  1580. 		Store_common_color_grid:move_cursor(1) 
  1581. 	 
  1582. 	elseif event == "mouse_move" then 
  1583. 		-- value contains the target_handle in this case 
  1584. 		local new_index = Store_common_color_grid:get_data_index(value) 
  1585. 		if new_index ~= 0 then 
  1586. 			Store_common_color_grid:set_selection(new_index) 
  1587. 			Store_common_color_grid:move_cursor(0, false, true) 
  1588. 		end 
  1589. 		 
  1590. 	else 
  1591. 		--do nothing 
  1592. 	end 
  1593. 	 
  1594. 	-- set the color and preview the item 
  1595. 	local idx = Store_common_color_grid:return_selected_index() 
  1596. 	Store_clothing_item_info.colors[Color_slot_chosen].index = Color_grid_data[idx].index 
  1597. 	Store_clothing_item_info.colors[Color_slot_chosen].red = Color_grid_data[idx].color.red 
  1598. 	Store_clothing_item_info.colors[Color_slot_chosen].green = Color_grid_data[idx].color.green 
  1599. 	Store_clothing_item_info.colors[Color_slot_chosen].blue = Color_grid_data[idx].color.blue	 
  1600. 		 
  1601. 	store_clothing_item_preview(true)		 
  1602. end 
  1603.  
  1604. -- Kick off previewing an item 
  1605. -- 
  1606. -- get_specific_variant: currently unused. 
  1607. -- 
  1608. function store_clothing_item_preview(get_specific_variant) 
  1609. 	Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_ITEM -- this needs to not be = -1 so we know to update 
  1610. end 
  1611.  
  1612. -- Background thread that updates the item that is previewed. 
  1613. -- 
  1614. function store_clothing_item_preview_update()  --this thread should be always running in the background when suits are being previewed 
  1615. 	debug_print("vint", "outfit update thread started\n") 
  1616. 	while true do 
  1617. 		if pcu_is_streaming_done() then 
  1618. 			delay(0.2) 
  1619. 			 
  1620. 			if Store_clothing_waiting_update_value ~= STORE_CLOTHING_PENDING_NONE then 
  1621. 			 
  1622. 				-- clothing items 
  1623. 				if Store_clothing_waiting_update_value == STORE_CLOTHING_PENDING_ITEM then			 
  1624. 					local t = Store_clothing_item_info 
  1625. 					debug_print("vint", "updating single item with logo "..var_to_string(t.logo_index).."\n") 
  1626. 					--if t.slot_index ~= STORE_CLOTHING_INVALID_INDEX then  --makes sure the item is initialized before trying to preview it 
  1627. 						if t.item_index < 0 or t.wear_option_index < 0 then 
  1628. 							pcu_set_slots_empty(Store_clothing_category) 
  1629. 						else 
  1630. 							pcu_set_slot_info(t.slot_index, t.item_index, t.variant_index, t.colors.num_colors, t.colors[0].index, 
  1631. 							t.colors[1].index, t.colors[2].index, t.wear_option_index, t.logo_index, t.logo_color_index, true) 
  1632. 						end 
  1633. 					--end 
  1634. 					 
  1635. 					-- This appears to be necessary to make sure Preview_slot global in C is updated. 
  1636. 					if t.slot_index ~= nil then 
  1637. 						store_clothing_item_get_slot_info(t.slot_index) 
  1638. 					end 
  1639. 				end 
  1640. 				 
  1641. 				-- outfits (in store) 
  1642. 				if Store_clothing_waiting_update_value == STORE_CLOTHING_PENDING_STORE_OUTFIT then 
  1643. 					debug_print("vint", "updating store outfit\n") 
  1644. 					pcu_wear_store_outfit(Store_clothing_outfit_id) 
  1645. 				end	 
  1646. 				 
  1647. 				-- outfits (in wardrobe) 
  1648. 				if Store_clothing_waiting_update_value == STORE_CLOTHING_PENDING_OWNED_OUTFIT then 
  1649. 					debug_print("vint", "updating owned outfit\n") 
  1650. 					pcu_wear_outfit(Store_clothing_outfit_id, Store_clothing_outfit_finalize) 
  1651. 				end					 
  1652. 				 
  1653. 				Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_NONE 
  1654. 			end 
  1655.  
  1656. 		end 
  1657. 		thread_yield() 
  1658. 	end 
  1659. end 
  1660.  
  1661. -- Callback that's called when asynchronous image loading is complete 
  1662. -- 
  1663. function store_clothing_set_logo() 
  1664. 	Store_logo1:set_image("ui_store_logo_lets_pretend") 
  1665. 	Store_logo2:set_image("ui_store_logo_lets_pretend") 
  1666. 	 
  1667. 	for i = 1, 4 do 
  1668. 		local r_h  = Vdo_base_object:new("rainbow"..i, 0, Store_clothing_doc_handle) 
  1669. 		r_h:set_image("ui_store_lets_pretend_rainbow") 
  1670. 		r_h  = Vdo_base_object:new("rainbow"..i.."_1", 0, Store_clothing_doc_handle) 
  1671. 		r_h:set_image("ui_store_lets_pretend_rainbow")		 
  1672. 	end 
  1673. end 
  1674.  
  1675. -- Sets up the hint buttons - will change between store/wardrobe. 
  1676. -- 
  1677. function store_clothing_set_hints(mode_switch_enabled) 
  1678. 	local hint_data = { {CTRL_MENU_BUTTON_B, "MENU_BACK"} } 
  1679. 		 
  1680. 	Store_common_hint_bar:set_hints(hint_data) 
  1681. 	 
  1682. 	if Game_platform == "PC" then 
  1683. 		Hint_bar_mouse_input_tracker:remove_all() 
  1684. 		 
  1685. 		Store_common_hint_bar:add_mouse_inputs("store_clothing", Hint_bar_mouse_input_tracker) 
  1686. 		Hint_bar_mouse_input_tracker:subscribe(true) 
  1687. 	end 
  1688. 	 
  1689. 	local hint_rotate_data = { 
  1690. 		{CTRL_BUTTON_RS, "STORE_ZOOM_ROTATE"}, 
  1691. 	} 
  1692. 	Store_common_rotate_hint:set_hints(hint_rotate_data)  
  1693. end 
  1694.  
  1695. -- When returning to the top level menu, we may need to restore items that were removed 
  1696. -- because they obscure other slots. 
  1697. -- 
  1698. function store_clothing_restore_items(menu_data) 
  1699. 	pcu_clear_obscured_slots() 
  1700. 	store_set_camera_pos("body")	 
  1701. end 
  1702.  
  1703. function store_clothing_wardrobe_outfit_menu_fill(menu_data) 
  1704.  
  1705. 	local store_clothing_wardrobe_outfit_menu = { 
  1706. 		on_enter = store_clothing_outfit_enter, 
  1707. 		[1] = { label = "CUST_ITEM_VIEW_OUTFITS", type = TYPE_BUTTON, on_sub_menu_fill = store_clothing_outfit_get_all, outfit_cb = store_clothing_outfit_select }, 
  1708. 		[2] = { label = "CUST_ITEM_CREATE_OUTFIT", type = TYPE_BUTTON, on_select = store_clothing_outfit_create }, 
  1709. 		[3] = { label = "CUST_ITEM_DELETE_OUTFIT", type = TYPE_BUTTON, on_sub_menu_fill = store_clothing_outfit_get_all, outfit_cb = store_clothing_outfit_delete }, 
  1710. 		[4] = { label = "CUST_ITEM_REMOVE_CLOTHING", type = TYPE_BUTTON, on_select = store_clothing_remove_clothing }, 
  1711. 	} 
  1712. 	 
  1713. 	Store_common_sub_menu = store_clothing_wardrobe_outfit_menu 
  1714. end 
  1715.  
  1716. function store_clothing_mode_set_init() 
  1717. 	-- Update our hints 
  1718. 	store_clothing_set_hints(Store_clothing_loaded_from_crib == false) 
  1719. 	 
  1720. 	-- Reset our header 
  1721. 	Store_header:clear_titles() 
  1722. 	Store_header:set_price(nil) 
  1723. 	Store_header:set_respect(nil)			 
  1724. 	 
  1725. 	-- Populate the areas and draw the first menu 
  1726. 	local store_clothing_name 
  1727. 	if Store_clothing_is_wardrobe then 
  1728. 		store_clothing_name = "wardrobe" 
  1729. 		Store_header:enable_price_respect(false) 
  1730. 		Store_header:push_title(nil, "MENU_SWAP_WARDROBE") 
  1731. 	else 
  1732. 		store_clothing_name = "DEBUG_CLOTHING_STORE" 
  1733. 		--Store_header:enable_price_respect(true)		 
  1734. 	end	 
  1735.  
  1736. 	-- reset our store stacks 
  1737. 	store_common_stack_clear_menu() 
  1738. 	store_common_stack_clear_id() 
  1739. 	store_common_stack_clear_index() 
  1740. 	 
  1741. 	Menu_data = {} 
  1742. 	pcu_get_areas(store_clothing_name, "store_clothing_area_add") 
  1743. 	Menu_data.on_enter = store_clothing_area_menu_update 
  1744. 	 
  1745. 	-- if we're in the wardrobe, add the outfit menu 
  1746. 	if Store_clothing_is_wardrobe then 
  1747. 		local item = { 
  1748. 			label = "CUST_ICON_OUTFITS", type = TYPE_BUTTON, on_sub_menu_fill = store_clothing_wardrobe_outfit_menu_fill 
  1749. 		}		 
  1750. 		Menu_data[#Menu_data + 1] = item		 
  1751.  
  1752. 		if Store_clothing_loaded_from_crib == false then 
  1753. 			item = { 
  1754. 				label = "MENU_BACK", type = TYPE_BUTTON, on_select = store_clothing_switch_mode 
  1755. 			} 
  1756. 			Menu_data[#Menu_data + 1] = item		 
  1757. 		end 
  1758. 	else 
  1759. 		local item = { 
  1760. 			label = "MENU_SWAP_WARDROBE", type = TYPE_BUTTON, on_select = store_clothing_switch_mode 
  1761. 		}		 
  1762. 		Menu_data[#Menu_data + 1] = item	 
  1763. 		 
  1764. 		-- Option to switch to the online character gallery 
  1765. 		local item = { 
  1766. 			label = "STORE_CHARACTER_GALLERY", type = TYPE_BUTTON, on_select = store_clothing_load_gallery, 
  1767. 		}		 
  1768. 		Menu_data[#Menu_data + 1] = item		 
  1769.  
  1770. 		-- add exit store option 
  1771. 		local exit_item = { 
  1772. 			label = "STORE_EXIT", type = TYPE_BUTTON, on_select = store_clothing_exit 
  1773. 		}		 
  1774. 		Menu_data[#Menu_data + 1] = exit_item		 
  1775. 	end	 
  1776. 	 
  1777. 	-- Set current area to first menu choice 
  1778. 	Store_clothing_area = Menu_data[1].id	 
  1779. 	 
  1780. 	-- Pass the table data to the megalist vdo. 
  1781. 	store_clothing_populate_list(Menu_data, 1)		 
  1782. end 
  1783.  
  1784. -- Refresh the clothing area menu when we return to it, since the "new" highlights may have been updated by browsing 
  1785. -- 
  1786. function store_clothing_area_menu_update(menu_data) 
  1787. 	local store_clothing_name 
  1788. 	if Store_clothing_is_wardrobe then 
  1789. 		store_clothing_name = "wardrobe" 
  1790. 	else 
  1791. 		store_clothing_name = "DEBUG_CLOTHING_STORE"		 
  1792. 	end	 
  1793.  
  1794. 	local index = Active_list:get_selection() 
  1795. 	Menu_data = {} 
  1796. 	pcu_get_areas(store_clothing_name, "store_clothing_area_add") 
  1797. 	Menu_data.on_enter = store_clothing_area_menu_update 
  1798. 	 
  1799. 	-- if we're in the wardrobe, add the outfit menu 
  1800. 	if Store_clothing_is_wardrobe then 
  1801. 		local item = { 
  1802. 			label = "CUST_ICON_OUTFITS", type = TYPE_BUTTON, on_sub_menu_fill = store_clothing_wardrobe_outfit_menu_fill 
  1803. 		}		 
  1804. 		Menu_data[#Menu_data + 1] = item		 
  1805.  
  1806. 		if Store_clothing_loaded_from_crib == false then 
  1807. 			item = { 
  1808. 				label = "MENU_BACK", type = TYPE_BUTTON, on_select = store_clothing_switch_mode 
  1809. 			} 
  1810. 			Menu_data[#Menu_data + 1] = item		 
  1811. 		end 
  1812. 	else 
  1813. 		local item = { 
  1814. 			label = "MENU_SWAP_WARDROBE", type = TYPE_BUTTON, on_select = store_clothing_switch_mode 
  1815. 		}		 
  1816. 		Menu_data[#Menu_data + 1] = item	 
  1817. 		 
  1818. 		-- Option to switch to the online character gallery 
  1819. 		local item = { 
  1820. 			label = "STORE_CHARACTER_GALLERY", type = TYPE_BUTTON, on_select = store_clothing_load_gallery, 
  1821. 		}		 
  1822. 		Menu_data[#Menu_data + 1] = item	 
  1823.  
  1824. 		-- add exit store option 
  1825. 		local exit_item = { 
  1826. 			label = "STORE_EXIT", type = TYPE_BUTTON, on_select = store_clothing_exit 
  1827. 		}		 
  1828. 		Menu_data[#Menu_data + 1] = exit_item			 
  1829. 	end	 
  1830. 	 
  1831. 	store_clothing_populate_list(Menu_data, index) 
  1832. 	 
  1833. 	-- Force removed clothing to be returned 
  1834. 	store_clothing_restore_items() 
  1835. end 
  1836.  
  1837. -- Load the online character gallery. 
  1838. -- 
  1839. function store_clothing_load_gallery() 
  1840. 	Online_check_thread = thread_new("store_clothing_check_online_for_gallery") 
  1841. end 
  1842.  
  1843. function store_clothing_check_online_for_gallery() 
  1844. 	online_and_privilege_validator_begin(false, true, true, true, true, true)	-- Check we're signed in and we have content permissions 
  1845. 	while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do 
  1846. 		thread_yield() 
  1847. 	end 
  1848. 			 
  1849. 	Input_tracker:subscribe(true) 
  1850. 	 
  1851. 	if Online_validator_result ~= ONLINE_VALIDATOR_PASSED then 
  1852. 		return 
  1853. 	end 
  1854. 		 
  1855. 	if main_menu_check_user_content() == false then 
  1856. 		dialog_box_message("MENU_TITLE_WARNING", "USER_CONTENT_PRIV_DENIED") 
  1857. 		return 
  1858. 	end 
  1859. 		 
  1860. 	push_screen("store_gallery") 
  1861. 	Online_check_thread = -1 
  1862. end 
  1863.  
  1864. -- Switch between store and wardrobe modes. 
  1865. -- 
  1866. function store_clothing_switch_mode() 
  1867.  
  1868. 	local store_main_grp = Vdo_base_object:new("store_main_grp", 0, Store_common_doc_handle) 
  1869. 	local store_to_wardrobe_anim = Vdo_anim_object:new("store_to_wardrobe_anim",0, Store_common_doc_handle) 
  1870. 	local wardrobe_twn_1 = Vdo_tween_object:new("wardrobe_twn_1", store_to_wardrobe_anim.handle) 
  1871. 	local wardrobe_twn_2 = Vdo_tween_object:new("wardrobe_twn_2", store_to_wardrobe_anim.handle) 
  1872. 	 
  1873. 	store_main_grp:set_property("background", true) 
  1874. 	--bg_saints_set_background(true) 
  1875. 	 
  1876. 	if Store_clothing_is_wardrobe == true then 
  1877. 		Store_clothing_is_wardrobe = false 
  1878. 		wardrobe_twn_1:set_end_event("store_clothing_switch_to_store") 
  1879. 	else 
  1880. 		Store_clothing_is_wardrobe = true 
  1881. 		wardrobe_twn_1:set_end_event("store_clothing_switch_to_wardrobe") 
  1882. 	end 
  1883. 	 
  1884. 	wardrobe_twn_2:set_end_event("store_clothing_switch_mode_complete")		 
  1885. 	 
  1886. 	store_to_wardrobe_anim:play(0) 
  1887. 	 
  1888. 	-- Lock controls until animation is done 
  1889. 	Input_tracker:subscribe(false) 
  1890. 	store_clothing_enable_mouse(false) 
  1891. 	 
  1892. 	-- Set camera position back to whole body 
  1893. 	store_set_camera_pos("body") 
  1894. end 
  1895.  
  1896. function store_clothing_switch_mode_complete() 
  1897. 	local store_main_grp = Vdo_base_object:new("store_main_grp", 0, Store_common_doc_handle) 
  1898. 	 
  1899. 	store_main_grp:set_property("background", false)	 
  1900. 	bg_saints_set_background(false) 
  1901. 	store_unlock_controls() 
  1902. end 
  1903.  
  1904. function store_clothing_switch_to_wardrobe() 
  1905. 	local store_logo_grp = Vdo_base_object:new("store_logo_grp", 0, Store_common_doc_handle) 
  1906. 	 
  1907. 	store_logo_grp:set_visible(false) 
  1908. 	Store_header:reformat_and_resize(true) 
  1909. 	 
  1910. 	store_clothing_mode_set_init() 
  1911. end 
  1912.  
  1913. function store_clothing_switch_to_store() 
  1914. 	local store_logo_grp = Vdo_base_object:new("store_logo_grp", 0, Store_common_doc_handle) 
  1915. 	 
  1916. 	store_logo_grp:set_visible(true) 
  1917. 	Store_header:reformat_and_resize(false) 
  1918. 	 
  1919. 	store_clothing_mode_set_init() 
  1920. end 
  1921.  
  1922. -- Acquire all the outfits the player has into a sub menu. 
  1923. -- 
  1924. function store_clothing_outfit_get_all(menu_data) 
  1925.  
  1926. 	-- disable switching modes here 
  1927. 	store_clothing_set_hints(false) 
  1928.  
  1929. 	Store_common_sub_menu = {} 
  1930. 	Store_common_sub_menu.cb = menu_data.outfit_cb 
  1931. 	 
  1932. 	pcu_report_outfits("store_clothing_outfit_add") 
  1933. 	 
  1934. 	if #Store_common_sub_menu == 0 then 
  1935. 		local new_item = { label = "NO_OUTFITS_DISPLAY_NAME", type = TYPE_BUTTON, on_select = store_common_back_menu } 
  1936. 		Store_common_sub_menu[1] = new_item 
  1937. 	else 
  1938. 		store_clothing_outfit_nav(Store_common_sub_menu[1]) 
  1939. 	end 
  1940. end 
  1941.  
  1942. -- Callback to add 1 outfit to the menu 
  1943. -- 
  1944. function store_clothing_outfit_add(outfit_idx) 
  1945. 	local menu_idx = #Store_common_sub_menu + 1 
  1946. 	local item = { label = "{OUTFIT_NAME_"..outfit_idx.."}", type = TYPE_BUTTON, outfit_index = outfit_idx, on_select = Store_common_sub_menu.cb, 
  1947. 						on_nav = store_clothing_outfit_nav, on_cancel = store_clothing_outfit_revert } 
  1948. 	Store_common_sub_menu[menu_idx] = item 
  1949. end 
  1950.  
  1951. -- Called when navigating over a different outfit. 
  1952. -- 
  1953. function store_clothing_outfit_nav(menu_data) 
  1954. 	Store_clothing_outfit_id = menu_data.outfit_index 
  1955. 	Store_clothing_outfit_finalize = false 
  1956. 	Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_OWNED_OUTFIT 
  1957. end 
  1958.  
  1959. -- Called when player backs out of outfit preview with back button. 
  1960. -- 
  1961. function store_clothing_outfit_revert(menu_data) 
  1962. 	pcu_category_nav_clear_slot(Store_clothing_area) 
  1963. end 
  1964.  
  1965. -- Handles when the player selects an outfit to preview 
  1966. -- 
  1967. function store_clothing_outfit_select() 
  1968. 	if (pcu_is_streaming_done()) then 
  1969. 		Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  1970. 		Store_common_popup:set_title("WEAR_OUTFIT_TITLE") 
  1971. 		Store_common_popup:set_text("CONFIRM_WEAR_OUTFIT")				 
  1972. 		Store_common_popup:nav_enable(true, "store_clothing_outfit_select_confirm", "store_clothing_popup_nav") 
  1973. 		Not_popup_grp:set_alpha(.5) 
  1974. 		Store_logo_grp:set_alpha(.5) 
  1975. 		Active_list:set_visible(false) 
  1976. 		 
  1977. 		store_clothing_enable_mouse(false) 
  1978. 	end 
  1979. end 
  1980.  
  1981. -- Confirmation for dialog to wear outfit. 
  1982. -- 
  1983. function store_clothing_outfit_select_confirm(event) 
  1984. 	Store_common_popup:nav_enable(false, nil, nil) 
  1985. 	Not_popup_grp:set_alpha(1)	 
  1986. 	Store_logo_grp:set_alpha(1) 
  1987. 	Active_list:set_visible(true) 
  1988. 	store_clothing_enable_mouse(true) 
  1989. 		 
  1990. 	-- The user hit the B button and is exiting 
  1991. 	-- This is redundant to selecting "No" in the list 
  1992. 	if event == "back" then 
  1993. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  1994. 		return 
  1995. 	end 
  1996. 	 
  1997. 	game_UI_audio_play("UI_Main_Menu_Select") 
  1998. 	 
  1999. 	-- Did we select yes?  This assumes yes is the first item 
  2000. 	if Store_common_popup:get_selected_data() ~= 1 then 
  2001. 		return 
  2002. 	end 
  2003. 	 
  2004. 	Store_clothing_outfit_finalize = true 
  2005. 	Store_clothing_waiting_update_value = STORE_CLOTHING_PENDING_OWNED_OUTFIT 
  2006. 	 
  2007. 	store_common_back_menu() 
  2008. end 
  2009.  
  2010. -- Create an outfit from the player's current clothes. 
  2011. -- 
  2012. function store_clothing_outfit_create() 
  2013.  
  2014. 	local success, reason_title, reason_body 
  2015. 	success, reason_title, reason_body = pcu_can_create_outfit() 
  2016. 	if success == true then 
  2017. 		-- disable switching modes here 
  2018. 		store_clothing_set_hints(false)	 
  2019. 	 
  2020. 		game_vkeyboard_input("OUTFIT_NAME_TAG", "OUTFIT_NAME_ENTRY_DIALOG", 16, "OUTFIT_NAME_TAG", "store_clothing_outfit_name_cb", true) 
  2021. 	else 
  2022. 		Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  2023. 		Store_common_popup:set_title(reason_title) 
  2024. 		Store_common_popup:set_text(reason_body)		 
  2025. 		Store_common_popup:nav_enable(true, "store_clothing_fail_msg", "store_clothing_popup_nav") 
  2026. 		Not_popup_grp:set_alpha(.5) 
  2027. 		Store_logo_grp:set_alpha(.5) 
  2028. 		Active_list:set_visible(false) 
  2029. 		 
  2030. 		store_clothing_enable_mouse(false) 
  2031. 	end 
  2032. end 
  2033.  
  2034. -- Callback from virtual keyboard. 
  2035. -- 
  2036. function store_clothing_outfit_name_cb(success) 
  2037. 	if success == true then 
  2038. 		pcu_create_outfit("VKEYBOARD_RESULTS") 
  2039. 	end 
  2040. 	 
  2041. 	-- enable switching modes here 
  2042. 	store_clothing_set_hints(Store_clothing_loaded_from_crib == false) 
  2043. end 
  2044.  
  2045. -- Pulls up dialog to confirm if we are going to delete an outfit. 
  2046. -- 
  2047. function store_clothing_outfit_delete(menu_data) 
  2048. 	Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)	 
  2049. 	Store_common_popup:set_title("CUST_ITEM_DELETE_OUTFIT") 
  2050. 	Store_common_popup:set_text("CONFIRM_DELETE_OUTFIT")		 
  2051. 	Store_common_popup:nav_enable(true, "store_clothing_outfit_delete_confirm", "store_clothing_popup_nav") 
  2052. 	Not_popup_grp:set_alpha(.5) 
  2053. 	Store_logo_grp:set_alpha(.5) 
  2054. 	Active_list:set_visible(false) 
  2055. 	 
  2056. 	store_clothing_enable_mouse(false) 
  2057. end 
  2058.  
  2059. -- Confirmation for dialog to delete outfit. 
  2060. -- 
  2061. function store_clothing_outfit_delete_confirm(event) 
  2062. 	Store_common_popup:nav_enable(false, nil, nil) 
  2063. 	Not_popup_grp:set_alpha(1) 
  2064. 	Store_logo_grp:set_alpha(1) 
  2065. 	Active_list:set_visible(true) 
  2066. 	store_clothing_enable_mouse(true) 
  2067. 		 
  2068. 	-- The user hit the B button and is exiting 
  2069. 	-- This is redundant to selecting "No" in the list 
  2070. 	if event == "back" then 
  2071. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  2072. 		return 
  2073. 	end 
  2074. 	 
  2075. 	game_UI_audio_play("UI_Main_Menu_Select") 
  2076. 	 
  2077. 	-- Did we select yes?  This assumes yes is the first item 
  2078. 	if Store_common_popup:get_selected_data() ~= 1 then 
  2079. 		return 
  2080. 	end 
  2081. 	 
  2082. 	pcu_delete_outfit(Store_clothing_outfit_id) 
  2083. 	pcu_clear_preview_slot() 
  2084. 	store_common_back_menu() 
  2085. end 
  2086.  
  2087. function store_clothing_remove_clothing() 
  2088. 	Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  2089. 	Store_common_popup:set_title("CUST_DIALOG_DISROBE_TITLE") 
  2090. 	Store_common_popup:set_text("CUST_DIALOG_DISROBE_BODY")		 
  2091. 	Store_common_popup:nav_enable(true, "clothing_store_remove_clothing_confirm", "store_clothing_popup_nav") 
  2092. 	Not_popup_grp:set_alpha(.5) 
  2093. 	Store_logo_grp:set_alpha(.5) 
  2094. 	Active_list:set_visible(false) 
  2095. 	 
  2096. 	store_clothing_enable_mouse(false) 
  2097. end 
  2098.  
  2099. function clothing_store_remove_clothing_confirm(event) 
  2100. 	Store_common_popup:nav_enable(false, nil, nil) 
  2101. 	Not_popup_grp:set_alpha(1) 
  2102. 	Store_logo_grp:set_alpha(1) 
  2103. 	Active_list:set_visible(true) 
  2104. 	store_clothing_enable_mouse(true) 
  2105. 		 
  2106. 	-- The user hit the B button and is exiting 
  2107. 	-- This is redundant to selecting "No" in the list 
  2108. 	if event == "back" then 
  2109. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  2110. 		return 
  2111. 	end 
  2112. 	 
  2113. 	game_UI_audio_play("UI_Main_Menu_Select") 
  2114. 	 
  2115. 	-- Did we select yes?  This assumes yes is the first item 
  2116. 	if Store_common_popup:get_selected_data() ~= 1 then 
  2117. 		return 
  2118. 	end 
  2119. 	 
  2120. 	pcu_remove_clothing() 
  2121. end 
  2122.  
  2123. function store_clothing_outfit_enter(menu_data) 
  2124.  
  2125. 	-- enable switching modes here 
  2126. 	store_clothing_set_hints(Store_clothing_loaded_from_crib == false) 
  2127. 	 
  2128. end 
  2129.  
  2130. function store_clothing_play_exit_anim() 
  2131.  
  2132. 	--[[if Store_clothing_loaded_from_crib == false then 
  2133.  
  2134. 		local anim_out = Vdo_anim_object:new("lets_pretend_bg_anim_out", 0, Store_clothing_doc_handle) 
  2135. 		local end_event_twn = Vdo_tween_object:new("anim_out_end_event", anim_out.handle) 
  2136. 			 
  2137. 		end_event_twn:set_end_event("store_unload_doc") 
  2138. 		 
  2139. 		anim_out:play(0) 
  2140. 		store_common_play_anim_out() 
  2141. 	else 
  2142. 		store_unload_doc() 
  2143. 	end]]-- 
  2144. 	 
  2145. 	local anim_out 
  2146. 	local end_event_twn 
  2147.  
  2148. 	if Store_index == CRIB then 
  2149. 			 
  2150. 			store_unload_doc() 
  2151. 			 
  2152. 	elseif  Store_index == LETS_PRETEND then 
  2153. 		 
  2154. 		--Find exit anim 
  2155. 		--Find end event twn 
  2156. 		--set end event to "store_unload_doc" 
  2157. 		--Play anim 
  2158. 		 
  2159. 		anim_out = Vdo_anim_object:new("lets_pretend_bg_anim_out", 0, Store_clothing_doc_handle) 
  2160. 		end_event_twn = Vdo_tween_object:new("anim_out_end_event", anim_out.handle) 
  2161. 			 
  2162. 		end_event_twn:set_end_event("store_unload_doc") 
  2163. 		 
  2164. 		anim_out:play(0) 
  2165. 		store_common_play_anim_out()		 
  2166. 		 
  2167. 	elseif Store_index == NOBODY_LOVES_ME then 
  2168. 	 
  2169. 		anim_out = Vdo_anim_object:new("nobody_bg_anim_out", 0, Store_clothing_doc_handle) 
  2170. 		end_event_twn = Vdo_tween_object:new("end_event_twn", anim_out.handle) 
  2171. 			 
  2172. 		end_event_twn:set_end_event("store_unload_doc") 
  2173. 		 
  2174. 		anim_out:play(0) 
  2175. 		store_common_play_anim_out()	 
  2176. 		 
  2177. 	elseif Store_index == LEATHER_AND_LACE then 
  2178. 		 
  2179. 		 
  2180. 		--must stop other bg anim from playing before fade out 
  2181. 		anim_out = Vdo_anim_object:new("lace_bg_anim_out", 0, Store_clothing_doc_handle) 
  2182. 		end_event_twn = Vdo_tween_object:new("end_event_twn", anim_out.handle) 
  2183. 			 
  2184. 		end_event_twn:set_end_event("store_unload_doc") 
  2185. 		 
  2186. 		anim_out:play(0) 
  2187. 		store_common_play_anim_out() 
  2188. 		 
  2189. 	elseif Store_index == PLANET_SAINTS then 
  2190. 		 
  2191. 		anim_out = Vdo_anim_object:new("planet_bg_anim_out", 0, Store_clothing_doc_handle) 
  2192. 		end_event_twn = Vdo_tween_object:new("end_event_twn", anim_out.handle) 
  2193. 			 
  2194. 		end_event_twn:set_end_event("store_unload_doc") 
  2195. 		 
  2196. 		anim_out:play(0) 
  2197. 		store_common_play_anim_out() 
  2198. 		 
  2199. 	elseif Store_index == IMPRESSIONS then 
  2200. 		 
  2201. 		anim_out = Vdo_anim_object:new("impressions_bg_anim_out", 0, Store_clothing_doc_handle) 
  2202. 		end_event_twn = Vdo_tween_object:new("end_event_twn", anim_out.handle) 
  2203. 			 
  2204. 		end_event_twn:set_end_event("store_unload_doc") 
  2205. 		 
  2206. 		anim_out:play(0) 
  2207. 		store_common_play_anim_out() 
  2208. 	else 
  2209. 		store_unload_doc() 
  2210. 	end 
  2211. 		 
  2212. end 
  2213.  
  2214. function store_unload_doc() 
  2215.  
  2216. 	vint_document_unload() 
  2217. 	 
  2218. end 
  2219.  
  2220. function store_clothing_bg_anim_done() 
  2221. 	store_common_bg_anim_complete() 
  2222. end 
  2223.  
  2224. -- ===================================== 
  2225. --       Mouse Specific Functions 
  2226. -- ===================================== 
  2227. function store_clothing_enable_mouse(enable) 
  2228. 	if Game_platform == "PC" and enable ~= nil then 
  2229. 		if Mouse_input_tracker ~= 0 then 
  2230. 			Mouse_input_tracker:subscribe(enable) 
  2231. 		end 
  2232. 		 
  2233. 		if Hint_bar_mouse_input_tracker ~= -1 then 
  2234. 			Hint_bar_mouse_input_tracker:subscribe(enable) 
  2235. 		end 
  2236. 	end 
  2237. end 
  2238.  
  2239. function store_clothing_mouse_click(event, target_handle) 
  2240. 	local hint_index = Store_common_hint_bar:get_hint_index(target_handle) 
  2241. 	if hint_index ~= 0 then 
  2242. 		if Current_tier == MENU_TIER then 
  2243. 			store_common_button_b() 
  2244. 		elseif Current_tier == COLOR_TIER then 
  2245. 			store_clothing_color_selected("back") 
  2246. 		end 
  2247. 	end 
  2248. end 
  2249.  
  2250. function store_clothing_mouse_move(event, target_handle) 
  2251.   
  2252. 	vint_set_mouse_cursor("") 
  2253. 	store_common_mouse_zoom(0.0) 
  2254.  
  2255. 	Store_common_hint_bar:set_highlight(0) 
  2256. 	 
  2257. 	local hint_index = Store_common_hint_bar:get_hint_index(target_handle) 
  2258. 	if hint_index ~= 0 then 
  2259. 		Store_common_hint_bar:set_highlight(hint_index, Store_common_current_highlight_color) 
  2260. 	end 
  2261. 	 
  2262. 	local old_index = Active_list:get_selection() 
  2263. 	local new_index = Active_list:get_button_index(target_handle) 
  2264. 	if new_index ~= 0 and new_index ~= old_index then 
  2265. 		Active_list:set_selection(new_index) 
  2266. 		Active_list:move_cursor(0, true) 
  2267. 		 
  2268. 		-- If the item has a callback for navigation, do it (such as putting clothes on) 
  2269. 		local data_item = Active_list:return_selected_data() 
  2270. 		if data_item.on_nav ~= nil then 
  2271. 			data_item.on_nav(data_item) 
  2272. 		elseif Menu_data.default_on_nav ~= nil then 
  2273. 			Menu_data.default_on_nav(data_item) 
  2274. 		end 
  2275. 		return 
  2276. 	end 
  2277. end 
  2278.  
  2279. function store_clothing_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines) 
  2280. 	if scroll_lines ~= 0 then 
  2281. 		if Store_common_color_grid.bg.handle == target_handle then 
  2282. 			Store_common_color_grid:scroll_list(scroll_lines * -1) 
  2283. 		end 
  2284. 	end 
  2285. end 
  2286.  
  2287. function store_clothing_mouse_drag(event, target_handle, mouse_x, mouse_y) 
  2288. 	if Store_common_color_grid.scrollbar.tab.handle == target_handle then 
  2289. 		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)) 
  2290. 		Store_common_color_grid:scroll_list(0, new_start_index) 
  2291. 	end 
  2292. end 
  2293.  
  2294. function store_clothing_mouse_drag_release(event, target_handle, mouse_x, mouse_y) 
  2295. 	if Store_common_color_grid.scrollbar.tab.handle == target_handle then 
  2296. 		local start_row = Store_common_color_grid:get_visible_rows() 
  2297. 		Store_common_color_grid.scrollbar:release_scrolltab(start_row, Store_common_color_grid.rows - (Store_common_color_grid.max_height - 1)) 
  2298. 		Store_common_color_grid:update_mouse_inputs() 
  2299. 	end 
  2300. end 
  2301.