./credits.lua

  1. ------------- 
  2. -- CREDITS -- 
  3. ------------- 
  4. -- Credits Constants 
  5. --Movement Constants 
  6. CREDITS_PIXELS_PER_SEC_MAX 	= 480 
  7. CREDITS_PIXELS_PER_SEC_MAX_PC = 480 
  8. CREDITS_PIXELS_PER_SEC_NORMAL = 50  
  9. CREDITS_PIXELS_PER_SEC_MIN 	= 5 
  10.  
  11. Credits_doc_handle = 0 
  12.  
  13. -- Enum types for credits 
  14. local CREDITS_TYPE_HEADER		=	0 
  15. local CREDITS_TYPE_HEADER_SUB	=	1 
  16. local CREDITS_TYPE_ROLE_NAME	=	2 
  17. local CREDITS_TYPE_MUSIC		=	3 
  18. local CREDITS_TYPE_IMAGE		=	4 
  19. local CREDITS_TYPE_CENTERED	=	5 
  20.  
  21. local CREDITS_FINISHED_TOKEN	= 100 
  22.  
  23. local Credits_finished = false 
  24. local Credit_skipped = false 
  25. local Input_tracker 
  26.  
  27. -------------------------------------- 
  28. --Defines spacing above each item... 
  29. -------------------------------------- 
  30. local CREDIT_OBJECT_FORMATTING = { 
  31. 	[CREDITS_TYPE_HEADER] = { 
  32. 			base_grp = "credit_header_grp",			-- Base group in the vint doc... 
  33. 			txt_objects = {"header_txt"},				-- Text object in the base group... 
  34. 			stacked = false,								-- If the items are stacked or set side to side. 
  35. 			[CREDITS_TYPE_HEADER] = 70,				-- Spacing to set from bottom of this item type... 
  36. 			[CREDITS_TYPE_HEADER_SUB] = 70, 
  37. 			[CREDITS_TYPE_ROLE_NAME] = 70, 
  38. 			[CREDITS_TYPE_MUSIC] = 70, 
  39. 			[CREDITS_TYPE_CENTERED] = 70, 
  40. 			[CREDITS_TYPE_IMAGE] = 30, 
  41. 		}, 
  42. 	[CREDITS_TYPE_HEADER_SUB] = { 
  43. 			base_grp = "credit_header_sub_grp", 
  44. 			txt_objects = {"header_sub_txt"}, 
  45. 			stacked = false, 
  46. 			[CREDITS_TYPE_HEADER] = 30, 
  47. 			[CREDITS_TYPE_HEADER_SUB] = 65, 
  48. 			[CREDITS_TYPE_ROLE_NAME] = 70, 
  49. 			[CREDITS_TYPE_MUSIC] = 70, 
  50. 			[CREDITS_TYPE_CENTERED] = 70, 
  51. 			[CREDITS_TYPE_IMAGE] = 30, 
  52. 		}, 
  53. 	[CREDITS_TYPE_ROLE_NAME] = { 
  54. 			base_grp = "credit_role_name_grp", 
  55. 			txt_objects = {"role_txt", "name_txt"}, 
  56. 			stacked = false, 
  57. 			[CREDITS_TYPE_HEADER] = 20, 
  58. 			[CREDITS_TYPE_HEADER_SUB] = 25, 
  59. 			[CREDITS_TYPE_ROLE_NAME] = 0, 
  60. 			[CREDITS_TYPE_MUSIC] = 35, 
  61. 			[CREDITS_TYPE_CENTERED] = 35, 
  62. 			[CREDITS_TYPE_IMAGE] = 30, 
  63. 		}, 
  64. 	[CREDITS_TYPE_MUSIC] = { 
  65. 			base_grp = "credit_music_grp", 
  66. 			txt_objects = {"song_name_txt", "description_txt"}, 
  67. 			stacked = true, 
  68. 			[CREDITS_TYPE_HEADER] = 20, 
  69. 			[CREDITS_TYPE_HEADER_SUB] = 25, 
  70. 			[CREDITS_TYPE_ROLE_NAME] = 35, 
  71. 			[CREDITS_TYPE_MUSIC] = 35, 
  72. 			[CREDITS_TYPE_CENTERED] = 35, 
  73. 			[CREDITS_TYPE_IMAGE] = 30, 
  74. 		}, 
  75. 	[CREDITS_TYPE_IMAGE] = { 
  76. 			base_grp = "credit_image_grp", 
  77. 			img_object = "image_bmp", 
  78. 			[CREDITS_TYPE_HEADER] = 20, 
  79. 			[CREDITS_TYPE_HEADER_SUB] = 25, 
  80. 			[CREDITS_TYPE_ROLE_NAME] = 35, 
  81. 			[CREDITS_TYPE_MUSIC] = 35, 
  82. 			[CREDITS_TYPE_CENTERED] = 35, 
  83. 			[CREDITS_TYPE_IMAGE] = 30, 
  84. 		}, 
  85. 	[CREDITS_TYPE_CENTERED] = { 
  86. 			base_grp = "credit_centered_grp", 
  87. 			txt_objects = {"centered_txt"}, 
  88. 			stacked = false, 
  89. 			[CREDITS_TYPE_HEADER] = 20, 
  90. 			[CREDITS_TYPE_HEADER_SUB] = 25, 
  91. 			[CREDITS_TYPE_ROLE_NAME] = 35, 
  92. 			[CREDITS_TYPE_MUSIC] = 35, 
  93. 			[CREDITS_TYPE_CENTERED] = 0, 
  94. 			[CREDITS_TYPE_IMAGE] = 30, 
  95. 		}, 
  96. } 
  97.  
  98. --General Constants 
  99. CREDITS_HALF_SCREEN_HEIGHT = 360 
  100. CREDITS_SCREEN_LEEWAY_TOP 				= 50 
  101. CREDITS_SCREEN_LEEWAY_BOTTOM 			= 250 
  102. CREDITS_IMAGE_SCREEN_LEEWAY_TOP		= 50 
  103. CREDITS_IMAGE_SCREEN_LEEWAY_BOTTOM 	= 250 
  104.  
  105.  
  106. Credits_images_default = { 
  107. 	"ui_credits_001", 
  108. 	"ui_credits_002", 
  109. 	"ui_credits_003", 
  110. 	--"ui_credits_004", 
  111. 	"ui_credits_005", 
  112. 	"ui_credits_006", 
  113. 	"ui_credits_007", 
  114. 	"ui_credits_008", 
  115. 	"ui_credits_009", 
  116. 	"ui_credits_010", 
  117. 	"ui_credits_011", 
  118. 	"ui_credits_012", 
  119. 	--"ui_credits_013", 
  120. 	"ui_credits_014", 
  121. 	"ui_credits_015", 
  122. 	"ui_credits_016", 
  123. 	"ui_credits_017", 
  124. 	"ui_credits_018", 
  125. 	"ui_credits_019", 
  126. 	"ui_credits_020", 
  127. 	"ui_credits_021", 
  128. 	"ui_credits_022", 
  129. 	"ui_credits_023", 
  130. 	"ui_credits_024", 
  131. 	--"ui_credits_025", 
  132. 	"ui_credits_026", 
  133. 	"ui_credits_027", 
  134.  
  135. 	"ui_credits_031", 
  136. 	--"ui_credits_032", 
  137. 	"ui_credits_033", 
  138. 	--"ui_credits_034", 
  139.  
  140. 	"ui_credits_036", 
  141. 	"ui_credits_037", 
  142. 	--"ui_credits_038", 
  143. 	"ui_credits_039", 
  144. 	"ui_credits_040", 
  145. 	--"ui_credits_041", 
  146. 	"ui_credits_042", 
  147. 	"ui_credits_043", 
  148. 	"ui_credits_044", 
  149. 	--"ui_credits_045", 
  150. 	"ui_credits_046", 
  151. 	"ui_credits_047", 
  152. 	"ui_credits_048", 
  153. 	--"ui_credits_049", 
  154. 	"ui_credits_050", 
  155. 	"ui_credits_051", 
  156. 	"ui_credits_052", 
  157.  
  158. 	"ui_credits_054", 
  159. 	"ui_credits_055", 
  160. 	"ui_credits_056", 
  161. 	--"ui_credits_057", 
  162. 	"ui_credits_058", 
  163. 	"ui_credits_059", 
  164. 	--"ui_credits_060", 
  165. 	"ui_credits_061", 
  166. 	"ui_credits_062", 
  167. 	--"ui_credits_063", 
  168. 	"ui_credits_064", 
  169. 	"ui_credits_065", 
  170. 	"ui_credits_066", 
  171. 	"ui_credits_067", 
  172. 	"ui_credits_068", 
  173. 	--"ui_credits_069", 
  174. 	"ui_credits_070", 
  175. 	"ui_credits_071", 
  176. 	--"ui_credits_072", 
  177. 	"ui_credits_073", 
  178. 	"ui_credits_074", 
  179. 	"ui_credits_075", 
  180. 	"ui_credits_076", 
  181. 	"ui_credits_077", 
  182. 	"ui_credits_078", 
  183. 	"ui_credits_079", 
  184. 	"ui_credits_080", 
  185. 	"ui_credits_081", 
  186. 	"ui_credits_082", 
  187. 	"ui_credits_083", 
  188. 	"ui_credits_084", 
  189. 	"ui_credits_085", 
  190. 	"ui_credits_086", 
  191. 	--"ui_credits_087", 
  192. 	--"ui_credits_088", 
  193. 	"ui_credits_089", 
  194. 	"ui_credits_090", 
  195.  
  196. 	"ui_credits_093", 
  197. 	"ui_credits_094", 
  198. 	"ui_credits_095", 
  199. 	--"ui_credits_096", 
  200. 	"ui_credits_097", 
  201. 	"ui_credits_098", 
  202. 	"ui_credits_099", 
  203. 	"ui_credits_100", 
  204. 	"ui_credits_101", 
  205. 	"ui_credits_150", 
  206. 	"ui_credits_151", 
  207. 	--"ui_credits_152", 
  208. 	"ui_credits_153", 
  209. } 
  210.  
  211. Credits_images_saints = { 
  212. 	"ui_credits_saints_001", 
  213. 	"ui_credits_saints_002", 
  214. 	"ui_credits_saints_003", 
  215. 	"ui_credits_saints_004", 
  216. 	"ui_credits_saints_005", 
  217. 	"ui_credits_saints_006", 
  218. 	"ui_credits_saints_007", 
  219. 	"ui_credits_saints_008", 
  220. 	"ui_credits_saints_009", 
  221. 	"ui_credits_saints_010", 
  222. 	"ui_credits_saints_011", 
  223. 	"ui_credits_saints_012", 
  224. 	"ui_credits_saints_013", 
  225. 	"ui_credits_saints_014", 
  226. 	"ui_credits_saints_015", 
  227. 	"ui_credits_saints_016", 
  228. 	"ui_credits_saints_017", 
  229. 	"ui_credits_saints_018", 
  230. 	"ui_credits_saints_019", 
  231. 	"ui_credits_saints_020", 
  232. 	"ui_credits_saints_021", 
  233. 	"ui_credits_saints_022", 
  234. 	"ui_credits_saints_023", 
  235. 	"ui_credits_saints_024", 
  236. 	"ui_credits_saints_025", 
  237. 	"ui_credits_saints_026", 
  238. 	"ui_credits_saints_027", 
  239. 	"ui_credits_saints_028", 
  240. 	"ui_credits_saints_029", 
  241. 	"ui_credits_saints_030", 
  242. 	"ui_credits_saints_031", 
  243. 	"ui_credits_saints_032", 
  244. 	"ui_credits_saints_033", 
  245. 	 
  246. 	--"ui_credits_001", 
  247. 	--"ui_credits_002", 
  248. 	--"ui_credits_003", 
  249. 	"ui_credits_004", 
  250. 	--"ui_credits_005", 
  251. 	--"ui_credits_006", 
  252. 	--"ui_credits_007", 
  253. 	"ui_credits_008", 
  254. 	--"ui_credits_009", 
  255. 	"ui_credits_010", 
  256. 	--"ui_credits_011", 
  257. 	--"ui_credits_012", 
  258. 	"ui_credits_013", 
  259. 	"ui_credits_014", 
  260. 	--"ui_credits_015", 
  261. 	--"ui_credits_016", 
  262. 	"ui_credits_017", 
  263. 	"ui_credits_018", 
  264. 	--"ui_credits_019", 
  265. 	"ui_credits_020", 
  266. 	--"ui_credits_021", 
  267. 	--"ui_credits_022", 
  268. 	"ui_credits_023", 
  269. 	"ui_credits_024", 
  270. 	--"ui_credits_025", 
  271. 	--"ui_credits_026", 
  272. 	"ui_credits_027", 
  273.  
  274. 	--"ui_credits_031", 
  275. 	"ui_credits_032", 
  276. 	--"ui_credits_033", 
  277. 	"ui_credits_034", 
  278.  
  279. 	"ui_credits_036", 
  280. 	"ui_credits_037", 
  281. 	--"ui_credits_038", 
  282. 	--"ui_credits_039", 
  283. 	--"ui_credits_040", 
  284. 	"ui_credits_041", 
  285. 	--"ui_credits_042", 
  286. 	--"ui_credits_043", 
  287. 	--"ui_credits_044", 
  288. 	"ui_credits_045", 
  289. 	--"ui_credits_046", 
  290. 	--"ui_credits_047", 
  291. 	--"ui_credits_048", 
  292. 	"ui_credits_049", 
  293. 	"ui_credits_050", 
  294. 	"ui_credits_051", 
  295. 	"ui_credits_052", 
  296.  
  297. 	--"ui_credits_054", 
  298. 	--"ui_credits_055", 
  299. 	--"ui_credits_056", 
  300. 	"ui_credits_057", 
  301. 	--"ui_credits_058", 
  302. 	--"ui_credits_059", 
  303. 	"ui_credits_060", 
  304. 	--"ui_credits_061", 
  305. 	--"ui_credits_062", 
  306. 	"ui_credits_063", 
  307. 	"ui_credits_064", 
  308. 	"ui_credits_065", 
  309. 	--"ui_credits_066", 
  310. 	--"ui_credits_067", 
  311. 	--"ui_credits_068", 
  312. 	"ui_credits_069", 
  313. 	--"ui_credits_070", 
  314. 	--"ui_credits_071", 
  315. 	"ui_credits_072", 
  316. 	--"ui_credits_073", 
  317. 	--"ui_credits_074", 
  318. 	"ui_credits_075", 
  319. 	--"ui_credits_076", 
  320. 	--"ui_credits_077", 
  321. 	--"ui_credits_078", 
  322. 	"ui_credits_079", 
  323. 	"ui_credits_080", 
  324. 	--"ui_credits_081", 
  325. 	"ui_credits_082", 
  326. 	--"ui_credits_083", 
  327. 	--"ui_credits_084", 
  328. 	"ui_credits_085", 
  329. 	"ui_credits_086", 
  330. 	--"ui_credits_087", 
  331. 	--"ui_credits_088", 
  332. 	"ui_credits_089", 
  333. 	"ui_credits_090", 
  334.  
  335. 	"ui_credits_093", 
  336. 	"ui_credits_094", 
  337. 	"ui_credits_095", 
  338. 	"ui_credits_096", 
  339. 	"ui_credits_097", 
  340. 	"ui_credits_098", 
  341. 	"ui_credits_099", 
  342. 	"ui_credits_100", 
  343. 	"ui_credits_101", 
  344. 	--"ui_credits_150", 
  345. 	--"ui_credits_151", 
  346. 	"ui_credits_152", 
  347. 	"ui_credits_153", 
  348. } 
  349.  
  350.  
  351. --init text size globals 
  352. Credits_cur_idx = -1				--Current credit index... 
  353. Credits_oldest_idx = 0			 
  354. Credits_cur_slide_pos = 400	--Position of slide... 400 starts us off the bottom of the screen... 
  355. Credits_num_items = 0			--Num Items 
  356. Credits_scroll_speed = CREDITS_PIXELS_PER_SEC_NORMAL 
  357. Credits_skip_available  = true 
  358.  
  359. Credits_objects = {} 
  360.  
  361. Credits = {} 
  362. Credits_data = { } 
  363.  
  364. --Credits Reel (aka images) 
  365. if vint_is_std_res() then 
  366. 	CREDITS_REEL_IMG_SPACING  = 70		--Spacing between reel images... 
  367. else 
  368. 	CREDITS_REEL_IMG_SPACING  = 20		--Spacing between reel images... 
  369. end 
  370.  
  371. CREDITS_REEL_IMG_HEIGHT  = 261			--Height of reel image... 
  372. Credits_reel_cur_idx = -1					--Current credit index... 
  373. Credits_reel_oldest_idx = 0 
  374. Credits_reel_cur_slide_pos = 640			--Position of slide... 600 starts us a bit below the log. 
  375. Credits_reel_num_items = 0					--Num Items 
  376. Credits_reel_data = {} 
  377.  
  378. local Credits_reel_load_queue = {}		--Images that we are loading... 
  379. local Credits_reel_load_num = 0			--# Images that we plan to load 
  380. local Credits_reel_loaded_num = 0		--# Images that loaded... 
  381.  
  382. Credits_inverse_scale			= 1.0 
  383. Credits_reel_inverse_scale		= 1.0 
  384.  
  385. --[[ 
  386. 	-- Comment Used as reference.... 
  387. 	Credits_data = { 
  388. 		[0] = {type = CREDITS_TYPE_HEADER, 			data = {"Volition"}}, 
  389. 		[1] = {type = CREDITS_TYPE_HEADER_SUB, 	data = {"Leads"}}, 
  390. 		[2] = {type = CREDITS_TYPE_ROLE_NAME, 		data = {"Producer", "Gred Donovan"}}, 
  391. 		[3] = {type = CREDITS_TYPE_ROLE_NAME, 		data = {"Product Technical Director", "Nick Lee"}}, 
  392. 		[4] = {type = CREDITS_TYPE_ROLE_NAME, 		data = {"Programmer", "David Absug"}}, 
  393. 		[5] = {type = CREDITS_TYPE_ROLE_NAME,		data = {"Programmer", "Jim Brennan"}}, 
  394. 		[6] = {type = CREDITS_TYPE_ROLE_NAME, 		data = {"Programmer", "John Buckley"}}, 
  395. 		[7] = {type = CREDITS_TYPE_MUSIC,			data = {"This is how we do it", "Performed by Jesus Christ Superstar. This covers any SR2 specific technical details that need to be documented. Things pertaining to how parts of the"}}, 
  396. 		[8] = {type = CREDITS_TYPE_MUSIC, 			data = {"Dear Maria, Count Me In", "Performed by All Time Low. Concerts, album reviews, pop, jazz and classical music news from the Los Angeles Times."}}, 
  397. 		[9] = {type = CREDITS_TYPE_MUSIC, 			data = {"Sorry", "Peformed by Buck Cherry. Check out new bands and artists on MySpace Music: Watch music videos, check out concerts and tour dates, music, news and more."}}, 
  398. 	} 
  399. 	Credits_num_items = 10 
  400. ]] 
  401.  
  402. Credits_thread = -1			--Thread for credits processing.... 
  403. Credits_reel_thread = -1			--Thread for credits processing.... 
  404. Credits_is_in_game = false 
  405.  
  406.  
  407. function credits_init() 
  408. 	Credits_doc_handle = vint_document_find("credits") 
  409. 	--Credits_format = "fail" 
  410. 	 
  411. 	--Check to see if we are in game... 
  412. 	if vint_document_find("main_menu_common") == 0 then 
  413. 		Credits_is_in_game = true  
  414. 	else 
  415. 		audio_object_post_event("Credits_main_menu", nil, nil, nil, false) 
  416. 	end 
  417. 	 
  418. 	--Dumping pause map if in game... 
  419. 	if Credits_is_in_game then 
  420. 		pause_map_dump() 
  421. 	end 
  422. 	 
  423. 	if vint_is_std_res() then 
  424. 		--Must scale overides in the document 
  425. 		Credits_inverse_scale		= 1/.55 
  426. 		Credits_reel_inverse_scale	= 1/.48		 
  427. 	end 
  428. 	 
  429. 	Credits_objects = {} 
  430. 	 
  431. 	--Build image table from out list (This just makes coding easier) 
  432. 	 
  433. 	if Credits_format == "saints" then  
  434. 		--Saints version shows saints in time pics then team pics 
  435. 		for idx, img in pairs(Credits_images_saints) do 
  436. 			Credits_reel_data[Credits_reel_num_items] = { img = img } 
  437. 			Credits_reel_num_items = Credits_reel_num_items + 1 
  438. 		end 
  439. 	else 
  440. 		--Default version shows just team pics 
  441. 		for idx, img in pairs(Credits_images_default) do 
  442. 			Credits_reel_data[Credits_reel_num_items] = { img = img } 
  443. 			Credits_reel_num_items = Credits_reel_num_items + 1 
  444. 		end 
  445. 	end 
  446. 	 
  447. 	--Wipe out original credits table... 
  448. 	Credits_images_default = {} 
  449. 	Credits_images_saints = {} 
  450. 	 
  451. 	--Template Elements 
  452. 	Credits_objects.credits_base_h = vint_object_find("credits_base_grp") 
  453. 	Credits_objects.credits_slide_h = vint_object_find("credits_slide_grp") 
  454. 	Credits_objects.credits_reel_slide_h = vint_object_find("credits_reel_slide_grp") 
  455. 	 
  456. 	--Hide all base objects 
  457. 	for idx, val in pairs(CREDIT_OBJECT_FORMATTING) do 
  458. 		local base_grp_h = vint_object_find(val.base_grp) 
  459. 		vint_set_property(base_grp_h, "visible", false) 
  460. 	end 
  461.  
  462. 	--Hide reel base object... 
  463. 	local h = vint_object_find("reel_bmp", Credits_objects.credits_reel_slide_h) 
  464. 	vint_set_property(h, "visible", false) 
  465. 	 
  466. 	--logo img placeholder 
  467. 	Credits_objects.logo = vint_object_find("credit_logo") 
  468.  
  469. 	--populate first item with image... 
  470. 	local header_txt_h = vint_object_find("header_txt", 0, Credits_doc_handle) 
  471. 	local role_txt_h = vint_object_find("role_txt", 0, Credits_doc_handle) 
  472. 	 
  473. 	--use alien logo and make text red 
  474. 	if Credits_format == "fail" then 
  475. 		Credits_data[Credits_num_items] = { type = CREDITS_TYPE_IMAGE, data = {"ui_credits_logo"} } 
  476. 		vint_set_property(header_txt_h, "tint", COLOR_CREDITS_TEXT_RED.R, COLOR_CREDITS_TEXT_RED.G, COLOR_CREDITS_TEXT_RED.B) 
  477. 		vint_set_property(role_txt_h, "tint", COLOR_CREDITS_TEXT_RED.R, COLOR_CREDITS_TEXT_RED.G, COLOR_CREDITS_TEXT_RED.B) 
  478. 		ui_audio_post_event("Credits_Music_M06") 
  479. 	--use saints crest and make text gold 
  480. 	else 
  481. 		Credits_data[Credits_num_items] = { type = CREDITS_TYPE_IMAGE, data = {"ui_credits_logo_eagle"} } 
  482. 		vint_set_property(header_txt_h, "tint", COLOR_CREDITS_TEXT_GOLD.R, COLOR_CREDITS_TEXT_GOLD.G, COLOR_CREDITS_TEXT_GOLD.B) 
  483. 		vint_set_property(role_txt_h, "tint", COLOR_CREDITS_TEXT_GOLD.R, COLOR_CREDITS_TEXT_GOLD.G, COLOR_CREDITS_TEXT_GOLD.B) 
  484. 		 
  485. 		if Credits_is_in_game == true then 
  486. 			ui_audio_post_event("Credits_End_1") 
  487. 		end 
  488. 	end 
  489. 	Credits_num_items = Credits_num_items + 1 
  490. 	 
  491. 	--Download 50 of the first credits... 
  492. 	vint_dataresponder_request("credits_grab_credits", "credits_populate", 50) 
  493. 	 
  494. 	--Start thread for credits processing.... 
  495. 	Credits_thread = thread_new("credits_process") 
  496. 	 
  497. 	 
  498. 	--Play slideshow 
  499. 	credits_start_slideshow() 
  500. 	 
  501. 	--hide background layers... 
  502. 	local background_base_bg_h = vint_object_find("background_base_bg") 
  503. 	local credits_bg_grp_h = vint_object_find("credits_bg_grp") 
  504. 	vint_set_property(background_base_bg_h, "alpha", 0) 
  505. 	vint_set_property(credits_bg_grp_h, "alpha", 0) 
  506. 	 
  507. 	--Is the main menu loaded? if so do not delay background fade in. 
  508. 	if Credits_is_in_game then 
  509. 		local anim_h 
  510. 		--Fade the background in after a few seconds so the credits play over the cutscene. 
  511. 		if Credits_format ~= "fail" then 
  512. 			anim_h = vint_object_find("credits_bg_game_fade_in_delay") 
  513. 		else 
  514. 			anim_h = vint_object_find("credits_bg_game_fade_in") 
  515. 		end 
  516. 		vint_apply_start_values(anim_h) 
  517. 	--	lua_play_anim(anim_h) 
  518. 	else 
  519. 		--We are in main menu, play different anim 
  520. 		local anim_h = vint_object_find("credits_bg_main_menu_fade_in") 
  521. 		lua_play_anim(anim_h) 
  522. 	end 
  523. 	 
  524. 	local anim = vint_object_find("credit_bg_loop_anim") 
  525. 	lua_play_anim(anim,0) 
  526. 	 
  527. 	--Subscribe to input... 
  528. 	Input_tracker = Vdo_input_tracker:new() 
  529. 	Input_tracker:add_input("select", "credits_button_b", 50) 
  530. 	Input_tracker:add_input("back", "credits_button_b", 50) 
  531. 	Input_tracker:add_input("map", "credits_button_b", 50) 
  532. 	Input_tracker:add_input("inventory_y", "credits_input_stick", 50, true) 
  533. 	 
  534. 	if game_get_platform() == "PC" then 
  535. 		Input_tracker:add_input("key_down", "credits_input_faster", 50) 
  536. 		Input_tracker:add_input("key_up", "credits_input_slower", 50) 
  537. 	end 
  538.  
  539. 	Input_tracker:subscribe(true) 
  540. end 
  541.  
  542. function credits_cleanup() 
  543. 	-- stop audio 
  544. 	audio_object_post_event("Credits_Stop", nil, nil, nil, false) 
  545. 	ui_audio_post_event("Credits_Stop") 
  546. 	 
  547. 	---Cleanup any loaded pegs from our image reel... 
  548. 	for idx, val in pairs(Credits_reel_load_queue) do 
  549. 		if val ~= nil then 
  550. 			game_peg_unload(val.image_name) 
  551. 		end 
  552. 	end 
  553.  
  554. 	-- If we are in game we need to restore the pause map... 
  555. 	if Credits_is_in_game then 
  556. 		pause_map_restore() 
  557. 	end	 
  558.  
  559. 	if Credits_thread ~= -1 then 
  560. 		thread_kill(Credits_thread) 
  561. 	end 
  562. 	 
  563. 	if Credits_reel_thread ~= -1 then 
  564. 		thread_kill(Credits_reel_thread) 
  565. 	end 
  566. 	 
  567. 	Input_tracker:subscribe(false) 
  568. end 
  569.  
  570. ------------------------------------------------------------------------------- 
  571. -- Populates the credits... 
  572. -- 
  573. function credits_populate(item_type, str1, str2) 
  574. 	if item_type == CREDITS_FINISHED_TOKEN then 
  575. 		Credits_finished = true 
  576. 		return 
  577. 	end 
  578.  
  579. 	--If string is empty skip this credit... 
  580. 	if str1 == "" or  str1 == nil then 
  581. 		Credit_skipped = true 
  582. 		return 
  583. 	end 
  584. 	 
  585. 	Credits_data[Credits_num_items] = { type = item_type, y = -1 } 
  586. 	 
  587. 	if str2 ~= nil then  
  588. 		if item_type == CREDITS_TYPE_ROLE_NAME then 
  589. 			Credits_data[Credits_num_items].data = { str2, str1 } 
  590. 		else 
  591. 			Credits_data[Credits_num_items].data = { str1, str2 } 
  592. 		end 
  593. 	else 
  594. 		Credits_data[Credits_num_items].data = { str1 } 
  595. 	end 
  596. 	Credits_num_items = Credits_num_items + 1 
  597. end 
  598.  
  599. -------------------------------------------------------------------------------- 
  600. -- Credits process thread... used for formatting and moving the credits.... 
  601. -------------------------------------------------------------------------------- 
  602. function credits_process() 
  603. 	 
  604. 	local move_amount = 0 
  605. 	 
  606. 	local prev_item, new_item, credit_h, h, item_width, item_height, prev_height, prev_item_y, item_y 
  607. 	local create_new_item = false 
  608. 	local credits_play = true 
  609. 	 
  610. 	while credits_play do 
  611. 		--move credits 
  612. 		move_amount = Credits_scroll_speed * get_frame_time() 
  613. 		 
  614. 		--Slide Credits up 
  615. 		Credits_cur_slide_pos = Credits_cur_slide_pos - move_amount 
  616. 		vint_set_property(Credits_objects.credits_slide_h, "anchor", 0, Credits_cur_slide_pos) 
  617. 	 
  618. 		--Is the first top item off the screen?	 
  619. 		if Credits_cur_idx < 0 then 
  620. 			--Initialize always create first item... 
  621. 			create_new_item = true 
  622. 		else 
  623. 			--Remove first item? 
  624. 			local actual_slide_pos = Credits_cur_slide_pos + CREDITS_HALF_SCREEN_HEIGHT  
  625. 			 
  626. 			if Credits_data[Credits_oldest_idx] ~= nil then	 
  627. 				if actual_slide_pos <  (Credits_data[Credits_oldest_idx].y + (Credits_data[Credits_oldest_idx].height * Credits_inverse_scale) + CREDITS_SCREEN_LEEWAY_TOP) * -1 then 
  628. 					--Lets kill it 
  629. 					if Credits_data[Credits_oldest_idx].credit_h ~= nil then 
  630. 						vint_object_destroy(Credits_data[Credits_oldest_idx].credit_h) 
  631. 					end 
  632. 					 
  633. 					Credits_data[Credits_oldest_idx] = nil 
  634. 					Credits_oldest_idx = Credits_oldest_idx + 1 
  635. 					 
  636. 					--Attempt to Get the next credit... 
  637. 					if Credits_finished ~= true then 
  638. 						Credit_skipped = true 
  639. 						while Credit_skipped == true do 
  640. 							Credit_skipped = false 
  641. 							vint_dataresponder_request("credits_grab_credits", "credits_populate", 1) 
  642. 						end 
  643. 					end 
  644. 					 
  645. 					--Are credits complete? 
  646. 					if Credits_num_items == Credits_oldest_idx then 
  647. 						--Credits complete 
  648. 						credits_complete() 
  649. 						credits_play = false 
  650. 					end 
  651. 				end 
  652. 			end	 
  653.  
  654. 			if Credits_data[Credits_cur_idx] ~= nil then		 
  655. 				--Build next item 
  656. 				local next_item_build_at = (Credits_data[Credits_cur_idx].y + Credits_data[Credits_cur_idx].height) * -1 
  657. 				actual_slide_pos = Credits_cur_slide_pos - CREDITS_HALF_SCREEN_HEIGHT  
  658. 				if actual_slide_pos < next_item_build_at + CREDITS_SCREEN_LEEWAY_BOTTOM then 
  659. 					create_new_item = true  
  660. 				end 
  661. 			end 
  662. 		end 
  663. 		 
  664. 		--Should I create an item on the bottom? 
  665. 		if create_new_item == true then 
  666. 			--What is the new item going to be? 
  667. 			local next_index = Credits_cur_idx + 1 
  668. 			new_item = Credits_data[next_index] 
  669. 			 
  670. 			if new_item ~= nil and next_index <= Credits_num_items then 
  671. 				--store new index to global. 
  672. 				Credits_cur_idx = next_index 
  673. 	 
  674. 				--get item type, data and formatting for that item... 
  675. 				local item_type = new_item.type 
  676. 				local item_data = new_item.data 
  677. 				local credit_object_format = CREDIT_OBJECT_FORMATTING[item_type] 
  678. 					 
  679. 				--find our base object 
  680. 				local base_grp = credit_object_format.base_grp 
  681. 				local base_grp_h = vint_object_find(base_grp)  
  682. 					 
  683. 				--Clone it... 
  684. 				local base_grp_clone_h = vint_object_clone(base_grp_h) 
  685. 				 
  686. 				local height = 0 
  687. 				 
  688. 				if item_type == CREDITS_TYPE_IMAGE then 
  689. 					--Image Type 
  690. 					local image_h = vint_object_find("img_bmp", base_grp_clone_h) 
  691. 					local image_name = item_data[1] 
  692. 					 
  693. 					vint_set_property(image_h, "image", image_name) 
  694. 					local image_width, image_height = element_get_actual_size(image_h) 
  695. 					height = image_height 
  696. 				else 
  697. 					--All other types... 
  698. 					local txt_objects = credit_object_format.txt_objects 
  699. 					local num_txt_objects = #txt_objects 
  700. 					 
  701. 					for i = 1, num_txt_objects do 
  702. 						local txt_object = txt_objects[i] 
  703. 						 
  704. 						--Find our text object... 
  705. 						local txt_object_h = vint_object_find(txt_object, base_grp_clone_h) 
  706. 						 
  707. 						local txt_data = item_data[i] 
  708. 						 
  709. 						--Set text tag... 
  710. 						vint_set_property(txt_object_h, "text_tag", txt_data) 
  711. 						 
  712. 						--calculate height... 
  713. 						if txt_data ~= "" then 
  714. 							--only calculate height on credit items with strings in them... 
  715. 							local text_width, text_height = element_get_actual_size(txt_object_h) 
  716. 							 
  717. 							--move name down on wrapped roles 
  718. 							if item_type == CREDITS_TYPE_ROLE_NAME then 
  719. 								if i == 1 then 
  720. 									local next_txt_object_h = vint_object_find(txt_objects[i+1], base_grp_clone_h) 
  721. 									local role_width, role_height = element_get_actual_size(txt_object_h) 
  722. 									local name_width, name_height = element_get_actual_size(next_txt_object_h) 
  723. 									if txt_object == "role_txt" and role_height > name_height then 
  724. 										local x, y = vint_get_property(next_txt_object_h, "anchor") 
  725. 										local name_move = y + (role_height - name_height) 
  726. 										vint_set_property(next_txt_object_h, "anchor", x, name_move) 
  727. 									end 
  728. 								end 
  729. 							end 
  730. 							 
  731. 							if credit_object_format.stacked == true then 
  732. 								 
  733. 								if i > 1 then 
  734. 									--get original position 
  735. 									local x, y = vint_get_property(txt_object_h, "anchor") 
  736. 									 
  737. 									--shift y down... +3 offset for each item. 
  738. 									y = height + (3 * (i - 1)) 
  739. 									 
  740. 									--set new position 
  741. 									vint_set_property(txt_object_h, "anchor", x, y) 
  742. 								end 
  743. 								 
  744. 								--stacked... add heights... 
  745. 								height = height + text_height 
  746. 							else 
  747. 								--Not stacked... figure out largest height... 
  748. 								height = max(height, text_height) 
  749. 							end 
  750. 						end 
  751. 					end 
  752. 					 
  753. 				end 
  754. 				 
  755. 				 
  756. 				--Reassign parent and set visible... 
  757. 				vint_object_set_parent(base_grp_clone_h, Credits_objects.credits_slide_h) 
  758. 				vint_set_property(base_grp_clone_h, "visible", true) 
  759. 				 
  760. 				--Calculate y from previous item data 
  761. 				prev_item = Credits_data[Credits_cur_idx - 1] 
  762. 				 
  763. 				if prev_item == nil then 
  764. 					--no item, so we always start at 0. 
  765. 					item_y = 0 
  766. 				else 
  767. 					local prev_type = prev_item.type 
  768. 					local vertical_spacing = credit_object_format[prev_type]		--get spacing from our previous object type... 
  769. 					local prev_height = prev_item.height								--get height of previous item...					 
  770. 					item_y = prev_item.y + prev_height + vertical_spacing			--add previous item y + height + spacing. 
  771. 				end 
  772. 				 
  773. 				--Position object 
  774. 				vint_set_property(base_grp_clone_h, "anchor", 0, item_y) 
  775. 				 
  776. 				--store off the new object for processing and cleanup... 
  777. 				new_item.credit_h = base_grp_clone_h 
  778. 				new_item.height = height  
  779. 				new_item.type = item_type  
  780. 				new_item.y = item_y  
  781. 			end 
  782. 			 
  783. 			--Do not create the next item automatically 
  784. 			create_new_item = false 
  785. 		end 
  786. 		thread_yield() 
  787. 	end 
  788. end 
  789.  
  790. -------------------------------------------------------------------------------- 
  791. -- Reel Slide 
  792. -------------------------------------------------------------------------------- 
  793. function credits_reel_process() 
  794. 	 
  795. 	local move_amount = 0 
  796. 	 
  797. 	local prev_item, new_item, credit_h, h, item_width, item_height, prev_item_height, prev_item_y, item_y 
  798. 	local next_item_build_at = 0 
  799. 	local create_new_item = false 
  800. 	local credits_play = true 
  801. 	 
  802. 	while credits_play do 
  803. 		--move Reel... 
  804. 		 
  805. 		--Reel moves at half speed of normal credit speed... 
  806. 		move_amount = Credits_scroll_speed * get_frame_time() *.6 
  807. 		 
  808. 		--Slide Credits up 
  809. 		Credits_reel_cur_slide_pos = Credits_reel_cur_slide_pos - move_amount 
  810. 		vint_set_property(Credits_objects.credits_reel_slide_h, "anchor", 0, Credits_reel_cur_slide_pos) 
  811. 		 
  812. 		--Is the first top item off the screen?	 
  813. 		if Credits_reel_cur_idx < 0 then 
  814. 			--Initialize always create first item... 
  815. 			create_new_item = true 
  816. 		else 
  817. 			--Remove first item? 
  818. 			local actual_slide_pos = Credits_reel_cur_slide_pos + CREDITS_HALF_SCREEN_HEIGHT  
  819. 			 
  820. 			if Credits_reel_data[Credits_reel_oldest_idx] ~= nil then	 
  821. 				if actual_slide_pos <  (Credits_reel_data[Credits_reel_oldest_idx].y + (CREDITS_REEL_IMG_HEIGHT * Credits_reel_inverse_scale) + CREDITS_IMAGE_SCREEN_LEEWAY_TOP) * -1 then 
  822. 					--Lets kill it 
  823. 					if Credits_reel_data[Credits_reel_oldest_idx].img_h ~= nil then 
  824. 						local image_data = Credits_reel_data[Credits_reel_oldest_idx] 
  825. 						vint_object_destroy(image_data.img_h) 
  826. 						game_peg_unload(image_data.img) 
  827. 						 
  828. 						Credits_reel_load_queue[image_data.queue_num] = nil 
  829. 					end 
  830. 					 
  831. 					Credits_reel_data[Credits_reel_oldest_idx] = nil 
  832. 					Credits_reel_oldest_idx = Credits_reel_oldest_idx + 1 
  833. 					 
  834. 					--Are credits complete? 
  835. 					if Credits_reel_num_items == Credits_reel_oldest_idx then 
  836. 						--Credit reel complete... 
  837. 						credits_play = false 
  838. 					end 
  839. 				end 
  840. 			end	 
  841. 			if Credits_reel_data[Credits_reel_cur_idx] ~= nil then		 
  842. 				actual_slide_pos = Credits_reel_cur_slide_pos - CREDITS_HALF_SCREEN_HEIGHT  
  843. 				if actual_slide_pos < next_item_build_at + CREDITS_IMAGE_SCREEN_LEEWAY_BOTTOM then				 
  844. 					create_new_item = true  
  845. 				end 
  846. 			end 
  847. 		end 
  848.  
  849. 		--Should I create an item on the bottom? 
  850. 		if create_new_item == true then 
  851. 			--What is the new item going to be? 
  852. 			local next_idx = Credits_reel_cur_idx + 1 
  853. 			new_item = Credits_reel_data[next_idx] 
  854. 			 
  855. 			if new_item ~= nil and next_idx <= Credits_reel_num_items then	 
  856. 				--store current index to global... 
  857. 				Credits_reel_cur_idx = next_idx 
  858. 				 
  859. 				local image_name = Credits_reel_data[Credits_reel_cur_idx].img 
  860. 		 
  861. 				--Position Image 
  862. 				local base_image_h = vint_object_find("reel_bmp", Credits_objects.credits_reel_slide_h) 
  863. 				 
  864. 				--Clone image base 
  865. 				local image_clone_h = vint_object_clone(base_image_h) 
  866. 				vint_object_set_parent(image_clone_h, Credits_objects.credits_reel_slide_h) 
  867. 				vint_set_property(image_clone_h, "visible", true) 
  868.  
  869. 				--Stream in the next image... 
  870. 				local queue_num = Credits_reel_load_num 
  871. 				game_peg_load_with_cb("credits_reel_peg_loaded", 1, image_name) 
  872. 				Credits_reel_load_queue[queue_num] = { image_name = image_name, image_h = image_clone_h} 
  873. 				Credits_reel_load_num = Credits_reel_load_num + 1 
  874. 				 
  875. 				--Position it. 
  876. 				 
  877. 				--Calculate y from previous item data 
  878. 				prev_item = Credits_reel_data[Credits_reel_cur_idx - 1] 
  879. 				if prev_item == nil then 
  880. 					--no item, so we always start at 0. 
  881. 					item_y = 0 
  882. 				else 
  883. 					item_y = prev_item.y + CREDITS_REEL_IMG_HEIGHT + CREDITS_REEL_IMG_SPACING --add previous item y + height + spacing. 
  884. 				end 
  885. 					 
  886. 				--Position object 
  887. 				vint_set_property(image_clone_h, "anchor", 0, item_y) 
  888. 				 
  889. 				--store off the new object for processing and cleanup... 
  890. 				new_item.img_h = image_clone_h 
  891. 				new_item.height = CREDITS_REEL_IMG_HEIGHT 
  892. 				new_item.queue_num = queue_num		--Store queue number so we can remove it from the list on peg unload... 
  893. 				 
  894. 				--Build next item 
  895. 				next_item_build_at = (item_y + CREDITS_REEL_IMG_HEIGHT) * -1 
  896. 				new_item.y = item_y  
  897. 			end 
  898. 			 
  899. 			--Do not create the next item automatically 
  900. 			create_new_item = false 
  901. 		end 
  902. 		thread_yield() 
  903. 	end 
  904. end 
  905.  
  906.  
  907. function credits_complete() 
  908. 	--Unsubscribe from controls 
  909. 	Input_tracker:subscribe(false) 
  910. 	 
  911. 	--Tell game that credits are done rolling 
  912. 	--TODO: Darryl needs to hook this in... 
  913. 	--credits_are_finished() 
  914. 	pop_screen() 
  915. end 
  916.  
  917. ---------------------------------- 
  918. --Input Functions 
  919. ---------------------------------- 
  920. function credits_input_stick(event, value) 
  921. 	if event == "inventory_y" then 
  922. 		--Adjust credit speed 
  923. 		if value > 0 then 
  924. 			Credits_scroll_speed = CREDITS_PIXELS_PER_SEC_NORMAL + (CREDITS_PIXELS_PER_SEC_MIN - CREDITS_PIXELS_PER_SEC_NORMAL ) * value  
  925. 			 
  926. 		elseif value < 0 then 
  927. 		 
  928. 			Credits_scroll_speed = 	CREDITS_PIXELS_PER_SEC_NORMAL + (CREDITS_PIXELS_PER_SEC_MAX - CREDITS_PIXELS_PER_SEC_NORMAL) * value * -1  
  929. 		else 
  930. 			Credits_scroll_speed = CREDITS_PIXELS_PER_SEC_NORMAL  
  931. 		end 
  932. 	end 
  933. end 
  934.  
  935.  
  936. function credits_input_faster(event) 
  937. 	local slow_speed = CREDITS_PIXELS_PER_SEC_NORMAL + (CREDITS_PIXELS_PER_SEC_MIN - CREDITS_PIXELS_PER_SEC_NORMAL)  
  938. 	local fast_speed = CREDITS_PIXELS_PER_SEC_NORMAL + (CREDITS_PIXELS_PER_SEC_MAX_PC - CREDITS_PIXELS_PER_SEC_NORMAL)  
  939. 	if Credits_scroll_speed == slow_speed then 
  940. 		Credits_scroll_speed = CREDITS_PIXELS_PER_SEC_NORMAL 
  941. 	elseif Credits_scroll_speed == CREDITS_PIXELS_PER_SEC_NORMAL then 
  942. 		Credits_scroll_speed = fast_speed 
  943. 	else 
  944. 		--Credits_scroll_speed = slow_speed 
  945. 	end 
  946. end 
  947.  
  948. function credits_input_slower(event) 
  949.  
  950. 	local slow_speed = CREDITS_PIXELS_PER_SEC_NORMAL + (CREDITS_PIXELS_PER_SEC_MIN - CREDITS_PIXELS_PER_SEC_NORMAL)  
  951. 	local fast_speed = CREDITS_PIXELS_PER_SEC_NORMAL + (CREDITS_PIXELS_PER_SEC_MAX_PC - CREDITS_PIXELS_PER_SEC_NORMAL)  
  952. 	if Credits_scroll_speed == fast_speed then 
  953. 		Credits_scroll_speed = CREDITS_PIXELS_PER_SEC_NORMAL 
  954. 	elseif Credits_scroll_speed == CREDITS_PIXELS_PER_SEC_NORMAL then 
  955. 		Credits_scroll_speed = slow_speed 
  956. 	else 
  957. 		--Credits_scroll_speed = fast_speed 
  958. 	end 
  959. end 
  960.  
  961. function credits_button_b(event, acceleration) 
  962. 	--exit credits 
  963. 	credits_complete() 
  964. end 
  965.  
  966.  
  967. function credits_reel_peg_loaded() 
  968. 	--after images load then we have to set the image on the bitmap handle... 
  969. 	local image_info = Credits_reel_load_queue[Credits_reel_loaded_num] 
  970. 	if image_info == nil then 
  971. 		return 
  972. 	end 
  973. 	 
  974. 	local image_name = image_info.image_name 
  975. 	local image_h = image_info.image_h 
  976. 	vint_set_property(image_h, "image", image_name) 
  977.  
  978. 	Credits_reel_loaded_num = Credits_reel_loaded_num + 1 
  979. end 
  980.  
  981. function credits_start_slideshow() 
  982. 	--Credits_reel_thread = thread_new("credits_reel_process") 
  983. end 
  984.  
  985. --[[ 
  986. OLD FUNCTIONALITY??? 
  987. function credits_input_btn(event, accelleration) 
  988. 	 
  989. 	if Credits_skip_available == true then 
  990. 		if event == "exit" then 
  991. 			credits_were_skipped() 
  992. 		elseif credits_in_cutscene() == false then 
  993. 			credits_complete() 
  994. 		end 
  995. 	end 
  996. end 
  997. ]] 
  998.