./main_menu_common.lua

  1. Menu_hint_bar = -1 
  2. Main_menu_coop_is_xbox_live = -1			-- bool to determine whether main_menu_coop is xbox live or system link... 
  3. Main_menu_common_doc = -1 
  4.  
  5. Header_obj = -1 
  6. List = -1 
  7. Screen_mask = -1 
  8. Screen_slide_out_anim = -1 
  9. Screen_slide_in_anim = -1 
  10. Screen_in_anim = -1 
  11. Screen_out_anim = -1 
  12. Screen_back_in_anim = -1 
  13. Screen_back_out_anim = -1 
  14.  
  15. SAVE_OPERATION_SAVE_GAME = 0 
  16. SAVE_OPERATION_LOAD_GAME = 1 
  17. Save_system_operation = SAVE_OPERATION_LOAD_GAME 
  18.  
  19. COOP_INVITE_LIST			= 0 
  20. COOP_ONLINE_JOIN_LIST  	= 1 
  21. COOP_SYSLINK_JOIN_LIST 	= 2 
  22. Coop_connect_operation = COOP_ONLINE_JOIN_LIST 
  23.  
  24. Enter_dlc_menu = false 
  25. Load_for_coop = false 
  26. In_pause_menu = false 
  27. Exit_after_closing = false 
  28. Whored_mode_active = false 
  29. First_time = true 
  30. Save_message_displayed = false 
  31. Start_game_after_display = false 
  32. Show_continue = false 
  33. Press_start_called = false 
  34. Close_all_menu = false 
  35. Join_friend_after_display = -1 
  36.  
  37. -- PC Menu has height adjusted 
  38. local PC_menu_adjusted = false 
  39.  
  40. function main_menu_common_init() 
  41. 	Main_menu_common_doc = vint_document_find("main_menu_common") 
  42.  
  43. 	-- Japanese Logo version... 
  44. 	local logo_jp_h = vint_object_find("logo_jp") 
  45. 	 
  46. 	--Adjust logo if we are japanese... 
  47. 	if game_get_language() == "JP" then 
  48. 		vint_set_property(logo_jp_h, "visible", true) 
  49. 	else 
  50. 		vint_set_property(logo_jp_h, "visible", false) 
  51. 	end 
  52. 	 
  53. 	List = Vdo_mega_list:new("list",0,Main_menu_common_doc) 
  54. 	List:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY) 
  55. 	 
  56. 	Header_obj = Vdo_pause_header:new("header",0,Main_menu_common_doc) 
  57. 	 
  58. 	List:set_visible(false) 
  59. 	Header_obj:set_visible(false) 
  60. 	 
  61. 	Screen_mask = vint_object_find("screen_mask",0,Main_menu_common_doc) 
  62. 	 
  63. 	Screen_in_anim = Vdo_anim_object:new("screen_in_anim",0,Main_menu_common_doc) 
  64. 	local twn = Vdo_tween_object:new("screen_in_twn", Screen_in_anim.handle) 
  65. 	twn:set_end_event("menu_common_anim_in_cb") 
  66. 	 
  67. 	Screen_out_anim = Vdo_anim_object:new("screen_out_anim",0,Main_menu_common_doc) 
  68. 	local twn2 = Vdo_tween_object:new("screen_out_twn", Screen_out_anim.handle) 
  69. 	twn2:set_end_event("menu_common_anim_out_cb") 
  70. 	 
  71. 	Screen_slide_out_anim = Vdo_anim_object:new("screen_slide_out_anim",0,Main_menu_common_doc) 
  72. 	local twn_out = Vdo_tween_object:new("screen_slide_out_twn1", Screen_slide_out_anim.handle) 
  73. 	twn_out:set_end_event("menu_common_anim_out_cb") 
  74. 	 
  75. 	Screen_slide_in_anim = Vdo_anim_object:new("screen_slide_in_anim",0,Main_menu_common_doc) 
  76. 	local twn_in = Vdo_tween_object:new("screen_slide_in_twn1", Screen_slide_in_anim.handle) 
  77. 	twn_in:set_end_event("menu_common_anim_in_cb") 
  78. 	 
  79. 	Screen_back_in_anim = Vdo_anim_object:new("screen_back_in_anim",0,Main_menu_common_doc) 
  80. 	local twn_back_in = Vdo_tween_object:new("back_in_twn1", Screen_back_in_anim.handle) 
  81. 	twn_back_in:set_end_event("menu_common_anim_in_cb") 
  82. 	 
  83. 	Screen_back_out_anim = Vdo_anim_object:new("screen_back_out_anim",0,Main_menu_common_doc) 
  84. 	local twn_back_out = Vdo_tween_object:new("back_out_twn1", Screen_back_out_anim.handle) 
  85. 	twn_back_out:set_end_event("menu_common_anim_out_cb") 
  86. 	 
  87. 	bg_saints_show(false) 
  88. 	 
  89. 	bg_saints_set_type(BG_TYPE_CENTER,true) 
  90. 	 
  91. 	--Hide everything on init... 
  92. 	main_menu_logo_hide() 
  93. 	 
  94. 	-- Move the title up on PC to make room for the extra options 
  95. 	if game_get_platform() == "PC" and PC_menu_adjusted == false then 
  96. 		local base_logo_h = vint_object_find("base_logo") 
  97. 		local x, y = vint_get_property(base_logo_h, "anchor") 
  98. 		if vint_is_std_res() then 
  99. 			vint_set_property(base_logo_h, "anchor", x, y - 35) 
  100. 		else 
  101. 			vint_set_property(base_logo_h, "anchor", x, y - 25) 
  102. 		end 
  103. 		PC_menu_adjusted = true 
  104. 	end 
  105. end 
  106.  
  107. function main_menu_common_cleanup() 
  108. end 
  109.  
  110. ------------------------------------------------------------------------------- 
  111. -- Start the bg video... 
  112. ------------------------------------------------------------------------------- 
  113. function main_menu_start_video(has_pressed_start) 
  114. 	bg_saints_set_video("main_menu_bg.bik") 
  115. 	if not has_pressed_start then 
  116. 		bg_saints_press_start_setup() 
  117. 	end 
  118. 	bg_saints_play_video(true, "video_stopped") 
  119. 	 
  120. 	if has_pressed_start == true then  
  121. 		bg_saints_main_menu_setup() 
  122. 	end 
  123. end 
  124.  
  125. function main_menu_stop_video() 
  126. 	bg_saints_play_video(false, "video_stopped") 
  127. end 
  128.  
  129. function video_stopped() 
  130. 	main_menu_video_has_stopped() 
  131. end 
  132.  
  133. function main_menu_common_reset() 
  134. 	main_menu_restart_video() 
  135. 	-- Move the title up on PC to make room for the extra options 
  136. 	if game_get_platform() == "PC" then 
  137. 		local base_logo_h = vint_object_find("base_logo") 
  138. 		local x, y = vint_get_property(base_logo_h, "anchor") 
  139. 		if vint_is_std_res() then 
  140. 			vint_set_property(base_logo_h, "anchor", x, y - 35) 
  141. 		else 
  142. 			vint_set_property(base_logo_h, "anchor", x, y - 25) 
  143. 		end 
  144. 		PC_menu_adjusted = true 
  145. 	end 
  146. end 
  147.  
  148. ------------------------------------------------------------------------------- 
  149. -- Show logo... 
  150. ------------------------------------------------------------------------------- 
  151. function main_menu_logo_show() 
  152. 	--show the main menu logo. 
  153. 	local intro_logo_anim_h = vint_object_find("intro_logo_anim", 0, Main_menu_common_doc) 
  154. 	lua_play_anim(intro_logo_anim_h, 0, Main_menu_common_doc) 
  155. 	First_time = true 
  156. end 
  157.  
  158. ------------------------------------------------------------------------------- 
  159. -- Hide logo... 
  160. ------------------------------------------------------------------------------- 
  161. function main_menu_logo_hide() 
  162. 	--we probably don't need this... 
  163. 	local intro_logo_anim_h = vint_object_find("intro_logo_anim", 0, Main_menu_common_doc) 
  164. 	vint_set_property(intro_logo_anim_h, "is_paused", true) 
  165. 	 
  166. 	local logo_h = vint_object_find("logo", 0, Main_menu_common_doc) 
  167. 	vint_set_property(logo_h, "alpha", 0) 
  168. 	 
  169. end 
  170.  
  171. ------------------------------------------------------------------------------- 
  172. ---LEGACY C++ stuff from the old main menu... 
  173. -- Lets clean this up. 
  174. ------------------------------------------------------------------------------- 
  175. function main_menu_controller_selected(show_continue) 
  176. 	Main_menu_controller_is_selected = true 
  177. 	Show_continue = show_continue 
  178. 	 
  179. 	main_menu_top_press_start_hide() 
  180. 	main_menu_top_menu_show() 
  181. 	 
  182. 	if Press_start_called == false then 
  183. 		bg_saints_main_menu_setup() 
  184. 		Press_start_called = true 
  185. 	end 
  186. end 
  187.  
  188. --FORCES the player to a specific menu... 
  189. function main_menu_force_to_menu() 
  190. 	--Don't do anything because we shouldn't 
  191. --[[ 
  192. 	if Main_menu_controller_selected == false then 
  193. 		Main_menu_first_menu = menu_name 
  194. 	else 
  195. 		main_menu_close_extra_screens(true) 
  196. 		if menu_name == "top" then 
  197. 			if Main_menu_controller_selected == true then 
  198. 				menu_hide_active() 
  199. 				vint_set_property(vint_object_find("safe_frame"), "visible", true) 
  200. 				Main_menu_can_has_input = true 
  201. 				menu_input_block(false) 
  202. 				main_menu_screen_fade(0) 
  203. 			end 
  204. 			 
  205. 			main_menu_grab_input() 
  206. 			dialog_box_force_close_all() 
  207. 		elseif menu_name == "coop_load" then 
  208. 			credits_force_close() 
  209. 			Pause_load_is_coop = true 
  210. 			vint_set_property(vint_object_find("safe_frame"), "visible", true) 
  211. 			main_menu_load_menu_select() 
  212. 		elseif menu_name == "customize" then 
  213. 			vint_set_property(vint_object_find("safe_frame"), "visible", true) 
  214. 			main_menu_customize_menu_select() 
  215. 		end 
  216. 	end 
  217. ]] 
  218. end 
  219.  
  220. function main_menu_nav(target, event) 
  221. 	-- We will try and use input tracker... 
  222. 	--do nothing 
  223. end 
  224.  
  225. function load_before_join() 
  226. 	Load_for_coop = true 
  227. 	push_screen("pause_save_game") 
  228. end 
  229.  
  230. -- Make the megalist look main menuy 
  231. -- 
  232. function main_menu_set_style(List, Header, Width, Num_pops) 
  233. 	 
  234. 	Header:set_visible(true) 
  235. 	List:set_visible(true) 
  236. 	 
  237. 	--get the list width 
  238. 	local list_w, list_h = vint_get_property(List.handle, "screen_size") 
  239. 	list_w = Width or list_w 
  240.  
  241. 	local new_x 
  242. 	if vint_is_std_res() == false then 
  243. 		new_x = 640 
  244. 	else 
  245. 		new_x = 320 * 1.5 
  246. 	end 
  247. 	new_x = new_x - (list_w * 0.5) 
  248. 	 
  249. 	local list_tween_h 
  250. 	local header_tween_h 
  251. 	local hint_bar_tween_h 
  252. 	 
  253. 	local max_width = 650 
  254. 	local back_out_twn1_h = vint_object_find("back_out_twn1", Screen_back_out_anim.handle) 
  255. 	local back_out_twn2_h = vint_object_find("back_out_twn2", Screen_back_out_anim.handle) 
  256. 	local back_out_twn3_h = vint_object_find("back_out_twn3", Screen_back_out_anim.handle) 
  257. 	 
  258. 	local slide_out_twn1_h = vint_object_find("screen_slide_out_twn1", Screen_slide_out_anim.handle) 
  259. 	local slide_out_twn2_h = vint_object_find("screen_slide_out_twn2", Screen_slide_out_anim.handle) 
  260. 	local slide_out_twn3_h = vint_object_find("screen_slide_out_twn3", Screen_slide_out_anim.handle) 
  261. 	 
  262. 	if list_w > max_width then 
  263. 		vint_set_property(back_out_twn1_h, "end_value", -1 * max_width, 652) 
  264. 		vint_set_property(back_out_twn2_h, "end_value", -1 * max_width, 230) 
  265. 		vint_set_property(back_out_twn3_h, "end_value", -1 * max_width, 267) 
  266. 		 
  267. 		vint_set_property(slide_out_twn1_h, "end_value", 1100, 652) 
  268. 		vint_set_property(slide_out_twn2_h, "end_value", 1100, 267) 
  269. 		vint_set_property(slide_out_twn3_h, "end_value", 1150, 230) 
  270. 	else 
  271. 		vint_set_property(back_out_twn1_h, "end_value", -300, 652) 
  272. 		vint_set_property(back_out_twn2_h, "end_value", -300, 230) 
  273. 		vint_set_property(back_out_twn3_h, "end_value", -300, 267) 
  274. 		 
  275. 		vint_set_property(slide_out_twn1_h, "end_value", 900, 652) 
  276. 		vint_set_property(slide_out_twn2_h, "end_value", 900, 267) 
  277. 		vint_set_property(slide_out_twn3_h, "end_value", 950, 230) 
  278. 	end 
  279. 	 
  280. 	if not First_time then 
  281. 		bg_saints_set_type(BG_TYPE_CENTER, true, list_w) 
  282. 		local mask_x,mask_y = vint_get_property(Screen_mask, "anchor") 
  283. 		main_menu_mask_morph(BG_TYPE_CENTER, list_w, new_x) 
  284. 			 
  285. 		if Num_pops > 0 then 
  286. 			main_menu_set_slide_in_values( new_x ) 
  287. 			vint_apply_start_values(Screen_slide_in_anim.handle) 
  288. 			Screen_slide_in_anim:play(0) 
  289. 		else 
  290. 			main_menu_set_back_in_values( new_x ) 
  291. 			vint_apply_start_values(Screen_back_in_anim.handle) 
  292. 			Screen_back_in_anim:play(0) 
  293. 		end 
  294. 	else 
  295. 		main_menu_center_layout( new_x ) 
  296. 		--vint_set_property(Screen_mask,"screen_size", list_w, 800) 
  297. 		main_menu_mask_morph(BG_TYPE_CENTER, list_w, new_x) 
  298. 		bg_saints_set_type(BG_TYPE_CENTER, false, list_w) 
  299. 	end 
  300. end 
  301.  
  302. function main_menu_mask_morph( screen_type, size_end_x, anchor_end_x ) 
  303. 	--get handles for everyone 
  304. 	local morph_anim_h = vint_object_find("screen_mask_anim", 0, Main_menu_common_doc) 
  305. 	local morph_scale_twn_h = vint_object_find("screen_mask_scale_twn", 0, Main_menu_common_doc) 
  306. 	local morph_anchor_twn_h = vint_object_find("screen_mask_anchor_twn", 0, Main_menu_common_doc)  
  307. 	 
  308. 	--create the center anchor point from the width of the mask 
  309. 	--anchor_end_x = (anchor_end_x) - (size_end_x * 0.5) 
  310.  
  311. 	--setup the anchor for the mask 
  312. 	--get the starting x position 
  313. 	local mask_anchor_start_x,mask_anchor_start_y = vint_get_property( Screen_mask, "anchor" ) 
  314. 	vint_set_property(morph_anchor_twn_h, "start_value", mask_anchor_start_x, mask_anchor_start_y ) 
  315. 	vint_set_property(morph_anchor_twn_h, "end_value", anchor_end_x, mask_anchor_start_y ) 
  316. 	 
  317. 	--setup the scale of the mask 
  318. 	--get the starting scale 
  319. 	local size_start_x,size_start_y = vint_get_property(Screen_mask,"scale") 
  320. 	--get the correct size, this fixes SD scale issues 
  321. 	local adjusted_size_end_x,crap = element_get_scale_from_size(Screen_mask, size_end_x, 16) 
  322. 	vint_set_property(morph_scale_twn_h, "start_value", size_start_x , size_start_y) 
  323. 	vint_set_property(morph_scale_twn_h, "end_value", adjusted_size_end_x , size_start_y) 
  324. 	 
  325. 	--play the animation 
  326. 	lua_play_anim(morph_anim_h, 0, Main_menu_common_doc)	 
  327. end 
  328.  
  329. function main_menu_set_slide_in_values( new_x ) 
  330. 	local hint_anchor_twn_h = vint_object_find("screen_slide_in_twn1", 0, Main_menu_common_doc) 
  331. 	local header_anchor_twn_h = vint_object_find("screen_slide_in_twn3", 0, Main_menu_common_doc)  
  332. 	local list_anchor_twn_h = vint_object_find("screen_slide_in_twn2", 0, Main_menu_common_doc)  
  333. 	 
  334. 	local hint_x,hint_y = vint_get_property(hint_anchor_twn_h, "end_value") 
  335. 	local header_x,header_y = vint_get_property(header_anchor_twn_h, "end_value") 
  336. 	local list_x,list_y = vint_get_property(list_anchor_twn_h, "end_value") 
  337. 	 
  338. 	vint_set_property(hint_anchor_twn_h, "end_value", new_x + 17, hint_y) 
  339. 	vint_set_property(header_anchor_twn_h, "end_value", new_x + 30, header_y) 
  340. 	vint_set_property(list_anchor_twn_h, "end_value", new_x, list_y) 
  341. end 
  342.  
  343. function main_menu_set_back_in_values( new_x ) 
  344. 	local hint_anchor_twn_h = vint_object_find("back_in_twn1", 0, Main_menu_common_doc) 
  345. 	local header_anchor_twn_h = vint_object_find("back_in_twn3", 0, Main_menu_common_doc)  
  346. 	local list_anchor_twn_h = vint_object_find("back_in_twn2", 0, Main_menu_common_doc)  
  347. 	 
  348. 	local hint_x,hint_y = vint_get_property(hint_anchor_twn_h, "end_value") 
  349. 	local header_x,header_y = vint_get_property(header_anchor_twn_h, "end_value") 
  350. 	local list_x,list_y = vint_get_property(list_anchor_twn_h, "end_value") 
  351. 	 
  352. 	vint_set_property(hint_anchor_twn_h, "end_value", new_x + 17, hint_y) 
  353. 	vint_set_property(header_anchor_twn_h, "end_value", new_x + 30, header_y) 
  354. 	vint_set_property(list_anchor_twn_h, "end_value", new_x, list_y) 
  355. end 
  356.  
  357. function main_menu_center_layout( new_x ) 
  358. 	--get the list x and y 
  359. 	local list_x, list_y = vint_get_property(List.handle, "anchor") 
  360. 	local header_x, header_y = vint_get_property(Header_obj.handle, "anchor") 
  361. 	local hint_anchor_twn_h = vint_object_find("back_in_twn1", 0, Main_menu_common_doc) 
  362. 	local hint_x,hint_y = vint_get_property(hint_anchor_twn_h, "end_value") 
  363. 	 
  364. 	vint_set_property(List.handle, "anchor", new_x, list_y) 
  365. 	vint_set_property(Header_obj.handle, "anchor", new_x + 30, header_y) 
  366. 	vint_set_property(Menu_hint_bar.handle, "anchor", new_x + 17, hint_y) 
  367. 	vint_set_property(Screen_mask, "anchor", new_x, -58) 
  368. end