./dialog.lua

  1. -- OLD CONSTANTS 
  2. DIALOG_RESULT_INVALID 		= -1 
  3. DIALOG_ACTION_INVALID 		= -1 
  4.  
  5. DIALOG_ACTION_NONE 			= 0 
  6. DIALOG_ACTION_FORCE_CLOSED = 1 
  7. DIALOG_ACTION_CLOSE 			= 2 
  8. DIALOG_ACTION_NAVIGATE 		= 3 
  9.  
  10. DIALOG_PRIORITY_INFORMATION 		= 0 
  11. DIALOG_PRIORITY_ACTION 				= 1 
  12. DIALOG_PRIORITY_GAME_CRITICAL		= 2 
  13. DIALOG_PRIORITY_SYSTEM_CRITICAL	= 3 
  14.  
  15. DIALOG_RESULT_YES = 0 
  16. DIALOG_RESULT_NO 	= 1 
  17.  
  18. -- New stuff... 
  19.  
  20. -- CONSTANTS 
  21.  
  22.  
  23. -- Dialog Operations 
  24. local DIALOG_OPERATION_NEW_DIALOG	= 1 
  25. local DIALOG_OPERATION_CLOSE 	 		= 2 
  26. local DIALOG_OPERATION_TRANSITION 	= 3 
  27. local DIALOG_OPERATION_SUSPEND		= 4 
  28. local DIALOG_OPERATION_RESUME			= 8 
  29. local DIALOG_OPERATION_REBUILD 		= 16 
  30.  
  31. local Input_tracker	-- Track input for dialogs... 
  32. local Pause_input_tracker -- Track input for the pause thing 
  33. local Mouse_input_tracker -- Track mouse inputs 
  34.  
  35. local Pause_input_added = false 
  36.  
  37. local Dialogs = {}	-- Where to store all the dialogs coming in from script... 
  38. local Dialog_objects = {} 
  39. Dialog_object_0 = -1 
  40. Dialog_object_1 = -1 
  41.  
  42. local Dialog_current_idx = -1 	-- Index to the current dialog we are going to modify... 
  43. local Dialog_current_handle = -1 	-- Handle to the current dialog we are going to modify... 
  44.  
  45. local Dialog_box =  { handles = { } } 
  46.  
  47. local Ignore_input = false 
  48.  
  49. ------------------------------- 
  50. -- Init Dialog Box.... 
  51. ------------------------------- 
  52. function dialog_init() 
  53. 	-- This is the first screen that can call an interface init... 
  54. 	-- Spawn any processes that need to happen before anything else... 
  55. 	 
  56. 	--This is the first screen that can call an init... So we will take advantage... 
  57. 	vint_lib_init_buttons()			--Inits all button mappings to globals... 
  58. 	vint_lib_init_constants()		--Inits any constants that get used by the game... 
  59. 	 
  60. 	local Dialog_document_handle = vint_document_find("dialog") 
  61. 	 
  62. 	local dialog_box_h = vint_object_find("box") 
  63.   
  64. 	Dialog_objects[0] = Vdo_dialog:new("box", 0, Dialog_document_handle, "dialog.lua", "Dialog_object_0") 
  65. 	Dialog_objects[1] = Vdo_dialog:clone(dialog_box_h, 0, Dialog_document_handle, "dialog.lua", "Dialog_object_1") 
  66.  
  67. 	Dialog_objects[0]:set_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_PRIMARY) 
  68. 	Dialog_objects[1]:set_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_PRIMARY) 
  69.  
  70. 	Dialog_object_0 = Dialog_objects[0] 
  71. 	Dialog_object_1 = Dialog_objects[1] 
  72. 	 
  73. 	--Clone objects... 
  74. 	vint_set_property(Dialog_objects[0].handle, "depth", -1200) 
  75. 	vint_set_property(Dialog_objects[1].handle, "depth", -1000) 
  76.  
  77. 	Dialog_current_idx = -1 
  78. 	 
  79. 	--Hide objects... 
  80. 	Dialog_objects[0]:hide() 
  81. 	Dialog_objects[1]:hide() 
  82. 	 
  83. 	--Input tracker for the dialog boxes... 
  84. 	Input_tracker = Vdo_input_tracker:new() 
  85. 	Input_tracker:add_input("select", 		"dialog_input", 200) 
  86. 	Input_tracker:add_input("back", 			"dialog_input", 200) 
  87. 	Input_tracker:add_input("nav_up", 		"dialog_input", 200) 
  88. 	Input_tracker:add_input("nav_down", 	"dialog_input", 200) 
  89. 	Input_tracker:add_input("nav_left", 	"dialog_input", 200) 
  90. 	Input_tracker:add_input("nav_right", 	"dialog_input", 200) 
  91. 	Input_tracker:add_input("pause", 		"dialog_input", 200) 
  92. 	Input_tracker:add_input("map", 			"dialog_input", 200) 
  93. 	Input_tracker:add_input("exit",			"dialog_input", 200) 
  94. 	Input_tracker:add_input("alt_select", 	"dialog_input", 200) 
  95. 	if game_get_platform() == "PC" then 
  96. 		Input_tracker:add_input("scancode", "dialog_input_tab", 50, false, 15) -- tab key 
  97. 	end 
  98.  
  99. 	Input_tracker:subscribe(false) 
  100.  
  101. 	-- Pause coop input 
  102. 	Pause_input_tracker = Vdo_input_tracker:new()	 
  103. 	Pause_input_tracker:add_input("map", 			"dialog_pause_input", 100) 
  104. 	Pause_input_tracker:add_input("select", 		"dialog_pause_input", 150) 
  105. 	Pause_input_tracker:add_input("back", 			"dialog_pause_input", 150) 
  106. 	Pause_input_tracker:add_input("nav_up", 		"dialog_pause_input", 150) 
  107. 	Pause_input_tracker:add_input("nav_down", 	"dialog_pause_input", 150) 
  108. 	Pause_input_tracker:add_input("nav_left", 	"dialog_pause_input", 150) 
  109. 	Pause_input_tracker:add_input("nav_right", 	"dialog_pause_input", 150) 
  110. 	Pause_input_tracker:add_input("exit",			"dialog_pause_input", 150) 
  111. 	Pause_input_tracker:add_input("alt_select", 	"dialog_pause_input", 150) 
  112. 	Pause_input_tracker:subscribe(false) 
  113. 	 
  114. 	-- Mouse input 
  115. 	if game_get_platform() == "PC" then 
  116. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  117. 	end 
  118. 	 
  119. 	--Paused stuff 
  120. 	local paused_h = vint_object_find("paused") 
  121. 	Dialog_box.handles.paused = paused_h 
  122. 	Dialog_box.handles.partner_paused = vint_object_find("partner_paused", paused_h) 
  123. 	Dialog_box.handles.paused_bg = vint_object_find("background", paused_h) 
  124. end 
  125.  
  126. function dialog_cleanup() 
  127. 	--Unsubscribe all inputs... 
  128. 	Input_tracker:subscribe(false) 
  129. 	Pause_input_tracker:subscribe(false) 
  130. 	 
  131. 	if Mouse_input_tracker ~= nil then 
  132. 		Mouse_input_tracker:remove_all() 
  133. 	end 
  134. end 
  135.  
  136. -- Dialog input... 
  137. function dialog_input(event, acceleration) 
  138. 	if Ignore_input == false then 
  139. 	 
  140. 		-- Hack, only accept nav up, nav down, and select events while not morphing to fix this but where if you spam the enter key on a dialog box, it will render all funny. 
  141. 		-- For reference, here's the bug "43070: [PC]: UI prompts go blank after accessing crib wardrobe, hitting random keys, then clicking on "save outfit"" 
  142. 		if not Dialog_objects[Dialog_current_idx].morph_playing then 
  143. 			if event == "nav_up" then		 
  144. 				if Dialog_objects[Dialog_current_idx]:nav(-1) then 
  145. 					game_UI_audio_play("UI_Reward_Store_Menu_Navigation") 
  146. 				end 
  147. 			elseif event == "nav_down" then 
  148. 				if Dialog_objects[Dialog_current_idx]:nav(1) then 
  149. 					game_UI_audio_play("UI_Reward_Store_Menu_Navigation") 
  150. 				end 
  151. 			elseif event == "select" or event == "pause" then 
  152. 				if Dialog_objects[Dialog_current_idx]:select() then 
  153. 					game_UI_audio_play("UI_Main_Menu_Select") 
  154. 				end 
  155. 				 
  156. 				local selected_option_idx = Dialog_objects[Dialog_current_idx]:get_selected() 
  157. 				if game_get_platform() == "PC" and game_is_active_input_gamepad() == false and Dialog_objects[Dialog_current_idx]:has_second_option(selected_option_idx) == true then 
  158. 					if Dialog_objects[Dialog_current_idx]:nav(1) then 
  159. 						game_UI_audio_play("UI_Reward_Store_Menu_Navigation") 
  160. 					end 
  161. 				end 
  162. 			end 
  163. 		end 
  164.  
  165. 		-- Don't worry about the morph for Back events. Otherwise, spinner dialogs aren't cancelable 
  166. 		if event == "back" then 
  167. 			if Dialog_objects[Dialog_current_idx]:back() then 
  168. 				game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  169. 			end 
  170. 		end 
  171. 	end 
  172. end 
  173.  
  174. function dialog_input_tab() 
  175. 	dialog_input("nav_down") 
  176. end 
  177.  
  178. function dialog_build(dialog_operation, handle, previous_handle) 
  179. 	 
  180. 	if dialog_operation == DIALOG_OPERATION_TRANSITION then 
  181. 		local dialog_data = Dialogs[previous_handle] 
  182. 		Dialogs[previous_handle] = { } 
  183. 		Dialogs[handle] = dialog_data 
  184. 		 
  185. 		local dialog = dialog_data.object		 
  186. 		dialog.dialog_handle = handle 
  187. 		Dialog_current_handle = handle 
  188. 		 
  189. 		-- Disable inputs (because this morphs the dialog) 
  190. 		dialog_disable_mouse_input() 
  191. 		 
  192. 		--Send data to vdo...		 
  193. 		dialog_data.widgets_count = 0 
  194. 		vint_dataresponder_request("dialog_populate", "dialog_populate", 0, handle) 
  195. 		 
  196. 		dialog:create(dialog_data, true, dialog_box_morph_done) 
  197. 		dialog:open() 
  198. 		vint_set_property(dialog_data.object.handle, "depth", (Dialog_current_idx + 1) * -1000) 
  199. 		 
  200. 		-- DAD - 4/22/11 - Nav to the default option 
  201. 		if dialog_data.default > 0 then 
  202. 			dialog:nav(dialog_data.default) 
  203. 		end 
  204.  
  205. 		-- Mouse inputs are added by dialog_box_morph_done 
  206. 		Input_tracker:subscribe(true) 
  207. 		 
  208. 	elseif dialog_operation == DIALOG_OPERATION_NEW_DIALOG then 
  209. 		-- determine which object the dialog should go into... 
  210. 		Dialog_current_idx = Dialog_current_idx + 1 
  211. 		assert_msg(Dialog_current_idx >= 0 and Dialog_current_idx <= 2, "Invalid Dialog_current_idx DIALOG_OPERATION_NEW_DIALOG") 
  212. 		local dialog_object = Dialog_objects[Dialog_current_idx] 
  213. 		dialog_object.dialog_handle = handle 
  214. 		 
  215. 		--Build table for dialog entry... 
  216. 		Dialogs[handle] = { 
  217. 			object = dialog_object, 
  218. 			title = -1, 
  219. 			widgets_count = 0, 
  220. 		} 
  221. 		Dialog_current_handle = handle 
  222. 		 
  223. 		-- Get dialog  data 
  224. 		vint_dataresponder_request("dialog_populate", "dialog_populate", 0, handle) 
  225.  
  226. 		--Send data to vdo... 
  227. 		local dialog_data = Dialogs[handle] 
  228. 		local dialog = dialog_data.object 
  229. 		dialog:create(dialog_data, false) 
  230. 		dialog:open(true) 
  231. 		vint_set_property(dialog_data.object.handle, "depth", (Dialog_current_idx + 1) * -1000) 
  232. 		 
  233. 		-- DAD - 4/22/11 - Nav to the default option 
  234. 		if dialog_data.default > 0 then 
  235. 			dialog:nav(dialog_data.default) 
  236. 		end 
  237. 		 
  238. 		dialog_add_mouse_inputs(dialog) 
  239. 		Input_tracker:subscribe(true) 
  240. 		 
  241. 		--play dialog sound 
  242. 		game_UI_audio_play("UI_HUD_Dialog_Critical") 
  243. 	 
  244. 	elseif dialog_operation == DIALOG_OPERATION_REBUILD then 
  245. 		local dialog_data = Dialogs[handle] 
  246. 		local dialog = dialog_data.object		 
  247. 		dialog.dialog_handle = handle 
  248. 		Dialog_current_handle = handle 
  249. 		 
  250. 		-- Disable inputs (because this morphs the dialog) 
  251. 		dialog_disable_mouse_input() 
  252. 		 
  253. 		--Send data to vdo...		 
  254. 		dialog_data.widgets_count = 0 
  255. 		vint_dataresponder_request("dialog_populate", "dialog_populate", 0, handle) 
  256. 		 
  257. 		dialog:create(dialog_data, true, dialog_box_morph_done) 
  258. 		vint_set_property(dialog_data.object.handle, "depth", (Dialog_current_idx + 1) * -1000) 
  259. 		 
  260. 		-- DAD - 4/22/11 - Nav to the default option 
  261. 		if dialog_data.default > 0 then 
  262. 			dialog:nav(dialog_data.default) 
  263. 		end 
  264.  
  265. 		--Mouse inputs are added by dialog_box_morph_done 
  266. 		--Input_tracker:subscribe(true) 
  267.  
  268. 	elseif dialog_operation == DIALOG_OPERATION_CLOSE then 
  269. 		local dialog_data = Dialogs[handle] 
  270. 		local dialog = dialog_data.object 
  271. 		dialog:close() 
  272. 		 
  273. 		local shift_index = -1 
  274. 		for i, dlg in pairs(Dialog_objects) do 
  275. 			if dlg.dialog_handle == handle then 
  276. 				if i < Dialog_current_idx then 
  277. 					shift_index = i 
  278. 				end 
  279. 			end 
  280. 		end 
  281. 		 
  282. 		-- shuffle the dialogs so that Dialog_current_idx is correct 
  283. 		-- and we don't lose any of the dialog objects 
  284. 		if shift_index >= 0 then 
  285. 			local temp = Dialog_objects[shift_index]	-- Store the closing dialog object 
  286. 			 
  287. 			-- Shift all the dialogs back one 
  288. 			for i = shift_index + 1, #Dialog_objects do 
  289. 				Dialog_objects[i - 1] = Dialog_objects[i] 
  290. 			end 
  291. 			 
  292. 			-- Push the closing one to the end 
  293. 			Dialog_objects[#Dialog_objects] = temp 
  294. 			 
  295. 			-- Current Index should now point correctly to the current dialog 
  296. 		end 
  297. 		 
  298. 		Dialog_current_idx = Dialog_current_idx - 1 
  299. 		assert_msg(Dialog_current_idx == -1 or Dialog_current_idx == 1, "Invalid Dialog_current_idx DIALOG_OPERATION_CLOSE") 
  300. 		if Dialog_current_idx < 0 then  
  301. 			Input_tracker:subscribe(false) 
  302. 			dialog_disable_mouse_input() 
  303. 		else 
  304. 			dialog_add_mouse_inputs(Dialog_objects[Dialog_current_idx]) 
  305. 		end 
  306. 	end 
  307. end 
  308.  
  309. ------------------------------------------------------------------------------- 
  310. -- Populates our dialog box... this is called via dataresponder... 
  311. ------------------------------------------------------------------------------- 
  312. function dialog_populate(handle, widget_type, ...) 
  313.  
  314. 	-- process standard type widgets...	 
  315. 	local widget = {} 
  316. 	widget.type = widget_type 
  317.  
  318. 	--process odd type widgets first... 
  319. 	if widget_type == DIALOG_WIDGET_TYPE_TITLE then 
  320. 		-- Populate title 
  321. 		widget.title = arg[1]	--Title of the dialog. 
  322. 		Dialogs[handle].default = arg[2] -- Default selection 
  323. 	elseif widget_type == DIALOG_WIDGET_TYPE_OPTION then 
  324. 		--Add option to dialog 
  325. 		widget.has_second_option 	= arg[1]		--Do we have second option or not? 
  326. 		widget.disabled 				= arg[2]		--Is the option disabled? So we can make it display differently and the user cannot select it. 
  327. 		widget.tag_1		 			= arg[3]		--tag for first part of option 
  328. 		widget.tag_2 		 			= arg[4]		--tag for second part of option 
  329. 		widget.option_id 				= arg[5]		--ID of option... this gets passed back to game so we know what has been selected 
  330. 	elseif widget_type == DIALOG_WIDGET_TYPE_TEXT then 
  331. 		--Text field for dialog... 
  332. 		widget.text_tag	 	= arg[1]		--The text tag for the widget. 
  333. 		widget.num_lines 		= arg[2]		--How many lines we should make the widget... 
  334. 		widget.is_waiting 	= arg[3]		--Determines if this text line should be a cancel/waiting button...(HACK FOR SPINNER TYPES) 
  335. 	elseif widget_type == DIALOG_WIDGET_TYPE_IMAGE then 
  336. 		--Image field for dialog... 
  337. 		widget.image_name		= arg[1]		--Image name to display. 
  338. 	elseif widget_type == DIALOG_WIDGET_TYPE_SPINNER then 
  339. 		--Spinner field for dialog... 
  340. 		widget.spinner_txt	= arg[1]		--This is the text that goes along with the spinner. 
  341. 	end 
  342. 	 
  343. 	local widget_num = Dialogs[handle].widgets_count 
  344. 	Dialogs[handle][widget_num] = widget 
  345. 	Dialogs[handle].widgets_count = widget_num + 1 
  346. end 
  347.  
  348. function do_define_test(dialog_handle, widget_type, ...) 
  349. end 
  350.  
  351. ------------------------------------ 
  352. --[	Lua Dialog Box Interface	]-- 
  353. ------------------------------------ 
  354. function dialog_box_confirmation(header, body, callback, is_close_on_death, is_close_on_damage, default) 
  355. 	if default == nil then 
  356. 		default = 0 
  357. 	end 
  358. 	local priority = DIALOG_PRIORITY_ACTION 
  359. 	local options = { [0] = "CONTROL_YES", [1] = "CONTROL_NO" } 
  360. 	return dialog_box_open(header, body, options, callback, default, priority, true, nil, is_close_on_death, is_close_on_damage) 
  361. end 
  362.  
  363. function dialog_box_destructive_confirmation(header, body, callback) 
  364. 	local priority = DIALOG_PRIORITY_ACTION 
  365. 	local options = { [0] = "CONTROL_YES", [1] = "CONTROL_NO" } 
  366. 	local default = 1 
  367. 	return dialog_box_open(header, body, options, callback, default, priority, true) 
  368. end 
  369.  
  370. function dialog_box_message(header, body, is_close_on_death, is_close_on_damage, callback) 
  371. 	local default = 0 
  372. 	local priority = DIALOG_PRIORITY_ACTION 
  373. 	local options = { [0] = "CONTROL_CONTINUE" } 
  374. 	return dialog_box_open(header, body, options, callback, 0, priority, false, nil, is_close_on_death, is_close_on_damage) 
  375. end 
  376.  
  377. function dialog_box_message_critical(header, body, is_close_on_death, is_close_on_damage) 
  378. 	local default = 0 
  379. 	local priority = DIALOG_PRIORITY_SYSTEM_CRITICAL 
  380. 	local options = { [0] = "CONTROL_CONTINUE" } 
  381. 	return dialog_box_open(header, body, options, nil, 0, priority, false, nil, is_close_on_death, is_close_on_damage) 
  382. end 
  383.  
  384. function dialog_box_open(header, body, options, callback, default, priority, is_confirmation, is_spinner, is_close_on_death, is_close_on_damage, is_close_on_mission_end, back_option) 
  385. 	priority = priority or DIALOG_PRIORITY_ACTION 
  386. 	callback = callback or "dialog_box_do_nothing" 
  387. 	is_confirmation = is_confirmation or false 
  388. 	is_spinner = is_spinner or false 
  389. 	is_close_on_death = is_close_on_death or true 
  390. 	is_close_on_damage = is_close_on_damage or false 
  391. 	is_close_on_mission_end = is_close_on_mission_end or true 
  392. 	back_option = back_option or -1 
  393. 	 
  394. 	local handle = dialog_box_create_internal(header, body, callback, priority, is_confirmation, is_spinner, options[0], options[1], options[2], options[3], default, is_close_on_death, is_close_on_damage, is_close_on_mission_end, back_option) 
  395. 	return handle 
  396. end 
  397.  
  398. function dialog_box_do_nothing() 
  399. end 
  400.  
  401. function dialog_box_morph_done() 
  402. 	if Dialog_current_idx > -1 then 
  403. 		dialog_add_mouse_inputs(Dialog_objects[Dialog_current_idx]) 
  404. 	end 
  405. end 
  406.  
  407. ------------------------------------------------------------------------------- 
  408. -- Mouse functions 
  409. ------------------------------------------------------------------------------- 
  410.  
  411. function dialog_add_mouse_inputs(dialog) 
  412. 	if Mouse_input_tracker ~= nil then 
  413. 		Mouse_input_tracker:remove_all(true) 
  414. 		dialog:add_mouse_inputs("dialog_mouse_click", "dialog_mouse_move", Mouse_input_tracker, 150) 
  415. 		Mouse_input_tracker:subscribe(true, true) 
  416. 	end 
  417. end 
  418.  
  419. function dialog_disable_mouse_input() 
  420. 	if Mouse_input_tracker ~= nil then 
  421. 		Mouse_input_tracker:remove_all(true) 
  422. 	end 
  423. end 
  424.  
  425. function dialog_mouse_move(event, target_handle) 
  426. 	if Ignore_input == false and not Dialog_objects[Dialog_current_idx].morph_playing then 
  427. 		 
  428. 		local hint_index = Dialog_objects[Dialog_current_idx].hint_bar:get_hint_index(target_handle) 
  429. 		 
  430. 		if hint_index == 1 then 
  431. 			Dialog_objects[Dialog_current_idx].hint_bar:set_highlight(hint_index) 
  432. 		else 
  433. 			Dialog_objects[Dialog_current_idx].hint_bar:set_highlight(0) 
  434. 		end 
  435.  
  436. 		local option_id = Dialog_objects[Dialog_current_idx]:get_option_index(target_handle) 
  437. 		if option_id > -1 then 
  438. 			Dialog_objects[Dialog_current_idx]:highlight_option(option_id) 
  439. 			game_UI_audio_play("UI_Reward_Store_Menu_Navigation")	 
  440. 		end 
  441. 	end 
  442. end 
  443.  
  444. function dialog_mouse_click(event, target_handle) 
  445. 	if Ignore_input == false and not Dialog_objects[Dialog_current_idx].morph_playing then 
  446. 		local hint_index = Dialog_objects[Dialog_current_idx].hint_bar:get_hint_index(target_handle) 
  447. 		if hint_index == 1 then 
  448. 			if Dialog_objects[Dialog_current_idx]:back() then 
  449. 				game_UI_audio_play("UI_Main_Menu_Nav_Back") 
  450. 			end 
  451. 		end 
  452. 		local option_id = Dialog_objects[Dialog_current_idx]:get_option_index(target_handle) 
  453. 		if option_id > -1 then 
  454. 			Dialog_objects[Dialog_current_idx]:highlight_option(option_id) 
  455. 			Dialog_objects[Dialog_current_idx]:select() 
  456. 			game_UI_audio_play("UI_Main_Menu_Select") 
  457. 		end 
  458. 	end 
  459. end 
  460.  
  461. ------------------------------------------------------------------------------- 
  462. -- Paused.... 
  463. ------------------------------------------------------------------------------- 
  464. Dialog_pause_disconnect_dialog_handle = 0 
  465. Dialog_pause_partner_paused = false 
  466. Dialog_pause_allow_disconnect = false 
  467.  
  468. ------------------------------------------------------------------------------- 
  469. -- Shows the simplified pause screen... this is called via game code. 
  470. -- @param partner_paused				did the coop player pause the game? 
  471. -- @param	just_show_disconnect		does not indicate that the secondary player has paused.(used in special cases) 
  472. ------------------------------------------------------------------------------- 
  473. function dialog_pause_show(partner_paused, just_show_disconnect) 
  474. 	local h = Dialog_box.handles 
  475.  
  476. 	vint_set_property(h.paused, "visible", true) 
  477. 	vint_set_property(h.paused, "alpha", 1) 
  478. 	vint_set_property(h.paused_bg, "visible", true) 
  479. 	 
  480. 	if partner_paused or just_show_disconnect then 
  481. 		vint_set_property(h.partner_paused, "visible", true) 
  482. 		vint_set_property(h.partner_paused, "alpha", 1) 
  483. 		if partner_paused then 
  484. 			Dialog_pause_partner_paused = true 
  485. 			vint_set_property(h.partner_paused, "text_tag", "DIALOG_PAUSE_START_TO_DISCONNECT") 
  486. 		end 
  487. 		if just_show_disconnect then 
  488. 			Dialog_pause_allow_disconnect = true 
  489. 			vint_set_property(h.partner_paused, "text_tag", "COOP_DISCONNECT") 
  490. 		end 
  491. 	else 
  492. 		--Hide partner paused... 
  493. 		vint_set_property(h.partner_paused, "visible", false) 
  494. 		vint_set_property(h.partner_paused, "alpha", 0) 
  495. 		Dialog_pause_partner_paused = false 
  496. 		Dialog_pause_allow_disconnect = false 
  497. 	end 
  498. 	 
  499. 	if partner_paused then 
  500. 		--make sure we only remove the pause input once... 
  501. 		if Pause_input_added == true then 
  502. 			Pause_input_tracker:remove_input("pause") 
  503. 			Pause_input_added = false  
  504. 		end 
  505. 	else 
  506. 		if Pause_input_added == false then 
  507. 			Pause_input_tracker:add_input("pause", 		"dialog_pause_input", 100) 
  508. 			Pause_input_added = true 
  509. 		end  
  510. 	end 
  511.  
  512. 	Pause_input_tracker:subscribe(true) 
  513. end 
  514.  
  515. ------------------------------------------------------------------------------- 
  516. -- Hides the simplified pause screen... this is called via game code. 
  517. ------------------------------------------------------------------------------- 
  518. function dialog_pause_hide() 
  519. 	local h = Dialog_box.handles 
  520.  
  521. 	vint_set_property(h.paused, "visible", false) 
  522. 	vint_set_property(h.partner_paused, "visible", false) 
  523. 	vint_set_property(h.paused_bg, "visible", false) 
  524. 		 
  525. 	if Dialog_pause_disconnect_dialog_handle  ~= 0 then 
  526. 		dialog_box_force_close(Dialog_pause_disconnect_dialog_handle) 
  527. 		Dialog_pause_disconnect_dialog_handle = 0 
  528. 	end 
  529. 	 
  530. 	--	Unsubscribe to input 
  531. 	Pause_input_tracker:subscribe(false) 
  532. end 
  533.  
  534. function dialog_pause_disconnect(result, action) 
  535. 	if result == 0 then 
  536. 		dialog_box_disconnect() 
  537. 	else 
  538. 		Pause_input_tracker:subscribe(true) 
  539. 	end 
  540. 	 
  541. 	Dialog_pause_disconnect_dialog_handle = 0 
  542. end 
  543.  
  544. function dialog_pause_input(event, accelleration) 
  545. 	if Ignore_input == false then 
  546. 		if Dialog_pause_partner_paused == true then 
  547. 			if event == "map" then 
  548. 				--Map is the button to exit out of a partner paused situation 
  549. 				local options = { [0] = "CONTROL_YES", [1] = "CONTROL_NO" } 
  550. 				Dialog_pause_disconnect_dialog_handle = dialog_box_open("MENU_TITLE_WARNING", "DIALOG_PAUSE_DISCONNECT_PROMPT", options, "dialog_pause_disconnect", 1, DIALOG_PRIORITY_SYSTEM_CRITICAL, true, nil, false, false) 
  551. 				Pause_input_tracker:subscribe(false) 
  552. 			end 
  553. 		else 
  554. 			if event == "map" and Dialog_pause_allow_disconnect == true then 
  555. 				--Map is the button to exit out of a partner paused situation 
  556. 				local options = { [0] = "CONTROL_YES", [1] = "CONTROL_NO" } 
  557. 				Dialog_pause_disconnect_dialog_handle = dialog_box_open("MENU_TITLE_WARNING", "DIALOG_PAUSE_DISCONNECT_PROMPT", options, "dialog_pause_disconnect", 1, DIALOG_PRIORITY_SYSTEM_CRITICAL, true, nil, false, false) 
  558. 				Pause_input_tracker:subscribe(false) 
  559. 			elseif event == "pause" then 
  560. 				--Pause is the event in a normal paused situation. 
  561. 				dialog_pause_unpause() 
  562. 			end 
  563. 		end 
  564. 	end 
  565. end 
  566.  
  567. ------------------------------------------------------------------------------- 
  568. -- UTILITY FUNCTIONS 
  569. ------------------------------------------------------------------------------- 
  570. -- helper function to set a text tag 
  571. function dialog_box_set_tag(handle, value) 
  572. 	if type(value) == "number" then 
  573. 		vint_set_property(handle, "text_tag_crc", value) 
  574. 	elseif type(value) == "string" then 
  575. 		vint_set_property(handle, "text_tag", value) 
  576. 	else 
  577. 	 
  578. 	end 
  579. end 
  580.  
  581. -- set whether the dialog ignores input 
  582. function dialog_ignore_input(value) 
  583. 	Ignore_input = value 
  584. end 
  585.  
  586. function dialog_text_update(option_idx, new_text) 
  587. 	assert_msg(Dialog_current_idx >= 0 and Dialog_current_idx <= 2, "Invalid Dialog_current_idx in dialog_text_update") 
  588. 	Dialog_objects[Dialog_current_idx]:set_option_text(option_idx, new_text, true, dialog_box_morph_done) 
  589. end 
  590.  
  591. function dialog_select_next() 
  592. 	Dialog_objects[Dialog_current_idx]:nav(1) 
  593. 	local selected_option_idx = Dialog_objects[Dialog_current_idx]:get_selected() 
  594. 	if Dialog_objects[Dialog_current_idx]:has_second_option(selected_option_idx) == true then 
  595. 		Dialog_objects[Dialog_current_idx]:select() 
  596. 	end 
  597. end 
  598.  
  599. ------------------------------------------------------------------------------- 
  600. -- Test Functions... 
  601. ------------------------------------------------------------------------------- 
  602. function dialog_test_populate(handle) 
  603. 		dialog_populate(handle, DIALOG_WIDGET_TYPE_TITLE, 		"EULA!") 
  604. 		dialog_populate(handle, DIALOG_WIDGET_TYPE_SPINNER, 	"Waiting for coop player. Waiting for coop player. Waiting for coop player. Waiting for coop player.")		 
  605.  
  606. 		--dialog_populate(handle, DIALOG_WIDGET_TYPE_TEXT,		"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sapien lectus, rhoncus eu malesuada at, sodales sed eros. Sed sollicitudin, lorem sed laoreet convallis, neque tortor placerat diam, vitae accumsan enim ante sit amet turpis. Curabitur tempor posuere mollis. Vivamus quam nisl, ultricies at tempus ut, varius id erat. Integer iaculis enim a velit sodales laoreet ultricies justo tincidunt. Vestibulum sagittis dolor lacus. Quisque varius ultrices risus sed adipiscing. Donec sit amet leo nec nisi mollis sodales. Nullam velit orci, ornare a dignissim quis, luctus in ipsum. Proin convallis felis leo, ac lacinia nunc. Donec eu ligula tellus, a molestie mauris. Quisque rutrum velit eget diam viverra vel congue ligula mollis. Etiam at consectetur nulla. Nunc et semper augue. Maecenas rutrum dui ut metus dapibus venenatis. In hac habitasse platea dictumst. Nullam aliquet metus non nibh porta eget convallis justo tristique. Cras erat augue, facilisis tempor suscipit a, placerat quis risus. ", 	"YES2", 	1) 
  607. --		dialog_populate(handle, DIALOG_WIDGET_TYPE_IMAGE, 		"ui_homie_pierce") 
  608. --		dialog_populate(handle, DIALOG_WIDGET_TYPE_IMAGE, 		"ui_homie_pierce") 
  609. 	--	dialog_populate(handle, DIALOG_WIDGET_TYPE_IMAGE, 		"ui_hud_inv_melee_bat") 
  610. 	--	dialog_populate(handle, DIALOG_WIDGET_TYPE_SPINNER, 	"This is some spinner text that i'm using to set everything to..")		 
  611. 	--	dialog_populate(handle, DIALOG_WIDGET_TYPE_TEXT,		"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sapien lectus, rhoncus eu malesuada at, sodales sed eros. Sed sollicitudin, lorem sed laoreet convallis, neque tortor placerat diam, vitae accumsan enim ante sit amet turpis. Curabitur tempor posuere mollis. Vivamus quam nisl, ultricies at tempus ut, varius id erat. Integer iaculis enim a velit sodales laoreet ultricies justo tincidunt. Vestibulum sagittis dolor lacus. Quisque varius ultrices risus sed adipiscing. Donec sit amet leo nec nisi mollis sodales. Nullam velit orci, ornare a dignissim quis, luctus in ipsum. Proin convallis felis leo, ac lacinia nunc. Donec eu ligula tellus, a molestie mauris. Quisque rutrum velit eget diam viverra vel congue ligula mollis. Etiam at consectetur nulla. Nunc et semper augue. Maecenas rutrum dui ut metus dapibus venenatis.", 	0) 
  612. 		 
  613. --	dialog_populate(handle, DIALOG_WIDGET_TYPE_TEXT,		"This is a block of text that we are using to represent word wrap. and more complicated matters", 	"YES2", 	1) 
  614.  
  615. 	--dialog_populate(handle, DIALOG_WIDGET_TYPE_TEXT,		"This is a block of text that we are using to", 	"YES2", 	1) 
  616. 		--dialog_populate(handle, DIALOG_WIDGET_TYPE_SPINNER, 	"This is some spinner text that i'm using to set everything to..")		 
  617. 	--	dialog_populate(handle, DIALOG_WIDGET_TYPE_OPTION,	 	"ZOMG WHAT UP?!",	nil, 	0) 
  618. 		dialog_populate(handle, DIALOG_WIDGET_TYPE_OPTION,	 	"ACCEPT",	"", 	0) 
  619. 	--	dialog_populate(handle, DIALOG_WIDGET_TYPE_OPTION, 		"REALLY LONG O...",	"FORTYNINE",	1) 
  620.  
  621. 	 dialog_populate(handle, DIALOG_WIDGET_TYPE_OPTION, 		"ZOMG REALLY LONG TEXT",	"YES2",	0) 
  622. 	--	dialog_populate(handle, DIALOG_WIDGET_TYPE_OPTION, 		"RAD2",	"NO...",	4) 
  623. --		dialog_populate(handle, DIALOG_WIDGET_TYPE_OPTION, 		"RAD2",	"NOKAY",	5) 
  624. 	--	dialog_populate(handle, DIALOG_WIDGET_TYPE_OPTION, 		"RAD2",	"NOKAY",	6) 
  625. end 
  626.