./city_load.lua

  1. local IMAGE_DELAY = 5 
  2.  
  3. City_load_data = {  
  4. 		handles = { }, 
  5. } 
  6.  
  7. City_load_images = {	 
  8. 	"ui_mainmenu_load_01", 
  9. 	"ui_mainmenu_load_02", 
  10. 	"ui_mainmenu_load_03", 
  11. 	"ui_mainmenu_load_04", 
  12. 	"ui_mainmenu_load_05", 
  13. } 
  14.  
  15. City_load_current_images = {} 
  16. local City_load_doc_handle = -1 
  17.  
  18. function city_load_init() 
  19. 	City_load_doc_handle = vint_document_find("city_load") 
  20. 	local h = -1 
  21. 	City_load_data.handles.loading_grp_h = vint_object_find("loading_grp",0,City_load_doc_handle) 
  22. 	h = City_load_data.handles.loading_grp_h 
  23. 	City_load_data.handles.images_h = vint_object_find("images",0,City_load_doc_handle) 
  24. 	h = City_load_data.handles.images_h 
  25. 	City_load_data.handles.bmp1_h = vint_object_find("bmp1", h) 
  26. 	City_load_data.handles.bmp2_h = vint_object_find("bmp2", h) 
  27. 	City_load_data.handles.bmp3_h = vint_object_find("bmp3", h) 
  28. 	 
  29. 	--looping animation stuff 
  30. 	City_load_data.handles.transition2_h = vint_object_find("transition2",0,City_load_doc_handle) 
  31. 	h = City_load_data.handles.transition2_h 
  32. 	City_load_data.handles.load3_bmp1_out = vint_object_find("load3_bmp1_in", h) 
  33. 	local twn_h = City_load_data.handles.load3_bmp1_out 
  34. 	 
  35. 	vint_set_property(twn_h, "end_event", "city_load_transition") 
  36. 	 
  37. 	local loading_anim_h = vint_object_find("loading_anim",0,City_load_doc_handle) 
  38. 	--local loading_twn_h = vint_object_find("loading_twn",loading_anim_h) 
  39. 	--vint_set_property(loading_twn_h, "end_event", "vint_anim_loop_callback") 
  40. 	lua_play_anim(loading_anim_h,0,City_load_doc_handle) 
  41. 	 
  42. 	 
  43. 	--play animations... 
  44. 	--local loading_pulse_anim_h = vint_object_find("loading_pulse_anim",0,City_load_doc_handle) 
  45. 	--lua_play_anim(loading_pulse_anim_h,0,City_load_doc_handle) 
  46. 	 
  47. 	local loading_in_anim_h = vint_object_find("loading_in_anim",0,City_load_doc_handle) 
  48. 	lua_play_anim(loading_in_anim_h,0,City_load_doc_handle) 
  49. 	 
  50. 	local screenshot_anim_h = vint_object_find("screenshot_anim",0,City_load_doc_handle) 
  51. 	lua_play_anim(screenshot_anim_h,0,City_load_doc_handle) 
  52. 	 
  53. 	 
  54. 	 
  55. 	local loading_images = {} 
  56. 	local random_num_values = {} 
  57. 	local random_num_count = 1 
  58. 	 
  59. 	local check_screen_fades = false 
  60. 	 
  61. 	--Make sure we don't try to load/unload our always loaded images 
  62. 	local screen_fade_doc_h = vint_document_find("screen_fade") 
  63. 	if screen_fade_doc_h ~= 0 then 
  64. 		--doc is loaded, now check if we are suing the always loaded images... 
  65. 		if Screen_fade_use_load_images then 
  66. 			check_screen_fades = true 
  67. 		end 
  68. 	end 
  69. 	 
  70. 	while #random_num_values < 3 do 
  71. 		local found_match = false 
  72. 		local random_num = rand_int(1,#City_load_images) 
  73. 		for i = 1, 3 do 
  74. 			if random_num == random_num_values[i] then 
  75. 				found_match = true 
  76. 			end 
  77. 		end 
  78. 		if found_match == false then 
  79. 			if check_screen_fades == true then 
  80. 				--loop through our loaded images and compare them against the city load images... 
  81. 				for idx, screen_fade_load_image in pairs(Screen_fade_loaded_images) do 
  82. 					if screen_fade_load_image == City_load_images[random_num] then 
  83. 						--Found match, don't add it to random_num_values. 
  84. 						found_match = true 
  85. 					end 
  86. 				end 
  87. 			end 
  88. 	 
  89. 			if found_match == false then 
  90. 				random_num_values[random_num_count] = random_num 
  91. 				random_num_count = random_num_count + 1 
  92. 			end 
  93. 		end 
  94. 	end 
  95. 	 
  96. 	local platform_file_ext = "" 
  97. 	if game_get_platform() == "PC" then 
  98. 		platform_file_ext = "_pc" 
  99. 	elseif game_get_platform() == "XBOX3" then 
  100. 		platform_file_ext = "_xbox3" 
  101. 	elseif game_get_platform() == "PS4" then 
  102. 		platform_file_ext = "_ps4" 
  103. 	end 
  104.  
  105. 	for i = 1, #random_num_values do 
  106. 		loading_images[i] = City_load_images[random_num_values[i]] .. platform_file_ext 
  107. 	end 
  108. 	 
  109. 	local images = loading_images 
  110. 	City_load_current_images = images 
  111. 	 
  112. 	game_peg_load_with_cb("city_load_set_images", 3, images[1],  images[2], images[3])	 
  113. 	 
  114. end 
  115.  
  116. function city_load_set_images() 
  117. 	vint_set_property(City_load_data.handles.bmp1_h, "image", City_load_current_images[1]) 
  118. 	vint_set_property(City_load_data.handles.bmp2_h, "image", City_load_current_images[2]) 
  119. 	vint_set_property(City_load_data.handles.bmp3_h, "image", City_load_current_images[3]) 
  120. 	 
  121. 	--set up the wait time 
  122. 	local wait_anim_h = vint_object_find("wait_10_anim", 0, City_load_doc_handle) 
  123. 	local wait_twn_h = vint_object_find("wait_twn", wait_anim_h) 
  124. 	vint_set_property(wait_twn_h, "end_event", "city_load_show_images") 
  125. 	vint_set_property(wait_twn_h, "duration", IMAGE_DELAY) 
  126. 	 
  127. 	--hide the images until we have dealyed time 
  128. 	local images_h = vint_object_find("images", 0, City_load_doc_handle) 
  129. 	vint_set_property(images_h, "visible", false) 
  130. 	 
  131. 	lua_play_anim(wait_anim_h, 0, City_load_doc_handle) 
  132. 	 
  133. 	-- Tell C code that images are done loading 
  134. 	city_load_img_load_complete() 
  135. end 
  136.  
  137. function city_load_show_images() 
  138. 	local images_h = vint_object_find("images", 0, City_load_doc_handle) 
  139. 	vint_set_property(images_h, "visible", true) 
  140. 	lua_play_anim(City_load_data.handles.transition2_h, 0, City_load_doc_handle) 
  141. 	 
  142. 	local start_images_anim_h = vint_object_find("start_images_anim", 0, City_load_doc_handle) 
  143. 	lua_play_anim(start_images_anim_h) 
  144. 	 
  145. end 
  146.  
  147. function city_load_hide_images() 
  148. 	local images_h = vint_object_find("images", 0, City_load_doc_handle) 
  149. 	vint_set_property(images_h, "visible", false) 
  150. 	for i, v in pairs(City_load_current_images) do 
  151. 		game_peg_unload(v) 
  152. 	end	 
  153. end 
  154.  
  155. function city_load_transition() 
  156. 	vint_set_property(City_load_data.handles.bmp1_h, "alpha", 1) 
  157. 	vint_set_property(City_load_data.handles.bmp2_h, "alpha", 1) 
  158. 	vint_set_property(City_load_data.handles.bmp3_h, "alpha", 1) 
  159. 	debug_print("vint", "city_load_transition, end of anim reached, looping now \n") 
  160. 	lua_play_anim(City_load_data.handles.transition2_h, 0, City_load_doc_handle) 
  161. end 
  162.  
  163. function city_load_cleanup() 
  164. 	 for i, v in pairs(City_load_current_images) do 
  165. 		 game_peg_unload(v) 
  166. 	 end 
  167. end 
  168.