./pause_menu_common.lua

  1. Menu_hint_bar = -1 
  2.  
  3. SAVE_OPERATION_SAVE_GAME = 0 
  4. SAVE_OPERATION_LOAD_GAME = 1 
  5. Save_system_operation = SAVE_OPERATION_LOAD_GAME 
  6.  
  7. COOP_INVITE_LIST			= 0 
  8. COOP_ONLINE_JOIN_LIST  	= 1 
  9. COOP_SYSLINK_JOIN_LIST 	= 2 
  10. Coop_connect_operation = COOP_INVITE_LIST 
  11.  
  12. In_pause_menu = true 
  13. Load_for_coop = false 
  14. Exit_after_closing = false 
  15. Save_message_displayed = false 
  16. Close_all_menu = false 
  17.  
  18. Pause_menu_common_doc_h = -1 
  19.  
  20. Header_obj = -1 
  21. List = -1 
  22. Screen_mask = -1 
  23. Screen_slide_out_anim = -1 
  24. Screen_slide_in_anim = -1 
  25. Screen_in_anim = -1 
  26. Screen_out_anim = -1 
  27. Screen_back_in_anim = -1 
  28. Screen_back_out_anim = -1 
  29.  
  30. First_time = true 
  31. Start_game_after_display = false 
  32. Join_friend_after_display = -1 
  33.  
  34. function pause_menu_common_init() 
  35. 	 
  36. 	Pause_menu_common_doc_h = vint_document_find("pause_menu_common") 
  37.  
  38. 	--Apply purple lut! 
  39. 	pause_menu_lut_effect("lut_completion_screen") 
  40. 	 
  41. 	-- Play sound effect for pause menu starting up 
  42. 	--play_ui_sound( "INT_PAUSE" ) 
  43. 	 
  44. 	--Initialize Hint Bar store it to global Menu_hint_bar 
  45. 	Menu_hint_bar = Vdo_hint_bar:new("hint_bar") 
  46. 	 
  47. 	Screen_mask = vint_object_find("screen_mask",0,Pause_menu_common_doc_h) 
  48. 	 
  49. 	Screen_in_anim = Vdo_anim_object:new("screen_in_anim",0,Pause_menu_common_doc_h) 
  50. 	local twn = Vdo_tween_object:new("screen_in_twn", Screen_in_anim.handle) 
  51. 	twn:set_end_event("menu_common_anim_in_cb") 
  52. 	 
  53. 	Screen_out_anim = Vdo_anim_object:new("screen_out_anim",0,Pause_menu_common_doc_h) 
  54. 	local twn2 = Vdo_tween_object:new("screen_out_twn", Screen_out_anim.handle) 
  55. 	twn2:set_end_event("menu_common_anim_out_cb") 
  56. 	 
  57. 	Screen_slide_out_anim = Vdo_anim_object:new("screen_slide_out_anim",0,Pause_menu_common_doc_h) 
  58. 	local twn_out = Vdo_tween_object:new("screen_slide_out_twn1", Screen_slide_out_anim.handle) 
  59. 	twn_out:set_end_event("menu_common_anim_out_cb") 
  60. 	 
  61. 	Screen_slide_in_anim = Vdo_anim_object:new("screen_slide_in_anim",0,Pause_menu_common_doc_h) 
  62. 	local twn_in = Vdo_tween_object:new("screen_slide_in_twn1", Screen_slide_in_anim.handle) 
  63. 	twn_in:set_end_event("menu_common_anim_in_cb") 
  64. 	 
  65. 	Screen_back_in_anim = Vdo_anim_object:new("screen_back_in_anim",0,Pause_menu_common_doc_h) 
  66. 	local twn_back_in = Vdo_tween_object:new("back_in_twn1", Screen_back_in_anim.handle) 
  67. 	twn_back_in:set_end_event("menu_common_anim_in_cb") 
  68. 	 
  69. 	Screen_back_out_anim = Vdo_anim_object:new("screen_back_out_anim",0,Pause_menu_common_doc_h) 
  70. 	local twn_back_out = Vdo_tween_object:new("back_out_twn1", Screen_back_out_anim.handle) 
  71. 	twn_back_out:set_end_event("menu_common_anim_out_cb") 
  72. 	 
  73. 	List = Vdo_mega_list:new("list",0,Pause_menu_common_doc_h) 
  74. 	List:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY) 
  75. 	 
  76. 	Header_obj = Vdo_pause_header:new("header",0,Pause_menu_common_doc_h) 
  77.  
  78. 	bg_saints_show(false) 
  79.  
  80. 	vint_apply_start_values(Screen_in_anim.handle) 
  81. end 
  82.  
  83. function pause_menu_common_cleanup() 
  84. 	-- Possibly, free up controller memory when document is unloaded... 
  85. 	-- This also happens in pause_options_controls_config() but is done here in case the user presses 
  86. 	-- The back button... 
  87. 	pause_menu_control_scheme_init(false) 
  88.  
  89. 	--Remove purple lut... 
  90. 	pause_menu_lut_effect("none") 
  91. end 
  92.  
  93. function pause_menu_common_server_drop() 
  94. 	Save_system_operation = SAVE_OPERATION_SAVE_GAME 
  95. 	Exit_after_closing = true 
  96. 	push_screen("pause_save_game") 
  97. end 
  98.  
  99. function pause_menu_common_open_invite() 
  100. 	Exit_after_closing = true 
  101. 	push_screen("pause_invite_friends") 
  102. end 
  103.  
  104. function pause_menu_common_open_cheat_save() 
  105. 	Save_system_operation = SAVE_OPERATION_SAVE_GAME 
  106. 	Close_all_menu = true 
  107. 	push_screen("pause_save_game") 
  108. end 
  109.  
  110. function pause_menu_intro_done() 
  111.  
  112. 	-- Jeff: This needs to be setup properly 
  113. 	--pause_menu_top_anim_in() 
  114.  
  115. end 
  116.  
  117. -- Make the pause menu megalist look pause menu 
  118. -- 
  119. function pause_menu_set_style(List, Header, Width, Num_pops) 
  120. 	--get the list width 
  121. 	local list_w, list_h = vint_get_property(List.handle, "screen_size") 
  122. 	list_w = Width or list_w 
  123. 	 
  124. 	Header:set_visible(true) 
  125. 	List:set_visible(true) 
  126. 	 
  127. 	local max_width = 650 
  128. 	local back_out_twn1_h = vint_object_find("back_out_twn1", Screen_back_out_anim.handle) 
  129. 	local back_out_twn2_h = vint_object_find("back_out_twn2", Screen_back_out_anim.handle) 
  130. 	local back_out_twn3_h = vint_object_find("back_out_twn3", Screen_back_out_anim.handle) 
  131. 	 
  132. 	if list_w > max_width then 
  133. 		vint_set_property(back_out_twn1_h, "end_value", -1 * max_width, 652) 
  134. 		vint_set_property(back_out_twn2_h, "end_value", -1 * max_width, 230) 
  135. 		vint_set_property(back_out_twn3_h, "end_value", -1 * max_width, 267) 
  136. 	else 
  137. 		vint_set_property(back_out_twn1_h, "end_value", -300, 652) 
  138. 		vint_set_property(back_out_twn2_h, "end_value", -300, 230) 
  139. 		vint_set_property(back_out_twn3_h, "end_value", -300, 267) 
  140. 	end 
  141. 	 
  142. 	local bg_anchor = 100 
  143. 	if vint_is_std_res() then 
  144. 		bg_anchor = 74 
  145. 	end 
  146. 	 
  147. 	if not First_time then 
  148. 		bg_saints_set_type(BG_TYPE_STRONGHOLD, true, list_w, bg_anchor) 
  149. 		local mask_x,mask_y = vint_get_property(Screen_mask,"anchor") 
  150. 		pause_menu_mask_morph(BG_TYPE_STRONGHOLD, list_w, mask_x) 
  151. 			 
  152. 		if Num_pops > 0 then 
  153. 			vint_apply_start_values(Screen_slide_in_anim.handle) 
  154. 			Screen_slide_in_anim:play(0) 
  155. 		else 
  156. 			vint_apply_start_values(Screen_back_in_anim.handle) 
  157. 			Screen_back_in_anim:play(0) 
  158. 		end 
  159. 	else 
  160. 		vint_set_property(Screen_mask,"screen_size",list_w,800) 
  161. 		bg_saints_set_type(BG_TYPE_STRONGHOLD, false, list_w, bg_anchor) 
  162. 	end 
  163. end 
  164.  
  165. function pause_menu_mask_morph( screen_type, size_end_x, anchor_end_x ) 
  166. 	--get handles for everyone 
  167. 	local morph_anim_h = vint_object_find("screen_mask_anim", 0, Pause_menu_common_doc_h) 
  168. 	local morph_scale_twn_h = vint_object_find("screen_mask_scale_twn", 0, Pause_menu_common_doc_h) 
  169. 	local morph_anchor_twn_h = vint_object_find("screen_mask_anchor_twn", 0, Pause_menu_common_doc_h)  
  170. 	 
  171. 	--set up the left shadow start and end values 
  172. 	--get the starting x position 
  173. 	--create the center anchor point from the width of the mask, only if we are center aligned 
  174. 	if screen_type == BG_TYPE_CENTER then 
  175. 		anchor_end_x = (anchor_end_x) - (size_end_x * 0.5) 
  176. 	end 
  177. 	 
  178. 	--setup the anchor for the mask 
  179. 	--get the starting x position 
  180. 	local mask_anchor_start_x,mask_anchor_start_y = vint_get_property( Screen_mask, "anchor" ) 
  181. 	vint_set_property(morph_anchor_twn_h, "start_value", mask_anchor_start_x, mask_anchor_start_y ) 
  182. 	vint_set_property(morph_anchor_twn_h, "end_value", anchor_end_x, mask_anchor_start_y ) 
  183. 	 
  184. 	--setup the scale of the mask 
  185. 	--get the starting scale 
  186. 	local size_start_x,size_start_y = vint_get_property(Screen_mask,"scale") 
  187. 	--get the correct size, this fixes SD scale issues 
  188. 	local adjusted_size_end_x,crap = element_get_scale_from_size(Screen_mask, size_end_x, 16) 
  189. 	vint_set_property(morph_scale_twn_h, "start_value", size_start_x , size_start_y) 
  190. 	vint_set_property(morph_scale_twn_h, "end_value", adjusted_size_end_x , size_start_y) 
  191. 	 
  192. 	--play the animation 
  193. 	lua_play_anim(morph_anim_h, 0, Pause_menu_common_doc_h)	 
  194. end 
  195.  
  196.  
  197.  
  198. --Wrapper for c++ lut swap function... 
  199. function pause_menu_lut_effect(lut_table_string) 
  200.  
  201. 	if lut_table_string ~= "none" then 
  202. 		local platform = game_get_platform() 
  203. 		local lut_platform_string = "" 
  204. 		 
  205. 		if platform == "PS3" then 
  206. 			lut_platform_string = "_ps3" 
  207. 		elseif platform == "XBOX360" then 
  208. 			lut_platform_string = "_xbox2" 
  209. 		elseif platform == "PC" then 
  210. 			lut_platform_string = "_pc" 
  211. 		end 
  212. 		completion_load_lut(lut_table_string .. lut_platform_string) 
  213. 	else 
  214. 		completion_load_lut(lut_table_string) 
  215. 	end 
  216. end