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