./pause_save_game.lua

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