./cell_camera.lua

  1. local Input_tracker 
  2. local Mouse_input_tracker 
  3. local Hint_bar  
  4.  
  5. local Camera_menu_data = { 
  6. 	[1] = { label = "CELL_CAMERA_MODE_TITLE", type = TYPE_TOGGLE, id = 1, current_value = 1, options = {"CELL_CAMERA_MODE_ENABLED", "CELL_CAMERA_MODE_DISABLED"} },	 
  7. } 
  8.  
  9. Camera_list = 0 
  10. Cell_camera_doc_handle = -1 
  11. local CHEATS_LIST_WIDTH 
  12.  
  13. function cell_camera_init() 
  14. 	--Get our document handle... 
  15. 	Cell_camera_doc_handle = vint_document_find("cell_camera") 
  16. 	 
  17. 	--Ask c++ if our camera is enabled... 
  18. 	local camera_enabled = cell_camera_is_enabled() 
  19. 	 
  20. 	--Set our menu to reflect game data... 
  21. 	if camera_enabled == true then 
  22. 		Camera_menu_data[1].current_value = 1 
  23. 	else 
  24. 		Camera_menu_data[1].current_value = 2 
  25. 	end 
  26. 	 
  27. 	--Format our screen... 
  28.  
  29. 	--Align web info... 
  30. 	 
  31. 	local how_to_txt_h = vint_object_find("how_to_txt", 0, Cell_camera_doc_handle) 
  32. 	resize_text_element(how_to_txt_h, 380) 
  33. 	 
  34. 	local web_title_txt_h = vint_object_find("web_title_txt" ,0, Cell_camera_doc_handle) 
  35. 	resize_text_element(web_title_txt_h, 380) 
  36. 		 
  37. 	local web_info_grp_h = vint_object_find("web_info_grp") 
  38. 	local x, y = vint_get_property(web_info_grp_h, "anchor") 
  39. 	 
  40. 	 
  41. 	 
  42. 	--Set up title 
  43. 	local cell_title_h = Vdo_cell_title:new("cell_title", 0, Cell_camera_doc_handle) 
  44. 	cell_title_h:set_text("MENU_CAMERA") 
  45. 	--cell_title_h:set_icon("ui_cell_icon_camera") 
  46. 	cell_title_h:play_dots_anim() 
  47. 	 
  48. 	--Align description/how to... 
  49. 	local description_1_txt_h = vint_object_find("description_1_txt") 
  50. 	local description_x, description_y = vint_get_property(description_1_txt_h, "anchor") 
  51. 	local description_width, description_height = element_get_actual_size(description_1_txt_h) 
  52. 	 
  53. 	local camera_hint_grp_h = vint_object_find("camera_hint_grp") 
  54. 	local camera_hint_x, camera_hint_y = vint_get_property(camera_hint_grp_h, "anchor") 
  55. 	 
  56. 	local camera_hint_y = description_y + description_height + 110 --+ ((y - (description_y + description_height))*.4)  
  57. 	 
  58. 	--vint_set_property(camera_hint_grp_h, "anchor", camera_hint_x, camera_hint_y) 
  59. 	 
  60. 	--set control image... 
  61. 	local camera_hint_text = vint_object_find("camera_hint_txt", 0, Cell_camera_doc_handle) 
  62. 	 
  63. 	local camera_hint_icon_vdo = Vdo_hint_button:new( "camera_hint_icon" ) 
  64. 	camera_hint_icon_vdo:set_button( CTRL_MENU_BUTTON_BACK, game_get_key_name_for_action( "CBA_GAC_TAKE_SCREENSHOT" ), false, false) 
  65. 	 
  66. 	if game_get_platform() == "PC" and game_is_active_input_gamepad() ~= true then 
  67. 		local hint_icon_w,hint_icon_h = camera_hint_icon_vdo:get_property( "screen_size" ) 
  68. 		local adjusted_hint_x = hint_icon_w * 0.5 
  69. 		 
  70. 		camera_hint_icon_vdo:set_property( "anchor", adjusted_hint_x, 0 ) 
  71. 		 
  72. 		local camera_hint_icon_bmp_h = vint_object_find( "camera_hint_icon_bmp" ) 
  73. 		vint_set_property( camera_hint_icon_bmp_h, "anchor", hint_icon_w + 6, 0 ) 
  74. 		vint_set_property(camera_hint_text, "visible", false) 
  75. 	else 
  76. 		local hint_text_w, hint_text_h = element_get_actual_size(camera_hint_text) 
  77. 		local hint_icon_w,hint_icon_h = camera_hint_icon_vdo:get_actual_size() 
  78. 		local adjusted_hint_x = hint_icon_w * 0.5 
  79. 		 
  80. 		camera_hint_icon_vdo:set_property( "anchor", hint_text_w + 20 + adjusted_hint_x, 0 ) 
  81. 		 
  82. 		local camera_hint_icon_bmp_h = vint_object_find( "camera_hint_icon_bmp" ) 
  83. 		vint_set_property( camera_hint_icon_bmp_h, "anchor", hint_text_w + 20 + hint_icon_w + 20, 0 ) 
  84. 		vint_set_property(camera_hint_text, "visible", true) 
  85. 	end 
  86. 	 
  87. 	 
  88. 	 
  89. 	 
  90. 	--Build our megalist...	 
  91. 	Camera_list = Vdo_mega_list:new("camera_list", 0, Cell_camera_doc_handle, "cell_camera.lua", "Camera_list") 
  92. 	Camera_list:set_properties(COLOR_CHEATS_PRIMARY, COLOR_CHEATS_SECONDARY, 10, .8, 410, false, false)	 
  93. 	Camera_list:draw_items(Camera_menu_data, 1) 
  94.  
  95. 	-- Subscribe to the button presses we need 
  96. 	Input_tracker = Vdo_input_tracker:new() 
  97. 	Input_tracker:add_input("map", "cell_camera_button_map", 50) 
  98. 	Input_tracker:add_input("back", "cell_camera_button_b", 50) 
  99. 	Input_tracker:add_input("nav_up", "cell_camera_nav", 50) 
  100. 	Input_tracker:add_input("nav_down", "cell_camera_nav", 50) 
  101. 	Input_tracker:add_input("nav_left", "cell_camera_nav_left_right", 50) 
  102. 	Input_tracker:add_input("nav_right", "cell_camera_nav_left_right", 50) 
  103. 	Input_tracker:subscribe(true) 
  104. 	 
  105. 	--[[ 
  106. 	local action_hint_data = { 
  107. 		{CTRL_BUTTON_DPAD_DOWN, "CELL_CAMERA_MODE_TAKE_SNAPSHOT"}, 
  108. 	} 
  109. 	local action_hint_bar = Vdo_hint_bar:new("action_hint") 
  110. 	action_hint_bar:set_hints(action_hint_data) 
  111. 	]] 
  112. 	 
  113. 	local hint_data = { 
  114. 		{CTRL_MENU_BUTTON_B, "MENU_BACK"}, 
  115. 	} 
  116. 	Hint_bar = Vdo_hint_bar:new("hint_bar") 
  117. 	Hint_bar:set_hints(hint_data) 
  118. 	 
  119. 	if game_get_platform() == "PC" then 
  120. 		Hint_bar:set_highlight(0) 
  121. 		 
  122. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  123. 		Camera_list:add_mouse_inputs("cell_camera", Mouse_input_tracker) 
  124. 		Hint_bar:add_mouse_inputs("cell_camera", Mouse_input_tracker) 
  125. 		Mouse_input_tracker:subscribe(true) 
  126. 	end 
  127. 	 
  128. 	--Transition the screen in... 
  129. 	cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_CAMERA, CELL_SCREEN_MAIN, nil) 
  130. 	--glitch 
  131. 	--glitch_cell() 
  132. end 
  133.  
  134. function cell_camera_nav(event) 
  135. 	if event == "nav_up" then 
  136. 		Camera_list:move_cursor(-1) 
  137. 	elseif event == "nav_down" then 
  138. 		Camera_list:move_cursor(1) 
  139. 	end 
  140. end 
  141.  
  142. function cell_camera_nav_left_right(event) 
  143. 	if Camera_list:list_is_playing() == false then 
  144. 		 
  145. 		Input_tracker:subscribe(false) 
  146. 		if game_get_platform() == "PC" then	 
  147. 			Mouse_input_tracker:subscribe(false) 
  148. 		end 
  149. 		--online_and_privilege_validator_begin(can_sign_in = false, check_service = true, check_online_priv = true, check_chat_priv = false, in_game = true, fail_on_chat = nil) 
  150. 		online_and_privilege_validator_begin(false, true, true, false, true)	-- Check we're signed in and we have content permissions 
  151. 		while Online_validator_result == ONLINE_VALIDATOR_IN_PROGRESS do 
  152. 			thread_yield() 
  153. 		end 
  154. 		 
  155. 		Input_tracker:subscribe(true) 
  156. 		if game_get_platform() == "PC" then	 
  157. 			Mouse_input_tracker:subscribe(true) 
  158. 		end 
  159. 		 
  160. 		if Online_validator_result ~= ONLINE_VALIDATOR_PASSED then 
  161. 			return 
  162. 		end 
  163. 		 
  164. 		if game_get_platform() == "XBOX360" then 
  165. 			if main_menu_xbox_get_age_group() == "unknown" then 
  166. 				dialog_box_message( "MENU_TITLE_NOTICE", "NO_NETWORK_CONNECTION" ) 
  167. 				return 
  168. 			end 
  169. 			 
  170. 			if main_menu_xbox_get_age_group() ~= "adult" then 
  171. 				dialog_box_message( "MENU_TITLE_NOTICE", "PLATFORM_XBOX_COMMUNITY_AGE_RESTRICTED" ) 
  172. 				return 
  173. 			end 
  174. 		end 
  175. 		 
  176. 		if game_get_platform() == "XBOX3"  then 
  177. 			if main_menu_xbox_get_age_group() == "unknown" then 
  178. 				dialog_box_message( "MENU_TITLE_NOTICE", "NO_NETWORK_CONNECTION" ) 
  179. 				return 
  180. 			end 
  181. 			 
  182. 			if main_menu_xbox_get_age_group() ~= "adult" then 
  183. 				dialog_box_message( "MENU_TITLE_NOTICE", "PLATFORM_XBOX_COMMUNITY_AGE_RESTRICTED" ) 
  184. 				return 
  185. 			end 
  186. 		end 
  187. 		if main_menu_check_social_privilege() == false then 
  188. 			dialog_box_message("MENU_TITLE_WARNING", "USER_CONTENT_PRIV_DENIED") 
  189. 			return 
  190. 		end 
  191.  
  192. 		if event == "nav_left" then 
  193. 			Camera_list:move_slider(1) 
  194. 		elseif event == "nav_right" then 
  195. 			Camera_list:move_slider(-1) 
  196. 		end 
  197. 		 
  198. 		local toggle_selection = Camera_list:get_toggle_selection() 
  199. 		 
  200. 		if toggle_selection == 1 then 
  201. 			--enabled 
  202. 			cell_camera_enable(true) 
  203. 		elseif toggle_selection == 2 then 
  204. 			--disabled 
  205. 			cell_camera_enable(false) 
  206. 		end 
  207. 	end 
  208. end 
  209.  
  210. function cell_camera_button_b(event, acceleration) 
  211. 	cell_camera_lock_controls() 
  212. 	ui_audio_post_event("UI_Hub_Menu_Back") 
  213. 	 
  214. 	--Transition the screen in... 
  215. 	cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_CAMERA, cell_camera_exit_to_main) 
  216. end 
  217.  
  218. function cell_camera_button_map(event, acceleration) 
  219. 	--Exit phone... 
  220. 	cell_camera_lock_controls() 
  221.  
  222. 	vint_dataresponder_post("cell_menu_state_dr", "Set", ID_MAIN) 
  223. 	ui_audio_post_event("UI_Hub_Menu_Back") 
  224.  
  225. 	--Transition the screen in... 
  226. 	cell_transition_screen(CELL_STATE_OUT, CELL_SCREEN_NONE, CELL_SCREEN_CAMERA, cell_camera_exit_to_game) 
  227. end 
  228.  
  229. function cell_camera_exit_to_main() 
  230. 	pop_screen() 
  231. end 
  232.  
  233. function cell_camera_exit_to_game() 
  234. 	pop_screen()	--camera 
  235. 	pop_screen()	--main menu 
  236. 	pop_screen()	--cellphone frame 
  237. end 
  238.  
  239. ------------------------------------------------------------------------------- 
  240. -- Controls Unlock  
  241. -- 
  242. function cell_camera_unlock_controls() 
  243. 	Input_tracker:subscribe(true) 
  244. 	if Mouse_input_tracker ~= nil then 
  245. 		Mouse_input_tracker:subscribe(true) 
  246. 	end 
  247. end 
  248.  
  249. ------------------------------------------------------------------------------- 
  250. -- Controls Lock 
  251. -- 
  252. function cell_camera_lock_controls() 
  253. 	Input_tracker:subscribe(false) 
  254. 	if Mouse_input_tracker ~= nil then 
  255. 		Mouse_input_tracker:subscribe(false) 
  256. 	end 
  257. end 
  258.  
  259. -- Mouse inputs 
  260. function cell_camera_mouse_click(event, target_handle, mouse_x, mouse_y) 
  261. 	local hint_index = Hint_bar:get_hint_index(target_handle) 
  262. 	if hint_index == 1 then 
  263. 		cell_camera_button_b() 
  264. 	end 
  265.  
  266. 	local new_index = Camera_list:get_button_index(target_handle) 
  267. 	if new_index ~= 0 then 
  268. 		Camera_list:set_selection(new_index) 
  269. 		cell_camera_nav_left_right("nav_right") 
  270. 	end 
  271. 	 
  272. 	if Camera_list:is_left_arrow(target_handle) then 
  273. 		cell_camera_nav_left_right("nav_left") 
  274. 	end 
  275. end 
  276.  
  277. function cell_camera_mouse_move(event, target_handle) 
  278. 	Hint_bar:set_highlight(0) 
  279. 	 
  280. 	local hint_index = Hint_bar:get_hint_index(target_handle) 
  281. 	if hint_index ~= 0 then 
  282. 		Hint_bar:set_highlight(hint_index) 
  283. 	end 
  284. 	 
  285. 	local new_index = Camera_list:get_button_index(target_handle) 
  286. 	if new_index ~= 0 then 
  287. 		Camera_list:set_selection(new_index) 
  288. 		Camera_list:move_cursor(0, true) 
  289. 	end 
  290. end 
  291.  
  292.