./store_stronghold.lua

  1.  
  2. SCALE_FONT_STORE_STRONGHOLD_LIST = 0.8 
  3.  
  4. Store_stronghold_doc_handle = -1 
  5.  
  6. local THREE_COUNT 		= 1 
  7. local NUKEPLANT 			= 2 
  8. local BROTHEL 				= 3 
  9. local POWDER				= 4 
  10.  
  11. local STRONGHOLD_POPULATE_TITLE		= 0 
  12. local STRONGHOLD_POPULATE_FIXED		= 1 
  13. local STRONGHOLD_POPULATE_REWARDS	= 2 
  14.  
  15. local STORE_STRONGHOLD_POPUP_X		= 134 
  16. local STORE_STRONGHOLD_POPUP_Y		= 170 
  17.  
  18. local STORE_STRONGHOLD_INFO_RESPONDER = "store_stronghold_populate" 
  19.  
  20.   
  21. local Stronghold_image_data = { 
  22. 	[THREE_COUNT] 	= { "ui_stronghold_3count_02",	"ui_stronghold_3count_02",	"ui_stronghold_3count_03" }, 
  23. 	[NUKEPLANT] 	= { "ui_stronghold_nuke_02",		"ui_stronghold_nuke_02",	"ui_stronghold_nuke_03" }, 
  24. 	[BROTHEL] 		= { "ui_stronghold_bdsm_02",		"ui_stronghold_bdsm_02",	"ui_stronghold_bdsm_03" }, 
  25. 	[POWDER] 		= { "ui_stronghold_3count_02",	"ui_stronghold_3count_02",	"ui_stronghold_3count_03" }, 
  26. } 
  27.  
  28. Store_stronghold_top_menu = {} 
  29.  
  30. -- Hint bar and store header vdo's. 
  31. local Store_logo1 
  32. local Store_logo2 
  33. local Not_popup_grp 
  34. local Detail_grp 
  35. local Reward_image 
  36. local Store_stronghold_in_anim 
  37. local Rewards_data = {} 
  38. local Stronghold_id 
  39. local Stronghold_input_tracker = {} 
  40. local Stronghold_gang_h 
  41.  
  42. local Store_stronghold_max_level = 0 
  43.  
  44. local Store_stronghold_upgrades_ready = false 
  45.  
  46. local Store_stronghold_kill_list_mouse = false 
  47.  
  48. local REWARD_SPACING = 26 
  49.  
  50. -- We used this as a reference to the current submenu we are building. 
  51. local Store_stronghold_building_menu = {} 
  52.  
  53. -- keeps track of which selection we were on when leaving to a sub-document 
  54. local Store_stronghold_current_menu_selection = 1 
  55.  
  56. local Stronghold_hint_bar_mouse_input_tracker 
  57. local Stronghold_full_screen_mouse_input_tracker 
  58. local Game_platform 
  59.  
  60. local Store_title_name = nil 
  61.  
  62. ---------------------------------------------------------------------------  
  63. -- Initialize crib Store (Customization) 
  64. --------------------------------------------------------------------------- 
  65. function store_stronghold_init() 
  66.  
  67. 	Store_common_current_highlight_color = COLOR_STORE_REWARDS_PRIMARY 
  68.  
  69. 	Game_platform = game_get_platform() 
  70. 	 
  71. 	Store_stronghold_doc_handle = vint_document_find("store_stronghold") 
  72. 	 
  73. 	local store_group = vint_object_find("screen_grp",0,Store_common_doc_handle) 
  74. 	vint_set_property(store_group,"visible",false) 
  75. 	 
  76. 	-- Set up some callbacks for the common store script 
  77. 	Store_common_populate_list_cb = store_stronghold_populate_list 
  78. 	Store_common_exit_cb				= store_stronghold_exit 
  79.  
  80. 	-- Subscribe to the button presses we need, Input_tracker is created in store_common.lua 
  81. 	Input_tracker:subscribe(false) 
  82.  
  83. 	vint_dataresponder_request(STORE_STRONGHOLD_INFO_RESPONDER, "store_stronghold_populate_title", 0, STRONGHOLD_POPULATE_TITLE) 
  84. 	vint_dataresponder_request(STORE_STRONGHOLD_INFO_RESPONDER, "store_stronghold_populate_data", 0, STRONGHOLD_POPULATE_FIXED) 
  85. 	vint_dataresponder_request(STORE_STRONGHOLD_INFO_RESPONDER, "store_stronghold_populate_rewards", 0, STRONGHOLD_POPULATE_REWARDS) 
  86. 	 
  87. 	--Set background for "bg_saints" 
  88. 	bg_saints_set_type(BG_TYPE_STRONGHOLD) 
  89. 	 
  90. 	--Setup Button Hints 
  91. 	local hint_data = { 
  92. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"},	 
  93. 	} 
  94. 	Store_common_hint_bar:set_hints(hint_data)  
  95. 	Store_common_hint_bar:set_visible(true) 
  96. 	 
  97. 	if game_is_active_input_gamepad() then 
  98. 		local hint_rotate_data = { 
  99. 			{CTRL_BUTTON_RS, "STORE_ZOOM_ROTATE"}, 
  100. 		} 
  101. 		Store_common_rotate_hint:set_hints(hint_rotate_data)  
  102. 		Store_common_rotate_hint:set_visible(false) 
  103. 	end 
  104. 	 
  105. 	if Game_platform == "PC" then 
  106. 		Mouse_input_tracker:subscribe(false) 
  107. 		 
  108. 		local bg_image_h = vint_object_find("stronghold_image") 
  109. 		 
  110. 		Stronghold_hint_bar_mouse_input_tracker = Vdo_input_tracker:new() 
  111. 		Store_common_hint_bar:add_mouse_inputs("store_stronghold", Stronghold_hint_bar_mouse_input_tracker) 
  112. 		Stronghold_hint_bar_mouse_input_tracker:subscribe(true) 
  113. 		 
  114. 		 
  115. 		Stronghold_full_screen_mouse_input_tracker = Vdo_input_tracker:new() 
  116. 		Stronghold_full_screen_mouse_input_tracker:add_mouse_input("mouse_click", "store_stronghold_button_a", 0, bg_image_h) 
  117. 		Stronghold_full_screen_mouse_input_tracker:subscribe(false) 
  118. 	end 
  119. 	 
  120. 	-- Set Store Header colors 
  121. 	Store_header:set_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY, COLOR_STORE_REWARDS_TERTIARY) 
  122. 	Store_header:set_visible(true) 
  123. 	--Store_header:enable_price_respect(true) 
  124. 	 
  125. 	Store_header:push_title( nil, Store_title_name ) 
  126. 	 
  127. 	Active_list:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY)			 
  128. 		 
  129. 	-- Everything that is not in the popup so we can fade it when the popup is active 
  130. 	Not_popup_grp = Vdo_base_object:new("not_popup_grp", 0, Store_common_doc_handle) 
  131. 	Detail_grp = Vdo_base_object:new("detail_group",0,Store_stronghold_doc_handle) 
  132. 	 
  133. 	-- Setup purchase popup 
  134. 	Store_common_popup:set_visible(false) 
  135. 	Store_common_popup:set_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY, COLOR_STORE_REWARDS_TERTIARY) 
  136. 	Store_common_popup:set_size(STORE_COMMON_LIST_SIZE, (LIST_BUTTON_HEIGHT * 5) + (LIST_BUTTON_SPACE * 5)) 
  137. 	 
  138. 	Store_common_popup:set_anchor(STORE_STRONGHOLD_POPUP_X,STORE_STRONGHOLD_POPUP_Y) 
  139.  
  140. 	vint_set_property(Crib_title,"visible",false) 
  141. 	 
  142. 	-- Pass the table data to the megalist vdo. 
  143. 	Menu_data = Store_stronghold_top_menu 
  144. 	 
  145. 	-- Pass the table data to the megalist vdo. 
  146. 	store_stronghold_populate_list(Menu_data, Store_stronghold_current_menu_selection)	 
  147.  
  148. 	-- set up flyby input tracker 
  149. 	Stronghold_input_tracker = Vdo_input_tracker:new() 
  150. 	Stronghold_input_tracker:add_input("select", "store_stronghold_button_a", 100) 
  151. 	 
  152. 	Stronghold_gang_h = vint_object_find("stronghold_gang", 0, Store_stronghold_doc_handle) 
  153. 	 
  154. 	local detail_anim_h = vint_object_find("stronghold_detail_anim") 
  155. 	vint_apply_start_values(detail_anim_h) 
  156. 	 
  157. 	store_unlock_controls() 
  158. 	 
  159. end 
  160.  
  161. function store_stronghold_load_complete(stronghold_icon_name) 
  162. 	-- Jason, this changed to stronghold_icon_name, which is a string 
  163. 	local gang_name = "" 
  164. 	if stronghold_icon_name == "Crib_3Count" then 
  165. 		Stronghold_id = THREE_COUNT 
  166. 		gang_name = "HUMAN_TEAM_LUCHADORES" 
  167. 	elseif stronghold_icon_name == "Crib_BDSM" then 
  168. 		Stronghold_id = BROTHEL 
  169. 		gang_name = "HUMAN_TEAM_MORNINGSTAR" 
  170. 	elseif stronghold_icon_name == "Crib_Nuke" then 
  171. 		Stronghold_id = NUKEPLANT 
  172. 		gang_name = "HUMAN_TEAM_DECKERS" 
  173. 	else 
  174. 		Stronghold_id = THREE_COUNT 
  175. 		gang_name = "HUMAN_TEAM_LUCHADORES" 
  176. 	end 
  177. 	 
  178. 	vint_set_property(Stronghold_gang_h, "visible", true) 
  179. 	vint_set_property(Stronghold_gang_h, "text_tag", gang_name) 
  180. 	 
  181. 	local image = Stronghold_image_data[Stronghold_id] 
  182. 	game_peg_load_with_cb("store_stronghold_bg_anim", 3, image[1],image[2],image[3]) 
  183. 	 
  184. end 
  185.  
  186. -- Cleanup function called on document unload. 
  187. -- 
  188. function store_stronghold_cleanup()	 
  189. 	 
  190. 	--unload the full screen images 
  191. 	local image = Stronghold_image_data[Stronghold_id] 
  192. 	game_peg_unload(image[1]) 
  193. 	game_peg_unload(image[2]) 
  194. 	game_peg_unload(image[3]) 
  195.  
  196. 	-- Some things need to be cleaned up right away when a store doc is unloading, particular disabled inputs which have 
  197. 	-- callbacks to the script that is unloading. 
  198. 	store_common_cleanup_current_store()	 
  199. end 
  200.  
  201. -- Called when this interface becomes the top one on the stack again. 
  202. -- 
  203. function store_stronghold_gained_focus() 
  204.  
  205. 	Store_common_current_highlight_color = COLOR_STORE_REWARDS_PRIMARY 
  206.  
  207. 	-- Reset our header 
  208. 	--Store_header:clear_titles() 
  209.  
  210. 	-- make background so it covers up the world 
  211. 	bg_saints_set_background(false) 
  212. 	 
  213. 	Input_tracker:subscribe(true)	 
  214. 	store_stronghold_enable_mouse(true) 
  215. 	 
  216. 	-- Need to clear out menu and menu stacks 
  217. 	store_common_stack_clear_menu() 
  218. 	store_common_stack_clear_id() 
  219. 	store_common_stack_clear_index() 
  220. 	 
  221. 	-- Pass the table data to the megalist vdo. 
  222. 	Menu_data = Store_stronghold_top_menu 
  223. 	 
  224. 	-- Pass the table data to the megalist vdo. 
  225. 	store_stronghold_populate_list(Menu_data, Store_stronghold_current_menu_selection)	 
  226. end 
  227.  
  228. function store_stronghold_bg_anim() 
  229.  
  230. 	Store_stronghold_in_anim = Vdo_anim_object:new("store_stronghold_slide_in_anim", 0, Store_common_doc_handle) 
  231. 	local twn = vint_object_find("end_event_twn_1",0,Store_common_doc_handle) 
  232. 	--vint_set_property(twn,"start_time",0) 
  233. 	--vint_set_property(twn,"start_value",500,-6) 
  234. 	--vint_set_property(twn,"end_value",-30,-6) 
  235. 	 
  236. 	twn = vint_object_find("strong_main_anchor_twn",0,Store_common_doc_handle) 
  237. 	--vint_set_property(twn,"start_value",500,-95) 
  238. 	--vint_set_property(twn,"end_value",-30,-95) 
  239. 	 
  240. 	vint_apply_start_values(Store_stronghold_in_anim.handle) 
  241. 	 
  242. 	Store_stronghold_in_anim:play() 
  243. 	 
  244. 	local detail_anim_h = vint_object_find("stronghold_detail_anim") 
  245. 	lua_play_anim(detail_anim_h, 0, Store_stronghold_doc_handle) 
  246. 	vint_apply_start_values(detail_anim_h) 
  247. 	 
  248. 	store_stronghold_refresh_rewards() 
  249. 	 
  250. 	local store_group = vint_object_find("screen_grp",0,Store_common_doc_handle) 
  251. 	vint_set_property(store_group,"visible",true) 
  252. 	 
  253. end 
  254.  
  255. function store_lock_controls() 
  256. 	Input_tracker:subscribe(false) 
  257. 	store_stronghold_enable_mouse(false) 
  258. end 
  259.  
  260. function store_unlock_controls() 
  261. 	Input_tracker:subscribe(true) 
  262. 	store_stronghold_enable_mouse(true) 
  263. end 
  264.  
  265. 	 
  266. -- Called when player requests exiting store. 
  267. -- 
  268. function store_stronghold_exit() 
  269. 	--we may not have to do a destructive action popup since we are going back to the crib menu 
  270. 	--[[Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  271. 	Store_common_popup:set_title("MENU_TITLE_WARNING") 
  272. 	Store_common_popup:set_text("STORE_EXIT_WARNING_BODY")		 
  273. 	Store_common_popup:nav_enable(true, "store_stronghold_exit_final", "store_stronghold_popup_nav") 
  274. 	Not_popup_grp:set_alpha(.5)]] 
  275. 	 
  276. 	store_lock_controls() 
  277. 	 
  278. 	-- clear out the price 
  279. 	Store_header:set_price(nil) 
  280. 	 
  281. 	local anim = vint_object_find("stronghold_detail_out_anim",0,Store_stronghold_doc_handle) 
  282. 	local twn = vint_object_find("new_tween1_1",0,Store_stronghold_doc_handle) 
  283. 	--set up the end event to pop the screen when the anim is done 
  284. 	vint_set_property(twn,"end_event","store_stronghold_anim_complete") 
  285. 	 
  286. 	lua_play_anim(anim,0) 
  287. 	 
  288. 	anim = vint_object_find("store_stronghold_slide_in_anim",0,Store_common_doc_handle) 
  289. 	twn = vint_object_find("end_event_twn_1",0,Store_common_doc_handle) 
  290. 	--vint_set_property(twn,"start_time",0) 
  291. 	--vint_set_property(twn,"start_value",-30,-6) 
  292. 	--vint_set_property(twn,"end_value",500,-6) 
  293. 	 
  294. 	twn = vint_object_find("strong_main_anchor_twn",0,Store_common_doc_handle) 
  295. 	--vint_set_property(twn,"start_value",-30,-95) 
  296. 	--vint_set_property(twn,"end_value",500,-95) 
  297. 	 
  298. 	lua_play_anim(anim,0) 
  299.  
  300. end 
  301.  
  302. function store_stronghold_anim_complete() 
  303. 	--force a screen pop to the crib menu 
  304. 	pop_screen() 
  305. end 
  306.  
  307. --[[ 
  308. -- No need for second exit (JMH 4/1/2011) 
  309. -- 
  310. -- Called when player has responded to store exit confirmation dialog. 
  311. -- 
  312. -- event: input response from the player 
  313. -- 
  314. function store_stronghold_exit_final(event) 
  315. 	Store_common_popup:nav_enable(false, nil, nil) 
  316. 		 
  317. 	-- The user hit the B button and is exiting 
  318. 	-- This is redundant to selecting "No" in the list 
  319. 	if event == "back" then 
  320. 		game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  321. 		Not_popup_grp:set_alpha(1) 
  322. 		Detail_grp:set_alpha(1) 
  323. 		store_stronghold_enable_mouse(true) 
  324. 		return 
  325. 	end 
  326. 	 
  327. 	game_UI_audio_play("UI_Main_Menu_Select") 
  328. 	 
  329. 	-- Did we select yes?  This assumes yes is the first item 
  330. 	if Store_common_popup:get_selected_data() ~= 1 then 
  331. 		Not_popup_grp:set_alpha(1) 
  332. 		Detail_grp:set_alpha(1) 
  333. 		store_stronghold_enable_mouse(true) 
  334. 		return 
  335. 	end 
  336. 	 
  337. 	--Not_popup_grp:set_alpha(0) 
  338. 	 
  339. 	local exit_anim = vint_object_find("stronghold_anim_out") 
  340. 	lua_play_anim(exit_anim) 
  341. 	 
  342. 	-- exit the interface 
  343. 	pop_screen() 
  344. end 
  345. ]] 
  346.  
  347. -- Populate the active megalist menu, and hide the previous menu 
  348. -- 
  349. -- list_data: 		this table contains the data to populate the megalist 
  350. -- current_index: 	the current index in the menu that's selected 
  351. -- 
  352. function store_stronghold_populate_list(list_data, current_index) 
  353. 	Active_list:draw_items(list_data, current_index, STORE_COMMON_LIST_SIZE, 10, LIST_FONT_SCALE)	 
  354. 	Active_list:set_visible(true) 
  355. 	 
  356. 	if Game_platform == "PC" then 
  357. 		Mouse_input_tracker:remove_all() 
  358. 		 
  359. 		Active_list:set_store("store_stronghold") 
  360. 		Active_list:add_mouse_inputs("store_common", Mouse_input_tracker) 
  361. 		Mouse_input_tracker:subscribe(true) 
  362. 	end 
  363. end 
  364.  
  365. -- Clears the price and respect values from the store header. 
  366. -- 
  367. function store_stronghold_header_revert(menu_data) 
  368. 	Store_header:set_price(nil) 
  369. 	Store_header:set_respect(nil) 
  370. end 
  371.  
  372. -- Handles navigation of any popups 
  373. function store_stronghold_popup_nav(event, value) 
  374. 	 
  375. 	if event == "nav_up" then	 
  376. 		Store_common_popup.list:move_cursor(-1)	 
  377. 	elseif event == "nav_down" then 
  378. 		Store_common_popup.list:move_cursor(1) 
  379. 	elseif event == "mouse_move" then 
  380. 		-- value contains the target_handle in this case 
  381. 		local new_index = Store_common_popup.list:get_button_index(value) 
  382. 		if new_index ~= 0 then 
  383. 			Store_common_popup.list:set_selection(new_index) 
  384. 			Store_common_popup.list:move_cursor(0, true) 
  385. 		end 
  386. 		 
  387. 	else 
  388. 		--do nothing 
  389. 	end 
  390. end 
  391.  
  392. -- Starts the flow of purchasing an upgrade 
  393. -- 
  394. function store_stronghold_purchase_upgrade() 
  395. 	--get the current highlight index 
  396. 	local current_item = Active_list:get_selection() 
  397. 	 
  398. 	Store_stronghold_current_menu_selection = current_item 
  399. 	 
  400. 	--make a shortcut to the main data table 
  401. 	local data = Store_stronghold_top_menu[current_item] 
  402. 	 
  403. 	if current_item > Store_stronghold_max_level + 1 then 
  404. 		Input_tracker:subscribe(false) 
  405. 		Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  406. 		Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  407. 		Store_common_popup:set_text("MENU_STRONGHOLD_PREVIOUS_UPGRADE")		 
  408. 		Store_common_popup:nav_enable(true, "store_stronghold_fail_msg", "store_stronghold_popup_nav") 
  409. 		Not_popup_grp:set_alpha(.5) 
  410. 		Detail_grp:set_alpha(.5) 
  411. 		store_stronghold_enable_mouse(false) 
  412. 		return 
  413. 	elseif Store_common_player_cash >= data.price and data.equipped == false then 
  414. 		local insert = { [0] = data.label, [1] = format_cash(data.price) } 
  415. 		local body = vint_insert_values_in_string("VCUST_PURCHASE_PROMPT", insert) 
  416. 		local heading = "MENU_TITLE_CONFIRM" 
  417. 		Input_tracker:subscribe(false) 
  418. 		Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)	 
  419. 		Store_common_popup:set_title(heading) 
  420. 		Store_common_popup:set_text(body)		 
  421. 		Store_common_popup:nav_enable(true, "store_stronghold_upgrade_confirm", "store_stronghold_popup_nav") 
  422. 		Not_popup_grp:set_alpha(.5) 
  423. 		Detail_grp:set_alpha(.5)		 
  424. 		store_stronghold_enable_mouse(false) 
  425. 	elseif not data.is_purchased then 
  426. 		Input_tracker:subscribe(false) 
  427. 		Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1) 
  428. 		Store_common_popup:set_title("MENU_TITLE_NOTICE") 
  429. 		Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")		 
  430. 		Store_common_popup:nav_enable(true, "store_stronghold_fail_msg", "store_stronghold_popup_nav") 
  431. 		Not_popup_grp:set_alpha(.5) 
  432. 		Detail_grp:set_alpha(.5) 
  433. 		store_stronghold_enable_mouse(false) 
  434. 	end		 
  435. end 
  436.  
  437. function store_stronghold_fail_msg(event) 
  438. 	Store_common_popup:nav_enable(false, nil, nil) 
  439. 	Not_popup_grp:set_alpha(1) 
  440. 	Detail_grp:set_alpha(1) 
  441. 	game_UI_audio_play("UI_Main_Menu_Select")	 
  442. 	store_stronghold_enable_mouse(true) 
  443. 	Input_tracker:subscribe(true) 
  444. end 
  445.  
  446. function store_stronghold_upgrade_confirm(event) 
  447. 	Store_common_popup:nav_enable(false, nil, nil) 
  448. 	Not_popup_grp:set_alpha(1) 
  449. 	Detail_grp:set_alpha(1) 
  450. 	store_stronghold_enable_mouse(true) 
  451. 	Input_tracker:subscribe(true) 
  452. 	 
  453. 	-- The user hit the B button and is exiting 
  454. 	-- This is redundant to selecting "No" in the list 
  455. 	if event == "back" then 
  456. 		game_UI_audio_play("UI_Main_Menu_Nav_Back")	 
  457. 		return 
  458. 	end 
  459. 	 
  460. 	--game_UI_audio_play("UI_Main_Menu_Select") 
  461. 	 
  462. 	-- Did we select yes?  This assumes yes is the first item 
  463. 	if Store_common_popup:get_selected_data() ~= 1 then 
  464. 		return 
  465. 	end 
  466. 	 
  467. 	game_UI_audio_play("UI_Buy_Building_Screen") 
  468. 	 
  469. 	--get the current highlight index 
  470. 	local current_item = Active_list:get_selection() 
  471. 	--make a shortcut to the main data table 
  472. 	local data = Store_stronghold_top_menu[current_item] 
  473. 	 
  474. 	Store_stronghold_max_level = Store_stronghold_max_level + 1 
  475. 	 
  476. 	--SET THE UPGRADE AS OWNED IN SCRIPT 
  477. 	data.equipped = true 
  478. 	data.is_purchased = true 
  479. 	data.price = 0 
  480. 	 
  481. 	Store_stronghold_kill_list_mouse = true 
  482. 	if Mouse_input_tracker ~= nil then 
  483. 		Mouse_input_tracker:subscribe(false) 
  484. 	end 
  485. 	--if Hint_bar_mouse_input_tracker ~= nil then 
  486. 		--Hint_bar_mouse_input_tracker:subscribe(false) 
  487. 	--end 
  488. 	 
  489. 	if Store_stronghold_current_menu_selection < 3 then 
  490. 		Store_stronghold_current_menu_selection = Store_stronghold_current_menu_selection + 1 
  491. 	end 
  492. 	 
  493. 	local exit_anim = Vdo_anim_object:new("store_stronghold_purchase_anim", 0, Store_common_doc_handle) 
  494. 	vint_apply_start_values(exit_anim.handle) 
  495. 	exit_anim:play() 
  496. 	 
  497. 	exit_anim = vint_object_find("stronghold_anim_out", 0, Store_stronghold_doc_handle) 
  498. 	vint_apply_start_values(exit_anim) 
  499. 	lua_play_anim(exit_anim, 0, Store_stronghold_doc_handle) 
  500. 	 
  501. 	--Store_common_hint_bar:set_visible(false) 
  502. 	 
  503. 	bg_saints_stronghold_drop_out() 
  504. 	 
  505. 	--subtract player cash 
  506. 	--do player upgrades immediately.   
  507. 	--NOTE: we will do reward screens after the flyby, but we need to ensure the rewards are given 
  508. 	-- then begin fade that precedes the flyby 
  509.  
  510. 	store_stronghold_game_purchase_upgrade() 
  511. 	 
  512. 	--It looks like the chunk swap are quick so we should not need to have a load screen. 
  513. 	 
  514. 	store_stronghold_setup_flyby() 
  515. end 
  516.  
  517. --C code calls this after the gun wipe is complete 
  518. --Camera flyby begins and input processing is enabled (A to cancel flyby) 
  519. function store_stronghold_wipe_complete() 
  520. 	--start custom input for continue 
  521. 	Stronghold_input_tracker:subscribe(true) 
  522. 	Stronghold_hint_bar_mouse_input_tracker:subscribe(true) 
  523. 	 
  524. 	Stronghold_full_screen_mouse_input_tracker:subscribe(true) 
  525. 	 
  526. 	--show the continue hint 
  527. 	local hint_data = { 
  528. 		{CTRL_MENU_BUTTON_A, "COMPLETION_CONTINUE"},	 
  529. 	} 
  530. 	Store_common_hint_bar:set_hints(hint_data)  
  531. 	 
  532. 	--local bg_group = vint_object_find("bg_group") 
  533. 	--vint_set_property(bg_group,"visible",false) 
  534. 	 
  535. 	--kill the header and the list 
  536. 	Store_header:set_visible(false) 
  537. 	Active_list:set_visible(false) 
  538. 	vint_set_property(Stronghold_gang_h, "visible", false) 
  539. 	 
  540. 	--show the large purchased text  
  541. 	local stronghold_purchased_h = vint_object_find("stronghold_purchased") 
  542. 	vint_set_property(stronghold_purchased_h, "visible", true) 
  543. 	 
  544. 	local exit_anim = Vdo_anim_object:new("store_stronghold_purchase_anim", 0, Store_common_doc_handle) 
  545. 	vint_apply_start_values(exit_anim.handle) 
  546. 	 
  547. 	local detail_anim_h = vint_object_find("stronghold_purchase_anim") 
  548. 	lua_play_anim(detail_anim_h) 
  549. 	 
  550. 	local anim = vint_object_find("store_stronghold_slide_in_anim", 0, Store_common_doc_handle) 
  551. 	local twn = vint_object_find("end_event_twn_1", anim) 
  552. 	vint_set_property(twn, "start_time", 5.0) 
  553. 	vint_set_property(twn, "end_event", "store_stronghold_hints_done") 
  554. 	 
  555. 	vint_apply_start_values(anim) 
  556. 	vint_apply_start_values(Store_stronghold_in_anim.handle) 
  557. 	bg_saints_animate() 
  558. 	Store_stronghold_in_anim:play() 
  559. end 
  560.  
  561. function store_stronghold_setup_flyby() 
  562. 	 
  563. 	--kill normal input 
  564. 	Input_tracker:subscribe(false) 
  565. end 
  566.  
  567. function store_stronghold_hints_done() 
  568. 	Store_stronghold_upgrades_ready = true 
  569. 	local anim = vint_object_find("store_stronghold_slide_in_anim", 0, Store_common_doc_handle) 
  570. 	local twn = vint_object_find("end_event_twn_1", anim) 
  571. 	vint_set_property(twn, "start_time", 0) 
  572. 	vint_set_property(twn, "end_event", nil) 
  573. end 
  574.  
  575. --This is called when we want to stop flyby 
  576. --After this is called, kick off awards 
  577. function store_stronghold_button_a() 
  578. 	if Store_stronghold_upgrades_ready then 
  579. 		Store_stronghold_upgrades_ready = false 
  580. 		Store_stronghold_kill_list_mouse = false 
  581. 		Stronghold_full_screen_mouse_input_tracker:subscribe(false) 
  582. 		if Mouse_input_tracker ~= nil then 
  583. 			Mouse_input_tracker:subscribe(true) 
  584. 		end 
  585. 		--if Hint_bar_mouse_input_tracker ~= nil then 
  586. 		--	Hint_bar_mouse_input_tracker:subscribe(true) 
  587. 		--end 
  588. 		-- reset input tracker 
  589. 		Stronghold_input_tracker:subscribe(false) 
  590. 		Input_tracker:subscribe(true) 
  591. 		 
  592. 		store_stronghold_upgrade_end_flyby() 
  593. 		 
  594. 		store_lock_controls() 
  595. 		 
  596. 		--Don't want to reset stronghold purchase screens yet.  We'll hide that change behind 
  597. 		--the reward screens.  
  598. 	end 
  599. end 
  600.  
  601. --reset stronghold store UI while on rewards screen 
  602. function store_stronghold_mid_awards_reset() 
  603. 	--enable input tracking  
  604. 	Input_tracker:subscribe(true) 
  605. 		 
  606. 	--RESET UI HERE. 
  607. 	--hide the large purchased text  
  608. 	local stronghold_purchased_h = vint_object_find("stronghold_purchased") 
  609. 	vint_set_property(stronghold_purchased_h,"visible",false) 
  610. 	 
  611. 	local bg_group = vint_object_find("bg_group") 
  612. 	vint_set_property(bg_group,"alpha",1.0) 
  613. 	 
  614. 	local stronghold_line = vint_object_find("stronghold_line") 
  615. 	vint_set_property(stronghold_line,"alpha",1.0) 
  616. 	 
  617. 	vint_set_property(Stronghold_gang_h, "visible", true) 
  618. 	 
  619. 	Store_header:set_visible(true) 
  620. 	Active_list:set_visible(true) 
  621. 	 
  622. 	-- Pass the table data to the megalist vdo. 
  623. 	store_stronghold_populate_list(Menu_data, Store_stronghold_current_menu_selection)	 
  624. 	 
  625. 	store_stronghold_refresh_rewards() 
  626. 	--Store_header:clear_titles() 
  627. 	--Store_header:push_title( nil, Store_title_name ) 
  628. 	 
  629. 	--set the new image 
  630. 	local bg_image_h = vint_object_find("stronghold_image") 
  631. 	vint_set_property( bg_image_h, "image", Stronghold_image_data[Stronghold_id][Store_stronghold_current_menu_selection]) 
  632. 	 
  633. 	local hint_data = { 
  634. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  635. 	} 
  636. 	Store_common_hint_bar:set_hints(hint_data) 
  637. 	store_unlock_controls() 
  638. 	 
  639. end 
  640.  
  641. -- Refreshes the rewards list based on the current highlight 
  642. -- 
  643. function store_stronghold_refresh_rewards() 
  644. 	--get the current highlight index 
  645. 	local current_item = Active_list:get_selection() 
  646. 	 
  647. 	--make a shortcut to the main data table 
  648. 	local data = Store_stronghold_top_menu[current_item] 
  649. 	 
  650. 	--set the cost of the upgrade 
  651. 	if data.price <= 0 or data.is_purchased then 
  652. 		Store_header:set_price(nil) 
  653. 	else 
  654. 		Store_header:set_price(data.price) 
  655. 	end 
  656. 	 
  657. 	local reward_text_h = vint_object_find("stronghold_reward_label_1") 
  658. 	vint_set_property(reward_text_h, "visible", false) 
  659.  
  660. 	--check if we have set rewards before 
  661. 	--if so kill everything 
  662. 	if #Rewards_data > 0 then 
  663. 		for i = 1, #Rewards_data do 
  664. 			vint_object_destroy( Rewards_data[i] ) 
  665. 		end 
  666. 		Rewards_data = {} 
  667. 	end 
  668. 	 
  669. 	--draw the new rewards strings 
  670. 	for i = 1, #data.rewards do 
  671. 		Rewards_data[i] = vint_object_clone(reward_text_h) 
  672. 		vint_set_property(Rewards_data[i],"visible",true) 
  673. 		vint_set_property(Rewards_data[i], "text_tag", data.rewards[i]) 
  674. 		local x, y =  vint_get_property( Rewards_data[i], "anchor") 
  675. 		vint_set_property(Rewards_data[i], "anchor", x, y + (i * REWARD_SPACING)) 
  676. 	end 
  677. 	 
  678. 	--set the new title 
  679. 	local title_h = vint_object_find("stronghold_title") 
  680. 	vint_set_property(title_h, "text_tag", data.label) 
  681. 	 
  682. 	local bg_image_h = vint_object_find("stronghold_image") 
  683. 	vint_set_property( bg_image_h, "image", Stronghold_image_data[Stronghold_id][current_item]) 
  684. 	 
  685. end 
  686.  
  687. function store_stronghold_populate_title(title_text) 
  688. 	Store_title_name = title_text 
  689. end 
  690.  
  691. function store_stronghold_populate_data(label, is_purchased, price) 
  692. 	-- label 			= string value for the button and title 
  693. 	-- is_purchased 	= bool for whether or not the stronghold upgrade has been purchased 
  694. 	-- price 			= price of the upgrade 
  695. 	-- rewards 			= table of strings for the rewards the player will get  
  696. 	 
  697. 	local current_index = #Store_stronghold_top_menu + 1 
  698. 	Store_stronghold_top_menu[current_index] = 
  699. 	{	label = label, 
  700. 		type = TYPE_BUTTON, 
  701. 		on_select = store_stronghold_purchase_upgrade, 
  702. 		id = current_index, 
  703. 		is_purchased = is_purchased, 
  704. 		equipped = is_purchased, 
  705. 		owned = true, 
  706. 		price = price, 
  707. 		on_nav = store_stronghold_refresh_rewards, 
  708. 		num_rewards = 0, 
  709. 		rewards = {} 
  710. 	} 
  711. 	if Store_stronghold_top_menu[current_index].equipped == true then 
  712. 		Store_stronghold_max_level = current_index 
  713. 	end 
  714. end 
  715.  
  716. function store_stronghold_populate_rewards(upgrade_level, reward_text) 
  717. 	-- valid upgrade level 
  718. 	upgrade_level = upgrade_level + 1 
  719. 	local cur_top_menu = Store_stronghold_top_menu[upgrade_level] 
  720. 	 
  721. 	if cur_top_menu == nil or reward_text == nil then 
  722. 		return 
  723. 	end 
  724. 	 
  725. 	cur_top_menu.num_rewards = cur_top_menu.num_rewards + 1 
  726. 	cur_top_menu.rewards[cur_top_menu.num_rewards] = reward_text 
  727. 	 
  728. end 
  729.  
  730. --Menu Options... 
  731.  
  732.  
  733. -- ===================================== 
  734. --       Mouse Specific Functions 
  735. -- ===================================== 
  736.  
  737. function store_stronghold_enable_mouse(enable) 
  738. 	if Game_platform == "PC" and enable ~= nil then 
  739. 		if Mouse_input_tracker ~= 0 then 
  740. 			Mouse_input_tracker:subscribe(enable) 
  741. 		end 
  742. 		 
  743. 		if Stronghold_hint_bar_mouse_input_tracker ~= nil then 
  744. 			Stronghold_hint_bar_mouse_input_tracker:subscribe(enable) 
  745. 		end 
  746. 	end 
  747. end 
  748.  
  749. function store_stronghold_mouse_click(event, target_handle) 
  750. 	local hint_index = Store_common_hint_bar:get_hint_index(target_handle) 
  751. 	if hint_index ~= 0 then 
  752. 		if Store_stronghold_upgrades_ready then 
  753. 			store_stronghold_button_a() 
  754. 			return 
  755. 		end 
  756. 		store_common_button_b() 
  757. 	end 
  758. end 
  759.  
  760. function store_stronghold_mouse_move(event, target_handle) 
  761. 	-- Reset all highlights 
  762. 	Store_common_hint_bar:set_highlight(0) 
  763. 	 
  764. 	-- Check if the mouse is over the hint bar buttons 
  765. 	local hint_index = Store_common_hint_bar:get_hint_index(target_handle) 
  766. 	if hint_index ~= 0 then 
  767. 		Store_common_hint_bar:set_highlight(hint_index, Store_common_current_highlight_color) 
  768. 		return 
  769. 	end 
  770. 	 
  771. 	-- Check if the mouse is over a button on the mega list 
  772. 	if Store_stronghold_kill_list_mouse == false then 
  773. 		local old_index = Active_list:get_selection() 
  774. 		local new_index = Active_list:get_button_index(target_handle) 
  775. 		if new_index ~= 0 and new_index ~= old_index then 
  776. 			Active_list:set_selection(new_index) 
  777. 			Active_list:move_cursor(0, true) 
  778. 			 
  779. 			-- If the item has a callback for navigation, do it (such as putting clothes on) 
  780. 			local data_item = Active_list:return_selected_data() 
  781. 			if data_item.on_nav ~= nil then 
  782. 				data_item.on_nav(data_item) 
  783. 			end 
  784. 			return 
  785. 		end 
  786. 	end 
  787. end 
  788.  
  789. function store_stronghold_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines) 
  790. end 
  791.  
  792. function store_stronghold_mouse_drag(event, target_handle, mouse_x, mouse_y) 
  793. end 
  794.  
  795. function store_stronghold_mouse_drag_release(event, target_handle, mouse_x, mouse_y) 
  796. end 
  797.