sr2lua/clothing_store.lua

  1. Clothing_store_building_menu = 0 
  2. Clothing_store_current_area = -1 
  3. Clothing_store_current_category = -1 
  4. Clothing_store_current_item = -1 
  5. Clothing_store_current_color_index = -1 
  6.  
  7. Clothing_store_original_value = -1 
  8. Clothing_store_item_update_value = -1 
  9. Clothing_store_item_update_thread = -1 
  10. Clothing_store_outfit_update_thread = -1 
  11.  
  12. Clothing_store_allow_swap = false; 
  13.  
  14. Clothing_store_waiting_update_value = -1 
  15. Clothing_store_update_type = 1; 
  16. --this variable is used to know what the next preview call to make on the player is 
  17. --1	this is an item 
  18. --2	this is an outfit from a store 
  19. --3	this is a player made outfit 
  20.  
  21. Clothing_store_menu_when_done_updating = -1; 
  22. Clothing_store_menu_when_done_updating_safe = -1; -- the safe one is gaurrenteed not to change when while the update thread is executing 
  23.  
  24. Clothing_store_top_menu = 0 
  25.  
  26. -- need 2 footer objects for transitions 
  27. Clothing_store_footers = { [0] = { grp = 0 }, [1] = { grp = 0 } } 
  28.  
  29.  
  30. Clothing_store_cash_displayed = -1 
  31. Clothing_store_cash_anim_h = 0 
  32.  
  33. Clothing_store_item_info = { 
  34. --[[ Initially empty but here are all of the fields that get populated 
  35. 	slot_index 
  36. 	item_index, item_name_* 
  37. 	variant_index, variant_name_*, num_variants 
  38. 	colors[3], num_colors, colors[n] == { index, red, green, blue } 
  39. 	wear_option_index, wear_option_name_*, num_wear_options 
  40. 	logo_index, logo_name_*, logo_color, logo_available 
  41. ]] 
  42. 	colors = { [0] = { }, [1] = { }, [2] = { } } 
  43. } 
  44.  
  45. Clothing_store_is_wardrobe = true			-- avoid some string compares 
  46.  
  47. CLOTHING_STORE_DOC_H = 0 
  48. CLOTHING_STORE_STYLE_FOOTER_HEIGHT = 40 
  49. CLOTHING_STORE_ITEM_UPDATE_VALUE_INVALID = -1  
  50. CLOTHING_STORE_INVALID_CATERGORY = -1 
  51. CLOTHING_STORE_INVALID_SLOT = -1 --slots are set up like this when a suit is selected (because the suit has no base slot) 
  52. CLOTHING_STORE_INVALID_INDEX = -1 
  53.  
  54. Clothing_store_allow_wardrobe = true 
  55. CLOTHING_STORE_WARDROBE_DISPLAY_NAME = "MENU_SWAP_WARDROBE" 
  56. CLOTHING_STORE_NO_OUTFITS_DISPLAY_NAME = "NO_OUTFITS_DISPLAY_NAME" 
  57.  
  58. Clothing_store_use_style = true 
  59.  
  60. function clothing_store_delayed_allow_swap() 
  61. 	delay(1.2) 
  62. 	Clothing_store_allow_swap = true	 
  63. end 
  64.  
  65. function clothing_store_init() 
  66. 	 
  67. 	Clothing_store_allow_swap = false 
  68. 	thread_new("clothing_store_delayed_allow_swap") 
  69. 	if CLOTHING_STORE_DOC_H == 0 then 
  70. 		CLOTHING_STORE_DOC_H = vint_document_find() 
  71. 	end 
  72. 	if Menu_swap_hud_hidden == true then 
  73. 		hud_hide(false) 
  74. 		Menu_swap_hud_hidden = false 
  75. 	end 
  76. 	if Clothing_store_outfit_update_thread == -1 then 
  77. 		Clothing_store_outfit_update_thread = thread_new("clothing_store_preview_update") 
  78. 	end 
  79. 	if (Clothing_store_name == "DEBUG_CLOTHING_STORE") then 
  80. 		local start_wardrobe 
  81. 		Clothing_store_name, Clothing_store_display_name, Clothing_store_allow_wardrobe, start_wardrobe = pcu_get_store_info() 
  82. 		if start_wardrobe then 
  83. 			Clothing_store_original_name = Clothing_store_name 
  84. 			Clothing_store_original_display_name = Clothing_store_display_name; 
  85. 			Clothing_store_name = "WARDROBE" 
  86. 			Clothing_store_display_name = CLOTHING_STORE_WARDROBE_DISPLAY_NAME 
  87. 			Clothing_store_is_wardrobe = true 
  88. 		elseif Clothing_store_name ~= "WARDROBE" and Clothing_store_name ~= "Wardrobe" and Clothing_store_name ~= "wardrobe" then 
  89. 			Clothing_store_original_name = Clothing_store_name 
  90. 			Clothing_store_original_display_name = Clothing_store_display_name; 
  91. 			Clothing_store_is_wardrobe = false 
  92. 		else 
  93. 			Clothing_store_original_name = "WARDROBE" 
  94. 			Clothing_store_name = "WARDROBE"  --to save me case mismatch headaches 
  95. 			Clothing_store_original_display_name = CLOTHING_STORE_WARDROBE_DISPLAY_NAME 
  96. 			Clothing_store_allow_wardrobe = false 
  97. 			Clothing_store_is_wardrobe = true	 
  98. 		end 
  99. 	end 
  100. 	if Clothing_store_allow_wardrobe == true then 
  101. 		if Clothing_store_name == "WARDROBE" then 
  102. 			Clothing_store_top_btn_tips.x_button = { label = "SWITCH_TO_STORE", 	enabled = btn_tips_default_a, } 
  103. 			Clothing_store_untop_btn_tips.x_button = { label = "SWITCH_TO_STORE", 	enabled = btn_tips_default_a, } 
  104. 			Clothing_store_is_wardrobe = true			 
  105. 		else 
  106. 			Clothing_store_top_btn_tips.x_button = { label = "SWITCH_TO_WARDROBE", 	enabled = btn_tips_default_a, } 
  107. 			Clothing_store_untop_btn_tips.x_button = { label = "SWITCH_TO_WARDROBE", 	enabled = btn_tips_default_a, }	 
  108. 			Clothing_store_is_wardrobe = false 
  109. 		end 
  110. 	end 
  111. 	 
  112. 	if mp_is_enabled() == true then 
  113. 		Clothing_store_top_btn_tips.b_button = { label = "MENU_BACK", 	enabled = btn_tips_default_a, } 
  114. 		Clothing_store_untop_btn_tips.b_button = { label = "MENU_BACK", 	enabled = btn_tips_default_a, } 
  115. 		Clothing_store_original_display_name = "MENU_SWAP_CLOTHING_STORE"; 
  116. 	else 
  117. 		Clothing_store_top_btn_tips.b_button = { label = "CONTROL_RESUME", 	enabled = btn_tips_default_a, } 
  118. 		Clothing_store_untop_btn_tips.b_button = { label = "MENU_BACK", 	enabled = btn_tips_default_a, } 
  119. 	end  
  120. 	 
  121. 	clothing_store_show()	--sets up Clothing_store_use_style, based on waredrobe and mp status. 
  122. 	menu_store_init(Clothing_store_use_style) 
  123. 	clothing_store_build_horz_menu() 
  124. 	menu_init() 
  125. 	menu_horz_init(Clothing_store_horz_menu) 
  126. 	 
  127. 	 
  128. 	--Event Tracking  
  129. 	if mp_is_enabled == true then 
  130. 		--debug_print("VINT", "EVENT TRACK: MP: Clothing Store\n") 
  131. 		event_tracking_interface_enter("MP: Clothing Store") 
  132. 	else 
  133. 		if Clothing_store_is_wardrobe == true then 
  134. 			--debug_print("VINT", "EVENT TRACK: Wardrobe\n") 
  135. 			event_tracking_interface_enter("Wardrobe") 
  136. 		else 
  137. 			--debug_print("VINT", "EVENT TRACK: Clothing Store\n") 
  138. 			event_tracking_interface_enter("Clothing Store") 
  139. 		end 
  140. 	end 
  141. 	 
  142. 	if mp_is_enabled() then 
  143. 		-- Make sure we back out by fading to black when viewing this in multiplayer mode 
  144. 		--Menu_fade_to_black = true 
  145. 		 
  146. 		-- Hide the hud for the duration 
  147. 		hud_fade_out() 
  148. 	end 
  149. end 
  150.  
  151. function clothing_store_show() 
  152. 	Clothing_store_use_style = false 
  153. 	 
  154. 	if Clothing_store_is_wardrobe == false then 
  155. 		if mp_is_enabled() == true then 
  156. 			Clothing_store_use_style = false 
  157. 		else 
  158. 			Clothing_store_use_style = true 
  159. 		end 
  160. 	end 
  161. 	 
  162. 	if mp_is_enabled() == true then 
  163. 		Clothing_store_top_btn_tips.b_button.label = "MENU_BACK" 
  164. 	end 
  165. end 
  166.  
  167. function clothing_store_cleanup() 
  168. 	peg_unload("ui_multiplayer") 
  169. 	peg_unload("ui_cl_logos") 
  170. end 
  171.  
  172. function clothing_store_exit() 
  173. 	if Clothing_store_is_wardrobe then 
  174. 		dialog_box_confirmation("STORE_EXIT_WARNING_HEADER", "CRIB_WARDROBE_EXIT", "clothing_store_confirm", true, true) 
  175. 	else 
  176. 		dialog_box_confirmation("STORE_EXIT_WARNING_HEADER", "STORE_EXIT_WARNING_BODY", "clothing_store_confirm", true, true) 
  177. 	end 
  178. end 
  179.  
  180. function clothing_store_exit_final() 
  181. 	Clothing_store_name = "DEBUG_CLOTHING_STORE" 
  182. 	Clothing_store_original_name = "DEBUG_CLOTHING_STORE" 
  183. 	vint_document_unload(vint_document_find("clothing_store")) 
  184. end 
  185.  
  186. function clothing_store_confirm(result, action) 
  187. 	if action ~= DIALOG_ACTION_CLOSE then 
  188. 		return 
  189. 	end 
  190. 	 
  191. 	if result == 0 then 
  192. 		menu_close(clothing_store_exit_final) 
  193. 	end 
  194. end 
  195.  
  196. function clothing_store_build_horz_menu() 
  197. 	debug_print("vint", "building a horz menu\n") 
  198. 	Clothing_store_horz_menu = { num_items = 0 } 
  199.  
  200. 	pcu_get_areas(Clothing_store_name, "clothing_store_add_horz_menu") 
  201. 	 
  202. 	if Clothing_store_is_wardrobe == true then 
  203. 		debug_print("vint", "adding an the special outfits tab because we're in the wardrobe\n") 
  204. 		Clothing_store_horz_menu[Clothing_store_horz_menu.num_items] = 
  205. 			{ label = "CUST_ICON_OUTFITS", sub_menu =  Clothing_store_wardrobe_outfit_menu } 
  206. 		Clothing_store_horz_menu.num_items = Clothing_store_horz_menu.num_items + 1 
  207. 	end 
  208. 	 
  209. 	if Clothing_store_is_wardrobe == true and mp_is_enabled() == true then 
  210. 		Clothing_store_horz_menu[Clothing_store_horz_menu.num_items] = 
  211. 			{ label = "CUST_ICON_BADGES", sub_menu = Clothing_store_mp_badges_menu } 
  212. 		Clothing_store_horz_menu.num_items = Clothing_store_horz_menu.num_items + 1 
  213. 	end 
  214. end 
  215.  
  216. function clothing_store_dump_item_info_debug() 
  217. --[[ 
  218. 	local t = Clothing_store_item_info 
  219. 	debug_print("vint", "\n") 
  220. 	debug_print("vint", "slot_index "..var_to_string(t.slot_index).."\n") 
  221. 	debug_print("vint", "item_index "..var_to_string(t.item_index).."\n") 
  222. 	debug_print("vint", "item_name_crc "..var_to_string(t.item_name_crc).."\n") 
  223. 	debug_print("vint", "item_name_str "..var_to_string(t.item_name_str).."\n") 
  224. 	debug_print("vint", "num_variants "..var_to_string(t.num_variants).."\n") 
  225. 	debug_print("vint", "variant_index "..var_to_string(t.variant_index).."\n") 
  226. 	debug_print("vint", "variant_name_crc "..var_to_string(t.variant_name_crc).."\n") 
  227. 	debug_print("vint", "variant_name_str "..var_to_string(t.variant_name_str).."\n") 
  228. 	debug_print("vint", "colors.num_colors "..var_to_string(t.colors.num_colors).."\n") 
  229. 	debug_print("vint", "colors[0].index "..var_to_string(t.colors[0].index).."\n") 
  230. 	debug_print("vint", "colors[0].red "..var_to_string(t.colors[0].red).."\n") 
  231. 	debug_print("vint", "colors[0].green "..var_to_string(t.colors[0].green).."\n") 
  232. 	debug_print("vint", "colors[0].blue "..var_to_string(t.colors[0].blue).."\n") 
  233. 	debug_print("vint", "colors[1].index "..var_to_string(t.colors[1].index).."\n") 
  234. 	debug_print("vint", "colors[1].red "..var_to_string(t.colors[1].red).."\n") 
  235. 	debug_print("vint", "colors[1].green "..var_to_string(t.colors[1].green).."\n") 
  236. 	debug_print("vint", "colors[1].blue "..var_to_string(t.colors[1].blue).."\n") 
  237. 	debug_print("vint", "colors[2].index "..var_to_string(t.colors[2].index).."\n") 
  238. 	debug_print("vint", "colors[2].red "..var_to_string(t.colors[2].red).."\n") 
  239. 	debug_print("vint", "colors[2].green "..var_to_string(t.colors[2].green).."\n") 
  240. 	debug_print("vint", "colors[2].blue "..var_to_string(t.colors[2].blue).."\n") 
  241. 	debug_print("vint", "num_wear_options "..var_to_string(t.num_wear_options).."\n") 
  242. 	debug_print("vint", "wear_option_index "..var_to_string(t.wear_option_index).."\n") 
  243. 	debug_print("vint", "wear_option_name_crc "..var_to_string(t.wear_option_name_crc).."\n") 
  244. 	debug_print("vint", "wear_option_name_str "..var_to_string(t.wear_option_name_str).."\n") 
  245. 	debug_print("vint", "num_logos "..var_to_string(t.num_logos).."\n") 
  246. 	debug_print("vint", "logo_index "..var_to_string(t.logo_index).."\n") 
  247. 	debug_print("vint", "logo_name_crc "..var_to_string(t.logo_name_crc).."\n") 
  248. 	debug_print("vint", "logo_name_str "..var_to_string(t.logo_name_str).."\n") 
  249. 	debug_print("vint", "logo_color_index "..var_to_string(t.logo_color_index).."\n") 
  250. 	debug_print("vint", "logo_color_red "..var_to_string(t.logo_color_red).."\n") 
  251. 	debug_print("vint", "logo_color_green "..var_to_string(t.logo_color_green).."\n") 
  252. 	debug_print("vint", "logo_color_blue "..var_to_string(t.logo_color_blue).."\n") 
  253. 	debug_print("vint", "item_style "..var_to_string(t.item_style).."\n") 
  254. 	debug_print("vint", "item_price "..var_to_string(t.item_price).."\n") 
  255. 	debug_print("vint", "\n") 
  256. 	]] 
  257. end 
  258.  
  259. function clothing_store_get_slot_info(slot) 
  260. 	local t = Clothing_store_item_info 
  261. 	local temp_logo_storage_color_index = t.logo_color_index 
  262. 	local temp_logo_storage_color_red = t.logo_color_red 
  263. 	local temp_logo_storage_color_green = t.logo_color_green 
  264. 	local temp_logo_storage_color_blue = t.logo_color_blue 
  265. 	 
  266. 	t.slot_index, t.item_index, t.item_name_crc, t.item_name_str, 
  267. 	t.num_variants, t.variant_index, t.variant_name_crc, t.variant_name_str, 
  268. 	t.colors.num_colors, 
  269. 	t.colors[0].index, t.colors[0].red, t.colors[0].green, t.colors[0].blue, 
  270. 	t.colors[1].index, t.colors[1].red, t.colors[1].green, t.colors[1].blue, 
  271. 	t.colors[2].index, t.colors[2].red, t.colors[2].green, t.colors[2].blue, 
  272. 	t.num_wear_options, t.wear_option_index, t.wear_option_name_crc, t.wear_option_name_str, 
  273. 	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, 
  274. 	t.item_style, t.item_price, 
  275. 	t.player_style_level, t.player_style_percent 
  276. 	= pcu_get_slot_info(slot) 
  277. 	 
  278. 	--do this to prevent logo color from being wiped when previewing the "no logo" logo 
  279. 	if t.logo_index == CLOTHING_STORE_INVALID_INDEX then 
  280. 		t.logo_color_index = temp_logo_storage_color_index 
  281. 		t.logo_color_red = temp_logo_storage_color_red 
  282. 		t.logo_color_green = temp_logo_storage_color_green  
  283. 		t.logo_color_blue = temp_logo_storage_color_blue 
  284. 	end 
  285. 	clothing_store_dump_item_info_debug() 
  286. end 
  287.  
  288. function clothing_store_get_item_defaults(item_index) 
  289. 	local t = Clothing_store_item_info 
  290. 	if item_index >= 0 then 
  291. 		t.slot_index, t.item_index, t.item_name_crc, t.item_name_str, 
  292. 		t.num_variants, t.variant_index, t.variant_name_crc, t.variant_name_str, 
  293. 		t.colors.num_colors, 
  294. 		t.colors[0].index, t.colors[0].red, t.colors[0].green, t.colors[0].blue, 
  295. 		t.colors[1].index, t.colors[1].red, t.colors[1].green, t.colors[1].blue, 
  296. 		t.colors[2].index, t.colors[2].red, t.colors[2].green, t.colors[2].blue, 
  297. 		t.num_wear_options, t.wear_option_index, t.wear_option_name_crc, t.wear_option_name_str, 
  298. 		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, 
  299. 		t.item_style, t.item_price, 
  300. 		t.player_style_level, t.player_style_percent 
  301. 		= pcu_get_item_defaults(item_index) 
  302. 	else 
  303. 		t.item_index = -1 
  304. 	end 
  305. 	 
  306. 	clothing_store_dump_item_info_debug() 
  307. end 
  308.  
  309. function clothing_store_get_owned_item_info(item_index, wardrobe_instance)  -- like get item defaults, but called when browsing the inventory 
  310. 	local t = Clothing_store_item_info 
  311. 	if wardrobe_instance == nil then 
  312. 		wardrobe_instance = -1  --this should never occur, but incase it does, this will make it assert instead of crash 
  313. 	end 
  314. 	if item_index >= 0 then 
  315. 		t.slot_index, t.item_index, t.item_name_crc, t.item_name_str, 
  316. 		t.num_variants, t.variant_index, t.variant_name_crc, t.variant_name_str, 
  317. 		t.colors.num_colors, 
  318. 		t.colors[0].index, t.colors[0].red, t.colors[0].green, t.colors[0].blue, 
  319. 		t.colors[1].index, t.colors[1].red, t.colors[1].green, t.colors[1].blue, 
  320. 		t.colors[2].index, t.colors[2].red, t.colors[2].green, t.colors[2].blue, 
  321. 		t.num_wear_options, t.wear_option_index, t.wear_option_name_crc, t.wear_option_name_str, 
  322. 		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 
  323. 		= pcu_get_owned_item_info(item_index, wardrobe_instance) 
  324. 	else 
  325. 		t.item_index = -1 
  326. 	end 
  327. 	 
  328. 	clothing_store_dump_item_info_debug() 
  329. end 
  330.  
  331. function clothing_store_preview_item(get_specific_variant) 
  332. 	local t = Clothing_store_item_info 
  333. 	local unavailable_grp_h = vint_object_find("preview_unavailable_grp") 
  334. 	local unavailable_txt_h = vint_object_find("preview_unavailable_txt", unavailable_grp_h) 
  335. 	vint_set_property(unavailable_txt_h, "word_wrap", true) 
  336. 	vint_set_property(unavailable_txt_h, "text_tag", "PREVIEW_UNAVAILABLE") 
  337.  
  338. 	debug_print("vint", "the item's index"..var_to_string(t.item_index).."\n") 
  339. 	 
  340. 	if t.num_wear_options == 0 then 
  341. 		vint_set_property(unavailable_grp_h, "visible", true) 
  342. 	else 
  343. 		vint_set_property(unavailable_grp_h, "visible", false) 
  344. 		if type(Clothing_store_item_update_value) == "table" and Clothing_store_item_update_value.is_outfit == true then 
  345. 			clothing_store_preview_store_outfit() 
  346. 		else 
  347. 			if mp_is_enabled() == true and Clothing_store_is_wardrobe == false then 
  348. 				-- We may be looking for one variant, otherwise we're looking for *all* variants (pass in nil) 
  349. 				local variant_index = get_specific_variant and Clothing_store_item_info.variant_index or nil 
  350. 			 
  351. 				if pcu_is_item_owned(Clothing_store_item_info.item_index, variant_index) == true then 
  352. 					clothing_store_already_owned_true() 
  353. 				else 
  354. 					clothing_store_already_owned_false() 
  355. 				end 
  356. 			else 
  357. 				clothing_store_already_owned_false() 
  358. 			end 
  359. 			 
  360. 			clothing_store_preview_single_item() 
  361. 		end 
  362. 	end 
  363. end 
  364.  
  365. function clothing_store_already_owned_true() 
  366. 	local unavailable_grp_h = vint_object_find("preview_unavailable_grp") 
  367. 	local unavailable_txt_h = vint_object_find("preview_unavailable_txt", unavailable_grp_h) 
  368. 	vint_set_property(unavailable_txt_h, "word_wrap", true) 
  369. 	vint_set_property(unavailable_txt_h, "text_tag", "MP_ITEM_OWNED") 
  370. 	vint_set_property(unavailable_grp_h, "visible", true) 
  371. end 
  372.  
  373. function clothing_store_already_owned_false() 
  374. 	local unavailable_grp_h = vint_object_find("preview_unavailable_grp") 
  375. 	vint_set_property(unavailable_grp_h, "visible", false) 
  376. end 
  377.  
  378. function clothing_store_add_horz_menu(area_index, label_crc, label_str) 
  379. 	local menu_idx = Clothing_store_horz_menu.num_items 
  380. 	 
  381. 	-- add an empty menu for this area 
  382. 	local new_menu = { 
  383. 		num_items = 0, on_back = clothing_store_exit, on_show = clothing_store_build_category_menu, on_alt_select = clothing_store_switch_mode, 
  384. 		on_nav = clothing_store_nav_category, area_id = area_index,  btn_tips = Clothing_store_top_btn_tips, 
  385. 	} 
  386. 	 
  387. 	Clothing_store_category_menus[menu_idx] = new_menu 
  388.  
  389. 	-- add new horz item 
  390. 	local new_item = { sub_menu = new_menu } 
  391. 	Clothing_store_horz_menu[menu_idx] = new_item 
  392. 	 
  393. 	if label_crc ~= nil then 
  394. 		new_menu.header_label_crc = label_crc 
  395. 		new_item.label_crc = label_crc 
  396. 	else 
  397. 		new_menu.header_label_str = label_str 
  398. 		new_item.label = label_str 
  399. 	end 
  400. 	 
  401. 	Clothing_store_horz_menu.num_items = menu_idx + 1 
  402. end 
  403.  
  404. function clothing_store_purge_pending_updates() 
  405.  
  406. 	if Clothing_store_item_update_thread ~= nil then 
  407. 		thread_kill(Clothing_store_item_update_thread) 
  408. 		debug_print("vint", "KILL Thread" .. Clothing_store_item_update_thread .. "\n") 
  409. 	end 
  410. 	Clothing_store_waiting_update_value = -1 
  411. end 
  412.  
  413.  
  414. function clothing_store_build_category_menu(menu_data) 
  415. 	Clothing_store_top_menu = menu_data 
  416. 	Clothing_store_current_area = menu_data.area_id 
  417. 	pcu_category_nav_clear_slot(menu_data.area_id) 
  418. 	Clothing_store_building_menu = menu_data 
  419. 	debug_print("vint","I think the menu ID is"..var_to_string(menu_data.area_id).."\n") 
  420. 	clothing_store_purge_pending_updates() 
  421. 	clothing_store_already_owned_false() 
  422.  
  423.  
  424. 	menu_data.num_items = 0 
  425. 	 
  426. 			 
  427. 	pcu_get_categories_in_area(menu_data.area_id, "clothing_store_add_category_item") 
  428. 	 
  429. 	if menu_data.num_items == 0 then 
  430. 		menu_data[0] = { label = "NO_ITEMS_DISPLAY_NAME", type = MENU_ITEM_TYPE_SELECTABLE } 
  431. 		menu_data.num_items = 1 
  432. 		Clothing_store_current_category = CLOTHING_STORE_INVALID_CATERGORY  
  433. 	else 
  434. 		if menu_data.highlighted_item == nil then 
  435. 			menu_data.highlighted_item = 0 
  436. 		end 
  437. 		if menu_data.highlighted_item >= menu_data.num_items then 
  438. 			menu_data.highlighted_item = 0 
  439. 		end 
  440. 		local i = menu_data[menu_data.highlighted_item] 
  441. 		pcu_set_active_category(i.cat_id, Clothing_store_current_area) 
  442. 		Clothing_store_current_category = i.cat_id 
  443. 		 
  444. 		Clothing_store_item_list_menu.header_label_crc = i.label_crc 
  445. 		Clothing_store_item_list_menu.header_label_str = i.label_str 
  446. 	end 
  447. end 
  448.  
  449. function clothing_store_add_category_item(category_id, label_crc, label_str) 
  450. 	local new_item = { type = MENU_ITEM_TYPE_SUB_MENU, sub_menu = Clothing_store_item_list_menu, cat_id = category_id }	 
  451. 	if label_crc ~= nil then 
  452. 		new_item.label_crc = label_crc 
  453. 	else 
  454. 		new_item.label = label_str 
  455. 	end 
  456. 	 
  457. 	local i = Clothing_store_building_menu.num_items 
  458. 	Clothing_store_building_menu[i] = new_item 
  459. 	Clothing_store_building_menu.num_items = i + 1 
  460. end 
  461.  
  462. function clothing_store_nav_category(menu_data) 
  463.  
  464.  
  465. 	debug_print("vint", "Naving Category\n") 
  466.  
  467. 	if pcu_is_streaming_done() and Clothing_store_waiting_update_value == -1 then 
  468. 		 
  469. 		debug_print("vint", "the currently selected category is "..var_to_string(Clothing_store_current_category).."\n"); 
  470. 		if Clothing_store_current_category ~= CLOTHING_STORE_INVALID_CATERGORY then 
  471. 			pcu_clear_preview_slot() 
  472. 			Clothing_store_current_category = menu_data[menu_data.highlighted_item].cat_id 
  473. 			pcu_set_active_category(Clothing_store_current_category, Clothing_store_current_area) 
  474. 		 
  475. 			local i = Menu_active[Menu_active.highlighted_item] 
  476. 			Clothing_store_item_list_menu.header_label_crc = i.label_crc 
  477. 			Clothing_store_item_list_menu.header_label_str = i.label_str 
  478. 		end 
  479. 	end 
  480. end 
  481.  
  482. function clothing_store_build_style_footer(menu_data) 
  483. 	local grp = vint_object_find("style_footer", Menu_option_labels.control_parent) 
  484. 	 
  485. 	--[[ 
  486. 	debug_print("vint", "clothing_store_build_style_footer()\n") 
  487. 	debug_print("vint", "menu_data.footer_height = "..var_to_string(menu_data.footer_height).."\n") 
  488. 	debug_print("vint", "menu_data.footer_height = "..var_to_string(menu_data.footer_height).."\n") 
  489. 	debug_print("vint", "grp = "..var_to_string(grp).."\n") 
  490. 	]] 
  491.  
  492. 	if menu_data.footer_height == 0 then 
  493. 		-- no active footer so hide the footer object 
  494. 		if grp ~= nil then 
  495. 			vint_set_property(grp, "visible", false) 
  496. 		end 
  497. 		 
  498. 		return 
  499. 	end 
  500. 	 
  501. 	-- clone if needed 
  502. 	if grp == 0 then 
  503. 		grp = vint_object_clone(vint_object_find("style_footer", nil, CLOTHING_STORE_DOC_H), Menu_option_labels.control_parent) 
  504. 	end 
  505.  
  506. 	vint_set_property(grp, "visible", true) 
  507. 	 
  508. 	menu_data.footer = { 
  509. 		footer_grp = grp, 
  510. 		price = vint_object_find("price_amount", grp), 
  511. 		style = vint_object_find("style_amount", grp), 
  512. 	} 
  513. 	 
  514. 	vint_set_property(menu_data.footer.style, "visible", Clothing_store_use_style) 
  515. end 
  516.  
  517. function clothing_store_update_style_footer(menu_data) 
  518. 	local item = Clothing_store_item_info 
  519. 	local fr = menu_data.footer 
  520. 	 
  521. 	if fr == nil then 
  522. 		return 
  523. 	end 
  524. 	 
  525. 	if fr.price ~= nil then 
  526. 		if item.item_price > menu_store_get_player_cash() then 
  527. 			vint_set_property(fr.price, "tint", 1, 0, 0) 
  528. 		else 
  529. 			vint_set_property(fr.price, "tint", 0.88, 0.749, 0.05) 
  530. 		end 
  531.  
  532. 		vint_set_property(fr.price, "text_tag", "$"..format_cash(item.item_price)) 
  533. 		 
  534. 		if menu_data.menu_width ~= nil then 
  535. 			vint_set_property(fr.price, "anchor", menu_data.menu_width - 20, 0) 
  536. 		end 
  537. 	end 
  538. 	 
  539. 	if fr.style ~= 0 then 
  540. 		--Localize style 
  541. 		local insert_value = {[0] = award_style("clothing", item.item_style, true)} 
  542. 		local style_string = vint_insert_values_in_string("STORE_ITEM_STYLE_AWARD", insert_value) 
  543. 		vint_set_property(fr.style, "text_tag", style_string) 
  544. 	end 
  545. end 
  546.  
  547. function clothing_store_confirm_remove_item() 
  548. 	dialog_box_confirmation("CUST_REMOVE_ITEM_TITLE", "CUST_REMOVE_ITEM_BODY", "clothing_store_remove_item_finalize") 
  549. end 
  550.  
  551. function clothing_store_remove_item_finalize(result, action) 
  552. 	if action ~= DIALOG_ACTION_CLOSE then 
  553. 		return 
  554. 	end 
  555. 	 
  556. 	if result == 0 then 
  557. 		pcu_set_slots_empty(Clothing_store_current_category, true) 
  558. 	end 
  559. end 
  560.  
  561. function clothing_store_remove_item_no_warning() 
  562. 	pcu_set_slots_empty(Clothing_store_current_category, true) 
  563. end 
  564.  
  565. function clothing_store_build_item_list_menu(menu_data) 
  566. 	--reset the update values 
  567. 	Clothing_store_item_update_value = CLOTHING_STORE_ITEM_UPDATE_VALUE_INVALID 
  568. 	Clothing_store_item_info.item_index = CLOTHING_STORE_INVALID_INDEX 
  569. 	clothing_store_purge_pending_updates() 
  570. 	debug_print("vint", "string name is"..var_to_string(Clothing_store_current_category).."\n"); 
  571. 	if Clothing_store_is_wardrobe == true and pcu_is_underwear_category(Clothing_store_current_category) == false then 
  572. 		local bra_required = pcu_bra_required() 
  573. 		if bra_required == false or pcu_is_bra_category(Clothing_store_current_category) == false then		 
  574. 			menu_data.num_items = 1 
  575. 			menu_data[0] = { label = "CUST_ITEM_NOTHING", type = MENU_ITEM_TYPE_SELECTABLE, on_select = clothing_store_remove_item_no_warning, item_id = -1}	 
  576. 		else 
  577. 		menu_data.num_items = 0 
  578. 		end 
  579. 	else 
  580. 		menu_data.num_items = 0 
  581. 	end 
  582. 	 
  583. 	menu_data.highlighted_item = nil 
  584. 	 
  585. 	Clothing_store_building_menu = menu_data 
  586. 	pcu_get_items_in_category(Clothing_store_current_category, "clothing_store_add_item_list_item") 
  587.  
  588. 	if menu_data.num_items > 0 then 
  589. 		if menu_data.highlighted_item == nil then 
  590. 			menu_data.highlighted_item = 0 
  591. 		end 
  592. 		 
  593. 		clothing_store_item_list_nav(menu_data) 
  594. 		 
  595. 		if Clothing_store_is_wardrobe == false then 
  596. 			menu_data.footer_height = CLOTHING_STORE_STYLE_FOOTER_HEIGHT 
  597. 			clothing_store_build_style_footer(menu_data) 
  598. 		else 
  599. 			menu_data.footer_height = 0 
  600. 		end 
  601. 	end 
  602. end 
  603.  
  604. function clothing_store_item_list_select() 
  605. 	Clothing_store_item_details_menu.highlighted_item = nil 
  606. 	if pcu_is_streaming_done() == true and Clothing_store_item_update_thread == -1 and Clothing_store_waiting_update_value == -1 then 
  607. 		menu_show(Clothing_store_item_details_menu, MENU_TRANSITION_SWEEP_LEFT) 
  608. 	end 
  609. end 
  610.  
  611. function clothing_store_item_notify_owned() 
  612. 	dialog_box_message("MENU_TITLE_NOTICE", "ALL_VARIANTS_ALREADY_OWNED", true, true) 
  613. end 
  614.  
  615. function clothing_store_add_item_list_item(item_id, label_crc, label_str, is_outfit, price, style, inc_wardrobe_instance, is_available) 
  616. 	local i = Clothing_store_building_menu.num_items 
  617. 	local new_item;  
  618. 	debug_print("vint", "availability = "..var_to_string(is_available).."\n") 
  619. 	if is_available ~= false then 
  620. 		if Clothing_store_is_wardrobe == false and mp_is_enabled() == true and pcu_is_item_owned(item_id, nil) == true then 
  621. 			-- We own all of this item's styles, so you can't actually select details 
  622. 			new_item = { type = MENU_ITEM_TYPE_SELECTABLE, on_select = clothing_store_item_notify_owned, item_id = item_id, wardrobe_instance = inc_wardrobe_instance } 
  623. 		else 
  624. 			new_item = { type = MENU_ITEM_TYPE_SELECTABLE, sub_menu = Clothing_store_item_details_menu, on_select = clothing_store_item_list_select, item_id = item_id, wardrobe_instance = inc_wardrobe_instance } 
  625. 		end 
  626. 	else 
  627. 		new_item = { type = MENU_ITEM_TYPE_SELECTABLE, item_id = item_id, wardrobe_instance = inc_wardrobe_instance } 
  628. 	end 
  629. 	 
  630. 	if label_crc ~= nil then 
  631. 		new_item.label_crc = label_crc 
  632. 	else 
  633. 		new_item.label = label_str 
  634. 	end 
  635. 	if is_outfit ~= nil and is_outfit == true then 
  636. 		if Clothing_store_is_wardrobe == false then 
  637. 			new_item.is_outfit = true 
  638. 			new_item.sub_menu = nil 
  639. 			new_item.on_select = clothing_store_purchase_item 
  640. 			new_item.item_price = price 
  641. 			new_item.item_style = style 
  642. 		else 
  643. 			new_item.is_outfit = true 
  644. 			new_item.sub_menu = nil 
  645. 			new_item.on_select = clothing_store_wear_item 
  646. 			new_item.item_price = nil    --for non outfits, these should be set in get_item_defaults 
  647. 			new_item.item_style = nil 
  648. 		end 
  649. 	else 
  650. 		new_item.is_outfit = false 
  651. 		if pcu_is_wearing_item(item_id) == true then 
  652. 			Clothing_store_building_menu.highlighted_item = i 
  653. 		end 
  654. 	end 
  655. 	Clothing_store_building_menu[i] = new_item 
  656. 	Clothing_store_building_menu.num_items = i + 1 
  657. end 
  658.  
  659. function clothing_store_item_list_back() 
  660. 	if pcu_is_streaming_done() then 
  661. 		if Clothing_store_item_update_thread ~= -1 then 
  662. 			thread_kill(Clothing_store_item_update_thread) 
  663. 			Clothing_store_item_update_thread = -1 
  664. 		end 
  665. 		audio_play(Menu_sound_back) 
  666. 		 
  667. 		local unavailable_grp_h = vint_object_find("preview_unavailable_grp") 
  668. 		vint_set_property(unavailable_grp_h, "visible", false) 
  669. 		pcu_clear_preview_slot() 
  670. 		 
  671. 		menu_show(Menu_active.parent_menu, MENU_TRANSITION_SWEEP_RIGHT) 
  672. 	end 
  673. end 
  674.  
  675. function clothing_store_delayed_item_update() 
  676. 	delay(0.4) 
  677. 	clothing_store_preview_item(false) 
  678. 	Clothing_store_item_update_thread = -1 
  679. end 
  680.  
  681. function clothing_store_item_list_nav(menu_data) 
  682. 	debug_print("vint", "clothing_store_item_list_nav()\n") 
  683.  
  684. 	menu_palette_invalidate() 
  685. 	if Clothing_store_item_update_thread ~= -1 then 
  686. 		 
  687. 		debug_print("vint", "clothing_store_item_list_nav() : thread_kill(Clothing_store_item_update_thread)\n") 
  688. 		thread_kill(Clothing_store_item_update_thread) 
  689. 	end 
  690. 	 
  691. 	Clothing_store_item_update_value = menu_data[menu_data.highlighted_item] 
  692. 	local i = menu_data[menu_data.highlighted_item] 
  693. 	if i.is_outfit ~= true then                 --if it's not an outfit, we need to read in a bunch of values 
  694. 		if Clothing_store_is_wardrobe == false then 
  695. 			clothing_store_get_item_defaults(i.item_id) 
  696. 		else 
  697. 			if i.label == "CUST_ITEM_NOTHING" then 
  698. 				Clothing_store_item_info.item_index = CLOTHING_STORE_INVALID_INDEX 
  699. 			else 
  700. 				clothing_store_get_owned_item_info(i.item_id, i.wardrobe_instance) 
  701. 				Clothing_store_item_info.wardrobe_instance = i.wardrobe_instance --store the instance of the current item incase we need to discard 
  702. 			end 
  703. 		end 
  704. 	else 
  705. 		Clothing_store_item_info.item_price = i.item_price  --if it as an outfit, then we've already read in the price/style 
  706. 		Clothing_store_item_info.item_style = i.item_style  
  707. 		Clothing_store_item_info.item_slot = CLOTHING_STORE_INVALID_SLOT --this is done so you can't mistakingly think a suit is an item and call functions with it 
  708. 		Clothing_store_item_info.slot_index = CLOTHING_STORE_INVALID_INDEX 
  709. 	end 
  710. 	 
  711. 	Clothing_store_item_update_thread = thread_new("clothing_store_delayed_item_update") 
  712. 	clothing_store_update_style_footer(menu_data) 
  713. end 
  714.  
  715. function clothing_store_details_style_select() 
  716. 	local m = Clothing_store_style_menu 
  717. 	local i = Clothing_store_item_info 
  718. 	m.num_items = 0 
  719. 	m.parent_menu = Clothing_store_item_details_menu 
  720. 	 
  721. 	Clothing_store_original_value = i.variant_index 
  722. 	 
  723. 	pcu_get_variants(i.slot_index, "clothing_store_style_add") 
  724. 	menu_show(m, MENU_TRANSITION_SWEEP_LEFT) 
  725. end 
  726.  
  727. function clothing_store_style_delayed_set() 
  728. 	delay(0.4) 
  729. 	clothing_store_style_set(Clothing_store_item_update_value) 
  730. 	Clothing_store_item_update_thread = -1 
  731. end 
  732.  
  733. function clothing_store_style_nav(menu_data) 
  734. 	if Clothing_store_item_update_thread ~= -1 then 
  735. 		thread_kill(Clothing_store_item_update_thread) 
  736. 	end 
  737. 	 
  738. 	Clothing_store_item_update_value = menu_data[menu_data.highlighted_item].variant_index 
  739. 	Clothing_store_item_update_thread = thread_new("clothing_store_style_delayed_set") 
  740. end 
  741.  
  742. function clothing_store_style_set(variant_index) 
  743. 	Clothing_store_item_info.variant_index = variant_index 
  744. 	clothing_store_preview_item(true) 
  745. 	--clothing_store_get_slot_info(Clothing_store_item_info.slot_index) 
  746. end 
  747.  
  748. function clothing_store_style_select(menu_label, menu_data) 
  749. 	Clothing_store_menu_when_done_updating = Clothing_store_item_details_menu; 
  750. 	clothing_store_style_set(menu_data.variant_index) 
  751. end 
  752.  
  753. function clothing_store_style_add(variant_index, name_crc, name_str) 
  754. 	local m = Clothing_store_style_menu	 
  755. 	local n = m.num_items 
  756. 	 
  757. 	m[n] = { 
  758. 		label = name_str, label_crc = name_crc, type = MENU_ITEM_TYPE_SELECTABLE, variant_index = variant_index, 
  759. 		on_select = clothing_store_style_select 
  760. 	} 
  761. 	 
  762. 	if variant_index == Clothing_store_item_info.variant_index then 
  763. 		m.highlighted_item = n 
  764. 	end 
  765. 	 
  766. 	m.num_items = n + 1 
  767. end 
  768.  
  769. function clothing_store_style_back(menu_data) 
  770. 	if Clothing_store_item_update_thread ~= -1 then 
  771. 		thread_kill(Clothing_store_item_update_thread) 
  772. 		Clothing_store_item_update_thread = -1 
  773. 	end 
  774. 	audio_play(Menu_sound_back) 
  775. 	 
  776. 	Clothing_store_item_info.variant_index = Clothing_store_original_value 
  777. 	Clothing_store_menu_when_done_updating = Menu_active.parent_menu 
  778. 	clothing_store_preview_item(true) 
  779. 	--clothing_store_get_slot_info(Clothing_store_item_info.slot_index) 
  780.  
  781. end 
  782.  
  783. function clothing_store_outfit_menu_on_show() 
  784. 	clothing_store_purge_pending_updates() 
  785. 	pcu_clear_obscured_slots() 
  786. 	store_set_camera_pos("body", true) 
  787. 	pcu_set_suits_active_category() 
  788. end 
  789.  
  790. function clothing_store_purchase_item() 
  791. 	if (pcu_is_streaming_done() and Clothing_store_waiting_update_value == -1 and Clothing_store_item_update_thread == -1) then 
  792. 		clothing_store_purge_pending_updates() 
  793. 		local item = Clothing_store_item_info 
  794. 		 
  795. 		if mp_is_enabled() == true and pcu_is_item_owned(item.item_index, item.variant_index) == true then 
  796. 			dialog_box_message("MENU_TITLE_NOTICE", "VARIANT_ALREADY_OWNED", true, true) 
  797. 			return 
  798. 		end 
  799. 		 
  800. 		if item.item_price > menu_store_get_player_cash() then 
  801. 			dialog_box_message("MENU_TITLE_NOTICE", "HUD_SHOP_INSUFFICIENT_FUNDS", true, true) 
  802. 			return 
  803. 		end 
  804. 		 
  805. 		dialog_box_confirmation("STORE_TITLE_PURCHASING", "STORE_TEXT_CONFIRM_PURCHASE_BLANK", "clothing_store_purchase_finalize_1", true, true) 
  806. 	end 
  807. end 
  808.  
  809. function clothing_store_wear_item() 
  810. 	if pcu_is_streaming_done() and Clothing_store_waiting_update_value == -1 then 
  811. 		pcu_wear_current_clothing() 
  812. 		menu_show(Clothing_store_top_menu, MENU_TRANSITION_SWEEP_LEFT) 
  813. 	end 
  814. 	 
  815. end 
  816.  
  817. function clothing_store_discard_item() 
  818. 	debug_print("vint", "I think the category is"..var_to_string(Clothing_store_current_category).."\n") 
  819. 	if pcu_is_current_item_worn(Clothing_store_item_info.slot_index, Clothing_store_item_info.wardrobe_instance) then 
  820. 		debug_print("vint", "I'm wearing the item i'm about to discard\n") 
  821. 		if pcu_is_underwear_category(Clothing_store_current_category) then 
  822. 			dialog_box_message("STORE_UNDERWEAR_WARNING","STORE_UNDERWEAR_SUB_WARNING", true, true) 
  823. 		else  
  824. 			if pcu_is_bra_category(Clothing_store_current_category) and pcu_bra_required() then 
  825. 				dialog_box_message("STORE_BRA_WARNING", "STORE_BRA_SUB_WARNING") 
  826. 			else 
  827. 				dialog_box_confirmation("STORE_TITLE_DISCARD", "STORE_TEXT_DISCARD", "clothing_store_discard_finalize1", true, true) 
  828. 			end 
  829. 		end 
  830. 	else 
  831. 		debug_print("vint", "I don't think the item is worn.\n") 
  832. 		dialog_box_confirmation("STORE_TITLE_DISCARD", "STORE_TEXT_DISCARD", "clothing_store_discard_finalize1", true, true) 
  833. 	end 
  834. end 
  835.  
  836. function clothing_store_purchase_finalize_1(response, action) 
  837. 	if action ~= DIALOG_ACTION_CLOSE then 
  838. 		return 
  839. 	end 
  840. 	 
  841. 	if response ~= 0 then 
  842. 		return 
  843. 	end 
  844. 	--there used to be item slot conflict checking here 
  845. 	clothing_store_purchase_finalize_2(0, DIALOG_ACTION_CLOSE) 
  846. 	 
  847. 	 
  848. end 
  849. 	 
  850. function clothing_store_purchase_finalize_2(response, action) 
  851. 	if action ~= DIALOG_ACTION_CLOSE then 
  852. 		return 
  853. 	end 
  854. 	 
  855. 	if response ~= 0 then 
  856. 		return 
  857. 	end 
  858.  
  859. 	if mp_is_enabled() == false then 
  860. 		award_style("clothing", Clothing_store_item_info.item_style) 
  861. 	end 
  862. 	 
  863. 	--clothing_store_preview_item() 
  864. 	if type(Clothing_store_item_update_value) == "table" and Clothing_store_item_update_value.is_outfit == true then 
  865. 		debug_print("vint", "trying to purchase outfit with ID: "..var_to_string(Clothing_store_item_update_value.item_id).."\n") 
  866. 		pcu_purchase_outfit(Clothing_store_item_update_value.item_id) 
  867. 	else 
  868. 		debug_print("vint", "trying to item in slot "..var_to_string(Clothing_store_item_info.slot_index).."\n") 
  869. 		pcu_purchase_slot(Clothing_store_item_info.slot_index) 
  870. 	end 
  871. 	menu_show(Clothing_store_top_menu, MENU_TRANSITION_SWEEP_LEFT) 
  872. 	audio_play(Menu_sound_purchase) 
  873. end 
  874.  
  875. function clothing_store_discard_finalize1(response, action) 
  876. 	if action ~= DIALOG_ACTION_CLOSE then 
  877. 		return 
  878. 	end 
  879. 	 
  880. 	if response ~= 0 then 
  881. 		return 
  882. 	end 
  883. 	if pcu_is_item_needed_for_outfit(Clothing_store_item_info.slot_index) then 
  884. 		dialog_box_confirmation("STORE_TITLE_DISCARD_OUTFIT_WARNING", "STORE_TEXT_DISCARD_OUTFIT_WARNING", "clothing_store_discard_finalize2", true, true) 
  885. 	else 
  886. 		pcu_discard_slot(Clothing_store_item_info.slot_index, Clothing_store_item_info.wardrobe_instance) 
  887. 		menu_show(Clothing_store_top_menu, MENU_TRANSITION_SWEEP_LEFT) 
  888. 	end 
  889. end 
  890.  
  891. function clothing_store_discard_finalize2(response, action) 
  892. 	if action ~= DIALOG_ACTION_CLOSE then 
  893. 		return 
  894. 	end 
  895. 	 
  896. 	if response ~= 0 then 
  897. 		return 
  898. 	end 
  899. 	 
  900. 	pcu_discard_slot(Clothing_store_item_info.slot_index, Clothing_store_item_info.wardrobe_instance) 
  901. 	menu_show(Clothing_store_top_menu, MENU_TRANSITION_SWEEP_LEFT) 
  902. end 
  903.  
  904. function clothing_store_details_nav(menu_data) 
  905. 	menu_palette_invalidate() 
  906. end 
  907.  
  908. function clothing_store_details_show(menu_data) 
  909. 	 
  910. 	-- kill preview thread 
  911. 	if Clothing_store_item_update_thread ~= -1 then 
  912. 		thread_kill(Clothing_store_item_update_thread) 
  913. 		Clothing_store_item_update_thread = -1 
  914. 	end 
  915.  
  916. 	-- set the header 
  917. 	menu_data.header_label_crc = Clothing_store_item_info.item_name_crc 
  918. 	menu_data.header_label_str = Clothing_store_item_info.item_name_str 
  919. 	 
  920. 	-- get info on the item 
  921. 	clothing_store_preview_item(true) 
  922. 	 
  923. 	-- build the menu 
  924. 	local num_items = 0 
  925. 	local m = Clothing_store_item_details_menu 
  926. 	local item = Clothing_store_item_info 
  927. 	 
  928. 	if item.colors.num_colors > 0 then 
  929. 		local p = Clothing_store_clothing_palette 
  930. 		local c = item.colors 
  931. 		Clothing_store_clothing_palette.num_colors = c.num_colors 
  932. 		 
  933. 		for i = 0, c.num_colors - 1 do 
  934. 			p[i].red		= c[i].red 
  935. 			p[i].green	= c[i].green 
  936. 			p[i].blue	= c[i].blue 
  937. 		end 
  938. 		 
  939. 		-- always allow color selection in mp 
  940. 		-- otherwise not in sp wardrobe 
  941. 		local allow_color_selection = Clothing_store_is_wardrobe == false or mp_is_enabled() == true 
  942.  
  943. 		m[num_items] =	{ 
  944. 			label = "CUST_MENU_COLOR", type = MENU_ITEM_TYPE_PALETTE, palette_colors = p, 
  945. 			on_select = clothing_store_palette_select, color_name = "clothing", disabled = (allow_color_selection == false) 
  946. 		} 
  947. 		 
  948. 		num_items = num_items + 1 
  949. 	end 
  950. 	 
  951. 	if item.num_variants > 1 then 
  952. 		local allow_style_selection = Clothing_store_is_wardrobe == false or mp_is_enabled() == true 
  953. 		m[num_items] = { 
  954. 			label = "MENU_STYLE", type = MENU_ITEM_TYPE_INFO_BOX, on_select = clothing_store_details_style_select, 
  955. 			info_text_str = item.variant_name_str, info_text_crc = item.variant_name_crc, disabled = (allow_style_selection == false) 
  956. 		} 
  957. 		num_items = num_items + 1 
  958. 	end 
  959. 	 
  960. 	if item.num_logos > 0 then 
  961. 		local allow_logo_selection = Clothing_store_is_wardrobe == false or mp_is_enabled() == true 
  962. 		m[num_items] = { label = "CUST_MENU_LOGO", type = MENU_ITEM_TYPE_INFO_BOX, on_select = clothing_store_details_logo_select,  
  963. 							disabled = (allow_logo_selection == false) } 
  964. 		 
  965. 		if Clothing_store_item_info.logo_index > -1 then 
  966. 			m[num_items].info_text_str = Clothing_store_item_info.logo_name_str 
  967. 			m[num_items].info_text_crc = Clothing_store_item_info.logo_name_crc 
  968.  
  969. 			local p = Clothing_store_logo_palette[0] 
  970. 			p.red = Clothing_store_item_info.logo_color_red 
  971. 			p.green = Clothing_store_item_info.logo_color_green 
  972. 			p.blue = Clothing_store_item_info.logo_color_blue 
  973. 		else 
  974. 			m[num_items].info_text_str = "CUST_NO_ITEMS" 
  975. 		end 
  976. 		 
  977. 		num_items = num_items + 1 
  978. 		 
  979. 		if item.logo_index > -1 then 
  980. 			local allow_logo_color_selection = Clothing_store_is_wardrobe == false or mp_is_enabled() == true 
  981. 			m[num_items] = { 
  982. 				label = "CUST_MENU_LOGO_COLOR", type = MENU_ITEM_TYPE_PALETTE, palette_colors = Clothing_store_logo_palette, 
  983. 				on_select = clothing_store_palette_select, color_name = "logo", disabled = (allow_logo_color_selection == false) 
  984. 			} 
  985. 			num_items = num_items + 1 
  986. 		end 
  987. 	end 
  988. 	 
  989. 	if item.num_wear_options > 1 then 
  990. 		m[num_items] = { 
  991. 			label = "CUST_MENU_WEAR_OPTION", type = MENU_ITEM_TYPE_INFO_BOX, on_select = clothing_store_details_wear_option_select, 
  992. 			info_text_str = item.wear_option_name_str, info_text_crc = item.wear_option_name_crc 
  993. 		} 
  994. 		num_items = num_items + 1 
  995. 	end 
  996.  
  997. 	if Clothing_store_is_wardrobe == true then 
  998. 		m[num_items] = { label = "CUST_ITEM_WEAR", type = MENU_ITEM_TYPE_SELECTABLE, on_select = clothing_store_wear_item } 
  999. 		num_items = num_items + 1 
  1000. 		if mp_is_enabled()== false then 
  1001. 			m[num_items] = { label = "STORE_DISCARD_ITEM", type = MENU_ITEM_TYPE_SELECTABLE, on_select = clothing_store_discard_item } 
  1002. 			num_items = num_items + 1 
  1003. 		end 
  1004. 	else 
  1005. 		m[num_items] = { label = "STORE_PURCHASE_ITEM", type = MENU_ITEM_TYPE_SELECTABLE, on_select = clothing_store_purchase_item } 
  1006. 		num_items = num_items + 1 
  1007. 	end 
  1008. 	 
  1009. 	if Clothing_store_is_wardrobe == false then 
  1010. 		menu_data.footer_height = CLOTHING_STORE_STYLE_FOOTER_HEIGHT 
  1011. 		clothing_store_build_style_footer(menu_data) 
  1012. 	else 
  1013. 		menu_data.footer_height = 0 
  1014. 	end 
  1015. 	 
  1016. 	m.num_items = num_items 
  1017. end 
  1018.  
  1019. function clothing_store_details_logo_select() 
  1020. 	Clothing_store_logo_list_menu.parent_menu = Menu_active 
  1021. 	menu_show(Clothing_store_logo_list_menu, MENU_TRANSITION_SWEEP_LEFT) 
  1022. end 
  1023.  
  1024. function clothing_store_palette_select(menu_label, menu_data) 
  1025. 	if menu_data.color_name == "logo" and Clothing_store_item_info.logo_index < 0 then 
  1026. 		return 
  1027. 	end 
  1028.  
  1029. 	local i = menu_label.control.highlighted_index 
  1030. 	local m = Clothing_store_color_menu 
  1031. 	local p = menu_data.palette_colors[i] 
  1032. 	m.header_label_str = p.label_str 
  1033. 	m.header_label_crc = p.label_crc 
  1034. 	m.color_name = menu_data.color_name 
  1035. 	m.color_idx = i 
  1036. 	menu_show(Clothing_store_color_menu, MENU_TRANSITION_SWEEP_LEFT) 
  1037. end 
  1038.  
  1039. function clothing_store_wear_option_back(menu_data) 
  1040. 	if Clothing_store_item_update_thread ~= -1 then 
  1041. 		thread_kill(Clothing_store_item_update_thread) 
  1042. 		Clothing_store_item_update_thread = -1 
  1043. 	end 
  1044. 	audio_play(Menu_sound_back) 
  1045.  
  1046. 	Clothing_store_item_info.wear_option_index = Clothing_store_original_value 
  1047. 	Clothing_store_menu_when_done_updating = Menu_active.parent_menu 
  1048. 	clothing_store_preview_item(true) 
  1049. 	--clothing_store_get_slot_info(Clothing_store_item_info.slot_index) 
  1050. 	 
  1051.  
  1052. end 
  1053.  
  1054. function clothing_store_wear_option_delayed_set() 
  1055. 	delay(0.4) 
  1056. 	clothing_store_wear_option_set(Clothing_store_item_update_value) 
  1057. 	Clothing_store_item_update_thread = -1 
  1058. end 
  1059.  
  1060. function clothing_store_wear_option_nav(menu_data) 
  1061. 	if Clothing_store_item_update_thread ~= -1 then 
  1062. 		thread_kill(Clothing_store_item_update_thread) 
  1063. 	end 
  1064. 	 
  1065. 	Clothing_store_item_update_value = menu_data[menu_data.highlighted_item].option_index 
  1066. 	Clothing_store_item_update_thread = thread_new("clothing_store_wear_option_delayed_set") 
  1067. end 
  1068.  
  1069. function clothing_store_wear_option_set(option_index) 
  1070. 	Clothing_store_item_info.wear_option_index = option_index 
  1071. 	clothing_store_preview_item(true) 
  1072. 	--clothing_store_get_slot_info(Clothing_store_item_info.slot_index) 
  1073. end 
  1074.  
  1075. function clothing_store_wear_option_select(menu_label, menu_data) 
  1076. 	Clothing_store_menu_when_done_updating = Clothing_store_item_details_menu 
  1077. 	clothing_store_wear_option_set(menu_data.option_index) 
  1078. end 
  1079.  
  1080. function clothing_store_wear_option_add(option_index, name_crc, name_str) 
  1081. 	local m = Clothing_store_wear_options_menu	 
  1082. 	local n = m.num_items 
  1083. 	 
  1084. 	m[n] = { 
  1085. 		label = name_str, label_crc = name_crc, type = MENU_ITEM_TYPE_SELECTABLE, option_index = option_index, 
  1086. 		on_select = clothing_store_wear_option_select 
  1087. 	} 
  1088. 	 
  1089. 	if option_index == Clothing_store_item_info.wear_option_index then 
  1090. 		m.highlighted_item = n 
  1091. 	end 
  1092. 	 
  1093. 	m.num_items = n + 1 
  1094. end 
  1095.  
  1096. function clothing_store_details_wear_option_select(menu_label, menu_data) 
  1097. 	local m = Clothing_store_wear_options_menu 
  1098. 	local i = Clothing_store_item_info 
  1099. 	m.num_items = 0 
  1100. 	m.parent_menu = Clothing_store_item_details_menu 
  1101. 	 
  1102. 	Clothing_store_original_value = Clothing_store_item_info.wear_option_index 
  1103. 	 
  1104. 	pcu_get_wear_options(i.slot_index, "clothing_store_wear_option_add") 
  1105. 	menu_show(m, MENU_TRANSITION_SWEEP_LEFT) 
  1106. end 
  1107.  
  1108. function clothing_store_color_grid_show(menu_data) 
  1109. 	menu_data.parent_menu = Clothing_store_item_details_menu 
  1110. 	if menu_data.color_name == "logo" then 
  1111. 		Clothing_store_original_value = Clothing_store_item_info.logo_color_index 
  1112. 		Clothing_store_item_update_value = 0 
  1113. 	else 
  1114. 		Clothing_store_original_value = Clothing_store_item_info.colors[menu_data.color_idx].index 
  1115. 		Clothing_store_item_update_value = Clothing_store_item_info.colors[menu_data.color_idx].index 
  1116. 	end 
  1117. 	 
  1118. 	local menu_item = menu_data[0] 
  1119.  
  1120. 	menu_item.swatches = { num_swatches = 0 } 
  1121. 	Clothing_store_building_menu = menu_data 
  1122. 	pcu_report_item_colors("clothing_store_add_color", Clothing_store_item_info.item_index) 
  1123.  
  1124. 	local swatch_template = vint_object_find("swatch_color", nil, MENU_BASE_DOC_HANDLE) 
  1125. 	menu_grid_show(menu_data, menu_item, swatch_template) 
  1126. 	clothing_store_color_grid_nav(menu_data, menu_item) 
  1127. end 
  1128.  
  1129. function clothing_store_add_color(color_index, label_crc, label_str, red, green, blue) 
  1130. 	local item = { 
  1131. 		color_index = color_index, red = red, green = green, blue = blue, label_crc = label_crc, label_str = label_str 
  1132. 	} 
  1133.  
  1134. 	local swatches = Clothing_store_building_menu[0].swatches 
  1135. 	local n = swatches.num_swatches 
  1136. 	swatches[n] = item 
  1137. 	 
  1138. 	if Clothing_store_color_menu.color_name == "logo" then 
  1139. 		if Clothing_store_item_info.logo_color_index == color_index then 
  1140. 			Clothing_store_building_menu[0].cur_idx = n 
  1141. 		end 
  1142. 	else 
  1143. 		if Clothing_store_item_info.colors[Clothing_store_color_menu.color_idx].index == color_index then 
  1144. 			Clothing_store_building_menu[0].cur_idx = n 
  1145. 		end 
  1146. 	end 
  1147.  
  1148. 	swatches.num_swatches = n + 1 
  1149. end 
  1150.  
  1151. function clothing_store_color_grid_release(menu) 
  1152. 	menu_grid_release(menu[0]) 
  1153. end 
  1154.  
  1155. function clothing_store_color_grid_back(menu_data) 
  1156. 	if Clothing_store_item_update_thread ~= -1 then 
  1157. 		thread_kill(Clothing_store_item_update_thread) 
  1158. 		Clothing_store_item_update_thread = -1 
  1159. 	end 
  1160. 	audio_play(Menu_sound_back) 
  1161.  
  1162. 	if menu_data.color_name == "logo" then 
  1163. 		Clothing_store_item_info.logo_color_index = Clothing_store_original_value 
  1164. 	else 
  1165. 		Clothing_store_item_info.colors[menu_data.color_idx].index = Clothing_store_original_value 
  1166. 	end 
  1167. 	Clothing_store_menu_when_done_updating = Menu_active.parent_menu 
  1168. 	clothing_store_preview_item(true)  
  1169.  
  1170. end 
  1171.  
  1172. function clothing_store_apply_item_color() 
  1173. 	if Clothing_store_color_menu.color_name == "logo" then 
  1174. 		Clothing_store_item_info.logo_color_index = Clothing_store_item_update_value 
  1175. 	else 
  1176. 		Clothing_store_item_info.colors[Clothing_store_color_menu.color_idx].index = 
  1177. 			Clothing_store_item_update_value 
  1178. 	end 
  1179. 		 
  1180. 	clothing_store_preview_item(true) 
  1181. 	--clothing_store_get_slot_info(Clothing_store_item_info.slot_index) 
  1182. end 
  1183.  
  1184. function clothing_store_color_grid_select() 
  1185. 	if Clothing_store_item_update_thread ~= -1 then 
  1186. 		thread_kill(Clothing_store_item_update_thread) 
  1187. 		Clothing_store_item_update_thread = -1 
  1188. 	end 
  1189. 	 
  1190. 	Clothing_store_menu_when_done_updating = Clothing_store_item_details_menu 
  1191. 	clothing_store_apply_item_color() 
  1192. end 
  1193.  
  1194. function clothing_store_delayed_color_update() 
  1195. 	delay(0.4) 
  1196. 	clothing_store_apply_item_color() 
  1197. 	Clothing_store_item_update_thread = -1 
  1198. end 
  1199.  
  1200. function clothing_store_color_grid_nav() 
  1201. 	if Clothing_store_item_update_thread ~= -1 then 
  1202. 		thread_kill(Clothing_store_item_update_thread) 
  1203. 	end 
  1204.  
  1205. 	local item = Clothing_store_color_menu[0] 
  1206. 	local swatches = item.swatches 
  1207. 	local cur_swatch = item.cur_row * item.num_cols + item.cur_col 
  1208. 	Clothing_store_item_update_value = swatches[cur_swatch].color_index 
  1209. 	Clothing_store_item_update_thread = thread_new("clothing_store_delayed_color_update") 
  1210. end 
  1211.  
  1212. function clothing_store_color_update_swatch(swatch) 
  1213. 	local fill = vint_object_find("fill", swatch.swatch_h) 
  1214. 	vint_set_property(fill, "tint", swatch.red, swatch.green, swatch.blue) 
  1215. end 
  1216.  
  1217. --------------------[ LOGO LIST GRID ]---------------------- 
  1218.  
  1219. function clothing_store_logo_list_add_swatch(logo_id, swatch_crc, label_crc, label_str) 
  1220. 	local swatches = Clothing_store_building_menu[0].swatches 
  1221. 	local n = swatches.num_swatches 
  1222. 	 
  1223. 	swatches[n] = { logo_id = logo_id, swatch_crc = swatch_crc, label_crc = label_crc, label_str = label_str } 
  1224.  
  1225. 	--Match logo id with the item the player is wearing... 
  1226. 	if logo_id == Clothing_store_item_info.logo_index then 
  1227. 		Clothing_store_building_menu[0].cur_idx = n 
  1228. 	end 
  1229.  
  1230. 	swatches.num_swatches = n + 1 
  1231. end 
  1232.  
  1233. function clothing_store_logo_list_back(menu_option, menu_data) 
  1234. 	if Clothing_store_item_update_thread > -1 then 
  1235. 		thread_kill(Clothing_store_item_update_thread) 
  1236. 		Clothing_store_item_update_thread = -1 
  1237. 	end 
  1238. 	audio_play(Menu_sound_back) 
  1239. 	 
  1240. 	Clothing_store_item_info.logo_index = Clothing_store_original_value 
  1241. 	Clothing_store_menu_when_done_updating = Menu_active.parent_menu 
  1242. 	clothing_store_preview_item(true); 
  1243. 	--clothing_store_get_slot_info(Clothing_store_item_info.slot_index) 
  1244. end 
  1245.  
  1246. function clothing_store_logo_list_delayed_update() 
  1247. 	delay(0.4) 
  1248. 	clothing_store_logo_list_update() 
  1249. 	Clothing_store_item_update_thread = -1 
  1250. end 
  1251.  
  1252. function clothing_store_logo_list_nav(menu_option, menu_data) 
  1253. 	if Clothing_store_item_update_thread > -1 then 
  1254. 		thread_kill(Clothing_store_item_update_thread) 
  1255. 		Clothing_store_item_update_thread = -1 
  1256. 	end 
  1257.  
  1258. 	local swatches = menu_data.swatches 
  1259. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  1260.  
  1261. 	if idx < swatches.num_swatches then 
  1262. 		Clothing_store_item_update_value = swatches[idx].logo_id 
  1263. 		Clothing_store_item_update_thread = thread_new("clothing_store_logo_list_delayed_update") 
  1264. 	end 
  1265. end 
  1266.  
  1267. function clothing_store_logo_list_release(menu) 
  1268. 	menu_grid_release(menu[0]) 
  1269. 	--	peg_unload("ui_cl_logos") 
  1270. end 
  1271.  
  1272. function clothing_store_logo_list_select(menu_option, menu_data) 
  1273. 	if Clothing_store_item_update_thread > -1 then 
  1274. 		thread_kill(Clothing_store_item_update_thread) 
  1275. 		Clothing_store_item_update_thread = -1 
  1276. 	end 
  1277. 	Clothing_store_menu_when_done_updating = Clothing_store_item_details_menu 
  1278. 	clothing_store_logo_list_update() 
  1279. end 
  1280.  
  1281. function clothing_store_logo_list_show(menu_data) 
  1282. 	Clothing_store_original_value = Clothing_store_item_info.logo_index 
  1283. 	Clothing_store_item_update_value = Clothing_store_item_info.logo_index 
  1284. 	local menu_item = menu_data[0] 
  1285.  
  1286. 	menu_item.swatches = { num_swatches = 1} 
  1287. 	menu_item.swatches[0] = { logo_id = -1, swatch_str = "ui_menu_none", label_str = "CUST_NO_ITEMS" } 
  1288. 	 
  1289. 	--Reseting current index for the menu item to nil to initialize the menu. 
  1290. 	menu_item.cur_idx = nil 
  1291.  
  1292. 	Clothing_store_building_menu = menu_data 
  1293. 	pcu_report_logos(Clothing_store_item_info.item_index, "clothing_store_logo_list_add_swatch") 
  1294.  
  1295. 	peg_load("ui_cl_logos") 
  1296.  
  1297. 	menu_grid_show(menu_data, menu_item) 
  1298. 	 
  1299. 	menu_data.footer_height = 0 
  1300. end 
  1301.  
  1302. function clothing_store_logo_list_update() 
  1303. 	Clothing_store_item_info.logo_index = Clothing_store_item_update_value 
  1304. 	clothing_store_preview_item(true) 
  1305. 	--clothing_store_get_slot_info(Clothing_store_item_info.slot_index) 
  1306. end 
  1307.  
  1308. function clothing_store_switch_mode() 
  1309. 	if Clothing_store_allow_swap == true then 
  1310. 		if Menu_swap_interface_reload_name ~= 0 then 	--This means a swap is in progress 
  1311. 			return 
  1312. 		end 
  1313. 		if Clothing_store_allow_wardrobe == false then 
  1314. 			return 
  1315. 		end 
  1316. 		menu_input_block(true) 
  1317. 		 
  1318. 		if Clothing_store_name == "WARDROBE" then 
  1319. 			Clothing_store_name = Clothing_store_original_name 
  1320. 			Clothing_store_display_name = Clothing_store_original_display_name; 
  1321. 			Clothing_store_is_wardrobe = false 
  1322. 		else 
  1323. 			Clothing_store_name = "WARDROBE" 
  1324. 			Clothing_store_display_name = CLOTHING_STORE_WARDROBE_DISPLAY_NAME 
  1325. 			Clothing_store_is_wardrobe = true 
  1326. 		end 
  1327.  
  1328. 		Menu_swap_interface_unload_handle = CLOTHING_STORE_DOC_H 
  1329. 		Menu_swap_interface_reload_name = vint_document_get_name_from_handle(CLOTHING_STORE_DOC_H) 
  1330. 		Menu_swap_callback_function = clothing_store_switch_callback 
  1331. 		Menu_swap_in_progress = true 
  1332. 		menu_swap_interface(Clothing_store_display_name, vint_menu_swap_unload) 
  1333. 	end 
  1334. end 
  1335.  
  1336. function clothing_store_switch_callback() 
  1337. 	menu_input_block(false) 
  1338. 	pcu_reset_handle(CLOTHING_STORE_DOC_H) 
  1339. end 
  1340.  
  1341. function clothing_store_wardrobe_create_outfit_verify() 
  1342. 	local success, reason_title, reason_body 
  1343. 	success, reason_title, reason_body = pcu_can_create_outfit() 
  1344. 	if success == true then 
  1345. 		clothing_store_wardrobe_create_outfit() 
  1346. 	else 
  1347. 		dialog_box_message(reason_title, reason_body) 
  1348. 	end 
  1349. end 
  1350.  
  1351. function clothing_store_wardrobe_create_outfit() 
  1352. 	vkeyboard_input("OUTFIT_NAME", "OUTFIT_NAME_DESC", 16, "OUTFIT_NAME_TAG", "clothing_store_outfit_name_cb", true) 
  1353. end 
  1354.  
  1355. function clothing_store_outfit_name_cb(success) 
  1356. 	if success == true then 
  1357. 		pcu_create_outfit("VKEYBOARD_RESULTS") 
  1358. 	end 
  1359. end 
  1360.  
  1361. function clothing_store_remove_clothing() 
  1362. 	dialog_box_confirmation("CUST_DIALOG_DISROBE_TITLE", "CUST_DIALOG_DISROBE_BODY", "clothing_store_remove_clothing_confirm", true, true) 
  1363. end 
  1364.  
  1365. function clothing_store_remove_clothing_confirm(result, action) 
  1366. 	if action ~= DIALOG_ACTION_CLOSE then 
  1367. 		return 
  1368. 	end 
  1369. 	 
  1370. 	if result ~= 0 then 
  1371. 		return 
  1372. 	end 
  1373. 	 
  1374. 	pcu_remove_clothing() 
  1375. end 
  1376.  
  1377. function clothing_store_view_outfits_show(menu_data) 
  1378. 	menu_data.num_items = 0 
  1379. 	 
  1380. 	pcu_report_outfits("clothing_store_view_outfits_add") 
  1381. 	 
  1382. 	if menu_data.num_items == 0 then 
  1383. 		menu_data.num_items = 1 
  1384. 		menu_data[0] = { label = CLOTHING_STORE_NO_OUTFITS_DISPLAY_NAME, type = MENU_ITEM_TYPE_SELECTABLE } 
  1385. 	else 
  1386. 		menu_data.highlighted_item = 0 
  1387. 		clothing_store_view_outfits_nav(menu_data) 
  1388. 	end 
  1389. end 
  1390.  
  1391. function clothing_store_view_outfits_add(outfit_idx) 
  1392. 	local i = Clothing_store_wardrobe_view_outfits_menu.num_items 
  1393. 	 
  1394. 	Clothing_store_wardrobe_view_outfits_menu[i] = { label = "{OUTFIT_NAME_"..outfit_idx.."}", type = MENU_ITEM_TYPE_SELECTABLE, outfit_index = outfit_idx, on_select = clothing_store_view_outfits_select} 
  1395. 	i = i + 1 
  1396. 	Clothing_store_wardrobe_view_outfits_menu.num_items = i 
  1397. end 
  1398.  
  1399. function clothing_store_view_outfits_nav(menu_data) 
  1400. 	if menu_data[menu_data.highlighted_item].outfit_index ~= nil then 
  1401. 		Clothing_store_item_update_value = menu_data[menu_data.highlighted_item].outfit_index; 
  1402. 		if Clothing_store_item_update_thread ~= -1 then 
  1403. 			thread_kill(Clothing_store_item_update_thread) 
  1404. 		end 
  1405. 		Clothing_store_item_update_thread = thread_new("clothing_store_preview_player_outfit") 
  1406. 	else 
  1407. 		Clothing_store_item_update_value = CLOTHING_STORE_ITEM_UPDATE_VALUE_INVALID; 
  1408. 	end 
  1409. end 
  1410.  
  1411. function clothing_store_preview_single_item() 
  1412. 	Clothing_store_waiting_update_value = -1 --this is done so that the update thread never processes incompelete data 
  1413. 	Clothing_store_update_type = 1 
  1414. 	Clothing_store_menu_when_done_updating_safe = Clothing_store_menu_when_done_updating 
  1415. 	Clothing_store_waiting_update_value = 1 -- this needs to not be = -1 so we know to update 
  1416. end 
  1417.  
  1418.  
  1419. function clothing_store_preview_store_outfit() 
  1420. 	Clothing_store_waiting_update_value = -1 
  1421. 	Clothing_store_update_type = 2 
  1422. 	Clothing_store_menu_when_done_updating_safe = Clothing_store_menu_when_done_updating 
  1423. 	Clothing_store_menu_when_done_updating = -1 
  1424. 	Clothing_store_waiting_update_value = Clothing_store_item_update_value.item_id 
  1425.  
  1426. end 
  1427.  
  1428. function clothing_store_preview_player_outfit() 
  1429. 	Clothing_store_waiting_update_value = -1 
  1430. 	Clothing_store_update_type = 3 
  1431. 	Clothing_store_menu_when_done_updating_safe = Clothing_store_menu_when_done_updating 
  1432. 	Clothing_store_menu_when_done_updating = -1 
  1433. 	Clothing_store_waiting_update_value = Clothing_store_item_update_value 
  1434. end 
  1435.  
  1436.  
  1437.  
  1438. function clothing_store_preview_update()  --this thread should be always running in the background when suits are being previewed 
  1439. 	debug_print("vint", "outfit update thread started\n") 
  1440. 	while true do 
  1441. 		if pcu_is_streaming_done() then 
  1442. 			--delay(0.2) 
  1443. 			if Clothing_store_waiting_update_value ~= -1 then 
  1444. 				if Clothing_store_update_type == 1 then 
  1445. 					local t = Clothing_store_item_info 
  1446. 					debug_print("vint", "updating single item with logo "..var_to_string(t.logo_index).."\n") 
  1447. 					if t.slot_index ~= CLOTHING_STORE_INVALID_INDEX then  --makes sure the item is initialized before trying to preview it 
  1448. 						if t.item_index < 0 or t.wear_option_index < 0 then 
  1449. 							pcu_set_slots_empty(Clothing_store_current_category) 
  1450. 						else 
  1451. 							pcu_set_slot_info(t.slot_index, t.item_index, t.variant_index, t.colors.num_colors, t.colors[0].index, 
  1452. 							t.colors[1].index, t.colors[2].index, t.wear_option_index, t.logo_index, t.logo_color_index, true) 
  1453. 						end 
  1454. 					end 
  1455. 					if t.slot_index ~= nil then 
  1456. 						clothing_store_get_slot_info(t.slot_index) 
  1457. 					end 
  1458. 				end				 
  1459. 				if Clothing_store_update_type == 2 then 
  1460. 					debug_print("vint", "updating store outfit\n") 
  1461. 					pcu_wear_store_outfit(Clothing_store_waiting_update_value) 
  1462. 				end		 
  1463. 				if Clothing_store_update_type == 3 then 
  1464. 					debug_print("vint", "updating player outfit\n") 
  1465. 					pcu_wear_outfit(Clothing_store_waiting_update_value) 
  1466. 				end	 
  1467. 				if Clothing_store_menu_when_done_updating_safe ~= -1 then 
  1468. 					menu_show(Clothing_store_menu_when_done_updating_safe, MENU_TRANSITION_SWEEP_RIGHT) 
  1469. 					Clothing_store_menu_when_done_updating_safe = -1 
  1470. 					Clothing_store_menu_when_done_updating = -1 
  1471. 				end 
  1472. 			Clothing_store_waiting_update_value = -1 
  1473. 			end 
  1474.  
  1475. 		end 
  1476. 		thread_yield() 
  1477. 	end 
  1478. end 
  1479.  
  1480. function clothing_store_view_outfits_back() 
  1481. 	--pcu_clear_preview_slot()  --this may needed to be added back in, but it needs to be tested with outfits 
  1482. 	audio_play(Menu_sound_back) 
  1483. 	menu_show(Menu_active.parent_menu, MENU_TRANSITION_SWEEP_RIGHT) 
  1484. end 
  1485.  
  1486. function clothing_store_delete_outfit_show(menu_data) 
  1487. 	menu_data.num_items = 0 
  1488. 	 
  1489. 	pcu_report_outfits("clothing_store_delete_outfit_add") 
  1490. 	 
  1491. 	if menu_data.num_items == 0 then 
  1492. 		menu_data.num_items = 1 
  1493. 		menu_data[0] = { label = "NO_OUTFITS_DISPLAY_NAME", type = MENU_ITEM_TYPE_SELECTABLE } 
  1494. 	else 
  1495. 		menu_data.highlighted_item = 0 
  1496. 		clothing_store_delete_outfits_nav(menu_data) 
  1497. 	end 
  1498. end 
  1499.  
  1500. function clothing_store_delete_outfit_add(outfit_idx) 
  1501. 	local i = Clothing_store_wardrobe_delete_outfit_menu.num_items 
  1502. 	 
  1503. 	Clothing_store_wardrobe_delete_outfit_menu[i] = 
  1504. 		{ label = "{OUTFIT_NAME_"..outfit_idx.."}", type = MENU_ITEM_TYPE_SELECTABLE, outfit_index = outfit_idx, on_select = clothing_store_delete_outfits_select } 
  1505. 	i = i + 1 
  1506. 	Clothing_store_wardrobe_delete_outfit_menu.num_items = i 
  1507. end 
  1508.  
  1509. function clothing_store_delete_outfits_nav(menu_data) 
  1510. 	Clothing_store_item_update_value = menu_data[menu_data.highlighted_item].outfit_index 
  1511. 	 
  1512. 	if Clothing_store_item_update_thread ~= -1 then 
  1513. 		thread_kill(Clothing_store_item_update_thread) 
  1514. 	end 
  1515.  
  1516. 	Clothing_store_item_update_thread = thread_new("clothing_store_preview_player_outfit") 
  1517. end 
  1518.  
  1519. function clothing_store_delete_outfits_select() 
  1520. 	dialog_box_confirmation("CUST_ITEM_DELETE_OUTFIT", "CONFIRM_DELETE_OUTFIT", "clothing_store_delete_outfit_confirm", true, true) 
  1521. end 
  1522.  
  1523. function clothing_store_delete_outfit_confirm(result, action) 
  1524. 	if action ~= DIALOG_ACTION_CLOSE then 
  1525. 		return 
  1526. 	end 
  1527. 	 
  1528. 	if result ~= 0 then 
  1529. 		return 
  1530. 	end 
  1531. 	 
  1532. 	pcu_delete_outfit(Clothing_store_item_update_value) 
  1533. 	pcu_clear_preview_slot() 
  1534. 	menu_show(Clothing_store_wardrobe_outfit_menu, MENU_TRANSITION_SWEEP_LEFT) 
  1535. end 
  1536.  
  1537. function clothing_store_view_outfits_select() 
  1538. 	if (pcu_is_streaming_done()) then 
  1539. 		if Clothing_store_item_update_value ~= CLOTHING_STORE_ITEM_UPDATE_VALUE_INVALID then 
  1540. 			pcu_wear_outfit(Clothing_store_item_update_value) 
  1541. 			dialog_box_confirmation("WEAR OUTFIT", "CONFIRM_WEAR_OUTFIT", "clothing_store_wear_outfit_confirm") 
  1542. 		else 
  1543. 			if Clothing_store_item_update_thread ~= -1 then 
  1544. 				thread_kill(Clothing_store_item_update_thread) 
  1545. 				Clothing_store_item_update_thread = -1 
  1546. 			end 
  1547. 		end 
  1548. 	end 
  1549. end 
  1550.  
  1551. function clothing_store_wear_outfit_confirm(result, action) 
  1552. 	if action ~= DIALOG_ACTION_CLOSE then 
  1553. 		return 
  1554. 	end 
  1555. 	 
  1556. 	if result ~= 0 then 
  1557. 		return 
  1558. 	end 
  1559. 	 
  1560. 	pcu_wear_outfit(Clothing_store_item_update_value, true) 
  1561. 	menu_show(Clothing_store_wardrobe_outfit_menu, MENU_TRANSITION_SWEEP_LEFT) 
  1562. end 
  1563.  
  1564. function clothing_store_badge_add(idx, bmp, name, current) 
  1565. 	local s = Clothing_store_mp_badges_menu[0].swatches 
  1566. 	local i = s.num_swatches 
  1567. 	 
  1568. 	s[i] = { badge_id = idx, swatch_str = bmp, label_str = name } 
  1569. 	 
  1570. 	if current == true then 
  1571. 		Clothing_store_mp_badges_menu[0].cur_idx = i 
  1572. 	end 
  1573. 	 
  1574. 	s.num_swatches = i + 1 
  1575. end 
  1576.  
  1577. function clothing_store_badges_show(menu_data) 
  1578. 	peg_load("ui_multiplayer") 
  1579. 	local menu_item = menu_data[0] 
  1580.  
  1581. 	-- setup the swatches 
  1582. 	menu_item.swatches = { num_swatches = 0, cur_row = 0, cur_col = 0 } 
  1583. 	pcu_report_avail_mp_badges("clothing_store_badge_add") 
  1584. 	menu_grid_show(menu_data, menu_item) 
  1585. end 
  1586.  
  1587. function clothing_store_badge_select(menu_label, menu_data) 
  1588. 	local swatches = menu_data.swatches 
  1589. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  1590.  
  1591. 	if idx < swatches.num_swatches then 
  1592. 		pcu_set_mp_badge(swatches[idx].badge_id) 
  1593. 		 
  1594. 		local str1 = vint_insert_values_in_string("CUST_BADGE_SELECTED", { [0] = swatches[idx].label_str }) 
  1595. 		local str2 = vint_insert_values_in_string("{0}\n\n{1}", { [0] = swatches[idx].label_str.."_DESC", [1] = str1 }) 
  1596. 		dialog_box_message("CUST_ICON_BADGES", str2) 
  1597. 	end 
  1598. end 
  1599.  
  1600. function clothing_store_badge_nav(menu_label, menu_data) 
  1601. 	--Do nothing 
  1602. end 
  1603.  
  1604. function clothing_store_badges_release(menu_data) 
  1605. 	peg_unload("ui_multiplayer") 
  1606. 	menu_grid_release(menu_data[0]) 
  1607. end 
  1608.  
  1609.  
  1610. --------------------[ MENU DATA ]---------------------- 
  1611.  
  1612. Clothing_store_top_btn_tips = { 
  1613. 		a_button = { label = "CONTROL_SELECT", 		enabled = btn_tips_default_a, }, --switch to wardrobe is dynamically added on init 
  1614. 		right_stick =  	{ label = "CONTROL_ZOOM_AND_ROTATE", 	enabled = true }, 
  1615. 																			--exit/ resume also dynamically added 
  1616.  
  1617. } 
  1618.  
  1619. Clothing_store_untop_btn_tips = { 
  1620. 		a_button = { label = "CONTROL_SELECT", 		enabled = btn_tips_default_a, }, 
  1621. 		right_stick =  	{ label = "CONTROL_ZOOM_AND_ROTATE", 	enabled = true }, 
  1622. } 
  1623.  
  1624. Clothing_store_clothing_palette = { 
  1625. 	num_colors = 3, 
  1626. 	 
  1627. 	[0] = { label_str = "CUST_PRIMARY_COLOR",	red = 1, green = 0, blue = 0 }, 
  1628. 	[1] = { label_str = "CUST_SECONDARY_COLOR",	red = 0, green = 0, blue = 0 }, 
  1629. 	[2] = { label_str = "CUST_TERTIARY_COLOR",	red = 0, green = 0, blue = 1 }, 
  1630. }                                    
  1631.  
  1632. Clothing_store_logo_palette = { 
  1633. 	num_colors = 1, 
  1634. 	[0] = { label_str = "CUST_LOGO_COLOR",	red = 1, green = 1, blue = 0 }, 
  1635. } 
  1636.  
  1637. Clothing_store_wardrobe_delete_outfit_menu = { 
  1638. 	header_label_str = "DELETE_OUTFIT", 
  1639. 	on_alt_select = clothing_store_switch_mode, 
  1640. 	on_show = clothing_store_delete_outfit_show, 
  1641. 	on_nav = clothing_store_delete_outfits_nav, 
  1642. 	btn_tips = Clothing_store_untop_btn_tips, 
  1643. 	num_items = 1, 
  1644.  
  1645. 	[0] = { label = "NO_OUTFITS_DISPLAY_NAME", type = MENU_ITEM_TYPE_SELECTABLE }, 
  1646. } 
  1647.  
  1648. Clothing_store_wardrobe_view_outfits_menu = { 
  1649. 	header_label_str = "CUST_ICON_OUTFITS", 
  1650. 	on_alt_select = clothing_store_switch_mode, 
  1651. 	on_nav = clothing_store_view_outfits_nav, 
  1652. 	on_show = clothing_store_view_outfits_show, 
  1653. 	on_back = clothing_store_view_outfits_back, 
  1654. 	btn_tips = Clothing_store_untop_btn_tips, 
  1655. 	num_items = 1, 
  1656.  
  1657. 	[0] = { label = "NO_OUTFITS_DISPLAY_NAME", type = MENU_ITEM_TYPE_SELECTABLE }, 
  1658. } 
  1659.  
  1660. Clothing_store_wardrobe_outfit_menu = { 
  1661. 	header_label_str = "CUST_ICON_OUTFITS", 
  1662. 	on_back = clothing_store_exit, 
  1663. 	on_alt_select = clothing_store_switch_mode, 
  1664. 	btn_tips = Clothing_store_top_btn_tips, 
  1665. 	on_show = clothing_store_outfit_menu_on_show, 
  1666. 	num_items = 4, 
  1667.  
  1668. 	[0] = { label = "CUST_ITEM_VIEW_OUTFITS", type = MENU_ITEM_TYPE_SUB_MENU, sub_menu = Clothing_store_wardrobe_view_outfits_menu }, 
  1669. 	[1] = { label = "CUST_ITEM_CREATE_OUTFIT", type = MENU_ITEM_TYPE_SELECTABLE, on_select = clothing_store_wardrobe_create_outfit_verify }, 
  1670. 	[2] = { label = "CUST_ITEM_DELETE_OUTFIT", type = MENU_ITEM_TYPE_SUB_MENU, sub_menu = Clothing_store_wardrobe_delete_outfit_menu }, 
  1671. 	[3] = { label = "CUST_ITEM_REMOVE_CLOTHING", type = MENU_ITEM_TYPE_SELECTABLE, on_select = clothing_store_remove_clothing }, 
  1672. } 
  1673.  
  1674. Clothing_store_style_menu = { 
  1675. 	header_label_str = "MENU_STYLE", 
  1676. 	on_nav = clothing_store_style_nav, 
  1677. 	on_back = clothing_store_style_back, 
  1678. 	on_alt_select = clothing_store_switch_mode, 
  1679. 	btn_tips = Clothing_store_untop_btn_tips, 
  1680. } 
  1681.  
  1682. Clothing_store_wear_options_menu = { 
  1683. 	header_label_str = "CUST_MENU_WEAR_OPTION", 
  1684. 	on_nav = clothing_store_wear_option_nav, 
  1685. 	on_back = clothing_store_wear_option_back, 
  1686. 	on_alt_select = clothing_store_switch_mode, 
  1687. 	btn_tips = Clothing_store_untop_btn_tips, 
  1688. } 
  1689.  
  1690. Clothing_store_color_menu = { 
  1691. 	header_label_str = "CUST_MENU_COLOR", 
  1692. 	on_show = clothing_store_color_grid_show, 
  1693. 	on_release = clothing_store_color_grid_release, 
  1694. 	on_back = clothing_store_color_grid_back, 
  1695. 	on_alt_select = clothing_store_switch_mode, 
  1696. 	btn_tips = Clothing_store_untop_btn_tips, 
  1697. 	num_items = 1, 
  1698. 	footer_height = 30, 
  1699. 	[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = clothing_store_color_grid_select, on_nav = clothing_store_color_grid_nav, 
  1700. 		row_height = 41, num_cols = 6, col_width = 65, highlight_scale = 1, unhighlight_scale = 0.8, 
  1701. 		update_swatch = clothing_store_color_update_swatch 
  1702. 	} 
  1703. } 
  1704.  
  1705. Clothing_store_logo_list_menu = { 
  1706. 	header_label_str = "CUST_MENU_LOGO", 
  1707. 	on_show = clothing_store_logo_list_show, 
  1708. 	on_release = clothing_store_logo_list_release, 
  1709. 	on_back = clothing_store_logo_list_back, 
  1710. 	on_alt_select = clothing_store_switch_mode, 
  1711. 	btn_tips = Clothing_store_untop_btn_tips, 
  1712. 	num_items = 1, 
  1713. 	[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = clothing_store_logo_list_select, on_nav = clothing_store_logo_list_nav, 
  1714. 		row_height = MENU_SWATCH_DEFAULT_ROW_HEIGHT, num_cols = 4, col_width = MENU_SWATCH_DEFAULT_COL_WIDTH, highlight_scale = 1, unhighlight_scale = 0.8}, 
  1715. } 
  1716.  
  1717. Clothing_store_item_details_menu = { 
  1718. 	header_label_str = "CUST_PURCHASE_ITEM", 
  1719. 	on_show = clothing_store_details_show, 
  1720. 	on_nav = clothing_store_details_nav, 
  1721. 	on_post_show = clothing_store_update_style_footer, 
  1722. 	on_alt_select = clothing_store_switch_mode, 
  1723. 	btn_tips = Clothing_store_untop_btn_tips, 
  1724. } 
  1725.  
  1726. Clothing_store_item_list_menu = { 
  1727. 	on_show = clothing_store_build_item_list_menu, 
  1728. 	on_back = clothing_store_item_list_back, 
  1729. 	on_alt_select = clothing_store_switch_mode, 
  1730. 	on_nav = clothing_store_item_list_nav, 
  1731. 	on_post_show = clothing_store_update_style_footer, 
  1732. 	btn_tips = Clothing_store_untop_btn_tips, 
  1733. } 
  1734.  
  1735. Clothing_store_mp_badges_menu = { 
  1736. 	header_label_str = "CUST_ICON_BADGES", 
  1737. 	num_items = 1, 
  1738. 	on_back = clothing_store_exit, 
  1739. 	on_show = clothing_store_badges_show, 
  1740. 	on_alt_select = clothing_store_switch_mode, 
  1741. 	on_release = clothing_store_badges_release, 
  1742. 	btn_tips = Clothing_store_top_btn_tips, 
  1743. 	footer_height = 30, 
  1744. 	 
  1745. 	[0] = { 
  1746. 		label = "", 
  1747. 		type = MENU_ITEM_TYPE_GRID, 
  1748. 		on_select = clothing_store_badge_select, 
  1749. 		on_nav = clothing_store_badge_nav, 
  1750. 		row_height = 72, 
  1751. 		num_cols = 4, 
  1752. 		col_width = 83, 
  1753. 		highlight_scale = 1, 
  1754. 		unhighlight_scale = 0.8 
  1755. 	}, 
  1756. } 
  1757.   
  1758. Clothing_store_category_menus = { }	-- dynamically built 
  1759.  
  1760. Clothing_store_horz_menu = { }		-- built dynamically in clothing_store_init() 
  1761.