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