./cmp_common.lua

  1. ------------------------------------------------------------------------------- 
  2. --Constants 
  3. ------------------------------------------------------------------------------- 
  4. CMP_TEST_MODE = false					--Modes for testing... 
  5. CMP_TEST_NO_MULTIPLIER = false 
  6.  
  7. --LUT tables... 
  8. CMP_LUT_DEFAULT = "none" 
  9. CMP_LUT_MISSION = "lut_completion_screen" 
  10.  
  11. --Screen Layout 
  12. CMP_SCREEN_LAYOUT_LEFT = 0 
  13. CMP_SCREEN_LAYOUT_RIGHT = 1 
  14.  
  15. --Screen types... 
  16. CMP_SCREEN_TITLE_INDEX = 1 
  17. CMP_SCREEN_CASH_INDEX = 2 
  18. CMP_SCREEN_RESPECT_INDEX = 3 
  19. CMP_SCREEN_CONTROL_INDEX = 4 
  20. CMP_SCREEN_REWARD_INDEX = 5 
  21. CMP_SCREEN_COOP_WAIT_INDEX = 6 
  22.  
  23. --Respect Constants... 
  24. local RESPECT_START_ANGLE = 2.51 
  25. local RESPECT_END_ANGLE = 2.65 	-- This is really negative, but entering as positive to make equation work 
  26.  
  27. local RESPECT_METER_UPDATE					= 0 
  28. local RESPECT_METER_UPDATE_BONUS			= 1 
  29. local RESPECT_METER_UPDATE_NO_BONUS		= 2 
  30.  
  31. -- District Control Constants... 
  32. local CONTROL_START_ANGLE 	= 2.43 
  33. local CONTROL_END_ANGLE 	= 2.27000	-- This is really negative, but entering as positive to make equation work 
  34.  
  35. local RESPECT_METER_UPDATE					= 0 
  36. local RESPECT_METER_UPDATE_BONUS			= 1 
  37. local RESPECT_METER_UPDATE_NO_BONUS		= 2 
  38.  
  39.  
  40. -- Cash/Respect Ramp Constants for Animation and Audio... 
  41. local CMP_TIME_CASH 					= 1166				--	23 frames (766) 
  42. local CMP_TIME_CASH_BONUS 			= 1100				-- 1 sec 3 frames? 
  43. local CMP_TIME_CASH_NO_BONUS 		= 2560				-- 2 sec 9 frames? 
  44. local CMP_TIME_RESPECT 				= 1766	* .001	-- 1 sec 22 frames (1733) 
  45. local CMP_TIME_RESPECT_BONUS		= 1580	* .001	-- 1 sec 14 frames (1733) 
  46. local CMP_TIME_RESPECT_NO_BONUS	= 3433 	* .001	-- 3 sec 13 frames (3433) 
  47. local CMP_TIME_CONTROL				= 1580	* .001	-- 1 sec 22 frames (1733) 
  48.  
  49. local CMP_COLOR_TEXT_PURPLE = {R=148/255, G=0/255, B=197/255} 
  50. local CMP_COLOR_TEXT_WHITE = {R=220/255, G=220/255, B=220/255} 
  51. local CMP_COLOR_TEXT_WHITE_2 = {R=180/255, G=180/255, B=180/255} 
  52.  
  53. ------------------------------------------------------------------------------- 
  54. -- Globals 
  55. ------------------------------------------------------------------------------- 
  56. Cmp_screen_idx = 0					--Index of the current screen 
  57. Cmp_screen_sequence_started = false 	-- Bool determines if we have started the screen... 
  58. Cmp_screen_is_playing = false		--Bool determines whether the current screen is in an animation state. 
  59. Cmp_screen_base_x = 0				-- Base position x 
  60. Cmp_screen_base_y = 0				-- Base position Y 
  61.  
  62. Cmp_common_doc = -1					-- Handle of common document 
  63. Cmp_specific_doc  = -1				-- Handle of specific completion screen doc(mission, activity, stronghold) 
  64. Cmp_image = 0							-- Used to store reference to loaded image for any completion screen format. 
  65. Cmp_common_has_image = false		-- Used to determine if we have an image or not (cannot use the name because of the way we load the image) 
  66. Cmp_common_image_is_visible = true 	--Used to determine if the completion image is visible or so we don't fade it out twice... 
  67. Cmp_common_bg_saints_active = false		--used to determine if bg saints is active or not... 
  68.  
  69. Cmp_Input_tracker = -1 
  70. local Cmp_mouse_input_tracker 
  71. local Cmp_bg_image 
  72. Cmp_common_input_is_blocked = true 
  73. Cmp_common_input_delay_thread = -1 
  74.  
  75. Cmp_common_coop_dialog_handle = 0	--coop dialog for exiting early... 
  76.  
  77. Cmp_sequence_data = -1				--Data reference for screen, this is set through cmp_common_screen_set_data(). 
  78. Cmp_hintbar = -1						--Global for the Hintbar VDO used on all the screens. 
  79.  
  80. Cmp_common_audio_ramp_id = -1				--Reference to audio ramp 
  81. Cmp_common_audio_music_id = -1			--Reference to completion screen music... 
  82.  
  83. --Stars 
  84. local Cmp_stars = { 
  85. 	[1] = "star_01", 
  86. 	[2] = "star_02", 
  87. 	[3] = "star_03", 
  88. 	[4] = "star_04", 
  89. 	[5] = "star_05", 
  90. 	[6] = "star_06", 
  91. 	[7] = "star_07", 
  92. 	[8] = "star_08", 
  93. 	[9] = "star_09", 
  94. 	[10] = "star_10", 
  95. 	[11] = "star_11", 
  96. 	[12] = "star_12", 
  97. } 
  98.  
  99. --Cash count 
  100. Cmp_screen_cash_start = 0				--When the cash count starts this the starting value... 
  101. Cmp_screen_cash_end = 0						--When the cash count ends this is the ending value... 
  102. Cmp_screen_cash_total = 0					--The total amount of cash earned... 
  103. Cmp_screen_cash_skip_bonus = false		--Determines whether or not we skip the multiplier stage... 
  104. Cmp_screen_cash_count_is_bonus = false	--Determines whether we are doing the bonus stage or not... 
  105. Cmp_screen_cash_skip = 0					--Determines if the cash screen should be skipped 
  106. Cmp_common_cash_complete_cb = 0			--Callback for function after cash is completed... 
  107.  
  108. --Respect  
  109. Cmp_screen_respect_queue = {} 
  110. Cmp_screen_respect_level_dif = 0			--Difference to the next level, this gets decremented every fill. 
  111. Cmp_screen_respect_target_pct = 0		--Target percentage for final fill, this is what the meter is set to after the last full fill. 
  112.  
  113. Cmp_screen_respect_time_start = 0		--This is the fill time for the percent part of the meter....	 
  114. Cmp_screen_respect_time_mid = 0  
  115. Cmp_screen_respect_time_end = 0  
  116.  
  117. Cmp_screen_respect_level_cur = 0		--This is the current level of the respect, we will increment manually this every time the meter fills up... 
  118. Cmp_screen_respect_skip_bonus = false	--Determines whether or not we skip the multiplier stage... 
  119.  
  120. --Coop 
  121. Cmp_screen_coop_is_waiting = false			--Determines whether or not we are on the coop waiting screen. 
  122. Cmp_screen_coop_gamer_tag = "PLAYER"		--Coop gamer tag... this should get updated by c++ in cmp_common_coop_wait_start() 
  123.  
  124. local continue_hint_data = { 
  125. 	{CTRL_MENU_BUTTON_A, "COMPLETION_CONTINUE"}, 
  126. } 
  127. local coop_hint_data = { 
  128. 	{CTRL_MENU_BUTTON_BACK, "COMPLETION_COOP_DISCONNECT"}, 
  129. } 
  130.  
  131. function cmp_common_init() 
  132. 	--Set common doc global... 
  133. 	Cmp_common_doc = vint_document_find("cmp_common") 
  134. 	 
  135. 	local h = vint_object_find("screen_grp") 
  136. 	Cmp_screen_base_x, Cmp_screen_base_y = vint_get_property(h, "anchor") 
  137. 	 
  138. 	--Init Hintbar 
  139. 	Cmp_hintbar = Vdo_hint_bar:new("hint_bar") 
  140. 	Cmp_hintbar:set_hints(continue_hint_data) 
  141. 	Cmp_hintbar:enable_text_shadow(true) 
  142. 	Cmp_hintbar:pulse(1) 
  143. 	Cmp_hintbar:set_alpha(0) 
  144.  
  145. 	local coop_hintbar = Vdo_hint_bar:new("coop_hint_bar") 
  146. 	coop_hintbar:set_hints(coop_hint_data) 
  147. 	coop_hintbar:enable_text_shadow(true) 
  148. 	 
  149. 	--Hide elements 
  150. 	local h = vint_object_find("background_base") 
  151. 	vint_set_property(h, "visible", false)  
  152. 	 
  153. 	local h = vint_object_find("title_grp", 0, Cmp_common_doc) 
  154. 	vint_set_property(h, "alpha", 0) 
  155. 	 
  156. 	local h = vint_object_find("cash_grp", 0, Cmp_common_doc) 
  157. 	vint_set_property(h, "alpha", 0) 
  158. 	local h = vint_object_find("cash_bonus_txt", 0, Cmp_common_doc) 
  159. 	vint_set_property(h, "alpha", 0) 
  160. 	 
  161. 	local h = vint_object_find("respect_grp", 0, Cmp_common_doc) 
  162. 	vint_set_property(h, "alpha", 0) 
  163. 	 
  164. 	local h = vint_object_find("control_grp", 0, Cmp_common_doc) 
  165. 	vint_set_property(h, "alpha", 0) 
  166. 	 
  167. 	local h = vint_object_find("coop_wait_grp", 0, Cmp_common_doc) 
  168. 	vint_set_property(h, "alpha", 0) 
  169. 	 
  170. 	-- Dynamically Replace color on all elements... 
  171. 	local purple_elements = { 
  172. 		"title_txt", 
  173. 		"cash_txt", 
  174. 		"respect_meter", 
  175. 		"respect_txt", 
  176. 	} 
  177. 	local white_elements = { 
  178. 		"complete_txt", 
  179. 		"cash_amount_txt", 
  180. 		"respect_level_text", 
  181. 	} 
  182. 	 
  183. 	local white_2_elements = { 
  184. 		"respect_bonus_txt", 
  185. 		"cash_bonus_txt", 
  186. 	} 
  187. 	 
  188. 	for idx, val in pairs(purple_elements) do 
  189. 		local h = vint_object_find(val) 
  190. 		vint_set_property(h, "tint", CMP_COLOR_TEXT_PURPLE.R, CMP_COLOR_TEXT_PURPLE.G, CMP_COLOR_TEXT_PURPLE.B) 
  191. 	end 
  192. 	 
  193. 	for idx, val in pairs(white_elements) do 
  194. 		local h = vint_object_find(val) 
  195. 		vint_set_property(h, "tint", CMP_COLOR_TEXT_WHITE.R, CMP_COLOR_TEXT_WHITE.G, CMP_COLOR_TEXT_WHITE.B) 
  196. 	end 
  197. 	 
  198. 	for idx, val in pairs(white_2_elements) do 
  199. 		local h = vint_object_find(val) 
  200. 		vint_set_property(h, "tint", CMP_COLOR_TEXT_WHITE_2.R, CMP_COLOR_TEXT_WHITE_2.G, CMP_COLOR_TEXT_WHITE_2.B) 
  201. 	end 
  202. 	 
  203. 	--bg saints group hide 
  204. 	local bg_saints_grp_h = vint_object_find("bg_saints_grp", 0, Cmp_common_doc) 
  205. 	vint_set_property(bg_saints_grp_h, "alpha", 0) 
  206. 	 
  207. 	--Loop BG Saints 
  208. 	local bg_saints_loop_anim_h = vint_object_find("bg_saints_loop_anim", 0, Cmp_common_doc) 
  209. 	lua_play_anim(bg_saints_loop_anim_h) 
  210. 	 
  211. 	--Tween Callbacks for ending Screens... 
  212. 	local twn_h = vint_object_find("title_end_twn", 0, Cmp_common_doc) 
  213. 	vint_set_property(twn_h, "end_event", "cmp_common_title_end") 
  214.  
  215. 	local twn_h = vint_object_find("title_in_twn", 0, Cmp_common_doc) 
  216. 	vint_set_property(twn_h, "end_event", "cmp_common_title_slam")	 
  217. 		 
  218. 	--Note: Cash will end on its own because it is run via thread...	 
  219. 	--Enable Cash Callback... 
  220. 	cmp_common_cash_callback_enable(true) 
  221. 	 
  222. 	--Enable Respect Callback... 
  223. 	cmp_common_respect_cb_enable(true) 
  224. 	 
  225. 	--Enable Control Callback... 
  226. 	cmp_common_control_cb_enable(true)	 
  227. 	 
  228. 	--Enable sound callbacks 
  229. 	cmp_audio_cb_enable() 
  230.  
  231. 	--Input 
  232. 	Cmp_Input_tracker = Vdo_input_tracker:new() 
  233. 	Cmp_Input_tracker:add_input("select", "cmp_process_input", 50) 
  234. 	Cmp_Input_tracker:add_input("back", "cmp_process_input", 50) 
  235. 	Cmp_Input_tracker:add_input("map", "cmp_process_input", 50) 
  236. 	Cmp_Input_tracker:add_input("pause", "cmp_process_input", 50) 
  237. 	Cmp_Input_tracker:subscribe(false) 
  238. 	 
  239. 	if game_get_platform() == "PC" then 
  240. 		Cmp_bg_image = Vdo_base_object:new("background_bmp", 0, Cmp_common_doc) 
  241. 		Cmp_mouse_input_tracker = Vdo_input_tracker:new() 
  242. 		Cmp_mouse_input_tracker:add_mouse_input("mouse_move", "cmp_common_mouse_move", 0, Cmp_bg_image.handle) 
  243. 		Cmp_mouse_input_tracker:add_mouse_input("mouse_click", "cmp_common_mouse_click", 0, Cmp_bg_image.handle) 
  244. 		Cmp_mouse_input_tracker:subscribe(false) 
  245. 	end 
  246. 	 
  247. 	vint_dataitem_add_subscription("completion_camera_shake", "update", "cmp_common_camera_shake_update") 
  248. end 
  249.  
  250. function cmp_common_cleanup() 
  251. 	--unsubscribe inputs... 
  252. 	if Cmp_Input_tracker ~= nil then 
  253. 		Cmp_Input_tracker:subscribe(false) 
  254. 	end 
  255. 	 
  256. 	if Cmp_mouse_input_tracker ~= nil then 
  257. 		Cmp_mouse_input_tracker:subscribe(false) 
  258. 	end 
  259. 	 
  260. 	--Unload image if we had one..... 
  261. 	if Cmp_image ~= 0 then 
  262. 		game_peg_unload(Cmp_image) 
  263. 	end 
  264.  
  265. 	cmp_common_lut_effect(CMP_LUT_DEFAULT) 
  266. 	 
  267. 	--Stop music... 
  268. 	game_audio_stop(Cmp_common_audio_music_id) 
  269. end 
  270.  
  271. function cmp_common_screen_start(screen_layout) 
  272. 	--Play Intro Animation...(This is screen independant) 
  273. 	local intro_anim_h = vint_object_find("screen_in_anim", 0, Cmp_common_doc) 
  274. 	lua_play_anim(intro_anim_h, 0, Cmp_common_doc) 
  275. 	 
  276. 	local use_as_background = true 
  277.  
  278. 	--determine if we skipped a cutscene or if there is no final screen 
  279. 	local mission_doc_h = vint_document_find("cmp_mission") 
  280. 	local activity_doc_h = vint_document_find("cmp_activity") 
  281. 	local stronghold_doc_h = vint_document_find("cmp_stronghold") 
  282. 	local show_mission_image = false 
  283. 	 
  284. 	--check to see if we want to show the image for mission screens... 
  285. 	if mission_doc_h ~= 0 then		 
  286. 		--first check if we had an active cutscene... 
  287. 		if completion_cutscene_was_active() then  
  288. 			--now check to see if we skipped the cutscene 
  289. 			if completion_cutscene_was_skipped() then 
  290. 				show_mission_image = true 
  291. 			end 
  292. 		end 
  293. 		 
  294. 		if not completion_cutscene_was_active() then 
  295. 			show_mission_image = true 
  296. 		end 
  297. 		 
  298. 		--Show black style screen if credits were active...(used in final cutscenes m23_out and m24_out) 
  299. 		if completion_cutscene_was_active() then 
  300. 			if completion_credits_were_active() then 
  301. 				show_mission_image = true 
  302. 			end 
  303. 		end 
  304. 		 
  305. 		--Show the image if  
  306. 		if show_mission_image then 
  307. 			--reset screen layout... 
  308. 			screen_layout = CMP_SCREEN_LAYOUT_LEFT 
  309. 			 
  310. 			--set image (this is loaded in with cmp_mission) 
  311. 			local image = "ui_cmp_saint" 
  312. 			Cmp_sequence_data[1].image = image 
  313. 			 
  314. 			--Set global to image name and set image names to the objects via callback. 
  315. 			Cmp_image = image 
  316. 			cmp_common_image_loaded() 
  317. 			 
  318. 			--Clear out the global image name so we don't try to clean it up. 
  319. 			Cmp_image = 0 
  320. 		end 
  321. 	end 
  322.  
  323. 	--Attemp to activate bg saints... 
  324. 	if activity_doc_h ~= 0 or stronghold_doc_h ~= 0 or show_mission_image == true then 
  325. 		Cmp_common_bg_saints_active = true 
  326. 		cmp_common_bg_saints_show(true) 
  327. 		use_as_background = false 
  328. 	end 
  329. 	 
  330. 	if Cmp_sequence_data[1] ~= nil then 
  331. 		if Cmp_sequence_data[1].mission_internal_name == "m06" then 
  332. 			use_as_background = false 
  333. 		end 
  334. 		if Cmp_sequence_data[1].mission_internal_name == "m16" then 
  335. 			if game_get_language() == "NL" then 
  336. 				--resize title for dutch in mission 16 
  337. 				cmp_common_title_resize(.55) 
  338. 			end 
  339. 		end 
  340. 	end 
  341.  
  342. 	--Show background_base... 
  343. 	local h = vint_object_find("background_base", 0, Cmp_common_doc) 
  344. 	vint_set_property(h, "visible", true)  
  345. 	vint_set_property(h, "background", use_as_background)  
  346. 	 
  347. 	--Right Justify screen if needed... 
  348. 	if screen_layout == CMP_SCREEN_LAYOUT_RIGHT then 
  349. 		--Align screen right (screen is default left aligned) 
  350. 		cmp_common_right_justification() 
  351. 	end	 
  352. 	 
  353. 	-- Advance first screen... 
  354. 	cmp_common_screen_advance(false) 
  355. 	 
  356. 	--Set that we have started the sequence... 
  357. 	Cmp_screen_sequence_started = true 
  358. 	 
  359. 	-- Unblock input. 
  360. 	Cmp_Input_tracker:subscribe(true) 
  361. 	if Cmp_mouse_input_tracker ~= nil then 
  362. 		Cmp_mouse_input_tracker:subscribe(true) 
  363. 	end 
  364. end 
  365.  
  366. function cmp_common_screen_set_data(data) 
  367. 	Cmp_sequence_data = data 
  368. end 
  369.  
  370.  
  371. -- Advances screen to next screen in sequence. 
  372. -- @param	force_advance		bool determines if we force advance to the next screen... 
  373. function cmp_common_screen_advance(force_advance) 
  374. 	if force_advance == false or force_advance == nil then 
  375. 		if Cmp_screen_is_playing then 
  376. 			--A current screen is in progress... we should force it to the end... 
  377. 			local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  378. 			if screen_data ~= nil then	 
  379. 				--Call Skip function for that particular screen type... 
  380. 				local screen_type = screen_data.type 
  381. 				Cmp_screens[screen_data.type].skip_func() 
  382. 			end 
  383. 			return 
  384. 		end 
  385. 	end 
  386. 	 
  387. 	-- If we aren't force advancing, we will animate it out. 
  388. 	if force_advance == false or force_advance == nil then 
  389. 		--Animate out the previous screen... 
  390. 		local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  391. 		if screen_data ~= nil then 
  392. 			local screen_type = screen_data.type 
  393. 			Cmp_screens[screen_data.type].out_func() 
  394. 		end 
  395. 	end 
  396. 	 
  397. 	--Increment the current screen to next... 
  398. 	Cmp_screen_idx = Cmp_screen_idx + 1 
  399. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  400.  
  401. 	--if we are a screen before the  final screen we should attemp to hide bg_saints_fade_anim 
  402. 	if screen_data ~= nil then 
  403. 		if screen_data.type == CMP_SCREEN_REWARD_INDEX then 
  404. 			cmp_common_bg_saints_show(false, true) 
  405. 			--Make sure image is faded out... 
  406. 			cmp_common_image_fade_out() 
  407. 		end 
  408. 		if screen_data.type == CMP_SCREEN_COOP_WAIT_INDEX then 
  409. 			--Make sure image is faded out... 
  410. 			cmp_common_image_fade_out() 
  411. 		end 
  412. 	end 
  413. 	--Determine if we start the next screen or exit... 
  414. 	if screen_data ~= nil then 
  415. 		--Call Start function for that particular screen type... 
  416. 		local screen_type = screen_data.type 
  417. 		Cmp_screens[screen_data.type].start_func() 
  418. 	else 
  419. 		-- Do nothing... Final screen is always the coop screen 
  420. 		-- and will bypass itself automatically if not needed to display. 
  421. 		return 
  422. 	end 
  423. end 
  424.  
  425. ---------------------------------------------------------------- 
  426. -- Screen based functions 
  427. ---------------------------------------------------------------- 
  428.  
  429. ---------------------------------------------------------------- 
  430. -- Title screen 
  431. ---------------------------------------------------------------- 
  432. function cmp_common_title_start() 
  433. 	cmp_common_input_block_delay() 
  434. 	Cmp_screen_is_playing = true 
  435.  
  436. 	--Set properties from screen data... 
  437. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  438. 	local title_string = screen_data.title_string  
  439. 	local image = screen_data.image  
  440. 	--local title_string = "THE DUKE IS BACK!" 
  441. 	local title_txt_h = vint_object_find("title_txt", 0, Cmp_common_doc) 
  442. 	vint_set_property(title_txt_h, "text_tag", title_string) 
  443. 	 
  444. 	local title_txt_width, title_txt_height = element_get_actual_size(title_txt_h) 
  445. 	local title_txt_x, title_txt_y = vint_get_property(title_txt_h, "anchor") 
  446. 	 
  447. 	--Adjust heights and header... 
  448. 	 
  449. 	--Get values that we need to calculate position... 
  450. 	local complete_txt_h = vint_object_find("complete_txt", 0, Cmp_common_doc) 
  451.  
  452. 	local complete_txt_x, complete_txt_y = vint_get_property(complete_txt_h, "anchor") 
  453. 	local complete_txt_width, complete_txt_height = element_get_actual_size(complete_txt_h) 
  454. 	 
  455. 	--Calculate new position... for "COMPLETE" text. 
  456. 	local new_y = title_txt_height + title_txt_y + 5 
  457. 	 
  458. 	--Set Values... 
  459. 	local complete_txt_slide_twn = vint_object_find("complete_txt_slide_twn", 0, Cmp_common_doc) 
  460. 	local slide_start_x, slide_start_y = vint_get_property(complete_txt_slide_twn, "start_value") 
  461. 	local slide_end_x, slide_end_y = vint_get_property(complete_txt_slide_twn, "end_value") 
  462. 	 
  463. 	vint_set_property(complete_txt_slide_twn, "start_value", slide_start_x, new_y) 
  464. 	vint_set_property(complete_txt_slide_twn, "end_value", slide_end_x, new_y) 
  465.  
  466. 	--determine if we have an image to display or not... 
  467. 	local img_grp_h = vint_object_find("img_grp", 0, Cmp_common_doc) 
  468.  
  469. 	if image ~= nil or image ~= 0 then 
  470. 		vint_set_property(img_grp_h, "visible", true) 
  471. 	else 
  472. 		vint_set_property(img_grp_h, "visible", false) 
  473. 	end 
  474.  
  475. 	--Override hintbar position... 
  476. 	Cmp_screens[Cmp_screen_idx].hint_bar_y = new_y + complete_txt_height + 125 
  477. 	 
  478. 	local title_anim_h = vint_object_find("title_in_anim", 0, Cmp_common_doc) 
  479. 	lua_play_anim(title_anim_h, 0, Cmp_common_doc) 
  480. 	 
  481. 	--Execute on start func if available... 
  482. 	if screen_data.on_start ~= nil and type(screen_data.on_start) == "function" then 
  483. 		screen_data.on_start() 
  484. 	end 
  485. end 
  486.  
  487. function cmp_common_title_skip() 
  488. 	--Move animation to end... 
  489. 	local title_anim_h = vint_object_find("title_in_anim", 0, Cmp_common_doc) 
  490. 	lua_play_anim(title_anim_h, -5, Cmp_common_doc) 
  491. 		 
  492. 	--Play Star Power... 
  493. 	cmp_common_star_power_start() 
  494. 	 
  495. 	--Force end... 
  496. 	cmp_common_title_end() 
  497. end 
  498.  
  499. function cmp_common_title_slam() 
  500. 	cmp_common_lut_effect(CMP_LUT_MISSION) 
  501. 	cmp_common_camera_shake() 
  502. 	cmp_common_star_power_start() 
  503. 	 
  504. 	game_letterbox_fade_out(true) 
  505. end 
  506.  
  507.  
  508. function cmp_common_title_end() 
  509. 	--Show hints... 
  510. 	cmp_common_hint_bar_show() 
  511. 	Cmp_screen_is_playing = false 
  512. end 
  513.  
  514. function cmp_common_title_out() 
  515. 	--Fade out title 
  516. 	local title_anim_h = vint_object_find("title_out_anim", 0, Cmp_common_doc) 
  517. 	lua_play_anim(title_anim_h, 0, Cmp_common_doc) 
  518. 	cmp_common_hint_bar_hide() 
  519. end 
  520.  
  521. ------------------------------------------------------------------------------- 
  522. -- Special case function to change the scale if needed. 
  523. --  
  524. function cmp_common_title_resize(scale) 
  525. 	local title_txt_h = vint_object_find("title_txt", 0, Cmp_common_doc) 
  526. 	vint_set_property(title_txt_h, "text_scale", scale, scale) 
  527. end 
  528.  
  529.  
  530. ---------------------------------------------------------------- 
  531. -- Cash screen 
  532. ---------------------------------------------------------------- 
  533. function cmp_common_cash_start() 
  534. 	--Initialize cash stuff... 
  535. 	Cmp_screen_is_playing = true 
  536. 	 
  537. 	--Get properties from screen data... 
  538. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  539. 	 
  540. 	if CMP_TEST_MODE then 
  541. 		screen_data.cash_reward = 2000  
  542. 		screen_data.cash_multiplier = 50 
  543. 		screen_data.cash_reward_inc_multiplier = 5000 
  544. 		if CMP_TEST_NO_MULTIPLIER then 
  545. 			screen_data.cash_multiplier = 0 
  546. 		end 
  547. 	end 
  548. 	 
  549. 	if screen_data.cash_reward == 0 then 
  550. 		--skip this screen if no reward granted... 
  551. 		cmp_common_cash_callback_enable(false) 
  552. 		cmp_common_screen_advance(true) 
  553. 		return 
  554. 	end 
  555. 	 
  556. 	--delay input... 
  557. 	cmp_common_input_block_delay() 
  558. 	 
  559. 	local cash_reward = screen_data.cash_reward  
  560. 	local cash_multiplier = screen_data.cash_multiplier  
  561. 	local cash_reward_inc_multiplier = screen_data.cash_reward_inc_multiplier  
  562. 	 
  563. 	Cmp_screen_cash_start	= 0  
  564. 	Cmp_screen_cash_end 		=	cash_reward 
  565. 	Cmp_screen_cash_total 	= cash_reward_inc_multiplier 
  566. 	 
  567. 	--Update bonus text... 
  568. 	local bonus_txt_h = vint_object_find("cash_bonus_txt", 0, Cmp_common_doc) 
  569. 	local values = {[0] = cash_multiplier} 
  570. 	local bonus_string = vint_insert_values_in_string("COMPLETION_BONUS", values) 
  571. 	vint_set_property(bonus_txt_h, "text_tag", bonus_string) 
  572.  
  573. 	--Start cash animation in...	 
  574. 	local cash_anim_h = vint_object_find("cash_in_anim", 0, Cmp_common_doc) 
  575. 	lua_play_anim(cash_anim_h, 0, Cmp_common_doc) 
  576.  
  577. 	--Set callback for cash count complete 
  578. 	if cash_multiplier > 0 then 
  579. 		--Show bonus stage... 
  580. 		Cmp_common_cash_complete_cb = cmp_common_cash_bonus_start 
  581. 		Cmp_screen_cash_skip_bonus = false 
  582. 	else 
  583. 		--Skip bonus stage... 
  584. 		Cmp_common_cash_complete_cb = cmp_common_cash_end 
  585. 		Cmp_screen_cash_skip_bonus = true 
  586. 	end 
  587. 	 
  588. 	--Start in the non bonus stage... 
  589. 	Cmp_screen_cash_count_is_bonus = false 
  590. 	 
  591. 	--Start counting the cash... 
  592. 	local cash_count_thread = thread_new("cmp_common_cash_count_thread") 
  593. end 
  594.  
  595. function cmp_common_cash_skip() 
  596.  
  597. 	--Destroy callbacks 
  598. 	cmp_common_cash_callback_enable(false) 
  599. 	local cash_anim_h = vint_object_find("cash_in_anim", 0, Cmp_common_doc) 
  600. 	lua_play_anim(cash_anim_h, -5, Cmp_common_doc) 
  601.  
  602. 	if Cmp_screen_cash_skip_bonus == false then 
  603. 		local cash_anim_h = vint_object_find("cash_bonus_in_anim", 0, Cmp_common_doc) 
  604. 		lua_play_anim(cash_anim_h, -5, Cmp_common_doc) 
  605. 	end 
  606. 	 
  607. 	local cash_h = vint_object_find("cash_amount_txt", 0, Cmp_common_doc) 
  608. 	vint_set_property(cash_h, "text_tag", "$" .. format_cash(Cmp_screen_cash_total) .. "\n") 
  609. 	 
  610. 	--Play star Power 
  611. 	cmp_common_star_power_start() 
  612. 	 
  613. 	--force end of screen(This is a fail safe in case our callbacks don't get called) 
  614. 	cmp_common_cash_end() 
  615. 	 
  616. 	--stop ramping audio... 
  617. 	cmp_audio_stop_ramp() 
  618. 	Cmp_screen_cash_skip = true 
  619. end 
  620.  
  621. function cmp_common_cash_slam() 
  622. 	if Cmp_screen_is_playing then 
  623. 		cmp_common_camera_shake() 
  624. 		cmp_common_star_power_start() 
  625. 		 
  626. 		if Cmp_screen_cash_skip_bonus then 
  627. 			-- skipping bonus... so, start ramp...  
  628. 			-- and of course... no multiplier 
  629. 			cmp_audio_cash_ramp_no_multiplier() 
  630. 		else 
  631. 			--Start ramp with bonus.. 
  632. 			cmp_audio_cash_ramp_multiplier() 
  633. 		end 
  634. 	end 
  635. end 
  636.  
  637. function cmp_common_cash_end() 
  638. 	--Show hints... 
  639. 	cmp_common_hint_bar_show() 
  640. 	Cmp_screen_is_playing = false 
  641. end 
  642.  
  643. function cmp_common_cash_out() 
  644. 	--Fade out Cash 
  645. 	local cash_anim_h = vint_object_find("cash_out_anim", 0, Cmp_common_doc) 
  646. 	lua_play_anim(cash_anim_h, 0, Cmp_common_doc) 
  647. 	cmp_common_hint_bar_hide() 
  648. end 
  649.  
  650. function cmp_common_cash_count_thread() 
  651.  
  652. 	--init stuff 
  653. 	local start_cash = Cmp_screen_cash_start			-- $ amount to start cash from... 
  654. 	local cash_this_frame = -1								-- How much cash gets displayed in the current frame...	 
  655. 	local is_complete = false								-- Is the screen complete? 
  656. 	Cmp_screen_cash_skip = false							-- Did we skip the cash? 
  657.  
  658. 	--get the variables from the global 
  659. 	local cash = Cmp_screen_cash_end - start_cash 
  660. 	local cash_end = Cmp_screen_cash_end 
  661. 	 
  662. 	local amt_min = 100 
  663. 	local amt_max = 33000 
  664. 	 
  665. 	local time_min = CMP_TIME_CASH 
  666. 	local time_max = CMP_TIME_CASH 
  667. 	 
  668. 	if Cmp_screen_cash_count_is_bonus then 
  669. 		time_min = CMP_TIME_CASH_BONUS 
  670. 		time_max = CMP_TIME_CASH_BONUS 
  671. 	elseif Cmp_screen_cash_skip_bonus then 
  672. 		time_min = CMP_TIME_CASH_NO_BONUS 
  673. 		time_max = CMP_TIME_CASH_NO_BONUS 
  674. 	end 
  675. 	 
  676. 	local init_time = floor(vint_get_time_index() * 1000) 
  677. 	local cur_time = init_time 
  678. 	local time_to_count = floor(time_min + ((time_max - time_min) * (cash / amt_max))) 
  679.  
  680. 	if time_to_count > time_max then 
  681. 		time_to_count = time_max 
  682. 	end 
  683. 		 
  684. 	if cash > 0 then 
  685. 		 
  686. 		while is_complete == false do 
  687. 		 
  688. 			local cur_time = floor(vint_get_time_index() * 1000) - init_time 
  689. 							 
  690. 			--set my values 
  691. 			cash_this_frame = cash * (cur_time / time_to_count) + start_cash 
  692. 			local cash_h = vint_object_find("cash_amount_txt", 0, Cmp_common_doc) 
  693. 			vint_set_property(cash_h, "text_tag", "$" .. format_cash(cash_this_frame) .. "\n") 
  694. 				 
  695. 			--Advance time so we skip... 
  696. 			if Cmp_screen_cash_skip == true then 
  697. 				cur_time = time_to_count 
  698. 				cash_end = Cmp_screen_cash_total 
  699. 				Cmp_common_cash_complete_cb = cmp_common_cash_end 
  700. 			end 
  701. 			 
  702. 			if cur_time >= time_to_count then 
  703. 				is_complete = true 
  704. 	 
  705. 				--force the values 
  706. 				vint_set_property(cash_h, "text_tag", "$" .. format_cash(cash_end)) 
  707. 				Cmp_common_cash_complete_cb() 
  708. 			end 
  709. 			thread_yield() 
  710. 		end 
  711. 	else 
  712. 		-- Start next screen? 
  713. 		cmp_common_cash_end() 
  714. 	end 
  715. end 
  716.  
  717. function cmp_common_cash_bonus_start() 
  718. 	-- Start Cash Bonus Screen 
  719. 	local cash_anim_h = vint_object_find("cash_bonus_in_anim", 0, Cmp_common_doc) 
  720. 	lua_play_anim(cash_anim_h, 0, Cmp_common_doc) 
  721.  
  722. 	--Set callback for cash count complete 
  723. 	Cmp_common_cash_complete_cb = cmp_common_cash_end 
  724. end 
  725.  
  726. function cmp_common_cash_bonus_slam() 
  727.  
  728. 	--Shake camera... 
  729. 	cmp_common_camera_shake() 
  730.  
  731. 	--Initialize cash stuff... 
  732. 	 
  733. 	--Get properties from screen data... 
  734. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  735. 	local cash_reward = screen_data.cash_reward  
  736. 	local cash_multiplier = screen_data.cash_multiplier  
  737. 	local cash_reward_inc_multiplier = screen_data.cash_reward_inc_multiplier  
  738. 	 
  739. 	Cmp_screen_cash_start = cash_reward 
  740. 	Cmp_screen_cash_end = cash_reward_inc_multiplier 
  741.  
  742. 	--Cash Ramp Bonus 
  743. 	cmp_audio_cash_bonus_ramp() 
  744. 	 
  745. 	--Start in the bonus stage... 
  746. 	Cmp_screen_cash_count_is_bonus = true 
  747. 	 
  748. 	--Start counting the cash... 
  749. 	local cash_count_thread = thread_new("cmp_common_cash_count_thread")		 
  750. end 
  751.  
  752.  
  753. -- Easy way to initialize or clear out the cash callbacks. 
  754. function cmp_common_cash_callback_enable(is_enabled) 
  755. 	local cash_slam_cb = "cmp_common_cash_slam" 
  756. 	local cash_bonus_slam_cb = "cmp_common_cash_bonus_slam" 
  757. 	 
  758. 	if is_enabled == false then 
  759. 		cash_slam_cb			=	nil 
  760. 		cash_bonus_slam_cb	=	nil 
  761. 	end 
  762. 	 
  763. 	local twn_h = vint_object_find("cash_slam_twn", 0, Cmp_common_doc) 
  764. 	vint_set_property(twn_h, "end_event", cash_slam_cb)		 
  765. 	 
  766. 	local twn_h = vint_object_find("cash_bonus_slam_twn", 0, Cmp_common_doc) 
  767. 	vint_set_property(twn_h, "end_event", cash_bonus_slam_cb)		 
  768. end 
  769.  
  770. ---------------------------------------------------------------- 
  771. --Respect screen 
  772. ---------------------------------------------------------------- 
  773. function cmp_common_respect_start() 
  774.  
  775. 	Cmp_screen_is_playing = true 
  776. 	 
  777. 	--Get properties from screen data... 
  778. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  779.  
  780. 	--respect is always displayed as one level up... (internally respect starts at 0... 
  781. 	screen_data.respect_level_old 			= screen_data.respect_level_old + 1 
  782. 	screen_data.respect_level_new 			= screen_data.respect_level_new + 1 
  783. 	screen_data.respect_level_multiplier 	= screen_data.respect_level_multiplier + 1 
  784. 	 
  785. 	if CMP_TEST_MODE then 
  786. 		screen_data.respect_pct_old 					= .1 
  787. 		screen_data.respect_level_old 				= 1 
  788. 		 
  789. 		screen_data.respect_pct_new 					= .6 
  790. 		screen_data.respect_level_new 				= 1 
  791. 		 
  792. 		screen_data.respect_multiplier 				= 40 
  793. 		 
  794. 		screen_data.respect_pct_multiplier 			= .8 
  795. 		screen_data.respect_level_multiplier 		= 2 
  796. 	end 
  797. 		 
  798. 	local respect_pct_old				= screen_data.respect_pct_old 
  799. 	local respect_level_old				= screen_data.respect_level_old 
  800. 	 
  801. 	local respect_pct_new				= screen_data.respect_pct_new 
  802. 	local respect_level_new				= screen_data.respect_level_new 
  803. 	 
  804. 	local respect_multiplier			= screen_data.respect_multiplier 
  805. 		 
  806. 	local respect_pct_multiplier		= screen_data.respect_pct_multiplier 
  807. 	local respect_level_multiplier	= screen_data.respect_level_multiplier 
  808. 	 
  809. 	if respect_level_old == respect_pct_new and screen_data.respect_level_old == screen_data.respect_level_new then 
  810. 		--Force skip this scren... no respect to ad... 
  811. 		cmp_common_respect_cb_enable(false) 
  812. 		cmp_common_screen_advance(true) 
  813. 		return 
  814. 	end 
  815. 	 
  816. 	--Delay input... 
  817. 	cmp_common_input_block_delay() 
  818.  
  819. 	 
  820. 	if respect_multiplier == 0 then 
  821. 		--skip bonus screen if there is no multiplier... 
  822. 		Cmp_screen_respect_skip_bonus = true 
  823. 		 
  824. 		--shift respect text to center 
  825. 		local respect_text_shift_grp_h = vint_object_find("respect_text_shift_grp", 0, Cmp_common_doc) 
  826. 		local x, y = vint_get_property(respect_text_shift_grp_h, "anchor") 
  827. 		vint_set_property(respect_text_shift_grp_h, "anchor", x, y + 30) 
  828. 	end 
  829. 	 
  830. 	--Set bonus text... 
  831. 	local bonus_txt_h = vint_object_find("respect_bonus_txt", 0, Cmp_common_doc) 
  832. 	local values = {[0] = respect_multiplier} 
  833. 	local bonus_string = vint_insert_values_in_string("COMPLETION_BONUS", values) 
  834. 	vint_set_property(bonus_txt_h, "text_tag", bonus_string) 
  835. 	 
  836. 	--figure out how long we are going to process the time... 
  837. 	local base_time = CMP_TIME_RESPECT 
  838. 	if	respect_multiplier ~= 0 then 
  839. 		--We have respect Multiplier 
  840. 		base_time = CMP_TIME_RESPECT 
  841. 		 
  842. 		--Ramp audio.. 
  843. 		cmp_audio_respect_ramp_multiplier() 
  844. 	else 
  845. 		--No multiplier 
  846. 		base_time = CMP_TIME_RESPECT_NO_BONUS  
  847. 		 
  848. 		--Ramp audio.. 
  849. 		cmp_audio_respect_ramp_no_multiplier() 
  850. 	end 
  851.  
  852. 	--Start meter fill! 
  853. 	cmp_common_respect_meter_update(respect_pct_old, respect_pct_new, respect_level_old, respect_level_new, base_time) 
  854.  
  855. 	local respect_anim_h = vint_object_find("respect_in_anim", 0, Cmp_common_doc) 
  856. 	lua_play_anim(respect_anim_h, 0, Cmp_common_doc) 
  857. end 
  858.  
  859. function cmp_common_respect_skip() 
  860. 	--Stop any tween callbacks from happening... 
  861. 	cmp_common_respect_cb_enable(false) 
  862. 	 
  863. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  864. 	local respect_pct_multiplier		= screen_data.respect_pct_multiplier 
  865. 	local respect_level_multiplier	= screen_data.respect_level_multiplier 
  866.  
  867. 	cmp_common_respect_fill_meter(0, respect_pct_multiplier, false) 
  868. 	 
  869. 	--Force meter level 
  870. 	local level = max(screen_data.respect_level_new, screen_data.respect_level_multiplier) 
  871.  
  872. 	--Force level of respect meter... 
  873. 	local txt_h = vint_object_find("respect_level_text", 0, Cmp_common_doc) 
  874. 	vint_set_property(txt_h, "text_tag", level) 
  875. 	 
  876. 	--Play slide in animation to end... 
  877. 	local respect_anim_h = vint_object_find("respect_in_anim", 0, Cmp_common_doc) 
  878. 	lua_play_anim(respect_anim_h, -5, Cmp_common_doc) 
  879. 	 
  880. 	if Cmp_screen_respect_skip_bonus == false then 
  881. 		--Play the bonus anim to end... 
  882. 		local respect_bonus_h = vint_object_find("respect_bonus_in_anim", 0, Cmp_common_doc) 
  883. 		lua_play_anim(respect_bonus_h, -5, Cmp_common_doc) 
  884. 	end 
  885. 	 
  886. 	--Play star Power 
  887. 	cmp_common_star_power_start() 
  888. 	 
  889. 	--stop ramping audio... 
  890. 	cmp_audio_stop_ramp() 
  891. 	 
  892. 	--End Screen... 
  893. 	cmp_common_respect_end() 
  894. end 
  895.  
  896.  
  897. function cmp_common_respect_end() 
  898. 	Cmp_screen_is_playing = false 
  899. 	cmp_common_hint_bar_show() 
  900. end 
  901.  
  902. function cmp_common_respect_out() 
  903. 	--Fade out Respect 
  904. 	local respect_anim_h = vint_object_find("respect_out_anim", 0, Cmp_common_doc) 
  905. 	lua_play_anim(respect_anim_h, 0, Cmp_common_doc) 
  906. 	cmp_common_hint_bar_hide() 
  907. end 
  908.  
  909.  
  910. --respect_up_level_up_cb_twn 
  911. function cmp_common_respect_slam() 
  912. 	if Cmp_screen_is_playing then 
  913. 		cmp_common_camera_shake() 
  914. 		cmp_common_star_power_start() 
  915. 	end 
  916. end 
  917.  
  918. --Bonus slam callback... 
  919. function cmp_common_respect_slam_bonus() 
  920. 	if Cmp_screen_is_playing then 
  921. 		cmp_common_camera_shake() 
  922. 		 
  923. 		--Get properties from screen data... 
  924. 		local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  925. 		local respect_pct_old				= screen_data.respect_pct_old 
  926. 		local respect_level_old				= screen_data.respect_level_old 
  927. 		 
  928. 		local respect_pct_new				= screen_data.respect_pct_new 
  929. 		local respect_level_new				= screen_data.respect_level_new 
  930. 		 
  931. 		local respect_multiplier			= screen_data.respect_multiplier 
  932. 			 
  933. 		local respect_pct_multiplier		= screen_data.respect_pct_multiplier 
  934. 		local respect_level_multiplier	= screen_data.respect_level_multiplier 
  935. 		 
  936. 		--Do fillup to multiplier level... 
  937. 		cmp_common_respect_meter_update(respect_pct_new,respect_pct_multiplier, respect_level_new, respect_level_multiplier, CMP_TIME_RESPECT_BONUS) 
  938. 		 
  939. 		--Set this flag so we don't play the bonus twice... 
  940. 		Cmp_screen_respect_skip_bonus = true 
  941. 		 
  942. 		--Ramp audio... 
  943. 		cmp_audio_respect_bonus_ramp() 
  944. 	end 
  945. end 
  946.  
  947. -- Update/animate the respect meter	 
  948. -- 
  949. -- @param	total_respect		current total amount of respect player has 
  950. -- @param	respect_pct		 	% the player is towards their next rank level 
  951. -- @param	level: 				player rank level 
  952. -- @param 	base					Base time it should take to fill up the meter from start to finish 
  953. function cmp_common_respect_meter_update(old_respect_pct, respect_pct, old_level, new_level, base_time) 
  954.  
  955. 	--Get differences between the levels 
  956. 	local level_dif = new_level - old_level 
  957. 	Cmp_screen_respect_level_cur = old_level 
  958. 	 
  959. 	--Initialize the level of the meter... 
  960. 	local txt_h = vint_object_find("respect_level_text", 0, Cmp_common_doc) 
  961. 	vint_set_property(txt_h, "text_tag", old_level) 
  962. 	 
  963. 	--If the difference is greater than 0 then we are going to level up... 
  964. 	if level_dif > 0 then 
  965. 		--Store to global... 
  966. 		Cmp_screen_respect_level_dif = level_dif 
  967.  
  968. 		--Store target percentage for the meter... 
  969. 		Cmp_screen_respect_target_pct = respect_pct			 
  970. 	 
  971. 		local first_ramp_pct = 1 - old_respect_pct 
  972. 		local final_ramp_pct = respect_pct 
  973. 		 
  974. 		local level_dif = level_dif 
  975. 		 
  976. 		--Calculate levels per second (total percentage / times the thing passes 0) 
  977. 		local revolutions_per_ms = base_time / (first_ramp_pct + (level_dif - 1) + final_ramp_pct) 
  978. 		Cmp_screen_respect_time_start = 	revolutions_per_ms * first_ramp_pct 
  979. 		Cmp_screen_respect_time_mid 	= 	revolutions_per_ms * 1 
  980. 		Cmp_screen_respect_time_end 	= 	revolutions_per_ms * final_ramp_pct 
  981.  
  982. 		--Setup callback so it can be filled again and again... 
  983. 		local twn_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc) 
  984. 		vint_set_property(twn_h, "end_event", "cmp_common_respect_fill_cb") 
  985. 		 
  986. 		--Modify time to fill... 
  987. 		cmp_common_respect_set_time(Cmp_screen_respect_time_start)	 
  988. 		cmp_common_respect_fill_meter(old_respect_pct, 1, true) 
  989. 	else 
  990. 		--No leveling, so do a standard one meter cycle increase. 
  991. 		Cmp_screen_respect_level_dif = 0 
  992. 		 
  993. 		--Setup callback for this is the only time its going to be filled... 
  994. 		local twn_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc) 
  995. 		vint_set_property(twn_h, "end_event", "cmp_common_respect_fill_end") 
  996. 		 
  997. 		local end_event = vint_get_property(twn_h, "end_event") 
  998.  
  999. 		--Reset time to fill 
  1000. 		cmp_common_respect_set_time(base_time)		 
  1001. 		 
  1002. 		--Fill meter anim... 
  1003. 		cmp_common_respect_fill_meter(old_respect_pct, respect_pct, true) 
  1004. 	end 
  1005. end 
  1006.  
  1007.  
  1008.  
  1009. ---------------------------------------------------------------------------  
  1010. -- Fills up the meter and plays added respect animation. 
  1011. -- After animation is complete it does a callback which checks if we've 
  1012. -- Increased a level and calls that animation... 
  1013. -- 
  1014. -- @param old_respect_pct		 
  1015. -- @param respect_pct			Percentage to transition too... 
  1016. -- @param do_animation			Text string for header 
  1017. --------------------------------------------------------------------------- 
  1018. function cmp_common_respect_fill_meter(old_respect_pct, respect_pct, do_animation) 
  1019. 		 
  1020. 	-- min/max for a percentage 
  1021. 	respect_pct = limit(respect_pct, 0, 1) 
  1022. 	 
  1023. 	local start_respect_angle = RESPECT_START_ANGLE - ((RESPECT_START_ANGLE + RESPECT_END_ANGLE) * old_respect_pct) 
  1024. 	local end_respect_angle = RESPECT_START_ANGLE - ((RESPECT_START_ANGLE + RESPECT_END_ANGLE) * respect_pct) 
  1025. 	 
  1026. 	if do_animation == true then 
  1027. 		-- Animate Meter 
  1028. 		local respect_up_anim_h = vint_object_find("respect_up_anim", 0, Cmp_common_doc) 
  1029. 		local meter_tween_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc) 
  1030. 		local meter_bg_tween_h = vint_object_find("respect_meter_bg_tween", 0, Cmp_common_doc) 
  1031. 		 
  1032. 		-- Animate from previous to new	 
  1033. 		vint_set_property(meter_tween_h, "start_value", start_respect_angle) 
  1034. 		vint_set_property(meter_tween_h, "end_value", end_respect_angle) 
  1035. 		 
  1036. 		vint_set_property(meter_bg_tween_h, "start_value", start_respect_angle - .03) 
  1037. 		vint_set_property(meter_bg_tween_h, "end_value", end_respect_angle - .03) 
  1038. 		 
  1039. 		lua_play_anim(respect_up_anim_h, 0, Cmp_common_doc) 
  1040. 	else 
  1041. 		--Stop Animation... 
  1042. 		local respect_up_anim_h = vint_object_find("respect_up_anim", 0, Cmp_common_doc) 
  1043. 		vint_set_property(respect_up_anim_h, "is_paused", true) 
  1044. 		 
  1045. 		--Manually set bars... 
  1046. 		local respect_meter_h =  vint_object_find("respect_meter", 0, Cmp_common_doc) 
  1047. 		local respect_meter_bg_h = vint_object_find("respect_meter_bg", 0, Cmp_common_doc) 
  1048. 		vint_set_property(respect_meter_h, "end_angle", end_respect_angle) 
  1049. 		vint_set_property(respect_meter_bg_h, "end_angle", end_respect_angle - .03) 
  1050. 	end 
  1051. end 
  1052.  
  1053. function cmp_common_respect_fill_cb() 
  1054.  
  1055. 	--Decrement the level difference... 
  1056. 	Cmp_screen_respect_level_dif = Cmp_screen_respect_level_dif - 1			 
  1057. 	 
  1058. 	--Swap the level 
  1059. 	local anim_h = vint_object_find("respect_level_up_anim", 0, Cmp_common_doc) 
  1060. 	lua_play_anim(anim_h, 0, Cmp_common_doc) 
  1061. 	 
  1062. 	--Determine if we are going to fill up again? 
  1063. 	if Cmp_screen_respect_level_dif <= 0 then 
  1064.  
  1065. 		--Setup callback for this is the last time its going to be filled... 
  1066. 		local twn_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc) 
  1067. 		vint_set_property(twn_h, "end_event", "cmp_common_respect_fill_end") 
  1068. 		 
  1069. 		--Set the the target fill time to something we calculated earlier.. 
  1070. 		cmp_common_respect_set_time(Cmp_screen_respect_time_end)	 
  1071. 		 
  1072. 		--This is the last fill so lets fill it up to the target percent...	 
  1073. 		cmp_common_respect_fill_meter(0, Cmp_screen_respect_target_pct, true) 
  1074. 	else 
  1075. 		--reset callback to call this function again after meter fills. 
  1076. 		local twn_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc) 
  1077. 		vint_set_property(twn_h, "end_event", "cmp_common_respect_fill_cb") 
  1078. 	 
  1079. 		--Set the the target fill time to something we calculated earlier.. 
  1080. 		cmp_common_respect_set_time(Cmp_screen_respect_time_mid)	 
  1081. 		 
  1082. 		--Do normal fill animation to the top... 
  1083. 		cmp_common_respect_fill_meter(0, 1, true) 
  1084. 	end 
  1085. end 
  1086.  
  1087. -- Upgrades the current level of the respect meter. 
  1088. -- This happens via callback of the respect level up animation... 
  1089. function cmp_common_respect_next_level() 
  1090. 	Cmp_screen_respect_level_cur = Cmp_screen_respect_level_cur + 1 
  1091. 	local txt_h = vint_object_find("respect_level_text", 0, Cmp_common_doc) 
  1092. 	vint_set_property(txt_h, "text_tag", Cmp_screen_respect_level_cur) 
  1093. end 
  1094.  
  1095. function cmp_common_respect_fill_end() 
  1096. 	-- Do we go into bonus? 
  1097. 	if Cmp_screen_respect_skip_bonus == false then 
  1098. 		--Lets not skip the bonus... 
  1099. 		local respect_bonus_anim_in_h = vint_object_find("respect_bonus_in_anim", 0, Cmp_common_doc) 
  1100. 		lua_play_anim(respect_bonus_anim_in_h, 0, Cmp_common_doc) 
  1101. 	else 
  1102. 		--End Screen 
  1103. 		cmp_common_respect_end() 
  1104. 	end 
  1105. end 
  1106.  
  1107. ---------------------------------------------------------------------------  
  1108. -- Sets the duration tweens for filling up the meter... 
  1109. -- 
  1110. -- @param t		Time it takes to fill up the meter... 
  1111. --------------------------------------------------------------------------- 
  1112. function cmp_common_respect_set_time(t) 
  1113. 	local meter_tween_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc) 
  1114. 	local meter_bg_tween_h =vint_object_find("respect_meter_bg_tween", 0, Cmp_common_doc) 
  1115. 	vint_set_property(meter_tween_h, "duration", t) 
  1116. 	vint_set_property(meter_bg_tween_h, "duration", t) 
  1117. end 
  1118.  
  1119. -- Easy way to initialize or clear out the respect callbacks. 
  1120. function cmp_common_respect_cb_enable(is_enabled) 
  1121. 	local respect_slam_cb = "cmp_common_respect_slam" 
  1122. 	local respect_bonus_cb = "cmp_common_respect_slam_bonus" 
  1123. 	local respect_level_cb = "cmp_common_respect_next_level" 
  1124. 	 
  1125. 	if is_enabled == false then 
  1126. 		respect_slam_cb	=	nil 
  1127. 		respect_bonus_cb	=	nil 
  1128. 		respect_level_cb	=	nil 
  1129. 	end 
  1130. 	 
  1131. 	--Respect Tween callbacks... 
  1132. 	local twn_h = vint_object_find("respect_slam_twn", 0, Cmp_common_doc) 
  1133. 	vint_set_property(twn_h, "end_event", respect_slam_cb)	 
  1134. 	 
  1135. 	local twn_h = vint_object_find("respect_bonus_twn", 0, Cmp_common_doc) 
  1136. 	vint_set_property(twn_h, "end_event", respect_bonus_cb)	 
  1137. 		 
  1138. 	-- when it is time to update the cash... 
  1139. 	local twn_h = vint_object_find("respect_level_up_twn", 0, Cmp_common_doc) 
  1140. 	vint_set_property(twn_h, "end_event", respect_level_cb) 
  1141. end 
  1142.  
  1143. ---------------------------------------------------------------- 
  1144. -- City Control screen 
  1145. ---------------------------------------------------------------- 
  1146. function cmp_common_control_start() 
  1147. 	Cmp_screen_is_playing = true 
  1148. 	 
  1149. 	--Get properties from screen data... 
  1150. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  1151.  
  1152. 	if CMP_TEST_MODE then 
  1153. 		-- do nothing... 
  1154. 	end 
  1155.  
  1156. 	local district_pct_old				= screen_data.district_pct_old 
  1157. 	local district_pct_new				= screen_data.district_pct_new	 
  1158. 	local district_cash_per_day		= screen_data.district_cash_per_day 
  1159. 	local district_team_name			= screen_data.district_team_name 
  1160. 	 
  1161. 	if district_pct_new == 0 or district_pct_new == nil then 
  1162. 		--Force skip this scren... 
  1163. 		cmp_common_screen_advance(true) 
  1164. 		return 
  1165. 	end 
  1166. 	 
  1167. 	if district_pct_new == district_pct_old then 
  1168. 		-- Skip screen if there is no gained district. 
  1169. 		cmp_common_screen_advance(true) 
  1170. 		return 
  1171. 	end 
  1172. 	 
  1173. 	--Delay input... 
  1174. 	cmp_common_input_block_delay() 
  1175. 	 
  1176. 	--Set text... 
  1177. 	local control_meter_pct_text_h = vint_object_find("control_meter_pct_text", 0, Cmp_common_doc) 
  1178. 	local values_1 = {[0] = floor(district_pct_old * 1000) * .1 } 
  1179. 	local control_pct_string = vint_insert_values_in_string("{0}%%%", values_1) 
  1180. 	vint_set_property(control_meter_pct_text_h, "text_tag", control_pct_string) 
  1181. 		 
  1182. 	local control_txt = vint_object_find("control_txt", 0, Cmp_common_doc) 
  1183. 	local values_2 = {[0] = district_team_name} 
  1184. 	local control_string = vint_insert_values_in_string("COMPLETION_CONTROL", values_2) 
  1185. 	vint_set_property(control_txt, "text_tag", control_string) 
  1186. 	 
  1187. 	local ctrl_width, ctrl_height = element_get_actual_size(control_txt) 
  1188. 	local ctrl_width_max = 383 --HD 
  1189. 	if vint_is_std_res() then 
  1190. 		ctrl_width_max = 312 
  1191. 	end 
  1192. 	if ctrl_width > ctrl_width_max then 
  1193. 		local scale = ctrl_width_max/ctrl_width 
  1194. 		vint_set_property(control_txt, "scale", scale, scale) 
  1195. 	end 
  1196. 		 
  1197. 	local control_cash_txt_h = vint_object_find("control_cash_txt", 0, Cmp_common_doc) 
  1198. 	local values_3 = {[0] = format_cash(district_cash_per_day)} 
  1199. 	local control_cash_string = vint_insert_values_in_string("COMPLETION_CONTROL_PER_DAY", values_3) 
  1200. 	vint_set_property(control_cash_txt_h, "text_tag", control_cash_string) 
  1201. 	 
  1202. 	--figure out how long we are going to process the time... 
  1203. 	local base_time = CMP_TIME_CONTROL 
  1204. 	 
  1205. 	--Ramp audio.. 
  1206. 	cmp_audio_control_ramp() 
  1207. 	 
  1208. 	--Start meter fill! 
  1209. 	cmp_common_control_meter_update(0, district_pct_new, base_time) 
  1210.  
  1211. 	local control_in_anim_h = vint_object_find("control_in_anim", 0, Cmp_common_doc) 
  1212. 	lua_play_anim(control_in_anim_h, 0, Cmp_common_doc) 
  1213.  
  1214. 	--slam in numbers 
  1215. 	local control_level_up_anim_h = vint_object_find("control_level_up_anim", 0, Cmp_common_doc) 
  1216. 	lua_play_anim(control_level_up_anim_h, 0, Cmp_common_doc) 
  1217. end 
  1218.  
  1219. function cmp_common_control_skip() 
  1220. 	if Cmp_screen_is_playing then 
  1221. 		--Stop any tween callbacks from happening... 
  1222. 		cmp_common_control_cb_enable(false) 
  1223. 		 
  1224. 		local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  1225. 		local district_pct_new				= screen_data.district_pct_new	 
  1226.  
  1227. 		--Force meter level 
  1228. 		cmp_common_control_fill_meter(0, district_pct_new, false) 
  1229. 		 
  1230. 		-- Force text into meter... 
  1231. 		local control_meter_pct_text_h = vint_object_find("control_meter_pct_text", 0, Cmp_common_doc) 
  1232. 		local values_1 = {[0] = floor(district_pct_new * 1000) * .1 } 
  1233. 		local control_pct_string = vint_insert_values_in_string("{0}%%%", values_1) 
  1234. 		vint_set_property(control_meter_pct_text_h, "text_tag", control_pct_string) 
  1235. 		 
  1236. 		--prevent audio callback from playing twice... I don't like this but its the only way (JMH 8/23/2011) 
  1237. 		--Control Cash Slam 
  1238. 		local twn_h = vint_object_find("control_cash_audio_slam_twn", 0, Cmp_common_doc) 
  1239. 		vint_set_property(twn_h, "end_event", nil)	 
  1240. 		 
  1241. 		--Play slide in animation to end... 
  1242. 		local control_in_anim_h = vint_object_find("control_in_anim", 0, Cmp_common_doc) 
  1243. 		lua_play_anim(control_in_anim_h, -10, Cmp_common_doc) 
  1244. 		 
  1245.  
  1246. 		--Play star Power 
  1247. 		cmp_common_star_power_start() 
  1248. 		 
  1249. 		--stop ramping audio... 
  1250. 		cmp_audio_stop_ramp() 
  1251. 		 
  1252. 		--end completion... 
  1253. 		cmp_common_control_end() 
  1254. 	end 
  1255. end 
  1256.  
  1257.  
  1258. function cmp_common_control_end() 
  1259. 	Cmp_screen_is_playing = false 
  1260. 	cmp_common_hint_bar_show() 
  1261. end 
  1262.  
  1263. function cmp_common_control_out() 
  1264. 	--Fade out Respect 
  1265. 	local control_out_anim_h = vint_object_find("control_out_anim", 0, Cmp_common_doc) 
  1266. 	lua_play_anim(control_out_anim_h, 0, Cmp_common_doc) 
  1267. 	cmp_common_hint_bar_hide() 
  1268. end 
  1269.  
  1270.  
  1271. -- When the meter flys in and stops we do this via tween cb... 
  1272. function cmp_common_control_slam() 
  1273. 	if Cmp_screen_is_playing then 
  1274. 		cmp_common_camera_shake() 
  1275. 		cmp_common_star_power_start() 
  1276. 	end 
  1277. end 
  1278.  
  1279. -- Update/animate the respect meter	 
  1280. -- 
  1281. -- @param	old_pct		current total amount of control player has over district 
  1282. -- @param	new_pct		current total amount of control player has over district 
  1283. -- @param 	base_time	Base time it should take to fill up the meter from start to finish 
  1284. function cmp_common_control_meter_update(pct_old, pct_new, base_time) 
  1285. 	 
  1286. 	--Reset time to fill 
  1287. 	cmp_common_control_set_time(base_time) 
  1288. 	 
  1289. 	--Setup callback for this is the only time its going to be filled... 
  1290. 	local twn_h = vint_object_find("control_meter_tween", 0, Cmp_common_doc) 
  1291. 	vint_set_property(twn_h, "end_event", "cmp_common_control_fill_end") 
  1292. 	 
  1293. 	--Fill meter anim... 
  1294. 	cmp_common_control_fill_meter(pct_old, pct_new, true) 
  1295. end 
  1296.  
  1297. ---------------------------------------------------------------------------  
  1298. -- Fills up the meter and plays added respect animation. 
  1299. -- After animation is complete it does a callback which checks if we've 
  1300. -- Increased a level and calls that animation... 
  1301. -- 
  1302. -- @param pct_old		 
  1303. -- @param pct_new			Percentage to transition too... 
  1304. -- @param do_animation			Text string for header 
  1305. --------------------------------------------------------------------------- 
  1306. function cmp_common_control_fill_meter(pct_old, pct_new, do_animation) 
  1307. 	 
  1308. 	-- min/max for a percentage 
  1309. 	pct_old = limit(pct_old, 0, 1) 
  1310. 	pct_new = limit(pct_new, 0, 1) 
  1311. 	 
  1312. 	local start_angle = 	CONTROL_START_ANGLE - ((CONTROL_START_ANGLE + CONTROL_END_ANGLE) * pct_old) 
  1313. 	local end_angle = 	CONTROL_START_ANGLE - ((CONTROL_START_ANGLE + CONTROL_END_ANGLE) * pct_new) 
  1314.  
  1315. 	if do_animation == true then 
  1316. 		-- Animate Meter 
  1317. 		local control_up_anim_h = vint_object_find("control_up_anim", 0, Cmp_common_doc) 
  1318. 		local meter_tween_h = vint_object_find("control_meter_tween", 0, Cmp_common_doc) 
  1319. 		local meter_bg_tween_h = vint_object_find("control_meter_bg_tween", 0, Cmp_common_doc) 
  1320. 		 
  1321. 		-- Animate from previous to new	 
  1322. 		vint_set_property(meter_tween_h, "start_value", start_angle) 
  1323. 		vint_set_property(meter_tween_h, "end_value", end_angle) 
  1324. 		 
  1325. 		vint_set_property(meter_bg_tween_h, "start_value", start_angle - .03) 
  1326. 		vint_set_property(meter_bg_tween_h, "end_value", end_angle - .03) 
  1327. 		 
  1328. 		lua_play_anim(control_up_anim_h, 0, Cmp_common_doc) 
  1329. 	else 
  1330. 		--Stop Animation... 
  1331. 		local control_up_anim_h = vint_object_find("respect_up_anim", 0, Cmp_common_doc) 
  1332. 		vint_set_property(control_up_anim_h, "is_paused", true) 
  1333. 		 
  1334. 		--Manually set bars... 
  1335. 		local respect_meter_h =  vint_object_find("respect_meter", 0, Cmp_common_doc) 
  1336. 		local respect_meter_bg_h = vint_object_find("respect_meter_bg", 0, Cmp_common_doc) 
  1337. 		vint_set_property(respect_meter_h, "end_angle", end_angle) 
  1338. 		vint_set_property(respect_meter_bg_h, "end_angle", end_angle - .03) 
  1339. 	end 
  1340. 	 
  1341. 	-- Force text into meter... 
  1342. 	local control_meter_pct_text_h = vint_object_find("control_meter_pct_text", 0, Cmp_common_doc) 
  1343. 	local values_1 = {[0] = floor(pct_new * 1000) * .1 } 
  1344. 	local control_pct_string = vint_insert_values_in_string("{0}%%%", values_1) 
  1345. 	vint_set_property(control_meter_pct_text_h, "text_tag", control_pct_string) 
  1346. 	 
  1347. end 
  1348.  
  1349. function cmp_common_control_fill_end() 
  1350. 	--End Screen 
  1351. 	if Cmp_screen_is_playing then 
  1352. 		cmp_common_control_end() 
  1353. 	end 
  1354. end 
  1355.  
  1356. ---------------------------------------------------------------------------  
  1357. -- Sets the duration tweens for filling up the meter... 
  1358. -- 
  1359. -- @param t		Time it takes to fill up the meter... 
  1360. --------------------------------------------------------------------------- 
  1361. function cmp_common_control_set_time(t) 
  1362. 	local meter_tween_h = vint_object_find("control_meter_tween", 0, Cmp_common_doc) 
  1363. 	local meter_bg_tween_h = vint_object_find("control_meter_bg_tween", 0, Cmp_common_doc) 
  1364. 	vint_set_property(meter_tween_h, "duration", t) 
  1365. 	vint_set_property(meter_bg_tween_h, "duration", t) 
  1366. end 
  1367.  
  1368. -- Easy way to initialize or clear out the control callbacks. 
  1369. function cmp_common_control_cb_enable(is_enabled) 
  1370.  
  1371. 	local control_slam_cb = "cmp_common_control_slam" 
  1372.  
  1373. 	if is_enabled == false then 
  1374. 		control_slam_cb	=	nil 
  1375. 	end 
  1376. 	 
  1377. 	--Respect Tween callbacks... 
  1378. 	local twn_h = vint_object_find("control_slam_twn", 0, Cmp_common_doc) 
  1379. 	vint_set_property(twn_h, "end_event", control_slam_cb)	 
  1380. end 
  1381.  
  1382.  
  1383.  
  1384.  
  1385. ---------------------------------------------------------------- 
  1386. -- Rewards screen 
  1387. ---------------------------------------------------------------- 
  1388. function cmp_common_rewards_start() 
  1389. 	--Get properties from screen data... 
  1390. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  1391. 	local rewards_count = screen_data.rewards_count 
  1392. 	 
  1393. 	--Set rewards count so it knows how many screens to display... 
  1394. 	reward_granted_set_reward_count(rewards_count) 
  1395. 	 
  1396. 	--Set callback on the reward screen, so we know when it is over... 
  1397. 	set_reward_granted_end_cb(cmp_common_rewards_end) 
  1398. 	 
  1399. 	--Start reward screen... 
  1400. 	reward_granted_start() 
  1401. 	 
  1402. 	Cmp_screen_is_playing = true 
  1403. end 
  1404.  
  1405. function cmp_common_rewards_skip() 
  1406. end 
  1407.  
  1408. function cmp_common_rewards_end() 
  1409. 	--Bring in background full black. so when we exit the reward screen we don't fade anything  
  1410. 	--weird uncleaned up... 
  1411. 	local h = vint_object_find("background_bmp", 0, Cmp_common_doc) 
  1412. 	vint_set_property(h, "alpha", 1) 
  1413. 	 
  1414. 	--Hide everything local to the common screen... afterwards we should always transition back to game, 
  1415. 	--So nothing else should display here from the main screen. This cleans up any 
  1416. 	--Stars or stuff leftover, this does not fix the player popping back in. (JMH 3/24/2011) 
  1417. 	local screen_h = vint_object_find("screen_grp", 0, Cmp_common_doc) 
  1418. 	local stars_h = vint_object_find("stars", 0, Cmp_common_doc) 
  1419. 	vint_set_property(screen_h, "visible", false) 
  1420. 	vint_set_property(stars_h, "visible", false) 
  1421.  
  1422. 	Cmp_screen_is_playing = false 
  1423. 	cmp_common_screen_advance(false) 
  1424. end 
  1425.  
  1426. function cmp_common_rewards_out() 
  1427. 	 
  1428. end 
  1429.  
  1430. ---------------------------------------------------------------- 
  1431. -- Unlock screen 
  1432. ---------------------------------------------------------------- 
  1433.  
  1434. ---------------------------------------------------------------- 
  1435. -- Coop Wait screen 
  1436. ---------------------------------------------------------------- 
  1437.  
  1438. --Fades in an start coop wait screen... 
  1439. function cmp_common_coop_wait_start() 
  1440. 	Completion_user_is_done_viewing() -- Notify other player that we're ready to move on 
  1441. 	if Completion_should_wait_for_coop() then 
  1442. 		--Play Fade In anim... 
  1443. 		local coop_anim_h = vint_object_find("coop_in_anim", 0, Cmp_common_doc) 
  1444. 		lua_play_anim(coop_anim_h, 0, Cmp_common_doc) 
  1445. 		 
  1446. 		--Play Pulse Anim... 
  1447. 		local coop_anim_h = vint_object_find("coop_waiting_pulse_anim", 0, Cmp_common_doc) 
  1448. 		lua_play_anim(coop_anim_h, 0, Cmp_common_doc) 
  1449. 		 
  1450. 		--Set Coop Player Gamer tag 
  1451. 		Cmp_screen_coop_gamer_tag = Completion_get_other_player_name() 
  1452. 		local values = {[0] = Cmp_screen_coop_gamer_tag} 
  1453. 		local waiting_string = vint_insert_values_in_string("COMPLETION_COOP_WAITING", values) 
  1454. 		local waiting_txt_h = vint_object_find("coop_waiting_txt", 0, Cmp_common_doc) 
  1455. 		vint_set_property(waiting_txt_h,"text_tag", waiting_string) 
  1456. 		 
  1457. 		Cmp_screen_is_playing = true 
  1458. 		Cmp_screen_coop_is_waiting = true 
  1459. 	else 
  1460. 		-- Do nothing... the game will call cmp_common_exit when we want to leave... 
  1461. 	end 
  1462.  
  1463. end 
  1464.  
  1465. function cmp_common_coop_wait_skip() 
  1466. 	--Does nothing... 
  1467. end 
  1468.  
  1469. --Fade out coop wait screen... 
  1470. function cmp_common_coop_wait_out() 
  1471. 	--only fade out if we had the coop screen up... 
  1472. 	if Cmp_screen_coop_is_waiting then 
  1473. 		local coop_anim_h = vint_object_find("coop_in_anim", 0, Cmp_common_doc) 
  1474. 		vint_set_property(coop_anim_h, "is_paused", true) 
  1475. 	 
  1476. 		local coop_anim_h = vint_object_find("coop_out_anim", 0, Cmp_common_doc) 
  1477. 		lua_play_anim(coop_anim_h, 0, Cmp_common_doc) 
  1478. 	end 
  1479. end 
  1480.  
  1481. function cmp_common_coop_wait_dialog() 
  1482. 	local options = { [0] = "CONTROL_YES", [1] = "CONTROL_NO" } 
  1483. 	Cmp_common_coop_dialog_handle = dialog_box_open("MENU_TITLE_WARNING", "DIALOG_PAUSE_DISCONNECT_PROMPT", options, "cmp_common_coop_disconnect", 1, DIALOG_PRIORITY_SYSTEM_CRITICAL, true, nil, false, false) 
  1484. end 
  1485.  
  1486. function cmp_common_coop_disconnect(result, action) 
  1487. 	if result == 0 then 
  1488. 		dialog_box_disconnect() 
  1489. 		 
  1490. 		--WHAT SHOULD I DO HERE? 
  1491. 		cmp_common_exit() 
  1492. 	end 
  1493. 	 
  1494. 	Cmp_common_coop_dialog_handle = 0 
  1495. end 
  1496.  
  1497. ---------------------------------------------------------------- 
  1498. -- Tables for packing screen based functions and constants 
  1499. ---------------------------------------------------------------- 
  1500. Cmp_screens = { 
  1501. 	[CMP_SCREEN_TITLE_INDEX] = { 
  1502. 		start_func = cmp_common_title_start, 
  1503. 		skip_func = cmp_common_title_skip, 
  1504. 		out_func = cmp_common_title_out, 
  1505. 		hint_bar_y = -1, --set via cmp_common_title_start()...  
  1506. 	}, 
  1507. 	[CMP_SCREEN_CASH_INDEX] = { 
  1508. 		start_func = cmp_common_cash_start, 
  1509. 		skip_func = cmp_common_cash_skip, 
  1510. 		out_func = cmp_common_cash_out, 
  1511. 		hint_bar_y = 433,   
  1512. 	}, 
  1513. 	[CMP_SCREEN_RESPECT_INDEX] = { 
  1514. 		start_func = cmp_common_respect_start, 
  1515. 		skip_func = cmp_common_respect_skip, 
  1516. 		out_func = cmp_common_respect_out, 
  1517. 		hint_bar_y = 454,   
  1518. 	}, 
  1519. 	[CMP_SCREEN_CONTROL_INDEX] = { 
  1520. 		start_func = cmp_common_control_start, 
  1521. 		skip_func = cmp_common_control_skip, 
  1522. 		out_func = cmp_common_control_out, 
  1523. 		hint_bar_y = 454,   
  1524. 	}, 
  1525. 	[CMP_SCREEN_REWARD_INDEX] = { 
  1526. 		start_func = cmp_common_rewards_start, 
  1527. 		skip_func = cmp_common_rewards_skip, 
  1528. 		out_func = cmp_common_rewards_out, 
  1529. 		hint_bar_y = nil,  
  1530. 	}, 
  1531. 	[CMP_SCREEN_COOP_WAIT_INDEX] = { 
  1532. 		start_func = cmp_common_coop_wait_start, 
  1533. 		skip_func = cmp_common_coop_wait_skip, 
  1534. 		out_func = cmp_common_coop_wait_out, 
  1535. 		hint_bar_y = nil,   
  1536. 	}, 
  1537. } 
  1538.  
  1539. ---------------------------------------------------------------- 
  1540. -- Common Screen functions 
  1541. ---------------------------------------------------------------- 
  1542.  
  1543. -- Hint bar 
  1544. function cmp_common_hint_bar_move(x,y) 
  1545. 	Cmp_hintbar:set_anchor(x,y) 
  1546. end 
  1547.  
  1548. function cmp_common_hint_bar_show() 
  1549. 	--Move hintbar 
  1550. 	--Get values from the hintbar and screen type table... 
  1551. 	local x, y = Cmp_hintbar:get_anchor() 
  1552. 	y = Cmp_screens[Cmp_screen_idx].hint_bar_y 
  1553. 	Cmp_hintbar:set_anchor(x,y) 
  1554. 	 
  1555. 	local anim_h = vint_object_find("hint_bar_out_anim", 0, Cmp_common_doc) 
  1556. 	vint_set_property(anim_h, "is_paused", true) 
  1557. 	 
  1558. 	local anim_h = vint_object_find("hint_bar_in_anim", 0, Cmp_common_doc) 
  1559. 	lua_play_anim(anim_h, 0, Cmp_common_doc) 
  1560. end 
  1561.  
  1562. function cmp_common_hint_bar_hide() 
  1563. 	local anim_h = vint_object_find("hint_bar_in_anim", 0, Cmp_common_doc) 
  1564. 	vint_set_property(anim_h, "is_paused", true) 
  1565. 	local anim_h = vint_object_find("hint_bar_out_anim", 0, Cmp_common_doc) 
  1566. 	lua_play_anim(anim_h, 0, Cmp_common_doc) 
  1567. end 
  1568.  
  1569. --Plays the star power animation... 
  1570. local Cmp_screen_star_power_screen = -1 
  1571. function cmp_common_star_power_start() 
  1572. 	--Only play the star power if we aren't playing already... 
  1573. 	if Cmp_screen_star_power_screen ~= Cmp_screen_idx then 
  1574. 		 
  1575. 		--Check if we aren't already playing for the screen 
  1576. 		local anim_h = vint_object_find("star_explode_anim", 0, Cmp_common_doc) 
  1577. 		lua_play_anim(anim_h, 0, Cmp_common_doc) 
  1578. 		 
  1579. 		for i = 1, #Cmp_stars do 
  1580. 			local h = vint_object_find(Cmp_stars[i], 0, Cmp_common_doc) 
  1581. 			local scale = rand_float(0.7, 1.1) 
  1582. 			local rotation = rand_float(0.1,0.3) 
  1583. 			local rotation_og = vint_get_property(h, "rotation") 
  1584. 			vint_set_property(h, "scale", scale, scale) 
  1585. 			vint_set_property(h, "rotation", rotation_og) 
  1586. 		end 
  1587. 		 
  1588. 		Cmp_screen_star_power_screen = Cmp_screen_idx 
  1589. 	end 
  1590. end 
  1591.  
  1592.  
  1593. --Exit screen 
  1594. function cmp_common_exit() 
  1595. 	 
  1596. 	--Tell game that we are done with the completion screen... 
  1597. 	completion_screen_finished() 
  1598. end 
  1599.  
  1600. ---------------------------------------------------------------- 
  1601. -- Input Processing 
  1602. ---------------------------------------------------------------- 
  1603. function cmp_process_input(event, acceleration) 
  1604. 	--only allow input if input isn't blocked... 
  1605. 	if Cmp_common_input_is_blocked == false then 
  1606. 		--Only process input if the screen has started... 
  1607. 		if Cmp_screen_sequence_started then 
  1608. 			if event == "select" then 
  1609. 				cmp_common_screen_advance(false) 
  1610. 			elseif event == "map" then 
  1611. 				--If we are waiting on the coop screen the bring up the dialog box... 
  1612. 				if Cmp_screen_coop_is_waiting then 
  1613. 					cmp_common_coop_wait_dialog() 
  1614. 				end 
  1615. 			elseif event == "back" then 
  1616. 				--Do nothing... 
  1617. 				--cmp_common_screen_advance() 
  1618. 			else 
  1619. 				--Do nothing... 
  1620. 			end 
  1621. 		end 
  1622. 	end 
  1623. end 
  1624.  
  1625.  
  1626. ---------------------------------------------------------------- 
  1627. -- Camera Shake... 
  1628. -- 
  1629. -- @di_param	x			Horizontal offset 
  1630. -- @di_param	y			Vertical offset 
  1631. ---------------------------------------------------------------- 
  1632. function cmp_common_camera_shake_update(di_h) 
  1633. 	local x, y = vint_dataitem_get(di_h) 
  1634. 	local screen_h = vint_object_find("screen_grp", 0, Cmp_common_doc) 
  1635.  
  1636. 	 
  1637. 	--Invert parameters and multiply by 2, then add to base position... 
  1638. 	x = Cmp_screen_base_x + (x * -1) 
  1639. 	y = Cmp_screen_base_y + (y * -1) 
  1640. 	 
  1641. 	vint_set_property(screen_h, "anchor", x, y) 
  1642. end 
  1643.  
  1644. ---------------------------------------------------------------- 
  1645. -- Wrappers for C Based functions... 
  1646. ---------------------------------------------------------------- 
  1647.  
  1648. --Wrapper for c++ camera shake function... 
  1649. function cmp_common_camera_shake(shake_type) 
  1650. 	completion_camera_shake() 
  1651. end 
  1652.  
  1653. --Wrapper for c++ lut swap function... 
  1654. function cmp_common_lut_effect(lut_table_string) 
  1655.  
  1656. 	if lut_table_string ~= CMP_LUT_DEFAULT then 
  1657. 		local platform = game_get_platform() 
  1658. 		local lut_platform_string = "" 
  1659. 		 
  1660. 		if platform == "PS3" then 
  1661. 			lut_platform_string = "_ps3" 
  1662. 		elseif platform == "XBOX360" then 
  1663. 			lut_platform_string = "_xbox2" 
  1664. 		elseif platform == "PC" then 
  1665. 			lut_platform_string = "_pc" 
  1666. 		end 
  1667. 		completion_load_lut(lut_table_string .. lut_platform_string) 
  1668. 	else 
  1669. 		completion_load_lut(lut_table_string) 
  1670. 	end 
  1671. end 
  1672.  
  1673. function cmp_common_bitmap_loaded() 
  1674. end 
  1675.  
  1676. ------------------------------------------------------------------- 
  1677. -- AUDIO 
  1678. ------------------------------------------------------------------- 
  1679.  
  1680. --Callbacks for audio placed directly on tweens... 
  1681. function cmp_audio_cb_enable() 
  1682. 	--In order of appearance... 
  1683. 	 
  1684. 	--Title Slam... ("title_in_anim") 
  1685. 	local twn_h = vint_object_find("title_slam_audio_twn", 0, Cmp_common_doc) 
  1686. 	vint_set_property(twn_h, "end_event", "cmp_audio_mission_complete") 
  1687.  
  1688. 	--Title music... ("title_in_anim") 
  1689. 	local twn_h = vint_object_find("title_slam_music_twn", 0, Cmp_common_doc) 
  1690. 	vint_set_property(twn_h, "duration", 0.133332 +.03)	--force duration to get music timed perfectly with slam... 
  1691. 	vint_set_property(twn_h, "end_event", "cmp_audio_music") 
  1692. 	 
  1693. 	--Cash Standard slam...("cash_anim_in") 
  1694. 	local twn_h = vint_object_find("cash_audio_twn", 0, Cmp_common_doc) 
  1695. 	vint_set_property(twn_h, "end_event", "cmp_audio_cash_slam") 
  1696. 	 
  1697. 	--Cash Bonus slam...("cash_bonus_anim_in") 
  1698. 	local twn_h = vint_object_find("cash_bonus_audio_twn", 0, Cmp_common_doc) 
  1699. 	vint_set_property(twn_h, "end_event", "cmp_audio_cash_bonus_slam") 
  1700. 	 
  1701. 	--Respect Slam 
  1702. 	local twn_h = vint_object_find("respect_audio_slam_twn", 0, Cmp_common_doc) 
  1703. 	vint_set_property(twn_h, "end_event", "cmp_audio_respect_slam")	 
  1704.  
  1705. 	--Respect Bonus Slam 
  1706. 	local twn_h = vint_object_find("respect_audio_bonus_slam_twn", 0, Cmp_common_doc) 
  1707. 	vint_set_property(twn_h, "end_event", "cmp_audio_respect_bonus_slam") 
  1708. 	 
  1709. 	--Control Slam 
  1710. 	local twn_h = vint_object_find("control_audio_slam_twn", 0, Cmp_common_doc) 
  1711. 	vint_set_property(twn_h, "end_event", "cmp_audio_control_slam")	 
  1712. 	 
  1713. 	--Control Cash Slam 
  1714. 	local twn_h = vint_object_find("control_cash_audio_slam_twn", 0, Cmp_common_doc) 
  1715. 	vint_set_property(twn_h, "end_event", "cmp_audio_control_cash_slam")	 
  1716. end 
  1717.  
  1718.  
  1719. --Slams... 
  1720. function cmp_audio_mission_complete() 
  1721. 	game_UI_audio_play("UI_Completion_Mission_Complete") 
  1722. end 
  1723. function cmp_audio_cash_slam() 
  1724. 	game_UI_audio_play("UI_Completion_Cash_Slam") 
  1725. end 
  1726. function cmp_audio_cash_bonus_slam() 
  1727. 	game_UI_audio_play("UI_Completion_Cash_Bonus_Slam") 
  1728. end 
  1729. function cmp_audio_respect_slam() 
  1730. 	game_UI_audio_play("UI_Completion_Respect_Slam") 
  1731. end 
  1732. function cmp_audio_respect_bonus_slam() 
  1733. 	game_UI_audio_play("UI_Completion_Respect_Bonus_Slam") 
  1734. end 
  1735. function cmp_audio_control_slam() 
  1736. 	game_UI_audio_play("UI_Completion_Respect_Slam") 
  1737. end 
  1738. function cmp_audio_control_cash_slam() 
  1739. 	game_UI_audio_play("UI_Completion_Respect_Bonus_Slam") 
  1740. end 
  1741.  
  1742. --Ramps... 
  1743. function cmp_audio_cash_ramp_no_multiplier() 
  1744. 	--CashRamLong 2sec 09 frames... 
  1745. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Cash_Ramp") 
  1746. end 
  1747. function cmp_audio_cash_ramp_multiplier() 
  1748. 	--short Cash Ramp 
  1749. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Cash_Ramp_Base") 
  1750. end 
  1751. function cmp_audio_cash_bonus_ramp() 
  1752. 	--Bonus Ramp... 
  1753. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Cash_Ramp_Bonus") 
  1754. end 
  1755. function cmp_audio_respect_ramp_no_multiplier() 
  1756. 	--respect ramp full 3  
  1757. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Respect_Ramp") 
  1758. end 
  1759. function cmp_audio_respect_ramp_multiplier() 
  1760. 	--respect ramp base 1sec 22...  
  1761. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Respect_Ramp_Base") 
  1762. end 
  1763. function cmp_audio_respect_bonus_ramp() 
  1764. 	--respect ramp Bonus 1sec 14... 
  1765. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Respect_Ramp_Bonus") 
  1766. end 
  1767. function cmp_audio_control_ramp() 
  1768. 	--respect ramp Bonus 1sec 14... 
  1769. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Respect_Ramp_Bonus") 
  1770. end 
  1771. function cmp_audio_music() 
  1772. 	Cmp_common_audio_music_id = game_audio_play("UI_Music", "UI_Music", "Mission_Completion") 
  1773. end 
  1774.  
  1775. function cmp_audio_stop_ramp() 
  1776. 	game_audio_stop(Cmp_common_audio_ramp_id) 
  1777. end 
  1778.  
  1779. function cmp_common_mouse_click(event, target_handle) 
  1780. 	if target_handle == Cmp_bg_image.handle then 
  1781. 		if Cmp_screen_coop_is_waiting == true then 
  1782. 			cmp_process_input("back") 
  1783. 		else  
  1784. 			cmp_process_input("select") 
  1785. 		end 
  1786. 	end 
  1787. 	 
  1788. end 
  1789.  
  1790. function cmp_common_mouse_move(event, target_handle) 
  1791. end 
  1792.  
  1793.  
  1794. ------------------------------------------------------------------------------- 
  1795. -- Sets up the screen for right justification 
  1796. ------------------------------------------------------------------------------- 
  1797. function cmp_common_right_justification() 
  1798.  
  1799. 	--Adjust base screen coords 
  1800. 	Cmp_screen_base_x = 25  
  1801. 	Cmp_screen_base_y = -100 
  1802. 	 
  1803. 	--If standard definition we need to adjust some more even... 
  1804. 	if vint_is_std_res() then 
  1805. 		Cmp_screen_base_x = -50 
  1806. 		Cmp_screen_base_y = -75 
  1807. 	end	 
  1808. 	 
  1809. 	 
  1810. 	local global_conversion_table = { 
  1811. 		--Screen Group Rotation... 
  1812. 		{ 
  1813. 			name = "screen_grp", 
  1814. 			prop = "rotation", 
  1815. 			val_1 = 0.13962634, --  8 degrees. 
  1816. 		}, 
  1817. 		--Shift screen around... 
  1818. 		{ 
  1819. 			name = "screen_grp", 
  1820. 			prop = "anchor", 
  1821. 			val_1 = Cmp_screen_base_x,  
  1822. 			val_2 = Cmp_screen_base_y, 
  1823. 		} 
  1824. 	} 
  1825. 	 
  1826. 	local title_converstion_table = { 
  1827. 		--Title  Alignments 
  1828. 		{	 
  1829. 			name = "complete_txt", 
  1830. 			prop = "auto_offset", 
  1831. 			val_1 = "ne", 
  1832. 		}, 
  1833. 		{	 
  1834. 			name = "title_txt", 
  1835. 			prop = "auto_offset", 
  1836. 			val_1 = "ne", 
  1837. 		}, 
  1838. 		{	 
  1839. 			name = "title_txt", 
  1840. 			prop = "horz_align", 
  1841. 			val_1 = "right", 
  1842. 		}, 
  1843. 		--Title Tweens 
  1844. 		{	 
  1845. 			name = "title_in_twn", 
  1846. 			prop = "start_value_x", 
  1847. 			val_1 = -20, 
  1848. 		}, 
  1849. 		{	 
  1850. 			name = "complete_txt_slide_twn", 
  1851. 			prop = "start_value_x", 
  1852. 			val_1 = -20, 
  1853. 		}, 
  1854. 		--End position overrides... 
  1855. 		{	 
  1856. 			name = "title_in_twn", 
  1857. 			prop = "end_value_x", 
  1858. 			val_1 = 647.0, 
  1859. 		}, 
  1860. 	} 
  1861. 	 
  1862. 	local cash_conversion_table = { 
  1863. 		--Cash Alignments 
  1864. 		{	 
  1865. 			name = "cash_txt", 
  1866. 			prop = "auto_offset", 
  1867. 			val_1 = "ne", 
  1868. 		}, 
  1869. 		{	 
  1870. 			name = "cash_bonus_txt", 
  1871. 			prop = "auto_offset", 
  1872. 			val_1 = "ne", 
  1873. 		}, 
  1874. 		{	 
  1875. 			name = "cash_amount_txt", 
  1876. 			prop = "auto_offset", 
  1877. 			val_1 = "ne", 
  1878. 		}, 
  1879. 		--Cash Tweens 
  1880. 		{	 
  1881. 			name = "cash_amount_slide_twn", 
  1882. 			prop = "start_value_x", 
  1883. 			val_1 = -20, 
  1884. 		}, 
  1885. 		{	 
  1886. 			name = "cash_slam_twn", 
  1887. 			prop = "start_value_x", 
  1888. 			val_1 = -20, 
  1889. 		}, 
  1890. 		{	 
  1891. 			name = "cash_bonus_slam_twn", 
  1892. 			prop = "start_value_x", 
  1893. 			val_1 = -20, 
  1894. 		}, 
  1895. 		--End position overrides 
  1896. 		{	 
  1897. 			name = "cash_amount_slide_twn", 
  1898. 			prop = "end_value_x", 
  1899. 			val_1 = 646, 
  1900. 		}, 
  1901. 		{	 
  1902. 			name = "cash_slam_twn", 
  1903. 			prop = "end_value_x", 
  1904. 			val_1 = 646, 
  1905. 		}, 
  1906. 	} 
  1907. 	local respect_conversion_table = { 
  1908. 		--Respect Alignments 
  1909. 		{	 
  1910. 			name = "respect_bonus_txt", 
  1911. 			prop = "auto_offset", 
  1912. 			val_1 = "ne", 
  1913. 		}, 
  1914. 		{	 
  1915. 			name = "respect_txt", 
  1916. 			prop = "auto_offset", 
  1917. 			val_1 = "ne", 
  1918. 		}, 
  1919. 		  
  1920. 		--Respect Tweens Start 
  1921. 		{	 
  1922. 			name = "respect_slam_twn", 
  1923. 			prop = "start_value_x", 
  1924. 			val_1 = -20, 
  1925. 		}, 
  1926. 		{	 
  1927. 			name = "respect_txt_twn", 
  1928. 			prop = "start_value_x", 
  1929. 			val_1 = -20, 
  1930. 		}, 
  1931. 		{	 
  1932. 			name = "respect_bonus_twn", 
  1933. 			prop = "start_value_x", 
  1934. 			val_1 = -20, 
  1935. 		}, 
  1936. 		--Respect Tweens End 
  1937. 		{	 
  1938. 			name = "respect_slam_twn", 
  1939. 			prop = "end_value_x", 
  1940. 			val_1 = 600, 
  1941. 		}, 
  1942. 		{	 
  1943. 			name = "respect_txt_twn", 
  1944. 			prop = "end_value_x", 
  1945. 			val_1 = 470, 
  1946. 		}, 
  1947. 		{	 
  1948. 			name = "respect_bonus_twn", 
  1949. 			prop = "end_value_x", 
  1950. 			val_1 = 472, 
  1951. 		}, 
  1952. 	} 
  1953. 	 
  1954. 	local control_conversion_table = { 
  1955. 		--Control Alignments 
  1956. 		{	 
  1957. 			name = "control_cash_txt", 
  1958. 			prop = "auto_offset", 
  1959. 			val_1 = "ne", 
  1960. 		}, 
  1961. 		{	 
  1962. 			name = "control_txt", 
  1963. 			prop = "horz_align", 
  1964. 			val_1 = "right", 
  1965. 		}, 
  1966. 		{	 
  1967. 			name = "control_txt", 
  1968. 			prop = "auto_offset", 
  1969. 			val_1 = "ne", 
  1970. 		}, 
  1971. 		  
  1972. 		--Control Tweens Start 
  1973. 		{	 
  1974. 			name = "control_slam_twn", 
  1975. 			prop = "start_value_x", 
  1976. 			val_1 = -20, 
  1977. 		}, 
  1978. 		{	 
  1979. 			name = "control_txt_twn", 
  1980. 			prop = "start_value_x", 
  1981. 			val_1 = -20, 
  1982. 		}, 
  1983. 		{	 
  1984. 			name = "control_cash_twn", 
  1985. 			prop = "start_value_x", 
  1986. 			val_1 = -20, 
  1987. 		}, 
  1988. 		--Control Tweens End 
  1989. 		{	 
  1990. 			name = "control_slam_twn", 
  1991. 			prop = "end_value_x", 
  1992. 			val_1 = 600, 
  1993. 		}, 
  1994. 		{	 
  1995. 			name = "control_txt_twn", 
  1996. 			prop = "end_value_x", 
  1997. 			val_1 = 470, 
  1998. 		}, 
  1999. 		{	 
  2000. 			name = "control_cash_twn", 
  2001. 			prop = "end_value_x", 
  2002. 			val_1 = 472, 
  2003. 		}, 
  2004. 	} 
  2005. 	 
  2006. 	local conversion_tables = { 
  2007. 		global_conversion_table, 
  2008. 		title_converstion_table, 
  2009. 		cash_conversion_table, 
  2010. 		respect_conversion_table, 
  2011. 		control_conversion_table, 
  2012. 	} 
  2013. 	 
  2014. 	local h 
  2015. 	local value_1, value_2 
  2016. 	 
  2017. 	--Loop through all the conversion tables 
  2018. 	for i, conversion_table in pairs(conversion_tables) do  
  2019. 		--Get specific conversion table 
  2020. 		for idx, val in pairs(conversion_table) do  
  2021. 			--Go through each item and start converting properties... 
  2022. 			h = vint_object_find(val.name, 0, Cmp_common_doc) 
  2023. 			local prop = val.prop 
  2024. 			if h ~= 0 then 
  2025. 				--Check for "special properties" so we can maintain variables on certain vectors. 
  2026. 				if prop == "start_value_x" then 
  2027. 					local x, y = vint_get_property(h, "start_value") 
  2028. 					vint_set_property(h, "start_value", val.val_1, y) 
  2029. 				elseif prop == "end_value_x" then 
  2030. 					local x, y = vint_get_property(h, "end_value") 
  2031. 					vint_set_property(h, "end_value", val.val_1, y) 
  2032. 				elseif prop == "anchor" then 
  2033. 					vint_set_property(h, "anchor", val.val_1, val.val_2) 
  2034. 				else 
  2035. 					vint_set_property(h, val.prop, val.val_1) 
  2036. 				end 
  2037. 			else 
  2038. 				--can't find object... 
  2039. 				debug_print("vint", "Item in conversion table is missing\n") 
  2040. 			end 
  2041. 		end 
  2042. 		 
  2043. 	end 
  2044. 	 
  2045. 	--Shift button hint over... 
  2046. 	local x, y = Cmp_hintbar:get_anchor() 
  2047. 	local width, height = Cmp_hintbar:get_size() 
  2048. 	Cmp_hintbar:set_anchor(x - width - 15, y) 
  2049. end 
  2050.  
  2051. function cmp_common_bg_saints_show(is_visible, delay) 
  2052. 	if Cmp_common_bg_saints_active ~= true then 
  2053. 		--ignore this function if we are not active... 
  2054. 		return 
  2055. 	end 
  2056. 	 
  2057. 	local delay_time = 0 
  2058. 	if delay then 
  2059. 		delay_time = .5 
  2060. 	end 
  2061. 	local bg_saints_fade_anim_h 	= vint_object_find("bg_saints_fade_anim", 0, Cmp_common_doc) 
  2062. 	local bg_saints_fade_twn_h 	= vint_object_find("bg_saints_fade_twn", 	0, Cmp_common_doc) 
  2063. 	local start_value, end_value = 1, 0 
  2064. 	if is_visible then 
  2065. 		start_value = 0 
  2066. 		end_value = 1 
  2067. 	end 
  2068.  
  2069. 	vint_set_property(bg_saints_fade_twn_h, "start_value", start_value) 
  2070. 	vint_set_property(bg_saints_fade_twn_h, "end_value", end_value) 
  2071. 	lua_play_anim(bg_saints_fade_anim_h, delay_time) 
  2072. end 
  2073.  
  2074.  
  2075. ------------------------------------------------------------------------------- 
  2076. -- Callback for when we have our completion image fully loaded... 
  2077. -- 
  2078. function cmp_common_image_loaded() 
  2079. 	--image is loaded... 
  2080. 	local img_grp_h = vint_object_find("img_grp", 0, Cmp_common_doc) 
  2081. 	 
  2082. 	--replace all 4 images... 
  2083. 	for i = 1, 4 do  
  2084. 		local screen_image_h = vint_object_find("screen_image_" .. i, 0, Cmp_common_doc) 
  2085. 		vint_set_property(screen_image_h, "image", Cmp_image) 
  2086. 	end 
  2087. 	Cmp_common_has_image = true 
  2088. end 
  2089.  
  2090. function cmp_common_image_fade_out() 
  2091. 	if Cmp_common_has_image and Cmp_common_image_is_visible then 
  2092. 		local image_fade_out_anim_h = vint_object_find("image_fade_out_anim", 0, Cmp_common_doc) 
  2093. 		lua_play_anim(image_fade_out_anim_h, 0, Cmp_common_doc) 
  2094. 		Cmp_common_image_is_visible = false 
  2095. 	end 
  2096. end 
  2097.  
  2098. function cmp_common_input_block_delay() 
  2099. 	Cmp_common_input_is_blocked = true 
  2100. 	if Cmp_common_input_delay_thread ~= -1 then 
  2101. 		thread_kill(Cmp_common_input_delay_thread) 
  2102. 	end 
  2103. 	if Cmp_common_input_delay_thread == -1 then 
  2104. 		Cmp_common_input_delay_thread = thread_new("cmp_common_input_block_thread") 
  2105. 	end 
  2106. end 
  2107. function cmp_common_input_block_thread() 
  2108. 	delay(.75) 
  2109. 	Cmp_common_input_is_blocked = false 
  2110. 	Cmp_common_input_delay_thread = -1 
  2111. end 
  2112.  
  2113. --Debug stuff put in for jon bruer JMH(3/24/2011) 
  2114. function cmp_bg_hide() 
  2115. 	local h = vint_object_find("background_base") 
  2116. 	vint_set_property(h, "visible", false)  
  2117. end