./bg_saints.lua

  1. Bg_saints_doc_handle = 0	--Doc handle to bg saints... 
  2.  
  3. BG_TYPE_DEFAULT 		= 0 
  4. BG_TYPE_STRONGHOLD 	= 1 
  5. BG_TYPE_COMPLETION 	= 2 
  6. BG_TYPE_CENTER			= 3 
  7. BG_TYPE_FULLSCREEN	= 4 
  8. BG_TYPE_PAUSE			= 5 
  9. BG_TYPE_CRIB			= 6 
  10. BG_TYPE_CRIB_USE		= 7 
  11. BG_TYPE_FAIL			= 8 
  12. BG_TYPE_VIDEO			= 9 
  13.  
  14. Bg_staints_play_logo_slide = false 
  15.   
  16. local Bg_saints_scale = 1 
  17. local Bg_saints_type = BG_TYPE_PAUSE 
  18.  
  19. local Bg_h 
  20. local Bg_saints_pause_grp_h 
  21. local Bg_saints_crib_grp_h 
  22. local Fail_grp_h 
  23. local Digits_grp_h = -1 
  24. local Video_grp_h 
  25. local Vignette_grp_h 
  26. local First_glitch_done = false 
  27.  
  28. local Bg_saints_pause_grp_hell_h 
  29. local Tiled_grp_hell_h 
  30. local Gradient_bg_hell_h 
  31. local Video_grp_hell_h 
  32.  
  33. -- BG Video frame times 
  34. local PRESS_START_LOOP_END 		= 186 
  35. local PRESS_START_TRANS_START 	= 200 
  36. local MAIN_MENU_LOOP_START 		= 291 
  37. local MAIN_MENU_LOOP_END	 		= 2614 
  38.  
  39.  
  40. local HD_Templates = { 
  41. 	[BG_TYPE_COMPLETION] 	= {	anchor_x = -6,  
  42. 											size_x = 1290, 
  43. 											use_background = false},											 
  44. 	[BG_TYPE_STRONGHOLD] 	= {	anchor_x = -6,  
  45. 											size_x = 1290, 
  46. 											use_background = false}, 
  47. 	[BG_TYPE_DEFAULT] 		= {	anchor_x = -6,  
  48. 											size_x = 1290, 
  49. 											use_background = true}, 
  50. 	[BG_TYPE_CENTER] 			= {	anchor_x = -6,  
  51. 											size_x = 1290, 
  52. 											use_background = false}, 
  53. 	[BG_TYPE_FULLSCREEN] 	= {	anchor_x = -6,  
  54. 											size_x = 1290, 
  55. 											use_background = false}, 
  56. 	[BG_TYPE_PAUSE] 			= {	anchor_x = -6,  
  57. 											size_x = 1290,	 
  58. 											use_background = false}, 
  59. 	[BG_TYPE_CRIB] 			= {	anchor_x = -6,  
  60. 											size_x = 1290, 
  61. 											use_background = false},	 
  62. 	[BG_TYPE_CRIB_USE] 		= {	anchor_x = -6,  
  63. 											size_x = 1290, 
  64. 											use_background = true},		 
  65. 	[BG_TYPE_FAIL] 			= {	anchor_x = -6,  
  66. 											size_x = 1290,	 
  67. 											use_background = false},	 
  68. 	[BG_TYPE_VIDEO] 			= {	anchor_x = -6,  
  69. 											size_x = 1290,	 
  70. 											use_background = false},											 
  71. } 
  72.  
  73. local SD_Templates = { 
  74. 	[BG_TYPE_COMPLETION] = {		anchor_x = -6, 			 
  75. 											size_x = 640,		 
  76. 											use_background = false}, 
  77. 	[BG_TYPE_STRONGHOLD] 	= {	anchor_x = -6,  
  78. 											size_x = 640,	 
  79. 											use_background = false}, 
  80. 	[BG_TYPE_DEFAULT] 		= {	anchor_x = -6,  
  81. 											size_x = 640, 
  82. 											use_background = true}, 
  83. 	[BG_TYPE_CENTER] 			= {	anchor_x = -6,  
  84. 											size_x = 640, 
  85. 											use_background = false}, 
  86. 	[BG_TYPE_FULLSCREEN] 	= {	anchor_x = -6,  
  87. 											size_x = 640, 
  88. 											use_background = false}, 
  89. 	[BG_TYPE_PAUSE] 			= {	anchor_x = -6,  
  90. 											size_x = 640, 
  91. 											use_background = false}, 
  92. 	[BG_TYPE_CRIB] 			= {	anchor_x = -6,  
  93. 											size_x = 640, 
  94. 											use_background = false},	 
  95. 	[BG_TYPE_CRIB_USE] 		= {	anchor_x = -6,  
  96. 											size_x = 640, 
  97. 											use_background = true},	 
  98. 	[BG_TYPE_FAIL] 			= {	anchor_x = -6,  
  99. 											size_x = 640, 
  100. 											use_background = false}, 
  101. 	[BG_TYPE_VIDEO] 			= {	anchor_x = -6,  
  102. 											size_x = 640, 
  103. 											use_background = false},										 
  104. } 
  105. function bg_saints_init() 
  106. 	Bg_saints_doc_handle = vint_document_find("bg_saints") 
  107. 	 
  108. 	--Play logo anim when main_menu_common inits 
  109. 	Bg_staints_play_logo_slide = true 
  110. 	 
  111. 	local bg_pulse_anim_h = vint_object_find("bg_pulse_anim", 0, Bg_saints_doc_handle) 
  112. 	local bg_crib_anim_h = vint_object_find("bg_crib_anim", 0, Bg_saints_doc_handle) 
  113. 	vint_apply_start_values(bg_pulse_anim_h) 
  114. 	 
  115. 	local bg_loop_twn_h = vint_object_find("end_event_twn", bg_crib_anim_h) 
  116. 	vint_set_property(bg_loop_twn_h, "end_event", "vint_anim_loop_callback") 
  117.  
  118. 	lua_play_anim(bg_pulse_anim_h) 
  119. 	lua_play_anim(bg_crib_anim_h) 
  120. 	 
  121. 	--local bg_loop_h = vint_object_find("bg_loop", 0, Bg_saints_doc_handle) 
  122. 	--lua_play_anim(bg_loop_h) 
  123. 	 
  124. 	Bg_saints_pause_grp_h = vint_object_find( "pause_grp", 0, Bg_saints_doc_handle ) 
  125. 	Bg_saints_crib_grp_h = vint_object_find( "crib_grp", 0, Bg_saints_doc_handle ) 
  126. 	Fail_grp_h = vint_object_find( "fail_grp", 0, Bg_saints_doc_handle ) 
  127. 	Digits_grp_h = vint_object_find( "digits_grp", 0, Bg_saints_doc_handle ) 
  128. 	Video_grp_h = vint_object_find( "video_grp", 0, Bg_saints_doc_handle ) 
  129. 	Vignette_grp_h = vint_object_find( "Vignette_grp", 0, Bg_saints_doc_handle ) 
  130.  
  131. 	-- hell background initialize 
  132. 	Bg_saints_pause_grp_hell_h = vint_object_find( "pause_grp_hell", 0, Bg_saints_doc_handle ) 
  133. 	Tiled_grp_hell_h = vint_object_find( "bg_tiled_grp_hell", 0, Bg_saints_doc_handle ) 
  134. 	Gradient_bg_hell_h = vint_object_find( "gradient_bg_hell", 0, Bg_saints_doc_handle ) 
  135. 	Video_grp_hell_h = vint_object_find( "video_grp_hell", 0, Bg_saints_doc_handle ) 
  136.  
  137. 	vint_set_property( Bg_saints_pause_grp_h, "visible", false ) 
  138. 	vint_set_property( Bg_saints_crib_grp_h, "visible", false ) 
  139. 	vint_set_property( Fail_grp_h, "visible", false ) 
  140. 	vint_set_property( Video_grp_h, "visible", false ) 
  141.  
  142. 	vint_set_property( Bg_saints_pause_grp_hell_h, "visible", false ) 
  143. 	vint_set_property( Tiled_grp_hell_h, "visible", false ) 
  144. 	vint_set_property( Gradient_bg_hell_h, "visible", false ) 
  145. 	vint_set_property( Video_grp_hell_h, "visible", false ) 
  146. 	 
  147. 	Bg_h = vint_object_find("bg", 0, Bg_saints_doc_handle) 
  148. 	 
  149. 	--Set default type... 
  150. 	bg_saints_set_type(BG_TYPE_PAUSE, false) 
  151. end 
  152.  
  153. function bg_saints_cleanup() 
  154. 	local bg_saints_video_h = vint_object_find( "bg_video", 0, Bg_saints_doc_handle ) 
  155. 	vint_set_property( bg_saints_video_h, "end_event", "" ) 
  156. 	vint_ramp_glitch(0, 0)  
  157. end 
  158.  
  159.  
  160. ------------------------------------------------------------------------------- 
  161. -- Sets type of background 
  162. -- @param	screen_type		Screen type: 	BG_TYPE_DEFAULT, BG_TYPE_STRONGHOLD, BG_TYPE_COMPLETION, BG_TYPE_CENTER 
  163. -- @param	morph				Bool:	do morph animation or not 
  164. -- @param	width				width override for background 
  165. -- @param	anchor			anchor override for background 
  166. -- 
  167. function bg_saints_set_type( screen_type, morph, width, anchor ) 
  168.  
  169. 	local screen_group_h = vint_object_find("screen_grp", 0, Bg_saints_doc_handle) 
  170. 	 
  171. 	local templates = HD_Templates 
  172. 	if vint_is_std_res() then 
  173. 		templates = SD_Templates 
  174. 	end 
  175. 	 
  176. 	Bg_saints_scale = vint_get_property(screen_group_h,"scale") 
  177. 	 
  178. 	Bg_saints_type = screen_type 
  179. 	 
  180. 	local template = templates[screen_type] 
  181. 	 
  182. 	--Check to see if our template is valid... 
  183. 	if template == nil then 
  184. 		template = templates[BG_TYPE_PAUSE] 
  185. 	end 
  186. 	 
  187. 	local use_background = template.use_background 
  188. 	bg_saints_set_background(use_background) 
  189.  
  190. end 
  191.  
  192. ------------------------------------------------------------------------------- 
  193. -- Morphs background from previous size/position to the next... 
  194. -- @param	screen_type		Screen type: 	BG_TYPE_DEFAULT, BG_TYPE_STRONGHOLD, BG_TYPE_COMPLETION, BG_TYPE_CENTER 
  195. -- @param	size_end_x		width that the animation will end on 
  196. -- @param	anchor_end_x	x position that the animation will end on 
  197. -- 
  198. function bg_saints_morph( screen_type, size_end_x, anchor_end_x ) 
  199. 	 
  200. end 
  201.  
  202. ------------------------------------------------------------------------------- 
  203. -- Animates background into view... 
  204. -- 
  205. function bg_saints_animate() 
  206. 	 
  207. 	bg_saints_show(true) 
  208. end 
  209.  
  210. ------------------------------------------------------------------------------- 
  211. -- Slides background into view... 
  212. -- 
  213. function bg_saints_slide_in(width, anchor) 
  214. 	 
  215. 	bg_saints_show(true) 
  216. end 
  217.  
  218. ------------------------------------------------------------------------------- 
  219. -- Slides background out of view... 
  220. -- 
  221. function bg_saints_slide_out(new_end_x) 
  222. 	 
  223. end 
  224.  
  225. ------------------------------------------------------------------------------- 
  226. -- Shows background 
  227. -- @param	is_visible 
  228. -- 
  229. function bg_saints_show( is_visible ) 
  230.  
  231. 	vint_set_property( Bg_h, "visible", is_visible ) 
  232. 	 
  233. 	if is_visible then 
  234. 		if Bg_saints_type == BG_TYPE_PAUSE then 
  235. 			vint_set_property( Bg_saints_pause_grp_h, "visible", false ) -- changed to false, showing new pause_grp_hell instead 
  236. 			vint_set_property( Bg_saints_crib_grp_h, "visible", false ) 
  237. 			vint_set_property( Video_grp_h, "visible", false ) 
  238. 			 
  239. 			vint_set_property(Digits_grp_h, "tint", COLOR_BG_DIGITS_PAUSE.R, COLOR_BG_DIGITS_PAUSE.G, COLOR_BG_DIGITS_PAUSE.B) 
  240. 			vint_set_property(Digits_grp_h, "alpha", 0)			-- changed alpha from 1 to 0 because we don't want to see the digits anymore on the pause screen 
  241. 			vint_set_property( Vignette_grp_h, "alpha", 0 )	-- changed alpha from .6 to 0  
  242. 			vint_set_property( Fail_grp_h, "visible", false ) 
  243. 			if First_glitch_done ~= true then 
  244. 				vint_set_glitch_preset("hub") 
  245. 				vint_spike_glitch( 200, 0 ) 
  246. 				First_glitch_done = true 
  247. 			end 
  248.  
  249. 			-- new pause menu stuff 
  250. 			vint_set_property( Bg_saints_pause_grp_hell_h, "visible", true ) 
  251. 			vint_set_property( Tiled_grp_hell_h, "visible", true ) 
  252. 			vint_set_property( Gradient_bg_hell_h, "visible", true ) 
  253. 			vint_set_property( Video_grp_hell_h, "visible", false ) -- no video on pause menu 
  254. 			 
  255.  
  256. 		elseif Bg_saints_type == BG_TYPE_VIDEO then 
  257. 			vint_set_property( Bg_saints_pause_grp_h, "visible", false )	-- changed to false, showing new pause_grp_hell instead 
  258. 			vint_set_property( Bg_saints_crib_grp_h, "visible", false ) 
  259. 			vint_set_property(Digits_grp_h, "tint", COLOR_BG_DIGITS_VIDEO.R, COLOR_BG_DIGITS_VIDEO.G, COLOR_BG_DIGITS_VIDEO.B) 
  260. 			vint_set_property(Digits_grp_h, "alpha", 0) 
  261. 			vint_set_property( Video_grp_h, "visible", false )				-- changed to false, don't want this video grp show anymore 
  262. 			vint_set_property( Vignette_grp_h, "alpha", 0 )					-- changed alpha from 1 to 0, don't want the old vignette anymore 
  263. 			vint_set_property( Fail_grp_h, "visible", false ) 
  264. 			if First_glitch_done ~= true then 
  265. 				vint_set_glitch_preset("hub") 
  266. 				vint_spike_glitch( 200, 0 ) 
  267. 				First_glitch_done = true 
  268. 			end 
  269. 			 
  270. 			--Reset the Video blocks so they don't show the video through the lines 
  271. 			--local video_block_l_h = vint_object_find("video_block_l", 0, Bg_saints_doc_handle) 
  272. 			--local video_block_r_h = vint_object_find("video_block_r", 0, Bg_saints_doc_handle) 
  273. 			--vint_set_property(video_block_l_h, "anchor", -104, -191) 
  274. 			--vint_set_property(video_block_r_h, "anchor", 998, -892) 
  275.  
  276. 			-- new background stuff 
  277. 			vint_set_property( Bg_saints_pause_grp_hell_h, "visible", true ) 
  278. 			vint_set_property( Tiled_grp_hell_h, "visible", true ) 
  279. 			vint_set_property( Gradient_bg_hell_h, "visible", false ) 
  280. 			vint_set_property( Video_grp_hell_h, "visible", true ) 
  281.  
  282. 		elseif Bg_saints_type == BG_TYPE_FAIL then 
  283. 			vint_set_property( Bg_saints_pause_grp_h, "visible", false ) -- changed to false, showing new pause_grp_hell instead 
  284. 			vint_set_property( Bg_saints_crib_grp_h, "visible", false ) 
  285. 			vint_set_property( Video_grp_h, "visible", false ) 
  286. 			vint_set_property( Vignette_grp_h, "alpha", .6 ) 
  287. 			vint_set_property( Bg_saints_pause_grp_h, "saturation", 0 ) 
  288. 			--vint_set_property( Bg_saints_pause_grp_h, "tint", 220/255, 37/255, 0/255 ) 
  289. 			vint_set_property( Fail_grp_h, "visible", true ) 
  290. 			vint_set_property(Digits_grp_h, "tint", COLOR_BG_DIGITS_FAIL.R, COLOR_BG_DIGITS_FAIL.G, COLOR_BG_DIGITS_FAIL.B) 
  291. 			vint_set_property(Digits_grp_h, "alpha", 1) 
  292. 			vint_ramp_glitch(0, 0)   
  293.  
  294. 			-- new pause menu stuff 
  295. 			vint_set_property( Bg_saints_pause_grp_hell_h, "visible", true ) 
  296. 			vint_set_property( Tiled_grp_hell_h, "visible", true ) 
  297. 			vint_set_property( Gradient_bg_hell_h, "visible", true ) 
  298. 			vint_set_property( Video_grp_hell_h, "visible", false ) -- no video on pause menu 
  299.  
  300. 		elseif Bg_saints_type == BG_TYPE_CRIB or Bg_saints_type == BG_TYPE_CRIB_USE then 
  301. 			vint_set_property( Bg_saints_crib_grp_h, "visible", true ) 
  302. 			vint_set_property( Bg_saints_pause_grp_h, "visible", false ) 
  303. 			vint_set_property( Vignette_grp_h, "alpha", .6 ) 
  304. 			vint_set_property( Video_grp_h, "visible", false ) 
  305. 			vint_set_property( Fail_grp_h, "visible", false ) 
  306.  
  307. 			vint_set_property( Bg_saints_pause_grp_hell_h, "visible", false ) 
  308. 			vint_set_property( Tiled_grp_hell_h, "visible", false ) 
  309. 			vint_set_property( Gradient_bg_hell_h, "visible", false ) 
  310. 			vint_set_property( Video_grp_hell_h, "visible", false ) 
  311.  
  312. 			vint_ramp_glitch(0, 0)   
  313. 		end 
  314. 	end 
  315. end 
  316.  
  317. ------------------------------------------------------------------------------- 
  318. -- Toggles the interface in background mode or not... 
  319. -- @param	is_visible 
  320. -- 
  321. function bg_saints_set_background(use_background) 
  322. 	vint_set_property(Bg_h, "background", use_background) 
  323. end 
  324.  
  325. ------------------------------------------------------------------------------- 
  326. -- Dims out everything behind bg saints... 
  327. -- @param	is_visible 
  328. -- 
  329. function bg_saints_dimmer_show( is_visible ) 
  330. 	 
  331. end 
  332.  
  333. ------------------------------------------------------------------------------- 
  334. -- Sets video  
  335. -- @param	video_name 
  336. -- 
  337. function bg_saints_set_video( video_name ) 
  338. 	local bg_saints_video_h = vint_object_find( "bg_video01", 0, Bg_saints_doc_handle) 
  339. 	vint_set_property( bg_saints_video_h, "vid_name", video_name ) 
  340. end 
  341.  
  342. ------------------------------------------------------------------------------- 
  343. -- Plays video 
  344. -- @param	is_playing 
  345. -- 
  346. function bg_saints_play_video( is_playing, stop_callback ) 
  347. 	local bg_saints_video_h = vint_object_find( "bg_video01", 0, Bg_saints_doc_handle ) 
  348. 	vint_set_property( bg_saints_video_h, "visible", is_playing ) 
  349. 	vint_set_property( bg_saints_video_h, "end_event", stop_callback )	 
  350.  
  351. 	if is_playing == false then 
  352. 		-- needed so we can unload it and steal its memories 
  353. 		vint_set_property( bg_saints_video_h, "is_stopped", true ) 
  354. 	else  
  355. 		vint_set_property( bg_saints_video_h, "is_paused", false ) 
  356. 	end 
  357. end 
  358.  
  359.  
  360. ------------------------------------------------------------------------------- 
  361. -- INTERFACE SPECIFIC FUNCTIONS 
  362. ------------------------------------------------------------------------------- 
  363. function bg_saints_stronghold_drop_out() 
  364. 	 
  365. end 
  366.  
  367.  
  368. ------------------------------------------------------------------------------- 
  369. -- MAIN MENU VIDEO CALLBACKS 
  370. ------------------------------------------------------------------------------- 
  371.  
  372. -- Press Start 
  373. function bg_saints_press_start_setup() 
  374. 	--local bg_saints_video_h = vint_object_find( "bg_video", 0, Bg_saints_doc_handle ) 
  375. 	--vint_set_property( bg_saints_video_h, "frame_event", "bg_saints_press_start_cb" ) 
  376. 	--vint_set_property( bg_saints_video_h, "frame_event_num", PRESS_START_LOOP_END )	 
  377. end 
  378. 	 
  379. function bg_saints_press_start_cb() 
  380. 	--thread_new("bg_saints_press_start_loop") 
  381. end 
  382.  
  383. function bg_saints_press_start_loop() 
  384. 	--delay(0.1) 
  385. 	 
  386. 	--local bg_saints_video_h = vint_object_find( "bg_video", 0, Bg_saints_doc_handle ) 
  387. 	--vint_set_property( bg_saints_video_h, "frame", 1 )	 
  388. end 
  389.  
  390.  
  391. -- Main Menu 
  392. function bg_saints_main_menu_setup() 
  393. 	--local bg_saints_video_h = vint_object_find( "bg_video", 0, Bg_saints_doc_handle ) 
  394. 	 
  395. 	--bg_saints_delay_trans() 
  396. 	--vint_set_property( bg_saints_video_h, "frame", PRESS_START_TRANS_START) 
  397. 	 
  398. 	--vint_set_property( bg_saints_video_h, "frame_event", "bg_saints_main_menu_cb" ) 
  399. 	--vint_set_property( bg_saints_video_h, "frame_event_num", MAIN_MENU_LOOP_END )		 
  400. end 
  401.  
  402. -- function bg_saints_delay_trans() 
  403. 	-- thread_new("bg_saints_press_start_trans") 
  404. -- end 
  405.  
  406. -- function bg_saints_press_start_trans() 
  407. 	-- delay(0.1) 
  408. 	 
  409. 	-- local bg_saints_video_h = vint_object_find( "bg_video", 0, Bg_saints_doc_handle ) 
  410. 	 
  411. 	-- vint_set_property( bg_saints_video_h, "frame", PRESS_START_TRANS_START )			 
  412. -- end 
  413.  
  414. function bg_saints_main_menu_cb() 
  415. 	--thread_new("bg_saints_main_menu_loop") 
  416. end 
  417.  
  418. function bg_saints_main_menu_loop() 
  419. 	--delay(0.005) 
  420. 	 
  421. 	--local bg_saints_video_h = vint_object_find( "bg_video", 0, Bg_saints_doc_handle ) 
  422. 	--vint_set_property( bg_saints_video_h, "frame", MAIN_MENU_LOOP_START ) 
  423. end 
  424.  
  425. function bg_saints_reset() 
  426. 	if game_get_platform() == "PC" then 
  427. 		local bg_saints_video_h = vint_object_find( "bg_video", 0, Bg_saints_doc_handle ) 
  428. 		vint_set_property( bg_saints_video_h, "is_stopped", true ) 
  429. 		vint_set_property( bg_saints_video_h, "is_stopped", false ) 
  430. 	end 
  431. end 
  432.