./screen_fade.lua

  1.  
  2. local SCREEN_FADE_STYLE_LEFT_TO_RIGHT 	= 0 
  3. local SCREEN_FADE_STYLE_ALPHA 			= 1 
  4.  
  5. local SCREEN_FADE_TYPE_IN 	= 0 
  6. local SCREEN_FADE_TYPE_OUT = 1 
  7.  
  8. local SCREEN_FADE_DEFAULT_DURATION = 1000		-- only used for classic in out fades.. 
  9.  
  10. local SCREEN_FADE_LEFT 	= 1 
  11. local SCREEN_FADE_RIGHT = -1 
  12.  
  13. local Screen_fade_doc_handle = -1 
  14.  
  15. local Screen_fade_state	= -1	--The state of the last called fade... 
  16.  
  17. local Screen_fades = { 
  18. 	[SCREEN_FADE_STYLE_LEFT_TO_RIGHT] = { 
  19. 		[SCREEN_FADE_TYPE_OUT] = { 
  20. 			anim_name = "left_to_right_black_anim", 
  21. 			grp_name = "screen_left_to_right_grp", 
  22. 		}, 
  23. 		[SCREEN_FADE_TYPE_IN] = { 
  24. 			anim_name = "left_to_right_none_anim", 
  25. 			grp_name = "screen_left_to_right_grp", 
  26. 		}, 
  27. 	},	 
  28. 	[SCREEN_FADE_STYLE_ALPHA] = { 
  29. 		[SCREEN_FADE_TYPE_OUT] = { 
  30. 			anim_name = "fade_none_to_black_anim",  
  31. 			grp_name = "screen_fade_grp" 
  32. 		}, 
  33. 		[SCREEN_FADE_TYPE_IN] = { 
  34. 			anim_name = "fade_black_to_none_anim", 
  35. 			grp_name = "screen_fade_grp" 
  36. 		}, 
  37. 	}, 
  38. } 
  39.  
  40. local Screen_fade_logo_is_visible 		= false		-- determines if our logo is visible or not. 
  41. local Screen_fade_images_is_visible 	= false	-- deterimes if our images are visible or not... 
  42.  
  43. local Screen_fade_images_grp_h 			= 0 
  44. local Screen_fade_images_trans_anim_h 	= 0 
  45. local Screen_fade_images_fade_anim_h 	= 0 
  46. local Screen_fade_images_fade_twn_h 	= 0 
  47.  
  48.  
  49. --Screen fade images globals... 
  50.  
  51. Screen_fade_images = {	 
  52. 	"ui_mainmenu_load_06", 
  53. 	"ui_mainmenu_load_07", 
  54. 	"ui_mainmenu_load_08", 
  55. 	"ui_mainmenu_load_09", 
  56. 	"ui_mainmenu_load_10", 
  57. 	"ui_mainmenu_load_11", 
  58. } 
  59.  
  60. Screen_fade_image_1_h = 0 
  61. Screen_fade_image_2_h = 0 
  62. Screen_fade_loaded_images = {} 
  63. Screen_fade_use_load_images 				= false 
  64.  
  65. Screen_fade_autosave_grp_h = 0 
  66. Screen_fade_autosave_grp_x, Screen_fade_autosave_grp_y = 0, 0 
  67.  
  68. Screen_fade_hide_ref_count = 0 
  69. local Screen_fade_force_white_load = false 
  70.  
  71. function screen_fade_init() 
  72. 	Screen_fade_doc_handle = vint_document_find("screen_fade") 
  73. 	 
  74. 	--Hide all groups 
  75. 	local safe_frame_h = vint_object_find("screen_grp") 
  76. 	vint_hide_children(safe_frame_h) 
  77. 	 
  78. 	--Setup tween callbacks.... 
  79. 	local tween_names_for_cb = { 
  80. 		"left_to_right_black_twn", 
  81. 		"fade_black_to_none_twn", 
  82. 		"fade_none_to_black_twn", 
  83. 		"left_to_right_none_twn", 
  84. 	} 
  85. 	for idx, val in pairs(tween_names_for_cb) do 
  86. 		local h = vint_object_find(val) 
  87. 		vint_set_property(h, "end_event", "screen_fade_complete_cb") 
  88. 	end	 
  89. 	 
  90. 	--hide loading 
  91. 	local loading_grp_h = vint_object_find("loading_grp") 
  92. 	local mem_loading_grp_h = vint_object_find("mem_loading_grp") 
  93. 	vint_set_property(loading_grp_h, "alpha", 0) 
  94. 	vint_set_property(mem_loading_grp_h, "alpha", 0) 
  95. 	 
  96. 	local loading_fade_out_twn_h = vint_object_find("loading_fade_out_twn") 
  97. 	vint_set_property(loading_fade_out_twn_h, "end_event", "screen_fade_logo_out_cb") 
  98. 	 
  99. 	--loop animation that plays over everythinng... 
  100. 	--local loading_anim_h = vint_object_find("loading_anim") 
  101. 	--local loading_twn_h = vint_object_find("loading_twn", loading_anim_h) 
  102. 	--vint_set_property(loading_twn_h, "end_event", "vint_anim_loop_callback") 
  103. 		 
  104. 	--Initialize Image Stuff 
  105. 	screen_fade_images_init() 
  106. 	 
  107. 	--Initialize auto save text... 
  108. 	screen_fade_auto_save_init() 
  109. 	 
  110. 	--Hide auto save by default 
  111. 	screen_fade_auto_save_hide() 
  112. end 
  113.  
  114. function screen_fade_cleanup() 
  115. 	screen_fade_images_cleanup() 
  116. end 
  117.  
  118. ------------------------------------------------------------------------------- 
  119. -- Fades the screen. This should be called directly from c++ 
  120. -- @param	style		style of fade(left to right, right to left, fade) SCREEN_FADE_STYLE_LEFT_TO_RIGHT, SCREEN_FADE_STYLE_RIGHT_TO_LEFT, SCREEN_FADE_STYLE_ALPHA) 
  121. -- @param	type		In or out? out = show black, in = show what is behind. (SCREEN_FADE_TYPE_IN, SCREEN_FADE_TYPE_OUT) 
  122. -- @param	duration	only for SCREEN_FADE_STYLE_ALPHA stuff. defaults to .25 seconds.  Units passed in are in milleseconds. 
  123. ------------------------------------------------------------------------------- 
  124. function screen_fade_do(style, type, duration, special_type, red, green, blue, fade_silently) 
  125. 	-- Force Hide all groups 
  126. 	 
  127. 	if red == 1 and green == 1 and blue == 1 then 
  128. 		Screen_fade_force_white_load = true 
  129. 		special_type = 1 
  130. 	else 
  131. 		Screen_fade_force_white_load = false 
  132. 	end 
  133. 	 
  134. 	local _red = 0 
  135. 	if red ~= nil then 
  136. 		_red = red 
  137. 	end 
  138. 	 
  139. 	local _green = 0 
  140. 	if green ~= nil then 
  141. 		_green = green 
  142. 	end 
  143. 	 
  144. 	local _blue = 0 
  145. 	if blue ~= nil then 
  146. 		_blue = blue 
  147. 	end 
  148. 	 
  149. 	local safe_frame_h = vint_object_find("screen_grp") 
  150. 	vint_hide_children(safe_frame_h) 
  151. 	 
  152. 	if fade_silently == false then 
  153. 		if type == SCREEN_FADE_TYPE_IN then 
  154. 			game_audio_play( "ui_screen_trans_in" ) 
  155. 		elseif type == SCREEN_FADE_TYPE_OUT then 
  156. 			game_audio_play( "ui_screen_trans_out" ) 
  157. 		end 
  158. 	end 
  159.  
  160. 	-- Force Pause all animations... 
  161. 	for key, val in pairs(Screen_fades) do 
  162. 		for k, v in pairs(val) do 
  163. 			local anim_h = vint_object_find(v.anim_name) 
  164. 			vint_set_property(anim_h, "is_paused", true) 
  165. 		end 
  166. 	end 
  167. 	 
  168. 	local screen_fade_data = Screen_fades[style][type] 
  169. 	if screen_fade_data == nil then 
  170. 		return 
  171. 	end 
  172.  
  173. 	-- Normal screen fades can accept a duration... 
  174. 	if style == SCREEN_FADE_STYLE_ALPHA then 
  175. 		local fade_1_h = vint_object_find("fade_black_to_none_twn") 
  176. 		local fade_2_h = vint_object_find("fade_none_to_black_twn") 
  177. 		 
  178. 		if duration == nil or duration < 0 then 
  179. 			duration = SCREEN_FADE_DEFAULT_DURATION 
  180. 		end 
  181. 		 
  182. 		-- convert to seconds 
  183. 		duration = duration * 0.001 
  184. 		 
  185. 		vint_set_property(fade_1_h, "duration", duration) 
  186. 		vint_set_property(fade_2_h, "duration", duration) 
  187. 	end 
  188.  
  189. 	--check to see if we need to hide the logo 
  190. 	if Screen_fade_logo_is_visible and type == SCREEN_FADE_TYPE_IN then 
  191. 		screen_fade_logo_hide() 
  192. 	end 
  193. 	 
  194. 	local fade_out_delay = 0 
  195. 	if Screen_fade_images_is_visible and type == SCREEN_FADE_TYPE_IN then 
  196. 		--fade_out_delay = 1 
  197. 		screen_fade_images_hide() 
  198. 	end 
  199. 	 
  200. 	local anim_h = vint_object_find(screen_fade_data.anim_name) 
  201. 	local grp_h = vint_object_find(screen_fade_data.grp_name) 
  202. 	 
  203. 	vint_set_property(grp_h, "visible", true) 
  204. 	 
  205. 	--if memory then straight fade to white instead of black 
  206. 	--local special_type = 1 
  207. 	local black_fade_h = vint_object_find("black_fade") 
  208. 	 
  209. 	if special_type == 1 then 
  210. 		vint_set_property(black_fade_h, "tint", 220/255,220/255,220/255) 
  211. 	else 
  212. 		vint_set_property(black_fade_h, "tint", _red, _green, _blue) 
  213. 	end 
  214. 	 
  215. 	lua_play_anim(anim_h, fade_out_delay) 
  216. 	 
  217. 	--hide white bg once fade in starts 
  218. 	if type == SCREEN_FADE_TYPE_IN then 
  219. 		local mem_white_bg_h = vint_object_find("mem_white_bg") 
  220. 		local mem_loading_grp_h = vint_object_find("mem_loading_grp") 
  221. 		vint_set_property(mem_white_bg_h, "alpha", 0) 
  222. 		vint_set_property(mem_loading_grp_h, "alpha", 0) 
  223. 	end 
  224. 	 
  225. 	Screen_fade_state = type 
  226. end 
  227.  
  228. --This is called when the transition is finished 
  229. function screen_fade_complete_cb(tween_h) 
  230. 	--Let C know we are done fading out the screen... 
  231. 	Screen_fade_transition_complete()  
  232.  
  233. 	--If we are fading back into game hide the bitmaps... 
  234. 	if Screen_fade_state == SCREEN_FADE_TYPE_IN then 
  235. 		-- Force Hide all groups 
  236. 		local safe_frame_h = vint_object_find("screen_grp") 
  237. 		vint_hide_children(safe_frame_h) 
  238. 	end 
  239. end 
  240.  
  241. ------------------------------------------------------------------------------- 
  242. -- C determines if we are going to show a logo during this transition... 
  243. -- 
  244. function screen_fade_logo_show(special_type) 
  245. 	 
  246. 	if Screen_fade_force_white_load == true then 
  247. 		special_type = 1 
  248. 		Screen_fade_force_white_load = false 
  249. 	end 
  250. 	 
  251. 	if Screen_fade_state == SCREEN_FADE_TYPE_IN then 
  252. 		--Do not show the logo if we are faded in... 
  253. 		return 
  254. 	end 
  255. 	 
  256. 	local loading_pulse_anim_h = -1 
  257. 	local loading_pulse_twn_h = -1 
  258. 	local loading_fade_in_anim_h = -1 
  259. 	 
  260. 	--Check if its a memory fade 
  261. 	--1 = Memory Fade 
  262. 	if special_type == 1 then 
  263. 		loading_fade_in_anim_h = vint_object_find("mem_loading_fade_in_anim") 
  264. 	else 
  265. 		loading_pulse_anim_h = vint_object_find("loading_pulse_anim") 
  266. 		loading_fade_in_anim_h = vint_object_find("loading_fade_in_anim") 
  267. 		lua_play_anim(loading_pulse_anim_h) 
  268. 	end 
  269. 	 
  270. 	--Play fade out of logo 
  271. 	local loading_fade_out_anim_h = vint_object_find("loading_fade_out_anim") 
  272. 	vint_set_property(loading_fade_out_anim_h, "is_paused", true) 
  273.  
  274. 	--Fade in logo 
  275. 	lua_play_anim(loading_fade_in_anim_h) 
  276. 	 
  277. 	Screen_fade_logo_is_visible = true 
  278. end 
  279.  
  280.  
  281. ------------------------------------------------------------------------------- 
  282. -- This is called to fade out the logo... 
  283. -- 
  284. function screen_fade_logo_hide() 
  285. 	--Check if its a memory fade 
  286. 	 
  287. 	local loading_fade_in_anim_h = vint_object_find("loading_fade_in_anim") 
  288. 	local mem_loading_fade_in_anim_h = vint_object_find("mem_loading_fade_in_anim") 
  289. 	local loading_fade_out_anim_h = vint_object_find("loading_fade_out_anim") 
  290. 	 
  291. 	-- Pause fade in of logo... 
  292. 	vint_set_property(loading_fade_in_anim_h, "is_paused", true) 
  293. 	vint_set_property(mem_loading_fade_in_anim_h, "is_paused", true) 
  294. 	 
  295. 	--Play fade out of logo 
  296. 	lua_play_anim(loading_fade_out_anim_h) 
  297. 	 
  298. end 
  299.  
  300. -------------------------------------------------------------------------------- 
  301. -- Called when logo is completely faded out 
  302. -- 
  303. function screen_fade_logo_out_cb() 
  304. 	--Start highlight on logo... 
  305. 	--local loading_anim_h = vint_object_find("loading_anim") 
  306. 	--vint_set_property(loading_anim_h, "is_paused", true) 
  307. 	 
  308. 	--Pulse center of logo... 
  309. 	 
  310. 	local loading_pulse_anim_h = vint_object_find("loading_pulse_anim") 
  311. 	local mem_loading_pulse_anim_h = vint_object_find("mem_loading_pulse_anim") 
  312. 	 
  313. 	vint_set_property(loading_pulse_anim_h, "is_paused", true) 
  314. 	vint_set_property(mem_loading_pulse_anim_h, "is_paused", true) 
  315. 	Screen_fade_logo_is_visible = false   
  316. 	 
  317. end 
  318.  
  319. -------------------------------------------------------------------------------- 
  320. -- Shows "Saving..." text and displays rotating spinner 
  321. -- 
  322. function screen_fade_auto_save_show() 
  323. 	 
  324. 	vint_set_property(Screen_fade_autosave_grp_h, "visible", true) 
  325. 	 
  326. 	local autosave_loop_anim_h = vint_object_find("autosave_loop_anim") 
  327. 	lua_play_anim(autosave_loop_anim_h) 
  328.  
  329. 	local hud_doc_h = vint_document_find("hud") 
  330. 	local move_y = 0 
  331. 	if hud_doc_h ~= 0 and Hud_gsi ~= -1 then 
  332. 		--check if hud gsi is active 
  333. 		if Hud_gsi:is_active_get() then 
  334. 			--Move it 
  335. 			local width, height = Hud_gsi:get_size() 
  336. 			move_y = Screen_fade_autosave_grp_y + height + 5 
  337. 		end 
  338. 	end 
  339. 	screen_fade_auto_save_move(move_y) 
  340. end 
  341.  
  342. -------------------------------------------------------------------------------- 
  343. -- Hides "Saving..." text  
  344. -- 
  345. function screen_fade_auto_save_hide() 
  346. 	local autosave_grp_h = vint_object_find("autosave_grp") 
  347. 	vint_set_property(autosave_grp_h, "visible", false) 
  348. 	 
  349. 	local autosave_loop_anim_h = vint_object_find("autosave_loop_anim") 
  350. 	vint_set_property(autosave_loop_anim_h, "is_paused", true) 
  351. end 
  352.  
  353. ------------------------------------------------------------------------------- 
  354. -- Initialize screen fades 
  355. -- Setup text boxes 
  356. -- 
  357. function screen_fade_auto_save_init() 
  358. 	Screen_fade_autosave_grp_h = vint_object_find("autosave_grp") 
  359. 	local saving_content_text_1_h = vint_object_find("saving_content_text_1") 
  360. 	local saving_content_bg_h 		= vint_object_find("saving_content_bg") 
  361. 	 
  362. 	vint_set_property(saving_content_text_1_h, "text_tag", "SAVE_WARNING_GAME")	--Saving Content 
  363. 	 
  364. 	local bg_width, bg_height = element_get_actual_size(saving_content_bg_h) 
  365. 	local text_1_width, text_1_height = element_get_actual_size(saving_content_text_1_h) 
  366. 	local text_1_x, text_1_y = vint_get_property(saving_content_text_1_h, "anchor") 
  367. 	local BG_PADDING = 10	 
  368. 		 
  369. 	local max_width = 340 
  370. 	if text_1_width > max_width then 
  371. 		local scale = max_width / text_1_width 
  372. 		vint_set_property(saving_content_text_1_h, "scale", scale, scale) 
  373. 	end 
  374. 	 
  375. 	local text_1_width, text_1_height = element_get_actual_size(saving_content_text_1_h) 
  376. 	bg_width = text_1_x + text_1_width + BG_PADDING 
  377. 	element_set_actual_size(saving_content_bg_h, bg_width, bg_height)	 
  378. 	 
  379. 	Screen_fade_autosave_grp_x, Screen_fade_autosave_grp_y = vint_get_property(Screen_fade_autosave_grp_h, "anchor") 
  380. end 
  381.  
  382. function screen_fade_auto_save_move(y_position) 
  383. 	if y_position ~= 0 then 
  384. 		vint_set_property(Screen_fade_autosave_grp_h, "anchor", Screen_fade_autosave_grp_x, y_position) 
  385. 	else 
  386. 		vint_set_property(Screen_fade_autosave_grp_h, "anchor", Screen_fade_autosave_grp_x, Screen_fade_autosave_grp_y) 
  387. 	end 
  388. end 
  389.  
  390.  
  391. ------------------------------------------------------------------------------- 
  392. -- Initialize screen fade images (called from init) 
  393. -- 
  394. function screen_fade_images_init() 
  395. 	Screen_fade_images_grp_h = vint_object_find("images_grp") 
  396. 	Screen_fade_images_fade_anim_h = vint_object_find("images_fade_anim") 
  397. 	Screen_fade_images_fade_twn_h  = vint_object_find("images_fade_twn", Screen_fade_images_fade_anim_h) 
  398. 	Screen_fade_images_trans_anim_h  = vint_object_find("images_transition_anim") 
  399.  
  400. 	 
  401. 	--Setup callback for fading in/out 
  402. 	vint_set_property(Screen_fade_images_fade_twn_h, "end_event", "screen_fade_images_fade_cb") 
  403. 	 
  404. 	--Set up loop for images... 
  405. 	local bmp1_fade_in_twn_h = vint_object_find("bmp1_fade_in_twn", Screen_fade_images_trans_anim_h) 
  406. 	vint_set_property(bmp1_fade_in_twn_h, "end_event", "vint_anim_loop_callback") 
  407.  
  408. 	--Hide images...	 
  409. 	vint_set_property(Screen_fade_images_grp_h, "alpha", 0) 
  410. 	 
  411. 	--Store paths to images... 
  412. 	Screen_fade_image_1_h = vint_object_find("bmp1", Screen_fade_images_grp_h) 
  413. 	Screen_fade_image_2_h = vint_object_find("bmp2", Screen_fade_images_grp_h) 
  414. 	 
  415. 	if sfx_use_load_images() then 
  416. 		local loading_images = {} 
  417. 		local random_num_values = {} 
  418. 		local random_num_count = 1 
  419. 		 
  420. 		local screen_fade_images_num = #Screen_fade_images 
  421. 		 
  422. 		while #random_num_values < 2 do 
  423. 			local found_match = false 
  424. 			local random_num = rand_int(1, screen_fade_images_num) 
  425. 			for i = 1, 3 do 
  426. 				if random_num == random_num_values[i] then 
  427. 					found_match = true 
  428. 				end 
  429. 			end 
  430. 			if found_match == false then 
  431. 				random_num_values[random_num_count] = random_num 
  432. 				random_num_count = random_num_count + 1 
  433. 			end 
  434. 		end 
  435. 		 
  436. 		local platform_file_ext = "" 
  437. 		if game_get_platform() == "PC" then 
  438. 			platform_file_ext = "_pc" 
  439. 		elseif game_get_platform() == "XBOX3" then 
  440. 			platform_file_ext = "_xbox3" 
  441. 		elseif game_get_platform() == "PS4" then 
  442. 			platform_file_ext = "_ps4" 
  443. 		end 
  444. 		 
  445. 		for i = 1, #random_num_values do 
  446. 			loading_images[i] = Screen_fade_images[random_num_values[i]] .. platform_file_ext 
  447. 		end 
  448. 		 
  449. 		Screen_fade_loaded_images = loading_images 
  450. 		game_peg_load_with_cb("screen_fade_images_loaded", 2, loading_images[1],  loading_images[2])	 
  451. 		 
  452. 		Screen_fade_use_load_images = true 
  453. 	end 
  454. end 
  455.  
  456. ------------------------------------------------------------------------------- 
  457. -- Cleanup any loaded images... (called from cleanup) 
  458. -- 
  459. function screen_fade_images_cleanup() 
  460. 	 
  461. 	if Screen_fade_use_load_images then 
  462. 		--Free up memory... 
  463. 		for i, v in pairs(Screen_fade_loaded_images) do 
  464. 			game_peg_unload(v) 
  465. 		end 
  466. 		Screen_fade_loaded_images = {} 
  467. 	end 
  468. 	 
  469. end 
  470.  
  471. ------------------------------------------------------------------------------- 
  472. -- Shows the screen fade images... (called from c++) 
  473. -- 
  474. function screen_fade_images_show() 
  475. 	--Fade in group based and fade it in with transition animation... 
  476. 	local images_alpha = vint_get_property(Screen_fade_images_grp_h, "alpha") 
  477. 	vint_set_property(Screen_fade_images_fade_twn_h, "start_value", images_alpha) 
  478. 	vint_set_property(Screen_fade_images_fade_twn_h, "end_value", 1) 
  479. 	local screenshot_anim_h  = vint_object_find("screenshot_anim") 
  480. 	 
  481. 	--Apply start values of animations 
  482. 	vint_apply_start_values(Screen_fade_images_fade_anim_h) 
  483. 	vint_apply_start_values(Screen_fade_images_trans_anim_h) 
  484. 	 
  485. 	--Start animations 
  486. 	lua_play_anim(Screen_fade_images_fade_anim_h) 
  487. 	vint_set_property(Screen_fade_images_grp_h, "alpha", 1) 
  488. 	lua_play_anim(Screen_fade_images_trans_anim_h) 
  489. 	lua_play_anim(screenshot_anim_h) 
  490. 	 
  491. 	Screen_fade_images_is_visible = true 
  492. end 
  493.  
  494. ------------------------------------------------------------------------------- 
  495. -- Hides the screen fade images... (called from c++) 
  496. -- 
  497. function screen_fade_images_hide() 
  498. 	--Fade in group based and fade it in with transition animation... 
  499. 	local images_alpha = vint_get_property(Screen_fade_images_grp_h, "alpha") 
  500. 	vint_set_property(Screen_fade_images_fade_twn_h, "start_value", images_alpha) 
  501. 	vint_set_property(Screen_fade_images_fade_twn_h, "end_value", 0) 
  502. 	 
  503. 	--lua_play_anim(Screen_fade_images_fade_anim_h) 
  504. 	vint_set_property(Screen_fade_images_grp_h, "alpha", 0) 
  505. 	Screen_fade_images_is_visible = false 
  506. 	 
  507. 	--vint_set_property(Screen_fade_images_fade_anim_h, "is_paused", true)        
  508. end 
  509.  
  510.  
  511. ------------------------------------------------------------------------------- 
  512. -- Sets screen background to render in the background or foreground (called from C++)  
  513. -- 
  514. function screen_fade_set_to_background(is_background) 
  515. 	local base_grp_h = vint_object_find("base_grp") 
  516. 	vint_set_property(base_grp_h, "background", is_background) 
  517. end 
  518.  
  519.  
  520. ------------------------------------------------------------------------------- 
  521. -- Callback for when the images are done fading... 
  522. -- 
  523.  
  524. function screen_fade_images_fade_cb() 
  525. 	if Screen_fade_images_is_visible == false then 
  526. 		--stop transition animation if we are paused... 
  527. 		vint_set_property(Screen_fade_images_trans_anim_h, "is_paused", true) 
  528. 	end 
  529. end 
  530.  
  531. ------------------------------------------------------------------------------- 
  532. -- Callabck to set the images that are loaded 
  533. -- 
  534.  
  535. function screen_fade_images_loaded() 
  536. 	--Replace image names with loaded images 
  537. 	vint_set_property(Screen_fade_image_1_h, "image", Screen_fade_loaded_images[1]) 
  538. 	vint_set_property(Screen_fade_image_2_h, "image", Screen_fade_loaded_images[2]) 
  539. end 
  540.  
  541. ------------------------------------------------------------------------------- 
  542. -- These are test functions to test the fades... 
  543. ------------------------------------------------------------------------------- 
  544. function screen_fade_1()  
  545. 	screen_fade_do(SCREEN_FADE_STYLE_LEFT_TO_RIGHT, SCREEN_FADE_TYPE_IN)	 
  546. end 
  547. function screen_fade_2() 
  548. 	screen_fade_do(SCREEN_FADE_STYLE_LEFT_TO_RIGHT, SCREEN_FADE_TYPE_OUT)	 
  549. end 
  550. function screen_fade_3() 
  551. 	screen_fade_do(SCREEN_FADE_STYLE_ALPHA, SCREEN_FADE_TYPE_IN)	 
  552. end 
  553. function screen_fade_4() 
  554. 	screen_fade_do(SCREEN_FADE_STYLE_ALPHA, SCREEN_FADE_TYPE_OUT)	 
  555. end 
  556. function screen_fade_5() 
  557. 	screen_fade_do(SCREEN_FADE_STYLE_ALPHA, SCREEN_FADE_TYPE_IN, 5000)	 
  558. end 
  559. function screen_fade_6() 
  560. 	screen_fade_do(SCREEN_FADE_STYLE_ALPHA, SCREEN_FADE_TYPE_OUT, 5000)	 
  561. end 
  562.  
  563. function screen_fade_hide() 
  564. 	if Screen_fade_hide_ref_count == 0 then 
  565. 		local d = vint_document_find( "screen_fade" ) 
  566. 		local h = vint_object_find( "safe_frame", nil, d ) 
  567. 		vint_set_property( h, "visible", false ) 
  568. 	end 
  569. 	 
  570. 	Screen_fade_hide_ref_count = Screen_fade_hide_ref_count + 1 
  571. end 
  572.  
  573. function screen_fade_unhide() 
  574. 	if Screen_fade_hide_ref_count < 1 then 
  575. 		assert_msg( false, "screen_fade_unhide(): ref count is already 0" ) 
  576. 		return 
  577. 	end 
  578. 	 
  579. 	if Screen_fade_hide_ref_count == 1 then 
  580. 		local d = vint_document_find( "screen_fade" ) 
  581. 		local h = vint_object_find( "safe_frame", nil, d ) 
  582. 		vint_set_property( h, "visible", true ) 
  583. 	end 
  584.  
  585. 	Screen_fade_hide_ref_count = Screen_fade_hide_ref_count - 1 
  586. end 
  587.  
  588. --[[ --------------------------------------------------------------------- 
  589. -- Function - screen_fade_reset 
  590. -- Description - called whenever the screen is reset 
  591. -- Parameters - none 
  592. -- Returns - nil 
  593. ]]-- --------------------------------------------------------------------- 
  594. function screen_fade_reset() 
  595. 	if game_get_platform() == "PC" then 
  596. 		if vint_is_std_res() then 
  597. 			vint_set_property(Screen_fade_autosave_grp_h, "anchor", 48, 36) 
  598. 			Screen_fade_autosave_grp_x = 48 
  599. 			Screen_fade_autosave_grp_y = 36 
  600. 			vint_set_property(Screen_fade_autosave_grp_h, "scale", 0.667, 0.667) 
  601. 		else 
  602. 			vint_set_property(Screen_fade_autosave_grp_h, "anchor", 96, 54) 
  603. 			Screen_fade_autosave_grp_x = 96 
  604. 			Screen_fade_autosave_grp_y = 54 
  605. 			vint_set_property(Screen_fade_autosave_grp_h, "scale", 1, 1) 
  606. 		end 
  607. 	end 
  608. end