sr2lua/weapon_store.lua

  1. ------------------ 
  2. -- WEAPON STORE -- 
  3. ------------------ 
  4. -- "global" variables 
  5. Weapon_menu_footer_ammo_meter_h 		= 0 
  6. Weapon_menu_footer_price_h 			= 0  
  7. Weapon_menu_footer_weapon_label_h 	= 0 
  8.  
  9. Weapon_store_menu_add_index = 0 
  10. Weapon_menu_cache_only = false 
  11. Weapon_menu_is_cache_menu = false 
  12. Weapon_menu_active_horz_menu = { } 
  13. Active_menu 					 = { } 
  14. Weapon_category_to_purchase = { } 
  15. Weapon_index_of_purchase 	 = { } 
  16.  
  17. Weapon_store_name = "MENU_SWAP_WEAPONS_STORE" 
  18. WEAPON_STORE_DOC_H = vint_document_find("weapon_store") 
  19.  
  20. ------------------ 
  21. --- ANIMATIONS --- 
  22. ------------------ 
  23. -- 
  24. Weapon_menu_anims = { 
  25. 	icon_highlight_anim_h = -1, 
  26. 	icon_dw_0_hl_anim_h = -1, 
  27. 	icon_dw_1_hl_anim_h = -1, 
  28. } 
  29.  
  30. ---------------------- 
  31. --	SYSTEM FUNCTIONS -- 
  32. ---------------------- 
  33. --[ INITIALIZE AND SHUTDOWN ]-- 
  34. ------------------------------- 
  35. --	Initialize the menu 
  36. function weapon_store_init() 
  37. 	 
  38. 	--Find and store animations 
  39. 	Weapon_menu_anims.icon_highlight_anim_h = vint_object_find("icon_highlight_anim") 
  40. 	Weapon_menu_anims.icon_dw_0_hl_anim_h = vint_object_find("icon_dw_0_hl_anim") 
  41. 	Weapon_menu_anims.icon_dw_1_hl_anim_h = vint_object_find("icon_dw_1_hl_anim") 
  42. 	Weapon_menu_anims.icon_purchase_anim_h = vint_object_find("icon_purchase_anim") 
  43.  
  44. 	 
  45. 	if Menu_swap_hud_hidden == true then 
  46. 		hud_hide(false) 
  47. 		Menu_swap_hud_hidden = false 
  48. 	end 
  49. 	 
  50. 	--Pause some of the anims 
  51. 	vint_set_property(Weapon_menu_anims.icon_purchase_anim_h, "is_paused", true) 
  52.  
  53. 	--Check what kind of interface mode we are in? weapons only? 
  54. 	Weapon_menu_cache_only = weapon_store_get_is_cache() 
  55. 	if Weapon_menu_cache_only == true then 
  56. 		Weapon_menu_is_cache_menu = true 
  57. 	end 
  58.  
  59. 	-- Only have the melee weapons available in Brass Knuckles 
  60. 	if weapon_store_is_melee_store() == true then 
  61. 		Weapon_store_horz_menu.num_items = 1 
  62. 		Weapon_store_horz_menu[0] = Weapon_store_horz_menu[1]	-- Swap melee with ammo 
  63. 	else 
  64. 		for i = 1, Weapon_store_horz_menu.num_items - 1 do 
  65. 			Weapon_store_horz_menu[i] = Weapon_store_horz_menu[i + 1] 
  66. 		end 
  67. 		Weapon_store_horz_menu.num_items = Weapon_store_horz_menu.num_items - 1 
  68. 	end 
  69. 	 
  70. 	--Event Tracking 
  71. 	if Weapon_menu_is_cache_menu == true then 
  72. 		event_tracking_interface_enter("Weapons Cache") 
  73. 	else 
  74. 		event_tracking_interface_enter("Weapons Store") 
  75. 	end 
  76. 	 
  77. 	weapons_store_show() 
  78. end 
  79.  
  80.  
  81. -- Shutdown and cleanup the menu 
  82. function weapon_store_cleanup() 
  83. end 
  84.  
  85. --[ EXIT ]-- 
  86. ------------ 
  87. function weapon_store_exit(menu_data) 
  88. 	local body 
  89. 	if Weapon_menu_cache_only == true then 
  90. 		body = "WPN_CACHE_EXIT_PROMPT" 
  91. 	else 
  92. 		-- Still might be a cache 
  93. 		if Weapon_menu_is_cache_menu then 
  94. 			body = "WPN_CACHE_EXIT_PROMPT" 
  95. 		else 
  96. 			-- We're not in cache 
  97. 			body = "WPN_STORE_EXIT_PROMPT" 
  98. 		end 
  99. 	end 
  100. 	 
  101. 	dialog_box_confirmation("MENU_TITLE_WARNING", body, "weapon_store_exit_confirm") 
  102. end 
  103.  
  104. function weapon_store_exit_confirm(result, action) 
  105. 	if action ~= DIALOG_ACTION_CLOSE then 
  106. 		return 
  107. 	end 
  108. 	 
  109. 	if result == 0 then 
  110. 		menu_close(weapon_store_exit_final) 
  111. 	end 
  112. end 
  113.  
  114. function weapon_store_exit_final() 
  115. 	vint_document_unload(WEAPON_STORE_DOC_H)	 
  116. end 
  117.  
  118. ----------------------- 
  119. -- MENU SWAPING 	  	-- 
  120. ----------------------- 
  121. function weapons_store_show() 
  122. 	local use_style = false 
  123. 	 
  124. 	if Weapon_menu_is_cache_menu == true then 
  125. 		Weapon_menu_active_horz_menu = Weapon_cache_horz_menu 
  126. 		Weapon_store_name = "MENU_SWAP_WEAPONS_CACHE" 
  127. 		 
  128. 		--Set Button tip Labels 
  129. 		Weapon_store_btn_tips.x_button.label = "MENU_SWAP_WEAPONS_STORE" 
  130. 	else 
  131. 		--Its a weapon store 
  132. 		Weapon_store_name = "MENU_SWAP_WEAPONS_STORE" 
  133. 		Weapon_menu_active_horz_menu = Weapon_store_horz_menu 
  134. 		-- RCS: 7/11/08, TDL 246474, weapon store no longer awards style points 
  135. --		use_style = true 
  136. 		 
  137. 		--Set Button tip Labels 
  138. 		Weapon_store_btn_tips.x_button.label = "MENU_SWAP_WEAPONS_CACHE" 
  139. 	end 
  140. 	 
  141. 	menu_store_init(use_style) 
  142. 	menu_init() 
  143. 	weapon_store_set_cache(Weapon_menu_is_cache_menu) 
  144. 	 
  145. 	menu_horz_init(Weapon_menu_active_horz_menu) 
  146. end 
  147.  
  148. function weapons_store_switch_mode() 
  149. 	if Weapon_menu_cache_only == true then 
  150. 		--Only can switch modes if we aren't weapons cache only 
  151. 		return 
  152. 	end 
  153. 	 
  154. 	if Weapon_store_name == "MENU_SWAP_WEAPONS_CACHE" then 
  155. 		Weapon_store_name = "MENU_SWAP_WEAPONS_STORE" 
  156. 		Weapon_menu_is_cache_menu = false 
  157. 	else 
  158. 		Weapon_store_name = "MENU_SWAP_WEAPONS_CACHE" 
  159. 		Weapon_menu_is_cache_menu = true 
  160. 	end 
  161. 	 
  162. 	menu_swap_interface(Weapon_store_name, weapons_store_show) 
  163. end 
  164.  
  165. ------------------------ 
  166. --	MENU FUNCTIONALITY -- 
  167. ------------------------ 
  168. function weapon_store_select_new_item(menu_label, menu_data) 
  169. 	local swatches = menu_data.swatches 
  170. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  171. 	local category = Weapon_menu_active_horz_menu[Weapon_menu_active_horz_menu.current_selection].category 
  172. 	if idx < swatches.num_swatches then 
  173. 		if Active_menu.footer_type ~= "ammo" then 
  174. 			weapon_store_footer_update(swatches[idx].label_str, -1, nil, swatches[idx].price, swatches[idx].owned) 
  175. 			weapon_store_change_weapon(category, swatches[idx].id, swatches[idx].dual_wield) 
  176. 		elseif Active_menu.footer_type == "ammo" then 
  177. 			local owned = false 
  178. 			if swatches[idx].ammo_current >= swatches[idx].ammo_max then 
  179. 				owned = true 
  180. 			end 
  181. 			 
  182. 			--Retrigger highlight animation 
  183. 			vint_set_property(Weapon_menu_anims.icon_highlight_anim_h, "target_handle", swatches[idx].swatch_h) 
  184. 			lua_play_anim(Weapon_menu_anims.icon_highlight_anim_h, 0) 
  185. 			vint_set_property(Weapon_menu_anims.icon_dw_0_hl_anim_h, "target_handle", swatches[idx].swatch_h) 
  186. 			lua_play_anim(Weapon_menu_anims.icon_dw_0_hl_anim_h, 0) 
  187. 			vint_set_property(Weapon_menu_anims.icon_dw_1_hl_anim_h, "target_handle", swatches[idx].swatch_h) 
  188. 			lua_play_anim(Weapon_menu_anims.icon_dw_1_hl_anim_h, 0) 
  189. 			 
  190. 			weapon_store_change_weapon(category, swatches[idx].id, false) 
  191. 			weapon_store_footer_update(swatches[idx].label_str, swatches[idx].ammo_current, swatches[idx].ammo_max, swatches[idx].price, owned) 
  192. 		end 
  193. 	end 
  194. end 
  195.  
  196. function weapon_store_swatch_on_enter(new_swatch) 
  197. 	--Retrigger highlight animation 
  198. 	vint_set_property(Weapon_menu_anims.icon_highlight_anim_h, "target_handle", new_swatch.swatch_h) 
  199. 	lua_play_anim(Weapon_menu_anims.icon_highlight_anim_h, 0) 
  200. 	vint_set_property(Weapon_menu_anims.icon_dw_0_hl_anim_h , "target_handle", new_swatch.swatch_h) 
  201. 	lua_play_anim(Weapon_menu_anims.icon_dw_0_hl_anim_h , 0) 
  202. 	vint_set_property(Weapon_menu_anims.icon_dw_1_hl_anim_h, "target_handle", new_swatch.swatch_h) 
  203. 	lua_play_anim(Weapon_menu_anims.icon_dw_1_hl_anim_h, 0) 
  204. end 
  205.  
  206. function weapon_store_swatch_on_leave(old_swatch) 
  207. 	--Remove highlight from old swatch 
  208. 	local icon_highlight = vint_object_find("icon_highlight", old_swatch.swatch_h ) 
  209. 	vint_set_property(icon_highlight, "alpha", 0) 
  210. 	local icon_dw_0_hl = vint_object_find("icon_dw_0_hl", old_swatch.swatch_h ) 
  211. 	local icon_dw_1_hl = vint_object_find("icon_dw_1_hl", old_swatch.swatch_h ) 
  212. 	vint_set_property(icon_dw_0_hl, "alpha", 0) 
  213. 	vint_set_property(icon_dw_1_hl, "alpha", 0) 
  214.  
  215. end 
  216.  
  217. function weapon_store_footer_build(menu_data) 
  218. 	local footer_master = vint_object_find("weapon_menu_footer", nil, WEAPON_STORE_DOC_H) 
  219. 	local grp = vint_object_clone(footer_master, Menu_option_labels.control_parent) 
  220. 	vint_set_property(grp, "visible", true) 
  221.  
  222. 	if menu_data.footer ~= nil and menu_data.footer.footer_grp ~= nil and menu_data.footer.footer_grp ~= 0 then 
  223. 		vint_object_destroy(menu_data.footer.footer_grp) 
  224. 	end 
  225. 	 
  226. 	menu_data.footer = { } 
  227. 	menu_data.footer.footer_grp = grp 
  228. 	 
  229. 	Weapon_menu_footer_ammo_meter_h = vint_object_find("ammo_amount", grp) 
  230. 	Weapon_menu_footer_price_h = vint_object_find("price_amount", grp) 
  231. 	Weapon_menu_footer_weapon_label_h = vint_object_find("weapon_label", grp) 
  232. 	 
  233. 	if menu_data.footer_type == "ammo" then 
  234. 		vint_set_property(Weapon_menu_footer_ammo_meter_h, "visible", true) 
  235. 		vint_set_property(Weapon_menu_footer_price_h, "visible", true) 
  236. 		vint_set_property(Weapon_menu_footer_weapon_label_h, "visible", true) 
  237. 	elseif menu_data.footer_type == "weapon" then 
  238. 		vint_set_property(Weapon_menu_footer_ammo_meter_h, "visible", false) 
  239. 		vint_set_property(Weapon_menu_footer_price_h, "visible", true) 
  240. 		vint_set_property(Weapon_menu_footer_weapon_label_h, "visible", true) 
  241. 	elseif menu_data.footer_type == "cache" then  
  242. 		vint_set_property(Weapon_menu_footer_ammo_meter_h, "visible", false) 
  243. 		vint_set_property(Weapon_menu_footer_price_h, "visible", false) 
  244. 		vint_set_property(Weapon_menu_footer_weapon_label_h, "visible", true) 
  245. 	end 
  246. end 
  247.  
  248. function weapon_store_footer_update(label, current_ammo, max_ammo, price, owned) 
  249. 	vint_set_property(Weapon_menu_footer_weapon_label_h, "visible", true) 
  250.  
  251. 	if current_ammo ~= -1 then 
  252. 		vint_set_property(Weapon_menu_footer_weapon_label_h, "text_tag", label) 
  253. 		vint_set_property(Weapon_menu_footer_ammo_meter_h, "text_tag", current_ammo .. "/" .. max_ammo) 
  254. 		vint_set_property(Weapon_menu_footer_ammo_meter_h, "visible", true) 
  255. 		 
  256. 		if current_ammo < max_ammo then 
  257. 			owned = false 
  258. 		end 
  259. 	else 
  260. 		vint_set_property(Weapon_menu_footer_ammo_meter_h, "visible", false) 
  261. 		vint_set_property(Weapon_menu_footer_weapon_label_h, "text_tag", label) 
  262. 	end 
  263. 	 
  264. 	if price ~= nil and price > 0 and owned == false then 
  265. 		vint_set_property(Weapon_menu_footer_price_h, "visible", true) 
  266. 		if Style_cluster_player_cash < price then 
  267. 			vint_set_property(Weapon_menu_footer_price_h, "tint", MENU_FOOTER_CASH_BROKE_COLOR.R, MENU_FOOTER_CASH_BROKE_COLOR.G, MENU_FOOTER_CASH_BROKE_COLOR.B) 
  268. 		else 
  269. 			vint_set_property(Weapon_menu_footer_price_h, "tint", MENU_FOOTER_CASH_NORMAL_COLOR.R, MENU_FOOTER_CASH_NORMAL_COLOR.G, MENU_FOOTER_CASH_NORMAL_COLOR.B) 
  270. 		end 
  271. 		vint_set_property(Weapon_menu_footer_price_h, "text_tag", "$" .. format_cash(price)) 
  272. 	else  
  273. 		vint_set_property(Weapon_menu_footer_price_h, "visible", false) 
  274. 	end 
  275. 	 
  276. 	weapon_store_footer_resize_text()  
  277. end 
  278.  
  279. function	weapon_store_footer_remove(menu_data) 
  280. 	if menu_data.footer ~= nil then 
  281. 		vint_set_property(menu_data.footer.footer_grp, "visible", false) 
  282. 		vint_object_destroy(menu_data.footer.footer_grp) 
  283. 	end 
  284. end 
  285.  
  286. function weapon_store_footer_finalize(menu_data) 
  287. 	vint_set_property(Weapon_menu_footer_price_h, "anchor", menu_data.menu_width - 20, 0) 
  288. 	weapon_store_footer_resize_text()  
  289. end 
  290.  
  291. function weapon_store_footer_resize_text()  
  292. 	if Menu_active == 0 then 
  293. 		return 
  294. 	end 
  295. 	 
  296. 	if Menu_active.footer_height ~= 0 then 
  297. 		vint_set_property(Weapon_menu_footer_weapon_label_h, "scale", 1.0, 1.0) 
  298. 		local text_x, text_y = vint_get_property(Weapon_menu_footer_weapon_label_h, "anchor") 
  299. 		local text_width, text_height = element_get_actual_size(Weapon_menu_footer_weapon_label_h) 
  300. 		local price_anchor_x = vint_get_property(Weapon_menu_footer_price_h, "anchor") 
  301. 		local price_width, price_height = element_get_actual_size(Weapon_menu_footer_price_h) 
  302. 		local size_of_text = Menu_active.menu_width - price_width - 30 
  303. 		local text_scale  = (size_of_text / (text_x + text_width)) 
  304. 		if text_x + text_width >= size_of_text then 
  305. 			vint_set_property(Weapon_menu_footer_weapon_label_h, "scale", text_scale, text_scale) 
  306. 		end 
  307. 	end 
  308. end 
  309.  
  310. ---[ CACHE MENU ]--- 
  311. -------------------- 
  312. function weapon_store_confirm_cache_selection(menu_label, menu_data) 
  313. 	local swatches = menu_data.swatches 
  314. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  315. 	if idx < swatches.num_swatches then 
  316. 		if swatches[idx].equipped == false then 
  317. 			weapon_store_purchase_weapon(Weapon_menu_active_horz_menu[Weapon_menu_active_horz_menu.current_selection].category, swatches[idx].id) 
  318. 			--	Update the swatched to show it is equipped 
  319. 			weapon_store_set_equipped(swatches, idx) 
  320. 		end 
  321. 	end 
  322. end 
  323.  
  324. ---[ WEAPON MENU ]--- 
  325. --------------------- 
  326. function weapon_store_update_weapon_menu(menu_item) 
  327. 	Weapon_store_menu_add_index = 0 
  328. 	menu_item.swatches = { num_swatches = 0 } 
  329. 	menu_item.cur_idx = 0 
  330.  
  331. 	local category = Weapon_menu_active_horz_menu[Weapon_menu_active_horz_menu.current_selection].category 
  332. 	 
  333. 	if category == "thrown" == true then 
  334. 		vint_dataresponder_request("weapon_store_populate_weapons", "weapon_store_weapon_menu_add_thrown_items", 0, category) 
  335. 	else 
  336. 		vint_dataresponder_request("weapon_store_populate_weapons", "weapon_store_weapon_menu_add_items", 0, category) 
  337. 	end 
  338. 	 
  339. 	menu_item.swatches.num_swatches = Weapon_store_menu_add_index 
  340. end 
  341.  
  342. function weapon_store_build_weapon_menu(menu_data) 
  343. 	Active_menu = menu_data 
  344. 	local menu_item = menu_data[0] 
  345.  
  346. 	menu_item.type=MENU_ITEM_TYPE_GRID 
  347. 	menu_item.label = "" 
  348. 	if Weapon_menu_is_cache_menu == true then 
  349. 		menu_item.on_select = weapon_store_confirm_cache_selection 
  350. 	else  
  351. 		if Weapon_menu_active_horz_menu[Weapon_menu_active_horz_menu.current_selection].category ~= "thrown" then 
  352. 			menu_item.on_select = weapon_store_confirm_weapon_selection  
  353. 		else 
  354. 			menu_item.on_select = weapon_store_confirm_throwing_weapon_selection 
  355. 		end 
  356. 	end 
  357. 	menu_item.on_nav = weapon_store_select_new_item 
  358. 	menu_data.footer_height = 40 
  359. 	 
  360. 	weapon_store_update_weapon_menu(menu_item) 
  361. 		 
  362. 	menu_data.header_label_str = Weapon_menu_active_horz_menu[Weapon_menu_active_horz_menu.current_selection].label 
  363. 	 
  364. 	if menu_item.swatches.num_swatches > 0 then 
  365. 		local master_swatch = vint_object_find("swatch_weapon", nil, WEAPON_STORE_DOC_H) 
  366. 		 
  367. 		if menu_item.swatches.num_swatches < 11 and menu_item.swatches.num_swatches > 8 then 
  368. 			menu_item.num_cols = 5 
  369. 		else 
  370. 			menu_item.num_cols = 4 
  371. 		end 
  372. 		 
  373. 		menu_grid_show(menu_data, menu_item, master_swatch)	 
  374. 		weapon_store_footer_build(menu_data)	 
  375. 		 
  376. 		--Play flashing animation on selected item 
  377. 		vint_set_property(Weapon_menu_anims.icon_highlight_anim_h, "target_handle", menu_item.swatches[0].swatch_h) 
  378. 		lua_play_anim(Weapon_menu_anims.icon_highlight_anim_h, 0) 
  379. 		vint_set_property(Weapon_menu_anims.icon_dw_0_hl_anim_h, "target_handle", menu_item.swatches[0].swatch_h) 
  380. 		lua_play_anim(Weapon_menu_anims.icon_dw_0_hl_anim_h, 0) 
  381. 		vint_set_property(Weapon_menu_anims.icon_dw_1_hl_anim_h, "target_handle", menu_item.swatches[0].swatch_h) 
  382. 		lua_play_anim(Weapon_menu_anims.icon_dw_1_hl_anim_h, 0) 
  383. 		 
  384. 		if menu_data.footer_type ~= "ammo" then 
  385. 			weapon_store_footer_update(menu_item.swatches[0].label_str, -1, nil, menu_item.swatches[0].price, menu_item.swatches[0].owned) 
  386. 		else  
  387. 			weapon_store_footer_update(menu_item.swatches[0].label_str, menu_item.swatches[0].ammo_current, menu_item.swatches[0].ammo_max, menu_item.swatches[0].price, menu_item.swatches[0].owned) 
  388. 		end 
  389. 		 
  390. 		vint_set_property(Menu_footer_style_h, "visible", false) 
  391. 	 
  392. 		local category = Weapon_menu_active_horz_menu[Weapon_menu_active_horz_menu.current_selection].category 
  393. 		weapon_store_change_weapon(category, menu_item.swatches[0].id, menu_item.swatches[0].dual_wield) 
  394. 	else  
  395. 		menu_data[0].type=MENU_ITEM_TYPE_SELECTABLE 
  396. 		menu_data[0].label="WPN_STORE_NO_WEAPONS_AVAILABLE" 
  397. 		menu_data[0].on_select = nil 
  398. 		menu_data[0].on_nav = nil 
  399. 		menu_data.footer_height = 0 
  400. 	end 
  401. end 
  402.  
  403. function weapon_store_weapon_update_swatch(swatch) 
  404. 	local ammo_icon = vint_object_find("ammo_icon", swatch.swatch_h) 
  405. 	local ammo_count = vint_object_find("ammo_count", swatch.swatch_h) 
  406. 	local icon = vint_object_find("icon", swatch.swatch_h) 
  407. 	local icon_dw_0 = vint_object_find("icon_dw_0", swatch.swatch_h) 
  408. 	local icon_dw_1 = vint_object_find("icon_dw_1", swatch.swatch_h) 
  409. 	local icon_dw_0_hl = vint_object_find("icon_dw_0_hl", swatch.swatch_h) 
  410. 	local icon_dw_1_hl = vint_object_find("icon_dw_1_hl", swatch.swatch_h) 
  411. 	local icon_highlight = vint_object_find("icon_highlight", swatch.swatch_h) 
  412. 	local icon_purchase = vint_object_find("icon_purchase", swatch.swatch_h) 
  413.  
  414. 	local ammo_current = swatch.ammo_current 
  415. 	local ammo_max = swatch.ammo_max 
  416. 	local ammo_percent, ammo_angle 
  417. 	local equipped_ammo_fill = vint_object_find("equipped_ammo_fill", swatch.swatch_h) 
  418. 	local equipped_ammo_bg = vint_object_find("equipped_ammo_bg", swatch.swatch_h) 
  419. 	local equipped_ammo_base = vint_object_find("equipped_ammo_base", swatch.swatch_h) 
  420. 	local equipped_ammo_inf  = vint_object_find("equipped_ammo_inf", swatch.swatch_h) 
  421. 	 
  422. 	local owned = vint_object_find("check_owned", swatch.swatch_h) 
  423. 		 
  424. 	--Stop Highlight animation 
  425. 	vint_set_property(Weapon_menu_anims.icon_highlight_anim_h, "is_paused", true) 
  426. 	vint_set_property(Weapon_menu_anims.icon_highlight_anim_h, "target_handle", nil) 
  427.  
  428. 	--Stop DW Highlight animation 
  429. --	vint_set_property(Weapon_menu_anims.icon_dw_0_hl_anim_h, "is_paused", true) 
  430. --	vint_set_property(Weapon_menu_anims.icon_dw_0_hl_anim_h, "target_handle", nil) 
  431. --	vint_set_property(Weapon_menu_anims.icon_dw_1_hl_anim_h, "is_paused", true) 
  432. --	vint_set_property(Weapon_menu_anims.icon_dw_1_hl_anim_h, "target_handle", nil) 
  433. 		 
  434. 	vint_set_property(ammo_icon, "visible", false) 
  435. 	vint_set_property(ammo_count, "visible", false) 
  436. 	vint_set_property(equipped_ammo_inf, "visible", false) 
  437. 	vint_set_property(icon, "image", swatch.icon_name) 
  438. 	vint_set_property(icon_highlight, "image", swatch.icon_name) 
  439. 	vint_set_property(icon_highlight, "alpha", 0) 
  440. 	vint_set_property(icon_dw_0, "image", swatch.icon_name) 
  441. 	vint_set_property(icon_dw_0_hl, "image", swatch.icon_name) 
  442. 	vint_set_property(icon_dw_0_hl, "alpha", 0) 
  443. 	vint_set_property(icon_dw_1, "image", swatch.icon_name) 
  444. 	vint_set_property(icon_dw_1_hl, "image", swatch.icon_name) 
  445. 	vint_set_property(icon_dw_1_hl, "alpha", 0) 
  446. 	vint_set_property(icon_purchase, "image", swatch.icon_name) 
  447.  
  448. 	if swatch.dual_wield == true then 
  449. 		vint_set_property(icon_dw_0, "visible", true) 
  450. 		vint_set_property(icon_dw_1, "visible", true) 
  451. 		vint_set_property(icon_dw_0_hl, "visible", true) 
  452. 		vint_set_property(icon_dw_1_hl, "visible", true) 
  453. 		vint_set_property(icon, "visible", false) 
  454. 		vint_set_property(icon_highlight, "visible", false) 
  455. 	else 
  456. 		vint_set_property(icon_dw_0, "visible", false) 
  457. 		vint_set_property(icon_dw_1, "visible", false) 
  458. 		vint_set_property(icon_dw_0_hl, "visible", false) 
  459. 		vint_set_property(icon_dw_1_hl, "visible", false) 
  460. 		vint_set_property(icon, "visible", true) 
  461. 		vint_set_property(icon_highlight, "visible", true) 
  462. 	end 
  463. 	 
  464. 	if swatch.equipped == true then 
  465. 		vint_set_property(equipped_ammo_base, "visible", true) 
  466. 		if ammo_max ~= 0 then 
  467. 			if swatch.unlimited_ammo == true then 
  468. 				vint_set_property(equipped_ammo_inf, "visible", true) 
  469. 				vint_set_property(equipped_ammo_bg, "visible", false) 
  470. 				vint_set_property(equipped_ammo_fill, "visible", false) 
  471. 			else 
  472. 				vint_set_property(equipped_ammo_inf, "visible", false) 
  473. 				vint_set_property(equipped_ammo_fill, "visible", true) 
  474. 				vint_set_property(equipped_ammo_bg, "visible", true) 
  475. 			end 
  476. 		else 
  477. 			vint_set_property(equipped_ammo_inf, "visible", false) 
  478. 			vint_set_property(equipped_ammo_fill, "visible", false) 
  479. 			vint_set_property(equipped_ammo_bg, "visible", false) 
  480. 		end 
  481. 	else 
  482. 		vint_set_property(equipped_ammo_inf, "visible", false) 
  483. 		vint_set_property(equipped_ammo_fill, "visible", false) 
  484. 		vint_set_property(equipped_ammo_bg, "visible", false) 
  485. 		vint_set_property(equipped_ammo_base, "visible", false) 
  486. 	end 
  487. 		 
  488. 	if swatch.owned == true and Weapon_menu_is_cache_menu == false and swatch.equipped == false then 
  489. 		vint_set_property(owned, "visible", true) 
  490. 	else 
  491. 		vint_set_property(owned, "visible", false) 
  492. 	end 
  493. 	 
  494.  
  495. 	--Set the fill of ammo bar 
  496. 	ammo_percent = ammo_current/ammo_max 
  497. 	ammo_angle = -4.7 + (-3.14 + 4.7) * ammo_percent 
  498. 	vint_set_property(equipped_ammo_fill, "start_angle", ammo_angle) 
  499. end 
  500.  
  501. function weapon_store_set_equipped(swatches, idx) 
  502. 	--Set Equipped indicator on the swatch 
  503. 	 
  504. 	--Find and show indicator elements 
  505. 	local	equipped_ammo_fill = vint_object_find("equipped_ammo_fill", swatches[idx].swatch_h) 
  506. 	local	equipped_ammo_bg = vint_object_find("equipped_ammo_bg", swatches[idx].swatch_h) 
  507. 	local	equipped_ammo_base = vint_object_find("equipped_ammo_base", swatches[idx].swatch_h) 
  508. 	local 	equipped_ammo_inf  = vint_object_find("equipped_ammo_inf", swatches[idx].swatch_h) 
  509. 	 
  510. 	vint_set_property(equipped_ammo_base, "visible", true) 
  511. 	if swatches[idx].ammo_max ~= 0 then 
  512. 		if swatches[idx].unlimited_ammo == true then 
  513. 			vint_set_property(equipped_ammo_inf, "visible", true) 
  514. 			vint_set_property(equipped_ammo_bg, "visible", false) 
  515. 			vint_set_property(equipped_ammo_fill, "visible", false) 
  516. 		else 
  517. 			vint_set_property(equipped_ammo_inf, "visible", false) 
  518. 			vint_set_property(equipped_ammo_fill, "visible", true) 
  519. 			vint_set_property(equipped_ammo_bg, "visible", true) 
  520. 		end 
  521. 	else 
  522. 		vint_set_property(equipped_ammo_inf, "visible", false) 
  523. 		vint_set_property(equipped_ammo_fill, "visible", false) 
  524. 		vint_set_property(equipped_ammo_bg, "visible", false) 
  525. 	end 
  526. 	 
  527. 	--Hide old equipped Indicator 
  528. 	for i = 0, swatches.num_swatches - 1 do 
  529. 		if swatches[i].equipped == true and i ~= idx then 
  530. 			equipped_ammo_inf = vint_object_find("equipped_ammo_inf", swatches[i].swatch_h) 
  531. 			equipped_ammo_fill = vint_object_find("equipped_ammo_fill", swatches[i].swatch_h) 
  532. 			equipped_ammo_bg = vint_object_find("equipped_ammo_bg", swatches[i].swatch_h) 
  533. 			equipped_ammo_base = vint_object_find("equipped_ammo_base", swatches[i].swatch_h) 
  534. 			vint_set_property(equipped_ammo_inf, "visible", false) 
  535. 			vint_set_property(equipped_ammo_fill, "visible", false) 
  536. 			vint_set_property(equipped_ammo_bg, "visible", false)	 
  537. 			vint_set_property(equipped_ammo_base, "visible", false) 
  538. 			swatches[i].equipped = false 
  539. 		end 
  540. 	end	 
  541. 	 
  542. 	swatches[idx].equipped = true 
  543. end 
  544.  
  545. --Resets all the owned swatches 
  546. function weapon_store_reset_owned(swatches) 
  547. 		 
  548. 	--Show old owned Indicator 
  549. 	for i = 0, swatches.num_swatches - 1 do 
  550. 		local owned_h = vint_object_find("check_owned", swatches[i].swatch_h) 
  551. 		if swatches[i].owned == true and swatches[i].equipped == false then 
  552. 			vint_set_property(owned_h, "visible", true) 
  553. 		else 
  554. 			vint_set_property(owned_h, "visible", false) 
  555. 		end 
  556. 	end	 
  557. 	 
  558. end 
  559.  
  560. -- Make the purchase 
  561. function weapon_purchase_confirm(result, action) 
  562. 	if action ~= DIALOG_ACTION_CLOSE then 
  563. 		return 
  564. 	end 
  565. 	 
  566. 	 
  567. 	 
  568. 	if result == 0 then 
  569. 		local category = Weapon_menu_active_horz_menu[Weapon_menu_active_horz_menu.current_selection].category 
  570.  
  571. 		--	Purchase the weapon 
  572. 		weapon_store_purchase_weapon(category, Weapon_category_to_purchase[Weapon_index_of_purchase].id) 
  573.  
  574. 		--	Update the swatched to show it is equipped and owned 
  575. 		-- RCS: 7/11/08, TDL 246474, weapon store no longer awards style points 
  576. --		award_style("weapon", Weapon_category_to_purchase[Weapon_index_of_purchase].price) 
  577. 		weapon_store_set_equipped(Weapon_category_to_purchase, Weapon_index_of_purchase) 
  578. 		weapon_store_reset_owned(Weapon_category_to_purchase) 
  579. 		Weapon_category_to_purchase[Weapon_index_of_purchase].owned = true 
  580.  
  581. 		--Play purchase animation (Find swatch, retarget & play) 
  582. 		local swatch_current_h = Weapon_category_to_purchase[Weapon_index_of_purchase].swatch_h 
  583. 		vint_set_property(Weapon_menu_anims.icon_purchase_anim_h, "is_paused", true) 
  584. 		vint_set_property(Weapon_menu_anims.icon_purchase_anim_h, "target_handle", swatch_current_h)	 
  585. 		lua_play_anim(Weapon_menu_anims.icon_purchase_anim_h, 0) 
  586. 		 
  587. 		--play the purchase sound 
  588. 		audio_play(Menu_sound_purchase) 
  589. 		 
  590. 		--	Update the footer to reflect that it is owned 
  591. 		if Active_menu.footer_type == "ammo" then 
  592. 			local owned = false 
  593. 			Weapon_category_to_purchase[Weapon_index_of_purchase].ammo_current = Weapon_category_to_purchase[Weapon_index_of_purchase].ammo_current + Weapon_category_to_purchase[Weapon_index_of_purchase].clip_size 
  594. 			if Weapon_category_to_purchase[Weapon_index_of_purchase].ammo_current >= Weapon_category_to_purchase[Weapon_index_of_purchase].ammo_max then 
  595. 				owned = true 
  596. 			end 
  597. 			weapon_store_footer_update(Weapon_category_to_purchase[Weapon_index_of_purchase].label_str, Weapon_category_to_purchase[Weapon_index_of_purchase].ammo_current, Weapon_category_to_purchase[Weapon_index_of_purchase].ammo_max, Weapon_category_to_purchase[Weapon_index_of_purchase].price, owned) 
  598. 		else 
  599. 			weapon_store_footer_update(Weapon_category_to_purchase[Weapon_index_of_purchase].label_str, -1, nil, Weapon_category_to_purchase[Weapon_index_of_purchase].price, true) 
  600. 		end 
  601. 	end 
  602. end 
  603.  
  604. --	The purchase was decided 
  605. function weapon_store_confirm_weapon_selection(menu_label, menu_data) 
  606. 	local swatches = menu_data.swatches 
  607. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  608.  
  609. 	if idx < swatches.num_swatches then 
  610. 		if swatches[idx].owned == false then 
  611. 			if Style_cluster_player_cash >= swatches[idx].price then 
  612. 				local insert = { [0] = swatches[idx].label_str, [1] = format_cash(swatches[idx].price) } 
  613. 				local body = vint_insert_values_in_string("WPN_STORE_PURCHASE_PROMPT", insert) 
  614. 				local heading = "MENU_TITLE_CONFIRM" 
  615. 				Weapon_category_to_purchase = swatches 
  616. 				Weapon_index_of_purchase = idx 
  617. 				dialog_box_confirmation(heading, body, "weapon_purchase_confirm") 
  618. 			else 
  619. 				dialog_box_message("MENU_TITLE_NOTICE", "HUD_SHOP_INSUFFICIENT_FUNDS") 
  620. 			end 
  621. 		else 
  622. 			dialog_box_message("MENU_TITLE_NOTICE", "WPNSTOR_TEXT_MAX_WEAPONS_STORE") 
  623. 		end 
  624. 	end 
  625. end 
  626.  
  627. function weapon_store_confirm_throwing_weapon_selection(menu_label, menu_data) 
  628. 	local swatches = menu_data.swatches 
  629. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  630. 	if idx < swatches.num_swatches then 
  631. 		if (swatches[idx].owned == false or swatches[idx].equipped == false) and Style_cluster_player_cash >= swatches[idx].price  
  632. 			and swatches[idx].ammo_current < swatches[idx].ammo_max then 
  633. 			local insert = { [0] = swatches[idx].label_str, [1] = format_cash(swatches[idx].price) } 
  634. 			local body = vint_insert_values_in_string("WPN_STORE_PURCHASE_PROMPT", insert) 
  635. 			local heading = "MENU_TITLE_CONFIRM" 
  636. 			Weapon_category_to_purchase = swatches 
  637. 			Weapon_index_of_purchase = idx 
  638. 			dialog_box_confirmation(heading, body, "weapon_purchase_confirm") 
  639. 		elseif swatches[idx].owned == true and swatches[idx].ammo_current < swatches[idx].ammo_max then 
  640. 			if Style_cluster_player_cash >= swatches[idx].price then 
  641. 				local saved_cash = Style_cluster_player_cash 
  642. 				local category = Weapon_menu_active_horz_menu[Weapon_menu_active_horz_menu.current_selection].category 
  643. 				weapon_store_purchase_weapon(category, swatches[idx].id) 
  644. 				swatches[idx].ammo_current = swatches[idx].ammo_current + swatches[idx].clip_size 
  645. 				 
  646. 				local owned = false 
  647. 				if swatches[idx].ammo_current >= swatches[idx].ammo_max then 
  648. 					swatches[idx].ammo_current = swatches[idx].ammo_max 
  649. 					owned = true 
  650. 				end 
  651. 				 
  652. 				weapon_store_weapon_update_swatch(swatches[idx]) 
  653. 				weapon_store_footer_update(swatches[idx].label_str, swatches[idx].ammo_current, swatches[idx].ammo_max, swatches[idx].price, owned) 
  654. 				if Style_cluster_player_cash - swatches[idx].price < swatches[idx].price and saved_cash == Style_cluster_player_cash then 
  655. 					vint_set_property(Weapon_menu_footer_price_h, "tint", 1, 0, 0) 
  656. 				end 
  657. 			else 
  658. 				dialog_box_message("MENU_TITLE_NOTICE", "HUD_SHOP_INSUFFICIENT_FUNDS") 
  659. 			end 
  660. 		elseif swatches[idx].owned == true and swatches[idx].ammo_current >= swatches[idx].ammo_max then 
  661. 			dialog_box_message("MENU_TITLE_NOTICE", "WPNSTOR_TEXT_MAX_AMMO_STORE") 
  662. 		else 
  663. 			dialog_box_message("MENU_TITLE_NOTICE", "HUD_SHOP_INSUFFICIENT_FUNDS") 
  664. 		end 
  665. 	end 
  666. end 
  667.  
  668. function weapon_store_weapon_menu_add_items(name_str, icon_name, price, own, equipped, id, ammo_current, ammo_max, unlimited_ammo, dual_wield) 
  669. 	local swatches = Active_menu[0].swatches 
  670. 	swatches[Weapon_store_menu_add_index] = { 
  671. 		label_str = name_str, price = price, icon_name = icon_name, owned = own,  
  672. 		equipped = equipped, id = id, ammo_current = ammo_current, ammo_max = ammo_max, 
  673. 		unlimited_ammo = unlimited_ammo, dual_wield = dual_wield, 
  674. 	} 
  675. 			 
  676. 	Weapon_store_menu_add_index = Weapon_store_menu_add_index + 1 
  677. end 
  678.  
  679. function weapon_store_weapon_menu_add_thrown_items(name_str, icon_name, price, own, equipped, id, ammo_current, ammo_max, unlimited_ammo, dual_wield) 
  680. 	local swatches = Active_menu[0].swatches 
  681.  
  682. 	swatches[Weapon_store_menu_add_index] = { 
  683. 		label_str = name_str, price = price, icon_name = icon_name, owned = own,  
  684. 		equipped = equipped, id = id, ammo_current = ammo_current, ammo_max = ammo_max, 
  685. 		clip_size = 1, unlimited_ammo = unlimited_ammo, dual_wield = dual_wield, 
  686. 	} 
  687. 			 
  688. 	Weapon_store_menu_add_index = Weapon_store_menu_add_index + 1 
  689. end 
  690.  
  691. function weapon_store_release_menu(menu_data) 
  692. 	weapon_store_footer_remove(menu_data) 
  693. 	if menu_data[0].type == MENU_ITEM_TYPE_GRID then 
  694. 		menu_grid_release(menu_data[0]) 
  695. 	end 
  696. end 
  697.  
  698. ---[ AMMO MENU ]--- 
  699. ------------------- 
  700. function weapon_store_update_ammo_menu(menu_data) 
  701. 	local menu_item = menu_data[0] 
  702. 	Weapon_store_menu_add_index = 0 
  703. 	menu_item.swatches = { num_swatches = 0 } 
  704. 	menu_item.cur_idx = 0 
  705.  
  706. 	vint_dataresponder_request("weapon_store_populate_ammo", "weapon_store_ammo_menu_add_items", 0) 
  707.  
  708. 	menu_item.swatches.num_swatches = Weapon_store_menu_add_index 
  709. end 
  710.  
  711. function weapon_store_build_ammo_menu(menu_data) 
  712. 	Active_menu = menu_data 
  713. 	local menu_item = menu_data[0] 
  714. 	menu_item.type = MENU_ITEM_TYPE_GRID 
  715. 	menu_item.label = "" 
  716. 	menu_item.on_select = weapon_store_confirm_ammo_selection 
  717. 	menu_item.on_nav = weapon_store_select_new_item 
  718. 	menu_data.footer_height = 40 
  719. 	 
  720. 	weapon_store_update_ammo_menu(menu_data) 
  721. 	 
  722. 	if menu_data[0].swatches.num_swatches == 0 then 
  723. 		menu_data[0].type=MENU_ITEM_TYPE_SELECTABLE 
  724. 		menu_data[0].label="WPN_STORE_NO_WEAPONS_AVAILABLE" 
  725. 		menu_data[0].on_select = nil 
  726. 		menu_data[0].on_nav = nil 
  727. 		menu_data.footer_height = 0 
  728. 		return 
  729. 	end 
  730. 	 
  731. 	local master_swatch = vint_object_find("swatch_weapon", nil, WEAPON_STORE_DOC_H) 
  732. 	menu_grid_show(menu_data, menu_item, master_swatch)	 
  733. 	 
  734. 	weapon_store_footer_build(menu_data)	 
  735.  
  736. 	local owned = false 
  737. 	 
  738. 	if menu_item.swatches[0].ammo_current >= menu_item.swatches[0].ammo_max then 
  739. 		owned = true 
  740. 	end 
  741. 	 
  742. 	--Play flashing animation on selected item 
  743. 	vint_set_property(Weapon_menu_anims.icon_highlight_anim_h, "target_handle", menu_item.swatches[0].swatch_h) 
  744. 	lua_play_anim(Weapon_menu_anims.icon_highlight_anim_h, 0) 
  745.  
  746.  
  747. 	weapon_store_footer_update(menu_item.swatches[0].label_str, menu_item.swatches[0].ammo_current, menu_item.swatches[0].ammo_max, menu_item.swatches[0].price, owned) 
  748. 	weapon_store_change_weapon("ammo", menu_item.swatches[0].id, false) 
  749. 	vint_set_property(Menu_footer_style_h, "visible", false) 
  750. end 
  751.  
  752. function weapon_store_ammo_update_swatch(swatch) 
  753. 	local ammo_icon = vint_object_find("ammo_icon", swatch.swatch_h) 
  754. 	local ammo_count = vint_object_find("ammo_count", swatch.swatch_h) 
  755. 	local icon = vint_object_find("icon", swatch.swatch_h) 
  756. 	local icon_highlight = vint_object_find("icon_highlight", swatch.swatch_h) 
  757. 	local icon_purchase = vint_object_find("icon_purchase", swatch.swatch_h) 
  758.  
  759. 	local equipped_ammo_fill = vint_object_find("equipped_ammo_fill", swatch.swatch_h) 
  760. 	local equipped_ammo_bg = vint_object_find("equipped_ammo_bg", swatch.swatch_h) 
  761. 	local equipped_ammo_base = vint_object_find("equipped_ammo_base", swatch.swatch_h) 
  762. 	 
  763. 	local owned = vint_object_find("check_owned", swatch.swatch_h) 
  764. 	 
  765. 	vint_set_property(ammo_icon, "visible", true) 
  766. 	vint_set_property(ammo_icon, "image", swatch.ammo_icon) 
  767. 	 
  768. 	vint_set_property(ammo_count, "visible", true) 
  769. 	vint_set_property(ammo_count, "text_tag", swatch.clip_size) 
  770. 	 
  771. 	local swatch_scale = vint_get_property(swatch.swatch_h, "scale") 
  772. 	local scaler = Menu_scaler / swatch_scale 
  773. 	 
  774. 	local ammo_icon_x, ammo_icon_y  = vint_get_property(ammo_icon, "anchor")  
  775. 	local ammo_count_x, ammo_count_y  = vint_get_property(ammo_count, "anchor")  
  776. 	local ammo_count_width, ammo_count_height  = vint_get_property(ammo_count, "screen_size")  
  777. 	local ammo_icon_x = ammo_count_x + ((ammo_count_width + 3)* scaler) 
  778. 	vint_set_property(ammo_icon, "anchor", ammo_icon_x, ammo_icon_y) 
  779. 	 
  780. 	--Hide equipped Icons 
  781. 	vint_set_property(equipped_ammo_fill, "visible", false) 
  782. 	vint_set_property(equipped_ammo_bg, "visible", false) 
  783. 	vint_set_property(equipped_ammo_base, "visible", false) 
  784. 	 
  785. 	vint_set_property(owned, "visible", false) 
  786. 	 
  787. 	--Stop highlight animation 
  788. 	vint_set_property(Weapon_menu_anims.icon_highlight_anim_h, "is_paused", true) 
  789. 	vint_set_property(Weapon_menu_anims.icon_highlight_anim_h, "target_handle", nil) 
  790. 	 
  791. 	vint_set_property(icon, "image", swatch.icon_name) 
  792. 	vint_set_property(icon_highlight, "image", swatch.icon_name) 
  793. 	vint_set_property(icon_highlight, "alpha", 0) 
  794. 	vint_set_property(icon_purchase, "image", swatch.icon_name) 
  795. 	 
  796. end 
  797.  
  798. function weapon_store_confirm_ammo_selection(menu_label, menu_data) 
  799. 	local swatches = menu_data.swatches 
  800. 	local idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  801.  
  802. 	if idx < swatches.num_swatches then 
  803. 		if swatches[idx].ammo_current < swatches[idx].ammo_max then 
  804. 			if Style_cluster_player_cash >= swatches[idx].price then 
  805. 				local saved_cash = Style_cluster_player_cash 
  806. 				weapon_store_purchase_ammo(swatches[idx].id) 
  807. 				swatches[idx].ammo_current = swatches[idx].ammo_current + swatches[idx].clip_size 
  808. 				local owned = false 
  809. 				if swatches[idx].ammo_current > swatches[idx].ammo_max then 
  810. 					swatches[idx].ammo_current = swatches[idx].ammo_max 
  811. 					owned = true 
  812. 				end 
  813. 			 
  814. 				--Play purchase animation (Find swatch, retarget & play) 
  815. 				local swatch_current_h = swatches[idx].swatch_h 
  816. 				vint_set_property(Weapon_menu_anims.icon_purchase_anim_h, "target_handle", swatch_current_h) 
  817. 				lua_play_anim(Weapon_menu_anims.icon_purchase_anim_h, 0) 
  818. 				 
  819. 				--play the purchase sound 
  820. 				audio_play(Menu_sound_purchase) 
  821. 				 
  822. 				weapon_store_footer_update(swatches[idx].label_str, swatches[idx].ammo_current, swatches[idx].ammo_max, swatches[idx].price, owned) 
  823. 				if Style_cluster_player_cash - swatches[idx].price < swatches[idx].price and saved_cash == Style_cluster_player_cash then 
  824. 					vint_set_property(Weapon_menu_footer_price_h, "tint", 1, 0, 0) 
  825. 				end 
  826. 			else 
  827. 				dialog_box_message("MENU_TITLE_NOTICE", "HUD_SHOP_INSUFFICIENT_FUNDS") 
  828. 			end 
  829. 		else 
  830. 			dialog_box_message("MENU_TITLE_NOTICE", "WPNSTOR_TEXT_MAX_AMMO_STORE") 
  831. 		end 
  832. 	end 
  833. end 
  834.  
  835. function weapon_store_ammo_menu_add_items(name, icon_name, ammo_icon, price, clip_size, current_amount, max_amount, id) 
  836. 	local swatches = Weapon_store_ammo_menu[0].swatches 
  837. 	swatches[Weapon_store_menu_add_index] = { 
  838. 		label_str = name, price = price, icon_name = icon_name, ammo_icon = ammo_icon, clip_size = clip_size, ammo_current = current_amount, ammo_max = max_amount, id = id, 
  839. 	} 
  840. 	 
  841. 	Weapon_store_menu_add_index = Weapon_store_menu_add_index + 1 
  842. end 
  843.  
  844. function weapon_store_ammo_menu_release(menu_data) 
  845. 	weapon_store_footer_remove(menu_data) 
  846. 	menu_grid_release(menu_data[0]) 
  847. end 
  848.  
  849.  
  850. function weapon_store_is_not_cache_only() 
  851. 	--Awesome logic, to determine to display button tips 
  852. 	if Weapon_menu_cache_only == true then 
  853. 		return false 
  854. 	else 
  855. 		return true 
  856. 	end 
  857. end 
  858.  
  859. --------------- 
  860. -- MENU DATA -- 
  861. --------------- 
  862. -- Button Tips 
  863. ------------------ 
  864. Weapon_store_btn_tips = { 
  865. 	a_button 	= 	{ label = "CONTROL_SELECT", 				enabled = btn_tips_default_a, }, 
  866. 	x_button 	= 	{ label = "MENU_SWAP_WEAPONS_CACHE", 	enabled = weapon_store_is_not_cache_only, }, 
  867. 	b_button 	= 	{ label = "MENU_RESUME", 						enabled = btn_tips_default_a, }, 
  868. } 
  869.  
  870. --	Ammo Menu 
  871. ------------------- 
  872. Weapon_store_ammo_menu = {  
  873. 	header_label_str 	 = "WPN_STORE_AMMO_TITLE", 
  874. 	num_items 	 	= 1, 
  875. 	on_show		 	= weapon_store_build_ammo_menu, 
  876. 	on_post_show 	= weapon_store_footer_finalize, 
  877. 	on_release	 	= weapon_store_release_menu, 
  878. 	on_back		 	= weapon_store_exit, 
  879. 	on_alt_select	= weapons_store_switch_mode, 
  880. 	 
  881. 	[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = weapon_store_confirm_ammo_selection, on_nav = weapon_store_select_new_item, 
  882. 		row_height = MENU_SWATCH_DEFAULT_ROW_HEIGHT, num_cols = 4, col_width = MENU_SWATCH_DEFAULT_COL_WIDTH, highlight_scale = 1,  
  883. 		unhighlight_scale = 0.8, update_swatch = weapon_store_ammo_update_swatch, on_enter = weapon_store_swatch_on_enter,  
  884. 		on_leave = weapon_store_swatch_on_leave }, 
  885. 	 
  886. 	btn_tips = Weapon_store_btn_tips, 
  887. 	footer_type	  = "ammo", 
  888. 	footer_height = 40, 
  889. } 
  890.  
  891.  
  892. --	Weapon Menu 
  893. -------------- 
  894. Weapon_store_weapon_menu_a = { 
  895. 	header_label_str 	 = "NOT SET", 
  896. 	num_items 	 = 1,  
  897. 	on_show		 = weapon_store_build_weapon_menu, 
  898. 	on_release	 = weapon_store_release_menu, 
  899. 	on_back		 = weapon_store_exit, 
  900. 	on_post_show = weapon_store_footer_finalize, 
  901. 	on_alt_select	= weapons_store_switch_mode, 
  902. 	 
  903. 	[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = weapon_store_confirm_weapon_selection, on_nav = weapon_store_select_new_item, 
  904. 		row_height = MENU_SWATCH_DEFAULT_ROW_HEIGHT, num_cols = 4, col_width = MENU_SWATCH_DEFAULT_COL_WIDTH, highlight_scale = 1, unhighlight_scale = 0.8, 
  905. 		update_swatch = weapon_store_weapon_update_swatch,	on_enter = weapon_store_swatch_on_enter, on_leave = weapon_store_swatch_on_leave }, 
  906. 	 
  907. 	btn_tips = Weapon_store_btn_tips, 
  908. 	footer_type	  = "weapon",	 
  909. 	footer_height = 40, 
  910. } 
  911.  
  912. Weapon_store_weapon_menu_b = { 
  913. 	header_label_str 	 = "NOT SET", 
  914. 	num_items 	 = 1,  
  915. 	on_show		 = weapon_store_build_weapon_menu, 
  916. 	on_post_show = weapon_store_footer_finalize, 
  917. 	on_release	 = weapon_store_release_menu, 
  918. 	on_back		 = weapon_store_exit, 
  919. 	on_alt_select	= weapons_store_switch_mode, 
  920. 	 
  921. 	[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = weapon_store_confirm_weapon_selection, on_nav = weapon_store_select_new_item, 
  922. 		row_height = MENU_SWATCH_DEFAULT_ROW_HEIGHT, num_cols = 4, col_width = MENU_SWATCH_DEFAULT_COL_WIDTH, highlight_scale = 1, unhighlight_scale = 0.8, update_swatch = weapon_store_weapon_update_swatch, 
  923. 		on_enter = weapon_store_swatch_on_enter, on_leave = weapon_store_swatch_on_leave }, 
  924. 	 
  925. 	btn_tips = Weapon_store_btn_tips, 
  926. 	footer_type	  = "weapon", 
  927. 	footer_height = 40, 
  928. } 
  929.  
  930. Weapon_store_weapon_menu_throwing = { 
  931. 	header_label_str 	 = "NOT SET", 
  932. 	num_items 	 = 1,  
  933. 	on_show		 = weapon_store_build_weapon_menu, 
  934. 	on_release	 = weapon_store_release_menu, 
  935. 	on_back		 = weapon_store_exit, 
  936. 	on_post_show = weapon_store_footer_finalize, 
  937. 	on_alt_select	= weapons_store_switch_mode, 
  938. 	 
  939. 	[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = weapon_store_confirm_throwing_weapon_selection, on_nav = weapon_store_select_new_item, 
  940. 		row_height = MENU_SWATCH_DEFAULT_ROW_HEIGHT, num_cols = 4, col_width = MENU_SWATCH_DEFAULT_COL_WIDTH, highlight_scale = 1,  
  941. 		unhighlight_scale = 0.8, update_swatch = weapon_store_weapon_update_swatch, on_enter = weapon_store_swatch_on_enter, on_leave = weapon_store_swatch_on_leave }, 
  942. 	 
  943. 	btn_tips = Weapon_store_btn_tips, 
  944. 	footer_type	  = "ammo",	 
  945. 	footer_height = 40, 
  946. } 
  947.  
  948. Weapon_store_cache_menu_a = { 
  949. 	header_label_str 	 = "NOT SET", 
  950. 	num_items 	 	= 1,  
  951. 	on_show		 	= weapon_store_build_weapon_menu, 
  952. 	on_post_show 	= weapon_store_footer_finalize, 
  953. 	on_release	 	= weapon_store_release_menu, 
  954. 	on_back		 	= weapon_store_exit, 
  955. 	on_alt_select	= weapons_store_switch_mode, 
  956. 	 
  957. 	btn_tips = Weapon_store_btn_tips, 
  958. 	[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = weapon_store_confirm_cache_selection, on_nav = weapon_store_select_new_item, 
  959. 		row_height = MENU_SWATCH_DEFAULT_ROW_HEIGHT, num_cols = 4, col_width = MENU_SWATCH_DEFAULT_COL_WIDTH, highlight_scale = 1, unhighlight_scale = 0.8, update_swatch = weapon_store_weapon_update_swatch, 
  960. 		on_enter = weapon_store_swatch_on_enter, on_leave = weapon_store_swatch_on_leave }, 
  961. 	 
  962. btn_tips = Weapon_store_btn_tips,	 
  963. 	footer_type	  = "cache", 
  964. 	footer_height = 40, 
  965. } 
  966.  
  967. Weapon_store_cache_menu_b = { 
  968. 	header_label_str 	 = "NOT SET", 
  969. 	num_items 	 	= 1,  
  970. 	on_show		 	= weapon_store_build_weapon_menu, 
  971. 	on_post_show 	= weapon_store_footer_finalize, 
  972. 	on_release	 	= weapon_store_release_menu, 
  973. 	on_back		 	= weapon_store_exit, 
  974. 	on_alt_select	= weapons_store_switch_mode, 
  975. 	 
  976. 	btn_tips = Weapon_store_btn_tips, 
  977. 	[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = weapon_store_confirm_cache_selection, on_nav = weapon_store_select_new_item, 
  978. 		row_height = MENU_SWATCH_DEFAULT_ROW_HEIGHT, num_cols = 4, col_width = MENU_SWATCH_DEFAULT_COL_WIDTH, highlight_scale = 1, unhighlight_scale = 0.8, update_swatch = weapon_store_weapon_update_swatch, 
  979. 		on_enter = weapon_store_swatch_on_enter, on_leave = weapon_store_swatch_on_leave }, 
  980. 		 
  981. 	footer_type	  = "cache", 
  982. 	footer_height = 40, 
  983. } 
  984.  
  985. Weapon_store_cache_menu_c = { 
  986. 	header_label_str 	 = "NOT SET", 
  987. 	num_items 	 	= 1,  
  988. 	on_show		 	= weapon_store_build_weapon_menu, 
  989. 	on_post_show 	= weapon_store_footer_finalize, 
  990. 	on_release	 	= weapon_store_release_menu, 
  991. 	on_back		 	= weapon_store_exit, 
  992. 	on_alt_select	= weapons_store_switch_mode, 
  993. 	 
  994. 	btn_tips = Weapon_store_btn_tips, 
  995. 	[0] = { label = "", type = MENU_ITEM_TYPE_GRID, on_select = weapon_store_confirm_cache_selection, on_nav = weapon_store_select_new_item, 
  996. 		row_height = MENU_SWATCH_DEFAULT_ROW_HEIGHT, num_cols = 4, col_width = 83, highlight_scale = 1, unhighlight_scale = 0.8, update_swatch = weapon_store_weapon_update_swatch,  
  997. 		on_enter = weapon_store_swatch_on_enter, on_leave = weapon_store_swatch_on_leave }, 
  998. 	 
  999. 	footer_type	  = "cache", 
  1000. 	footer_height = 40, 
  1001. } 
  1002.  
  1003.  
  1004. --	Horizontal Menu 
  1005. ------------------ 
  1006. Weapon_store_horz_menu = { 
  1007. 	num_items = 8, 
  1008. 	current_selection = 0, 
  1009. 	 
  1010. 	[0] = { label = "WPN_STORE_AMMO_TITLE", 		sub_menu = Weapon_store_ammo_menu, 		category = "ammo"  		}, 
  1011. 	[1] = { label = "WPN_STORE_MELEE_TITLE",		sub_menu = Weapon_store_weapon_menu_a, 	category = "melee" 		}, 
  1012. 	[2] = { label = "WPN_STORE_PISTOL_TITLE",	 	sub_menu = Weapon_store_weapon_menu_b, 	category = "pistol"		}, 
  1013. 	[3] = { label = "WPN_STORE_SMG_TITLE", 			sub_menu = Weapon_store_weapon_menu_a, 	category = "smg" 		}, 
  1014. 	[4] = { label = "WPN_STORE_SHOTGUN_TITLE",		sub_menu = Weapon_store_weapon_menu_b, 	category = "shotgun" 	}, 
  1015. 	[5] = { label = "WPN_STORE_RIFLE_TITLE", 		sub_menu = Weapon_store_weapon_menu_a, 	category = "rifle" 		}, 
  1016. 	[6] = { label = "WPN_STORE_SPECIAL_TITLE",	 	sub_menu = Weapon_store_weapon_menu_b, 	category = "special" 	}, 
  1017. 	[7] = { label = "WPN_STORE_THROWN_TITLE", 		sub_menu = Weapon_store_weapon_menu_throwing, category = "thrown" }, 
  1018. } 
  1019.  
  1020. Weapon_cache_horz_menu = { 
  1021. 	num_items = 7, 
  1022. 	current_selection = 0, 
  1023. 	 
  1024. 	[0] = { label = "WPN_STORE_MELEE_TITLE", 	sub_menu = Weapon_store_cache_menu_a, category = "melee"	}, 
  1025. 	[1] = { label = "WPN_STORE_PISTOL_TITLE", 	sub_menu = Weapon_store_cache_menu_b, category = "pistol" 	}, 
  1026. 	[2] = { label = "WPN_STORE_SMG_TITLE", 		sub_menu = Weapon_store_cache_menu_a, category = "smg"		}, 
  1027. 	[3] = { label = "WPN_STORE_SHOTGUN_TITLE",	sub_menu = Weapon_store_cache_menu_b, category = "shotgun"	}, 
  1028. 	[4] = { label = "WPN_STORE_RIFLE_TITLE", 	sub_menu = Weapon_store_cache_menu_a, category = "rifle" 	}, 
  1029. 	[5] = { label = "WPN_STORE_SPECIAL_TITLE", 	sub_menu = Weapon_store_cache_menu_c, category = "special" 	}, 
  1030. 	[6] = { label = "WPN_STORE_THROWN_TITLE", 	sub_menu = Weapon_store_cache_menu_b, category = "thrown" 	}, 
  1031. 	 
  1032. }