./store_tattoo.lua

  1.  
  2. local SCALE_FONT_STORE_TATTOO_LIST = 0.8 
  3.  
  4. Store_tattoo_doc_handle = -1 
  5.  
  6. -- Used to determine which of three colors player is currently picking, and the index in the color grid is currently chosen. 
  7. local Color_grid_idx		= 1 
  8. local Color_slot_chosen		= 0 
  9.  
  10. local Color_grid_data		= {} 
  11.  
  12. -- Mouse input-related variables 
  13. local Game_platform 
  14. local Hint_bar_mouse_input_tracker 
  15.  
  16. local MENU_TIER	= 1 
  17. local COLOR_TIER	= 2 
  18. local Current_tier = MENU_TIER 
  19.  
  20. local Store_tattoo_in_anim 
  21.  
  22. local Player_creation_bg_anim 
  23.  
  24. -- Hint bar and store header vdo's. 
  25. local Not_popup_grp 
  26.  
  27. local Store_tattoo_building_menu 
  28.  
  29. local Store_tattoo_current_area 
  30. local Store_tattoo_current_item 
  31. local Store_tattoo_current_color 
  32. local Store_tattoo_current_alpha 
  33. local Store_tattoo_current_price 
  34. local Store_tattoo_current_respect 
  35.  
  36. local Store_tattoo_reverted = {} 
  37.  
  38. local Store_tattoo_nav_thread = -1 
  39.  
  40. local Store_tattoo_init_camera_moved = false 
  41.  
  42. local STORE_CHARACTER_HAIR_AREA_BEGIN		= 0 
  43. local STORE_CHARACTER_HAIR_AREA_HEAD		= 0 
  44. local STORE_CHARACTER_HAIR_AREA_END			= 0 
  45.  
  46. local Store_character_hair_values = { 
  47. 	[STORE_CHARACTER_HAIR_AREA_HEAD]     = { name = "head", style = -1, primary = -1, secondary = -1 }, 
  48. } 
  49.  
  50. function store_tattoo_composite_alpha_done() 
  51. 	-- Disable mouse input for active_list and hint_bar 
  52. 	store_tattoo_enable_mouse(false) 
  53. 	 
  54. 	store_tattoo_purchase() 
  55. end 
  56.  
  57. function store_tattoo_composite_alpha_change(menu_data) 
  58. 	Store_tattoo_current_alpha = menu_data.current_value 
  59. 	 
  60. 	pcr_change_composite(Store_tattoo_current_area, Store_tattoo_current_item, Store_tattoo_current_color, Store_tattoo_current_alpha) 
  61. end 
  62.  
  63. function store_tattoo_composite_show_alpha_menu() 
  64. 	Active_list:set_visible(true) 
  65. 	 
  66. 	-- Get data to populate the megalist 
  67. 	local New_menu_data = { 
  68. 		[1] = { label = "CUST_OPACITY_SLIDER", type = TYPE_SLIDER, on_select = nil, 
  69. 			on_value_update = store_tattoo_composite_alpha_change, min = 0, max = 1, step = 0.05, current_value = Store_tattoo_current_alpha },	 
  70. 		[2] = { label = "STORE_PURCHASE_ITEM", label_crc = nil,	 type = TYPE_BUTTON, on_select = store_tattoo_composite_alpha_done, }, 
  71. 	} 
  72. 	 
  73. 	store_common_push_menu(New_menu_data) 
  74. end 
  75.  
  76. function store_tattoo_color_grid_show(menu_data) 
  77. 	Active_list:set_visible(false) 
  78. 	 
  79. 	-- display the grid 
  80. 	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) 
  81. 	Store_common_color_grid:set_visible(true) 
  82. 	Store_common_color_grid:nav_enable(true, "store_tattoo_color_select", "store_tattoo_color_grid_nav")	 
  83. 	Color_grid_data.alpha_select = menu_data.alpha_select	 
  84. 	 
  85. 	-- Disable the mouse for the active list when showing the color grid 
  86. 	if Mouse_input_tracker ~= 0 then 
  87. 		Mouse_input_tracker:subscribe(false) 
  88. 	end 
  89. 	Current_tier = COLOR_TIER 
  90. end 
  91.  
  92. function store_tattoo_color_grid_nav(event, value) 
  93. 	store_tattoo_grid_nav(event, value) 
  94. 	 
  95. 	-- set the color and preview the item 
  96. 	local idx = Store_common_color_grid:return_selected_index() 
  97. 	Store_tattoo_current_color = Color_grid_data[idx].index 
  98. 	 
  99. 	if Store_tattoo_nav_thread ~= -1 then 
  100. 		thread_kill(Store_tattoo_nav_thread) 
  101. 		Store_tattoo_nav_thread = -1 
  102. 	end 
  103. 	 
  104. 	Store_tattoo_nav_thread = thread_new("store_tattoo_item_delayed_set")	 
  105. end 
  106.  
  107. function store_tattoo_add_color(color_index, label_crc, label_str, red, green, blue, max_colors, is_current) 
  108. 	local grid_idx = #Color_grid_data + 1 
  109. 	 
  110. 	Color_grid_data[grid_idx] = { 
  111. 		icon = "ui_menu_veh_pnt_base", 
  112. 		label = label_str, 
  113. 		label_crc = label_crc, 
  114. 		color = {red = red, green = green, blue = blue}, 
  115. 		index = color_index, 
  116. 	} 
  117. 	 
  118. 	if is_current == true then 
  119. 		Color_grid_idx = grid_idx 
  120. 		Store_tattoo_current_color = Color_grid_data[grid_idx].index 
  121. 	end 
  122. end 
  123.  
  124. function store_tattoo_purchase() 
  125. 	store_tattoo_enable_mouse(false) 
  126.  
  127. 	-- Are we short on cash? 
  128. 	if Store_tattoo_current_price ~= nil and Store_tattoo_current_price > Store_common_player_cash then 
  129. 		Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  130. 		Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  131. 		Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")		 
  132. 		Store_common_popup:nav_enable(true, "store_tattoo_fail_msg", "store_tattoo_popup_nav") 
  133. 		Not_popup_grp:set_alpha(.5)	 
  134. 		return 
  135. 	end 
  136. 	 
  137. 	-- Make sure they want to buy this 
  138. 	Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  139. 	Store_common_popup:set_title("STORE_TITLE_PURCHASING") 
  140. 	Store_common_popup:set_text("STORE_TEXT_CONFIRM_PURCHASE_BLANK")				 
  141. 	Store_common_popup:nav_enable(true, "store_tattoo_item_purchase_final", "store_tattoo_popup_nav") 
  142. 	Not_popup_grp:set_alpha(.5)	 
  143. end 
  144.  
  145. function store_tattoo_color_select(event) 
  146. 	Store_common_color_grid:nav_enable(false, nil, nil) 
  147. 	Store_common_color_grid:set_visible(false) 
  148. 	Active_list:set_visible(true) 
  149.  
  150. 	Current_tier = MENU_TIER 
  151. 	 
  152. 	-- Did the player select a color? 
  153. 	if not (event == "select" or event == "mouse_click") then 
  154. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  155. 		store_tattoo_enable_mouse(true) 
  156. 	else 
  157. 		game_UI_audio_play("UI_Main_Menu_Select") 
  158. 		if Color_grid_data.alpha_select then 
  159. 			store_tattoo_composite_show_alpha_menu() 
  160. 		else 
  161. 			-- Disable mouse input for active_list and hint_bar 
  162. 			store_tattoo_enable_mouse(false) 
  163. 			store_tattoo_purchase() 
  164. 		end 
  165. 	end 
  166. end 
  167.  
  168. -- Finalize or cancel a purchase based on the result of the confirmation question. 
  169. -- 
  170. function store_tattoo_item_purchase_final(event) 
  171.  
  172. 	Store_common_popup:nav_enable(false, nil, nil) 
  173. 	Not_popup_grp:set_alpha(1) 
  174. 	 
  175. 	-- Re-enable the mouse for disabled elements 
  176. 	store_tattoo_enable_mouse(true) 
  177. 	 
  178. 	-- The user hit the B button and are cancelling the purchase 
  179. 	-- This is redundant to selecting "No" in the list 
  180. 	if event == "back" then 
  181. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  182. 		return 
  183. 	end 
  184. 	 
  185. 	game_UI_audio_play("UI_Main_Menu_Select") 
  186. 	 
  187. 	-- Did we select yes?  This assumes yes is the first item 
  188. 	if Store_common_popup:get_selected_data() ~= 1 then 
  189. 		return 
  190. 	end 
  191.  
  192. 	-- award respect and actually purchase the item 
  193. 	if Store_tattoo_current_respect ~= nil then 
  194. 		game_award_respect(Store_tattoo_current_respect, nil, nil, true) 
  195. 	end 
  196. 	 
  197. 	if Store_tattoo_current_price ~= nil then 
  198. 		pcr_purchase_tattoo(Store_tattoo_current_price) 
  199. 	end 
  200. 	 
  201. 	Store_tattoo_reverted = {}	 
  202. 	 
  203. 	ui_audio_post_event("tattoo_purchase") 
  204. 	 
  205. 	store_tattoo_header_revert() 
  206. 	store_common_back_menu()	 
  207. 	store_common_back_menu()	 
  208. 	 
  209. 	-- do this so holding down the button doesn't cause repeated actions 
  210. 	Input_tracker:subscribe(false)		 
  211. 	Input_tracker:subscribe(true)		 
  212. end 
  213.  
  214. function store_tattoo_fail_msg(event) 
  215. 	Store_common_popup:nav_enable(false, nil, nil) 
  216. 	game_UI_audio_play("UI_Main_Menu_Select") 
  217. 	Not_popup_grp:set_alpha(1) 
  218. 	 
  219. 	-- Re-enable the mouse for active_list and hint_bar 
  220. 	store_tattoo_enable_mouse(true) 
  221. end 
  222.  
  223. function store_tattoo_popup_nav(event, value) 
  224. 	 
  225. 	if event == "mouse_move" then 
  226. 		vint_set_mouse_cursor("") 
  227. 	end 
  228. 	if event == "nav_up" then	 
  229. 		Store_common_popup.list:move_cursor(-1)	 
  230. 	elseif event == "nav_down" then 
  231. 		Store_common_popup.list:move_cursor(1) 
  232. 	elseif event == "mouse_move" then 
  233. 		-- value contains the target_handle in this case 
  234. 		local new_index = Store_common_popup.list:get_button_index(value) 
  235. 		if new_index ~= 0 then 
  236. 			Store_common_popup.list:set_selection(new_index) 
  237. 			Store_common_popup.list:move_cursor(0, true) 
  238. 		end 
  239. 	else 
  240. 		--do nothing 
  241. 	end 
  242. 		 
  243. end	 
  244. 	 
  245.  
  246. function store_tattoo_item_set(menu_data)	 
  247.  
  248. 	if menu_data.tattoo_item ~= -1 then 
  249. 		if menu_data.colorized then 
  250. 			store_tattoo_color_grid_show(menu_data) 
  251. 		else 
  252. 			if menu_data.alpha_select then 
  253. 				store_tattoo_composite_show_alpha_menu() 
  254. 			else 
  255. 				store_tattoo_purchase() 
  256. 			end 
  257. 		end 
  258. 	else 
  259. 		store_common_back_menu() 
  260. 	end 
  261. end 
  262.  
  263. function store_tattoo_item_revert() 
  264.  
  265. 	-- If a set operation hasn't been enacted yet, we need to cancel it first. 
  266. 	if Store_tattoo_nav_thread ~= -1 then 
  267. 		thread_kill(Store_tattoo_nav_thread) 
  268. 		Store_tattoo_nav_thread = -1 
  269. 	end 
  270.  
  271. 	for index, revert_item in pairs(Store_tattoo_reverted) do 
  272. 		pcr_change_composite(revert_item.area, revert_item.index, revert_item.color, revert_item.alpha) 
  273. 	end 
  274. 	Store_tattoo_reverted = {} 
  275. 	 
  276. 	store_tattoo_header_revert()	 
  277. end 
  278.  
  279. function store_tattoo_item_delayed_set() 
  280. 	delay(0.4) 
  281. 	pcr_change_composite(Store_tattoo_current_area, Store_tattoo_current_item, Store_tattoo_current_color) 
  282. 	Store_tattoo_nav_thread = -1 
  283. end 
  284.  
  285. function store_tattoo_item_nav(menu_data) 
  286. 	if Store_tattoo_nav_thread ~= -1 then 
  287. 		thread_kill(Store_tattoo_nav_thread) 
  288. 		Store_tattoo_nav_thread = -1 
  289. 	end 
  290. 	 
  291. 	Store_tattoo_current_price = menu_data.price 
  292. 	Store_tattoo_current_respect = menu_data.respect	 
  293. 	 
  294. 	Store_header:set_price(menu_data.price) 
  295. 	Store_header:set_respect(menu_data.respect) 
  296. 	 
  297. 	Store_tattoo_current_item = menu_data.tattoo_item 
  298. 	Store_tattoo_nav_thread = thread_new("store_tattoo_item_delayed_set") 
  299. end 
  300.  
  301. function store_tattoo_item_add(tattoo_index, name_crc, name_str, current, colorized, alpha_select, price, respect) 
  302. 	local item = { 
  303. 		type = TYPE_BUTTON, tattoo_item = tattoo_index, label = name_str, label_crc = name_crc, on_nav = store_tattoo_item_nav,  price = price, respect = respect, 
  304. 		on_select = store_tattoo_item_set, on_cancel = store_tattoo_item_revert, colorized = colorized, alpha_select = alpha_select, 
  305. 	} 
  306.  
  307. 	if item.price == 0 then 
  308. 		item.price = nil 
  309. 	end 
  310. 	 
  311. 	if item.respect == 0 then 
  312. 		item.respect = nil 
  313. 	end 
  314. 	 
  315. 	local menu_idx = #Store_tattoo_building_menu + 1 
  316. 	 
  317. 	if current == true then 
  318. 		Store_tattoo_building_menu.start_index = menu_idx 
  319. 		Store_tattoo_current_item = tattoo_index 
  320. 		 
  321. 		Store_tattoo_current_price = price 
  322. 		Store_tattoo_current_respect = respect	 
  323. 		 
  324. 		Store_header:set_price(price) 
  325. 		Store_header:set_respect(respect)		 
  326. 	end 
  327.  
  328. 	Store_tattoo_building_menu[menu_idx] = item 
  329. end 
  330.  
  331. function store_tattoo_menu_build(menu_data) 
  332.  
  333. 	Store_tattoo_reverted = {} 
  334.  
  335. 	if menu_data.tattoo_area ~= nil then 
  336. 		Store_tattoo_current_area = menu_data.tattoo_area 
  337. 	else 
  338. 		return 
  339. 	end 
  340. 	 
  341. 	-- We need to store values to restore in case player cancels/reverts.  We do this for the 
  342. 	-- current tattoo area, and any areas that this one "replaces" (overlaps).  We then clear 
  343. 	-- out any "replaced" tatttoos. 
  344. 		 
  345. 	local index, color, alpha = pcr_get_composite_info(Store_tattoo_current_area) 
  346. 	local revert_item = { area = Store_tattoo_current_area, index = index, color = color, alpha = alpha } 
  347. 	Store_tattoo_reverted[#Store_tattoo_reverted + 1] = revert_item 
  348. 	 
  349. 	-- SEH 6/22/2011 - FrankM said we shouldn't replace other tattoo slots; they should be allowed to overlap 
  350. 	-- if menu_data.replace ~= nil then 
  351. 		-- for key, area in pairs(menu_data.replace) do 
  352. 			-- local index, color = pcr_get_composite_info(area) 
  353. 			-- local revert_item = { area = area, index = index, color = color, alpha = alpha } 
  354. 			-- Store_tattoo_reverted[#Store_tattoo_reverted + 1] = revert_item 
  355. 	 
  356. 			-- pcr_change_composite(area, -1, 0) 
  357. 		-- end 
  358. 	-- end	 
  359. 	 
  360. 	-- Get the colors for the palette. 
  361. 	-- We need to do this now, because we need to find and save off the current tattoo the player has in case they revert. 
  362. 	Color_grid_data = {} 
  363. 	Color_grid_idx = 1 
  364. 	Store_tattoo_current_color = -1 
  365.  
  366. 	pcr_report_composite_colors(Store_tattoo_current_area, true, "store_tattoo_add_color")		 
  367. 	 
  368. 	Store_tattoo_building_menu = menu_data.sub_menu 
  369. 	Store_tattoo_current_item = -1 
  370. 	Store_tattoo_current_alpha = 1	 
  371. 	 
  372. 	local item = { 
  373. 		label = "CUST_ITEM_NOTHING", type = TYPE_BUTTON, tattoo_item = -1, on_nav = store_tattoo_item_nav, 
  374. 		on_select = store_tattoo_item_set, on_cancel = store_tattoo_item_revert, 
  375. 	} 
  376. 		 
  377. 	local menu_idx = #Store_tattoo_building_menu + 1 
  378. 	Store_tattoo_building_menu[menu_idx] = item 
  379. 	 
  380. 	pcr_report_composite_items(Store_tattoo_current_area, "store_tattoo_item_add") 
  381. 	 
  382. end 
  383.  
  384.  
  385. -- Main menu 
  386. -------------------------------------------- 
  387.  
  388. function store_tattoo_exit_final(event) 
  389. 	Store_common_popup:nav_enable(false, nil, nil) 
  390. 	 
  391. 	-- The user hit the B button and is exiting 
  392. 	-- This is redundant to selecting "No" in the list 
  393. 	if event == "back" then 
  394. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  395. 		Not_popup_grp:set_alpha(1) 
  396. 		store_tattoo_enable_mouse(true) 
  397. 		return 
  398. 	end 
  399. 	 
  400. 	game_UI_audio_play("UI_Main_Menu_Select")	 
  401. 	 
  402. 	-- Did we select yes?  This assumes yes is the first item 
  403. 	if Store_common_popup:get_selected_data() ~= 1 then 
  404. 		Not_popup_grp:set_alpha(1) 
  405. 		store_tattoo_enable_mouse(true) 
  406. 		return 
  407. 	end 
  408. 	 
  409. 	ui_audio_post_event("UI_Store_Exit") 
  410. 	 
  411. 	store_lock_controls() 
  412. 	 
  413. 	Not_popup_grp:set_alpha(0) 
  414. 	 
  415. 	-- exit the interface 
  416. 	 
  417. 	local anim_out = Vdo_anim_object:new("tattoo_bg_anim_out", 0, Store_tattoo_doc_handle) 
  418. 	anim_out:play(0) 
  419.  
  420. 	pop_screen() 
  421. 	 
  422. end 
  423.  
  424. -- Player has requested to leave the store.  Get confirmation before doing so. 
  425. -- 
  426. function store_tattoo_exit(menu_data) 
  427.  
  428. 	local body = "STORE_EXIT_WARNING_BODY" 
  429. 	local heading = "MENU_TITLE_WARNING" 
  430. 	 
  431. 	Store_common_popup:populate_list(Yes_no_choices, 2, STORE_COMMON_LIST_SIZE, 2)	 
  432. 	Store_common_popup:set_title(heading) 
  433. 	Store_common_popup:set_text(body)		 
  434. 	Store_common_popup:nav_enable(true, "store_tattoo_exit_final", "store_tattoo_popup_nav") 
  435. 	Not_popup_grp:set_alpha(.5) 
  436. 	 
  437. 	-- Disable mouse input for other items while the popup is up 
  438. 	store_tattoo_enable_mouse(false)	 
  439. end 
  440.  
  441. -- We have returned to the top level menu.  Currently restores camera position and 
  442. -- makes sure the thread for preset updates is killed. 
  443. -- 
  444. function store_tattoo_return_main(menu_data) 
  445. 	store_set_camera_pos("body")	 
  446. end 
  447.  
  448. function store_tattoo_set_start_camera() 
  449. 	if Store_tattoo_init_camera_moved == false then 
  450. 		store_set_camera_pos("body")	 
  451. 		store_start_lighting_change() 
  452. 		Store_tattoo_init_camera_moved = true 
  453. 	end 
  454. end 
  455.  
  456. local Store_tattoo_head = { 
  457. 	{ label = "CUST_TATTOO_HEAD_TOP", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo head", camera = "head top", }, 
  458. 	{ label = "CUST_TATTOO_NECK", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo neck", camera = "neck", }, 
  459. } 
  460.  
  461. local Store_tattoo_upper_body = { 
  462. 	{ label = "CUST_TATTOO_ENTIRE_BACK", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo entire back", camera = "entire back", 
  463. 	  replace = { "tattoo upper back", "tattoo lower back" }, }, 
  464. 	{ label = "CUST_TATTOO_UPPER_BACK", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo upper back", camera = "upper back", 
  465. 	  replace = { "tattoo entire back" }, }, 
  466. 	{ label = "CUST_TATTOO_LOWER_BACK", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo lower back", camera = "lower back",	 
  467. 	  replace = { "tattoo entire back" }, }, 
  468. 	   
  469. 	{ label = "CUST_TATTOO_ENTIRE_CHEST", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo entire chest", camera = "entire chest", 
  470. 	  replace = { "tattoo upper chest", "tattoo lower chest" }, }, 
  471. 	{ label = "CUST_TATTOO_UPPER_CHEST", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo upper chest", camera = "upper chest", 
  472. 	  replace = { "tattoo entire chest" }, },	 
  473. 	{ label = "CUST_TATTOO_LOWER_CHEST", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo lower chest", camera = "lower chest", 
  474. 	  replace = { "tattoo entire chest" }, },	 
  475. } 
  476.  
  477. local Store_tattoo_arms = { 
  478. 	{ label = "CUST_TATTOO_ENTIRE_ARM_RIGHT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo entire arm right", camera = "entire arm right", 
  479. 	  replace = { "tattoo upper arm right", "tattoo lower arm right", "tattoo hand right" }, }, 
  480. 	{ label = "CUST_TATTOO_UPPER_ARM_RIGHT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo upper arm right", camera = "upper arm right", 
  481. 	  replace = { "tattoo entire arm right" }, },	 
  482. 	{ label = "CUST_TATTOO_LOWER_ARM_RIGHT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo lower arm right", camera = "lower arm right", 
  483. 	  replace = { "tattoo entire arm right" }, },	 
  484. 	{ label = "CUST_TATTOO_HAND_RIGHT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo hand right", camera = "hand left", 
  485. 	  replace = { "tattoo entire arm right" }, },		 
  486. 	 
  487. 	{ label = "CUST_TATTOO_ENTIRE_ARM_LEFT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo entire arm left", camera = "entire arm left",	 
  488. 	  replace = { "tattoo upper arm left", "tattoo lower arm left", "tattoo hand left" }, }, 
  489. 	{ label = "CUST_TATTOO_UPPER_ARM_LEFT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo upper arm left", camera = "upper arm left", 
  490. 	  replace = { "tattoo entire arm left" }, },		 
  491. 	{ label = "CUST_TATTOO_LOWER_ARM_LEFT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo lower arm left", camera = "lower arm left", 
  492. 	  replace = { "tattoo entire arm left" }, },		 
  493. 	{ label = "CUST_TATTOO_HAND_LEFT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo hand left", camera = "hand left", 
  494. 	  replace = { "tattoo entire arm left" }, },		 
  495. } 
  496.  
  497. local Store_tattoo_legs = { 
  498. 	{ label = "CUST_TATTOO_ENTIRE_LEG_RIGHT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo leg right", camera = "entire leg right", },	 
  499. 	{ label = "CUST_TATTOO_ENTIRE_LEG_LEFT", type = TYPE_BUTTON, on_sub_menu_fill = store_tattoo_menu_build, tattoo_area = "tattoo leg left", camera = "entire leg left", },	 
  500. } 
  501.  
  502. local Store_tattoo_main_menu = { 
  503. 	on_enter = store_tattoo_return_main, 
  504.  
  505. 	{ label = "CUST_TATTOO_HEAD", type = TYPE_BUTTON, sub_menu = Store_tattoo_head }, 
  506. 	{ label = "CUST_TATTOO_UPPER_BODY", type = TYPE_BUTTON, sub_menu = Store_tattoo_upper_body },	 
  507. 	{ label = "CUST_TATTOO_ARMS", type = TYPE_BUTTON, sub_menu = Store_tattoo_arms },	 
  508. 	{ label = "CUST_TATTOO_LEGS", type = TYPE_BUTTON, sub_menu = Store_tattoo_legs },		 
  509. 	{ label = "STORE_EXIT", type = TYPE_BUTTON, on_select = store_tattoo_exit } 
  510. } 
  511.  
  512. ---------------------------------------------------------------------------  
  513. -- Initialize Tattoo Store 
  514. --------------------------------------------------------------------------- 
  515. function store_tattoo_init() 
  516.  
  517. 	Store_common_current_highlight_color = COLOR_PLAYER_CREATION_PRIMARY 
  518. 	 
  519. 	-- Find doc handle 
  520. 	Store_tattoo_doc_handle = vint_document_find("store_tattoo") 
  521.  
  522. 	-- Set up some callbacks for the common store script 
  523. 	Store_common_populate_list_cb = store_tattoo_populate_list 
  524. 	Store_common_exit_cb				= store_tattoo_exit 
  525.  
  526. 	store_lock_controls() 
  527. 	 
  528. 	-- Save the platform and set up the hint_bar mouse input 
  529. 	Game_platform = game_get_platform() 
  530. 	if Game_platform == "PC" then 
  531. 		Hint_bar_mouse_input_tracker = Vdo_input_tracker:new() 
  532. 	end 
  533. 	 
  534. 	--Setup Button Hints 
  535. 	local hint_data = { 
  536. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  537. 	} 
  538. 	Store_common_hint_bar:set_hints(hint_data)  
  539. 	Store_common_hint_bar:set_visible(true)	 
  540. 	 
  541. 	local hint_rotate_data = { 
  542. 		{CTRL_BUTTON_RS, "STORE_ZOOM_ROTATE"}, 
  543. 	} 
  544. 	Store_common_rotate_hint:set_hints(hint_rotate_data) 	 
  545. 	Store_common_rotate_hint:enable_text_shadow(true) 
  546. 	Store_common_rotate_hint:set_visible(true) 
  547. 	if game_get_platform() == "PC" then 
  548. 		Store_common_rotate_hint:set_visible(false) 
  549. 	end	 
  550. 	 
  551. 	Store_header:set_visible(true)		 
  552. 		 
  553. 	-- Everything that is not in the popup so we can fade it when the popup is active 
  554. 	Not_popup_grp = Vdo_base_object:new("not_popup_grp", 0, Store_common_doc_handle) 
  555.  
  556. 	-- Setup purchase popup 
  557. 	Store_common_popup:set_visible(false) 
  558. 	Store_common_popup:set_size(STORE_COMMON_LIST_SIZE, (LIST_BUTTON_HEIGHT * 5) + (LIST_BUTTON_SPACE * 5)) 
  559. 	 
  560. 	-- Setup Color grid 
  561. 	Store_common_color_grid:set_visible(false) 
  562. 	Store_common_color_grid:set_ui_screen("store_tattoo") 
  563. 	 
  564. 	-- Populate the areas and draw the first menu 
  565. 	Menu_data = Store_tattoo_main_menu 
  566. 	 
  567. 	-- Pass the table data to the megalist vdo. 
  568. 	store_tattoo_populate_list(Menu_data, 1) 
  569. 	 
  570. 	-- Hide background animations 
  571. 	--local player_creation_grp = Vdo_base_object:new("player_creation_grp", 0, Store_tattoo_doc_handle) 
  572. 	--player_creation_grp:set_visible(false)	 
  573.  
  574. 	local color_primary, color_secondary, color_tertiary 
  575. 	 
  576. 	-- Change colors for player creation 
  577. 	color_primary = COLOR_PLAYER_CREATION_PRIMARY 
  578. 	color_secondary = COLOR_PLAYER_CREATION_SECONDARY 
  579. 	color_tertiary = COLOR_PLAYER_CREATION_TERTIARY		 
  580.  
  581. 	-- Set background animations  
  582. 	Store_tattoo_in_anim = Vdo_anim_object:new("store_common_in_anim", 0, Store_common_doc_handle)		 
  583. 		 
  584. 	local anim_in = Vdo_anim_object:new("tattoo_bg_anim_in", 0, Store_tattoo_doc_handle) 
  585. 	local tattoo_bg_anim = Vdo_anim_object:new("tattoo_bg_anim", 0, Store_tattoo_doc_handle)	 
  586. 	local skull_anim = Vdo_anim_object:new("skull_anim", 0, Store_tattoo_doc_handle)	 
  587. 	local rustys_anim = Vdo_anim_object:new("rustys_anim", 0, Store_tattoo_doc_handle)	 
  588. 	local needle_anim = Vdo_anim_object:new("needle_anim", 0, Store_tattoo_doc_handle)	 
  589. 	local end_event_twn = Vdo_tween_object:new("end_event_twn", Store_tattoo_in_anim.handle) 
  590. 	 
  591. 	local twn_h = vint_object_find("new_tween10", anim_in.handle) 
  592. 	vint_set_property(twn_h, "end_event", "store_tattoo_bg_anim_done") 
  593. 	 
  594. 	end_event_twn:set_end_event("store_unlock_controls") 
  595. 	 
  596. 	vint_apply_start_values(Store_tattoo_in_anim.handle) 
  597. 	vint_apply_start_values(skull_anim.handle) 
  598. 	vint_apply_start_values(rustys_anim.handle) 
  599. 	vint_apply_start_values(needle_anim.handle) 
  600. 	 
  601. 	-- Start animations now 
  602. 	Store_tattoo_in_anim:play(0) 
  603. 	anim_in:play(0) 
  604. 	tattoo_bg_anim:play(0) 
  605. 	skull_anim:play(0) 
  606. 	rustys_anim:play(0) 
  607. 	needle_anim:play(0) 
  608. 	 
  609. 	ui_audio_post_event("enter_rustys_needle") 
  610. 	 
  611. 	--Player_creation_bg_anim:play(0) 
  612. 		 
  613. 	-- Set colors 
  614. 	Store_header:set_color(color_primary, color_secondary, color_tertiary)		 
  615. 	Active_list:set_highlight_color(color_primary, color_secondary, color_tertiary)		 
  616. 	Store_common_color_grid:set_highlight_color(color_primary, color_secondary, color_tertiary)		 
  617. 	Store_common_popup:set_color(color_primary, color_secondary, color_tertiary)	 
  618. 	 
  619. 	-- SEH: not hiding hair now, but we may want to add this back, at least for tattoos on the head. 
  620. 	-- save hair settings, then remove hair 
  621. 	--store_tattoo_hair_save_current() 
  622. 	--pcr_change_hair(STORE_CHARACTER_HAIR_AREA_HEAD, -1, 1, 1) 
  623. 	 
  624. 	character_enable_mouse_drag(true) 
  625. end 
  626.  
  627. function store_lock_controls() 
  628. 	Input_tracker:subscribe(false) 
  629. 	store_tattoo_enable_mouse(false) 
  630. end 
  631.  
  632. function store_unlock_controls() 
  633. 	Input_tracker:subscribe(true) 
  634. 	store_tattoo_enable_mouse(true) 
  635. end 
  636.  
  637. ---------------------------------------------------------------------------  
  638. -- Cleanup Tattoo Store 
  639. --------------------------------------------------------------------------- 
  640. function store_tattoo_cleanup() 
  641.  
  642. 	-- revert any pending changes 
  643. 	store_tattoo_item_revert()	 
  644.  
  645. 	-- Nuke all button subscriptions 
  646. 	Input_tracker:subscribe(false) 
  647. 	store_tattoo_enable_mouse(false) 
  648. 	 
  649. 	character_enable_mouse_drag(false) 
  650. 	 
  651. 	-- Some things need to be cleaned up right away when a store doc is unloading, particular disabled inputs which have 
  652. 	-- callbacks to the script that is unloading. 
  653. 	store_common_cleanup_current_store() 
  654. end 
  655.  
  656. -- Populate the active megalist menu, and hide the previous menu 
  657. -- 
  658. -- list_data: 		this table contains the data to populate the megalist 
  659. -- current_index: 	the current index in the menu that's selected 
  660. -- 
  661. function store_tattoo_populate_list(list_data, current_index) 
  662. 	Active_list:draw_items(list_data, current_index, STORE_COMMON_LIST_SIZE, 12, SCALE_FONT_STORE_TATTOO_LIST) 
  663. 	Active_list:set_visible(true) 
  664. 	 
  665. 	-- Update the hint bar 
  666. 	store_tattoo_set_hints(list_data) 
  667. 	 
  668. 	-- Add mouse inputs for active_list 
  669. 	if Game_platform == "PC" then 
  670. 		Mouse_input_tracker:remove_all() 
  671. 		 
  672. 		Active_list:set_store("store_tattoo") 
  673. 		Active_list:add_mouse_inputs("store_common", Mouse_input_tracker) 
  674. 		store_tattoo_enable_mouse(true) 
  675. 	end 
  676. end 
  677.  
  678. -- Sets up the hint buttons 
  679. -- 
  680. function store_tattoo_set_hints(list_data) 
  681.  
  682. 	-- build hint data 
  683. 	local hint_data = {} 
  684. 	local hint_count = 0 
  685.  
  686. 	-- If all the items in the menu are sliders (no submenus) then add an "accept" hint 
  687. 	-- restore all to original values 
  688. 	local has_buttons = false 
  689. 	for i = 1, #list_data do 
  690. 		if list_data[i].type == TYPE_BUTTON then 
  691. 			has_buttons = true 
  692. 		end 
  693. 	end 
  694. 	 
  695. 	if has_buttons == false then 
  696. 		hint_count = hint_count + 1 
  697. 		hint_data[hint_count] = {CTRL_MENU_BUTTON_A, "PAUSE_MENU_ACCEPT"} 
  698. 	end 
  699.  
  700. 	-- add back choice 
  701. 	-- Are we on the main screen? 
  702. 	local back_hint 
  703. 	if store_common_stack_get_menu() ~= nil then 
  704. 		back_hint = {CTRL_MENU_BUTTON_B, "MENU_BACK"} 
  705. 	else 
  706. 		back_hint = {CTRL_MENU_BUTTON_B, "STORE_EXIT"}	 
  707. 	end	 
  708. 	 
  709. 	hint_count = hint_count + 1 
  710. 	hint_data[hint_count] = back_hint 
  711. 	 
  712. 	Store_common_hint_bar:set_hints(hint_data) 
  713. 	 
  714. 	-- Add mouse input subscriptions 
  715. 	if Game_platform == "PC" then 
  716. 		Hint_bar_mouse_input_tracker:remove_all() 
  717. 		 
  718. 		Store_common_hint_bar:add_mouse_inputs("store_tattoo", Hint_bar_mouse_input_tracker) 
  719. 		Hint_bar_mouse_input_tracker:subscribe(true) 
  720. 	end 
  721. 	 
  722. 	local hint_rotate_data = { 
  723. 		{CTRL_BUTTON_RS, "STORE_ZOOM_ROTATE"}, 
  724. 	} 
  725. 	Store_common_rotate_hint:set_hints(hint_rotate_data)  
  726. 	if game_get_platform() == "PC" then 
  727. 		Store_common_rotate_hint:set_visible(false) 
  728. 	end 
  729. end 
  730.  
  731. -- Handle navigating grid 
  732. function store_tattoo_grid_nav(event, value) 
  733.  
  734. 	if event == "nav_up" then	 
  735. 		Store_common_color_grid:move_cursor(-2)	 
  736. 	elseif event == "nav_down" then 
  737. 		Store_common_color_grid:move_cursor(2) 
  738. 	elseif event == "nav_left" then 
  739. 		Store_common_color_grid:move_cursor(-1) 
  740. 	elseif event == "nav_right" then 
  741. 		Store_common_color_grid:move_cursor(1) 
  742. 	elseif event == "mouse_move" then 
  743. 		-- value contains the target_handle in this case 
  744. 		local new_index = Store_common_color_grid:get_data_index(value) 
  745. 		if new_index ~= 0 then 
  746. 			Store_common_color_grid:set_selection(new_index) 
  747. 			Store_common_color_grid:move_cursor(0, false, true) 
  748. 		end 
  749. 	 
  750. 	else 
  751. 		--do nothing 
  752. 	end 
  753. end 
  754.  
  755. function store_tattoo_header_revert(menu_data) 
  756. 	Store_header:set_price(nil) 
  757. 	Store_header:set_respect(nil) 
  758. end 
  759.  
  760. -- Save off the player's current hair settings into the table Store_character_hair_values 
  761. -- 
  762. function store_tattoo_hair_save_current() 
  763.  
  764. 	for i = STORE_CHARACTER_HAIR_AREA_BEGIN, STORE_CHARACTER_HAIR_AREA_END do 
  765. 		if i == STORE_CHARACTER_HAIR_AREA_HEAD then		 
  766. 			Store_character_hair_values[i].style, Store_character_hair_values[i].primary, Store_character_hair_values[i].secondary = pcr_get_hair_info(i) 
  767. 		end 
  768. 		 
  769. 		-- SEH -- work around? 
  770. 		if Store_character_hair_values[i].style == -2 then 
  771. 			Store_character_hair_values[i].style = -1 
  772. 		end 
  773. 	end 
  774. end 
  775.  
  776. -- Restore hair settings from current saved values 
  777. -- 
  778. function store_character_hair_revert_to_saved() 
  779.  
  780. 	for i = STORE_CHARACTER_HAIR_AREA_BEGIN, STORE_CHARACTER_HAIR_AREA_END do 
  781. 		if i == STORE_CHARACTER_HAIR_AREA_HEAD then 
  782. 			pcr_change_hair(i, Store_character_hair_values[i].style, Store_character_hair_values[i].primary, Store_character_hair_values[i].secondary) 
  783. 		end 
  784. 	end 
  785. end 
  786.  
  787. function store_tattoo_bg_anim_done() 
  788. 	store_common_bg_anim_complete() 
  789. end 
  790.  
  791. -- ===================================== 
  792. --       Mouse Specific Functions 
  793. -- ===================================== 
  794. function store_tattoo_enable_mouse(enable) 
  795. 	if Game_platform == "PC" and enable ~= nil then 
  796. 		if Mouse_input_tracker ~= 0 then 
  797. 			Mouse_input_tracker:subscribe(enable) 
  798. 		end 
  799. 		 
  800. 		if Hint_bar_mouse_input_tracker ~= nil then 
  801. 			Hint_bar_mouse_input_tracker:subscribe(enable) 
  802. 		end 
  803. 	end 
  804. end 
  805.  
  806. function store_tattoo_mouse_click(event, target_handle) 
  807. 	local hint_index = Store_common_hint_bar:get_hint_index(target_handle) 
  808. 	if hint_index ~= 0 then 
  809. 		if Store_common_hint_bar.hint_data[hint_index][1] == CTRL_MENU_BUTTON_B then 
  810. 			if Current_tier == MENU_TIER then 
  811. 				store_common_button_b() 
  812. 			elseif Current_tier == COLOR_TIER then 
  813. 				store_tattoo_color_select("back") 
  814. 			end 
  815. 		elseif Store_common_hint_bar.hint_data[hint_index][1] == CTRL_MENU_BUTTON_A then 
  816. 			store_common_button_a() 
  817. 		else 
  818. 			-- Should never get here (figure out what caused it and add case for it) 
  819. 			store_common_button_b() 
  820. 		end 
  821. 	end 
  822. end 
  823.  
  824. function store_tattoo_mouse_move(event, target_handle) 
  825.  
  826. 	vint_set_mouse_cursor("") 
  827. 	store_common_mouse_zoom(0.0) 
  828.  
  829. 	Store_common_hint_bar:set_highlight(0) 
  830. 	 
  831. 	local hint_index = Store_common_hint_bar:get_hint_index(target_handle) 
  832. 	if hint_index ~= 0 then 
  833. 		Store_common_hint_bar:set_highlight(hint_index, Store_common_current_highlight_color) 
  834. 	end 
  835. 	 
  836. 	local old_index = Active_list:get_selection() 
  837. 	local new_index = Active_list:get_button_index(target_handle) 
  838. 	if new_index ~= 0 and new_index ~= old_index then 
  839. 		Active_list:set_selection(new_index) 
  840. 		Active_list:move_cursor(0, true) 
  841. 		 
  842. 		-- If the item has a callback for navigation, do it (such as putting clothes on) 
  843. 		local data_item = Active_list:return_selected_data() 
  844. 		if data_item.on_nav ~= nil then 
  845. 			data_item.on_nav(data_item) 
  846. 		end 
  847. 		return 
  848. 	end 
  849. end 
  850.  
  851. function store_tattoo_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines) 
  852. 	if scroll_lines ~= 0 then 
  853. 		if Store_common_color_grid.bg.handle == target_handle then 
  854. 			Store_common_color_grid:scroll_list(scroll_lines * -1) 
  855. 		end 
  856. 	end 
  857. end 
  858.  
  859. function store_tattoo_mouse_drag(event, target_handle, mouse_x, mouse_y) 
  860. 	if Store_common_color_grid.scrollbar.tab.handle == target_handle then 
  861. 		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)) 
  862. 		Store_common_color_grid:scroll_list(0, new_start_index) 
  863. 	end 
  864. end 
  865.  
  866. function store_tattoo_mouse_drag_release(event, target_handle, mouse_x, mouse_y) 
  867. 	if Store_common_color_grid.scrollbar.tab.handle == target_handle then 
  868. 		local start_row = Store_common_color_grid:get_visible_rows() 
  869. 		Store_common_color_grid.scrollbar:release_scrolltab(start_row, Store_common_color_grid.rows - (Store_common_color_grid.max_height - 1)) 
  870. 		Store_common_color_grid:update_mouse_inputs() 
  871. 	end 
  872. end 
  873.