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