./screen_capture.lua

  1. local SCREEN_CAPTURE_ACTION_UPLOAD = 1 
  2. local SCREEN_CAPTURE_ACTION_CANCEL = 2 
  3.  
  4. local Megalist_data = { 
  5. 	[1] = { 
  6. 		type = TYPE_BUTTON, 
  7. 		label = "CELL_CAMERA_MODE_UPLOAD_SNAPSHOT", 
  8. 		id = SCREEN_CAPTURE_ACTION_UPLOAD, 
  9. 	}, 
  10. 	[2] = { 
  11. 		type = TYPE_BUTTON, 
  12. 		label = "CONTROL_CANCEL",	 
  13. 		id = SCREEN_CAPTURE_ACTION_CANCEL, 
  14. 	}, 
  15. } 
  16.  
  17. Camera_list = -1 
  18. local Input_tracker 
  19. local Screen_grp_h = 0 
  20. local Mouse_input_tracker = -1 
  21. local Screen_capture_doc_h = -1 
  22.  
  23. function screen_capture_init() 
  24. 	Screen_capture_doc_h = vint_document_find("screen_capture") 
  25. 	Screen_grp_h = vint_object_find("screen_grp") 
  26. 	vint_set_property(Screen_grp_h, "visible", false) 
  27. 	 
  28. 	local message_h = vint_object_find("message") 
  29. 	vint_set_property(message_h, "text_tag", "CELL_CAMERA_MODE_UPLOAD_PROMPT") 
  30. 	 
  31. 	--this will bring up options 
  32. 	Camera_list = Vdo_mega_list:new("megalist", 0, Screen_capture_doc_h, "screen_capture.lua", "Camera_list") 
  33. 	Camera_list:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY) 
  34. 	Camera_list:draw_items(Megalist_data, 1, 500) 
  35. 	 
  36. 	 
  37. 	--subscribe to inputs... 
  38. 	Input_tracker = Vdo_input_tracker:new() 
  39. 	Input_tracker:add_input("select", "screen_capture_input", 50) 
  40. 	Input_tracker:add_input("back", "screen_capture_input", 50) 
  41. 	Input_tracker:add_input("nav_up", "screen_capture_input", 50) 
  42. 	Input_tracker:add_input("nav_down", "screen_capture_input", 50) 
  43. 	Input_tracker:add_input("nav_left", "screen_capture_input", 50) 
  44. 	Input_tracker:add_input("nav_right", "screen_capture_input", 50) 
  45. 	 
  46. 	Input_tracker:subscribe(false); 
  47. 	 
  48. 	-- Add mouse inputs for the PC 
  49. 	if game_get_platform() == "PC" then 
  50. 		 
  51. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  52. 		Camera_list:add_mouse_inputs("screen_capture", Mouse_input_tracker) 
  53. 		Mouse_input_tracker:subscribe(false) 
  54.  
  55. 	end 
  56. 	 
  57. end 
  58.  
  59.  
  60. function screen_capture_open_preview_dialog() 
  61.  
  62. 	--show screen 
  63. 	vint_set_property(Screen_grp_h, "visible", true) 
  64. 	 
  65. 	--subscribe to inputs... 
  66. 	Input_tracker:subscribe(true) 
  67. 	 
  68. 	if game_get_platform() == "PC" then 
  69. 		Mouse_input_tracker:subscribe(true) 
  70. 	end 
  71. end 
  72.  
  73. function screen_capture_close_dialog(do_upload) 
  74. 	-- tell c++ to upload or bail 
  75. 	screen_capture_preview_should_upload(do_upload) 
  76. 	 
  77. 	-- hide upload dialog 
  78. 	Input_tracker:subscribe(false) 
  79. 	if game_get_platform() == "PC" then 
  80. 		Mouse_input_tracker:subscribe(false) 
  81. 	end 
  82. 	vint_set_property(Screen_grp_h, "visible", false) 
  83. end 
  84.  
  85.  
  86. function screen_capture_input(event) 
  87. 	if event == "nav_up" then 
  88. 		Camera_list:move_cursor(-1) 
  89. 	elseif event == "nav_down" then 
  90. 		Camera_list:move_cursor(1) 
  91. 	elseif event == "select" then 
  92. 		if Camera_list:list_is_playing() == false then 
  93. 			local id = Camera_list:get_id() 
  94. 			if id == SCREEN_CAPTURE_ACTION_UPLOAD then 
  95. 				screen_capture_close_dialog(true) 
  96. 			elseif id == SCREEN_CAPTURE_ACTION_CANCEL then 
  97. 				screen_capture_close_dialog(false) 
  98. 			end 
  99. 		end	 
  100. 	elseif event == "back" then 
  101. 		screen_capture_close_dialog(false) 
  102. 	end 
  103. end 
  104.  
  105. function screen_capture_mouse_move(event, target_handle) 
  106. 	local new_index = Camera_list:get_button_index(target_handle) 
  107. 	if new_index ~= 0 then 
  108. 		Camera_list:set_selection(new_index) 
  109. 		Camera_list:move_cursor(0, true) 
  110. 	end 
  111. end 
  112.  
  113. -- Mouse inputs 
  114. function screen_capture_mouse_click(event, target_handle, mouse_x, mouse_y) 
  115. 	if Camera_list:list_is_playing() == false then 
  116. 		local new_index = Camera_list:get_button_index(target_handle) 
  117. 		if new_index == SCREEN_CAPTURE_ACTION_UPLOAD then 
  118. 			screen_capture_close_dialog(true) 
  119. 		end 
  120. 		 
  121. 		if new_index == SCREEN_CAPTURE_ACTION_CANCEL then 
  122. 			screen_capture_close_dialog(false) 
  123. 		end 
  124. 	end 
  125. end