./pause_save_game.lua

  1. local ID_NEW_SAVE_GAME 			= 99 
  2. local ID_NO_GAMES					= -1 
  3. local Screen_width			= 834 
  4.  
  5. local Save_load_max_visible	= 6 
  6.  
  7. local Save_load_doc 	= -1 
  8. Save_load_list = -1 
  9.  
  10. local Save_load_unload_img = -1 
  11. local Save_load_image_update_thread = -1 
  12. local Save_load_current_image = nil 
  13.  
  14. local Save_load_stat_grp = -1 
  15.  
  16. local Save_load_image = nil 
  17.  
  18. local Save_load_data = {} 
  19. local Num_saves = 0 
  20.  
  21. local Input_tracker = {} 
  22. local Mouse_input_tracker = 0 
  23. local Hint_bar_mouse_input_tracker = 0 
  24. local Save_id 
  25.  
  26. local Device_selected = false 
  27. local Slide_out = true 
  28.  
  29. local Previous_save_load_list_index = 0 
  30.  
  31. Pause_Respect_meter = -1 
  32. Pause_District_meter = -1 
  33.  
  34. local Pause_save_images = { 
  35. 	["generic"] = "ui_save_0", 
  36. 	["city"] = "ui_save_city", 
  37. } 
  38.  
  39. function pause_save_game_init() 
  40. 	Save_load_doc = vint_document_find("pause_save_game") 
  41. 	 
  42. 	--wait till dump to turn on screen 
  43. 	local screen_grp = vint_object_find("screen_grp", 0, Save_load_doc) 
  44. 	vint_set_property(screen_grp, "visible", false) 
  45. 	 
  46. 	--HVS_TBT 6/4/2014: check to see if our save op has been overridden by voice. If so, change it! 
  47. 	local save_op_override = -1 
  48. 	local plat = game_get_platform() 
  49. 	if plat == "PS4" or plat == "XBOX3" then 
  50. 		save_op_override = get_hvs_voice_save_op_override() 
  51. 	end 
  52. 	if save_op_override >= 0 and save_op_override <= 1 then 
  53. 		Save_system_operation = save_op_override; 
  54. 	end 
  55.  
  56. 	save_system_set_operation(Save_system_operation) 
  57.  
  58. 	Pause_Respect_meter = Vdo_respect_meter:new("respect_meter", 0, 0, "pause_save_game.lua", "Pause_Respect_meter")	 
  59. 	Pause_District_meter = Vdo_city_control:new("control_meter", 0, 0, "pause_save_game.lua", "Pause_District_meter") 
  60. 	 
  61. 	Save_load_list = Vdo_mega_list:new("list", 0, Save_load_doc, "pause_save_game.lua", "Save_load_list") 
  62. 	Save_load_list:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY) 
  63. 	 
  64. 	Save_load_stat_grp = vint_object_find("save_stats_group",0,Save_load_doc) 
  65. 	 
  66. 	if In_pause_menu then 
  67. 		Save_load_max_visible	= 6 
  68. 	else 
  69. 		Save_load_max_visible	= 5 
  70. 	end 
  71. 	 
  72. 	-- Subscribe to the button presses we need 
  73. 	Input_tracker = Vdo_input_tracker:new() 
  74. 	 
  75. 	thread_new("pause_save_game_dump_map") 
  76. end 
  77. 	 
  78. function pause_save_game_dump_map() 
  79. 	pause_map_dump(true) 
  80. 	local screen_grp = vint_object_find("screen_grp", 0, Save_load_doc) 
  81. 	if game_get_platform() == "PS3" then 
  82.  
  83. 		if Save_system_operation == SAVE_OPERATION_LOAD_GAME then 
  84. 			save_system_load_game()	-- call upon the ps3 xmb 
  85. 		else 
  86. 			save_system_save_game() -- call upon ps3 xmb 
  87. 		end 
  88. 		  
  89. 		 
  90. 		vint_set_property(screen_grp, "visible", false) 
  91. 		 
  92. 		if First_time then 
  93. 			First_time = false 
  94. 		else 
  95. 			Slide_out = false 
  96. 		end 
  97. 		bg_saints_set_type(BG_TYPE_PAUSE, false, 1280) 
  98. 		 
  99. 		Header_obj:set_visible(false) 
  100. 		List:set_visible(false) 
  101. 		 
  102. 		menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_slide_out_anim) 
  103. 		--menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_out_anim) 
  104. 			 
  105. 	else 
  106.  
  107. 		local header_str = "" 
  108. 		if (Save_system_operation == SAVE_OPERATION_LOAD_GAME) then 
  109. 			Input_tracker:add_input("select", "load_button_a", 50) 
  110. 			header_str = "SAVELOAD_LOAD_GAME" 
  111. 		else  
  112. 			Input_tracker:add_input("select", "save_button_a", 50) 
  113. 			header_str = "SAVELOAD_SAVE_GAME" 
  114. 		end 
  115. 		 
  116. 		Input_tracker:add_input("back", "save_load_button_b", 50) 
  117. 		Input_tracker:add_input("alt_select", "save_load_button_x", 50) 
  118. 		if game_get_platform() == "PC" then 
  119. 			Input_tracker:add_input("scancode", "save_load_button_y", 50, false, 211) --'del' key 
  120. 			Input_tracker:add_input("gamepad_y", "save_load_button_y", 50) 
  121. 		else 
  122. 			Input_tracker:add_input("exit", "save_load_button_y", 50) 
  123. 		end 
  124.  
  125. 		if In_pause_menu then 
  126. 			Input_tracker:add_input("pause", "save_load_button_start", 50) 
  127. 		end	 
  128. 		Input_tracker:add_input("nav_up", "save_load_nav_up", 50) 
  129. 		Input_tracker:add_input("nav_down", "save_load_nav_down", 50) 
  130. 		Input_tracker:subscribe(false) 
  131. 		 
  132. 		-- Add mouse inputs for the PC 
  133. 		if game_get_platform() == "PC" then 
  134. 			Mouse_input_tracker = Vdo_input_tracker:new() 
  135. 			Hint_bar_mouse_input_tracker = Vdo_input_tracker:new() 
  136. 			Menu_hint_bar:set_highlight(0) 
  137. 			-- Hint bar and list inputs added elsewhere 
  138. 		 
  139. 			Hint_bar_mouse_input_tracker:subscribe(false) 
  140. 			Mouse_input_tracker:subscribe(false) 
  141. 		end 
  142.  
  143. 		--Initialize Header 
  144. 		local ctrl_header_obj = Vdo_pause_header:new("header", 0, Save_load_doc) 
  145. 		ctrl_header_obj:set_text(header_str, Screen_width) 
  146. 		--ctrl_header_obj:set_text_scale(0.8) 
  147. 		--ctrl_header_obj:show_dots(false) 
  148. 		 
  149. 	 
  150. 		--SAVE_LOAD_WIDTH = 834 
  151. 		--Store some locals to the pause menu common for screen processing. 
  152. 		menu_common_set_list_style(List, Header_obj, Screen_width) 
  153. 		 
  154. 		Header_obj:set_visible(false) 
  155. 		List:set_visible(false) 
  156. 		 
  157. 		save_load_refresh(false) 
  158. 		 
  159. 		local pause_screen_in_anim = Vdo_anim_object:new("save_back_in_anim", 0, Save_load_doc) 
  160. 		--if in pause menu act normal 
  161. 		 
  162. 		menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_slide_out_anim) 
  163. 		 
  164. 		pause_screen_in_anim:play(0) 
  165. 		 
  166. 		save_load_set_header() 
  167. 		vint_set_property(screen_grp, "visible", true) 
  168. 		 
  169. 	end 
  170. end 
  171.  
  172. function save_load_image_done() 
  173. 	local save_image_h = vint_object_find("save_image", 0, Save_load_doc) 
  174. 	vint_set_property(save_image_h,"image",Save_load_image) 
  175. 	vint_set_property(save_image_h,"visible",true) 
  176. end 
  177.  
  178. function save_game_populate(handle, is_loadable, is_autosave, is_cheat, description, percent, time_played, time_stamp, difficulty, missions_completed, districts_owned, cash, rank, current_respect_pct, total_respect, district_control_pct, last_mission_id, image_name) 
  179. 	 
  180. 	Previous_save_load_list_index = 1 
  181. 	 
  182. 	Num_saves = Num_saves + 1 
  183.  
  184. 	if handle == ID_NEW_SAVE_GAME or handle == ID_NO_GAMES then 
  185. 		if handle == ID_NEW_SAVE_GAME then 
  186. 			Save_load_data[Num_saves] =  
  187. 				{ type = TYPE_ROW, label_1 = "SAVELOAD_NEW_SAVE_GAME", save_id = ID_NEW_SAVE_GAME, 
  188. 				  label_2 = "", label_3 = "", label_4 = "" } 
  189. 		else	 
  190. 			Save_load_data[Num_saves] =  
  191. 				{ type = TYPE_ROW, label_1 = "SAVELOAD_NOTHING_TO_LOAD", save_id = ID_NO_GAMES, 
  192. 				  label_2 = "", label_3 = "", label_4 = "", show_button = false } 
  193. 		end 
  194. 		return 
  195. 	end 
  196. 	 
  197. 	local played_hours = floor(time_played / 60) 
  198. 	local played_mins = floor(time_played - (played_hours * 60)) 
  199. 	local game_time 
  200. 	 
  201. 	if played_mins > 9 then 
  202. 		game_time = ""..played_hours..":"..played_mins 
  203. 	else 
  204. 		game_time = ""..played_hours..":0"..played_mins 
  205. 	end 
  206. 	 
  207. 	Save_load_data[Num_saves] = { 
  208. 		type = TYPE_ROW, 
  209. 		--Info for displaying the Vdo_pause_row 
  210. 		label_1 = description, 
  211. 		label_2 = percent .. "%%", 
  212. 		label_3 = game_time, 
  213. 		label_4 = time_stamp,	 
  214. 		 
  215. 		--Data used by this script... 
  216. 		has_data = true, 
  217. 		save_id = handle, 
  218. 		description = description, 
  219. 		is_loadable = is_loadable, 
  220. 		missions_completed = missions_completed,  
  221. 		districts_owned = districts_owned, 
  222. 		is_cheat = is_cheat,  
  223. 		game_time = game_time,  
  224. 		difficulty = difficulty,  
  225. 		is_autosave = is_autosave,  
  226. 		percent = percent .. "%%", 
  227. 		cash = "{GAME_CASH}" .. cash, 
  228. 		rank = rank, 
  229. 		current_respect_pct = current_respect_pct, 
  230. 		total_respect = total_respect, 
  231. 		district_control_pct = district_control_pct, 
  232. 		last_mission_id = last_mission_id + 1, --this is so the data matches whats in sr3_city_quests.xtbl 
  233. 		image_name = image_name, 
  234. 	} 
  235.  
  236. end 
  237.  
  238. function pause_save_game_cleanup() 
  239. 	if Save_load_current_image ~= nil then 
  240. 		game_peg_unload(Save_load_current_image) 
  241. 	end		 
  242. 	if Save_load_unload_img ~= nil then 
  243. 		game_peg_unload(Save_load_unload_img) 
  244. 	end 
  245. 	if Save_load_image ~= nil then 
  246. 		game_peg_unload(Save_load_image) 
  247. 	end 
  248. 	 
  249. 	-- Nuke all button subscriptions 
  250. 	Input_tracker:subscribe(false) 
  251. 	if Mouse_input_tracker ~= 0 then 
  252. 		Mouse_input_tracker:subscribe(false) 
  253. 		Hint_bar_mouse_input_tracker:subscribe(false) 
  254. 	end 
  255. 			 
  256. 	Header_obj:set_visible(true) 
  257. 	List:set_visible(true) 
  258. 	 
  259. 	pause_map_restore() 
  260. 		 
  261. 	-- DAD - 6/16/11 - DO NOT REMOVE, this will break PS3 load game if you don't do this. 
  262. 	save_game_wrap_up() 
  263. end 
  264.  
  265. function device_selected() 
  266. 	Device_selected = true 
  267. end 
  268.  
  269. function save_load_lock_input(locked) 
  270. 	Input_tracker:subscribe(not locked) 
  271. 	 
  272. 	if  Mouse_input_tracker ~= 0 then 
  273. 		Mouse_input_tracker:subscribe(not locked) 
  274. 		Hint_bar_mouse_input_tracker:subscribe(not locked) 
  275. 	end 
  276. end 
  277.  
  278. function save_load_nav_up(event, acceleration) 
  279. 	--Don't do anything if list is only 1 item 
  280. 	if #Save_load_data == 1 then 
  281. 		return 
  282. 	end 
  283. 	-- Move highlight up 
  284. 	Save_load_list:move_cursor(-1) 
  285. 	save_load_set_header() 
  286. 	save_load_set_hints_on_nav() 
  287. 	if Mouse_input_tracker ~= 0 then 
  288. 		Save_load_list:set_mouse_highlight(-1) 
  289. 		Save_load_list:update_mouse_inputs("save_load", Mouse_input_tracker) 
  290. 	end 
  291. end 
  292.  
  293. function save_load_nav_down(event, acceleration) 
  294. 	--Don't do anything if list is only 1 item 
  295. 	if #Save_load_data == 1 then 
  296. 		return 
  297. 	end 
  298. 	-- Move highlight down 
  299. 	Save_load_list:move_cursor(1) 
  300. 	save_load_set_header() 
  301. 	save_load_set_hints_on_nav() 
  302. 	if Mouse_input_tracker ~= 0 then 
  303. 		Save_load_list:set_mouse_highlight(-1) 
  304. 		Save_load_list:update_mouse_inputs("save_load", Mouse_input_tracker) 
  305. 	end 
  306. end 
  307.  
  308. function save_button_a(event, acceleration) 
  309. 	if Save_load_list:list_is_playing() == false then 
  310. 		if not Device_selected then 
  311. 			return 
  312. 		end 
  313. 		 
  314. 		local current_button = Save_load_list:get_selection() 
  315. 		local data = Save_load_data[current_button] 
  316. 		if not data then 
  317. 			return 
  318. 		end 
  319. 		 
  320. 		if data.save_id == ID_NO_GAMES then 
  321. 			return 
  322. 		end 
  323. 		 
  324. 		save_load_lock_input(true) 
  325. 		save_system_save_game(data.save_id) 
  326. 	end 
  327. end 
  328.  
  329. function load_confirm(result, action) 
  330. 	if result == 0 then 
  331. 		Input_tracker:subscribe(false) 
  332. 		if Load_for_coop == true then 
  333. 			-- HVS_JRS 9/16/2014 check what the options systemlink_or_lan is set to 
  334. 			if (Main_menu_coop_is_xbox_live == -1) then 
  335. 				Main_menu_coop_is_xbox_live = not game_coop_shouldbe_syslink() 
  336. 				debug_print("always_on","load_confirm Main_menu_coop_is_xbox_live initialized to:" .. var_to_string(Main_menu_coop_is_xbox_live) .. "\n") 
  337. 			end 
  338. 			if Main_menu_coop_is_xbox_live then 
  339. 				game_coop_start_new_live() 
  340. 			else  
  341. 				game_coop_start_new_syslink() 
  342. 			end 
  343. 		end	 
  344. 		save_system_load_game(Save_id) 
  345. 	else	 
  346. 		Input_tracker:subscribe(true) 
  347. 	end 
  348. end 
  349.  
  350. function load_button_a(event, acceleration) 
  351. 	-- HVS_ARF - HS# 10810 See explanation in multi_core_platform.h 
  352. 	if save_system_has_accepted_game_invite() then 
  353. 		return 
  354. 	end 
  355. 	 
  356. 	if not Device_selected then 
  357. 		return 
  358. 	end 
  359.  
  360. 	local current_button = Save_load_list:get_selection() 
  361. 	local data = Save_load_data[current_button] 
  362. 	if not data then 
  363. 		return 
  364. 	end 
  365.  
  366. 	if data.save_id == ID_NO_GAMES then 
  367. 		return 
  368. 	end 
  369. 	 
  370. 	if In_pause_menu == false then 
  371. 		game_UI_audio_play("UI_Main_Menu_Select")	 
  372. 		Save_id = data.save_id 
  373. 		load_confirm(0, 0) 
  374. 	else  
  375. 		if game_is_waiting_for_partner() then 
  376. 			dialog_box_message("MENU_TITLE_NOTICE", "HUD_WAIT_FOR_PARTNER_TO_JOIN") 
  377. 			return 
  378. 		end 
  379. 		Save_id = data.save_id 
  380. 		dialog_box_destructive_confirmation("SAVELOAD_LOAD_GAME", "SAVELOAD_LOAD_GAME_CONFIRM_EXPOSITION", "load_confirm") 
  381. 		Input_tracker:subscribe(false) 
  382. 	end 
  383. 	 
  384. end 
  385.  
  386. function save_load_refresh(dont_unsubscribe_inputs) 
  387. 	if dont_unsubscribe_inputs == false then 
  388. 		Input_tracker:subscribe(false) --Nuke button subscription, will resubscribe after list redraws... 
  389. 		if Mouse_input_tracker ~= 0 then 
  390. 			Mouse_input_tracker:remove_all() 
  391. 		end 
  392. 	end 
  393.  
  394. 	-- Empty save game list to start until code flags an update 
  395. 	Save_load_data = {} 
  396. 	Save_load_data.row_alignment = {ALIGN_LEFT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT} 
  397. 	Save_load_data.row_column_count = 4 
  398. 	 
  399. 	Save_load_list:set_visible(false) 
  400.  
  401. 	Num_saves = 0 
  402. 	vint_dataresponder_request("save_system_populate", "save_game_populate", 0, Save_system_operation) 
  403. 	Save_load_list:set_properties(nil, nil, Save_load_max_visible, .8, Screen_width, false, true) 
  404. 	Save_load_list:draw_items(Save_load_data, 1)	 
  405. 	Save_load_list:set_visible(true) 
  406. 	save_load_set_hints_on_nav() 
  407.  
  408. 	local col_1_x, col_2_x, col_3_x, col_4_x = Save_load_list:row_get_column_positions() 
  409. 	save_load_align_header_columns(col_1_x, col_2_x, col_3_x, col_4_x) 
  410. 	save_load_set_header() 
  411. 	 
  412. 	Input_tracker:subscribe(true) 
  413. 	if Mouse_input_tracker ~= 0 then 
  414. 		save_load_reset_mouse_inputs(false) 
  415. 	end 
  416. 	 
  417. end 
  418.  
  419. function save_load_button_x(event, acceleration) 
  420. 	-- HVS_TJW, save_system_change_device() only functions on Xbox360, so we don't have to stop input on other platforms 
  421. 	if game_get_platform() == "XBOX360" then 
  422. 		save_system_change_device() 
  423. 		Input_tracker:subscribe(false) 
  424. 	end 
  425. end 
  426.  
  427. function save_load_delete_cb(result, action) 
  428. 	if result == 0 then 
  429. 		save_system_delete_game(Save_id) 
  430. 	else 
  431. 		Input_tracker:subscribe(true) 
  432. 	end 
  433. end 
  434.  
  435. function save_load_button_y(event, acceleration) 
  436. 	if Save_load_list:list_is_playing() == false then	 
  437. 		if not Device_selected then 
  438. 			return 
  439. 		end 
  440. 		 
  441. 		local current_button = Save_load_list:get_selection() 
  442. 		local data = Save_load_data[current_button] 
  443. 		if not data then 
  444. 			return 
  445. 		end 
  446.  
  447. 		if data.save_id == ID_NO_GAMES then 
  448. 			return 
  449. 		end 
  450. 			 
  451. 		if data.save_id == ID_NEW_SAVE_GAME then 
  452. 			return 
  453. 		end 
  454. 		 
  455. 		Save_id = data.save_id 
  456. 		dialog_box_confirmation("MENU_TITLE_WARNING", "MENU_DELETE_SAVE", "save_load_delete_cb",nil,nil,1) 
  457. 		Input_tracker:subscribe(false) 
  458. 	end 
  459. end 
  460.  
  461. function save_load_button_b(event, acceleration) 
  462. 	-- If the load was initiated from coop, then make sure we tell coop we're not loading. 
  463. 	if Load_for_coop == true then 
  464. 		save_system_cancel_coop_load() 
  465. 		Input_tracker:subscribe(false) 
  466. 		if Mouse_input_tracker ~= 0 then 
  467. 			Mouse_input_tracker:subscribe(false) 
  468. 			Hint_bar_mouse_input_tracker:subscribe(false) 
  469. 		end 
  470. 		Load_for_coop = false	-- reset the variable 
  471. 	end 
  472. 	 
  473. 	if Exit_after_closing == true then 
  474. 		pause_menu_quit_game_internal() 
  475. 		Exit_after_closing = false 
  476. 		Close_all_menu = false 
  477. 	elseif Close_all_menu == true then 
  478. 		Input_tracker:subscribe(false) 
  479. 		menu_common_transition_pop(3) 
  480. 		if Mouse_input_tracker ~= 0 then 
  481. 			Mouse_input_tracker:subscribe(false) 
  482. 			Hint_bar_mouse_input_tracker:subscribe(false) 
  483. 		end 
  484. 		Exit_after_closing = false		-- reset 
  485. 		Close_all_menu = false			-- reset 
  486. 		return 
  487. 	else 
  488. 		--Remove current menu from the stack 
  489. 		Input_tracker:subscribe(false) 
  490. 		menu_common_stack_remove() 
  491. 		menu_common_transition_pop(1) 
  492. 		if In_pause_menu then 
  493. 			Save_load_list:set_visible(true) 
  494. 		end 
  495. 		 
  496. 		if Mouse_input_tracker ~= 0 then 
  497. 			Mouse_input_tracker:subscribe(false) 
  498. 			Hint_bar_mouse_input_tracker:subscribe(false) 
  499. 		end 
  500. 	end 
  501. 	--[[ 
  502. 	if not In_pause_menu then 
  503. 		if Slide_out then 
  504. 			bg_saints_slide_out() 
  505. 			local anim = Vdo_anim_object:new("save_slide_in_anim", 0, Save_load_doc) 
  506. 			local twn_h = vint_object_find("save_screen_anchor", 0, Save_load_doc) 
  507. 			local twn_start_x,twn_start_y = vint_get_property(twn_h,"start_value") 
  508. 			local twn_end_x,twn_end_y = vint_get_property(twn_h,"end_value") 
  509. 			vint_set_property(twn_h,"start_value",twn_end_x,twn_end_y) 
  510. 			vint_set_property(twn_h,"end_value",-900,twn_start_y) 
  511. 			anim:play(0) 
  512. 		end  
  513. 	end 
  514. 	]] 
  515. end 
  516.  
  517. function save_load_button_start(event, acceleration) 
  518. 	if Exit_after_closing == true then 
  519. 		pause_menu_quit_game_internal() 
  520. 	else 
  521. 		local screen_grp_h = vint_object_find("screen_grp", 0, Save_load_doc) 
  522. 	 
  523. 		local screen_out_anim_h = vint_object_find("screen_out_anim", 0, Save_load_doc) 
  524. 		lua_play_anim(screen_out_anim_h, 0, Save_load_doc) 
  525. 		 
  526. 		menu_common_set_screen_data(List, Header_obj, Input_tracker, Screen_back_out_anim, Screen_out_anim, pause_menu_top_anim_in_done) 
  527.  
  528. 		bg_saints_slide_out() 
  529. 		 
  530. 		menu_common_transition_pop(3)	-- save_load, pause_menu_top, menu_common 
  531. 	end 
  532. end 
  533.  
  534. function save_load_set_button_hints(show_delete) 
  535. 	--Set Button hints 
  536. 	local hint_data 
  537. 	if (game_get_platform() == "PS3") or (game_get_platform() == "PS4") or (game_get_platform() == "XBOX3") then -- HVS_TJW, show hints on PS4 too, HVS_BT xbox3 too please! 
  538. 		hint_data = { 
  539. 			{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  540. 		} 
  541. 		 
  542. 		if show_delete then  
  543. 			hint_data[2] = {CTRL_BUTTON_Y, "MENU_OPTIONS_DELETE", game_get_key_name(211)} --"del" -- HVS_TJW, show delete button on these platforms too... 
  544. 		end 
  545. 	elseif (game_get_platform() == "XBOX360") then 
  546. 		hint_data = { 
  547. 			{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  548. 			{CTRL_BUTTON_X, "MENU_OPTIONS_SELECT_STORAGE"}, 
  549. 		} 
  550. 		 
  551. 		if show_delete then  
  552. 			hint_data[3] = {CTRL_BUTTON_Y, "MENU_OPTIONS_DELETE", game_get_key_name(211)} --"del" 
  553. 		end 
  554. 	elseif game_get_platform() == "PC" then 
  555. 		hint_data = { 
  556. 			{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  557. 		} 
  558. 		 
  559. 		if show_delete then  
  560. 			hint_data[2] = {CTRL_BUTTON_Y, "MENU_OPTIONS_DELETE", game_get_key_name(211)} --"del" 
  561. 			if Save_system_operation == SAVE_OPERATION_LOAD_GAME then 
  562. 				hint_data[3] = {CTRL_MENU_BUTTON_A, "COOP_LOAD_OLD_TEXT", game_get_key_name(28)} 
  563. 			else 
  564. 				hint_data[3] = {CTRL_MENU_BUTTON_A, "TRIGGER_SAVE", game_get_key_name(28)} 
  565. 			end 
  566. 		else 
  567. 			if Save_system_operation == SAVE_OPERATION_LOAD_GAME then 
  568. 				hint_data[2] = {CTRL_MENU_BUTTON_A, "COOP_LOAD_OLD_TEXT", game_get_key_name(28)} 
  569. 			else 
  570. 				hint_data[2] = {CTRL_MENU_BUTTON_A, "TRIGGER_SAVE", game_get_key_name(28)} 
  571. 			end 
  572. 		end 
  573. 	end 
  574. 	Menu_hint_bar:set_hints(hint_data)  
  575. 	Menu_hint_bar:set_visible(true) 
  576. 	Menu_hint_bar:set_alpha(1.0)	 
  577. end 
  578.  
  579. function save_load_set_header() 
  580. 	local current_button = Save_load_list:get_selection() 
  581. 	local data = Save_load_data[current_button] 
  582. 	 
  583. 	local save_image_h = vint_object_find("save_image", 0, Save_load_doc) 
  584. 	vint_set_property(save_image_h, "visible", false) 
  585. 	 
  586. 	if not data or data.has_data ~= true then 
  587. 		if Save_load_image == nil then 
  588. 			local new_image = Pause_save_images["generic"] 
  589. 			if Save_load_current_image ~= nil then 
  590. 				game_peg_unload(Save_load_current_image) 
  591. 			end 
  592. 			if new_image ~= nil then 
  593. 				-- must set save_load_loading_img before calling game_peg_load_with_cb(), which could fire the callback right away 
  594. 				Save_load_image = new_image                              
  595. 				game_peg_load_with_cb("save_load_show_image", 1, new_image) 
  596. 			end 
  597. 		end 
  598. 		vint_set_property(Save_load_stat_grp,"visible",false) 
  599. 		return 
  600. 	end 
  601. 	 
  602. 	--sets the new save file image 
  603. 	--Save_load_image = data.image 
  604. 	--game_peg_load_with_cb("save_load_image_done", 1, Save_load_image) 
  605. 		 
  606. 	local time_h = vint_object_find("time_value",0,Save_load_doc) 
  607. 	local completion_h = vint_object_find("completion_value",0,Save_load_doc) 
  608. 	local difficulty_h = vint_object_find("difficulty_value",0,Save_load_doc) 
  609. 	local missions_h = vint_object_find("missions_value",0,Save_load_doc) 
  610. 	local cash_h = vint_object_find("cash_value",0,Save_load_doc) 
  611. 	local save_cheat_text_h = vint_object_find("save_cheat_text",0,Save_load_doc) 
  612. 	 
  613. 	vint_set_property(time_h,"text_tag",data.game_time) 
  614. 	vint_set_property(completion_h,"text_tag",data.percent) 
  615. 	vint_set_property(difficulty_h,"text_tag",data.difficulty) 
  616. 	vint_set_property(missions_h,"text_tag",data.missions_completed) 
  617. 	vint_set_property(cash_h,"text_tag",data.cash) 
  618. 	 
  619. 	vint_set_property(save_cheat_text_h, "visible", data.is_cheat) 
  620.  
  621. 	Pause_Respect_meter:reset_first_update() 
  622. 	Pause_Respect_meter:update_respect(data.total_respect, data.current_respect_pct, data.rank, false) 
  623.  
  624. 	Pause_District_meter:update(data.district_control_pct) 
  625. 	 
  626. 	vint_set_property(Save_load_stat_grp,"visible",true) 
  627. 	 
  628. 	 
  629. 	 
  630. 	if Save_load_image == nil then 
  631. 		 
  632. 		local new_image 
  633. 		if data.image_name ~= nil and data.image_name ~= "" then 				 
  634. 			new_image = data.image_name 
  635. 		else 
  636. 			new_image = Pause_save_images["generic"] 
  637. 		end 
  638. 		 
  639. 		if Save_load_current_image ~= nil then 
  640. 			game_peg_unload(Save_load_current_image) 
  641. 		end 
  642. 		if new_image ~= nil then 
  643. 			-- must set save_load_loading_img before calling game_peg_load_with_cb(), which could fire the callback right away 
  644. 			Save_load_image = new_image 
  645. 			game_peg_load_with_cb("save_load_show_image", 1, new_image) 
  646. 		end 
  647. 	end 
  648. end 
  649.  
  650. -- Callback for when an image is done loading. 
  651. -- SEH: It might make sense to roll this into vdo_bitmap_viewer... 
  652. -- 
  653. function save_load_show_image() 
  654. 	local current_button = Save_load_list:get_selection() 
  655. 	local data = Save_load_data[current_button] 
  656. 	 
  657. 	local new_image 
  658. 	if data.image_name ~= nil and data.image_name ~= "" then 				 
  659. 		new_image = data.image_name 
  660. 	else 
  661. 		new_image = Pause_save_images["generic"] 
  662. 	end 
  663. 	 
  664. 	local save_image_h = vint_object_find("save_image", 0, Save_load_doc) 
  665. 	  
  666. 	if Save_load_image == new_image then 
  667. 		vint_set_property(save_image_h, "visible", true) 
  668. 		vint_set_property(save_image_h, "image", new_image) 
  669. 		Save_load_image = nil 
  670. 		Save_load_current_image = new_image 
  671. 	else 
  672. 		-- a new image was picked while we were loading - load this now, and unload the one we just loaded 
  673. 		if new_image ~= nil then 
  674. 			Save_load_unload_img = Save_load_image 
  675. 			Save_load_image = new_image 
  676. 			Save_load_image_update_thread = thread_new("save_load_image_update")           
  677. 		else 
  678. 			game_peg_unload(Save_load_image) 
  679. 			Save_load_image = nil 
  680. 		end 
  681. 	end 
  682. end 
  683.  
  684. function save_load_image_update() 
  685. 	 delay(0.2) 
  686. 	 game_peg_unload(Save_load_unload_img)  
  687. 	 game_peg_load_with_cb("save_load_show_image", 1, Save_load_image) 
  688. 	 Save_load_image_update_thread = -1 
  689. end 
  690.  
  691. function save_load_set_hints_on_nav() 
  692. 	local current_button = Save_load_list:get_selection() 
  693. 	local data = Save_load_data[current_button] 
  694. 	if not data then 
  695. 		save_load_set_button_hints(false) 
  696. 		return 
  697. 	end 
  698. 	 
  699. 	if not data or data.save_id == ID_NEW_SAVE_GAME or data.save_id == ID_NO_GAMES then 
  700. 		save_load_set_button_hints(false) 
  701. 	else 
  702. 		save_load_set_button_hints(true) 
  703. 	end 
  704. 	save_load_reset_mouse_inputs(true) 
  705. end 
  706.  
  707. -- Mouse inputs 
  708. function save_load_mouse_click(event, target_handle, mouse_x, mouse_y) 
  709. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  710. 	 
  711. 	if hint_index == 1 then 
  712. 		save_load_button_b() 
  713. 	end 
  714. 	if hint_index == 2 then 
  715. 		if Save_system_operation == SAVE_OPERATION_SAVE_GAME then 
  716. 			local current_button = Save_load_list:get_selection() 
  717. 			if current_button == 1 then 
  718. 				save_button_a() 
  719. 			else 
  720. 				save_load_button_y() 
  721. 			end 
  722. 		else 
  723. 			save_load_button_y() 
  724. 		end 
  725. 	end 
  726. 	if hint_index == 3 then 
  727. 		if Save_system_operation == SAVE_OPERATION_SAVE_GAME then 
  728. 			save_button_a() 
  729. 		else 
  730. 			load_button_a() 
  731. 		end 
  732. 	end 
  733.  
  734. 	local new_index = Save_load_list:get_button_index(target_handle) 
  735. 	 
  736. 	if new_index ~= 0 then 
  737. 		Save_load_list:set_selection(new_index) 
  738. 		Save_load_list:move_cursor(0, true) 
  739. 		save_load_set_header() 
  740. 		save_load_set_hints_on_nav() 
  741. 		 
  742. 		if( Previous_save_load_list_index == new_index) then 
  743. 			if Save_system_operation == SAVE_OPERATION_SAVE_GAME then 
  744. 				save_button_a() 
  745. 			else 
  746. 				load_button_a() 
  747. 			end 
  748. 		end 
  749. 	end 
  750. 	Previous_save_load_list_index = new_index 
  751. end 
  752.  
  753. function save_load_mouse_move(event, target_handle) 
  754. 	Menu_hint_bar:set_highlight(0) 
  755. 	 
  756. 	local hint_index = Menu_hint_bar:get_hint_index(target_handle) 
  757. 	if hint_index ~= 0 then 
  758. 		Menu_hint_bar:set_highlight(hint_index) 
  759. 	end 
  760. 	 
  761. 	local new_index = Save_load_list:get_button_index(target_handle) 
  762. 	Save_load_list:set_mouse_highlight(new_index) 
  763. end 
  764.  
  765. function save_load_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines) 
  766. 	if scroll_lines ~= 0 then 
  767. 		if Save_load_list:get_scroll_region_handle() == target_handle then 
  768. 			Save_load_list:scroll_list(scroll_lines * -1) 
  769. 			save_load_reset_mouse_inputs(false) 
  770. 		end 
  771. 	end 
  772. end 
  773.  
  774. function save_load_mouse_drag(event, target_handle, mouse_x, mouse_y) 
  775. 	if Save_load_list.scrollbar.tab_grp.handle == target_handle then 
  776. 		local new_start_index = Save_load_list.scrollbar:drag_scrolltab(mouse_y, Save_load_list.num_buttons - (Save_load_list.max_buttons - 1)) 
  777. 		Save_load_list:scroll_list(0, new_start_index) 
  778. 	end 
  779. end 
  780.  
  781. -- Updates the mouse inputs for the list and snaps the scrolltab to the closest notch based on the visible index 
  782. -- 
  783. function save_load_mouse_drag_release(event, target_handle, mouse_x, mouse_y) 
  784. 	if Save_load_list.scrollbar.tab_grp.handle == target_handle then 
  785. 		local start_index = Save_load_list:get_visible_indices() 
  786. 		Save_load_list.scrollbar:release_scrolltab(start_index, Save_load_list.num_buttons - (Save_load_list.max_buttons - 1)) 
  787. 		save_load_reset_mouse_inputs(false) 
  788. 	end 
  789. end 
  790.  
  791. function save_load_reset_mouse_inputs(hint_only) 
  792. 	if Mouse_input_tracker ~= 0 then 
  793. 		if hint_only == false then 
  794. 			Mouse_input_tracker:remove_all() 
  795. 			Save_load_list:add_mouse_inputs("save_load", Mouse_input_tracker) 
  796. 			Mouse_input_tracker:subscribe(true) 
  797. 		end 
  798. 		Hint_bar_mouse_input_tracker:remove_all() 
  799. 		Menu_hint_bar:add_mouse_inputs("save_load", Hint_bar_mouse_input_tracker) 
  800. 		Hint_bar_mouse_input_tracker:subscribe(true) 
  801. 	end 
  802. end 
  803.  
  804. function save_load_mask_morph( screen_type, size_end_x, anchor_end_x ) 
  805. 	 
  806. end 
  807.  
  808. function save_load_set_slide_in_values( new_x ) 
  809.  
  810. --[[ 
  811.  
  812. 	local header_anchor_twn_h = vint_object_find("save_header_back_anchor", 0, Save_load_doc)  
  813. 	local list_anchor_twn_h = vint_object_find("save_list_back_anchor", 0, Save_load_doc)  
  814. 	local row_anchor_twn_h = vint_object_find("save_row_back_anchor", 0, Save_load_doc) 
  815. 	local image_anchor_twn_h = vint_object_find("save_image_back_anchor", 0, Save_load_doc)  
  816. 	local stats_anchor_twn_h = vint_object_find("save_stats_back_anchor", 0, Save_load_doc)  
  817. 	 
  818. 	local header_x,header_y = vint_get_property(header_anchor_twn_h, "end_value") 
  819. 	local list_x,list_y = vint_get_property(list_anchor_twn_h, "end_value") 
  820. 	local row_x,row_y = vint_get_property(row_anchor_twn_h, "end_value") 
  821. 	local image_x,image_y = vint_get_property(image_anchor_twn_h, "end_value") 
  822. 	local stats_x,stats_y = vint_get_property(stats_anchor_twn_h, "end_value") 
  823. 	 
  824. 	local ctrl_offset = 46 
  825. 	local header_offset = 30 
  826. 	local list_offset = 0 
  827. 	local row_offset = 6 
  828. 	local image_offset = 0 
  829. 	local stats_offset = 372 
  830. 	if vint_is_std_res() == true then 
  831. 		ctrl_offset = 75 
  832. 		header_offset = 60 
  833. 		list_offset = 28 
  834. 		row_offset = -28 
  835. 		image_offset = 28 
  836. 		stats_offset = 400 
  837. 	end 
  838. 	 
  839. 	--vint_set_property(header_anchor_twn_h, "end_value", new_x + header_offset, header_y) 
  840. 	--vint_set_property(list_anchor_twn_h, "end_value", new_x + list_offset, list_y) 
  841. 	--vint_set_property(row_anchor_twn_h, "end_value", new_x - row_offset, row_y) 
  842. 	--vint_set_property(image_anchor_twn_h, "end_value", new_x + image_offset, image_y) 
  843. 	--vint_set_property(stats_anchor_twn_h, "end_value", new_x + stats_offset, stats_y) 
  844. 	 
  845. 	]] 
  846. end 
  847.  
  848.  
  849. function save_load_align_header_columns(col_1, col_2, col_3, col_4) 
  850. 	local mission_name_label_h = vint_object_find("mission_name_label", 	0, Save_load_doc) 
  851. 	local date_label_h 			= vint_object_find("date_label", 			0, Save_load_doc) 
  852. 	local completion_label_h 	= vint_object_find("completion_label", 	0, Save_load_doc) 
  853. 	local time_label_h 			= vint_object_find("time_label", 			0, Save_load_doc) 
  854. 	 
  855. 	local shift_x = 8 
  856. 	local x, y = vint_get_property(mission_name_label_h, "anchor") 
  857. 	vint_set_property(mission_name_label_h, "anchor", col_1 + shift_x, y) 
  858. 	 
  859. 	x, y = vint_get_property(completion_label_h, "anchor") 
  860. 	vint_set_property(completion_label_h, "anchor", col_2 + shift_x, y) 
  861. 	 
  862. 	x, y = vint_get_property(time_label_h, "anchor") 
  863. 	vint_set_property(time_label_h, "anchor", col_3 + shift_x, y) 
  864. 	 
  865. 	x, y = vint_get_property(date_label_h, "anchor") 
  866. 	vint_set_property(date_label_h, "anchor", col_4 + shift_x, y) 
  867. 	 
  868. 	--resize line 
  869. 	local header_line_h = vint_object_find("header_line", 0, Save_load_doc) 
  870. 	element_set_actual_size(header_line_h, col_4 + shift_x - 44, 2) 
  871. 	 
  872. end 
  873.  
  874. function save_load_ps3_complete(success, should_exit_menu) 
  875. 	if Load_for_coop == true then 
  876. 		if success == true then 
  877. 			if Main_menu_coop_is_xbox_live then 
  878. 				game_coop_start_new_live() 
  879. 			else  
  880. 				game_coop_start_new_syslink() 
  881. 			end 
  882. 		else  
  883. 			save_system_cancel_coop_load() 
  884. 		end 
  885. 	end 
  886.  
  887. 	if should_exit_menu == false then 
  888. 		return 
  889. 	end 
  890. 	 
  891. 	if Exit_after_closing == true then 
  892. 		pause_menu_quit_game_internal() 
  893. 	elseif Close_all_menu == true then 
  894. 		menu_common_stack_remove() 
  895. 		menu_common_transition_pop(3) 
  896. 		Save_load_list:set_visible(true) 
  897. 		 
  898. 		if Mouse_input_tracker ~= 0 then 
  899. 			Mouse_input_tracker:subscribe(false) 
  900. 			Hint_bar_mouse_input_tracker:subscribe(false) 
  901. 		end 
  902. 	else 
  903. 		--Remove current menu from the stack 
  904. 		menu_common_stack_remove() 
  905. 		menu_common_transition_pop(1) 
  906. 		Save_load_list:set_visible(true) 
  907. 		 
  908. 		if Mouse_input_tracker ~= 0 then 
  909. 			Mouse_input_tracker:subscribe(false) 
  910. 			Hint_bar_mouse_input_tracker:subscribe(false) 
  911. 		end 
  912. 	end 
  913. 	--[[ 
  914. 	if not In_pause_menu then 
  915. 		if Slide_out then 
  916. 			bg_saints_slide_out() 
  917. 			local anim = Vdo_anim_object:new("save_slide_in_anim", 0, Save_load_doc) 
  918. 			local twn_h = vint_object_find("save_screen_anchor", 0, Save_load_doc) 
  919. 			local twn_start_x,twn_start_y = vint_get_property(twn_h,"start_value") 
  920. 			local twn_end_x,twn_end_y = vint_get_property(twn_h,"end_value") 
  921. 			vint_set_property(twn_h,"start_value",twn_end_x,twn_end_y) 
  922. 			vint_set_property(twn_h,"end_value",-900,twn_start_y) 
  923. 			anim:play(0) 
  924. 		end 
  925. 	end 
  926. 	]] 
  927. end